@assemblyline-agents/runtime 1.0.0 → 3.0.0
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/LICENSE +1 -1
- package/dist/a2a-client.d.ts +22 -0
- package/dist/a2a-client.d.ts.map +1 -0
- package/dist/a2a-client.js +211 -0
- package/dist/a2a-client.js.map +1 -0
- package/dist/agent-capability-snapshot.d.ts +32 -0
- package/dist/agent-capability-snapshot.d.ts.map +1 -0
- package/dist/agent-capability-snapshot.js +77 -0
- package/dist/agent-capability-snapshot.js.map +1 -0
- package/dist/agent-event-handlers.d.ts +21 -0
- package/dist/agent-event-handlers.d.ts.map +1 -0
- package/dist/agent-event-handlers.js +64 -0
- package/dist/agent-event-handlers.js.map +1 -0
- package/dist/agent-hook-context.d.ts +8 -0
- package/dist/agent-hook-context.d.ts.map +1 -0
- package/dist/agent-hook-context.js +29 -0
- package/dist/agent-hook-context.js.map +1 -0
- package/dist/agent-hook-evaluation.d.ts +61 -0
- package/dist/agent-hook-evaluation.d.ts.map +1 -0
- package/dist/agent-hook-evaluation.js +197 -0
- package/dist/agent-hook-evaluation.js.map +1 -0
- package/dist/agent-hook-run-lifecycle.d.ts +44 -0
- package/dist/agent-hook-run-lifecycle.d.ts.map +1 -0
- package/dist/agent-hook-run-lifecycle.js +76 -0
- package/dist/agent-hook-run-lifecycle.js.map +1 -0
- package/dist/agent-state.d.ts +31 -0
- package/dist/agent-state.d.ts.map +1 -0
- package/dist/agent-state.js +80 -0
- package/dist/agent-state.js.map +1 -0
- package/dist/agent-surface.d.ts +32 -0
- package/dist/agent-surface.d.ts.map +1 -0
- package/dist/agent-surface.js +85 -0
- package/dist/agent-surface.js.map +1 -0
- package/dist/attachments.d.ts +5 -1
- package/dist/attachments.d.ts.map +1 -1
- package/dist/attachments.js +58 -32
- package/dist/attachments.js.map +1 -1
- package/dist/audience.d.ts +30 -0
- package/dist/audience.d.ts.map +1 -0
- package/dist/audience.js +68 -0
- package/dist/audience.js.map +1 -0
- package/dist/authored-hooks.d.ts +6 -0
- package/dist/authored-hooks.d.ts.map +1 -0
- package/dist/authored-hooks.js +17 -0
- package/dist/authored-hooks.js.map +1 -0
- package/dist/automation-event-match.d.ts +8 -0
- package/dist/automation-event-match.d.ts.map +1 -0
- package/dist/automation-event-match.js +25 -0
- package/dist/automation-event-match.js.map +1 -0
- package/dist/background-review-trigger.d.ts +9 -0
- package/dist/background-review-trigger.d.ts.map +1 -0
- package/dist/background-review-trigger.js +72 -0
- package/dist/background-review-trigger.js.map +1 -0
- package/dist/background-review-types.d.ts +60 -0
- package/dist/background-review-types.d.ts.map +1 -0
- package/dist/background-review-types.js +2 -0
- package/dist/background-review-types.js.map +1 -0
- package/dist/background-review-worker.d.ts +14 -0
- package/dist/background-review-worker.d.ts.map +1 -0
- package/dist/background-review-worker.js +61 -0
- package/dist/background-review-worker.js.map +1 -0
- package/dist/background-review.d.ts +5 -0
- package/dist/background-review.d.ts.map +1 -0
- package/dist/background-review.js +332 -0
- package/dist/background-review.js.map +1 -0
- package/dist/builtin-tool-executors.d.ts +50 -27
- package/dist/builtin-tool-executors.d.ts.map +1 -1
- package/dist/builtin-tool-executors.js +332 -124
- package/dist/builtin-tool-executors.js.map +1 -1
- package/dist/builtin-tools.d.ts +16 -9
- package/dist/builtin-tools.d.ts.map +1 -1
- package/dist/builtin-tools.js +308 -116
- package/dist/builtin-tools.js.map +1 -1
- package/dist/capability-catalog.d.ts +3 -2
- package/dist/capability-catalog.d.ts.map +1 -1
- package/dist/capability-catalog.js +12 -7
- package/dist/capability-catalog.js.map +1 -1
- package/dist/capability-inspection.d.ts +31 -0
- package/dist/capability-inspection.d.ts.map +1 -0
- package/dist/capability-inspection.js +58 -0
- package/dist/capability-inspection.js.map +1 -0
- package/dist/channel-http-util.d.ts.map +1 -1
- package/dist/channel-http-util.js +6 -5
- package/dist/channel-http-util.js.map +1 -1
- package/dist/channel-ingress.d.ts +16 -1
- package/dist/channel-ingress.d.ts.map +1 -1
- package/dist/channel-ingress.js +152 -14
- package/dist/channel-ingress.js.map +1 -1
- package/dist/channel.d.ts +73 -3
- package/dist/channel.d.ts.map +1 -1
- package/dist/checkpoints.d.ts +1 -1
- package/dist/checkpoints.d.ts.map +1 -1
- package/dist/checkpoints.js +6 -6
- package/dist/checkpoints.js.map +1 -1
- package/dist/child-process-env.d.ts +7 -0
- package/dist/child-process-env.d.ts.map +1 -0
- package/dist/child-process-env.js +41 -0
- package/dist/child-process-env.js.map +1 -0
- package/dist/computer-relay-protocol.d.ts.map +1 -1
- package/dist/computer-relay-protocol.js +4 -4
- package/dist/computer-relay-protocol.js.map +1 -1
- package/dist/concurrency.d.ts +1 -1
- package/dist/concurrency.js +1 -1
- package/dist/connection-auth-util.d.ts +1 -0
- package/dist/connection-auth-util.d.ts.map +1 -1
- package/dist/connection-auth-util.js +3 -1
- package/dist/connection-auth-util.js.map +1 -1
- package/dist/connection-clients.d.ts +11 -3
- package/dist/connection-clients.d.ts.map +1 -1
- package/dist/connection-clients.js +71 -8
- package/dist/connection-clients.js.map +1 -1
- package/dist/connection-event-store.d.ts +98 -0
- package/dist/connection-event-store.d.ts.map +1 -0
- package/dist/connection-event-store.js +162 -0
- package/dist/connection-event-store.js.map +1 -0
- package/dist/connection-events.d.ts +51 -0
- package/dist/connection-events.d.ts.map +1 -0
- package/dist/connection-events.js +343 -0
- package/dist/connection-events.js.map +1 -0
- package/dist/connection-stores.d.ts +6 -0
- package/dist/connection-stores.d.ts.map +1 -1
- package/dist/connection-stores.js +20 -1
- package/dist/connection-stores.js.map +1 -1
- package/dist/connection-util.d.ts +3 -2
- package/dist/connection-util.d.ts.map +1 -1
- package/dist/connection-util.js +18 -1
- package/dist/connection-util.js.map +1 -1
- package/dist/connections.d.ts +60 -5
- package/dist/connections.d.ts.map +1 -1
- package/dist/connections.js +390 -57
- package/dist/connections.js.map +1 -1
- package/dist/context-policy-util.d.ts.map +1 -1
- package/dist/context-policy-util.js +1 -3
- package/dist/context-policy-util.js.map +1 -1
- package/dist/conversation-context.d.ts +9 -4
- package/dist/conversation-context.d.ts.map +1 -1
- package/dist/conversation-context.js +65 -19
- package/dist/conversation-context.js.map +1 -1
- package/dist/conversation-transcript.d.ts +8 -5
- package/dist/conversation-transcript.d.ts.map +1 -1
- package/dist/conversation-transcript.js +24 -5
- package/dist/conversation-transcript.js.map +1 -1
- package/dist/conversation-turn-coalescing.d.ts +22 -0
- package/dist/conversation-turn-coalescing.d.ts.map +1 -0
- package/dist/conversation-turn-coalescing.js +121 -0
- package/dist/conversation-turn-coalescing.js.map +1 -0
- package/dist/conversation-turn-dispatch.d.ts +5 -2
- package/dist/conversation-turn-dispatch.d.ts.map +1 -1
- package/dist/conversation-turn-dispatch.js +59 -22
- package/dist/conversation-turn-dispatch.js.map +1 -1
- package/dist/default-outbound-route.d.ts +29 -0
- package/dist/default-outbound-route.d.ts.map +1 -0
- package/dist/default-outbound-route.js +105 -0
- package/dist/default-outbound-route.js.map +1 -0
- package/dist/delivery-artifacts.d.ts +2 -0
- package/dist/delivery-artifacts.d.ts.map +1 -0
- package/dist/delivery-artifacts.js +34 -0
- package/dist/delivery-artifacts.js.map +1 -0
- package/dist/delivery-files.d.ts +5 -0
- package/dist/delivery-files.d.ts.map +1 -0
- package/dist/delivery-files.js +33 -0
- package/dist/delivery-files.js.map +1 -0
- package/dist/delivery-queue.d.ts +21 -1
- package/dist/delivery-queue.d.ts.map +1 -1
- package/dist/delivery-queue.js +144 -1
- package/dist/delivery-queue.js.map +1 -1
- package/dist/delivery-send.d.ts +2 -2
- package/dist/delivery-send.d.ts.map +1 -1
- package/dist/delivery-send.js +256 -100
- package/dist/delivery-send.js.map +1 -1
- package/dist/durable-files.d.ts +37 -0
- package/dist/durable-files.d.ts.map +1 -0
- package/dist/durable-files.js +63 -0
- package/dist/durable-files.js.map +1 -0
- package/dist/harness-loop.d.ts +18 -9
- package/dist/harness-loop.d.ts.map +1 -1
- package/dist/harness-loop.js +245 -50
- package/dist/harness-loop.js.map +1 -1
- package/dist/heic-transcode-worker.d.ts +2 -0
- package/dist/heic-transcode-worker.d.ts.map +1 -0
- package/dist/heic-transcode-worker.js +59 -0
- package/dist/heic-transcode-worker.js.map +1 -0
- package/dist/heic-transcode.d.ts +18 -0
- package/dist/heic-transcode.d.ts.map +1 -0
- package/dist/heic-transcode.js +99 -0
- package/dist/heic-transcode.js.map +1 -0
- package/dist/human-input-routing.d.ts +22 -0
- package/dist/human-input-routing.d.ts.map +1 -0
- package/dist/human-input-routing.js +26 -0
- package/dist/human-input-routing.js.map +1 -0
- package/dist/in-memory-agent-state-store.d.ts +21 -0
- package/dist/in-memory-agent-state-store.d.ts.map +1 -0
- package/dist/in-memory-agent-state-store.js +97 -0
- package/dist/in-memory-agent-state-store.js.map +1 -0
- package/dist/in-memory-conversation-turn-store.d.ts +3 -1
- package/dist/in-memory-conversation-turn-store.d.ts.map +1 -1
- package/dist/in-memory-conversation-turn-store.js +41 -2
- package/dist/in-memory-conversation-turn-store.js.map +1 -1
- package/dist/in-memory-run-store.d.ts +8 -0
- package/dist/in-memory-run-store.d.ts.map +1 -1
- package/dist/in-memory-run-store.js +28 -5
- package/dist/in-memory-run-store.js.map +1 -1
- package/dist/in-memory-sandbox-session-store.d.ts +2 -1
- package/dist/in-memory-sandbox-session-store.d.ts.map +1 -1
- package/dist/in-memory-sandbox-session-store.js +65 -1
- package/dist/in-memory-sandbox-session-store.js.map +1 -1
- package/dist/in-memory-small-stores.d.ts +18 -1
- package/dist/in-memory-small-stores.d.ts.map +1 -1
- package/dist/in-memory-small-stores.js +107 -1
- package/dist/in-memory-small-stores.js.map +1 -1
- package/dist/in-memory-workspace-store.d.ts +40 -0
- package/dist/in-memory-workspace-store.d.ts.map +1 -0
- package/dist/in-memory-workspace-store.js +370 -0
- package/dist/in-memory-workspace-store.js.map +1 -0
- package/dist/index.d.ts +116 -45
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +637 -566
- package/dist/index.js.map +1 -1
- package/dist/json-util.d.ts +8 -0
- package/dist/json-util.d.ts.map +1 -1
- package/dist/json-util.js +8 -0
- package/dist/json-util.js.map +1 -1
- package/dist/learning-store.d.ts +111 -0
- package/dist/learning-store.d.ts.map +1 -0
- package/dist/learning-store.js +193 -0
- package/dist/learning-store.js.map +1 -0
- package/dist/local-sandbox.d.ts +3 -2
- package/dist/local-sandbox.d.ts.map +1 -1
- package/dist/local-sandbox.js +69 -25
- package/dist/local-sandbox.js.map +1 -1
- package/dist/mcp-client.d.ts.map +1 -1
- package/dist/mcp-client.js +3 -2
- package/dist/mcp-client.js.map +1 -1
- package/dist/media-processor.d.ts +42 -0
- package/dist/media-processor.d.ts.map +1 -0
- package/dist/media-processor.js +2 -0
- package/dist/media-processor.js.map +1 -0
- package/dist/model-media.d.ts +13 -1
- package/dist/model-media.d.ts.map +1 -1
- package/dist/model-media.js +81 -18
- package/dist/model-media.js.map +1 -1
- package/dist/model-visible-interrupts.d.ts +10 -0
- package/dist/model-visible-interrupts.d.ts.map +1 -0
- package/dist/model-visible-interrupts.js +41 -0
- package/dist/model-visible-interrupts.js.map +1 -0
- package/dist/operator-controls.d.ts.map +1 -1
- package/dist/operator-controls.js +16 -3
- package/dist/operator-controls.js.map +1 -1
- package/dist/outbound-http-policy.d.ts +7 -0
- package/dist/outbound-http-policy.d.ts.map +1 -0
- package/dist/outbound-http-policy.js +155 -0
- package/dist/outbound-http-policy.js.map +1 -0
- package/dist/principals.d.ts +18 -0
- package/dist/principals.d.ts.map +1 -0
- package/dist/principals.js +90 -0
- package/dist/principals.js.map +1 -0
- package/dist/public-api.d.ts +21 -0
- package/dist/public-api.d.ts.map +1 -0
- package/dist/public-api.js +19 -0
- package/dist/public-api.js.map +1 -0
- package/dist/replay-resume.d.ts +15 -3
- package/dist/replay-resume.d.ts.map +1 -1
- package/dist/replay-resume.js +256 -24
- package/dist/replay-resume.js.map +1 -1
- package/dist/resource-projection-util.d.ts +1 -1
- package/dist/resource-projection-util.d.ts.map +1 -1
- package/dist/resource-projection-util.js +21 -10
- package/dist/resource-projection-util.js.map +1 -1
- package/dist/resource-projection.d.ts +8 -1
- package/dist/resource-projection.d.ts.map +1 -1
- package/dist/resource-projection.js +230 -26
- package/dist/resource-projection.js.map +1 -1
- package/dist/run-heartbeat.d.ts +12 -2
- package/dist/run-heartbeat.d.ts.map +1 -1
- package/dist/run-heartbeat.js +31 -4
- package/dist/run-heartbeat.js.map +1 -1
- package/dist/run-outcome.d.ts +9 -5
- package/dist/run-outcome.d.ts.map +1 -1
- package/dist/run-outcome.js +16 -5
- package/dist/run-outcome.js.map +1 -1
- package/dist/run-recovery.d.ts +31 -2
- package/dist/run-recovery.d.ts.map +1 -1
- package/dist/run-recovery.js +211 -32
- package/dist/run-recovery.js.map +1 -1
- package/dist/run-replay.d.ts +35 -0
- package/dist/run-replay.d.ts.map +1 -0
- package/dist/run-replay.js +193 -0
- package/dist/run-replay.js.map +1 -0
- package/dist/run-result.d.ts +4 -0
- package/dist/run-result.d.ts.map +1 -0
- package/dist/run-result.js +18 -0
- package/dist/run-result.js.map +1 -0
- package/dist/run-timeline-query.d.ts +38 -0
- package/dist/run-timeline-query.d.ts.map +1 -0
- package/dist/run-timeline-query.js +99 -0
- package/dist/run-timeline-query.js.map +1 -0
- package/dist/runs-query.d.ts.map +1 -1
- package/dist/runs-query.js +12 -4
- package/dist/runs-query.js.map +1 -1
- package/dist/runtime-bundle.d.ts.map +1 -1
- package/dist/runtime-bundle.js +2 -0
- package/dist/runtime-bundle.js.map +1 -1
- package/dist/runtime-learning.d.ts +88 -0
- package/dist/runtime-learning.d.ts.map +1 -0
- package/dist/runtime-learning.js +260 -0
- package/dist/runtime-learning.js.map +1 -0
- package/dist/runtime-types.d.ts +79 -10
- package/dist/runtime-types.d.ts.map +1 -1
- package/dist/sandbox-fs.d.ts +9 -5
- package/dist/sandbox-fs.d.ts.map +1 -1
- package/dist/sandbox-fs.js +50 -33
- package/dist/sandbox-fs.js.map +1 -1
- package/dist/sandbox-handle.d.ts +25 -0
- package/dist/sandbox-handle.d.ts.map +1 -0
- package/dist/sandbox-handle.js +120 -0
- package/dist/sandbox-handle.js.map +1 -0
- package/dist/sandbox-session-identity.d.ts +14 -0
- package/dist/sandbox-session-identity.d.ts.map +1 -0
- package/dist/sandbox-session-identity.js +33 -0
- package/dist/sandbox-session-identity.js.map +1 -0
- package/dist/sandbox-session-key.d.ts.map +1 -1
- package/dist/sandbox-session-key.js +14 -10
- package/dist/sandbox-session-key.js.map +1 -1
- package/dist/sandbox-session-lifecycle.d.ts +12 -0
- package/dist/sandbox-session-lifecycle.d.ts.map +1 -0
- package/dist/sandbox-session-lifecycle.js +261 -0
- package/dist/sandbox-session-lifecycle.js.map +1 -0
- package/dist/sandbox-snapshot-policy.js +3 -3
- package/dist/sandbox-snapshot-policy.js.map +1 -1
- package/dist/sandbox-state-sync.d.ts +22 -0
- package/dist/sandbox-state-sync.d.ts.map +1 -0
- package/dist/sandbox-state-sync.js +147 -0
- package/dist/sandbox-state-sync.js.map +1 -0
- package/dist/sandbox-sync-worker.d.ts +11 -2
- package/dist/sandbox-sync-worker.d.ts.map +1 -1
- package/dist/sandbox-sync-worker.js +143 -31
- package/dist/sandbox-sync-worker.js.map +1 -1
- package/dist/schedule-execution.d.ts.map +1 -1
- package/dist/schedule-execution.js +187 -57
- package/dist/schedule-execution.js.map +1 -1
- package/dist/sdk-api-client.d.ts +17 -0
- package/dist/sdk-api-client.d.ts.map +1 -0
- package/dist/sdk-api-client.js +55 -0
- package/dist/sdk-api-client.js.map +1 -0
- package/dist/security.js +2 -2
- package/dist/security.js.map +1 -1
- package/dist/self-improvement.d.ts +34 -6
- package/dist/self-improvement.d.ts.map +1 -1
- package/dist/self-improvement.js +140 -34
- package/dist/self-improvement.js.map +1 -1
- package/dist/skill-bundles.d.ts +55 -0
- package/dist/skill-bundles.d.ts.map +1 -0
- package/dist/skill-bundles.js +134 -0
- package/dist/skill-bundles.js.map +1 -0
- package/dist/source-loader.d.ts +8 -0
- package/dist/source-loader.d.ts.map +1 -1
- package/dist/source-loader.js +41 -10
- package/dist/source-loader.js.map +1 -1
- package/dist/state-store-helpers.d.ts +2 -0
- package/dist/state-store-helpers.d.ts.map +1 -1
- package/dist/state-store-helpers.js +11 -1
- package/dist/state-store-helpers.js.map +1 -1
- package/dist/state-stores.d.ts +2 -0
- package/dist/state-stores.d.ts.map +1 -1
- package/dist/state-stores.js +40 -7
- package/dist/state-stores.js.map +1 -1
- package/dist/state.d.ts +344 -5
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +44 -2
- package/dist/state.js.map +1 -1
- package/dist/storage.d.ts +59 -2
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +183 -6
- package/dist/storage.js.map +1 -1
- package/dist/subagent-execution.d.ts +7 -6
- package/dist/subagent-execution.d.ts.map +1 -1
- package/dist/subagent-execution.js +58 -19
- package/dist/subagent-execution.js.map +1 -1
- package/dist/target-instructions.d.ts +14 -0
- package/dist/target-instructions.d.ts.map +1 -0
- package/dist/target-instructions.js +18 -0
- package/dist/target-instructions.js.map +1 -0
- package/dist/tool-apis.d.ts.map +1 -1
- package/dist/tool-apis.js +55 -10
- package/dist/tool-apis.js.map +1 -1
- package/dist/tool-execution.d.ts +26 -13
- package/dist/tool-execution.d.ts.map +1 -1
- package/dist/tool-execution.js +368 -239
- package/dist/tool-execution.js.map +1 -1
- package/dist/turn-media.d.ts +29 -0
- package/dist/turn-media.d.ts.map +1 -0
- package/dist/turn-media.js +233 -0
- package/dist/turn-media.js.map +1 -0
- package/dist/usage-reconciliation.d.ts +1 -1
- package/dist/usage-reconciliation.js +1 -1
- package/dist/workspace-id.d.ts +10 -0
- package/dist/workspace-id.d.ts.map +1 -0
- package/dist/workspace-id.js +55 -0
- package/dist/workspace-id.js.map +1 -0
- package/dist/workspace-manifest.d.ts +24 -0
- package/dist/workspace-manifest.d.ts.map +1 -0
- package/dist/workspace-manifest.js +111 -0
- package/dist/workspace-manifest.js.map +1 -0
- package/dist/workspace-operation-limiter.d.ts +16 -0
- package/dist/workspace-operation-limiter.d.ts.map +1 -0
- package/dist/workspace-operation-limiter.js +31 -0
- package/dist/workspace-operation-limiter.js.map +1 -0
- package/dist/workspace-operations.d.ts +145 -0
- package/dist/workspace-operations.d.ts.map +1 -0
- package/dist/workspace-operations.js +420 -0
- package/dist/workspace-operations.js.map +1 -0
- package/dist/workspace-runtime.d.ts +110 -0
- package/dist/workspace-runtime.d.ts.map +1 -0
- package/dist/workspace-runtime.js +240 -0
- package/dist/workspace-runtime.js.map +1 -0
- package/dist/workspace-search.d.ts +55 -0
- package/dist/workspace-search.d.ts.map +1 -0
- package/dist/workspace-search.js +262 -0
- package/dist/workspace-search.js.map +1 -0
- package/dist/workspace-service.d.ts +173 -0
- package/dist/workspace-service.d.ts.map +1 -0
- package/dist/workspace-service.js +619 -0
- package/dist/workspace-service.js.map +1 -0
- package/dist/workspace.d.ts +7 -0
- package/dist/workspace.d.ts.map +1 -0
- package/dist/workspace.js +7 -0
- package/dist/workspace.js.map +1 -0
- package/package.json +7 -4
- package/dist/agent-harness.d.ts +0 -108
- package/dist/agent-harness.d.ts.map +0 -1
- package/dist/agent-harness.js +0 -2
- package/dist/agent-harness.js.map +0 -1
- package/dist/attachments-legacy.d.ts +0 -17
- package/dist/attachments-legacy.d.ts.map +0 -1
- package/dist/attachments-legacy.js +0 -273
- package/dist/attachments-legacy.js.map +0 -1
- package/dist/code-mode.d.ts +0 -20
- package/dist/code-mode.d.ts.map +0 -1
- package/dist/code-mode.js +0 -658
- package/dist/code-mode.js.map +0 -1
- package/dist/hook-dispatch.d.ts +0 -19
- package/dist/hook-dispatch.d.ts.map +0 -1
- package/dist/hook-dispatch.js +0 -37
- package/dist/hook-dispatch.js.map +0 -1
- package/dist/pi-agent-harness.d.ts +0 -40
- package/dist/pi-agent-harness.d.ts.map +0 -1
- package/dist/pi-agent-harness.js +0 -222
- package/dist/pi-agent-harness.js.map +0 -1
- package/dist/pi-harness.d.ts +0 -42
- package/dist/pi-harness.d.ts.map +0 -1
- package/dist/pi-harness.js +0 -142
- package/dist/pi-harness.js.map +0 -1
- package/dist/run-resolver.d.ts +0 -35
- package/dist/run-resolver.d.ts.map +0 -1
- package/dist/run-resolver.js +0 -84
- package/dist/run-resolver.js.map +0 -1
- package/dist/usage-budget.d.ts +0 -29
- package/dist/usage-budget.d.ts.map +0 -1
- package/dist/usage-budget.js +0 -145
- package/dist/usage-budget.js.map +0 -1
|
@@ -1,37 +1,71 @@
|
|
|
1
|
-
import { isConnectionAuthorizationRequiredError, shellQuote } from "@assemblyline-agents/core";
|
|
2
|
-
import {
|
|
1
|
+
import { isConnectionAuthorizationRequiredError, isRecoverableToolError, shellQuote } from "@assemblyline-agents/core";
|
|
2
|
+
import { HISTORY_SEARCH_TOOL_NAME, LOAD_SKILL_TOOL_NAME, PAIR_TOOL_NAME, runtimeToolsForSurface, TOOL_SEARCH_TOOL_NAME } from "./builtin-tools.js";
|
|
3
3
|
import { connectionSearchResultForModel, normalizeDeferredToolSearchInput } from "./capability-catalog.js";
|
|
4
|
-
import { CONNECTION_SEARCH_TOOL_NAME, parseQualifiedName, RuntimeConnectionRegistry } from "./connections.js";
|
|
4
|
+
import { CONNECTION_SEARCH_TOOL_NAME, isConnectionConfigurationError, parseQualifiedName, RuntimeConnectionRegistry } from "./connections.js";
|
|
5
5
|
import { evalRunOptionsForRun } from "./eval-run-options.js";
|
|
6
|
-
import { isJsonObject, redactedToolInput, safeJson } from "./json-util.js";
|
|
7
|
-
import {
|
|
8
|
-
import { skillNameFromSkillPath } from "./resource-projection-util.js";
|
|
6
|
+
import { isJsonObject, previewString, redactedToolInput, safeJson } from "./json-util.js";
|
|
7
|
+
import { normalizeResourcePath, skillNameFromSkillPath } from "./resource-projection-util.js";
|
|
9
8
|
import { normalizeConnectionApproval, stringValue } from "./runtime-util.js";
|
|
9
|
+
import { audienceFromRun, principalKey } from "./audience.js";
|
|
10
|
+
import { applyCoreToolPolicy } from "./security.js";
|
|
10
11
|
import { parseSkillBody } from "./self-improvement.js";
|
|
12
|
+
import { initiatorFromRun, principalFromRun } from "./principals.js";
|
|
13
|
+
import { authorizationRequiredModelOutput } from "./model-visible-interrupts.js";
|
|
11
14
|
/**
|
|
12
15
|
* Runtime-handled tool executors: the builtin skill/discovery tools
|
|
13
|
-
* (load_skill
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
+
* (load_skill and tool_search), the deferred tool catalog, the tool-call
|
|
17
|
+
* bookkeeping those paths share, and the connection tool executors together
|
|
18
|
+
* with the connection-registry factories they run against.
|
|
16
19
|
* None of these route through an authored tool definition, so their records
|
|
17
20
|
* are written here rather than by executeToolWithRecord in
|
|
18
21
|
* ./tool-execution.js. Imports only the {@link ToolExecutionHost} type from
|
|
19
22
|
* ./tool-execution.js, so the value-level module graph stays acyclic.
|
|
20
23
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
/** Cap on inventory entries returned by load_skill; the full tree stays reachable via list/grep. */
|
|
25
|
+
const LOAD_SKILL_RESOURCE_INVENTORY_LIMIT = 150;
|
|
26
|
+
export async function skillLoadDetailsImpl(host, run, skillName) {
|
|
27
|
+
await host.ensureSkillsSeeded(run);
|
|
28
|
+
const skill = await host.skillStore.get(host.skillScopeForRun(run), skillName);
|
|
29
|
+
if (!skill || skill.pending || skill.archived)
|
|
25
30
|
throw new Error(`Skill not found: ${skillName}`);
|
|
26
31
|
const parsed = parseSkillBody(skill.body);
|
|
27
|
-
|
|
32
|
+
const surfacePath = host.surfaceForRun(run).path;
|
|
33
|
+
const entryPath = host.skillBundleIndex.entrypointPathForSkill(skill.name, surfacePath);
|
|
34
|
+
const bundle = host.skillBundleIndex.bundleForSkill(skill.name, surfacePath);
|
|
35
|
+
const closure = host.skillBundleIndex
|
|
36
|
+
.resourceClosureForSkill(skill.name, surfacePath)
|
|
37
|
+
.filter((resource) => resource.runtimePath !== entryPath);
|
|
38
|
+
const details = {
|
|
28
39
|
name: skill.name,
|
|
29
40
|
description: parsed.description || `Skill ${skill.name}`,
|
|
30
41
|
declaredTools: parsed.allowedTools,
|
|
31
42
|
instructions: parsed.instructions,
|
|
32
43
|
origin: skill.origin,
|
|
33
|
-
path:
|
|
44
|
+
path: entryPath,
|
|
45
|
+
resources: closure
|
|
46
|
+
.slice(0, LOAD_SKILL_RESOURCE_INVENTORY_LIMIT)
|
|
47
|
+
.map((resource) => ({ path: resource.runtimePath, size: resource.size, contentType: resource.contentType })),
|
|
48
|
+
resourceCount: closure.length,
|
|
49
|
+
resourceBytes: closure.reduce((total, resource) => total + resource.size, 0)
|
|
34
50
|
};
|
|
51
|
+
if (bundle) {
|
|
52
|
+
details.bundle = {
|
|
53
|
+
id: bundle.id,
|
|
54
|
+
kind: bundle.kind,
|
|
55
|
+
...(bundle.plugin ? { plugin: { name: bundle.plugin.name, ...(bundle.plugin.version ? { version: bundle.plugin.version } : {}) } } : {})
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
return details;
|
|
59
|
+
}
|
|
60
|
+
/** Resolve a load_skill `path` input: canonical entrypoint paths first, then the legacy shapes. */
|
|
61
|
+
function skillNameFromLoadInput(host, requested) {
|
|
62
|
+
try {
|
|
63
|
+
return host.skillBundleIndex.skillNameForEntrypointPath(normalizeResourcePath(requested))
|
|
64
|
+
?? skillNameFromSkillPath(requested);
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return skillNameFromSkillPath(requested);
|
|
68
|
+
}
|
|
35
69
|
}
|
|
36
70
|
export function createConnectionRegistryImpl(host, channel, turn) {
|
|
37
71
|
const session = { channel };
|
|
@@ -41,18 +75,24 @@ export function createConnectionRegistryImpl(host, channel, turn) {
|
|
|
41
75
|
session.userId = turn.userId;
|
|
42
76
|
if (turn?.metadata)
|
|
43
77
|
session.metadata = turn.metadata;
|
|
78
|
+
if (turn?.principal)
|
|
79
|
+
session.principal = turn.principal;
|
|
80
|
+
if (turn?.initiator)
|
|
81
|
+
session.initiator = turn.initiator;
|
|
44
82
|
return new RuntimeConnectionRegistry({
|
|
45
83
|
connections: host.mergedConnections(),
|
|
46
84
|
env: host.env,
|
|
47
85
|
fetch: host.fetch,
|
|
48
86
|
session,
|
|
87
|
+
audience: turn?.audience ?? { private: true },
|
|
88
|
+
agentId: host.manifest.agent.id ?? host.manifest.agentRevision,
|
|
49
89
|
grantStore: host.connectionGrantStore,
|
|
50
90
|
authorizationSessionStore: host.connectionAuthorizationSessionStore,
|
|
51
91
|
...(host.connectionCallbackBaseUrl ? { callbackBaseUrl: host.connectionCallbackBaseUrl } : {}),
|
|
52
92
|
loadDefinition: async (connection) => host.loadConnectionDefinition(connection)
|
|
53
93
|
});
|
|
54
94
|
}
|
|
55
|
-
export function createConnectionRegistryForRunImpl(host, run, fallbackChannel, sandboxHandle) {
|
|
95
|
+
export function createConnectionRegistryForRunImpl(host, run, fallbackChannel, sandboxHandle, selectedConnections) {
|
|
56
96
|
const session = {
|
|
57
97
|
channel: typeof run.input.channel === "string" ? run.input.channel : fallbackChannel
|
|
58
98
|
};
|
|
@@ -62,17 +102,26 @@ export function createConnectionRegistryForRunImpl(host, run, fallbackChannel, s
|
|
|
62
102
|
session.userId = run.input.userId;
|
|
63
103
|
if (isJsonObject(run.input.metadata))
|
|
64
104
|
session.metadata = run.input.metadata;
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
105
|
+
const principal = principalFromRun(run);
|
|
106
|
+
const initiator = initiatorFromRun(run);
|
|
107
|
+
if (principal)
|
|
108
|
+
session.principal = principal;
|
|
109
|
+
if (initiator)
|
|
110
|
+
session.initiator = initiator;
|
|
111
|
+
const surface = host.surfaceForRun(run);
|
|
112
|
+
const subagentConnectionNames = surface.path !== "root" ? new Set(surface.connections) : undefined;
|
|
113
|
+
const scopedConnectionNames = selectedConnections && subagentConnectionNames
|
|
114
|
+
? new Set([...selectedConnections].filter((name) => subagentConnectionNames.has(name)))
|
|
115
|
+
: selectedConnections ?? subagentConnectionNames;
|
|
69
116
|
return new RuntimeConnectionRegistry({
|
|
70
|
-
connections: scopedConnectionNames
|
|
117
|
+
connections: (scopedConnectionNames
|
|
71
118
|
? host.mergedConnections().filter((connection) => scopedConnectionNames.has(connection.name))
|
|
72
|
-
: host.mergedConnections(),
|
|
119
|
+
: host.mergedConnections()),
|
|
73
120
|
env: host.env,
|
|
74
121
|
fetch: host.fetch,
|
|
75
122
|
session,
|
|
123
|
+
audience: audienceFromRun(run),
|
|
124
|
+
agentId: host.manifest.agent.id ?? host.manifest.agentRevision,
|
|
76
125
|
grantStore: host.connectionGrantStore,
|
|
77
126
|
authorizationSessionStore: host.connectionAuthorizationSessionStore,
|
|
78
127
|
...(host.connectionCallbackBaseUrl ? { callbackBaseUrl: host.connectionCallbackBaseUrl } : {}),
|
|
@@ -108,11 +157,16 @@ export async function beginConnectionAuthorizationImpl(host, connectionName, ses
|
|
|
108
157
|
resolverSession.conversationId = session.conversationId;
|
|
109
158
|
if (session.userId)
|
|
110
159
|
resolverSession.userId = session.userId;
|
|
160
|
+
if (session.principal)
|
|
161
|
+
resolverSession.principal = session.principal;
|
|
162
|
+
if (session.initiator)
|
|
163
|
+
resolverSession.initiator = session.initiator;
|
|
111
164
|
const registry = new RuntimeConnectionRegistry({
|
|
112
165
|
connections: host.mergedConnections(),
|
|
113
166
|
env: host.env,
|
|
114
167
|
fetch: host.fetch,
|
|
115
168
|
session: resolverSession,
|
|
169
|
+
agentId: host.manifest.agent.id ?? host.manifest.agentRevision,
|
|
116
170
|
grantStore: host.connectionGrantStore,
|
|
117
171
|
authorizationSessionStore: host.connectionAuthorizationSessionStore,
|
|
118
172
|
...(host.connectionCallbackBaseUrl ? { callbackBaseUrl: host.connectionCallbackBaseUrl } : {}),
|
|
@@ -126,6 +180,7 @@ export function createConnectionRegistryForSessionImpl(host, session) {
|
|
|
126
180
|
env: host.env,
|
|
127
181
|
fetch: host.fetch,
|
|
128
182
|
session: session.session,
|
|
183
|
+
agentId: host.manifest.agent.id ?? host.manifest.agentRevision,
|
|
129
184
|
grantStore: host.connectionGrantStore,
|
|
130
185
|
authorizationSessionStore: host.connectionAuthorizationSessionStore,
|
|
131
186
|
...(host.connectionCallbackBaseUrl ? { callbackBaseUrl: host.connectionCallbackBaseUrl } : {}),
|
|
@@ -135,12 +190,17 @@ export function createConnectionRegistryForSessionImpl(host, session) {
|
|
|
135
190
|
export async function executeLoadSkillTool(host, run, state, input, idempotencyKey) {
|
|
136
191
|
const raw = isJsonObject(input) ? input : {};
|
|
137
192
|
const requested = stringValue(raw.name) || stringValue(raw.skillName) || stringValue(raw.path);
|
|
138
|
-
const skillName = requested
|
|
193
|
+
const skillName = requested
|
|
194
|
+
? skillNameFromLoadInput(host, requested) ?? requested
|
|
195
|
+
: "";
|
|
139
196
|
const toolCall = await recordRuntimeHandledToolStart(host, run, LOAD_SKILL_TOOL_NAME, input, idempotencyKey);
|
|
140
197
|
try {
|
|
141
198
|
if (!skillName)
|
|
142
199
|
throw new Error("load_skill requires name.");
|
|
143
|
-
|
|
200
|
+
if (!state.allowedSkills.has(skillName)) {
|
|
201
|
+
throw new Error(`Skill ${skillName} is not enabled by the current agent capability snapshot.`);
|
|
202
|
+
}
|
|
203
|
+
const loaded = await skillLoadDetailsImpl(host, run, skillName);
|
|
144
204
|
let sandboxProjected = false;
|
|
145
205
|
const activeSandbox = state.sandboxHandle.current();
|
|
146
206
|
if (activeSandbox) {
|
|
@@ -166,24 +226,109 @@ export async function executeLoadSkillTool(host, run, state, input, idempotencyK
|
|
|
166
226
|
};
|
|
167
227
|
if (loaded.declaredTools.length > 0)
|
|
168
228
|
output.declaredTools = loaded.declaredTools;
|
|
229
|
+
if (loaded.bundle)
|
|
230
|
+
output.bundle = safeJson(loaded.bundle);
|
|
231
|
+
if (loaded.resourceCount > 0) {
|
|
232
|
+
output.resources = loaded.resources.map((resource) => safeJson(resource));
|
|
233
|
+
output.resourceCount = loaded.resourceCount;
|
|
234
|
+
output.resourceBytes = loaded.resourceBytes;
|
|
235
|
+
if (loaded.resourceCount > loaded.resources.length) {
|
|
236
|
+
output.resourceInventoryTruncated = true;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
169
239
|
await completeRuntimeHandledTool(host, run, toolCall, LOAD_SKILL_TOOL_NAME, output);
|
|
170
240
|
await host.state.appendEvent(run.id, "skill.loaded", {
|
|
171
241
|
skill: loaded.name,
|
|
172
242
|
origin: loaded.origin,
|
|
173
243
|
path: loaded.path,
|
|
244
|
+
...(loaded.bundle ? { bundle: loaded.bundle.id } : {}),
|
|
245
|
+
resourceCount: loaded.resourceCount,
|
|
174
246
|
sandboxProjected
|
|
175
247
|
});
|
|
176
248
|
return { run: await host.state.getRun(run.id) ?? run, modelOutput: output, skillName: loaded.name };
|
|
177
249
|
}
|
|
178
250
|
catch (error) {
|
|
179
|
-
return failRuntimeHandledTool(host, run, toolCall, LOAD_SKILL_TOOL_NAME, error
|
|
251
|
+
return failRuntimeHandledTool(host, run, toolCall, LOAD_SKILL_TOOL_NAME, error);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
export async function executeHistorySearchTool(host, run, input, idempotencyKey) {
|
|
255
|
+
const raw = isJsonObject(input) ? input : {};
|
|
256
|
+
const query = stringValue(raw.query);
|
|
257
|
+
const scope = stringValue(raw.scope) || "current_conversation";
|
|
258
|
+
const rawLimit = typeof raw.limit === "number" && Number.isFinite(raw.limit) ? Math.floor(raw.limit) : 8;
|
|
259
|
+
const limit = Math.min(50, Math.max(1, rawLimit));
|
|
260
|
+
const toolCall = await recordRuntimeHandledToolStart(host, run, HISTORY_SEARCH_TOOL_NAME, input, idempotencyKey);
|
|
261
|
+
try {
|
|
262
|
+
if (!query)
|
|
263
|
+
throw new Error("history_search requires query.");
|
|
264
|
+
if (!["current_conversation", "current_channel", "my_conversations"].includes(scope)) {
|
|
265
|
+
throw new Error(`Unsupported history_search scope: ${scope}`);
|
|
266
|
+
}
|
|
267
|
+
const search = {
|
|
268
|
+
agentScope: host.memoryScopeForRun(run).agentScope,
|
|
269
|
+
query,
|
|
270
|
+
limit
|
|
271
|
+
};
|
|
272
|
+
if (scope === "current_conversation") {
|
|
273
|
+
const conversationId = stringValue(run.input.conversationId);
|
|
274
|
+
if (!conversationId)
|
|
275
|
+
throw new Error("history_search current_conversation requires an active conversation.");
|
|
276
|
+
search.conversationId = conversationId;
|
|
277
|
+
}
|
|
278
|
+
else if (scope === "current_channel") {
|
|
279
|
+
const metadata = isJsonObject(run.input.metadata) ? run.input.metadata : {};
|
|
280
|
+
const source = isJsonObject(metadata.source) ? metadata.source : undefined;
|
|
281
|
+
const provider = stringValue(source?.provider);
|
|
282
|
+
const workspaceId = stringValue(source?.workspaceId);
|
|
283
|
+
const channelId = stringValue(source?.channelId);
|
|
284
|
+
if (!provider || !workspaceId || !channelId) {
|
|
285
|
+
throw new Error("history_search current_channel is unavailable because this turn has no attributed channel scope.");
|
|
286
|
+
}
|
|
287
|
+
const channel = stringValue(run.input.channel);
|
|
288
|
+
if (channel)
|
|
289
|
+
search.channel = channel;
|
|
290
|
+
search.source = { provider, workspaceId, channelId };
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
if (!audienceFromRun(run).private) {
|
|
294
|
+
throw new Error("history_search my_conversations is unavailable in a shared conversation.");
|
|
295
|
+
}
|
|
296
|
+
const principal = principalFromRun(run);
|
|
297
|
+
const subject = principal ? principalKey(principal) : stringValue(run.input.userId);
|
|
298
|
+
if (!subject)
|
|
299
|
+
throw new Error("history_search my_conversations requires an authenticated conversation subject.");
|
|
300
|
+
search.subject = subject;
|
|
301
|
+
}
|
|
302
|
+
const results = await host.state.searchMessages(search);
|
|
303
|
+
const output = {
|
|
304
|
+
query,
|
|
305
|
+
scope,
|
|
306
|
+
matches: results.map((result) => {
|
|
307
|
+
const contentSource = isJsonObject(result.message.content.source) ? result.message.content.source : undefined;
|
|
308
|
+
const conversationSource = isJsonObject(result.conversationMetadata.source) ? result.conversationMetadata.source : undefined;
|
|
309
|
+
return {
|
|
310
|
+
messageId: result.message.id,
|
|
311
|
+
conversationId: result.message.conversationId,
|
|
312
|
+
role: result.message.role,
|
|
313
|
+
text: previewString(stringValue(result.message.content.text), 1_200),
|
|
314
|
+
createdAt: result.message.createdAt,
|
|
315
|
+
score: result.score,
|
|
316
|
+
source: safeJson(contentSource ?? conversationSource ?? {})
|
|
317
|
+
};
|
|
318
|
+
})
|
|
319
|
+
};
|
|
320
|
+
await completeRuntimeHandledTool(host, run, toolCall, HISTORY_SEARCH_TOOL_NAME, output);
|
|
321
|
+
return { run: await host.state.getRun(run.id) ?? run, modelOutput: output };
|
|
322
|
+
}
|
|
323
|
+
catch (error) {
|
|
324
|
+
return failRuntimeHandledTool(host, run, toolCall, HISTORY_SEARCH_TOOL_NAME, error);
|
|
180
325
|
}
|
|
181
326
|
}
|
|
182
327
|
export async function executeToolSearchTool(host, run, state, input, idempotencyKey) {
|
|
183
328
|
const request = normalizeDeferredToolSearchInput(input);
|
|
184
329
|
const toolCall = await recordRuntimeHandledToolStart(host, run, TOOL_SEARCH_TOOL_NAME, input, idempotencyKey);
|
|
185
330
|
try {
|
|
186
|
-
const local =
|
|
331
|
+
const local = searchDeferredTools(host, run, request.query, request.limit);
|
|
187
332
|
const connectionResults = state.connectionRegistry.hasLiveConnections()
|
|
188
333
|
? await state.connectionRegistry.search({
|
|
189
334
|
keywords: request.query,
|
|
@@ -195,7 +340,16 @@ export async function executeToolSearchTool(host, run, state, input, idempotency
|
|
|
195
340
|
toolName: TOOL_SEARCH_TOOL_NAME
|
|
196
341
|
})
|
|
197
342
|
: [];
|
|
198
|
-
|
|
343
|
+
const connectionFailures = connectionResults.filter((result) => result.error && result.needsAuthorization !== true);
|
|
344
|
+
const connectionStatuses = connectionResults.filter((result) => result.needsAuthorization === true);
|
|
345
|
+
const connectionMatches = connectionResults.filter((result) => !result.error);
|
|
346
|
+
const actionableConnectionMatches = connectionMatches.filter((result) => result.qualifiedName && result.tool && result.inputSchema);
|
|
347
|
+
if (connectionFailures.length > 0 && local.length === 0 && actionableConnectionMatches.length === 0) {
|
|
348
|
+
throw new Error(`Deferred connection tool discovery failed: ${connectionFailures
|
|
349
|
+
.map((result) => `${result.connection}: ${result.error}`)
|
|
350
|
+
.join("; ")}`);
|
|
351
|
+
}
|
|
352
|
+
for (const result of actionableConnectionMatches) {
|
|
199
353
|
if (!result.qualifiedName || !result.tool || !result.inputSchema)
|
|
200
354
|
continue;
|
|
201
355
|
const metadata = {
|
|
@@ -208,10 +362,18 @@ export async function executeToolSearchTool(host, run, state, input, idempotency
|
|
|
208
362
|
if (result.outputSchema)
|
|
209
363
|
metadata.outputSchema = result.outputSchema;
|
|
210
364
|
state.discoveredConnectionTools.set(result.qualifiedName, metadata);
|
|
365
|
+
state.activeToolNames.add(result.qualifiedName);
|
|
211
366
|
}
|
|
367
|
+
for (const tool of local)
|
|
368
|
+
state.activeToolNames.add(tool.name);
|
|
369
|
+
const activated = [
|
|
370
|
+
...local.map((tool) => tool.name),
|
|
371
|
+
...actionableConnectionMatches.flatMap((result) => result.qualifiedName ? [result.qualifiedName] : [])
|
|
372
|
+
];
|
|
212
373
|
const output = {
|
|
213
374
|
query: request.query,
|
|
214
|
-
totalAvailable:
|
|
375
|
+
totalAvailable: deferredTools(host, run).length + connectionMatches.length,
|
|
376
|
+
activated,
|
|
215
377
|
matches: [
|
|
216
378
|
...local.map((tool) => ({
|
|
217
379
|
name: tool.name,
|
|
@@ -220,84 +382,33 @@ export async function executeToolSearchTool(host, run, state, input, idempotency
|
|
|
220
382
|
tags: tool.tags ?? [],
|
|
221
383
|
aliases: tool.aliases ?? []
|
|
222
384
|
})),
|
|
223
|
-
...
|
|
385
|
+
...connectionMatches.map(connectionSearchResultForModel)
|
|
224
386
|
].slice(0, request.limit)
|
|
225
387
|
};
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
229
|
-
catch (error) {
|
|
230
|
-
return failRuntimeHandledTool(host, run, toolCall, TOOL_SEARCH_TOOL_NAME, error, { recoverable: true });
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
export async function executeToolDescribeTool(host, run, state, input, idempotencyKey) {
|
|
234
|
-
const raw = isJsonObject(input) ? input : {};
|
|
235
|
-
const name = stringValue(raw.name);
|
|
236
|
-
const toolCall = await recordRuntimeHandledToolStart(host, run, TOOL_DESCRIBE_TOOL_NAME, input, idempotencyKey);
|
|
237
|
-
try {
|
|
238
|
-
if (!name)
|
|
239
|
-
throw new Error("tool_describe requires name.");
|
|
240
|
-
const local = deferredLocalTools(host).find((tool) => tool.name === name);
|
|
241
|
-
if (local) {
|
|
242
|
-
const definition = await host.loadTool(local);
|
|
243
|
-
const output = {
|
|
244
|
-
name: local.name,
|
|
245
|
-
kind: "tool",
|
|
246
|
-
description: definition.description ?? local.description,
|
|
247
|
-
inputSchema: safeJson(definition.inputSchema ?? local.inputSchema),
|
|
248
|
-
outputSchema: safeJson(definition.outputSchema ?? local.outputSchema ?? {})
|
|
249
|
-
};
|
|
250
|
-
await completeRuntimeHandledTool(host, run, toolCall, TOOL_DESCRIBE_TOOL_NAME, output);
|
|
251
|
-
return { run: await host.state.getRun(run.id) ?? run, modelOutput: output };
|
|
388
|
+
if (connectionStatuses.length > 0) {
|
|
389
|
+
output.connectionStatuses = connectionStatuses.map(connectionSearchResultForModel);
|
|
252
390
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
const parsed = parseQualifiedName(name);
|
|
256
|
-
const results = parsed
|
|
257
|
-
? await state.connectionRegistry.search({ keywords: parsed.toolName, connection: parsed.connectionName, limit: 10 }, {
|
|
258
|
-
runId: run.id,
|
|
259
|
-
toolCallId: toolCall.id,
|
|
260
|
-
toolName: TOOL_DESCRIBE_TOOL_NAME
|
|
261
|
-
})
|
|
262
|
-
: [];
|
|
263
|
-
const result = results.find((candidate) => candidate.qualifiedName === name);
|
|
264
|
-
if (result?.qualifiedName && result.tool && result.inputSchema) {
|
|
265
|
-
connection = {
|
|
266
|
-
connection: result.connection,
|
|
267
|
-
name: result.tool,
|
|
268
|
-
qualifiedName: result.qualifiedName,
|
|
269
|
-
description: result.description,
|
|
270
|
-
inputSchema: result.inputSchema,
|
|
271
|
-
...(result.outputSchema ? { outputSchema: result.outputSchema } : {})
|
|
272
|
-
};
|
|
273
|
-
state.discoveredConnectionTools.set(name, connection);
|
|
274
|
-
}
|
|
391
|
+
if (connectionFailures.length > 0) {
|
|
392
|
+
output.connectionErrors = connectionFailures.map(connectionSearchResultForModel);
|
|
275
393
|
}
|
|
276
|
-
|
|
277
|
-
throw new Error(`Deferred tool not found: ${name}`);
|
|
278
|
-
const output = {
|
|
279
|
-
name: connection.qualifiedName,
|
|
280
|
-
kind: "connection_tool",
|
|
281
|
-
connection: connection.connection,
|
|
282
|
-
description: connection.description,
|
|
283
|
-
inputSchema: safeJson(connection.inputSchema),
|
|
284
|
-
outputSchema: safeJson(connection.outputSchema ?? {})
|
|
285
|
-
};
|
|
286
|
-
await completeRuntimeHandledTool(host, run, toolCall, TOOL_DESCRIBE_TOOL_NAME, output);
|
|
394
|
+
await completeRuntimeHandledTool(host, run, toolCall, TOOL_SEARCH_TOOL_NAME, output);
|
|
287
395
|
return { run: await host.state.getRun(run.id) ?? run, modelOutput: output };
|
|
288
396
|
}
|
|
289
397
|
catch (error) {
|
|
290
|
-
return failRuntimeHandledTool(host, run, toolCall,
|
|
398
|
+
return failRuntimeHandledTool(host, run, toolCall, TOOL_SEARCH_TOOL_NAME, error);
|
|
291
399
|
}
|
|
292
400
|
}
|
|
293
|
-
export function
|
|
294
|
-
return
|
|
295
|
-
.filter((tool) =>
|
|
296
|
-
.
|
|
401
|
+
export function deferredTools(host, run) {
|
|
402
|
+
return runtimeToolsForSurface(host.surfaceForRun(run).tools)
|
|
403
|
+
.filter((tool) => tool.visibility === "deferred")
|
|
404
|
+
.flatMap((tool) => {
|
|
405
|
+
const policyTool = applyCoreToolPolicy(tool, host.coreToolPolicy);
|
|
406
|
+
return policyTool ? [policyTool] : [];
|
|
407
|
+
});
|
|
297
408
|
}
|
|
298
|
-
|
|
409
|
+
function searchDeferredTools(host, run, query, limit) {
|
|
299
410
|
const lower = query.toLowerCase();
|
|
300
|
-
return
|
|
411
|
+
return deferredTools(host, run)
|
|
301
412
|
.map((tool) => ({
|
|
302
413
|
tool,
|
|
303
414
|
haystack: [
|
|
@@ -312,13 +423,14 @@ async function searchDeferredLocalTools(host, query, limit) {
|
|
|
312
423
|
.map((entry) => entry.tool)
|
|
313
424
|
.slice(0, limit);
|
|
314
425
|
}
|
|
315
|
-
async function recordRuntimeHandledToolStart(host, run, toolName, input, idempotencyKey) {
|
|
426
|
+
export async function recordRuntimeHandledToolStart(host, run, toolName, input, idempotencyKey) {
|
|
316
427
|
await host.state.appendEvent(run.id, "tool.call_requested", { toolName, input: redactedToolInput(input) });
|
|
317
428
|
let toolCall = await host.state.createToolCall({
|
|
318
429
|
runId: run.id,
|
|
319
430
|
toolName,
|
|
320
431
|
status: "requested",
|
|
321
|
-
|
|
432
|
+
// Raw, not redacted: resume paths re-execute persisted tool-call input.
|
|
433
|
+
input: safeJson(input),
|
|
322
434
|
idempotencyKey
|
|
323
435
|
});
|
|
324
436
|
toolCall = await host.state.updateToolCall(toolCall.id, { status: "running" });
|
|
@@ -337,21 +449,86 @@ async function completeRuntimeHandledTool(host, run, toolCall, toolName, output)
|
|
|
337
449
|
modelOutput: safeJson(output)
|
|
338
450
|
});
|
|
339
451
|
}
|
|
452
|
+
/**
|
|
453
|
+
* Finalize a durably recordable model-invoked tool failure. Tool failures are
|
|
454
|
+
* model results, not run failures; callers only throw when durable state cannot
|
|
455
|
+
* be written and continuing would therefore be unsafe.
|
|
456
|
+
*/
|
|
340
457
|
export async function failRuntimeHandledTool(host, run, toolCall, toolName, error, options) {
|
|
341
458
|
const message = error instanceof Error ? error.message : String(error);
|
|
459
|
+
const failureKind = options?.failureKind
|
|
460
|
+
?? (isRecoverableToolError(error) ? "invalid_input" : "execution_error");
|
|
461
|
+
const modelOutput = {
|
|
462
|
+
error: message,
|
|
463
|
+
failure: {
|
|
464
|
+
kind: failureKind,
|
|
465
|
+
runCanContinue: true
|
|
466
|
+
}
|
|
467
|
+
};
|
|
342
468
|
await host.state.updateToolCall(toolCall.id, { status: "failed", error: message });
|
|
343
|
-
await host.state.appendEvent(run.id, "tool.execution_failed", {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
// over rather than irreversibly failing the whole run.
|
|
347
|
-
return { run, modelOutput: { error: message } };
|
|
348
|
-
}
|
|
349
|
-
const failedRun = await failRun({ state: host.state }, run.id, {
|
|
350
|
-
reason: "tool.execution_failed",
|
|
469
|
+
await host.state.appendEvent(run.id, "tool.execution_failed", {
|
|
470
|
+
toolCallId: toolCall.id,
|
|
471
|
+
toolName,
|
|
351
472
|
error: message,
|
|
352
|
-
|
|
473
|
+
failureKind,
|
|
474
|
+
recoverable: true
|
|
353
475
|
});
|
|
354
|
-
return { run:
|
|
476
|
+
return { run: await host.state.getRun(run.id) ?? run, modelOutput };
|
|
477
|
+
}
|
|
478
|
+
/** Event appended whenever a pair call cannot proceed for a connection. */
|
|
479
|
+
export const CONNECTION_PAIRING_UNAVAILABLE_EVENT = "connection.pairing_unavailable";
|
|
480
|
+
/**
|
|
481
|
+
* The core `pair` tool: redeem a user-pasted one-time binding packet against a
|
|
482
|
+
* live connection, host-side. Unlike the synthetic `<connection>__pair`
|
|
483
|
+
* discovery tool this executor never requires prior discovery, and when no
|
|
484
|
+
* connection can pair it reports the per-connection resolve failures instead
|
|
485
|
+
* of a generic "not exposed" dead end. Errors are recoverable: the model
|
|
486
|
+
* relays the cause to the user rather than failing the run.
|
|
487
|
+
*/
|
|
488
|
+
export async function executePairTool(host, run, registry, input, idempotencyKey) {
|
|
489
|
+
const toolCall = await recordRuntimeHandledToolStart(host, run, PAIR_TOOL_NAME, input, idempotencyKey);
|
|
490
|
+
try {
|
|
491
|
+
const raw = isJsonObject(input) ? input : {};
|
|
492
|
+
const secret = typeof raw.secret === "string" ? raw.secret.trim() : "";
|
|
493
|
+
const requested = typeof raw.connection === "string" ? raw.connection.trim() : "";
|
|
494
|
+
if (!secret)
|
|
495
|
+
throw new Error("pair requires the full pasted packet or claim code as `secret`.");
|
|
496
|
+
const status = await registry.pairingStatus();
|
|
497
|
+
const target = requested || (status.pairable.length === 1 ? status.pairable[0] : "");
|
|
498
|
+
if (!target) {
|
|
499
|
+
if (status.pairable.length > 1) {
|
|
500
|
+
throw new Error(`Multiple connections support pairing (${status.pairable.join(", ")}); pass the intended one as \`connection\`.`);
|
|
501
|
+
}
|
|
502
|
+
throw await pairingUnavailableError(host, run, status.unavailable);
|
|
503
|
+
}
|
|
504
|
+
if (!status.pairable.includes(target)) {
|
|
505
|
+
const failure = status.unavailable.find((item) => item.connection === target);
|
|
506
|
+
if (failure)
|
|
507
|
+
throw await pairingUnavailableError(host, run, [failure]);
|
|
508
|
+
}
|
|
509
|
+
// Redemption re-validates the target (registered, private-surface access,
|
|
510
|
+
// pairing support) and reports the precise refusal to the model.
|
|
511
|
+
const result = await registry.redeemPairingCode(target, secret);
|
|
512
|
+
const output = { connected: true, connection: result.connection, message: result.message };
|
|
513
|
+
await completeRuntimeHandledTool(host, run, toolCall, PAIR_TOOL_NAME, output);
|
|
514
|
+
return { run: await host.state.getRun(run.id) ?? run, modelOutput: output };
|
|
515
|
+
}
|
|
516
|
+
catch (error) {
|
|
517
|
+
return failRuntimeHandledTool(host, run, toolCall, PAIR_TOOL_NAME, error);
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
// Persist why pairing is impossible before the error reaches the model, so an
|
|
521
|
+
// operator can see the cause in the event log even if the conversation moves on.
|
|
522
|
+
async function pairingUnavailableError(host, run, unavailable) {
|
|
523
|
+
for (const item of unavailable) {
|
|
524
|
+
await host.state.appendEvent(run.id, CONNECTION_PAIRING_UNAVAILABLE_EVENT, {
|
|
525
|
+
connection: item.connection,
|
|
526
|
+
reason: item.reason
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
if (unavailable.length === 0)
|
|
530
|
+
return new Error("No live connection supports pairing.");
|
|
531
|
+
return new Error(`No connection can pair right now: ${unavailable.map((item) => `${item.connection}: ${item.reason}`).join("; ")}`);
|
|
355
532
|
}
|
|
356
533
|
export async function executeConnectionSearchTool(host, run, registry, input, idempotencyKey) {
|
|
357
534
|
await host.state.appendEvent(run.id, "tool.call_requested", { toolName: CONNECTION_SEARCH_TOOL_NAME, input: redactedToolInput(input) });
|
|
@@ -359,7 +536,8 @@ export async function executeConnectionSearchTool(host, run, registry, input, id
|
|
|
359
536
|
runId: run.id,
|
|
360
537
|
toolName: CONNECTION_SEARCH_TOOL_NAME,
|
|
361
538
|
status: "requested",
|
|
362
|
-
|
|
539
|
+
// Raw, not redacted: resume paths re-execute persisted tool-call input.
|
|
540
|
+
input: safeJson(input),
|
|
363
541
|
idempotencyKey
|
|
364
542
|
});
|
|
365
543
|
await host.state.updateToolCall(toolCall.id, { status: "running" });
|
|
@@ -394,17 +572,24 @@ export async function executeConnectionSearchTool(host, run, registry, input, id
|
|
|
394
572
|
// Recoverable: model-invoked discovery, so return the error, don't fail the run.
|
|
395
573
|
const message = error instanceof Error ? error.message : String(error);
|
|
396
574
|
await host.state.updateToolCall(toolCall.id, { status: "failed", error: message });
|
|
397
|
-
await host.state.appendEvent(run.id, "tool.execution_failed", {
|
|
575
|
+
await host.state.appendEvent(run.id, "tool.execution_failed", {
|
|
576
|
+
toolCallId: toolCall.id,
|
|
577
|
+
toolName: CONNECTION_SEARCH_TOOL_NAME,
|
|
578
|
+
error: message,
|
|
579
|
+
failureKind: "execution_error",
|
|
580
|
+
recoverable: true
|
|
581
|
+
});
|
|
398
582
|
return { run: await host.state.getRun(run.id) ?? run, results: [{ connection: "connection_search", description: "Connection search failed.", error: message }] };
|
|
399
583
|
}
|
|
400
584
|
}
|
|
401
|
-
export async function executeConnectionTool(host, run, registry, toolName, input, approved, idempotencyKey) {
|
|
585
|
+
export async function executeConnectionTool(host, run, registry, toolName, input, approved, idempotencyKey, authorizationBehavior = "pause") {
|
|
402
586
|
await host.state.appendEvent(run.id, "tool.call_requested", { toolName, input: redactedToolInput(input) });
|
|
403
587
|
let toolCall = await host.state.createToolCall({
|
|
404
588
|
runId: run.id,
|
|
405
589
|
toolName,
|
|
406
590
|
status: "requested",
|
|
407
|
-
|
|
591
|
+
// Raw, not redacted: connection-auth resume re-executes this input.
|
|
592
|
+
input: safeJson(input),
|
|
408
593
|
idempotencyKey
|
|
409
594
|
});
|
|
410
595
|
const parsed = parseQualifiedName(toolName);
|
|
@@ -425,7 +610,7 @@ export async function executeConnectionTool(host, run, registry, toolName, input
|
|
|
425
610
|
toolName,
|
|
426
611
|
source: "eval"
|
|
427
612
|
});
|
|
428
|
-
return executeConnectionToolWithRecordImpl(host, run, registry, toolName, toolCall, input);
|
|
613
|
+
return executeConnectionToolWithRecordImpl(host, run, registry, toolName, toolCall, input, authorizationBehavior);
|
|
429
614
|
}
|
|
430
615
|
if (approval.mode !== "never" && !approved) {
|
|
431
616
|
toolCall = await host.state.updateToolCall(toolCall.id, { status: "waiting_for_approval" });
|
|
@@ -442,9 +627,9 @@ export async function executeConnectionTool(host, run, registry, toolName, input
|
|
|
442
627
|
});
|
|
443
628
|
return { run: waitingRun, waitingForApproval: true, toolCallId: toolCall.id, toolName };
|
|
444
629
|
}
|
|
445
|
-
return executeConnectionToolWithRecordImpl(host, run, registry, toolName, toolCall, input);
|
|
630
|
+
return executeConnectionToolWithRecordImpl(host, run, registry, toolName, toolCall, input, authorizationBehavior);
|
|
446
631
|
}
|
|
447
|
-
export async function executeConnectionToolWithRecordImpl(host, run, registry, toolName, toolCall, input) {
|
|
632
|
+
export async function executeConnectionToolWithRecordImpl(host, run, registry, toolName, toolCall, input, authorizationBehavior = "pause") {
|
|
448
633
|
await host.state.updateToolCall(toolCall.id, { status: "running" });
|
|
449
634
|
await host.state.appendEvent(run.id, "tool.execution_started", { toolCallId: toolCall.id, toolName });
|
|
450
635
|
try {
|
|
@@ -472,9 +657,13 @@ export async function executeConnectionToolWithRecordImpl(host, run, registry, t
|
|
|
472
657
|
}
|
|
473
658
|
catch (error) {
|
|
474
659
|
if (isConnectionAuthorizationRequiredError(error)) {
|
|
475
|
-
await host.state.updateToolCall(toolCall.id, { status: "failed", error: error.message });
|
|
476
|
-
const waitingRun = await host.state.updateRun(run.id, { status: "waiting_for_connection" });
|
|
477
660
|
const authorizationSessionId = isJsonObject(error.challenge) && typeof error.challenge.sessionId === "string" ? error.challenge.sessionId : undefined;
|
|
661
|
+
const modelOutput = authorizationRequiredModelOutput(error);
|
|
662
|
+
await host.state.updateToolCall(toolCall.id, {
|
|
663
|
+
status: "failed",
|
|
664
|
+
error: error.message,
|
|
665
|
+
modelOutput
|
|
666
|
+
});
|
|
478
667
|
await host.state.appendEvent(run.id, "authorization.required", {
|
|
479
668
|
toolCallId: toolCall.id,
|
|
480
669
|
toolName,
|
|
@@ -482,20 +671,39 @@ export async function executeConnectionToolWithRecordImpl(host, run, registry, t
|
|
|
482
671
|
reason: error.reason,
|
|
483
672
|
challenge: safeJson(error.challenge ?? {})
|
|
484
673
|
});
|
|
674
|
+
if (authorizationBehavior === "return") {
|
|
675
|
+
await host.state.appendEvent(run.id, "authorization.returned_to_model", {
|
|
676
|
+
toolCallId: toolCall.id,
|
|
677
|
+
toolName,
|
|
678
|
+
connectionName: error.connectionName,
|
|
679
|
+
recoverable: true
|
|
680
|
+
});
|
|
681
|
+
return {
|
|
682
|
+
run: await host.state.getRun(run.id) ?? run,
|
|
683
|
+
modelOutput,
|
|
684
|
+
toolCallId: toolCall.id,
|
|
685
|
+
toolName
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
const waitingRun = await host.state.updateRun(run.id, { status: "waiting_for_connection" });
|
|
485
689
|
const out = { run: waitingRun, waitingForConnection: true, toolCallId: toolCall.id, toolName };
|
|
486
690
|
if (authorizationSessionId)
|
|
487
691
|
out.authorizationSessionId = authorizationSessionId;
|
|
488
692
|
return out;
|
|
489
693
|
}
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
error:
|
|
496
|
-
data: { toolCallId: toolCall.id, toolName }
|
|
694
|
+
// Every connection failure that reached a model-invoked tool boundary is
|
|
695
|
+
// returned through the normal result channel. The model may correct its
|
|
696
|
+
// arguments, choose another connection, or explain configuration trouble
|
|
697
|
+
// to the user. Authorization remains the explicit pause path above.
|
|
698
|
+
const failure = await failRuntimeHandledTool(host, run, toolCall, toolName, error, {
|
|
699
|
+
failureKind: isConnectionConfigurationError(error) ? "configuration_error" : "execution_error"
|
|
497
700
|
});
|
|
498
|
-
return {
|
|
701
|
+
return {
|
|
702
|
+
run: failure.run,
|
|
703
|
+
modelOutput: failure.modelOutput,
|
|
704
|
+
toolCallId: toolCall.id,
|
|
705
|
+
toolName
|
|
706
|
+
};
|
|
499
707
|
}
|
|
500
708
|
}
|
|
501
709
|
//# sourceMappingURL=builtin-tool-executors.js.map
|