feat(ai-workspace): support SEO codex provider bridge

This commit is contained in:
Codex
2026-07-03 08:43:37 +03:00
parent 1aceabee44
commit a7c6c34c82
26 changed files with 1649 additions and 36 deletions
@@ -1257,6 +1257,8 @@ function usesJsonOutput(args) {
return Array.isArray(args) && args.includes('--json')
}
const CODEX_ASSISTANT_TEXT_MAX = 250000
function truncateText(value, max = 1400) {
const text = String(value || '').trim()
return text.length > max ? `${text.slice(0, max).trim()}...` : text
@@ -1504,7 +1506,7 @@ function createActiveMirror(command, payload = {}, meta = {}) {
if (kind === 'codex_files') state.currentFiles = markdownText(event.text || text, 3000)
if (kind === 'codex_tool') state.currentTool = markdownText(event.text || text, 3000)
if (kind === 'codex_todo') state.currentTodo = markdownText(event.text || text, 3000)
if (kind === 'codex_message') state.assistantText = markdownText(event.text || text, 12000)
if (kind === 'codex_message') state.assistantText = markdownText(event.text || text, CODEX_ASSISTANT_TEXT_MAX)
if (kind === 'done' || kind === 'codex_turn_completed') state.status = 'completed'
if (kind === 'timeout') state.status = 'timeout'
if (kind === 'error' && !/reconnecting/i.test(text)) state.status = 'failed'
@@ -1520,7 +1522,7 @@ function createActiveMirror(command, payload = {}, meta = {}) {
async complete(status, assistantText = '') {
state.status = status
state.finishedAt = new Date().toISOString()
if (assistantText) state.assistantText = markdownText(assistantText, 12000)
if (assistantText) state.assistantText = markdownText(assistantText, CODEX_ASSISTANT_TEXT_MAX)
await write({
at: state.finishedAt,
kind: `mirror_${status}`,
@@ -1656,7 +1658,7 @@ function codexJsonEventToBridgeEvent(event, reasoningSummaryState = null) {
const text = truncateText(reasoningTextFromItem(item))
return text ? { kind: 'codex_reasoning', message: text } : null
}
if (itemType === 'agent_message') return { kind: 'codex_message', message: 'Assistant response received.', text: truncateText(item.text || '') }
if (itemType === 'agent_message') return { kind: 'codex_message', message: 'Assistant response received.', text: markdownText(item.text || '', CODEX_ASSISTANT_TEXT_MAX) }
if (itemType === 'command_execution') {
const status = item.status ? ` - ${item.status}` : ''
return {
@@ -9,7 +9,7 @@ import { fileURLToPath } from "node:url";
const DEFAULT_GATEWAY = "https://ai-hub.nodedc.ru";
const PACKAGE_NAME = "@nodedc/ai-workspace-bridge";
const SERVICE_NAME = "NDC AI Workspace Bridge";
const WINDOWS_TASK_NAME = "NDC AI Workspace Bridge";
const WINDOWS_TASK_NAME = "NDCAIWorkspaceBridge";
const HEALTH_PATH = "/api/ai-workspace/bridge/v1/health";
const BRIDGE_PROTOCOL_VERSION = "ai-workspace-bridge.v1";
const BRIDGE_CAPABILITIES = [
@@ -638,7 +638,7 @@ async function installAutostart(startScriptPath, installRoot) {
async function installWindowsTask(startScriptPath) {
const taskRun = `"${process.execPath}" "${startScriptPath}"`;
runCommandQuiet("schtasks", ["/Delete", "/TN", WINDOWS_TASK_NAME, "/F"], {});
runCommandQuiet("schtasks", ["/Delete", "/TN", WINDOWS_TASK_NAME, "/F"], { shell: false });
await runCommand("schtasks", [
"/Create",
"/TN",
@@ -650,7 +650,7 @@ async function installWindowsTask(startScriptPath) {
"/RL",
"HIGHEST",
"/F",
], {});
], { shell: false });
}
async function installLaunchAgent(startScriptPath) {
@@ -788,7 +788,7 @@ function runCommandQuiet(command, args, options = {}) {
const result = spawnSync(command, args, {
env: commandEnv(options),
encoding: "utf8",
shell: process.platform === "win32",
shell: options.shell ?? process.platform === "win32",
windowsHide: true,
});
return {
@@ -807,7 +807,7 @@ function runCommand(command, args, options = {}) {
const child = spawn(command, args, {
env: commandEnv(options),
stdio: options.stdio || "inherit",
shell: process.platform === "win32",
shell: options.shell ?? process.platform === "win32",
windowsHide: true,
});
child.on("error", reject);
@@ -1,6 +1,6 @@
{
"name": "@nodedc/ai-workspace-bridge",
"version": "0.1.0",
"version": "0.1.1",
"description": "Install NODE.DC AI Workspace Bridge worker.",
"type": "module",
"bin": {