actoviq-agent-sdk 0.4.6 → 0.4.7
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 +203 -0
- package/README-zh.md +54 -19
- package/README.md +53 -19
- package/SECURITY.md +26 -0
- package/assets/actoviq-icon.ico +0 -0
- package/bin/actoviq-gui.js +28 -3
- package/dist/src/buddy/actoviqBuddy.d.ts.map +1 -1
- package/dist/src/buddy/actoviqBuddy.js +3 -4
- package/dist/src/buddy/actoviqBuddy.js.map +1 -1
- package/dist/src/cli/actoviq-react.js +495 -60
- package/dist/src/cli/actoviq-react.js.map +1 -1
- package/dist/src/compat/diagnostics.d.ts +18 -0
- package/dist/src/compat/diagnostics.d.ts.map +1 -0
- package/dist/src/compat/diagnostics.js +47 -0
- package/dist/src/compat/diagnostics.js.map +1 -0
- package/dist/src/compat/index.d.ts +8 -0
- package/dist/src/compat/index.d.ts.map +1 -0
- package/dist/src/compat/index.js +6 -0
- package/dist/src/compat/index.js.map +1 -0
- package/dist/src/config/actoviqHome.d.ts +32 -0
- package/dist/src/config/actoviqHome.d.ts.map +1 -0
- package/dist/src/config/actoviqHome.js +228 -0
- package/dist/src/config/actoviqHome.js.map +1 -0
- package/dist/src/config/actoviqSettingsStore.d.ts.map +1 -1
- package/dist/src/config/actoviqSettingsStore.js +6 -6
- package/dist/src/config/actoviqSettingsStore.js.map +1 -1
- package/dist/src/config/agentProfiles.d.ts +77 -0
- package/dist/src/config/agentProfiles.d.ts.map +1 -0
- package/dist/src/config/agentProfiles.js +319 -0
- package/dist/src/config/agentProfiles.js.map +1 -0
- package/dist/src/config/loadDefaultActoviqSettings.d.ts.map +1 -1
- package/dist/src/config/loadDefaultActoviqSettings.js +2 -3
- package/dist/src/config/loadDefaultActoviqSettings.js.map +1 -1
- package/dist/src/config/projectSessionDirectory.d.ts.map +1 -1
- package/dist/src/config/projectSessionDirectory.js +3 -2
- 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 +13 -2
- package/dist/src/config/resolveRuntimeConfig.js.map +1 -1
- package/dist/src/core/agent-spec.d.ts +74 -0
- package/dist/src/core/agent-spec.d.ts.map +1 -0
- package/dist/src/core/agent-spec.js +2 -0
- package/dist/src/core/agent-spec.js.map +1 -0
- package/dist/src/core/errors.d.ts +42 -0
- package/dist/src/core/errors.d.ts.map +1 -0
- package/dist/src/core/errors.js +53 -0
- package/dist/src/core/errors.js.map +1 -0
- package/dist/src/core/index.d.ts +11 -0
- package/dist/src/core/index.d.ts.map +1 -0
- package/dist/src/core/index.js +4 -0
- package/dist/src/core/index.js.map +1 -0
- package/dist/src/core/items.d.ts +161 -0
- package/dist/src/core/items.d.ts.map +1 -0
- package/dist/src/core/items.js +2 -0
- package/dist/src/core/items.js.map +1 -0
- package/dist/src/core/json.d.ts +20 -0
- package/dist/src/core/json.d.ts.map +1 -0
- package/dist/src/core/json.js +80 -0
- package/dist/src/core/json.js.map +1 -0
- package/dist/src/core/model-ref.d.ts +6 -0
- package/dist/src/core/model-ref.d.ts.map +1 -0
- package/dist/src/core/model-ref.js +2 -0
- package/dist/src/core/model-ref.js.map +1 -0
- package/dist/src/core/run.d.ts +35 -0
- package/dist/src/core/run.d.ts.map +1 -0
- package/dist/src/core/run.js +2 -0
- package/dist/src/core/run.js.map +1 -0
- package/dist/src/core/usage.d.ts +32 -0
- package/dist/src/core/usage.d.ts.map +1 -0
- package/dist/src/core/usage.js +111 -0
- package/dist/src/core/usage.js.map +1 -0
- package/dist/src/errors.d.ts +19 -0
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/errors.js +27 -0
- package/dist/src/errors.js.map +1 -1
- package/dist/src/events/index.d.ts +4 -0
- package/dist/src/events/index.d.ts.map +1 -0
- package/dist/src/events/index.js +4 -0
- package/dist/src/events/index.js.map +1 -0
- package/dist/src/events/openTelemetry.d.ts +51 -0
- package/dist/src/events/openTelemetry.d.ts.map +1 -0
- package/dist/src/events/openTelemetry.js +116 -0
- package/dist/src/events/openTelemetry.js.map +1 -0
- package/dist/src/events/processors.d.ts +14 -0
- package/dist/src/events/processors.d.ts.map +1 -0
- package/dist/src/events/processors.js +60 -0
- package/dist/src/events/processors.js.map +1 -0
- package/dist/src/events/runEvents.d.ts +66 -0
- package/dist/src/events/runEvents.d.ts.map +1 -0
- package/dist/src/events/runEvents.js +143 -0
- package/dist/src/events/runEvents.js.map +1 -0
- package/dist/src/gui/actoviqGui.d.ts +15 -0
- package/dist/src/gui/actoviqGui.d.ts.map +1 -1
- package/dist/src/gui/actoviqGui.js +18034 -1919
- package/dist/src/gui/actoviqGui.js.map +1 -1
- package/dist/src/gui/contextRailStore.d.ts +47 -0
- package/dist/src/gui/contextRailStore.d.ts.map +1 -0
- package/dist/src/gui/contextRailStore.js +163 -0
- package/dist/src/gui/contextRailStore.js.map +1 -0
- package/dist/src/gui/electronMain.js +32 -16
- package/dist/src/gui/electronMain.js.map +1 -1
- package/dist/src/gui/guiAssets.d.ts +6 -0
- package/dist/src/gui/guiAssets.d.ts.map +1 -0
- package/dist/src/gui/guiAssets.js +48 -0
- package/dist/src/gui/guiAssets.js.map +1 -0
- package/dist/src/gui/guiSyntaxHighlight.d.ts +11 -0
- package/dist/src/gui/guiSyntaxHighlight.d.ts.map +1 -0
- package/dist/src/gui/guiSyntaxHighlight.js +348 -0
- package/dist/src/gui/guiSyntaxHighlight.js.map +1 -0
- package/dist/src/gui/projectMeta.d.ts +15 -0
- package/dist/src/gui/projectMeta.d.ts.map +1 -0
- package/dist/src/gui/projectMeta.js +61 -0
- package/dist/src/gui/projectMeta.js.map +1 -0
- package/dist/src/gui/projectWorkbench.d.ts +73 -0
- package/dist/src/gui/projectWorkbench.d.ts.map +1 -0
- package/dist/src/gui/projectWorkbench.js +307 -0
- package/dist/src/gui/projectWorkbench.js.map +1 -0
- package/dist/src/gui/terminalManager.d.ts +33 -0
- package/dist/src/gui/terminalManager.d.ts.map +1 -0
- package/dist/src/gui/terminalManager.js +206 -0
- package/dist/src/gui/terminalManager.js.map +1 -0
- package/dist/src/gui/transcript/clientBundle.d.ts +6 -0
- package/dist/src/gui/transcript/clientBundle.d.ts.map +1 -0
- package/dist/src/gui/transcript/clientBundle.js +978 -0
- package/dist/src/gui/transcript/clientBundle.js.map +1 -0
- package/dist/src/gui/transcript/index.d.ts +9 -0
- package/dist/src/gui/transcript/index.d.ts.map +1 -0
- package/dist/src/gui/transcript/index.js +6 -0
- package/dist/src/gui/transcript/index.js.map +1 -0
- package/dist/src/gui/transcript/parts.d.ts +81 -0
- package/dist/src/gui/transcript/parts.d.ts.map +1 -0
- package/dist/src/gui/transcript/parts.js +476 -0
- package/dist/src/gui/transcript/parts.js.map +1 -0
- package/dist/src/gui/transcript/registry.d.ts +8 -0
- package/dist/src/gui/transcript/registry.d.ts.map +1 -0
- package/dist/src/gui/transcript/registry.js +32 -0
- package/dist/src/gui/transcript/registry.js.map +1 -0
- package/dist/src/gui/transcript/scroll.d.ts +9 -0
- package/dist/src/gui/transcript/scroll.d.ts.map +1 -0
- package/dist/src/gui/transcript/scroll.js +13 -0
- package/dist/src/gui/transcript/scroll.js.map +1 -0
- package/dist/src/gui/transcript/styles.d.ts +3 -0
- package/dist/src/gui/transcript/styles.d.ts.map +1 -0
- package/dist/src/gui/transcript/styles.js +172 -0
- package/dist/src/gui/transcript/styles.js.map +1 -0
- package/dist/src/gui/workspaceNote.d.ts +4 -0
- package/dist/src/gui/workspaceNote.d.ts.map +1 -0
- package/dist/src/gui/workspaceNote.js +21 -0
- package/dist/src/gui/workspaceNote.js.map +1 -0
- package/dist/src/gui/workspaceRegistry.d.ts +11 -0
- package/dist/src/gui/workspaceRegistry.d.ts.map +1 -0
- package/dist/src/gui/workspaceRegistry.js +114 -0
- package/dist/src/gui/workspaceRegistry.js.map +1 -0
- package/dist/src/hooks/userHooks.d.ts +29 -8
- package/dist/src/hooks/userHooks.d.ts.map +1 -1
- package/dist/src/hooks/userHooks.js +106 -34
- package/dist/src/hooks/userHooks.js.map +1 -1
- package/dist/src/index.d.ts +24 -6
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +18 -6
- package/dist/src/index.js.map +1 -1
- package/dist/src/issues/durableIssueCoordinator.d.ts +57 -0
- package/dist/src/issues/durableIssueCoordinator.d.ts.map +1 -0
- package/dist/src/issues/durableIssueCoordinator.js +128 -0
- package/dist/src/issues/durableIssueCoordinator.js.map +1 -0
- package/dist/src/issues/issueExecution.d.ts +34 -0
- package/dist/src/issues/issueExecution.d.ts.map +1 -0
- package/dist/src/issues/issueExecution.js +190 -0
- package/dist/src/issues/issueExecution.js.map +1 -0
- package/dist/src/issues/issueStore.d.ts +95 -0
- package/dist/src/issues/issueStore.d.ts.map +1 -0
- package/dist/src/issues/issueStore.js +373 -0
- package/dist/src/issues/issueStore.js.map +1 -0
- package/dist/src/manager/projectManager.d.ts +103 -0
- package/dist/src/manager/projectManager.d.ts.map +1 -0
- package/dist/src/manager/projectManager.js +547 -0
- package/dist/src/manager/projectManager.js.map +1 -0
- package/dist/src/mcp/connectionManager.d.ts +22 -2
- package/dist/src/mcp/connectionManager.d.ts.map +1 -1
- package/dist/src/mcp/connectionManager.js +153 -41
- package/dist/src/mcp/connectionManager.js.map +1 -1
- package/dist/src/mcp/mcpServerConfig.d.ts.map +1 -1
- package/dist/src/mcp/mcpServerConfig.js +7 -7
- package/dist/src/mcp/mcpServerConfig.js.map +1 -1
- package/dist/src/memory/actoviqMemory.js +6 -6
- package/dist/src/memory/actoviqMemory.js.map +1 -1
- package/dist/src/memory/sessionHistory.js +2 -2
- package/dist/src/memory/sessionHistory.js.map +1 -1
- package/dist/src/node/index.d.ts +5 -0
- package/dist/src/node/index.d.ts.map +1 -0
- package/dist/src/node/index.js +5 -0
- package/dist/src/node/index.js.map +1 -0
- package/dist/src/node/sqliteCheckpointAdapter.d.ts +20 -0
- package/dist/src/node/sqliteCheckpointAdapter.d.ts.map +1 -0
- package/dist/src/node/sqliteCheckpointAdapter.js +163 -0
- package/dist/src/node/sqliteCheckpointAdapter.js.map +1 -0
- package/dist/src/node/sqliteDurableChildStore.d.ts +21 -0
- package/dist/src/node/sqliteDurableChildStore.d.ts.map +1 -0
- package/dist/src/node/sqliteDurableChildStore.js +124 -0
- package/dist/src/node/sqliteDurableChildStore.js.map +1 -0
- package/dist/src/node/sqliteSessionAdapter.d.ts +28 -0
- package/dist/src/node/sqliteSessionAdapter.d.ts.map +1 -0
- package/dist/src/node/sqliteSessionAdapter.js +99 -0
- package/dist/src/node/sqliteSessionAdapter.js.map +1 -0
- package/dist/src/orchestration/agentTool.d.ts +50 -0
- package/dist/src/orchestration/agentTool.d.ts.map +1 -0
- package/dist/src/orchestration/agentTool.js +132 -0
- package/dist/src/orchestration/agentTool.js.map +1 -0
- package/dist/src/orchestration/background.d.ts +102 -0
- package/dist/src/orchestration/background.d.ts.map +1 -0
- package/dist/src/orchestration/background.js +310 -0
- package/dist/src/orchestration/background.js.map +1 -0
- package/dist/src/orchestration/childRunner.d.ts +12 -0
- package/dist/src/orchestration/childRunner.d.ts.map +1 -0
- package/dist/src/orchestration/childRunner.js +179 -0
- package/dist/src/orchestration/childRunner.js.map +1 -0
- package/dist/src/orchestration/contracts.d.ts +169 -0
- package/dist/src/orchestration/contracts.d.ts.map +1 -0
- package/dist/src/orchestration/contracts.js +11 -0
- package/dist/src/orchestration/contracts.js.map +1 -0
- package/dist/src/orchestration/handoff.d.ts +32 -0
- package/dist/src/orchestration/handoff.d.ts.map +1 -0
- package/dist/src/orchestration/handoff.js +60 -0
- package/dist/src/orchestration/handoff.js.map +1 -0
- package/dist/src/orchestration/index.d.ts +9 -0
- package/dist/src/orchestration/index.d.ts.map +1 -0
- package/dist/src/orchestration/index.js +9 -0
- package/dist/src/orchestration/index.js.map +1 -0
- package/dist/src/orchestration/presets.d.ts +51 -0
- package/dist/src/orchestration/presets.d.ts.map +1 -0
- package/dist/src/orchestration/presets.js +78 -0
- package/dist/src/orchestration/presets.js.map +1 -0
- package/dist/src/orchestration/scope.d.ts +69 -0
- package/dist/src/orchestration/scope.d.ts.map +1 -0
- package/dist/src/orchestration/scope.js +371 -0
- package/dist/src/orchestration/scope.js.map +1 -0
- package/dist/src/orchestration/workflowGraph.d.ts +73 -0
- package/dist/src/orchestration/workflowGraph.d.ts.map +1 -0
- package/dist/src/orchestration/workflowGraph.js +255 -0
- package/dist/src/orchestration/workflowGraph.js.map +1 -0
- package/dist/src/parity/actoviqCleanBridgeCompatSdk.d.ts.map +1 -1
- package/dist/src/parity/actoviqCleanBridgeCompatSdk.js +101 -48
- package/dist/src/parity/actoviqCleanBridgeCompatSdk.js.map +1 -1
- package/dist/src/parity/bridgeConfigs.d.ts +2 -2
- package/dist/src/parity/bridgeConfigs.d.ts.map +1 -1
- package/dist/src/parity/bridgeConfigs.js +78 -39
- package/dist/src/parity/bridgeConfigs.js.map +1 -1
- package/dist/src/parity/bridgeProviders.d.ts +9 -6
- package/dist/src/parity/bridgeProviders.d.ts.map +1 -1
- package/dist/src/parity/bridgeProviders.js +140 -26
- package/dist/src/parity/bridgeProviders.js.map +1 -1
- package/dist/src/parity/portableSessions.js +2 -2
- package/dist/src/parity/portableSessions.js.map +1 -1
- package/dist/src/profiles/index.d.ts +15 -0
- package/dist/src/profiles/index.d.ts.map +1 -0
- package/dist/src/profiles/index.js +618 -0
- package/dist/src/profiles/index.js.map +1 -0
- package/dist/src/profiles/types.d.ts +102 -0
- package/dist/src/profiles/types.d.ts.map +1 -0
- package/dist/src/profiles/types.js +9 -0
- package/dist/src/profiles/types.js.map +1 -0
- package/dist/src/provider/client.d.ts +1 -1
- package/dist/src/provider/client.d.ts.map +1 -1
- package/dist/src/provider/openai-model-api.js +1 -1
- package/dist/src/provider/openai-model-api.js.map +1 -1
- package/dist/src/providers-v2/adapter-base.d.ts +35 -0
- package/dist/src/providers-v2/adapter-base.d.ts.map +1 -0
- package/dist/src/providers-v2/adapter-base.js +115 -0
- package/dist/src/providers-v2/adapter-base.js.map +1 -0
- package/dist/src/providers-v2/anthropic.d.ts +15 -0
- package/dist/src/providers-v2/anthropic.d.ts.map +1 -0
- package/dist/src/providers-v2/anthropic.js +414 -0
- package/dist/src/providers-v2/anthropic.js.map +1 -0
- package/dist/src/providers-v2/capabilities.d.ts +33 -0
- package/dist/src/providers-v2/capabilities.d.ts.map +1 -0
- package/dist/src/providers-v2/capabilities.js +218 -0
- package/dist/src/providers-v2/capabilities.js.map +1 -0
- package/dist/src/providers-v2/index.d.ts +12 -0
- package/dist/src/providers-v2/index.d.ts.map +1 -0
- package/dist/src/providers-v2/index.js +8 -0
- package/dist/src/providers-v2/index.js.map +1 -0
- package/dist/src/providers-v2/legacy.d.ts +26 -0
- package/dist/src/providers-v2/legacy.d.ts.map +1 -0
- package/dist/src/providers-v2/legacy.js +543 -0
- package/dist/src/providers-v2/legacy.js.map +1 -0
- package/dist/src/providers-v2/mapping.d.ts +34 -0
- package/dist/src/providers-v2/mapping.d.ts.map +1 -0
- package/dist/src/providers-v2/mapping.js +194 -0
- package/dist/src/providers-v2/mapping.js.map +1 -0
- package/dist/src/providers-v2/openai-chat.d.ts +16 -0
- package/dist/src/providers-v2/openai-chat.d.ts.map +1 -0
- package/dist/src/providers-v2/openai-chat.js +318 -0
- package/dist/src/providers-v2/openai-chat.js.map +1 -0
- package/dist/src/providers-v2/openai-responses.d.ts +15 -0
- package/dist/src/providers-v2/openai-responses.d.ts.map +1 -0
- package/dist/src/providers-v2/openai-responses.js +356 -0
- package/dist/src/providers-v2/openai-responses.js.map +1 -0
- package/dist/src/providers-v2/registry.d.ts +39 -0
- package/dist/src/providers-v2/registry.d.ts.map +1 -0
- package/dist/src/providers-v2/registry.js +101 -0
- package/dist/src/providers-v2/registry.js.map +1 -0
- package/dist/src/providers-v2/stream.d.ts +14 -0
- package/dist/src/providers-v2/stream.d.ts.map +1 -0
- package/dist/src/providers-v2/stream.js +115 -0
- package/dist/src/providers-v2/stream.js.map +1 -0
- package/dist/src/providers-v2/transport.d.ts +36 -0
- package/dist/src/providers-v2/transport.d.ts.map +1 -0
- package/dist/src/providers-v2/transport.js +337 -0
- package/dist/src/providers-v2/transport.js.map +1 -0
- package/dist/src/providers-v2/types.d.ts +162 -0
- package/dist/src/providers-v2/types.d.ts.map +1 -0
- package/dist/src/providers-v2/types.js +8 -0
- package/dist/src/providers-v2/types.js.map +1 -0
- package/dist/src/router/modelRouter.d.ts.map +1 -1
- package/dist/src/router/modelRouter.js +2 -3
- package/dist/src/router/modelRouter.js.map +1 -1
- package/dist/src/runtime/actoviqAgents.d.ts +5 -0
- package/dist/src/runtime/actoviqAgents.d.ts.map +1 -1
- package/dist/src/runtime/actoviqAgents.js +22 -4
- package/dist/src/runtime/actoviqAgents.js.map +1 -1
- package/dist/src/runtime/actoviqBackgroundTasks.d.ts +2 -1
- package/dist/src/runtime/actoviqBackgroundTasks.d.ts.map +1 -1
- package/dist/src/runtime/actoviqBackgroundTasks.js +4 -2
- package/dist/src/runtime/actoviqBackgroundTasks.js.map +1 -1
- package/dist/src/runtime/actoviqCompact.d.ts +15 -0
- package/dist/src/runtime/actoviqCompact.d.ts.map +1 -1
- package/dist/src/runtime/actoviqCompact.js +36 -10
- package/dist/src/runtime/actoviqCompact.js.map +1 -1
- package/dist/src/runtime/actoviqModelApi.d.ts.map +1 -1
- package/dist/src/runtime/actoviqModelApi.js +16 -2
- package/dist/src/runtime/actoviqModelApi.js.map +1 -1
- package/dist/src/runtime/actoviqPermissions.js +5 -1
- package/dist/src/runtime/actoviqPermissions.js.map +1 -1
- package/dist/src/runtime/agentClient.d.ts +3 -0
- package/dist/src/runtime/agentClient.d.ts.map +1 -1
- package/dist/src/runtime/agentClient.js +127 -45
- package/dist/src/runtime/agentClient.js.map +1 -1
- package/dist/src/runtime/agentRuntimeDiscovery.d.ts +75 -0
- package/dist/src/runtime/agentRuntimeDiscovery.d.ts.map +1 -0
- package/dist/src/runtime/agentRuntimeDiscovery.js +311 -0
- package/dist/src/runtime/agentRuntimeDiscovery.js.map +1 -0
- package/dist/src/runtime/agentSession.d.ts +18 -0
- package/dist/src/runtime/agentSession.d.ts.map +1 -1
- package/dist/src/runtime/agentSession.js +36 -0
- package/dist/src/runtime/agentSession.js.map +1 -1
- package/dist/src/runtime/asyncQueue.d.ts +99 -8
- package/dist/src/runtime/asyncQueue.d.ts.map +1 -1
- package/dist/src/runtime/asyncQueue.js +437 -37
- package/dist/src/runtime/asyncQueue.js.map +1 -1
- package/dist/src/runtime/conversationEngine.d.ts +7 -0
- package/dist/src/runtime/conversationEngine.d.ts.map +1 -1
- package/dist/src/runtime/conversationEngine.js +278 -18
- package/dist/src/runtime/conversationEngine.js.map +1 -1
- package/dist/src/runtime/deadline.d.ts +13 -0
- package/dist/src/runtime/deadline.d.ts.map +1 -0
- package/dist/src/runtime/deadline.js +67 -0
- package/dist/src/runtime/deadline.js.map +1 -0
- package/dist/src/runtime/messageUtils.d.ts +5 -0
- package/dist/src/runtime/messageUtils.d.ts.map +1 -1
- package/dist/src/runtime/messageUtils.js +17 -0
- package/dist/src/runtime/messageUtils.js.map +1 -1
- package/dist/src/runtime/sessionTurnCoordinator.d.ts +12 -0
- package/dist/src/runtime/sessionTurnCoordinator.d.ts.map +1 -0
- package/dist/src/runtime/sessionTurnCoordinator.js +23 -0
- package/dist/src/runtime/sessionTurnCoordinator.js.map +1 -0
- package/dist/src/runtime/tools.d.ts.map +1 -1
- package/dist/src/runtime/tools.js +1 -0
- package/dist/src/runtime/tools.js.map +1 -1
- package/dist/src/runtime-v2/agentRuntime.d.ts +136 -0
- package/dist/src/runtime-v2/agentRuntime.d.ts.map +1 -0
- package/dist/src/runtime-v2/agentRuntime.js +1341 -0
- package/dist/src/runtime-v2/agentRuntime.js.map +1 -0
- package/dist/src/runtime-v2/index.d.ts +6 -0
- package/dist/src/runtime-v2/index.d.ts.map +1 -0
- package/dist/src/runtime-v2/index.js +6 -0
- package/dist/src/runtime-v2/index.js.map +1 -0
- package/dist/src/runtime-v2/middleware/index.d.ts +5 -0
- package/dist/src/runtime-v2/middleware/index.d.ts.map +1 -0
- package/dist/src/runtime-v2/middleware/index.js +4 -0
- package/dist/src/runtime-v2/middleware/index.js.map +1 -0
- package/dist/src/runtime-v2/middleware/pipeline.d.ts +56 -0
- package/dist/src/runtime-v2/middleware/pipeline.d.ts.map +1 -0
- package/dist/src/runtime-v2/middleware/pipeline.js +242 -0
- package/dist/src/runtime-v2/middleware/pipeline.js.map +1 -0
- package/dist/src/runtime-v2/middleware/registry.d.ts +17 -0
- package/dist/src/runtime-v2/middleware/registry.d.ts.map +1 -0
- package/dist/src/runtime-v2/middleware/registry.js +46 -0
- package/dist/src/runtime-v2/middleware/registry.js.map +1 -0
- package/dist/src/runtime-v2/middleware/stages.d.ts +25 -0
- package/dist/src/runtime-v2/middleware/stages.d.ts.map +1 -0
- package/dist/src/runtime-v2/middleware/stages.js +48 -0
- package/dist/src/runtime-v2/middleware/stages.js.map +1 -0
- package/dist/src/runtime-v2/middleware/types.d.ts +51 -0
- package/dist/src/runtime-v2/middleware/types.d.ts.map +1 -0
- package/dist/src/runtime-v2/middleware/types.js +2 -0
- package/dist/src/runtime-v2/middleware/types.js.map +1 -0
- package/dist/src/runtime-v2/services.d.ts +33 -0
- package/dist/src/runtime-v2/services.d.ts.map +1 -0
- package/dist/src/runtime-v2/services.js +92 -0
- package/dist/src/runtime-v2/services.js.map +1 -0
- package/dist/src/runtime-v2/state.d.ts +71 -0
- package/dist/src/runtime-v2/state.d.ts.map +1 -0
- package/dist/src/runtime-v2/state.js +2 -0
- package/dist/src/runtime-v2/state.js.map +1 -0
- package/dist/src/runtime-v2/tools.d.ts +124 -0
- package/dist/src/runtime-v2/tools.d.ts.map +1 -0
- package/dist/src/runtime-v2/tools.js +185 -0
- package/dist/src/runtime-v2/tools.js.map +1 -0
- package/dist/src/scheduling/durableAgentScheduler.d.ts +46 -0
- package/dist/src/scheduling/durableAgentScheduler.d.ts.map +1 -0
- package/dist/src/scheduling/durableAgentScheduler.js +97 -0
- package/dist/src/scheduling/durableAgentScheduler.js.map +1 -0
- package/dist/src/scheduling/index.d.ts +3 -0
- package/dist/src/scheduling/index.d.ts.map +1 -1
- package/dist/src/scheduling/index.js +2 -0
- package/dist/src/scheduling/index.js.map +1 -1
- package/dist/src/scheduling/taskPersistence.d.ts +9 -0
- package/dist/src/scheduling/taskPersistence.d.ts.map +1 -0
- package/dist/src/scheduling/taskPersistence.js +238 -0
- package/dist/src/scheduling/taskPersistence.js.map +1 -0
- package/dist/src/storage/atomicJsonWrite.d.ts +13 -0
- package/dist/src/storage/atomicJsonWrite.d.ts.map +1 -0
- package/dist/src/storage/atomicJsonWrite.js +40 -0
- package/dist/src/storage/atomicJsonWrite.js.map +1 -0
- package/dist/src/storage/backgroundTaskStore.d.ts.map +1 -1
- package/dist/src/storage/backgroundTaskStore.js +2 -6
- package/dist/src/storage/backgroundTaskStore.js.map +1 -1
- package/dist/src/storage/mailboxStore.d.ts.map +1 -1
- package/dist/src/storage/mailboxStore.js +2 -6
- package/dist/src/storage/mailboxStore.js.map +1 -1
- package/dist/src/storage/sessionStore.d.ts +3 -0
- package/dist/src/storage/sessionStore.d.ts.map +1 -1
- package/dist/src/storage/sessionStore.js +169 -10
- package/dist/src/storage/sessionStore.js.map +1 -1
- package/dist/src/storage/teammateStore.d.ts.map +1 -1
- package/dist/src/storage/teammateStore.js +2 -6
- package/dist/src/storage/teammateStore.js.map +1 -1
- package/dist/src/storage-v2/contracts.d.ts +36 -0
- package/dist/src/storage-v2/contracts.d.ts.map +1 -0
- package/dist/src/storage-v2/contracts.js +2 -0
- package/dist/src/storage-v2/contracts.js.map +1 -0
- package/dist/src/storage-v2/errors.d.ts +21 -0
- package/dist/src/storage-v2/errors.d.ts.map +1 -0
- package/dist/src/storage-v2/errors.js +44 -0
- package/dist/src/storage-v2/errors.js.map +1 -0
- package/dist/src/storage-v2/index.d.ts +8 -0
- package/dist/src/storage-v2/index.d.ts.map +1 -0
- package/dist/src/storage-v2/index.js +8 -0
- package/dist/src/storage-v2/index.js.map +1 -0
- package/dist/src/storage-v2/legacyJsonV1Items.d.ts +10 -0
- package/dist/src/storage-v2/legacyJsonV1Items.d.ts.map +1 -0
- package/dist/src/storage-v2/legacyJsonV1Items.js +153 -0
- package/dist/src/storage-v2/legacyJsonV1Items.js.map +1 -0
- package/dist/src/storage-v2/migration.d.ts +32 -0
- package/dist/src/storage-v2/migration.d.ts.map +1 -0
- package/dist/src/storage-v2/migration.js +242 -0
- package/dist/src/storage-v2/migration.js.map +1 -0
- package/dist/src/storage-v2/sqliteDriver.d.ts +24 -0
- package/dist/src/storage-v2/sqliteDriver.d.ts.map +1 -0
- package/dist/src/storage-v2/sqliteDriver.js +90 -0
- package/dist/src/storage-v2/sqliteDriver.js.map +1 -0
- package/dist/src/storage-v2/sqliteStorage.d.ts +55 -0
- package/dist/src/storage-v2/sqliteStorage.d.ts.map +1 -0
- package/dist/src/storage-v2/sqliteStorage.js +905 -0
- package/dist/src/storage-v2/sqliteStorage.js.map +1 -0
- package/dist/src/storage-v2/types.d.ts +198 -0
- package/dist/src/storage-v2/types.d.ts.map +1 -0
- package/dist/src/storage-v2/types.js +2 -0
- package/dist/src/storage-v2/types.js.map +1 -0
- package/dist/src/surfaces/index.d.ts +8 -0
- package/dist/src/surfaces/index.d.ts.map +1 -0
- package/dist/src/surfaces/index.js +8 -0
- package/dist/src/surfaces/index.js.map +1 -0
- package/dist/src/surfaces/internal.d.ts +17 -0
- package/dist/src/surfaces/internal.d.ts.map +1 -0
- package/dist/src/surfaces/internal.js +116 -0
- package/dist/src/surfaces/internal.js.map +1 -0
- package/dist/src/surfaces/legacyEventAdapter.d.ts +38 -0
- package/dist/src/surfaces/legacyEventAdapter.d.ts.map +1 -0
- package/dist/src/surfaces/legacyEventAdapter.js +373 -0
- package/dist/src/surfaces/legacyEventAdapter.js.map +1 -0
- package/dist/src/surfaces/legacySurfacePipeline.d.ts +18 -0
- package/dist/src/surfaces/legacySurfacePipeline.d.ts.map +1 -0
- package/dist/src/surfaces/legacySurfacePipeline.js +25 -0
- package/dist/src/surfaces/legacySurfacePipeline.js.map +1 -0
- package/dist/src/surfaces/redaction.d.ts +12 -0
- package/dist/src/surfaces/redaction.d.ts.map +1 -0
- package/dist/src/surfaces/redaction.js +111 -0
- package/dist/src/surfaces/redaction.js.map +1 -0
- package/dist/src/surfaces/runEventLegacyCompat.d.ts +26 -0
- package/dist/src/surfaces/runEventLegacyCompat.d.ts.map +1 -0
- package/dist/src/surfaces/runEventLegacyCompat.js +339 -0
- package/dist/src/surfaces/runEventLegacyCompat.js.map +1 -0
- package/dist/src/surfaces/runEventProjector.d.ts +44 -0
- package/dist/src/surfaces/runEventProjector.d.ts.map +1 -0
- package/dist/src/surfaces/runEventProjector.js +404 -0
- package/dist/src/surfaces/runEventProjector.js.map +1 -0
- package/dist/src/surfaces/runtimeBridgeAdapter.d.ts +30 -0
- package/dist/src/surfaces/runtimeBridgeAdapter.d.ts.map +1 -0
- package/dist/src/surfaces/runtimeBridgeAdapter.js +38 -0
- package/dist/src/surfaces/runtimeBridgeAdapter.js.map +1 -0
- package/dist/src/surfaces/types.d.ts +38 -0
- package/dist/src/surfaces/types.d.ts.map +1 -0
- package/dist/src/surfaces/types.js +2 -0
- package/dist/src/surfaces/types.js.map +1 -0
- package/dist/src/team/agentPool.d.ts +2 -0
- package/dist/src/team/agentPool.d.ts.map +1 -1
- package/dist/src/team/agentPool.js +3 -1
- package/dist/src/team/agentPool.js.map +1 -1
- package/dist/src/team/modelTeam.d.ts +25 -19
- package/dist/src/team/modelTeam.d.ts.map +1 -1
- package/dist/src/team/modelTeam.js +293 -294
- package/dist/src/team/modelTeam.js.map +1 -1
- package/dist/src/team/pricing.d.ts.map +1 -1
- package/dist/src/team/pricing.js +2 -1
- package/dist/src/team/pricing.js.map +1 -1
- package/dist/src/team/teamDefinitions.d.ts +28 -1
- package/dist/src/team/teamDefinitions.d.ts.map +1 -1
- package/dist/src/team/teamDefinitions.js +204 -8
- package/dist/src/team/teamDefinitions.js.map +1 -1
- package/dist/src/team/teamGraph.d.ts +191 -0
- package/dist/src/team/teamGraph.d.ts.map +1 -0
- package/dist/src/team/teamGraph.js +616 -0
- package/dist/src/team/teamGraph.js.map +1 -0
- package/dist/src/team/teamGraphLayout.d.ts +44 -0
- package/dist/src/team/teamGraphLayout.d.ts.map +1 -0
- package/dist/src/team/teamGraphLayout.js +120 -0
- package/dist/src/team/teamGraphLayout.js.map +1 -0
- package/dist/src/team/teamGraphScaffold.d.ts +76 -0
- package/dist/src/team/teamGraphScaffold.d.ts.map +1 -0
- package/dist/src/team/teamGraphScaffold.js +409 -0
- package/dist/src/team/teamGraphScaffold.js.map +1 -0
- package/dist/src/team/teamGraphV3.d.ts +28 -0
- package/dist/src/team/teamGraphV3.d.ts.map +1 -0
- package/dist/src/team/teamGraphV3.js +640 -0
- package/dist/src/team/teamGraphV3.js.map +1 -0
- package/dist/src/team/teamPreferences.d.ts +11 -0
- package/dist/src/team/teamPreferences.d.ts.map +1 -0
- package/dist/src/team/teamPreferences.js +48 -0
- package/dist/src/team/teamPreferences.js.map +1 -0
- package/dist/src/team/teamPrompts.d.ts +16 -0
- package/dist/src/team/teamPrompts.d.ts.map +1 -0
- package/dist/src/team/teamPrompts.js +44 -0
- package/dist/src/team/teamPrompts.js.map +1 -0
- package/dist/src/team/teamRunView.d.ts +78 -0
- package/dist/src/team/teamRunView.d.ts.map +1 -0
- package/dist/src/team/teamRunView.js +205 -0
- package/dist/src/team/teamRunView.js.map +1 -0
- package/dist/src/team/teamRuntime.d.ts +19 -2
- package/dist/src/team/teamRuntime.d.ts.map +1 -1
- package/dist/src/team/teamRuntime.js +13 -7
- package/dist/src/team/teamRuntime.js.map +1 -1
- package/dist/src/tools/actoviqCoreTools.d.ts +2 -1
- package/dist/src/tools/actoviqCoreTools.d.ts.map +1 -1
- package/dist/src/tools/actoviqCoreTools.js +4 -1
- package/dist/src/tools/actoviqCoreTools.js.map +1 -1
- package/dist/src/tools/actoviqShellTools.d.ts.map +1 -1
- package/dist/src/tools/actoviqShellTools.js +10 -0
- package/dist/src/tools/actoviqShellTools.js.map +1 -1
- package/dist/src/tools/askUserQuestion/AskUserQuestionTool.d.ts.map +1 -1
- package/dist/src/tools/askUserQuestion/AskUserQuestionTool.js +2 -0
- package/dist/src/tools/askUserQuestion/AskUserQuestionTool.js.map +1 -1
- package/dist/src/tools/bash/BashTool.d.ts +33 -2
- package/dist/src/tools/bash/BashTool.d.ts.map +1 -1
- package/dist/src/tools/bash/BashTool.js +140 -2
- package/dist/src/tools/bash/BashTool.js.map +1 -1
- package/dist/src/tools/bash/prompt.d.ts +1 -1
- package/dist/src/tools/bash/prompt.d.ts.map +1 -1
- package/dist/src/tools/bash/prompt.js +1 -0
- package/dist/src/tools/bash/prompt.js.map +1 -1
- package/dist/src/tools/planMode/PlanModeTools.js +2 -2
- package/dist/src/tools/planMode/PlanModeTools.js.map +1 -1
- package/dist/src/tools/todo/TodoWriteTool.d.ts +1 -1
- package/dist/src/tui/actoviqTui.d.ts.map +1 -1
- package/dist/src/tui/actoviqTui.js +522 -97
- package/dist/src/tui/actoviqTui.js.map +1 -1
- package/dist/src/tui/pluginCatalog.d.ts.map +1 -1
- package/dist/src/tui/pluginCatalog.js +3 -1
- package/dist/src/tui/pluginCatalog.js.map +1 -1
- package/dist/src/types.d.ts +355 -23
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js.map +1 -1
- package/dist/src/ui/commandSurface.d.ts.map +1 -1
- package/dist/src/ui/commandSurface.js +23 -3
- package/dist/src/ui/commandSurface.js.map +1 -1
- package/dist/src/workflow/workflowPersistence.d.ts.map +1 -1
- package/dist/src/workflow/workflowPersistence.js +2 -1
- package/dist/src/workflow/workflowPersistence.js.map +1 -1
- package/dist/src/workflow/workflowScriptRuntime.d.ts +4 -0
- package/dist/src/workflow/workflowScriptRuntime.d.ts.map +1 -1
- package/dist/src/workflow/workflowScriptRuntime.js +69 -18
- package/dist/src/workflow/workflowScriptRuntime.js.map +1 -1
- package/dist/src/workflow-v2/boundary.d.ts +2 -0
- package/dist/src/workflow-v2/boundary.d.ts.map +1 -0
- package/dist/src/workflow-v2/boundary.js +45 -0
- package/dist/src/workflow-v2/boundary.js.map +1 -0
- package/dist/src/workflow-v2/capabilities.d.ts +5 -0
- package/dist/src/workflow-v2/capabilities.d.ts.map +1 -0
- package/dist/src/workflow-v2/capabilities.js +32 -0
- package/dist/src/workflow-v2/capabilities.js.map +1 -0
- package/dist/src/workflow-v2/errors.d.ts +43 -0
- package/dist/src/workflow-v2/errors.d.ts.map +1 -0
- package/dist/src/workflow-v2/errors.js +84 -0
- package/dist/src/workflow-v2/errors.js.map +1 -0
- package/dist/src/workflow-v2/index.d.ts +9 -0
- package/dist/src/workflow-v2/index.d.ts.map +1 -0
- package/dist/src/workflow-v2/index.js +6 -0
- package/dist/src/workflow-v2/index.js.map +1 -0
- package/dist/src/workflow-v2/json.d.ts +5 -0
- package/dist/src/workflow-v2/json.d.ts.map +1 -0
- package/dist/src/workflow-v2/json.js +40 -0
- package/dist/src/workflow-v2/json.js.map +1 -0
- package/dist/src/workflow-v2/limits.d.ts +15 -0
- package/dist/src/workflow-v2/limits.d.ts.map +1 -0
- package/dist/src/workflow-v2/limits.js +37 -0
- package/dist/src/workflow-v2/limits.js.map +1 -0
- package/dist/src/workflow-v2/localIsolatedProcessExecutor.d.ts +25 -0
- package/dist/src/workflow-v2/localIsolatedProcessExecutor.d.ts.map +1 -0
- package/dist/src/workflow-v2/localIsolatedProcessExecutor.js +423 -0
- package/dist/src/workflow-v2/localIsolatedProcessExecutor.js.map +1 -0
- package/dist/src/workflow-v2/localProcessChild.d.ts +2 -0
- package/dist/src/workflow-v2/localProcessChild.d.ts.map +1 -0
- package/dist/src/workflow-v2/localProcessChild.js +305 -0
- package/dist/src/workflow-v2/localProcessChild.js.map +1 -0
- package/dist/src/workflow-v2/router.d.ts +10 -0
- package/dist/src/workflow-v2/router.d.ts.map +1 -0
- package/dist/src/workflow-v2/router.js +28 -0
- package/dist/src/workflow-v2/router.js.map +1 -0
- package/dist/src/workflow-v2/trustedCompatibilityExecutor.d.ts +17 -0
- package/dist/src/workflow-v2/trustedCompatibilityExecutor.d.ts.map +1 -0
- package/dist/src/workflow-v2/trustedCompatibilityExecutor.js +159 -0
- package/dist/src/workflow-v2/trustedCompatibilityExecutor.js.map +1 -0
- package/dist/src/workflow-v2/types.d.ts +67 -0
- package/dist/src/workflow-v2/types.d.ts.map +1 -0
- package/dist/src/workflow-v2/types.js +2 -0
- package/dist/src/workflow-v2/types.js.map +1 -0
- package/package.json +96 -10
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/** Maps runtime-v2 JSON checkpoints onto the tenant-scoped SQLite contract. */
|
|
2
|
+
export class SqliteRunCheckpointAdapter {
|
|
3
|
+
store;
|
|
4
|
+
tenantId;
|
|
5
|
+
checkpointId;
|
|
6
|
+
constructor(options) {
|
|
7
|
+
if (!options.tenantId.trim())
|
|
8
|
+
throw new TypeError('tenantId must not be empty.');
|
|
9
|
+
this.store = options.store;
|
|
10
|
+
this.tenantId = options.tenantId;
|
|
11
|
+
this.checkpointId = options.checkpointId ?? (runId => runId);
|
|
12
|
+
}
|
|
13
|
+
async save(state) {
|
|
14
|
+
const checkpointId = this.checkpointId(state.runId);
|
|
15
|
+
const current = await this.store.load({ tenantId: this.tenantId, checkpointId });
|
|
16
|
+
const jsonState = toStorageJson(state);
|
|
17
|
+
await this.store.save({
|
|
18
|
+
tenantId: this.tenantId,
|
|
19
|
+
checkpointId,
|
|
20
|
+
runId: state.runId,
|
|
21
|
+
sessionId: state.sessionId,
|
|
22
|
+
expectedRevision: current?.revision ?? null,
|
|
23
|
+
status: mapStatus(state),
|
|
24
|
+
state: jsonState,
|
|
25
|
+
interruption: mapInterruption(state),
|
|
26
|
+
pendingSideEffects: mapPendingSideEffects(state),
|
|
27
|
+
traceContext: {
|
|
28
|
+
traceId: state.trace.traceId,
|
|
29
|
+
spanId: state.trace.spanId,
|
|
30
|
+
...(state.trace.parentSpanId === undefined
|
|
31
|
+
? {}
|
|
32
|
+
: { parentSpanId: state.trace.parentSpanId }),
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
async load(runId) {
|
|
37
|
+
const checkpoint = await this.store.load({
|
|
38
|
+
tenantId: this.tenantId,
|
|
39
|
+
checkpointId: this.checkpointId(runId),
|
|
40
|
+
});
|
|
41
|
+
if (!checkpoint)
|
|
42
|
+
return undefined;
|
|
43
|
+
return fromCheckpoint(checkpoint);
|
|
44
|
+
}
|
|
45
|
+
/** Marks the checkpoint completed while retaining an auditable tombstone. */
|
|
46
|
+
async delete(runId) {
|
|
47
|
+
const checkpointId = this.checkpointId(runId);
|
|
48
|
+
const current = await this.store.load({ tenantId: this.tenantId, checkpointId });
|
|
49
|
+
if (!current || current.status === 'completed')
|
|
50
|
+
return;
|
|
51
|
+
await this.store.save({
|
|
52
|
+
tenantId: this.tenantId,
|
|
53
|
+
checkpointId,
|
|
54
|
+
runId: current.runId,
|
|
55
|
+
sessionId: current.sessionId,
|
|
56
|
+
expectedRevision: current.revision,
|
|
57
|
+
status: 'completed',
|
|
58
|
+
state: current.state,
|
|
59
|
+
pendingSideEffects: current.pendingSideEffects,
|
|
60
|
+
traceContext: current.traceContext,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function mapStatus(state) {
|
|
65
|
+
if (state.pendingTool?.status === 'awaiting_approval')
|
|
66
|
+
return 'awaiting_side_effect';
|
|
67
|
+
return state.status;
|
|
68
|
+
}
|
|
69
|
+
function mapInterruption(state) {
|
|
70
|
+
const pending = state.pendingTool;
|
|
71
|
+
if (state.status !== 'interrupted' || !pending?.interruptionId)
|
|
72
|
+
return undefined;
|
|
73
|
+
return {
|
|
74
|
+
reason: 'tool_approval',
|
|
75
|
+
resumable: true,
|
|
76
|
+
requestedAt: new Date().toISOString(),
|
|
77
|
+
details: {
|
|
78
|
+
interruptionId: pending.interruptionId,
|
|
79
|
+
callId: pending.call.id,
|
|
80
|
+
toolName: pending.call.name,
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function mapPendingSideEffects(state) {
|
|
85
|
+
const pending = state.pendingTool;
|
|
86
|
+
if (!pending || pending.effect === 'read')
|
|
87
|
+
return [];
|
|
88
|
+
return [{
|
|
89
|
+
sideEffectId: pending.call.id,
|
|
90
|
+
kind: `tool:${pending.call.name}`,
|
|
91
|
+
status: pending.status === 'committed'
|
|
92
|
+
? 'succeeded'
|
|
93
|
+
: pending.status === 'started'
|
|
94
|
+
? 'started'
|
|
95
|
+
: 'pending',
|
|
96
|
+
...(pending.idempotencyKey === undefined ? {} : { idempotencyKey: pending.idempotencyKey }),
|
|
97
|
+
input: toStorageJson(pending.call.input),
|
|
98
|
+
...(pending.result?.type === 'tool_result'
|
|
99
|
+
? { output: toStorageJson(pending.result.output) }
|
|
100
|
+
: {}),
|
|
101
|
+
}];
|
|
102
|
+
}
|
|
103
|
+
export function toStorageJson(value) {
|
|
104
|
+
return toStorageJsonInternal(value, new Set());
|
|
105
|
+
}
|
|
106
|
+
function fromCheckpoint(checkpoint) {
|
|
107
|
+
if (!isSerializedRunState(checkpoint.state)) {
|
|
108
|
+
throw new TypeError(`Checkpoint "${checkpoint.checkpointId}" does not contain runtime-v2 state.`);
|
|
109
|
+
}
|
|
110
|
+
return structuredClone(checkpoint.state);
|
|
111
|
+
}
|
|
112
|
+
function isSerializedRunState(value) {
|
|
113
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
114
|
+
return false;
|
|
115
|
+
const record = value;
|
|
116
|
+
return record.schemaVersion === 1
|
|
117
|
+
&& typeof record.runId === 'string'
|
|
118
|
+
&& typeof record.agentId === 'string'
|
|
119
|
+
&& typeof record.agentConfigDigest === 'string'
|
|
120
|
+
&& typeof record.status === 'string'
|
|
121
|
+
&& typeof record.trace === 'object'
|
|
122
|
+
&& Array.isArray(record.transcript)
|
|
123
|
+
&& Array.isArray(record.generatedItems);
|
|
124
|
+
}
|
|
125
|
+
function toStorageJsonInternal(value, ancestors) {
|
|
126
|
+
if (value === null || typeof value === 'string' || typeof value === 'boolean')
|
|
127
|
+
return value;
|
|
128
|
+
if (typeof value === 'number') {
|
|
129
|
+
if (!Number.isFinite(value))
|
|
130
|
+
throw new TypeError('Checkpoint contains a non-finite number.');
|
|
131
|
+
return value;
|
|
132
|
+
}
|
|
133
|
+
if (typeof value !== 'object') {
|
|
134
|
+
throw new TypeError(`Checkpoint contains non-JSON value ${typeof value}.`);
|
|
135
|
+
}
|
|
136
|
+
if (ancestors.has(value))
|
|
137
|
+
throw new TypeError('Checkpoint contains a cyclic value.');
|
|
138
|
+
ancestors.add(value);
|
|
139
|
+
try {
|
|
140
|
+
if (Array.isArray(value)) {
|
|
141
|
+
return value.map((entry, index) => {
|
|
142
|
+
if (entry === undefined)
|
|
143
|
+
throw new TypeError(`Checkpoint array contains undefined at ${index}.`);
|
|
144
|
+
return toStorageJsonInternal(entry, ancestors);
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
const prototype = Object.getPrototypeOf(value);
|
|
148
|
+
if (prototype !== Object.prototype && prototype !== null) {
|
|
149
|
+
throw new TypeError('Checkpoint contains a non-plain object.');
|
|
150
|
+
}
|
|
151
|
+
const result = {};
|
|
152
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
153
|
+
if (entry === undefined)
|
|
154
|
+
continue;
|
|
155
|
+
result[key] = toStorageJsonInternal(entry, ancestors);
|
|
156
|
+
}
|
|
157
|
+
return result;
|
|
158
|
+
}
|
|
159
|
+
finally {
|
|
160
|
+
ancestors.delete(value);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=sqliteCheckpointAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqliteCheckpointAdapter.js","sourceRoot":"","sources":["../../../src/node/sqliteCheckpointAdapter.ts"],"names":[],"mappings":"A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,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACjD,IAAI,KAAK,KAAK,SAAS;gBAAE,SAAS;YAClC,MAAM,CAAC,GAAG,CAAC,GAAG,qBAAqB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QACxD,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;YAAS,CAAC;QACT,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { DurableChildRecord, DurableChildStore } from '../orchestration/background.js';
|
|
2
|
+
import { type CheckpointStore } from '../storage-v2/index.js';
|
|
3
|
+
export interface SqliteDurableChildStoreOptions {
|
|
4
|
+
readonly store: CheckpointStore;
|
|
5
|
+
readonly tenantId: string;
|
|
6
|
+
readonly prefix?: string;
|
|
7
|
+
}
|
|
8
|
+
/** SQLite-backed durable child records with storage-level CAS and enumeration. */
|
|
9
|
+
export declare class SqliteDurableChildStore implements DurableChildStore {
|
|
10
|
+
private readonly store;
|
|
11
|
+
private readonly tenantId;
|
|
12
|
+
private readonly prefix;
|
|
13
|
+
constructor(options: SqliteDurableChildStoreOptions);
|
|
14
|
+
create(record: DurableChildRecord): Promise<void>;
|
|
15
|
+
get(childId: string): Promise<DurableChildRecord | undefined>;
|
|
16
|
+
compareAndSet(childId: string, expectedRevision: number, next: DurableChildRecord): Promise<boolean>;
|
|
17
|
+
list(parentRunId?: string): Promise<readonly DurableChildRecord[]>;
|
|
18
|
+
private checkpointId;
|
|
19
|
+
private saveRequest;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=sqliteDurableChildStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqliteDurableChildStore.d.ts","sourceRoot":"","sources":["../../../src/node/sqliteDurableChildStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAGL,KAAK,eAAe,EAGrB,MAAM,wBAAwB,CAAC;AAGhC,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,kFAAkF;AAClF,qBAAa,uBAAwB,YAAW,iBAAiB;IAC/D,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAkB;IACxC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;gBAEpB,OAAO,EAAE,8BAA8B;IAO7C,MAAM,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAMjD,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC;IAQ7D,aAAa,CACjB,OAAO,EAAE,MAAM,EACf,gBAAgB,EAAE,MAAM,EACxB,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAAC,OAAO,CAAC;IAab,IAAI,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,kBAAkB,EAAE,CAAC;IAUxE,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,WAAW;CAoBpB"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { StorageConflictError, } from '../storage-v2/index.js';
|
|
2
|
+
import { toStorageJson } from './sqliteCheckpointAdapter.js';
|
|
3
|
+
/** SQLite-backed durable child records with storage-level CAS and enumeration. */
|
|
4
|
+
export class SqliteDurableChildStore {
|
|
5
|
+
store;
|
|
6
|
+
tenantId;
|
|
7
|
+
prefix;
|
|
8
|
+
constructor(options) {
|
|
9
|
+
if (!options.tenantId.trim())
|
|
10
|
+
throw new TypeError('tenantId must not be empty.');
|
|
11
|
+
this.store = options.store;
|
|
12
|
+
this.tenantId = options.tenantId;
|
|
13
|
+
this.prefix = options.prefix ?? 'orchestration-child:';
|
|
14
|
+
}
|
|
15
|
+
async create(record) {
|
|
16
|
+
if (record.revision !== 0)
|
|
17
|
+
throw new Error('New durable child revision must be zero.');
|
|
18
|
+
const saved = await this.store.save(this.saveRequest(record, null));
|
|
19
|
+
if (saved.revision !== record.revision)
|
|
20
|
+
throw new Error('Durable child create revision mismatch.');
|
|
21
|
+
}
|
|
22
|
+
async get(childId) {
|
|
23
|
+
const checkpoint = await this.store.load({
|
|
24
|
+
tenantId: this.tenantId,
|
|
25
|
+
checkpointId: this.checkpointId(childId),
|
|
26
|
+
});
|
|
27
|
+
return checkpoint ? checkpointToRecord(checkpoint) : undefined;
|
|
28
|
+
}
|
|
29
|
+
async compareAndSet(childId, expectedRevision, next) {
|
|
30
|
+
if (next.childId !== childId || next.revision !== expectedRevision + 1) {
|
|
31
|
+
throw new Error('Durable child CAS must advance exactly one revision.');
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
const saved = await this.store.save(this.saveRequest(next, expectedRevision));
|
|
35
|
+
return saved.revision === next.revision;
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
if (error instanceof StorageConflictError)
|
|
39
|
+
return false;
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async list(parentRunId) {
|
|
44
|
+
const checkpoints = await this.store.list({ tenantId: this.tenantId, limit: 100_000 });
|
|
45
|
+
return checkpoints
|
|
46
|
+
.filter(checkpoint => checkpoint.checkpointId.startsWith(this.prefix))
|
|
47
|
+
.map(checkpointToRecord)
|
|
48
|
+
.filter(record => parentRunId === undefined || record.parent.runId === parentRunId)
|
|
49
|
+
.sort((left, right) => left.createdAt.localeCompare(right.createdAt)
|
|
50
|
+
|| left.childId.localeCompare(right.childId));
|
|
51
|
+
}
|
|
52
|
+
checkpointId(childId) {
|
|
53
|
+
if (!childId.trim())
|
|
54
|
+
throw new TypeError('childId must not be empty.');
|
|
55
|
+
return `${this.prefix}${encodeURIComponent(childId)}`;
|
|
56
|
+
}
|
|
57
|
+
saveRequest(record, expectedRevision) {
|
|
58
|
+
return {
|
|
59
|
+
tenantId: this.tenantId,
|
|
60
|
+
checkpointId: this.checkpointId(record.childId),
|
|
61
|
+
runId: record.childId,
|
|
62
|
+
sessionId: record.parent.tenantSession.sessionId,
|
|
63
|
+
expectedRevision,
|
|
64
|
+
status: checkpointStatus(record.status),
|
|
65
|
+
state: toStorageJson(record),
|
|
66
|
+
pendingSideEffects: pendingEffects(record),
|
|
67
|
+
traceContext: {
|
|
68
|
+
traceId: record.parent.trace.traceId,
|
|
69
|
+
spanId: record.parent.trace.spanId,
|
|
70
|
+
...(record.parent.trace.parentSpanId
|
|
71
|
+
? { parentSpanId: record.parent.trace.parentSpanId }
|
|
72
|
+
: {}),
|
|
73
|
+
},
|
|
74
|
+
updatedAt: record.updatedAt,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function checkpointStatus(status) {
|
|
79
|
+
return status === 'queued' ? 'running' : status;
|
|
80
|
+
}
|
|
81
|
+
function pendingEffects(record) {
|
|
82
|
+
if (record.effect === 'read')
|
|
83
|
+
return [];
|
|
84
|
+
const status = record.status === 'queued'
|
|
85
|
+
? 'pending'
|
|
86
|
+
: record.status === 'running'
|
|
87
|
+
? 'started'
|
|
88
|
+
: record.status === 'completed'
|
|
89
|
+
? 'succeeded'
|
|
90
|
+
: record.status === 'failed'
|
|
91
|
+
? 'failed'
|
|
92
|
+
: 'unknown';
|
|
93
|
+
return [{
|
|
94
|
+
sideEffectId: record.childId,
|
|
95
|
+
kind: `background:${record.agentId}`,
|
|
96
|
+
status,
|
|
97
|
+
...(record.idempotencyKey ? { idempotencyKey: record.idempotencyKey } : {}),
|
|
98
|
+
input: toStorageJson(record.input),
|
|
99
|
+
...(record.result ? { output: toStorageJson(record.result.output) } : {}),
|
|
100
|
+
...(record.error ? { error: toStorageJson(record.error) } : {}),
|
|
101
|
+
}];
|
|
102
|
+
}
|
|
103
|
+
function checkpointToRecord(checkpoint) {
|
|
104
|
+
if (!isDurableChildRecord(checkpoint.state)) {
|
|
105
|
+
throw new TypeError(`Checkpoint "${checkpoint.checkpointId}" is not a durable child record.`);
|
|
106
|
+
}
|
|
107
|
+
if (checkpoint.state.revision !== checkpoint.revision) {
|
|
108
|
+
throw new TypeError(`Durable child "${checkpoint.state.childId}" revision does not match storage.`);
|
|
109
|
+
}
|
|
110
|
+
return structuredClone(checkpoint.state);
|
|
111
|
+
}
|
|
112
|
+
function isDurableChildRecord(value) {
|
|
113
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
114
|
+
return false;
|
|
115
|
+
const record = value;
|
|
116
|
+
return record.schemaVersion === 1
|
|
117
|
+
&& typeof record.childId === 'string'
|
|
118
|
+
&& typeof record.revision === 'number'
|
|
119
|
+
&& typeof record.parent === 'object'
|
|
120
|
+
&& typeof record.agentId === 'string'
|
|
121
|
+
&& Array.isArray(record.input)
|
|
122
|
+
&& typeof record.status === 'string';
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=sqliteDurableChildStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqliteDurableChildStore.js","sourceRoot":"","sources":["../../../src/node/sqliteDurableChildStore.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,oBAAoB,GAKrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAQ7D,kFAAkF;AAClF,MAAM,OAAO,uBAAuB;IACjB,KAAK,CAAkB;IACvB,QAAQ,CAAS;IACjB,MAAM,CAAS;IAEhC,YAAY,OAAuC;QACjD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE;YAAE,MAAM,IAAI,SAAS,CAAC,6BAA6B,CAAC,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AC;IACtF,MAAM,MAAM,GAAG,KAAgC,CAAC;IAChD,OAAO,MAAM,CAAC,aAAa,KAAK,CAAC;WAC5B,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ;WAClC,OAAO,MAAM,CAAC,QAAQ,KAAK,QAAQ;WACnC,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ;WACjC,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ;WAClC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;WAC3B,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { InputItem } from '../core/index.js';
|
|
2
|
+
import type { RuntimeSessionStore } from '../runtime-v2/state.js';
|
|
3
|
+
import type { SessionStoreV2 } from '../storage-v2/index.js';
|
|
4
|
+
export interface SqliteRuntimeSessionAdapterOptions {
|
|
5
|
+
readonly store: SessionStoreV2;
|
|
6
|
+
}
|
|
7
|
+
/** Canonical-item adapter for the append-only tenant-scoped session store. */
|
|
8
|
+
export declare class SqliteRuntimeSessionAdapter implements RuntimeSessionStore {
|
|
9
|
+
private readonly options;
|
|
10
|
+
constructor(options: SqliteRuntimeSessionAdapterOptions);
|
|
11
|
+
close(): void;
|
|
12
|
+
load(request: {
|
|
13
|
+
readonly tenantId: string;
|
|
14
|
+
readonly sessionId: string;
|
|
15
|
+
}): Promise<{
|
|
16
|
+
readonly items: readonly InputItem[];
|
|
17
|
+
readonly revision: string;
|
|
18
|
+
}>;
|
|
19
|
+
append(request: {
|
|
20
|
+
readonly tenantId: string;
|
|
21
|
+
readonly sessionId: string;
|
|
22
|
+
readonly items: readonly InputItem[];
|
|
23
|
+
readonly expectedRevision: string;
|
|
24
|
+
}): Promise<{
|
|
25
|
+
readonly revision: string;
|
|
26
|
+
}>;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=sqliteSessionAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqliteSessionAdapter.d.ts","sourceRoot":"","sources":["../../../src/node/sqliteSessionAdapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAI7D,MAAM,WAAW,kCAAkC;IACjD,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;CAChC;AAED,8EAA8E;AAC9E,qBAAa,2BAA4B,YAAW,mBAAmB;IACzD,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,kCAAkC;IAExE,KAAK,IAAI,IAAI;IAIP,IAAI,CAAC,OAAO,EAAE;QAClB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;KAC5B,GAAG,OAAO,CAAC;QAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,CAAC;QAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IAkB1E,MAAM,CAAC,OAAO,EAAE;QACpB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;QAC3B,QAAQ,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,CAAC;QACrC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;KACnC,GAAG,OAAO,CAAC;QAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;CAiB3C"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { convertLegacyJsonV1Message } from '../storage-v2/legacyJsonV1Items.js';
|
|
3
|
+
import { toStorageJson } from './sqliteCheckpointAdapter.js';
|
|
4
|
+
/** Canonical-item adapter for the append-only tenant-scoped session store. */
|
|
5
|
+
export class SqliteRuntimeSessionAdapter {
|
|
6
|
+
options;
|
|
7
|
+
constructor(options) {
|
|
8
|
+
this.options = options;
|
|
9
|
+
}
|
|
10
|
+
close() {
|
|
11
|
+
// The adapter does not own the shared DurableStorageV2 connection.
|
|
12
|
+
}
|
|
13
|
+
async load(request) {
|
|
14
|
+
let session = await this.options.store.get(request);
|
|
15
|
+
if (!session) {
|
|
16
|
+
try {
|
|
17
|
+
session = await this.options.store.create(request);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
// A concurrent creator may win between get/create. Re-read before surfacing it.
|
|
21
|
+
session = await this.options.store.get(request);
|
|
22
|
+
if (!session)
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const loaded = await this.options.store.load({ ...request, afterSequence: 0 });
|
|
27
|
+
return {
|
|
28
|
+
items: loaded.items.flatMap(item => parseSessionItem(item.kind, item.payload, item.itemId)),
|
|
29
|
+
revision: String(loaded.session.revision),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
async append(request) {
|
|
33
|
+
const expectedRevision = Number(request.expectedRevision);
|
|
34
|
+
if (!Number.isSafeInteger(expectedRevision) || expectedRevision < 0) {
|
|
35
|
+
throw new TypeError(`Invalid session revision "${request.expectedRevision}".`);
|
|
36
|
+
}
|
|
37
|
+
const saved = await this.options.store.append({
|
|
38
|
+
tenantId: request.tenantId,
|
|
39
|
+
sessionId: request.sessionId,
|
|
40
|
+
expectedRevision,
|
|
41
|
+
items: request.items.map(item => ({
|
|
42
|
+
itemId: item.id ?? randomUUID(),
|
|
43
|
+
kind: item.type,
|
|
44
|
+
payload: toStorageJson(item),
|
|
45
|
+
})),
|
|
46
|
+
});
|
|
47
|
+
return { revision: String(saved.revision) };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function parseSessionItem(kind, value, itemId) {
|
|
51
|
+
// JSON-v1 run records are audit metadata, not conversation messages. Accept
|
|
52
|
+
// both the final name and the name emitted by early storage-v2 previews.
|
|
53
|
+
if (kind === 'legacy_run' || kind === 'run')
|
|
54
|
+
return [];
|
|
55
|
+
if (kind === 'message' && !isCanonicalItem(value)) {
|
|
56
|
+
return convertLegacyJsonV1Message(value, `session item "${itemId}"`);
|
|
57
|
+
}
|
|
58
|
+
const item = parseCanonicalItem(value, itemId);
|
|
59
|
+
// Provider-specific blocks from an unknown legacy provider cannot safely be
|
|
60
|
+
// replayed to a different provider. They remain in the append journal for
|
|
61
|
+
// audit/export, but are intentionally omitted from the active transcript.
|
|
62
|
+
if (item.type === 'raw' && item.provider === 'legacy')
|
|
63
|
+
return [];
|
|
64
|
+
return [item];
|
|
65
|
+
}
|
|
66
|
+
function parseCanonicalItem(value, itemId) {
|
|
67
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
68
|
+
throw new TypeError(`Session item "${itemId}" is not a canonical object.`);
|
|
69
|
+
}
|
|
70
|
+
const type = value.type;
|
|
71
|
+
if (typeof type !== 'string' || !CANONICAL_ITEM_TYPES.has(type)) {
|
|
72
|
+
throw new TypeError(`Session item "${itemId}" has unknown canonical type ${String(type)}.`);
|
|
73
|
+
}
|
|
74
|
+
return structuredClone(value);
|
|
75
|
+
}
|
|
76
|
+
function isCanonicalItem(value) {
|
|
77
|
+
return typeof value === 'object'
|
|
78
|
+
&& value !== null
|
|
79
|
+
&& !Array.isArray(value)
|
|
80
|
+
&& typeof value.type === 'string'
|
|
81
|
+
&& CANONICAL_ITEM_TYPES.has(value.type);
|
|
82
|
+
}
|
|
83
|
+
const CANONICAL_ITEM_TYPES = new Set([
|
|
84
|
+
'text',
|
|
85
|
+
'image',
|
|
86
|
+
'audio',
|
|
87
|
+
'document',
|
|
88
|
+
'artifact_ref',
|
|
89
|
+
'tool_call',
|
|
90
|
+
'tool_result',
|
|
91
|
+
'handoff_call',
|
|
92
|
+
'handoff_result',
|
|
93
|
+
'reasoning',
|
|
94
|
+
'raw',
|
|
95
|
+
'structured',
|
|
96
|
+
'refusal',
|
|
97
|
+
'error',
|
|
98
|
+
]);
|
|
99
|
+
//# sourceMappingURL=sqliteSessionAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqliteSessionAdapter.js","sourceRoot":"","sources":["../../../src/node/sqliteSessionAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAKzC,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAM7D,8EAA8E;AAC9E,MAAM,OAAO,2BAA2B;IACT;IAA7B,YAA6B,OAA2C;QAA3C,YAAO,GAAP,OAAO,CAAoC;IAAG,CAAC;IAE5E,KAAK;QACH,mEAAmE;IACrE,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,OAGV;QACC,IAAI,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACpD,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,IAAI,CAAC;gBACH,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YACrD,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,gFAAgF;gBAChF,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;gBAChD,IAAI,CAAC,OAAO;oBAAE,MAAM,KAAK,CAAC;YAC5B,CAAC;QACH,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,OAAO,EAAE,aAAa,EAAE,CAAC,EAAE,CAAC,CAAC;QAC/E,OAAO;YACL,KAAK,EAAE,MAAM,CAA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,oBAAoB,GAAG,IAAI,GAAG,CAAC;IACnC,MAAM;IACN,OAAO;IACP,OAAO;IACP,UAAU;IACV,cAAc;IACd,WAAW;IACX,aAAa;IACb,cAAc;IACd,gBAAgB;IAChB,WAAW;IACX,KAAK;IACL,YAAY;IACZ,SAAS;IACT,OAAO;CACR,CAAC,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type AgentSpec, type JsonObject, type JsonValue, type ToolResultItem } from '../core/index.js';
|
|
2
|
+
import type { RuntimeTool, ToolBehavior, ToolExecutionContext, ToolSchema } from '../runtime-v2/tools.js';
|
|
3
|
+
import type { ChildFailurePolicy, ChildRunOutcome, ConversationState, OrchestrationInput, OrchestrationScope } from './contracts.js';
|
|
4
|
+
import { ChildRunner } from './childRunner.js';
|
|
5
|
+
export interface AgentToolOptions<TChildContext = unknown, TOutput = string> {
|
|
6
|
+
readonly name?: string;
|
|
7
|
+
readonly description?: string;
|
|
8
|
+
readonly mapInput?: (input: JsonValue) => OrchestrationInput;
|
|
9
|
+
readonly childContext?: (input: JsonValue) => TChildContext;
|
|
10
|
+
readonly failurePolicy?: ChildFailurePolicy;
|
|
11
|
+
readonly effect?: ToolBehavior['effect'];
|
|
12
|
+
readonly idempotencyKey?: (input: JsonValue) => string | undefined;
|
|
13
|
+
readonly metadata?: Readonly<JsonObject>;
|
|
14
|
+
readonly _output?: TOutput;
|
|
15
|
+
}
|
|
16
|
+
export interface AgentToolInvocation<TChildContext = unknown> {
|
|
17
|
+
readonly parent: OrchestrationScope;
|
|
18
|
+
readonly conversation: ConversationState;
|
|
19
|
+
readonly callId: string;
|
|
20
|
+
readonly input: JsonValue;
|
|
21
|
+
readonly context?: TChildContext;
|
|
22
|
+
}
|
|
23
|
+
export interface AgentToolInvocationResult<TOutput = string> {
|
|
24
|
+
readonly mode: 'agent-as-tool';
|
|
25
|
+
readonly ownerBefore: ConversationState['owner'];
|
|
26
|
+
readonly ownerAfter: ConversationState['owner'];
|
|
27
|
+
readonly conversation: ConversationState;
|
|
28
|
+
readonly toolResult: ToolResultItem;
|
|
29
|
+
readonly child: ChildRunOutcome<TOutput>;
|
|
30
|
+
}
|
|
31
|
+
export interface RuntimeToolAdapterOptions<TManagerContext> {
|
|
32
|
+
readonly scope: (managerContext: TManagerContext, execution: ToolExecutionContext<TManagerContext>) => OrchestrationScope;
|
|
33
|
+
readonly managerAgentId?: (managerContext: TManagerContext, execution: ToolExecutionContext<TManagerContext>) => string;
|
|
34
|
+
readonly inputSchema?: ToolSchema<JsonValue>;
|
|
35
|
+
}
|
|
36
|
+
/** Agent-as-tool is a child invocation; its internal transcript never takes ownership. */
|
|
37
|
+
export declare class AgentTool<TChildContext = unknown, TOutput = string> {
|
|
38
|
+
readonly agent: AgentSpec<TChildContext, TOutput>;
|
|
39
|
+
private readonly runner;
|
|
40
|
+
private readonly options;
|
|
41
|
+
readonly name: string;
|
|
42
|
+
readonly description: string;
|
|
43
|
+
constructor(agent: AgentSpec<TChildContext, TOutput>, runner: ChildRunner, options?: AgentToolOptions<TChildContext, TOutput>);
|
|
44
|
+
invoke(invocation: AgentToolInvocation<TChildContext>): Promise<AgentToolInvocationResult<TOutput>>;
|
|
45
|
+
/** Adapter for runtime-v2 ToolRegistry; the manager runtime creates the final item. */
|
|
46
|
+
asRuntimeTool<TManagerContext>(adapter: RuntimeToolAdapterOptions<TManagerContext>): RuntimeTool<TManagerContext, JsonValue, JsonValue>;
|
|
47
|
+
private mapInput;
|
|
48
|
+
}
|
|
49
|
+
export declare function agentAsTool<TChildContext = unknown, TOutput = string>(agent: AgentSpec<TChildContext, TOutput>, runner: ChildRunner, options?: AgentToolOptions<TChildContext, TOutput>): AgentTool<TChildContext, TOutput>;
|
|
50
|
+
//# sourceMappingURL=agentTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentTool.d.ts","sourceRoot":"","sources":["../../../src/orchestration/agentTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,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