eve 0.47.2 → 0.47.3
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 +14 -0
- package/dist/src/channel/activity-renderer.d.ts +21 -0
- package/dist/src/channel/activity-renderer.js +1 -0
- package/dist/src/channel/activity-sink.d.ts +2 -0
- package/dist/src/channel/activity-sink.js +1 -0
- package/dist/src/channel/auth/oidc.js +1 -1
- package/dist/src/channel/channel-address.js +1 -1
- package/dist/src/channel/compiled-channel.d.ts +2 -0
- package/dist/src/channel/compiled-channel.js +2 -2
- package/dist/src/channel/forwarded-principal.js +1 -1
- package/dist/src/channel/session.d.ts +3 -2
- package/dist/src/channel/session.js +1 -1
- package/dist/src/channel/types.d.ts +11 -0
- package/dist/src/chunks/{use-eve-agent-CacMaX4P.js → use-eve-agent-DjYwFJF7.js} +1 -0
- package/dist/src/chunks/{use-eve-agent-kmlFdOBB.js → use-eve-agent-DkUB0Ok4.js} +1 -0
- package/dist/src/cli/dev/tui/status-line.d.ts +6 -0
- package/dist/src/cli/dev/tui/status-line.js +1 -1
- package/dist/src/cli/dev/tui/terminal-renderer.js +12 -12
- package/dist/src/cli/dev/tui/tui.js +1 -1
- package/dist/src/compiler/extension-compatibility.d.ts +4 -4
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/compiler/normalize-subagent.js +1 -1
- package/dist/src/context/keys.d.ts +2 -1
- package/dist/src/context/keys.js +1 -1
- package/dist/src/eve-channel/activity-observer-request.d.ts +7 -0
- package/dist/src/eve-channel/activity-observer-request.js +1 -0
- package/dist/src/eve-channel/index.js +1 -1
- package/dist/src/eve-channel/request.d.ts +3 -1
- package/dist/src/eve-channel/request.js +1 -1
- package/dist/src/execution/activity-collector.d.ts +12 -0
- package/dist/src/execution/activity-collector.js +1 -0
- package/dist/src/execution/activity-events.d.ts +7 -0
- package/dist/src/execution/activity-events.js +1 -0
- package/dist/src/execution/activity-route.d.ts +2 -0
- package/dist/src/execution/activity-route.js +1 -0
- package/dist/src/execution/activity-text.d.ts +3 -0
- package/dist/src/execution/activity-text.js +1 -0
- package/dist/src/execution/activity-work-id.d.ts +9 -0
- package/dist/src/execution/activity-work-id.js +1 -0
- package/dist/src/execution/activity-work.d.ts +20 -0
- package/dist/src/execution/activity-work.js +1 -0
- package/dist/src/execution/agent-handle-dispatch.d.ts +3 -1
- package/dist/src/execution/agent-handle-dispatch.js +1 -1
- package/dist/src/execution/delegated-parent-notification.js +1 -1
- package/dist/src/execution/dispatch-runtime-actions-shared.d.ts +8 -0
- package/dist/src/execution/dispatch-runtime-actions-shared.js +1 -1
- package/dist/src/execution/dispatch-runtime-actions-step.js +1 -1
- package/dist/src/execution/eve-workflow-attributes.js +1 -1
- package/dist/src/execution/remote-agent-dispatch.d.ts +3 -1
- package/dist/src/execution/remote-agent-dispatch.js +1 -1
- package/dist/src/execution/runtime-context.js +1 -1
- package/dist/src/execution/sandbox/bindings/vercel-credentials.js +1 -1
- package/dist/src/execution/session-activity-projection.d.ts +14 -0
- package/dist/src/execution/session-activity-projection.js +1 -0
- package/dist/src/execution/session-activity-renderer-step.d.ts +15 -0
- package/dist/src/execution/session-activity-renderer-step.js +1 -0
- package/dist/src/execution/session-activity.d.ts +6 -0
- package/dist/src/execution/session-activity.js +1 -0
- package/dist/src/execution/session-callback-request.d.ts +1 -0
- package/dist/src/execution/session-callback-request.js +1 -1
- package/dist/src/execution/session-callback-route.js +1 -1
- package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
- package/dist/src/execution/subagent-start-local.d.ts +1 -0
- package/dist/src/execution/subagent-start-local.js +1 -1
- package/dist/src/execution/subagent-start-remote.d.ts +1 -0
- package/dist/src/execution/subagent-start-remote.js +1 -1
- package/dist/src/execution/subagent-tool.d.ts +2 -1
- package/dist/src/execution/subagent-tool.js +1 -1
- package/dist/src/execution/submit-activity.d.ts +7 -0
- package/dist/src/execution/submit-activity.js +1 -0
- package/dist/src/execution/tasks/child/steps.d.ts +8 -0
- package/dist/src/execution/tasks/child/steps.js +1 -1
- package/dist/src/execution/tasks/child/update.js +1 -1
- package/dist/src/execution/tasks/child/workflow.d.ts +3 -0
- package/dist/src/execution/tasks/child/workflow.js +1 -1
- package/dist/src/execution/tasks/parent/delegate.d.ts +3 -0
- package/dist/src/execution/tasks/parent/delegate.js +1 -1
- package/dist/src/execution/tasks/parent/dispatch-task-step.js +1 -1
- package/dist/src/execution/tasks/parent/hitl-proxy-steps.js +1 -1
- package/dist/src/execution/tasks/parent/tool-execution.js +1 -1
- package/dist/src/execution/terminate-child-sessions-step.js +1 -1
- package/dist/src/execution/tools/connection-search.js +1 -1
- package/dist/src/execution/tools/subagent/local.js +1 -1
- package/dist/src/execution/turn-control-receiver.js +1 -1
- package/dist/src/execution/turn-workflow.js +1 -1
- package/dist/src/execution/web-fetch/request.js +1 -1
- package/dist/src/execution/wire/session-inbox-contract.d.ts +2 -2
- package/dist/src/execution/wire/session-inbox-contract.js +1 -1
- package/dist/src/execution/wire/session-inbox-encoder.d.ts +6 -2
- package/dist/src/execution/wire/session-inbox-encoder.js +1 -1
- package/dist/src/execution/wire/session-inbox-wire.js +1 -1
- package/dist/src/execution/wire/session-inbox-wire.v2-migration.d.ts +4 -0
- package/dist/src/execution/wire/session-inbox-wire.v2-migration.js +1 -0
- package/dist/src/execution/wire/session-inbox-wire.v2.d.ts +478 -0
- package/dist/src/execution/wire/session-inbox-wire.v2.js +1 -0
- package/dist/src/execution/workflow-entry.js +1 -1
- package/dist/src/execution/workflow-runtime.d.ts +4 -0
- package/dist/src/execution/workflow-runtime.js +1 -1
- package/dist/src/execution/workflow-steps.js +1 -1
- package/dist/src/harness/ai-sdk-telemetry.d.ts +5 -1
- package/dist/src/harness/ai-sdk-telemetry.js +1 -1
- package/dist/src/harness/approval-delivery-coordinator.js +1 -1
- package/dist/src/harness/authorization.js +1 -1
- package/dist/src/harness/channel-delivery-instrumentation.js +1 -1
- package/dist/src/harness/instrumentation/content-policy.d.ts +3 -5
- package/dist/src/harness/instrumentation/content-policy.js +1 -1
- package/dist/src/harness/instrumentation/dispatch.js +1 -1
- package/dist/src/harness/instrumentation/lifecycle.d.ts +10 -4
- package/dist/src/harness/instrumentation/runtime-context.js +1 -1
- package/dist/src/harness/instrumentation/runtime.d.ts +3 -3
- package/dist/src/harness/prepare-trace-context.d.ts +3 -3
- package/dist/src/harness/prepare-trace-context.js +1 -1
- package/dist/src/harness/tool-loop.js +2 -2
- package/dist/src/harness/tool-model-output.js +1 -1
- package/dist/src/internal/application/compiled-artifacts.js +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/user-agent.d.ts +2 -0
- package/dist/src/internal/user-agent.js +1 -1
- package/dist/src/protocol/activity.d.ts +105 -0
- package/dist/src/protocol/activity.js +1 -0
- package/dist/src/protocol/message.js +2 -2
- package/dist/src/protocol/routes.d.ts +4 -0
- package/dist/src/protocol/routes.js +1 -1
- package/dist/src/public/channels/auth.js +1 -1
- package/dist/src/public/channels/slack/defaults.js +1 -1
- package/dist/src/runtime/channels/registry.js +1 -1
- package/dist/src/runtime/connections/openapi-client.js +1 -1
- package/dist/src/runtime/subagents/dynamic-remote-agent-config.js +1 -1
- package/dist/src/setup/gateway-models.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 +9 -5
- package/dist/src/svelte/index.js +1 -1
- package/dist/src/svelte/use-eve-agent.js +1 -1
- package/dist/src/tracing/agent-approval-instrumentation.d.ts +0 -2
- package/dist/src/tracing/agent-approval-instrumentation.js +1 -1
- package/dist/src/tracing/agent-otel-provider.d.ts +3 -3
- package/dist/src/tracing/agent-otel-provider.js +2 -2
- package/dist/src/tracing/agent-otel-session-context.d.ts +3 -3
- package/dist/src/tracing/agent-otel-session-context.js +1 -1
- package/dist/src/tracing/agent-trace-context-store.d.ts +3 -0
- package/dist/src/tracing/agent-trace-context-store.js +1 -1
- package/dist/src/tracing/agent-trace-state.d.ts +2 -0
- package/dist/src/tracing/otel-declaration.d.ts +7 -3
- package/dist/src/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/reference/cli.md +4 -4
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{isLoopbackHostname,isPrivateOrReservedIpAddress}from"#shared/network-address.js";import{isIP}from"node:net";import{lookup}from"node:dns";const REDIRECT_STATUSES=new Set([301,302,303,307,308]),UNSAFE_DESTINATION_ERROR=`URL must not target localhost, private, link-local, or reserved IP addresses.`;async function requestPublicUrl(e,t){let n=parseHttpsUrl(e);for(let e=0;;e++){let{dispatcher:r,response:a}=await requestOnce(n,t);try{let r=a.headers.get(`location`);if(r!==null&&REDIRECT_STATUSES.has(a.status)&&e<10){await cancelResponseBody(a),n=parseHttpsUrl(new URL(r,n).toString());continue}return await consumeResponse(a,t.maxResponseSize)}finally{await r.close()}}}function parseHttpsUrl(e){let t;try{t=new URL(e)}catch{throw Error(`URL must be a valid absolute https:// URL.`)}if(t.protocol!==`https:`)throw Error(`URL must start with https://`);return t}async function requestOnce(e,t){assertPublicHostname(e.hostname);let{Agent:n,Dispatcher1Wrapper:r}=await import(`undici`),i=new r(new n({connect:{lookup:createPublicLookup()}}));try{return{dispatcher:i,response:await fetchWithDispatcher(e,{dispatcher:i,headers:t.headers,redirect:`manual`,signal:t.signal})}}catch(e){throw await i.close(),e}}function fetchWithDispatcher(e,t){return fetch(e,t)}function assertPublicHostname(t){let r=t.replace(/^\[(.*)\]$/u,`$1`);if(isIP(r)!==0){assertPublicAddress(r);return}if(isLoopbackHostname(r))throw Error(UNSAFE_DESTINATION_ERROR)}function assertPublicAddress(e){if(isPrivateOrReservedIpAddress(e))throw Error(UNSAFE_DESTINATION_ERROR)}function createPublicLookup(){return(e,t,n)=>{lookup(e,{all:!0,verbatim:!0},(r,i)=>{if(r!==null){n(r,``,0);return}try{for(let{address:e}of i)assertPublicAddress(e)}catch(e){n(e,``,0);return}let a=t.family===void 0||t.family===0?i:i.filter(({family:e})=>e===t.family);if(a.length===0){let t=Error(`Unable to resolve URL hostname "${e}" in the requested IP family.`);Object.assign(t,{code:`ENOTFOUND`}),n(t,``,0);return}if(t.all===!0){n(null,a);return}let o=a[0];n(null,o.address,o.family)})}}async function consumeResponse(e,t){let n=parseContentLength(e.headers.get(`content-length`));if(n!==void 0&&n>t)throw await cancelResponseBody(e),createResponseTooLargeError();let r=await readBoundedBody(e,t),i=r.byteLength===0?null:Uint8Array.from(r).buffer;return new Response(i,{headers:e.headers,status:e.status,statusText:e.statusText})}function parseContentLength(e){if(e===null)return;let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>=0?t:void 0}async function readBoundedBody(e,t){if(e.body===null)return new Uint8Array;let n=e.body.getReader(),r=[],i=0;try{for(;;){let{done:e,value:a}=await n.read();if(e)break;if(i+=a.byteLength,i>t)throw await n.cancel(),createResponseTooLargeError();r.push(a)}}finally{n.releaseLock()}let a=new Uint8Array(i),o=0;for(let e of r)a.set(e,o),o+=e.byteLength;return a}async function cancelResponseBody(e){try{await e.body?.cancel()}catch{}}function createResponseTooLargeError(){return Error(`Response too large (exceeds 5 MB limit).`)}export{requestPublicUrl};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/** Every explicit session-inbox wire version still supported by producers. */
|
|
2
|
-
export declare const SESSION_INBOX_WIRE_VERSIONS: readonly [1];
|
|
2
|
+
export declare const SESSION_INBOX_WIRE_VERSIONS: readonly [1, 2];
|
|
3
3
|
export type SessionInboxWireVersion = (typeof SESSION_INBOX_WIRE_VERSIONS)[number];
|
|
4
4
|
/** Current persisted session-inbox wire version. */
|
|
5
|
-
export declare const SESSION_INBOX_WIRE_VERSION: 1;
|
|
5
|
+
export declare const SESSION_INBOX_WIRE_VERSION: 1 | 2;
|
|
6
6
|
/** Hook metadata field advertising the consumer's inbox wire capability. */
|
|
7
7
|
export declare const SESSION_INBOX_WIRE_VERSION_METADATA_KEY = "sessionInboxWireVersion";
|
|
8
8
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const SESSION_INBOX_WIRE_VERSIONS=[1],SESSION_INBOX_WIRE_VERSION=SESSION_INBOX_WIRE_VERSIONS[SESSION_INBOX_WIRE_VERSIONS.length-1],SESSION_INBOX_WIRE_VERSION_METADATA_KEY=`sessionInboxWireVersion`;function isSessionInboxWireVersion(t){return SESSION_INBOX_WIRE_VERSIONS.some(e=>e===t)}var SessionInboxWireError=class extends Error{constructor(e){super(e),this.name=`SessionInboxWireError`}};export{SESSION_INBOX_WIRE_VERSION,SESSION_INBOX_WIRE_VERSIONS,SESSION_INBOX_WIRE_VERSION_METADATA_KEY,SessionInboxWireError,isSessionInboxWireVersion};
|
|
1
|
+
const SESSION_INBOX_WIRE_VERSIONS=[1,2],SESSION_INBOX_WIRE_VERSION=SESSION_INBOX_WIRE_VERSIONS[SESSION_INBOX_WIRE_VERSIONS.length-1],SESSION_INBOX_WIRE_VERSION_METADATA_KEY=`sessionInboxWireVersion`;function isSessionInboxWireVersion(t){return SESSION_INBOX_WIRE_VERSIONS.some(e=>e===t)}var SessionInboxWireError=class extends Error{constructor(e){super(e),this.name=`SessionInboxWireError`}};export{SESSION_INBOX_WIRE_VERSION,SESSION_INBOX_WIRE_VERSIONS,SESSION_INBOX_WIRE_VERSION_METADATA_KEY,SessionInboxWireError,isSessionInboxWireVersion};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { DeliverHookPayload, SessionCommand, SessionTimeoutHookPayload } from "#channel/types.js";
|
|
2
2
|
import { type SessionInboxWireV1 } from "#execution/wire/session-inbox-wire.v1.js";
|
|
3
|
+
import { type SessionInboxWireV2 } from "#execution/wire/session-inbox-wire.v2.js";
|
|
3
4
|
import { type SessionInboxWireTarget, type SessionInboxWireVersion } from "#execution/wire/session-inbox-contract.js";
|
|
4
5
|
type SessionInboxCommand = DeliverHookPayload | SessionCommand | SessionTimeoutHookPayload;
|
|
5
6
|
/** Current wire type consumed after migration. */
|
|
6
|
-
export type SessionInboxWire =
|
|
7
|
+
export type SessionInboxWire = SessionInboxWireV2;
|
|
7
8
|
type LegacySessionInboxWireTarget = Extract<SessionInboxWireTarget, {
|
|
8
9
|
readonly version: 0;
|
|
9
10
|
}>;
|
|
@@ -11,11 +12,14 @@ type LegacySessionInboxWireTarget = Extract<SessionInboxWireTarget, {
|
|
|
11
12
|
declare function encode(command: SessionInboxCommand, target: {
|
|
12
13
|
readonly version: 1;
|
|
13
14
|
}): SessionInboxWireV1;
|
|
15
|
+
declare function encode(command: SessionInboxCommand, target: {
|
|
16
|
+
readonly version: 2;
|
|
17
|
+
}): SessionInboxWireV2;
|
|
14
18
|
declare function encode(command: SessionInboxCommand, target: {
|
|
15
19
|
readonly version: SessionInboxWireVersion;
|
|
16
20
|
}): unknown;
|
|
17
21
|
declare function encode(command: SessionInboxCommand, target: LegacySessionInboxWireTarget): Record<string, unknown>;
|
|
18
|
-
declare function encode(command: SessionInboxCommand, target: SessionInboxWireTarget): SessionInboxWireV1 | Record<string, unknown>;
|
|
22
|
+
declare function encode(command: SessionInboxCommand, target: SessionInboxWireTarget): SessionInboxWireV1 | SessionInboxWireV2 | Record<string, unknown>;
|
|
19
23
|
/** Server/step-safe producer facade. */
|
|
20
24
|
export declare const sessionInboxWire: {
|
|
21
25
|
readonly encode: typeof encode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SessionInboxWireError,isSessionInboxWireVersion}from"#execution/wire/session-inbox-contract.js";import{encodeSessionCommandV1}from"#execution/wire/session-inbox-wire.v1.js";import{encodeSessionCommandV0}from"#execution/wire/session-inbox-wire.v0.js";const versionedEncoders={1:encodeSessionCommandV1};function encode(
|
|
1
|
+
import{SessionInboxWireError,isSessionInboxWireVersion}from"#execution/wire/session-inbox-contract.js";import{encodeSessionCommandV1}from"#execution/wire/session-inbox-wire.v1.js";import{encodeSessionCommandV2}from"#execution/wire/session-inbox-wire.v2.js";import{encodeSessionCommandV0}from"#execution/wire/session-inbox-wire.v0.js";const versionedEncoders={1:e=>encodeSessionCommandV1(withoutActivityObserver(e)),2:encodeSessionCommandV2};function encode(r,i){if(i.version===0)return encodeSessionCommandV0(encodeSessionCommandV1(withoutActivityObserver(r)),i.variant);if(isSessionInboxWireVersion(i.version))return versionedEncoders[i.version](r);throw new SessionInboxWireError(`Cannot encode session inbox payload for unknown wire version ${JSON.stringify(i.version)}.`)}function withoutActivityObserver(e){if(!(`caller`in e)||e.caller?.activityObserver===void 0)return e;let{activityObserver:t,...n}=e.caller;return{...e,caller:n}}const sessionInboxWire={encode};export{sessionInboxWire};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SESSION_INBOX_WIRE_VERSION,SessionInboxWireError,SessionInboxWireError as SessionInboxWireError$1}from"#execution/wire/session-inbox-contract.js";import{sessionInboxWireV0Migration}from"#execution/wire/session-inbox-wire.v0.js";import{runMigrationChain}from"#execution/durable-session-migrations/chain.js";const WIRE_LABEL=`session inbox payload`,sessionInboxMigrations=[sessionInboxWireV0Migration];function decode(t){let n;try{
|
|
1
|
+
import{SESSION_INBOX_WIRE_VERSION,SessionInboxWireError,SessionInboxWireError as SessionInboxWireError$1}from"#execution/wire/session-inbox-contract.js";import{sessionInboxWireV0Migration}from"#execution/wire/session-inbox-wire.v0.js";import{runMigrationChain}from"#execution/durable-session-migrations/chain.js";import{normalizeSessionInboxWireV2,sessionInboxWireV1Migration}from"#execution/wire/session-inbox-wire.v2-migration.js";const WIRE_LABEL=`session inbox payload`,sessionInboxMigrations=[sessionInboxWireV0Migration,sessionInboxWireV1Migration];function decode(t){let n=typeof t==`object`&&t&&`version`in t?t.version:void 0,r;try{r=runMigrationChain({initialVersion:0,label:WIRE_LABEL,migrations:sessionInboxMigrations,targetVersion:SESSION_INBOX_WIRE_VERSION,value:t})}catch(e){throw new SessionInboxWireError$1(e instanceof Error?e.message:String(e))}let i=normalizeSessionInboxWireV2(r);if(i.version!==SESSION_INBOX_WIRE_VERSION)throw new SessionInboxWireError$1(`${WIRE_LABEL} declares version ${JSON.stringify(i.version)}, expected ${SESSION_INBOX_WIRE_VERSION}.`);if(n===2&&i.kind===`deliver`&&!(`payload`in i))throw new SessionInboxWireError$1(`${WIRE_LABEL} does not match wire version 2.`);return normalizeWire(i)}const sessionInboxWire={decode};function normalizeWire(e){switch(e.kind){case`deliver`:return{auth:e.auth,caller:e.caller,deliveryMetadata:e.deliveryMetadata,kind:`deliver`,payloads:e.payloads,requestId:e.requestId,taskDeliveryId:e.taskDeliveryId,turnPolicy:e.turnPolicy};case`session-timeout`:return{kind:`session-timeout`};case`clear`:return{kind:`clear`};case`compact`:return{kind:`compact`};case`reset`:return{kind:`reset`,reason:e.reason};case`cancel`:return{kind:`cancel`,taskId:e.taskId,turnId:e.turnId};default:throw new SessionInboxWireError$1(`${WIRE_LABEL} has an unrecognized kind ${JSON.stringify(e.kind)}.`)}}export{SessionInboxWireError,sessionInboxWire};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { VersionMigration } from "#execution/durable-session-migrations/chain.js";
|
|
2
|
+
export declare const sessionInboxWireV1Migration: VersionMigration;
|
|
3
|
+
/** Converts Workflow-VM records into this realm before wire consumption. */
|
|
4
|
+
export declare function normalizeSessionInboxWireV2(value: unknown, arrayFallback?: boolean): unknown;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isObject}from"#shared/guards.js";const sessionInboxWireV1Migration={from:1,migrate(e){let t=normalizeSessionInboxWireV2(e);return{...t,...t.kind===`deliver`&&!(`payload`in t)?{payload:{}}:{},version:2}},to:2};function normalizeSessionInboxWireV2(e,t=!1){return e===void 0?t?null:void 0:Array.isArray(e)?e.map(e=>normalizeSessionInboxWireV2(e,!0)):isPlainRecord$1(e)?Object.fromEntries(Object.entries(e).filter(e=>e[1]!==void 0).map(([e,t])=>[e,normalizeSessionInboxWireV2(t)])):e}function isPlainRecord$1(t){if(!isObject(t))return!1;let n=Object.getPrototypeOf(t);return n===null||n===Object.prototype||Object.getPrototypeOf(n)===null}export{normalizeSessionInboxWireV2,sessionInboxWireV1Migration};
|
|
@@ -0,0 +1,478 @@
|
|
|
1
|
+
import { z } from "#compiled/zod/index.js";
|
|
2
|
+
import type { DeliverHookPayload, SessionCommand, SessionTimeoutHookPayload } from "#channel/types.js";
|
|
3
|
+
/** Version 2 adds activity observer metadata to delegated callers. */
|
|
4
|
+
export declare const sessionInboxWireV2Schema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
5
|
+
auth: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
6
|
+
attributes: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
7
|
+
authenticator: z.ZodString;
|
|
8
|
+
issuer: z.ZodOptional<z.ZodString>;
|
|
9
|
+
principalId: z.ZodString;
|
|
10
|
+
principalType: z.ZodString;
|
|
11
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
12
|
+
}, z.core.$strict>>>;
|
|
13
|
+
deliveryMetadata: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
14
|
+
channelKind: z.ZodString;
|
|
15
|
+
channelName: z.ZodString;
|
|
16
|
+
deliveryId: z.ZodString;
|
|
17
|
+
payloadIndex: z.ZodNumber;
|
|
18
|
+
requestId: z.ZodOptional<z.ZodString>;
|
|
19
|
+
requestTraceContext: z.ZodOptional<z.ZodObject<{
|
|
20
|
+
spanId: z.ZodString;
|
|
21
|
+
traceFlags: z.ZodNumber;
|
|
22
|
+
traceId: z.ZodString;
|
|
23
|
+
}, z.core.$strict>>;
|
|
24
|
+
}, z.core.$strict>>>;
|
|
25
|
+
kind: z.ZodLiteral<"deliver">;
|
|
26
|
+
payloads: z.ZodArray<z.ZodObject<{
|
|
27
|
+
context: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
28
|
+
inputResponses: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
29
|
+
optionId: z.ZodOptional<z.ZodString>;
|
|
30
|
+
requestId: z.ZodString;
|
|
31
|
+
text: z.ZodOptional<z.ZodString>;
|
|
32
|
+
}, z.core.$strict>>>;
|
|
33
|
+
message: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
34
|
+
providerOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("../../shared/json.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonObject, unknown>>>>;
|
|
35
|
+
text: z.ZodString;
|
|
36
|
+
type: z.ZodLiteral<"text">;
|
|
37
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
38
|
+
image: z.ZodCustom<URL | import("ai").DataContent, URL | import("ai").DataContent>;
|
|
39
|
+
mediaType: z.ZodOptional<z.ZodString>;
|
|
40
|
+
providerOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("../../shared/json.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonObject, unknown>>>>;
|
|
41
|
+
type: z.ZodLiteral<"image">;
|
|
42
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
43
|
+
data: z.ZodCustom<URL | import("ai").DataContent, URL | import("ai").DataContent>;
|
|
44
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
45
|
+
mediaType: z.ZodString;
|
|
46
|
+
providerOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("../../shared/json.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonObject, unknown>>>>;
|
|
47
|
+
type: z.ZodLiteral<"file">;
|
|
48
|
+
}, z.core.$strict>], "type">>]>>;
|
|
49
|
+
outputSchema: z.ZodOptional<z.ZodType<import("../../shared/json.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonObject, unknown>>>;
|
|
50
|
+
task: z.ZodOptional<z.ZodObject<{
|
|
51
|
+
authorizationEvents: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
52
|
+
hookPayload: z.ZodObject<{
|
|
53
|
+
callId: z.ZodString;
|
|
54
|
+
childSessionId: z.ZodString;
|
|
55
|
+
event: z.ZodCustom<Record<string, unknown>, Record<string, unknown>>;
|
|
56
|
+
kind: z.ZodLiteral<"subagent-authorization-event">;
|
|
57
|
+
subagentName: z.ZodString;
|
|
58
|
+
}, z.core.$strict>;
|
|
59
|
+
taskId: z.ZodString;
|
|
60
|
+
}, z.core.$strict>>>;
|
|
61
|
+
inputRequests: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
62
|
+
hookPayload: z.ZodObject<{
|
|
63
|
+
callId: z.ZodString;
|
|
64
|
+
childContinuationToken: z.ZodString;
|
|
65
|
+
childSessionId: z.ZodString;
|
|
66
|
+
event: z.ZodObject<{
|
|
67
|
+
requests: z.ZodArray<z.ZodObject<{
|
|
68
|
+
action: z.ZodObject<{
|
|
69
|
+
callId: z.ZodString;
|
|
70
|
+
input: z.ZodType<import("../../shared/json.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonObject, unknown>>;
|
|
71
|
+
kind: z.ZodLiteral<"tool-call">;
|
|
72
|
+
toolName: z.ZodString;
|
|
73
|
+
}, z.core.$strict>;
|
|
74
|
+
allowFreeform: z.ZodOptional<z.ZodBoolean>;
|
|
75
|
+
display: z.ZodOptional<z.ZodEnum<{
|
|
76
|
+
confirmation: "confirmation";
|
|
77
|
+
select: "select";
|
|
78
|
+
text: "text";
|
|
79
|
+
}>>;
|
|
80
|
+
kind: z.ZodEnum<{
|
|
81
|
+
question: "question";
|
|
82
|
+
"session-limit": "session-limit";
|
|
83
|
+
"tool-approval": "tool-approval";
|
|
84
|
+
}>;
|
|
85
|
+
options: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
86
|
+
description: z.ZodOptional<z.ZodString>;
|
|
87
|
+
id: z.ZodString;
|
|
88
|
+
label: z.ZodString;
|
|
89
|
+
style: z.ZodOptional<z.ZodEnum<{
|
|
90
|
+
danger: "danger";
|
|
91
|
+
default: "default";
|
|
92
|
+
primary: "primary";
|
|
93
|
+
}>>;
|
|
94
|
+
}, z.core.$strict>>>;
|
|
95
|
+
prompt: z.ZodString;
|
|
96
|
+
requestId: z.ZodString;
|
|
97
|
+
}, z.core.$strict>>;
|
|
98
|
+
sequence: z.ZodNumber;
|
|
99
|
+
stepIndex: z.ZodNumber;
|
|
100
|
+
turnId: z.ZodString;
|
|
101
|
+
}, z.core.$strict>;
|
|
102
|
+
kind: z.ZodLiteral<"subagent-input-request">;
|
|
103
|
+
subagentName: z.ZodString;
|
|
104
|
+
}, z.core.$strict>;
|
|
105
|
+
taskId: z.ZodString;
|
|
106
|
+
}, z.core.$strict>>>;
|
|
107
|
+
views: z.ZodOptional<z.ZodArray<z.ZodType<import("../../tasks/types.ts").TaskView, unknown, z.core.$ZodTypeInternals<import("../../tasks/types.ts").TaskView, unknown>>>>;
|
|
108
|
+
}, z.core.$strict>>;
|
|
109
|
+
}, z.core.$loose>>;
|
|
110
|
+
requestId: z.ZodOptional<z.ZodString>;
|
|
111
|
+
taskDeliveryId: z.ZodOptional<z.ZodString>;
|
|
112
|
+
turnPolicy: z.ZodOptional<z.ZodEnum<{
|
|
113
|
+
queue: "queue";
|
|
114
|
+
steer: "steer";
|
|
115
|
+
}>>;
|
|
116
|
+
caller: z.ZodOptional<z.ZodObject<{
|
|
117
|
+
callId: z.ZodString;
|
|
118
|
+
replyTo: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
119
|
+
kind: z.ZodLiteral<"hook">;
|
|
120
|
+
token: z.ZodString;
|
|
121
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
122
|
+
kind: z.ZodLiteral<"callback">;
|
|
123
|
+
token: z.ZodString;
|
|
124
|
+
url: z.ZodString;
|
|
125
|
+
}, z.core.$strict>], "kind">;
|
|
126
|
+
subagentName: z.ZodString;
|
|
127
|
+
taskId: z.ZodOptional<z.ZodString>;
|
|
128
|
+
activityObserver: z.ZodOptional<z.ZodObject<{
|
|
129
|
+
sink: z.ZodObject<{
|
|
130
|
+
url: z.ZodString;
|
|
131
|
+
version: z.ZodLiteral<1>;
|
|
132
|
+
}, z.core.$strict>;
|
|
133
|
+
workIdentity: z.ZodOptional<z.ZodObject<{
|
|
134
|
+
callId: z.ZodOptional<z.ZodString>;
|
|
135
|
+
id: z.ZodString;
|
|
136
|
+
kind: z.ZodEnum<{
|
|
137
|
+
"remote-agent": "remote-agent";
|
|
138
|
+
"root-turn": "root-turn";
|
|
139
|
+
subagent: "subagent";
|
|
140
|
+
task: "task";
|
|
141
|
+
}>;
|
|
142
|
+
name: z.ZodOptional<z.ZodString>;
|
|
143
|
+
parentId: z.ZodOptional<z.ZodString>;
|
|
144
|
+
rootSessionId: z.ZodString;
|
|
145
|
+
rootTurnId: z.ZodString;
|
|
146
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
147
|
+
turnId: z.ZodOptional<z.ZodString>;
|
|
148
|
+
}, z.core.$strict>>;
|
|
149
|
+
}, z.core.$strict>>;
|
|
150
|
+
}, z.core.$strict>>;
|
|
151
|
+
payload: z.ZodObject<{
|
|
152
|
+
context: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
153
|
+
inputResponses: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
154
|
+
optionId: z.ZodOptional<z.ZodString>;
|
|
155
|
+
requestId: z.ZodString;
|
|
156
|
+
text: z.ZodOptional<z.ZodString>;
|
|
157
|
+
}, z.core.$strict>>>;
|
|
158
|
+
message: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
159
|
+
providerOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("../../shared/json.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonObject, unknown>>>>;
|
|
160
|
+
text: z.ZodString;
|
|
161
|
+
type: z.ZodLiteral<"text">;
|
|
162
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
163
|
+
image: z.ZodCustom<URL | import("ai").DataContent, URL | import("ai").DataContent>;
|
|
164
|
+
mediaType: z.ZodOptional<z.ZodString>;
|
|
165
|
+
providerOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("../../shared/json.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonObject, unknown>>>>;
|
|
166
|
+
type: z.ZodLiteral<"image">;
|
|
167
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
168
|
+
data: z.ZodCustom<URL | import("ai").DataContent, URL | import("ai").DataContent>;
|
|
169
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
170
|
+
mediaType: z.ZodString;
|
|
171
|
+
providerOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("../../shared/json.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonObject, unknown>>>>;
|
|
172
|
+
type: z.ZodLiteral<"file">;
|
|
173
|
+
}, z.core.$strict>], "type">>]>>;
|
|
174
|
+
outputSchema: z.ZodOptional<z.ZodType<import("../../shared/json.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonObject, unknown>>>;
|
|
175
|
+
task: z.ZodOptional<z.ZodObject<{
|
|
176
|
+
authorizationEvents: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
177
|
+
hookPayload: z.ZodObject<{
|
|
178
|
+
callId: z.ZodString;
|
|
179
|
+
childSessionId: z.ZodString;
|
|
180
|
+
event: z.ZodCustom<Record<string, unknown>, Record<string, unknown>>;
|
|
181
|
+
kind: z.ZodLiteral<"subagent-authorization-event">;
|
|
182
|
+
subagentName: z.ZodString;
|
|
183
|
+
}, z.core.$strict>;
|
|
184
|
+
taskId: z.ZodString;
|
|
185
|
+
}, z.core.$strict>>>;
|
|
186
|
+
inputRequests: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
187
|
+
hookPayload: z.ZodObject<{
|
|
188
|
+
callId: z.ZodString;
|
|
189
|
+
childContinuationToken: z.ZodString;
|
|
190
|
+
childSessionId: z.ZodString;
|
|
191
|
+
event: z.ZodObject<{
|
|
192
|
+
requests: z.ZodArray<z.ZodObject<{
|
|
193
|
+
action: z.ZodObject<{
|
|
194
|
+
callId: z.ZodString;
|
|
195
|
+
input: z.ZodType<import("../../shared/json.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("../../shared/json.ts").JsonObject, unknown>>;
|
|
196
|
+
kind: z.ZodLiteral<"tool-call">;
|
|
197
|
+
toolName: z.ZodString;
|
|
198
|
+
}, z.core.$strict>;
|
|
199
|
+
allowFreeform: z.ZodOptional<z.ZodBoolean>;
|
|
200
|
+
display: z.ZodOptional<z.ZodEnum<{
|
|
201
|
+
confirmation: "confirmation";
|
|
202
|
+
select: "select";
|
|
203
|
+
text: "text";
|
|
204
|
+
}>>;
|
|
205
|
+
kind: z.ZodEnum<{
|
|
206
|
+
question: "question";
|
|
207
|
+
"session-limit": "session-limit";
|
|
208
|
+
"tool-approval": "tool-approval";
|
|
209
|
+
}>;
|
|
210
|
+
options: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
211
|
+
description: z.ZodOptional<z.ZodString>;
|
|
212
|
+
id: z.ZodString;
|
|
213
|
+
label: z.ZodString;
|
|
214
|
+
style: z.ZodOptional<z.ZodEnum<{
|
|
215
|
+
danger: "danger";
|
|
216
|
+
default: "default";
|
|
217
|
+
primary: "primary";
|
|
218
|
+
}>>;
|
|
219
|
+
}, z.core.$strict>>>;
|
|
220
|
+
prompt: z.ZodString;
|
|
221
|
+
requestId: z.ZodString;
|
|
222
|
+
}, z.core.$strict>>;
|
|
223
|
+
sequence: z.ZodNumber;
|
|
224
|
+
stepIndex: z.ZodNumber;
|
|
225
|
+
turnId: z.ZodString;
|
|
226
|
+
}, z.core.$strict>;
|
|
227
|
+
kind: z.ZodLiteral<"subagent-input-request">;
|
|
228
|
+
subagentName: z.ZodString;
|
|
229
|
+
}, z.core.$strict>;
|
|
230
|
+
taskId: z.ZodString;
|
|
231
|
+
}, z.core.$strict>>>;
|
|
232
|
+
views: z.ZodOptional<z.ZodArray<z.ZodType<import("../../tasks/types.ts").TaskView, unknown, z.core.$ZodTypeInternals<import("../../tasks/types.ts").TaskView, unknown>>>>;
|
|
233
|
+
}, z.core.$strict>>;
|
|
234
|
+
}, z.core.$loose>;
|
|
235
|
+
version: z.ZodLiteral<2>;
|
|
236
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
237
|
+
kind: z.ZodLiteral<"session-timeout">;
|
|
238
|
+
version: z.ZodLiteral<2>;
|
|
239
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
240
|
+
kind: z.ZodLiteral<"clear">;
|
|
241
|
+
version: z.ZodLiteral<2>;
|
|
242
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
243
|
+
kind: z.ZodLiteral<"compact">;
|
|
244
|
+
version: z.ZodLiteral<2>;
|
|
245
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
246
|
+
kind: z.ZodLiteral<"reset">;
|
|
247
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
248
|
+
version: z.ZodLiteral<2>;
|
|
249
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
250
|
+
kind: z.ZodLiteral<"cancel">;
|
|
251
|
+
taskId: z.ZodOptional<z.ZodString>;
|
|
252
|
+
turnId: z.ZodOptional<z.ZodString>;
|
|
253
|
+
version: z.ZodLiteral<2>;
|
|
254
|
+
}, z.core.$strict>], "kind">;
|
|
255
|
+
export type SessionInboxWireV2 = z.infer<typeof sessionInboxWireV2Schema>;
|
|
256
|
+
export declare function parseSessionInboxWireV2(value: unknown): z.ZodSafeParseResult<{
|
|
257
|
+
auth?: {
|
|
258
|
+
attributes: Record<string, string | string[]>;
|
|
259
|
+
authenticator: string;
|
|
260
|
+
issuer?: string | undefined;
|
|
261
|
+
principalId: string;
|
|
262
|
+
principalType: string;
|
|
263
|
+
subject?: string | undefined;
|
|
264
|
+
} | null | undefined;
|
|
265
|
+
deliveryMetadata?: {
|
|
266
|
+
channelKind: string;
|
|
267
|
+
channelName: string;
|
|
268
|
+
deliveryId: string;
|
|
269
|
+
payloadIndex: number;
|
|
270
|
+
requestId?: string | undefined;
|
|
271
|
+
requestTraceContext?: {
|
|
272
|
+
spanId: string;
|
|
273
|
+
traceFlags: number;
|
|
274
|
+
traceId: string;
|
|
275
|
+
} | undefined;
|
|
276
|
+
}[] | undefined;
|
|
277
|
+
kind: "deliver";
|
|
278
|
+
payloads: {
|
|
279
|
+
[x: string]: unknown;
|
|
280
|
+
context?: string[] | undefined;
|
|
281
|
+
inputResponses?: {
|
|
282
|
+
optionId?: string | undefined;
|
|
283
|
+
requestId: string;
|
|
284
|
+
text?: string | undefined;
|
|
285
|
+
}[] | undefined;
|
|
286
|
+
message?: string | ({
|
|
287
|
+
providerOptions?: Record<string, import("../../shared/json.ts").JsonObject> | undefined;
|
|
288
|
+
text: string;
|
|
289
|
+
type: "text";
|
|
290
|
+
} | {
|
|
291
|
+
image: URL | import("ai").DataContent;
|
|
292
|
+
mediaType?: string | undefined;
|
|
293
|
+
providerOptions?: Record<string, import("../../shared/json.ts").JsonObject> | undefined;
|
|
294
|
+
type: "image";
|
|
295
|
+
} | {
|
|
296
|
+
data: URL | import("ai").DataContent;
|
|
297
|
+
filename?: string | undefined;
|
|
298
|
+
mediaType: string;
|
|
299
|
+
providerOptions?: Record<string, import("../../shared/json.ts").JsonObject> | undefined;
|
|
300
|
+
type: "file";
|
|
301
|
+
})[] | undefined;
|
|
302
|
+
outputSchema?: import("../../shared/json.ts").JsonObject | undefined;
|
|
303
|
+
task?: {
|
|
304
|
+
authorizationEvents?: {
|
|
305
|
+
hookPayload: {
|
|
306
|
+
callId: string;
|
|
307
|
+
childSessionId: string;
|
|
308
|
+
event: Record<string, unknown>;
|
|
309
|
+
kind: "subagent-authorization-event";
|
|
310
|
+
subagentName: string;
|
|
311
|
+
};
|
|
312
|
+
taskId: string;
|
|
313
|
+
}[] | undefined;
|
|
314
|
+
inputRequests?: {
|
|
315
|
+
hookPayload: {
|
|
316
|
+
callId: string;
|
|
317
|
+
childContinuationToken: string;
|
|
318
|
+
childSessionId: string;
|
|
319
|
+
event: {
|
|
320
|
+
requests: {
|
|
321
|
+
action: {
|
|
322
|
+
callId: string;
|
|
323
|
+
input: import("../../shared/json.ts").JsonObject;
|
|
324
|
+
kind: "tool-call";
|
|
325
|
+
toolName: string;
|
|
326
|
+
};
|
|
327
|
+
allowFreeform?: boolean | undefined;
|
|
328
|
+
display?: "confirmation" | "select" | "text" | undefined;
|
|
329
|
+
kind: "question" | "session-limit" | "tool-approval";
|
|
330
|
+
options?: {
|
|
331
|
+
description?: string | undefined;
|
|
332
|
+
id: string;
|
|
333
|
+
label: string;
|
|
334
|
+
style?: "danger" | "default" | "primary" | undefined;
|
|
335
|
+
}[] | undefined;
|
|
336
|
+
prompt: string;
|
|
337
|
+
requestId: string;
|
|
338
|
+
}[];
|
|
339
|
+
sequence: number;
|
|
340
|
+
stepIndex: number;
|
|
341
|
+
turnId: string;
|
|
342
|
+
};
|
|
343
|
+
kind: "subagent-input-request";
|
|
344
|
+
subagentName: string;
|
|
345
|
+
};
|
|
346
|
+
taskId: string;
|
|
347
|
+
}[] | undefined;
|
|
348
|
+
views?: import("../../tasks/types.ts").TaskView[] | undefined;
|
|
349
|
+
} | undefined;
|
|
350
|
+
}[];
|
|
351
|
+
requestId?: string | undefined;
|
|
352
|
+
taskDeliveryId?: string | undefined;
|
|
353
|
+
turnPolicy?: "queue" | "steer" | undefined;
|
|
354
|
+
caller?: {
|
|
355
|
+
callId: string;
|
|
356
|
+
replyTo: {
|
|
357
|
+
kind: "hook";
|
|
358
|
+
token: string;
|
|
359
|
+
} | {
|
|
360
|
+
kind: "callback";
|
|
361
|
+
token: string;
|
|
362
|
+
url: string;
|
|
363
|
+
};
|
|
364
|
+
subagentName: string;
|
|
365
|
+
taskId?: string | undefined;
|
|
366
|
+
activityObserver?: {
|
|
367
|
+
sink: {
|
|
368
|
+
url: string;
|
|
369
|
+
version: 1;
|
|
370
|
+
};
|
|
371
|
+
workIdentity?: {
|
|
372
|
+
callId?: string | undefined;
|
|
373
|
+
id: string;
|
|
374
|
+
kind: "remote-agent" | "root-turn" | "subagent" | "task";
|
|
375
|
+
name?: string | undefined;
|
|
376
|
+
parentId?: string | undefined;
|
|
377
|
+
rootSessionId: string;
|
|
378
|
+
rootTurnId: string;
|
|
379
|
+
sessionId?: string | undefined;
|
|
380
|
+
turnId?: string | undefined;
|
|
381
|
+
} | undefined;
|
|
382
|
+
} | undefined;
|
|
383
|
+
} | undefined;
|
|
384
|
+
payload: {
|
|
385
|
+
[x: string]: unknown;
|
|
386
|
+
context?: string[] | undefined;
|
|
387
|
+
inputResponses?: {
|
|
388
|
+
optionId?: string | undefined;
|
|
389
|
+
requestId: string;
|
|
390
|
+
text?: string | undefined;
|
|
391
|
+
}[] | undefined;
|
|
392
|
+
message?: string | ({
|
|
393
|
+
providerOptions?: Record<string, import("../../shared/json.ts").JsonObject> | undefined;
|
|
394
|
+
text: string;
|
|
395
|
+
type: "text";
|
|
396
|
+
} | {
|
|
397
|
+
image: URL | import("ai").DataContent;
|
|
398
|
+
mediaType?: string | undefined;
|
|
399
|
+
providerOptions?: Record<string, import("../../shared/json.ts").JsonObject> | undefined;
|
|
400
|
+
type: "image";
|
|
401
|
+
} | {
|
|
402
|
+
data: URL | import("ai").DataContent;
|
|
403
|
+
filename?: string | undefined;
|
|
404
|
+
mediaType: string;
|
|
405
|
+
providerOptions?: Record<string, import("../../shared/json.ts").JsonObject> | undefined;
|
|
406
|
+
type: "file";
|
|
407
|
+
})[] | undefined;
|
|
408
|
+
outputSchema?: import("../../shared/json.ts").JsonObject | undefined;
|
|
409
|
+
task?: {
|
|
410
|
+
authorizationEvents?: {
|
|
411
|
+
hookPayload: {
|
|
412
|
+
callId: string;
|
|
413
|
+
childSessionId: string;
|
|
414
|
+
event: Record<string, unknown>;
|
|
415
|
+
kind: "subagent-authorization-event";
|
|
416
|
+
subagentName: string;
|
|
417
|
+
};
|
|
418
|
+
taskId: string;
|
|
419
|
+
}[] | undefined;
|
|
420
|
+
inputRequests?: {
|
|
421
|
+
hookPayload: {
|
|
422
|
+
callId: string;
|
|
423
|
+
childContinuationToken: string;
|
|
424
|
+
childSessionId: string;
|
|
425
|
+
event: {
|
|
426
|
+
requests: {
|
|
427
|
+
action: {
|
|
428
|
+
callId: string;
|
|
429
|
+
input: import("../../shared/json.ts").JsonObject;
|
|
430
|
+
kind: "tool-call";
|
|
431
|
+
toolName: string;
|
|
432
|
+
};
|
|
433
|
+
allowFreeform?: boolean | undefined;
|
|
434
|
+
display?: "confirmation" | "select" | "text" | undefined;
|
|
435
|
+
kind: "question" | "session-limit" | "tool-approval";
|
|
436
|
+
options?: {
|
|
437
|
+
description?: string | undefined;
|
|
438
|
+
id: string;
|
|
439
|
+
label: string;
|
|
440
|
+
style?: "danger" | "default" | "primary" | undefined;
|
|
441
|
+
}[] | undefined;
|
|
442
|
+
prompt: string;
|
|
443
|
+
requestId: string;
|
|
444
|
+
}[];
|
|
445
|
+
sequence: number;
|
|
446
|
+
stepIndex: number;
|
|
447
|
+
turnId: string;
|
|
448
|
+
};
|
|
449
|
+
kind: "subagent-input-request";
|
|
450
|
+
subagentName: string;
|
|
451
|
+
};
|
|
452
|
+
taskId: string;
|
|
453
|
+
}[] | undefined;
|
|
454
|
+
views?: import("../../tasks/types.ts").TaskView[] | undefined;
|
|
455
|
+
} | undefined;
|
|
456
|
+
};
|
|
457
|
+
version: 2;
|
|
458
|
+
} | {
|
|
459
|
+
kind: "session-timeout";
|
|
460
|
+
version: 2;
|
|
461
|
+
} | {
|
|
462
|
+
kind: "clear";
|
|
463
|
+
version: 2;
|
|
464
|
+
} | {
|
|
465
|
+
kind: "compact";
|
|
466
|
+
version: 2;
|
|
467
|
+
} | {
|
|
468
|
+
kind: "reset";
|
|
469
|
+
reason?: string | undefined;
|
|
470
|
+
version: 2;
|
|
471
|
+
} | {
|
|
472
|
+
kind: "cancel";
|
|
473
|
+
taskId?: string | undefined;
|
|
474
|
+
turnId?: string | undefined;
|
|
475
|
+
version: 2;
|
|
476
|
+
}>;
|
|
477
|
+
/** Builds and validates one complete version-2 wire value. */
|
|
478
|
+
export declare function encodeSessionCommandV2(command: DeliverHookPayload | SessionCommand | SessionTimeoutHookPayload): SessionInboxWireV2;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{z}from"#compiled/zod/index.js";import{formatValidationError}from"#runtime/validation.js";import{coalesceDeliverPayloads}from"#execution/deliver-payloads.js";import{SessionInboxWireError}from"#execution/wire/session-inbox-contract.js";import{sessionInboxWireV1Schema}from"#execution/wire/session-inbox-wire.v1.js";import{normalizeSessionInboxWireV2}from"#execution/wire/session-inbox-wire.v2-migration.js";const activityWorkIdentitySchema=z.object({callId:z.string().optional(),id:z.string(),kind:z.enum([`root-turn`,`subagent`,`remote-agent`,`task`]),name:z.string().optional(),parentId:z.string().optional(),rootSessionId:z.string(),rootTurnId:z.string(),sessionId:z.string().optional(),turnId:z.string().optional()}).strict(),activityObserverSchema=z.object({sink:z.object({url:z.string(),version:z.literal(1)}).strict(),workIdentity:activityWorkIdentitySchema.optional()}).strict(),v1=sessionInboxWireV1Schema.options,v1Deliver=v1[0],v1Caller=v1Deliver.shape.caller.unwrap(),version=z.literal(2),sessionInboxWireV2Schema=z.discriminatedUnion(`kind`,[v1Deliver.extend({caller:v1Caller.extend({activityObserver:activityObserverSchema.optional()}).optional(),payload:v1Deliver.shape.payload.unwrap(),version}),v1[1].extend({version}),v1[2].extend({version}),v1[3].extend({version}),v1[4].extend({version}),v1[5].extend({version})]);function parseSessionInboxWireV2(e){return sessionInboxWireV2Schema.safeParse(normalizeSessionInboxWireV2(e))}function encodeSessionCommandV2(e){let t=parseSessionInboxWireV2(e.kind===`send`?{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,version:2}:e.kind===`deliver`?{...e,payload:coalesceDeliverPayloads(e.payloads),version:2}:{...e,version:2});if(!t.success)throw new SessionInboxWireError(`Produced a session inbox payload that does not match wire version 2: ${formatValidationError(t.error)}`);return t.data}export{encodeSessionCommandV2,parseSessionInboxWireV2,sessionInboxWireV2Schema};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{sessionCommandHookToken}from"#execution/session-command-token.js";import{isTaskOwnedSerializedContext}from"#execution/tasks/child/instructions.js";import{readSerializedSubagentDepth}from"#harness/subagent-depth.js";import{readChannelRequestId,readRootSessionId}from"#execution/eve-workflow-attributes.js";import{getWorkflowMetadata,getWritable}from"#compiled/@workflow/core/index.js";import{isHookConflictError}from"#execution/hook-ownership.js";import{activeTurnId}from"#harness/active-turn-id.js";import{fireSessionCallbackStep}from"#execution/session-callback-step.js";import{normalizeSerializableError}from"#execution/workflow-errors.js";import{SessionStateCursor}from"#execution/session-state-cursor.js";import{cancelDescendantTurnsStep}from"#execution/cancel-descendant-turns-step.js";import{bindTurnCallerContextStep,notifyCancelledTaskCallerStep,notifyDelegatedParentStep,notifyTaskTurnStartedStep,notifyTurnCallerStep,resolveInitialTurnCallerStep}from"#execution/delegated-parent-notification.js";import{createDelegatedSubagentErrorResult,createDelegatedSubagentSuccessResult}from"#execution/delegated-parent-result.js";import{nextTurnDelivery}from"#execution/parked-delivery-wait.js";import{dispatchAndAwaitTurn}from"#execution/turn-dispatch.js";import{createSessionStep}from"#execution/create-session-step.js";import{settleCancelledTurnStep}from"#execution/settle-cancelled-turn-step.js";import{emitTerminalSessionFailureStep}from"#execution/terminal-session-failure-step.js";import{createSessionCommandInbox}from"#execution/session-command-inbox.js";import{DEFAULT_SESSION_TIMEOUT_MS}from"#execution/session-timeout.js";import{emitTerminalSessionCompletionStep}from"#execution/terminal-session-completion-step.js";import{createSessionTimeoutControl}from"#execution/session-timeout-control.js";import{terminateChildSessionsStep}from"#execution/terminate-child-sessions-step.js";async function workflowEntry(e){"use workflow";let{workflowRunId:s,workflowStartedAt:c}=getWorkflowMetadata(),d=e.serializedContext[`eve.continuationToken`]||``,f=e.serializedContext[`eve.mode`],p=e.serializedContext[`eve.capabilities`],m=e.serializedContext[`eve.bundle`];e.serializedContext[`eve.sessionId`]=s;let g=getWritable(),y={caller:void 0,callerResolved:!1,lastSessionState:void 0};try{let a=readRootSessionId(e.serializedContext),o=readSerializedSubagentDepth(e.serializedContext),l=e.serializedContext[`eve.dynamicSubagentAgentConfig`],{state:u}=await createSessionStep({compiledArtifactsSource:m.source,continuationToken:d,dynamicSubagentAgentConfig:l,inheritedLimits:e.limits,nodeId:m.nodeId,outputSchema:e.input.outputSchema,rootSessionId:a,sessionId:s,subagentDepth:o,taskOwned:isTaskOwnedSerializedContext(e.serializedContext)});y.lastSessionState=u,y.caller=await resolveInitialTurnCallerStep({serializedContext:e.serializedContext}),y.callerResolved=!0;let h=await runDriverLoop({capabilities:p,driverWritable:g,initialInput:{deliveryMetadata:e.serializedContext[`eve.channelDelivery`]===void 0?void 0:[{...e.serializedContext[`eve.channelDelivery`],payloadIndex:0}],kind:`deliver`,payloads:[{message:e.input.message,context:e.input.context,outputSchema:e.input.outputSchema}],requestId:readChannelRequestId(e.serializedContext)},crashCleanupState:y,mode:f,serializedContext:e.serializedContext,sessionState:u,sessionTimeoutDeadline:e.sessionTimeoutMs===!1?void 0:new Date(c.getTime()+(e.sessionTimeoutMs??DEFAULT_SESSION_TIMEOUT_MS))});return h.kind===`result`?h.result:await finalizeExpiredSession({caller:y.caller,driverWritable:g,mode:f,serializedContext:h.serializedContext,sessionState:h.sessionState})}catch(t){throw y.lastSessionState!==void 0&&await terminateChildSessionsStep({serializedContext:e.serializedContext,sessionState:y.lastSessionState}),await emitTerminalSessionFailureStep({error:normalizeSerializableError(t),parentWritable:g,serializedContext:e.serializedContext}),f===`task`?(await fireSessionCallbackStep({error:normalizeSerializableError(t),serializedContext:e.serializedContext,status:`failed`}),await notifyDelegatedParentStep({result:createDelegatedSubagentErrorResult(e.serializedContext,t),serializedContext:e.serializedContext})):await notifyTurnCallerStep({caller:await resolveCallerForCrash(y,e.serializedContext),lifecycle:`terminal`,sessionId:s,settled:{isError:!0,output:t}}),createSafeOuterWorkflowError()}}async function resolveCallerForCrash(e,t){if(e.callerResolved)return e.caller;try{return await resolveInitialTurnCallerStep({serializedContext:t})}catch{return}}function createSafeOuterWorkflowError(){let e=Error(`Agent workflow failed. Inspect the private session trace for details.`);return e.name=`EveWorkflowFailure`,e}async function runDriverLoop(t){let n=new Map,nextParkedActivity=async e=>{let r=new Set(e.expectedAttemptIds);for(let e of n.keys())r.has(e)||n.delete(e);for(;;){if(r.size>0&&[...r].every(e=>n.has(e))){let e=[...r].map(e=>n.get(e));return n.clear(),{kind:`authorization-resume`,payloads:e}}let e=await nextTurnDelivery({awaitAuthorizationCallbacks:r.size>0,bufferedDeliveries:i,bufferedSessionControls:a,cancelledTaskIds:o,commandInbox:u,deferDeliveries:t.mode===`task`&&r.size>0,driverWritable:t.driverWritable,seenTaskDeliveries:l,stateCursor:v});if(e.kind!==`authorization`)return e;for(let t of e.payloads){let e=t.authorizationCallback;typeof e?.attemptId==`string`&&r.has(e.attemptId)&&!n.has(e.attemptId)&&n.set(e.attemptId,t)}if(e.closed){let e=[...n.values()];return n.clear(),{kind:`authorization-resume`,payloads:e}}}},r=0,nextTurnControlToken=()=>`${t.sessionState.sessionId}:turn-control:${String(r++)}`,i=[],a=[],o=new Set,l=new Set,u=createSessionCommandInbox(),h=sessionCommandHookToken(t.sessionState.sessionId);await u.claimStable(h),await u.claimAuthorization(`${t.sessionState.sessionId}:auth`);let _=t.sessionTimeoutDeadline===void 0?void 0:createSessionTimeoutControl({deadline:t.sessionTimeoutDeadline,token:h}),v=new SessionStateCursor({serializedContext:t.serializedContext,sessionState:t.sessionState}),y,runTurn=async e=>{let n=t.crashCleanupState.caller;n?.taskId!==void 0&&(l.add(n.taskId),await notifyTaskTurnStartedStep({caller:n,childSessionId:v.sessionState.sessionId,childTurnId:activeTurnId(v.sessionState.emissionState)}));let r=await bindTurnCallerContextStep({caller:n,serializedContext:v.serializedContext}),s=await dispatchAndAwaitTurn({bufferedDeliveries:i,bufferedSessionControls:a,cancelledTaskIds:o,capabilities:t.capabilities,commandInbox:u,controlToken:nextTurnControlToken(),delivery:e,mode:t.mode,parentWritable:t.driverWritable,serializedContext:r,seenTaskDeliveries:l,sessionState:v.sessionState});return await y?.(),y=s.dispose,v.adoptState(s.action),t.crashCleanupState.lastSessionState=v.sessionState,s.action};try{if(t.sessionState.continuationToken)try{await u.rekeyContinuation(t.sessionState.continuationToken)}catch(e){if(!isHookConflictError(e))throw e;return{kind:`result`,result:{output:``}}}await _?.start();let e=await runTurn(t.initialInput);for(;;){if(e.kind===`done`)return{kind:`result`,result:await finalizeDone({action:e,caller:t.crashCleanupState.caller,mode:t.mode})};if(e.kind!==`park`)throw Error(`Driver received unexpected turn action "${e.kind}".`);if(e.cancelled===!0){let e=await settleCancelledTurnStep({parentWritable:t.driverWritable,serializedContext:v.serializedContext,sessionState:v.sessionState});v.adoptState(e);let n={caller:t.crashCleanupState.caller,sessionId:v.sessionState.sessionId};await notifyCancelledTaskCallerStep(e.usage===void 0?n:{...n,usage:e.usage}),t.crashCleanupState.lastSessionState=v.sessionState}v.sessionState.continuationToken&&await u.rekeyContinuation(v.sessionState.continuationToken);let n=e.settled;e.cancelled!==!0&&n!==void 0?(await notifyTurnCallerStep({caller:t.crashCleanupState.caller,lifecycle:`parked`,sessionId:v.sessionState.sessionId,settled:n}),t.crashCleanupState.caller=void 0):e.cancelled===!0&&(t.crashCleanupState.caller=void 0);let r=await nextParkedActivity({expectedAttemptIds:e.authorizationAttemptIds??[]});if(t.crashCleanupState.lastSessionState=v.sessionState,r.kind===`authorization-resume`){e=await runTurn({kind:`deliver`,payloads:r.payloads});continue}if(r.kind===`expired`)return{kind:`expired`,serializedContext:v.serializedContext,sessionState:v.sessionState};if(r.kind===`reset`)return await terminateChildSessionsStep({serializedContext:v.serializedContext,sessionState:v.sessionState}),{kind:`result`,result:{output:``}};if(r.kind===`clear`||r.kind===`compact`){e=await runTurn({kind:r.kind});continue}if(r.kind===`closed`)return await terminateChildSessionsStep({serializedContext:v.serializedContext,sessionState:v.sessionState}),{kind:`result`,result:{output:``}};if(r.kind===`cancel-turn`){await cancelDescendantTurnsStep({serializedContext:v.serializedContext,sessionState:v.sessionState});let n=await settleCancelledTurnStep({parentWritable:t.driverWritable,serializedContext:v.serializedContext,sessionState:v.sessionState});v.adoptState(n),e={...e,settled:void 0},t.crashCleanupState.caller=void 0,t.crashCleanupState.lastSessionState=v.sessionState;continue}r.delivery.caller!==void 0&&(t.crashCleanupState.caller=r.delivery.caller),e=await runTurn(r.delivery)}}finally{await y?.(),await _?.dispose(),await u.dispose()}}async function finalizeExpiredSession(e){return await terminateChildSessionsStep({serializedContext:e.serializedContext,sessionState:e.sessionState}),await emitTerminalSessionCompletionStep({parentWritable:e.driverWritable,serializedContext:e.serializedContext}),e.mode===`task`?(await fireSessionCallbackStep({output:``,serializedContext:e.serializedContext,status:`completed`}),await notifyDelegatedParentStep({result:createDelegatedSubagentSuccessResult(e.serializedContext,``),serializedContext:e.serializedContext})):await notifyTurnCallerStep({caller:e.caller,lifecycle:`terminal`,sessionId:e.sessionState.sessionId,settled:{output:``}}),{output:``}}async function finalizeDone(e){let{output:t,serializedContext:n}=e.action,r=e.action.isError===!0;if(await terminateChildSessionsStep({serializedContext:n,sessionState:e.action.sessionState}),e.mode===`task`)await fireSessionCallbackStep({error:r?t:void 0,output:r?void 0:t,serializedContext:n,status:r?`failed`:`completed`,usage:e.action.usage}),await notifyDelegatedParentStep({result:r?createDelegatedSubagentErrorResult(n,t):createDelegatedSubagentSuccessResult(n,t),serializedContext:n,usage:e.action.usage});else{let n={output:t,usage:e.action.usageDelta};r&&(n.isError=!0),await notifyTurnCallerStep({caller:e.caller,lifecycle:`terminal`,sessionId:e.action.sessionState.sessionId,settled:n})}return{output:t}}export{workflowEntry};
|
|
1
|
+
import{sessionCommandHookToken}from"#execution/session-command-token.js";import{getWorkflowMetadata,getWritable}from"#compiled/@workflow/core/index.js";import{isHookConflictError}from"#execution/hook-ownership.js";import{isTaskOwnedSerializedContext}from"#execution/tasks/child/instructions.js";import{readSerializedSubagentDepth}from"#harness/subagent-depth.js";import{readChannelRequestId,readRootSessionId}from"#execution/eve-workflow-attributes.js";import{activeTurnId}from"#harness/active-turn-id.js";import{fireSessionCallbackStep}from"#execution/session-callback-step.js";import{normalizeSerializableError}from"#execution/workflow-errors.js";import{SessionStateCursor}from"#execution/session-state-cursor.js";import{cancelDescendantTurnsStep}from"#execution/cancel-descendant-turns-step.js";import{bindTurnCallerContextStep,notifyCancelledTaskCallerStep,notifyDelegatedParentStep,notifyTaskTurnStartedStep,notifyTurnCallerStep,resolveInitialTurnCallerStep}from"#execution/delegated-parent-notification.js";import{createDelegatedSubagentErrorResult,createDelegatedSubagentSuccessResult}from"#execution/delegated-parent-result.js";import{nextTurnDelivery}from"#execution/parked-delivery-wait.js";import{dispatchAndAwaitTurn}from"#execution/turn-dispatch.js";import{createSessionStep}from"#execution/create-session-step.js";import{settleCancelledTurnStep}from"#execution/settle-cancelled-turn-step.js";import{emitTerminalSessionFailureStep}from"#execution/terminal-session-failure-step.js";import{createSessionCommandInbox}from"#execution/session-command-inbox.js";import{DEFAULT_SESSION_TIMEOUT_MS}from"#execution/session-timeout.js";import{emitTerminalSessionCompletionStep}from"#execution/terminal-session-completion-step.js";import{createSessionTimeoutControl}from"#execution/session-timeout-control.js";import{terminateChildSessionsStep}from"#execution/terminate-child-sessions-step.js";async function workflowEntry(e){"use workflow";let{workflowRunId:r,workflowStartedAt:c}=getWorkflowMetadata(),d=e.serializedContext[`eve.continuationToken`]||``,f=e.serializedContext[`eve.mode`],p=e.serializedContext[`eve.capabilities`],m=e.serializedContext[`eve.bundle`];e.serializedContext[`eve.sessionId`]=r;let g=getWritable(),y={caller:void 0,callerResolved:!1,lastSessionState:void 0};try{let t=readRootSessionId(e.serializedContext),n=readSerializedSubagentDepth(e.serializedContext),l=e.serializedContext[`eve.dynamicSubagentAgentConfig`],{state:u}=await createSessionStep({compiledArtifactsSource:m.source,continuationToken:d,dynamicSubagentAgentConfig:l,inheritedLimits:e.limits,nodeId:m.nodeId,outputSchema:e.input.outputSchema,rootSessionId:t,sessionId:r,subagentDepth:n,taskOwned:isTaskOwnedSerializedContext(e.serializedContext)});y.lastSessionState=u,y.caller=await resolveInitialTurnCallerStep({serializedContext:e.serializedContext}),y.callerResolved=!0;let h=await runDriverLoop({capabilities:p,driverWritable:g,initialInput:{deliveryMetadata:e.serializedContext[`eve.channelDelivery`]===void 0?void 0:[{...e.serializedContext[`eve.channelDelivery`],payloadIndex:0}],kind:`deliver`,payloads:[{message:e.input.message,context:e.input.context,outputSchema:e.input.outputSchema}],requestId:readChannelRequestId(e.serializedContext)},crashCleanupState:y,mode:f,serializedContext:e.serializedContext,sessionState:u,sessionTimeoutDeadline:e.sessionTimeoutMs===!1?void 0:new Date(c.getTime()+(e.sessionTimeoutMs??DEFAULT_SESSION_TIMEOUT_MS))});return h.kind===`result`?h.result:await finalizeExpiredSession({caller:y.caller,driverWritable:g,mode:f,serializedContext:h.serializedContext,sessionState:h.sessionState})}catch(t){throw y.lastSessionState!==void 0&&await terminateChildSessionsStep({serializedContext:e.serializedContext,sessionState:y.lastSessionState}),await emitTerminalSessionFailureStep({error:normalizeSerializableError(t),parentWritable:g,serializedContext:e.serializedContext}),f===`task`?(await fireSessionCallbackStep({error:normalizeSerializableError(t),serializedContext:e.serializedContext,status:`failed`}),await notifyDelegatedParentStep({result:createDelegatedSubagentErrorResult(e.serializedContext,t),serializedContext:e.serializedContext})):await notifyTurnCallerStep({caller:await resolveCallerForCrash(y,e.serializedContext),lifecycle:`terminal`,sessionId:r,settled:{isError:!0,output:t}}),createSafeOuterWorkflowError()}}async function resolveCallerForCrash(e,t){if(e.callerResolved)return e.caller;try{return await resolveInitialTurnCallerStep({serializedContext:t})}catch{return}}function createSafeOuterWorkflowError(){let e=Error(`Agent workflow failed. Inspect the private session trace for details.`);return e.name=`EveWorkflowFailure`,e}async function runDriverLoop(t){let n=new Map,nextParkedActivity=async e=>{let r=new Set(e.expectedAttemptIds);for(let e of n.keys())r.has(e)||n.delete(e);for(;;){if(r.size>0&&[...r].every(e=>n.has(e))){let e=[...r].map(e=>n.get(e));return n.clear(),{kind:`authorization-resume`,payloads:e}}let e=await nextTurnDelivery({awaitAuthorizationCallbacks:r.size>0,bufferedDeliveries:a,bufferedSessionControls:o,cancelledTaskIds:s,commandInbox:u,deferDeliveries:t.mode===`task`&&r.size>0,driverWritable:t.driverWritable,seenTaskDeliveries:l,stateCursor:v});if(e.kind!==`authorization`)return e;for(let t of e.payloads){let e=t.authorizationCallback;typeof e?.attemptId==`string`&&r.has(e.attemptId)&&!n.has(e.attemptId)&&n.set(e.attemptId,t)}if(e.closed){let e=[...n.values()];return n.clear(),{kind:`authorization-resume`,payloads:e}}}},i=0,nextTurnControlToken=()=>`${t.sessionState.sessionId}:turn-control:${String(i++)}`,a=[],o=[],s=new Set,l=new Set,u=createSessionCommandInbox(),h=sessionCommandHookToken(t.sessionState.sessionId);await u.claimStable(h),await u.claimAuthorization(`${t.sessionState.sessionId}:auth`);let _=t.sessionTimeoutDeadline===void 0?void 0:createSessionTimeoutControl({deadline:t.sessionTimeoutDeadline,token:h}),v=new SessionStateCursor({serializedContext:t.serializedContext,sessionState:t.sessionState}),y,runTurn=async e=>{let n=t.crashCleanupState.caller;n?.taskId!==void 0&&(l.add(n.taskId),await notifyTaskTurnStartedStep({caller:n,childSessionId:v.sessionState.sessionId,childTurnId:activeTurnId(v.sessionState.emissionState)}));let r=await bindTurnCallerContextStep({caller:n,serializedContext:v.serializedContext}),i=await dispatchAndAwaitTurn({bufferedDeliveries:a,bufferedSessionControls:o,cancelledTaskIds:s,capabilities:t.capabilities,commandInbox:u,controlToken:nextTurnControlToken(),delivery:e,mode:t.mode,parentWritable:t.driverWritable,serializedContext:r,seenTaskDeliveries:l,sessionState:v.sessionState});return await y?.(),y=i.dispose,v.adoptState(i.action),t.crashCleanupState.lastSessionState=v.sessionState,i.action};try{if(t.sessionState.continuationToken)try{await u.rekeyContinuation(t.sessionState.continuationToken)}catch(e){if(!isHookConflictError(e))throw e;return{kind:`result`,result:{output:``}}}await _?.start();let e=await runTurn(t.initialInput);for(;;){if(e.kind===`done`)return{kind:`result`,result:await finalizeDone({action:e,caller:t.crashCleanupState.caller,mode:t.mode})};if(e.kind!==`park`)throw Error(`Driver received unexpected turn action "${e.kind}".`);if(e.cancelled===!0){let e=await settleCancelledTurnStep({parentWritable:t.driverWritable,serializedContext:v.serializedContext,sessionState:v.sessionState});v.adoptState(e);let n={caller:t.crashCleanupState.caller,sessionId:v.sessionState.sessionId};await notifyCancelledTaskCallerStep(e.usage===void 0?n:{...n,usage:e.usage}),t.crashCleanupState.lastSessionState=v.sessionState}v.sessionState.continuationToken&&await u.rekeyContinuation(v.sessionState.continuationToken);let n=e.settled;e.cancelled!==!0&&n!==void 0?(await notifyTurnCallerStep({caller:t.crashCleanupState.caller,lifecycle:`parked`,sessionId:v.sessionState.sessionId,settled:n}),t.crashCleanupState.caller=void 0):e.cancelled===!0&&(t.crashCleanupState.caller=void 0);let r=await nextParkedActivity({expectedAttemptIds:e.authorizationAttemptIds??[]});if(t.crashCleanupState.lastSessionState=v.sessionState,r.kind===`authorization-resume`){e=await runTurn({kind:`deliver`,payloads:r.payloads});continue}if(r.kind===`expired`)return{kind:`expired`,serializedContext:v.serializedContext,sessionState:v.sessionState};if(r.kind===`reset`)return await terminateChildSessionsStep({serializedContext:v.serializedContext,sessionState:v.sessionState}),{kind:`result`,result:{output:``}};if(r.kind===`clear`||r.kind===`compact`){e=await runTurn({kind:r.kind});continue}if(r.kind===`closed`)return await terminateChildSessionsStep({serializedContext:v.serializedContext,sessionState:v.sessionState}),{kind:`result`,result:{output:``}};if(r.kind===`cancel-turn`){await cancelDescendantTurnsStep({serializedContext:v.serializedContext,sessionState:v.sessionState});let n=await settleCancelledTurnStep({parentWritable:t.driverWritable,serializedContext:v.serializedContext,sessionState:v.sessionState});v.adoptState(n),e={...e,settled:void 0},t.crashCleanupState.caller=void 0,t.crashCleanupState.lastSessionState=v.sessionState;continue}r.delivery.caller!==void 0&&(t.crashCleanupState.caller=r.delivery.caller),e=await runTurn(r.delivery)}}finally{await y?.(),await _?.dispose(),await u.dispose()}}async function finalizeExpiredSession(e){return await terminateChildSessionsStep({serializedContext:e.serializedContext,sessionState:e.sessionState}),await emitTerminalSessionCompletionStep({parentWritable:e.driverWritable,serializedContext:e.serializedContext}),e.mode===`task`?(await fireSessionCallbackStep({output:``,serializedContext:e.serializedContext,status:`completed`}),await notifyDelegatedParentStep({result:createDelegatedSubagentSuccessResult(e.serializedContext,``),serializedContext:e.serializedContext})):await notifyTurnCallerStep({caller:e.caller,lifecycle:`terminal`,sessionId:e.sessionState.sessionId,settled:{output:``}}),{output:``}}async function finalizeDone(e){let{output:t,serializedContext:n}=e.action,r=e.action.isError===!0;if(await terminateChildSessionsStep({serializedContext:n,sessionState:e.action.sessionState}),e.mode===`task`)await fireSessionCallbackStep({error:r?t:void 0,output:r?void 0:t,serializedContext:n,status:r?`failed`:`completed`,usage:e.action.usage}),await notifyDelegatedParentStep({result:r?createDelegatedSubagentErrorResult(n,t):createDelegatedSubagentSuccessResult(n,t),serializedContext:n,usage:e.action.usage});else{let n={output:t,usage:e.action.usageDelta};r&&(n.isError=!0),await notifyTurnCallerStep({caller:e.caller,lifecycle:`terminal`,sessionId:e.action.sessionState.sessionId,settled:n})}return{output:t}}export{workflowEntry};
|
|
@@ -44,6 +44,10 @@ export declare const sessionTimeoutWorkflowReference: {
|
|
|
44
44
|
export declare const taskRunWorkflowReference: {
|
|
45
45
|
workflowId: string;
|
|
46
46
|
};
|
|
47
|
+
/** Stable workflow reference for root-session activity collectors. */
|
|
48
|
+
export declare const activityCollectorWorkflowReference: {
|
|
49
|
+
workflowId: string;
|
|
50
|
+
};
|
|
47
51
|
/**
|
|
48
52
|
* Creates a workflow-backed runtime whose long-lived driver owns the
|
|
49
53
|
* event stream and dispatches each turn as a child workflow run.
|