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
|
@@ -6,16 +6,21 @@
|
|
|
6
6
|
* rendering (no React/Ink).
|
|
7
7
|
*/
|
|
8
8
|
import { execSync, spawnSync } from 'node:child_process';
|
|
9
|
+
import { createHash } from 'node:crypto';
|
|
9
10
|
import fs from 'node:fs';
|
|
10
11
|
import path from 'node:path';
|
|
11
12
|
import * as readline from 'node:readline';
|
|
12
|
-
import { createActoviqCoreTools, createAgentSdk, detectBridgeProviders, loadDefaultActoviqSettings, loadJsonConfigFile, listWorkflows, loadWorkflow, listTeamDefinitions, loadTeamDefinition, cloneTeamDefinition, instantiateTeamDefinition, listTeamAgentLabels, countTeamAgents, createModelTeam, createTeamTool, readTeamPreferences, createManagerTools, buildManagerSystemPrompt, buildUpdateProgressPrompt, formatManagerUpdatePreview, resolveGitHubDigestForUpdate, readManagerConfig, writeManagerConfig, readProjectPlanFile, readProgressFile, managerProgressPath, createProjectIssue, executeProjectIssue, isIssueStatus, isIssueStorageMode, listProjectIssues, listScheduledAutomationTasks, resolveActoviqHome, listRouterProfiles, loadRouterProfile, resolveRoutedRun, transitionProjectIssue, WorktreeService, } from '../index.js';
|
|
13
|
+
import { createActoviqCoreTools, createAgentSdk, createActoviqBridgeSdk, detectBridgeProviders, loadDefaultActoviqSettings, loadJsonConfigFile, listWorkflows, loadWorkflow, listTeamDefinitions, loadTeamDefinition, cloneTeamDefinition, instantiateTeamDefinition, listTeamAgentLabels, countTeamAgents, createModelTeam, createTeamTool, readTeamPreferences, createManagerTools, buildManagerSystemPrompt, buildUpdateProgressPrompt, formatManagerUpdatePreview, resolveGitHubDigestForUpdate, readManagerConfig, writeManagerConfig, readProjectPlanFile, readProgressFile, managerProgressPath, createProjectIssue, executeProjectIssue, isIssueStatus, isIssueStorageMode, listProjectIssues, listScheduledAutomationTasks, resolveActoviqHome, externalSkillPreferencesToRuntimeOptions, readActoviqExternalSkillPreferences, createManagedPluginRuntime, patchManagedPluginSettings, readManagedPluginCatalog, listRouterProfiles, loadRouterProfile, resolveRoutedRun, transitionProjectIssue, WorktreeService, } from '../index.js';
|
|
14
|
+
import { adaptBridgeRun } from '../parity/bridgeEventAdapter.js';
|
|
15
|
+
import { ExternalCliRuntimeManager } from '../parity/externalCliRuntimeManager.js';
|
|
16
|
+
import { externalCliSessionMatchesConfig, listExternalCliSessions, readExternalCliSession, } from '../parity/externalCliSessions.js';
|
|
17
|
+
import { parseCrushSessionReferenceDetails } from '../parity/crushSessionHistory.js';
|
|
13
18
|
import { readProjectMeta } from '../gui/projectMeta.js';
|
|
14
19
|
import { persistActoviqSettingsStore, resolveActoviqSettingsStore, } from '../config/actoviqSettingsStore.js';
|
|
15
20
|
import { createPreToolUseHookClassifier, readPreToolUseHooks, readPostToolUseHooks, runPostToolUseHooks, readSessionStartHooks, runSessionStartHooks } from '../hooks/userHooks.js';
|
|
16
21
|
import { isRecord } from '../runtime/helpers.js';
|
|
17
22
|
import { getLoadedJsonConfig } from '../config/loadJsonConfigFile.js';
|
|
18
|
-
import { findBridgeConfig, maskApiKey, readBridgeConfigs, addBridgeConfig, removeBridgeConfig, } from '../parity/bridgeConfigs.js';
|
|
23
|
+
import { findBridgeConfig, maskApiKey, readBridgeConfigs, addBridgeConfig, removeBridgeConfig, isManagedExternalCliRuntime, } from '../parity/bridgeConfigs.js';
|
|
19
24
|
import { buildRouteModelApi } from '../router/modelRouter.js';
|
|
20
25
|
import { addMcpServer, readMcpServerConfig, removeMcpServer } from '../mcp/mcpServerConfig.js';
|
|
21
26
|
import { isReadOnlyBashCommand } from '../runtime/bashClassification.js';
|
|
@@ -26,7 +31,8 @@ import { planFilePath, readPlanFile } from '../tools/planMode/PlanModeTools.js';
|
|
|
26
31
|
import { loadProjectContext } from '../memory/projectContext.js';
|
|
27
32
|
import { LegacySurfaceEventPipeline, } from '../surfaces/index.js';
|
|
28
33
|
import { pathToFileURL } from 'node:url';
|
|
29
|
-
import { ACTOVIQ_INTERACTIVE_COMMANDS, SUBCOMMAND_DESCRIPTIONS, filterInteractiveCommands, } from '../ui/commandSurface.js';
|
|
34
|
+
import { ACTOVIQ_INTERACTIVE_COMMANDS, SUBCOMMAND_DESCRIPTIONS, filterInteractiveCommands, selectInteractiveCommand, } from '../ui/commandSurface.js';
|
|
35
|
+
import { createAgentExecutionProjectView, createAgentExecutionRootView, formatAgentExecutionTreeLines, } from '../ui/agentExecutionView.js';
|
|
30
36
|
import { A, stringWidth, truncateToWidth, wrapToWidth } from './ansi.js';
|
|
31
37
|
import { InputEditor } from './editor.js';
|
|
32
38
|
import { discoverActoviqPlugins } from './pluginCatalog.js';
|
|
@@ -40,6 +46,8 @@ const MENU_MAX_ROWS = 12;
|
|
|
40
46
|
const PROMPT_GLYPH = '❯';
|
|
41
47
|
const SESSION_EFFORT_KEY = '__actoviqEffort';
|
|
42
48
|
const EFFORT_LEVELS = ['low', 'medium', 'high', 'max'];
|
|
49
|
+
const MANAGED_PLUGIN_FINAL_CLOSE_ATTEMPTS = 2;
|
|
50
|
+
const MANAGED_PLUGIN_FINAL_CLOSE_TIMEOUT_MS = 35_000;
|
|
43
51
|
/** Core tools that mutate state and require approval in 'default' mode. */
|
|
44
52
|
const MUTATING_TOOLS = new Set(['Bash', 'Write', 'Edit', 'NotebookEdit']);
|
|
45
53
|
const PERMISSION_MODES = new Set([
|
|
@@ -50,6 +58,36 @@ const PERMISSION_MODES = new Set([
|
|
|
50
58
|
'auto',
|
|
51
59
|
]);
|
|
52
60
|
export const TUI_SLASH_COMMANDS = ACTOVIQ_INTERACTIVE_COMMANDS;
|
|
61
|
+
function errorMessage(error) {
|
|
62
|
+
return error instanceof Error ? error.message : String(error);
|
|
63
|
+
}
|
|
64
|
+
async function closeManagedPluginsForExit(close) {
|
|
65
|
+
const failures = [];
|
|
66
|
+
for (let attempt = 1; attempt <= MANAGED_PLUGIN_FINAL_CLOSE_ATTEMPTS; attempt += 1) {
|
|
67
|
+
let timer;
|
|
68
|
+
try {
|
|
69
|
+
await Promise.race([
|
|
70
|
+
close(),
|
|
71
|
+
new Promise((_resolve, reject) => {
|
|
72
|
+
timer = setTimeout(() => {
|
|
73
|
+
reject(new Error(`managed plugin cleanup timed out after ${MANAGED_PLUGIN_FINAL_CLOSE_TIMEOUT_MS}ms`));
|
|
74
|
+
}, MANAGED_PLUGIN_FINAL_CLOSE_TIMEOUT_MS);
|
|
75
|
+
}),
|
|
76
|
+
]);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
failures.push(error);
|
|
81
|
+
process.stderr.write(`[actoviq-tui] warning: managed plugin cleanup attempt ${attempt}/` +
|
|
82
|
+
`${MANAGED_PLUGIN_FINAL_CLOSE_ATTEMPTS} failed: ${errorMessage(error)}\n`);
|
|
83
|
+
}
|
|
84
|
+
finally {
|
|
85
|
+
if (timer)
|
|
86
|
+
clearTimeout(timer);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
throw new AggregateError(failures, 'Managed plugin cleanup failed after bounded retries; an external sandbox may remain active and billing may continue.');
|
|
90
|
+
}
|
|
53
91
|
/** Mask an API key for display: show first 4 + last 4, hide the middle. */
|
|
54
92
|
function maskKey(key) {
|
|
55
93
|
if (key.length <= 8)
|
|
@@ -59,6 +97,10 @@ function maskKey(key) {
|
|
|
59
97
|
export function filterSlashCommands(input) {
|
|
60
98
|
return filterInteractiveCommands(input);
|
|
61
99
|
}
|
|
100
|
+
/** Agent conversations are independently resumable, but stay out of the normal chat list. */
|
|
101
|
+
export function isTuiChatSession(session) {
|
|
102
|
+
return session.kind !== 'manager' && session.kind !== 'agent';
|
|
103
|
+
}
|
|
62
104
|
/**
|
|
63
105
|
* Detect an active "@file" mention at the cursor for path completion. Returns
|
|
64
106
|
* the partial token typed after the '@' plus the '@' offset, or null when the
|
|
@@ -211,23 +253,47 @@ export async function runActoviqTui(options = {}) {
|
|
|
211
253
|
// Missing local config is fine; env vars may carry credentials.
|
|
212
254
|
}
|
|
213
255
|
let applyPlanPermission = null;
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
256
|
+
let managedPluginRuntime = null;
|
|
257
|
+
let tools = [];
|
|
258
|
+
const rebuildInteractiveTools = async () => {
|
|
259
|
+
if (managedPluginRuntime) {
|
|
260
|
+
await managedPluginRuntime.close();
|
|
261
|
+
}
|
|
262
|
+
const store = await resolveActoviqSettingsStore({
|
|
263
|
+
configPath: options.configPath,
|
|
264
|
+
});
|
|
265
|
+
managedPluginRuntime = createManagedPluginRuntime(store.raw, { cwd: workDir });
|
|
266
|
+
tools = [
|
|
267
|
+
...createActoviqCoreTools({
|
|
268
|
+
cwd: workDir,
|
|
269
|
+
onPlanModeChange: async (mode) => {
|
|
270
|
+
if (mode === 'plan')
|
|
271
|
+
await applyPlanPermission?.();
|
|
272
|
+
},
|
|
273
|
+
}),
|
|
274
|
+
...managedPluginRuntime.tools,
|
|
275
|
+
];
|
|
276
|
+
const byName = new Map(tools.map(tool => [tool.name, tool]));
|
|
277
|
+
tools = [...byName.values()];
|
|
278
|
+
};
|
|
279
|
+
const createCleanSdk = async () => {
|
|
280
|
+
await rebuildInteractiveTools();
|
|
281
|
+
const externalSkillPreferences = await readActoviqExternalSkillPreferences({
|
|
282
|
+
actoviqHomeDir: resolveActoviqHome(),
|
|
283
|
+
workDir,
|
|
284
|
+
});
|
|
285
|
+
return createAgentSdk({
|
|
286
|
+
workDir,
|
|
287
|
+
tools,
|
|
288
|
+
permissionMode,
|
|
289
|
+
externalSkills: externalSkillPreferencesToRuntimeOptions(externalSkillPreferences),
|
|
290
|
+
// Load user-managed stdio MCP servers from ~/.actoviq/mcp.json (gap #10).
|
|
291
|
+
mcpServers: readMcpServerConfig().servers.map(s => (s.command
|
|
292
|
+
? { kind: 'stdio', name: s.name, command: s.command, ...(s.args ? { args: s.args } : {}), ...(s.env ? { env: s.env } : {}), ...(s.cwd ? { cwd: s.cwd } : {}) }
|
|
293
|
+
: { kind: 'streamable_http', name: s.name, url: s.url, ...(s.headers ? { headers: s.headers } : {}) })),
|
|
294
|
+
...(options.model ? { model: options.model } : {}),
|
|
295
|
+
});
|
|
296
|
+
};
|
|
231
297
|
let sdk;
|
|
232
298
|
let toolMetadata;
|
|
233
299
|
while (true) {
|
|
@@ -321,19 +387,177 @@ export async function runActoviqTui(options = {}) {
|
|
|
321
387
|
// /model router: when set, each user turn is classified and routed to a model.
|
|
322
388
|
let activeRouter = null;
|
|
323
389
|
let routedModelLabel = null;
|
|
324
|
-
//
|
|
325
|
-
//
|
|
326
|
-
//
|
|
327
|
-
// injected per-run into session.stream({model, modelApi}) — same session,
|
|
328
|
-
// context naturally survives switching bridge↔hadamard.
|
|
390
|
+
// A named config can use either the in-process API bridge or a real external
|
|
391
|
+
// CLI. External clients/sessions are isolated by Actoviq session, config, and
|
|
392
|
+
// cwd so switching chats cannot leak native runtime context.
|
|
329
393
|
let bridgeMode = false;
|
|
330
394
|
let activeBridgeConfig = null;
|
|
331
395
|
// Pre-built {model, modelApi} for the active config. Built once at activation;
|
|
332
396
|
// stale after disable (cleared). Per-run injection reuses the /model router's
|
|
333
397
|
// proven mechanism (session.stream({model, modelApi})).
|
|
334
398
|
let activeBridgeModelApi = null;
|
|
335
|
-
|
|
399
|
+
const RUNTIME_METADATA_KEY = '__actoviqRuntime';
|
|
400
|
+
const CONFIG_NAME_METADATA_KEY = '__actoviqConfigName';
|
|
401
|
+
const RUNTIME_MODEL_METADATA_KEY = '__actoviqRuntimeModel';
|
|
402
|
+
const EXTERNAL_SESSIONS_METADATA_KEY = '__actoviqExternalSessions';
|
|
403
|
+
// Display label for the active runtime model.
|
|
336
404
|
let bridgeModelLabel = null;
|
|
405
|
+
const externalBridgeRuntimes = new Map();
|
|
406
|
+
const externalCliRuntimeManager = new ExternalCliRuntimeManager();
|
|
407
|
+
const externalCliRunLabels = new Map();
|
|
408
|
+
function sameWorkspace(left, right) {
|
|
409
|
+
const a = path.resolve(left);
|
|
410
|
+
const b = path.resolve(right);
|
|
411
|
+
return process.platform === 'win32' ? a.toLowerCase() === b.toLowerCase() : a === b;
|
|
412
|
+
}
|
|
413
|
+
function externalSessionBindingKey(config, targetWorkDir = sdk.config.workDir) {
|
|
414
|
+
return createHash('sha256')
|
|
415
|
+
.update(config.runtime + '\u0000' + config.name + '\u0000' + path.resolve(targetWorkDir))
|
|
416
|
+
.digest('hex')
|
|
417
|
+
.slice(0, 24);
|
|
418
|
+
}
|
|
419
|
+
function externalBridgeRuntimeKey(config, targetSession = session, targetWorkDir = sdk.config.workDir) {
|
|
420
|
+
return targetSession.id + '\u0000' + externalSessionBindingKey(config, targetWorkDir);
|
|
421
|
+
}
|
|
422
|
+
function externalSessionBindings(targetSession = session) {
|
|
423
|
+
const raw = targetSession.metadata[EXTERNAL_SESSIONS_METADATA_KEY];
|
|
424
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw))
|
|
425
|
+
return {};
|
|
426
|
+
const bindings = {};
|
|
427
|
+
for (const [key, value] of Object.entries(raw)) {
|
|
428
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
429
|
+
continue;
|
|
430
|
+
const record = value;
|
|
431
|
+
if (!isManagedExternalCliRuntime(record.runtime)
|
|
432
|
+
|| typeof record.configName !== 'string'
|
|
433
|
+
|| typeof record.cwd !== 'string'
|
|
434
|
+
|| typeof record.nativeSessionId !== 'string'
|
|
435
|
+
|| !record.nativeSessionId)
|
|
436
|
+
continue;
|
|
437
|
+
bindings[key] = {
|
|
438
|
+
runtime: record.runtime,
|
|
439
|
+
configName: record.configName,
|
|
440
|
+
cwd: record.cwd,
|
|
441
|
+
nativeSessionId: record.nativeSessionId,
|
|
442
|
+
updatedAt: typeof record.updatedAt === 'string' ? record.updatedAt : '',
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
return bindings;
|
|
446
|
+
}
|
|
447
|
+
function externalNativeSessionId(config, targetSession = session, targetWorkDir = sdk.config.workDir) {
|
|
448
|
+
const binding = externalSessionBindings(targetSession)[externalSessionBindingKey(config, targetWorkDir)];
|
|
449
|
+
if (!binding
|
|
450
|
+
|| binding.runtime !== config.runtime
|
|
451
|
+
|| binding.configName !== config.name
|
|
452
|
+
|| !sameWorkspace(binding.cwd, targetWorkDir))
|
|
453
|
+
return undefined;
|
|
454
|
+
return binding.nativeSessionId;
|
|
455
|
+
}
|
|
456
|
+
async function rememberExternalNativeSession(config, nativeSessionId, targetSession = session, targetWorkDir = sdk.config.workDir) {
|
|
457
|
+
if (!nativeSessionId)
|
|
458
|
+
return;
|
|
459
|
+
const bindings = externalSessionBindings(targetSession);
|
|
460
|
+
bindings[externalSessionBindingKey(config, targetWorkDir)] = {
|
|
461
|
+
runtime: config.runtime,
|
|
462
|
+
configName: config.name,
|
|
463
|
+
cwd: path.resolve(targetWorkDir),
|
|
464
|
+
nativeSessionId,
|
|
465
|
+
updatedAt: new Date().toISOString(),
|
|
466
|
+
};
|
|
467
|
+
await targetSession.mergeMetadata({ [EXTERNAL_SESSIONS_METADATA_KEY]: bindings });
|
|
468
|
+
}
|
|
469
|
+
async function persistSessionRuntimeMetadata(targetSession = session, config = activeBridgeConfig, modelLabel = bridgeModelLabel) {
|
|
470
|
+
await targetSession.mergeMetadata({
|
|
471
|
+
[RUNTIME_METADATA_KEY]: config?.runtime ?? 'hadamard',
|
|
472
|
+
[CONFIG_NAME_METADATA_KEY]: config?.name ?? null,
|
|
473
|
+
[RUNTIME_MODEL_METADATA_KEY]: config?.model ?? modelLabel ?? null,
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
function clearBridgeSelection() {
|
|
477
|
+
bridgeMode = false;
|
|
478
|
+
activeBridgeConfig = null;
|
|
479
|
+
activeBridgeModelApi = null;
|
|
480
|
+
bridgeModelLabel = null;
|
|
481
|
+
}
|
|
482
|
+
async function restoreSessionRuntimeSelection() {
|
|
483
|
+
const configName = session.metadata[CONFIG_NAME_METADATA_KEY];
|
|
484
|
+
if (typeof configName !== 'string' || !configName.trim()) {
|
|
485
|
+
clearBridgeSelection();
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
const stored = findBridgeConfig(configName);
|
|
489
|
+
if (!stored) {
|
|
490
|
+
clearBridgeSelection();
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
const model = session.metadata[RUNTIME_MODEL_METADATA_KEY];
|
|
494
|
+
const config = typeof model === 'string' && model.trim()
|
|
495
|
+
? { ...stored, model: model.trim() }
|
|
496
|
+
: stored;
|
|
497
|
+
if (!await activateBridgeConfig(config))
|
|
498
|
+
clearBridgeSelection();
|
|
499
|
+
}
|
|
500
|
+
function activeExternalBridgeRuntime() {
|
|
501
|
+
if (!bridgeMode
|
|
502
|
+
|| activeBridgeConfig?.execution !== 'cli'
|
|
503
|
+
|| !isManagedExternalCliRuntime(activeBridgeConfig.runtime))
|
|
504
|
+
return null;
|
|
505
|
+
return externalBridgeRuntimes.get(externalBridgeRuntimeKey(activeBridgeConfig)) ?? null;
|
|
506
|
+
}
|
|
507
|
+
function externalBridgeFingerprint(config) {
|
|
508
|
+
return JSON.stringify([
|
|
509
|
+
config.runtime,
|
|
510
|
+
config.authSource ?? 'native',
|
|
511
|
+
config.authSource === 'apiKey' ? config.apiKey ?? '' : '',
|
|
512
|
+
config.authSource === 'apiKey' ? config.baseURL ?? '' : '',
|
|
513
|
+
config.authSource === 'apiKey' ? config.credentialProvider ?? '' : '',
|
|
514
|
+
config.trustProjectResources === true,
|
|
515
|
+
]);
|
|
516
|
+
}
|
|
517
|
+
function externalCliConfigId(config) {
|
|
518
|
+
const digest = createHash('sha256')
|
|
519
|
+
.update(externalBridgeFingerprint(config))
|
|
520
|
+
.digest('hex')
|
|
521
|
+
.slice(0, 12);
|
|
522
|
+
return `${config.name}:${digest}`;
|
|
523
|
+
}
|
|
524
|
+
function findConflictingExternalCliRun(config, targetSession = session, targetWorkDir = sdk.config.workDir) {
|
|
525
|
+
const configId = externalCliConfigId(config);
|
|
526
|
+
return externalCliRuntimeManager.list().find(run => {
|
|
527
|
+
if (run.actoviqSessionId !== targetSession.id
|
|
528
|
+
|| !sameWorkspace(run.cwd, targetWorkDir)
|
|
529
|
+
|| (run.status !== 'queued' && run.status !== 'running'))
|
|
530
|
+
return false;
|
|
531
|
+
const label = externalCliRunLabels.get(run.runId);
|
|
532
|
+
return run.configId === configId
|
|
533
|
+
|| (label?.configName === config.name && label.runtime === config.runtime);
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
function externalCliDisplayText(value, config) {
|
|
537
|
+
let safe = value;
|
|
538
|
+
if (config?.apiKey)
|
|
539
|
+
safe = safe.split(config.apiKey).join('[REDACTED]');
|
|
540
|
+
return safe
|
|
541
|
+
.replace(/Bearer\s+[^\s,;]+/giu, 'Bearer [REDACTED]')
|
|
542
|
+
.replace(/((?:api[_-]?key|token|authorization|password|secret)\s*[:=]\s*)[^\s,;]+/giu, '$1[REDACTED]')
|
|
543
|
+
.replace(/\b(?:sk|key)-[A-Za-z0-9_-]{12,}\b/gu, '[REDACTED]');
|
|
544
|
+
}
|
|
545
|
+
function externalCliPreview(value, config, maxLength = 180) {
|
|
546
|
+
const normalized = externalCliDisplayText(value, config).replace(/\s+/gu, ' ').trim();
|
|
547
|
+
return normalized.length > maxLength
|
|
548
|
+
? `${normalized.slice(0, maxLength - 3)}...`
|
|
549
|
+
: normalized;
|
|
550
|
+
}
|
|
551
|
+
function externalCliHistorySourceLabel(summary) {
|
|
552
|
+
if (summary.runtime !== 'crush')
|
|
553
|
+
return undefined;
|
|
554
|
+
const reference = parseCrushSessionReferenceDetails(summary.path);
|
|
555
|
+
if (!reference)
|
|
556
|
+
return undefined;
|
|
557
|
+
return reference.managedProfileId
|
|
558
|
+
? `Managed profile \u00b7 ${reference.managedProfileId.slice(0, 8)}`
|
|
559
|
+
: 'Native login';
|
|
560
|
+
}
|
|
337
561
|
let abortCtrl = null;
|
|
338
562
|
// Persistent Manager session (kind: 'manager') — reused across /manager
|
|
339
563
|
// update/chat turns so the Manager keeps its own conversation context.
|
|
@@ -419,6 +643,10 @@ export async function runActoviqTui(options = {}) {
|
|
|
419
643
|
// is working on / what remains — Claude Code's main progress affordance.
|
|
420
644
|
let currentTodos = [];
|
|
421
645
|
const currentPermissionMode = () => session.permissionContext.mode ?? permissionMode;
|
|
646
|
+
const currentExternalCliPermissionMode = () => {
|
|
647
|
+
const mode = currentPermissionMode();
|
|
648
|
+
return mode === 'auto' ? 'default' : mode;
|
|
649
|
+
};
|
|
422
650
|
const currentEffort = () => {
|
|
423
651
|
const stored = session.metadata[SESSION_EFFORT_KEY];
|
|
424
652
|
if (stored === 'auto')
|
|
@@ -470,6 +698,7 @@ export async function runActoviqTui(options = {}) {
|
|
|
470
698
|
sdk = nextSdk;
|
|
471
699
|
session = nextSession;
|
|
472
700
|
toolMetadata = nextToolMetadata;
|
|
701
|
+
await restoreSessionRuntimeSelection();
|
|
473
702
|
}
|
|
474
703
|
catch (error) {
|
|
475
704
|
await nextSdk.close().catch(() => undefined);
|
|
@@ -1104,6 +1333,19 @@ export async function runActoviqTui(options = {}) {
|
|
|
1104
1333
|
return imagesAdded > 0 ? blocks : text;
|
|
1105
1334
|
}
|
|
1106
1335
|
async function startRun(text) {
|
|
1336
|
+
if (bridgeMode
|
|
1337
|
+
&& activeBridgeConfig?.execution === 'cli'
|
|
1338
|
+
&& isManagedExternalCliRuntime(activeBridgeConfig.runtime)) {
|
|
1339
|
+
const conflictingRun = findConflictingExternalCliRun(activeBridgeConfig);
|
|
1340
|
+
if (conflictingRun) {
|
|
1341
|
+
appendStatic([
|
|
1342
|
+
...formatErrorLine(`background run ${conflictingRun.runId} is still ${conflictingRun.status}; this native CLI session cannot run concurrently.`),
|
|
1343
|
+
...formatInfoLine(`Wait for it to finish, or use /bridge runs and /bridge stop ${conflictingRun.runId}.`),
|
|
1344
|
+
'',
|
|
1345
|
+
]);
|
|
1346
|
+
return;
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1107
1349
|
running = true;
|
|
1108
1350
|
runStartedAt = Date.now();
|
|
1109
1351
|
runToolCount = 0;
|
|
@@ -1140,7 +1382,19 @@ export async function runActoviqTui(options = {}) {
|
|
|
1140
1382
|
// normal run.
|
|
1141
1383
|
let eventStream;
|
|
1142
1384
|
let resultPromise;
|
|
1143
|
-
|
|
1385
|
+
const externalBridge = activeExternalBridgeRuntime();
|
|
1386
|
+
if (externalBridge && activeBridgeConfig) {
|
|
1387
|
+
statusNote = 'cli:' + activeBridgeConfig.runtime;
|
|
1388
|
+
const nativeStream = externalBridge.session.stream(text, {
|
|
1389
|
+
model: bridgeModelLabel ?? activeBridgeConfig.model,
|
|
1390
|
+
signal: abortCtrl.signal,
|
|
1391
|
+
permissionMode: currentExternalCliPermissionMode(),
|
|
1392
|
+
});
|
|
1393
|
+
const adapted = adaptBridgeRun(nativeStream, nativeStream.result, 'tui-cli-' + runStartedAt, activeBridgeConfig.runtime);
|
|
1394
|
+
eventStream = adapted;
|
|
1395
|
+
resultPromise = adapted.result;
|
|
1396
|
+
}
|
|
1397
|
+
else if (bridgeMode && activeBridgeModelApi) {
|
|
1144
1398
|
// Bridge mode: run in-process through the selected config's
|
|
1145
1399
|
// provider/apiKey/baseURL/model (no child process). Inject the
|
|
1146
1400
|
// pre-built {model, modelApi} into session.stream — the /model
|
|
@@ -1186,13 +1440,28 @@ export async function runActoviqTui(options = {}) {
|
|
|
1186
1440
|
const result = await resultPromise;
|
|
1187
1441
|
// Accumulate token + USD usage for /cost and /usage. The model is the
|
|
1188
1442
|
// routed model (if a router is active) or the session model. Bridge runs
|
|
1189
|
-
recordUsage(routed?.model ?? activeBridgeModelApi?.model ?? session.model, result.usage);
|
|
1443
|
+
recordUsage(routed?.model ?? activeBridgeModelApi?.model ?? bridgeModelLabel ?? session.model, result.usage);
|
|
1190
1444
|
const rest = flusher.drain();
|
|
1191
1445
|
if (rest.length > 0)
|
|
1192
1446
|
appendStatic(rest);
|
|
1193
1447
|
if (!flusher.hasContent && result.text && runHadNoStreamedText()) {
|
|
1194
1448
|
appendStatic([result.text]);
|
|
1195
1449
|
}
|
|
1450
|
+
if (externalBridge
|
|
1451
|
+
&& activeBridgeConfig?.execution === 'cli'
|
|
1452
|
+
&& isManagedExternalCliRuntime(activeBridgeConfig.runtime)) {
|
|
1453
|
+
const externalConfig = activeBridgeConfig;
|
|
1454
|
+
await rememberExternalNativeSession(externalConfig, externalBridge.session.id)
|
|
1455
|
+
.catch(() => undefined);
|
|
1456
|
+
await persistSessionRuntimeMetadata(session, externalConfig, bridgeModelLabel)
|
|
1457
|
+
.catch(() => undefined);
|
|
1458
|
+
if (result.text) {
|
|
1459
|
+
await session.appendMessages([
|
|
1460
|
+
{ role: 'user', content: text },
|
|
1461
|
+
{ role: 'assistant', content: result.text },
|
|
1462
|
+
]).catch(() => undefined);
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1196
1465
|
if (result.incompleteReason) {
|
|
1197
1466
|
appendStatic(formatInfoLine(`run incomplete: ${result.incompleteReason}`));
|
|
1198
1467
|
}
|
|
@@ -1387,7 +1656,7 @@ export async function runActoviqTui(options = {}) {
|
|
|
1387
1656
|
resume: '/resume [session-id]',
|
|
1388
1657
|
tools: '/tools',
|
|
1389
1658
|
skills: '/skills',
|
|
1390
|
-
agents: '/agents',
|
|
1659
|
+
agents: '/agents [list|runs|show <root-execution-id>|open <session-or-execution-id>]',
|
|
1391
1660
|
mcp: '/mcp',
|
|
1392
1661
|
hooks: '/hooks',
|
|
1393
1662
|
plugins: '/plugins',
|
|
@@ -1400,21 +1669,37 @@ export async function runActoviqTui(options = {}) {
|
|
|
1400
1669
|
};
|
|
1401
1670
|
return usage[name] ?? `/${name}`;
|
|
1402
1671
|
}
|
|
1403
|
-
async function resumeSession(sessionId) {
|
|
1672
|
+
async function resumeSession(sessionId, options = {}) {
|
|
1404
1673
|
const listed = await sdk.sessions.list();
|
|
1405
1674
|
const target = listed.find(item => item.id === sessionId);
|
|
1675
|
+
if (!target) {
|
|
1676
|
+
appendStatic([
|
|
1677
|
+
...formatErrorLine(`No persisted conversation exists for '${sessionId}'. The execution record may outlive its session.`),
|
|
1678
|
+
'',
|
|
1679
|
+
]);
|
|
1680
|
+
return false;
|
|
1681
|
+
}
|
|
1406
1682
|
if (target?.kind === 'manager') {
|
|
1407
1683
|
appendStatic([...formatErrorLine('Manager sessions live in the Project Manager panel only.'), '']);
|
|
1408
|
-
return;
|
|
1684
|
+
return false;
|
|
1685
|
+
}
|
|
1686
|
+
if (target.kind === 'agent' && !options.allowAgent) {
|
|
1687
|
+
appendStatic([
|
|
1688
|
+
...formatErrorLine('Agent conversations open from /agents runs, /agents show, or /agents open.'),
|
|
1689
|
+
'',
|
|
1690
|
+
]);
|
|
1691
|
+
return false;
|
|
1409
1692
|
}
|
|
1410
1693
|
session = await sdk.resumeSession(sessionId);
|
|
1694
|
+
await restoreSessionRuntimeSelection();
|
|
1411
1695
|
appendStatic([
|
|
1412
1696
|
...formatInfoLine(`resumed: ${session.id} · ${session.title} · ${session.model}`),
|
|
1413
1697
|
'',
|
|
1414
1698
|
]);
|
|
1699
|
+
return true;
|
|
1415
1700
|
}
|
|
1416
1701
|
async function chooseSessionToResume() {
|
|
1417
|
-
const sessions = (await sdk.sessions.list()).filter(item => item.id !== session.id && item
|
|
1702
|
+
const sessions = (await sdk.sessions.list()).filter(item => item.id !== session.id && isTuiChatSession(item));
|
|
1418
1703
|
if (sessions.length === 0) {
|
|
1419
1704
|
appendStatic([...formatInfoLine('no other project sessions to resume'), '']);
|
|
1420
1705
|
return;
|
|
@@ -1697,10 +1982,334 @@ export async function runActoviqTui(options = {}) {
|
|
|
1697
1982
|
}
|
|
1698
1983
|
}
|
|
1699
1984
|
}
|
|
1985
|
+
function requireActiveExternalCliConfig(action) {
|
|
1986
|
+
const config = activeBridgeConfig;
|
|
1987
|
+
if (!bridgeMode || !config) {
|
|
1988
|
+
appendStatic([
|
|
1989
|
+
...formatErrorLine(`/bridge ${action} requires an active External CLI config.`),
|
|
1990
|
+
...formatInfoLine('Use /bridge switch <name> to activate an External CLI config.'),
|
|
1991
|
+
'',
|
|
1992
|
+
]);
|
|
1993
|
+
return null;
|
|
1994
|
+
}
|
|
1995
|
+
if (config.execution !== 'cli') {
|
|
1996
|
+
appendStatic([
|
|
1997
|
+
...formatErrorLine(`/bridge ${action} is available only in External CLI mode.`),
|
|
1998
|
+
...formatInfoLine(`The active config "${config.name}" uses Direct API mode.`),
|
|
1999
|
+
'',
|
|
2000
|
+
]);
|
|
2001
|
+
return null;
|
|
2002
|
+
}
|
|
2003
|
+
if (!isManagedExternalCliRuntime(config.runtime)) {
|
|
2004
|
+
appendStatic([
|
|
2005
|
+
...formatErrorLine(`External CLI control does not support runtime "${config.runtime}".`),
|
|
2006
|
+
...formatInfoLine('Supported external runtimes: Claude Code, CodeWhale, Pi, Codex, Reasonix, and Crush.'),
|
|
2007
|
+
'',
|
|
2008
|
+
]);
|
|
2009
|
+
return null;
|
|
2010
|
+
}
|
|
2011
|
+
return config;
|
|
2012
|
+
}
|
|
2013
|
+
function printBridgeStatus() {
|
|
2014
|
+
if (!activeBridgeConfig) {
|
|
2015
|
+
appendStatic([
|
|
2016
|
+
`${A.bold}Bridge status${A.reset}`,
|
|
2017
|
+
` ${A.dim}mode${A.reset} off`,
|
|
2018
|
+
` ${A.dim}background${A.reset} ${externalCliRuntimeManager.list().filter(run => run.actoviqSessionId === session.id && (run.status === 'queued' || run.status === 'running')).length} active`,
|
|
2019
|
+
'',
|
|
2020
|
+
]);
|
|
2021
|
+
return;
|
|
2022
|
+
}
|
|
2023
|
+
const config = activeBridgeConfig;
|
|
2024
|
+
const activeRuns = externalCliRuntimeManager.list().filter(run => run.actoviqSessionId === session.id
|
|
2025
|
+
&& (run.status === 'queued' || run.status === 'running'));
|
|
2026
|
+
const mode = config.execution === 'cli'
|
|
2027
|
+
? 'External CLI'
|
|
2028
|
+
: (config.runtime === 'hadamard' ? 'Hadamard SDK' : 'Direct API');
|
|
2029
|
+
const lines = [
|
|
2030
|
+
`${A.bold}Bridge status${A.reset}`,
|
|
2031
|
+
` ${A.dim}config${A.reset} ${config.name}`,
|
|
2032
|
+
` ${A.dim}mode${A.reset} ${mode}`,
|
|
2033
|
+
` ${A.dim}runtime${A.reset} ${config.runtime}`,
|
|
2034
|
+
` ${A.dim}model${A.reset} ${bridgeModelLabel ?? config.model ?? 'runtime default'}`,
|
|
2035
|
+
];
|
|
2036
|
+
if (config.execution === 'cli') {
|
|
2037
|
+
lines.push(` ${A.dim}auth${A.reset} ${config.authSource === 'apiKey' ? 'API key override' : 'native CLI login/config'}`, ` ${A.dim}cwd${A.reset} ${sdk.config.workDir}`, ` ${A.dim}session${A.reset} ${activeExternalBridgeRuntime()?.session.id ?? 'not started'}`, ` ${A.dim}background${A.reset} ${activeRuns.length} active`);
|
|
2038
|
+
}
|
|
2039
|
+
else {
|
|
2040
|
+
lines.push(` ${A.dim}external CLI controls are disabled for this config${A.reset}`);
|
|
2041
|
+
}
|
|
2042
|
+
lines.push('');
|
|
2043
|
+
appendStatic(lines);
|
|
2044
|
+
}
|
|
2045
|
+
async function printExternalCliHistory(nativeSessionId = '') {
|
|
2046
|
+
const config = requireActiveExternalCliConfig('history');
|
|
2047
|
+
if (!config)
|
|
2048
|
+
return;
|
|
2049
|
+
try {
|
|
2050
|
+
const allSessions = (await listExternalCliSessions({
|
|
2051
|
+
runtimes: [config.runtime],
|
|
2052
|
+
crushCwd: sdk.config.workDir,
|
|
2053
|
+
actoviqHomeDir: sdk.config.homeDir,
|
|
2054
|
+
}))
|
|
2055
|
+
.filter(item => externalCliSessionMatchesConfig(item, {
|
|
2056
|
+
runtime: config.runtime,
|
|
2057
|
+
authSource: config.authSource,
|
|
2058
|
+
profileName: config.name,
|
|
2059
|
+
}, { actoviqHomeDir: sdk.config.homeDir }));
|
|
2060
|
+
if (nativeSessionId) {
|
|
2061
|
+
const summary = allSessions.find(item => item.nativeSessionId === nativeSessionId);
|
|
2062
|
+
if (!summary) {
|
|
2063
|
+
appendStatic([
|
|
2064
|
+
...formatErrorLine(`native ${config.runtime} session not found: ${nativeSessionId}`),
|
|
2065
|
+
'',
|
|
2066
|
+
]);
|
|
2067
|
+
return;
|
|
2068
|
+
}
|
|
2069
|
+
const nativeSession = await readExternalCliSession(summary.path, {
|
|
2070
|
+
detailMaxBytes: 512 * 1024,
|
|
2071
|
+
detailMaxMessages: 200,
|
|
2072
|
+
crushCwd: sdk.config.workDir,
|
|
2073
|
+
actoviqHomeDir: sdk.config.homeDir,
|
|
2074
|
+
});
|
|
2075
|
+
if (!nativeSession) {
|
|
2076
|
+
appendStatic([...formatErrorLine(`native session could not be read: ${nativeSessionId}`), '']);
|
|
2077
|
+
return;
|
|
2078
|
+
}
|
|
2079
|
+
const sourceLabel = externalCliHistorySourceLabel(summary);
|
|
2080
|
+
const detailLines = [
|
|
2081
|
+
`${A.bold}${externalCliPreview(nativeSession.summary.title, config) || nativeSessionId}${A.reset}`,
|
|
2082
|
+
`${A.dim}${config.runtime}${sourceLabel ? ` \u00b7 ${sourceLabel}` : ''} 路 ${nativeSessionId}${nativeSession.summary.cwd ? ` 路 ${externalCliDisplayText(nativeSession.summary.cwd, config)}` : ''}${A.reset}`,
|
|
2083
|
+
...formatDivider(screen.width),
|
|
2084
|
+
];
|
|
2085
|
+
if (nativeSession.truncated) {
|
|
2086
|
+
detailLines.push(`${A.dim}bounded transcript preview${A.reset}`, '');
|
|
2087
|
+
}
|
|
2088
|
+
for (const message of nativeSession.messages) {
|
|
2089
|
+
const model = message.model ? ` 路 ${externalCliDisplayText(message.model, config)}` : '';
|
|
2090
|
+
detailLines.push(`${A.bold}${message.role}${A.reset}${A.dim}${model}${A.reset}`);
|
|
2091
|
+
if (message.text) {
|
|
2092
|
+
const safeText = externalCliDisplayText(message.text, config);
|
|
2093
|
+
detailLines.push(...wrapToWidth(safeText, Math.max(20, screen.width - 4)).map(line => ` ${line}`));
|
|
2094
|
+
}
|
|
2095
|
+
if (message.tools?.length) {
|
|
2096
|
+
const safeTools = externalCliDisplayText(JSON.stringify(message.tools, null, 2) ?? '', config);
|
|
2097
|
+
detailLines.push(...wrapToWidth(safeTools, Math.max(20, screen.width - 4)).map(line => ` ${A.dim}${line}${A.reset}`));
|
|
2098
|
+
}
|
|
2099
|
+
detailLines.push('');
|
|
2100
|
+
}
|
|
2101
|
+
detailLines.push(...formatInfoLine(`Use /bridge resume ${nativeSessionId} to continue this native conversation.`), '');
|
|
2102
|
+
appendStatic(detailLines);
|
|
2103
|
+
return;
|
|
2104
|
+
}
|
|
2105
|
+
const sessions = allSessions.slice(0, 20);
|
|
2106
|
+
const runtimeLabel = {
|
|
2107
|
+
claude: 'Claude Code',
|
|
2108
|
+
codewhale: 'CodeWhale',
|
|
2109
|
+
pi: 'Pi',
|
|
2110
|
+
codex: 'Codex',
|
|
2111
|
+
reasonix: 'Reasonix',
|
|
2112
|
+
crush: 'Crush',
|
|
2113
|
+
};
|
|
2114
|
+
const lines = [
|
|
2115
|
+
`${A.bold}${runtimeLabel[config.runtime]} native conversations${A.reset}`,
|
|
2116
|
+
...formatDivider(screen.width),
|
|
2117
|
+
];
|
|
2118
|
+
if (sessions.length === 0) {
|
|
2119
|
+
lines.push(` ${A.dim}no native conversations found${A.reset}`);
|
|
2120
|
+
}
|
|
2121
|
+
else {
|
|
2122
|
+
for (const item of sessions) {
|
|
2123
|
+
const sourceLabel = externalCliHistorySourceLabel(item);
|
|
2124
|
+
lines.push(` ${A.bold}${item.nativeSessionId}${A.reset} ${A.dim}· ${item.updatedAt} · ${item.messageCount} messages${sourceLabel ? ` \u00b7 ${sourceLabel}` : ''}${A.reset}`, ` ${externalCliPreview(item.title, config) || '(untitled)'}`);
|
|
2125
|
+
if (item.cwd)
|
|
2126
|
+
lines.push(` ${A.dim}${externalCliDisplayText(item.cwd, config)}${A.reset}`);
|
|
2127
|
+
}
|
|
2128
|
+
}
|
|
2129
|
+
lines.push('', ...formatInfoLine('Use /bridge history <native-id> to inspect or /bridge resume <native-id> to continue.'), ...formatInfoLine('Credentials and history file paths stay hidden.'), '');
|
|
2130
|
+
appendStatic(lines);
|
|
2131
|
+
}
|
|
2132
|
+
catch (error) {
|
|
2133
|
+
appendStatic([
|
|
2134
|
+
...formatErrorLine(`could not read CLI history: ${externalCliDisplayText(error.message, config)}`),
|
|
2135
|
+
'',
|
|
2136
|
+
]);
|
|
2137
|
+
}
|
|
2138
|
+
}
|
|
2139
|
+
async function resumeExternalCliHistorySession(nativeSessionId) {
|
|
2140
|
+
const config = requireActiveExternalCliConfig('resume');
|
|
2141
|
+
if (!config)
|
|
2142
|
+
return;
|
|
2143
|
+
try {
|
|
2144
|
+
const summary = (await listExternalCliSessions({
|
|
2145
|
+
runtimes: [config.runtime],
|
|
2146
|
+
crushCwd: sdk.config.workDir,
|
|
2147
|
+
actoviqHomeDir: sdk.config.homeDir,
|
|
2148
|
+
}))
|
|
2149
|
+
.find(item => item.nativeSessionId === nativeSessionId && externalCliSessionMatchesConfig(item, {
|
|
2150
|
+
runtime: config.runtime,
|
|
2151
|
+
authSource: config.authSource,
|
|
2152
|
+
profileName: config.name,
|
|
2153
|
+
}, { actoviqHomeDir: sdk.config.homeDir }));
|
|
2154
|
+
if (!summary) {
|
|
2155
|
+
appendStatic([
|
|
2156
|
+
...formatErrorLine(`native ${config.runtime} session not found: ${nativeSessionId}`),
|
|
2157
|
+
'',
|
|
2158
|
+
]);
|
|
2159
|
+
return;
|
|
2160
|
+
}
|
|
2161
|
+
if (summary.cwd && !sameWorkspace(summary.cwd, sdk.config.workDir)) {
|
|
2162
|
+
appendStatic([
|
|
2163
|
+
...formatErrorLine(`open the session workspace before resuming it: ${externalCliDisplayText(summary.cwd, config)}`),
|
|
2164
|
+
'',
|
|
2165
|
+
]);
|
|
2166
|
+
return;
|
|
2167
|
+
}
|
|
2168
|
+
const runtimeKey = externalBridgeRuntimeKey(config);
|
|
2169
|
+
const existing = externalBridgeRuntimes.get(runtimeKey);
|
|
2170
|
+
if (existing) {
|
|
2171
|
+
await existing.client.close();
|
|
2172
|
+
externalBridgeRuntimes.delete(runtimeKey);
|
|
2173
|
+
}
|
|
2174
|
+
await rememberExternalNativeSession(config, summary.nativeSessionId);
|
|
2175
|
+
await persistSessionRuntimeMetadata(session, config, bridgeModelLabel);
|
|
2176
|
+
appendStatic([
|
|
2177
|
+
...formatInfoLine(`native ${config.runtime} session selected: ${summary.nativeSessionId}`),
|
|
2178
|
+
...formatInfoLine('The next message resumes that native conversation.'),
|
|
2179
|
+
'',
|
|
2180
|
+
]);
|
|
2181
|
+
}
|
|
2182
|
+
catch (error) {
|
|
2183
|
+
appendStatic([
|
|
2184
|
+
...formatErrorLine(`could not resume CLI history: ${externalCliDisplayText(error.message, config)}`),
|
|
2185
|
+
'',
|
|
2186
|
+
]);
|
|
2187
|
+
}
|
|
2188
|
+
}
|
|
2189
|
+
async function startExternalCliBackgroundRun(prompt) {
|
|
2190
|
+
const config = requireActiveExternalCliConfig('background');
|
|
2191
|
+
if (!config)
|
|
2192
|
+
return;
|
|
2193
|
+
const effort = currentEffort();
|
|
2194
|
+
const originSession = session;
|
|
2195
|
+
const originWorkDir = sdk.config.workDir;
|
|
2196
|
+
try {
|
|
2197
|
+
const run = await externalCliRuntimeManager.start({
|
|
2198
|
+
actoviqSessionId: originSession.id,
|
|
2199
|
+
configId: externalCliConfigId(config),
|
|
2200
|
+
cwd: originWorkDir,
|
|
2201
|
+
prompt,
|
|
2202
|
+
background: true,
|
|
2203
|
+
nativeSessionId: externalNativeSessionId(config, originSession, originWorkDir),
|
|
2204
|
+
clientOptions: {
|
|
2205
|
+
directCli: true,
|
|
2206
|
+
directCliProvider: config.runtime,
|
|
2207
|
+
workDir: sdk.config.workDir,
|
|
2208
|
+
authSource: config.authSource === 'apiKey' ? 'apiKey' : 'native',
|
|
2209
|
+
credentialProvider: config.credentialProvider,
|
|
2210
|
+
profileName: config.name,
|
|
2211
|
+
...(config.authSource === 'apiKey'
|
|
2212
|
+
? {
|
|
2213
|
+
apiKey: config.apiKey,
|
|
2214
|
+
baseURL: config.baseURL,
|
|
2215
|
+
}
|
|
2216
|
+
: {}),
|
|
2217
|
+
trustProjectResources: config.trustProjectResources,
|
|
2218
|
+
},
|
|
2219
|
+
sessionOptions: {
|
|
2220
|
+
title: `actoviq-tui-background-${config.runtime}-${config.name}`,
|
|
2221
|
+
},
|
|
2222
|
+
runOptions: {
|
|
2223
|
+
model: bridgeModelLabel ?? config.model,
|
|
2224
|
+
includePartialMessages: true,
|
|
2225
|
+
permissionMode: currentExternalCliPermissionMode(),
|
|
2226
|
+
...(effort && effort !== 'auto' ? { effort } : {}),
|
|
2227
|
+
},
|
|
2228
|
+
});
|
|
2229
|
+
externalCliRunLabels.set(run.runId, {
|
|
2230
|
+
configName: config.name,
|
|
2231
|
+
runtime: config.runtime,
|
|
2232
|
+
});
|
|
2233
|
+
appendStatic([
|
|
2234
|
+
...formatInfoLine(`background run queued · ${run.runId} · ${config.runtime} CLI`),
|
|
2235
|
+
...formatInfoLine('Use /bridge runs to inspect it or /bridge stop <runId> to interrupt it.'),
|
|
2236
|
+
'',
|
|
2237
|
+
]);
|
|
2238
|
+
void externalCliRuntimeManager.wait(run.runId).then(async (completed) => {
|
|
2239
|
+
if (!completed || shuttingDown)
|
|
2240
|
+
return;
|
|
2241
|
+
if (completed.status === 'completed' && completed.result) {
|
|
2242
|
+
const completedNativeSessionId = completed.nativeSessionId || completed.result.nativeSessionId;
|
|
2243
|
+
if (completedNativeSessionId) {
|
|
2244
|
+
await rememberExternalNativeSession(config, completedNativeSessionId, originSession, originWorkDir);
|
|
2245
|
+
}
|
|
2246
|
+
await originSession.appendMessages([
|
|
2247
|
+
{ role: 'user', content: prompt },
|
|
2248
|
+
{ role: 'assistant', content: completed.result.text },
|
|
2249
|
+
]);
|
|
2250
|
+
}
|
|
2251
|
+
const message = completed.status === 'completed'
|
|
2252
|
+
? `background run completed · ${completed.runId}`
|
|
2253
|
+
: `background run ${completed.status} · ${completed.runId}${completed.error?.message ? ` · ${externalCliPreview(completed.error.message, config)}` : ''}`;
|
|
2254
|
+
appendStatic([...formatInfoLine(message), '']);
|
|
2255
|
+
}).catch(() => undefined);
|
|
2256
|
+
}
|
|
2257
|
+
catch (error) {
|
|
2258
|
+
appendStatic([
|
|
2259
|
+
...formatErrorLine(`could not start background run: ${externalCliDisplayText(error.message, config)}`),
|
|
2260
|
+
'',
|
|
2261
|
+
]);
|
|
2262
|
+
}
|
|
2263
|
+
}
|
|
2264
|
+
function printExternalCliRuns() {
|
|
2265
|
+
const runs = externalCliRuntimeManager.list()
|
|
2266
|
+
.filter(run => run.actoviqSessionId === session.id)
|
|
2267
|
+
.sort((left, right) => right.createdAt.localeCompare(left.createdAt))
|
|
2268
|
+
.slice(0, 20);
|
|
2269
|
+
const lines = [
|
|
2270
|
+
`${A.bold}External CLI background runs${A.reset}`,
|
|
2271
|
+
...formatDivider(screen.width),
|
|
2272
|
+
];
|
|
2273
|
+
if (runs.length === 0) {
|
|
2274
|
+
lines.push(` ${A.dim}no background runs in this TUI session${A.reset}`);
|
|
2275
|
+
}
|
|
2276
|
+
else {
|
|
2277
|
+
for (const run of runs) {
|
|
2278
|
+
const label = externalCliRunLabels.get(run.runId);
|
|
2279
|
+
const runtime = label?.runtime ?? 'external';
|
|
2280
|
+
const configName = label?.configName ?? 'unknown config';
|
|
2281
|
+
const runConfig = label ? findBridgeConfig(label.configName) : undefined;
|
|
2282
|
+
lines.push(` ${A.bold}${run.runId}${A.reset} ${A.dim}· ${run.status} · ${runtime} · ${configName}${A.reset}`);
|
|
2283
|
+
if (run.nativeSessionId) {
|
|
2284
|
+
lines.push(` ${A.dim}native session: ${run.nativeSessionId}${A.reset}`);
|
|
2285
|
+
}
|
|
2286
|
+
const result = run.result?.text ? externalCliPreview(run.result.text, runConfig) : '';
|
|
2287
|
+
const error = run.error?.message ? externalCliPreview(run.error.message, runConfig) : '';
|
|
2288
|
+
if (result)
|
|
2289
|
+
lines.push(` ${result}`);
|
|
2290
|
+
else if (error)
|
|
2291
|
+
lines.push(` ${A.red}${error}${A.reset}`);
|
|
2292
|
+
}
|
|
2293
|
+
}
|
|
2294
|
+
lines.push('');
|
|
2295
|
+
appendStatic(lines);
|
|
2296
|
+
}
|
|
2297
|
+
function stopExternalCliRun(runId) {
|
|
2298
|
+
const run = externalCliRuntimeManager.get(runId);
|
|
2299
|
+
if (!run || run.actoviqSessionId !== session.id) {
|
|
2300
|
+
appendStatic([...formatErrorLine(`unknown external CLI run: ${runId}`), '']);
|
|
2301
|
+
return;
|
|
2302
|
+
}
|
|
2303
|
+
if (!externalCliRuntimeManager.abort(runId)) {
|
|
2304
|
+
appendStatic([...formatInfoLine(`run ${runId} is already ${run.status}`), '']);
|
|
2305
|
+
return;
|
|
2306
|
+
}
|
|
2307
|
+
appendStatic([...formatInfoLine(`stopping background run · ${runId}`), '']);
|
|
2308
|
+
}
|
|
1700
2309
|
async function runBridgePrompt(prompt) {
|
|
1701
2310
|
// /bridge run forces a bridge turn. If no config is active, open the board
|
|
1702
2311
|
// (or error if none saved) rather than auto-picking a detected runtime.
|
|
1703
|
-
if (!bridgeMode || !
|
|
2312
|
+
if (!bridgeMode || !activeBridgeConfig) {
|
|
1704
2313
|
const configs = readBridgeConfigs().configs;
|
|
1705
2314
|
if (configs.length === 0) {
|
|
1706
2315
|
appendStatic([...formatErrorLine('No bridge configs saved. Use /bridge config to add one.'), '']);
|
|
@@ -1714,9 +2323,8 @@ export async function runActoviqTui(options = {}) {
|
|
|
1714
2323
|
async function disableBridge() {
|
|
1715
2324
|
// Switch back to the SDK's default model/provider. The conversation
|
|
1716
2325
|
// context stays intact (same session). Config stays saved for re-activation.
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
activeBridgeModelApi = null;
|
|
2326
|
+
clearBridgeSelection();
|
|
2327
|
+
await persistSessionRuntimeMetadata();
|
|
1720
2328
|
appendStatic([
|
|
1721
2329
|
...formatInfoLine('bridge mode off — back to default provider (session intact)'),
|
|
1722
2330
|
'',
|
|
@@ -1728,16 +2336,21 @@ export async function runActoviqTui(options = {}) {
|
|
|
1728
2336
|
` ${A.dim}(bare)${A.reset} — list saved configs; pick one to activate`,
|
|
1729
2337
|
` ${A.dim}config${A.reset} — add / edit / remove named connection configs`,
|
|
1730
2338
|
` ${A.dim}run <prompt>${A.reset} — run one turn through the active runtime`,
|
|
2339
|
+
` ${A.dim}background <prompt>${A.reset} — start work in the active external CLI`,
|
|
2340
|
+
` ${A.dim}runs${A.reset} — list external CLI background runs`,
|
|
2341
|
+
` ${A.dim}stop <runId>${A.reset} — interrupt a background run`,
|
|
2342
|
+
` ${A.dim}status${A.reset} — show execution, runtime, auth source, and session`,
|
|
2343
|
+
` ${A.dim}history [native-id]${A.reset} — list or inspect native CLI conversations (paths hidden)`,
|
|
2344
|
+
` ${A.dim}resume <native-id>${A.reset} — resume a native CLI conversation in this workspace`,
|
|
1731
2345
|
` ${A.dim}switch <name>${A.reset} — activate a saved config by name (or a raw provider id)`,
|
|
1732
2346
|
` ${A.dim}model [id]${A.reset} — set model for the current runtime`,
|
|
1733
2347
|
` ${A.dim}setup${A.reset} — detect + configure paths (legacy)`,
|
|
1734
2348
|
` ${A.dim}off${A.reset} — disable bridge mode`,
|
|
1735
2349
|
` ${A.dim}help${A.reset} — show this list`,
|
|
1736
|
-
...formatInfoLine('
|
|
1737
|
-
...formatInfoLine('
|
|
1738
|
-
...formatInfoLine('
|
|
1739
|
-
...formatInfoLine('
|
|
1740
|
-
...formatInfoLine('retained across /bridge off; bridge turns also save to the hadamard session.'),
|
|
2350
|
+
...formatInfoLine('External CLI commands support every registered CLI runtime.'),
|
|
2351
|
+
...formatInfoLine('Native auth lets each CLI read its own login/config; key overrides are'),
|
|
2352
|
+
...formatInfoLine('injected into child processes and never printed in status or run output.'),
|
|
2353
|
+
...formatInfoLine('Direct API configs keep using the existing in-process bridge path.'),
|
|
1741
2354
|
'',
|
|
1742
2355
|
]);
|
|
1743
2356
|
}
|
|
@@ -1762,8 +2375,9 @@ export async function runActoviqTui(options = {}) {
|
|
|
1762
2375
|
for (const c of configs) {
|
|
1763
2376
|
const active = activeBridgeConfig?.name === c.name;
|
|
1764
2377
|
const mark = active ? `${A.green}●${A.reset}` : `${A.dim}○${A.reset}`;
|
|
1765
|
-
|
|
1766
|
-
lines.push(`
|
|
2378
|
+
const mode = c.execution === 'cli' ? 'External CLI' : (c.runtime === 'hadamard' ? 'Hadamard SDK' : 'Direct API');
|
|
2379
|
+
lines.push(` ${mark} ${A.bold}${c.name}${A.reset} ${A.dim}· ${mode} · ${c.runtime}${A.reset}${c.model ? ` ${A.dim}· ${c.model}${A.reset}` : ''}`);
|
|
2380
|
+
lines.push(` ${A.dim}${c.execution === 'cli' && c.authSource === 'native' ? 'auth: CLI login' : 'key: ' + maskApiKey(c.apiKey)}${c.baseURL ? ` · ${c.baseURL}` : ''}${A.reset}`);
|
|
1767
2381
|
}
|
|
1768
2382
|
}
|
|
1769
2383
|
lines.push('');
|
|
@@ -1777,7 +2391,7 @@ export async function runActoviqTui(options = {}) {
|
|
|
1777
2391
|
...configs.map(c => ({
|
|
1778
2392
|
id: `c:${c.name}`,
|
|
1779
2393
|
label: `${c.name}${activeBridgeConfig?.name === c.name ? ' *' : ''}`,
|
|
1780
|
-
description: `${c.
|
|
2394
|
+
description: `${c.execution === 'cli' ? 'External CLI' : 'Direct API'} · ${c.runtime}${c.execution === 'cli' ? ` · ${c.authSource === 'native' ? 'CLI login' : 'key override'}` : ''}${c.model ? ` · ${c.model}` : ''}`,
|
|
1781
2395
|
})),
|
|
1782
2396
|
{ id: 'config', label: '⚙ Manage configs…', description: 'add / edit / remove saved configs' },
|
|
1783
2397
|
{ id: 'run', label: '▶ Run a prompt…', description: 'run one turn through the active runtime' },
|
|
@@ -1834,6 +2448,77 @@ export async function runActoviqTui(options = {}) {
|
|
|
1834
2448
|
// session.stream (same session, context naturally survives switching).
|
|
1835
2449
|
async function activateBridgeConfig(config) {
|
|
1836
2450
|
try {
|
|
2451
|
+
if (config.execution === 'cli') {
|
|
2452
|
+
if (!isManagedExternalCliRuntime(config.runtime)) {
|
|
2453
|
+
throw new Error('External CLI mode requires an installed CLI runtime.');
|
|
2454
|
+
}
|
|
2455
|
+
const externalConfig = config;
|
|
2456
|
+
const fingerprint = externalBridgeFingerprint(externalConfig);
|
|
2457
|
+
const runtimeKey = externalBridgeRuntimeKey(externalConfig);
|
|
2458
|
+
let runtime = externalBridgeRuntimes.get(runtimeKey);
|
|
2459
|
+
if (runtime && runtime.fingerprint !== fingerprint) {
|
|
2460
|
+
await runtime.client.close();
|
|
2461
|
+
externalBridgeRuntimes.delete(runtimeKey);
|
|
2462
|
+
runtime = undefined;
|
|
2463
|
+
}
|
|
2464
|
+
const boundNativeSessionId = externalNativeSessionId(externalConfig);
|
|
2465
|
+
const resumed = Boolean(runtime || boundNativeSessionId);
|
|
2466
|
+
if (!runtime) {
|
|
2467
|
+
const client = await createActoviqBridgeSdk({
|
|
2468
|
+
directCli: true,
|
|
2469
|
+
directCliProvider: config.runtime,
|
|
2470
|
+
workDir: sdk.config.workDir,
|
|
2471
|
+
authSource: config.authSource === 'apiKey' ? 'apiKey' : 'native',
|
|
2472
|
+
credentialProvider: config.credentialProvider,
|
|
2473
|
+
profileName: config.name,
|
|
2474
|
+
...(config.authSource === 'apiKey'
|
|
2475
|
+
? {
|
|
2476
|
+
apiKey: config.apiKey,
|
|
2477
|
+
baseURL: config.baseURL,
|
|
2478
|
+
}
|
|
2479
|
+
: {}),
|
|
2480
|
+
trustProjectResources: config.trustProjectResources,
|
|
2481
|
+
});
|
|
2482
|
+
const sessionOptions = { title: 'actoviq-tui-' + config.runtime + '-' + config.name };
|
|
2483
|
+
const nativeSession = boundNativeSessionId
|
|
2484
|
+
? await client.resumeSession(boundNativeSessionId, sessionOptions)
|
|
2485
|
+
: await client.createSession(sessionOptions);
|
|
2486
|
+
runtime = { client, session: nativeSession, fingerprint };
|
|
2487
|
+
externalBridgeRuntimes.set(runtimeKey, runtime);
|
|
2488
|
+
}
|
|
2489
|
+
activeBridgeModelApi = null;
|
|
2490
|
+
bridgeModelLabel = config.model ?? null;
|
|
2491
|
+
activeBridgeConfig = config;
|
|
2492
|
+
bridgeMode = true;
|
|
2493
|
+
await persistSessionRuntimeMetadata(session, config, bridgeModelLabel);
|
|
2494
|
+
appendStatic([
|
|
2495
|
+
...formatInfoLine('runtime active — '
|
|
2496
|
+
+ config.runtime
|
|
2497
|
+
+ ' CLI · '
|
|
2498
|
+
+ (config.authSource === 'apiKey' ? 'API key override' : 'native CLI login')
|
|
2499
|
+
+ ' · model: '
|
|
2500
|
+
+ (config.model ?? 'runtime default')
|
|
2501
|
+
+ (resumed ? ' · resumed' : '')),
|
|
2502
|
+
...formatInfoLine('working directory: ' + sdk.config.workDir + ' · native session: ' + runtime.session.id),
|
|
2503
|
+
'',
|
|
2504
|
+
]);
|
|
2505
|
+
return true;
|
|
2506
|
+
}
|
|
2507
|
+
const hadamardUsesDefaults = config.runtime === 'hadamard'
|
|
2508
|
+
&& !config.apiKey?.trim()
|
|
2509
|
+
&& !config.baseURL?.trim();
|
|
2510
|
+
if (hadamardUsesDefaults) {
|
|
2511
|
+
activeBridgeModelApi = null;
|
|
2512
|
+
bridgeModelLabel = config.model ?? null;
|
|
2513
|
+
activeBridgeConfig = config;
|
|
2514
|
+
bridgeMode = false;
|
|
2515
|
+
await persistSessionRuntimeMetadata(session, config, bridgeModelLabel);
|
|
2516
|
+
appendStatic([
|
|
2517
|
+
...formatInfoLine('Hadamard SDK active · model: ' + (config.model ?? session.model)),
|
|
2518
|
+
'',
|
|
2519
|
+
]);
|
|
2520
|
+
return true;
|
|
2521
|
+
}
|
|
1837
2522
|
const routed = await buildRouteModelApi({
|
|
1838
2523
|
model: config.model || session.model,
|
|
1839
2524
|
provider: config.provider,
|
|
@@ -1845,6 +2530,7 @@ export async function runActoviqTui(options = {}) {
|
|
|
1845
2530
|
bridgeModelLabel = routed.model;
|
|
1846
2531
|
activeBridgeConfig = config;
|
|
1847
2532
|
bridgeMode = true;
|
|
2533
|
+
await persistSessionRuntimeMetadata(session, config, bridgeModelLabel);
|
|
1848
2534
|
appendStatic([
|
|
1849
2535
|
...formatInfoLine(`bridge active — config: ${config.name} · provider: ${config.provider} · model: ${routed.model}`),
|
|
1850
2536
|
...formatInfoLine(`apiKey: ${maskApiKey(config.apiKey)}${config.baseURL ? ` · baseURL: ${config.baseURL}` : ''}`),
|
|
@@ -1913,11 +2599,27 @@ export async function runActoviqTui(options = {}) {
|
|
|
1913
2599
|
const existing = store.configs.find(c => c.name === name);
|
|
1914
2600
|
const updated = await editBridgeConfig(existing);
|
|
1915
2601
|
if (updated) {
|
|
2602
|
+
const wasActive = activeBridgeConfig?.name === existing.name
|
|
2603
|
+
|| activeBridgeConfig?.name === updated.name;
|
|
2604
|
+
const previousRuntimeKey = wasActive
|
|
2605
|
+
&& activeBridgeConfig?.execution === 'cli'
|
|
2606
|
+
&& isManagedExternalCliRuntime(activeBridgeConfig.runtime)
|
|
2607
|
+
? externalBridgeRuntimeKey(activeBridgeConfig)
|
|
2608
|
+
: undefined;
|
|
1916
2609
|
addBridgeConfig(updated); // dedupe-by-name replaces
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
2610
|
+
if (wasActive) {
|
|
2611
|
+
if (await activateBridgeConfig(updated)) {
|
|
2612
|
+
const nextRuntimeKey = updated.execution === 'cli'
|
|
2613
|
+
&& isManagedExternalCliRuntime(updated.runtime)
|
|
2614
|
+
? externalBridgeRuntimeKey(updated)
|
|
2615
|
+
: undefined;
|
|
2616
|
+
if (previousRuntimeKey && previousRuntimeKey !== nextRuntimeKey) {
|
|
2617
|
+
const previousRuntime = externalBridgeRuntimes.get(previousRuntimeKey);
|
|
2618
|
+
await previousRuntime?.client.close().catch(() => undefined);
|
|
2619
|
+
externalBridgeRuntimes.delete(previousRuntimeKey);
|
|
2620
|
+
}
|
|
2621
|
+
appendStatic([...formatInfoLine(`active config "${updated.name}" updated and reactivated`), '']);
|
|
2622
|
+
}
|
|
1921
2623
|
}
|
|
1922
2624
|
else {
|
|
1923
2625
|
appendStatic([...formatInfoLine(`config "${updated.name}" saved`), '']);
|
|
@@ -1935,7 +2637,8 @@ export async function runActoviqTui(options = {}) {
|
|
|
1935
2637
|
continue;
|
|
1936
2638
|
removeBridgeConfig(name);
|
|
1937
2639
|
if (activeBridgeConfig?.name === name) {
|
|
1938
|
-
|
|
2640
|
+
await disableBridge();
|
|
2641
|
+
appendStatic([...formatInfoLine(`removed active config "${name}" and disabled bridge mode`), '']);
|
|
1939
2642
|
}
|
|
1940
2643
|
else {
|
|
1941
2644
|
appendStatic([...formatInfoLine(`removed config "${name}"`), '']);
|
|
@@ -1952,8 +2655,25 @@ export async function runActoviqTui(options = {}) {
|
|
|
1952
2655
|
async function editBridgeConfig(existing) {
|
|
1953
2656
|
// Work on a local copy so Cancel discards all edits.
|
|
1954
2657
|
const draft = existing
|
|
1955
|
-
? {
|
|
1956
|
-
|
|
2658
|
+
? {
|
|
2659
|
+
name: existing.name,
|
|
2660
|
+
provider: existing.provider,
|
|
2661
|
+
runtime: existing.runtime,
|
|
2662
|
+
execution: existing.execution ?? 'api',
|
|
2663
|
+
authSource: existing.authSource ?? 'apiKey',
|
|
2664
|
+
...(existing.apiKey ? { apiKey: existing.apiKey } : {}),
|
|
2665
|
+
...(existing.baseURL ? { baseURL: existing.baseURL } : {}),
|
|
2666
|
+
...(existing.model ? { model: existing.model } : {}),
|
|
2667
|
+
...(existing.credentialProvider ? { credentialProvider: existing.credentialProvider } : {}),
|
|
2668
|
+
...(existing.trustProjectResources ? { trustProjectResources: true } : {}),
|
|
2669
|
+
}
|
|
2670
|
+
: {
|
|
2671
|
+
name: '',
|
|
2672
|
+
provider: 'anthropic',
|
|
2673
|
+
runtime: 'claude',
|
|
2674
|
+
execution: 'cli',
|
|
2675
|
+
authSource: 'native',
|
|
2676
|
+
};
|
|
1957
2677
|
// Lazy-detect: runtimes are probed only when the user opens the runtime
|
|
1958
2678
|
// picker, so the form renders instantly. Cached after first probe.
|
|
1959
2679
|
let detections = null;
|
|
@@ -1964,9 +2684,13 @@ export async function runActoviqTui(options = {}) {
|
|
|
1964
2684
|
`${A.bold}${header}${A.reset} — edit any field, then Save`,
|
|
1965
2685
|
...formatDivider(screen.width),
|
|
1966
2686
|
` ${A.bold}name${A.reset} ${draft.name || `${A.dim}(unset)${A.reset}`}`,
|
|
1967
|
-
` ${A.bold}
|
|
2687
|
+
` ${A.bold}execution${A.reset} ${draft.execution === 'cli' ? 'External CLI' : (draft.runtime === 'hadamard' ? 'Hadamard SDK' : 'Direct API')}`,
|
|
2688
|
+
` ${A.bold}runtime${A.reset} ${A.bold}${draft.runtime}${A.reset} ${A.dim}(${draft.provider})${A.reset}`,
|
|
2689
|
+
` ${A.bold}auth${A.reset} ${draft.execution === 'cli' ? (draft.authSource === 'native' ? 'reuse CLI login' : 'API key override') : 'API adapter credentials'}`,
|
|
1968
2690
|
` ${A.bold}apiKey${A.reset} ${maskApiKey(draft.apiKey)}`,
|
|
1969
2691
|
` ${A.bold}baseURL${A.reset} ${draft.baseURL || `${A.dim}(inherit)${A.reset}`}`,
|
|
2692
|
+
` ${A.bold}key provider${A.reset} ${draft.credentialProvider || `${A.dim}(infer from model/runtime)${A.reset}`}`,
|
|
2693
|
+
` ${A.bold}project config${A.reset} ${draft.trustProjectResources ? 'trusted' : 'not trusted'}`,
|
|
1970
2694
|
` ${A.bold}model${A.reset} ${draft.model || `${A.dim}(inherit)${A.reset}`}`,
|
|
1971
2695
|
'',
|
|
1972
2696
|
];
|
|
@@ -1977,9 +2701,13 @@ export async function runActoviqTui(options = {}) {
|
|
|
1977
2701
|
searchable: false,
|
|
1978
2702
|
items: [
|
|
1979
2703
|
{ id: 'name', label: `name: ${draft.name || '(unset)'}`, description: 'a label you pick, e.g. deepseek-claude' },
|
|
1980
|
-
{ id: '
|
|
2704
|
+
{ id: 'execution', label: `execution: ${draft.execution === 'cli' ? 'External CLI' : 'Direct API'}`, description: 'launch an installed CLI or use Actoviq API adapters' },
|
|
2705
|
+
{ id: 'provider', label: `runtime: ${draft.runtime}`, description: `${draft.provider} · pick from detected runtimes` },
|
|
2706
|
+
{ id: 'auth', label: `auth: ${draft.authSource === 'native' ? 'reuse CLI login' : 'API key override'}`, description: draft.execution === 'cli' ? 'credential source for the child CLI' : 'used by External CLI mode' },
|
|
1981
2707
|
{ id: 'apiKey', label: `apiKey: ${maskApiKey(draft.apiKey)}`, description: 'injected as the credential each turn (hidden input)' },
|
|
1982
2708
|
{ id: 'baseURL', label: `baseURL: ${draft.baseURL || '(inherit)'}`, description: 'the backend endpoint (e.g. https://api.deepseek.com)' },
|
|
2709
|
+
{ id: 'credentialProvider', label: `key provider: ${draft.credentialProvider || '(infer)'}`, description: 'provider env mapping for multi-backend CLIs, e.g. openai, anthropic, deepseek' },
|
|
2710
|
+
{ id: 'trustProjectResources', label: `project config: ${draft.trustProjectResources ? 'trusted' : 'not trusted'}`, description: 'allow runtime-specific project config; required for explicit-key Crush when config exists' },
|
|
1983
2711
|
{ id: 'model', label: `model: ${draft.model || '(inherit)'}`, description: 'optional model id' },
|
|
1984
2712
|
{ id: 'save', label: '💾 Save config', description: draft.name ? `commit "${draft.name}"` : 'a name is required to save' },
|
|
1985
2713
|
{ id: 'cancel', label: '✕ Cancel', description: 'discard changes' },
|
|
@@ -1993,19 +2721,37 @@ export async function runActoviqTui(options = {}) {
|
|
|
1993
2721
|
appendStatic([...formatErrorLine('cannot save — name is required (edit the name field first)'), '']);
|
|
1994
2722
|
continue;
|
|
1995
2723
|
}
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2724
|
+
if (draft.execution === 'cli' && !isManagedExternalCliRuntime(draft.runtime)) {
|
|
2725
|
+
appendStatic([
|
|
2726
|
+
...formatErrorLine('External CLI mode requires a registered CLI runtime.'),
|
|
2727
|
+
'',
|
|
2728
|
+
]);
|
|
2729
|
+
continue;
|
|
2730
|
+
}
|
|
2731
|
+
if (draft.execution === 'cli' && draft.authSource === 'apiKey' && !draft.apiKey) {
|
|
2732
|
+
appendStatic([
|
|
2733
|
+
...formatErrorLine('API-key override requires an API key.'),
|
|
2734
|
+
'',
|
|
2735
|
+
]);
|
|
2736
|
+
continue;
|
|
2737
|
+
}
|
|
2738
|
+
const config = {
|
|
2739
|
+
name,
|
|
2740
|
+
provider: draft.provider,
|
|
2741
|
+
runtime: draft.runtime,
|
|
2742
|
+
execution: draft.execution,
|
|
2743
|
+
authSource: draft.authSource,
|
|
2744
|
+
};
|
|
2003
2745
|
if (draft.apiKey)
|
|
2004
2746
|
config.apiKey = draft.apiKey;
|
|
2005
2747
|
if (draft.baseURL)
|
|
2006
2748
|
config.baseURL = draft.baseURL;
|
|
2007
2749
|
if (draft.model)
|
|
2008
2750
|
config.model = draft.model;
|
|
2751
|
+
if (draft.credentialProvider)
|
|
2752
|
+
config.credentialProvider = draft.credentialProvider;
|
|
2753
|
+
if (draft.trustProjectResources)
|
|
2754
|
+
config.trustProjectResources = true;
|
|
2009
2755
|
return config;
|
|
2010
2756
|
}
|
|
2011
2757
|
if (choice === 'name') {
|
|
@@ -2014,6 +2760,55 @@ export async function runActoviqTui(options = {}) {
|
|
|
2014
2760
|
draft.name = v;
|
|
2015
2761
|
continue;
|
|
2016
2762
|
}
|
|
2763
|
+
if (choice === 'execution') {
|
|
2764
|
+
const v = await selectItem({
|
|
2765
|
+
title: 'Execution mode',
|
|
2766
|
+
subtitle: 'API mode stays in Actoviq; CLI mode launches the installed runtime',
|
|
2767
|
+
searchable: false,
|
|
2768
|
+
items: [
|
|
2769
|
+
{ id: 'cli', label: 'External CLI', description: 'Managed CLI child process with native session resume' },
|
|
2770
|
+
{ id: 'api', label: 'Direct API', description: 'Actoviq provider adapter; no external CLI process' },
|
|
2771
|
+
],
|
|
2772
|
+
});
|
|
2773
|
+
if (v === 'cli') {
|
|
2774
|
+
if (!isManagedExternalCliRuntime(draft.runtime)) {
|
|
2775
|
+
appendStatic([
|
|
2776
|
+
...formatErrorLine('External CLI mode requires a registered CLI runtime.'),
|
|
2777
|
+
'',
|
|
2778
|
+
]);
|
|
2779
|
+
}
|
|
2780
|
+
else {
|
|
2781
|
+
draft.execution = 'cli';
|
|
2782
|
+
draft.authSource = draft.authSource ?? 'native';
|
|
2783
|
+
}
|
|
2784
|
+
}
|
|
2785
|
+
else if (v === 'api') {
|
|
2786
|
+
draft.execution = 'api';
|
|
2787
|
+
draft.authSource = 'apiKey';
|
|
2788
|
+
}
|
|
2789
|
+
continue;
|
|
2790
|
+
}
|
|
2791
|
+
if (choice === 'auth') {
|
|
2792
|
+
if (draft.execution !== 'cli') {
|
|
2793
|
+
appendStatic([
|
|
2794
|
+
...formatInfoLine('Authentication source applies to External CLI mode.'),
|
|
2795
|
+
'',
|
|
2796
|
+
]);
|
|
2797
|
+
continue;
|
|
2798
|
+
}
|
|
2799
|
+
const v = await selectItem({
|
|
2800
|
+
title: 'CLI authentication',
|
|
2801
|
+
subtitle: 'Native login never copies credentials into Actoviq',
|
|
2802
|
+
searchable: false,
|
|
2803
|
+
items: [
|
|
2804
|
+
{ id: 'native', label: 'Reuse CLI login / config', description: 'inherit HOME and let the CLI read its own credentials' },
|
|
2805
|
+
{ id: 'apiKey', label: 'API key override', description: 'inject this config key into the child process only' },
|
|
2806
|
+
],
|
|
2807
|
+
});
|
|
2808
|
+
if (v === 'native' || v === 'apiKey')
|
|
2809
|
+
draft.authSource = v;
|
|
2810
|
+
continue;
|
|
2811
|
+
}
|
|
2017
2812
|
if (choice === 'provider') {
|
|
2018
2813
|
// Show detected runtimes as the primary options; each maps to an
|
|
2019
2814
|
// in-process provider. Detection is lazy — probed only when the user
|
|
@@ -2024,13 +2819,13 @@ export async function runActoviqTui(options = {}) {
|
|
|
2024
2819
|
const RUNTIME_MAP = {
|
|
2025
2820
|
claude: { provider: 'anthropic', label: 'claude' },
|
|
2026
2821
|
codewhale: { provider: 'anthropic', label: 'codewhale' },
|
|
2027
|
-
reasonix: { provider: '
|
|
2822
|
+
reasonix: { provider: 'openai', label: 'reasonix' },
|
|
2028
2823
|
pi: { provider: 'openai', label: 'pi' },
|
|
2029
2824
|
codex: { provider: 'openai', label: 'codex' },
|
|
2030
2825
|
crush: { provider: 'openai', label: 'crush' },
|
|
2031
2826
|
};
|
|
2032
2827
|
const curProvider = draft.provider;
|
|
2033
|
-
const curRuntime =
|
|
2828
|
+
const curRuntime = draft.runtime;
|
|
2034
2829
|
const items = detections.map(d => ({
|
|
2035
2830
|
id: d.id,
|
|
2036
2831
|
label: `${d.id}${d.id === curRuntime ? ' ✓' : ''}`,
|
|
@@ -2045,6 +2840,7 @@ export async function runActoviqTui(options = {}) {
|
|
|
2045
2840
|
if (v) {
|
|
2046
2841
|
const mapped = RUNTIME_MAP[v] ?? { provider: 'anthropic' };
|
|
2047
2842
|
draft.provider = mapped.provider;
|
|
2843
|
+
draft.runtime = v;
|
|
2048
2844
|
}
|
|
2049
2845
|
continue;
|
|
2050
2846
|
}
|
|
@@ -2067,6 +2863,31 @@ export async function runActoviqTui(options = {}) {
|
|
|
2067
2863
|
draft.baseURL = v || undefined;
|
|
2068
2864
|
continue;
|
|
2069
2865
|
}
|
|
2866
|
+
if (choice === 'credentialProvider') {
|
|
2867
|
+
const v = (await promptText({
|
|
2868
|
+
title: 'Credential provider',
|
|
2869
|
+
label: 'provider id',
|
|
2870
|
+
initial: draft.credentialProvider,
|
|
2871
|
+
description: 'openai, anthropic, deepseek, gemini, openrouter, etc.; leave empty to infer',
|
|
2872
|
+
}))?.trim();
|
|
2873
|
+
if (v !== undefined)
|
|
2874
|
+
draft.credentialProvider = v || undefined;
|
|
2875
|
+
continue;
|
|
2876
|
+
}
|
|
2877
|
+
if (choice === 'trustProjectResources') {
|
|
2878
|
+
const v = await selectItem({
|
|
2879
|
+
title: 'Project runtime config',
|
|
2880
|
+
subtitle: 'Project-local runtime files may change provider/tool behavior',
|
|
2881
|
+
searchable: false,
|
|
2882
|
+
items: [
|
|
2883
|
+
{ id: 'no', label: 'Do not trust', description: 'use runtime defaults and managed credentials where supported' },
|
|
2884
|
+
{ id: 'yes', label: 'Trust project config', description: 'allow project-local CLI resources and configuration' },
|
|
2885
|
+
],
|
|
2886
|
+
});
|
|
2887
|
+
if (v === 'yes' || v === 'no')
|
|
2888
|
+
draft.trustProjectResources = v === 'yes';
|
|
2889
|
+
continue;
|
|
2890
|
+
}
|
|
2070
2891
|
if (choice === 'model') {
|
|
2071
2892
|
const v = (await promptText({
|
|
2072
2893
|
title: 'Model',
|
|
@@ -2097,6 +2918,9 @@ export async function runActoviqTui(options = {}) {
|
|
|
2097
2918
|
if (modelId) {
|
|
2098
2919
|
// Direct set: /bridge model claude-sonnet-4-6
|
|
2099
2920
|
bridgeModelLabel = modelId;
|
|
2921
|
+
if (activeBridgeConfig)
|
|
2922
|
+
activeBridgeConfig = { ...activeBridgeConfig, model: modelId };
|
|
2923
|
+
await persistSessionRuntimeMetadata();
|
|
2100
2924
|
appendStatic([...formatInfoLine(`bridge model → ${modelId}`), '']);
|
|
2101
2925
|
return;
|
|
2102
2926
|
}
|
|
@@ -2109,6 +2933,13 @@ export async function runActoviqTui(options = {}) {
|
|
|
2109
2933
|
}));
|
|
2110
2934
|
if (v !== undefined) {
|
|
2111
2935
|
bridgeModelLabel = v.trim() || null;
|
|
2936
|
+
if (activeBridgeConfig) {
|
|
2937
|
+
activeBridgeConfig = {
|
|
2938
|
+
...activeBridgeConfig,
|
|
2939
|
+
...(bridgeModelLabel ? { model: bridgeModelLabel } : { model: undefined }),
|
|
2940
|
+
};
|
|
2941
|
+
}
|
|
2942
|
+
await persistSessionRuntimeMetadata();
|
|
2112
2943
|
appendStatic([...formatInfoLine(`bridge model → ${bridgeModelLabel || 'session default'}`), '']);
|
|
2113
2944
|
}
|
|
2114
2945
|
}
|
|
@@ -2240,6 +3071,139 @@ export async function runActoviqTui(options = {}) {
|
|
|
2240
3071
|
]);
|
|
2241
3072
|
}
|
|
2242
3073
|
}
|
|
3074
|
+
function flattenAgentExecutionNodes(view) {
|
|
3075
|
+
const nodes = [];
|
|
3076
|
+
const visit = (node) => {
|
|
3077
|
+
nodes.push(node);
|
|
3078
|
+
node.children.forEach(visit);
|
|
3079
|
+
};
|
|
3080
|
+
if (view.root)
|
|
3081
|
+
visit(view.root);
|
|
3082
|
+
view.detached.forEach(visit);
|
|
3083
|
+
return nodes;
|
|
3084
|
+
}
|
|
3085
|
+
function formatAgentExecutionElapsed(elapsedMs) {
|
|
3086
|
+
if (elapsedMs < 1_000)
|
|
3087
|
+
return `${elapsedMs}ms`;
|
|
3088
|
+
if (elapsedMs < 60_000)
|
|
3089
|
+
return `${Math.round(elapsedMs / 100) / 10}s`;
|
|
3090
|
+
return `${Math.floor(elapsedMs / 60_000)}m ${Math.round((elapsedMs % 60_000) / 1_000)}s`;
|
|
3091
|
+
}
|
|
3092
|
+
async function openAgentExecutionConversation(reference) {
|
|
3093
|
+
let snapshots;
|
|
3094
|
+
try {
|
|
3095
|
+
snapshots = await sdk.executions.listSnapshots();
|
|
3096
|
+
}
|
|
3097
|
+
catch (error) {
|
|
3098
|
+
appendStatic([...formatErrorLine(`could not load Agent executions: ${error.message}`), '']);
|
|
3099
|
+
return;
|
|
3100
|
+
}
|
|
3101
|
+
const views = snapshots.map(snapshot => createAgentExecutionRootView(snapshot));
|
|
3102
|
+
const node = views.flatMap(flattenAgentExecutionNodes).find(item => item.id === reference || item.sessionId === reference);
|
|
3103
|
+
if (!node) {
|
|
3104
|
+
appendStatic([
|
|
3105
|
+
...formatErrorLine(`No Agent execution or conversation matches '${reference}'. Use /agents runs to browse.`),
|
|
3106
|
+
'',
|
|
3107
|
+
]);
|
|
3108
|
+
return;
|
|
3109
|
+
}
|
|
3110
|
+
await resumeSession(node.sessionId, { allowAgent: true });
|
|
3111
|
+
}
|
|
3112
|
+
async function showAgentExecution(rootExecutionId) {
|
|
3113
|
+
let snapshot;
|
|
3114
|
+
try {
|
|
3115
|
+
snapshot = await sdk.executions.getSnapshot(rootExecutionId);
|
|
3116
|
+
}
|
|
3117
|
+
catch (error) {
|
|
3118
|
+
appendStatic([...formatErrorLine(`could not load Agent execution: ${error.message}`), '']);
|
|
3119
|
+
return;
|
|
3120
|
+
}
|
|
3121
|
+
if (!snapshot) {
|
|
3122
|
+
appendStatic([
|
|
3123
|
+
...formatErrorLine(`No Agent execution tree found for '${rootExecutionId}'. Use /agents runs to browse.`),
|
|
3124
|
+
'',
|
|
3125
|
+
]);
|
|
3126
|
+
return;
|
|
3127
|
+
}
|
|
3128
|
+
const view = createAgentExecutionRootView(snapshot);
|
|
3129
|
+
const nodes = flattenAgentExecutionNodes(view);
|
|
3130
|
+
appendStatic([
|
|
3131
|
+
`${A.bold}Agent execution${A.reset} ${A.dim}${view.rootExecutionId}${A.reset}`,
|
|
3132
|
+
`${A.dim}${view.status} · ${view.nodeCount} agents · ${view.edgeCount} links · ${formatAgentExecutionElapsed(view.timing.elapsedMs)}${A.reset}`,
|
|
3133
|
+
...formatAgentExecutionTreeLines(view, {
|
|
3134
|
+
prefix: ' ',
|
|
3135
|
+
includeActivity: true,
|
|
3136
|
+
includePlan: true,
|
|
3137
|
+
includeTiming: true,
|
|
3138
|
+
maxMetaWidth: Math.max(36, screen.width - 12),
|
|
3139
|
+
}),
|
|
3140
|
+
'',
|
|
3141
|
+
]);
|
|
3142
|
+
if (nodes.length === 0)
|
|
3143
|
+
return;
|
|
3144
|
+
const selected = await selectItem({
|
|
3145
|
+
title: 'Agent execution conversations',
|
|
3146
|
+
subtitle: 'Choose an Agent or subagent to open its independent conversation',
|
|
3147
|
+
items: nodes.map(node => ({
|
|
3148
|
+
id: node.id,
|
|
3149
|
+
label: `${' '.repeat(node.depth)}${node.displayName}`,
|
|
3150
|
+
description: `${node.status} · ${node.runtime}${node.model ? ` · ${node.model}` : ''}`,
|
|
3151
|
+
detail: [
|
|
3152
|
+
`session: ${node.sessionId}`,
|
|
3153
|
+
node.currentActivity?.summary,
|
|
3154
|
+
node.currentStep ? `current: ${node.currentStep.title}` : undefined,
|
|
3155
|
+
node.nextSteps.length ? `next: ${node.nextSteps.slice(0, 3).map(step => step.title).join(', ')}` : undefined,
|
|
3156
|
+
].filter((value) => Boolean(value)).join('\n'),
|
|
3157
|
+
})),
|
|
3158
|
+
});
|
|
3159
|
+
if (selected)
|
|
3160
|
+
await openAgentExecutionConversation(selected);
|
|
3161
|
+
}
|
|
3162
|
+
async function showAgentRuns() {
|
|
3163
|
+
let snapshots;
|
|
3164
|
+
try {
|
|
3165
|
+
snapshots = await sdk.executions.listSnapshots();
|
|
3166
|
+
}
|
|
3167
|
+
catch (error) {
|
|
3168
|
+
appendStatic([...formatErrorLine(`could not load Agent executions: ${error.message}`), '']);
|
|
3169
|
+
return;
|
|
3170
|
+
}
|
|
3171
|
+
const project = createAgentExecutionProjectView(snapshots);
|
|
3172
|
+
if (project.totalExecutionCount === 0) {
|
|
3173
|
+
appendStatic([...formatInfoLine('no Agent executions are recorded for this project'), '']);
|
|
3174
|
+
return;
|
|
3175
|
+
}
|
|
3176
|
+
const summary = (label, executions) => [
|
|
3177
|
+
`${A.bold}${label}${A.reset} ${A.dim}(${executions.length})${A.reset}`,
|
|
3178
|
+
...executions.map(execution => ` ${execution.status === 'errored' ? A.red : execution.isActive ? A.green : A.dim}${execution.rootExecutionId}${A.reset} ${execution.displayName} · ${execution.nodeCount} agents · ${formatAgentExecutionElapsed(execution.timing.elapsedMs)}`),
|
|
3179
|
+
];
|
|
3180
|
+
appendStatic([
|
|
3181
|
+
`${A.bold}Agent executions${A.reset} ${A.dim}${project.totalAgentCount} agent conversations${A.reset}`,
|
|
3182
|
+
...summary('Active', project.active),
|
|
3183
|
+
...summary('Completed', project.completed),
|
|
3184
|
+
'',
|
|
3185
|
+
]);
|
|
3186
|
+
const selected = await selectItem({
|
|
3187
|
+
title: 'Agent execution runs',
|
|
3188
|
+
subtitle: `${project.activeExecutionCount} active · ${project.completedExecutionCount} completed`,
|
|
3189
|
+
items: [
|
|
3190
|
+
...project.active.map(execution => ({
|
|
3191
|
+
id: execution.rootExecutionId,
|
|
3192
|
+
label: `Active · ${execution.displayName}`,
|
|
3193
|
+
description: `${execution.status} · ${execution.nodeCount} agents · ${execution.currentActivity?.summary ?? 'waiting'}`,
|
|
3194
|
+
detail: execution.rootExecutionId,
|
|
3195
|
+
})),
|
|
3196
|
+
...project.completed.map(execution => ({
|
|
3197
|
+
id: execution.rootExecutionId,
|
|
3198
|
+
label: `Completed · ${execution.displayName}`,
|
|
3199
|
+
description: `${execution.status} · ${execution.nodeCount} agents · ${formatAgentExecutionElapsed(execution.timing.elapsedMs)}`,
|
|
3200
|
+
detail: execution.rootExecutionId,
|
|
3201
|
+
})),
|
|
3202
|
+
],
|
|
3203
|
+
});
|
|
3204
|
+
if (selected)
|
|
3205
|
+
await showAgentExecution(selected);
|
|
3206
|
+
}
|
|
2243
3207
|
async function showMcp() {
|
|
2244
3208
|
const byServer = new Map();
|
|
2245
3209
|
for (const tool of toolMetadata.filter(item => item.provider === 'mcp')) {
|
|
@@ -2348,6 +3312,7 @@ export async function runActoviqTui(options = {}) {
|
|
|
2348
3312
|
}
|
|
2349
3313
|
async function showPlugins() {
|
|
2350
3314
|
const store = await resolveActoviqSettingsStore({ configPath: options.configPath });
|
|
3315
|
+
const managed = readManagedPluginCatalog(store.raw).plugins;
|
|
2351
3316
|
const configuredDirs = Array.isArray(store.raw.pluginDirs)
|
|
2352
3317
|
? store.raw.pluginDirs.filter((value) => typeof value === 'string')
|
|
2353
3318
|
: [];
|
|
@@ -2356,23 +3321,71 @@ export async function runActoviqTui(options = {}) {
|
|
|
2356
3321
|
homeDir: store.homeDir,
|
|
2357
3322
|
configuredDirs,
|
|
2358
3323
|
});
|
|
2359
|
-
if (plugins.length === 0) {
|
|
2360
|
-
appendStatic([
|
|
2361
|
-
...formatInfoLine('no Clean plugins discovered in user, project, or configured plugin directories'),
|
|
2362
|
-
'',
|
|
2363
|
-
]);
|
|
2364
|
-
return;
|
|
2365
|
-
}
|
|
2366
3324
|
const selected = await selectItem({
|
|
2367
|
-
title: '
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
3325
|
+
title: 'Plugins',
|
|
3326
|
+
subtitle: 'Built-in managed integrations and local plugin manifests',
|
|
3327
|
+
items: [
|
|
3328
|
+
...managed.map(plugin => ({
|
|
3329
|
+
id: `managed:${plugin.id}`,
|
|
3330
|
+
label: plugin.name,
|
|
3331
|
+
description: `${plugin.state} · ${plugin.description}`,
|
|
3332
|
+
detail: plugin.statusDetail ?? plugin.category,
|
|
3333
|
+
})),
|
|
3334
|
+
...plugins.map(plugin => ({
|
|
3335
|
+
id: `local:${plugin.path}`,
|
|
3336
|
+
label: plugin.name,
|
|
3337
|
+
description: [plugin.version, plugin.capabilities.join(', ')].filter(Boolean).join(' · '),
|
|
3338
|
+
detail: `${plugin.description ?? ''} ${plugin.path}`,
|
|
3339
|
+
})),
|
|
3340
|
+
],
|
|
2374
3341
|
});
|
|
2375
|
-
|
|
3342
|
+
if (selected?.startsWith('managed:')) {
|
|
3343
|
+
const id = selected.slice('managed:'.length);
|
|
3344
|
+
const plugin = managed.find(item => item.id === id);
|
|
3345
|
+
if (!plugin)
|
|
3346
|
+
return;
|
|
3347
|
+
const action = await selectItem({
|
|
3348
|
+
title: plugin.name,
|
|
3349
|
+
subtitle: plugin.description,
|
|
3350
|
+
searchable: false,
|
|
3351
|
+
items: [
|
|
3352
|
+
{
|
|
3353
|
+
id: 'toggle',
|
|
3354
|
+
label: plugin.state === 'available' ? 'Install' : plugin.enabled ? 'Disable' : 'Enable',
|
|
3355
|
+
description: `Current state: ${plugin.state}`,
|
|
3356
|
+
},
|
|
3357
|
+
{
|
|
3358
|
+
id: 'details',
|
|
3359
|
+
label: 'Show configuration status',
|
|
3360
|
+
description: plugin.secretConfigured ? 'Credential configured' : 'No plugin credential stored',
|
|
3361
|
+
},
|
|
3362
|
+
],
|
|
3363
|
+
});
|
|
3364
|
+
if (action === 'toggle') {
|
|
3365
|
+
const raw = structuredClone(store.raw);
|
|
3366
|
+
const enabling = plugin.state === 'available' || !plugin.enabled;
|
|
3367
|
+
patchManagedPluginSettings(raw, plugin.id, { enabled: enabling });
|
|
3368
|
+
await persistActoviqSettingsStore(store.configPath, raw);
|
|
3369
|
+
await loadJsonConfigFile(store.configPath);
|
|
3370
|
+
await withSpinner('reloading managed plugins', reloadCleanSdk);
|
|
3371
|
+
appendStatic([
|
|
3372
|
+
...formatInfoLine(`${plugin.name} ${enabling ? 'enabled' : 'disabled'}`),
|
|
3373
|
+
'',
|
|
3374
|
+
]);
|
|
3375
|
+
}
|
|
3376
|
+
else if (action === 'details') {
|
|
3377
|
+
appendStatic([
|
|
3378
|
+
`${A.cyan}${plugin.name}${A.reset}`,
|
|
3379
|
+
`${A.dim}${plugin.description}${A.reset}`,
|
|
3380
|
+
`${A.dim}state: ${plugin.state} · credential: ${plugin.secretConfigured ? 'configured' : 'not configured'}${A.reset}`,
|
|
3381
|
+
...formatInfoLine('Use GUI Customize for provider URLs, API keys, browser profiles, and health checks.'),
|
|
3382
|
+
'',
|
|
3383
|
+
]);
|
|
3384
|
+
}
|
|
3385
|
+
return;
|
|
3386
|
+
}
|
|
3387
|
+
const localPath = selected?.startsWith('local:') ? selected.slice('local:'.length) : '';
|
|
3388
|
+
const plugin = plugins.find(item => item.path === localPath);
|
|
2376
3389
|
if (plugin) {
|
|
2377
3390
|
appendStatic([
|
|
2378
3391
|
`${A.cyan}${plugin.name}${A.reset}${plugin.version ? ` ${plugin.version}` : ''}`,
|
|
@@ -2580,12 +3593,13 @@ export async function runActoviqTui(options = {}) {
|
|
|
2580
3593
|
// Switch the active session.
|
|
2581
3594
|
const prevSession = session;
|
|
2582
3595
|
session = nextSession;
|
|
3596
|
+
await restoreSessionRuntimeSelection();
|
|
2583
3597
|
await prevSession.delete().catch(() => undefined);
|
|
2584
3598
|
appendStatic([...formatInfoLine(`rewound ${n} message${n === 1 ? '' : 's'} (session ${session.id}), files unchanged`), '']);
|
|
2585
3599
|
return;
|
|
2586
3600
|
}
|
|
2587
3601
|
case 'sessions': {
|
|
2588
|
-
const sessions = (await sdk.sessions.list()).filter(
|
|
3602
|
+
const sessions = (await sdk.sessions.list()).filter(isTuiChatSession);
|
|
2589
3603
|
appendStatic([
|
|
2590
3604
|
...(sessions.length > 0
|
|
2591
3605
|
? sessions.map(item => `${item.id === session.id ? A.green : A.dim}${item.id}${A.reset} ${item.title} · ${item.model} · ${item.status}`)
|
|
@@ -2876,9 +3890,49 @@ export async function runActoviqTui(options = {}) {
|
|
|
2876
3890
|
case 'skills':
|
|
2877
3891
|
await showSkills();
|
|
2878
3892
|
return;
|
|
2879
|
-
case 'agents':
|
|
2880
|
-
|
|
3893
|
+
case 'agents': {
|
|
3894
|
+
const trimmedArgs = args.trim();
|
|
3895
|
+
const subcommandEnd = trimmedArgs.search(/\s/);
|
|
3896
|
+
const subcommand = (subcommandEnd < 0 ? trimmedArgs : trimmedArgs.slice(0, subcommandEnd))
|
|
3897
|
+
.toLowerCase() || 'list';
|
|
3898
|
+
const target = subcommandEnd < 0 ? '' : trimmedArgs.slice(subcommandEnd + 1).trim();
|
|
3899
|
+
if (subcommand === 'list') {
|
|
3900
|
+
if (target) {
|
|
3901
|
+
appendStatic([...formatErrorLine('usage: /agents [list|runs|show <root-execution-id>|open <session-or-execution-id>]'), '']);
|
|
3902
|
+
}
|
|
3903
|
+
else {
|
|
3904
|
+
await showAgents();
|
|
3905
|
+
}
|
|
3906
|
+
return;
|
|
3907
|
+
}
|
|
3908
|
+
if (subcommand === 'runs') {
|
|
3909
|
+
if (target)
|
|
3910
|
+
await showAgentExecution(target);
|
|
3911
|
+
else
|
|
3912
|
+
await showAgentRuns();
|
|
3913
|
+
return;
|
|
3914
|
+
}
|
|
3915
|
+
if (subcommand === 'show') {
|
|
3916
|
+
if (!target) {
|
|
3917
|
+
appendStatic([...formatErrorLine('usage: /agents show <root-execution-id>'), '']);
|
|
3918
|
+
}
|
|
3919
|
+
else {
|
|
3920
|
+
await showAgentExecution(target);
|
|
3921
|
+
}
|
|
3922
|
+
return;
|
|
3923
|
+
}
|
|
3924
|
+
if (subcommand === 'open') {
|
|
3925
|
+
if (!target) {
|
|
3926
|
+
appendStatic([...formatErrorLine('usage: /agents open <session-or-execution-id>'), '']);
|
|
3927
|
+
}
|
|
3928
|
+
else {
|
|
3929
|
+
await openAgentExecutionConversation(target);
|
|
3930
|
+
}
|
|
3931
|
+
return;
|
|
3932
|
+
}
|
|
3933
|
+
appendStatic([...formatErrorLine('usage: /agents [list|runs|show <root-execution-id>|open <session-or-execution-id>]'), '']);
|
|
2881
3934
|
return;
|
|
3935
|
+
}
|
|
2882
3936
|
case 'mcp':
|
|
2883
3937
|
await showMcp();
|
|
2884
3938
|
return;
|
|
@@ -3069,6 +4123,46 @@ export async function runActoviqTui(options = {}) {
|
|
|
3069
4123
|
await runBridgePrompt(bp);
|
|
3070
4124
|
return;
|
|
3071
4125
|
}
|
|
4126
|
+
if (args === 'background' || args.startsWith('background ')) {
|
|
4127
|
+
const prompt = args.startsWith('background ') ? args.slice(11).trim() : '';
|
|
4128
|
+
if (!prompt) {
|
|
4129
|
+
appendStatic([...formatErrorLine('usage: /bridge background <prompt>'), '']);
|
|
4130
|
+
return;
|
|
4131
|
+
}
|
|
4132
|
+
await startExternalCliBackgroundRun(prompt);
|
|
4133
|
+
return;
|
|
4134
|
+
}
|
|
4135
|
+
if (args === 'runs') {
|
|
4136
|
+
printExternalCliRuns();
|
|
4137
|
+
return;
|
|
4138
|
+
}
|
|
4139
|
+
if (args === 'stop' || args.startsWith('stop ')) {
|
|
4140
|
+
const runId = args.startsWith('stop ') ? args.slice(5).trim() : '';
|
|
4141
|
+
if (!runId) {
|
|
4142
|
+
appendStatic([...formatErrorLine('usage: /bridge stop <runId>'), '']);
|
|
4143
|
+
return;
|
|
4144
|
+
}
|
|
4145
|
+
stopExternalCliRun(runId);
|
|
4146
|
+
return;
|
|
4147
|
+
}
|
|
4148
|
+
if (args === 'status') {
|
|
4149
|
+
printBridgeStatus();
|
|
4150
|
+
return;
|
|
4151
|
+
}
|
|
4152
|
+
if (args === 'history' || args.startsWith('history ')) {
|
|
4153
|
+
const nativeSessionId = args.startsWith('history ') ? args.slice(8).trim() : '';
|
|
4154
|
+
await printExternalCliHistory(nativeSessionId);
|
|
4155
|
+
return;
|
|
4156
|
+
}
|
|
4157
|
+
if (args === 'resume' || args.startsWith('resume ')) {
|
|
4158
|
+
const nativeSessionId = args.startsWith('resume ') ? args.slice(7).trim() : '';
|
|
4159
|
+
if (!nativeSessionId) {
|
|
4160
|
+
appendStatic([...formatErrorLine('usage: /bridge resume <native-id>'), '']);
|
|
4161
|
+
return;
|
|
4162
|
+
}
|
|
4163
|
+
await resumeExternalCliHistorySession(nativeSessionId);
|
|
4164
|
+
return;
|
|
4165
|
+
}
|
|
3072
4166
|
if (args === 'switch' || args.startsWith('switch ')) {
|
|
3073
4167
|
const target = args.startsWith('switch ') ? args.slice(7).trim() : '';
|
|
3074
4168
|
await switchBridgeProvider(target);
|
|
@@ -3532,13 +4626,16 @@ export async function runActoviqTui(options = {}) {
|
|
|
3532
4626
|
renderDynamic();
|
|
3533
4627
|
return;
|
|
3534
4628
|
}
|
|
3535
|
-
const
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
4629
|
+
const selectedCommand = !running
|
|
4630
|
+
? selectInteractiveCommand(editor.text, menuSelected)
|
|
4631
|
+
: undefined;
|
|
4632
|
+
if (selectedCommand) {
|
|
3539
4633
|
editor.clear();
|
|
3540
4634
|
menuSelected = 0;
|
|
3541
|
-
|
|
4635
|
+
// A selected completion already contains its subcommand. Keeping the
|
|
4636
|
+
// partially typed second word would turn `/agents runs` into
|
|
4637
|
+
// `/agents runs runs` on Enter.
|
|
4638
|
+
await runSlashCommand(selectedCommand);
|
|
3542
4639
|
return;
|
|
3543
4640
|
}
|
|
3544
4641
|
const value = editor.submit();
|
|
@@ -3912,6 +5009,7 @@ export async function runActoviqTui(options = {}) {
|
|
|
3912
5009
|
if (shuttingDown)
|
|
3913
5010
|
return;
|
|
3914
5011
|
shuttingDown = true;
|
|
5012
|
+
let exitCode = code;
|
|
3915
5013
|
if (spinnerTimer)
|
|
3916
5014
|
clearInterval(spinnerTimer);
|
|
3917
5015
|
cancelScheduledDynamicRender();
|
|
@@ -3921,14 +5019,31 @@ export async function runActoviqTui(options = {}) {
|
|
|
3921
5019
|
if (process.stdin.isTTY)
|
|
3922
5020
|
process.stdin.setRawMode(false);
|
|
3923
5021
|
process.stdin.pause();
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
5022
|
+
if (managedPluginRuntime) {
|
|
5023
|
+
try {
|
|
5024
|
+
await closeManagedPluginsForExit(managedPluginRuntime.close);
|
|
5025
|
+
}
|
|
5026
|
+
catch (error) {
|
|
5027
|
+
exitCode = 1;
|
|
5028
|
+
process.stderr.write(`[actoviq-tui] ERROR: ${errorMessage(error)} ` +
|
|
5029
|
+
'Check E2B/Playwright resources manually before assuming billing has stopped.\n');
|
|
5030
|
+
}
|
|
3929
5031
|
}
|
|
3930
|
-
|
|
3931
|
-
|
|
5032
|
+
const cleanupResults = await Promise.allSettled([
|
|
5033
|
+
sdk.close(),
|
|
5034
|
+
externalCliRuntimeManager.close(),
|
|
5035
|
+
...[...externalBridgeRuntimes.values()].map(runtime => runtime.client.close()),
|
|
5036
|
+
]);
|
|
5037
|
+
const cleanupFailures = cleanupResults
|
|
5038
|
+
.filter((result) => result.status === 'rejected');
|
|
5039
|
+
if (cleanupFailures.length > 0) {
|
|
5040
|
+
exitCode = 1;
|
|
5041
|
+
process.stderr.write(`[actoviq-tui] ERROR: ${cleanupFailures.length} runtime cleanup operation(s) failed: ` +
|
|
5042
|
+
`${cleanupFailures.map(result => errorMessage(result.reason)).join('; ')}\n`);
|
|
5043
|
+
}
|
|
5044
|
+
externalBridgeRuntimes.clear();
|
|
5045
|
+
externalCliRunLabels.clear();
|
|
5046
|
+
process.exit(exitCode);
|
|
3932
5047
|
}
|
|
3933
5048
|
screen.start();
|
|
3934
5049
|
appendStatic(formatBanner({
|
|
@@ -3938,6 +5053,7 @@ export async function runActoviqTui(options = {}) {
|
|
|
3938
5053
|
permissionMode: currentPermissionMode(),
|
|
3939
5054
|
width: screen.width,
|
|
3940
5055
|
}));
|
|
5056
|
+
await restoreSessionRuntimeSelection();
|
|
3941
5057
|
renderDynamic();
|
|
3942
5058
|
readline.emitKeypressEvents(process.stdin);
|
|
3943
5059
|
if (process.stdin.isTTY)
|