actoviq-agent-sdk 0.4.7 → 0.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -1
- package/README-zh.md +8 -5
- package/README.md +9 -6
- package/assets/actoviq-icon.png +0 -0
- package/dist/src/browser/actoviqBrowserSession.d.ts +137 -0
- package/dist/src/browser/actoviqBrowserSession.d.ts.map +1 -0
- package/dist/src/browser/actoviqBrowserSession.js +623 -0
- package/dist/src/browser/actoviqBrowserSession.js.map +1 -0
- package/dist/src/browser/actoviqBrowserTools.d.ts +80 -0
- package/dist/src/browser/actoviqBrowserTools.d.ts.map +1 -0
- package/dist/src/browser/actoviqBrowserTools.js +177 -0
- package/dist/src/browser/actoviqBrowserTools.js.map +1 -0
- package/dist/src/browser/browserSettings.d.ts +8 -0
- package/dist/src/browser/browserSettings.d.ts.map +1 -0
- package/dist/src/browser/browserSettings.js +47 -0
- package/dist/src/browser/browserSettings.js.map +1 -0
- package/dist/src/cli/actoviq-react.js +144 -4
- package/dist/src/cli/actoviq-react.js.map +1 -1
- package/dist/src/computer/actoviqComputerUse.d.ts.map +1 -1
- package/dist/src/computer/actoviqComputerUse.js +226 -40
- package/dist/src/computer/actoviqComputerUse.js.map +1 -1
- package/dist/src/computer/e2bComputerUse.d.ts +57 -0
- package/dist/src/computer/e2bComputerUse.d.ts.map +1 -0
- package/dist/src/computer/e2bComputerUse.js +401 -0
- package/dist/src/computer/e2bComputerUse.js.map +1 -0
- package/dist/src/config/agentProfiles.d.ts +8 -1
- package/dist/src/config/agentProfiles.d.ts.map +1 -1
- package/dist/src/config/agentProfiles.js +86 -4
- package/dist/src/config/agentProfiles.js.map +1 -1
- package/dist/src/config/projectSessionDirectory.d.ts +22 -0
- package/dist/src/config/projectSessionDirectory.d.ts.map +1 -1
- package/dist/src/config/projectSessionDirectory.js +512 -46
- package/dist/src/config/projectSessionDirectory.js.map +1 -1
- package/dist/src/config/resolveRuntimeConfig.d.ts.map +1 -1
- package/dist/src/config/resolveRuntimeConfig.js +12 -7
- package/dist/src/config/resolveRuntimeConfig.js.map +1 -1
- package/dist/src/gui/actoviqGui.d.ts +3 -0
- package/dist/src/gui/actoviqGui.d.ts.map +1 -1
- package/dist/src/gui/actoviqGui.js +7247 -997
- package/dist/src/gui/actoviqGui.js.map +1 -1
- package/dist/src/gui/electronMain.js +21 -4
- package/dist/src/gui/electronMain.js.map +1 -1
- package/dist/src/gui/externalCliAgentMonitor.d.ts +15 -0
- package/dist/src/gui/externalCliAgentMonitor.d.ts.map +1 -0
- package/dist/src/gui/externalCliAgentMonitor.js +133 -0
- package/dist/src/gui/externalCliAgentMonitor.js.map +1 -0
- package/dist/src/gui/projectWorkbench.d.ts +2 -0
- package/dist/src/gui/projectWorkbench.d.ts.map +1 -1
- package/dist/src/gui/projectWorkbench.js +66 -1
- package/dist/src/gui/projectWorkbench.js.map +1 -1
- package/dist/src/gui/transcript/clientBundle.d.ts.map +1 -1
- package/dist/src/gui/transcript/clientBundle.js +157 -17
- package/dist/src/gui/transcript/clientBundle.js.map +1 -1
- package/dist/src/gui/transcript/parts.d.ts.map +1 -1
- package/dist/src/gui/transcript/parts.js +28 -0
- package/dist/src/gui/transcript/parts.js.map +1 -1
- package/dist/src/index.d.ts +36 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +22 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/parity/actoviqBridgeSdk.d.ts +13 -1
- package/dist/src/parity/actoviqBridgeSdk.d.ts.map +1 -1
- package/dist/src/parity/actoviqBridgeSdk.js +1022 -83
- package/dist/src/parity/actoviqBridgeSdk.js.map +1 -1
- package/dist/src/parity/bridgeConfigs.d.ts +15 -0
- package/dist/src/parity/bridgeConfigs.d.ts.map +1 -1
- package/dist/src/parity/bridgeConfigs.js +112 -3
- package/dist/src/parity/bridgeConfigs.js.map +1 -1
- package/dist/src/parity/bridgeEventAdapter.d.ts +5 -1
- package/dist/src/parity/bridgeEventAdapter.d.ts.map +1 -1
- package/dist/src/parity/bridgeEventAdapter.js +65 -12
- package/dist/src/parity/bridgeEventAdapter.js.map +1 -1
- package/dist/src/parity/bridgeExecResolver.d.ts +10 -11
- package/dist/src/parity/bridgeExecResolver.d.ts.map +1 -1
- package/dist/src/parity/bridgeExecResolver.js +40 -23
- package/dist/src/parity/bridgeExecResolver.js.map +1 -1
- package/dist/src/parity/bridgeProcessTree.d.ts +3 -0
- package/dist/src/parity/bridgeProcessTree.d.ts.map +1 -0
- package/dist/src/parity/bridgeProcessTree.js +83 -0
- package/dist/src/parity/bridgeProcessTree.js.map +1 -0
- package/dist/src/parity/bridgeProviders.d.ts +16 -2
- package/dist/src/parity/bridgeProviders.d.ts.map +1 -1
- package/dist/src/parity/bridgeProviders.js +482 -100
- package/dist/src/parity/bridgeProviders.js.map +1 -1
- package/dist/src/parity/codewhaleRuntimeAdapter.d.ts +18 -0
- package/dist/src/parity/codewhaleRuntimeAdapter.d.ts.map +1 -0
- package/dist/src/parity/codewhaleRuntimeAdapter.js +350 -0
- package/dist/src/parity/codewhaleRuntimeAdapter.js.map +1 -0
- package/dist/src/parity/crushManagedClient.d.ts +84 -0
- package/dist/src/parity/crushManagedClient.d.ts.map +1 -0
- package/dist/src/parity/crushManagedClient.js +978 -0
- package/dist/src/parity/crushManagedClient.js.map +1 -0
- package/dist/src/parity/crushSessionHistory.d.ts +53 -0
- package/dist/src/parity/crushSessionHistory.d.ts.map +1 -0
- package/dist/src/parity/crushSessionHistory.js +358 -0
- package/dist/src/parity/crushSessionHistory.js.map +1 -0
- package/dist/src/parity/externalCliAuth.d.ts +23 -0
- package/dist/src/parity/externalCliAuth.d.ts.map +1 -0
- package/dist/src/parity/externalCliAuth.js +268 -0
- package/dist/src/parity/externalCliAuth.js.map +1 -0
- package/dist/src/parity/externalCliRuntimeManager.d.ts +138 -0
- package/dist/src/parity/externalCliRuntimeManager.d.ts.map +1 -0
- package/dist/src/parity/externalCliRuntimeManager.js +527 -0
- package/dist/src/parity/externalCliRuntimeManager.js.map +1 -0
- package/dist/src/parity/externalCliSessions.d.ts +90 -0
- package/dist/src/parity/externalCliSessions.d.ts.map +1 -0
- package/dist/src/parity/externalCliSessions.js +1436 -0
- package/dist/src/parity/externalCliSessions.js.map +1 -0
- package/dist/src/parity/reasonixAcpSession.d.ts +35 -0
- package/dist/src/parity/reasonixAcpSession.d.ts.map +1 -0
- package/dist/src/parity/reasonixAcpSession.js +472 -0
- package/dist/src/parity/reasonixAcpSession.js.map +1 -0
- package/dist/src/parity/reasonixManagedClient.d.ts +56 -0
- package/dist/src/parity/reasonixManagedClient.d.ts.map +1 -0
- package/dist/src/parity/reasonixManagedClient.js +293 -0
- package/dist/src/parity/reasonixManagedClient.js.map +1 -0
- package/dist/src/parity/reasonixSessionParser.d.ts +50 -0
- package/dist/src/parity/reasonixSessionParser.d.ts.map +1 -0
- package/dist/src/parity/reasonixSessionParser.js +440 -0
- package/dist/src/parity/reasonixSessionParser.js.map +1 -0
- package/dist/src/plugins/githubPlugin.d.ts +64 -0
- package/dist/src/plugins/githubPlugin.d.ts.map +1 -0
- package/dist/src/plugins/githubPlugin.js +261 -0
- package/dist/src/plugins/githubPlugin.js.map +1 -0
- package/dist/src/plugins/kimiWebBridgePlugin.d.ts +32 -0
- package/dist/src/plugins/kimiWebBridgePlugin.d.ts.map +1 -0
- package/dist/src/plugins/kimiWebBridgePlugin.js +214 -0
- package/dist/src/plugins/kimiWebBridgePlugin.js.map +1 -0
- package/dist/src/plugins/managedPluginCatalog.d.ts +47 -0
- package/dist/src/plugins/managedPluginCatalog.d.ts.map +1 -0
- package/dist/src/plugins/managedPluginCatalog.js +399 -0
- package/dist/src/plugins/managedPluginCatalog.js.map +1 -0
- package/dist/src/plugins/managedPluginHealth.d.ts +9 -0
- package/dist/src/plugins/managedPluginHealth.d.ts.map +1 -0
- package/dist/src/plugins/managedPluginHealth.js +149 -0
- package/dist/src/plugins/managedPluginHealth.js.map +1 -0
- package/dist/src/plugins/managedPluginRuntime.d.ts +14 -0
- package/dist/src/plugins/managedPluginRuntime.d.ts.map +1 -0
- package/dist/src/plugins/managedPluginRuntime.js +331 -0
- package/dist/src/plugins/managedPluginRuntime.js.map +1 -0
- package/dist/src/plugins/ocrPlugin.d.ts +46 -0
- package/dist/src/plugins/ocrPlugin.d.ts.map +1 -0
- package/dist/src/plugins/ocrPlugin.js +464 -0
- package/dist/src/plugins/ocrPlugin.js.map +1 -0
- package/dist/src/provider/client.d.ts +7 -1
- package/dist/src/provider/client.d.ts.map +1 -1
- package/dist/src/provider/client.js +61 -6
- package/dist/src/provider/client.js.map +1 -1
- package/dist/src/provider/openai-client.d.ts.map +1 -1
- package/dist/src/provider/openai-client.js +49 -3
- package/dist/src/provider/openai-client.js.map +1 -1
- package/dist/src/runtime/actoviqAgentExecutions.d.ts +85 -0
- package/dist/src/runtime/actoviqAgentExecutions.d.ts.map +1 -0
- package/dist/src/runtime/actoviqAgentExecutions.js +479 -0
- package/dist/src/runtime/actoviqAgentExecutions.js.map +1 -0
- package/dist/src/runtime/actoviqAgents.d.ts +15 -12
- package/dist/src/runtime/actoviqAgents.d.ts.map +1 -1
- package/dist/src/runtime/actoviqAgents.js +15 -0
- package/dist/src/runtime/actoviqAgents.js.map +1 -1
- package/dist/src/runtime/actoviqBackgroundTasks.d.ts +17 -2
- package/dist/src/runtime/actoviqBackgroundTasks.d.ts.map +1 -1
- package/dist/src/runtime/actoviqBackgroundTasks.js +291 -104
- package/dist/src/runtime/actoviqBackgroundTasks.js.map +1 -1
- package/dist/src/runtime/actoviqCompact.d.ts.map +1 -1
- package/dist/src/runtime/actoviqCompact.js +10 -75
- package/dist/src/runtime/actoviqCompact.js.map +1 -1
- package/dist/src/runtime/actoviqSkills.d.ts +14 -1
- package/dist/src/runtime/actoviqSkills.d.ts.map +1 -1
- package/dist/src/runtime/actoviqSkills.js +27 -2
- package/dist/src/runtime/actoviqSkills.js.map +1 -1
- package/dist/src/runtime/agentClient.d.ts +16 -2
- package/dist/src/runtime/agentClient.d.ts.map +1 -1
- package/dist/src/runtime/agentClient.js +745 -207
- package/dist/src/runtime/agentClient.js.map +1 -1
- package/dist/src/runtime/agentExecution.d.ts +196 -0
- package/dist/src/runtime/agentExecution.d.ts.map +1 -0
- package/dist/src/runtime/agentExecution.js +360 -0
- package/dist/src/runtime/agentExecution.js.map +1 -0
- package/dist/src/runtime/agentRuntimeDiscovery.d.ts +8 -2
- package/dist/src/runtime/agentRuntimeDiscovery.d.ts.map +1 -1
- package/dist/src/runtime/agentRuntimeDiscovery.js +30 -18
- package/dist/src/runtime/agentRuntimeDiscovery.js.map +1 -1
- package/dist/src/runtime/conversationEngine.d.ts +2 -1
- package/dist/src/runtime/conversationEngine.d.ts.map +1 -1
- package/dist/src/runtime/conversationEngine.js +66 -50
- package/dist/src/runtime/conversationEngine.js.map +1 -1
- package/dist/src/runtime/externalSkillCatalog.d.ts +107 -0
- package/dist/src/runtime/externalSkillCatalog.d.ts.map +1 -0
- package/dist/src/runtime/externalSkillCatalog.js +895 -0
- package/dist/src/runtime/externalSkillCatalog.js.map +1 -0
- package/dist/src/runtime/externalSkillPreferences.d.ts +25 -0
- package/dist/src/runtime/externalSkillPreferences.d.ts.map +1 -0
- package/dist/src/runtime/externalSkillPreferences.js +132 -0
- package/dist/src/runtime/externalSkillPreferences.js.map +1 -0
- package/dist/src/runtime/externalSkillRuntime.d.ts +31 -0
- package/dist/src/runtime/externalSkillRuntime.d.ts.map +1 -0
- package/dist/src/runtime/externalSkillRuntime.js +129 -0
- package/dist/src/runtime/externalSkillRuntime.js.map +1 -0
- package/dist/src/runtime/sessionTurnCoordinator.d.ts +2 -2
- package/dist/src/runtime/sessionTurnCoordinator.js +2 -2
- package/dist/src/storage/agentExecutionStore.d.ts +31 -0
- package/dist/src/storage/agentExecutionStore.d.ts.map +1 -0
- package/dist/src/storage/agentExecutionStore.js +413 -0
- package/dist/src/storage/agentExecutionStore.js.map +1 -0
- package/dist/src/storage/backgroundTaskStore.d.ts +5 -0
- package/dist/src/storage/backgroundTaskStore.d.ts.map +1 -1
- package/dist/src/storage/backgroundTaskStore.js +79 -3
- package/dist/src/storage/backgroundTaskStore.js.map +1 -1
- package/dist/src/storage/sessionStore.d.ts +8 -0
- package/dist/src/storage/sessionStore.d.ts.map +1 -1
- package/dist/src/storage/sessionStore.js +134 -18
- package/dist/src/storage/sessionStore.js.map +1 -1
- package/dist/src/team/teamGraphLayout.d.ts +53 -1
- package/dist/src/team/teamGraphLayout.d.ts.map +1 -1
- package/dist/src/team/teamGraphLayout.js +127 -1
- package/dist/src/team/teamGraphLayout.js.map +1 -1
- package/dist/src/team/teamGraphScaffold.d.ts.map +1 -1
- package/dist/src/team/teamGraphScaffold.js +31 -0
- package/dist/src/team/teamGraphScaffold.js.map +1 -1
- package/dist/src/team/teamGraphV3.d.ts +1 -0
- package/dist/src/team/teamGraphV3.d.ts.map +1 -1
- package/dist/src/team/teamGraphV3.js +24 -5
- package/dist/src/team/teamGraphV3.js.map +1 -1
- package/dist/src/team/teamPropose.d.ts +19 -0
- package/dist/src/team/teamPropose.d.ts.map +1 -0
- package/dist/src/team/teamPropose.js +126 -0
- package/dist/src/team/teamPropose.js.map +1 -0
- package/dist/src/tools/actoviqCoreTools.d.ts.map +1 -1
- package/dist/src/tools/actoviqCoreTools.js +3 -1
- package/dist/src/tools/actoviqCoreTools.js.map +1 -1
- package/dist/src/tools/exaSearch.d.ts +56 -0
- package/dist/src/tools/exaSearch.d.ts.map +1 -0
- package/dist/src/tools/exaSearch.js +170 -0
- package/dist/src/tools/exaSearch.js.map +1 -0
- package/dist/src/tools/tavilySearch.d.ts +34 -1
- package/dist/src/tools/tavilySearch.d.ts.map +1 -1
- package/dist/src/tools/tavilySearch.js +69 -54
- package/dist/src/tools/tavilySearch.js.map +1 -1
- package/dist/src/tools/todo/TodoWriteTool.d.ts +1 -1
- package/dist/src/tui/actoviqTui.d.ts +3 -1
- package/dist/src/tui/actoviqTui.d.ts.map +1 -1
- package/dist/src/tui/actoviqTui.js +1208 -92
- package/dist/src/tui/actoviqTui.js.map +1 -1
- package/dist/src/types.d.ts +223 -14
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js.map +1 -1
- package/dist/src/ui/agentExecutionView.d.ts +111 -0
- package/dist/src/ui/agentExecutionView.d.ts.map +1 -0
- package/dist/src/ui/agentExecutionView.js +442 -0
- package/dist/src/ui/agentExecutionView.js.map +1 -0
- package/dist/src/ui/commandSurface.d.ts +2 -0
- package/dist/src/ui/commandSurface.d.ts.map +1 -1
- package/dist/src/ui/commandSurface.js +38 -3
- package/dist/src/ui/commandSurface.js.map +1 -1
- package/dist/src/workflow-v2/localIsolatedProcessExecutor.d.ts.map +1 -1
- package/dist/src/workflow-v2/localIsolatedProcessExecutor.js +6 -2
- package/dist/src/workflow-v2/localIsolatedProcessExecutor.js.map +1 -1
- package/package.json +35 -7
|
@@ -23,6 +23,8 @@ import { ActoviqBridgeProcessError } from '../errors.js';
|
|
|
23
23
|
import { mapActoviqEnvToAnthropicEnv } from '../config/anthropicEnvMapping.js';
|
|
24
24
|
import { getLoadedJsonConfig } from '../config/loadJsonConfigFile.js';
|
|
25
25
|
import { findExecutableOnPath, IS_WINDOWS, pathExists, } from './bridgeExecResolver.js';
|
|
26
|
+
import { buildCodewhaleArgs, createCodewhaleNormalizer, } from './codewhaleRuntimeAdapter.js';
|
|
27
|
+
import { createReasonixAcpSession } from './reasonixAcpSession.js';
|
|
26
28
|
const DEFAULT_VERSION_PROBE_TIMEOUT_MS = 3_000;
|
|
27
29
|
const VERSION_PROBE_MAX_BUFFER_BYTES = 1024 * 1024;
|
|
28
30
|
const PROCESS_TREE_KILL_TIMEOUT_MS = 2_500;
|
|
@@ -61,7 +63,7 @@ function waitForChildExit(child) {
|
|
|
61
63
|
child.once('close', finish);
|
|
62
64
|
});
|
|
63
65
|
}
|
|
64
|
-
async function
|
|
66
|
+
export async function terminateBridgeProcessTree(child) {
|
|
65
67
|
const pid = child.pid;
|
|
66
68
|
if (!pid || hasExited(child))
|
|
67
69
|
return;
|
|
@@ -141,7 +143,7 @@ function probeExecutableVersion(executablePath, timeoutMs) {
|
|
|
141
143
|
});
|
|
142
144
|
const timer = setTimeout(() => {
|
|
143
145
|
timedOut = true;
|
|
144
|
-
void
|
|
146
|
+
void terminateBridgeProcessTree(child).finally(() => {
|
|
145
147
|
reject(new Error('Bridge provider version probe timed out.'));
|
|
146
148
|
});
|
|
147
149
|
}, timeoutMs);
|
|
@@ -355,39 +357,38 @@ class PiProvider extends BaseRuntimeProvider {
|
|
|
355
357
|
id = 'pi';
|
|
356
358
|
pathBinary = 'pi';
|
|
357
359
|
displayName = 'pi CLI (@earendil-works/pi-coding-agent)';
|
|
358
|
-
buildArgs(
|
|
359
|
-
|
|
360
|
-
//
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
if (
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
360
|
+
buildArgs(_prompt, options) {
|
|
361
|
+
// Pi has no argv option terminator. Managed mode uses the official RPC
|
|
362
|
+
// protocol so arbitrary user text is sent as JSON over stdin, never argv.
|
|
363
|
+
const args = ['--mode', 'rpc'];
|
|
364
|
+
args.push(options.trustProjectResources ? '--approve' : '--no-approve');
|
|
365
|
+
const model = splitPiModel(options.model);
|
|
366
|
+
const provider = model.provider ?? normalizePiProvider(options.credentialProvider);
|
|
367
|
+
if (provider)
|
|
368
|
+
args.push('--provider', provider);
|
|
369
|
+
if (model.model)
|
|
370
|
+
args.push('--model', model.model);
|
|
369
371
|
if (options.appendSystemPrompt) {
|
|
370
372
|
args.push('--append-system-prompt', options.appendSystemPrompt);
|
|
371
373
|
}
|
|
372
374
|
else if (options.systemPrompt) {
|
|
373
375
|
args.push('--system-prompt', options.systemPrompt);
|
|
374
376
|
}
|
|
375
|
-
|
|
376
|
-
|
|
377
|
+
if (options.effort)
|
|
378
|
+
args.push('--thinking', options.effort);
|
|
379
|
+
args.push(...piToolArguments(options));
|
|
377
380
|
if (typeof options.resume === 'string') {
|
|
378
|
-
args.push('--session', options.resume);
|
|
381
|
+
args.push('--session', validatePiSessionId(options.resume));
|
|
379
382
|
}
|
|
380
383
|
else if (options.resume === true) {
|
|
381
|
-
|
|
384
|
+
throw new ActoviqBridgeProcessError('Pi managed mode requires an exact session id; the interactive --resume picker is unavailable.');
|
|
382
385
|
}
|
|
383
386
|
else if (options.sessionId) {
|
|
384
|
-
args.push('--session-id', options.sessionId);
|
|
387
|
+
args.push('--session-id', validatePiSessionId(options.sessionId));
|
|
385
388
|
}
|
|
386
389
|
else if (options.continueMostRecent) {
|
|
387
390
|
args.push('--continue');
|
|
388
391
|
}
|
|
389
|
-
// pi takes the prompt as the final positional argument.
|
|
390
|
-
args.push(prompt);
|
|
391
392
|
return args;
|
|
392
393
|
}
|
|
393
394
|
buildChildEnv(baseEnv, settingsEnv, overrides) {
|
|
@@ -396,118 +397,387 @@ class PiProvider extends BaseRuntimeProvider {
|
|
|
396
397
|
// provider-specific key directly. No ANTHROPIC_* remapping for non-claude.
|
|
397
398
|
return { ...baseEnv, ...settingsEnv, ...(overrides ?? {}) };
|
|
398
399
|
}
|
|
399
|
-
createNormalizer() {
|
|
400
|
-
return new PiNormalizer();
|
|
400
|
+
createNormalizer(prompt = '', options = {}) {
|
|
401
|
+
return new PiNormalizer(prompt, options);
|
|
401
402
|
}
|
|
402
403
|
suggestedModels() {
|
|
403
404
|
return ['gpt-5', 'gpt-5-mini', 'claude-sonnet-4-6', 'deepseek-v4-pro', 'gemini-2.5-pro'];
|
|
404
405
|
}
|
|
405
406
|
}
|
|
407
|
+
const PI_READ_ONLY_TOOLS = ['read', 'grep', 'find', 'ls'];
|
|
408
|
+
const PI_EDIT_TOOLS = [...PI_READ_ONLY_TOOLS, 'edit', 'write'];
|
|
409
|
+
function validatePiSessionId(value) {
|
|
410
|
+
const sessionId = value.trim();
|
|
411
|
+
if (!sessionId
|
|
412
|
+
|| sessionId.length > 256
|
|
413
|
+
|| sessionId.startsWith('-')
|
|
414
|
+
|| !/^[A-Za-z0-9][A-Za-z0-9._-]*$/u.test(sessionId)) {
|
|
415
|
+
throw new ActoviqBridgeProcessError('Pi session id must contain only letters, numbers, dots, underscores, or hyphens.');
|
|
416
|
+
}
|
|
417
|
+
return sessionId;
|
|
418
|
+
}
|
|
419
|
+
function splitPiModel(value) {
|
|
420
|
+
const normalized = value?.trim();
|
|
421
|
+
if (!normalized)
|
|
422
|
+
return {};
|
|
423
|
+
const separator = normalized.indexOf('/');
|
|
424
|
+
if (separator <= 0 || separator === normalized.length - 1)
|
|
425
|
+
return { model: normalized };
|
|
426
|
+
return {
|
|
427
|
+
provider: normalized.slice(0, separator),
|
|
428
|
+
model: normalized.slice(separator + 1),
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
function normalizePiProvider(value) {
|
|
432
|
+
const provider = value?.trim();
|
|
433
|
+
if (!provider)
|
|
434
|
+
return undefined;
|
|
435
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9._-]*$/u.test(provider)) {
|
|
436
|
+
throw new ActoviqBridgeProcessError('Pi credential provider must contain only letters, numbers, dots, underscores, or hyphens.');
|
|
437
|
+
}
|
|
438
|
+
return provider;
|
|
439
|
+
}
|
|
440
|
+
function piToolArguments(options) {
|
|
441
|
+
if (options.tools === 'none')
|
|
442
|
+
return ['--no-tools'];
|
|
443
|
+
const bypass = options.dangerouslySkipPermissions
|
|
444
|
+
|| options.permissionMode === 'bypassPermissions';
|
|
445
|
+
const permissionUpperBound = bypass
|
|
446
|
+
? undefined
|
|
447
|
+
: new Set(options.permissionMode === 'acceptEdits'
|
|
448
|
+
? PI_EDIT_TOOLS
|
|
449
|
+
: PI_READ_ONLY_TOOLS);
|
|
450
|
+
let permitted;
|
|
451
|
+
if (Array.isArray(options.tools)) {
|
|
452
|
+
permitted = [...options.tools];
|
|
453
|
+
}
|
|
454
|
+
else if (!bypass) {
|
|
455
|
+
permitted = options.permissionMode === 'acceptEdits'
|
|
456
|
+
? [...PI_EDIT_TOOLS]
|
|
457
|
+
: [...PI_READ_ONLY_TOOLS];
|
|
458
|
+
}
|
|
459
|
+
if (options.allowedTools?.length) {
|
|
460
|
+
permitted = permitted
|
|
461
|
+
? permitted.filter(tool => options.allowedTools.includes(tool))
|
|
462
|
+
: [...options.allowedTools];
|
|
463
|
+
}
|
|
464
|
+
if (options.disallowedTools?.length && permitted) {
|
|
465
|
+
permitted = permitted.filter(tool => !options.disallowedTools.includes(tool));
|
|
466
|
+
}
|
|
467
|
+
if (permissionUpperBound && permitted) {
|
|
468
|
+
permitted = permitted.filter(tool => permissionUpperBound.has(tool));
|
|
469
|
+
}
|
|
470
|
+
const args = [];
|
|
471
|
+
if (permitted) {
|
|
472
|
+
if (permitted.length === 0)
|
|
473
|
+
return ['--no-tools'];
|
|
474
|
+
args.push('--tools', [...new Set(permitted)].join(','));
|
|
475
|
+
}
|
|
476
|
+
if (options.disallowedTools?.length) {
|
|
477
|
+
args.push('--exclude-tools', [...new Set(options.disallowedTools)].join(','));
|
|
478
|
+
}
|
|
479
|
+
return args;
|
|
480
|
+
}
|
|
406
481
|
class PiNormalizer {
|
|
482
|
+
prompt;
|
|
483
|
+
options;
|
|
484
|
+
interactive = true;
|
|
485
|
+
abortGraceMs = 250;
|
|
407
486
|
sessionId;
|
|
408
487
|
cwd;
|
|
409
488
|
model;
|
|
410
489
|
initEmitted = false;
|
|
411
|
-
|
|
412
|
-
|
|
490
|
+
finalAssistantText = '';
|
|
491
|
+
streamedAssistantText = '';
|
|
492
|
+
lastError;
|
|
493
|
+
stopReason;
|
|
494
|
+
turns = 0;
|
|
495
|
+
finished = false;
|
|
496
|
+
totalCostUsd;
|
|
497
|
+
constructor(prompt, options) {
|
|
498
|
+
this.prompt = prompt;
|
|
499
|
+
this.options = options;
|
|
500
|
+
}
|
|
501
|
+
start(control) {
|
|
502
|
+
control.write({ id: 'actoviq-state', type: 'get_state' });
|
|
503
|
+
control.write({ id: 'actoviq-prompt', type: 'prompt', message: this.prompt });
|
|
504
|
+
}
|
|
505
|
+
abort(control) {
|
|
506
|
+
control.write({ id: 'actoviq-abort', type: 'abort' });
|
|
507
|
+
}
|
|
508
|
+
translate(raw, control) {
|
|
413
509
|
const type = typeof raw.type === 'string' ? raw.type : '';
|
|
510
|
+
if (type === 'response' && raw.id === 'actoviq-state') {
|
|
511
|
+
const state = piRpcPayload(raw);
|
|
512
|
+
this.sessionId = stringField(state, 'sessionId', 'session_id', 'id') ?? this.sessionId;
|
|
513
|
+
this.cwd = stringField(state, 'cwd') ?? this.cwd;
|
|
514
|
+
this.model = stringField(state, 'model') ?? this.model;
|
|
515
|
+
return this.emitInit();
|
|
516
|
+
}
|
|
517
|
+
if (type === 'response' && raw.id === 'actoviq-prompt' && raw.success === false) {
|
|
518
|
+
this.lastError = rpcErrorMessage(raw) ?? 'Pi rejected the prompt request.';
|
|
519
|
+
return this.finish(control, true);
|
|
520
|
+
}
|
|
414
521
|
if (type === 'session') {
|
|
415
522
|
this.sessionId = typeof raw.id === 'string' ? raw.id : this.sessionId;
|
|
416
523
|
this.cwd = typeof raw.cwd === 'string' ? raw.cwd : this.cwd;
|
|
417
|
-
// No init emission yet — wait for agent_start so we mirror claude's
|
|
418
|
-
// "runtime ready" semantics. The session header carries no model.
|
|
419
524
|
return [];
|
|
420
525
|
}
|
|
421
|
-
if (type === 'agent_start'
|
|
422
|
-
this.
|
|
423
|
-
const init = bridgeEvent('system', {
|
|
424
|
-
subtype: 'init',
|
|
425
|
-
session_id: this.sessionId ?? '',
|
|
426
|
-
cwd: this.cwd,
|
|
427
|
-
// pi exposes no tool/skill/agent catalog in its stream; introspection
|
|
428
|
-
// methods will return empty/limited data for this provider.
|
|
429
|
-
tools: [],
|
|
430
|
-
mcp_servers: [],
|
|
431
|
-
slash_commands: [],
|
|
432
|
-
agents: [],
|
|
433
|
-
skills: [],
|
|
434
|
-
plugins: [],
|
|
435
|
-
model: this.model,
|
|
436
|
-
});
|
|
437
|
-
return [init];
|
|
438
|
-
}
|
|
526
|
+
if (type === 'agent_start')
|
|
527
|
+
return this.emitInit();
|
|
439
528
|
if (type === 'message_update') {
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
if (isRecord(ame) && ame.type === 'text_delta' && typeof ame.delta === 'string') {
|
|
444
|
-
this.pendingAssistantText += ame.delta;
|
|
529
|
+
const event = raw.assistantMessageEvent;
|
|
530
|
+
if (isRecord(event) && event.type === 'text_delta' && typeof event.delta === 'string') {
|
|
531
|
+
this.streamedAssistantText += event.delta;
|
|
445
532
|
return [bridgeEvent('stream_event', {
|
|
446
533
|
session_id: this.sessionId ?? '',
|
|
447
534
|
event: {
|
|
448
535
|
type: 'content_block_delta',
|
|
449
|
-
index: 0,
|
|
450
|
-
delta: { type: 'text_delta', text:
|
|
536
|
+
index: typeof event.contentIndex === 'number' ? event.contentIndex : 0,
|
|
537
|
+
delta: { type: 'text_delta', text: event.delta },
|
|
451
538
|
},
|
|
452
539
|
})];
|
|
453
540
|
}
|
|
541
|
+
if (isRecord(event) && event.type === 'thinking_delta' && typeof event.delta === 'string') {
|
|
542
|
+
return [bridgeEvent('stream_event', {
|
|
543
|
+
session_id: this.sessionId ?? '',
|
|
544
|
+
event: {
|
|
545
|
+
type: 'content_block_delta',
|
|
546
|
+
index: typeof event.contentIndex === 'number' ? event.contentIndex : 0,
|
|
547
|
+
delta: { type: 'thinking_delta', thinking: event.delta },
|
|
548
|
+
},
|
|
549
|
+
})];
|
|
550
|
+
}
|
|
551
|
+
if (isRecord(event) && event.type === 'error') {
|
|
552
|
+
this.lastError = stringField(event, 'error', 'message') ?? 'Pi assistant stream failed.';
|
|
553
|
+
}
|
|
454
554
|
return [];
|
|
455
555
|
}
|
|
556
|
+
if (type === 'tool_execution_start') {
|
|
557
|
+
return [bridgeEvent('assistant', {
|
|
558
|
+
session_id: this.sessionId ?? '',
|
|
559
|
+
message: {
|
|
560
|
+
role: 'assistant',
|
|
561
|
+
content: [{
|
|
562
|
+
type: 'tool_use',
|
|
563
|
+
id: stringField(raw, 'toolCallId', 'tool_call_id') ?? 'pi-tool-unknown',
|
|
564
|
+
name: stringField(raw, 'toolName', 'tool_name') ?? 'tool',
|
|
565
|
+
input: isRecord(raw.args) ? raw.args : {},
|
|
566
|
+
}],
|
|
567
|
+
},
|
|
568
|
+
})];
|
|
569
|
+
}
|
|
570
|
+
if (type === 'tool_execution_update') {
|
|
571
|
+
return [bridgeEvent('stream_event', {
|
|
572
|
+
session_id: this.sessionId ?? '',
|
|
573
|
+
event: {
|
|
574
|
+
type: 'tool_progress',
|
|
575
|
+
tool_call_id: stringField(raw, 'toolCallId', 'tool_call_id'),
|
|
576
|
+
tool_name: stringField(raw, 'toolName', 'tool_name'),
|
|
577
|
+
content: piResultText(raw.partialResult),
|
|
578
|
+
cumulative: true,
|
|
579
|
+
},
|
|
580
|
+
})];
|
|
581
|
+
}
|
|
582
|
+
if (type === 'tool_execution_end') {
|
|
583
|
+
return [bridgeEvent('user', {
|
|
584
|
+
session_id: this.sessionId ?? '',
|
|
585
|
+
message: {
|
|
586
|
+
role: 'user',
|
|
587
|
+
content: [{
|
|
588
|
+
type: 'tool_result',
|
|
589
|
+
tool_use_id: stringField(raw, 'toolCallId', 'tool_call_id') ?? 'pi-tool-unknown',
|
|
590
|
+
content: piResultText(raw.result),
|
|
591
|
+
is_error: raw.isError === true,
|
|
592
|
+
}],
|
|
593
|
+
},
|
|
594
|
+
})];
|
|
595
|
+
}
|
|
456
596
|
if (type === 'message_end') {
|
|
457
597
|
const message = raw.message;
|
|
458
598
|
if (isRecord(message) && message.role === 'assistant') {
|
|
459
|
-
|
|
460
|
-
if (typeof message.model === 'string') {
|
|
461
|
-
this.model = message.model;
|
|
462
|
-
}
|
|
599
|
+
this.model = stringField(message, 'model') ?? this.model;
|
|
463
600
|
const text = extractPiAssistantText(message);
|
|
601
|
+
if (text)
|
|
602
|
+
this.finalAssistantText = text;
|
|
603
|
+
this.stopReason = stringField(message, 'stopReason', 'stop_reason') ?? this.stopReason;
|
|
604
|
+
this.lastError = stringField(message, 'errorMessage', 'error_message') ?? this.lastError;
|
|
605
|
+
const usage = isRecord(message.usage) ? message.usage : undefined;
|
|
606
|
+
const cost = usage && typeof usage.cost === 'number'
|
|
607
|
+
? usage.cost
|
|
608
|
+
: usage && isRecord(usage.cost) && typeof usage.cost.total === 'number'
|
|
609
|
+
? usage.cost.total
|
|
610
|
+
: undefined;
|
|
611
|
+
if (cost != null)
|
|
612
|
+
this.totalCostUsd = (this.totalCostUsd ?? 0) + cost;
|
|
464
613
|
return [bridgeEvent('assistant', {
|
|
465
614
|
session_id: this.sessionId ?? '',
|
|
466
615
|
message: {
|
|
467
616
|
role: 'assistant',
|
|
468
|
-
content:
|
|
617
|
+
content: extractPiAssistantContent(message),
|
|
618
|
+
model: this.model,
|
|
619
|
+
usage,
|
|
469
620
|
},
|
|
470
621
|
})];
|
|
471
622
|
}
|
|
472
623
|
return [];
|
|
473
624
|
}
|
|
474
|
-
if (type === '
|
|
475
|
-
|
|
476
|
-
|
|
625
|
+
if (type === 'turn_end') {
|
|
626
|
+
this.turns += 1;
|
|
627
|
+
return [];
|
|
628
|
+
}
|
|
629
|
+
if (type === 'auto_retry_start' || type === 'auto_retry_end'
|
|
630
|
+
|| type === 'compaction_start' || type === 'compaction_end'
|
|
631
|
+
|| type === 'queue_update' || type === 'extension_error') {
|
|
632
|
+
return [bridgeEvent('system', {
|
|
633
|
+
...raw,
|
|
634
|
+
subtype: type,
|
|
477
635
|
session_id: this.sessionId ?? '',
|
|
478
|
-
is_error: false,
|
|
479
|
-
result: this.pendingAssistantText,
|
|
480
|
-
stop_reason: 'end_turn',
|
|
481
|
-
num_turns: 1,
|
|
482
636
|
})];
|
|
483
637
|
}
|
|
638
|
+
if (type === 'agent_end' || type === 'agent_settled') {
|
|
639
|
+
return this.finish(control, false);
|
|
640
|
+
}
|
|
484
641
|
return [];
|
|
485
642
|
}
|
|
643
|
+
emitInit() {
|
|
644
|
+
if (this.initEmitted)
|
|
645
|
+
return [];
|
|
646
|
+
this.initEmitted = true;
|
|
647
|
+
return [bridgeEvent('system', {
|
|
648
|
+
subtype: 'init',
|
|
649
|
+
session_id: this.sessionId ?? (this.options.sessionId ?? ''),
|
|
650
|
+
cwd: this.cwd,
|
|
651
|
+
tools: [],
|
|
652
|
+
mcp_servers: [],
|
|
653
|
+
slash_commands: [],
|
|
654
|
+
agents: [],
|
|
655
|
+
skills: [],
|
|
656
|
+
plugins: [],
|
|
657
|
+
model: this.model ?? this.options.model,
|
|
658
|
+
permission_mode: this.options.permissionMode ?? 'default',
|
|
659
|
+
})];
|
|
660
|
+
}
|
|
661
|
+
finish(control, forcedError) {
|
|
662
|
+
if (this.finished)
|
|
663
|
+
return [];
|
|
664
|
+
this.finished = true;
|
|
665
|
+
control?.endInput();
|
|
666
|
+
const isError = forcedError || Boolean(this.lastError) || this.stopReason === 'error';
|
|
667
|
+
return [
|
|
668
|
+
...this.emitInit(),
|
|
669
|
+
bridgeEvent('result', {
|
|
670
|
+
subtype: isError ? 'error' : 'success',
|
|
671
|
+
session_id: this.sessionId ?? (this.options.sessionId ?? ''),
|
|
672
|
+
is_error: isError,
|
|
673
|
+
result: this.lastError || this.finalAssistantText || this.streamedAssistantText,
|
|
674
|
+
stop_reason: isError ? 'error' : (this.stopReason ?? 'end_turn'),
|
|
675
|
+
num_turns: Math.max(1, this.turns),
|
|
676
|
+
total_cost_usd: this.totalCostUsd,
|
|
677
|
+
}),
|
|
678
|
+
];
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
function piRpcPayload(raw) {
|
|
682
|
+
if (isRecord(raw.data))
|
|
683
|
+
return raw.data;
|
|
684
|
+
if (isRecord(raw.result))
|
|
685
|
+
return raw.result;
|
|
686
|
+
return raw;
|
|
687
|
+
}
|
|
688
|
+
function rpcErrorMessage(raw) {
|
|
689
|
+
if (typeof raw.error === 'string')
|
|
690
|
+
return raw.error;
|
|
691
|
+
if (isRecord(raw.error))
|
|
692
|
+
return stringField(raw.error, 'message', 'error');
|
|
693
|
+
return stringField(raw, 'message');
|
|
694
|
+
}
|
|
695
|
+
function stringField(value, ...keys) {
|
|
696
|
+
for (const key of keys) {
|
|
697
|
+
if (typeof value[key] === 'string' && value[key])
|
|
698
|
+
return value[key];
|
|
699
|
+
}
|
|
700
|
+
return undefined;
|
|
701
|
+
}
|
|
702
|
+
function piResultText(value) {
|
|
703
|
+
if (typeof value === 'string')
|
|
704
|
+
return value;
|
|
705
|
+
if (!isRecord(value))
|
|
706
|
+
return value == null ? '' : (JSON.stringify(value) ?? '');
|
|
707
|
+
if (Array.isArray(value.content)) {
|
|
708
|
+
return value.content.map(block => {
|
|
709
|
+
if (typeof block === 'string')
|
|
710
|
+
return block;
|
|
711
|
+
if (isRecord(block) && typeof block.text === 'string')
|
|
712
|
+
return block.text;
|
|
713
|
+
return isRecord(block) ? (JSON.stringify(block) ?? '') : '';
|
|
714
|
+
}).join('\n');
|
|
715
|
+
}
|
|
716
|
+
return JSON.stringify(value, null, 2) ?? '';
|
|
486
717
|
}
|
|
487
718
|
function extractPiAssistantText(message) {
|
|
488
719
|
const content = message.content;
|
|
489
|
-
if (!Array.isArray(content))
|
|
720
|
+
if (!Array.isArray(content))
|
|
490
721
|
return typeof content === 'string' ? content : '';
|
|
722
|
+
return content.map(block => isRecord(block) && block.type === 'text' && typeof block.text === 'string'
|
|
723
|
+
? block.text
|
|
724
|
+
: '').join('');
|
|
725
|
+
}
|
|
726
|
+
function extractPiAssistantContent(message) {
|
|
727
|
+
if (!Array.isArray(message.content)) {
|
|
728
|
+
const text = typeof message.content === 'string' ? message.content : '';
|
|
729
|
+
return text ? [{ type: 'text', text }] : [];
|
|
491
730
|
}
|
|
492
|
-
|
|
493
|
-
|
|
731
|
+
const content = [];
|
|
732
|
+
for (const block of message.content) {
|
|
494
733
|
if (!isRecord(block))
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
734
|
+
continue;
|
|
735
|
+
if (block.type === 'text' && typeof block.text === 'string') {
|
|
736
|
+
content.push({ type: 'text', text: block.text });
|
|
737
|
+
}
|
|
738
|
+
if (block.type === 'thinking' && typeof block.thinking === 'string') {
|
|
739
|
+
content.push({ type: 'thinking', thinking: block.thinking });
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
return content;
|
|
499
743
|
}
|
|
500
744
|
// ---------------------------------------------------------------------------
|
|
501
745
|
// codex provider (codex exec --json)
|
|
502
746
|
// ---------------------------------------------------------------------------
|
|
747
|
+
function validateCodexSessionId(value) {
|
|
748
|
+
const sessionId = value.trim();
|
|
749
|
+
if (!sessionId
|
|
750
|
+
|| sessionId.length > 256
|
|
751
|
+
|| sessionId.startsWith('-')
|
|
752
|
+
|| /[\u0000-\u001f\u007f]/u.test(sessionId)) {
|
|
753
|
+
throw new ActoviqBridgeProcessError('Codex session id must be a non-option UUID or thread name without control characters.');
|
|
754
|
+
}
|
|
755
|
+
return sessionId;
|
|
756
|
+
}
|
|
503
757
|
class CodexProvider extends BaseRuntimeProvider {
|
|
504
758
|
id = 'codex';
|
|
505
759
|
pathBinary = 'codex';
|
|
506
760
|
displayName = 'Codex CLI (@openai/codex)';
|
|
507
761
|
buildArgs(prompt, options) {
|
|
508
|
-
const
|
|
509
|
-
|
|
510
|
-
|
|
762
|
+
const shouldResume = typeof options.resume === 'string'
|
|
763
|
+
|| options.resume === true
|
|
764
|
+
|| options.continueMostRecent === true;
|
|
765
|
+
const args = shouldResume
|
|
766
|
+
? ['exec', 'resume', '--json', '--skip-git-repo-check']
|
|
767
|
+
: ['exec', '--json', '--skip-git-repo-check', '--color', 'never'];
|
|
768
|
+
// `codex exec` cannot relay an interactive approval back through this
|
|
769
|
+
// JSONL adapter. Preserve the caller's permission boundary explicitly:
|
|
770
|
+
// default/plan are read-only, acceptEdits is workspace-write, and only an
|
|
771
|
+
// explicit bypassPermissions selection disables the sandbox.
|
|
772
|
+
if (options.permissionMode === 'bypassPermissions') {
|
|
773
|
+
args.push('--dangerously-bypass-approvals-and-sandbox');
|
|
774
|
+
}
|
|
775
|
+
else {
|
|
776
|
+
const sandbox = options.permissionMode === 'acceptEdits'
|
|
777
|
+
? 'workspace-write'
|
|
778
|
+
: 'read-only';
|
|
779
|
+
args.push('-c', `sandbox_mode="${sandbox}"`, '-c', 'approval_policy="never"');
|
|
780
|
+
}
|
|
511
781
|
if (options.model) {
|
|
512
782
|
args.push('-m', options.model);
|
|
513
783
|
}
|
|
@@ -517,6 +787,17 @@ class CodexProvider extends BaseRuntimeProvider {
|
|
|
517
787
|
if (typeof options.maxTurns === 'number') {
|
|
518
788
|
args.push('-c', `max_turns=${options.maxTurns}`);
|
|
519
789
|
}
|
|
790
|
+
if (shouldResume && typeof options.resume !== 'string') {
|
|
791
|
+
args.push('--last');
|
|
792
|
+
}
|
|
793
|
+
// Codex parses options anywhere before `--`. Keep both the externally
|
|
794
|
+
// supplied prompt and resume identifier in the positional-argument domain
|
|
795
|
+
// so values such as `--dangerously-bypass-approvals-and-sandbox` cannot
|
|
796
|
+
// widen the permission mode selected above.
|
|
797
|
+
args.push('--');
|
|
798
|
+
if (typeof options.resume === 'string') {
|
|
799
|
+
args.push(validateCodexSessionId(options.resume));
|
|
800
|
+
}
|
|
520
801
|
args.push(prompt);
|
|
521
802
|
return args;
|
|
522
803
|
}
|
|
@@ -531,11 +812,52 @@ class CodexProvider extends BaseRuntimeProvider {
|
|
|
531
812
|
return ['gpt-5', 'gpt-5-mini', 'o3', 'o4-mini'];
|
|
532
813
|
}
|
|
533
814
|
}
|
|
815
|
+
const CODEX_TOOL_ITEM_TYPES = ['command_execution', 'file_change', 'mcp_tool_call'];
|
|
816
|
+
function isCodexToolItem(item) {
|
|
817
|
+
return CODEX_TOOL_ITEM_TYPES.includes(item.type);
|
|
818
|
+
}
|
|
819
|
+
function codexToolName(item) {
|
|
820
|
+
if (item.type !== 'mcp_tool_call')
|
|
821
|
+
return String(item.type);
|
|
822
|
+
const parts = ['mcp'];
|
|
823
|
+
if (typeof item.server === 'string' && item.server)
|
|
824
|
+
parts.push(item.server);
|
|
825
|
+
if (typeof item.tool === 'string' && item.tool)
|
|
826
|
+
parts.push(item.tool);
|
|
827
|
+
return parts.length > 1 ? parts.join('__') : 'mcp_tool_call';
|
|
828
|
+
}
|
|
829
|
+
function codexToolInput(item) {
|
|
830
|
+
if (item.type === 'command_execution') {
|
|
831
|
+
return typeof item.command === 'string' ? { command: item.command } : {};
|
|
832
|
+
}
|
|
833
|
+
if (item.type === 'file_change') {
|
|
834
|
+
return { changes: Array.isArray(item.changes) ? item.changes : [] };
|
|
835
|
+
}
|
|
836
|
+
if (isRecord(item.arguments))
|
|
837
|
+
return item.arguments;
|
|
838
|
+
return item.arguments === undefined ? {} : { arguments: item.arguments };
|
|
839
|
+
}
|
|
840
|
+
function codexToolResultContent(item) {
|
|
841
|
+
const value = item.type === 'command_execution'
|
|
842
|
+
? item.aggregated_output ?? item.output ?? item.error
|
|
843
|
+
: item.type === 'file_change'
|
|
844
|
+
? item.changes ?? item.result ?? item.error
|
|
845
|
+
: item.error ?? item.result;
|
|
846
|
+
if (typeof value === 'string')
|
|
847
|
+
return value;
|
|
848
|
+
return value == null ? '' : (JSON.stringify(value, null, 2) ?? '');
|
|
849
|
+
}
|
|
850
|
+
function codexToolResultIsError(item) {
|
|
851
|
+
return item.status === 'failed'
|
|
852
|
+
|| (typeof item.exit_code === 'number' && item.exit_code !== 0)
|
|
853
|
+
|| (item.error !== undefined && item.error !== null);
|
|
854
|
+
}
|
|
534
855
|
class CodexNormalizer {
|
|
535
856
|
threadId;
|
|
536
857
|
initEmitted = false;
|
|
537
858
|
translate(raw) {
|
|
538
859
|
const type = typeof raw.type === 'string' ? raw.type : '';
|
|
860
|
+
const item = isRecord(raw.item) ? raw.item : undefined;
|
|
539
861
|
if (type === 'thread.started') {
|
|
540
862
|
this.threadId = typeof raw.thread_id === 'string' ? raw.thread_id : this.threadId;
|
|
541
863
|
if (!this.initEmitted) {
|
|
@@ -555,9 +877,37 @@ class CodexNormalizer {
|
|
|
555
877
|
}
|
|
556
878
|
return [];
|
|
557
879
|
}
|
|
880
|
+
if ((type === 'item.started' || type === 'item.completed') && item && isCodexToolItem(item)) {
|
|
881
|
+
const id = typeof item.id === 'string' ? item.id : `${String(item.type)}-unknown`;
|
|
882
|
+
if (type === 'item.started') {
|
|
883
|
+
return [bridgeEvent('assistant', {
|
|
884
|
+
session_id: this.threadId ?? '',
|
|
885
|
+
message: {
|
|
886
|
+
role: 'assistant',
|
|
887
|
+
content: [{
|
|
888
|
+
type: 'tool_use',
|
|
889
|
+
id,
|
|
890
|
+
name: codexToolName(item),
|
|
891
|
+
input: codexToolInput(item),
|
|
892
|
+
}],
|
|
893
|
+
},
|
|
894
|
+
})];
|
|
895
|
+
}
|
|
896
|
+
return [bridgeEvent('user', {
|
|
897
|
+
session_id: this.threadId ?? '',
|
|
898
|
+
message: {
|
|
899
|
+
role: 'user',
|
|
900
|
+
content: [{
|
|
901
|
+
type: 'tool_result',
|
|
902
|
+
tool_use_id: id,
|
|
903
|
+
content: codexToolResultContent(item),
|
|
904
|
+
is_error: codexToolResultIsError(item),
|
|
905
|
+
}],
|
|
906
|
+
},
|
|
907
|
+
})];
|
|
908
|
+
}
|
|
558
909
|
if (type === 'item.completed') {
|
|
559
|
-
|
|
560
|
-
if (isRecord(item) && item.type === 'agent_message' && typeof item.text === 'string') {
|
|
910
|
+
if (item?.type === 'agent_message' && typeof item.text === 'string') {
|
|
561
911
|
return [bridgeEvent('assistant', {
|
|
562
912
|
session_id: this.threadId ?? '',
|
|
563
913
|
message: {
|
|
@@ -648,23 +998,13 @@ class CodewhaleProvider extends BaseRuntimeProvider {
|
|
|
648
998
|
pathBinary = 'codewhale';
|
|
649
999
|
displayName = 'CodeWhale CLI (codewhale)';
|
|
650
1000
|
buildArgs(prompt, options) {
|
|
651
|
-
|
|
652
|
-
// codewhale persists sessions per workspace. Its --session-id RESUMES by
|
|
653
|
-
// id rather than creating, and we can't reliably feed its native id back
|
|
654
|
-
// through ActoviqBridgeSession's uuid, so use --continue (most-recent) for
|
|
655
|
-
// resumed turns — correct for sequential same-provider turns and survives
|
|
656
|
-
// switching away and back.
|
|
657
|
-
if (options.resume || options.continueMostRecent) {
|
|
658
|
-
args.push('--continue');
|
|
659
|
-
}
|
|
660
|
-
args.push(prompt);
|
|
661
|
-
return args;
|
|
1001
|
+
return buildCodewhaleArgs(prompt, options);
|
|
662
1002
|
}
|
|
663
1003
|
buildChildEnv(baseEnv, settingsEnv, overrides) {
|
|
664
1004
|
return { ...baseEnv, ...settingsEnv, ...(overrides ?? {}) };
|
|
665
1005
|
}
|
|
666
1006
|
createNormalizer() {
|
|
667
|
-
return
|
|
1007
|
+
return createCodewhaleNormalizer();
|
|
668
1008
|
}
|
|
669
1009
|
suggestedModels() { return []; }
|
|
670
1010
|
}
|
|
@@ -675,30 +1015,72 @@ class ReasonixProvider extends BaseRuntimeProvider {
|
|
|
675
1015
|
id = 'reasonix';
|
|
676
1016
|
pathBinary = 'reasonix';
|
|
677
1017
|
displayName = 'Reasonix CLI (reasonix)';
|
|
678
|
-
buildArgs(
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
args.push('-m', options.model);
|
|
682
|
-
}
|
|
683
|
-
if (options.systemPrompt) {
|
|
684
|
-
args.push('-s', options.systemPrompt);
|
|
685
|
-
}
|
|
686
|
-
if (options.effort) {
|
|
687
|
-
args.push('--effort', options.effort);
|
|
1018
|
+
buildArgs(_prompt, options) {
|
|
1019
|
+
if (options.resume === true || options.continueMostRecent) {
|
|
1020
|
+
throw new ActoviqBridgeProcessError('Reasonix managed mode requires an exact persisted session id.');
|
|
688
1021
|
}
|
|
689
|
-
args
|
|
1022
|
+
const args = ['acp'];
|
|
1023
|
+
// --model exists in both the legacy and current ACP CLIs. Effort/budget are
|
|
1024
|
+
// negotiated through advertised ACP config options by the session state.
|
|
1025
|
+
if (options.model)
|
|
1026
|
+
args.push('--model', validateReasonixValue(options.model, 'model'));
|
|
690
1027
|
return args;
|
|
691
1028
|
}
|
|
692
1029
|
buildChildEnv(baseEnv, settingsEnv, overrides) {
|
|
693
1030
|
return { ...baseEnv, ...settingsEnv, ...(overrides ?? {}) };
|
|
694
1031
|
}
|
|
695
|
-
createNormalizer() {
|
|
696
|
-
return new
|
|
1032
|
+
createNormalizer(prompt = '', options = {}) {
|
|
1033
|
+
return new ReasonixAcpNormalizer(prompt, options);
|
|
697
1034
|
}
|
|
698
1035
|
suggestedModels() {
|
|
699
1036
|
return ['deepseek-v4-pro', 'deepseek-v4-flash'];
|
|
700
1037
|
}
|
|
701
1038
|
}
|
|
1039
|
+
function validateReasonixValue(value, label) {
|
|
1040
|
+
const normalized = value.trim();
|
|
1041
|
+
if (!normalized || normalized.length > 512 || normalized.startsWith('-')
|
|
1042
|
+
|| /[\u0000-\u001f\u007f]/u.test(normalized)) {
|
|
1043
|
+
throw new ActoviqBridgeProcessError(`Reasonix ${label} must be a non-option value without control characters.`);
|
|
1044
|
+
}
|
|
1045
|
+
return normalized;
|
|
1046
|
+
}
|
|
1047
|
+
class ReasonixAcpNormalizer {
|
|
1048
|
+
interactive = true;
|
|
1049
|
+
abortGraceMs = 300;
|
|
1050
|
+
session;
|
|
1051
|
+
constructor(prompt, options) {
|
|
1052
|
+
const nativeSessionId = typeof options.resume === 'string'
|
|
1053
|
+
? validateReasonixValue(options.resume, 'session id')
|
|
1054
|
+
: undefined;
|
|
1055
|
+
this.session = createReasonixAcpSession({
|
|
1056
|
+
prompt,
|
|
1057
|
+
cwd: options.workDir ?? process.cwd(),
|
|
1058
|
+
model: options.model,
|
|
1059
|
+
effort: options.effort,
|
|
1060
|
+
maxBudgetUsd: options.maxBudgetUsd,
|
|
1061
|
+
permissionMode: options.permissionMode ?? 'default',
|
|
1062
|
+
nativeSessionId,
|
|
1063
|
+
});
|
|
1064
|
+
}
|
|
1065
|
+
start(control) {
|
|
1066
|
+
for (const record of this.session.start())
|
|
1067
|
+
control.write(record);
|
|
1068
|
+
}
|
|
1069
|
+
abort(control) {
|
|
1070
|
+
for (const record of this.session.cancel())
|
|
1071
|
+
control.write(record);
|
|
1072
|
+
}
|
|
1073
|
+
translate(raw, control) {
|
|
1074
|
+
const handled = this.session.handle(raw);
|
|
1075
|
+
if (control) {
|
|
1076
|
+
for (const record of handled.outbound)
|
|
1077
|
+
control.write(record);
|
|
1078
|
+
if (handled.done)
|
|
1079
|
+
control.endInput();
|
|
1080
|
+
}
|
|
1081
|
+
return handled.events;
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
702
1084
|
class CrushProvider extends BaseRuntimeProvider {
|
|
703
1085
|
id = 'crush';
|
|
704
1086
|
pathBinary = 'crush';
|