eve 0.62.0 → 0.63.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/src/cli/dev/tui/model-picker.d.ts +48 -0
- package/dist/src/cli/dev/tui/model-picker.js +1 -0
- package/dist/src/cli/dev/tui/prompt-commands.js +1 -1
- package/dist/src/cli/dev/tui/runner.js +2 -2
- package/dist/src/cli/dev/tui/setup-commands.d.ts +1 -1
- package/dist/src/cli/dev/tui/setup-commands.js +1 -1
- package/dist/src/cli/dev/tui/setup-flow.d.ts +2 -2
- package/dist/src/cli/dev/tui/setup-panel.d.ts +1 -26
- package/dist/src/cli/dev/tui/setup-panel.js +3 -3
- package/dist/src/cli/dev/tui/stream-format.d.ts +0 -7
- package/dist/src/cli/dev/tui/stream-format.js +1 -1
- package/dist/src/cli/dev/tui/subagent-pump.js +1 -1
- package/dist/src/cli/dev/tui/terminal-renderer.js +12 -12
- package/dist/src/cli/dev/tui/test/fake-setup-flow-renderer.js +1 -1
- package/dist/src/cli/dev/tui/test/mock-terminal.js +1 -1
- package/dist/src/cli/dev/tui/theme.d.ts +0 -8
- package/dist/src/cli/dev/tui/theme.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +1 -1
- package/dist/src/compiler/extension-compatibility.d.ts +25 -6
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/compiler/normalize-agent-config.js +1 -1
- package/dist/src/compiler/normalize-tool.js +1 -1
- package/dist/src/context/build-dynamic-tools.js +1 -1
- package/dist/src/context/dynamic-tool-lifecycle.js +1 -1
- package/dist/src/evals/runner/derive-run-facts.js +1 -1
- package/dist/src/evals/types.d.ts +4 -3
- package/dist/src/eve-channel/request.js +1 -1
- package/dist/src/execution/cancel-descendant-turns-step.js +1 -1
- package/dist/src/execution/cancel-indexed-session-tasks-step.d.ts +2 -1
- package/dist/src/execution/cancel-indexed-session-tasks-step.js +1 -1
- package/dist/src/execution/coordination-dispatch-shared.d.ts +1 -6
- 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/legacy-session/interrupt-step.js +1 -1
- package/dist/src/execution/node-step.js +1 -1
- package/dist/src/execution/proxied-deliver-step.js +1 -1
- package/dist/src/execution/route-child-delivery.js +3 -1
- package/dist/src/execution/session/admission.js +1 -1
- package/dist/src/execution/session/handoff-steps.js +1 -1
- package/dist/src/execution/session/handoff.d.ts +2 -1
- package/dist/src/execution/session/handoff.js +1 -1
- package/dist/src/execution/session/input-queue.d.ts +2 -0
- package/dist/src/execution/session/input-queue.js +1 -1
- package/dist/src/execution/session/next-input.js +1 -1
- package/dist/src/execution/session/turn.js +1 -1
- package/dist/src/execution/session-workflow-tool-run.js +1 -1
- package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
- package/dist/src/execution/stable-workflow-names.d.ts +0 -1
- package/dist/src/execution/stable-workflow-names.js +1 -1
- package/dist/src/execution/tasks/child/notify.d.ts +44 -0
- package/dist/src/execution/tasks/child/notify.js +1 -0
- package/dist/src/execution/tasks/parent/control-shared.d.ts +2 -5
- package/dist/src/execution/tasks/parent/control-shared.js +1 -1
- package/dist/src/execution/tasks/parent/delegate.d.ts +8 -36
- package/dist/src/execution/tasks/parent/delegate.js +1 -1
- package/dist/src/execution/tasks/parent/dispatch.d.ts +3 -5
- package/dist/src/execution/tasks/parent/dispatch.js +1 -1
- package/dist/src/execution/tasks/parent/hitl-proxy-steps.d.ts +4 -1
- package/dist/src/execution/tasks/parent/hitl-proxy-steps.js +1 -1
- package/dist/src/execution/tasks/parent/run-parent.d.ts +5 -19
- package/dist/src/execution/tasks/parent/run-parent.js +1 -1
- package/dist/src/execution/tasks/parent/task-cancel.d.ts +6 -5
- package/dist/src/execution/tasks/parent/task-cancel.js +1 -1
- package/dist/src/execution/tasks/parent/tool-execution.js +1 -1
- package/dist/src/execution/tool-auth.d.ts +3 -9
- package/dist/src/execution/tool-auth.js +1 -1
- package/dist/src/execution/tools/agent-router-workflow.js +1 -1
- package/dist/src/execution/tools/sleep-workflow.js +1 -1
- package/dist/src/execution/tools/subagent/accept-event-step.js +1 -1
- package/dist/src/execution/tools/subagent/emit-event-step.d.ts +11 -0
- package/dist/src/execution/tools/subagent/emit-event-step.js +1 -0
- package/dist/src/execution/tools/subagent/invoke-agent.d.ts +5 -7
- package/dist/src/execution/tools/subagent/invoke-agent.js +1 -1
- package/dist/src/execution/tools/subagent/invoke-preparation.js +1 -1
- package/dist/src/execution/tools/subagent/invoke-step.d.ts +3 -2
- package/dist/src/execution/tools/subagent/invoke-step.js +1 -1
- package/dist/src/execution/tools/subagent/task-agent-requests.d.ts +0 -1
- package/dist/src/execution/tools/subagent/task-agent-requests.js +1 -1
- package/dist/src/execution/tools/subagent/task-cancel.d.ts +1 -1
- package/dist/src/execution/tools/subagent/task-cancel.js +1 -1
- package/dist/src/execution/tools/workflow/background.d.ts +1 -1
- package/dist/src/execution/tools/workflow/background.js +1 -1
- package/dist/src/execution/tools/workflow/body.d.ts +0 -2
- package/dist/src/execution/tools/workflow/body.js +1 -1
- package/dist/src/execution/tools/workflow/cancel.d.ts +4 -3
- package/dist/src/execution/tools/workflow/cancel.js +1 -1
- package/dist/src/execution/tools/workflow/cancellation-policy.d.ts +2 -0
- package/dist/src/execution/tools/workflow/cancellation-policy.js +1 -0
- package/dist/src/execution/tools/workflow/messages.d.ts +0 -1
- package/dist/src/execution/tools/workflow/owner-channels.d.ts +6 -6
- package/dist/src/execution/tools/workflow/owner-inbox.d.ts +5 -9
- package/dist/src/execution/tools/workflow/owner-inbox.js +1 -1
- package/dist/src/execution/tools/workflow/owner.d.ts +6 -2
- package/dist/src/execution/tools/workflow/owner.js +1 -1
- package/dist/src/execution/tools/workflow/start.js +1 -1
- package/dist/src/execution/tools/workflow/types.d.ts +11 -19
- package/dist/src/execution/tools/workflow/types.js +1 -1
- package/dist/src/execution/tools/workflow/workflow-owner-background.d.ts +13 -0
- package/dist/src/execution/tools/workflow/workflow-owner-background.js +1 -0
- package/dist/src/execution/tools/workflow/workflow-owner-blocking.d.ts +12 -0
- package/dist/src/execution/tools/workflow/workflow-owner-blocking.js +1 -0
- package/dist/src/execution/tools/workflow/workflow.d.ts +3 -3
- package/dist/src/execution/tools/workflow/workflow.js +1 -1
- package/dist/src/execution/workflow-runtime.d.ts +0 -4
- package/dist/src/execution/workflow-runtime.js +1 -1
- package/dist/src/harness/background-tools.d.ts +3 -5
- package/dist/src/harness/coordination.js +1 -1
- package/dist/src/harness/emission.js +1 -1
- package/dist/src/harness/execute-tool.d.ts +2 -29
- package/dist/src/harness/tool-loop.js +1 -1
- package/dist/src/harness/tool-model-output.js +1 -1
- package/dist/src/harness/tools.js +1 -1
- package/dist/src/harness/workflow-tool-runs.d.ts +53 -18
- package/dist/src/harness/workflow-tool-runs.js +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/nitro/dev-runtime-artifacts.js +1 -1
- package/dist/src/protocol/message.d.ts +4 -4
- package/dist/src/public/tools/index.d.ts +2 -2
- package/dist/src/runtime/agent/resolve-model.js +1 -1
- package/dist/src/runtime/connections/scoped-authorization.js +1 -1
- package/dist/src/runtime/sessions/turn.d.ts +10 -8
- package/dist/src/runtime/subagents/registry.js +1 -1
- package/dist/src/runtime/subagents/workflow.js +1 -1
- package/dist/src/runtime/tools/registry.js +1 -1
- package/dist/src/setup/flows/model.d.ts +5 -5
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/shared/action-types.d.ts +0 -4
- package/dist/src/shared/action-types.js +1 -1
- package/dist/src/tasks/delivery-context.js +2 -2
- package/dist/src/tasks/notification.d.ts +4 -0
- package/dist/src/tasks/notification.js +1 -0
- package/dist/src/tasks/session-task-cohorts.d.ts +1 -12
- package/dist/src/tasks/session-task-cohorts.js +1 -1
- package/dist/src/tasks/transitions.d.ts +5 -2
- package/dist/src/tasks/transitions.js +1 -1
- package/dist/src/tasks/types.d.ts +2 -52
- package/dist/src/tasks/types.js +1 -1
- package/dist/src/tools/definition.d.ts +1 -25
- package/dist/src/tools/definition.js +1 -1
- package/dist/src/tools/dynamic.d.ts +1 -3
- package/dist/src/tools/framework/agent.d.ts +16 -22
- package/dist/src/tools/framework/agent.js +1 -1
- package/dist/src/tools/workflow-definition.d.ts +16 -5
- package/dist/src/tracing/agent-invocation-coordinator.js +1 -1
- package/dist/src/tracing/agent-trace-context-store.js +1 -1
- package/docs/concepts/execution-model-and-durability.mdx +4 -5
- package/docs/concepts/sessions-runs-and-streaming.md +2 -2
- package/docs/evals/assertions.mdx +5 -1
- package/docs/guides/dev-tui.md +21 -9
- package/docs/guides/frontend/overview.mdx +1 -1
- package/docs/subagents/index.mdx +12 -9
- package/docs/tools/overview.mdx +26 -34
- package/docs/tools/workflows.mdx +31 -24
- package/package.json +1 -1
- package/dist/src/cli/dev/tui/model-editor.d.ts +0 -103
- package/dist/src/cli/dev/tui/model-editor.js +0 -1
- package/dist/src/execution/tasks/child/steps.d.ts +0 -81
- package/dist/src/execution/tasks/child/steps.js +0 -1
- package/dist/src/execution/tasks/child/workflow.d.ts +0 -28
- package/dist/src/execution/tasks/child/workflow.js +0 -1
- package/dist/src/execution/tools/subagent/emit-called-step.d.ts +0 -9
- package/dist/src/execution/tools/subagent/emit-called-step.js +0 -1
- package/dist/src/execution/tools/workflow/run-control.d.ts +0 -14
- package/dist/src/execution/tools/workflow/run-control.js +0 -1
- package/dist/src/tasks/session-index.d.ts +0 -65
- package/dist/src/tasks/session-index.js +0 -1
- package/dist/src/tools/task.d.ts +0 -55
- package/dist/src/tools/task.js +0 -1
|
@@ -4,15 +4,17 @@ import type { InternalToolDefinition } from "#tools/definition.js";
|
|
|
4
4
|
import type { AgentSourceOwner } from "#compiler/source-graph.js";
|
|
5
5
|
import type { PreparedToolBehavior } from "#tools/behavior.js";
|
|
6
6
|
/** Grouped durable workflow metadata for one prepared harness tool. */
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
export interface PreparedRuntimeWorkflowTask {
|
|
8
|
+
/**
|
|
9
|
+
* Runtime graph ID of the agent definition this tool delegates to, including
|
|
10
|
+
* the root agent for the framework `agent` tool. Used for receipts and handle
|
|
11
|
+
* reservations; `agentId` identifies the resulting agent instance.
|
|
12
|
+
* Absent for authored workflow tools, even if their body calls `ctx.agent()`.
|
|
13
|
+
*/
|
|
14
|
+
readonly nodeId?: string;
|
|
15
|
+
/** Registered workflow definition to execute. */
|
|
10
16
|
readonly workflowId: string;
|
|
11
|
-
}
|
|
12
|
-
readonly nodeId: string;
|
|
13
|
-
readonly resultKind: "subagent";
|
|
14
|
-
readonly workflowId: string;
|
|
15
|
-
};
|
|
17
|
+
}
|
|
16
18
|
/**
|
|
17
19
|
* Serializable authored tool descriptor prepared by the runtime for one
|
|
18
20
|
* harness turn.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{serializeInputSchema,serializeOutputSchema}from"#tools/schema.js";import{SUBAGENT_TASK_RECEIPT_OUTPUT_SCHEMA}from"#tools/framework/task-contract.js";import{SUBAGENT_TOOL_INPUT_SCHEMA}from"#tools/framework/agent-contract.js";import{subagentToolExecuteWorkflowReference}from"#runtime/subagents/workflow-reference.js";import{RuntimeRegistry,RuntimeRegistryError}from"#internal/runtime-registry.js";const SUBAGENT_TOOL_INPUT_JSON_SCHEMA=serializeInputSchema(SUBAGENT_TOOL_INPUT_SCHEMA),SUBAGENT_TOOL_OUTPUT_JSON_SCHEMA=serializeOutputSchema(SUBAGENT_TASK_RECEIPT_OUTPUT_SCHEMA);function createRuntimeSubagentRegistry(e){let t=[],n=new Set,r=[],i=new RuntimeRegistry(`subagent`),a=new Set(e.reservedToolNames??[]),o=new Set(e.disabledToolNames??[]),s=new Map;for(let c of e.subagents){let e={logicalPath:c.logicalPath,sourceId:c.sourceId};if(s.has(c.nodeId))throw new RuntimeRegistryError(`subagent`,`Found multiple runtime subagents mapped to node id "${c.nodeId}".`,{...e,entryName:c.name});let l,u=c.kind===`subagent`?c.dynamic:void 0;if(u===void 0){let n=createPreparedRuntimeSubagentTool(c,SUBAGENT_TOOL_INPUT_JSON_SCHEMA);l={definition:c,prepared:n},i.register(c.name,l,{location:e,duplicateMessage:`Found multiple subagents named "${c.name}". Subagent names must be unique at runtime.`});let r=c.tool!==!1&&!o.has(c.name);if(r&&a.has(c.name))throw new RuntimeRegistryError(`subagent`,`Subagent "${c.name}" collides with another runtime-visible tool name.`,{...e,entryName:c.name});r&&t.push(n)}else n.add(c.nodeId),r.push({...u,kind:`subagent`,logicalPath:c.logicalPath,name:c.name,nodeId:c.nodeId,sourceId:c.sourceId,sourceKind:`module`,tool:!o.has(c.name)&&void 0}),l={definition:c};s.set(c.nodeId,l)}return{dynamicNodeIds:n,dynamicResolvers:r,preparedTools:t,subagentsByName:i.asMap(),subagentsByNodeId:s}}function createPreparedRuntimeSubagentTool(e,t=SUBAGENT_TOOL_INPUT_JSON_SCHEMA){if(e.description===void 0)throw Error(`Static subagent "${e.name}" is missing a description.`);return{behavior:{availability:[],handling:{kind:`dispatch`,target:e.kind===`remote`?{kind:`remote-agent-call`,nodeId:e.nodeId,remoteAgentName:e.name}:{kind:`subagent-call`,nodeId:e.nodeId,subagentName:e.name}}},description:`${e.description}\n\nThis call starts a background task and returns a task receipt immediately.`,execution:`background`,inputSchema:t,kind:e.kind,logicalPath:e.logicalPath,name:e.name,nodeId:e.nodeId,outputSchema:SUBAGENT_TOOL_OUTPUT_JSON_SCHEMA,sourceId:e.sourceId,task:{nodeId:e.nodeId,
|
|
1
|
+
import{serializeInputSchema,serializeOutputSchema}from"#tools/schema.js";import{SUBAGENT_TASK_RECEIPT_OUTPUT_SCHEMA}from"#tools/framework/task-contract.js";import{SUBAGENT_TOOL_INPUT_SCHEMA}from"#tools/framework/agent-contract.js";import{subagentToolExecuteWorkflowReference}from"#runtime/subagents/workflow-reference.js";import{RuntimeRegistry,RuntimeRegistryError}from"#internal/runtime-registry.js";const SUBAGENT_TOOL_INPUT_JSON_SCHEMA=serializeInputSchema(SUBAGENT_TOOL_INPUT_SCHEMA),SUBAGENT_TOOL_OUTPUT_JSON_SCHEMA=serializeOutputSchema(SUBAGENT_TASK_RECEIPT_OUTPUT_SCHEMA);function createRuntimeSubagentRegistry(e){let t=[],n=new Set,r=[],i=new RuntimeRegistry(`subagent`),a=new Set(e.reservedToolNames??[]),o=new Set(e.disabledToolNames??[]),s=new Map;for(let c of e.subagents){let e={logicalPath:c.logicalPath,sourceId:c.sourceId};if(s.has(c.nodeId))throw new RuntimeRegistryError(`subagent`,`Found multiple runtime subagents mapped to node id "${c.nodeId}".`,{...e,entryName:c.name});let l,u=c.kind===`subagent`?c.dynamic:void 0;if(u===void 0){let n=createPreparedRuntimeSubagentTool(c,SUBAGENT_TOOL_INPUT_JSON_SCHEMA);l={definition:c,prepared:n},i.register(c.name,l,{location:e,duplicateMessage:`Found multiple subagents named "${c.name}". Subagent names must be unique at runtime.`});let r=c.tool!==!1&&!o.has(c.name);if(r&&a.has(c.name))throw new RuntimeRegistryError(`subagent`,`Subagent "${c.name}" collides with another runtime-visible tool name.`,{...e,entryName:c.name});r&&t.push(n)}else n.add(c.nodeId),r.push({...u,kind:`subagent`,logicalPath:c.logicalPath,name:c.name,nodeId:c.nodeId,sourceId:c.sourceId,sourceKind:`module`,tool:!o.has(c.name)&&void 0}),l={definition:c};s.set(c.nodeId,l)}return{dynamicNodeIds:n,dynamicResolvers:r,preparedTools:t,subagentsByName:i.asMap(),subagentsByNodeId:s}}function createPreparedRuntimeSubagentTool(e,t=SUBAGENT_TOOL_INPUT_JSON_SCHEMA){if(e.description===void 0)throw Error(`Static subagent "${e.name}" is missing a description.`);return{behavior:{availability:[],handling:{kind:`dispatch`,target:e.kind===`remote`?{kind:`remote-agent-call`,nodeId:e.nodeId,remoteAgentName:e.name}:{kind:`subagent-call`,nodeId:e.nodeId,subagentName:e.name}}},description:`${e.description}\n\nThis call starts a background task and returns a task receipt immediately.`,execution:`background`,inputSchema:t,kind:e.kind,logicalPath:e.logicalPath,name:e.name,nodeId:e.nodeId,outputSchema:SUBAGENT_TOOL_OUTPUT_JSON_SCHEMA,sourceId:e.sourceId,task:{nodeId:e.nodeId,workflowId:subagentToolExecuteWorkflowReference.workflowId}}}export{createPreparedRuntimeSubagentTool,createRuntimeSubagentRegistry};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{invokeAgent}from"#execution/tools/subagent/invoke-agent.js";async function subagentToolExecuteWorkflow(e,t){"use workflow";let n={...typeof e.agentId==`string`&&e.agentId.trim()!==``?{agentId:e.agentId}:{},message:e.message,outputSchema:e.outputSchema,target:t.toolName};return await invokeAgent(t,n,{invocationId:t.callId
|
|
1
|
+
import{invokeAgent}from"#execution/tools/subagent/invoke-agent.js";async function subagentToolExecuteWorkflow(e,t){"use workflow";let n={...typeof e.agentId==`string`&&e.agentId.trim()!==``?{agentId:e.agentId}:{},message:e.message,outputSchema:e.outputSchema,target:t.toolName};return await invokeAgent(t,n,{invocationId:t.callId})}subagentToolExecuteWorkflow.workflowId=`workflow//eve//subagentToolExecuteWorkflow`;export{subagentToolExecuteWorkflow};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{serializeInputSchema,serializeOutputSchema}from"#tools/schema.js";import{ROOT_RUNTIME_AGENT_NODE_ID}from"#runtime/graph.js";import{AGENT_TOOL_NAME}from"#tools/framework/agent-contract.js";import{subagentToolExecuteWorkflowReference}from"#runtime/subagents/workflow-reference.js";import{RuntimeRegistry}from"#internal/runtime-registry.js";async function createRuntimeToolRegistry(e,t={}){let n=[],r=new RuntimeRegistry(`tool`,t.reservedToolNames??[]);for(let i of e.tools){let e=await createPreparedRuntimeTool(i,t.nodeId);r.register(i.name,{definition:i,prepared:e},{location:{logicalPath:i.logicalPath,sourceId:i.sourceId},duplicateMessage:`Found multiple authored tools named "${i.name}". Tool names must be unique at runtime.`,reservedMessage:`Tool "${i.name}" collides with another runtime-visible tool name.`}),n.push(e)}return{preparedTools:n,toolsByName:r.asMap()}}function findRegisteredRuntimeTool(e,t){return e.toolsByName.get(t)??null}async function createPreparedRuntimeTool(e,t){let n=e.behavior?.handling?.kind===`dispatch`&&e.behavior.handling.action===`self-agent`,r=n?subagentToolExecuteWorkflowReference.workflowId:e.behavior?.handling?.kind===`workflow-tool`?e.behavior.handling.workflowId:void 0;return{availableInSubagents:e.availableInSubagents,behavior:prepareToolBehavior(e.behavior,t,n?subagentToolExecuteWorkflowReference.workflowId:void 0),description:e.description,execution:e.execution,inputSchema:serializeInputSchema(e.inputSchema),kind:`authored-tool`,logicalPath:e.logicalPath,name:e.name,owner:e.owner,outputSchema:serializeOutputSchema(e.outputSchema),rootOnly:n||void 0,sourceId:e.sourceId,task:r===void 0?void 0:n?{nodeId:ROOT_RUNTIME_AGENT_NODE_ID,
|
|
1
|
+
import{serializeInputSchema,serializeOutputSchema}from"#tools/schema.js";import{ROOT_RUNTIME_AGENT_NODE_ID}from"#runtime/graph.js";import{AGENT_TOOL_NAME}from"#tools/framework/agent-contract.js";import{subagentToolExecuteWorkflowReference}from"#runtime/subagents/workflow-reference.js";import{RuntimeRegistry}from"#internal/runtime-registry.js";async function createRuntimeToolRegistry(e,t={}){let n=[],r=new RuntimeRegistry(`tool`,t.reservedToolNames??[]);for(let i of e.tools){let e=await createPreparedRuntimeTool(i,t.nodeId);r.register(i.name,{definition:i,prepared:e},{location:{logicalPath:i.logicalPath,sourceId:i.sourceId},duplicateMessage:`Found multiple authored tools named "${i.name}". Tool names must be unique at runtime.`,reservedMessage:`Tool "${i.name}" collides with another runtime-visible tool name.`}),n.push(e)}return{preparedTools:n,toolsByName:r.asMap()}}function findRegisteredRuntimeTool(e,t){return e.toolsByName.get(t)??null}async function createPreparedRuntimeTool(e,t){let n=e.behavior?.handling?.kind===`dispatch`&&e.behavior.handling.action===`self-agent`,r=n?subagentToolExecuteWorkflowReference.workflowId:e.behavior?.handling?.kind===`workflow-tool`?e.behavior.handling.workflowId:void 0;return{availableInSubagents:e.availableInSubagents,behavior:prepareToolBehavior(e.behavior,t,n?subagentToolExecuteWorkflowReference.workflowId:void 0),description:e.description,execution:e.execution,inputSchema:serializeInputSchema(e.inputSchema),kind:`authored-tool`,logicalPath:e.logicalPath,name:e.name,owner:e.owner,outputSchema:serializeOutputSchema(e.outputSchema),rootOnly:n||void 0,sourceId:e.sourceId,task:r===void 0?void 0:n?{nodeId:ROOT_RUNTIME_AGENT_NODE_ID,workflowId:r}:{workflowId:r}}}function prepareToolBehavior(e,t,n){if(e===void 0)return;let r;if(n!==void 0&&t!==void 0)r={kind:`dispatch`,target:{kind:`self-agent-call`,nodeId:t,subagentName:AGENT_TOOL_NAME}};else if(e.handling?.kind===`dispatch`){if(e.handling.action===`self-agent`&&t===void 0)throw Error(`The self-agent tool requires a concrete runtime node id.`);r={kind:`dispatch`,target:e.handling.action===`self-agent`?{kind:`self-agent-call`,nodeId:t,subagentName:AGENT_TOOL_NAME}:{kind:e.handling.action}}}else r=e.handling?.kind===`workflow-tool`?{kind:`dispatch`,target:{kind:`workflow-tool-call`,workflowId:n??e.handling.workflowId}}:e.handling;return{availability:e.availability,handling:r,presentation:e.presentation}}export{createRuntimeToolRegistry,findRegisteredRuntimeTool};
|
|
@@ -25,8 +25,8 @@ export interface CurrentAgentModel {
|
|
|
25
25
|
}
|
|
26
26
|
export type { GatewayServiceTierState };
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
28
|
+
* The model picker inputs, resolved before it opens. The first step is a
|
|
29
|
+
* searchable catalog, or a fixed model when
|
|
30
30
|
* the authored model is a source-backed SDK call `/model` cannot rewrite.
|
|
31
31
|
*/
|
|
32
32
|
export interface ModelSettingsRequest {
|
|
@@ -59,7 +59,7 @@ export interface ModelSettingsResult {
|
|
|
59
59
|
reasoning?: "default" | ReasoningLevel;
|
|
60
60
|
serviceTier?: "standard" | "priority";
|
|
61
61
|
}
|
|
62
|
-
/** Renderer-owned
|
|
62
|
+
/** Renderer-owned model picker; only the dev TUI implements this. */
|
|
63
63
|
export type ModelSettingsPicker = (request: ModelSettingsRequest) => Promise<ModelSettingsResult | undefined>;
|
|
64
64
|
/** Injected for tests; defaults to the real reads, fetches, and source edit. */
|
|
65
65
|
export interface ModelFlowDeps {
|
|
@@ -75,7 +75,7 @@ export interface ModelFlowDeps {
|
|
|
75
75
|
}) => Promise<ApplyModelSettingsOutcome>;
|
|
76
76
|
/** Catalog fetch behind the shared model picker. */
|
|
77
77
|
selectModel?: SelectModelDeps;
|
|
78
|
-
/** The
|
|
78
|
+
/** The model picker; the dev TUI renderer implements it. */
|
|
79
79
|
pickModelSettings?: ModelSettingsPicker;
|
|
80
80
|
}
|
|
81
81
|
export type ModelFlowResult = {
|
|
@@ -91,7 +91,7 @@ export type ModelFlowResult = {
|
|
|
91
91
|
/** The provider selected in a completed provider sub-flow. */
|
|
92
92
|
providerSelection?: ProviderSelection;
|
|
93
93
|
};
|
|
94
|
-
/** Selects a model
|
|
94
|
+
/** Selects a model, speed, and reasoning, then applies the completed selection together. */
|
|
95
95
|
export declare function runModelFlow(input: {
|
|
96
96
|
/** Selected agent root whose authored model settings are edited. */
|
|
97
97
|
appRoot: string;
|
|
@@ -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.
|
|
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.63.0`,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__",
|
|
@@ -93,10 +93,6 @@ export declare const runtimeWorkflowTaskRequestSchema: z.ZodObject<{
|
|
|
93
93
|
input: z.ZodType<import("#shared/json.js").JsonObject, unknown, z.core.$ZodTypeInternals<import("#shared/json.js").JsonObject, unknown>>;
|
|
94
94
|
kind: z.ZodLiteral<"workflow-task">;
|
|
95
95
|
nodeId: z.ZodOptional<z.ZodString>;
|
|
96
|
-
resultKind: z.ZodOptional<z.ZodEnum<{
|
|
97
|
-
subagent: "subagent";
|
|
98
|
-
tool: "tool";
|
|
99
|
-
}>>;
|
|
100
96
|
toolName: z.ZodString;
|
|
101
97
|
workflowId: z.ZodString;
|
|
102
98
|
}, z.core.$strict>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z}from"#compiled/zod/index.js";import{jsonObjectSchema,jsonValueSchema}from"#shared/json-schemas.js";import{agentTurnOutcomeSchema,agentTurnOutcomeWithCostSchema}from"#shared/agent-turn-outcome.js";import{tokenUsageSchema,tokenUsageWithCostSchema}from"#shared/token-usage.js";const runtimeToolCallActionRequestSchema=z.object({callId:z.string(),input:jsonObjectSchema,kind:z.literal(`tool-call`),toolName:z.string()}).strict(),runtimeSubagentCallActionRequestSchema=z.object({callId:z.string(),description:z.string(),input:jsonObjectSchema,kind:z.literal(`subagent-call`),name:z.string(),nodeId:z.string(),subagentName:z.string()}).strict(),runtimeRemoteAgentCallActionRequestSchema=z.object({callId:z.string(),description:z.string(),input:jsonObjectSchema,kind:z.literal(`remote-agent-call`),name:z.string(),nodeId:z.string(),remoteAgentName:z.string()}).strict(),runtimeWorkflowToolCallActionRequestSchema=z.object({callId:z.string(),input:jsonObjectSchema,kind:z.literal(`workflow-tool-call`),toolName:z.string(),workflowId:z.string()}).strict();z.object({callId:z.string(),description:z.string(),input:jsonObjectSchema,kind:z.literal(`subagent-call`),name:z.string(),nodeId:z.string(),subagentName:z.string()}).strict();const runtimeRemoteAgentDispatchRequestSchema=z.object({callId:z.string(),description:z.string(),input:jsonObjectSchema,kind:z.literal(`remote-agent-call`),name:z.string(),nodeId:z.string(),remoteAgentName:z.string()}).strict(),runtimeWorkflowTaskRequestSchema=z.object({callId:z.string(),executeInput:jsonValueSchema.optional(),input:jsonObjectSchema,kind:z.literal(`workflow-task`),nodeId:z.string().optional(),
|
|
1
|
+
import{z}from"#compiled/zod/index.js";import{jsonObjectSchema,jsonValueSchema}from"#shared/json-schemas.js";import{agentTurnOutcomeSchema,agentTurnOutcomeWithCostSchema}from"#shared/agent-turn-outcome.js";import{tokenUsageSchema,tokenUsageWithCostSchema}from"#shared/token-usage.js";const runtimeToolCallActionRequestSchema=z.object({callId:z.string(),input:jsonObjectSchema,kind:z.literal(`tool-call`),toolName:z.string()}).strict(),runtimeSubagentCallActionRequestSchema=z.object({callId:z.string(),description:z.string(),input:jsonObjectSchema,kind:z.literal(`subagent-call`),name:z.string(),nodeId:z.string(),subagentName:z.string()}).strict(),runtimeRemoteAgentCallActionRequestSchema=z.object({callId:z.string(),description:z.string(),input:jsonObjectSchema,kind:z.literal(`remote-agent-call`),name:z.string(),nodeId:z.string(),remoteAgentName:z.string()}).strict(),runtimeWorkflowToolCallActionRequestSchema=z.object({callId:z.string(),input:jsonObjectSchema,kind:z.literal(`workflow-tool-call`),toolName:z.string(),workflowId:z.string()}).strict();z.object({callId:z.string(),description:z.string(),input:jsonObjectSchema,kind:z.literal(`subagent-call`),name:z.string(),nodeId:z.string(),subagentName:z.string()}).strict();const runtimeRemoteAgentDispatchRequestSchema=z.object({callId:z.string(),description:z.string(),input:jsonObjectSchema,kind:z.literal(`remote-agent-call`),name:z.string(),nodeId:z.string(),remoteAgentName:z.string()}).strict(),runtimeWorkflowTaskRequestSchema=z.object({callId:z.string(),executeInput:jsonValueSchema.optional(),input:jsonObjectSchema,kind:z.literal(`workflow-task`),nodeId:z.string().optional(),toolName:z.string(),workflowId:z.string()}).strict(),runtimeLoadSkillActionRequestSchema=z.object({callId:z.string(),input:jsonObjectSchema,kind:z.literal(`load-skill`)}).strict(),RUNTIME_WORKFLOW_TOOL_ACTION=Symbol.for(`eve:runtime-workflow-tool-action`);function markRuntimeWorkflowToolAction(e){return Object.defineProperty(e,RUNTIME_WORKFLOW_TOOL_ACTION,{value:!0}),e}function isRuntimeWorkflowToolAction(e){return e.kind===`workflow-tool-call`||e.kind===`tool-call`&&Reflect.get(e,RUNTIME_WORKFLOW_TOOL_ACTION)===!0}const runtimeActionRequestSchema=z.discriminatedUnion(`kind`,[runtimeLoadSkillActionRequestSchema,runtimeRemoteAgentCallActionRequestSchema,runtimeSubagentCallActionRequestSchema,runtimeToolCallActionRequestSchema,runtimeWorkflowToolCallActionRequestSchema]);z.object({callId:z.string(),isError:z.boolean().optional(),kind:z.literal(`tool-result`),output:jsonValueSchema,toolName:z.string()}).strict();const runtimeSubagentChildResultFields={backgroundTask:z.strictObject({status:z.literal(`working`),taskId:z.string()}).optional(),callId:z.string(),isError:z.boolean().optional(),kind:z.literal(`subagent-result`),origin:z.literal(`child`),output:jsonValueSchema,subagentName:z.string()},runtimeSubagentChildResultSchema=z.object({backgroundTask:z.strictObject({status:z.literal(`working`),taskId:z.string()}).optional(),callId:z.string(),isError:z.boolean().optional(),kind:z.literal(`subagent-result`),origin:z.literal(`child`),outcome:agentTurnOutcomeSchema,output:jsonValueSchema,subagentName:z.string(),usage:tokenUsageSchema.optional()}).strict(),runtimeSubagentChildResultWithCostSchema=z.object({...runtimeSubagentChildResultFields,outcome:agentTurnOutcomeWithCostSchema,usage:tokenUsageWithCostSchema.optional()}).strict();z.object({callId:z.string(),isError:z.literal(!0),kind:z.literal(`subagent-result`),origin:z.literal(`dispatch`),output:jsonValueSchema,subagentName:z.string()}).strict(),z.object({callId:z.string(),isError:z.boolean().optional(),kind:z.literal(`load-skill-result`),output:jsonValueSchema,name:z.string().optional()}).strict();export{isRuntimeWorkflowToolAction,markRuntimeWorkflowToolAction,runtimeActionRequestSchema,runtimeRemoteAgentCallActionRequestSchema,runtimeRemoteAgentDispatchRequestSchema,runtimeSubagentChildResultSchema,runtimeSubagentChildResultWithCostSchema,runtimeToolCallActionRequestSchema,runtimeWorkflowTaskRequestSchema};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{markFrameworkStepInput}from"#harness/messages.js";import{
|
|
1
|
+
import{markFrameworkStepInput}from"#harness/messages.js";import{getBackgroundWorkflowToolRuns,readWorkflowTaskView}from"#harness/workflow-tool-runs.js";import{getTaskCohortId}from"#tasks/session-task-cohorts.js";import{EMPTY_DELIVERY_SENTINEL}from"#shared/empty-delivery.js";const TASK_DELIVERY_CONTEXT_LABEL=`[Task state]`,TASK_DELIVERY_INITIATING_INSTRUCTION=`Background task reporting: launch acknowledgement
|
|
2
2
|
The latest ${TASK_DELIVERY_CONTEXT_LABEL} message is runtime-authored and lists background tasks accepted so far from the current turn. They continue independently after this turn.
|
|
3
3
|
|
|
4
|
-
Continue carrying out the user's request, including starting any remaining background work. When no further tool calls are needed in this turn, send one brief user-facing acknowledgement that the background work has started. Do not wait for results or report results that are not available yet. End the turn after the acknowledgement.`,TASK_DELIVERY_SETTLED_INSTRUCTION=`Background task reporting\nThis turn was triggered by background task activity. The accompanying ${TASK_DELIVERY_CONTEXT_LABEL} message is runtime-authored and lists overlapping background tasks in the same cohort, potentially started across different user turns, all settled, with every available terminal output. Do not reply with ${EMPTY_DELIVERY_SENTINEL}. Send one user-facing response that combines their useful results.`;function getBackgroundTaskDelivery(e){if(typeof e!=`object`||!e)return;let t=e;return t.kind===`deliver`&&typeof t.taskDeliveryId==`string`?e:void 0}function markBackgroundTaskStepInput(e){return e.message===void 0?e:markFrameworkStepInput(e,`execution.background_task`)}function resolveTaskDeliveryContext(e){let t=
|
|
4
|
+
Continue carrying out the user's request, including starting any remaining background work. When no further tool calls are needed in this turn, send one brief user-facing acknowledgement that the background work has started. Do not wait for results or report results that are not available yet. End the turn after the acknowledgement.`,TASK_DELIVERY_SETTLED_INSTRUCTION=`Background task reporting\nThis turn was triggered by background task activity. The accompanying ${TASK_DELIVERY_CONTEXT_LABEL} message is runtime-authored and lists overlapping background tasks in the same cohort, potentially started across different user turns, all settled, with every available terminal output. Do not reply with ${EMPTY_DELIVERY_SENTINEL}. Send one user-facing response that combines their useful results.`;function getBackgroundTaskDelivery(e){if(typeof e!=`object`||!e)return;let t=e;return t.kind===`deliver`&&typeof t.taskDeliveryId==`string`?e:void 0}function markBackgroundTaskStepInput(e){return e.message===void 0?e:markFrameworkStepInput(e,`execution.background_task`)}function resolveTaskDeliveryContext(e){let t=getBackgroundWorkflowToolRuns(e.state),n=t.find(t=>e.taskDeliveryId.startsWith(`${t.task.taskId}:`));return n===void 0?void 0:{...projectTaskCohort(t.filter(e=>getTaskCohortId(e.task)===getTaskCohortId(n.task))),rootTurnId:n.origin.turnId}}function resolveInitiatingTaskContext(e){let t=getBackgroundWorkflowToolRuns(e.state).filter(t=>t.origin.turnId===e.turnId);if(t.some(e=>e.task.outcome===void 0))return{...projectTaskCohort(t),phase:`initiating`}}function projectTaskCohort(e){let t=e.every(e=>e.task.outcome!==void 0),n=e.map(e=>{let n=readWorkflowTaskView(e.task);return{name:e.task.metadata.name,output:t?n?.lastOutput:void 0,status:n?.status??`pending`,taskId:e.task.taskId}});return{context:`${TASK_DELIVERY_CONTEXT_LABEL}\n${JSON.stringify({tasks:n})}`,phase:t?`settled`:`pending`}}export{TASK_DELIVERY_CONTEXT_LABEL,TASK_DELIVERY_INITIATING_INSTRUCTION,TASK_DELIVERY_SETTLED_INSTRUCTION,getBackgroundTaskDelivery,markBackgroundTaskStepInput,resolveInitiatingTaskContext,resolveTaskDeliveryContext};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function formatTaskNotification(e){let t=`Background task ${e.taskId} (${e.metadata.name})`;return e.status===`input_required`?`${t} needs input.`:e.status===`completed`?`${t} is completed.\n\nResult:\n${formatTaskOutput(e.lastOutput.data)}`:e.status===`failed`?`${t} failed.\n\nError:\n${formatTaskOutput(e.lastOutput.data)}`:`${t} is cancelled.`}function formatTaskOutput(e){return typeof e==`string`?e:JSON.stringify(e)??`null`}export{formatTaskNotification,formatTaskOutput};
|
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
import type { SessionStateMap } from "#harness/types.js";
|
|
2
|
-
/** Session-state key for the parent's task index; mutable task records live in task runs. */
|
|
3
|
-
export declare const SESSION_TASKS_STATE_KEY = "eve.tasks";
|
|
4
|
-
export declare const SESSION_TASKS_STATE_VERSION = 2;
|
|
5
2
|
/** An entry without a join target starts its own cohort. */
|
|
6
3
|
export declare function getTaskCohortId(task: {
|
|
7
4
|
readonly taskId: string;
|
|
8
5
|
readonly cohortId?: string;
|
|
9
6
|
}): string;
|
|
10
|
-
|
|
11
|
-
* Reads cohort identities and settlement for workflow-side completion batching.
|
|
12
|
-
* Full task validation stays in getSessionTaskIndex on the step side, so
|
|
13
|
-
* the workflow bundle does not retain the task schemas and their dependencies.
|
|
14
|
-
*/
|
|
15
|
-
export declare function getSessionTaskCohorts(state: SessionStateMap | undefined): ReadonlyMap<string, {
|
|
16
|
-
readonly cohortId: string;
|
|
17
|
-
readonly settled: boolean;
|
|
18
|
-
}>;
|
|
7
|
+
export declare function getSessionTaskCohorts(state: SessionStateMap | undefined): ReadonlyMap<string, string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{getBackgroundWorkflowToolRuns}from"#harness/workflow-tool-runs.js";function getTaskCohortId(e){return e.cohortId??e.taskId}function getSessionTaskCohorts(e){return new Map(getBackgroundWorkflowToolRuns(e).map(({task:e})=>[e.taskId,getTaskCohortId(e)]))}export{getSessionTaskCohorts,getTaskCohortId};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { WorkflowToolRunOutcomeMessage } from "#execution/tools/workflow/messages.js";
|
|
1
2
|
import { type TaskCommand, type TaskView } from "#tasks/types.js";
|
|
2
3
|
export type TaskTransitionResult = {
|
|
3
4
|
readonly action: "accepted";
|
|
@@ -10,5 +11,7 @@ export type TaskTransitionResult = {
|
|
|
10
11
|
readonly view: TaskView;
|
|
11
12
|
readonly reason: string;
|
|
12
13
|
};
|
|
13
|
-
/** Pure
|
|
14
|
-
export declare function applyTaskTransition(view: TaskView, command: TaskCommand
|
|
14
|
+
/** Pure transition function for the background invocation view. */
|
|
15
|
+
export declare function applyTaskTransition(view: TaskView, command: TaskCommand | ({
|
|
16
|
+
readonly kind: "outcome";
|
|
17
|
+
} & WorkflowToolRunOutcomeMessage)): TaskTransitionResult;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{workflowToolRunFailureOutput}from"#execution/tools/workflow/owner-inbox.js";import{isTerminalTaskStatus,readTaskInputRequestId}from"#tasks/types.js";function applyTaskTransition(e,t){if(isTerminalTaskStatus(e.status))return t.kind===`cancel`&&e.status===`cancelled`?{action:`noop`,view:e}:{action:`rejected`,reason:`Task "${e.taskId}" is already ${e.status}; "${t.kind}" cannot change a terminal task.`,view:e};let n={metadata:e.metadata,taskId:e.taskId};if(t.kind===`outcome`){let e=t.result;return{action:`accepted`,view:e.status===`completed`?{...n,status:`completed`,lastOutput:{type:`result`,data:e.output}}:e.status===`failed`?{...n,status:`failed`,lastOutput:{type:`error`,data:workflowToolRunFailureOutput(t)}}:{...n,status:`cancelled`}}}switch(t.kind){case`reject-dispatch`:return{action:`accepted`,view:{...n,lastOutput:{data:t.data,type:`error`},status:`failed`}};case`cancel`:return{action:`accepted`,view:t.usage===void 0?{...n,status:`cancelled`}:{...n,status:`cancelled`,usage:t.usage}};case`require-input`:return isValidInputRequestBatch(t.inputRequests)?{action:`accepted`,view:{inputRequests:t.inputRequests,metadata:e.metadata,status:`input_required`,taskId:e.taskId}}:{action:`rejected`,reason:`Task "${e.taskId}" received an invalid input request batch.`,view:e};case`ready`:return{action:`accepted`,view:e};case`answered`:{if(e.status!==`input_required`)return{action:`noop`,view:e};let n=new Set(t.requestIds),r=e.inputRequests.filter(e=>{let t=readTaskInputRequestId(e);return t===void 0||!n.has(t)});return r.length===e.inputRequests.length?{action:`noop`,view:e}:r.length>0?{action:`accepted`,view:{...e,inputRequests:r}}:{action:`accepted`,view:{metadata:e.metadata,status:`working`,taskId:e.taskId}}}}}function isValidInputRequestBatch(e){if(e.length===0)return!1;let t=e.map(readTaskInputRequestId);return t.every(e=>e!==void 0&&e.length>0)&&new Set(t).size===t.length}export{applyTaskTransition};
|
|
@@ -2,7 +2,6 @@ import type { SubagentAuthorizationEvent, SubagentAuthorizationEventHookPayload
|
|
|
2
2
|
import type { WorkflowToolAgentRequest } from "#execution/tools/workflow/messages.js";
|
|
3
3
|
import type { SessionInboxAddress } from "#execution/session-inbox/address.js";
|
|
4
4
|
import { type JsonValue } from "#shared/json.js";
|
|
5
|
-
import type { TaskExecutorBinding } from "#tools/task.js";
|
|
6
5
|
/** Durable lifecycle status for one unit of background work. */
|
|
7
6
|
export type TaskStatus = "working" | "input_required" | "completed" | "failed" | "cancelled";
|
|
8
7
|
/** Executor-neutral identity shown for one task. */
|
|
@@ -35,10 +34,6 @@ export declare function readTaskInputRequestId(request: TaskInputRequest): strin
|
|
|
35
34
|
interface TaskViewBase {
|
|
36
35
|
readonly taskId: string;
|
|
37
36
|
readonly metadata: TaskMetadata;
|
|
38
|
-
/** Private executor state, excluded from model-visible JSON. */
|
|
39
|
-
readonly executor?: {
|
|
40
|
-
readonly binding?: TaskExecutorBinding;
|
|
41
|
-
};
|
|
42
37
|
/** Retained for accounting, excluded from model-visible JSON. */
|
|
43
38
|
readonly usage?: TaskUsage;
|
|
44
39
|
}
|
|
@@ -67,19 +62,8 @@ export type TaskView = TaskViewBase & ({
|
|
|
67
62
|
readonly inputRequests?: never;
|
|
68
63
|
readonly lastOutput?: never;
|
|
69
64
|
});
|
|
70
|
-
/**
|
|
65
|
+
/** Admission, cancellation, and input state changes for a background invocation. */
|
|
71
66
|
export type TaskCommand = {
|
|
72
|
-
readonly executor: TaskExecutorBinding;
|
|
73
|
-
readonly kind: "bind";
|
|
74
|
-
} | {
|
|
75
|
-
readonly kind: "complete";
|
|
76
|
-
readonly data: JsonValue;
|
|
77
|
-
readonly usage?: TaskUsage;
|
|
78
|
-
} | {
|
|
79
|
-
readonly kind: "fail";
|
|
80
|
-
readonly data: JsonValue;
|
|
81
|
-
readonly usage?: TaskUsage;
|
|
82
|
-
} | {
|
|
83
67
|
readonly kind: "reject-dispatch";
|
|
84
68
|
readonly data: JsonValue;
|
|
85
69
|
} | {
|
|
@@ -98,31 +82,6 @@ export interface TaskCommandHookPayload {
|
|
|
98
82
|
readonly kind: "task-command";
|
|
99
83
|
readonly command: TaskCommand;
|
|
100
84
|
}
|
|
101
|
-
/** One authored message delivered to the parent as a new turn. */
|
|
102
|
-
export interface TaskInboundMessage {
|
|
103
|
-
readonly callId: string;
|
|
104
|
-
readonly kind: "task-message";
|
|
105
|
-
readonly message: string;
|
|
106
|
-
readonly messageIndex: number;
|
|
107
|
-
readonly messageEpoch: string;
|
|
108
|
-
}
|
|
109
|
-
/** Intermediate progress reported by an executor. */
|
|
110
|
-
export interface TaskInboundUpdate {
|
|
111
|
-
readonly callId: string;
|
|
112
|
-
readonly updateIndex: number;
|
|
113
|
-
readonly updateEpoch: string;
|
|
114
|
-
readonly kind: "task-update";
|
|
115
|
-
readonly message: string;
|
|
116
|
-
}
|
|
117
|
-
/** One workflow-executor request bound to its private answer hook. */
|
|
118
|
-
export interface TaskInboundInputRequest {
|
|
119
|
-
readonly kind: "task-input-request";
|
|
120
|
-
readonly replyTo: string;
|
|
121
|
-
readonly requests: readonly TaskInputRequest[];
|
|
122
|
-
readonly sequence: number;
|
|
123
|
-
readonly stepIndex: number;
|
|
124
|
-
readonly turnId: string;
|
|
125
|
-
}
|
|
126
85
|
/** One human answer routed through the task that owns the blocked executor. */
|
|
127
86
|
export interface TaskInboundAnswerInput {
|
|
128
87
|
readonly auth?: unknown;
|
|
@@ -137,7 +96,7 @@ export interface TaskInboundAnswerInput {
|
|
|
137
96
|
readonly kind: "input-response";
|
|
138
97
|
readonly taskId: string;
|
|
139
98
|
}
|
|
140
|
-
export type TaskRunInboundPayload = TaskCommandHookPayload | TaskInboundAnswerInput
|
|
99
|
+
export type TaskRunInboundPayload = TaskCommandHookPayload | TaskInboundAnswerInput;
|
|
141
100
|
/** Generic task-owned request sent through the parent session payload. */
|
|
142
101
|
interface TaskInputRequestDeliveryBase {
|
|
143
102
|
readonly replyTo: string;
|
|
@@ -172,15 +131,6 @@ export interface TaskAgentRequestDelivery {
|
|
|
172
131
|
readonly request: WorkflowToolAgentRequest;
|
|
173
132
|
readonly taskId: string;
|
|
174
133
|
}
|
|
175
|
-
export interface TaskProgress {
|
|
176
|
-
readonly callId: string;
|
|
177
|
-
readonly kind: "task-progress";
|
|
178
|
-
readonly taskId: string;
|
|
179
|
-
readonly update: JsonValue;
|
|
180
|
-
readonly updateIndex: number;
|
|
181
|
-
}
|
|
182
|
-
export declare const TASK_PROGRESS_STREAM_NAMESPACE = "eve.task.progress";
|
|
183
|
-
export declare const TASK_VIEW_STREAM_NAMESPACE = "eve.task";
|
|
184
134
|
export declare function isTerminalTaskStatus(status: TaskStatus): boolean;
|
|
185
135
|
export declare function isReadyTaskStatus(status: TaskStatus): boolean;
|
|
186
136
|
export {};
|
package/dist/src/tasks/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsonValuesEqual}from"#shared/json.js";function sameTaskMetadata(e,t){return jsonValuesEqual(e,t)}function readTaskUsage(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=readUsageAxis(e,`cacheReadTokens`),n=readUsageAxis(e,`cacheWriteTokens`),r=readUsageAxis(e,`costUsd`),i=readUsageAxis(e,`inputTokens`),a=readUsageAxis(e,`outputTokens`);if(t===void 0||n===void 0||i===void 0||a===void 0)return;let o={cacheReadTokens:t,cacheWriteTokens:n,inputTokens:i,outputTokens:a};return r!==void 0&&(o.costUsd=r),o}function readUsageAxis(e,t){let n=Reflect.get(e,t);return typeof n==`number`&&Number.isFinite(n)&&n>=0?n:void 0}function readTaskInputRequestId(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=Reflect.get(e,`requestId`);return typeof t==`string`?t:void 0}const TASK_AUTHORIZATION_REQUEST_ID_PREFIX=`task:authorization`;function taskAuthorizationRequestId(e){return e.type===`approval.candidate`||e.type===`approval.settled`?`${TASK_AUTHORIZATION_REQUEST_ID_PREFIX}:${e.data.requestId}`:`${TASK_AUTHORIZATION_REQUEST_ID_PREFIX}:${e.data.attemptId??e.data.name}`}
|
|
1
|
+
import{jsonValuesEqual}from"#shared/json.js";function sameTaskMetadata(e,t){return jsonValuesEqual(e,t)}function readTaskUsage(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=readUsageAxis(e,`cacheReadTokens`),n=readUsageAxis(e,`cacheWriteTokens`),r=readUsageAxis(e,`costUsd`),i=readUsageAxis(e,`inputTokens`),a=readUsageAxis(e,`outputTokens`);if(t===void 0||n===void 0||i===void 0||a===void 0)return;let o={cacheReadTokens:t,cacheWriteTokens:n,inputTokens:i,outputTokens:a};return r!==void 0&&(o.costUsd=r),o}function readUsageAxis(e,t){let n=Reflect.get(e,t);return typeof n==`number`&&Number.isFinite(n)&&n>=0?n:void 0}function readTaskInputRequestId(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=Reflect.get(e,`requestId`);return typeof t==`string`?t:void 0}const TASK_AUTHORIZATION_REQUEST_ID_PREFIX=`task:authorization`;function taskAuthorizationRequestId(e){return e.type===`approval.candidate`||e.type===`approval.settled`?`${TASK_AUTHORIZATION_REQUEST_ID_PREFIX}:${e.data.requestId}`:`${TASK_AUTHORIZATION_REQUEST_ID_PREFIX}:${e.data.attemptId??e.data.name}`}function isTerminalTaskStatus(e){return e===`completed`||e===`failed`||e===`cancelled`}function isReadyTaskStatus(e){return e===`input_required`||isTerminalTaskStatus(e)}export{isReadyTaskStatus,isTerminalTaskStatus,readTaskInputRequestId,readTaskUsage,sameTaskMetadata,taskAuthorizationRequestId};
|
|
@@ -7,13 +7,11 @@ import type { TokenResult } from "#shared/connection-types.js";
|
|
|
7
7
|
import type { ToolAuthOptions, ToolAuthProvider } from "#tools/auth.js";
|
|
8
8
|
import type { InputOption } from "#shared/input.js";
|
|
9
9
|
import type { ToolModelOutput } from "#tools/model-output.js";
|
|
10
|
-
import type { TaskExec, TaskReceipt } from "#tools/task.js";
|
|
11
10
|
type ApprovalContextInput<TInput> = unknown extends TInput ? Record<string, unknown> : TInput;
|
|
12
11
|
export type { ToolAuthDefinition, ToolAuthOptions, ToolAuthProvider } from "#tools/auth.js";
|
|
13
12
|
export type { ToolModelOutput, ToolModelOutputPart } from "#tools/model-output.js";
|
|
14
|
-
export type { TaskExec, TaskExecutorBinding, TaskReceipt } from "#tools/task.js";
|
|
15
13
|
export type ToolExecuteOptions = Omit<ToolExecutionOptions<unknown>, "context">;
|
|
16
|
-
export type ToolExecuteFn<TInput = unknown, TOutput = unknown> = (input: TInput, options: ToolExecuteOptions
|
|
14
|
+
export type ToolExecuteFn<TInput = unknown, TOutput = unknown> = (input: TInput, options: ToolExecuteOptions) => Promise<TOutput> | TOutput | AsyncIterable<TOutput>;
|
|
17
15
|
export type ToolExecution = "background";
|
|
18
16
|
interface ToolDefinitionBase {
|
|
19
17
|
/** Whether delegated agent sessions receive this tool. Defaults to `true`. */
|
|
@@ -168,21 +166,10 @@ export interface ToolDefinition<TInput = unknown, TOutput = unknown> extends Pub
|
|
|
168
166
|
*/
|
|
169
167
|
toModelOutput?: (output: TOutput) => ToolModelOutput | Promise<ToolModelOutput>;
|
|
170
168
|
}
|
|
171
|
-
/** A tool whose executor can outlive the model tool-call phase as a durable task. */
|
|
172
|
-
export interface BackgroundToolDefinition<TInput = unknown, TOutput = unknown> extends PublicToolDefinition<TInput, TaskReceipt> {
|
|
173
|
-
readonly execution: "background";
|
|
174
|
-
execute(input: TInput, ctx: ToolContext, task: TaskExec): Promise<TOutput> | TOutput | AsyncIterable<unknown>;
|
|
175
|
-
approval?: Approval<ApprovalContextInput<TInput>>;
|
|
176
|
-
toModelOutput?: (output: TaskReceipt) => ToolModelOutput | Promise<ToolModelOutput>;
|
|
177
|
-
}
|
|
178
169
|
type ToolOutputFromExecuteReturn<TReturn> = TReturn extends Promise<infer TOutput> ? TOutput : TReturn extends AsyncIterable<infer TOutput> ? TOutput : TReturn;
|
|
179
|
-
type BackgroundToolOutputFromExecuteReturn<TReturn> = TReturn extends AsyncGenerator<unknown, infer TOutput> ? TOutput : TReturn extends AsyncIterable<unknown> ? null : Awaited<TReturn>;
|
|
180
170
|
type ToolDefinitionWithExecuteReturn<TInput, TOutput, TReturn> = ToolDefinition<TInput, TOutput> & {
|
|
181
171
|
execute(input: TInput, ctx: ToolContext): TReturn;
|
|
182
172
|
};
|
|
183
|
-
type BackgroundToolDefinitionWithExecuteReturn<TInput, TOutput, TReturn> = BackgroundToolDefinition<TInput, TOutput> & {
|
|
184
|
-
execute(input: TInput, ctx: ToolContext, task: TaskExec): TReturn;
|
|
185
|
-
};
|
|
186
173
|
/**
|
|
187
174
|
* Defines a tool configuration, used both for static tools (default export
|
|
188
175
|
* from `agent/tools/*.ts`) and as the entry wrapper inside `defineDynamic`
|
|
@@ -191,17 +178,6 @@ type BackgroundToolDefinitionWithExecuteReturn<TInput, TOutput, TReturn> = Backg
|
|
|
191
178
|
* For static tools, the runtime tool name is the filename slug. `defineTool`
|
|
192
179
|
* stamps a brand that lifecycle code validates; it rejects raw object literals.
|
|
193
180
|
*/
|
|
194
|
-
export declare function defineTool<TSchema extends StandardSchemaV1<unknown, unknown> | StandardJSONSchemaV1<unknown, unknown>, TReturn>(definition: {
|
|
195
|
-
description: BackgroundToolDefinition<unknown, unknown>["description"];
|
|
196
|
-
execution: "background";
|
|
197
|
-
inputSchema: TSchema;
|
|
198
|
-
outputSchema?: PublicToolDefinition<unknown, TaskReceipt>["outputSchema"];
|
|
199
|
-
execute(input: StandardSchemaV1.InferOutput<TSchema>, ctx: ToolContext, task: TaskExec): TReturn;
|
|
200
|
-
label?: BackgroundToolDefinition<StandardSchemaV1.InferOutput<TSchema>, BackgroundToolOutputFromExecuteReturn<TReturn>>["label"];
|
|
201
|
-
approval?: BackgroundToolDefinition<StandardSchemaV1.InferOutput<TSchema>, unknown>["approval"];
|
|
202
|
-
approvalKey?: BackgroundToolDefinition<StandardSchemaV1.InferOutput<TSchema>, unknown>["approvalKey"];
|
|
203
|
-
toModelOutput?: BackgroundToolDefinition<unknown, BackgroundToolOutputFromExecuteReturn<TReturn>>["toModelOutput"];
|
|
204
|
-
}): BackgroundToolDefinitionWithExecuteReturn<StandardSchemaV1.InferOutput<TSchema>, BackgroundToolOutputFromExecuteReturn<TReturn>, TReturn>;
|
|
205
181
|
export declare function defineTool<TInputSchema extends StandardSchemaV1<unknown, unknown> | StandardJSONSchemaV1<unknown, unknown>, TOutputSchema extends StandardJSONSchemaV1<unknown, unknown>, TReturn extends Promise<StandardJSONSchemaV1.InferOutput<TOutputSchema>> | StandardJSONSchemaV1.InferOutput<TOutputSchema> | AsyncIterable<StandardJSONSchemaV1.InferOutput<TOutputSchema>>>(definition: {
|
|
206
182
|
description: ToolDefinition<unknown, unknown>["description"];
|
|
207
183
|
inputSchema: TInputSchema;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{collectDurableDynamicToolCallbacks,stampDurableDynamicToolCallbacks}from"#tools/durable-callbacks.js";import{TOOL_BRAND}from"#tools/dynamic.js";import{stampDefinitionKey}from"#internal/authored-definition/source-identity.js";function defineTool(e){return stampToolDefinition(e,`defineTool`)}function stampToolDefinition(e,t){if(e.auth!==void 0)throw Error(`${t}: The "auth" field is no longer supported. Pass auth providers inline to ctx.getToken(provider) or ctx.requireAuth(provider).`);return Object.assign(e,{[TOOL_BRAND]:!0}),stampDurableDynamicToolCallbacks(e,collectDurableDynamicToolCallbacks({inputSchema:e.inputSchema,outputSchema:e.outputSchema,label:e.label,approval:e.approval,approvalKey:e.approvalKey,execute:e.execute,toModelOutput:e.toModelOutput})),stampDefinitionKey(e,`tool:${e.description}`),e}const DISABLED_TOOL_SENTINEL_KIND=`eve:disabled-tool`;function disableTool(){return{kind:DISABLED_TOOL_SENTINEL_KIND}}function isDisabledToolSentinel(e){return typeof e==`object`&&!!e&&e.kind===DISABLED_TOOL_SENTINEL_KIND}export{defineTool,disableTool,isDisabledToolSentinel,stampToolDefinition};
|
|
1
|
+
import{collectDurableDynamicToolCallbacks,stampDurableDynamicToolCallbacks}from"#tools/durable-callbacks.js";import{TOOL_BRAND}from"#tools/dynamic.js";import{stampDefinitionKey}from"#internal/authored-definition/source-identity.js";function defineTool(e){if(`execution`in e&&e.execution!==void 0)throw Error(`defineTool: "execution" is not supported. Use defineWorkflowTool for background work.`);return stampToolDefinition(e,`defineTool`)}function stampToolDefinition(e,t){if(e.auth!==void 0)throw Error(`${t}: The "auth" field is no longer supported. Pass auth providers inline to ctx.getToken(provider) or ctx.requireAuth(provider).`);return Object.assign(e,{[TOOL_BRAND]:!0}),stampDurableDynamicToolCallbacks(e,collectDurableDynamicToolCallbacks({inputSchema:e.inputSchema,outputSchema:e.outputSchema,label:e.label,approval:e.approval,approvalKey:e.approvalKey,execute:e.execute,toModelOutput:e.toModelOutput})),stampDefinitionKey(e,`tool:${e.description}`),e}const DISABLED_TOOL_SENTINEL_KIND=`eve:disabled-tool`;function disableTool(){return{kind:DISABLED_TOOL_SENTINEL_KIND}}function isDisabledToolSentinel(e){return typeof e==`object`&&!!e&&e.kind===DISABLED_TOOL_SENTINEL_KIND}export{defineTool,disableTool,isDisabledToolSentinel,stampToolDefinition};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Approval } from "#approval/definition.js";
|
|
2
2
|
import type { DynamicResolveContext, DynamicToolEventName } from "#dynamic/definition.js";
|
|
3
3
|
import type { PublicToolInputSchema, PublicToolOutputSchema, ToolLabelDefinition, ToolContext } from "#tools/definition.js";
|
|
4
|
-
import type { TaskExec } from "#tools/task.js";
|
|
5
4
|
import type { ToolModelOutput } from "#tools/model-output.js";
|
|
6
5
|
/**
|
|
7
6
|
* A single tool entry within a resolved dynamic tool set.
|
|
@@ -21,8 +20,7 @@ export interface DynamicToolEntry<TInput = Record<string, unknown>, TOutput = an
|
|
|
21
20
|
readonly description: string;
|
|
22
21
|
readonly inputSchema: PublicToolInputSchema<TInput>;
|
|
23
22
|
readonly outputSchema?: PublicToolOutputSchema<TOutput>;
|
|
24
|
-
|
|
25
|
-
execute(input: TInput, ctx: ToolContext, task?: TaskExec): TOutput | Promise<TOutput>;
|
|
23
|
+
execute(input: TInput, ctx: ToolContext): TOutput | Promise<TOutput>;
|
|
26
24
|
readonly toModelOutput?: (output: TOutput) => ToolModelOutput | Promise<ToolModelOutput>;
|
|
27
25
|
/**
|
|
28
26
|
* Optional per-call approval gate, mirroring the authored-tool
|
|
@@ -1,24 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} | undefined;
|
|
18
|
-
}, ctx: import("#tools/definition.js").ToolContext, task: import("#tools/definition.js").TaskExec): {
|
|
19
|
-
agentId: string;
|
|
20
|
-
status: "working";
|
|
21
|
-
taskId: string;
|
|
22
|
-
};
|
|
1
|
+
import type { z } from "#compiled/zod/index.js";
|
|
2
|
+
import { SUBAGENT_TASK_RECEIPT_OUTPUT_SCHEMA } from "#tools/framework/task-contract.js";
|
|
3
|
+
export declare const agent: {
|
|
4
|
+
description: string;
|
|
5
|
+
execution: string;
|
|
6
|
+
inputSchema: z.ZodObject<{
|
|
7
|
+
agentId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
8
|
+
message: z.ZodString;
|
|
9
|
+
outputSchema: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
10
|
+
}, z.core.$strict>;
|
|
11
|
+
outputSchema: z.ZodObject<{
|
|
12
|
+
agentId: z.ZodString;
|
|
13
|
+
status: z.ZodLiteral<"working">;
|
|
14
|
+
taskId: z.ZodString;
|
|
15
|
+
}, z.core.$strict>;
|
|
16
|
+
execute(): z.infer<typeof SUBAGENT_TASK_RECEIPT_OUTPUT_SCHEMA>;
|
|
23
17
|
};
|
|
24
18
|
export default agent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{stampToolDefinition}from"#tools/definition.js";import{SUBAGENT_TASK_RECEIPT_OUTPUT_SCHEMA}from"#tools/framework/task-contract.js";import{AGENT_TOOL_DESCRIPTION,SUBAGENT_TOOL_INPUT_SCHEMA}from"#tools/framework/agent-contract.js";import{attachToolBehavior}from"#tools/behavior.js";const agent=attachToolBehavior(stampToolDefinition({description:`${AGENT_TOOL_DESCRIPTION} This call starts a background task and returns a task receipt immediately.`,execution:`background`,inputSchema:SUBAGENT_TOOL_INPUT_SCHEMA,outputSchema:SUBAGENT_TASK_RECEIPT_OUTPUT_SCHEMA,execute(){throw Error(`The framework "agent" tool was executed directly. It must be resolved through the runtime tool registry, which dispatches it to the shared subagent workflow.`)}},`defineTool`),{availability:[`root-session`],handling:{action:`self-agent`,kind:`dispatch`}});export{agent,agent as default};
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import type { StandardJSONSchemaV1, StandardSchemaV1 } from "#compiled/@standard-schema/spec/index.js";
|
|
2
2
|
import type { Approval } from "#approval/definition.js";
|
|
3
3
|
import type { JsonObject, JsonValue } from "#shared/json.js";
|
|
4
|
-
import { type PublicToolDefinition, type
|
|
5
|
-
import type { TaskExec } from "#tools/task.js";
|
|
4
|
+
import { type PublicToolDefinition, type ToolContext, type ToolInputRequest, type ToolInputResponse } from "#tools/definition.js";
|
|
6
5
|
import type { ToolModelOutput } from "#tools/model-output.js";
|
|
6
|
+
/** Fixed acknowledgement returned when a background task is admitted. */
|
|
7
|
+
export interface TaskReceipt {
|
|
8
|
+
readonly status: "working";
|
|
9
|
+
readonly taskId: string;
|
|
10
|
+
}
|
|
7
11
|
export interface AgentInput {
|
|
8
12
|
readonly agentId?: string;
|
|
9
13
|
readonly message: string;
|
|
@@ -71,22 +75,29 @@ export interface BlockingWorkflowToolDefinition<TInput = unknown, TOutput = unkn
|
|
|
71
75
|
approval?: Approval<unknown extends TInput ? Record<string, unknown> : TInput>;
|
|
72
76
|
toModelOutput?: (output: TOutput) => ToolModelOutput | Promise<ToolModelOutput>;
|
|
73
77
|
}
|
|
74
|
-
type BackgroundWorkflowToolDefinition<TInput, TOutput> =
|
|
78
|
+
export type BackgroundWorkflowToolDefinition<TInput, TOutput> = PublicToolDefinition<TInput, TaskReceipt> & {
|
|
75
79
|
readonly [WORKFLOW_TOOL_BRAND]: true;
|
|
76
|
-
|
|
80
|
+
readonly execution: "background";
|
|
81
|
+
execute(input: TInput, ctx: WorkflowToolContext): Promise<TOutput> | AsyncIterable<unknown>;
|
|
82
|
+
approval?: Approval<unknown extends TInput ? Record<string, unknown> : TInput>;
|
|
83
|
+
toModelOutput?: (output: TaskReceipt) => ToolModelOutput | Promise<ToolModelOutput>;
|
|
77
84
|
};
|
|
78
85
|
/** A static tool whose executor runs as a durable workflow. */
|
|
79
86
|
export type WorkflowToolDefinition<TInput = unknown, TOutput = unknown> = BlockingWorkflowToolDefinition<TInput, TOutput> | BackgroundWorkflowToolDefinition<TInput, TOutput>;
|
|
80
87
|
type Unbranded<T> = T extends unknown ? Omit<T, typeof WORKFLOW_TOOL_BRAND> : never;
|
|
81
88
|
type BackgroundReturn<T> = T extends AsyncGenerator<unknown, infer Output> ? Output : T extends AsyncIterable<unknown> ? null : Awaited<T>;
|
|
82
89
|
type BackgroundDefinition<TInput, TReturn> = Omit<BackgroundWorkflowToolDefinition<TInput, BackgroundReturn<TReturn>>, typeof WORKFLOW_TOOL_BRAND | "execute"> & {
|
|
83
|
-
execute(input: TInput, ctx: WorkflowToolContext
|
|
90
|
+
execute(input: TInput, ctx: WorkflowToolContext): TReturn;
|
|
84
91
|
};
|
|
85
92
|
type WorkflowReturn<T> = T extends AsyncIterable<infer Output> ? Output : Awaited<T>;
|
|
86
93
|
type Schema = StandardSchemaV1<unknown, unknown> | StandardJSONSchemaV1<unknown, unknown>;
|
|
87
94
|
type Definition<TInput, TReturn> = Omit<BlockingWorkflowToolDefinition<TInput, WorkflowReturn<TReturn>>, typeof WORKFLOW_TOOL_BRAND | "execute"> & {
|
|
88
95
|
execute(input: TInput, ctx: WorkflowToolContext): TReturn;
|
|
89
96
|
};
|
|
97
|
+
export declare function defineWorkflowTool<TInputSchema extends Schema, TOutputSchema extends StandardJSONSchemaV1<unknown, unknown>, TReturn extends Promise<StandardJSONSchemaV1.InferOutput<TOutputSchema>> | AsyncIterable<StandardJSONSchemaV1.InferOutput<TOutputSchema>>>(definition: Omit<Definition<StandardSchemaV1.InferOutput<TInputSchema>, TReturn>, "inputSchema" | "outputSchema"> & {
|
|
98
|
+
inputSchema: TInputSchema;
|
|
99
|
+
outputSchema: TOutputSchema;
|
|
100
|
+
}): BlockingWorkflowToolDefinition<StandardSchemaV1.InferOutput<TInputSchema>, StandardJSONSchemaV1.InferOutput<TOutputSchema>>;
|
|
90
101
|
export declare function defineWorkflowTool<TSchema extends Schema, TReturn extends Promise<unknown> | AsyncIterable<unknown>>(definition: Omit<BackgroundDefinition<StandardSchemaV1.InferOutput<TSchema>, TReturn>, "inputSchema"> & {
|
|
91
102
|
inputSchema: TSchema;
|
|
92
103
|
}): BackgroundWorkflowToolDefinition<StandardSchemaV1.InferOutput<TSchema>, BackgroundReturn<TReturn>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"#shared/channel-audience.js";import{applyLiveDeliveryAudienceCeiling,readForwardedTraceAssertion}from"#shared/forwarded-trace-policy.js";import{ConversationIdKey}from"#context/keys.js";import{readConversationId}from"#tracing/conversation-context.js";import{
|
|
1
|
+
import"#shared/channel-audience.js";import{applyLiveDeliveryAudienceCeiling,readForwardedTraceAssertion}from"#shared/forwarded-trace-policy.js";import{ConversationIdKey}from"#context/keys.js";import{readConversationId}from"#tracing/conversation-context.js";import{getBlockingWorkflowToolRuns}from"#harness/workflow-tool-runs.js";import{readActionTraceContext,readTaskActionTrace,readTurnTraceContext,recordActionInvocationKind,recordNestedAgentInvocation}from"#tracing/agent-trace-context-store.js";import{invocationError,recordNestedAgentInvocationTerminal}from"#tracing/agent-invocation-terminal.js";import{deriveAgentActionSpanId}from"#tracing/agent-span-id-generator.js";function prepareAgentInvocationTrace(e){let t=readConversationId(e.serializedContext[ConversationIdKey.name]),n=e.taskId===void 0?void 0:readTaskActionTrace(e.serializedContext,e.sessionId,e.taskId),r=e.taskId===void 0?getBlockingWorkflowToolRuns(e.sessionState).find(t=>t.address.runId===e.ownerId)?.callId:n?.callId,i=n?.turnId??e.turnId,a=readTurnTraceContext(e.serializedContext,e.sessionId,i),o=e.conversation,s=o?.audience??`unknown`,c=o?.environment??`production`,l=(r===void 0?void 0:readActionTraceContext(e.serializedContext,e.sessionId,i,r))??a,u=l?.decision===void 0?void 0:applyLiveDeliveryAudienceCeiling(l.decision,s,l.forwardedTracePolicy,c),d=r===void 0?e.serializedContext:r===e.invocation.callId?recordActionInvocationKind({callId:e.invocation.callId,kind:e.invocation.kind,serializedContext:e.serializedContext,sessionId:e.sessionId,turnId:i}):recordNestedAgentInvocation({callId:e.invocation.callId,kind:e.invocation.kind,name:e.invocation.name,outerCallId:r,recordOutputs:u?.action===`record`&&u.recordOutputs,serializedContext:e.serializedContext,sessionId:e.sessionId,spanId:deriveAgentActionSpanId(e.sessionId,i,e.invocation.callId),startTimeMs:e.startTimeMs,turnId:i}),f=readActionTraceContext(d,e.sessionId,i,e.invocation.callId)??l,p=readForwardedTraceAssertion(f?.forwardedTracePolicy),m=f?.decision===void 0?f:{...f,decision:applyLiveDeliveryAudienceCeiling(f.decision,s,p,c)};return{dispatch:{conversationId:t,originAudience:p?.originAudience??s,parentTraceContext:m},fail:t=>recordNestedAgentInvocationTerminal({callId:e.invocation.callId,serializedContext:d,sessionId:e.sessionId,terminal:{acceptedAtMs:Date.now(),error:invocationError(t.output),outcome:`failed`},turnId:i}),serializedContext:d}}export{prepareAgentInvocationTrace};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createLogger}from"#internal/logging.js";import{decisionToTraceContentCeiling,resolveForwardedTraceSeed}from"#shared/forwarded-trace-policy.js";import{contextStorage,loadContext}from"#context/container.js";import{SessionTraceSeedKey}from"#context/keys.js";import{ContextKey}from"#context/key.js";import{
|
|
1
|
+
import{createLogger}from"#internal/logging.js";import{decisionToTraceContentCeiling,resolveForwardedTraceSeed}from"#shared/forwarded-trace-policy.js";import{contextStorage,loadContext}from"#context/container.js";import{SessionTraceSeedKey}from"#context/keys.js";import{ContextKey}from"#context/key.js";import{getBackgroundWorkflowToolRuns,getBlockingWorkflowToolRuns}from"#harness/workflow-tool-runs.js";import{deriveTaskId}from"#tasks/task-id.js";import{actionIdempotencyKey}from"#instrumentation/lifecycle.js";import{AGENT_TRACE_CONTEXT_KEY,deserializeAgentTraceContextState,emptyAgentTraceContextState,serializeAgentTraceContextState}from"#tracing/agent-trace-context-codec.js";const AgentTraceContextKey=new ContextKey(AGENT_TRACE_CONTEXT_KEY,{codec:{deserialize:deserializeAgentTraceContextState,serialize:serializeAgentTraceContextState}});function pruneAgentTraceState(e,t,n){try{pruneTraceOwnership(e,t,n)}catch(e){createLogger(`tracing.retention`).warn(`could not reconcile trace ownership; preserving trace state`,{error:e})}}function pruneTraceOwnership(e,t,n){let r=e.get(AgentTraceContextKey);if(r===void 0)return;let i=new Set(getBlockingWorkflowToolRuns(n).map(e=>e.callId)),a=new Set(getBackgroundWorkflowToolRuns(n).filter(e=>e.task.outcome===void 0).map(e=>e.task.taskId)),o=Object.fromEntries(Object.entries(r.actionAnchors).filter(([e,n])=>n.sessionId!==t||r.actions[e]!==void 0||i.has(n.callId)||a.has(deriveTaskId({callId:n.callId,parentSessionId:t,parentTurnId:n.turnId})))),s=new Set(Object.values(o).filter(e=>e.sessionId===t).map(e=>e.callId)),c=Object.fromEntries(Object.entries(r.invocations).filter(([,e])=>e.sessionId!==t||e.terminal!==void 0||s.has(e.parentActionCallId)));e.set(AgentTraceContextKey,{...r,actionAnchors:o,invocations:c})}function readCurrentSessionTraceDecision(e){let t=contextStorage.getStore();return t===void 0?void 0:readSessionTraceDecision(t,e)}function readSessionTraceDecision(e,t){return e.get(AgentTraceContextKey)?.sessions[t]?.decision}function preserveSerializedAgentTraceState(e,t){let n=t[AgentTraceContextKey.name];return n===void 0?e:{...e,[AgentTraceContextKey.name]:n}}function readTurnTraceContext(e,t,n){let r=e[AgentTraceContextKey.name];if(r===void 0)return;let i=deserializeAgentTraceContextState(r),a=i.turns[turnKey(t,n)];return a===void 0?void 0:withTraceDecision(e,a.context,i.sessions[t]?.decision)}function readActionTraceContext(e,t,n,r){let i=e[AgentTraceContextKey.name];if(i===void 0)return;let a=deserializeAgentTraceContextState(i),o=actionIdempotencyKey(t,n,r),s=a.invocations[o]??a.actions[o]??a.actionAnchors[o];if(s!==void 0)return withTraceDecision(e,{isRemote:!1,spanId:s.spanId,traceFlags:s.parent.traceFlags,traceId:s.parent.traceId},a.sessions[s.sessionId]?.decision)}function readTaskActionTrace(e,t,n){let r=deserializeAgentTraceContextState(e[AgentTraceContextKey.name]);return Object.values(r.actionAnchors).find(e=>e.sessionId===t&&deriveTaskId({callId:e.callId,parentSessionId:t,parentTurnId:e.turnId})===n)}function recordNestedAgentInvocation(e){let t=e.serializedContext[AgentTraceContextKey.name];if(t===void 0)return e.serializedContext;let n=deserializeAgentTraceContextState(t),r=actionIdempotencyKey(e.sessionId,e.turnId,e.outerCallId),i=n.actions[r]??n.actionAnchors[r];if(i===void 0)return e.serializedContext;let a=actionIdempotencyKey(e.sessionId,e.turnId,e.callId),promote=e=>e.isWorkflowTool===!0&&e.kind===`tool-call`?{...e,workflowName:e.name}:e,o=n.actions[r]===void 0?n.actions:{...n.actions,[r]:promote(n.actions[r])},s=n.actionAnchors[r]===void 0?n.actionAnchors:{...n.actionAnchors,[r]:promote(n.actionAnchors[r])};if(n.invocations[a]!==void 0)return{...e.serializedContext,[AgentTraceContextKey.name]:serializeAgentTraceContextState({...n,actionAnchors:s,actions:o})};let c={attemptIndex:i.attemptIndex,callId:e.callId,channelAudience:i.channelAudience,kind:e.kind,name:e.name,parent:{spanId:i.spanId,traceFlags:i.parent.traceFlags,traceId:i.parent.traceId},parentActionCallId:e.outerCallId,recordOutputs:e.recordOutputs===!0,rootSessionId:i.rootSessionId,sessionId:i.sessionId,spanId:e.spanId,startTimeMs:e.startTimeMs,stepIndex:i.stepIndex,turnId:i.turnId};return{...e.serializedContext,[AgentTraceContextKey.name]:serializeAgentTraceContextState({...n,actionAnchors:s,actions:o,invocations:{...n.invocations,[a]:c}})}}function recordActionInvocationKind(e){let t=e.serializedContext[AgentTraceContextKey.name];if(t===void 0)return e.serializedContext;let n=deserializeAgentTraceContextState(t),update=t=>t.sessionId===e.sessionId&&t.turnId===e.turnId&&t.callId===e.callId?{...t,isWorkflowTool:void 0,kind:e.kind,workflowName:void 0}:t;return{...e.serializedContext,[AgentTraceContextKey.name]:serializeAgentTraceContextState({...n,actionAnchors:Object.fromEntries(Object.entries(n.actionAnchors).map(([e,t])=>[e,update(t)])),actions:Object.fromEntries(Object.entries(n.actions).map(([e,t])=>[e,update(t)]))})}}function withTraceDecision(e,t,n){let r=e[SessionTraceSeedKey.name],i=resolveForwardedTraceSeed({decision:n??r?.decision,forwardedTracePolicy:r?.forwardedTracePolicy,traceFlags:t.traceFlags}),a=i.decision,o=i.forwardedTracePolicy,s=decisionToTraceContentCeiling(a),c={...t,traceFlags:i.traceFlags};if(o===void 0)return a===void 0?c:{...c,decision:a};let l=s===void 0?o:{...o,ceiling:s};return a===void 0?{...c,forwardedTracePolicy:l}:{...c,decision:a,forwardedTracePolicy:l}}var ContextAgentTraceStateStore=class{deleteAction(e){updateState(t=>{let n={...t.actions};return delete n[e],{...t,actions:n}})}deleteActionAnchors(e){updateState(t=>({...t,actionAnchors:Object.fromEntries(Object.entries(t.actionAnchors).filter(([,t])=>t.sessionId!==e))}))}deleteActions(e,t){updateState(n=>{let r={...n.actions};for(let[n,i]of Object.entries(r))i.sessionId===e&&(t===void 0||i.turnId===t)&&delete r[n];return{...n,actions:r}})}deleteInvocation(e){updateState(t=>{let n={...t.invocations};return delete n[e],{...t,invocations:n}})}deleteInvocations(e,t){updateState(n=>({...n,invocations:Object.fromEntries(Object.entries(n.invocations).filter(([,n])=>n.sessionId!==e||t!==void 0&&n.turnId!==t))}))}deleteSession(e){updateState(t=>{let n={...t.sessions};return delete n[e],{...t,sessions:n}})}deleteTurn(e,t){updateState(n=>{let r={...n.turns};return delete r[turnKey(e,t)],{...n,turns:r}})}findAction(e,t){return Object.values(contextStorage.getStore()?.get(AgentTraceContextKey)?.actions??{}).find(n=>n.sessionId===e&&n.callId===t)}findActionAnchor(e,t,n){return Object.values(contextStorage.getStore()?.get(AgentTraceContextKey)?.actionAnchors??{}).find(r=>r.sessionId===e&&r.turnId===t&&r.callId===n)}findInvocations(e,t,n){return Object.values(contextStorage.getStore()?.get(AgentTraceContextKey)?.invocations??{}).filter(r=>(e===void 0||r.sessionId===e)&&(t===void 0||r.turnId===t)&&(n===void 0||r.parentActionCallId===n))}getAction(e){return contextStorage.getStore()?.get(AgentTraceContextKey)?.actions[e]}getSession(e){return contextStorage.getStore()?.get(AgentTraceContextKey)?.sessions[e]}getTurn(e,t){return contextStorage.getStore()?.get(AgentTraceContextKey)?.turns[turnKey(e,t)]}setAction(e,t){updateState(n=>({...n,actions:{...n.actions,[e]:t}}))}setActionAnchor(e,t){updateState(n=>({...n,actionAnchors:{...n.actionAnchors,[e]:t}}))}setInvocation(e,t){updateState(n=>({...n,invocations:{...n.invocations,[e]:t}}))}setSession(e,t){updateState(n=>({...n,sessions:{...n.sessions,[e]:t}}))}setTurn(e,t,n){updateState(r=>({...r,turns:{...r.turns,[turnKey(e,t)]:n}}))}updateTurn(e,t,n){updateState(r=>{let i=turnKey(e,t),a=r.turns[i];return a===void 0?r:{...r,turns:{...r.turns,[i]:n(a)}}})}};function updateState(e){loadContext().set(AgentTraceContextKey,t=>e(t??emptyAgentTraceContextState()))}function turnKey(e,t){return`${e}\0${t}`}export{ContextAgentTraceStateStore,preserveSerializedAgentTraceState,pruneAgentTraceState,readActionTraceContext,readCurrentSessionTraceDecision,readSessionTraceDecision,readTaskActionTrace,readTurnTraceContext,recordActionInvocationKind,recordNestedAgentInvocation};
|