eve 0.60.0 → 0.60.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 +6 -0
- package/dist/src/compiled/.vendor-stamp.json +1 -1
- package/dist/src/compiler/extension-compatibility.d.ts +2 -2
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/execution/coordination-dispatch-shared.d.ts +2 -0
- package/dist/src/execution/coordination-dispatch-shared.js +1 -1
- package/dist/src/execution/coordination-dispatch-step.js +1 -1
- package/dist/src/execution/dynamic-workflow/tool.js +1 -1
- package/dist/src/execution/tasks/parent/tool-execution.js +1 -1
- package/dist/src/execution/tools/agent-router-workflow.d.ts +5 -0
- package/dist/src/execution/tools/agent-router-workflow.js +1 -0
- package/dist/src/execution/tools/agent-router.d.ts +9 -0
- package/dist/src/execution/tools/agent-router.js +1 -0
- package/dist/src/execution/tools/sleep-workflow.js +1 -1
- package/dist/src/execution/tools/subagent/metadata.d.ts +4 -0
- package/dist/src/execution/tools/subagent/metadata.js +1 -0
- package/dist/src/execution/tools/workflow/body.d.ts +3 -0
- package/dist/src/execution/tools/workflow/body.js +1 -1
- package/dist/src/execution/tools/workflow/start.d.ts +1 -0
- package/dist/src/execution/tools/workflow/start.js +1 -1
- package/dist/src/execution/tools/workflow/types.d.ts +2 -0
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/public/tools/agent-router.d.ts +1 -0
- package/dist/src/public/tools/agent-router.js +1 -0
- package/dist/src/public/tools/index.d.ts +1 -1
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/tools/provided/agent-router.d.ts +7 -0
- package/dist/src/tools/provided/agent-router.js +1 -0
- package/dist/src/tools/workflow-definition.d.ts +6 -1
- package/docs/guides/evaluate.md +1 -1
- package/docs/reference/typescript-api.md +3 -1
- package/docs/tools/workflows.mdx +87 -4
- package/package.json +6 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# eve
|
|
2
2
|
|
|
3
|
+
## 0.60.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 76d4dd8: Workflow tools can read effective declared-subagent descriptions from `ctx.agents`, including subagents hidden from the parent model. Export `agentRouter()` from `eve/tools/agent-router` to route each task across that complete map with JEV and invoke the selected agent.
|
|
8
|
+
|
|
3
9
|
## 0.60.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"zod": "4.5.4",
|
|
56
56
|
"zod-validation-error": "5.0.0"
|
|
57
57
|
},
|
|
58
|
-
"scriptHash": "
|
|
58
|
+
"scriptHash": "0ea0d04153546a7f75f6eeca7cd503ba507d4704ee695ee2b40f309bec6fa49d",
|
|
59
59
|
"toolVersions": {
|
|
60
60
|
"rolldown": "1.2.8",
|
|
61
61
|
"typescript": "7.0.2"
|
|
@@ -11,8 +11,8 @@ declare const EXTENSION_CAPABILITY_CONTRACTS: {
|
|
|
11
11
|
readonly dropped: {};
|
|
12
12
|
};
|
|
13
13
|
readonly tool: {
|
|
14
|
-
readonly current:
|
|
15
|
-
readonly supported: readonly [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 28, 29, 30, 31, 32, 34, 35, 44, 45, 46, 49];
|
|
14
|
+
readonly current: 50;
|
|
15
|
+
readonly supported: readonly [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 28, 29, 30, 31, 32, 34, 35, 44, 45, 46, 49, 50];
|
|
16
16
|
readonly dropped: {
|
|
17
17
|
readonly 14: "TaskExec.delegated was removed; migrate to workflow-backed background tools";
|
|
18
18
|
readonly 15: "TaskExec replaces stageEffect with send";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readFile,writeFile}from"node:fs/promises";import{z}from"#compiled/zod/index.js";import{join}from"node:path";import{formatValidationError}from"#runtime/validation.js";const EXTENSION_COMPATIBILITY_MANIFEST_KIND=`eve-extension`,EXTENSION_COMPATIBILITY_MANIFEST_FORMAT_VERSION=2,EXTENSION_COMPATIBILITY_MANIFEST_FILENAME=`_manifest.json`,EXTENSION_CAPABILITY_CONTRACTS={extension:{current:1,supported:[1],dropped:{}},tool:{current:49,supported:[1,2,3,4,5,6,7,8,9,10,11,12,13,28,29,30,31,32,34,35,44,45,46,49],dropped:{14:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,15:`TaskExec replaces stageEffect with send`,16:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,17:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,18:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,19:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,20:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,21:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,22:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,23:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,24:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,25:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,26:`Background tools now use task yield descriptors`,27:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,33:`ctx.agent now accepts the subagent name as its first argument, derives invocation identity internally, and infers structured output types`,36:`experimental_workflow and eve/tools/workflow were removed; migrate to the workflow factory from eve/tools/workflow`,37:`experimental_workflow and eve/tools/workflow were removed; migrate to the workflow factory from eve/tools/workflow`,38:`experimental_workflow and eve/tools/workflow were removed; migrate to the workflow factory from eve/tools/workflow`,39:`experimental_workflow and eve/tools/workflow were removed; migrate to the workflow factory from eve/tools/workflow`,40:`runWorkflowProgram was made internal; use the workflow factory from eve/tools/workflow`,41:`workflow no longer accepts agents and its options argument is optional; use workflow() or workflow({ maxSubagents })`,42:`Legacy session history migration was removed; user-role messages require current provenance kinds.`,43:`Legacy session history migration was removed; user-role messages require current provenance kinds.`,47:`eve/experimental/evaluate was removed; import evaluate from eve/ai`,48:`eve/experimental/evaluate was removed; import evaluate from eve/ai`}},dynamicTool:{current:48,supported:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,22,28,29,30,31,32,33,41,48],dropped:{21:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`,23:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,24:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,25:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,26:`Background tools now use task yield descriptors`,27:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,34:`Legacy session history migration was removed; user-role messages require current provenance kinds.`,35:`workflowMaxSubagents was removed with experimental_workflow; configure generated-program limits with the workflow factory`,36:`workflowMaxSubagents was removed with experimental_workflow; configure generated-program limits with the workflow factory`,37:`workflowMaxSubagents was removed with experimental_workflow; configure generated-program limits with the workflow factory`,38:`workflowMaxSubagents was removed with experimental_workflow; configure generated-program limits with the workflow factory`,39:`Legacy session history migration was removed; user-role messages require current provenance kinds.`,40:`Legacy session history migration was removed; user-role messages require current provenance kinds.`,42:`autoModel and eve/experimental/evaluate were removed; import auto from eve/models`,43:`autoModel and eve/experimental/evaluate were removed; import auto from eve/models`,44:`autoModel and eve/experimental/evaluate were removed; import auto from eve/models`,45:`autoModel and eve/experimental/evaluate were removed; import auto from eve/models`,46:`autoModel and eve/experimental/evaluate were removed; import auto from eve/models`,47:`autoModel and eve/experimental/evaluate were removed; import auto from eve/models`}},channel:{current:25,supported:[1,2,3,4,5,6,7,8,9,10,11,13,14,15,16,17,18,23,24,25],dropped:{12:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`,19:`Continuation rekey was removed; channel extensions must use additive continuation.alias instead.`,20:`Continuation rekey was removed; channel extensions must use additive continuation.alias instead.`,21:`Continuation rekey was removed; channel extensions must use additive continuation.alias instead.`,22:`Continuation rekey was removed; channel extensions must use additive continuation.alias instead.`}},schedule:{current:13,supported:[1,2,3,4,6,7,8,9,10,11,12,13],dropped:{5:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`}},subagent:{current:17,supported:[3,4,6,7,8,9,10,11,12,13,14,15,16,17],dropped:{1:`Persistent subagent sessions are now the default and the experimental opt-in was removed`,2:`Persistent subagent sessions are now the default and the experimental opt-in was removed`,5:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`}},connection:{current:22,supported:[1,2,3,4,5,6,7,8,11,12,13,14,15,16,17,18,19,20,21,22],dropped:{9:`Dynamic connection resolvers no longer receive conversation or channel continuation data`,10:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`}},hook:{current:23,supported:[10,11,12,13,14,15,17,18,19,20,21,22,23],dropped:{1:`Model identity moved from session.started runtime metadata to step.started call attribution.`,2:`Model identity moved from session.started runtime metadata to step.started call attribution.`,3:`Model identity moved from session.started runtime metadata to step.started call attribution.`,4:`Model identity moved from session.started runtime metadata to step.started call attribution.`,5:`Model identity moved from session.started runtime metadata to step.started call attribution.`,6:`Model identity moved from session.started runtime metadata to step.started call attribution.`,7:`Model identity moved from session.started runtime metadata to step.started call attribution.`,8:`Model identity moved from session.started runtime metadata to step.started call attribution.`,9:`Model identity moved from session.started runtime metadata to step.started call attribution.`,16:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`}},skill:{current:1,supported:[1],dropped:{}},dynamicSkill:{current:20,supported:[1,2,3,4,5,6,7,8,9,10,11,12,14,15,16,17,18,19,20],dropped:{13:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`}},instructions:{current:2,supported:[1,2],dropped:{}},dynamicInstructions:{current:21,supported:[1,2,3,4,5,6,7,8,9,10,11,12,13,15,16,17,18,19,20,21],dropped:{14:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`}},config:{current:1,supported:[1],dropped:{}},state:{current:6,supported:[1,2,3,4,5,6],dropped:{}}},EXTENSION_CAPABILITY_VERSIONS=Object.fromEntries(Object.entries(EXTENSION_CAPABILITY_CONTRACTS).map(([e,t])=>[e,t.current])),EXTENSION_CAPABILITY_SUPPORT=Object.keys(EXTENSION_CAPABILITY_CONTRACTS).reduce((e,t)=>(e[t]=EXTENSION_CAPABILITY_CONTRACTS[t].supported,e),{}),extensionCompatibilityManifestV1Schema=z.object({kind:z.literal(EXTENSION_COMPATIBILITY_MANIFEST_KIND),formatVersion:z.literal(1),builtWithEve:z.string().min(1),requires:z.record(z.string(),z.number().int().positive())}).strict(),extensionCompatibilityManifestV2Schema=extensionCompatibilityManifestV1Schema.extend({formatVersion:z.literal(2),build:z.object({externalDependencies:z.array(z.string().min(1)).readonly()}).strict().optional()}),extensionCompatibilityManifestSchema=z.union([extensionCompatibilityManifestV1Schema,extensionCompatibilityManifestV2Schema]);function serializeExtensionCompatibilityManifest(e){return`${JSON.stringify(e,null,2)}\n`}function parseExtensionCompatibilityManifest(e,t){let n;try{n=JSON.parse(e)}catch(e){throw Error(`Extension compatibility manifest "${t}" is not valid JSON: ${e instanceof Error?e.message:String(e)}`)}let r=extensionCompatibilityManifestSchema.safeParse(n);if(!r.success)throw Error(`Extension compatibility manifest "${t}" is invalid. ${formatValidationError(r.error)}`);return r.data}async function readExtensionCompatibilityManifest(e){return parseExtensionCompatibilityManifest(await readFile(e,`utf8`),e)}async function writeExtensionCompatibilityManifest(e,t){await writeFile(join(e,EXTENSION_COMPATIBILITY_MANIFEST_FILENAME),serializeExtensionCompatibilityManifest(t),`utf8`)}function findUnsupportedExtensionCapabilities(e,t=EXTENSION_CAPABILITY_SUPPORT){return Object.entries(e.requires).flatMap(([e,n])=>{let r=Object.hasOwn(t,e)?t[e]??[]:[];return r.includes(n)?[]:[{capability:e,requiredVersion:n,supportedVersions:r}]}).sort((e,t)=>e.capability.localeCompare(t.capability))}export{EXTENSION_CAPABILITY_SUPPORT,EXTENSION_CAPABILITY_VERSIONS,EXTENSION_COMPATIBILITY_MANIFEST_FILENAME,EXTENSION_COMPATIBILITY_MANIFEST_FORMAT_VERSION,EXTENSION_COMPATIBILITY_MANIFEST_KIND,findUnsupportedExtensionCapabilities,parseExtensionCompatibilityManifest,readExtensionCompatibilityManifest,serializeExtensionCompatibilityManifest,writeExtensionCompatibilityManifest};
|
|
1
|
+
import{readFile,writeFile}from"node:fs/promises";import{z}from"#compiled/zod/index.js";import{join}from"node:path";import{formatValidationError}from"#runtime/validation.js";const EXTENSION_COMPATIBILITY_MANIFEST_KIND=`eve-extension`,EXTENSION_COMPATIBILITY_MANIFEST_FORMAT_VERSION=2,EXTENSION_COMPATIBILITY_MANIFEST_FILENAME=`_manifest.json`,EXTENSION_CAPABILITY_CONTRACTS={extension:{current:1,supported:[1],dropped:{}},tool:{current:50,supported:[1,2,3,4,5,6,7,8,9,10,11,12,13,28,29,30,31,32,34,35,44,45,46,49,50],dropped:{14:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,15:`TaskExec replaces stageEffect with send`,16:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,17:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,18:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,19:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,20:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,21:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,22:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,23:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,24:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,25:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,26:`Background tools now use task yield descriptors`,27:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,33:`ctx.agent now accepts the subagent name as its first argument, derives invocation identity internally, and infers structured output types`,36:`experimental_workflow and eve/tools/workflow were removed; migrate to the workflow factory from eve/tools/workflow`,37:`experimental_workflow and eve/tools/workflow were removed; migrate to the workflow factory from eve/tools/workflow`,38:`experimental_workflow and eve/tools/workflow were removed; migrate to the workflow factory from eve/tools/workflow`,39:`experimental_workflow and eve/tools/workflow were removed; migrate to the workflow factory from eve/tools/workflow`,40:`runWorkflowProgram was made internal; use the workflow factory from eve/tools/workflow`,41:`workflow no longer accepts agents and its options argument is optional; use workflow() or workflow({ maxSubagents })`,42:`Legacy session history migration was removed; user-role messages require current provenance kinds.`,43:`Legacy session history migration was removed; user-role messages require current provenance kinds.`,47:`eve/experimental/evaluate was removed; import evaluate from eve/ai`,48:`eve/experimental/evaluate was removed; import evaluate from eve/ai`}},dynamicTool:{current:48,supported:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,22,28,29,30,31,32,33,41,48],dropped:{21:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`,23:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,24:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,25:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,26:`Background tools now use task yield descriptors`,27:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,34:`Legacy session history migration was removed; user-role messages require current provenance kinds.`,35:`workflowMaxSubagents was removed with experimental_workflow; configure generated-program limits with the workflow factory`,36:`workflowMaxSubagents was removed with experimental_workflow; configure generated-program limits with the workflow factory`,37:`workflowMaxSubagents was removed with experimental_workflow; configure generated-program limits with the workflow factory`,38:`workflowMaxSubagents was removed with experimental_workflow; configure generated-program limits with the workflow factory`,39:`Legacy session history migration was removed; user-role messages require current provenance kinds.`,40:`Legacy session history migration was removed; user-role messages require current provenance kinds.`,42:`autoModel and eve/experimental/evaluate were removed; import auto from eve/models`,43:`autoModel and eve/experimental/evaluate were removed; import auto from eve/models`,44:`autoModel and eve/experimental/evaluate were removed; import auto from eve/models`,45:`autoModel and eve/experimental/evaluate were removed; import auto from eve/models`,46:`autoModel and eve/experimental/evaluate were removed; import auto from eve/models`,47:`autoModel and eve/experimental/evaluate were removed; import auto from eve/models`}},channel:{current:25,supported:[1,2,3,4,5,6,7,8,9,10,11,13,14,15,16,17,18,23,24,25],dropped:{12:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`,19:`Continuation rekey was removed; channel extensions must use additive continuation.alias instead.`,20:`Continuation rekey was removed; channel extensions must use additive continuation.alias instead.`,21:`Continuation rekey was removed; channel extensions must use additive continuation.alias instead.`,22:`Continuation rekey was removed; channel extensions must use additive continuation.alias instead.`}},schedule:{current:13,supported:[1,2,3,4,6,7,8,9,10,11,12,13],dropped:{5:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`}},subagent:{current:17,supported:[3,4,6,7,8,9,10,11,12,13,14,15,16,17],dropped:{1:`Persistent subagent sessions are now the default and the experimental opt-in was removed`,2:`Persistent subagent sessions are now the default and the experimental opt-in was removed`,5:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`}},connection:{current:22,supported:[1,2,3,4,5,6,7,8,11,12,13,14,15,16,17,18,19,20,21,22],dropped:{9:`Dynamic connection resolvers no longer receive conversation or channel continuation data`,10:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`}},hook:{current:23,supported:[10,11,12,13,14,15,17,18,19,20,21,22,23],dropped:{1:`Model identity moved from session.started runtime metadata to step.started call attribution.`,2:`Model identity moved from session.started runtime metadata to step.started call attribution.`,3:`Model identity moved from session.started runtime metadata to step.started call attribution.`,4:`Model identity moved from session.started runtime metadata to step.started call attribution.`,5:`Model identity moved from session.started runtime metadata to step.started call attribution.`,6:`Model identity moved from session.started runtime metadata to step.started call attribution.`,7:`Model identity moved from session.started runtime metadata to step.started call attribution.`,8:`Model identity moved from session.started runtime metadata to step.started call attribution.`,9:`Model identity moved from session.started runtime metadata to step.started call attribution.`,16:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`}},skill:{current:1,supported:[1],dropped:{}},dynamicSkill:{current:20,supported:[1,2,3,4,5,6,7,8,9,10,11,12,14,15,16,17,18,19,20],dropped:{13:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`}},instructions:{current:2,supported:[1,2],dropped:{}},dynamicInstructions:{current:21,supported:[1,2,3,4,5,6,7,8,9,10,11,12,13,15,16,17,18,19,20,21],dropped:{14:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`}},config:{current:1,supported:[1],dropped:{}},state:{current:6,supported:[1,2,3,4,5,6],dropped:{}}},EXTENSION_CAPABILITY_VERSIONS=Object.fromEntries(Object.entries(EXTENSION_CAPABILITY_CONTRACTS).map(([e,t])=>[e,t.current])),EXTENSION_CAPABILITY_SUPPORT=Object.keys(EXTENSION_CAPABILITY_CONTRACTS).reduce((e,t)=>(e[t]=EXTENSION_CAPABILITY_CONTRACTS[t].supported,e),{}),extensionCompatibilityManifestV1Schema=z.object({kind:z.literal(EXTENSION_COMPATIBILITY_MANIFEST_KIND),formatVersion:z.literal(1),builtWithEve:z.string().min(1),requires:z.record(z.string(),z.number().int().positive())}).strict(),extensionCompatibilityManifestV2Schema=extensionCompatibilityManifestV1Schema.extend({formatVersion:z.literal(2),build:z.object({externalDependencies:z.array(z.string().min(1)).readonly()}).strict().optional()}),extensionCompatibilityManifestSchema=z.union([extensionCompatibilityManifestV1Schema,extensionCompatibilityManifestV2Schema]);function serializeExtensionCompatibilityManifest(e){return`${JSON.stringify(e,null,2)}\n`}function parseExtensionCompatibilityManifest(e,t){let n;try{n=JSON.parse(e)}catch(e){throw Error(`Extension compatibility manifest "${t}" is not valid JSON: ${e instanceof Error?e.message:String(e)}`)}let r=extensionCompatibilityManifestSchema.safeParse(n);if(!r.success)throw Error(`Extension compatibility manifest "${t}" is invalid. ${formatValidationError(r.error)}`);return r.data}async function readExtensionCompatibilityManifest(e){return parseExtensionCompatibilityManifest(await readFile(e,`utf8`),e)}async function writeExtensionCompatibilityManifest(e,t){await writeFile(join(e,EXTENSION_COMPATIBILITY_MANIFEST_FILENAME),serializeExtensionCompatibilityManifest(t),`utf8`)}function findUnsupportedExtensionCapabilities(e,t=EXTENSION_CAPABILITY_SUPPORT){return Object.entries(e.requires).flatMap(([e,n])=>{let r=Object.hasOwn(t,e)?t[e]??[]:[];return r.includes(n)?[]:[{capability:e,requiredVersion:n,supportedVersions:r}]}).sort((e,t)=>e.capability.localeCompare(t.capability))}export{EXTENSION_CAPABILITY_SUPPORT,EXTENSION_CAPABILITY_VERSIONS,EXTENSION_COMPATIBILITY_MANIFEST_FILENAME,EXTENSION_COMPATIBILITY_MANIFEST_FORMAT_VERSION,EXTENSION_COMPATIBILITY_MANIFEST_KIND,findUnsupportedExtensionCapabilities,parseExtensionCompatibilityManifest,readExtensionCompatibilityManifest,serializeExtensionCompatibilityManifest,writeExtensionCompatibilityManifest};
|
|
@@ -11,6 +11,7 @@ import type { SessionParent } from "#channel/types.js";
|
|
|
11
11
|
import { type DurableSessionState, readDurableSession } from "#execution/durable-session-store.js";
|
|
12
12
|
import { buildSubagentRunInput } from "#subagents/tool.js";
|
|
13
13
|
import type { WorkflowToolRunOwner } from "#execution/tools/workflow/messages.js";
|
|
14
|
+
import type { WorkflowAgentMetadata } from "#tools/workflow-definition.js";
|
|
14
15
|
export type DispatchPlanEntry = {
|
|
15
16
|
readonly kind: "task-control";
|
|
16
17
|
readonly action: RuntimeToolCallActionRequest;
|
|
@@ -60,6 +61,7 @@ export interface PreparedCoordinationDispatch<PlanEntry = DispatchPlanEntry> {
|
|
|
60
61
|
readonly plan: readonly PlanEntry[];
|
|
61
62
|
readonly session: RuntimeSession;
|
|
62
63
|
readonly sessionState: DurableSessionState;
|
|
64
|
+
readonly workflowAgents: Readonly<Record<string, WorkflowAgentMetadata>>;
|
|
63
65
|
}
|
|
64
66
|
/**
|
|
65
67
|
* Runs every dispatch precondition that may throw — durable reads, context
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ConversationContextKey}from"#shared/conversation-context.js";import"#channel/adapter.js";import"#context/container.js";import{ActivityObserverKey,AuthKey,CapabilitiesKey,ChannelInstrumentationKey,InitiatorAuthKey,LocalDevRequestKey,ParentSessionKey,SandboxKey}from"#context/keys.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{deriveRootTurnActivityWorkId}from"#execution/activity-work-id.js";import{deserializeContext}from"#context/serialize.js";import{createDurableSessionState,readDurableSession}from"#execution/durable-session-store.js";import{getAgentHandleStore}from"#subagents/handles/store.js";import{resolveEffectiveAgentRuntime}from"#execution/effective-agent-config.js";import{hydrateDurableSession}from"#execution/session.js";import{isTaskControlAction}from"#execution/tasks/parent/dispatch.js";import{buildAdapterContext}from"#channel/adapter-context.js";import{withContextScope}from"#context/run-step.js";import{assertUniqueCoordinationCallIds,getPendingCoordinationBatch,setPendingCoordinationBatch}from"#harness/coordination.js";import{activeTurnId}from"#harness/active-turn-id.js";import"#subagents/tool.js";async function prepareCoordinationDispatch(e){let t=readDurableSession(e.sessionState),n=getPendingCoordinationBatch(t.state);if(n===void 0)return;let r=[...n.runtimeActions,...n.tasks];if(r.length===0)return;let i=n.event.turnId||activeTurnId(e.sessionState.emissionState),a=n.event.turnId===i?n.event:{...n.event,turnId:i},o=await deserializeContext(e.serializedContext),s=await prepareActionDispatch({batch:{event:a,localFanoutSize:n.localFanoutSize,requests:r},ctx:o,durableSession:t,plan:()=>planDispatch({requests:r}),serializedContext:e.serializedContext});if(a===n.event)return{...s,sessionState:e.sessionState};let c=setPendingCoordinationBatch({...n,event:a,session:s.session});return{...s,session:c,sessionState:createDurableSessionState({session:c})}}async function prepareActionDispatch(e){let{batch:t,durableSession:n}=e;assertUniqueCoordinationCallIds(t.requests);let r=e.ctx,i=r.require(BundleKey),a=resolveEffectiveAgentRuntime(i,r),o=hydrateDurableSession({compactionOverrides:{thresholdPercent:a.thresholdPercent},durable:n,turnAgent:a.turnAgent}),s=r.require(ChannelKey);getAgentHandleStore(n.state);let c=e.plan({bundle:i,ctx:r,requests:t.requests,session:o}),l=resolveActiveSandboxSessionId(s.state,o.sessionId);if(e.planSharesSandbox?.({bundle:i,plan:c})===!0)try{o=(await withContextScope(r,o,async e=>(await r.require(SandboxKey).get(),{result:void 0,session:e}))).session}finally{r.clearVirtualContext()}return{adapter:s,adapterCtx:buildAdapterContext(s,r),auth:r.get(AuthKey)??null,batch:t,bundle:i,capabilities:r.get(CapabilitiesKey),channelMetadata:r.get(ChannelInstrumentationKey),inheritedConversation:r.get(ConversationContextKey),fanoutSize:e.fanoutSize??t.localFanoutSize??0,initiatorAuth:r.get(InitiatorAuthKey)??null,localDevRequest:r.get(LocalDevRequestKey),parentSession:r.get(ParentSessionKey),plan:c,activityObserver:resolvePreparedActivity(r.get(ActivityObserverKey),o,t.event.turnId),sandboxSessionId:l,serializedContext:e.serializedContext,session:o}}function resolvePreparedActivity(e,t,n){if(e!==void 0)return{sink:e.sink,workIdentity:e.workIdentity??{id:deriveRootTurnActivityWorkId({sessionId:t.sessionId,turnId:n}),kind:`root-turn`,rootSessionId:t.rootSessionId??t.sessionId,rootTurnId:n,sessionId:t.sessionId,turnId:n}}}function resolveActiveSandboxSessionId(e,t){if(typeof e!=`object`||!e)return t;let n=e.sandboxSessionId;return typeof n==`string`&&n.length>0?n:t}function planDispatch(e){return e.requests.map(e=>{if(e.kind===`tool-call`){if(!isTaskControlAction(e))throw Error(`Unsupported task control "${e.toolName}".`);return{action:e,kind:`task-control`}}if(e.kind===`workflow-task`)return{kind:`workflow-task`,task:e};throw Error(`Unsupported coordination request "${String(e.kind)}".`)})}export{prepareActionDispatch,prepareCoordinationDispatch};
|
|
1
|
+
import{ConversationContextKey}from"#shared/conversation-context.js";import"#channel/adapter.js";import"#context/container.js";import{ActivityObserverKey,AuthKey,CapabilitiesKey,ChannelInstrumentationKey,InitiatorAuthKey,LocalDevRequestKey,ParentSessionKey,SandboxKey}from"#context/keys.js";import{BundleKey,ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{deriveRootTurnActivityWorkId}from"#execution/activity-work-id.js";import{deserializeContext}from"#context/serialize.js";import{createDurableSessionState,readDurableSession}from"#execution/durable-session-store.js";import{getAgentHandleStore}from"#subagents/handles/store.js";import{resolveEffectiveAgentRuntime}from"#execution/effective-agent-config.js";import{hydrateDurableSession}from"#execution/session.js";import{isTaskControlAction}from"#execution/tasks/parent/dispatch.js";import{buildAdapterContext}from"#channel/adapter-context.js";import{withContextScope}from"#context/run-step.js";import{assertUniqueCoordinationCallIds,getPendingCoordinationBatch,setPendingCoordinationBatch}from"#harness/coordination.js";import{activeTurnId}from"#harness/active-turn-id.js";import"#subagents/tool.js";import{resolveWorkflowAgentMetadata}from"#execution/tools/subagent/metadata.js";async function prepareCoordinationDispatch(e){let t=readDurableSession(e.sessionState),n=getPendingCoordinationBatch(t.state);if(n===void 0)return;let r=[...n.runtimeActions,...n.tasks];if(r.length===0)return;let i=n.event.turnId||activeTurnId(e.sessionState.emissionState),a=n.event.turnId===i?n.event:{...n.event,turnId:i},o=await deserializeContext(e.serializedContext),s=await prepareActionDispatch({batch:{event:a,localFanoutSize:n.localFanoutSize,requests:r},ctx:o,durableSession:t,plan:()=>planDispatch({requests:r}),serializedContext:e.serializedContext});if(a===n.event)return{...s,sessionState:e.sessionState};let c=setPendingCoordinationBatch({...n,event:a,session:s.session});return{...s,session:c,sessionState:createDurableSessionState({session:c})}}async function prepareActionDispatch(e){let{batch:t,durableSession:n}=e;assertUniqueCoordinationCallIds(t.requests);let r=e.ctx,i=r.require(BundleKey),a=resolveEffectiveAgentRuntime(i,r),o=hydrateDurableSession({compactionOverrides:{thresholdPercent:a.thresholdPercent},durable:n,turnAgent:a.turnAgent}),s=r.require(ChannelKey);getAgentHandleStore(n.state);let c=e.plan({bundle:i,ctx:r,requests:t.requests,session:o}),l=resolveActiveSandboxSessionId(s.state,o.sessionId);if(e.planSharesSandbox?.({bundle:i,plan:c})===!0)try{o=(await withContextScope(r,o,async e=>(await r.require(SandboxKey).get(),{result:void 0,session:e}))).session}finally{r.clearVirtualContext()}return{adapter:s,adapterCtx:buildAdapterContext(s,r),auth:r.get(AuthKey)??null,batch:t,bundle:i,capabilities:r.get(CapabilitiesKey),channelMetadata:r.get(ChannelInstrumentationKey),inheritedConversation:r.get(ConversationContextKey),fanoutSize:e.fanoutSize??t.localFanoutSize??0,initiatorAuth:r.get(InitiatorAuthKey)??null,localDevRequest:r.get(LocalDevRequestKey),parentSession:r.get(ParentSessionKey),plan:c,activityObserver:resolvePreparedActivity(r.get(ActivityObserverKey),o,t.event.turnId),sandboxSessionId:l,serializedContext:e.serializedContext,session:o,workflowAgents:resolveWorkflowAgentMetadata(r)}}function resolvePreparedActivity(e,t,n){if(e!==void 0)return{sink:e.sink,workIdentity:e.workIdentity??{id:deriveRootTurnActivityWorkId({sessionId:t.sessionId,turnId:n}),kind:`root-turn`,rootSessionId:t.rootSessionId??t.sessionId,rootTurnId:n,sessionId:t.sessionId,turnId:n}}}function resolveActiveSandboxSessionId(e,t){if(typeof e!=`object`||!e)return t;let n=e.sandboxSessionId;return typeof n==`string`&&n.length>0?n:t}function planDispatch(e){return e.requests.map(e=>{if(e.kind===`tool-call`){if(!isTaskControlAction(e))throw Error(`Unsupported task control "${e.toolName}".`);return{action:e,kind:`task-control`}}if(e.kind===`workflow-task`)return{kind:`workflow-task`,task:e};throw Error(`Unsupported coordination request "${String(e.kind)}".`)})}export{prepareActionDispatch,prepareCoordinationDispatch};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createDurableSessionState}from"#execution/durable-session-store.js";import{executeTaskControlAction}from"#execution/tasks/parent/dispatch.js";import{cancelBackgroundAgentTask}from"#execution/tools/subagent/task-cancel.js";import{prepareCoordinationDispatch}from"#execution/coordination-dispatch-shared.js";import{startWorkflowTask}from"#execution/tools/workflow/start.js";async function dispatchCoordinationStep(e){"use step";let t=await prepareCoordinationDispatch({serializedContext:e.serializedContext,sessionState:e.sessionState});if(t===void 0)return{results:[],sessionState:e.sessionState,pendingTasks:[]};let{batch:n,session:r}=t,i=r,a=[],o=[];for(let r of t.plan){if(r.kind===`workflow-task`){let o=await startWorkflowTask({auth:t.auth,batchEvent:n.event,initiatorAuth:t.initiatorAuth,owner:e.workflowToolRunOwner,parentSession:t.parentSession,session:i,task:r.task});i=o.session,o.result!==void 0&&a.push(o.result);continue}if(r.kind===`task-control`){let e=await executeTaskControlAction({action:r.action,cancelOwnedWork:cancelBackgroundAgentTask,serializedContext:t.serializedContext,session:i});i=e.session,e.pendingTask!==void 0&&o.push(e.pendingTask),a.push(e.result)}}return{results:a,sessionState:i===r?t.sessionState:createDurableSessionState({session:i}),pendingTasks:o}}export{dispatchCoordinationStep};
|
|
1
|
+
import{createDurableSessionState}from"#execution/durable-session-store.js";import{executeTaskControlAction}from"#execution/tasks/parent/dispatch.js";import{cancelBackgroundAgentTask}from"#execution/tools/subagent/task-cancel.js";import{prepareCoordinationDispatch}from"#execution/coordination-dispatch-shared.js";import{startWorkflowTask}from"#execution/tools/workflow/start.js";async function dispatchCoordinationStep(e){"use step";let t=await prepareCoordinationDispatch({serializedContext:e.serializedContext,sessionState:e.sessionState});if(t===void 0)return{results:[],sessionState:e.sessionState,pendingTasks:[]};let{batch:n,session:r}=t,i=r,a=[],o=[];for(let r of t.plan){if(r.kind===`workflow-task`){let o=await startWorkflowTask({agents:t.workflowAgents,auth:t.auth,batchEvent:n.event,initiatorAuth:t.initiatorAuth,owner:e.workflowToolRunOwner,parentSession:t.parentSession,session:i,task:r.task});i=o.session,o.result!==void 0&&a.push(o.result);continue}if(r.kind===`task-control`){let e=await executeTaskControlAction({action:r.action,cancelOwnedWork:cancelBackgroundAgentTask,serializedContext:t.serializedContext,session:i});i=e.session,e.pendingTask!==void 0&&o.push(e.pendingTask),a.push(e.result)}}return{results:a,sessionState:i===r?t.sessionState:createDurableSessionState({session:i}),pendingTasks:o}}export{dispatchCoordinationStep};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{runJsProgram}from"#execution/dynamic-workflow/workflow.js";async function executeWorkflowProgram(e,t){"use workflow";return runJsProgram(e.js,t,{maxSubagents:e.maxSubagents??0})}executeWorkflowProgram.workflowId=`workflow//eve@0.60.
|
|
1
|
+
import{runJsProgram}from"#execution/dynamic-workflow/workflow.js";async function executeWorkflowProgram(e,t){"use workflow";return runJsProgram(e.js,t,{maxSubagents:e.maxSubagents??0})}executeWorkflowProgram.workflowId=`workflow//eve@0.60.1//executeWorkflowProgram`;export{executeWorkflowProgram};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{sessionCommandHookToken}from"#execution/session-inbox/address.js";import{loadContext}from"#context/container.js";import{ActivityObserverKey}from"#context/keys.js";import{parseJsonValue}from"#shared/json.js";import{buildCallbackContext}from"#context/build-callback-context.js";import{parseWorkflowToolInput}from"#execution/tools/workflow/background.js";import{getHarnessEmissionState}from"#harness/emission.js";import{deriveAgentOperationId}from"#subagents/handles/operation-id.js";import{getAgentHandleStore,writeHandles}from"#subagents/handles/store.js";import{findSessionTaskEntry,recordSessionTask}from"#tasks/session-index.js";import{runStep}from"#context/run-step.js";import{activeTurnId}from"#harness/active-turn-id.js";import{AGENT_BUSY,AGENT_MISMATCH,AGENT_UNREACHABLE,formatAgentBusyMessage}from"#subagents/agent-handle-errors.js";import{sendTaskCommand,sendTaskInboundPayload,startTaskRun,waitForTaskCommandOwner}from"#execution/tasks/parent/run-parent.js";import{isAuthorizationSignal}from"#harness/authorization.js";import{isTurnCancellation}from"#harness/turn-cancellation.js";import{beginBackgroundTask,createTaskAgentDispatchContext,prepareBackgroundTask,rejectDelegatedDispatch}from"#execution/tasks/parent/delegate.js";import{applyTaskAgentHandleCommand}from"#subagents/handles/transitions.js";import{BackgroundToolExecutorKey}from"#harness/background-tools.js";import{deriveBackgroundTaskActivityObserver}from"#execution/activity-work.js";import{isAsyncIterable}from"#shared/async-iterable.js";import{projectToolStartLabel}from"#harness/action-presentation.js";import{createTaskMessage,isTaskMessage}from"#tools/task.js";import{projectSubagentTask}from"#execution/tasks/parent/subagent-task-projection.js";import{steerBackgroundAgent}from"#execution/tools/subagent/steer.js";const IN_PROCESS_WORKFLOW_EXECUTOR={data:{},kind:`workflow-task`};function runBackgroundStep(e,t,n){return runStep(e,t,n,[backgroundToolExecutionProvider])}const backgroundToolExecutionProvider={key:BackgroundToolExecutorKey,create(e,t){return{value:new BackgroundToolExecutionScope(t)}},async commit(e,t){return await requireExecutionScope(e).commit(t)},async rollback(e,t){await requireExecutionScope(e).rollback(t)},decorateStepResult(e,t){return requireExecutionScope(e).decorate(t)}};function readRetainedBackgroundToolResult(e){let t=e.get(BackgroundToolExecutorKey);return t instanceof BackgroundToolExecutionScope?t.retainedResult():void 0}var BackgroundToolExecutionScope=class{executions=new Map;records=[];agentHandleSession;agentHandlesChanged=!1;retained=!1;initialSession;constructor(e){this.initialSession=e,this.agentHandleSession=e}execute(e){let t=this.executions.get(e.options.toolCallId);if(t!==void 0)return t;if(!e.batch.calls.some(t=>t.callId===e.options.toolCallId))throw Error(`Background tool call "${e.options.toolCallId}" was not registered before execution.`);let n=this.start(e);return this.executions.set(e.options.toolCallId,n),n}async readAgentViews(){return(getAgentHandleStore(this.agentHandleSession.state)?.handles??[]).flatMap(e=>e.phase===`reserved`?[]:e.phase===`available`?[{availability:`available`,id:e.identity.id,name:e.identity.name}]:e.phase===`claimed`?[{availability:`busy`,id:e.identity.id,name:e.identity.name,taskId:e.ownerId,taskStatus:`working`}]:[])}hasPendingTasks(){return this.records.some(e=>e.settled&&e.task!==void 0)}async commit(e){let t=this.records.filter(e=>!e.settled);return t.length>0&&await this.compensate(t,Error(`Background tool execution did not delegate or complete its task.`)),this.apply(e)}decorate(e){let t=this.resultFields();return t===void 0?e:{...e,...t}}async rollback(e){let t=this.records.filter(e=>e.settled),n=this.records.filter(e=>!e.settled);if(n.length>0&&await this.compensate(n,e),t.length===0){this.retained=this.agentHandlesChanged&&isTurnCancellation(e);return}if(isTurnCancellation(e)){this.retained=!0;return}await this.compensate(t,e)}retainedResult(){return this.retained?this.resultFields():void 0}apply(e){let t=e;for(let e of this.records)e.settled&&e.task!==void 0&&(t=recordSessionTask(t,e.task));return this.agentHandlesChanged&&(t=writeHandles(t,getAgentHandleStore(this.agentHandleSession.state)?.handles??[])),t}resultFields(){let e=this.records.flatMap(e=>e.settled&&e.task!==void 0?[{callId:e.callId,taskInboxToken:e.task.taskInboxToken,taskId:e.task.taskId,taskRunId:e.task.taskRunId}]:[]);if(e.length!==0||this.agentHandlesChanged)return{backgroundTaskSession:this.apply(this.initialSession),backgroundTasks:e}}async start(e){let t={callId:e.options.toolCallId,settled:!1};this.records.push(t);let n=getHarnessEmissionState(this.initialSession.state),r=loadContext(),i=await this.startTask({ctx:r,emission:n,input:e,record:t});if(i.kind===`steered`)return t.settled=!0,i.receipt;let a=i.task;t.task=a;let o={binding:{taskId:a.taskId,token:a.taskInboxToken},postMessage:createTaskMessage,send(){throw Error(`task.send() was replaced by yielded task descriptors.`)},session:this.initialSession,task:a,taskId:a.taskId};if(e.definition.workflowId!==void 0)return t.settled=!0,{...i.receipt,status:`working`,taskId:a.taskId};let s=e.definition.execute(e.toolInput,e.options,o),c=isAsyncIterable(s)?await executeBackgroundIterable({callId:e.options.toolCallId,output:s,task:a}):await s;return isAuthorizationSignal(c)?c:(await deliverTaskCommand(a,{data:parseJsonValue(c),kind:`complete`}),t.settled=!0,{status:`working`,taskId:a.taskId})}async startTask(e){let t=e.input.definition.workflowId===void 0?void 0:{...e.input.definition,workflowId:e.input.definition.workflowId},n=t===void 0?void 0:parseWorkflowToolInput(e.input.toolInput,e.input.definition.name),r=activeTurnId(e.emission),i=t?.resultKind===`subagent`&&n!==void 0?projectSubagentTask({ctx:e.ctx,input:n,name:e.input.definition.name,nodeId:t.nodeId??e.input.definition.name,taskInput:{callId:e.input.options.toolCallId,parentSessionId:this.initialSession.sessionId,parentTurnId:r}}):void 0;if(i!==void 0&&i.identity===void 0&&!hasAgentHandle(this.agentHandleSession,i.metadata.agentId)){let{agentId:a,...o}=n;n=o,i=projectSubagentTask({ctx:e.ctx,input:o,name:e.input.definition.name,nodeId:t.nodeId??e.input.definition.name,taskInput:{callId:e.input.options.toolCallId,parentSessionId:this.initialSession.sessionId,parentTurnId:r}})}let a=i?.metadata??{kind:`tool`,name:e.input.definition.name},o=projectToolStartLabel(e.input.definition,e.input.toolInput),s=buildCallbackContext().session,c={activityObserver:deriveBackgroundTaskActivityObserver({activityObserver:e.ctx.get(ActivityObserverKey),callId:e.input.options.toolCallId,label:o,name:a.name,parentSessionId:this.initialSession.sessionId,parentTurnId:r,rootSessionId:this.initialSession.rootSessionId??this.initialSession.sessionId}),callId:e.input.options.toolCallId,dispatchContext:createTaskAgentDispatchContext(e.ctx,s.auth),metadata:a,parentSessionId:this.initialSession.sessionId,parentStepIndex:e.emission.stepIndex,parentTurnId:r,session:this.initialSession};if(t===void 0)return{kind:`started`,task:await beginBackgroundTask({activityObserver:c.activityObserver,callId:c.callId,dispatchContext:c.dispatchContext,metadata:c.metadata,parentSessionId:c.parentSessionId,parentStepIndex:c.parentStepIndex,parentTurnId:c.parentTurnId,session:c.session})};if(n===void 0)throw Error(`Background workflow tool "${e.input.definition.name}" has no input.`);let l={...prepareBackgroundTask(c),activityWorkIdentity:t.resultKind===`subagent`?c.activityObserver?.workIdentity:void 0};if(t.resultKind===`subagent`&&i!==void 0&&i.identity!==void 0){let t=i.identity;if(this.applyAgentHandleCommand({identity:t.identity,callId:c.callId,kind:`reserve`,operationId:t.operation.id,ownerId:l.taskId}).kind!==`ready`)throw Error(`Agent handle store rejected start operation "${t.operation.id}".`);e.record.reservation={agentId:t.identity.id,operationId:t.operation.id}}if(t.resultKind===`subagent`&&i!==void 0&&i.identity===void 0){let t=deriveAgentOperationId({callId:c.callId,parentSessionId:c.parentSessionId,parentTurnId:r}),a=this.applyAgentHandleCommand({agentId:i.metadata.agentId,callId:c.callId,expectedTarget:i.metadata.mode,invokedName:i.metadata.name,kind:`claim`,operationId:t,ownerId:l.taskId});if(a.kind===`busy`&&a.handle.phase===`claimed`){let t=a.handle,r=findSessionTaskEntry(this.agentHandleSession.state,t.ownerId);if(r?.metadata.kind===`subagent`&&r.metadata.agentId===t.identity.id&&r.metadata.name===t.identity.name&&r.terminalView===void 0)return await steerBackgroundAgent({ctx:e.ctx,handle:t,callId:c.callId,input:n,session:this.agentHandleSession}),{kind:`steered`,receipt:{agentId:t.identity.id,taskId:r.taskId,status:`working`}}}readClaimedHandle(a)?e.record.claim={operationId:t,taskId:l.taskId}:throwAgentClaimError(i.metadata.agentId,a)}await startTaskRun({activityObserver:c.activityObserver,initialView:{metadata:l.metadata,status:`working`,taskId:l.taskId},parentContinuationToken:sessionCommandHookToken(this.initialSession.sessionId),taskInboxToken:l.taskInboxToken,workflow:{callId:c.callId,executeInput:t.executeInput?.(n),input:n,resultKind:t.resultKind,session:s,stepIndex:e.emission.stepIndex,toolName:e.input.definition.name,taskId:l.taskId,workflowId:t.workflowId}});let u=await waitForTaskCommandOwner({taskInboxToken:l.taskInboxToken}),d={...l,executor:IN_PROCESS_WORKFLOW_EXECUTOR,taskRunId:u.runId};return e.record.task=d,t.resultKind!==`subagent`||i===void 0?{kind:`started`,task:d}:{kind:`started`,receipt:i.receipt,task:d}}applyAgentHandleCommand(e){let t=applyTaskAgentHandleCommand(this.agentHandleSession,e);return t.session!==this.agentHandleSession&&(this.agentHandleSession=t.session,this.agentHandlesChanged=!0),t.result}async compensate(e,t){let n=[];for(let r of e.toReversed()){if(r.task!==void 0)try{await rejectDelegatedDispatch({error:{code:`PARENT_STEP_FAILED`,message:t instanceof Error?t.message:String(t)},task:r.task})}catch(e){n.push(e)}r.claim!==void 0&&this.applyAgentHandleCommand({kind:`release-owner`,ownerId:r.claim.taskId}),r.reservation!==void 0&&r.task!==void 0&&this.applyAgentHandleCommand({agentId:r.reservation.agentId,kind:`remove`,ownerId:r.task.taskId})}if(n.length>0)throw AggregateError([t,...n],`Background tool execution failed and its tasks could not all be rejected.`,{cause:t})}};async function executeBackgroundIterable(e){let t=e.output[Symbol.asyncIterator](),n=0,r=await t.next();for(;!r.done;){let i=isTaskMessage(r.value)?{callId:e.callId,kind:`task-message`,message:r.value.message,messageEpoch:e.task.taskId,messageIndex:n++}:{callId:e.callId,kind:`task-update`,message:typeof r.value==`string`?r.value:JSON.stringify(r.value),updateEpoch:e.task.taskId,updateIndex:n++};if(await sendTaskInboundPayload({payload:i,taskInboxToken:e.task.taskInboxToken})!==`delivered`)throw Error(`Task run "${e.task.taskId}" did not accept "${i.kind}".`);r=await t.next()}return r.value??null}function hasAgentHandle(e,t){return getAgentHandleStore(e.state)?.handles.some(e=>e.identity.id===t)===!0}function requireExecutionScope(e){if(!(e instanceof BackgroundToolExecutionScope))throw Error(`The background tool executor is not owned by the task runtime.`);return e}async function deliverTaskCommand(e,t){if(await sendTaskCommand({command:t,taskInboxToken:e.taskInboxToken})!==`delivered`)throw Error(`Task run "${e.taskId}" did not accept "${t.kind}".`)}function readClaimedHandle(e){return e.kind===`ready`&&e.handle?.phase===`claimed`}function throwAgentClaimError(e,t){throw t.kind===`mismatch`?Error(JSON.stringify({code:AGENT_MISMATCH,message:`Agent "${e}" no longer matches this subagent definition. Start a new agent instead.`})):t.kind===`busy`?Error(JSON.stringify({code:AGENT_BUSY,message:formatAgentBusyMessage({agentId:e,agentName:t.handle.identity.name,ownerId:`ownerId`in t.handle?t.handle.ownerId:void 0})})):Error(JSON.stringify({code:AGENT_UNREACHABLE,message:`Agent with id "${e}" is no longer reachable.`}))}export{backgroundToolExecutionProvider,readRetainedBackgroundToolResult,runBackgroundStep};
|
|
1
|
+
import{sessionCommandHookToken}from"#execution/session-inbox/address.js";import{loadContext}from"#context/container.js";import{ActivityObserverKey}from"#context/keys.js";import{parseJsonValue}from"#shared/json.js";import{buildCallbackContext}from"#context/build-callback-context.js";import{parseWorkflowToolInput}from"#execution/tools/workflow/background.js";import{getHarnessEmissionState}from"#harness/emission.js";import{deriveAgentOperationId}from"#subagents/handles/operation-id.js";import{getAgentHandleStore,writeHandles}from"#subagents/handles/store.js";import{findSessionTaskEntry,recordSessionTask}from"#tasks/session-index.js";import{runStep}from"#context/run-step.js";import{activeTurnId}from"#harness/active-turn-id.js";import{resolveWorkflowAgentMetadata}from"#execution/tools/subagent/metadata.js";import{AGENT_BUSY,AGENT_MISMATCH,AGENT_UNREACHABLE,formatAgentBusyMessage}from"#subagents/agent-handle-errors.js";import{sendTaskCommand,sendTaskInboundPayload,startTaskRun,waitForTaskCommandOwner}from"#execution/tasks/parent/run-parent.js";import{isAuthorizationSignal}from"#harness/authorization.js";import{isTurnCancellation}from"#harness/turn-cancellation.js";import{beginBackgroundTask,createTaskAgentDispatchContext,prepareBackgroundTask,rejectDelegatedDispatch}from"#execution/tasks/parent/delegate.js";import{applyTaskAgentHandleCommand}from"#subagents/handles/transitions.js";import{BackgroundToolExecutorKey}from"#harness/background-tools.js";import{deriveBackgroundTaskActivityObserver}from"#execution/activity-work.js";import{isAsyncIterable}from"#shared/async-iterable.js";import{projectToolStartLabel}from"#harness/action-presentation.js";import{createTaskMessage,isTaskMessage}from"#tools/task.js";import{projectSubagentTask}from"#execution/tasks/parent/subagent-task-projection.js";import{steerBackgroundAgent}from"#execution/tools/subagent/steer.js";const IN_PROCESS_WORKFLOW_EXECUTOR={data:{},kind:`workflow-task`};function runBackgroundStep(e,t,n){return runStep(e,t,n,[backgroundToolExecutionProvider])}const backgroundToolExecutionProvider={key:BackgroundToolExecutorKey,create(e,t){return{value:new BackgroundToolExecutionScope(t)}},async commit(e,t){return await requireExecutionScope(e).commit(t)},async rollback(e,t){await requireExecutionScope(e).rollback(t)},decorateStepResult(e,t){return requireExecutionScope(e).decorate(t)}};function readRetainedBackgroundToolResult(e){let t=e.get(BackgroundToolExecutorKey);return t instanceof BackgroundToolExecutionScope?t.retainedResult():void 0}var BackgroundToolExecutionScope=class{executions=new Map;records=[];agentHandleSession;agentHandlesChanged=!1;retained=!1;initialSession;constructor(e){this.initialSession=e,this.agentHandleSession=e}execute(e){let t=this.executions.get(e.options.toolCallId);if(t!==void 0)return t;if(!e.batch.calls.some(t=>t.callId===e.options.toolCallId))throw Error(`Background tool call "${e.options.toolCallId}" was not registered before execution.`);let n=this.start(e);return this.executions.set(e.options.toolCallId,n),n}async readAgentViews(){return(getAgentHandleStore(this.agentHandleSession.state)?.handles??[]).flatMap(e=>e.phase===`reserved`?[]:e.phase===`available`?[{availability:`available`,id:e.identity.id,name:e.identity.name}]:e.phase===`claimed`?[{availability:`busy`,id:e.identity.id,name:e.identity.name,taskId:e.ownerId,taskStatus:`working`}]:[])}hasPendingTasks(){return this.records.some(e=>e.settled&&e.task!==void 0)}async commit(e){let t=this.records.filter(e=>!e.settled);return t.length>0&&await this.compensate(t,Error(`Background tool execution did not delegate or complete its task.`)),this.apply(e)}decorate(e){let t=this.resultFields();return t===void 0?e:{...e,...t}}async rollback(e){let t=this.records.filter(e=>e.settled),n=this.records.filter(e=>!e.settled);if(n.length>0&&await this.compensate(n,e),t.length===0){this.retained=this.agentHandlesChanged&&isTurnCancellation(e);return}if(isTurnCancellation(e)){this.retained=!0;return}await this.compensate(t,e)}retainedResult(){return this.retained?this.resultFields():void 0}apply(e){let t=e;for(let e of this.records)e.settled&&e.task!==void 0&&(t=recordSessionTask(t,e.task));return this.agentHandlesChanged&&(t=writeHandles(t,getAgentHandleStore(this.agentHandleSession.state)?.handles??[])),t}resultFields(){let e=this.records.flatMap(e=>e.settled&&e.task!==void 0?[{callId:e.callId,taskInboxToken:e.task.taskInboxToken,taskId:e.task.taskId,taskRunId:e.task.taskRunId}]:[]);if(e.length!==0||this.agentHandlesChanged)return{backgroundTaskSession:this.apply(this.initialSession),backgroundTasks:e}}async start(e){let t={callId:e.options.toolCallId,settled:!1};this.records.push(t);let n=getHarnessEmissionState(this.initialSession.state),r=loadContext(),i=await this.startTask({ctx:r,emission:n,input:e,record:t});if(i.kind===`steered`)return t.settled=!0,i.receipt;let a=i.task;t.task=a;let o={binding:{taskId:a.taskId,token:a.taskInboxToken},postMessage:createTaskMessage,send(){throw Error(`task.send() was replaced by yielded task descriptors.`)},session:this.initialSession,task:a,taskId:a.taskId};if(e.definition.workflowId!==void 0)return t.settled=!0,{...i.receipt,status:`working`,taskId:a.taskId};let s=e.definition.execute(e.toolInput,e.options,o),c=isAsyncIterable(s)?await executeBackgroundIterable({callId:e.options.toolCallId,output:s,task:a}):await s;return isAuthorizationSignal(c)?c:(await deliverTaskCommand(a,{data:parseJsonValue(c),kind:`complete`}),t.settled=!0,{status:`working`,taskId:a.taskId})}async startTask(e){let t=e.input.definition.workflowId===void 0?void 0:{...e.input.definition,workflowId:e.input.definition.workflowId},n=t===void 0?void 0:parseWorkflowToolInput(e.input.toolInput,e.input.definition.name),r=activeTurnId(e.emission),i=t?.resultKind===`subagent`&&n!==void 0?projectSubagentTask({ctx:e.ctx,input:n,name:e.input.definition.name,nodeId:t.nodeId??e.input.definition.name,taskInput:{callId:e.input.options.toolCallId,parentSessionId:this.initialSession.sessionId,parentTurnId:r}}):void 0;if(i!==void 0&&i.identity===void 0&&!hasAgentHandle(this.agentHandleSession,i.metadata.agentId)){let{agentId:a,...o}=n;n=o,i=projectSubagentTask({ctx:e.ctx,input:o,name:e.input.definition.name,nodeId:t.nodeId??e.input.definition.name,taskInput:{callId:e.input.options.toolCallId,parentSessionId:this.initialSession.sessionId,parentTurnId:r}})}let a=i?.metadata??{kind:`tool`,name:e.input.definition.name},o=projectToolStartLabel(e.input.definition,e.input.toolInput),s=buildCallbackContext().session,c={activityObserver:deriveBackgroundTaskActivityObserver({activityObserver:e.ctx.get(ActivityObserverKey),callId:e.input.options.toolCallId,label:o,name:a.name,parentSessionId:this.initialSession.sessionId,parentTurnId:r,rootSessionId:this.initialSession.rootSessionId??this.initialSession.sessionId}),callId:e.input.options.toolCallId,dispatchContext:createTaskAgentDispatchContext(e.ctx,s.auth),metadata:a,parentSessionId:this.initialSession.sessionId,parentStepIndex:e.emission.stepIndex,parentTurnId:r,session:this.initialSession};if(t===void 0)return{kind:`started`,task:await beginBackgroundTask({activityObserver:c.activityObserver,callId:c.callId,dispatchContext:c.dispatchContext,metadata:c.metadata,parentSessionId:c.parentSessionId,parentStepIndex:c.parentStepIndex,parentTurnId:c.parentTurnId,session:c.session})};if(n===void 0)throw Error(`Background workflow tool "${e.input.definition.name}" has no input.`);let l={...prepareBackgroundTask(c),activityWorkIdentity:t.resultKind===`subagent`?c.activityObserver?.workIdentity:void 0};if(t.resultKind===`subagent`&&i!==void 0&&i.identity!==void 0){let t=i.identity;if(this.applyAgentHandleCommand({identity:t.identity,callId:c.callId,kind:`reserve`,operationId:t.operation.id,ownerId:l.taskId}).kind!==`ready`)throw Error(`Agent handle store rejected start operation "${t.operation.id}".`);e.record.reservation={agentId:t.identity.id,operationId:t.operation.id}}if(t.resultKind===`subagent`&&i!==void 0&&i.identity===void 0){let t=deriveAgentOperationId({callId:c.callId,parentSessionId:c.parentSessionId,parentTurnId:r}),a=this.applyAgentHandleCommand({agentId:i.metadata.agentId,callId:c.callId,expectedTarget:i.metadata.mode,invokedName:i.metadata.name,kind:`claim`,operationId:t,ownerId:l.taskId});if(a.kind===`busy`&&a.handle.phase===`claimed`){let t=a.handle,r=findSessionTaskEntry(this.agentHandleSession.state,t.ownerId);if(r?.metadata.kind===`subagent`&&r.metadata.agentId===t.identity.id&&r.metadata.name===t.identity.name&&r.terminalView===void 0)return await steerBackgroundAgent({ctx:e.ctx,handle:t,callId:c.callId,input:n,session:this.agentHandleSession}),{kind:`steered`,receipt:{agentId:t.identity.id,taskId:r.taskId,status:`working`}}}readClaimedHandle(a)?e.record.claim={operationId:t,taskId:l.taskId}:throwAgentClaimError(i.metadata.agentId,a)}await startTaskRun({activityObserver:c.activityObserver,initialView:{metadata:l.metadata,status:`working`,taskId:l.taskId},parentContinuationToken:sessionCommandHookToken(this.initialSession.sessionId),taskInboxToken:l.taskInboxToken,workflow:{agents:resolveWorkflowAgentMetadata(e.ctx),callId:c.callId,executeInput:t.executeInput?.(n),input:n,resultKind:t.resultKind,session:s,stepIndex:e.emission.stepIndex,toolName:e.input.definition.name,taskId:l.taskId,workflowId:t.workflowId}});let u=await waitForTaskCommandOwner({taskInboxToken:l.taskInboxToken}),d={...l,executor:IN_PROCESS_WORKFLOW_EXECUTOR,taskRunId:u.runId};return e.record.task=d,t.resultKind!==`subagent`||i===void 0?{kind:`started`,task:d}:{kind:`started`,receipt:i.receipt,task:d}}applyAgentHandleCommand(e){let t=applyTaskAgentHandleCommand(this.agentHandleSession,e);return t.session!==this.agentHandleSession&&(this.agentHandleSession=t.session,this.agentHandlesChanged=!0),t.result}async compensate(e,t){let n=[];for(let r of e.toReversed()){if(r.task!==void 0)try{await rejectDelegatedDispatch({error:{code:`PARENT_STEP_FAILED`,message:t instanceof Error?t.message:String(t)},task:r.task})}catch(e){n.push(e)}r.claim!==void 0&&this.applyAgentHandleCommand({kind:`release-owner`,ownerId:r.claim.taskId}),r.reservation!==void 0&&r.task!==void 0&&this.applyAgentHandleCommand({agentId:r.reservation.agentId,kind:`remove`,ownerId:r.task.taskId})}if(n.length>0)throw AggregateError([t,...n],`Background tool execution failed and its tasks could not all be rejected.`,{cause:t})}};async function executeBackgroundIterable(e){let t=e.output[Symbol.asyncIterator](),n=0,r=await t.next();for(;!r.done;){let i=isTaskMessage(r.value)?{callId:e.callId,kind:`task-message`,message:r.value.message,messageEpoch:e.task.taskId,messageIndex:n++}:{callId:e.callId,kind:`task-update`,message:typeof r.value==`string`?r.value:JSON.stringify(r.value),updateEpoch:e.task.taskId,updateIndex:n++};if(await sendTaskInboundPayload({payload:i,taskInboxToken:e.task.taskInboxToken})!==`delivered`)throw Error(`Task run "${e.task.taskId}" did not accept "${i.kind}".`);r=await t.next()}return r.value??null}function hasAgentHandle(e,t){return getAgentHandleStore(e.state)?.handles.some(e=>e.identity.id===t)===!0}function requireExecutionScope(e){if(!(e instanceof BackgroundToolExecutionScope))throw Error(`The background tool executor is not owned by the task runtime.`);return e}async function deliverTaskCommand(e,t){if(await sendTaskCommand({command:t,taskInboxToken:e.taskInboxToken})!==`delivered`)throw Error(`Task run "${e.taskId}" did not accept "${t.kind}".`)}function readClaimedHandle(e){return e.kind===`ready`&&e.handle?.phase===`claimed`}function throwAgentClaimError(e,t){throw t.kind===`mismatch`?Error(JSON.stringify({code:AGENT_MISMATCH,message:`Agent "${e}" no longer matches this subagent definition. Start a new agent instead.`})):t.kind===`busy`?Error(JSON.stringify({code:AGENT_BUSY,message:formatAgentBusyMessage({agentId:e,agentName:t.handle.identity.name,ownerId:`ownerId`in t.handle?t.handle.ownerId:void 0})})):Error(JSON.stringify({code:AGENT_UNREACHABLE,message:`Agent with id "${e}" is no longer reachable.`}))}export{backgroundToolExecutionProvider,readRetainedBackgroundToolResult,runBackgroundStep};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { JsonValue } from "#shared/json.js";
|
|
2
|
+
import type { WorkflowToolContext } from "#tools/workflow-definition.js";
|
|
3
|
+
import type { AgentRouterInput } from "#execution/tools/agent-router.js";
|
|
4
|
+
/** Routes one task through the complete workflow agent metadata snapshot. */
|
|
5
|
+
export declare function executeAgentRouterTool(input: AgentRouterInput, ctx: WorkflowToolContext): Promise<JsonValue>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{evaluate}from"#ai/evaluate.js";async function executeAgentRouterTool(e,t){"use workflow";let n=await chooseTarget(e.message,descriptions(t),t.abortSignal);return t.agent(n,e.outputSchema===void 0?{message:e.message}:{message:e.message,outputSchema:e.outputSchema})}async function chooseTarget(e,t,n){"use step";let r=Object.keys(t);if(r.length===0)throw Error(`agentRouter requires at least one available declared subagent.`);return r.length===1?r[0]:(await evaluate({abortSignal:n,state:{message:e},questions:{route:{type:`choice`,instructions:`Which subagent should handle this task?`,criteria:t}}})).answers.route.choice}function descriptions(e){return Object.fromEntries(Object.entries(e.agents).map(([e,t])=>[e,t.description]))}executeAgentRouterTool.workflowId=`workflow//eve@0.60.1//executeAgentRouterTool`;export{executeAgentRouterTool};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from "#compiled/zod/index.js";
|
|
2
|
+
import type { JsonObject } from "#shared/json.js";
|
|
3
|
+
export { executeAgentRouterTool } from "#execution/tools/agent-router-workflow.js";
|
|
4
|
+
export declare const AGENT_ROUTER_TOOL_DESCRIPTION = "Route a task to the best available subagent based on each subagent's declared description.";
|
|
5
|
+
export interface AgentRouterInput {
|
|
6
|
+
readonly message: string;
|
|
7
|
+
readonly outputSchema?: JsonObject;
|
|
8
|
+
}
|
|
9
|
+
export declare const AGENT_ROUTER_INPUT_SCHEMA: z.ZodType<AgentRouterInput>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{z}from"#compiled/zod/index.js";import{executeAgentRouterTool}from"#execution/tools/agent-router-workflow.js";const AGENT_ROUTER_TOOL_DESCRIPTION=`Route a task to the best available subagent based on each subagent's declared description.`,AGENT_ROUTER_INPUT_SCHEMA=z.strictObject({message:z.string().min(1).describe(`The complete task to send to the selected agent.`),outputSchema:z.record(z.string(),z.json()).describe(`Optional JSON Schema the selected agent's output must match.`).optional()});export{AGENT_ROUTER_INPUT_SCHEMA,AGENT_ROUTER_TOOL_DESCRIPTION,executeAgentRouterTool};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{sleep}from"#compiled/@workflow/core/index.js";async function executeSleepTool(e){"use workflow";return await sleep(Math.ceil(e.seconds*1e3)),{waitedSeconds:e.seconds}}executeSleepTool.workflowId=`workflow//eve@0.60.
|
|
1
|
+
import{sleep}from"#compiled/@workflow/core/index.js";async function executeSleepTool(e){"use workflow";return await sleep(Math.ceil(e.seconds*1e3)),{waitedSeconds:e.seconds}}executeSleepTool.workflowId=`workflow//eve@0.60.1//executeSleepTool`;export{executeSleepTool};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ContextReader } from "#context/key.js";
|
|
2
|
+
import type { WorkflowAgentMetadata } from "#tools/workflow-definition.js";
|
|
3
|
+
/** Snapshots callable agent metadata for one workflow tool run. */
|
|
4
|
+
export declare function resolveWorkflowAgentMetadata(ctx: ContextReader): Readonly<Record<string, WorkflowAgentMetadata>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{SessionDynamicSubagentSelectionsKey,TurnDynamicSubagentSelectionsKey}from"#context/keys.js";import{BundleKey}from"#runtime/sessions/runtime-context-keys.js";function resolveWorkflowAgentMetadata(e){let t=e.get(BundleKey);if(t===void 0)return{};let n=new Map;for(let[e,r]of t.subagentRegistry.subagentsByName??[]){let t=r.definition.description;t!==void 0&&n.set(e,{description:t})}let r=effectiveDynamicSelections(e);for(let e of Object.values(r))e!==null&&n.set(e.prepared.name,{description:e.kind===`subagent`?e.agentConfig.description:e.remoteAgent.description});return Object.fromEntries(n)}function effectiveDynamicSelections(e){return{...e.get(SessionDynamicSubagentSelectionsKey),...e.get(TurnDynamicSubagentSelectionsKey)}}export{resolveWorkflowAgentMetadata};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { SessionContext } from "#context/session-context.js";
|
|
2
|
+
import type { WorkflowToolContext } from "#tools/workflow-definition.js";
|
|
2
3
|
import { type WorkflowToolRunOutcome, type WorkflowToolRunOwner, type WorkflowToolRunRef } from "#execution/tools/workflow/messages.js";
|
|
3
4
|
import type { JsonObject, JsonValue } from "#shared/json.js";
|
|
4
5
|
export interface WorkflowBodyDefinition {
|
|
6
|
+
/** Snapshot added for new runs; absent only when resuming an older durable payload. */
|
|
7
|
+
readonly agents?: WorkflowToolContext["agents"];
|
|
5
8
|
readonly callId: string;
|
|
6
9
|
readonly executeInput?: JsonValue;
|
|
7
10
|
readonly input: JsonObject;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getWorkflowMetadata}from"#compiled/@workflow/core/index.js";import{normalizeSerializableError}from"#execution/workflow-errors.js";import{resumeHookStep}from"#execution/tools/workflow/resume-hook-step.js";import{createTaskMessage}from"#tools/task.js";import{ask,attachWorkflowToolRunContext}from"#execution/tools/workflow/ask.js";import{agent}from"#execution/tools/subagent/invoke-agent.js";import"#execution/tools/workflow/messages.js";import{readRegisteredWorkflow}from"#execution/workflow-registry.js";async function executeWorkflowBody(e,t){let n=createWorkflowBodyRef(e),r=createWorkflowBodyContext(e,t);attachWorkflowToolRunContext(r,{from:n,owner:e.owner});let i=0;try{let t=resolveWorkflowToolExecute(e),a=e.execution===`background`?createWorkflowTaskExec(e):void 0,o=t(e.executeInput??e.input,r,a),s;if(!isAsyncIterable(o))s=await o;else{let t=o[Symbol.asyncIterator](),r,a=await t.next();for(;a.done!==!0;){r=a.value;let o={from:n,update:a.value};await resumeHookStep(e.owner.inbox,{kind:`report`,...o}),i+=1,a=await t.next()}s=a.value??(e.execution===`blocking`?r:void 0)??null}return{outcome:{output:s,status:`completed`},reportCount:i}}catch(e){return t.aborted?{outcome:{reason:t.reason instanceof Error?t.reason.message:String(t.reason??``),status:`cancelled`},reportCount:i}:{outcome:{error:normalizeSerializableError(e),status:`failed`},reportCount:i}}}function createWorkflowBodyRef(e){return{callId:e.callId,execution:e.execution,input:e.input,resultKind:e.resultKind,runId:e.runId??getWorkflowMetadata().workflowRunId,sequence:e.session.turn.sequence,stepIndex:e.stepIndex,toolName:e.toolName,turnId:e.session.turn.id}}function resolveWorkflowToolExecute(e){let t=readRegisteredWorkflow(e.workflowId);if(typeof t!=`function`)throw Error(`Tool "${e.toolName}" is not registered as a workflow in this deployment (${e.workflowId}). The tool was renamed or removed after this run started.`);return t}function createWorkflowBodyContext(e,t){let unavailable=(t,n)=>{throw Error(`ctx.${t} is not available inside a workflow tool; ${n}. Tool "${e.toolName}" runs as a durable workflow body, which only replays deterministic code.`)},n={agent:((e,t)=>agent(n,e,t)),ask:e=>ask(n,e),abortSignal:t,callId:e.callId,getSandbox:()=>unavailable(`getSandbox()`,`the session sandbox belongs to the turn`),getSkill:()=>unavailable(`getSkill()`,`skills are read through the session sandbox`),getToken:()=>unavailable(`getToken()`,`pass ctx directly to a "use step" helper to resolve credentials`),requireAuth:()=>unavailable(`requireAuth()`,`pass ctx directly to a "use step" helper to request authorization`),session:e.session,toolName:e.toolName};return n}function createWorkflowTaskExec(e){if(e.taskId===void 0)throw Error(`Background workflow tool "${e.toolName}" has no task id.`);return{binding:{taskId:e.taskId,token:e.taskId},postMessage:createTaskMessage,send(){throw Error(`task.send() was replaced by yielded task descriptors.`)},session:void 0,task:void 0,taskId:e.taskId}}function isAsyncIterable(e){return typeof e==`object`&&!!e&&typeof e[Symbol.asyncIterator]==`function`}export{createWorkflowBodyRef,executeWorkflowBody};
|
|
1
|
+
import{getWorkflowMetadata}from"#compiled/@workflow/core/index.js";import{normalizeSerializableError}from"#execution/workflow-errors.js";import{resumeHookStep}from"#execution/tools/workflow/resume-hook-step.js";import{createTaskMessage}from"#tools/task.js";import{ask,attachWorkflowToolRunContext}from"#execution/tools/workflow/ask.js";import{agent}from"#execution/tools/subagent/invoke-agent.js";import"#execution/tools/workflow/messages.js";import{readRegisteredWorkflow}from"#execution/workflow-registry.js";async function executeWorkflowBody(e,t){let n=createWorkflowBodyRef(e),r=createWorkflowBodyContext(e,t);attachWorkflowToolRunContext(r,{from:n,owner:e.owner});let i=0;try{let t=resolveWorkflowToolExecute(e),a=e.execution===`background`?createWorkflowTaskExec(e):void 0,o=t(e.executeInput??e.input,r,a),s;if(!isAsyncIterable(o))s=await o;else{let t=o[Symbol.asyncIterator](),r,a=await t.next();for(;a.done!==!0;){r=a.value;let o={from:n,update:a.value};await resumeHookStep(e.owner.inbox,{kind:`report`,...o}),i+=1,a=await t.next()}s=a.value??(e.execution===`blocking`?r:void 0)??null}return{outcome:{output:s,status:`completed`},reportCount:i}}catch(e){return t.aborted?{outcome:{reason:t.reason instanceof Error?t.reason.message:String(t.reason??``),status:`cancelled`},reportCount:i}:{outcome:{error:normalizeSerializableError(e),status:`failed`},reportCount:i}}}function createWorkflowBodyRef(e){return{callId:e.callId,execution:e.execution,input:e.input,resultKind:e.resultKind,runId:e.runId??getWorkflowMetadata().workflowRunId,sequence:e.session.turn.sequence,stepIndex:e.stepIndex,toolName:e.toolName,turnId:e.session.turn.id}}function resolveWorkflowToolExecute(e){let t=readRegisteredWorkflow(e.workflowId);if(typeof t!=`function`)throw Error(`Tool "${e.toolName}" is not registered as a workflow in this deployment (${e.workflowId}). The tool was renamed or removed after this run started.`);return t}function createWorkflowBodyContext(e,t){let unavailable=(t,n)=>{throw Error(`ctx.${t} is not available inside a workflow tool; ${n}. Tool "${e.toolName}" runs as a durable workflow body, which only replays deterministic code.`)},n={agent:((e,t)=>agent(n,e,t)),agents:Object.freeze(Object.fromEntries(Object.entries(e.agents??{}).map(([e,t])=>[e,Object.freeze({...t})]))),ask:e=>ask(n,e),abortSignal:t,callId:e.callId,getSandbox:()=>unavailable(`getSandbox()`,`the session sandbox belongs to the turn`),getSkill:()=>unavailable(`getSkill()`,`skills are read through the session sandbox`),getToken:()=>unavailable(`getToken()`,`pass ctx directly to a "use step" helper to resolve credentials`),requireAuth:()=>unavailable(`requireAuth()`,`pass ctx directly to a "use step" helper to request authorization`),session:e.session,toolName:e.toolName};return n}function createWorkflowTaskExec(e){if(e.taskId===void 0)throw Error(`Background workflow tool "${e.toolName}" has no task id.`);return{binding:{taskId:e.taskId,token:e.taskId},postMessage:createTaskMessage,send(){throw Error(`task.send() was replaced by yielded task descriptors.`)},session:void 0,task:void 0,taskId:e.taskId}}function isAsyncIterable(e){return typeof e==`object`&&!!e&&typeof e[Symbol.asyncIterator]==`function`}export{createWorkflowBodyRef,executeWorkflowBody};
|
|
@@ -7,6 +7,7 @@ import type { WorkflowToolRunOwner } from "#execution/tools/workflow/messages.js
|
|
|
7
7
|
export declare function startWorkflowToolRun(input: Omit<WorkflowToolRunInput, "hookToken">): Promise<WorkflowToolRunAddress>;
|
|
8
8
|
/** Starts one durable workflow task and records it on the owning session. */
|
|
9
9
|
export declare function startWorkflowTask(input: {
|
|
10
|
+
readonly agents: WorkflowToolRunInput["agents"];
|
|
10
11
|
readonly auth: SessionAuth["current"];
|
|
11
12
|
readonly batchEvent: {
|
|
12
13
|
readonly sequence: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createLogger,logError}from"#internal/logging.js";import{toError}from"#shared/errors.js";import{startWorkflowOnCurrentDeployment,workflowToolRunWorkflowReference}from"#execution/workflow-runtime.js";import{recordWorkflowToolRun}from"#harness/workflow-tool-runs.js";import{createRuntimeToolResultFromValue}from"#harness/action-result-helpers.js";const log=createLogger(`execution.workflow-tool-run`);async function startWorkflowToolRun(e){let t=crypto.randomUUID();return{hookToken:t,runId:(await startWorkflowOnCurrentDeployment(workflowToolRunWorkflowReference,[{...e,hookToken:t}])).runId}}async function startWorkflowTask(e){let{task:t,batchEvent:n,session:r}=e;try{let i=await startWorkflowToolRun({callId:t.callId,executeInput:t.executeInput,input:t.input,owner:e.owner,resultKind:t.resultKind,session:{auth:{current:e.auth,initiator:e.initiatorAuth},id:r.sessionId,parent:e.parentSession,turn:{id:n.turnId,sequence:n.sequence}},stepIndex:n.stepIndex,toolName:t.toolName,workflowId:t.workflowId});return{session:recordWorkflowToolRun(r,{callId:t.callId,hookToken:i.hookToken,resultKind:t.resultKind??`tool`,runId:i.runId,toolName:t.toolName})}}catch(e){return logError(log,`workflow tool run failed to start`,e,{callId:t.callId,toolName:t.toolName}),{result:createRuntimeToolResultFromValue({callId:t.callId,isError:!0,output:toError(e),toolName:t.toolName}),session:r}}}export{startWorkflowTask,startWorkflowToolRun};
|
|
1
|
+
import{createLogger,logError}from"#internal/logging.js";import{toError}from"#shared/errors.js";import{startWorkflowOnCurrentDeployment,workflowToolRunWorkflowReference}from"#execution/workflow-runtime.js";import{recordWorkflowToolRun}from"#harness/workflow-tool-runs.js";import{createRuntimeToolResultFromValue}from"#harness/action-result-helpers.js";const log=createLogger(`execution.workflow-tool-run`);async function startWorkflowToolRun(e){let t=crypto.randomUUID();return{hookToken:t,runId:(await startWorkflowOnCurrentDeployment(workflowToolRunWorkflowReference,[{...e,hookToken:t}])).runId}}async function startWorkflowTask(e){let{task:t,batchEvent:n,session:r}=e;try{let i=await startWorkflowToolRun({agents:e.agents,callId:t.callId,executeInput:t.executeInput,input:t.input,owner:e.owner,resultKind:t.resultKind,session:{auth:{current:e.auth,initiator:e.initiatorAuth},id:r.sessionId,parent:e.parentSession,turn:{id:n.turnId,sequence:n.sequence}},stepIndex:n.stepIndex,toolName:t.toolName,workflowId:t.workflowId});return{session:recordWorkflowToolRun(r,{callId:t.callId,hookToken:i.hookToken,resultKind:t.resultKind??`tool`,runId:i.runId,toolName:t.toolName})}}catch(e){return logError(log,`workflow tool run failed to start`,e,{callId:t.callId,toolName:t.toolName}),{result:createRuntimeToolResultFromValue({callId:t.callId,isError:!0,output:toError(e),toolName:t.toolName}),session:r}}}export{startWorkflowTask,startWorkflowToolRun};
|
|
@@ -2,12 +2,14 @@ import type { SessionContext } from "#context/session-context.js";
|
|
|
2
2
|
import type { JsonObject, JsonValue } from "#shared/json.js";
|
|
3
3
|
import type { TaskExecutorBinding } from "#tools/task.js";
|
|
4
4
|
import type { WorkflowToolRunOwner } from "#execution/tools/workflow/messages.js";
|
|
5
|
+
import type { WorkflowAgentMetadata } from "#tools/workflow-definition.js";
|
|
5
6
|
export type WorkflowToolRunSessionContext = SessionContext["session"];
|
|
6
7
|
export declare const WORKFLOW_TOOL_EXECUTOR_KIND = "workflow-tool";
|
|
7
8
|
/** Private task executor binding for the workflow tool run doing the task's work. */
|
|
8
9
|
export declare function createWorkflowToolExecutorBinding(input: WorkflowToolRunAddress): TaskExecutorBinding;
|
|
9
10
|
export declare function readWorkflowToolExecutorAddress(executor: TaskExecutorBinding | undefined): WorkflowToolRunAddress | undefined;
|
|
10
11
|
export interface WorkflowToolRunInput {
|
|
12
|
+
readonly agents: Readonly<Record<string, WorkflowAgentMetadata>>;
|
|
11
13
|
readonly callId: string;
|
|
12
14
|
readonly execution?: "background" | "blocking";
|
|
13
15
|
readonly executeInput?: JsonValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRequire}from"node:module";import{basename,dirname,join}from"node:path";import{existsSync,readFileSync,realpathSync}from"node:fs";import{fileURLToPath}from"node:url";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";let cachedPackageInfo,cachedPackageLocation;const BUNDLED_FALLBACK_PACKAGE_VERSION=`0.60.
|
|
1
|
+
import{createRequire}from"node:module";import{basename,dirname,join}from"node:path";import{existsSync,readFileSync,realpathSync}from"node:fs";import{fileURLToPath}from"node:url";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";let cachedPackageInfo,cachedPackageLocation;const BUNDLED_FALLBACK_PACKAGE_VERSION=`0.60.1`,WORKFLOW_MODULE_ALIASES={"workflow/errors":`src/compiled/@workflow/errors/index.js`,"workflow/internal/private":`src/compiled/@workflow/core/private.js`};function resolveFallbackPackageVersion(){return BUNDLED_FALLBACK_PACKAGE_VERSION.startsWith(`__`)?`0.0.0`:BUNDLED_FALLBACK_PACKAGE_VERSION}const FALLBACK_PACKAGE_INFO={name:EVE_PACKAGE_NAME,version:resolveFallbackPackageVersion()};function resolveCurrentModulePath(){return typeof __filename==`string`?__filename:resolveCurrentModulePathFromStack()}function resolveCurrentModulePathFromStack(){let e=Error.prepareStackTrace;try{Error.prepareStackTrace=(e,t)=>t;let e=Error().stack?.[0]?.getFileName();if(typeof e!=`string`||e.length===0)throw Error(`Failed to resolve the current module path from the stack trace.`);return e.startsWith(`file:`)?fileURLToPath(e):e}finally{Error.prepareStackTrace=e}}const require=createRequire(resolveCurrentModulePath());function tryResolveVerifiedPackageRoot(e){try{let t=realpathSync.native(e);return tryReadInstalledPackageInfo(t,EVE_PACKAGE_NAME)===void 0?void 0:dirname(t)}catch{return}}function findNearestVerifiedPackageRoot(e){let t=e;for(;;){let e=tryResolveVerifiedPackageRoot(join(t,`package.json`));if(e!==void 0)return e;let n=dirname(t);if(n===t)return;t=n}}function tryResolveDirectBuildLocation(e){let t=dirname(e);for(;;){if(basename(t)===`dist`){let e=tryResolveVerifiedPackageRoot(join(dirname(t),`package.json`));if(e!==void 0)return{packageBuildRoot:t,packageRoot:e}}let e=dirname(t);if(e===t)return;t=e}}function isSourceCheckout(e){return existsSync(join(e,`src`,`internal`,`application`,`package.ts`))}function tryCreatePackageLocation(e){if(isSourceCheckout(e))return{packageBuildRoot:null,packageRoot:e};let t=join(e,`dist`);if(existsSync(t))return{packageBuildRoot:t,packageRoot:e}}function resolveSelfPackageJsonPath(e){return createRequire(e).resolve(`${EVE_PACKAGE_NAME}/package.json`)}function resolvePackageLocationFromModulePath(e,t=resolveSelfPackageJsonPath){let n=realpathSync.native(e),r=tryResolveDirectBuildLocation(n);if(r!==void 0)return r;let i=findNearestVerifiedPackageRoot(dirname(n));if(i!==void 0&&isSourceCheckout(i))return{packageBuildRoot:null,packageRoot:i};try{let e=tryResolveVerifiedPackageRoot(t(n)),r=e===void 0?void 0:tryCreatePackageLocation(e);if(r!==void 0)return r}catch{}let a=i===void 0?void 0:tryCreatePackageLocation(i);if(a!==void 0)return a;throw Error(`Failed to resolve the eve package root from "${e}".`)}function resolvePackageLocation(){return cachedPackageLocation??=resolvePackageLocationFromModulePath(resolveCurrentModulePath()),cachedPackageLocation}function resolvePackageBuildRoot(){return resolvePackageLocation().packageBuildRoot}function resolvePackageRoot(){return resolvePackageLocation().packageRoot}function tryResolvePackageRoot(){try{return resolvePackageRoot()}catch{return}}function rewriteSourceFilePathForBuild(e){return e.replace(/\.[cm]?tsx?$/,`.js`)}function resolvePackageSourceFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),e):join(t,rewriteSourceFilePathForBuild(e))}function resolvePackageSourceDirectoryPath(e){let t=resolvePackageBuildRoot();return join(t===null?resolvePackageRoot():t,e)}function resolvePackageDependencyPath(e){return require.resolve(e)}function resolvePackageCompiledFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),`.generated`,`compiled`,e.replace(/^src\/compiled\//,``)):join(t,e)}function normalizeInstalledPackageInfo(e){let t=e;if(typeof t.name==`string`&&typeof t.version==`string`)return{name:t.name,version:t.version}}function tryReadInstalledPackageInfo(e,t){let n=normalizeInstalledPackageInfo(JSON.parse(readFileSync(e,`utf8`)));if(n?.name===t)return n}function resolveInstalledPackageInfo(){if(cachedPackageInfo)return cachedPackageInfo;let e=tryResolvePackageRoot(),t=e===void 0?void 0:tryReadInstalledPackageInfo(join(e,`package.json`),EVE_PACKAGE_NAME);if(t)return cachedPackageInfo=t,cachedPackageInfo;try{let e=tryReadInstalledPackageInfo(require.resolve(`${EVE_PACKAGE_NAME}/package.json`),EVE_PACKAGE_NAME);if(e)return cachedPackageInfo=e,cachedPackageInfo}catch{}return cachedPackageInfo={...FALLBACK_PACKAGE_INFO},cachedPackageInfo}function readWorkflowVersionFromManifest(e){let t=e;for(let e of[t.devDependencies,t.dependencies,t.peerDependencies]){let t=e?.[`@workflow/core`];if(typeof t==`string`&&t.trim().length>0)return t}}function resolveExpectedWorkflowVersion(){let e=tryResolvePackageRoot();if(e!==void 0)try{return readWorkflowVersionFromManifest(JSON.parse(readFileSync(join(e,`package.json`),`utf8`)))}catch{}try{return readWorkflowVersionFromManifest(JSON.parse(readFileSync(require.resolve(`${EVE_PACKAGE_NAME}/package.json`),`utf8`)))}catch{return}}function resolveWorkflowModulePath(e){if(e===`workflow`)return resolvePackageSourceFilePath(`src/internal/workflow/index.ts`);if(e===`workflow/api`||e===`workflow/runtime`)return resolvePackageSourceFilePath(`src/internal/workflow/runtime.ts`);if(e===`workflow/internal/builtins`)return resolvePackageSourceFilePath(`src/internal/workflow/builtins.ts`);let t=WORKFLOW_MODULE_ALIASES[e];return t===void 0?require.resolve(e):resolvePackageCompiledFilePath(t)}export{resolveExpectedWorkflowVersion,resolveInstalledPackageInfo,resolvePackageCompiledFilePath,resolvePackageDependencyPath,resolvePackageLocationFromModulePath,resolvePackageRoot,resolvePackageSourceDirectoryPath,resolvePackageSourceFilePath,resolveWorkflowModulePath};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { agentRouter, type AgentRouterInput, type AgentRouterTool, } from "#tools/provided/agent-router.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{agentRouter}from"#tools/provided/agent-router.js";export{agentRouter};
|
|
@@ -10,5 +10,5 @@ export type { DynamicEvents, DynamicResolveContext, DynamicSentinel } from "#dyn
|
|
|
10
10
|
export type { DynamicToolEntry, DynamicToolEvents, DynamicToolSet, DynamicToolResult, } from "#tools/dynamic.js";
|
|
11
11
|
export { type SessionContext } from "#public/definitions/callback-context.js";
|
|
12
12
|
export { toolResultFrom, type MatchedConnectionResult, type MatchedToolResult, type ToolResultFromFn, } from "#public/tools/result.js";
|
|
13
|
-
export { defineWorkflowTool, type WorkflowToolContext, type WorkflowToolDefinition, type AgentInput, } from "#tools/workflow-definition.js";
|
|
13
|
+
export { defineWorkflowTool, type WorkflowToolContext, type WorkflowToolDefinition, type AgentInput, type WorkflowAgentMetadata, } from "#tools/workflow-definition.js";
|
|
14
14
|
export type { ToolInputRequest, ToolInputResponse } from "#tools/definition.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{pinnedNodeEngineMajor}from"../../node-engine.js";import{parseChatGptModelSelection}from"../../../shared/chatgpt-model.js";import{SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS}from"../update/module-files.js";import{pathExists,writeTextFile}from"../files.js";import{blockingCreateInPlaceEntries}from"../create-in-place.js";import{DEFAULT_CONNECT_PACKAGE_VERSION,resolveVersionToken}from"../version-tokens.js";import{applyPackageManagerWorkspaceConfiguration,isPackageManagerWorkspaceMember,patchWorkspaceRootPackageJson}from"../workspace-root.js";import{WEB_APP_TEMPLATE_FILES}from"./web-template.js";import{mkdir,readdir,stat}from"node:fs/promises";import{basename,join,resolve}from"node:path";const CURRENT_DIRECTORY_PROJECT_NAME=`.`,DEFAULT_AI_PACKAGE_VERSION=`^7.0.105`,DEFAULT_ZOD_PACKAGE_VERSION=`4.5.4`,DEFAULT_EVE_PACKAGE_CONTRACT={version:`0.60.
|
|
1
|
+
import{pinnedNodeEngineMajor}from"../../node-engine.js";import{parseChatGptModelSelection}from"../../../shared/chatgpt-model.js";import{SUPPORTED_AUTHORED_MODULE_FILE_EXTENSIONS}from"../update/module-files.js";import{pathExists,writeTextFile}from"../files.js";import{blockingCreateInPlaceEntries}from"../create-in-place.js";import{DEFAULT_CONNECT_PACKAGE_VERSION,resolveVersionToken}from"../version-tokens.js";import{applyPackageManagerWorkspaceConfiguration,isPackageManagerWorkspaceMember,patchWorkspaceRootPackageJson}from"../workspace-root.js";import{WEB_APP_TEMPLATE_FILES}from"./web-template.js";import{mkdir,readdir,stat}from"node:fs/promises";import{basename,join,resolve}from"node:path";const CURRENT_DIRECTORY_PROJECT_NAME=`.`,DEFAULT_AI_PACKAGE_VERSION=`^7.0.105`,DEFAULT_ZOD_PACKAGE_VERSION=`4.5.4`,DEFAULT_EVE_PACKAGE_CONTRACT={version:`0.60.1`,nodeEngine:`>=24`};function resolveEvePackageContract(e=DEFAULT_EVE_PACKAGE_CONTRACT){return{version:resolveVersionToken(`evePackage.version`,e.version),nodeEngine:resolveVersionToken(`evePackage.nodeEngine`,e.nodeEngine)}}function modelProviderSlug(e){let t=(e.split(`/`)[0]??``).replaceAll(/[^A-Za-z0-9._-]/gu,``);return t.length>0?t:`anthropic`}function byokProviderEnvVar(e){let t=modelProviderSlug(e).toUpperCase().replaceAll(/[^A-Z0-9]/gu,`_`);return`${/^[0-9]/.test(t)?`_`:``}${t}_API_KEY`}function agentTemplateFiles(e,t){return{"agent/agent.ts":renderAgentTemplate(e,t),"agent/channels/eve.ts":WEB_APP_TEMPLATE_FILES[`agent/channels/eve.ts`],"agent/instructions.md":AGENT_INSTRUCTIONS_TEMPLATE}}function renderAgentTemplate(e,t){let n=parseChatGptModelSelection(e);return n===void 0?BASE_AGENT_TEMPLATE.replaceAll(`__EVE_INIT_MODEL__`,e).replaceAll(`__EVE_INIT_REASONING__`,reasoningTemplateLine(t)):`import { defineAgent } from "eve";\nimport { chatgpt } from "eve/models/openai";\n\nexport default defineAgent({\n model: chatgpt(${JSON.stringify(n)}),\n${reasoningTemplateLine(t)}});\n`}function reasoningTemplateLine(e){return e===void 0||e===`provider-default`?``:` reasoning: "${e}",\n`}function renderTemplate(e,t){return e===BASE_AGENT_TEMPLATE&&parseChatGptModelSelection(t.model)!==void 0?renderAgentTemplate(t.model,t.reasoning):e.replaceAll(`__EVE_INIT_APP_NAME__`,t.appName).replaceAll(`__EVE_INIT_MODEL__`,t.model).replaceAll(`__EVE_INIT_REASONING__`,reasoningTemplateLine(t.reasoning)).replaceAll(`__EVE_INIT_BYOK_PROVIDER__`,modelProviderSlug(t.model)).replaceAll(`__EVE_INIT_BYOK_ENV_VAR__`,byokProviderEnvVar(t.model)).replaceAll(`__EVE_INIT_PACKAGE_VERSION__`,formatEveDependencySpecifier(t.eveVersion)).replaceAll(`__EVE_INIT_AI_SDK_VERSION__`,t.aiPackageVersion).replaceAll(`__EVE_INIT_CONNECT_VERSION__`,t.connectPackageVersion).replaceAll(`__EVE_INIT_ZOD_VERSION__`,t.zodPackageVersion).replaceAll(`__EVE_INIT_TYPESCRIPT_VERSION__`,t.typescriptPackageVersion).replaceAll(`__EVE_INIT_TYPES_NODE_VERSION__`,t.nodeTypesVersion).replaceAll(`__EVE_INIT_NODE_ENGINE__`,t.nodeEngine)}function formatEveDependencySpecifier(e){return/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z-.]+)?$/.test(e)?`^${e}`:e}const BASE_AGENT_TEMPLATE=`import { defineAgent } from "eve";
|
|
2
2
|
|
|
3
3
|
export default defineAgent({
|
|
4
4
|
model: "__EVE_INIT_MODEL__",
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { JsonValue } from "#shared/json.js";
|
|
2
|
+
import { type AgentRouterInput } from "#execution/tools/agent-router.js";
|
|
3
|
+
import { type BlockingWorkflowToolDefinition } from "#tools/workflow-definition.js";
|
|
4
|
+
export type { AgentRouterInput };
|
|
5
|
+
export type AgentRouterTool = BlockingWorkflowToolDefinition<AgentRouterInput, JsonValue>;
|
|
6
|
+
/** Defines a workflow tool that uses JEV to route a task across all available declared subagents. */
|
|
7
|
+
export declare function agentRouter(): AgentRouterTool;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{defineWorkflowTool}from"#tools/workflow-definition.js";import{AGENT_ROUTER_INPUT_SCHEMA,AGENT_ROUTER_TOOL_DESCRIPTION,executeAgentRouterTool}from"#execution/tools/agent-router.js";function agentRouter(){return defineWorkflowTool({description:AGENT_ROUTER_TOOL_DESCRIPTION,execute:executeAgentRouterTool,inputSchema:AGENT_ROUTER_INPUT_SCHEMA})}export{agentRouter};
|
|
@@ -39,6 +39,9 @@ type JsonSchemaOutput<TSchema> = TSchema extends {
|
|
|
39
39
|
} ? boolean : TSchema extends {
|
|
40
40
|
readonly type: "null";
|
|
41
41
|
} ? null : JsonValue;
|
|
42
|
+
export interface WorkflowAgentMetadata {
|
|
43
|
+
readonly description: string;
|
|
44
|
+
}
|
|
42
45
|
interface WorkflowAgent {
|
|
43
46
|
<const TOutputSchema extends JsonObject>(target: string, input: AgentInput & {
|
|
44
47
|
readonly outputSchema: TOutputSchema;
|
|
@@ -50,8 +53,10 @@ interface WorkflowAgent {
|
|
|
50
53
|
* getToken/requireAuth; those capabilities throw in the workflow body itself.
|
|
51
54
|
*/
|
|
52
55
|
export type WorkflowToolContext = Pick<ToolContext, "abortSignal" | "callId" | "session" | "toolName" | "getToken" | "requireAuth"> & {
|
|
53
|
-
/** Invoke
|
|
56
|
+
/** Invoke an agent by its path-derived name. */
|
|
54
57
|
agent: WorkflowAgent;
|
|
58
|
+
/** Metadata for agents callable by this workflow, including hidden agents. */
|
|
59
|
+
agents: Readonly<Record<string, WorkflowAgentMetadata>>;
|
|
55
60
|
/** Ask the human on the session's channel; awaiting the answer suspends the run. */
|
|
56
61
|
ask(request: ToolInputRequest): PromiseLike<ToolInputResponse>;
|
|
57
62
|
};
|
package/docs/guides/evaluate.md
CHANGED
|
@@ -141,7 +141,7 @@ export default defineTool({
|
|
|
141
141
|
|
|
142
142
|
The choice above is typed as `"billing" | "support"`. Each question appears under
|
|
143
143
|
its authored key in `result.answers`. Results also include token usage, warnings,
|
|
144
|
-
provider metadata, and response metadata.
|
|
144
|
+
provider metadata, and response metadata. To use that choice to delegate while keeping specialist subagents out of the parent model's tools, see [Route to a hidden subagent with JEV](/docs/tools/workflows#route-to-a-hidden-subagent-with-jev).
|
|
145
145
|
|
|
146
146
|
`evaluate` accepts AI SDK evaluation options, including `maxRetries`, `headers`,
|
|
147
147
|
and `providerOptions`. Pass an `abortSignal` to cancel the request. Input and
|
|
@@ -56,7 +56,7 @@ export default defineTool({
|
|
|
56
56
|
| `mockModel` | `eve/evals` | Deterministic fixture agent models | [Evals](../evals/overview) |
|
|
57
57
|
| `useEveAgent` | `eve/react`, `eve/vue`, `eve/svelte` | frontend | [Frontend](../guides/frontend/overview) |
|
|
58
58
|
|
|
59
|
-
Tool-wide authoring helpers and types such as `defineTool`, `defineWorkflowTool`, `defineDurableCallback`, `defineDurableSchema`, `defineDynamic`, `disableTool`, and `ToolLabelDefinition` come from `eve/tools`. Capability-specific definitions and helpers use their own subpaths (see [Built-in tools](../concepts/built-in-tools)): reusable definitions such as `bash` and `glob` come from `eve/tools/<name>`, `webSearch` comes from `eve/tools/web_search`, `sleep` comes from `eve/tools/sleep`, and approval policies and types come from `eve/tools/approval`. The route verbs `GET`/`HEAD`/`POST`/`PUT`/`PATCH`/`DELETE`/`OPTIONS`/`WS` plus `disableRoute` come from `eve/channels`, and the channel auth helpers `localDev`/`vercelOidc`/`placeholderAuth` come from `eve/channels/auth`.
|
|
59
|
+
Tool-wide authoring helpers and types such as `defineTool`, `defineWorkflowTool`, `defineDurableCallback`, `defineDurableSchema`, `defineDynamic`, `disableTool`, and `ToolLabelDefinition` come from `eve/tools`. Capability-specific definitions and helpers use their own subpaths (see [Built-in tools](../concepts/built-in-tools)): reusable definitions such as `bash` and `glob` come from `eve/tools/<name>`, `webSearch` comes from `eve/tools/web_search`, `agentRouter` comes from `eve/tools/agent-router`, `sleep` comes from `eve/tools/sleep`, and approval policies and types come from `eve/tools/approval`. The route verbs `GET`/`HEAD`/`POST`/`PUT`/`PATCH`/`DELETE`/`OPTIONS`/`WS` plus `disableRoute` come from `eve/channels`, and the channel auth helpers `localDev`/`vercelOidc`/`placeholderAuth` come from `eve/channels/auth`.
|
|
60
60
|
|
|
61
61
|
`AgentReasoningDefinition` is exported from `eve` for the top-level `defineAgent({ reasoning })` setting. `AgentLimitsDefinition` is exported for `defineAgent({ limits })`. `AgentWorkflowDefinition`, `AgentWorkflowRetentionDefinition`, and `AgentWorkflowWorldDefinition` are exported from `eve` for the `defineAgent({ experimental: { workflow } })` config shape. `WebSearchToolInput` and `WebSearchProvider` are exported from `eve/tools/web_search`.
|
|
62
62
|
|
|
@@ -108,6 +108,8 @@ import template from "../../prompts/template.txt?raw";
|
|
|
108
108
|
| `ctx.getToken(provider)` | Resolve a bearer token for an inline auth provider such as `connect("...")` |
|
|
109
109
|
| `ctx.requireAuth(provider)` | Evict and re-authorize an inline provider, commonly after a downstream `401` |
|
|
110
110
|
|
|
111
|
+
Authored workflow tools also receive `ctx.agents`, a replay-stable map of effective declared-subagent descriptions, and `ctx.agent(name, input)` for invocation. See [Workflows as tools](../tools/workflows#delegate-work-ctxagent) for the workflow-only context.
|
|
112
|
+
|
|
111
113
|
## Imports at a glance
|
|
112
114
|
|
|
113
115
|
| Import | Holds |
|
package/docs/tools/workflows.mdx
CHANGED
|
@@ -15,7 +15,7 @@ suspend in either execution mode; running in the background does not require a s
|
|
|
15
15
|
|
|
16
16
|
Workflow tools use the [Workflow SDK](https://workflow-sdk.dev): `"use workflow"`, `"use step"`, `createHook`,
|
|
17
17
|
`createWebhook`, `sleep`, retries, and replay. eve provides `ctx.ask` for questions answered through
|
|
18
|
-
the session's channel and `ctx.agent` for durable subagent delegation. Use `yield` to report
|
|
18
|
+
the session's channel, `ctx.agents` for effective subagent descriptions, and `ctx.agent` for durable subagent delegation. Use `yield` to report
|
|
19
19
|
progress and `await` on a workflow operation to wait durably. Values needed after a durable wait
|
|
20
20
|
stay in local variables in the workflow body.
|
|
21
21
|
|
|
@@ -78,13 +78,13 @@ or days later, the run resumes, deploys, and returns. The model sees one tool re
|
|
|
78
78
|
- Import `createHook`, `createWebhook`, `sleep`, and `FatalError` from `workflow` in the body.
|
|
79
79
|
`start`, `getRun`, and `resumeHook` from `workflow/api` belong in steps. Your app does not install
|
|
80
80
|
the SDK; for types, new projects list `eve/workflow-modules` in the tsconfig `types`.
|
|
81
|
-
- In the body, `ctx` has `session`, `callId`, `toolName`, `abortSignal`, `agent`, and `ask`.
|
|
81
|
+
- In the body, `ctx` has `session`, `callId`, `toolName`, `abortSignal`, `agent`, `agents`, and `ask`.
|
|
82
82
|
`getToken` and `requireAuth` work inside a `"use step"` helper that receives `ctx` as a direct argument;
|
|
83
83
|
they throw in the workflow body. `getSandbox` and `getSkill` remain unavailable.
|
|
84
84
|
- The tool's input must be a JSON object. Workflow bodies are for static tools under `agent/tools/`,
|
|
85
85
|
not tools returned from `defineDynamic` resolvers.
|
|
86
86
|
|
|
87
|
-
`ctx.agent` and `ctx.ask` are available only on `WorkflowToolContext`. Ordinary tools, channel
|
|
87
|
+
`ctx.agent`, `ctx.agents`, and `ctx.ask` are available only on `WorkflowToolContext`. Ordinary tools, channel
|
|
88
88
|
handlers, and schedule handlers do not receive these methods. A shared helper may accept
|
|
89
89
|
`WorkflowToolContext` from `eve/tools` and use the context supplied by a workflow tool body.
|
|
90
90
|
|
|
@@ -302,7 +302,7 @@ and can only show the model's input. Both compose: `approval` before the run, `c
|
|
|
302
302
|
|
|
303
303
|
## Delegate work: `ctx.agent`
|
|
304
304
|
|
|
305
|
-
Workflow tools can call a
|
|
305
|
+
Workflow tools can call a subagent and wait for its result:
|
|
306
306
|
|
|
307
307
|
```ts
|
|
308
308
|
const result = await ctx.agent("reviewer", {
|
|
@@ -321,6 +321,89 @@ The first argument is the subagent's path-derived name. It can identify a model-
|
|
|
321
321
|
continue an existing child. An inline `outputSchema` requires structured output and determines the
|
|
322
322
|
return type, so `result` in the example is typed as `{ findings: string[] }`.
|
|
323
323
|
|
|
324
|
+
### Route to a hidden subagent with JEV
|
|
325
|
+
|
|
326
|
+
Use an authored workflow tool when the parent model should decide to delegate, but JEV should choose the specialist. Set `tool: false` on each specialist so the parent model sees only the routing tool. The specialists remain available through `ctx.agents` and callable through `ctx.agent()`:
|
|
327
|
+
|
|
328
|
+
```ts title="agent/subagents/researcher/agent.ts"
|
|
329
|
+
import { defineAgent } from "eve";
|
|
330
|
+
|
|
331
|
+
export default defineAgent({
|
|
332
|
+
description: "Investigation, analysis, and explanation",
|
|
333
|
+
model: "anthropic/claude-opus-4.8",
|
|
334
|
+
tool: false,
|
|
335
|
+
});
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
```ts title="agent/subagents/operator/agent.ts"
|
|
339
|
+
import { defineAgent } from "eve";
|
|
340
|
+
|
|
341
|
+
export default defineAgent({
|
|
342
|
+
description: "Execution and operational changes",
|
|
343
|
+
model: "openai/gpt-5.6-sol",
|
|
344
|
+
tool: false,
|
|
345
|
+
});
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
Define the model-visible router under `agent/tools/`. Build the JEV criteria from the subagents' effective descriptions, then pass its typed choice directly to `ctx.agent()`:
|
|
349
|
+
|
|
350
|
+
```ts title="agent/tools/agent-router.ts"
|
|
351
|
+
import { evaluate } from "eve/ai";
|
|
352
|
+
import { defineWorkflowTool, type WorkflowToolContext } from "eve/tools";
|
|
353
|
+
import { z } from "zod";
|
|
354
|
+
|
|
355
|
+
async function chooseTarget(task: string, ctx: WorkflowToolContext) {
|
|
356
|
+
"use step";
|
|
357
|
+
|
|
358
|
+
const result = await evaluate({
|
|
359
|
+
abortSignal: ctx.abortSignal,
|
|
360
|
+
state: { task },
|
|
361
|
+
questions: {
|
|
362
|
+
route: {
|
|
363
|
+
type: "choice",
|
|
364
|
+
instructions: "Which specialist should handle this task?",
|
|
365
|
+
criteria: {
|
|
366
|
+
researcher: ctx.agents.researcher.description,
|
|
367
|
+
operator: ctx.agents.operator.description,
|
|
368
|
+
},
|
|
369
|
+
},
|
|
370
|
+
},
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
return result.answers.route.choice;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
export default defineWorkflowTool({
|
|
377
|
+
description: "Route a task to the appropriate specialist.",
|
|
378
|
+
inputSchema: z.object({ task: z.string().min(1).max(8000) }),
|
|
379
|
+
async execute({ task }, ctx) {
|
|
380
|
+
"use workflow";
|
|
381
|
+
|
|
382
|
+
const target = await chooseTarget(task, ctx);
|
|
383
|
+
|
|
384
|
+
return ctx.agent(target, { message: task });
|
|
385
|
+
},
|
|
386
|
+
});
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
The evaluation runs in a step so workflow replay records its result instead of making the routing request again. The parent model receives `agent-router`, but not `researcher` or `operator`. JEV returns the typed `"researcher" | "operator"` choice, and the selected subagent's result becomes the `agent-router` tool result.
|
|
390
|
+
|
|
391
|
+
`ctx.agents` is a replay-stable metadata snapshot taken when the workflow starts. It includes agents hidden from the parent model with `tool: false` or `disableTool()`, but exposes no model definitions, credentials, or callbacks. Invocation still checks the subagent's availability through `ctx.agent()`.
|
|
392
|
+
|
|
393
|
+
#### Route across every subagent
|
|
394
|
+
|
|
395
|
+
Use `agentRouter()` when the router should consider every available declared subagent with the default JEV routing instructions:
|
|
396
|
+
|
|
397
|
+
```ts title="agent/tools/agent-router.ts"
|
|
398
|
+
import { agentRouter } from "eve/tools/agent-router";
|
|
399
|
+
|
|
400
|
+
export default agentRouter();
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
Its input is `{ message: string, outputSchema?: object }`. With two or more available subagents, `agentRouter()` sends the message and every effective description to JEV, then invokes the selected path-derived name through `ctx.agent()`. It invokes a sole available subagent without evaluation and forwards an optional `outputSchema`. The built-in root-copy `agent` target is not included.
|
|
404
|
+
|
|
405
|
+
This pattern controls specialist selection, not whether the parent model delegates at all. Route before the parent model runs if every incoming request must go through JEV.
|
|
406
|
+
|
|
324
407
|
## Report progress: `yield`
|
|
325
408
|
|
|
326
409
|
A workflow body may be an async generator. Ordinary yields report progress in both execution
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eve",
|
|
3
|
-
"version": "0.60.
|
|
3
|
+
"version": "0.60.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Filesystem-first framework for durable backend AI agents that run anywhere.",
|
|
6
6
|
"keywords": [
|
|
@@ -127,6 +127,11 @@
|
|
|
127
127
|
"import": "./dist/src/public/memory/file/vercel.js",
|
|
128
128
|
"default": "./dist/src/public/memory/file/vercel.js"
|
|
129
129
|
},
|
|
130
|
+
"./tools/agent-router": {
|
|
131
|
+
"types": "./dist/src/public/tools/agent-router.d.ts",
|
|
132
|
+
"import": "./dist/src/public/tools/agent-router.js",
|
|
133
|
+
"default": "./dist/src/public/tools/agent-router.js"
|
|
134
|
+
},
|
|
130
135
|
"./tools/sleep": {
|
|
131
136
|
"types": "./dist/src/public/tools/sleep.d.ts",
|
|
132
137
|
"import": "./dist/src/public/tools/sleep.js",
|