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
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createLogger}from"#internal/logging.js";import{getWritable}from"#compiled/@workflow/core/index.js";import{resumeSessionInbox}from"#execution/session-inbox/resume.js";import{resumeWorkflowToolRunAnswers}from"#execution/tools/workflow/answer.js";import{submitActivity}from"#execution/submit-activity.js";import{isTaskWorkflowTargetGone}from"#execution/tasks/workflow-target.js";import{TASK_PROGRESS_STREAM_NAMESPACE,TASK_VIEW_STREAM_NAMESPACE,isTerminalTaskStatus,taskAuthorizationRequestId}from"#tasks/types.js";const log=createLogger(`execution.tasks.run`);async function appendTaskViewStep(e){"use step";let t=getWritable({namespace:TASK_VIEW_STREAM_NAMESPACE}).getWriter();try{await t.write(e.view)}finally{t.releaseLock()}let n=projectTaskActivity({activityObserver:e.activityObserver,settledAt:new Date().toISOString(),view:e.view});await submitActivity({events:n,sink:e.activityObserver?.sink})}function projectTaskActivity(e){let t=e.activityObserver?.workIdentity;if(t===void 0)return[];let n=e.view.status;return n===`working`?[{eventId:`${t.id}:started`,kind:`work.started`,startedAt:e.settledAt,work:t}]:n!==`completed`&&n!==`failed`&&n!==`cancelled`?[]:[{eventId:`${t.id}:settled:${n}`,kind:`work.settled`,outcome:n,settledAt:e.settledAt,workId:t.id}]}async function appendTaskProgressStep(e){"use step";let t=getWritable({namespace:TASK_PROGRESS_STREAM_NAMESPACE}).getWriter();try{await t.write(e.progress)}finally{t.releaseLock()}}async function wakeTaskParentStep(e){"use step";let t={message:formatTaskNotification(e.view)};isTerminalTaskStatus(e.view.status)&&(t.task={views:[e.view]});let n={kind:`send`,payload:t,taskDeliveryId:`${e.view.taskId}:ready:${e.view.status}`};try{await resumeSessionInbox(e.token,n)}catch(t){if(isTaskWorkflowTargetGone(t)){log.warn(`task wake target is gone; the parent session already ended`,{status:e.view.status,taskId:e.view.taskId});return}throw t}}async function wakeTaskUpdateParentStep(e){"use step";let t={kind:`send`,payload:{message:`Background task ${e.view.taskId} (${e.view.metadata.name}) update: ${e.update.message}`},taskDeliveryId:`${e.view.taskId}:update:${e.update.updateEpoch}:${e.update.updateIndex}:${e.update.callId}`};try{await resumeSessionInbox(e.token,t)}catch(e){if(isTaskWorkflowTargetGone(e))return;throw e}}async function wakeTaskMessageParentStep(e){"use step";let t={kind:`send`,payload:{message:e.message.message},taskDeliveryId:`${e.taskId}:message:${e.message.messageEpoch}:${e.message.messageIndex}:${e.message.callId}`};try{await resumeSessionInbox(e.token,t)}catch(e){if(isTaskWorkflowTargetGone(e))return;throw e}}async function wakeTaskAgentRequestParentStep(e){"use step";let t=e.request.request;if(t.kind!==`agent-invoke`&&t.kind!==`agent-settled`)throw Error(`Cannot forward task input as an agent request.`);let n={replyTo:e.request.replyTo,request:t,taskId:e.taskId},r=t.kind===`agent-invoke`?t.invocationId:`${t.result.callId}:settled`,i={kind:`send`,payload:{task:{agentRequests:[n]}},taskDeliveryId:`${e.taskId}:agent:${e.request.from.runId}:${r}`};try{await resumeSessionInbox(e.token,i)}catch(e){if(!isTaskWorkflowTargetGone(e))throw e}}async function wakeTaskAuthorizationParentStep(e){"use step";let{event:t}=e.request,n=t.event.data,r={task:{authorizationEvents:[{hookPayload:t,taskId:e.taskId}]}};t.event.type===`authorization.required`&&(r.message=`Background task ${e.taskId} needs authorization.`);let i={kind:`send`,payload:r,taskDeliveryId:`${e.taskId}:authorization:${t.event.type}:${n.turnId}:${n.stepIndex}:${n.sequence}:${taskAuthorizationRequestId(t.event)}`};try{await resumeSessionInbox(e.token,i)}catch(e){if(!isTaskWorkflowTargetGone(e))throw e}}async function wakeWorkflowTaskInputRequestParentStep(e){"use step";let t={kind:`send`,payload:{task:{inputRequests:[e.request.requests===void 0?{replyTo:e.request.replyTo,request:e.request.request,sequence:e.request.sequence,stepIndex:e.request.stepIndex,taskId:e.taskId,turnId:e.request.turnId}:{replyTo:e.request.replyTo,requests:e.request.requests,sequence:e.request.sequence,stepIndex:e.request.stepIndex,taskId:e.taskId,turnId:e.request.turnId}]}},taskDeliveryId:`${e.taskId}:input:${e.request.turnId}:${e.request.stepIndex}:${e.request.sequence}`};try{await resumeSessionInbox(e.token,t)}catch(e){if(!isTaskWorkflowTargetGone(e))throw e}}async function deliverTaskInputResponsesStep(e){"use step";let t=new Set(e.requestIds),n={auth:e.answer.auth,kind:`send`,payload:{inputResponses:e.answer.inputResponses.filter(e=>t.has(e.requestId))},taskDeliveryId:`${e.answer.taskId}:${[...e.requestIds].sort().join(`,`)}`};try{if(e.answer.childResponseUrl!==void 0){let t=await fetch(e.answer.childResponseUrl,{body:JSON.stringify({inputResponses:n.payload.inputResponses}),headers:{"content-type":`application/json`},method:`POST`,redirect:`error`});if(t.status===404)return`unreachable`;if(!t.ok)throw Error(`Remote task input delivery failed with HTTP ${t.status}.`)}else e.answerHook===void 0?await resumeSessionInbox(e.answer.childSessionInbox??e.answer.childContinuationToken,n):await resumeWorkflowToolRunAnswers(e.answer.childContinuationToken,n.payload.inputResponses);return`delivered`}catch(t){if(isTaskWorkflowTargetGone(t))return log.warn(`task input answer target is gone; the child turn already ended`,{taskId:e.answer.taskId}),`unreachable`;throw t}}function formatTaskNotification(e){let t=`Background task ${e.taskId} (${e.metadata.name})`;return e.status===`input_required`?`${t} needs input.`: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{appendTaskProgressStep,appendTaskViewStep,deliverTaskInputResponsesStep,formatTaskNotification,projectTaskActivity,wakeTaskAgentRequestParentStep,wakeTaskAuthorizationParentStep,wakeTaskMessageParentStep,wakeTaskParentStep,wakeTaskUpdateParentStep,wakeWorkflowTaskInputRequestParentStep};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { ActivityObserverConfig } from "#channel/types.js";
|
|
2
|
-
import { type WorkflowBodyDefinition } from "#execution/tools/workflow/body.js";
|
|
3
|
-
import { type TaskInputRequest, type TaskView } from "#tasks/types.js";
|
|
4
|
-
export interface TaskRunWorkflowInput {
|
|
5
|
-
readonly activityObserver?: ActivityObserverConfig;
|
|
6
|
-
readonly initialView: TaskView;
|
|
7
|
-
readonly parentContinuationToken: string;
|
|
8
|
-
readonly taskInboxToken: string;
|
|
9
|
-
readonly workflow?: WorkflowBodyDefinition;
|
|
10
|
-
}
|
|
11
|
-
/** A workflow-body question routed through the task that owns the workflow tool run. */
|
|
12
|
-
interface WorkflowToolRunTaskInputRequestBase {
|
|
13
|
-
readonly kind: "task-input-request";
|
|
14
|
-
readonly replyTo: string;
|
|
15
|
-
readonly sequence: number;
|
|
16
|
-
readonly stepIndex: number;
|
|
17
|
-
readonly turnId: string;
|
|
18
|
-
}
|
|
19
|
-
export type WorkflowToolRunTaskInputRequest = WorkflowToolRunTaskInputRequestBase & ({
|
|
20
|
-
readonly request: TaskInputRequest;
|
|
21
|
-
readonly requests?: never;
|
|
22
|
-
} | {
|
|
23
|
-
readonly request?: never;
|
|
24
|
-
readonly requests: readonly TaskInputRequest[];
|
|
25
|
-
});
|
|
26
|
-
/** Owns lifecycle for one background task and consumes its executor traffic. */
|
|
27
|
-
export declare function taskRunWorkflow(input: TaskRunWorkflowInput): Promise<void>;
|
|
28
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createHook}from"#compiled/@workflow/core/index.js";import{claimHookOwnership,isHookConflictError}from"#execution/hook-ownership.js";import{resumeHookStep}from"#execution/tools/workflow/resume-hook-step.js";import{workflowToolRunOutcomeToTaskCommand,workflowToolRunReportToTaskPayload,workflowToolRunRequestToTaskInputRequest}from"#execution/tools/workflow/owner-inbox.js";import{isReadyTaskStatus,isTerminalTaskStatus,readTaskInputRequestId}from"#tasks/types.js";import{appendTaskProgressStep,appendTaskViewStep,deliverTaskInputResponsesStep,wakeTaskAgentRequestParentStep,wakeTaskAuthorizationParentStep,wakeTaskMessageParentStep,wakeTaskParentStep,wakeTaskUpdateParentStep,wakeWorkflowTaskInputRequestParentStep}from"#execution/tasks/child/steps.js";import{createWorkflowBodyRef,executeWorkflowBody}from"#execution/tools/workflow/body.js";import{createChannelReader,raceChannelReads}from"#execution/tools/workflow/owner-channels.js";import{openWorkflowToolRunOwnerInbox}from"#execution/tools/workflow/owner.js";import{applyTaskTransition}from"#tasks/transitions.js";async function taskRunWorkflow(e){"use workflow";let t=createHook({token:e.taskInboxToken}),n=openWorkflowToolRunOwnerInbox(),r=[n.reader,createChannelReader(`commands`,t)],i=e.initialView,a=!1,o=!1,s,c=[],l=0,u={messages:[],ownerRequests:[]},d=new Map,f=new AbortController,p,m=e.workflow===void 0,h;try{await claimHookOwnership(t)}catch(e){if(isHookConflictError(e))return;throw e}for(await appendTaskViewStep({activityObserver:e.activityObserver,view:i});h!==void 0&&l>=h.reportCount&&(m=!0,await applyPayload({command:workflowToolRunOutcomeToTaskCommand({from:createWorkflowBodyRef({...e.workflow,execution:`background`}),result:h.outcome}),kind:`task-command`}),h=void 0,i.status===`cancelled`&&a&&!o&&await wakeTaskParentStep({token:e.parentContinuationToken,view:i})),!isFinished();){let e=await raceChannelReads(p===void 0?r:[...r,p]);if(e.channel===`body`){if(p=void 0,e.next.done)continue;h=e.next.value;continue}if(e.next.done)return;if(e.channel===`workflow`){let t=e.next.value;if(t.kind===`report`){await applyPayload(workflowToolRunReportToTaskPayload(t,i.taskId,l++));continue}if(t.kind===`outcome`){await applyPayload({command:workflowToolRunOutcomeToTaskCommand(t),kind:`task-command`});continue}let n=t,r=n.request.kind;if(r===`agent-invoke`||r===`agent-settled`||r===`authorization-request`){await handleOwnerRequest(n);continue}n.requestCoordinates===void 0&&d.set(n.replyTo,{runId:n.from.runId}),await applyPayload(workflowToolRunRequestToTaskInputRequest(n));continue}await applyPayload(e.next.value)}function isFinished(){return isTerminalTaskStatus(i.status)&&a&&m}async function handleUpdate(t){if(i.metadata.kind===`subagent`){if(o)return;a&&!isTerminalTaskStatus(i.status)?await wakeTaskUpdateParentStep({token:e.parentContinuationToken,update:t,view:i}):c.push(t);return}await appendTaskProgressStep({progress:{callId:t.callId,kind:`task-progress`,taskId:i.taskId,update:t.message,updateIndex:t.updateIndex}})}async function handleMessage(t){if(!(o||isTerminalTaskStatus(i.status))){if(!a){u.messages.push(t);return}await wakeTaskMessageParentStep({message:t,taskId:i.taskId,token:e.parentContinuationToken})}}async function applyPayload(t){let r=t.kind===`task-command`&&t.command.kind===`ready`,c=t.kind===`task-command`&&t.command.kind===`reject-dispatch`;if((r||c)&&(a=!0),c&&(o=!0),(r||c)&&(c||isTerminalTaskStatus(i.status)?m=!0:e.workflow!==void 0&&p===void 0&&h===void 0&&!m&&(p=createChannelReader(`body`,awaitBodyResult(executeWorkflowBody({...e.workflow,execution:`background`,owner:n.owner},f.signal)))),await flushPendingTraffic()),t.kind===`task-input-request`&&(s=t),t.kind===`task-message`){await handleMessage(t);return}if(t.kind===`task-update`){await handleUpdate(t);return}let l;if(t.kind===`input-response`)l=i.status===`input_required`?await resolveAnsweredCommand(i,t,d.get(t.childContinuationToken)):void 0;else if(t.kind===`task-input-request`)l={inputRequests:t.requests??[t.request],kind:`require-input`};else if(t.kind===`task-command`)l=t.command;else return;if(l===void 0)return;if(r&&isTerminalTaskStatus(i.status)){await flushUpdates(!0),await wakeTaskParentStep({token:e.parentContinuationToken,view:i});return}let u=i;await transitionTask(l)&&(l.kind===`cancel`&&(f.abort(Error(`Task ${i.taskId} was cancelled.`)),p===void 0&&(m=!0)),isTerminalTaskStatus(i.status)||await flushUpdates(),s!==void 0&&a&&i.status===`input_required`?(await wakeWorkflowTaskInputRequestParentStep({request:s,taskId:i.taskId,token:e.parentContinuationToken}),s=void 0):!o&&a&&(l.kind!==`cancel`||m)&&(!isTerminalTaskStatus(u.status)&&isTerminalTaskStatus(i.status)||!isReadyTaskStatus(u.status)&&isReadyTaskStatus(i.status)&&s===void 0)&&await wakeTaskParentStep({token:e.parentContinuationToken,view:i}),i.status!==`input_required`&&(s=void 0))}async function flushUpdates(t=!1){if(!(!a||isTerminalTaskStatus(i.status)&&!t)){for(let t of c)await wakeTaskUpdateParentStep({token:e.parentContinuationToken,update:t,view:i});c=[]}}async function transitionTask(t){let n=applyTaskTransition(i,t);return n.action===`accepted`&&(i=n.view,await appendTaskViewStep({activityObserver:e.activityObserver,view:i}),!0)}async function handleOwnerRequest(t){if(!a){u.ownerRequests.push(t);return}let{request:n,replyTo:r}=t;if(n.kind===`authorization-request`&&n.event.childSessionId===t.from.runId){await handleStepAuthorization(n,r);return}if(!(o||isTerminalTaskStatus(i.status))){if(n.kind===`authorization-request`){await wakeTaskAuthorizationParentStep({request:n,taskId:i.taskId,token:e.parentContinuationToken});return}await wakeTaskAgentRequestParentStep({request:t,taskId:i.taskId,token:e.parentContinuationToken})}}async function handleStepAuthorization(t,n){let r=t.event.event,a=r.type===`authorization.completed`;if(!o&&(!isTerminalTaskStatus(i.status)||a)){let n=`attemptId`in r.data?r.data.attemptId:void 0;n!==void 0&&r.type===`authorization.required`?await transitionTask({kind:`require-input`,inputRequests:[...i.status===`input_required`?i.inputRequests:[],{kind:`authorization`,requestId:n,name:r.data.name}]}):n!==void 0&&await transitionTask({kind:`answered`,requestIds:[n]}),await wakeTaskAuthorizationParentStep({request:t,taskId:i.taskId,token:e.parentContinuationToken})}await resumeHookStep(n,null,{ifPresent:!0})}async function flushPendingTraffic(){if(!o)for(let t of u.messages)await wakeTaskMessageParentStep({message:t,taskId:i.taskId,token:e.parentContinuationToken});for(let e of u.ownerRequests)await handleOwnerRequest(e);u.messages.length=0,u.ownerRequests.length=0}}async function*awaitBodyResult(e){yield await e}async function resolveAnsweredCommand(e,t,n){if(t.taskId!==e.taskId)return;let r=new Set(e.inputRequests.flatMap(e=>{let t=readTaskInputRequestId(e);return t===void 0?[]:[t]})),i=t.inputResponses.map(e=>e.requestId).filter(e=>r.has(e));if(i.length!==0)return await deliverTaskInputResponsesStep({answer:t,answerHook:n,requestIds:i})===`delivered`?{kind:`answered`,requestIds:i}:void 0}taskRunWorkflow.workflowId=`workflow//eve//taskRunWorkflow`;export{taskRunWorkflow};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type UnstampedMessageStreamEvent } from "#protocol/message.js";
|
|
2
|
-
/** Emits an already-projected task-owned `subagent.called` event on the parent stream. */
|
|
3
|
-
export declare function emitTaskSubagentCalledStep(input: {
|
|
4
|
-
readonly event: UnstampedMessageStreamEvent;
|
|
5
|
-
readonly sessionWritable: WritableStream<Uint8Array>;
|
|
6
|
-
readonly serializedContext: Record<string, unknown>;
|
|
7
|
-
}): Promise<{
|
|
8
|
-
readonly serializedContext: Record<string, unknown>;
|
|
9
|
-
}>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{callAdapterEventHandler}from"#channel/adapter.js";import{encodeMessageStreamEvent,stampMessageStreamEvent}from"#protocol/message.js";import{ChannelKey}from"#runtime/sessions/runtime-context-keys.js";import{deserializeContext,serializeContext}from"#context/serialize.js";import{buildAdapterContext}from"#channel/adapter-context.js";async function emitTaskSubagentCalledStep(e){"use step";let t=await deserializeContext(e.serializedContext),n=t.require(ChannelKey),r=await callAdapterEventHandler(n,e.event,buildAdapterContext(n,t)),i=e.sessionWritable.getWriter();try{await i.write(encodeMessageStreamEvent(stampMessageStreamEvent(r)))}finally{i.releaseLock()}return{serializedContext:serializeContext(t)}}export{emitTaskSubagentCalledStep};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The run's control inbox. An unawaited hook read is not scheduled under
|
|
3
|
-
* replay, so `cancelled` must be raced for a cancel to be observed at all.
|
|
4
|
-
*/
|
|
5
|
-
export interface WorkflowToolRunControlInbox {
|
|
6
|
-
readonly signal: AbortSignal;
|
|
7
|
-
/** Rejects with {@link WorkflowToolRunCancelledError} when a cancel message arrives; never resolves. */
|
|
8
|
-
readonly cancelled: Promise<never>;
|
|
9
|
-
reason(): string | undefined;
|
|
10
|
-
}
|
|
11
|
-
export declare function openWorkflowToolRunControlInbox(hookToken: string): WorkflowToolRunControlInbox;
|
|
12
|
-
export declare class WorkflowToolRunCancelledError extends Error {
|
|
13
|
-
constructor(reason: string);
|
|
14
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createHook}from"#compiled/@workflow/core/index.js";import{isWorkflowToolRunControlMessage}from"#execution/tools/workflow/messages.js";function openWorkflowToolRunControlInbox(e){let t=createHook({token:e})[Symbol.asyncIterator](),n=new AbortController,r,i=consumeCancel(t,e=>{r=e,n.abort(new WorkflowToolRunCancelledError(e))});return i.catch(()=>{}),{cancelled:i,reason:()=>r,signal:n.signal}}async function consumeCancel(e,t){for(;;){let n=await e.next();if(n.done===!0)return await new Promise(()=>{});if(isWorkflowToolRunControlMessage(n.value))throw t(n.value.reason),new WorkflowToolRunCancelledError(n.value.reason)}}var WorkflowToolRunCancelledError=class extends Error{constructor(e){super(e),this.name=`WorkflowToolRunCancelledError`}};export{WorkflowToolRunCancelledError,openWorkflowToolRunControlInbox};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import type { HarnessSession, SessionStateMap } from "#harness/types.js";
|
|
2
|
-
import { type ActivityWorkIdentityV1 } from "#protocol/activity.js";
|
|
3
|
-
import type { TaskExecutorBinding } from "#tools/task.js";
|
|
4
|
-
import { type TaskMetadata, type TaskView } from "#tasks/types.js";
|
|
5
|
-
import { type DurableDynamicSubagentSelection, type SessionAuth } from "#context/keys.js";
|
|
6
|
-
/**
|
|
7
|
-
* Session-state key for the parent's live-task index.
|
|
8
|
-
*
|
|
9
|
-
* The parent session stores only this index; the mutable task record
|
|
10
|
-
* lives in the dedicated durable task run. The PR #1190 spike found the
|
|
11
|
-
* session-state boundary unworkable for task state itself: session state
|
|
12
|
-
* threads through step results, while callback routes and child
|
|
13
|
-
* executors must update tasks without holding the current snapshot.
|
|
14
|
-
*/
|
|
15
|
-
export { SESSION_TASKS_STATE_KEY } from "#tasks/session-task-cohorts.js";
|
|
16
|
-
/**
|
|
17
|
-
* One task owned by this session. Immutable model-safe metadata keeps the
|
|
18
|
-
* task-to-agent join available before the task run publishes its first view.
|
|
19
|
-
*
|
|
20
|
-
* `taskInboxToken` is the private routing credential for the task run's
|
|
21
|
-
* inbound hook. It must never render into model context, history, task
|
|
22
|
-
* views, or compaction summaries — the model addresses tasks by
|
|
23
|
-
* `taskId` only, and lookup verifies ownership through this index.
|
|
24
|
-
*/
|
|
25
|
-
export interface SessionTaskIndexEntry {
|
|
26
|
-
readonly activityWorkIdentity?: ActivityWorkIdentityV1;
|
|
27
|
-
readonly dispatchContext: SessionTaskDispatchContext;
|
|
28
|
-
readonly taskId: string;
|
|
29
|
-
readonly taskRunId: string;
|
|
30
|
-
/** Immutable fallback once the owning workflow run expires. */
|
|
31
|
-
readonly terminalView?: TaskView;
|
|
32
|
-
readonly taskInboxToken: string;
|
|
33
|
-
readonly createdByStepIndex?: number;
|
|
34
|
-
readonly createdByTurnId: string;
|
|
35
|
-
/** Immutable join target; absent on the task that starts a cohort. */
|
|
36
|
-
readonly cohortId?: string;
|
|
37
|
-
readonly executor?: TaskExecutorBinding;
|
|
38
|
-
readonly metadata: TaskMetadata;
|
|
39
|
-
}
|
|
40
|
-
export interface TaskAgentDispatchContext {
|
|
41
|
-
readonly auth: SessionAuth;
|
|
42
|
-
readonly sessionDynamicSubagentSelections?: Readonly<Record<string, DurableDynamicSubagentSelection>>;
|
|
43
|
-
readonly turnDynamicSubagentSelections?: Readonly<Record<string, DurableDynamicSubagentSelection>>;
|
|
44
|
-
}
|
|
45
|
-
export declare const LEGACY_TASK_AGENT_DISPATCH_CONTEXT: {
|
|
46
|
-
readonly legacy: true;
|
|
47
|
-
};
|
|
48
|
-
export type SessionTaskDispatchContext = TaskAgentDispatchContext | typeof LEGACY_TASK_AGENT_DISPATCH_CONTEXT;
|
|
49
|
-
/**
|
|
50
|
-
* Reads and validates the task index from session state.
|
|
51
|
-
*
|
|
52
|
-
* A present but invalid index throws: treating corruption as absence
|
|
53
|
-
* would silently orphan every live task's routing credential.
|
|
54
|
-
*/
|
|
55
|
-
export declare function getSessionTaskIndex(state: SessionStateMap | undefined): readonly SessionTaskIndexEntry[];
|
|
56
|
-
/** Caches one terminal view beside its task-run address. */
|
|
57
|
-
export declare function cacheTerminalTaskView(state: SessionStateMap | undefined, view: TaskView): SessionStateMap | undefined;
|
|
58
|
-
/** Finds one owned task; `undefined` enforces parent-session ownership. */
|
|
59
|
-
export declare function findSessionTaskEntry(state: SessionStateMap | undefined, taskId: string): SessionTaskIndexEntry | undefined;
|
|
60
|
-
/**
|
|
61
|
-
* Joins the indexed cohort that still has unreported/nonterminal work. Cached
|
|
62
|
-
* terminal siblings remain members until the whole cohort settles. Membership
|
|
63
|
-
* and creation provenance survive replay, even after that cohort has settled.
|
|
64
|
-
*/
|
|
65
|
-
export declare function recordSessionTask(session: HarnessSession, entry: Omit<SessionTaskIndexEntry, "cohortId">): HarnessSession;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{z}from"#compiled/zod/index.js";import"#context/keys.js";import{parseActivityWorkIdentityV1}from"#protocol/activity.js";import{SESSION_TASKS_STATE_KEY,SESSION_TASKS_STATE_KEY as SESSION_TASKS_STATE_KEY$1,SESSION_TASKS_STATE_VERSION,getTaskCohortId}from"#tasks/session-task-cohorts.js";import{sameTaskMetadata}from"#tasks/types.js";const taskMetadataSchema=z.looseObject({kind:z.string().min(1),name:z.string().min(1)}),LEGACY_TASK_AGENT_DISPATCH_CONTEXT={legacy:!0},sessionAuthContextSchema=z.strictObject({attributes:z.record(z.string(),z.union([z.string(),z.array(z.string()).readonly()])),authenticator:z.string(),issuer:z.string().optional(),principalId:z.string(),principalType:z.string(),subject:z.string().optional()}),dynamicSubagentSelectionsSchema=z.record(z.string(),z.custom()),taskAgentDispatchContextSchema=z.strictObject({auth:z.strictObject({current:sessionAuthContextSchema.nullable(),initiator:sessionAuthContextSchema.nullable()}),sessionDynamicSubagentSelections:dynamicSubagentSelectionsSchema.optional(),turnDynamicSubagentSelections:dynamicSubagentSelectionsSchema.optional()}),sessionTaskDispatchContextSchema=z.union([taskAgentDispatchContextSchema,z.strictObject({legacy:z.literal(!0)})]),taskViewBaseShape={inputRequests:z.never().optional(),executor:z.looseObject({binding:z.looseObject({data:z.record(z.string(),z.custom()),kind:z.string().min(1)}).optional()}).optional(),metadata:taskMetadataSchema,taskId:z.string().min(1),usage:z.looseObject({cacheReadTokens:z.number().nonnegative(),cacheWriteTokens:z.number().nonnegative(),costUsd:z.number().finite().nonnegative().optional(),inputTokens:z.number().nonnegative(),outputTokens:z.number().nonnegative()}).optional()},taskViewSchema=z.discriminatedUnion(`status`,[z.looseObject({...taskViewBaseShape,lastOutput:z.looseObject({data:z.custom(),type:z.literal(`result`)}),status:z.literal(`completed`)}),z.looseObject({...taskViewBaseShape,lastOutput:z.looseObject({data:z.custom(),type:z.literal(`error`)}),status:z.literal(`failed`)}),z.looseObject({...taskViewBaseShape,lastOutput:z.never().optional(),status:z.literal(`cancelled`)})]),storedSessionTaskIndexEntrySchema=z.looseObject({activityWorkIdentity:z.custom(e=>parseActivityWorkIdentityV1(e)!==void 0).optional(),taskInboxToken:z.string().min(1),createdByStepIndex:z.number().int().nonnegative().optional(),createdByTurnId:z.string().min(1),cohortId:z.string().min(1).optional(),dispatchContext:sessionTaskDispatchContextSchema.optional(),executor:z.looseObject({data:z.record(z.string(),z.custom()),kind:z.string().min(1)}).optional(),metadata:taskMetadataSchema,taskId:z.string().min(1),taskRunId:z.string().min(1),terminalView:taskViewSchema.optional()}),sessionTaskIndexSchema=z.looseObject({tasks:z.array(storedSessionTaskIndexEntrySchema),version:z.literal(SESSION_TASKS_STATE_VERSION)}).refine(e=>new Set(e.tasks.map(e=>e.taskId)).size===e.tasks.length,{message:`Task ids must be unique.`}).refine(e=>e.tasks.every(e=>e.terminalView===void 0||e.terminalView.taskId===e.taskId&&sameTaskMetadata(e.terminalView.metadata,e.metadata)),{message:`Cached terminal views must match their task index entry.`});function getSessionTaskIndex(e){return readSessionTaskIndex(e).tasks}function readSessionTaskIndex(e){let t=e?.[SESSION_TASKS_STATE_KEY$1];if(t===void 0)return{tasks:[],version:SESSION_TASKS_STATE_VERSION};let n=typeof t==`object`&&t?Reflect.get(t,`version`):void 0;if(n!==SESSION_TASKS_STATE_VERSION)throw Error(`Unsupported task index version ${JSON.stringify(n)} under session state key "${SESSION_TASKS_STATE_KEY$1}"; expected version ${SESSION_TASKS_STATE_VERSION}.`);let r=sessionTaskIndexSchema.safeParse(t);if(!r.success)throw Error(`Corrupt task index under session state key "${SESSION_TASKS_STATE_KEY$1}": ${r.error.message}`);return{...r.data,tasks:r.data.tasks.map(e=>({...e,dispatchContext:e.dispatchContext??LEGACY_TASK_AGENT_DISPATCH_CONTEXT}))}}function cacheTerminalTaskView(e,t){if(!isValidTerminalView(t))throw Error(`Cannot cache invalid terminal task "${t.taskId}".`);let n=readSessionTaskIndex(e),r=n.tasks,i=r.findIndex(e=>e.taskId===t.taskId);if(i<0)return e;if(!sameTaskMetadata(r[i].metadata,t.metadata))throw Error(`Task view metadata does not match index entry "${t.taskId}".`);let a=[...r],o=a[i].terminalView;return a[i]={...a[i],terminalView:taskViewSchema.parse({...o,...t,metadata:{...o?.metadata,...t.metadata},lastOutput:t.lastOutput===void 0?void 0:{...o?.lastOutput,...t.lastOutput},usage:t.usage===void 0?void 0:{...o?.usage,...t.usage},executor:t.executor===void 0?void 0:{...o?.executor,...t.executor,binding:t.executor.binding===void 0?void 0:{...o?.executor?.binding,...t.executor.binding}}})},{...e,[SESSION_TASKS_STATE_KEY$1]:{...n,tasks:a}}}function isValidTerminalView(e){if(e.inputRequests!==void 0)return!1;switch(e.status){case`completed`:return e.lastOutput?.type===`result`;case`failed`:return e.lastOutput?.type===`error`;case`cancelled`:return e.lastOutput===void 0;case`working`:return!1}}function findSessionTaskEntry(e,t){return getSessionTaskIndex(e).find(e=>e.taskId===t)}function recordSessionTask(e,t){let n=readSessionTaskIndex(e.state),r=[...n.tasks],i=r.findIndex(e=>e.taskId===t.taskId),a=r[i];if(a!==void 0)r[i]={...a,...t,metadata:{...a.metadata,...t.metadata},activityWorkIdentity:t.activityWorkIdentity===void 0?a.activityWorkIdentity:{...a.activityWorkIdentity,...t.activityWorkIdentity},executor:t.executor===void 0?a.executor:{...a.executor,...t.executor},cohortId:a.cohortId,createdByStepIndex:a.createdByStepIndex,createdByTurnId:a.createdByTurnId,dispatchContext:a.dispatchContext,terminalView:a.terminalView??t.terminalView};else{let e=r.find(e=>e.terminalView===void 0);r.push({...t,cohortId:e===void 0?void 0:getTaskCohortId(e)})}return{...e,state:{...e.state,[SESSION_TASKS_STATE_KEY$1]:{...n,tasks:r,version:SESSION_TASKS_STATE_VERSION}}}}export{LEGACY_TASK_AGENT_DISPATCH_CONTEXT,SESSION_TASKS_STATE_KEY,cacheTerminalTaskView,findSessionTaskEntry,getSessionTaskIndex,recordSessionTask};
|
package/dist/src/tools/task.d.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import type { BackgroundTask } from "#execution/tasks/parent/delegate.js";
|
|
2
|
-
import type { HarnessSession } from "#harness/types.js";
|
|
3
|
-
import type { JsonObject, JsonValue } from "#shared/json.js";
|
|
4
|
-
declare const TASK_MESSAGE_KIND: "eve:task-message";
|
|
5
|
-
export type TaskMessage = JsonObject & {
|
|
6
|
-
readonly kind: typeof TASK_MESSAGE_KIND;
|
|
7
|
-
readonly message: string;
|
|
8
|
-
};
|
|
9
|
-
export declare function createTaskMessage(message: string): TaskMessage;
|
|
10
|
-
export declare function isTaskMessage(value: unknown): value is TaskMessage;
|
|
11
|
-
/** Opaque, framework-private address used to control a task executor. */
|
|
12
|
-
export interface TaskExecutorBinding {
|
|
13
|
-
readonly kind: string;
|
|
14
|
-
readonly data: JsonObject;
|
|
15
|
-
}
|
|
16
|
-
/** @deprecated Use workflow-backed background tools with yield descriptors. */
|
|
17
|
-
export interface TaskBinding {
|
|
18
|
-
readonly taskId: string;
|
|
19
|
-
readonly token: string;
|
|
20
|
-
readonly url?: string;
|
|
21
|
-
}
|
|
22
|
-
/** @deprecated Use workflow-backed background tools with yield descriptors. */
|
|
23
|
-
export type TaskSendCommand = {
|
|
24
|
-
readonly kind: "update";
|
|
25
|
-
readonly message: string;
|
|
26
|
-
} | {
|
|
27
|
-
readonly kind: "complete";
|
|
28
|
-
readonly data: JsonValue;
|
|
29
|
-
} | {
|
|
30
|
-
readonly kind: "fail";
|
|
31
|
-
readonly data: JsonValue;
|
|
32
|
-
} | {
|
|
33
|
-
readonly kind: "cancel";
|
|
34
|
-
};
|
|
35
|
-
/** Fixed acknowledgement returned when a background task is admitted. */
|
|
36
|
-
export interface TaskReceipt {
|
|
37
|
-
readonly status: "working";
|
|
38
|
-
readonly taskId: string;
|
|
39
|
-
}
|
|
40
|
-
/** Capability passed only to tools declared with `execution: "background"`. */
|
|
41
|
-
export interface TaskExec {
|
|
42
|
-
/** Model-facing durable task identity. */
|
|
43
|
-
readonly taskId: string;
|
|
44
|
-
/** Returns a descriptor which sends one message to the parent when yielded. */
|
|
45
|
-
postMessage(message: string): TaskMessage;
|
|
46
|
-
/** @deprecated Use yields from a workflow-backed background tool. */
|
|
47
|
-
readonly binding: TaskBinding;
|
|
48
|
-
/** @deprecated Use yields from a workflow-backed background tool. */
|
|
49
|
-
readonly send: (command: TaskSendCommand) => Promise<void>;
|
|
50
|
-
/** @deprecated Use ctx.session. */
|
|
51
|
-
readonly session: HarnessSession;
|
|
52
|
-
/** @deprecated Framework-owned task internals are not part of the authoring API. */
|
|
53
|
-
readonly task: BackgroundTask;
|
|
54
|
-
}
|
|
55
|
-
export {};
|
package/dist/src/tools/task.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const TASK_MESSAGE_KIND=`eve:task-message`;function createTaskMessage(e){if(e.trim()===``)throw TypeError(`Task messages must not be empty.`);return{kind:TASK_MESSAGE_KIND,message:e}}function isTaskMessage(e){return typeof e==`object`&&!!e&&Reflect.get(e,`kind`)===TASK_MESSAGE_KIND}export{createTaskMessage,isTaskMessage};
|