@assemblyline-agents/runtime 2.0.0 → 3.1.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-hook-context.d.ts +6 -1
- package/dist/agent-hook-context.d.ts.map +1 -1
- package/dist/agent-hook-context.js +24 -11
- package/dist/agent-hook-context.js.map +1 -1
- package/dist/agent-hook-evaluation.d.ts +6 -1
- package/dist/agent-hook-evaluation.d.ts.map +1 -1
- package/dist/agent-hook-evaluation.js +16 -5
- package/dist/agent-hook-evaluation.js.map +1 -1
- package/dist/agent-hook-run-lifecycle.d.ts +5 -1
- package/dist/agent-hook-run-lifecycle.d.ts.map +1 -1
- package/dist/agent-hook-run-lifecycle.js +11 -13
- package/dist/agent-hook-run-lifecycle.js.map +1 -1
- 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/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.map +1 -1
- package/dist/background-review-trigger.js +14 -16
- package/dist/background-review-trigger.js.map +1 -1
- package/dist/background-review-types.d.ts +9 -2
- package/dist/background-review-types.d.ts.map +1 -1
- package/dist/background-review-worker.js +2 -2
- package/dist/background-review-worker.js.map +1 -1
- package/dist/background-review.d.ts.map +1 -1
- package/dist/background-review.js +27 -10
- package/dist/background-review.js.map +1 -1
- package/dist/builtin-tool-executors.d.ts +47 -21
- package/dist/builtin-tool-executors.d.ts.map +1 -1
- package/dist/builtin-tool-executors.js +293 -121
- package/dist/builtin-tool-executors.js.map +1 -1
- package/dist/builtin-tools.d.ts +16 -8
- package/dist/builtin-tools.d.ts.map +1 -1
- package/dist/builtin-tools.js +309 -70
- 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 +10 -6
- 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 -2
- 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 +117 -7
- package/dist/channel-ingress.js.map +1 -1
- package/dist/channel.d.ts +58 -2
- 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 +1 -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 +3 -0
- package/dist/connection-stores.d.ts.map +1 -1
- package/dist/connection-stores.js +4 -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 +54 -5
- package/dist/connections.d.ts.map +1 -1
- package/dist/connections.js +342 -53
- 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 +6 -2
- package/dist/conversation-context.d.ts.map +1 -1
- package/dist/conversation-context.js +45 -12
- 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 +6 -1
- package/dist/harness-loop.d.ts.map +1 -1
- package/dist/harness-loop.js +110 -25
- 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-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 +73 -36
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +390 -258
- 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/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/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 +8 -0
- package/dist/replay-resume.d.ts.map +1 -1
- package/dist/replay-resume.js +141 -11
- 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 +229 -29
- 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 +14 -5
- package/dist/run-outcome.js.map +1 -1
- package/dist/run-recovery.d.ts +19 -3
- package/dist/run-recovery.d.ts.map +1 -1
- package/dist/run-recovery.js +205 -34
- 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 +11 -3
- 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 +15 -13
- package/dist/runtime-learning.d.ts.map +1 -1
- package/dist/runtime-learning.js +79 -58
- package/dist/runtime-learning.js.map +1 -1
- package/dist/runtime-types.d.ts +68 -9
- package/dist/runtime-types.d.ts.map +1 -1
- package/dist/sandbox-fs.d.ts +8 -5
- package/dist/sandbox-fs.d.ts.map +1 -1
- package/dist/sandbox-fs.js +30 -31
- 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 +12 -9
- package/dist/sandbox-session-key.js.map +1 -1
- package/dist/sandbox-session-lifecycle.d.ts.map +1 -1
- package/dist/sandbox-session-lifecycle.js +187 -44
- package/dist/sandbox-session-lifecycle.js.map +1 -1
- package/dist/sandbox-snapshot-policy.js +3 -3
- package/dist/sandbox-snapshot-policy.js.map +1 -1
- package/dist/sandbox-state-sync.d.ts +4 -2
- package/dist/sandbox-state-sync.d.ts.map +1 -1
- package/dist/sandbox-state-sync.js +47 -15
- package/dist/sandbox-state-sync.js.map +1 -1
- 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 +127 -23
- 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 +5 -1
- package/dist/self-improvement.d.ts.map +1 -1
- package/dist/self-improvement.js +28 -14
- 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.js +7 -7
- 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 +1 -0
- package/dist/state-stores.d.ts.map +1 -1
- package/dist/state-stores.js +26 -7
- package/dist/state-stores.js.map +1 -1
- package/dist/state.d.ts +305 -5
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +41 -2
- package/dist/state.js.map +1 -1
- package/dist/storage.d.ts +47 -2
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +158 -6
- package/dist/storage.js.map +1 -1
- package/dist/subagent-execution.d.ts +1 -1
- package/dist/subagent-execution.d.ts.map +1 -1
- package/dist/subagent-execution.js +10 -12
- package/dist/subagent-execution.js.map +1 -1
- package/dist/target-instructions.js +1 -1
- package/dist/target-instructions.js.map +1 -1
- package/dist/tool-apis.d.ts.map +1 -1
- package/dist/tool-apis.js +33 -9
- package/dist/tool-apis.js.map +1 -1
- package/dist/tool-execution.d.ts +22 -12
- package/dist/tool-execution.d.ts.map +1 -1
- package/dist/tool-execution.js +368 -238
- 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/index.js
CHANGED
|
@@ -1,34 +1,48 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { join, resolve } from "node:path";
|
|
3
3
|
import { builtInToolDefinition } from "./builtin-tools.js";
|
|
4
|
-
export
|
|
4
|
+
export * from "./public-api.js";
|
|
5
|
+
export { builtInToolDefaults, FILES_MOUNT_TOOL_NAME, FILES_SEARCH_TOOL_NAME, HISTORY_SEARCH_TOOL_NAME, PAIR_TOOL_NAME } from "./builtin-tools.js";
|
|
6
|
+
export { inspectAgentCapabilities } from "./capability-inspection.js";
|
|
7
|
+
export { CONNECTION_PAIRING_UNAVAILABLE_EVENT, executePairTool } from "./builtin-tool-executors.js";
|
|
5
8
|
import { resolveEvalToolStub, validateEvalRunOptions } from "./eval-run-options.js";
|
|
9
|
+
import { rememberDefaultOutboundRoute } from "./default-outbound-route.js";
|
|
10
|
+
import { audienceFromRun, audienceUserKey, normalizeAgentAudience } from "./audience.js";
|
|
6
11
|
import { AgentSourceModuleLoader } from "./source-loader.js";
|
|
7
12
|
import { AgentEventHandlerRegistry } from "./agent-event-handlers.js";
|
|
8
13
|
import { immutableAgentRunContext } from "./agent-hook-evaluation.js";
|
|
9
14
|
import { hookCapabilityCatalog } from "./agent-hook-context.js";
|
|
15
|
+
import { flattenSubagents, rootAgentSurface, subagentSurface, surfaceForPath, surfaceForRun, durableAgentSurfaceScope } from "./agent-surface.js";
|
|
10
16
|
import { createRuntimeAgentHookController, recoverAgentHookController, removeTerminalAgentHookState, resolvedInstructionsForRun as resolvedHookInstructionsForRun } from "./agent-hook-run-lifecycle.js";
|
|
11
17
|
import { compiledChannelProvider, providerIngressSecurityError, providerIngressSecurityWarnings, resolveCoreToolPolicy, trustedAttachmentProviderForTurn } from "./security.js";
|
|
12
18
|
export { constantTimeSecretEqual } from "./security.js";
|
|
13
19
|
export { RUN_STREAM_TERMINAL_EVENTS } from "./run-stream.js";
|
|
14
20
|
export { failRun } from "./run-outcome.js";
|
|
15
|
-
|
|
21
|
+
export { MAX_CHANNEL_TURN_COALESCING_WINDOW_MS, QUEUED_CHANNEL_TURN_COALESCING_KEY, QUEUED_CHANNEL_TURN_KEY, QUEUED_CHANNEL_TURN_MERGED_INTO_KEY, QUEUED_CHANNEL_TURN_PARTS_KEY } from "./conversation-turn-coalescing.js";
|
|
22
|
+
import { ARTIFACT_DIR_NAME, ASSEMBLY_LINE_MANIFEST_SCHEMA_VERSION } from "@assemblyline-agents/core";
|
|
16
23
|
import { resolveBooleanEnv, resolveNonNegativeIntegerEnv, resolvePositiveIntegerEnv } from "./env-config.js";
|
|
24
|
+
import { humanInputModeForChannel, withHumanInputMode } from "./human-input-routing.js";
|
|
17
25
|
import { RunEventBus, withRunEventPublishing } from "./run-stream.js";
|
|
18
26
|
import { failRun as failRunImpl, handleRunExecutionError, logTerminalRunEvent, settleCompletionBoundaryControlImpl } from "./run-outcome.js";
|
|
19
|
-
import { registerRunAbortController, startRunHeartbeatImpl } from "./run-heartbeat.js";
|
|
27
|
+
import { cacheRunControlSignal, registerRunAbortController, startRunHeartbeatImpl, trackActiveRunHeartbeat } from "./run-heartbeat.js";
|
|
20
28
|
import { redactTruncateJson } from "./content-capture.js";
|
|
21
29
|
import { isJsonObject, safeJson } from "./json-util.js";
|
|
22
30
|
import { sandboxSessionKeyForRun } from "./sandbox-session-key.js";
|
|
23
31
|
export { sandboxSessionKeyForRun } from "./sandbox-session-key.js";
|
|
24
32
|
import { conversationInitiator, defaultUserPrincipal, initiatorFromRun, normalizeAgentPrincipal, principalFromRun, principalUserId } from "./principals.js";
|
|
25
|
-
import {
|
|
33
|
+
import { InMemoryConnectionEventStore } from "./connection-event-store.js";
|
|
34
|
+
import { acceptConnectionEvent, checkConnectionEvents, drainConnectionEventInbox, reconcileConnectionEvents } from "./connection-events.js";
|
|
35
|
+
import { InMemoryConnectionAuthorizationSessionStore, InMemoryConnectionGrantStore, RuntimeConnectionRegistry } from "./connections.js";
|
|
36
|
+
export { FileConnectionEventStore, InMemoryConnectionEventStore } from "./connection-event-store.js";
|
|
37
|
+
export { connectionEventUrl } from "./connection-events.js";
|
|
26
38
|
import { InMemoryConnectionDefinitionStore, InMemoryScheduleStore, InMemorySkillStore, compiledConnectionFromStored, isHostAllowed, resolveSkillsConfig, resolveSchedulesConfig, resolveConnectionsConfig } from "./self-improvement.js";
|
|
27
39
|
import { InMemoryLearningStore } from "./learning-store.js";
|
|
28
40
|
import { RuntimeLearningManager } from "./runtime-learning.js";
|
|
29
41
|
import { materializeTurnAttachments } from "./attachments.js";
|
|
30
|
-
|
|
42
|
+
import { mergeJsonObjects, processRuntimeTurnMedia } from "./turn-media.js";
|
|
43
|
+
export { mergeJsonObjects, processTurnMedia } from "./turn-media.js";
|
|
31
44
|
export { attachmentFetchTimeoutMs, attachmentRemoteUrl, attachmentTrustedForProvider, firstDownloadableUrl } from "./attachments.js";
|
|
45
|
+
export { assertExternalHttpUrl, fetchExternalHttp, isPublicAddress } from "./outbound-http-policy.js";
|
|
32
46
|
import { LocalSandboxAdapter } from "./local-sandbox.js";
|
|
33
47
|
import { schedulerAdapterForKind } from "./scheduler.js";
|
|
34
48
|
import { isTelemetrySink, telemetrySinkFromSetupResult } from "./telemetry.js";
|
|
@@ -37,17 +51,23 @@ import { createJsonConsoleLogger, normalizeLogLevel } from "./logging.js";
|
|
|
37
51
|
import { runDueDeliveriesImpl, startDeliveryWorkerImpl } from "./delivery-queue.js";
|
|
38
52
|
import { recoverIncompleteRunsImpl, startBackgroundWorkersImpl } from "./run-recovery.js";
|
|
39
53
|
import { captureSandboxSnapshotImpl, disposeSandboxSessionImpl, inspectSandboxSyncJobImpl, retrySandboxSyncJobImpl, runDueSandboxSyncJobsImpl, sandboxSyncDiagnosticsImpl, startSandboxSyncWorkerImpl } from "./sandbox-sync-worker.js";
|
|
40
|
-
import { beginChannelTurnImpl, completeRunImpl,
|
|
41
|
-
import { backfillMemoryDocumentsFromFileIndexesImpl, hydrateLogicalPathForToolImpl, listResourcesForRunImpl, memoryScopeForRunImpl, projectResourcesForRunImpl, projectSkillIntoSandboxImpl, readResourceForRunImpl, readSandboxTombstonesWithMissingProjectedFilesImpl, recordSandboxTombstoneImpl, runMemoryEmbeddingBackfillImpl } from "./resource-projection.js";
|
|
54
|
+
import { beginChannelTurnImpl, completeRunImpl, latestRunFailureMessageImpl, recordChannelTurnStartImpl, sendDeliveryImpl, stopUnclaimedChannelTurnImpl, stopChannelTurnImpl } from "./delivery-send.js";
|
|
55
|
+
import { backfillMemoryDocumentsFromFileIndexesImpl, hydrateLogicalPathForToolImpl, listResourcesForRunImpl, memoryScopeForRunImpl, projectLoadedSkillsIntoSandboxImpl, projectResourcesForRunImpl, projectSkillIntoSandboxImpl, readResourceForRunImpl, readSandboxTombstonesWithMissingProjectedFilesImpl, recordSandboxTombstoneImpl, runMemoryEmbeddingBackfillImpl } from "./resource-projection.js";
|
|
56
|
+
import { createSkillBundleIndex, createSkillResourceReader } from "./skill-bundles.js";
|
|
57
|
+
import { createSandboxHandleImpl } from "./sandbox-handle.js";
|
|
58
|
+
import { RuntimeWorkspaceManager, WorkspaceRuntimeMethods } from "./workspace-runtime.js";
|
|
42
59
|
import { beginConnectionAuthorizationImpl, createConnectionRegistryForRunImpl, createConnectionRegistryForSessionImpl, createConnectionRegistryImpl, executeConnectionToolWithRecordImpl, skillLoadDetailsImpl } from "./builtin-tool-executors.js";
|
|
43
60
|
import { createMemoryToolApiImpl, createResourceToolApiImpl, durableStepImpl } from "./tool-apis.js";
|
|
44
61
|
import { executeToolImpl, executeToolWithRecordImpl, harnessExecuteToolImpl, modelToolsImpl, selectToolImpl, visibleToolSetImpl, wrapSandboxImpl } from "./tool-execution.js";
|
|
45
62
|
import { dispatchAutomationEventImpl, normalizeScheduleTriggerDefinitionImpl, registerManifestSchedulesImpl, runDueSchedulesImpl, startSchedulerPollingLoopImpl } from "./schedule-execution.js";
|
|
46
63
|
import { completeConnectionAuthorizationCallbackImpl, replayImpl, resumeApprovalNowImpl, resumeHarnessLoopImpl, resumeInputNowImpl, resumeRunFromContinuationImpl, resumeSuspendedNowImpl } from "./replay-resume.js";
|
|
64
|
+
import { recordRunReplayStarted, rerunFromSnapshot } from "./run-replay.js";
|
|
65
|
+
export { RunReplayError } from "./run-replay.js";
|
|
66
|
+
import { buildRunAgentResult } from "./run-result.js";
|
|
47
67
|
import { readSubagentImpl, runSubagentImpl, sendSubagentFollowupImpl } from "./subagent-execution.js";
|
|
48
|
-
import { createHarnessContextImpl, DEFAULT_MAX_MODEL_ITERATIONS, DEFAULT_OUTPUT_VALIDATION_MAX_RETRIES, executeHarnessTurnImpl, persistHarnessContinuationImpl,
|
|
68
|
+
import { createHarnessContextImpl, DEFAULT_MAX_MODEL_ITERATIONS, DEFAULT_OUTPUT_VALIDATION_MAX_RETRIES, executeHarnessTurnImpl, persistHarnessContinuationImpl, resolveAgentHarnessImpl, runHarnessLoopImpl } from "./harness-loop.js";
|
|
49
69
|
import { getAgentControlImpl, requestRunControlImpl, setAgentEnabledImpl, setAgentMaintenanceImpl } from "./operator-controls.js";
|
|
50
|
-
import { acceptChannelTurnImpl, channelAttachmentResolverImpl, dispatchHttpChannelImpl, loadChannelModuleImpl, startChannelIngressImpl } from "./channel-ingress.js";
|
|
70
|
+
import { acceptChannelTurnImpl, channelAttachmentResolverImpl, dispatchHttpChannelImpl, loadChannelModuleImpl, observeChannelMessageImpl, startChannelAgentTurnImpl, startChannelIngressImpl } from "./channel-ingress.js";
|
|
51
71
|
import { augmentChannelContextImpl, buildContextBundleImpl, prepareConversationImpl, recentHistoryImpl } from "./conversation-context.js";
|
|
52
72
|
import { loadResumableConversationTranscriptImpl } from "./conversation-transcript.js";
|
|
53
73
|
import { ConversationTurnDispatcher } from "./conversation-turn-dispatch.js";
|
|
@@ -55,41 +75,25 @@ import { instructionsForRunTargetImpl } from "./target-instructions.js";
|
|
|
55
75
|
import { emitTelemetrySpanImpl, runSpanAttributesImpl } from "./telemetry.js";
|
|
56
76
|
import { normalizeRuntimeState } from "./state-stores.js";
|
|
57
77
|
import { COMPACTABLE_ACTIVE_CHECKPOINT_NAMES, checkpointDataForStorage as checkpointDataForBlobStorage, emptyCheckpointRetentionResult, hydrateCheckpointData as hydrateCheckpointDataFromBlob, resolveCheckpointRetentionPolicy } from "./checkpoints.js";
|
|
58
|
-
// State record types, capability facets (RunStore & friends), the
|
|
59
|
-
// StateAdapter intersection, StateStores, and the capability guards.
|
|
60
78
|
export * from "./state.js";
|
|
61
79
|
export * from "./principals.js";
|
|
80
|
+
export * from "./audience.js";
|
|
62
81
|
export { evalRunOptionsForRun, validateEvalRunOptions } from "./eval-run-options.js";
|
|
63
|
-
export { InMemoryConversationStore, InMemoryConversationTurnStore, InMemoryFileIndexStore, InMemoryMemoryStateStore, InMemoryRunStore, InMemorySandboxSessionStore, InMemoryScheduleStateStore, InMemoryUsageStore, composeStateStores, normalizeRuntimeState } from "./state-stores.js";
|
|
82
|
+
export { InMemoryConversationStore, InMemoryConversationTurnStore, InMemoryFileIndexStore, InMemoryMemoryStateStore, InMemoryRunStore, InMemorySandboxSessionStore, InMemoryScheduleStateStore, InMemoryUsageStore, InMemoryWorkspaceStore, composeStateStores, normalizeMemoryPath, normalizeRuntimeState } from "./state-stores.js";
|
|
83
|
+
export * from "./workspace.js";
|
|
64
84
|
export { applyDeliveryPatch, createDeliveryRecord, deliveryQueueRetryDelayMs, isDeliveryDue, normalizeDeliveryRecord, stateSupportsDeliveryQueue } from "./delivery-queue.js";
|
|
65
85
|
export { defaultRunStaleAfterMs } from "./run-recovery.js";
|
|
66
86
|
export { BoundedSemaphore, RunCapacityError, retryAfterSeconds } from "./concurrency.js";
|
|
67
87
|
import { BoundedSemaphore, RunCapacityError } from "./concurrency.js";
|
|
68
88
|
import { DEFAULT_MODEL_OUTPUT_MAX_CHARS } from "@assemblyline-agents/core";
|
|
69
|
-
|
|
70
|
-
export { FileConnectionDefinitionStore, FileScheduleStore, FileSkillStore, InMemoryConnectionDefinitionStore, InMemoryScheduleStore, InMemorySkillStore, computeNextRun, resolveSkillsConfig, resolveSchedulesConfig, resolveConnectionsConfig } from "./self-improvement.js";
|
|
71
|
-
export { FileLearningStore, InMemoryLearningStore } from "./learning-store.js";
|
|
72
|
-
export { LocalSandboxAdapter } from "./local-sandbox.js";
|
|
73
|
-
export { FileMemoryStore, FileStateAdapter, InMemoryMemoryStore, InMemoryStateAdapter, LocalBlobAdapter, StateMemoryStore } from "./storage.js";
|
|
74
|
-
export { gatewaySchedulerAdapter, localSchedulerAdapter, postgresSchedulerAdapter, schedulerAdapterForKind } from "./scheduler.js";
|
|
75
|
-
export { createOpenTelemetrySink } from "./telemetry.js";
|
|
76
|
-
export { createJsonConsoleLogger, noopLogger, normalizeLogLevel } from "./logging.js";
|
|
77
|
-
export { capabilityCatalogForManifest, capabilityForModel, capabilityMatchesId, connectionSearchResultForModel, normalizeCapabilityKind, normalizeCapabilityRouterInput, normalizeDeferredToolSearchInput, routerShouldSearchConnections, scoreCapability, searchCapabilityCatalog, tokenizeCapabilityQuery } from "./capability-catalog.js";
|
|
78
|
-
export { fetchJson, fetchWithPolicy, readBodyCapped, retryAfterMs, HttpResponseTooLargeError } from "./http.js";
|
|
79
|
-
import { hydrateSandboxFilesystem, visibleToolsForSkills } from "./sandbox-fs.js";
|
|
80
|
-
export { buildDefaultContextBundle, hydrateSandboxFilesystem, syncSandboxFilesystem, visibleToolsForSkills } from "./sandbox-fs.js";
|
|
81
|
-
export { queryAgentRuns } from "./runs-query.js";
|
|
82
|
-
export { UsageAccountingError, createUsageRecord, matchesUsageQuery, microsToUsd, queryUsageRecords, reconcileUsageRecord, sha256Json, summarizeUsageRecords, usageTokensAreAuthoritative, usageRecordInput, usdToMicros } from "./usage-records.js";
|
|
83
|
-
export { reconcileOpenAIOrganization, reconcileOpenRouterUsage, usageReconciliationReport } from "./usage-reconciliation.js";
|
|
89
|
+
import { visibleToolsForSkills } from "./sandbox-fs.js";
|
|
84
90
|
import { resolveResourceProjectionPolicy } from "./resource-projection-util.js";
|
|
85
91
|
import { syncMemoryFromSandbox, syncSkillsFromSandbox } from "./sandbox-state-sync.js";
|
|
86
92
|
import { acquireSandboxForRun as acquireSandboxSessionForRun } from "./sandbox-session-lifecycle.js";
|
|
87
93
|
import { resolveSandboxSnapshotPolicy } from "./sandbox-snapshot-policy.js";
|
|
88
94
|
import { inferToolInput } from "./channel-http-util.js";
|
|
89
95
|
import { connectionPrincipalKeyForGrant, durableAgentScopeForManifest, isInstrumentationDefinition, normalizeCapturePolicy, randomHex, stringValue, timestamp, } from "./runtime-util.js";
|
|
90
|
-
export
|
|
91
|
-
export { loadRuntimeBundle } from "./runtime-bundle.js";
|
|
92
|
-
export class AssemblyLineRuntime {
|
|
96
|
+
export class AssemblyLineRuntime extends WorkspaceRuntimeMethods {
|
|
93
97
|
manifest;
|
|
94
98
|
state;
|
|
95
99
|
runEventBus = new RunEventBus();
|
|
@@ -99,6 +103,7 @@ export class AssemblyLineRuntime {
|
|
|
99
103
|
blob;
|
|
100
104
|
sandbox;
|
|
101
105
|
scheduler;
|
|
106
|
+
mediaProcessors;
|
|
102
107
|
deliveryMode;
|
|
103
108
|
toolStubs;
|
|
104
109
|
/** Per-run {results:[...]} stub cursors; in-memory by design (see eval-run-options.ts). */
|
|
@@ -116,9 +121,11 @@ export class AssemblyLineRuntime {
|
|
|
116
121
|
connections;
|
|
117
122
|
env;
|
|
118
123
|
fetch;
|
|
124
|
+
attachmentHostResolver;
|
|
119
125
|
logger;
|
|
120
126
|
connectionGrantStore;
|
|
121
127
|
connectionAuthorizationSessionStore;
|
|
128
|
+
connectionEventStore;
|
|
122
129
|
connectionCallbackBaseUrl;
|
|
123
130
|
skillStore;
|
|
124
131
|
learningStore;
|
|
@@ -163,14 +170,19 @@ export class AssemblyLineRuntime {
|
|
|
163
170
|
hostInstrumentationProvided;
|
|
164
171
|
instrumentationConfig;
|
|
165
172
|
sourceLoader;
|
|
173
|
+
skillBundleIndex;
|
|
174
|
+
skillResourceReader;
|
|
166
175
|
contextPolicyPromise;
|
|
167
176
|
/** Fast local view of durable control intents, refreshed by run heartbeats. */
|
|
168
177
|
runControlIntents = new Map();
|
|
178
|
+
/** Runs currently owned by this process, used to route immediate control signals without leaking orphan ids. */
|
|
179
|
+
activeRunExecutions = new Set();
|
|
169
180
|
/** Deadline-fired runs (read by shouldStopRun) + their in-flight abort controllers. */
|
|
170
181
|
runDeadlines = new Set();
|
|
171
182
|
runAbortControllers = new Map();
|
|
172
183
|
maxRunDurationMs;
|
|
173
184
|
constructor(options) {
|
|
185
|
+
super();
|
|
174
186
|
this.manifest = options.manifest;
|
|
175
187
|
const normalizedState = normalizeRuntimeState(options.state ?? new InMemoryStateAdapter());
|
|
176
188
|
// Events fan out to live streams; terminal outcomes become log lines at
|
|
@@ -179,15 +191,17 @@ export class AssemblyLineRuntime {
|
|
|
179
191
|
this.blob = options.blob ?? new LocalBlobAdapter();
|
|
180
192
|
this.sandbox = options.sandbox ?? new LocalSandboxAdapter();
|
|
181
193
|
this.scheduler = options.scheduler ?? schedulerAdapterForKind(this.manifest.gateway.scheduler?.kind);
|
|
194
|
+
this.mediaProcessors = options.mediaProcessors ?? [];
|
|
182
195
|
this.deliveryMode = options.deliveryMode ?? "send";
|
|
183
196
|
this.toolStubs = options.toolStubs ?? {};
|
|
184
197
|
this.devMode = options.devMode ?? false;
|
|
185
198
|
this.sourceBundle = options.sourceBundle ?? {};
|
|
186
199
|
this.connections = options.connections ?? {};
|
|
187
|
-
this.env =
|
|
200
|
+
this.env = { ...(options.env ?? process.env) };
|
|
188
201
|
this.fetch = options.fetch ?? globalThis.fetch.bind(globalThis);
|
|
202
|
+
this.attachmentHostResolver = options.attachmentHostResolver;
|
|
189
203
|
this.logger = options.logger ??
|
|
190
|
-
createJsonConsoleLogger({ level: normalizeLogLevel(this.env.
|
|
204
|
+
createJsonConsoleLogger({ level: normalizeLogLevel(this.env.ASSEMBLY_LINE_LOG_LEVEL) ?? "info" });
|
|
191
205
|
this.eventHandlers = new AgentEventHandlerRegistry(this.agentName(), (runId, type, data) => this.state.appendEvent(runId, type, data), this.logger);
|
|
192
206
|
if (normalizedState.degradedFacets.length > 0) {
|
|
193
207
|
this.logger.warn("state.degraded", {
|
|
@@ -199,7 +213,7 @@ export class AssemblyLineRuntime {
|
|
|
199
213
|
this.models = options.models;
|
|
200
214
|
this.agentHarnessOverride = options.agentHarness;
|
|
201
215
|
this.modelHarnesses = options.modelHarnesses ?? {};
|
|
202
|
-
this.checkpointEveryIteration = resolveBooleanEnv(this.env.
|
|
216
|
+
this.checkpointEveryIteration = resolveBooleanEnv(this.env.ASSEMBLY_LINE_CHECKPOINT_EVERY_ITERATION, true);
|
|
203
217
|
this.checkpointRetention = resolveCheckpointRetentionPolicy(options.checkpointRetention, this.env);
|
|
204
218
|
this.checkpointBlobStorageEnabled = options.blob !== undefined && this.checkpointRetention.blobThresholdBytes > 0;
|
|
205
219
|
this.telemetry = options.telemetry;
|
|
@@ -215,12 +229,13 @@ export class AssemblyLineRuntime {
|
|
|
215
229
|
};
|
|
216
230
|
this.connectionGrantStore = options.connectionGrantStore ?? new InMemoryConnectionGrantStore();
|
|
217
231
|
this.connectionAuthorizationSessionStore = options.connectionAuthorizationSessionStore ?? new InMemoryConnectionAuthorizationSessionStore();
|
|
232
|
+
this.connectionEventStore = options.connectionEventStore ?? new InMemoryConnectionEventStore();
|
|
218
233
|
this.connectionCallbackBaseUrl = options.connectionCallbackBaseUrl;
|
|
219
234
|
this.skillStore = options.skillStore ?? new InMemorySkillStore();
|
|
220
235
|
this.learningStore = options.learningStore ?? new InMemoryLearningStore();
|
|
221
236
|
this.memoryEmbeddingProvider = options.memoryEmbeddingProvider;
|
|
222
237
|
const memoryEmbeddingsRequested = options.memoryEmbeddingsEnabled ??
|
|
223
|
-
resolveBooleanEnv(this.env.
|
|
238
|
+
resolveBooleanEnv(this.env.ASSEMBLY_LINE_MEMORY_EMBEDDINGS_ENABLED, Boolean(options.memoryEmbeddingProvider));
|
|
224
239
|
const memoryEmbeddingStoreAvailable = this.state.supportsMemoryEmbeddings?.() ?? true;
|
|
225
240
|
this.memoryEmbeddingsEnabled = memoryEmbeddingsRequested && memoryEmbeddingStoreAvailable;
|
|
226
241
|
if (memoryEmbeddingsRequested && !memoryEmbeddingStoreAvailable) {
|
|
@@ -236,37 +251,48 @@ export class AssemblyLineRuntime {
|
|
|
236
251
|
this.connectionsConfig = resolveConnectionsConfig(this.manifest.agent.dynamicConnections, this.env);
|
|
237
252
|
this.schedulerEnabled = options.schedulerEnabled;
|
|
238
253
|
this.schedulerTickMs = options.schedulerTickMs ?? 60_000;
|
|
239
|
-
this.scheduleMaxConsecutiveFailures = resolvePositiveIntegerEnv(this.env.
|
|
254
|
+
this.scheduleMaxConsecutiveFailures = resolvePositiveIntegerEnv(this.env.ASSEMBLY_LINE_SCHEDULE_MAX_FAILURES, 5);
|
|
240
255
|
this.now = options.now ?? (() => new Date());
|
|
256
|
+
this.workspaceRuntime = new RuntimeWorkspaceManager({
|
|
257
|
+
state: this.state,
|
|
258
|
+
blob: this.blob,
|
|
259
|
+
agentScope: this.durableAgentScope(),
|
|
260
|
+
now: this.now,
|
|
261
|
+
env: this.env,
|
|
262
|
+
...(this.memoryEmbeddingProvider ? { embeddingProvider: this.memoryEmbeddingProvider } : {}),
|
|
263
|
+
sandboxSessionKey: (run) => this.sandboxSessionKey(run)
|
|
264
|
+
});
|
|
241
265
|
this.runtimeLearning = new RuntimeLearningManager({
|
|
242
266
|
state: this.state, manifest: this.manifest,
|
|
243
267
|
env: this.env, logger: this.logger,
|
|
244
|
-
|
|
268
|
+
learningStore: this.learningStore,
|
|
245
269
|
skillStore: this.skillStore, memoryStore: this.memoryStore,
|
|
246
|
-
|
|
270
|
+
skillsConfigForSurface: (surfacePath) => this.skillsConfigForSurface(surfacePath),
|
|
271
|
+
skillScopeForSurface: (surfacePath) => this.skillScopeForSurface(surfacePath),
|
|
272
|
+
anySkillsEnabled: () => this.anySkillsEnabled(),
|
|
247
273
|
memoryScopeForRun: (run) => this.memoryScopeForRun(run),
|
|
248
274
|
resolveAgentHarness: (modelSpec) => this.resolveAgentHarness(modelSpec),
|
|
249
275
|
now: () => this.now()
|
|
250
276
|
});
|
|
251
277
|
this.sandboxSnapshotPolicy = resolveSandboxSnapshotPolicy(this.manifest, this.env, options.sandboxSnapshotPolicy);
|
|
252
|
-
this.sandboxSyncInline = options.sandboxSyncInline ?? resolveBooleanEnv(this.env.
|
|
253
|
-
this.sandboxSyncLeaseMs = options.sandboxSyncLeaseMs ?? resolvePositiveIntegerEnv(this.env.
|
|
254
|
-
this.sandboxSyncBatchSize = options.sandboxSyncBatchSize ?? resolvePositiveIntegerEnv(this.env.
|
|
255
|
-
this.sandboxSyncMaxAttempts = options.sandboxSyncMaxAttempts ?? resolvePositiveIntegerEnv(this.env.
|
|
256
|
-
this.deliveryQueueLeaseMs = options.deliveryQueueLeaseMs ?? resolvePositiveIntegerEnv(this.env.
|
|
257
|
-
this.toolOutputMaxChars = resolvePositiveIntegerEnv(this.env.
|
|
258
|
-
this.toolTimeoutMs = resolveNonNegativeIntegerEnv(this.env.
|
|
259
|
-
this.deliveryQueueBatchSize = options.deliveryQueueBatchSize ?? resolvePositiveIntegerEnv(this.env.
|
|
260
|
-
this.deliveryQueueMaxAttempts = options.deliveryQueueMaxAttempts ?? resolvePositiveIntegerEnv(this.env.
|
|
261
|
-
this.deliveryQueueIntervalMs = options.deliveryQueueIntervalMs ?? resolvePositiveIntegerEnv(this.env.
|
|
262
|
-
this.runHeartbeatMs = options.runHeartbeatMs ?? resolvePositiveIntegerEnv(this.env.
|
|
263
|
-
this.maxRunDurationMs = options.maxRunDurationMs ?? resolveNonNegativeIntegerEnv(this.env.
|
|
264
|
-
this.runRecoveryIntervalMs = options.runRecoveryIntervalMs ?? resolvePositiveIntegerEnv(this.env.
|
|
265
|
-
this.maxModelIterations = resolvePositiveIntegerEnv(this.env.
|
|
266
|
-
this.outputValidationMaxRetries = resolveNonNegativeIntegerEnv(this.env.
|
|
278
|
+
this.sandboxSyncInline = options.sandboxSyncInline ?? resolveBooleanEnv(this.env.ASSEMBLY_LINE_SANDBOX_SYNC_INLINE, false);
|
|
279
|
+
this.sandboxSyncLeaseMs = options.sandboxSyncLeaseMs ?? resolvePositiveIntegerEnv(this.env.ASSEMBLY_LINE_SANDBOX_SYNC_LEASE_MS, 5 * 60_000);
|
|
280
|
+
this.sandboxSyncBatchSize = options.sandboxSyncBatchSize ?? resolvePositiveIntegerEnv(this.env.ASSEMBLY_LINE_SANDBOX_SYNC_BATCH_SIZE, 10);
|
|
281
|
+
this.sandboxSyncMaxAttempts = options.sandboxSyncMaxAttempts ?? resolvePositiveIntegerEnv(this.env.ASSEMBLY_LINE_SANDBOX_SYNC_MAX_ATTEMPTS, 5);
|
|
282
|
+
this.deliveryQueueLeaseMs = options.deliveryQueueLeaseMs ?? resolvePositiveIntegerEnv(this.env.ASSEMBLY_LINE_DELIVERY_QUEUE_LEASE_MS, 60_000);
|
|
283
|
+
this.toolOutputMaxChars = resolvePositiveIntegerEnv(this.env.ASSEMBLY_LINE_TOOL_OUTPUT_MAX_CHARS, DEFAULT_MODEL_OUTPUT_MAX_CHARS);
|
|
284
|
+
this.toolTimeoutMs = resolveNonNegativeIntegerEnv(this.env.ASSEMBLY_LINE_TOOL_TIMEOUT_MS, 600_000);
|
|
285
|
+
this.deliveryQueueBatchSize = options.deliveryQueueBatchSize ?? resolvePositiveIntegerEnv(this.env.ASSEMBLY_LINE_DELIVERY_QUEUE_BATCH_SIZE, 10);
|
|
286
|
+
this.deliveryQueueMaxAttempts = options.deliveryQueueMaxAttempts ?? resolvePositiveIntegerEnv(this.env.ASSEMBLY_LINE_DELIVERY_QUEUE_MAX_ATTEMPTS, 5);
|
|
287
|
+
this.deliveryQueueIntervalMs = options.deliveryQueueIntervalMs ?? resolvePositiveIntegerEnv(this.env.ASSEMBLY_LINE_DELIVERY_QUEUE_INTERVAL_MS, 15_000);
|
|
288
|
+
this.runHeartbeatMs = options.runHeartbeatMs ?? resolvePositiveIntegerEnv(this.env.ASSEMBLY_LINE_RUN_HEARTBEAT_MS, 30_000);
|
|
289
|
+
this.maxRunDurationMs = options.maxRunDurationMs ?? resolveNonNegativeIntegerEnv(this.env.ASSEMBLY_LINE_MAX_RUN_DURATION_MS, 3_600_000);
|
|
290
|
+
this.runRecoveryIntervalMs = options.runRecoveryIntervalMs ?? resolvePositiveIntegerEnv(this.env.ASSEMBLY_LINE_RUN_RECOVERY_INTERVAL_MS, 60_000);
|
|
291
|
+
this.maxModelIterations = resolvePositiveIntegerEnv(this.env.ASSEMBLY_LINE_MAX_MODEL_ITERATIONS, DEFAULT_MAX_MODEL_ITERATIONS);
|
|
292
|
+
this.outputValidationMaxRetries = resolveNonNegativeIntegerEnv(this.env.ASSEMBLY_LINE_OUTPUT_VALIDATION_MAX_RETRIES, DEFAULT_OUTPUT_VALIDATION_MAX_RETRIES);
|
|
267
293
|
this.runSemaphore = new BoundedSemaphore({
|
|
268
|
-
maxConcurrent: options.maxConcurrentRuns ?? resolvePositiveIntegerEnv(this.env.
|
|
269
|
-
maxQueued: options.maxQueuedRuns ?? resolvePositiveIntegerEnv(this.env.
|
|
294
|
+
maxConcurrent: options.maxConcurrentRuns ?? resolvePositiveIntegerEnv(this.env.ASSEMBLY_LINE_MAX_CONCURRENT_RUNS, Infinity),
|
|
295
|
+
maxQueued: options.maxQueuedRuns ?? resolvePositiveIntegerEnv(this.env.ASSEMBLY_LINE_MAX_QUEUED_RUNS, 0)
|
|
270
296
|
});
|
|
271
297
|
this.conversationTurnDispatcher = new ConversationTurnDispatcher({
|
|
272
298
|
state: this.state, logger: this.logger,
|
|
@@ -285,10 +311,17 @@ export class AssemblyLineRuntime {
|
|
|
285
311
|
sourceBundle: this.sourceBundle,
|
|
286
312
|
...(options.artifactRoot ? { cacheRoot: join(resolve(options.artifactRoot), ARTIFACT_DIR_NAME, "module-cache") } : {})
|
|
287
313
|
});
|
|
314
|
+
this.skillBundleIndex = createSkillBundleIndex(this.manifest);
|
|
315
|
+
this.skillResourceReader = createSkillResourceReader({
|
|
316
|
+
manifest: this.manifest,
|
|
317
|
+
...(options.resourcesRoot ? { resourcesRoot: options.resourcesRoot } : {}),
|
|
318
|
+
manifestRoot: this.manifest.root,
|
|
319
|
+
sourceBundle: this.sourceBundle
|
|
320
|
+
});
|
|
288
321
|
}
|
|
289
322
|
boot() {
|
|
290
|
-
if (this.manifest.schemaVersion !==
|
|
291
|
-
throw new Error(`Unsupported
|
|
323
|
+
if (this.manifest.schemaVersion !== ASSEMBLY_LINE_MANIFEST_SCHEMA_VERSION) {
|
|
324
|
+
throw new Error(`Unsupported Assembly Line manifest schema ${this.manifest.schemaVersion}.`);
|
|
292
325
|
}
|
|
293
326
|
this.sourceLoader.ensureCacheReady();
|
|
294
327
|
if (!this.devMode) {
|
|
@@ -374,17 +407,41 @@ export class AssemblyLineRuntime {
|
|
|
374
407
|
this.logger.warn("provider ingress security warning", { warning });
|
|
375
408
|
}
|
|
376
409
|
}
|
|
377
|
-
skillScope() { return this.
|
|
410
|
+
skillScope() { return this.skillScopeForSurface("root"); }
|
|
411
|
+
skillScopeForSurface(surfacePath) {
|
|
412
|
+
surfaceForPath(this.manifest, surfacePath);
|
|
413
|
+
return durableAgentSurfaceScope(this.durableAgentScope(), surfacePath);
|
|
414
|
+
}
|
|
415
|
+
skillScopeForRun(run) {
|
|
416
|
+
return this.skillScopeForSurface(surfaceForRun(this.manifest, run).path);
|
|
417
|
+
}
|
|
418
|
+
skillsConfigForSurface(surfacePath) {
|
|
419
|
+
if (surfacePath === "root")
|
|
420
|
+
return this.skillsConfig;
|
|
421
|
+
const surface = surfaceForPath(this.manifest, surfacePath);
|
|
422
|
+
return resolveSkillsConfig({
|
|
423
|
+
...(this.manifest.agent.selfImprovement ?? {}),
|
|
424
|
+
...(surface.selfImprovement ?? {})
|
|
425
|
+
}, this.env);
|
|
426
|
+
}
|
|
427
|
+
skillsConfigForRun(run) {
|
|
428
|
+
return this.skillsConfigForSurface(surfaceForRun(this.manifest, run).path);
|
|
429
|
+
}
|
|
430
|
+
anySkillsEnabled() {
|
|
431
|
+
return ["root", ...flattenSubagents(this.manifest.subagents).map((subagent) => subagent.path)]
|
|
432
|
+
.some((surfacePath) => this.skillsConfigForSurface(surfacePath).enabled);
|
|
433
|
+
}
|
|
378
434
|
connectionScope() { return this.durableAgentScope(); }
|
|
379
435
|
durableAgentScope() { return durableAgentScopeForManifest(this.manifest); }
|
|
380
436
|
usesRevisionScopedDurableState() { return this.durableAgentScope() === this.manifest.agentRevision; }
|
|
381
437
|
scheduleScopeForRun(run) {
|
|
382
|
-
const
|
|
383
|
-
|
|
384
|
-
|
|
438
|
+
const audience = audienceFromRun(run);
|
|
439
|
+
return audienceUserKey(audience)
|
|
440
|
+
?? (!audience.private ? audience.conversationId : undefined)
|
|
441
|
+
?? this.durableAgentScope();
|
|
385
442
|
}
|
|
386
443
|
/** Seed the durable skill store from compiled manifest skills (idempotent). */
|
|
387
|
-
async ensureSkillsSeeded() { return this.runtimeLearning.ensureSkillsSeeded(); }
|
|
444
|
+
async ensureSkillsSeeded(surfacePath = "root") { return this.runtimeLearning.ensureSkillsSeeded(surfacePath); }
|
|
388
445
|
async migrateLegacyConnectionScope() {
|
|
389
446
|
if (this.connectionScopeMigrated)
|
|
390
447
|
return;
|
|
@@ -401,19 +458,19 @@ export class AssemblyLineRuntime {
|
|
|
401
458
|
}
|
|
402
459
|
}
|
|
403
460
|
/** Live skill catalog (durable store, post-seed) for context assembly and inspection. */
|
|
404
|
-
async listSkills() { return this.runtimeLearning.listSkills(); }
|
|
461
|
+
async listSkills(surfacePath = "root") { return this.runtimeLearning.listSkills(surfacePath); }
|
|
405
462
|
/** Persist an agent/user authored skill, honoring the write-approval gate. */
|
|
406
|
-
async saveSkill(input) { return this.runtimeLearning.saveSkill(input); }
|
|
407
|
-
async deleteSkill(name) { return this.runtimeLearning.deleteSkill(name); }
|
|
408
|
-
async listSkillRevisions(name) { return this.runtimeLearning.listSkillRevisions(name); }
|
|
409
|
-
async restoreSkillRevision(name, revision) { return this.runtimeLearning.restoreSkillRevision(name, revision); }
|
|
410
|
-
async listPendingSkillChanges() { return this.runtimeLearning.listPendingSkillChanges(); }
|
|
411
|
-
async approveSkillChange(id) { return this.runtimeLearning.approveSkillChange(id); }
|
|
412
|
-
async rejectSkillChange(id) { return this.runtimeLearning.rejectSkillChange(id); }
|
|
463
|
+
async saveSkill(input, surfacePath = "root") { return this.runtimeLearning.saveSkill(input, surfacePath); }
|
|
464
|
+
async deleteSkill(name, surfacePath = "root") { return this.runtimeLearning.deleteSkill(name, surfacePath); }
|
|
465
|
+
async listSkillRevisions(name, surfacePath = "root") { return this.runtimeLearning.listSkillRevisions(name, surfacePath); }
|
|
466
|
+
async restoreSkillRevision(name, revision, surfacePath = "root") { return this.runtimeLearning.restoreSkillRevision(name, revision, surfacePath); }
|
|
467
|
+
async listPendingSkillChanges(surfacePath = "root") { return this.runtimeLearning.listPendingSkillChanges(surfacePath); }
|
|
468
|
+
async approveSkillChange(id, surfacePath = "root") { return this.runtimeLearning.approveSkillChange(id, surfacePath); }
|
|
469
|
+
async rejectSkillChange(id, surfacePath = "root") { return this.runtimeLearning.rejectSkillChange(id, surfacePath); }
|
|
413
470
|
async recordRunFeedback(runId, feedback) {
|
|
414
471
|
return this.runtimeLearning.recordRunFeedback(runId, feedback);
|
|
415
472
|
}
|
|
416
|
-
async listBackgroundReviews() { return this.runtimeLearning.listBackgroundReviews(); }
|
|
473
|
+
async listBackgroundReviews(surfacePath = "root") { return this.runtimeLearning.listBackgroundReviews(surfacePath); }
|
|
417
474
|
async runDueBackgroundReviews(options = {}) {
|
|
418
475
|
return this.runtimeLearning.runDueBackgroundReviews(options);
|
|
419
476
|
}
|
|
@@ -540,83 +597,26 @@ export class AssemblyLineRuntime {
|
|
|
540
597
|
state: this.state,
|
|
541
598
|
memoryStore: this.memoryStore,
|
|
542
599
|
skillStore: this.skillStore,
|
|
600
|
+
skillBundleIndex: this.skillBundleIndex,
|
|
543
601
|
learningStore: this.learningStore,
|
|
544
|
-
|
|
602
|
+
skillsConfigForRun: (run) => this.skillsConfigForRun(run),
|
|
545
603
|
memoryScopeForRun: (candidate) => this.memoryScopeForRun(candidate),
|
|
546
|
-
|
|
604
|
+
skillScopeForRun: (run) => this.skillScopeForRun(run)
|
|
547
605
|
};
|
|
548
606
|
}
|
|
549
607
|
createSandboxHandle(getRun, setRun, getBundle) {
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
blob: runtime.blob
|
|
563
|
-
});
|
|
564
|
-
await runtime.state.appendEvent(run.id, "filesystem.hydrated", {
|
|
565
|
-
memory: "/memory",
|
|
566
|
-
history: "/history",
|
|
567
|
-
files: "/files",
|
|
568
|
-
workspace: "/workspace",
|
|
569
|
-
mode: runtime.legacyFullSandboxHydration() ? "full" : "minimal"
|
|
570
|
-
});
|
|
571
|
-
await runtime.createCheckpoint({
|
|
572
|
-
runId: run.id,
|
|
573
|
-
name: "filesystem.hydrated",
|
|
574
|
-
data: {
|
|
575
|
-
memory: "/memory",
|
|
576
|
-
history: "/history",
|
|
577
|
-
files: "/files",
|
|
578
|
-
workspace: "/workspace",
|
|
579
|
-
mode: runtime.legacyFullSandboxHydration() ? "full" : "minimal"
|
|
580
|
-
}
|
|
581
|
-
});
|
|
582
|
-
const selectedConnections = Array.isArray(run.input.agentConnections)
|
|
583
|
-
? new Set(run.input.agentConnections.filter((name) => typeof name === "string"))
|
|
584
|
-
: new Set();
|
|
585
|
-
await materializeConnectionCredentialsIntoSandbox(run, runtime.createConnectionRegistryForRun(run, "local", undefined, selectedConnections), sandboxSession, (eventType, payload) => runtime.state.appendEvent(run.id, eventType, payload));
|
|
586
|
-
return sandboxSession;
|
|
587
|
-
};
|
|
588
|
-
return {
|
|
589
|
-
current() {
|
|
590
|
-
return sandboxSession;
|
|
591
|
-
},
|
|
592
|
-
async get() {
|
|
593
|
-
if (sandboxSession)
|
|
594
|
-
return sandboxSession;
|
|
595
|
-
// Memoize the in-flight acquisition: parallel tool calls must share
|
|
596
|
-
// one sandbox session instead of racing to create two.
|
|
597
|
-
acquiring ??= acquire().catch((error) => {
|
|
598
|
-
acquiring = undefined;
|
|
599
|
-
throw error;
|
|
600
|
-
});
|
|
601
|
-
return acquiring;
|
|
602
|
-
},
|
|
603
|
-
async getWrapped() {
|
|
604
|
-
const run = getRun();
|
|
605
|
-
return runtime.wrapSandbox(run.id, await this.get());
|
|
606
|
-
},
|
|
607
|
-
async reset() {
|
|
608
|
-
const active = sandboxSession ?? (acquiring ? await acquiring : undefined);
|
|
609
|
-
if (active)
|
|
610
|
-
await runtime.disposeSandboxSession(getRun().id, active);
|
|
611
|
-
sandboxSession = undefined;
|
|
612
|
-
acquiring = undefined;
|
|
613
|
-
},
|
|
614
|
-
async dispose() {
|
|
615
|
-
if (!sandboxSession)
|
|
616
|
-
return;
|
|
617
|
-
await runtime.disposeSandboxSession(getRun().id, sandboxSession);
|
|
618
|
-
}
|
|
619
|
-
};
|
|
608
|
+
return createSandboxHandleImpl({
|
|
609
|
+
state: this.state,
|
|
610
|
+
blob: this.blob,
|
|
611
|
+
acquireSandboxForRun: (run) => this.acquireSandboxForRun(run),
|
|
612
|
+
createCheckpoint: (input) => this.createCheckpoint(input),
|
|
613
|
+
legacyFullSandboxHydration: () => this.legacyFullSandboxHydration(),
|
|
614
|
+
hydrateWorkspace: (run, session) => this.workspaceRuntime.service.hydrate(run, session, this.sandboxSessionKey(run)),
|
|
615
|
+
projectLoadedSkills: (run, session) => this.projectLoadedSkillsIntoSandbox(run, session),
|
|
616
|
+
createConnectionRegistryForRun: (run, channel, selectedConnections) => this.createConnectionRegistryForRun(run, channel, undefined, selectedConnections),
|
|
617
|
+
wrapSandbox: (runId, session) => this.wrapSandbox(runId, session),
|
|
618
|
+
disposeSandboxSession: (runId, session) => this.disposeSandboxSession(runId, session)
|
|
619
|
+
}, getRun, setRun, getBundle);
|
|
620
620
|
}
|
|
621
621
|
sandboxSessionKey(run) {
|
|
622
622
|
return sandboxSessionKeyForRun(this.durableAgentScope(), run);
|
|
@@ -631,8 +631,8 @@ export class AssemblyLineRuntime {
|
|
|
631
631
|
}, run);
|
|
632
632
|
}
|
|
633
633
|
legacyFullSandboxHydration() {
|
|
634
|
-
return this.env.
|
|
635
|
-
this.env.
|
|
634
|
+
return this.env.ASSEMBLY_LINE_LEGACY_FULL_SANDBOX_HYDRATION === "1" ||
|
|
635
|
+
this.env.ASSEMBLY_LINE_LEGACY_FULL_SANDBOX_HYDRATION === "true";
|
|
636
636
|
}
|
|
637
637
|
async ensureDynamicConnections() {
|
|
638
638
|
if (!this.connectionsConfig.dynamic) {
|
|
@@ -724,18 +724,36 @@ export class AssemblyLineRuntime {
|
|
|
724
724
|
await this.ensureSkillsSeeded();
|
|
725
725
|
await this.ensureDynamicConnections();
|
|
726
726
|
const spanStartedAt = timestamp();
|
|
727
|
-
const channel = options.
|
|
727
|
+
const channel = (options.existingRun && typeof options.existingRun.input.channel === "string"
|
|
728
|
+
? options.existingRun.input.channel
|
|
729
|
+
: undefined) ?? options.turn?.channel ?? options.channel ?? "local";
|
|
728
730
|
const channelDefinition = this.manifest.channels.find((candidate) => candidate.name === channel);
|
|
729
|
-
const suppliedConversationId = options.
|
|
731
|
+
const suppliedConversationId = (options.existingRun && typeof options.existingRun.input.conversationId === "string"
|
|
732
|
+
? options.existingRun.input.conversationId
|
|
733
|
+
: undefined) ?? options.turn?.conversationId ?? options.conversationId;
|
|
730
734
|
const legacyUserId = options.turn?.userId ?? options.userId;
|
|
731
|
-
const principal =
|
|
732
|
-
?? (options.
|
|
735
|
+
const principal = (options.existingRun ? principalFromRun(options.existingRun) : undefined)
|
|
736
|
+
?? normalizeAgentPrincipal(options.turn?.principal ?? options.principal)
|
|
733
737
|
?? defaultUserPrincipal(legacyUserId, channel);
|
|
734
|
-
const initiator =
|
|
735
|
-
?? (options.
|
|
738
|
+
const initiator = (options.existingRun ? initiatorFromRun(options.existingRun) : undefined)
|
|
739
|
+
?? normalizeAgentPrincipal(options.turn?.initiator ?? options.initiator)
|
|
736
740
|
?? principal;
|
|
741
|
+
// Channel turns derive their audience from the authenticated turn, so it
|
|
742
|
+
// cannot disagree with the principal or conversation; other callers are
|
|
743
|
+
// trusted embedders and default to a private direct run.
|
|
744
|
+
const audience = (options.existingRun ? normalizeAgentAudience(options.existingRun.input.audience) : undefined)
|
|
745
|
+
?? normalizeAgentAudience(options.turn?.audience ?? options.audience)
|
|
746
|
+
?? { private: true };
|
|
747
|
+
const replyTarget = options.existingRun && isJsonObject(options.existingRun.input.replyTarget)
|
|
748
|
+
? options.existingRun.input.replyTarget
|
|
749
|
+
: safeJson({
|
|
750
|
+
channel,
|
|
751
|
+
conversationId: suppliedConversationId ?? null,
|
|
752
|
+
delivery: options.turn?.delivery ?? options.delivery ?? null
|
|
753
|
+
});
|
|
737
754
|
const runInput = {
|
|
738
755
|
message: options.message,
|
|
756
|
+
agentSurface: "root",
|
|
739
757
|
channel,
|
|
740
758
|
eventId: options.turn?.eventId ?? options.eventId ?? null,
|
|
741
759
|
conversationId: suppliedConversationId ?? options.existingRun?.input.conversationId ?? null,
|
|
@@ -747,11 +765,18 @@ export class AssemblyLineRuntime {
|
|
|
747
765
|
userId: principalUserId(principal) ?? legacyUserId ?? null,
|
|
748
766
|
principal: principal ? safeJson(principal) : null,
|
|
749
767
|
initiator: initiator ? safeJson(initiator) : null,
|
|
768
|
+
audience: safeJson(audience),
|
|
750
769
|
projectId: options.projectId ?? options.existingRun?.input.projectId ?? null,
|
|
751
|
-
|
|
770
|
+
workspaceId: options.workspaceId ?? options.existingRun?.input.workspaceId ?? null,
|
|
771
|
+
tenantId: options.tenantId ?? options.existingRun?.input.tenantId ?? null,
|
|
772
|
+
delivery: isJsonObject(replyTarget.delivery) ? replyTarget.delivery : null,
|
|
773
|
+
replyTarget,
|
|
752
774
|
metadata: options.metadata ?? options.turn?.metadata ?? {},
|
|
775
|
+
sandboxCredentials: options.sandboxCredentials ?? (options.existingRun && isJsonObject(options.existingRun.input.sandboxCredentials) ? options.existingRun.input.sandboxCredentials : {}),
|
|
776
|
+
...(options.replay !== undefined ? { replay: safeJson(options.replay) } : {}),
|
|
753
777
|
...(options.eval !== undefined ? { eval: validateEvalRunOptions(options.eval) } : {})
|
|
754
778
|
};
|
|
779
|
+
await rememberDefaultOutboundRoute({ manifest: this.manifest, state: this.state, agentScope: this.durableAgentScope(), now: this.now() }, options, runInput);
|
|
755
780
|
let run = options.existingRun
|
|
756
781
|
? await this.state.updateRun(options.existingRun.id, {
|
|
757
782
|
input: {
|
|
@@ -771,6 +796,8 @@ export class AssemblyLineRuntime {
|
|
|
771
796
|
this.logger.warn("onRunCreated hook failed", { runId: run.id, error: error instanceof Error ? error.message : String(error) });
|
|
772
797
|
}
|
|
773
798
|
await this.state.appendEvent(run.id, "run.accepted", { agentRevision: this.manifest.agentRevision });
|
|
799
|
+
if (options.replay)
|
|
800
|
+
await recordRunReplayStarted(this.state, run.id, options.replay);
|
|
774
801
|
if (this.usesRevisionScopedDurableState() && (this.skillsConfig.enabled || this.connectionsConfig.dynamic)) {
|
|
775
802
|
await this.state.appendEvent(run.id, "agent.scope_fallback", {
|
|
776
803
|
reason: "missing_agent_id",
|
|
@@ -778,6 +805,10 @@ export class AssemblyLineRuntime {
|
|
|
778
805
|
message: "Durable learned state is scoped to agentRevision because agent.id is not configured."
|
|
779
806
|
});
|
|
780
807
|
}
|
|
808
|
+
const preExecution = await this.state.getRun(run.id);
|
|
809
|
+
if (preExecution?.status === "cancelled") {
|
|
810
|
+
return this.result(preExecution, "Run was cancelled before execution started.");
|
|
811
|
+
}
|
|
781
812
|
run = await this.state.updateRun(run.id, { status: "running" });
|
|
782
813
|
const heartbeat = this.startRunHeartbeat(run.id);
|
|
783
814
|
const channelTurnStart = earlyChannelTurn
|
|
@@ -795,18 +826,42 @@ export class AssemblyLineRuntime {
|
|
|
795
826
|
await this.stopChannelTurn(channelLifecycle, run, channel);
|
|
796
827
|
};
|
|
797
828
|
try {
|
|
798
|
-
const
|
|
799
|
-
|
|
800
|
-
|
|
829
|
+
const channelModule = channelDefinition
|
|
830
|
+
? await this.loadChannelModule(channelDefinition)
|
|
831
|
+
: undefined;
|
|
832
|
+
const humanInputMode = humanInputModeForChannel(channelModule);
|
|
833
|
+
run = await this.state.updateRun(run.id, {
|
|
834
|
+
input: withHumanInputMode(run.input, humanInputMode)
|
|
835
|
+
});
|
|
836
|
+
await this.state.appendEvent(run.id, "human_input.route_selected", {
|
|
801
837
|
channel,
|
|
802
|
-
|
|
803
|
-
...(trustedProvider ? { trustedProvider } : {}),
|
|
804
|
-
...(resolveAttachment ? { resolveAttachment } : {}),
|
|
805
|
-
env: this.env,
|
|
806
|
-
fetch: this.fetch,
|
|
807
|
-
blob: this.blob,
|
|
808
|
-
state: this.state
|
|
838
|
+
mode: humanInputMode
|
|
809
839
|
});
|
|
840
|
+
const turnAttachments = options.attachments ?? options.turn?.attachments ?? [];
|
|
841
|
+
let attachments = [];
|
|
842
|
+
if (turnAttachments.length > 0) {
|
|
843
|
+
if (typeof run.input.conversationId !== "string" || !run.input.conversationId) {
|
|
844
|
+
run = await this.state.updateRun(run.id, {
|
|
845
|
+
input: { ...run.input, conversationId: run.id }
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
const fileWorkspace = await this.workspaceRuntime.service.resolveForRun(run);
|
|
849
|
+
const resolveAttachment = await this.channelAttachmentResolver(channelDefinition, trustedProvider);
|
|
850
|
+
attachments = await materializeTurnAttachments({
|
|
851
|
+
run,
|
|
852
|
+
workspaceId: fileWorkspace.id,
|
|
853
|
+
channel,
|
|
854
|
+
attachments: turnAttachments,
|
|
855
|
+
...(trustedProvider ? { trustedProvider } : {}),
|
|
856
|
+
...(resolveAttachment ? { resolveAttachment } : {}),
|
|
857
|
+
allowRemoteDownload: options.allowRemoteAttachments === true,
|
|
858
|
+
env: this.env,
|
|
859
|
+
fetch: this.fetch,
|
|
860
|
+
...(this.attachmentHostResolver ? { hostResolver: this.attachmentHostResolver } : {}),
|
|
861
|
+
blob: this.blob,
|
|
862
|
+
state: this.state
|
|
863
|
+
});
|
|
864
|
+
}
|
|
810
865
|
const hydratedOptions = { ...options, attachments };
|
|
811
866
|
if (options.turn)
|
|
812
867
|
hydratedOptions.turn = { ...options.turn, attachments };
|
|
@@ -842,26 +897,7 @@ export class AssemblyLineRuntime {
|
|
|
842
897
|
attachmentMetadata: attachments
|
|
843
898
|
}
|
|
844
899
|
});
|
|
845
|
-
const
|
|
846
|
-
if (missingConnections.length > 0) {
|
|
847
|
-
const waitingRun = await this.state.updateRun(run.id, { status: "waiting_for_connection" });
|
|
848
|
-
await this.state.appendEvent(run.id, "connection.required", {
|
|
849
|
-
missingConnections,
|
|
850
|
-
recoverable: true
|
|
851
|
-
});
|
|
852
|
-
await this.emitSpan("ai.assembly-line.turn", spanStartedAt, this.runSpanAttributes(waitingRun, {
|
|
853
|
-
status: "waiting_for_connection"
|
|
854
|
-
}), {
|
|
855
|
-
spanId: this.turnSpanId(waitingRun.id),
|
|
856
|
-
status: "ok"
|
|
857
|
-
});
|
|
858
|
-
await this.emitSpan("assembly-line.run", spanStartedAt, {
|
|
859
|
-
runId: run.id,
|
|
860
|
-
status: "waiting_for_connection",
|
|
861
|
-
agentRevision: this.manifest.agentRevision
|
|
862
|
-
});
|
|
863
|
-
return this.result(waitingRun, `Connection required: ${missingConnections.join(", ")}`, false, false, true);
|
|
864
|
-
}
|
|
900
|
+
const media = await processRuntimeTurnMedia(this, run, attachments, hydratedOptions, channel, principalUserId(principal) ?? legacyUserId, conversation.id);
|
|
865
901
|
const augmentation = hydratedOptions.turn
|
|
866
902
|
? await this.augmentChannelContext(channel, hydratedOptions.turn, run)
|
|
867
903
|
: undefined;
|
|
@@ -877,13 +913,14 @@ export class AssemblyLineRuntime {
|
|
|
877
913
|
capabilities,
|
|
878
914
|
run
|
|
879
915
|
};
|
|
880
|
-
|
|
881
|
-
|
|
916
|
+
const channelContext = mergeJsonObjects(media.channelContext, augmentation?.channelContext);
|
|
917
|
+
if (channelContext)
|
|
918
|
+
contextInput.channelContext = channelContext;
|
|
882
919
|
if (hydratedOptions.promptContext)
|
|
883
920
|
contextInput.promptContext = hydratedOptions.promptContext;
|
|
884
921
|
if (hydratedOptions.target)
|
|
885
922
|
contextInput.target = hydratedOptions.target;
|
|
886
|
-
let bundle = await this.buildContextBundle(contextInput);
|
|
923
|
+
let bundle = options.contextSnapshot ? structuredClone(options.contextSnapshot) : await this.buildContextBundle(contextInput);
|
|
887
924
|
const contextBlob = await this.blob.put(`context/${run.id}.json`, JSON.stringify(bundle, null, 2), "application/json");
|
|
888
925
|
run = await this.state.updateRun(run.id, { contextBundleId: contextBlob.id });
|
|
889
926
|
await this.state.appendEvent(run.id, "context.bundle_built", { contextBundleId: contextBlob.id });
|
|
@@ -901,7 +938,7 @@ export class AssemblyLineRuntime {
|
|
|
901
938
|
let structuredOutput;
|
|
902
939
|
const tool = this.selectTool(hydratedOptions);
|
|
903
940
|
if (tool) {
|
|
904
|
-
if (!capabilities.tools.includes(tool.name)) {
|
|
941
|
+
if (!capabilities.tools.includes(tool.name) && tool.visibility !== "deferred") {
|
|
905
942
|
const message = `Forced tool ${tool.name} is not enabled by the current agent capability snapshot.`;
|
|
906
943
|
const error = new Error(message);
|
|
907
944
|
error.name = "AgentCapabilityViolationError";
|
|
@@ -961,7 +998,8 @@ export class AssemblyLineRuntime {
|
|
|
961
998
|
loopInput.turn = hydratedOptions.turn;
|
|
962
999
|
if (conversation?.id) {
|
|
963
1000
|
loopInput.conversationId = conversation.id;
|
|
964
|
-
|
|
1001
|
+
if (!options.contextSnapshot)
|
|
1002
|
+
loopInput.transcript = await this.loadConversationTranscript(conversation.id, run.id);
|
|
965
1003
|
}
|
|
966
1004
|
const outcome = await this.runHarnessLoop(loopInput);
|
|
967
1005
|
run = outcome.run;
|
|
@@ -1008,10 +1046,12 @@ export class AssemblyLineRuntime {
|
|
|
1008
1046
|
return result;
|
|
1009
1047
|
}
|
|
1010
1048
|
catch (error) {
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1049
|
+
await handleRunExecutionError({
|
|
1050
|
+
state: this.state,
|
|
1051
|
+
logger: this.logger,
|
|
1052
|
+
deliveryQueueMaxAttempts: this.deliveryQueueMaxAttempts,
|
|
1053
|
+
now: () => this.now()
|
|
1054
|
+
}, run.id, error);
|
|
1015
1055
|
throw error;
|
|
1016
1056
|
}
|
|
1017
1057
|
finally {
|
|
@@ -1025,7 +1065,7 @@ export class AssemblyLineRuntime {
|
|
|
1025
1065
|
}
|
|
1026
1066
|
/** Bump `updatedAt` while a run executes; enforces the wall-clock deadline (run-heartbeat.ts). */
|
|
1027
1067
|
startRunHeartbeat(runId) {
|
|
1028
|
-
return startRunHeartbeatImpl({
|
|
1068
|
+
return trackActiveRunHeartbeat(this.activeRunExecutions, runId, startRunHeartbeatImpl({
|
|
1029
1069
|
state: this.state,
|
|
1030
1070
|
logger: this.logger,
|
|
1031
1071
|
runHeartbeatMs: this.runHeartbeatMs,
|
|
@@ -1037,10 +1077,10 @@ export class AssemblyLineRuntime {
|
|
|
1037
1077
|
controller.abort();
|
|
1038
1078
|
},
|
|
1039
1079
|
debugSwallow: (message, fields) => this.debugSwallow(message, fields)
|
|
1040
|
-
}, runId);
|
|
1080
|
+
}, runId));
|
|
1041
1081
|
}
|
|
1042
1082
|
registerRunAbort(runId, controller) {
|
|
1043
|
-
return registerRunAbortController(this.runAbortControllers, this.runDeadlines, runId, controller);
|
|
1083
|
+
return registerRunAbortController(this.runAbortControllers, this.runDeadlines, runId, controller, this.runControlIntents);
|
|
1044
1084
|
}
|
|
1045
1085
|
conversationContextHost() {
|
|
1046
1086
|
const runtime = this;
|
|
@@ -1051,6 +1091,7 @@ export class AssemblyLineRuntime {
|
|
|
1051
1091
|
coreToolPolicy: this.coreToolPolicy,
|
|
1052
1092
|
memoryStore: this.memoryStore,
|
|
1053
1093
|
skillStore: this.skillStore,
|
|
1094
|
+
skillBundleIndex: this.skillBundleIndex,
|
|
1054
1095
|
sourceLoader: this.sourceLoader,
|
|
1055
1096
|
get contextPolicyPromise() {
|
|
1056
1097
|
return runtime.contextPolicyPromise;
|
|
@@ -1063,8 +1104,9 @@ export class AssemblyLineRuntime {
|
|
|
1063
1104
|
warnSwallow: (message, fields) => this.warnSwallow(message, fields),
|
|
1064
1105
|
memoryScopeForRun: (run) => this.memoryScopeForRun(run),
|
|
1065
1106
|
durableAgentScope: () => this.durableAgentScope(),
|
|
1066
|
-
ensureSkillsSeeded: () => this.ensureSkillsSeeded(),
|
|
1067
|
-
|
|
1107
|
+
ensureSkillsSeeded: (surfacePath) => this.ensureSkillsSeeded(surfacePath),
|
|
1108
|
+
skillScopeForSurface: (surfacePath) => this.skillScopeForSurface(surfacePath),
|
|
1109
|
+
surfaceForRun: (run) => surfaceForRun(this.manifest, run)
|
|
1068
1110
|
};
|
|
1069
1111
|
}
|
|
1070
1112
|
async prepareConversation(run, options, channel) {
|
|
@@ -1113,9 +1155,10 @@ export class AssemblyLineRuntime {
|
|
|
1113
1155
|
createConnectionRegistryForRun: (run, fallbackChannel, sandboxHandle, selectedConnections) => this.createConnectionRegistryForRun(run, fallbackChannel, sandboxHandle, selectedConnections),
|
|
1114
1156
|
missingRequiredConnections: (selected) => this.missingRequiredConnections(selected),
|
|
1115
1157
|
visibleToolSet: (defaultToolNames, activeSkills) => this.visibleToolSet(defaultToolNames, activeSkills),
|
|
1116
|
-
modelTools: (activeToolNames, connectionRegistry, discoveredConnectionTools) => this.modelTools(activeToolNames, connectionRegistry, discoveredConnectionTools),
|
|
1158
|
+
modelTools: (run, activeToolNames, connectionRegistry, discoveredConnectionTools, options) => this.modelTools(run, activeToolNames, connectionRegistry, discoveredConnectionTools, options),
|
|
1117
1159
|
harnessExecuteTool: (call, state) => this.harnessExecuteTool(call, state),
|
|
1118
1160
|
createCheckpoint: (input) => this.createCheckpoint(input),
|
|
1161
|
+
hydrateCheckpointData: (data) => this.hydrateCheckpointData(data),
|
|
1119
1162
|
emitSpan: (name, startedAt, attributes, options) => this.emitSpan(name, startedAt, attributes, options),
|
|
1120
1163
|
runSpanAttributes: (run, extra) => this.runSpanAttributes(run, extra),
|
|
1121
1164
|
turnSpanId: (runId) => this.turnSpanId(runId)
|
|
@@ -1127,15 +1170,16 @@ export class AssemblyLineRuntime {
|
|
|
1127
1170
|
throw new Error("No compiled model is available for harness resolution.");
|
|
1128
1171
|
return resolveAgentHarnessImpl(this.harnessLoopHost(), resolvedModel);
|
|
1129
1172
|
}
|
|
1130
|
-
piHarness() {
|
|
1131
|
-
return piHarnessImpl(this.harnessLoopHost());
|
|
1132
|
-
}
|
|
1133
1173
|
async runHarnessLoop(input) {
|
|
1134
1174
|
return runHarnessLoopImpl(this.harnessLoopHost(), input);
|
|
1135
1175
|
}
|
|
1136
1176
|
/** Load the conversation's stored transcript for resume, or undefined when disabled/absent. */
|
|
1137
1177
|
async loadConversationTranscript(conversationId, runId) {
|
|
1138
|
-
return loadResumableConversationTranscriptImpl(this.conversationContextHost(), {
|
|
1178
|
+
return loadResumableConversationTranscriptImpl(this.conversationContextHost(), {
|
|
1179
|
+
state: this.state,
|
|
1180
|
+
createCheckpoint: (input) => this.createCheckpoint(input),
|
|
1181
|
+
hydrateCheckpointData: (data) => this.hydrateCheckpointData(data)
|
|
1182
|
+
}, conversationId, runId);
|
|
1139
1183
|
}
|
|
1140
1184
|
createHarnessContext(session, loopState, resumed) {
|
|
1141
1185
|
return createHarnessContextImpl(this.harnessLoopHost(), session, loopState, resumed);
|
|
@@ -1184,9 +1228,10 @@ export class AssemblyLineRuntime {
|
|
|
1184
1228
|
ensureDynamicConnections: () => this.ensureDynamicConnections(),
|
|
1185
1229
|
withRunAdmission: (work) => this.withRunAdmission(work),
|
|
1186
1230
|
listHydratedCheckpoints: (runId) => this.listHydratedCheckpoints(runId),
|
|
1231
|
+
hydrateCheckpointData: (data) => this.hydrateCheckpointData(data),
|
|
1187
1232
|
resolveAgentHarness: (modelSpec) => this.resolveAgentHarness(modelSpec),
|
|
1188
1233
|
ensureAgentHookController: (run) => this.ensureAgentHookController(run),
|
|
1189
|
-
resolvedInstructionsForRun: (run, bundle, capabilities) => this.
|
|
1234
|
+
resolvedInstructionsForRun: (run, bundle, capabilities) => resolvedHookInstructionsForRun(this.manifest, run, bundle.instructions, capabilities),
|
|
1190
1235
|
buildContextBundle: (input) => this.buildContextBundle(input),
|
|
1191
1236
|
createSandboxHandle: (getRun, setRun, getBundle) => this.createSandboxHandle(getRun, setRun, getBundle),
|
|
1192
1237
|
executeToolWithRecord: (run, tool, toolCall, input, sandboxHandle, approvedToolCall) => this.executeToolWithRecord(run, tool, toolCall, input, sandboxHandle, approvedToolCall),
|
|
@@ -1203,12 +1248,17 @@ export class AssemblyLineRuntime {
|
|
|
1203
1248
|
createCheckpoint: (input) => this.createCheckpoint(input),
|
|
1204
1249
|
result: (run, response, waitingForApproval, waitingForInput, waitingForConnection) => this.result(run, response, waitingForApproval, waitingForInput, waitingForConnection),
|
|
1205
1250
|
completeRun: (run, sandboxHandle, response, channel, turn, conversationId) => this.completeRun(run, sandboxHandle, response, channel, turn, conversationId),
|
|
1206
|
-
runDeliveryChannel: (run) => this.runDeliveryChannel(run)
|
|
1251
|
+
runDeliveryChannel: (run) => this.runDeliveryChannel(run),
|
|
1252
|
+
enqueueConversationTurn: (input) => this.conversationTurnDispatcher.enqueue(input)
|
|
1207
1253
|
};
|
|
1208
1254
|
}
|
|
1209
1255
|
async replay(runId) {
|
|
1210
1256
|
return replayImpl(this.replayResumeHost(), runId);
|
|
1211
1257
|
}
|
|
1258
|
+
/** Start a new, isolated run from a terminal run's verified durable input snapshot. */
|
|
1259
|
+
async rerun(runId, lifecycle) {
|
|
1260
|
+
return rerunFromSnapshot({ runId, state: this.state, blob: this.blob, manifest: this.manifest, run: (options) => this.run(options) }, lifecycle);
|
|
1261
|
+
}
|
|
1212
1262
|
/** Resumes never consume run capacity (deadlock risk); they only count toward `onIdle()`. */
|
|
1213
1263
|
async resumeApproval(runId) {
|
|
1214
1264
|
const result = await this.withRunAdmission(() => this.resumeApprovalNow(runId));
|
|
@@ -1219,9 +1269,22 @@ export class AssemblyLineRuntime {
|
|
|
1219
1269
|
return resumeApprovalNowImpl(this.replayResumeHost(), runId);
|
|
1220
1270
|
}
|
|
1221
1271
|
async completeConnectionAuthorizationCallback(callback) {
|
|
1272
|
+
const authorizationSession = callback.params.state
|
|
1273
|
+
? await this.connectionAuthorizationSessionStore.getSessionByState(callback.params.state)
|
|
1274
|
+
: undefined;
|
|
1222
1275
|
const result = await completeConnectionAuthorizationCallbackImpl(this.replayResumeHost(), callback);
|
|
1223
1276
|
if (result.runResult)
|
|
1224
1277
|
await this.conversationTurnDispatcher.settleRunResult(result.runResult);
|
|
1278
|
+
if (authorizationSession) {
|
|
1279
|
+
await this.reconcileConnectionEvents({
|
|
1280
|
+
connection: authorizationSession.connectionName,
|
|
1281
|
+
principal: authorizationSession.principal,
|
|
1282
|
+
force: true
|
|
1283
|
+
}).catch((error) => this.logger.warn("connection event reconcile after authorization failed", {
|
|
1284
|
+
connection: authorizationSession.connectionName,
|
|
1285
|
+
error: error instanceof Error ? error.message : String(error)
|
|
1286
|
+
}));
|
|
1287
|
+
}
|
|
1225
1288
|
return result;
|
|
1226
1289
|
}
|
|
1227
1290
|
/**
|
|
@@ -1237,6 +1300,65 @@ export class AssemblyLineRuntime {
|
|
|
1237
1300
|
async beginConnectionAuthorization(connectionName, session = {}) {
|
|
1238
1301
|
return beginConnectionAuthorizationImpl(this.toolExecutionHost(), connectionName, session);
|
|
1239
1302
|
}
|
|
1303
|
+
connectionEventsHost(publicUrl) {
|
|
1304
|
+
const resolvedPublicUrl = publicUrl ?? this.connectionCallbackBaseUrl;
|
|
1305
|
+
return {
|
|
1306
|
+
manifest: this.manifest,
|
|
1307
|
+
env: this.env,
|
|
1308
|
+
fetch: this.fetch,
|
|
1309
|
+
logger: this.logger,
|
|
1310
|
+
agentScope: this.durableAgentScope(),
|
|
1311
|
+
store: this.connectionEventStore,
|
|
1312
|
+
grantStore: this.connectionGrantStore,
|
|
1313
|
+
...(resolvedPublicUrl ? { publicUrl: resolvedPublicUrl } : {}),
|
|
1314
|
+
createRegistry: (principal) => new RuntimeConnectionRegistry({
|
|
1315
|
+
connections: this.mergedConnections(),
|
|
1316
|
+
env: this.env,
|
|
1317
|
+
fetch: this.fetch,
|
|
1318
|
+
session: {
|
|
1319
|
+
channel: "connection-event",
|
|
1320
|
+
principal,
|
|
1321
|
+
...(principal.type === "user" ? { userId: principal.id } : {})
|
|
1322
|
+
},
|
|
1323
|
+
agentId: this.manifest.agent.id ?? this.manifest.agentRevision,
|
|
1324
|
+
grantStore: this.connectionGrantStore,
|
|
1325
|
+
authorizationSessionStore: this.connectionAuthorizationSessionStore,
|
|
1326
|
+
...(this.connectionCallbackBaseUrl ? { callbackBaseUrl: this.connectionCallbackBaseUrl } : {}),
|
|
1327
|
+
loadDefinition: async (connection) => this.loadConnectionDefinition(connection)
|
|
1328
|
+
}),
|
|
1329
|
+
dispatchAutomationEvent: (event) => this.dispatchAutomationEvent(event),
|
|
1330
|
+
appendAudit: (type, data) => this.state.appendRuntimeControlEvent(this.durableAgentScope(), type, data)
|
|
1331
|
+
};
|
|
1332
|
+
}
|
|
1333
|
+
async reconcileConnectionEvents(options = {}) {
|
|
1334
|
+
return reconcileConnectionEvents(this.connectionEventsHost(options.publicUrl), options);
|
|
1335
|
+
}
|
|
1336
|
+
async checkConnectionEvents(connection) {
|
|
1337
|
+
return checkConnectionEvents(this.connectionEventsHost(), connection);
|
|
1338
|
+
}
|
|
1339
|
+
async acceptConnectionEvent(connectionName, bindingId, request) {
|
|
1340
|
+
return acceptConnectionEvent(this.connectionEventsHost(), connectionName, bindingId, request);
|
|
1341
|
+
}
|
|
1342
|
+
async runDueConnectionEvents(options = {}) {
|
|
1343
|
+
return drainConnectionEventInbox(this.connectionEventsHost(), options);
|
|
1344
|
+
}
|
|
1345
|
+
startConnectionEventWorker(options = {}) {
|
|
1346
|
+
const intervalMs = positiveLimit(options.intervalMs, 1_000);
|
|
1347
|
+
const tick = () => this.runDueConnectionEvents({
|
|
1348
|
+
...(options.batchSize !== undefined ? { limit: options.batchSize } : {}),
|
|
1349
|
+
...(options.leaseForMs !== undefined ? { leaseForMs: options.leaseForMs } : {})
|
|
1350
|
+
}).catch((error) => this.logger.warn("connection event worker tick failed", { error: error instanceof Error ? error.message : String(error) }));
|
|
1351
|
+
void tick();
|
|
1352
|
+
const timer = setInterval(() => void tick(), intervalMs);
|
|
1353
|
+
timer.unref?.();
|
|
1354
|
+
const reconcile = () => this.reconcileConnectionEvents().catch((error) => this.logger.warn("connection event reconcile tick failed", {
|
|
1355
|
+
error: error instanceof Error ? error.message : String(error)
|
|
1356
|
+
}));
|
|
1357
|
+
void reconcile();
|
|
1358
|
+
const reconcileTimer = setInterval(() => void reconcile(), 60_000);
|
|
1359
|
+
reconcileTimer.unref?.();
|
|
1360
|
+
return { stop: () => { clearInterval(timer); clearInterval(reconcileTimer); } };
|
|
1361
|
+
}
|
|
1240
1362
|
/** Resumes never consume run capacity (deadlock risk); they only count toward `onIdle()`. */
|
|
1241
1363
|
async resumeInput(runId, answer) {
|
|
1242
1364
|
const result = await this.withRunAdmission(() => this.resumeInputNow(runId, answer));
|
|
@@ -1289,12 +1411,7 @@ export class AssemblyLineRuntime {
|
|
|
1289
1411
|
state: this.state,
|
|
1290
1412
|
boot: () => this.boot(),
|
|
1291
1413
|
durableAgentScope: () => this.durableAgentScope(),
|
|
1292
|
-
cacheRunControl: (runId, intent) =>
|
|
1293
|
-
if (intent)
|
|
1294
|
-
this.runControlIntents.set(runId, intent);
|
|
1295
|
-
else
|
|
1296
|
-
this.runControlIntents.delete(runId);
|
|
1297
|
-
}
|
|
1414
|
+
cacheRunControl: (runId, intent) => cacheRunControlSignal(this.runControlIntents, this.activeRunExecutions, this.runAbortControllers, runId, intent)
|
|
1298
1415
|
};
|
|
1299
1416
|
}
|
|
1300
1417
|
async resumeHarnessLoop(run, harness, restored, resume) {
|
|
@@ -1338,7 +1455,7 @@ export class AssemblyLineRuntime {
|
|
|
1338
1455
|
if (!snapshot.declaration.skills.includes(skillName)) {
|
|
1339
1456
|
throw new Error(`Skill ${skillName} is not enabled by the current agent capability snapshot.`);
|
|
1340
1457
|
}
|
|
1341
|
-
const loaded = await this.skillLoadDetails(skillName);
|
|
1458
|
+
const loaded = await this.skillLoadDetails(run, skillName);
|
|
1342
1459
|
const output = {
|
|
1343
1460
|
name: loaded.name,
|
|
1344
1461
|
skillName: loaded.name,
|
|
@@ -1423,7 +1540,7 @@ export class AssemblyLineRuntime {
|
|
|
1423
1540
|
shouldStartScheduler() {
|
|
1424
1541
|
if (this.schedulerEnabled === false)
|
|
1425
1542
|
return false;
|
|
1426
|
-
if (this.env.
|
|
1543
|
+
if (this.env.ASSEMBLY_LINE_SCHEDULER_ENABLED === "false" || this.env.ASSEMBLY_LINE_SCHEDULER_ENABLED === "0")
|
|
1427
1544
|
return false;
|
|
1428
1545
|
return true;
|
|
1429
1546
|
}
|
|
@@ -1447,6 +1564,8 @@ export class AssemblyLineRuntime {
|
|
|
1447
1564
|
runHeartbeatMs: this.runHeartbeatMs,
|
|
1448
1565
|
sandboxSyncMaxAttempts: this.sandboxSyncMaxAttempts,
|
|
1449
1566
|
deliveryQueueMaxAttempts: this.deliveryQueueMaxAttempts,
|
|
1567
|
+
connectionAuthorizationSessionStore: this.connectionAuthorizationSessionStore,
|
|
1568
|
+
missingRequiredConnections: (selected) => this.missingRequiredConnections(selected),
|
|
1450
1569
|
resumeRunFromContinuation: (run, context) => this.withRunAdmission(() => this.resumeRunFromContinuation(run, context)),
|
|
1451
1570
|
listHydratedCheckpoints: (runId) => this.listHydratedCheckpoints(runId)
|
|
1452
1571
|
};
|
|
@@ -1471,6 +1590,7 @@ export class AssemblyLineRuntime {
|
|
|
1471
1590
|
startSandboxSyncWorker: (workerOptions) => this.startSandboxSyncWorker(workerOptions),
|
|
1472
1591
|
startConversationTurnWorker: (workerOptions) => this.conversationTurnDispatcher.startWorker(workerOptions?.intervalMs),
|
|
1473
1592
|
startBackgroundReviewWorker: (workerOptions) => this.startBackgroundReviewWorker(workerOptions),
|
|
1593
|
+
startConnectionEventWorker: (workerOptions) => this.startConnectionEventWorker(workerOptions),
|
|
1474
1594
|
recoverIncompleteRuns: (recoveryOptions) => this.recoverIncompleteRuns(recoveryOptions),
|
|
1475
1595
|
agentEnabled: () => this.agentEnabled()
|
|
1476
1596
|
}, options);
|
|
@@ -1515,6 +1635,10 @@ export class AssemblyLineRuntime {
|
|
|
1515
1635
|
deliveryQueueLeaseMs: this.deliveryQueueLeaseMs,
|
|
1516
1636
|
deliveryQueueMaxAttempts: this.deliveryQueueMaxAttempts,
|
|
1517
1637
|
sandboxSyncMaxAttempts: this.sandboxSyncMaxAttempts,
|
|
1638
|
+
workspaceFilesForDelivery: async (run) => {
|
|
1639
|
+
const workspace = await this.workspaceRuntime.service.resolveForRun(run);
|
|
1640
|
+
return (await this.workspaceRuntime.service.loadManifest(workspace)).manifest.entries;
|
|
1641
|
+
},
|
|
1518
1642
|
result: (run, response, waitingForApproval, waitingForInput, waitingForConnection) => this.result(run, response, waitingForApproval, waitingForInput, waitingForConnection),
|
|
1519
1643
|
sandboxSessionKey: (run) => this.sandboxSessionKey(run),
|
|
1520
1644
|
debugSwallow: (message, fields) => this.debugSwallow(message, fields),
|
|
@@ -1532,9 +1656,6 @@ export class AssemblyLineRuntime {
|
|
|
1532
1656
|
async latestRunFailureMessage(runId) {
|
|
1533
1657
|
return latestRunFailureMessageImpl(this.deliverySendHost(), runId);
|
|
1534
1658
|
}
|
|
1535
|
-
async enqueueSandboxSyncAfterDelivery(run, sandboxSession) {
|
|
1536
|
-
return enqueueSandboxSyncAfterDeliveryImpl(this.deliverySendHost(), run, sandboxSession);
|
|
1537
|
-
}
|
|
1538
1659
|
sandboxSyncWorkerHost() {
|
|
1539
1660
|
return {
|
|
1540
1661
|
state: this.state,
|
|
@@ -1549,6 +1670,7 @@ export class AssemblyLineRuntime {
|
|
|
1549
1670
|
readSandboxTombstonesWithMissingProjectedFiles: (sandbox) => this.readSandboxTombstonesWithMissingProjectedFiles(sandbox),
|
|
1550
1671
|
syncMemoryFromSandbox: (run, sandboxSession, tombstones) => this.syncMemoryFromSandbox(run, sandboxSession, tombstones),
|
|
1551
1672
|
syncSkillsFromSandbox: (run, sandboxSession, tombstones) => this.syncSkillsFromSandbox(run, sandboxSession, tombstones),
|
|
1673
|
+
syncWorkspace: (run, sandboxSession, syncJob) => this.workspaceRuntime.sync(run, sandboxSession, syncJob),
|
|
1552
1674
|
emitSpan: (name, startedAt, attributes, options) => this.emitSpan(name, startedAt, attributes, options),
|
|
1553
1675
|
runSpanAttributes: (run, extra) => this.runSpanAttributes(run, extra),
|
|
1554
1676
|
turnSpanId: (runId) => this.turnSpanId(runId),
|
|
@@ -1597,14 +1719,14 @@ export class AssemblyLineRuntime {
|
|
|
1597
1719
|
visibleToolSet(defaultToolNames, activeSkills) {
|
|
1598
1720
|
return visibleToolSetImpl(this.toolExecutionHost(), defaultToolNames, activeSkills);
|
|
1599
1721
|
}
|
|
1600
|
-
async skillLoadDetails(skillName) {
|
|
1601
|
-
return skillLoadDetailsImpl(this.toolExecutionHost(), skillName);
|
|
1722
|
+
async skillLoadDetails(run, skillName) {
|
|
1723
|
+
return skillLoadDetailsImpl(this.toolExecutionHost(), run, skillName);
|
|
1602
1724
|
}
|
|
1603
1725
|
async instructionsForRunTarget(run, target, baseInstructions) {
|
|
1604
|
-
return instructionsForRunTargetImpl({ appendEvent: (runId, type, data) => this.state.appendEvent(runId, type, data), skillLoadDetails: (skillName) => this.skillLoadDetails(skillName) }, run, target, baseInstructions);
|
|
1726
|
+
return instructionsForRunTargetImpl({ appendEvent: (runId, type, data) => this.state.appendEvent(runId, type, data), skillLoadDetails: (skillName) => this.skillLoadDetails(run, skillName) }, run, target, baseInstructions);
|
|
1605
1727
|
}
|
|
1606
|
-
async modelTools(activeToolNames, connectionRegistry, discoveredConnectionTools = new Map()) {
|
|
1607
|
-
return modelToolsImpl(this.toolExecutionHost(), activeToolNames, connectionRegistry, discoveredConnectionTools);
|
|
1728
|
+
async modelTools(run, activeToolNames, connectionRegistry, discoveredConnectionTools = new Map(), options) {
|
|
1729
|
+
return modelToolsImpl(this.toolExecutionHost(), run, activeToolNames, connectionRegistry, discoveredConnectionTools, options);
|
|
1608
1730
|
}
|
|
1609
1731
|
async harnessExecuteTool(call, state) {
|
|
1610
1732
|
return harnessExecuteToolImpl(this.toolExecutionHost(), call, state);
|
|
@@ -1647,7 +1769,12 @@ export class AssemblyLineRuntime {
|
|
|
1647
1769
|
env: this.env,
|
|
1648
1770
|
fetch: this.fetch,
|
|
1649
1771
|
state: this.state,
|
|
1650
|
-
blob: this.blob
|
|
1772
|
+
blob: this.blob,
|
|
1773
|
+
agent: {
|
|
1774
|
+
start: (turn) => startChannelAgentTurnImpl(this.channelIngressHost(), channel.name, turn),
|
|
1775
|
+
observe: (observation) => observeChannelMessageImpl(this.channelIngressHost(), channel, observation),
|
|
1776
|
+
cancel: (runId) => this.cancelRun(runId)
|
|
1777
|
+
}
|
|
1651
1778
|
};
|
|
1652
1779
|
}
|
|
1653
1780
|
missingRequiredConnections(selected) {
|
|
@@ -1665,11 +1792,11 @@ export class AssemblyLineRuntime {
|
|
|
1665
1792
|
this.instrumentationLoaded = true;
|
|
1666
1793
|
return;
|
|
1667
1794
|
}
|
|
1668
|
-
const instrumentation =
|
|
1795
|
+
const instrumentation = this.manifest.instrumentation
|
|
1796
|
+
? await this.sourceLoader.load(this.manifest.instrumentation)
|
|
1797
|
+
: {};
|
|
1669
1798
|
const defaultExport = instrumentation.default;
|
|
1670
1799
|
const definition = isInstrumentationDefinition(defaultExport) ? defaultExport : undefined;
|
|
1671
|
-
// Host/gateway-supplied instrumentation wins over instrumentation.ts, mirroring
|
|
1672
|
-
// the telemetry-sink precedence below.
|
|
1673
1800
|
if (definition && !this.hostInstrumentationProvided) {
|
|
1674
1801
|
this.instrumentationConfig = {
|
|
1675
1802
|
recordInputs: definition.recordInputs ?? false,
|
|
@@ -1695,7 +1822,7 @@ export class AssemblyLineRuntime {
|
|
|
1695
1822
|
this.instrumentationLoaded = true;
|
|
1696
1823
|
}
|
|
1697
1824
|
agentName() {
|
|
1698
|
-
return this.manifest.agent.name ?? this.manifest.agent.description ?? `
|
|
1825
|
+
return this.manifest.agent.name ?? this.manifest.agent.description ?? `assembly-line-${this.manifest.agentRevision.slice(0, 12)}`;
|
|
1699
1826
|
}
|
|
1700
1827
|
traceIdForRun(runId) {
|
|
1701
1828
|
return createHash("sha256").update(runId).digest("hex").slice(0, 32);
|
|
@@ -1722,11 +1849,13 @@ export class AssemblyLineRuntime {
|
|
|
1722
1849
|
toolExecutionHost() {
|
|
1723
1850
|
return {
|
|
1724
1851
|
state: this.state,
|
|
1852
|
+
blob: this.blob,
|
|
1725
1853
|
env: this.env,
|
|
1726
1854
|
fetch: this.fetch,
|
|
1727
1855
|
manifest: this.manifest,
|
|
1728
1856
|
coreToolPolicy: this.coreToolPolicy,
|
|
1729
1857
|
skillStore: this.skillStore,
|
|
1858
|
+
skillBundleIndex: this.skillBundleIndex,
|
|
1730
1859
|
memoryStore: this.memoryStore,
|
|
1731
1860
|
sandbox: this.sandbox,
|
|
1732
1861
|
connections: this.connections,
|
|
@@ -1736,12 +1865,13 @@ export class AssemblyLineRuntime {
|
|
|
1736
1865
|
toolOutputMaxChars: this.toolOutputMaxChars,
|
|
1737
1866
|
toolTimeoutMs: this.toolTimeoutMs,
|
|
1738
1867
|
sandboxSyncMaxAttempts: this.sandboxSyncMaxAttempts,
|
|
1739
|
-
|
|
1868
|
+
skillsConfigForRun: (run) => this.skillsConfigForRun(run),
|
|
1740
1869
|
schedulesConfig: this.schedulesConfig,
|
|
1741
1870
|
connectionsConfig: this.connectionsConfig,
|
|
1871
|
+
surfaceForRun: (run) => surfaceForRun(this.manifest, run),
|
|
1742
1872
|
agentStateForRun: (runId) => this.agentStateForRun(runId),
|
|
1743
|
-
ensureSkillsSeeded: () => this.ensureSkillsSeeded(),
|
|
1744
|
-
|
|
1873
|
+
ensureSkillsSeeded: (run) => this.ensureSkillsSeeded(surfaceForRun(this.manifest, run).path),
|
|
1874
|
+
skillScopeForRun: (run) => this.skillScopeForRun(run),
|
|
1745
1875
|
scheduleScopeForRun: (run) => this.scheduleScopeForRun(run),
|
|
1746
1876
|
memoryScopeForRun: (run) => this.memoryScopeForRun(run),
|
|
1747
1877
|
sandboxSessionKey: (run) => this.sandboxSessionKey(run),
|
|
@@ -1754,13 +1884,14 @@ export class AssemblyLineRuntime {
|
|
|
1754
1884
|
recordSandboxTombstone: (run, sandbox, path) => this.recordSandboxTombstone(run, sandbox, path),
|
|
1755
1885
|
createCheckpoint: (input) => this.createCheckpoint(input),
|
|
1756
1886
|
listHydratedCheckpoints: (runId) => this.listHydratedCheckpoints(runId),
|
|
1887
|
+
executeWorkspaceTool: (run, toolName, input, sandboxHandle) => this.workspaceRuntime.executeTool(run, toolName, input, sandboxHandle),
|
|
1757
1888
|
emitSpan: (name, startedAt, attributes, options) => this.emitSpan(name, startedAt, attributes, options),
|
|
1758
1889
|
runSpanAttributes: (run, extra) => this.runSpanAttributes(run, extra),
|
|
1759
1890
|
turnSpanId: (runId) => this.turnSpanId(runId),
|
|
1760
1891
|
toolContentAttributes: (input, output) => this.toolContentAttributes(input, output),
|
|
1761
|
-
saveSkill: (input) => this.saveSkill(input),
|
|
1762
|
-
listSkills: () => this.listSkills(),
|
|
1763
|
-
deleteSkill: (name) => this.deleteSkill(name),
|
|
1892
|
+
saveSkill: (input, run) => this.saveSkill(input, surfaceForRun(this.manifest, run).path),
|
|
1893
|
+
listSkills: (run) => this.listSkills(surfaceForRun(this.manifest, run).path),
|
|
1894
|
+
deleteSkill: (name, run) => this.deleteSkill(name, surfaceForRun(this.manifest, run).path),
|
|
1764
1895
|
createDynamicSchedule: (input) => this.createDynamicSchedule(input),
|
|
1765
1896
|
listDynamicSchedules: (scope) => this.listDynamicSchedules(scope),
|
|
1766
1897
|
updateDynamicSchedule: (scope, id, patch) => this.updateDynamicSchedule(scope, id, patch),
|
|
@@ -1800,11 +1931,14 @@ export class AssemblyLineRuntime {
|
|
|
1800
1931
|
blob: this.blob,
|
|
1801
1932
|
memoryStore: this.memoryStore,
|
|
1802
1933
|
skillStore: this.skillStore,
|
|
1934
|
+
skillBundleIndex: this.skillBundleIndex,
|
|
1935
|
+
skillResourceReader: this.skillResourceReader,
|
|
1803
1936
|
resourceProjectionPolicy: this.resourceProjectionPolicy,
|
|
1804
1937
|
memoryEmbeddingProvider: this.memoryEmbeddingProvider,
|
|
1805
1938
|
memoryEmbeddingsEnabled: this.memoryEmbeddingsEnabled,
|
|
1806
|
-
|
|
1807
|
-
durableAgentScope: () => this.durableAgentScope()
|
|
1939
|
+
skillScopeForRun: (run) => this.skillScopeForRun(run),
|
|
1940
|
+
durableAgentScope: () => this.durableAgentScope(),
|
|
1941
|
+
surfaceForRun: (run) => surfaceForRun(this.manifest, run)
|
|
1808
1942
|
};
|
|
1809
1943
|
}
|
|
1810
1944
|
async listResourcesForRun(run, scope, input = {}) {
|
|
@@ -1819,6 +1953,9 @@ export class AssemblyLineRuntime {
|
|
|
1819
1953
|
async projectSkillIntoSandbox(run, sandbox, skillName) {
|
|
1820
1954
|
return projectSkillIntoSandboxImpl(this.resourceProjectionHost(), run, sandbox, skillName);
|
|
1821
1955
|
}
|
|
1956
|
+
async projectLoadedSkillsIntoSandbox(run, sandbox) {
|
|
1957
|
+
return projectLoadedSkillsIntoSandboxImpl(this.resourceProjectionHost(), run, sandbox);
|
|
1958
|
+
}
|
|
1822
1959
|
async hydrateLogicalPathForTool(run, sandbox, path, options = {}) {
|
|
1823
1960
|
return hydrateLogicalPathForToolImpl(this.resourceProjectionHost(), run, sandbox, path, options);
|
|
1824
1961
|
}
|
|
@@ -1847,7 +1984,10 @@ export class AssemblyLineRuntime {
|
|
|
1847
1984
|
await this.runtimeLearning.handleRuntimeEvent(runId, event.type);
|
|
1848
1985
|
}
|
|
1849
1986
|
async createAgentHookController(run, options, channel, conversationId, attachments) {
|
|
1850
|
-
const disabledTools =
|
|
1987
|
+
const disabledTools = this.disabledToolsForRun(run);
|
|
1988
|
+
const surface = rootAgentSurface(this.manifest);
|
|
1989
|
+
const liveSkills = (await this.listSkills(surface.path)).map((skill) => skill.name).sort();
|
|
1990
|
+
const baseCatalog = hookCapabilityCatalog(this.manifest, surface);
|
|
1851
1991
|
const created = await createRuntimeAgentHookController({
|
|
1852
1992
|
manifest: this.manifest,
|
|
1853
1993
|
state: this.state,
|
|
@@ -1865,11 +2005,15 @@ export class AssemblyLineRuntime {
|
|
|
1865
2005
|
...(typeof run.input.userId === "string" ? { userId: run.input.userId } : {}),
|
|
1866
2006
|
...(principalFromRun(run) ? { principal: principalFromRun(run) } : {}),
|
|
1867
2007
|
...(initiatorFromRun(run) ? { initiator: initiatorFromRun(run) } : {}),
|
|
2008
|
+
audience: audienceFromRun(run),
|
|
1868
2009
|
...((options.metadata ?? options.turn?.metadata) ? {
|
|
1869
2010
|
metadata: (options.metadata ?? options.turn?.metadata)
|
|
1870
2011
|
} : {}),
|
|
1871
2012
|
attachments
|
|
1872
2013
|
}),
|
|
2014
|
+
surface,
|
|
2015
|
+
catalog: { ...baseCatalog, skills: new Set(liveSkills) },
|
|
2016
|
+
defaultSkills: liveSkills,
|
|
1873
2017
|
disabledTools,
|
|
1874
2018
|
createCheckpoint: (input) => this.createCheckpoint(input),
|
|
1875
2019
|
listCheckpoints: (runId) => this.listHydratedCheckpoints(runId)
|
|
@@ -1879,7 +2023,9 @@ export class AssemblyLineRuntime {
|
|
|
1879
2023
|
return created.controller;
|
|
1880
2024
|
}
|
|
1881
2025
|
async createSubagentHookController(run, subagent, message, conversationId) {
|
|
1882
|
-
const
|
|
2026
|
+
const surface = subagentSurface(subagent);
|
|
2027
|
+
const liveSkills = (await this.listSkills(surface.path)).map((skill) => skill.name).sort();
|
|
2028
|
+
const baseCatalog = hookCapabilityCatalog(this.manifest, surface);
|
|
1883
2029
|
const created = await createRuntimeAgentHookController({
|
|
1884
2030
|
manifest: this.manifest,
|
|
1885
2031
|
state: this.state,
|
|
@@ -1887,15 +2033,18 @@ export class AssemblyLineRuntime {
|
|
|
1887
2033
|
sourceLoader: this.sourceLoader,
|
|
1888
2034
|
eventHandlers: this.eventHandlers,
|
|
1889
2035
|
logger: this.logger,
|
|
1890
|
-
agentScope: `${this.durableAgentScope()}:subagent:${subagent.
|
|
2036
|
+
agentScope: `${this.durableAgentScope()}:subagent:${subagent.path}`,
|
|
1891
2037
|
conversationId,
|
|
1892
2038
|
agentSource: subagent.agentSource,
|
|
2039
|
+
surface,
|
|
1893
2040
|
catalog: {
|
|
1894
2041
|
...baseCatalog,
|
|
2042
|
+
skills: new Set(liveSkills),
|
|
1895
2043
|
models: new Set(subagent.possibleModels),
|
|
1896
2044
|
connections: new Set(subagent.connections),
|
|
1897
2045
|
...(subagent.maxReasoning !== undefined ? { maxReasoning: subagent.maxReasoning } : {})
|
|
1898
2046
|
},
|
|
2047
|
+
defaultSkills: liveSkills,
|
|
1899
2048
|
run: immutableAgentRunContext({
|
|
1900
2049
|
id: run.id,
|
|
1901
2050
|
message,
|
|
@@ -1904,9 +2053,11 @@ export class AssemblyLineRuntime {
|
|
|
1904
2053
|
...(typeof run.input.userId === "string" ? { userId: run.input.userId } : {}),
|
|
1905
2054
|
...(principalFromRun(run) ? { principal: principalFromRun(run) } : {}),
|
|
1906
2055
|
...(initiatorFromRun(run) ? { initiator: initiatorFromRun(run) } : {}),
|
|
2056
|
+
audience: audienceFromRun(run),
|
|
1907
2057
|
...(isJsonObject(run.input.metadata) ? { metadata: run.input.metadata } : {}),
|
|
1908
2058
|
attachments: []
|
|
1909
2059
|
}),
|
|
2060
|
+
disabledTools: this.disabledToolsForRun(run),
|
|
1910
2061
|
createCheckpoint: (input) => this.createCheckpoint(input),
|
|
1911
2062
|
listCheckpoints: (runId) => this.listHydratedCheckpoints(runId)
|
|
1912
2063
|
});
|
|
@@ -1914,6 +2065,10 @@ export class AssemblyLineRuntime {
|
|
|
1914
2065
|
this.agentHookControllers.set(run.id, created.controller);
|
|
1915
2066
|
return created.controller;
|
|
1916
2067
|
}
|
|
2068
|
+
disabledToolsForRun(run) {
|
|
2069
|
+
const disabledTools = new Set(Object.entries(this.coreToolPolicy).filter(([, mode]) => mode === "disabled").map(([name]) => name));
|
|
2070
|
+
return disabledTools;
|
|
2071
|
+
}
|
|
1917
2072
|
agentStateForRun(runId) {
|
|
1918
2073
|
const handle = this.agentStateHandles.get(runId);
|
|
1919
2074
|
if (!handle)
|
|
@@ -1931,9 +2086,6 @@ export class AssemblyLineRuntime {
|
|
|
1931
2086
|
createSubagent: (subagent, message, conversationId) => this.createSubagentHookController(run, subagent, message, conversationId)
|
|
1932
2087
|
});
|
|
1933
2088
|
}
|
|
1934
|
-
resolvedInstructionsForRun(run, bundle, capabilities) {
|
|
1935
|
-
return resolvedHookInstructionsForRun(this.manifest, this.sourceLoader, run, bundle.instructions, capabilities);
|
|
1936
|
-
}
|
|
1937
2089
|
async loadTool(tool, run) {
|
|
1938
2090
|
const stub = resolveEvalToolStub(this.evalStubCursors, run, tool.name) ?? this.toolStubs[tool.name];
|
|
1939
2091
|
if (stub) {
|
|
@@ -1943,8 +2095,6 @@ export class AssemblyLineRuntime {
|
|
|
1943
2095
|
execute: async (input) => stub(input)
|
|
1944
2096
|
};
|
|
1945
2097
|
}
|
|
1946
|
-
// Only builtin-sourced entries resolve to the built-in implementation; an
|
|
1947
|
-
// authored tool that shares a built-in's name is an override and loads its module.
|
|
1948
2098
|
if (tool.source.path.startsWith("__builtin__")) {
|
|
1949
2099
|
const builtIn = builtInToolDefinition(tool.name);
|
|
1950
2100
|
if (builtIn)
|
|
@@ -1953,26 +2103,8 @@ export class AssemblyLineRuntime {
|
|
|
1953
2103
|
const module = await this.sourceLoader.load(tool.source);
|
|
1954
2104
|
return module.default;
|
|
1955
2105
|
}
|
|
1956
|
-
async loadInstrumentationModule() {
|
|
1957
|
-
if (!this.manifest.instrumentation)
|
|
1958
|
-
return {};
|
|
1959
|
-
return this.sourceLoader.load(this.manifest.instrumentation);
|
|
1960
|
-
}
|
|
1961
2106
|
async result(run, response, waitingForApproval, waitingForInput, waitingForConnection) {
|
|
1962
|
-
|
|
1963
|
-
run,
|
|
1964
|
-
events: await this.state.listEvents(run.id),
|
|
1965
|
-
toolCalls: await this.state.listToolCalls(run.id),
|
|
1966
|
-
deliveries: await this.state.listDeliveries(run.id),
|
|
1967
|
-
response
|
|
1968
|
-
};
|
|
1969
|
-
if (waitingForApproval !== undefined)
|
|
1970
|
-
result.waitingForApproval = waitingForApproval;
|
|
1971
|
-
if (waitingForInput !== undefined)
|
|
1972
|
-
result.waitingForInput = waitingForInput;
|
|
1973
|
-
if (waitingForConnection !== undefined)
|
|
1974
|
-
result.waitingForConnection = waitingForConnection;
|
|
1975
|
-
return result;
|
|
2107
|
+
return buildRunAgentResult(this.state, run, response, waitingForApproval, waitingForInput, waitingForConnection);
|
|
1976
2108
|
}
|
|
1977
2109
|
}
|
|
1978
2110
|
export async function runLocalAgent(options) {
|