eve 0.64.0 → 0.65.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 +31 -0
- package/dist/src/channel/resolve-text.d.ts +11 -7
- package/dist/src/channel/resolve-text.js +1 -1
- package/dist/src/channel/types.d.ts +4 -5
- package/dist/src/chunks/{use-eve-agent-BdKlQF32.js → use-eve-agent-BIouJCii.js} +2 -10
- package/dist/src/chunks/{use-eve-agent-IIuxkn6y.js → use-eve-agent-BRvEh9sO.js} +2 -10
- package/dist/src/cli/commands/registry-pnpm-build-policy-flow.d.ts +1 -1
- package/dist/src/cli/commands/registry-pnpm-build-policy-flow.js +1 -1
- package/dist/src/cli/dev/command-options.d.ts +1 -0
- package/dist/src/cli/dev/command.js +2 -2
- package/dist/src/cli/dev/local-server-process.js +1 -1
- package/dist/src/cli/dev/tui/blocks.d.ts +1 -1
- package/dist/src/cli/dev/tui/blocks.js +1 -1
- package/dist/src/cli/dev/tui/question-panel.d.ts +3 -2
- package/dist/src/cli/dev/tui/rail.d.ts +1 -1
- package/dist/src/cli/dev/tui/runner.d.ts +0 -1
- package/dist/src/cli/dev/tui/runner.js +2 -2
- package/dist/src/cli/dev/tui/terminal-renderer.d.ts +0 -1
- package/dist/src/cli/dev/tui/terminal-renderer.js +11 -12
- package/dist/src/cli/dev/tui/theme.d.ts +1 -1
- package/dist/src/cli/dev/tui/tool-presentation.d.ts +4 -4
- package/dist/src/cli/dev/tui/tool-presentation.js +1 -1
- package/dist/src/client/agent-info-schema.d.ts +0 -2
- package/dist/src/client/agent-info-schema.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +1 -2
- package/dist/src/compiler/artifacts.d.ts +2 -0
- package/dist/src/compiler/artifacts.js +1 -1
- package/dist/src/compiler/bundled-extension.d.ts +17 -0
- package/dist/src/compiler/bundled-extension.js +1 -0
- package/dist/src/compiler/compile-agent.d.ts +4 -0
- package/dist/src/compiler/compile-agent.js +1 -1
- package/dist/src/compiler/compile-from-memory.js +1 -1
- package/dist/src/compiler/development-extensions.d.ts +23 -0
- package/dist/src/compiler/development-extensions.js +1 -0
- package/dist/src/compiler/extension-compatibility.d.ts +2 -2
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/compiler/load-binding-namespace.js +1 -1
- package/dist/src/compiler/manifest.js +1 -1
- package/dist/src/compiler/normalize-manifest-helpers.js +1 -1
- package/dist/src/compiler/normalize-manifest-types.d.ts +23 -0
- package/dist/src/compiler/normalize-manifest-types.js +1 -0
- package/dist/src/compiler/normalize-manifest.d.ts +2 -7
- package/dist/src/compiler/normalize-manifest.js +1 -1
- package/dist/src/compiler/source-graph-paths.d.ts +2 -0
- package/dist/src/compiler/source-graph-paths.js +1 -0
- package/dist/src/compiler/source-graph.d.ts +4 -1
- package/dist/src/compiler/source-graph.js +1 -1
- package/dist/src/context/dynamic-skill-lifecycle.js +1 -1
- package/dist/src/discover/bundled-extension.d.ts +11 -0
- package/dist/src/discover/bundled-extension.js +1 -0
- package/dist/src/discover/discover-agent.js +1 -1
- package/dist/src/discover/manifest.d.ts +5 -0
- package/dist/src/evals/assertions/collector.js +1 -1
- package/dist/src/evals/cli/eval.js +2 -2
- package/dist/src/evals/runner/artifacts.js +1 -1
- package/dist/src/evals/types.d.ts +2 -0
- package/dist/src/execution/coordination-dispatch-step.js +1 -1
- package/dist/src/execution/dynamic-workflow/tool.js +1 -1
- package/dist/src/execution/node-step.d.ts +2 -4
- package/dist/src/execution/node-step.js +1 -1
- package/dist/src/execution/proxied-deliver-step.js +1 -1
- package/dist/src/execution/sandbox/bindings/just-bash-runtime.js +1 -1
- package/dist/src/execution/sandbox/bindings/microsandbox-runtime.js +1 -1
- package/dist/src/execution/sandbox/development-lazy-prewarm.d.ts +7 -0
- package/dist/src/execution/sandbox/development-lazy-prewarm.js +1 -0
- package/dist/src/execution/sandbox/ensure.js +1 -1
- package/dist/src/execution/sandbox/glob-tool.js +1 -1
- package/dist/src/execution/sandbox/grep-tool.js +1 -1
- package/dist/src/execution/sandbox/prewarm.js +1 -1
- package/dist/src/execution/sandbox/read-file.js +1 -1
- package/dist/src/execution/session/turn-step.js +1 -1
- package/dist/src/execution/session-workflow-tool-run.js +1 -1
- package/dist/src/execution/tasks/parent/tool-execution.js +1 -1
- package/dist/src/execution/tools/agent-router-workflow.js +1 -1
- package/dist/src/execution/tools/ask-question-workflow.d.ts +11 -0
- package/dist/src/execution/tools/ask-question-workflow.js +1 -0
- package/dist/src/execution/tools/ask-question.d.ts +20 -0
- package/dist/src/execution/tools/ask-question.js +2 -0
- package/dist/src/execution/tools/file-state.d.ts +1 -7
- package/dist/src/execution/tools/file-state.js +1 -1
- package/dist/src/execution/tools/sleep-workflow.js +1 -1
- package/dist/src/execution/tools/workflow/answer.d.ts +2 -0
- package/dist/src/execution/tools/workflow/answer.js +1 -1
- package/dist/src/execution/tools/workflow/ask.d.ts +3 -2
- package/dist/src/execution/tools/workflow/ask.js +1 -1
- package/dist/src/execution/tools/workflow/body.d.ts +5 -0
- package/dist/src/execution/tools/workflow/body.js +1 -1
- package/dist/src/execution/tools/workflow/cancel.d.ts +0 -4
- package/dist/src/execution/tools/workflow/cancel.js +1 -1
- package/dist/src/execution/tools/workflow/start.d.ts +1 -0
- package/dist/src/execution/tools/workflow/start.js +1 -1
- package/dist/src/framework/sources/registry.js +1 -1
- package/dist/src/harness/compaction-prompt.d.ts +0 -6
- package/dist/src/harness/compaction-prompt.js +2 -2
- package/dist/src/harness/compaction.js +1 -1
- package/dist/src/harness/hitl/approval-input-requests.d.ts +0 -2
- package/dist/src/harness/hitl/approval-input-requests.js +1 -1
- package/dist/src/harness/input-extraction.d.ts +4 -15
- package/dist/src/harness/input-extraction.js +1 -1
- package/dist/src/harness/input-request-class.d.ts +0 -20
- package/dist/src/harness/input-request-class.js +1 -1
- package/dist/src/harness/input-requests.d.ts +1 -1
- package/dist/src/harness/input-requests.js +1 -1
- package/dist/src/harness/pending-input-batches.d.ts +1 -1
- package/dist/src/harness/proxy-input-requests.d.ts +9 -1
- package/dist/src/harness/proxy-input-requests.js +1 -1
- package/dist/src/harness/stale-input-responses.d.ts +1 -2
- package/dist/src/harness/stale-input-responses.js +1 -1
- package/dist/src/harness/tool-loop.js +2 -2
- package/dist/src/harness/tools.d.ts +0 -9
- package/dist/src/harness/tools.js +1 -1
- package/dist/src/harness/types.d.ts +2 -9
- package/dist/src/internal/application/compiled-artifacts.js +1 -1
- package/dist/src/internal/application/optional-package-install.d.ts +3 -0
- package/dist/src/internal/application/optional-package-install.js +2 -2
- package/dist/src/internal/application/output-publication-lock.d.ts +6 -0
- package/dist/src/internal/application/output-publication-lock.js +1 -1
- package/dist/src/internal/application/output-publication.js +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/authored-definition/schema-backed.js +1 -1
- package/dist/src/internal/authored-module-loader.d.ts +1 -0
- package/dist/src/internal/authored-module-loader.js +1 -1
- package/dist/src/internal/authored-runtime-modules.d.ts +1 -0
- package/dist/src/internal/development-programmatic-source-loader.d.ts +6 -0
- package/dist/src/internal/development-programmatic-source-loader.js +1 -0
- package/dist/src/internal/nitro/dev-runtime-artifacts.js +1 -1
- package/dist/src/internal/nitro/development-generation.js +1 -1
- package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
- package/dist/src/internal/nitro/host/dev-authored-rebuild-coordinator.d.ts +2 -0
- package/dist/src/internal/nitro/host/dev-authored-rebuild-coordinator.js +1 -1
- package/dist/src/internal/nitro/host/dev-workspace-extensions.js +1 -1
- package/dist/src/internal/nitro/host/development-runtime-prune-plugin.d.ts +9 -0
- package/dist/src/internal/nitro/host/development-runtime-prune-plugin.js +2 -0
- package/dist/src/internal/nitro/host/prepare-application-host.d.ts +2 -0
- package/dist/src/internal/nitro/host/prepare-application-host.js +1 -1
- package/dist/src/internal/nitro/host/start-development-server.js +2 -2
- package/dist/src/internal/nitro/host/types.d.ts +3 -0
- package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.js +1 -1
- package/dist/src/internal/workflow-bundle/workflow-builders.d.ts +0 -2
- package/dist/src/internal/workflow-bundle/workflow-builders.js +1 -1
- package/dist/src/public/next/vercel-output-config.js +1 -1
- package/dist/src/public/tools/ask-question.d.ts +1 -1
- package/dist/src/public/tools/ask-question.js +1 -1
- package/dist/src/runtime/agent/mock-model-fixtures.js +2 -2
- package/dist/src/runtime/cache-key.js +1 -1
- package/dist/src/runtime/sandbox/prepared-artifacts.js +1 -1
- package/dist/src/self-modification/extension/subagents/agent/instructions.js +6 -2
- package/dist/src/{cli/commands/registry-pnpm-build-policy.d.ts → setup/primitives/pm/pnpm-build-policy.d.ts} +4 -0
- package/dist/src/setup/primitives/pm/pnpm-build-policy.js +8 -0
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/shared/input.d.ts +1 -6
- package/dist/src/shared/sandbox-provider.d.ts +2 -0
- package/dist/src/subagents/hitl-proxy.d.ts +11 -1
- package/dist/src/subagents/hitl-proxy.js +1 -1
- package/dist/src/svelte/index.js +1 -1
- package/dist/src/svelte/use-eve-agent.js +1 -1
- package/dist/src/tools/behavior.d.ts +2 -5
- package/dist/src/tools/definition.d.ts +23 -5
- package/dist/src/tools/provided/ask-question.d.ts +18 -0
- package/dist/src/tools/provided/ask-question.js +1 -0
- package/dist/src/tools/provided/sleep.d.ts +2 -2
- package/dist/src/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/agent-config.md +11 -11
- package/docs/channels/slack.mdx +1 -1
- package/docs/concepts/built-in-tools.md +16 -66
- package/docs/concepts/default-harness.md +1 -3
- package/docs/concepts/execution-model-and-durability.mdx +1 -1
- package/docs/concepts/sessions-runs-and-streaming.md +2 -2
- package/docs/evals/assertions.mdx +2 -2
- package/docs/evals/judge.mdx +3 -3
- package/docs/getting-started.mdx +1 -1
- package/docs/guides/deployment/vercel.mdx +0 -6
- package/docs/guides/dev-tui.md +1 -1
- package/docs/guides/evaluate.md +12 -9
- package/docs/guides/frontend/overview.mdx +1 -1
- package/docs/guides/instrumentation/instrumentation.mdx +1 -1
- package/docs/guides/instrumentation/migration.md +1 -6
- package/docs/guides/instrumentation/otel.mdx +15 -47
- package/docs/reference/cli.md +10 -7
- package/docs/reference/typescript-api.md +42 -41
- package/docs/sandbox/index.mdx +3 -1
- package/docs/sandbox/just-bash.mdx +6 -0
- package/docs/skills.mdx +2 -0
- package/docs/subagents/index.mdx +7 -5
- package/docs/tools/human-in-the-loop.md +22 -11
- package/docs/tools/workflows.mdx +44 -19
- package/docs/tutorial/guard-the-spend.mdx +1 -1
- package/package.json +1 -9
- package/dist/src/cli/commands/registry-pnpm-build-policy.js +0 -6
- package/dist/src/cli/dev/tui/todo-panel.d.ts +0 -44
- package/dist/src/cli/dev/tui/todo-panel.js +0 -1
- package/dist/src/compiled/@workflow/builders/LICENSE.md +0 -201
- package/dist/src/compiled/@workflow/builders/index.d.ts +0 -62
- package/dist/src/compiled/@workflow/builders/index.js +0 -1
- package/dist/src/execution/compaction.d.ts +0 -14
- package/dist/src/execution/compaction.js +0 -1
- package/dist/src/execution/sandbox/development-prewarm.d.ts +0 -20
- package/dist/src/execution/sandbox/development-prewarm.js +0 -1
- package/dist/src/execution/tools/todo.d.ts +0 -91
- package/dist/src/execution/tools/todo.js +0 -2
- package/dist/src/harness/hitl/question-input-requests.d.ts +0 -15
- package/dist/src/harness/hitl/question-input-requests.js +0 -1
- package/dist/src/harness/request-input-tool.d.ts +0 -4
- package/dist/src/harness/request-input-tool.js +0 -1
- package/dist/src/public/tools/todo.d.ts +0 -3
- package/dist/src/public/tools/todo.js +0 -1
- package/dist/src/tools/framework/ask-question.d.ts +0 -38
- package/dist/src/tools/framework/ask-question.js +0 -1
- package/dist/src/tools/provided/todo.d.ts +0 -8
- package/dist/src/tools/provided/todo.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getWorkflowMetadata}from"#compiled/@workflow/core/index.js";import{normalizeSerializableError}from"#execution/workflow-errors.js";import{resumeHookStep}from"#execution/tools/workflow/resume-hook-step.js";import{ask,attachWorkflowToolRunContext}from"#execution/tools/workflow/ask.js";import{agent}from"#execution/tools/subagent/invoke-agent.js";import"#execution/tools/workflow/messages.js";import{readRegisteredWorkflow}from"#execution/workflow-registry.js";async function executeWorkflowBody(e,t){let n=createWorkflowBodyRef(e),r=createWorkflowBodyContext(e,t);attachWorkflowToolRunContext(r,{from:n,owner:e.owner});let i=0;try{let t=resolveWorkflowToolExecute(e)(e.executeInput??e.input,r),a;if(!isAsyncIterable(t))a=await t;else{let r=t[Symbol.asyncIterator](),o,s=await r.next();for(;s.done!==!0;){o=s.value;let t={from:n,update:s.value};await resumeHookStep(e.owner.inbox,{kind:`report`,...t}),i+=1,s=await r.next()}a=s.value??(e.execution===`blocking`?o:void 0)??null}return{outcome:{output:a,status:`completed`},reportCount:i}}catch(e){return t.aborted?{outcome:{reason:t.reason instanceof Error?t.reason.message:String(t.reason??``),status:`cancelled`},reportCount:i}:{outcome:{error:normalizeSerializableError(e),status:`failed`},reportCount:i}}}function createWorkflowBodyRef(e){return{callId:e.callId,execution:e.execution,input:e.input,runId:e.runId??getWorkflowMetadata().workflowRunId,sequence:e.session.turn.sequence,stepIndex:e.stepIndex,toolName:e.toolName,turnId:e.session.turn.id}}function resolveWorkflowToolExecute(e){let t=readRegisteredWorkflow(e.workflowId);if(typeof t!=`function`)throw Error(`Tool "${e.toolName}" is not registered as a workflow in this deployment (${e.workflowId}). The tool was renamed or removed after this run started.`);return t}function createWorkflowBodyContext(e,t){let unavailable=(t,n)=>{throw Error(`ctx.${t} is not available inside a workflow tool; ${n}. Tool "${e.toolName}" runs as a durable workflow body, which only replays deterministic code.`)},n={agent:((e,t)=>agent(n,e,t)),agents:Object.freeze(Object.fromEntries(Object.entries(e.agents??{}).map(([e,t])=>[e,Object.freeze({...t})]))),ask:e=>ask(n,e),abortSignal:t,callId:e.callId,getSandbox:()=>unavailable(`getSandbox()`,`the session sandbox belongs to the turn`),getSkill:()=>unavailable(`getSkill()`,`skills are read through the session sandbox`),getToken:()=>unavailable(`getToken()`,`pass ctx directly to a "use step" helper to resolve credentials`),requireAuth:()=>unavailable(`requireAuth()`,`pass ctx directly to a "use step" helper to request authorization`),session:e.session,toolName:e.toolName};return n}function isAsyncIterable(e){return typeof e==`object`&&!!e&&typeof e[Symbol.asyncIterator]==`function`}export{createWorkflowBodyRef,executeWorkflowBody};
|
|
1
|
+
import{getWorkflowMetadata}from"#compiled/@workflow/core/index.js";import{normalizeSerializableError}from"#execution/workflow-errors.js";import{resumeHookStep}from"#execution/tools/workflow/resume-hook-step.js";import{ask,attachWorkflowToolRunContext}from"#execution/tools/workflow/ask.js";import{agent}from"#execution/tools/subagent/invoke-agent.js";import"#execution/tools/workflow/messages.js";import{readRegisteredWorkflow}from"#execution/workflow-registry.js";async function executeWorkflowBody(e,t){let n=createWorkflowBodyRef(e),r=createWorkflowBodyContext(e,t);attachWorkflowToolRunContext(r,{canRequestInput:e.canRequestInput,from:n,owner:e.owner});let i=0;try{let t=resolveWorkflowToolExecute(e)(e.executeInput??e.input,r),a;if(!isAsyncIterable(t))a=await t;else{let r=t[Symbol.asyncIterator](),o,s=await r.next();for(;s.done!==!0;){o=s.value;let t={from:n,update:s.value};await resumeHookStep(e.owner.inbox,{kind:`report`,...t}),i+=1,s=await r.next()}a=s.value??(e.execution===`blocking`?o:void 0)??null}return{outcome:{output:a,status:`completed`},reportCount:i}}catch(e){return t.aborted?{outcome:{reason:t.reason instanceof Error?t.reason.message:String(t.reason??``),status:`cancelled`},reportCount:i}:{outcome:{error:normalizeSerializableError(e),status:`failed`},reportCount:i}}}function createWorkflowBodyRef(e){return{callId:e.callId,execution:e.execution,input:e.input,runId:e.runId??getWorkflowMetadata().workflowRunId,sequence:e.session.turn.sequence,stepIndex:e.stepIndex,toolName:e.toolName,turnId:e.session.turn.id}}function resolveWorkflowToolExecute(e){let t=readRegisteredWorkflow(e.workflowId);if(typeof t!=`function`)throw Error(`Tool "${e.toolName}" is not registered as a workflow in this deployment (${e.workflowId}). The tool was renamed or removed after this run started.`);return t}function createWorkflowBodyContext(e,t){let unavailable=(t,n)=>{throw Error(`ctx.${t} is not available inside a workflow tool; ${n}. Tool "${e.toolName}" runs as a durable workflow body, which only replays deterministic code.`)},n={agent:((e,t)=>agent(n,e,t)),agents:Object.freeze(Object.fromEntries(Object.entries(e.agents??{}).map(([e,t])=>[e,Object.freeze({...t})]))),ask:e=>ask(n,e),abortSignal:t,callId:e.callId,getSandbox:()=>unavailable(`getSandbox()`,`the session sandbox belongs to the turn`),getSkill:()=>unavailable(`getSkill()`,`skills are read through the session sandbox`),getToken:()=>unavailable(`getToken()`,`pass ctx directly to a "use step" helper to resolve credentials`),requireAuth:()=>unavailable(`requireAuth()`,`pass ctx directly to a "use step" helper to request authorization`),session:e.session,toolName:e.toolName};return n}function isAsyncIterable(e){return typeof e==`object`&&!!e&&typeof e[Symbol.asyncIterator]==`function`}export{createWorkflowBodyRef,executeWorkflowBody};
|
|
@@ -6,7 +6,3 @@ import type { WorkflowToolRunAddress } from "#execution/tools/workflow/types.js"
|
|
|
6
6
|
export declare function cancelWorkflowToolRun(run: WorkflowToolRunAddress, reason: string): Promise<void>;
|
|
7
7
|
/** Allows cooperative cleanup, then forcibly stops a still-live run. */
|
|
8
8
|
export declare function settleWorkflowToolRunCancellation(runId: string, reason: string, cooperative?: boolean): Promise<void>;
|
|
9
|
-
export declare function cancelWorkflowToolRunStep(input: {
|
|
10
|
-
readonly reason: string;
|
|
11
|
-
readonly run: WorkflowToolRunAddress;
|
|
12
|
-
}): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createLogger,logError}from"#internal/logging.js";import{cancelRun,getRun,getWorld,resumeHook}from"#internal/workflow/runtime.js";import{isTaskWorkflowTargetGone}from"#execution/tasks/workflow-target.js";import{WORKFLOW_CANCELLATION_SETTLE_MS}from"#execution/tools/workflow/cancellation-policy.js";const log=createLogger(`execution.workflow-tool-run`);async function cancelWorkflowToolRun(e,t){let n={kind:`cancel`,reason:t},r=!1;try{await resumeHook(e.hookToken,n),r=!0}catch(t){isTaskWorkflowTargetGone(t)||logError(log,`failed to signal a workflow tool run to cancel; cancelling it outright`,t,{runId:e.runId})}try{await settleWorkflowToolRunCancellation(e.runId,t,r)}catch(t){if(isTaskWorkflowTargetGone(t))return;logError(log,`failed to cancel workflow tool run; it may run to completion`,t,{runId:e.runId})}}async function settleWorkflowToolRunCancellation(e,t,n=!0){if(n){let t=Date.now()+WORKFLOW_CANCELLATION_SETTLE_MS;for(;Date.now()<t;){try{let t=await getRun(e).status;if(t!==`pending`&&t!==`running`)return}catch(e){if(isTaskWorkflowTargetGone(e))return;throw e}await new Promise(e=>setTimeout(e,250))}}try{await cancelRun(await getWorld(),e,{cancelReason:t})}catch(e){if(isTaskWorkflowTargetGone(e))return;throw e}}
|
|
1
|
+
import{createLogger,logError}from"#internal/logging.js";import{cancelRun,getRun,getWorld,resumeHook}from"#internal/workflow/runtime.js";import{isTaskWorkflowTargetGone}from"#execution/tasks/workflow-target.js";import{WORKFLOW_CANCELLATION_SETTLE_MS}from"#execution/tools/workflow/cancellation-policy.js";const log=createLogger(`execution.workflow-tool-run`);async function cancelWorkflowToolRun(e,t){let n={kind:`cancel`,reason:t},r=!1;try{await resumeHook(e.hookToken,n),r=!0}catch(t){isTaskWorkflowTargetGone(t)||logError(log,`failed to signal a workflow tool run to cancel; cancelling it outright`,t,{runId:e.runId})}try{await settleWorkflowToolRunCancellation(e.runId,t,r)}catch(t){if(isTaskWorkflowTargetGone(t))return;logError(log,`failed to cancel workflow tool run; it may run to completion`,t,{runId:e.runId})}}async function settleWorkflowToolRunCancellation(e,t,n=!0){if(n){let t=Date.now()+WORKFLOW_CANCELLATION_SETTLE_MS;for(;Date.now()<t;){try{let t=await getRun(e).status;if(t!==`pending`&&t!==`running`)return}catch(e){if(isTaskWorkflowTargetGone(e))return;throw e}await new Promise(e=>setTimeout(e,250))}}try{await cancelRun(await getWorld(),e,{cancelReason:t})}catch(e){if(isTaskWorkflowTargetGone(e))return;throw e}}export{cancelWorkflowToolRun,settleWorkflowToolRunCancellation};
|
|
@@ -9,6 +9,7 @@ export declare function startWorkflowToolRun(input: Omit<WorkflowToolRunInput, "
|
|
|
9
9
|
export declare function startWorkflowTask(input: {
|
|
10
10
|
readonly agents: WorkflowToolRunInput["agents"];
|
|
11
11
|
readonly auth: SessionAuth["current"];
|
|
12
|
+
readonly canRequestInput: boolean;
|
|
12
13
|
readonly batchEvent: {
|
|
13
14
|
readonly sequence: number;
|
|
14
15
|
readonly stepIndex: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createLogger,logError}from"#internal/logging.js";import{toError}from"#shared/errors.js";import{startWorkflowOnCurrentDeployment,workflowToolRunWorkflowReference}from"#execution/workflow-runtime.js";import{registerWorkflowToolRun}from"#harness/workflow-tool-runs.js";import{createRuntimeToolResultFromValue}from"#harness/action-result-helpers.js";const log=createLogger(`execution.workflow-tool-run`);async function startWorkflowToolRun(e){let t=crypto.randomUUID();return{hookToken:t,runId:(await startWorkflowOnCurrentDeployment(workflowToolRunWorkflowReference,[{...e,hookToken:t}])).runId}}async function startWorkflowTask(e){let{task:t,batchEvent:n,session:r}=e;try{let i=await startWorkflowToolRun({agents:e.agents,callId:t.callId,executeInput:t.executeInput,input:t.input,owner:e.owner,session:{auth:{current:e.auth,initiator:e.initiatorAuth},id:r.sessionId,parent:e.parentSession,turn:{id:n.turnId,sequence:n.sequence}},stepIndex:n.stepIndex,toolName:t.toolName,workflowId:t.workflowId});return{session:registerWorkflowToolRun(r,{callId:t.callId,lifetime:`turn`,origin:{turnId:n.turnId,stepIndex:n.stepIndex},address:i,toolName:t.toolName})}}catch(e){return logError(log,`workflow tool run failed to start`,e,{callId:t.callId,toolName:t.toolName}),{result:createRuntimeToolResultFromValue({callId:t.callId,isError:!0,output:toError(e),toolName:t.toolName}),session:r}}}export{startWorkflowTask,startWorkflowToolRun};
|
|
1
|
+
import{createLogger,logError}from"#internal/logging.js";import{toError}from"#shared/errors.js";import{startWorkflowOnCurrentDeployment,workflowToolRunWorkflowReference}from"#execution/workflow-runtime.js";import{registerWorkflowToolRun}from"#harness/workflow-tool-runs.js";import{createRuntimeToolResultFromValue}from"#harness/action-result-helpers.js";const log=createLogger(`execution.workflow-tool-run`);async function startWorkflowToolRun(e){let t=crypto.randomUUID();return{hookToken:t,runId:(await startWorkflowOnCurrentDeployment(workflowToolRunWorkflowReference,[{...e,hookToken:t}])).runId}}async function startWorkflowTask(e){let{task:t,batchEvent:n,session:r}=e;try{let i=await startWorkflowToolRun({agents:e.agents,callId:t.callId,canRequestInput:e.canRequestInput,executeInput:t.executeInput,input:t.input,owner:e.owner,session:{auth:{current:e.auth,initiator:e.initiatorAuth},id:r.sessionId,parent:e.parentSession,turn:{id:n.turnId,sequence:n.sequence}},stepIndex:n.stepIndex,toolName:t.toolName,workflowId:t.workflowId});return{session:registerWorkflowToolRun(r,{callId:t.callId,lifetime:`turn`,origin:{turnId:n.turnId,stepIndex:n.stepIndex},address:i,toolName:t.toolName})}}catch(e){return logError(log,`workflow tool run failed to start`,e,{callId:t.callId,toolName:t.toolName}),{result:createRuntimeToolResultFromValue({callId:t.callId,isError:!0,output:toError(e),toolName:t.toolName}),session:r}}}export{startWorkflowTask,startWorkflowToolRun};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{createAgentSourceRegistry,defineProgrammaticAgentSource,loadProgrammaticModuleNamespace,memoizeModuleNamespaceFactories}from"#compiler/source-graph.js";const revision=`eve@${resolveInstalledPackageInfo().version}:compiled-manifest-
|
|
1
|
+
import{resolveInstalledPackageInfo}from"#internal/application/package.js";import{createAgentSourceRegistry,defineProgrammaticAgentSource,loadProgrammaticModuleNamespace,memoizeModuleNamespaceFactories}from"#compiler/source-graph.js";const revision=`eve@${resolveInstalledPackageInfo().version}:compiled-manifest-v50`,localDefaults=defineProgrammaticAgentSource({id:`eve:defaults`,revision,modules:[{logicalPath:`agent.ts`,loadNamespace:()=>import(`#framework/sources/modules/agent.js`)},{logicalPath:`sandbox.ts`,semanticRevision:`eve:default-sandbox:v1`,loadNamespace:()=>import(`#framework/sources/modules/sandbox.js`)},{logicalPath:`tools/bash.ts`,loadNamespace:()=>import(`#tools/provided/bash.js`)},{logicalPath:`tools/read_file.ts`,loadNamespace:()=>import(`#tools/provided/read-file.js`)},{logicalPath:`tools/write_file.ts`,loadNamespace:()=>import(`#tools/provided/write-file.js`)},{logicalPath:`tools/web_fetch.ts`,loadNamespace:()=>import(`#tools/provided/web-fetch.js`)},{logicalPath:`tools/load_skill.ts`,loadNamespace:()=>import(`#tools/provided/load-skill.js`)},{logicalPath:`tools/connection_search.ts`,loadNamespace:()=>import(`#tools/framework/connection-search.js`)},{logicalPath:`tools/task_cancel.ts`,loadNamespace:()=>import(`#tools/framework/task-cancel.js`)},{logicalPath:`tools/web_search.ts`,loadNamespace:()=>import(`#tools/provided/web-search.js`)}]}),rootDefaults=defineProgrammaticAgentSource({id:`eve:root-defaults`,revision,modules:[{logicalPath:`tools/agent.ts`,loadNamespace:()=>import(`#tools/framework/agent.js`)},{logicalPath:`channels/eve.ts`,loadNamespace:()=>import(`#framework/sources/modules/eve-channel.js`)},{logicalPath:`channels/home.ts`,loadNamespace:()=>import(`#framework/sources/modules/home-channel.js`)}]}),memoryWrapperTemplateSource=defineProgrammaticAgentSource({id:`eve:memory-wrapper`,revision,modules:[{logicalPath:`tools/memory-wrapper.ts`,loadNamespace:async e=>{let{loadMemoryWrapperNamespace:t}=await import(`#framework/sources/modules/memory-wrapper.js`);return await t(e)}}]}),frameworkAgentSourceRegistry=createAgentSourceRegistry([{applyTo:`all-local-nodes`,source:localDefaults},{applyTo:`root`,source:rootDefaults}],{templates:[memoryWrapperTemplateSource]}),memoryWrapperTemplate=frameworkAgentSourceRegistry.templates.get(memoryWrapperTemplateSource.id);async function loadFrameworkProgrammaticModule(e,t){return memoizeModuleNamespaceFactories(await loadProgrammaticModuleNamespace({backing:e,dependencyNamespaces:t,registries:[frameworkAgentSourceRegistry]}))}export{frameworkAgentSourceRegistry,loadFrameworkProgrammaticModule,memoryWrapperTemplate};
|
|
@@ -2,12 +2,6 @@ import type { ModelMessage } from "ai";
|
|
|
2
2
|
export declare const COMPACTION_CHECKPOINT_MARKER = "Summary of our conversation so far:";
|
|
3
3
|
/** Synthetic resumption prompt used when no real user message can be replayed. */
|
|
4
4
|
export declare const COMPACTION_RESUMPTION_MESSAGE = "Continue.";
|
|
5
|
-
/**
|
|
6
|
-
* Label line of the framework-injected todo preservation message. Owned here
|
|
7
|
-
* so compaction can recognize the message as synthetic when picking a user
|
|
8
|
-
* message to replay after compaction.
|
|
9
|
-
*/
|
|
10
|
-
export declare const TODO_COMPACTION_PRESERVATION_LABEL = "[Your task list was preserved across context compaction]";
|
|
11
5
|
export interface CompactionPrompt {
|
|
12
6
|
readonly prompt: string;
|
|
13
7
|
readonly system: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{estimateTokens}from"#harness/token-estimate.js";const COMPACTION_CHECKPOINT_MARKER=`Summary of our conversation so far:`,COMPACTION_RESUMPTION_MESSAGE=`Continue.`,
|
|
1
|
+
import{estimateTokens}from"#harness/token-estimate.js";const COMPACTION_CHECKPOINT_MARKER=`Summary of our conversation so far:`,COMPACTION_RESUMPTION_MESSAGE=`Continue.`,COMPACTION_SYSTEM_PROMPT=`You are performing a CONTEXT CHECKPOINT COMPACTION. Create a handoff summary for another LLM that will resume the task.
|
|
2
2
|
|
|
3
3
|
Include:
|
|
4
4
|
|
|
@@ -23,4 +23,4 @@ Make completed work explicit so the next model does not repeat it. Keep complete
|
|
|
23
23
|
Large tool outputs are the main thing to compress: reduce each to the findings the next model needs — what was searched or read, what it established, and the exact identifiers involved — rather than reproducing the output. The next model cannot see the originals, so nothing it would need to act on may be lost.`}function formatCompactionTranscript(e){let t=e.filter(e=>e.content.trim().length>0).map(e=>`### ${e.role}\n${e.content.trim()}`);return t.length===0?`(empty)`:t.join(`
|
|
24
24
|
|
|
25
25
|
`)}function renderCompactionMessageContent(e,t){return typeof e.content==`string`?renderConversationText(e.content,t):e.content.map(e=>renderCompactionContentPart(e,t)).filter(e=>e.length>0).join(`
|
|
26
|
-
`).trim()}function renderCompactionContentPart(e,t){switch(e.type){case`text`:return renderConversationText(e.text,t);case`reasoning`:return``;case`file`:return renderAttachedFileStub(e.filename,e.mediaType);case`tool-call`:return renderTranscriptToolCall(e,t);case`tool-result`:return renderTranscriptToolResult(e,t);default:return``}}const TRANSCRIPT_PAYLOAD_LIMIT=2e3;function renderTranscriptToolCall(e,t){return renderToolCall(e,t===void 0?TRANSCRIPT_PAYLOAD_LIMIT:280)}function renderTranscriptToolResult(e,t){let n=t===void 0?TRANSCRIPT_PAYLOAD_LIMIT:280,r=e.isError?`errored`:`returned`,i=renderToolResultOutput(e.output,n);return i?`Tool ${e.toolName} ${r} ${i}`:`Tool ${e.toolName} ${r}`}function renderToolResultOutput(e,t){let n=contentToolOutputParts(e);return n===void 0?renderPayload(e,t):capText(n.map(e=>renderContentToolOutputPart(e,t)).filter(e=>e.length>0).join(` `),t)}function contentToolOutputParts(e){if(typeof e!=`object`||!e)return;let t=e;return t.type===`content`&&Array.isArray(t.value)?t.value:void 0}function stubContentOutputFileParts(e){let t=contentToolOutputParts(e);if(t===void 0)return e;let n=!1,r=t.map(e=>{if(typeof e!=`object`||!e)return e;let t=e;return t.type!==`file`&&t.type!==`media`?e:(n=!0,{text:renderAttachedFileStub(typeof t.filename==`string`?t.filename:void 0,typeof t.mediaType==`string`?t.mediaType:`unknown`),type:`text`})});return n?{type:`content`,value:r}:e}function renderContentToolOutputPart(e,t){if(typeof e!=`object`||!e)return renderPayload(e,t);let n=e;return n.type===`text`&&typeof n.text==`string`?n.text:n.type===`file`||n.type===`media`?renderAttachedFileStub(typeof n.filename==`string`?n.filename:void 0,typeof n.mediaType==`string`?n.mediaType:`unknown`):renderPayload(e,t)}function renderToolCall(e,t){let n=renderPayload(e.input,t);return n?`Called ${e.toolName} with ${n}`:`Called ${e.toolName}`}function renderPayload(e,t){return e===void 0?``:capText(JSON.stringify(e)??``,t)}function renderAttachedFileStub(e,t){return`Attached file ${e??`attachment`} (${t})`}function renderConversationText(e,t){return t===void 0?e.trim():capText(e,t)}function sliceUtf16Safe(e,t){if(t<=0)return``;if(e.length<=t)return e;let n=t,r=e.charCodeAt(n-1);return r>=55296&&r<=56319&&--n,e.slice(0,n)}function capText(e,t){let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:`${sliceUtf16Safe(n,t).trimEnd()}…`}export{COMPACTION_CHECKPOINT_MARKER,COMPACTION_PROMPT_ENVELOPE,COMPACTION_RESUMPTION_MESSAGE,
|
|
26
|
+
`).trim()}function renderCompactionContentPart(e,t){switch(e.type){case`text`:return renderConversationText(e.text,t);case`reasoning`:return``;case`file`:return renderAttachedFileStub(e.filename,e.mediaType);case`tool-call`:return renderTranscriptToolCall(e,t);case`tool-result`:return renderTranscriptToolResult(e,t);default:return``}}const TRANSCRIPT_PAYLOAD_LIMIT=2e3;function renderTranscriptToolCall(e,t){return renderToolCall(e,t===void 0?TRANSCRIPT_PAYLOAD_LIMIT:280)}function renderTranscriptToolResult(e,t){let n=t===void 0?TRANSCRIPT_PAYLOAD_LIMIT:280,r=e.isError?`errored`:`returned`,i=renderToolResultOutput(e.output,n);return i?`Tool ${e.toolName} ${r} ${i}`:`Tool ${e.toolName} ${r}`}function renderToolResultOutput(e,t){let n=contentToolOutputParts(e);return n===void 0?renderPayload(e,t):capText(n.map(e=>renderContentToolOutputPart(e,t)).filter(e=>e.length>0).join(` `),t)}function contentToolOutputParts(e){if(typeof e!=`object`||!e)return;let t=e;return t.type===`content`&&Array.isArray(t.value)?t.value:void 0}function stubContentOutputFileParts(e){let t=contentToolOutputParts(e);if(t===void 0)return e;let n=!1,r=t.map(e=>{if(typeof e!=`object`||!e)return e;let t=e;return t.type!==`file`&&t.type!==`media`?e:(n=!0,{text:renderAttachedFileStub(typeof t.filename==`string`?t.filename:void 0,typeof t.mediaType==`string`?t.mediaType:`unknown`),type:`text`})});return n?{type:`content`,value:r}:e}function renderContentToolOutputPart(e,t){if(typeof e!=`object`||!e)return renderPayload(e,t);let n=e;return n.type===`text`&&typeof n.text==`string`?n.text:n.type===`file`||n.type===`media`?renderAttachedFileStub(typeof n.filename==`string`?n.filename:void 0,typeof n.mediaType==`string`?n.mediaType:`unknown`):renderPayload(e,t)}function renderToolCall(e,t){let n=renderPayload(e.input,t);return n?`Called ${e.toolName} with ${n}`:`Called ${e.toolName}`}function renderPayload(e,t){return e===void 0?``:capText(JSON.stringify(e)??``,t)}function renderAttachedFileStub(e,t){return`Attached file ${e??`attachment`} (${t})`}function renderConversationText(e,t){return t===void 0?e.trim():capText(e,t)}function sliceUtf16Safe(e,t){if(t<=0)return``;if(e.length<=t)return e;let n=t,r=e.charCodeAt(n-1);return r>=55296&&r<=56319&&--n,e.slice(0,n)}function capText(e,t){let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:`${sliceUtf16Safe(n,t).trimEnd()}…`}export{COMPACTION_CHECKPOINT_MARKER,COMPACTION_PROMPT_ENVELOPE,COMPACTION_RESUMPTION_MESSAGE,TRANSCRIPT_PAYLOAD_LIMIT,createCompactionPrompt,sliceUtf16Safe,stubContentOutputFileParts};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{generateText}from"ai";import{createFrameworkUserMessage,isFrameworkUserMessage}from"#harness/messages.js";import{COMPACTION_CHECKPOINT_MARKER,COMPACTION_PROMPT_ENVELOPE,COMPACTION_RESUMPTION_MESSAGE,TRANSCRIPT_PAYLOAD_LIMIT,createCompactionPrompt,sliceUtf16Safe,stubContentOutputFileParts}from"#harness/compaction-prompt.js";
|
|
1
|
+
import{generateText}from"ai";import{createFrameworkUserMessage,isFrameworkUserMessage}from"#harness/messages.js";import{estimateTokens}from"#harness/token-estimate.js";import{COMPACTION_CHECKPOINT_MARKER,COMPACTION_PROMPT_ENVELOPE,COMPACTION_RESUMPTION_MESSAGE,TRANSCRIPT_PAYLOAD_LIMIT,createCompactionPrompt,sliceUtf16Safe,stubContentOutputFileParts}from"#harness/compaction-prompt.js";const COMPACTION_PROMPT_OVERHEAD_TOKENS=estimateTokens([{content:COMPACTION_PROMPT_ENVELOPE.system,role:`system`},createFrameworkUserMessage(`context.compaction`,COMPACTION_PROMPT_ENVELOPE.prompt)]);function getInputTokenCount(e,t,n=0,r=0){let i=t.lastKnownInputTokens,a=t.lastKnownPromptMessageCount;return i===void 0||a===void 0||!Number.isInteger(a)||a<0||a>e.length?estimateTokens(e)+n:i+estimateTokens(e.slice(a))+Math.max(0,n-r)}function shouldCompact(e,t,n=0,r=0){return e.length>0&&getInputTokenCount(e,t,n,r)+COMPACTION_PROMPT_OVERHEAD_TOKENS>t.threshold}async function resolveCompactionModel(e){let t=e.compactionModelReference??e.modelReference;return{model:t===e.modelReference?e.model:await e.resolveModel(t),providerOptions:t.providerOptions}}const COMPACTION_HEURISTICS=[toolResultCapHeuristic];function toolResultCapHeuristic(e){let t=withResumptionGuard([...e.previousCheckpoint===void 0?[]:[createFrameworkUserMessage(`context.compaction`,COMPACTION_CHECKPOINT_MARKER),{content:e.previousCheckpoint,role:`assistant`}],...capToolResults(e.older),...e.recent],e.conversation,e.config.threshold);return evaluateThreshold(t,e.config,`should-compact`,e.tokenEstimateAdjustment).type===`within-limit`?{messages:t,type:`within-limit`}:{type:`insufficient`}}function evaluateThreshold(e,t,n,r=0){let i=n===`should-compact`?COMPACTION_PROMPT_OVERHEAD_TOKENS:0,a=estimateTokens(e)+i+r;return{estimatedTokens:a,type:a<=t.threshold?`within-limit`:`over-limit`}}async function compactMessages(e,t,n,r,i,a,o,s=!1,c){let{conversation:l,previousCheckpoint:u}=extractPreviousCheckpoint(e),d=selectRecentWindowSize(l,s?{...n,recentWindowSize:1}:n);if(!s){let{older:t,recent:r}=splitMessagesForCompaction(l,d);if(t.length===0&&u===void 0)return keepNonToolResultMessages(r);let i=Math.max(0,(c??getInputTokenCount(e,n))-estimateTokens(e));for(let e of COMPACTION_HEURISTICS){let a=e({config:n,conversation:l,older:t,previousCheckpoint:u,recent:r,tokenEstimateAdjustment:i});if(a.type===`within-limit`)return a.messages}}for(;;){let{older:e,recent:s}=splitMessagesForCompaction(l,d),c=createCompactionPrompt({messages:e,previousCheckpoint:u,transcriptBudgetTokens:n.threshold}),f=await generateText({abortSignal:o,headers:a,messages:[createFrameworkUserMessage(`context.compaction`,c.prompt)],model:t,providerOptions:r,system:c.system,telemetry:i?{...i,functionId:`eve.compaction`}:void 0,temperature:0});if(f.text.trim().length===0)throw Error(`The compaction model returned an empty summary. Finish reason: ${f.finishReason}.`);let p=[createFrameworkUserMessage(`context.compaction`,COMPACTION_CHECKPOINT_MARKER),{content:f.text,role:`assistant`}],m=withResumptionGuard([...p,...s],l,n.threshold);if(evaluateThreshold(m,n,`estimate`).type===`within-limit`)return m;let h=withResumptionGuard([...p,...keepNonToolResultMessages(s)],l,n.threshold);if(evaluateThreshold(h,n,`estimate`).type===`within-limit`||d===0)return h;--d}}function capToolResults(e){return e.map(e=>{if(e.role!==`tool`||typeof e.content==`string`)return e;let t=!1,n=e.content.map(e=>{if(e.type!==`tool-result`)return e;let n=stubContentOutputFileParts(e.output),r=JSON.stringify(n)??``;return r.length<=TRANSCRIPT_PAYLOAD_LIMIT?n===e.output?e:(t=!0,{...e,output:n}):(t=!0,{...e,output:{type:`text`,value:`[Truncated by eve: tool result reduced during context compaction. Re-run the tool if you need the full output.]\n\n${sliceUtf16Safe(r,TRANSCRIPT_PAYLOAD_LIMIT)}`}})});return t?{...e,content:n}:e})}function withResumptionGuard(e,t,n){let r=e.at(-1)?.role,i=findLastRealUserMessage(t),a=i!==void 0&&e.some(e=>e.role===`user`&&e.content===i.content);return r!==void 0&&r!==`assistant`?r===`tool`&&i!==void 0&&!a&&estimateTokens([i])<=n?[...e,i]:e:[...e,i!==void 0&&!a?i:createFrameworkUserMessage(`execution.continuation`,COMPACTION_RESUMPTION_MESSAGE)]}function findLastRealUserMessage(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n?.role===`user`&&typeof n.content==`string`&&!isFrameworkUserMessage(n))return n}}function extractPreviousCheckpoint(e){let t=e[0],n=e[1];return t?.role!==`user`||t.content!==COMPACTION_CHECKPOINT_MARKER||n?.role!==`assistant`?{conversation:[...e],previousCheckpoint:void 0}:{conversation:e.slice(2),previousCheckpoint:assistantMessageText(n)}}function keepNonToolResultMessages(e){let t=[];for(let n of e)if(n.role!==`tool`){if(n.role===`assistant`){let e=assistantMessageText(n);e.length>0&&t.push({content:e,role:`assistant`});continue}t.push(n)}return t}function assistantMessageText(e){return typeof e.content==`string`?e.content.trim():e.content.filter(e=>e.type===`text`).map(e=>e.text).join(``).trim()}function selectRecentWindowSize(e,t){let n=Math.min(t.recentWindowSize,Math.max(e.length-1,0)),r=resolveCompactionSummaryReserve(t),i=0,a=0;for(let o=e.length-1;o>=0&&i<n;--o){let n=e[o];if(n===void 0)continue;let s=estimateTokens([n]);if(a+s+r>t.threshold)break;a+=s,i+=1}return i}function resolveCompactionSummaryReserve(e){return Math.min(2048,Math.max(64,Math.floor(e.threshold/4)))}function splitMessagesForCompaction(e,t){if(t<=0)return{older:[...e],recent:[]};let n=e.length-t;for(;n<e.length&&e[n]?.role===`tool`;)n+=1;return{older:e.slice(0,n),recent:e.slice(n)}}export{compactMessages,getInputTokenCount,resolveCompactionModel,shouldCompact};
|
|
@@ -5,8 +5,6 @@ import type { HarnessSession } from "#harness/types.js";
|
|
|
5
5
|
export type RejectedActionBatch = ResolvedInputActionBatch;
|
|
6
6
|
export declare function findAnsweredApprovalBatches(batches: readonly PendingInputBatch[], responses: readonly InputResponse[]): PendingInputBatch[];
|
|
7
7
|
export declare function resolveApprovalInputBatches(input: InputDomainResolverInput & {
|
|
8
|
-
readonly approvalBatches: readonly PendingInputBatch[];
|
|
9
|
-
readonly questionBatches: readonly PendingInputBatch[];
|
|
10
8
|
readonly resolveApprovalKey?: (request: InputRequest) => string | undefined;
|
|
11
9
|
}): ResolvePendingInputResult;
|
|
12
10
|
/** Returns recorded approval keys that have no matching request still pending. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getPendingInputBatches,queueDeferredStepInput,removePendingInputBatches}from"#harness/pending-input-batches.js";import{isApprovalRequest}from"#harness/input-request-class.js";import{TOOL_EXECUTION_DENIED_MESSAGE,buildResolvedInputBatch,resolveApprovalOutcome}from"#harness/input-request-resolution.js";import{appendResolvedBatchTranscript,compactStepInput,finishResolvedInput,responsesForBatches}from"#harness/hitl/pending-input-resolution.js";
|
|
1
|
+
import{getPendingInputBatches,queueDeferredStepInput,removePendingInputBatches}from"#harness/pending-input-batches.js";import{isApprovalRequest}from"#harness/input-request-class.js";import{TOOL_EXECUTION_DENIED_MESSAGE,buildResolvedInputBatch,resolveApprovalOutcome}from"#harness/input-request-resolution.js";import{appendResolvedBatchTranscript,compactStepInput,finishResolvedInput,responsesForBatches}from"#harness/hitl/pending-input-resolution.js";const APPROVED_TOOLS_KEY=`eve.runtime.hitl.approvedTools`;function findAnsweredApprovalBatches(e,t){let n=new Set(t.map(e=>e.requestId));return e.filter(e=>e.requests.every(e=>!isApprovalRequest(e)||n.has(e.requestId)))}function resolveApprovalInputBatches(e){let t=new Set(findAnsweredApprovalBatches(e.batches,e.responses)),n=e.batches.find(e=>t.has(e)),r=e.batches.filter(e=>e!==n),i=responsesForBatches(e.responses,r);if(n===void 0){if(e.resolvedStepInput?.message===void 0)return{outcome:`unresolved`,messages:[...e.baseHistory],session:queueDeferredStepInput(e.session,compactStepInput(e.resolvedStepInput))};let t=i.length===0?e.session:queueDeferredStepInput(e.session,{inputResponses:i});return{consumedMessage:e.resolvedStepInput.messageConsumed,outcome:`continue`,messages:[...e.baseHistory],session:t}}let a=resolveApprovalBatch({batch:n,messages:[...e.baseHistory],resolveApprovalKey:e.resolveApprovalKey,responses:e.responses,session:e.session}),o=buildResolvedInputBatch(n,e.responses);return finishResolvedInput({deferTurnInput:!0,leftoverResponses:i,messages:a.messages,rejectedActions:a.rejectedActions,resolvedInputs:o===void 0?[]:[o],resolvedStepInput:e.resolvedStepInput,session:removePendingInputBatches(a.session,[n])})}function getApprovedTools(e,t){let n=readRecordedApprovedTools(e);for(let r of getPendingInputBatches(e.state))for(let e of r.requests)isApprovalRequest(e)&&n.delete(t?.(e)??e.action.toolName);return n}function readRecordedApprovedTools(e){let t=e.state?.[APPROVED_TOOLS_KEY];return Array.isArray(t)?new Set(t):new Set}function resolveApprovalBatch(e){let t=recordApprovedTools({pendingBatch:e.batch,resolveApprovalKey:e.resolveApprovalKey,responses:e.responses,session:e.session}),n=buildApprovalBatchToolResponseParts(e.batch,e.responses);appendResolvedBatchTranscript(e.messages,e.batch,n);let r=buildRejectedActionBatch(e.batch,e.responses);return{messages:e.messages,rejectedActions:r===void 0?void 0:[r],session:t}}function recordApprovedTools(e){let t=new Set(e.responses.filter(e=>e.optionId===`approve`).map(e=>e.requestId)),n=e.pendingBatch.requests.filter(e=>isApprovalRequest(e)&&t.has(e.requestId)).map(t=>e.resolveApprovalKey?.(t)??t.action.toolName);if(n.length===0)return e.session;let r={...e.session.state};return r[APPROVED_TOOLS_KEY]=[...new Set([...readRecordedApprovedTools(e.session),...n])],{...e.session,state:r}}function buildRejectedActionBatch(e,t){if(e.event===void 0)return;let n=new Map(t.map(e=>[e.requestId,e])),r=[];for(let t of e.requests){if(!isApprovalRequest(t))continue;let{approved:e,reason:i,status:a}=resolveApprovalOutcome(n.get(t.requestId));e||r.push({callId:t.action.callId,isError:!0,kind:`tool-result`,output:{approval:{requestId:t.requestId,status:a},code:`TOOL_EXECUTION_DENIED`,message:i??TOOL_EXECUTION_DENIED_MESSAGE,tool:{result:`not_run`}},toolName:t.action.toolName})}return r.length>0?{event:e.event,results:r}:void 0}function buildApprovalBatchToolResponseParts(e,t){let n=new Map(t.map(e=>[e.requestId,e])),r=[];for(let t of e.requests){let e=n.get(t.requestId);switch(t.kind){case`tool-approval`:r.push(...buildApprovalToolResponseParts(t,e));break;case`question`:case`session-limit`:throw TypeError(`Approval pending input batches cannot contain a "${t.kind}" request.`);default:{let e=t.kind;throw TypeError(`Unhandled pending input request kind: ${String(e)}`)}}}return r}function buildApprovalToolResponseParts(e,t){let{approved:n,reason:r}=resolveApprovalOutcome(t),i=[{approvalId:e.requestId,approved:n,reason:r,type:`tool-approval-response`}];return n||i.push({output:{type:`execution-denied`,reason:r},toolCallId:e.action.callId,toolName:e.action.toolName,type:`tool-result`}),i}export{findAnsweredApprovalBatches,getApprovedTools,resolveApprovalInputBatches};
|
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
import type { ContentPart, ModelMessage, ToolSet
|
|
2
|
-
import type { HarnessToolMap } from "#harness/types.js";
|
|
1
|
+
import type { ContentPart, ModelMessage, ToolSet } from "ai";
|
|
3
2
|
import type { InputRequest } from "#shared/input.js";
|
|
4
|
-
/**
|
|
5
|
-
* Extracts question input requests from tool calls that target the
|
|
6
|
-
* `ask_question` framework tool.
|
|
7
|
-
*/
|
|
8
|
-
export declare function extractQuestionInputRequests(input: {
|
|
9
|
-
readonly excludedCallIds: ReadonlySet<string>;
|
|
10
|
-
readonly toolCalls: readonly TypedToolCall<ToolSet>[];
|
|
11
|
-
readonly tools: HarnessToolMap;
|
|
12
|
-
}): InputRequest[];
|
|
13
3
|
/**
|
|
14
4
|
* Extracts tool approval input requests from AI SDK content parts that
|
|
15
5
|
* contain `tool-approval-request` entries.
|
|
@@ -19,12 +9,11 @@ export declare function extractToolApprovalInputRequests(input: {
|
|
|
19
9
|
readonly excludedCallIds?: ReadonlySet<string>;
|
|
20
10
|
}): InputRequest[];
|
|
21
11
|
/**
|
|
22
|
-
* Recovers request metadata for submitted input response IDs from
|
|
23
|
-
* history. The newest occurrence wins so compacted or repeated history
|
|
24
|
-
* not replace the request that is closest to the current turn.
|
|
12
|
+
* Recovers approval request metadata for submitted input response IDs from
|
|
13
|
+
* model history. The newest occurrence wins so compacted or repeated history
|
|
14
|
+
* does not replace the request that is closest to the current turn.
|
|
25
15
|
*/
|
|
26
16
|
export declare function extractHistoricalInputRequests(input: {
|
|
27
17
|
readonly history: readonly ModelMessage[];
|
|
28
18
|
readonly requestIds: ReadonlySet<string>;
|
|
29
|
-
readonly tools: HarnessToolMap;
|
|
30
19
|
}): ReadonlyMap<string, InputRequest>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{boolean,literal,object,string,unknown}from"../node_modules/.pnpm/zod@4.5.4/node_modules/zod/v4/classic/schemas.js";import"../node_modules/.pnpm/zod@4.5.4/node_modules/zod/index.js";import{createRuntimeToolCallActionFromToolCall}from"#harness/tool-call-action.js";const ToolCallDescriptorSchema=object({input:unknown(),toolCallId:string(),toolName:string()}),PersistedToolCallSchema=ToolCallDescriptorSchema.extend({type:literal(`tool-call`)}),ToolApprovalRequestSchema=object({approvalId:string(),isAutomatic:boolean().optional().catch(void 0),toolCall:ToolCallDescriptorSchema.optional().catch(void 0),toolCallId:string().optional().catch(void 0),type:literal(`tool-approval-request`)});function
|
|
1
|
+
import{boolean,literal,object,string,unknown}from"../node_modules/.pnpm/zod@4.5.4/node_modules/zod/v4/classic/schemas.js";import"../node_modules/.pnpm/zod@4.5.4/node_modules/zod/index.js";import{createRuntimeToolCallActionFromToolCall}from"#harness/tool-call-action.js";const ToolCallDescriptorSchema=object({input:unknown(),toolCallId:string(),toolName:string()}),PersistedToolCallSchema=ToolCallDescriptorSchema.extend({type:literal(`tool-call`)}),ToolApprovalRequestSchema=object({approvalId:string(),isAutomatic:boolean().optional().catch(void 0),toolCall:ToolCallDescriptorSchema.optional().catch(void 0),toolCallId:string().optional().catch(void 0),type:literal(`tool-approval-request`)});function extractToolApprovalInputRequests(e){return extractApprovalRequests(e)}function extractApprovalRequests(e){let t=[],n=new Map;for(let t of e.content){let e=PersistedToolCallSchema.safeParse(t);e.success&&n.set(e.data.toolCallId,e.data)}for(let r of e.content){let i=ToolApprovalRequestSchema.safeParse(r);if(!i.success)continue;let a=i.data;if(e.includedRequestIds!==void 0&&!e.includedRequestIds.has(a.approvalId)||a.isAutomatic===!0)continue;let o=a.toolCall??(a.toolCallId===void 0?void 0:n.get(a.toolCallId));o!==void 0&&(e.excludedCallIds?.has(o.toolCallId)||t.push({action:createRuntimeToolCallActionFromToolCall({toolCall:o}),allowFreeform:!1,display:`confirmation`,kind:`tool-approval`,options:[{id:`approve`,label:`Approve`},{id:`cancel`,label:`Cancel`}],prompt:`Approve tool call: ${o.toolName}`,requestId:a.approvalId}))}return t}function extractHistoricalInputRequests(e){let t=new Map;for(let n=e.history.length-1;n>=0;--n){let r=e.history[n];if(r?.role!==`assistant`||!Array.isArray(r.content))continue;let i=extractApprovalRequests({content:r.content,includedRequestIds:e.requestIds});for(let n of i)e.requestIds.has(n.requestId)&&!t.has(n.requestId)&&t.set(n.requestId,n);if(t.size===e.requestIds.size)break}return t}export{extractHistoricalInputRequests,extractToolApprovalInputRequests};
|
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shape and behavior classification for pending input requests, shared by
|
|
3
|
-
* the harness resolution path and protocol clients (e.g. the dev TUI's
|
|
4
|
-
* rendering decisions).
|
|
5
|
-
*/
|
|
6
1
|
import type { InputRequest } from "#shared/input.js";
|
|
7
2
|
/** Returns true when the request gates an AI SDK tool call. */
|
|
8
3
|
export declare function isApprovalRequest(request: InputRequest): boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Behavioral class of a pending input request.
|
|
11
|
-
*
|
|
12
|
-
* `"required"` — the request must be explicitly answered before the turn can
|
|
13
|
-
* move on. While one is unanswered, any other arriving input is queued and
|
|
14
|
-
* replayed on the step after the answer. The pending batch never churns, so
|
|
15
|
-
* the request ids the user is answering stay valid.
|
|
16
|
-
*
|
|
17
|
-
* `"dismissable"` — a plain follow-up message counts as the user moving on.
|
|
18
|
-
* The request resolves as a real `tool-result` with `status: "ignored"` and
|
|
19
|
-
* the model continues with the message in the same step.
|
|
20
|
-
*/
|
|
21
|
-
export type InputRequestClass = "dismissable" | "required";
|
|
22
|
-
/** Classifies one pending request; see {@link InputRequestClass}. */
|
|
23
|
-
export declare function classifyInputRequest(request: InputRequest): InputRequestClass;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function isApprovalRequest(e){return e.kind===`tool-approval`}
|
|
1
|
+
function isApprovalRequest(e){return e.kind===`tool-approval`}export{isApprovalRequest};
|
|
@@ -21,7 +21,7 @@ export declare function hasPendingApprovalBatch(session: HarnessSession): boolea
|
|
|
21
21
|
*
|
|
22
22
|
* Ordered batches remain independently answerable. Session-limit prompts own
|
|
23
23
|
* resolution while open; approval batches preserve AI SDK's tail-message
|
|
24
|
-
* requirement
|
|
24
|
+
* requirement.
|
|
25
25
|
*/
|
|
26
26
|
export declare function resolvePendingInput(input: {
|
|
27
27
|
/** The turn currently advancing through the harness tool loop. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readClientContext}from"#internal/client-context.js";import{resolveTextToResponses}from"#channel/resolve-text.js";import{appendPendingInputBatch,consumeDeferredStepInput,getDeferredStepInput,getPendingInputBatches,getPendingInputRequestIds,hasDeferredStepInput,hasPendingInputBatch,queueDeferredStepInput}from"#harness/pending-input-batches.js";import{resolveToolCallInputObject}from"#harness/coordination.js";import{isApprovalRequest}from"#harness/input-request-class.js";import{compactStepInput}from"#harness/hitl/pending-input-resolution.js";import{
|
|
1
|
+
import{readClientContext}from"#internal/client-context.js";import{resolveTextToResponses}from"#channel/resolve-text.js";import{appendPendingInputBatch,consumeDeferredStepInput,getDeferredStepInput,getPendingInputBatches,getPendingInputRequestIds,hasDeferredStepInput,hasPendingInputBatch,queueDeferredStepInput}from"#harness/pending-input-batches.js";import{resolveToolCallInputObject}from"#harness/coordination.js";import{isApprovalRequest}from"#harness/input-request-class.js";import{compactStepInput}from"#harness/hitl/pending-input-resolution.js";import{hasTailApprovalResponse}from"#harness/current-messages.js";import{findAnsweredApprovalBatches,getApprovedTools,resolveApprovalInputBatches}from"#harness/hitl/approval-input-requests.js";import{clearPendingSessionLimitPrompt,isSessionLimitInputBatch,resolveSessionLimitInput}from"#harness/hitl/session-limit-input-requests.js";function hasStepInput(e){return e===void 0?!1:e.message!==void 0||(e.inputResponses?.length??0)>0}function hasRunnableDeferredStepInput(e){let t=getDeferredStepInput(e);if(t===void 0)return!1;if(t.message!==void 0||(t.context?.length??0)>0||readClientContext(t)!==void 0||t.outputSchema!==void 0||(t.runtimeActionResults?.length??0)>0)return!0;let n=[...t.inputResponses??[],...(t.attributedInputResponses??[]).map(({response:e})=>e)];if(n.length===0)return!1;let r=getPendingInputBatches(e.state),i=routePendingInput(r);switch(i.kind){case`session-limit`:return i.batch.requests.every(e=>n.some(t=>t.requestId===e.requestId));case`approvals`:return findAnsweredApprovalBatches(r,n).length>0}}function hasPendingApprovalBatch(e){return getPendingInputBatches(e.state).some(e=>e.requests.some(e=>isApprovalRequest(e)))}function resolvePendingInput(e){let t=[...e.history??e.session.history],n=getPendingInputBatches(e.session.state);if(n.length===0)return{outcome:`continue`,messages:t,session:e.session};let r=routePendingInput(n),i=hasTailApprovalResponse(t),a=r.kind===`session-limit`?r.batch:n.length===1?n[0]:void 0,o=a===void 0?e.stepInput:resolveTextMessageInput(a,e.stepInput),s=canonicalizeInputResponses(o?.inputResponses??[]);if(e.internalStep===!0&&canContinuePastHistoricalInput({activeTurnId:e.activeTurnId,batches:n,responses:s,route:r})&&o?.message===void 0)return{outcome:`continue`,messages:t,session:o===void 0?e.session:queueDeferredStepInput(e.session,compactStepInput(o))};if(r.kind===`approvals`&&e.deferMessagesWhileApprovalsPending===!0&&o?.message!==void 0&&findAnsweredApprovalBatches(n,s).length===0)return{deferredMessage:!0,outcome:`unresolved`,messages:t,session:queueDeferredStepInput(e.session,compactStepInput(o))};if(s.length===0&&o?.message===void 0){let n=compactStepInput(o);return{outcome:`unresolved`,messages:t,session:n.context!==void 0||readClientContext(n)!==void 0||n.outputSchema!==void 0?queueDeferredStepInput(e.session,n):e.session}}let c={baseHistory:t,batches:n,deferTurnInput:i,resolvedStepInput:o,responses:s,session:e.session};switch(r.kind){case`session-limit`:return resolveSessionLimitInput({...c,pendingBatch:r.batch});case`approvals`:return resolveApprovalInputBatches({...c,resolveApprovalKey:e.resolveApprovalKey})}}function canContinuePastHistoricalInput(e){return e.activeTurnId===void 0||e.route.kind===`session-limit`||e.responses.length>0&&findAnsweredApprovalBatches(e.batches,e.responses).length>0?!1:e.batches.every(t=>t.event!==void 0&&t.event.turnId!==e.activeTurnId)}function routePendingInput(e){let t=e.find(e=>isSessionLimitInputBatch(e));if(t!==void 0)return{batch:t,kind:`session-limit`};for(let t of e)for(let e of t.requests)if(!isApprovalRequest(e))throw TypeError(`Unhandled pending input request kind: ${e.kind}`);return{kind:`approvals`}}function canonicalizeInputResponses(e){let t=new Map;for(let n of e)t.set(n.requestId,n);return[...t.values()]}function resolveTextMessageInput(e,t){if(typeof t?.message!=`string`)return t;let n=new Set(e.requests.map(e=>e.requestId));if(t.inputResponses?.some(e=>n.has(e.requestId)))return t;let r=new Set(e.responseAuthRequiredRequestIds??[]),i=e.requests.filter(e=>!r.has(e.requestId)),a=resolveTextToResponses(t.message,i);return a.length===0?t:compactStepInput({...t,inputResponses:[...t.inputResponses??[],...a],messageConsumed:!0,message:void 0})}function createRuntimeToolCallActionFromToolCall(e){return{callId:e.toolCall.toolCallId,input:resolveToolCallInputObject(e.toolCall.input,{callId:e.toolCall.toolCallId,toolName:e.toolCall.toolName}),kind:`tool-call`,toolName:e.toolCall.toolName}}export{appendPendingInputBatch,clearPendingSessionLimitPrompt,consumeDeferredStepInput,createRuntimeToolCallActionFromToolCall,getApprovedTools,getPendingInputRequestIds,hasDeferredStepInput,hasPendingApprovalBatch,hasPendingInputBatch,hasRunnableDeferredStepInput,hasStepInput,resolvePendingInput};
|
|
@@ -23,7 +23,7 @@ export interface PendingInputBatch {
|
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* Returns true when the session holds at least one pending HITL batch
|
|
26
|
-
* (tool approvals or
|
|
26
|
+
* (tool approvals or a session-limit continuation prompt).
|
|
27
27
|
*/
|
|
28
28
|
export declare function hasPendingInputBatch(state: SessionStateMap | undefined): boolean;
|
|
29
29
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SubagentInputRequestHookPayload } from "#channel/types.js";
|
|
2
2
|
import type { HarnessSession, SessionStateMap } from "#harness/types.js";
|
|
3
|
-
import type
|
|
3
|
+
import { type InputOption, type InputRequestKind } from "#shared/input.js";
|
|
4
4
|
import { type SessionInboxAddress } from "#execution/session-inbox/address.js";
|
|
5
5
|
/**
|
|
6
6
|
* Marks a continuation token as a bare hook a workflow tool run created for one
|
|
@@ -8,6 +8,14 @@ import { type SessionInboxAddress } from "#execution/session-inbox/address.js";
|
|
|
8
8
|
*/
|
|
9
9
|
export interface AnswerHookRoute {
|
|
10
10
|
readonly runId: string;
|
|
11
|
+
/** Present for a `ctx.ask()` question: what a plain-text message may answer or dismiss. */
|
|
12
|
+
readonly question?: AnswerHookQuestion;
|
|
13
|
+
}
|
|
14
|
+
/** The parts of a `ctx.ask()` request a plain-text message is resolved against. */
|
|
15
|
+
export interface AnswerHookQuestion {
|
|
16
|
+
readonly allowFreeform?: boolean;
|
|
17
|
+
readonly dismissible?: boolean;
|
|
18
|
+
readonly options?: readonly InputOption[];
|
|
11
19
|
}
|
|
12
20
|
/** Routing and control metadata for one descendant-owned input request. */
|
|
13
21
|
export interface ProxyInputRequest {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isLoopbackHostname}from"#shared/network-address.js";import{isSessionInboxAddress}from"#execution/session-inbox/address.js";const PROXY_INPUT_REQUESTS_KEY=`eve.runtime.proxyInputRequests`,PROXY_INPUT_REQUEST_KINDS={question:!0,"session-limit":!0,"tool-approval":!0};function createTaskInputRequestId(e,t){return`${e}:${t}`}function getProxyInputRequests(e){return new Map(Object.entries(readMap(e)))}function hasProxyInputRequests(e){for(let t of Object.keys(readMap(e)))return!0;return!1}function upsertProxyInputRequests(e){return{...e.session,state:upsertProxyInputRequestState({entries:e.entries,forChildContinuationToken:e.forChildContinuationToken,state:e.session.state})}}function upsertProxyInputRequestState(e){let t={};for(let[n,r]of Object.entries(readMap(e.state)))r.childContinuationToken!==e.forChildContinuationToken&&(t[n]=r);for(let[n,r]of e.entries)t[n]=r;let n={...e.state};return Object.keys(t).length===0?delete n[PROXY_INPUT_REQUESTS_KEY]:n[PROXY_INPUT_REQUESTS_KEY]=t,Object.keys(n).length>0?n:void 0}function clearProxyInputRequestsForChild(e,t){return clearProxyInputRequestsWhere(e,e=>e.childContinuationToken===t)}function clearProxyInputRequestsWhere(e,t){let n=readMap(e.state),r={},i=!1;for(let[e,a]of Object.entries(n)){if(t(a)){i=!0;continue}r[e]=a}return i?writeMap(e,r):e}function retireProxyInputRequests(e,t){let n={...readMap(e.state)},r=!1;for(let e of t)Object.hasOwn(n,e)&&(delete n[e],r=!0);return r?writeMap(e,n):e}function clearProxyInputRequestsForTask(e,t){return clearProxyInputRequestsWhere(e,e=>e.taskId===t)}function clearAllProxyInputRequests(e){return hasProxyInputRequests(e.state)?writeMap(e,{}):e}function toProxyInputRequestEntries(e,t){let n={approvalRequestIds:e.event.requests.flatMap(e=>e.kind===`tool-approval`?[e.requestId]:[]),requestIds:e.event.requests.map(e=>e.requestId)};return e.event.requests.map(r=>{let i={batch:n,childContinuationToken:e.childContinuationToken,kind:r.kind};return t!==void 0&&(i.taskId=t),e.childSessionInbox?.sessionId===e.childSessionId&&(i.childSessionInbox=e.childSessionInbox),[r.requestId,i]})}function readMap(e){let t=e?.[PROXY_INPUT_REQUESTS_KEY];if(typeof t!=`object`||!t||Array.isArray(t))return{};let n={};for(let[e,r]of Object.entries(t)){let t=parseProxyInputRequest(r,e);t!==void 0&&(n[e]=t)}return n}function writeMap(e,t){let n={...e.state};return Object.keys(t).length===0?(delete n[PROXY_INPUT_REQUESTS_KEY],{...e,state:Object.keys(n).length>0?n:void 0}):(n[PROXY_INPUT_REQUESTS_KEY]=t,{...e,state:n})}function parseProxyInputRequest(e,t){if(typeof e!=`object`||!e||Array.isArray(e)||!(`childContinuationToken`in e)||!(`kind`in e)||typeof e.childContinuationToken!=`string`||!isInputRequestKind(e.kind))return;let n=`taskId`in e?e.taskId:void 0,r=`childRequestId`in e?e.childRequestId:void 0,i=`childResponseUrl`in e?e.childResponseUrl:void 0;if(n!==void 0&&(typeof n!=`string`||n.length===0)||r!==void 0&&(typeof r!=`string`||r.length===0)||n===void 0!=(r===void 0)||i!==void 0&&(typeof i!=`string`||!isAllowedChildResponseUrl(i)))return;let a=`batch`in e?parseProxyInputRequestBatch(e.batch):void 0,o=`answerHook`in e?parseAnswerHookRoute(e.answerHook):void 0;if(`answerHook`in e&&o===void 0)return;let s=`childSessionInbox`in e?e.childSessionInbox:void 0;if(s!==void 0&&!isSessionInboxAddress(s))return;let c={childContinuationToken:e.childContinuationToken,kind:e.kind};return o!==void 0&&(c.answerHook=o),s!==void 0&&(c.childSessionInbox=s),a!==void 0&&a.requestIds.includes(t)&&(c.batch=a),typeof r==`string`&&(c.childRequestId=r),typeof i==`string`&&(c.childResponseUrl=i),typeof n==`string`&&(c.taskId=n),c}function parseAnswerHookRoute(e){if(typeof e
|
|
1
|
+
import{isLoopbackHostname}from"#shared/network-address.js";import{isSessionInboxAddress}from"#execution/session-inbox/address.js";import{inputOptionSchema}from"#shared/input.js";const PROXY_INPUT_REQUESTS_KEY=`eve.runtime.proxyInputRequests`,PROXY_INPUT_REQUEST_KINDS={question:!0,"session-limit":!0,"tool-approval":!0};function createTaskInputRequestId(e,t){return`${e}:${t}`}function getProxyInputRequests(e){return new Map(Object.entries(readMap(e)))}function hasProxyInputRequests(e){for(let t of Object.keys(readMap(e)))return!0;return!1}function upsertProxyInputRequests(e){return{...e.session,state:upsertProxyInputRequestState({entries:e.entries,forChildContinuationToken:e.forChildContinuationToken,state:e.session.state})}}function upsertProxyInputRequestState(e){let t={};for(let[n,r]of Object.entries(readMap(e.state)))r.childContinuationToken!==e.forChildContinuationToken&&(t[n]=r);for(let[n,r]of e.entries)t[n]=r;let n={...e.state};return Object.keys(t).length===0?delete n[PROXY_INPUT_REQUESTS_KEY]:n[PROXY_INPUT_REQUESTS_KEY]=t,Object.keys(n).length>0?n:void 0}function clearProxyInputRequestsForChild(e,t){return clearProxyInputRequestsWhere(e,e=>e.childContinuationToken===t)}function clearProxyInputRequestsWhere(e,t){let n=readMap(e.state),r={},i=!1;for(let[e,a]of Object.entries(n)){if(t(a)){i=!0;continue}r[e]=a}return i?writeMap(e,r):e}function retireProxyInputRequests(e,t){let n={...readMap(e.state)},r=!1;for(let e of t)Object.hasOwn(n,e)&&(delete n[e],r=!0);return r?writeMap(e,n):e}function clearProxyInputRequestsForTask(e,t){return clearProxyInputRequestsWhere(e,e=>e.taskId===t)}function clearAllProxyInputRequests(e){return hasProxyInputRequests(e.state)?writeMap(e,{}):e}function toProxyInputRequestEntries(e,t){let n={approvalRequestIds:e.event.requests.flatMap(e=>e.kind===`tool-approval`?[e.requestId]:[]),requestIds:e.event.requests.map(e=>e.requestId)};return e.event.requests.map(r=>{let i={batch:n,childContinuationToken:e.childContinuationToken,kind:r.kind};return t!==void 0&&(i.taskId=t),e.childSessionInbox?.sessionId===e.childSessionId&&(i.childSessionInbox=e.childSessionInbox),[r.requestId,i]})}function readMap(e){let t=e?.[PROXY_INPUT_REQUESTS_KEY];if(typeof t!=`object`||!t||Array.isArray(t))return{};let n={};for(let[e,r]of Object.entries(t)){let t=parseProxyInputRequest(r,e);t!==void 0&&(n[e]=t)}return n}function writeMap(e,t){let n={...e.state};return Object.keys(t).length===0?(delete n[PROXY_INPUT_REQUESTS_KEY],{...e,state:Object.keys(n).length>0?n:void 0}):(n[PROXY_INPUT_REQUESTS_KEY]=t,{...e,state:n})}function parseProxyInputRequest(e,t){if(typeof e!=`object`||!e||Array.isArray(e)||!(`childContinuationToken`in e)||!(`kind`in e)||typeof e.childContinuationToken!=`string`||!isInputRequestKind(e.kind))return;let n=`taskId`in e?e.taskId:void 0,r=`childRequestId`in e?e.childRequestId:void 0,i=`childResponseUrl`in e?e.childResponseUrl:void 0;if(n!==void 0&&(typeof n!=`string`||n.length===0)||r!==void 0&&(typeof r!=`string`||r.length===0)||n===void 0!=(r===void 0)||i!==void 0&&(typeof i!=`string`||!isAllowedChildResponseUrl(i)))return;let a=`batch`in e?parseProxyInputRequestBatch(e.batch):void 0,o=`answerHook`in e?parseAnswerHookRoute(e.answerHook):void 0;if(`answerHook`in e&&o===void 0)return;let s=`childSessionInbox`in e?e.childSessionInbox:void 0;if(s!==void 0&&!isSessionInboxAddress(s))return;let c={childContinuationToken:e.childContinuationToken,kind:e.kind};return o!==void 0&&(c.answerHook=o),s!==void 0&&(c.childSessionInbox=s),a!==void 0&&a.requestIds.includes(t)&&(c.batch=a),typeof r==`string`&&(c.childRequestId=r),typeof i==`string`&&(c.childResponseUrl=i),typeof n==`string`&&(c.taskId=n),c}function parseAnswerHookRoute(e){if(typeof e!=`object`||!e||!(`runId`in e)||typeof e.runId!=`string`||e.runId.length===0)return;if(!(`question`in e)||e.question===void 0)return{runId:e.runId};let t=parseAnswerHookQuestion(e.question);return t===void 0?void 0:{question:t,runId:e.runId}}function parseAnswerHookQuestion(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t={};for(let n of[`allowFreeform`,`dismissible`]){let r=Reflect.get(e,n);if(r!==void 0){if(typeof r!=`boolean`)return;t[n]=r}}let n=Reflect.get(e,`options`);if(n!==void 0){let e=inputOptionSchema.array().safeParse(n);if(!e.success)return;t.options=e.data}return t}function parseProxyInputRequestBatch(e){if(typeof e!=`object`||!e||Array.isArray(e)||!(`approvalRequestIds`in e)||!(`requestIds`in e)||!isStringArray(e.approvalRequestIds)||!isStringArray(e.requestIds))return;let t=new Set(e.requestIds);if(!(t.size!==e.requestIds.length||e.approvalRequestIds.some(e=>!t.has(e))))return{approvalRequestIds:e.approvalRequestIds,requestIds:e.requestIds}}function isStringArray(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function isAllowedChildResponseUrl(e){let t;try{t=new URL(e)}catch{return!1}return t.protocol===`https:`||t.protocol===`http:`&&isLoopbackHostname(t.hostname)}function isInputRequestKind(e){return typeof e==`string`&&Object.hasOwn(PROXY_INPUT_REQUEST_KINDS,e)}export{clearAllProxyInputRequests,clearProxyInputRequestsForChild,clearProxyInputRequestsForTask,clearProxyInputRequestsWhere,createTaskInputRequestId,getProxyInputRequests,hasProxyInputRequests,retireProxyInputRequests,toProxyInputRequestEntries,upsertProxyInputRequestState,upsertProxyInputRequests};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ModelMessage, UserContent } from "ai";
|
|
2
|
-
import type {
|
|
2
|
+
import type { StepInput } from "#harness/types.js";
|
|
3
3
|
type StaleResponseConversion = {
|
|
4
4
|
readonly kind: "unchanged";
|
|
5
5
|
readonly stepInput?: StepInput;
|
|
@@ -40,6 +40,5 @@ export declare function convertStaleResponsesToUserMessage(input: {
|
|
|
40
40
|
readonly history: readonly ModelMessage[];
|
|
41
41
|
readonly pendingRequestIds: ReadonlySet<string>;
|
|
42
42
|
readonly stepInput?: StepInput;
|
|
43
|
-
readonly tools: HarnessToolMap;
|
|
44
43
|
}): StaleResponseConversion;
|
|
45
44
|
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{appendUserContent,normalizeUserContent}from"#harness/messages.js";import{
|
|
1
|
+
import{appendUserContent,normalizeUserContent}from"#harness/messages.js";import{isSessionLimitContinuationRequestId}from"#harness/session-limit-continuation.js";import{extractHistoricalInputRequests}from"#harness/input-extraction.js";function dropStaleSessionLimitContinuationResponses(e){if(e.stepInput===void 0)return;let t=e.stepInput.inputResponses??[],n=e.stepInput.attributedInputResponses??[],keep=t=>e.pendingRequestIds.has(t)||!isSessionLimitContinuationRequestId(t),r=t.filter(e=>keep(e.requestId)),i=n.filter(({response:e})=>keep(e.requestId));if(r.length===t.length&&i.length===n.length)return e.stepInput;let{attributedInputResponses:a,inputResponses:o,...s}=e.stepInput,c=s;return r.length>0&&(c.inputResponses=r),i.length>0&&(c.attributedInputResponses=i),c}function convertStaleResponsesToUserMessage(e){if(e.stepInput===void 0)return{kind:`unchanged`};let t=e.stepInput.inputResponses??[],n=e.stepInput.attributedInputResponses??[];if(t.length===0&&n.length===0)return{kind:`unchanged`,stepInput:e.stepInput};let r=[],i=[],a=[];for(let n of t)(e.pendingRequestIds.has(n.requestId)?r:a).push(n);for(let t of n)e.pendingRequestIds.has(t.response.requestId)?i.push(t):a.push(t.response);if(a.length===0)return{kind:`unchanged`,stepInput:e.stepInput};let o=extractHistoricalInputRequests({history:e.history,requestIds:new Set(a.map(e=>e.requestId))}),s=appendOptionalUserContent(e.stepInput.message,formatModelMessage(a,o)),c=appendOptionalUserContent(e.stepInput.message,formatDisplayMessage(a,o)),{attributedInputResponses:l,inputResponses:u,...d}=e.stepInput,f={...d,message:s};return r.length>0&&(f.inputResponses=r),i.length>0&&(f.attributedInputResponses=i),{displayMessage:c,kind:`converted`,stepInput:f}}function formatModelMessage(e,t){let n=e.map(e=>{let n=t.get(e.requestId),r=n?.options?.find(t=>t.id===e.optionId),i={};if(e.optionId!==void 0&&(i.optionId=e.optionId),r!==void 0){let e={id:r.id,label:r.label};r.description!==void 0&&(e.description=r.description),i.selectedOption=e}e.text!==void 0&&(i.text=e.text);let a={requestId:e.requestId,response:i};return n!==void 0&&(a.prompt=n.prompt,a.requestType=`approval`),a});return[`The user submitted the following response to an earlier interactive prompt.`,`Treat it as new input at the current point in the conversation and decide whether it is still relevant. This does not authorize an earlier action; request approval again if that action is still needed.`,JSON.stringify(n,null,2)].join(`
|
|
2
2
|
`)}function formatDisplayMessage(e,t){return e.map(e=>e.text!==void 0&&e.text.length>0?e.text:t.get(e.requestId)?.options?.find(t=>t.id===e.optionId)?.label??e.optionId??`Response to an earlier interactive prompt`).join(`
|
|
3
3
|
`)}function appendOptionalUserContent(e,t){let n=normalizeUserContent(e);return n===void 0?t:appendUserContent({appended:t,existing:n})}export{convertStaleResponsesToUserMessage,dropStaleSessionLimitContinuationResponses};
|