eve 0.36.0 → 0.37.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/README.md +1 -0
- package/dist/src/channel/routes.d.ts +13 -3
- package/dist/src/channel/routes.js +1 -1
- package/dist/src/channel/session-callback.js +1 -1
- package/dist/src/channel/session.d.ts +2 -1
- package/dist/src/channel/session.js +1 -1
- package/dist/src/channel/types.d.ts +41 -0
- package/dist/src/chunks/{use-eve-agent-CnppTEFk.js → use-eve-agent-Bi5fRxcZ.js} +9 -1
- package/dist/src/chunks/{use-eve-agent-COmP-H8R.js → use-eve-agent-DbKUBhl-.js} +9 -1
- package/dist/src/cli/commands/agent-instructions.d.ts +4 -4
- package/dist/src/cli/commands/init-confirm.d.ts +12 -0
- package/dist/src/cli/commands/init-confirm.js +1 -0
- package/dist/src/cli/commands/init-git.js +1 -1
- package/dist/src/cli/commands/init-recovery.d.ts +3 -0
- package/dist/src/cli/commands/init-recovery.js +3 -0
- package/dist/src/cli/commands/init-target.d.ts +21 -0
- package/dist/src/cli/commands/init-target.js +1 -0
- package/dist/src/cli/commands/init.d.ts +6 -5
- package/dist/src/cli/commands/init.js +1 -1
- package/dist/src/cli/dev/tui/runner.d.ts +8 -0
- package/dist/src/cli/dev/tui/runner.js +1 -1
- package/dist/src/cli/dev/tui/subagent-pump.d.ts +27 -22
- package/dist/src/cli/dev/tui/subagent-pump.js +1 -1
- package/dist/src/cli/dev/tui/terminal-renderer.d.ts +16 -0
- package/dist/src/cli/dev/tui/terminal-renderer.js +12 -12
- package/dist/src/cli/dev/tui/tool-presentation.js +1 -1
- package/dist/src/cli/run.d.ts +1 -0
- package/dist/src/cli/run.js +3 -3
- package/dist/src/client/open-stream.d.ts +2 -0
- package/dist/src/client/open-stream.js +1 -1
- package/dist/src/client/session.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +3 -1
- package/dist/src/compiled/@modelcontextprotocol/server/LICENSE +216 -0
- package/dist/src/compiled/@modelcontextprotocol/server/index.d.ts +98 -0
- package/dist/src/compiled/@modelcontextprotocol/server/index.js +80 -0
- package/dist/src/compiled/@vercel/sandbox/api-client/api-client.d.ts +339 -0
- package/dist/src/compiled/@vercel/sandbox/api-client/index.d.ts +1 -1
- package/dist/src/compiled/@vercel/sandbox/api-client/validators.d.ts +25 -1
- package/dist/src/compiled/@vercel/sandbox/drive.d.ts +140 -0
- package/dist/src/compiled/@vercel/sandbox/index.d.ts +3 -2
- package/dist/src/compiled/@vercel/sandbox/index.js +13 -13
- package/dist/src/compiled/@vercel/sandbox/sandbox.d.ts +55 -18
- package/dist/src/compiled/@vercel/sandbox-stable/LICENSE +201 -0
- package/dist/src/compiled/@vercel/sandbox-stable/_async-retry.d.ts +8 -0
- package/dist/src/compiled/@vercel/sandbox-stable/_workflow-serde.d.ts +5 -0
- package/dist/src/compiled/@vercel/sandbox-stable/api-client/api-client.d.ts +1456 -0
- package/dist/src/compiled/@vercel/sandbox-stable/api-client/api-error.d.ts +29 -0
- package/dist/src/compiled/@vercel/sandbox-stable/api-client/base-client.d.ts +39 -0
- package/dist/src/compiled/@vercel/sandbox-stable/api-client/file-writer.d.ts +66 -0
- package/dist/src/compiled/@vercel/sandbox-stable/api-client/index.d.ts +2 -0
- package/dist/src/compiled/@vercel/sandbox-stable/api-client/validators.d.ts +899 -0
- package/dist/src/compiled/@vercel/sandbox-stable/api-client/with-retry.d.ts +10 -0
- package/dist/src/compiled/@vercel/sandbox-stable/auth/error.d.ts +15 -0
- package/dist/src/compiled/@vercel/sandbox-stable/auth/file.d.ts +18 -0
- package/dist/src/compiled/@vercel/sandbox-stable/auth/index.d.ts +6 -0
- package/dist/src/compiled/@vercel/sandbox-stable/auth/oauth.d.ts +111 -0
- package/dist/src/compiled/@vercel/sandbox-stable/auth/poll-for-token.d.ts +28 -0
- package/dist/src/compiled/@vercel/sandbox-stable/auth/project.d.ts +40 -0
- package/dist/src/compiled/@vercel/sandbox-stable/command.d.ts +292 -0
- package/dist/src/compiled/@vercel/sandbox-stable/constants.d.ts +5 -0
- package/dist/src/compiled/@vercel/sandbox-stable/execution-context.d.ts +116 -0
- package/dist/src/compiled/@vercel/sandbox-stable/filesystem.d.ts +258 -0
- package/dist/src/compiled/@vercel/sandbox-stable/index.d.ts +12 -0
- package/dist/src/compiled/@vercel/sandbox-stable/index.js +1 -0
- package/dist/src/compiled/@vercel/sandbox-stable/network-policy.d.ts +169 -0
- package/dist/src/compiled/@vercel/sandbox-stable/proxy.d.ts +55 -0
- package/dist/src/compiled/@vercel/sandbox-stable/sandbox-user.d.ts +212 -0
- package/dist/src/compiled/@vercel/sandbox-stable/sandbox.d.ts +1216 -0
- package/dist/src/compiled/@vercel/sandbox-stable/session.d.ts +433 -0
- package/dist/src/compiled/@vercel/sandbox-stable/snapshot.d.ts +229 -0
- package/dist/src/compiled/@vercel/sandbox-stable/utils/get-credentials.d.ts +21 -0
- package/dist/src/compiled/@vercel/sandbox-stable/utils/paginator.d.ts +16 -0
- package/dist/src/compiled/@vercel/sandbox-stable/utils/resolveSignal.d.ts +15 -0
- package/dist/src/compiled/@vercel/sandbox-stable/utils/sandbox-snapshot.d.ts +11 -0
- package/dist/src/compiled/@vercel/sandbox-stable/utils/types.d.ts +11 -0
- package/dist/src/compiled/_chunks/node/{auth-BS3UoyvT.js → auth-BaNbsImr.js} +1 -1
- package/dist/src/compiled/_chunks/node/version-BYHw-SDY.js +1 -0
- package/dist/src/compiler/extension-compatibility.d.ts +10 -10
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/compiler/manifest.js +1 -1
- package/dist/src/compiler/normalize-agent-config.js +1 -1
- package/dist/src/compiler/normalize-manifest.js +1 -1
- package/dist/src/compiler/normalize-subagent.d.ts +1 -1
- package/dist/src/compiler/normalize-subagent.js +1 -1
- package/dist/src/context/serialized-dynamic-model-selection.d.ts +2 -0
- package/dist/src/context/serialized-dynamic-model-selection.js +1 -0
- package/dist/src/execution/agent-handle-dispatch.d.ts +15 -1
- package/dist/src/execution/agent-handle-dispatch.js +1 -1
- package/dist/src/execution/cancel-descendant-turns-step.js +1 -1
- package/dist/src/execution/delegated-parent-notification.d.ts +17 -0
- package/dist/src/execution/delegated-parent-notification.js +1 -1
- package/dist/src/execution/deliver-payloads.js +1 -1
- package/dist/src/execution/dispatch-runtime-actions-shared.d.ts +155 -0
- package/dist/src/execution/dispatch-runtime-actions-shared.js +1 -0
- package/dist/src/execution/dispatch-runtime-actions-step.d.ts +18 -14
- package/dist/src/execution/dispatch-runtime-actions-step.js +1 -1
- package/dist/src/execution/dispatch-workflow-runtime-actions-step.d.ts +7 -2
- package/dist/src/execution/dispatch-workflow-runtime-actions-step.js +1 -1
- package/dist/src/execution/effective-output-schema.d.ts +21 -0
- package/dist/src/execution/effective-output-schema.js +1 -0
- package/dist/src/execution/eve-workflow-attributes.d.ts +2 -0
- package/dist/src/execution/node-step.js +1 -1
- package/dist/src/execution/parked-delivery-wait.d.ts +8 -12
- package/dist/src/execution/parked-delivery-wait.js +1 -1
- package/dist/src/execution/{route-proxied-deliver-step.d.ts → proxied-deliver-step.d.ts} +7 -4
- package/dist/src/execution/proxied-deliver-step.js +1 -0
- package/dist/src/execution/remote-agent-dispatch.d.ts +32 -0
- package/dist/src/execution/remote-agent-dispatch.js +1 -1
- package/dist/src/execution/remote-agent-route-url.d.ts +2 -0
- package/dist/src/execution/remote-agent-route-url.js +1 -0
- package/dist/src/execution/route-child-delivery.d.ts +2 -1
- package/dist/src/execution/route-child-delivery.js +1 -1
- package/dist/src/execution/sandbox/bindings/vercel.d.ts +2 -1
- package/dist/src/execution/sandbox/bindings/vercel.js +1 -1
- package/dist/src/execution/session-callback-step.d.ts +11 -0
- package/dist/src/execution/session-callback-step.js +1 -1
- package/dist/src/execution/session-command-wire.js +1 -1
- package/dist/src/execution/session-state-cursor.d.ts +25 -0
- package/dist/src/execution/session-state-cursor.js +1 -0
- package/dist/src/execution/settle-cancelled-turn-step.d.ts +2 -0
- package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
- package/dist/src/execution/subagent-event-proxy-step.d.ts +15 -0
- package/dist/src/execution/subagent-event-proxy-step.js +1 -1
- package/dist/src/execution/subagent-hitl-proxy.d.ts +14 -7
- package/dist/src/execution/subagent-hitl-proxy.js +1 -1
- package/dist/src/execution/subagent-start-local.d.ts +29 -0
- package/dist/src/execution/subagent-start-local.js +1 -0
- package/dist/src/execution/subagent-start-remote.d.ts +23 -0
- package/dist/src/execution/subagent-start-remote.js +1 -0
- package/dist/src/execution/task-event-callback.d.ts +13 -0
- package/dist/src/execution/task-event-callback.js +1 -0
- package/dist/src/execution/task-input-capability.d.ts +4 -0
- package/dist/src/execution/task-input-capability.js +1 -0
- package/dist/src/execution/tasks/child/steps.d.ts +46 -0
- package/dist/src/execution/tasks/child/steps.js +1 -0
- package/dist/src/execution/tasks/child/workflow.d.ts +31 -0
- package/dist/src/execution/tasks/child/workflow.js +1 -0
- package/dist/src/execution/tasks/parent/agent-identity.d.ts +13 -0
- package/dist/src/execution/tasks/parent/agent-identity.js +1 -0
- package/dist/src/execution/tasks/parent/agent-views.d.ts +6 -0
- package/dist/src/execution/tasks/parent/agent-views.js +1 -0
- package/dist/src/execution/tasks/parent/continuation-dispatch.d.ts +37 -0
- package/dist/src/execution/tasks/parent/continuation-dispatch.js +1 -0
- package/dist/src/execution/tasks/parent/control-shared.d.ts +36 -0
- package/dist/src/execution/tasks/parent/control-shared.js +1 -0
- package/dist/src/execution/tasks/parent/delegate.d.ts +70 -0
- package/dist/src/execution/tasks/parent/delegate.js +1 -0
- package/dist/src/execution/tasks/parent/dispatch-task-step.d.ts +19 -0
- package/dist/src/execution/tasks/parent/dispatch-task-step.js +1 -0
- package/dist/src/execution/tasks/parent/dispatch.d.ts +33 -0
- package/dist/src/execution/tasks/parent/dispatch.js +1 -0
- package/dist/src/execution/tasks/parent/hitl-proxy-steps.d.ts +29 -0
- package/dist/src/execution/tasks/parent/hitl-proxy-steps.js +1 -0
- package/dist/src/execution/tasks/parent/run-parent.d.ts +72 -0
- package/dist/src/execution/tasks/parent/run-parent.js +1 -0
- package/dist/src/execution/tasks/parent/send.d.ts +25 -0
- package/dist/src/execution/tasks/parent/send.js +1 -0
- package/dist/src/execution/tasks/workflow-target.d.ts +2 -0
- package/dist/src/execution/tasks/workflow-target.js +1 -0
- package/dist/src/execution/terminate-child-sessions-step.d.ts +1 -0
- package/dist/src/execution/terminate-child-sessions-step.js +1 -1
- package/dist/src/execution/turn-control-receiver.d.ts +10 -0
- package/dist/src/execution/turn-control-receiver.js +1 -1
- package/dist/src/execution/turn-dispatch.d.ts +2 -0
- package/dist/src/execution/turn-dispatch.js +1 -1
- package/dist/src/execution/turn-execution-cursor.d.ts +2 -8
- package/dist/src/execution/turn-execution-cursor.js +1 -1
- package/dist/src/execution/turn-workflow.js +1 -1
- package/dist/src/execution/workflow-callback-url.d.ts +5 -0
- package/dist/src/execution/workflow-callback-url.js +1 -1
- package/dist/src/execution/workflow-entry.js +1 -1
- package/dist/src/execution/workflow-runtime.d.ts +9 -0
- package/dist/src/execution/workflow-runtime.js +1 -1
- package/dist/src/execution/workflow-steps.d.ts +7 -21
- package/dist/src/execution/workflow-steps.js +1 -1
- package/dist/src/harness/advertised-tools.js +1 -1
- package/dist/src/harness/authorization.js +1 -1
- package/dist/src/harness/execute-tool.d.ts +7 -0
- package/dist/src/harness/handles/prompt.d.ts +12 -0
- package/dist/src/harness/handles/prompt.js +2 -1
- package/dist/src/harness/handles/query.js +1 -1
- package/dist/src/harness/handles/store.d.ts +9 -2
- package/dist/src/harness/handles/store.js +1 -1
- package/dist/src/harness/handles/transitions.d.ts +10 -1
- package/dist/src/harness/handles/transitions.js +1 -1
- package/dist/src/harness/proxy-input-requests.d.ts +21 -4
- package/dist/src/harness/proxy-input-requests.js +1 -1
- package/dist/src/harness/runtime-actions.d.ts +2 -0
- package/dist/src/harness/runtime-actions.js +1 -1
- package/dist/src/harness/session-limit-enforcement.js +1 -1
- package/dist/src/harness/tool-loop.js +2 -2
- package/dist/src/harness/workflow-runtime-action-state.js +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/authored-definition/core.js +1 -1
- package/dist/src/internal/invocation/agent-invocation.d.ts +54 -0
- package/dist/src/internal/invocation/agent-invocation.js +1 -0
- package/dist/src/internal/invocation/attributes.d.ts +2 -0
- package/dist/src/internal/invocation/attributes.js +1 -0
- package/dist/src/internal/invocation/metadata.d.ts +9 -0
- package/dist/src/internal/invocation/metadata.js +1 -0
- package/dist/src/internal/invocation/workflow-execution.d.ts +32 -0
- package/dist/src/internal/invocation/workflow-execution.js +1 -0
- package/dist/src/internal/mcp/http-security.d.ts +12 -0
- package/dist/src/internal/mcp/http-security.js +1 -0
- package/dist/src/internal/mcp/protected-resource.d.ts +9 -0
- package/dist/src/internal/mcp/protected-resource.js +1 -0
- package/dist/src/internal/mcp/streamable-http-server.d.ts +51 -0
- package/dist/src/internal/mcp/streamable-http-server.js +1 -0
- package/dist/src/internal/nitro/routes/channel-dispatch.js +1 -1
- package/dist/src/internal/nitro/routes/channel-route-context.d.ts +14 -0
- package/dist/src/internal/nitro/routes/channel-route-context.js +1 -1
- package/dist/src/internal/nitro/routes/runtime-stack.d.ts +2 -0
- package/dist/src/internal/nitro/routes/runtime-stack.js +1 -1
- package/dist/src/internal/vercel-agent-summary.d.ts +1 -1
- package/dist/src/packages/eve-catalog/src/index.js +1 -1
- package/dist/src/protocol/message.d.ts +28 -0
- package/dist/src/protocol/message.js +2 -2
- package/dist/src/protocol/routes.d.ts +14 -0
- package/dist/src/protocol/routes.js +1 -1
- package/dist/src/public/channels/auth.d.ts +36 -0
- package/dist/src/public/channels/auth.js +1 -1
- package/dist/src/public/channels/eve.js +1 -1
- package/dist/src/public/channels/mcp.d.ts +19 -0
- package/dist/src/public/channels/mcp.js +1 -0
- package/dist/src/public/definitions/channel.d.ts +2 -2
- package/dist/src/public/definitions/channel.js +1 -1
- package/dist/src/public/sandbox/backends/vercel.d.ts +5 -4
- package/dist/src/public/sandbox/backends/vercel.js +1 -1
- package/dist/src/public/sandbox/vercel-sandbox.d.ts +25 -1
- package/dist/src/public/sandbox/vercel.d.ts +2 -1
- package/dist/src/public/sandbox/vercel.js +1 -1
- package/dist/src/react/use-eve-agent.js +1 -1
- package/dist/src/runtime/actions/types.d.ts +9 -0
- package/dist/src/runtime/actions/types.js +1 -1
- package/dist/src/runtime/agent/bootstrap.js +1 -1
- package/dist/src/runtime/connections/authorization-complete-page.js +70 -28
- package/dist/src/runtime/framework-channels/index.js +1 -1
- package/dist/src/runtime/framework-tools/index.js +1 -1
- package/dist/src/runtime/framework-tools/tasks.d.ts +95 -0
- package/dist/src/runtime/framework-tools/tasks.js +1 -0
- package/dist/src/runtime/prompt/compose.d.ts +1 -0
- package/dist/src/runtime/prompt/compose.js +1 -1
- package/dist/src/runtime/resolve-agent-graph.js +1 -1
- package/dist/src/runtime/resolve-agent.js +1 -1
- package/dist/src/runtime/session-callback-route.js +1 -1
- package/dist/src/runtime/task-input-response-route.d.ts +5 -0
- package/dist/src/runtime/task-input-response-route.js +1 -0
- package/dist/src/setup/scaffold/create/add-to-project.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/setup/scaffold/create/web-template.d.ts +1 -1
- package/dist/src/setup/scaffold/create/web-template.js +0 -1
- package/dist/src/shared/agent-definition.d.ts +7 -0
- package/dist/src/shared/sandbox-network-policy.d.ts +1 -1
- package/dist/src/svelte/index.js +1 -1
- package/dist/src/svelte/use-eve-agent.js +1 -1
- package/dist/src/tasks/json.d.ts +88 -0
- package/dist/src/tasks/json.js +1 -0
- package/dist/src/tasks/session-index.d.ts +48 -0
- package/dist/src/tasks/session-index.js +1 -0
- package/dist/src/tasks/task-id.d.ts +34 -0
- package/dist/src/tasks/task-id.js +1 -0
- package/dist/src/tasks/transitions.d.ts +23 -0
- package/dist/src/tasks/transitions.js +1 -0
- package/dist/src/tasks/types.d.ts +295 -0
- package/dist/src/tasks/types.js +1 -0
- package/dist/src/tasks/wire.d.ts +26 -0
- package/dist/src/tasks/wire.js +1 -0
- package/dist/src/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/channels/eve.mdx +14 -0
- package/docs/guides/client/streaming.mdx +1 -1
- package/docs/reference/cli.md +10 -6
- package/docs/tools/human-in-the-loop.md +3 -1
- package/package.json +8 -1
- package/dist/src/compiled/_chunks/node/version-Cztrk7z6.js +0 -1
- package/dist/src/execution/route-proxied-deliver-step.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{routeProxiedDeliverStep}from"#execution/
|
|
1
|
+
import{coalesceDeliverPayloads}from"#execution/deliver-payloads.js";import{routeProxiedDeliverStep}from"#execution/proxied-deliver-step.js";import{emitRecordedTaskAuthorizationEventStep,emitRecordedTaskInputRequestStep}from"#execution/subagent-event-proxy-step.js";import{acceptTaskAuthorizationEventStep,recordTaskInputRequestStep,recordTerminalTaskViewsStep}from"#execution/tasks/parent/hitl-proxy-steps.js";async function routeDeliverToChildren(i){let a=coalesceDeliverPayloads(i.delivery.payloads),o=i.serializedContext,s=i.sessionState;(a.task?.views?.length??0)>0&&(s=await recordTerminalTaskViewsStep({sessionState:s,views:a.task?.views??[]}));for(let e of a.task?.inputRequests??[]){let t=await recordTaskInputRequestStep({hookPayload:e.hookPayload,serializedContext:o,sessionState:s,taskId:e.taskId});if(s=t.sessionState,!t.accepted)continue;let n=await emitRecordedTaskInputRequestStep({hookPayload:t.hookPayload,parentWritable:i.parentWritable,serializedContext:o,sessionState:s});o=n.serializedContext,s=n.sessionState}for(let e of a.task?.authorizationEvents??[]){if(!await acceptTaskAuthorizationEventStep({hookPayload:e.hookPayload,sessionState:s,taskId:e.taskId}))continue;let t=await emitRecordedTaskAuthorizationEventStep({hookPayload:e.hookPayload,parentWritable:i.parentWritable,serializedContext:o,sessionState:s});o=t.serializedContext,s=t.sessionState}let c=[],l=[];for(let[e,t]of i.delivery.payloads.entries()){let n={...t};if(delete n.task,Object.keys(n).length===0)continue;let r=c.length;c.push(n);for(let t of i.delivery.deliveryMetadata??[])t.payloadIndex===e&&l.push({...t,payloadIndex:r})}let u=c.length===0?void 0:{...i.delivery,deliveryMetadata:l.length===0?void 0:l,payloads:c};return u===void 0?{kind:`continue`,remainder:void 0,serializedContext:o,sessionState:s}:s.hasProxyInputRequests?await routeProxiedDeliverStep({delivery:u,parentWritable:i.parentWritable,serializedContext:o,sessionState:s}):{kind:`continue`,remainder:u,serializedContext:o,sessionState:s}}export{routeDeliverToChildren};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { SandboxBackend } from "#public/definitions/sandbox-backend.js";
|
|
2
|
-
import type { VercelSandboxBootstrapUseOptions, VercelSandboxSessionUseOptions } from "#public/sandbox/vercel-sandbox.js";
|
|
2
|
+
import type { VercelSandboxBootstrapUseOptions, VercelSandboxSessionCreateContext, VercelSandboxSessionCreateOptions, VercelSandboxSessionUseOptions } from "#public/sandbox/vercel-sandbox.js";
|
|
3
3
|
import { type CreateVercelSandbox } from "#execution/sandbox/bindings/vercel-create-sdk.js";
|
|
4
4
|
import type { VercelCreateOptions, VercelModule } from "#execution/sandbox/bindings/vercel-sdk-types.js";
|
|
5
5
|
export interface CreateVercelSandboxInput {
|
|
6
6
|
readonly createSandbox?: CreateVercelSandbox;
|
|
7
7
|
readonly createOptions?: VercelCreateOptions;
|
|
8
8
|
readonly loadSandboxModule?: () => Promise<VercelModule>;
|
|
9
|
+
readonly resolveSessionCreateOptions?: (context: VercelSandboxSessionCreateContext) => Promise<VercelSandboxSessionCreateOptions> | VercelSandboxSessionCreateOptions;
|
|
9
10
|
}
|
|
10
11
|
/**
|
|
11
12
|
* Creates the Vercel-backed sandbox backend.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolveSandboxModelPath}from"#shared/skill-paths.js";import{WORKSPACE_ROOT}from"#runtime/workspace/types.js";import{streamToBuffer}from"#execution/sandbox/stream-utils.js";import{createLoggingSandboxSession}from"#execution/sandbox/logging-session.js";import{buildSandboxSession}from"#execution/sandbox/session.js";import{SandboxTemplateNotProvisionedError}from"#public/definitions/sandbox-backend.js";import{adaptMultiplexedCommandToSandboxProcess}from"#execution/sandbox/multiplexed-command.js";import{applyInitialVercelNetworkPolicy,ensureVercelSandboxBaseRuntime}from"#execution/sandbox/bindings/vercel-base-runtime.js";import{createVercelEveImageSandbox}from"#execution/sandbox/bindings/vercel-create-sdk.js";import{isVercelSandboxMissingError,isVercelSnapshotUnavailableError}from"#execution/sandbox/bindings/vercel-errors.js";import{getNamedVercelSandbox}from"#execution/sandbox/bindings/vercel-lookup.js";import{normalizeVercelReadStream}from"#execution/sandbox/bindings/vercel-read-stream.js";function createVercelSandbox(e={}){let t=e.loadSandboxModule??(async()=>await import(`#compiled/@vercel/sandbox/index.js`)),n={timeout:DEFAULT_SANDBOX_TIMEOUT_MS,...e.createOptions},r=e.createSandbox??createVercelEveImageSandbox,i=new Map;return{name:`vercel`,async create(
|
|
1
|
+
import{resolveSandboxModelPath}from"#shared/skill-paths.js";import{WORKSPACE_ROOT}from"#runtime/workspace/types.js";import{streamToBuffer}from"#execution/sandbox/stream-utils.js";import{createLoggingSandboxSession}from"#execution/sandbox/logging-session.js";import{buildSandboxSession}from"#execution/sandbox/session.js";import{SandboxTemplateNotProvisionedError}from"#public/definitions/sandbox-backend.js";import{adaptMultiplexedCommandToSandboxProcess}from"#execution/sandbox/multiplexed-command.js";import{applyInitialVercelNetworkPolicy,ensureVercelSandboxBaseRuntime}from"#execution/sandbox/bindings/vercel-base-runtime.js";import{createVercelEveImageSandbox}from"#execution/sandbox/bindings/vercel-create-sdk.js";import{isVercelSandboxMissingError,isVercelSnapshotUnavailableError}from"#execution/sandbox/bindings/vercel-errors.js";import{getNamedVercelSandbox}from"#execution/sandbox/bindings/vercel-lookup.js";import{normalizeVercelReadStream}from"#execution/sandbox/bindings/vercel-read-stream.js";function createVercelSandbox(e={}){let t=e.loadSandboxModule??(async()=>await import(`#compiled/@vercel/sandbox/index.js`)),n={timeout:DEFAULT_SANDBOX_TIMEOUT_MS,...e.createOptions},r=e.createSandbox??createVercelEveImageSandbox,i=new Map;return{name:`vercel`,async create(o){let c=resolveVercelSandboxTags(n.tags,o.tags),u=o.templateKey===null?null:await readTemplateForCreate({createOptions:n,loadSandboxModule:t,prewarmedTemplates:i,templateKey:o.templateKey}),d=await t(),f;try{f=await ensureSession({createOptions:n,createSandbox:r,existingMetadata:o.existingMetadata,resolveSessionCreateOptions:e.resolveSessionCreateOptions,sandboxModule:d,sessionId:o.tags?.sessionId??o.sessionKey,sessionKey:o.sessionKey,snapshotId:u?.snapshotId,tags:c})}catch(e){throw u!==null&&(isVercelSnapshotUnavailableError(e)||isVercelSandboxMissingError(e))?(i.delete(u.templateKey),await(await getNamedVercelSandbox({createOptions:n,sandboxModule:d,sandboxName:u.sandboxName}))?.delete(),new SandboxTemplateNotProvisionedError({backendName:`vercel`,templateKey:u.templateKey})):Error(`Failed to create sandbox session "${o.sessionKey}": ${errorMessage(e)}`,{cause:e})}return u===null&&f.created&&(await ensureVercelSandboxBaseRuntime(f.sandbox),await applyInitialVercelNetworkPolicy(f.sandbox,n.networkPolicy)),createHandle(f.sandbox,o.sessionKey)},async prewarm(e){let a;try{a=await ensureTemplateWithUnavailableRetry({bootstrap:e.bootstrap,createOptions:n,createSandbox:r,loadSandboxModule:t,log:e.log,seedFiles:e.seedFiles,templateKey:e.templateKey})}catch(t){throw Error(`Failed to prewarm Vercel sandbox template "${e.templateKey}": ${errorMessage(t)}`,{cause:t})}return i.set(e.templateKey,a.template),{reused:a.reused}}}}async function ensureTemplateWithUnavailableRetry(e){try{return await ensureTemplate(e)}catch(t){if(!isVercelSnapshotUnavailableError(t)&&!isVercelSandboxMissingError(t))throw t;return e.log?.(`cached template disappeared; rebuilding sandbox template`),await ensureTemplate(e)}}async function readTemplate(e){let t=e.prewarmedTemplates.get(e.templateKey);if(t!==void 0)return t;let n=await e.loadSandboxModule(),r=await getNamedVercelSandbox({createOptions:e.createOptions,sandboxModule:n,sandboxName:e.templateKey});if(r===null||typeof r.currentSnapshotId!=`string`)throw new SandboxTemplateNotProvisionedError({backendName:`vercel`,templateKey:e.templateKey});return{sandboxName:r.name,snapshotId:r.currentSnapshotId,templateKey:e.templateKey}}async function readTemplateForCreate(e){try{return await readTemplate(e)}catch(t){throw SandboxTemplateNotProvisionedError.is(t)?t:Error(`Failed to read sandbox template "${e.templateKey}": ${errorMessage(t)}`,{cause:t})}}async function ensureTemplate(e){let t=await e.loadSandboxModule(),n=await getNamedVercelSandbox({createOptions:e.createOptions,sandboxModule:t,sandboxName:e.templateKey}),a=resolveVercelSandboxTags(e.createOptions.tags,e.tags),o=extractAuthorSnapshotId(e.createOptions);if(n!==null&&isUnprovisionedTerminalTemplateSandbox(n,o)&&(await n.delete(),n=null),n===null?n=await e.createSandbox({sandboxModule:t,createOptions:withBaseSetupNetworkPolicy({...e.createOptions,name:e.templateKey,persistent:!1,tags:a})}):await ensureVercelSandboxTags(n,a),typeof n.currentSnapshotId==`string`&&n.currentSnapshotId.length>0&&n.currentSnapshotId!==o)return{reused:!0,template:{sandboxName:n.name,snapshotId:n.currentSnapshotId,templateKey:e.templateKey}};e.log?.(`preparing base runtime inside sandbox`),await ensureVercelSandboxBaseRuntime(n),await applyInitialVercelNetworkPolicy(n,e.createOptions.networkPolicy);let c=buildSandboxSession(createVercelInternalSandboxSession(n,e.templateKey),createVercelNetworkPolicySetter(n));await writeVercelSandboxSeedFiles({sandbox:n,seedFiles:e.seedFiles,session:c}),e.bootstrap!==void 0&&(e.log?.(`running sandbox bootstrap`),await e.bootstrap({use:async t=>(t!==void 0&&await n.update(t),createLoggingSandboxSession({log:e.log,session:c}))}));let l=await n.snapshot();return{reused:!1,template:{sandboxName:n.name,snapshotId:l.snapshotId,templateKey:e.templateKey}}}async function ensureSession(e){let t=getVercelSandboxName(e.existingMetadata)??e.sessionKey,n=await getNamedVercelSandbox({createOptions:e.createOptions,sandboxModule:e.sandboxModule,sandboxName:t});if(n!==null)return await ensureVercelSandboxTags(n,e.tags),{created:!1,sandbox:n};let r=createSessionCreateParams(e,t,await e.resolveSessionCreateOptions?.({session:{id:e.sessionId}}));return e.tags!==void 0&&(r.tags=e.tags),{created:!0,sandbox:await e.createSandbox({createOptions:r,sandboxModule:e.sandboxModule})}}function createSessionCreateParams(e,t,n={}){let r={...e.createOptions,...n};if(e.snapshotId===void 0)return withBaseSetupNetworkPolicy({...r,name:t,persistent:!0});let{image:i,runtime:a,source:o,...s}=r;return{...s,name:t,persistent:!0,source:{snapshotId:e.snapshotId,type:`snapshot`}}}function withBaseSetupNetworkPolicy(e){return{...e,networkPolicy:`allow-all`}}function createHandle(e,t){return{session:buildSandboxSession(createVercelInternalSandboxSession(e,t),createVercelNetworkPolicySetter(e)),useSessionFn:async n=>(n!==void 0&&await e.update(n),buildSandboxSession(createVercelInternalSandboxSession(e,t),createVercelNetworkPolicySetter(e))),async captureState(){return{backendName:`vercel`,metadata:{sandboxName:e.name},sessionKey:t}},async stop(){await stopVercelSandbox(e)},async shutdown(){try{await stopVercelSandbox(e)}catch{}}}}async function stopVercelSandbox(e){e.status!==`running`&&e.status!==`pending`||await e.stop()}function createVercelNetworkPolicySetter(e){return async t=>{await e.update({networkPolicy:t})}}function createVercelInternalSandboxSession(e,r){return{id:r,resolvePath:resolveVercelSandboxPath,async spawn(n){return adaptMultiplexedCommandToSandboxProcess({command:await e.runCommand({args:[`-lc`,n.command],cmd:`bash`,cwd:n.workingDirectory??WORKSPACE_ROOT,detached:!0,env:n.env,signal:n.abortSignal}),getOutput:e=>e.stream})},async readFile(t){return normalizeVercelReadStream(await e.readFile({path:t.path}))},async writeFile(t){let r=await streamToBuffer(t.content);await e.writeFiles([{content:r,path:t.path}])},async removePath(t){await e.fs.rm(t.path,{force:t.force,recursive:t.recursive,signal:t.abortSignal})}}}async function writeVercelSandboxSeedFiles(t){if(t.seedFiles.length===0)return;let n=await Promise.all(t.seedFiles.map(async n=>({content:typeof n.content==`string`?Buffer.from(n.content):n.content,path:await resolveSandboxModelPath({path:n.path,sandbox:t.session})})));await t.sandbox.writeFiles(n)}function resolveVercelSandboxPath(e){return e.startsWith(`/`)?e:`${WORKSPACE_ROOT}/${e}`}function isUnprovisionedTerminalTemplateSandbox(e,t){let n=e.currentSnapshotId;return typeof n==`string`&&n.length>0&&n!==t?!1:e.status===`aborted`||e.status===`failed`||e.status===`stopped`}function extractAuthorSnapshotId(e){let t=e.source;if(t?.type===`snapshot`&&typeof t.snapshotId==`string`)return t.snapshotId}function getVercelSandboxName(e){let t=e?.sandboxName;return typeof t==`string`?t:void 0}function resolveVercelSandboxTags(e,t){let n={};if(e!==void 0)for(let[t,r]of Object.entries(e))n[t]=r;if(t!==void 0)for(let[e,r]of Object.entries(t))n[e]=r;let r=Object.keys(n).length;if(r!==0){if(r>VERCEL_SANDBOX_TAG_LIMIT)throw Error(`Vercel Sandbox supports at most ${VERCEL_SANDBOX_TAG_LIMIT} tags. eve reserves "agent", "channel", and "sessionId"; remove or consolidate custom tags passed to vercel().`);return n}}async function ensureVercelSandboxTags(e,t){t===void 0||areVercelSandboxTagsEqual(e.tags,t)||await e.update({tags:t})}function areVercelSandboxTagsEqual(e,t){let n=e??{},r=Object.entries(n),i=Object.entries(t);return r.length===i.length&&i.every(([e,t])=>n[e]===t)}function errorMessage(e){if(e instanceof Error){let t=e.json,n=e.text,r=typeof n==`string`&&n.length>0?n:t===void 0?void 0:JSON.stringify(t);return r===void 0?e.message:`${e.message}: ${r}`}return String(e)}const DEFAULT_SANDBOX_TIMEOUT_MS=1800*1e3,VERCEL_SANDBOX_TAG_LIMIT=5;export{createVercelSandbox};
|
|
@@ -1,4 +1,15 @@
|
|
|
1
|
+
import type { SubagentAuthorizationEvent } from "#channel/types.js";
|
|
1
2
|
import type { TokenUsage } from "#shared/token-usage.js";
|
|
3
|
+
import type { UnstampedMessageStreamEvent } from "#protocol/message.js";
|
|
4
|
+
/** Sends task-owned remote HITL and authorization events to the parent callback capability. */
|
|
5
|
+
export declare function fireTaskEventCallbackStep(input: {
|
|
6
|
+
readonly callback: unknown;
|
|
7
|
+
readonly childContinuationToken: string;
|
|
8
|
+
readonly childSessionId: string;
|
|
9
|
+
readonly event: SubagentAuthorizationEvent | Extract<UnstampedMessageStreamEvent, {
|
|
10
|
+
type: "input.requested";
|
|
11
|
+
}>;
|
|
12
|
+
}): Promise<void>;
|
|
2
13
|
/**
|
|
3
14
|
* Sends the configured session terminal callback.
|
|
4
15
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createLogger}from"#internal/logging.js";import{SessionCallbackKey}from"#context/keys.js";import{toErrorMessage}from"#shared/errors.js";import{SESSION_FAILED}from"#harness/agent-handle-errors.js";import{parseSessionCallback}from"#channel/session-callback.js";import{postSessionCallbackRequest}from"#execution/session-callback-request.js";const log=createLogger(`execution.session-callback`);async function
|
|
1
|
+
import{createLogger}from"#internal/logging.js";import{SessionCallbackKey}from"#context/keys.js";import{toErrorMessage}from"#shared/errors.js";import{SESSION_FAILED}from"#harness/agent-handle-errors.js";import{parseSessionCallback}from"#channel/session-callback.js";import{postSessionCallbackRequest}from"#execution/session-callback-request.js";const log=createLogger(`execution.session-callback`);async function fireTaskEventCallbackStep(e){"use step";let t=parseSerializedSessionCallback(e.callback);if(t.taskId===void 0)return;let n=e.event.type===`input.requested`,r=n?`task.input-requested`:`task.authorization`,i=await postSessionCallbackRequest({body:{callId:t.callId,childContinuationToken:e.childContinuationToken,childSessionId:e.childSessionId,event:n?e.event.data:e.event,kind:r,subagentName:t.subagentName,taskId:t.taskId},url:t.url});if(!i.ok)throw Error(`Task event callback failed with HTTP ${i.status}.`)}async function fireSessionCallbackStep(e){"use step";let i=e.serializedContext[`eve.sessionId`]??``,o=e.serializedContext[SessionCallbackKey.name];if(o!==void 0)try{let t=parseSerializedSessionCallback(o),a=await postSessionCallbackRequest({body:e.status===`completed`?buildCompletedCallbackBody({callback:t,output:e.output,sessionId:i,usage:e.usage}):{callId:t.callId,error:{code:SESSION_FAILED,message:toErrorMessage(e.error)},kind:`session.failed`,sessionId:i,subagentName:t.subagentName,usage:e.usage},url:t.url});if(!a.ok)throw Error(`Session callback failed with HTTP ${a.status}.`)}catch(e){throw log.error(`failed to post session callback`,{error:e,sessionId:i}),e}}function buildCompletedCallbackBody(e){let t={callId:e.callback.callId,kind:`session.completed`,output:e.output??``,sessionId:e.sessionId,subagentName:e.callback.subagentName};return e.usage===void 0?t:{...t,usage:e.usage}}function parseSerializedSessionCallback(e){let t=parseSessionCallback(e);if(!t.ok)throw Error(`Serialized session callback is invalid.`,{cause:t.cause});return t.callback}export{fireSessionCallbackStep,fireTaskEventCallbackStep};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function sendCommandToDelivery(e){return{auth:e.auth,caller:e.caller,deliveryMetadata:e.delivery===void 0?void 0:[{...e.delivery,payloadIndex:0}],kind:`deliver`,payload:e.payload,payloads:[e.payload],requestId:e.requestId,turnPolicy:e.turnPolicy}}export{sendCommandToDelivery};
|
|
1
|
+
function sendCommandToDelivery(e){return{auth:e.auth,caller:e.caller,deliveryMetadata:e.delivery===void 0?void 0:[{...e.delivery,payloadIndex:0}],kind:`deliver`,payload:e.payload,payloads:[e.payload],requestId:e.requestId,taskDeliveryId:e.taskDeliveryId,turnPolicy:e.turnPolicy}}export{sendCommandToDelivery};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { DurableSessionState } from "#execution/durable-session-store.js";
|
|
2
|
+
/** A durable-state transition; absent fields keep the cursor's current value. */
|
|
3
|
+
export interface SessionStateTransition {
|
|
4
|
+
readonly serializedContext?: Record<string, unknown>;
|
|
5
|
+
readonly sessionState?: DurableSessionState;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Owns the mutable serialized-context / session-state pair that durable
|
|
9
|
+
* steps thread through a run. Holders adopt each step's transition instead
|
|
10
|
+
* of rebinding both values by hand at every callsite.
|
|
11
|
+
*/
|
|
12
|
+
export declare class SessionStateCursor {
|
|
13
|
+
private currentSerializedContext;
|
|
14
|
+
private currentSessionState;
|
|
15
|
+
constructor(input: {
|
|
16
|
+
readonly serializedContext: Record<string, unknown>;
|
|
17
|
+
readonly sessionState: DurableSessionState;
|
|
18
|
+
});
|
|
19
|
+
/** Latest adopted serialized runtime context. */
|
|
20
|
+
get serializedContext(): Record<string, unknown>;
|
|
21
|
+
/** Latest adopted durable session state. */
|
|
22
|
+
get sessionState(): DurableSessionState;
|
|
23
|
+
/** Adopts a state transition; fields a step did not change carry forward. */
|
|
24
|
+
adoptState(transition: SessionStateTransition): void;
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var SessionStateCursor=class{currentSerializedContext;currentSessionState;constructor(e){this.currentSerializedContext=e.serializedContext,this.currentSessionState=e.sessionState}get serializedContext(){return this.currentSerializedContext}get sessionState(){return this.currentSessionState}adoptState(e){this.currentSerializedContext=e.serializedContext??this.currentSerializedContext,this.currentSessionState=e.sessionState??this.currentSessionState}};export{SessionStateCursor};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { type DurableSessionState } from "#execution/durable-session-store.js";
|
|
2
|
+
import type { TokenUsage } from "#shared/token-usage.js";
|
|
2
3
|
export interface CancelledTurnSettleResult {
|
|
3
4
|
readonly serializedContext: Record<string, unknown>;
|
|
4
5
|
readonly sessionState: DurableSessionState;
|
|
6
|
+
readonly usage?: TokenUsage;
|
|
5
7
|
}
|
|
6
8
|
/**
|
|
7
9
|
* Settles one cancelled turn: emits `turn.cancelled` → `session.waiting`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{callAdapterEventHandler}from"#channel/adapter.js";import{ChannelInstrumentationKey}from"#context/keys.js";import{encodeMessageStreamEvent,stampMessageStreamEvent}from"#protocol/message.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{getHarnessEmissionState,isHarnessBetweenTurns,setHarnessEmissionState}from"#harness/emission.js";import{abandonRunningAgentTurns}from"#harness/handles/transitions.js";import{deserializeContext,serializeContext}from"#context/serialize.js";import{createDurableSessionState,readDurableSession}from"#execution/durable-session-store.js";import{hydrateDurableSession}from"#execution/session.js";import{resolveEffectiveAgentRuntime}from"#execution/effective-agent-config.js";import{buildAdapterContext}from"#channel/adapter-context.js";import{clearPendingRuntimeActionBatch}from"#harness/runtime-actions.js";import{
|
|
1
|
+
import{callAdapterEventHandler}from"#channel/adapter.js";import{ChannelInstrumentationKey}from"#context/keys.js";import{encodeMessageStreamEvent,stampMessageStreamEvent}from"#protocol/message.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{getHarnessEmissionState,isHarnessBetweenTurns,setHarnessEmissionState}from"#harness/emission.js";import{abandonRunningAgentTurns}from"#harness/handles/transitions.js";import{deserializeContext,serializeContext}from"#context/serialize.js";import{createDurableSessionState,readDurableSession}from"#execution/durable-session-store.js";import{hydrateDurableSession}from"#execution/session.js";import{resolveEffectiveAgentRuntime}from"#execution/effective-agent-config.js";import{buildAdapterContext}from"#channel/adapter-context.js";import{clearPendingRuntimeActionBatch}from"#harness/runtime-actions.js";import{clearPendingWorkflowInterrupt}from"#harness/workflow-interrupt-state.js";import{clearAllProxyInputRequests,getProxyInputRequests,hasProxyInputRequests}from"#harness/proxy-input-requests.js";import{getInstrumentationRuntime}from"#harness/instrumentation/runtime.js";import{setChannelContext}from"#execution/channel-context.js";import{dispatchStreamEventHooks}from"#context/hook-lifecycle.js";import{withContextScope}from"#context/run-step.js";import{reconcileSessionContinuationToken}from"#execution/reconcile-session-continuation-token.js";import{activeTurnId}from"#harness/active-turn-id.js";import{emitCancelledTurn}from"#harness/cancelled-turn-emission.js";import{clearPendingSessionLimitPrompt}from"#harness/input-requests.js";import{createInstrumentationHandleEvent}from"#harness/instrumentation/native-events.js";import{getTurnUsageState,toUsage}from"#harness/turn-tag-state.js";async function settleCancelledTurnStep(a){"use step";let o=await readDurableSession(a.sessionState),s=await deserializeContext(a.serializedContext),c=s.require(ChannelKey),l=buildAdapterContext(c,s),u=s.require(BundleKey),d=resolveEffectiveAgentRuntime(u,s),f=getInstrumentationRuntime(),p=hydrateDurableSession({compactionOverrides:{thresholdPercent:d.thresholdPercent},durable:o,turnAgent:d.turnAgent}),m=getHarnessEmissionState(o.state),h=[...getProxyInputRequests(o.state).values()].some(e=>e.kind===`session-limit`);if(!(isHarnessBetweenTurns(p)&&hasProxyInputRequests(o.state)&&!h)){let n=a.parentWritable.getWriter();try{let r=await withContextScope(s,p,async r=>{let baseEmit=async t=>{let r=await callAdapterEventHandler(c,t,l);setChannelContext(s,{...c,state:{...l.state}});let i=stampMessageStreamEvent(r);await n.write(encodeMessageStreamEvent(i)),await dispatchStreamEventHooks({ctx:s,event:i,registry:u.hookRegistry})};return{result:await emitCancelledTurn(createInstrumentationHandleEvent({agentName:u.turnAgent.id,channelKind:s.get(ChannelInstrumentationKey)?.kind,handleEvent:baseEmit,hooks:f?.hooks,sessionId:p.sessionId,turnId:activeTurnId(m)})??baseEmit,m),session:r}});m=r.result,p=r.session}finally{await f?.forceFlush(),n.releaseLock()}}let g=reconcileSessionContinuationToken(s,setHarnessEmissionState(clearPendingSessionLimitPrompt(clearAllProxyInputRequests(clearPendingWorkflowInterrupt(clearPendingRuntimeActionBatch(abandonRunningAgentTurns(p))))),m)),_=getTurnUsageState(p.state)?.session,v={serializedContext:serializeContext(s),sessionState:createDurableSessionState({session:g})};return _===void 0?v:{...v,usage:toUsage(_)}}export{settleCancelledTurnStep};
|
|
@@ -13,11 +13,26 @@ export declare function runProxySubagentEventStep(input: {
|
|
|
13
13
|
readonly serializedContext: Record<string, unknown>;
|
|
14
14
|
readonly sessionState: DurableSessionState;
|
|
15
15
|
}): Promise<ProxySubagentEventResult>;
|
|
16
|
+
/** Emits a task request whose proxy routes were committed by a prior step. */
|
|
17
|
+
export declare function emitRecordedTaskInputRequestStep(input: {
|
|
18
|
+
readonly hookPayload: SubagentInputRequestHookPayload;
|
|
19
|
+
readonly parentWritable: WritableStream<Uint8Array>;
|
|
20
|
+
readonly serializedContext: Record<string, unknown>;
|
|
21
|
+
readonly sessionState: DurableSessionState;
|
|
22
|
+
}): Promise<ProxySubagentEventResult>;
|
|
23
|
+
/** Emits a task authorization event after its ownership was validated. */
|
|
24
|
+
export declare function emitRecordedTaskAuthorizationEventStep(input: {
|
|
25
|
+
readonly hookPayload: SubagentAuthorizationEventHookPayload;
|
|
26
|
+
readonly parentWritable: WritableStream<Uint8Array>;
|
|
27
|
+
readonly serializedContext: Record<string, unknown>;
|
|
28
|
+
readonly sessionState: DurableSessionState;
|
|
29
|
+
}): Promise<ProxySubagentEventResult>;
|
|
16
30
|
/** Applies one proxied child event to an already-hydrated parent context. */
|
|
17
31
|
export declare function emitProxiedSubagentEvent(input: {
|
|
18
32
|
readonly ctx: ContextContainer;
|
|
19
33
|
readonly durableSession: DurableSession;
|
|
20
34
|
readonly hookPayload: SubagentEventHookPayload;
|
|
21
35
|
readonly parentWritable: WritableStream<Uint8Array>;
|
|
36
|
+
readonly recordProxyInputRequests?: boolean;
|
|
22
37
|
}): Promise<ProxySubagentEventResult>;
|
|
23
38
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{callAdapterEventHandler}from"#channel/adapter.js";import{ModeKey}from"#context/keys.js";import{encodeMessageStreamEvent,stampMessageStreamEvent}from"#protocol/message.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{deserializeContext,serializeContext}from"#context/serialize.js";import{createDurableSessionState,readDurableSession}from"#execution/durable-session-store.js";import{hydrateDurableSession}from"#execution/session.js";import{resolveEffectiveAgentRuntime}from"#execution/effective-agent-config.js";import{buildAdapterContext}from"#channel/adapter-context.js";import{upsertProxyInputRequests}from"#harness/proxy-input-requests.js";import{emitProxiedInputRequest}from"#execution/subagent-hitl-proxy.js";import{setChannelContext}from"#execution/channel-context.js";import{withContextScope}from"#context/run-step.js";import{reconcileSessionContinuationToken}from"#execution/reconcile-session-continuation-token.js";async function runProxySubagentEventStep(e){"use step";let t=await readDurableSession(e.sessionState);return emitProxiedSubagentEvent({ctx:await deserializeContext(e.serializedContext),durableSession:t,hookPayload:e.hookPayload,parentWritable:e.parentWritable})}async function emitProxiedSubagentEvent(i){let{ctx:a}=i,o=a.require(ChannelKey),s=resolveEffectiveAgentRuntime(a.require(BundleKey),a),c=hydrateDurableSession({compactionOverrides:{thresholdPercent:s.thresholdPercent},durable:i.durableSession,turnAgent:s.turnAgent}),l=buildAdapterContext(o,a),u=i.parentWritable.getWriter(),d,f;try{let emit=async t=>{let r=await callAdapterEventHandler(o,t,l);await u.write(encodeMessageStreamEvent(stampMessageStreamEvent(r)))},r=await withContextScope(a,c,async e=>{if(i.hookPayload.kind===`subagent-authorization-event`)return await emit(i.hookPayload.event),{result:void 0,session:e};let n=await emitProxiedInputRequest({emit,hookPayload:i.hookPayload,mode:a.require(ModeKey),session:e});return{result:n.entries,session:n.session}});d=r.result,f=r.session}finally{u.releaseLock()}setChannelContext(a,{...o,state:{...l.state}}),d!==void 0&&i.hookPayload.kind===`subagent-input-request`&&(f=upsertProxyInputRequests({entries:d,forChildContinuationToken:i.hookPayload.childContinuationToken,session:f}));let p=reconcileSessionContinuationToken(a,f);return{serializedContext:serializeContext(a),sessionState:createDurableSessionState({session:p})}}export{emitProxiedSubagentEvent,runProxySubagentEventStep};
|
|
1
|
+
import{callAdapterEventHandler}from"#channel/adapter.js";import{ModeKey}from"#context/keys.js";import{encodeMessageStreamEvent,stampMessageStreamEvent}from"#protocol/message.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{deserializeContext,serializeContext}from"#context/serialize.js";import{createDurableSessionState,readDurableSession}from"#execution/durable-session-store.js";import{hydrateDurableSession}from"#execution/session.js";import{resolveEffectiveAgentRuntime}from"#execution/effective-agent-config.js";import{buildAdapterContext}from"#channel/adapter-context.js";import{upsertProxyInputRequests}from"#harness/proxy-input-requests.js";import{emitProxiedInputRequest}from"#execution/subagent-hitl-proxy.js";import{setChannelContext}from"#execution/channel-context.js";import{withContextScope}from"#context/run-step.js";import{reconcileSessionContinuationToken}from"#execution/reconcile-session-continuation-token.js";async function runProxySubagentEventStep(e){"use step";let t=await readDurableSession(e.sessionState);return emitProxiedSubagentEvent({ctx:await deserializeContext(e.serializedContext),durableSession:t,hookPayload:e.hookPayload,parentWritable:e.parentWritable})}async function emitRecordedTaskInputRequestStep(e){"use step";let t=await readDurableSession(e.sessionState);return emitProxiedSubagentEvent({ctx:await deserializeContext(e.serializedContext),durableSession:t,hookPayload:e.hookPayload,parentWritable:e.parentWritable,recordProxyInputRequests:!1})}async function emitRecordedTaskAuthorizationEventStep(e){"use step";let t=await readDurableSession(e.sessionState);return emitProxiedSubagentEvent({ctx:await deserializeContext(e.serializedContext),durableSession:t,hookPayload:e.hookPayload,parentWritable:e.parentWritable,recordProxyInputRequests:!1})}async function emitProxiedSubagentEvent(i){let{ctx:a}=i,o=a.require(ChannelKey),s=resolveEffectiveAgentRuntime(a.require(BundleKey),a),c=hydrateDurableSession({compactionOverrides:{thresholdPercent:s.thresholdPercent},durable:i.durableSession,turnAgent:s.turnAgent}),l=buildAdapterContext(o,a),u=i.parentWritable.getWriter(),d,f;try{let emit=async t=>{let r=await callAdapterEventHandler(o,t,l);await u.write(encodeMessageStreamEvent(stampMessageStreamEvent(r)))},r=await withContextScope(a,c,async e=>{if(i.hookPayload.kind===`subagent-authorization-event`)return await emit(i.hookPayload.event),{result:void 0,session:e};let n=await emitProxiedInputRequest({emit,hookPayload:i.hookPayload,mode:a.require(ModeKey),session:e});return{result:n.entries,session:n.session}});d=r.result,f=r.session}finally{u.releaseLock()}setChannelContext(a,{...o,state:{...l.state}}),i.recordProxyInputRequests!==!1&&d!==void 0&&i.hookPayload.kind===`subagent-input-request`&&(f=upsertProxyInputRequests({entries:d,forChildContinuationToken:i.hookPayload.childContinuationToken,session:f}));let p=reconcileSessionContinuationToken(a,f);return{serializedContext:serializeContext(a),sessionState:createDurableSessionState({session:p})}}export{emitProxiedSubagentEvent,emitRecordedTaskAuthorizationEventStep,emitRecordedTaskInputRequestStep,runProxySubagentEventStep};
|
|
@@ -17,19 +17,25 @@ export declare function emitProxiedInputRequest(input: {
|
|
|
17
17
|
readonly entries: readonly (readonly [requestId: string, route: ProxyInputRequest])[];
|
|
18
18
|
readonly session: HarnessSession;
|
|
19
19
|
}>;
|
|
20
|
+
/** One proxied-child bucket of a routed deliver payload. */
|
|
21
|
+
export interface RoutedChildDelivery {
|
|
22
|
+
readonly childContinuationToken: string;
|
|
23
|
+
readonly childResponseUrl?: string;
|
|
24
|
+
readonly payload: {
|
|
25
|
+
readonly inputResponses: readonly InputResponse[];
|
|
26
|
+
};
|
|
27
|
+
/** Parent-visible request IDs safe to retire once this bucket is forwarded. */
|
|
28
|
+
readonly retireRequestIds: readonly string[];
|
|
29
|
+
/** Present when the child is owned by a task run, which delivers on the parent's behalf. */
|
|
30
|
+
readonly taskId?: string;
|
|
31
|
+
}
|
|
20
32
|
/**
|
|
21
33
|
* Outcome of splitting one deliver payload by the session's proxy map.
|
|
22
34
|
* `forSelf` is the parent-local remainder (or `undefined` when fully
|
|
23
35
|
* routed); `forChildren` carries one entry per descendant token.
|
|
24
36
|
*/
|
|
25
37
|
export interface RoutedDeliverPayload {
|
|
26
|
-
readonly forChildren: readonly
|
|
27
|
-
readonly childContinuationToken: string;
|
|
28
|
-
readonly payload: {
|
|
29
|
-
readonly inputResponses: readonly InputResponse[];
|
|
30
|
-
};
|
|
31
|
-
readonly retireRequestIds: readonly string[];
|
|
32
|
-
}[];
|
|
38
|
+
readonly forChildren: readonly RoutedChildDelivery[];
|
|
33
39
|
readonly forSelf: DeliverPayload | undefined;
|
|
34
40
|
readonly parentAction: {
|
|
35
41
|
readonly kind: "cancel-turn";
|
|
@@ -37,6 +43,7 @@ export interface RoutedDeliverPayload {
|
|
|
37
43
|
}
|
|
38
44
|
/** Splits a deliver payload into parent-local and proxied-child buckets. */
|
|
39
45
|
export declare function routeDeliverPayload(input: {
|
|
46
|
+
readonly allowRoute?: (requestId: string, route: ProxyInputRequest) => boolean;
|
|
40
47
|
readonly payload: DeliverPayload;
|
|
41
48
|
readonly state: SessionStateMap | undefined;
|
|
42
49
|
}): RoutedDeliverPayload;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createInputRequestedEvent}from"#protocol/message.js";import{emitTurnEpilogue,getHarnessEmissionState,setHarnessEmissionState}from"#harness/emission.js";import{getProxyInputRequests,toProxyInputRequestEntries}from"#harness/proxy-input-requests.js";import{SESSION_LIMIT_STOP_OPTION_ID}from"#harness/session-limit-continuation.js";async function emitProxiedInputRequest(i){await i.emit(createInputRequestedEvent({requests:i.hookPayload.event.requests,sequence:i.hookPayload.event.sequence,stepIndex:i.hookPayload.event.stepIndex,turnId:i.hookPayload.event.turnId}));let o=i.session;if(i.mode===`conversation`){let e=getHarnessEmissionState(i.session.state),a=await emitTurnEpilogue(i.emit,e,i.mode);o=setHarnessEmissionState(i.session,a)}return{entries:toProxyInputRequestEntries(i.hookPayload),session:o}}function routeDeliverPayload(e){let t=getProxyInputRequests(e.state),n=e.payload.inputResponses??[],r=new Map,a=[],s;for(let
|
|
1
|
+
import{createInputRequestedEvent}from"#protocol/message.js";import{emitTurnEpilogue,getHarnessEmissionState,setHarnessEmissionState}from"#harness/emission.js";import{getProxyInputRequests,toProxyInputRequestEntries}from"#harness/proxy-input-requests.js";import{SESSION_LIMIT_STOP_OPTION_ID}from"#harness/session-limit-continuation.js";async function emitProxiedInputRequest(i){await i.emit(createInputRequestedEvent({requests:i.hookPayload.event.requests,sequence:i.hookPayload.event.sequence,stepIndex:i.hookPayload.event.stepIndex,turnId:i.hookPayload.event.turnId}));let o=i.session;if(i.mode===`conversation`){let e=getHarnessEmissionState(i.session.state),a=await emitTurnEpilogue(i.emit,e,i.mode);o=setHarnessEmissionState(i.session,a)}return{entries:toProxyInputRequestEntries(i.hookPayload),session:o}}function routeDeliverPayload(e){let t=getProxyInputRequests(e.state),n=e.payload.inputResponses??[],r=new Map,a=[],s;for(let i of n){let n=t.get(i.requestId);if(n===void 0||e.allowRoute?.(i.requestId,n)===!1){a.push(i);continue}n.kind===`session-limit`&&i.optionId===SESSION_LIMIT_STOP_OPTION_ID&&(s={kind:`cancel-turn`});let c=n.taskId===void 0?n.childContinuationToken:`${n.childContinuationToken}\0${n.childResponseUrl??`local`}\0${n.taskId}`,l=r.get(c);l===void 0?r.set(c,{childContinuationToken:n.childContinuationToken,parentRequestIds:[i.requestId],responses:[toChildInputResponse(i,n)],routes:[n],...n.childResponseUrl!==void 0&&{childResponseUrl:n.childResponseUrl},...n.taskId!==void 0&&{taskId:n.taskId}}):(l.parentRequestIds.push(i.requestId),l.responses.push(toChildInputResponse(i,n)),l.routes.push(n))}let c=[...r.values()].map(({childContinuationToken:e,childResponseUrl:n,parentRequestIds:r,responses:i,routes:a,taskId:o})=>{let s=new Set(r),c=new Set(s);for(let n of a)if(n.batch!==void 0&&batchResolves({batch:n.batch,childContinuationToken:e,entries:t,responseIds:s}))for(let e of n.batch.requestIds)c.add(e);return{childContinuationToken:e,payload:{inputResponses:i},retireRequestIds:[...c],...n!==void 0&&{childResponseUrl:n},...o!==void 0&&{taskId:o}}}),l={};for(let[t,n]of Object.entries(e.payload))t===`inputResponses`||n===void 0||(l[t]=n);return a.length>0&&(l.inputResponses=a),{forChildren:c,forSelf:Object.keys(l).length>0?l:void 0,parentAction:s}}function batchResolves(e){return e.batch.approvalRequestIds.length===0||e.batch.approvalRequestIds.every(t=>{let n=e.entries.get(t);return n===void 0||!sameBatch(n,e)||e.responseIds.has(t)})}function sameBatch(e,t){return e.childContinuationToken===t.childContinuationToken&&e.batch?.requestIds.length===t.batch.requestIds.length&&e.batch.requestIds.every((e,n)=>e===t.batch.requestIds[n])}function toChildInputResponse(e,t){return t.childRequestId===void 0?e:{...e,requestId:t.childRequestId}}export{emitProxiedInputRequest,routeDeliverPayload};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { DispatchOutcome, RuntimeSession } from "#execution/agent-handle-dispatch.js";
|
|
2
|
+
import { buildSubagentRunInput, type SubagentInputSource } from "#execution/subagent-tool.js";
|
|
3
|
+
import { createWorkflowRuntime } from "#execution/workflow-runtime.js";
|
|
4
|
+
import type { RuntimeSubagentCallActionRequest } from "#runtime/actions/types.js";
|
|
5
|
+
import type { CompiledBundle } from "#runtime/sessions/runtime-context-keys.js";
|
|
6
|
+
type DynamicSubagentAgentConfig = Parameters<typeof createWorkflowRuntime>[0]["dynamicSubagentAgentConfig"];
|
|
7
|
+
/** Starts one local subagent after dispatch planning has selected its target. */
|
|
8
|
+
export declare function startLocalSubagent(input: {
|
|
9
|
+
readonly action: RuntimeSubagentCallActionRequest;
|
|
10
|
+
readonly auth: Parameters<typeof buildSubagentRunInput>[0]["auth"];
|
|
11
|
+
readonly batchEvent: {
|
|
12
|
+
readonly sequence: number;
|
|
13
|
+
readonly turnId: string;
|
|
14
|
+
};
|
|
15
|
+
readonly bundle: CompiledBundle;
|
|
16
|
+
readonly capabilities: Parameters<typeof buildSubagentRunInput>[0]["capabilities"];
|
|
17
|
+
readonly channelMetadata: Parameters<typeof buildSubagentRunInput>[0]["channelMetadata"];
|
|
18
|
+
readonly currentSession: RuntimeSession;
|
|
19
|
+
readonly dynamicSubagentAgentConfig?: DynamicSubagentAgentConfig;
|
|
20
|
+
readonly fanoutSize: number;
|
|
21
|
+
readonly initiatorAuth: Parameters<typeof buildSubagentRunInput>[0]["initiatorAuth"];
|
|
22
|
+
readonly parentContinuationToken: string | undefined;
|
|
23
|
+
readonly parentTraceContext: Parameters<typeof buildSubagentRunInput>[0]["parentTraceContext"];
|
|
24
|
+
readonly persistentSessions: boolean;
|
|
25
|
+
readonly session: RuntimeSession;
|
|
26
|
+
readonly source: SubagentInputSource;
|
|
27
|
+
readonly taskOwned: boolean;
|
|
28
|
+
}): Promise<DispatchOutcome>;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createLogger,logError}from"#internal/logging.js";import{isRuntimeSessionOwnershipConflictError}from"#execution/runtime-errors.js";import{toErrorMessage}from"#shared/errors.js";import{SUBAGENT_START_FAILED}from"#harness/agent-handle-errors.js";import{confirmAgentStarted,confirmTaskAgentAddress,prepareAgentStart,rejectAgentEffect}from"#harness/handles/transitions.js";import{createWorkflowRuntime}from"#execution/workflow-runtime.js";import{buildSubagentRunInput}from"#execution/subagent-tool.js";import{mintStartOperation}from"#execution/dispatch-start-operation.js";const log=createLogger(`execution.subagent-start-local`);async function startLocalSubagent(e){let{action:t,source:n}=e,r=createWorkflowRuntime({compiledArtifactsSource:e.bundle.compiledArtifactsSource,dynamicSubagentAgentConfig:e.dynamicSubagentAgentConfig,nodeId:t.nodeId}),{childContinuationToken:i,runInput:a}=buildSubagentRunInput({action:t,auth:e.auth,batchEvent:e.batchEvent,capabilities:e.capabilities,channelMetadata:e.channelMetadata,fanoutSize:e.fanoutSize,initiatorAuth:e.initiatorAuth,parentContinuationToken:e.parentContinuationToken,parentTraceContext:e.parentTraceContext,persistentSessions:e.persistentSessions,session:e.session,source:n}),o=n.type===`runtime`?`agent/self`:`agent/local`,{identity:s,operation:c}=mintStartOperation({callId:t.callId,name:t.subagentName,nodeId:t.nodeId,parentSessionId:e.session.sessionId,parentTurnId:e.batchEvent.turnId}),l=prepareAgentStart(e.currentSession,{identity:s,operation:c,target:{continuationToken:i,kind:o}}),u;try{u=(await r.createSession(a)).sessionId}catch(e){if(!isRuntimeSessionOwnershipConflictError(e))return logError(log,`local subagent start failed`,e,{callId:t.callId,nodeId:t.nodeId,subagentName:t.subagentName}),{kind:`error`,result:{callId:t.callId,isError:!0,kind:`subagent-result`,origin:`dispatch`,output:{code:SUBAGENT_START_FAILED,message:toErrorMessage(e)},subagentName:t.subagentName},session:rejectAgentEffect(l,{disposition:`dead`,operationId:c.id})};u=e.ownerSessionId}let d={continuationToken:i,kind:o,sessionId:u};return{address:d,callId:t.callId,kind:`called`,name:t.name,session:e.taskOwned?confirmTaskAgentAddress(l,{address:d,operationId:c.id}):confirmAgentStarted(l,{address:d,operationId:c.id}),toolName:t.subagentName}}export{startLocalSubagent};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { DispatchOutcome, RuntimeSession } from "#execution/agent-handle-dispatch.js";
|
|
2
|
+
import { resolveRemoteAgentForAction, startRemoteAgentSession } from "#execution/remote-agent-dispatch.js";
|
|
3
|
+
import type { RuntimeRemoteAgentCallActionRequest } from "#runtime/actions/types.js";
|
|
4
|
+
import type { CompiledBundle } from "#runtime/sessions/runtime-context-keys.js";
|
|
5
|
+
/** Starts one remote subagent after dispatch planning has selected its target. */
|
|
6
|
+
export declare function startRemoteSubagent(input: {
|
|
7
|
+
readonly action: RuntimeRemoteAgentCallActionRequest;
|
|
8
|
+
readonly auth: Parameters<typeof startRemoteAgentSession>[0]["auth"];
|
|
9
|
+
readonly batchEvent: {
|
|
10
|
+
readonly sequence: number;
|
|
11
|
+
readonly turnId: string;
|
|
12
|
+
};
|
|
13
|
+
readonly bundle: CompiledBundle;
|
|
14
|
+
readonly callbackBaseUrl: string | undefined;
|
|
15
|
+
readonly currentSession: RuntimeSession;
|
|
16
|
+
readonly dynamicRemoteAgent?: NonNullable<Parameters<typeof resolveRemoteAgentForAction>[0]["dynamicRemoteAgent"]>;
|
|
17
|
+
readonly initiatorAuth: Parameters<typeof startRemoteAgentSession>[0]["initiatorAuth"];
|
|
18
|
+
readonly parentContinuationToken: string | undefined;
|
|
19
|
+
readonly parentTraceContext: Parameters<typeof startRemoteAgentSession>[0]["parentTraceContext"];
|
|
20
|
+
readonly persistentSessions: boolean;
|
|
21
|
+
readonly session: RuntimeSession;
|
|
22
|
+
readonly taskOwned: boolean;
|
|
23
|
+
}): Promise<DispatchOutcome>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createLogger,logError}from"#internal/logging.js";import{resolveRemoteAgentForAction,startRemoteAgentSession}from"#execution/remote-agent-dispatch.js";import{confirmAgentStarted,confirmTaskAgentAddress,prepareAgentStart,rejectAgentEffect}from"#harness/handles/transitions.js";import{createRemoteAgentStartFailureResult}from"#execution/dispatch-action-failures.js";import{mintStartOperation}from"#execution/dispatch-start-operation.js";const log=createLogger(`execution.subagent-start-remote`);async function startRemoteSubagent(e){let{action:r}=e,i,a;try{if(e.callbackBaseUrl===void 0)throw Error(`Cannot dispatch remote agent without a callback base URL.`);i=e.callbackBaseUrl,a=resolveRemoteAgentForAction({dynamicRemoteAgent:e.dynamicRemoteAgent,nodeId:r.nodeId,remoteAgentName:r.remoteAgentName,registry:e.bundle.subagentRegistry.subagentsByNodeId})}catch(n){return logError(log,`remote agent start failed`,n,{remoteAgentName:r.remoteAgentName,nodeId:r.nodeId,callId:r.callId}),{kind:`error`,result:createRemoteAgentStartFailureResult({action:r,error:n}),session:e.currentSession}}let{identity:o,operation:s}=mintStartOperation({callId:r.callId,name:r.remoteAgentName,nodeId:r.nodeId,parentSessionId:e.session.sessionId,parentTurnId:e.batchEvent.turnId}),c=prepareAgentStart(e.currentSession,{identity:o,operation:s,target:{callbackBaseUrl:i,kind:`agent/remote`,url:a.url}});try{let t=await startRemoteAgentSession({action:r,auth:e.auth,callbackBaseUrl:i,callbackToken:e.parentContinuationToken,initiatorAuth:e.initiatorAuth,operationId:s.id,parentTraceContext:e.parentTraceContext,persistentSessions:e.persistentSessions,remote:a,session:e.session}),n={callbackBaseUrl:i,kind:`agent/remote`,sessionId:t.sessionId,url:a.url};return{address:n,callId:r.callId,kind:`called`,name:r.name,session:e.taskOwned?confirmTaskAgentAddress(c,{address:n,operationId:s.id}):confirmAgentStarted(c,{address:n,operationId:s.id}),toolName:r.remoteAgentName}}catch(e){return logError(log,`remote agent start failed`,e,{remoteAgentName:r.remoteAgentName,nodeId:r.nodeId,callId:r.callId}),{kind:`error`,result:createRemoteAgentStartFailureResult({action:r,error:e}),session:rejectAgentEffect(c,{disposition:`dead`,operationId:s.id})}}}export{startRemoteSubagent};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ContextContainer } from "#context/container.js";
|
|
2
|
+
import type { UnstampedMessageStreamEvent } from "#protocol/message.js";
|
|
3
|
+
/**
|
|
4
|
+
* Forwards one task child's blocking transition to its parent's session
|
|
5
|
+
* callback.
|
|
6
|
+
*
|
|
7
|
+
* Task children report HITL and authorization transitions to the parent's
|
|
8
|
+
* task run before local emission, so the run can block/unblock the task
|
|
9
|
+
* under one durable decision. A session without a callback capability
|
|
10
|
+
* (non-delegated runs) is a no-op, as is any event outside the three
|
|
11
|
+
* blocking transitions.
|
|
12
|
+
*/
|
|
13
|
+
export declare function forwardTaskEventToSessionCallback(ctx: ContextContainer, event: UnstampedMessageStreamEvent): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ContinuationTokenKey,SessionCallbackKey,SessionIdKey}from"#context/keys.js";import{fireTaskEventCallbackStep}from"#execution/session-callback-step.js";async function forwardTaskEventToSessionCallback(e,t){let n=e.get(SessionCallbackKey);n!==void 0&&(t.type!==`input.requested`&&t.type!==`authorization.required`&&t.type!==`authorization.completed`||await fireTaskEventCallbackStep({callback:n,childContinuationToken:e.require(ContinuationTokenKey),childSessionId:e.require(SessionIdKey),event:t}))}export{forwardTaskEventToSessionCallback};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Narrows one private create-once session token to task-input delivery only. */
|
|
2
|
+
export declare function createTaskInputCapabilityToken(operationToken: string): string;
|
|
3
|
+
/** Resolves a task-input capability to the create-once session hook it may address. */
|
|
4
|
+
export declare function readTaskInputTargetToken(capabilityToken: string): string | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const OPERATION_TOKEN_PREFIX=`eve:eve:op:`,TASK_INPUT_TOKEN_PREFIX=`eve:task-input:`,TOKEN_DIGEST=/^[a-f0-9]{32}$/;function createTaskInputCapabilityToken(n){let r=readTokenDigest(n,OPERATION_TOKEN_PREFIX);if(r===void 0)throw Error(`Remote task input requires an eve create-once session capability.`);return`${TASK_INPUT_TOKEN_PREFIX}${r}`}function readTaskInputTargetToken(n){let r=readTokenDigest(n,TASK_INPUT_TOKEN_PREFIX);return r===void 0?void 0:`${OPERATION_TOKEN_PREFIX}${r}`}function readTokenDigest(e,t){if(!e.startsWith(t))return;let r=e.slice(t.length);return TOKEN_DIGEST.test(r)?r:void 0}export{createTaskInputCapabilityToken,readTaskInputTargetToken};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type TaskInboundAnswerInput, type TaskInboundAuthorizationEvent, type TaskInboundInputRequest, type TaskView } from "#tasks/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Appends one full task view to the owning task run's `eve.task`
|
|
4
|
+
* stream. Only the task run workflow calls this, which is what makes
|
|
5
|
+
* the run the single writer readers can trust without re-validating.
|
|
6
|
+
*/
|
|
7
|
+
export declare function appendTaskViewStep(input: {
|
|
8
|
+
readonly view: TaskView;
|
|
9
|
+
}): Promise<void>;
|
|
10
|
+
/** Re-emits a task-owned child authorization event through the parent channel. */
|
|
11
|
+
export declare function wakeTaskAuthorizationParentStep(input: {
|
|
12
|
+
readonly request: TaskInboundAuthorizationEvent;
|
|
13
|
+
readonly taskId: string;
|
|
14
|
+
readonly token: string;
|
|
15
|
+
}): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Wakes the parent session with a framework task notification.
|
|
18
|
+
*
|
|
19
|
+
* Rides the ordinary session delivery path: a parked parent starts a
|
|
20
|
+
* turn carrying this message, while an active turn observes it at the
|
|
21
|
+
* next safe boundary through the driver's normal delivery routing. A
|
|
22
|
+
* parent whose session already ended is a tolerated no-op.
|
|
23
|
+
*/
|
|
24
|
+
export declare function wakeTaskParentStep(input: {
|
|
25
|
+
readonly token: string;
|
|
26
|
+
readonly view: TaskView;
|
|
27
|
+
}): Promise<void>;
|
|
28
|
+
/** Sends an exact local-task HITL batch to the parent's pre-model router. */
|
|
29
|
+
export declare function wakeTaskInputRequestParentStep(input: {
|
|
30
|
+
readonly request: TaskInboundInputRequest;
|
|
31
|
+
readonly taskId: string;
|
|
32
|
+
readonly token: string;
|
|
33
|
+
}): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Forwards answered input to the blocked child.
|
|
36
|
+
*
|
|
37
|
+
* The task run performs this itself so the child unblocks and the
|
|
38
|
+
* view leaves `input_required` under one durable decision. Returns
|
|
39
|
+
* `unreachable` when the child hook is already gone, which leaves the
|
|
40
|
+
* outstanding batch untouched rather than reporting a task as working
|
|
41
|
+
* when nothing received the answer.
|
|
42
|
+
*/
|
|
43
|
+
export declare function deliverTaskInputResponsesStep(input: {
|
|
44
|
+
readonly answer: TaskInboundAnswerInput;
|
|
45
|
+
readonly requestIds: readonly string[];
|
|
46
|
+
}): Promise<"delivered" | "unreachable">;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createLogger}from"#internal/logging.js";import{resumeHook}from"#internal/workflow/runtime.js";import{getWritable}from"#compiled/@workflow/core/index.js";import{isTaskWorkflowTargetGone}from"#execution/tasks/workflow-target.js";import{TASK_VIEW_STREAM_NAMESPACE,isTerminalTaskStatus,taskAuthorizationRequestId}from"#tasks/types.js";const log=createLogger(`execution.tasks.run`);async function appendTaskViewStep(e){"use step";let t=getWritable({namespace:TASK_VIEW_STREAM_NAMESPACE}).getWriter();try{await t.write(e.view)}finally{t.releaseLock()}}async function wakeTaskAuthorizationParentStep(e){"use step";let n={callId:e.request.callId,childSessionId:e.request.childSessionId,event:e.request.event,kind:`subagent-authorization-event`,subagentName:e.request.subagentName},r=e.request.event.data,i={task:{authorizationEvents:[{hookPayload:n,taskId:e.taskId}]}};e.request.event.type===`authorization.required`&&(i.message=`Background task ${e.taskId} needs authorization.`);let a={kind:`send`,payload:i,taskDeliveryId:`${e.taskId}:authorization:${e.request.event.type}:${r.turnId}:${r.stepIndex}:${r.sequence}:${taskAuthorizationRequestId(e.request.event)}`};try{await resumeHook(e.token,a)}catch(e){if(isTaskWorkflowTargetGone(e))return;throw e}}async function wakeTaskParentStep(e){"use step";let n={message:formatTaskNotification(e.view)};isTerminalTaskStatus(e.view.status)&&(n.task={views:[e.view]});let r={kind:`send`,payload:n,taskDeliveryId:`${e.view.taskId}:ready:${e.view.status}`};try{await resumeHook(e.token,r)}catch(t){if(isTaskWorkflowTargetGone(t)){log.warn(`task wake target is gone; the parent session already ended`,{status:e.view.status,taskId:e.view.taskId});return}throw t}}async function wakeTaskInputRequestParentStep(e){"use step";let n={kind:`send`,payload:{task:{inputRequests:[{hookPayload:e.request,taskId:e.taskId}]}},taskDeliveryId:`${e.taskId}:input:${e.request.event.turnId}:${e.request.event.stepIndex}:${e.request.event.sequence}`};try{await resumeHook(e.token,n)}catch(e){if(isTaskWorkflowTargetGone(e))return;throw e}}async function deliverTaskInputResponsesStep(e){"use step";let n=new Set(e.requestIds),r={auth:e.answer.auth,kind:`send`,payload:{inputResponses:e.answer.inputResponses.filter(e=>n.has(e.requestId))},taskDeliveryId:`${e.answer.taskId}:${[...e.requestIds].sort().join(`,`)}`};try{if(e.answer.childResponseUrl!==void 0){let t=await fetch(e.answer.childResponseUrl,{body:JSON.stringify({inputResponses:r.payload.inputResponses}),headers:{"content-type":`application/json`},method:`POST`,redirect:`error`});if(t.status===404)return`unreachable`;if(!t.ok)throw Error(`Remote task input delivery failed with HTTP ${t.status}.`)}else await resumeHook(e.answer.childContinuationToken,r);return`delivered`}catch(t){if(isTaskWorkflowTargetGone(t))return log.warn(`task input answer target is gone; the child turn already ended`,{taskId:e.answer.taskId}),`unreachable`;throw t}}function formatTaskNotification(e){let t=`Background task ${e.taskId} (${e.metadata.name})`;return e.status===`input_required`?`${t} needs input. Use task_peek to inspect the outstanding requests.`:`${t} is ${e.status}. Use task_peek to read its output.`}export{appendTaskViewStep,deliverTaskInputResponsesStep,wakeTaskAuthorizationParentStep,wakeTaskInputRequestParentStep,wakeTaskParentStep};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type TaskView } from "#tasks/types.js";
|
|
2
|
+
/** Input for one durable task run. */
|
|
3
|
+
export interface TaskRunWorkflowInput {
|
|
4
|
+
/** Private task inbox token; a routing credential, never model-visible. */
|
|
5
|
+
readonly taskInboxToken: string;
|
|
6
|
+
/** The creation view, normally `working`. */
|
|
7
|
+
readonly initialView: TaskView;
|
|
8
|
+
/** Parent session delivery token used to wake the task's owning parent. */
|
|
9
|
+
readonly parentContinuationToken: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The durable task run: single writer for one task's lifecycle.
|
|
13
|
+
*
|
|
14
|
+
* Consumes commands and child wire payloads over its private hook,
|
|
15
|
+
* applies the pure transition function, and appends a full `TaskView`
|
|
16
|
+
* per accepted command to its `eve.task` run stream. Competing
|
|
17
|
+
* completion, cancellation, and input transitions serialize here;
|
|
18
|
+
* rejected commands (for example a late child result after `cancelled`)
|
|
19
|
+
* change nothing.
|
|
20
|
+
*
|
|
21
|
+
* Wake policy: a transition into a ready status — terminal or
|
|
22
|
+
* `input_required` — delivers a framework notification to the parent
|
|
23
|
+
* session. A parked parent starts a turn; an active turn observes the
|
|
24
|
+
* delivery at its next safe boundary. Nothing else wakes the parent.
|
|
25
|
+
*
|
|
26
|
+
* The run ends when the task reaches a terminal status. Its view
|
|
27
|
+
* stream stays readable, so terminal tasks remain peekable; the
|
|
28
|
+
* disposed hook makes any later command fail loudly instead of queueing
|
|
29
|
+
* against a finished task.
|
|
30
|
+
*/
|
|
31
|
+
export declare function taskRunWorkflow(input: TaskRunWorkflowInput): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createHook}from"#compiled/@workflow/core/index.js";import{claimHookOwnership,disposeHook,isHookConflictError}from"#execution/hook-ownership.js";import{isReadyTaskStatus,isTerminalTaskStatus,readTaskInputRequestId,readTaskUsage}from"#tasks/types.js";import{appendTaskViewStep,deliverTaskInputResponsesStep,wakeTaskAuthorizationParentStep,wakeTaskInputRequestParentStep,wakeTaskParentStep}from"#execution/tasks/child/steps.js";import{applyTaskTransition}from"#tasks/transitions.js";import{translateTaskInboundPayload}from"#tasks/wire.js";function isTaskRunFinished(e,t){return!isTerminalTaskStatus(e.status)||!t?!1:e.status!==`cancelled`||e.executor?.lifecycle===`terminal`}async function taskRunWorkflow(i){"use workflow";let a=createHook({token:i.taskInboxToken}),o=a[Symbol.asyncIterator](),s=!1;try{try{await claimHookOwnership(a),s=!0}catch(e){if(isHookConflictError(e))return;throw e}let e=i.initialView,n,c=[],l=!1;for(await appendTaskViewStep({view:e});!isTaskRunFinished(e,l);){let t=await o.next();if(t.done===!0)return;let r=t.value.kind===`subagent-authorization-event`?{...t.value,kind:`authorization-event`}:t.value;if(r.kind===`authorization-event`&&(r.event.type===`approval.candidate`||r.event.type===`approval.settled`))continue;let a=r.kind===`task-command`&&r.command.kind===`ready`,s=r.kind===`task-command`&&r.command.kind===`reject-dispatch`;(a||s)&&(l=!0),r.kind===`subagent-input-request`&&(n=r),r.kind===`authorization-event`&&c.push(r);let u=e.status===`cancelled`&&r.kind===`runtime-action-result`,d=r.kind===`input-response`,f;if(u)f={kind:`settle-executor`,usage:readTaskUsage(r.results[0]?.outcome?.usageDelta)};else if(d){if(e.status!==`input_required`)continue;f=await resolveAnsweredCommand(e,r)}else f=translateTaskInboundPayload(r);if(f===void 0)continue;if(a&&isTerminalTaskStatus(e.status)){await wakeTaskParentStep({token:i.parentContinuationToken,view:e});continue}let p=applyTaskTransition(e,f);if(p.outcome!==`accepted`)continue;let m=!isTerminalTaskStatus(e.status)&&isTerminalTaskStatus(p.view.status),h=!isReadyTaskStatus(e.status)&&isReadyTaskStatus(p.view.status);e=p.view,await appendTaskViewStep({view:e});let g=l&&!m?c:[];for(let t of g)await wakeTaskAuthorizationParentStep({request:t,taskId:e.taskId,token:i.parentContinuationToken});(m||g.length>0)&&(c=[]),n!==void 0&&l&&e.status===`input_required`?(await wakeTaskInputRequestParentStep({request:n,taskId:e.taskId,token:i.parentContinuationToken}),n=void 0):!s&&g.length===0&&l&&(m||h&&n===void 0)&&await wakeTaskParentStep({token:i.parentContinuationToken,view:e}),e.status!==`input_required`&&(n=void 0)}}finally{s&&await disposeHook(a)}}async function resolveAnsweredCommand(e,t){if(t.taskId!==e.taskId)return;let n=new Set(e.inputRequests.flatMap(e=>{let t=readTaskInputRequestId(e);return t===void 0?[]:[t]})),r=t.inputResponses.map(e=>e.requestId).filter(e=>n.has(e));return r.length===0?void 0:await deliverTaskInputResponsesStep({answer:t,requestIds:r})===`delivered`?{kind:`answered`,requestIds:r}:void 0}export{taskRunWorkflow};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { RuntimeAgentHandleAction } from "#execution/agent-handle-dispatch.js";
|
|
2
|
+
/** Resolves the persistent agent identity attached to one delegated task. */
|
|
3
|
+
export declare function describeTaskAgent(input: {
|
|
4
|
+
readonly action: RuntimeAgentHandleAction;
|
|
5
|
+
readonly agentId?: string;
|
|
6
|
+
readonly parentSessionId: string;
|
|
7
|
+
readonly parentTurnId: string;
|
|
8
|
+
}): {
|
|
9
|
+
readonly agentId: string;
|
|
10
|
+
readonly callId: string;
|
|
11
|
+
readonly mode: "local" | "remote";
|
|
12
|
+
readonly name: string;
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{mintStartOperation}from"#execution/dispatch-start-operation.js";function describeTaskAgent(e){let{action:t}=e,n=t.kind===`remote-agent-call`?t.remoteAgentName:t.subagentName;return{agentId:e.agentId??mintStartOperation({callId:t.callId,name:n,nodeId:t.nodeId,parentSessionId:e.parentSessionId,parentTurnId:e.parentTurnId}).identity.id,callId:t.callId,mode:t.kind===`remote-agent-call`?`remote`:`local`,name:n}}export{describeTaskAgent};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { HarnessSession } from "#harness/types.js";
|
|
2
|
+
import { type AgentView } from "#harness/handles/prompt.js";
|
|
3
|
+
/** Derives model-visible task-agent availability from authoritative task views. */
|
|
4
|
+
export declare function readTaskAgentViews(session: HarnessSession): Promise<readonly AgentView[]>;
|
|
5
|
+
/** Appends the changed task-agent projection before the next model call. */
|
|
6
|
+
export declare function appendTaskAgentAnnouncement(session: HarnessSession): Promise<HarnessSession>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{formatAgentStatus,getAgentHandleStore}from"#harness/handles/store.js";import{getSessionTaskIndex}from"#tasks/session-index.js";import{resolveAgentsAnnouncement}from"#harness/handles/prompt.js";import{readTaskViews}from"#execution/tasks/parent/control-shared.js";async function readTaskAgentViews(r){let a=(getAgentHandleStore(r.state)?.handles??[]).filter(e=>e.phase===`addressed`);if(a.length===0)return[];let o=await readTaskViews(getSessionTaskIndex(r.state)),s=new Map;for(let e of o){let t=s.get(e.metadata.agentId)??[];s.set(e.metadata.agentId,[...t,e])}return a.map(t=>{let n=s.get(t.identity.id)??[],r=n.filter(e=>e.status===`working`||e.status===`input_required`);if(r.length>1)throw Error(`Agent "${t.identity.id}" has more than one nonterminal task.`);let i=r[0];if(i!==void 0){let e=i.status===`input_required`?`input_required`:`working`;return{availability:`busy`,id:t.identity.id,name:t.identity.name,taskId:i.taskId,taskStatus:e}}let a=n.at(-1);return{availability:`available`,id:t.identity.id,name:t.identity.name,statusLine:a?.lastOutput===void 0?void 0:formatAgentStatus(a.lastOutput.data)}})}async function appendTaskAgentAnnouncement(e){let n=resolveAgentsAnnouncement({agentViews:await readTaskAgentViews(e),messages:e.history,store:getAgentHandleStore(e.state)});return n===void 0?e:{...e,history:[...e.history,{content:n,role:`user`}]}}export{appendTaskAgentAnnouncement,readTaskAgentViews};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type DispatchOutcome, type RuntimeAgentHandleAction, type RuntimeSession } from "#execution/agent-handle-dispatch.js";
|
|
2
|
+
import { settleDelegatedDispatch, type DelegatedTask } from "#execution/tasks/parent/delegate.js";
|
|
3
|
+
import { describeTaskAgent } from "#execution/tasks/parent/agent-identity.js";
|
|
4
|
+
import type { RuntimeSubagentDispatchFailure } from "#runtime/actions/types.js";
|
|
5
|
+
export type PersistedContinuationTask = Awaited<ReturnType<typeof settleDelegatedDispatch>>;
|
|
6
|
+
/** Describes task identity from the stored address when continuing an agent. */
|
|
7
|
+
export declare function describeTaskDispatch(input: {
|
|
8
|
+
readonly action: RuntimeAgentHandleAction;
|
|
9
|
+
readonly agentId: string | undefined;
|
|
10
|
+
readonly parentSessionId: string;
|
|
11
|
+
readonly parentTurnId: string;
|
|
12
|
+
readonly session: RuntimeSession;
|
|
13
|
+
}): ReturnType<typeof describeTaskAgent>;
|
|
14
|
+
export declare function checkTaskContinuationAvailability(input: {
|
|
15
|
+
readonly action: RuntimeAgentHandleAction;
|
|
16
|
+
readonly agentId: string;
|
|
17
|
+
readonly parentStepIndex: number;
|
|
18
|
+
readonly parentTurnId: string;
|
|
19
|
+
readonly session: RuntimeSession;
|
|
20
|
+
}): Promise<RuntimeSubagentDispatchFailure | undefined>;
|
|
21
|
+
/**
|
|
22
|
+
* Persists the task's ownership and routing entry in the parent session's
|
|
23
|
+
* `eve.tasks` index and creates its parked tool-call receipt before dispatch.
|
|
24
|
+
*/
|
|
25
|
+
export declare function persistContinuationTaskInParentSession(input: {
|
|
26
|
+
readonly action: RuntimeAgentHandleAction;
|
|
27
|
+
readonly agentId: string;
|
|
28
|
+
readonly delegated: DelegatedTask;
|
|
29
|
+
readonly session: RuntimeSession;
|
|
30
|
+
}): Promise<PersistedContinuationTask | undefined>;
|
|
31
|
+
export declare function settleTaskDispatchError(input: {
|
|
32
|
+
readonly delegated: DelegatedTask;
|
|
33
|
+
readonly outcome: Extract<DispatchOutcome, {
|
|
34
|
+
readonly kind: "error";
|
|
35
|
+
}>;
|
|
36
|
+
readonly persisted: PersistedContinuationTask | undefined;
|
|
37
|
+
}): Promise<RuntimeSubagentDispatchFailure>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{AGENT_BUSY}from"#harness/agent-handle-errors.js";import{createAgentErrorResult}from"#execution/agent-handle-dispatch.js";import{findActiveTaskForAgent,findTaskAgentAddress}from"#execution/tasks/parent/control-shared.js";import{failDelegatedDispatch,rejectDelegatedDispatch,settleDelegatedDispatch}from"#execution/tasks/parent/delegate.js";import{describeTaskAgent}from"#execution/tasks/parent/agent-identity.js";function describeTaskDispatch(e){let t=describeTaskAgent(e),n=e.agentId===void 0?void 0:findTaskAgentAddress(e.session,e.agentId);return n===void 0?t:{...t,mode:n.address.kind===`agent/remote`?`remote`:`local`}}async function checkTaskContinuationAvailability(r){let i=await findActiveTaskForAgent(r.session,r.agentId,r.parentTurnId,r.parentStepIndex);return i===void 0?void 0:createAgentErrorResult({action:r.action,code:AGENT_BUSY,message:`Agent "${r.agentId}" is busy with task "${i.view.taskId}" (${i.view.status}).`})}async function persistContinuationTaskInParentSession(e){let t=findTaskAgentAddress(e.session,e.agentId);if(t!==void 0)return settleDelegatedDispatch({callId:e.action.callId,session:e.session,subagentName:t.identity.name,task:e.delegated})}async function settleTaskDispatchError(e){return e.persisted!==void 0&&e.outcome.deliveryAmbiguous===!0||await(e.persisted===void 0?rejectDelegatedDispatch:failDelegatedDispatch)({error:e.outcome.result.output,task:e.delegated}),e.persisted===void 0?e.outcome.result:{...e.outcome.result,output:attachTaskId(e.outcome.result.output,e.delegated.taskId)}}function attachTaskId(e,t){return typeof e==`object`&&e&&!Array.isArray(e)?{...e,taskId:t}:{error:e,taskId:t}}export{checkTaskContinuationAvailability,describeTaskDispatch,persistContinuationTaskInParentSession,settleTaskDispatchError};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { RuntimeSession } from "#execution/agent-handle-dispatch.js";
|
|
2
|
+
import { type AgentHandle } from "#harness/handles/store.js";
|
|
3
|
+
import type { RuntimeActionResult, RuntimeToolCallActionRequest } from "#runtime/actions/types.js";
|
|
4
|
+
import { type SessionTaskIndexEntry } from "#tasks/session-index.js";
|
|
5
|
+
import type { TaskView } from "#tasks/types.js";
|
|
6
|
+
/**
|
|
7
|
+
* Result and lookup helpers shared by the task-control executors
|
|
8
|
+
* (`task_peek`/`task_cancel` in the dispatch module,
|
|
9
|
+
* `task_send` in its own).
|
|
10
|
+
*/
|
|
11
|
+
/** Resolves owned index entries, or the ids this session does not own. */
|
|
12
|
+
export declare function lookupTaskEntries(session: RuntimeSession, taskIds: readonly string[]): {
|
|
13
|
+
readonly entries: SessionTaskIndexEntry[];
|
|
14
|
+
readonly kind: "found";
|
|
15
|
+
} | {
|
|
16
|
+
readonly kind: "unknown";
|
|
17
|
+
readonly unknown: string[];
|
|
18
|
+
};
|
|
19
|
+
/** Reads the latest view of every entry, defaulting to `working`. */
|
|
20
|
+
export declare function readTaskViews(entries: readonly SessionTaskIndexEntry[]): Promise<TaskView[]>;
|
|
21
|
+
export declare function readTaskView(entry: SessionTaskIndexEntry): Promise<TaskView>;
|
|
22
|
+
/** Finds the persistent address record for one task-owned agent. */
|
|
23
|
+
export declare function findTaskAgentAddress(session: RuntimeSession, agentId: string): Extract<AgentHandle, {
|
|
24
|
+
phase: "addressed";
|
|
25
|
+
}> | undefined;
|
|
26
|
+
/** Returns the one nonterminal task owning an agent, if any. */
|
|
27
|
+
export declare function findActiveTaskForAgent(session: RuntimeSession, agentId: string, parentTurnId?: string, parentStepIndex?: number): Promise<{
|
|
28
|
+
readonly entry: SessionTaskIndexEntry;
|
|
29
|
+
readonly view: TaskView;
|
|
30
|
+
} | undefined>;
|
|
31
|
+
/** One successful task-control result carrying full task views. */
|
|
32
|
+
export declare function createTaskViewsResult(action: RuntimeToolCallActionRequest, views: readonly TaskView[]): RuntimeActionResult;
|
|
33
|
+
/** One task-control error the model can act on. */
|
|
34
|
+
export declare function createTaskControlError(action: RuntimeToolCallActionRequest, message: string): RuntimeActionResult;
|
|
35
|
+
/** The ownership error for ids outside this session's task index. */
|
|
36
|
+
export declare function createUnknownTasksError(action: RuntimeToolCallActionRequest, unknown: readonly string[]): RuntimeActionResult;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getAgentHandleStore}from"#harness/handles/store.js";import{readLatestTaskView}from"#execution/tasks/parent/run-parent.js";import{findSessionTaskEntry,getSessionTaskIndex}from"#tasks/session-index.js";import{isTaskWorkflowTargetGone}from"#execution/tasks/workflow-target.js";import{taskViewsToJson}from"#tasks/json.js";function lookupTaskEntries(e,t){let r=[],i=[];for(let a of t){let t=findSessionTaskEntry(e.state,a);t===void 0?i.push(a):r.push(t)}return i.length>0?{kind:`unknown`,unknown:i}:{entries:r,kind:`found`}}async function readTaskViews(e){return Promise.all(e.map(readTaskView))}async function readTaskView(e){try{return await readLatestTaskView({taskRunId:e.taskRunId})??createPendingTaskView(e)}catch(t){if(isTaskWorkflowTargetGone(t)&&e.terminalView!==void 0)return e.terminalView;throw t}}function createPendingTaskView(e){return{metadata:e.metadata,status:`working`,taskId:e.taskId}}function findTaskAgentAddress(t,n){return(getAgentHandleStore(t.state)?.handles??[]).find(e=>e.phase===`addressed`&&e.identity.id===n)}async function findActiveTaskForAgent(e,t,n,i){let a=getSessionTaskIndex(e.state).filter(e=>e.metadata.agentId===t),o=await readTaskViews(a);return a.flatMap((e,t)=>{let r=o[t];return r!==void 0&&(e.createdByTurnId===n&&e.createdByStepIndex===i||r.status===`working`||r.status===`input_required`)?[{entry:e,view:r}]:[]})[0]}function createTaskViewsResult(e,t){return{callId:e.callId,kind:`tool-result`,output:taskViewsToJson(t),toolName:e.toolName}}function createTaskControlError(e,t){return{callId:e.callId,isError:!0,kind:`tool-result`,output:{message:t},toolName:e.toolName}}function createUnknownTasksError(e,t){return createTaskControlError(e,`Unknown task ids: ${t.join(`, `)}. Tasks belong to the session that created them.`)}export{createTaskControlError,createTaskViewsResult,createUnknownTasksError,findActiveTaskForAgent,findTaskAgentAddress,lookupTaskEntries,readTaskView,readTaskViews};
|