eve 0.53.1 → 0.54.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 +15 -0
- package/dist/src/channel/types.d.ts +2 -0
- package/dist/src/cli/commands/trace-detail.js +1 -1
- package/dist/src/cli/commands/trace.d.ts +2 -2
- package/dist/src/cli/commands/trace.js +3 -3
- package/dist/src/cli/dev/tui/runner.js +1 -1
- package/dist/src/cli/dev/tui/traces/trace-conversation.d.ts +5 -5
- package/dist/src/cli/dev/tui/traces/trace-conversation.js +1 -1
- package/dist/src/cli/dev/tui/traces/trace-view.js +1 -1
- package/dist/src/cli/dev/tui/traces/trace-viewer-session.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +1 -1
- package/dist/src/compiled/@opentelemetry/api/index.d.ts +1 -0
- package/dist/src/compiler/extension-compatibility.d.ts +4 -4
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/context/dynamic-instruction-lifecycle.d.ts +2 -1
- package/dist/src/context/dynamic-instruction-lifecycle.js +1 -1
- package/dist/src/context/keys.d.ts +3 -1
- package/dist/src/context/keys.js +1 -1
- package/dist/src/eve-channel/index.js +1 -1
- package/dist/src/execution/cancelled-model-call-batch.js +1 -1
- package/dist/src/execution/cancelled-turn-message.js +1 -1
- package/dist/src/execution/compaction.d.ts +2 -2
- package/dist/src/execution/coordination-dispatch-shared.d.ts +0 -1
- package/dist/src/execution/coordination-dispatch-shared.js +1 -1
- package/dist/src/execution/durable-session-store.d.ts +2 -2
- package/dist/src/execution/eve-workflow-attributes.d.ts +3 -3
- package/dist/src/execution/next-driver-action.d.ts +2 -0
- package/dist/src/execution/route-child-delivery.js +1 -1
- package/dist/src/execution/runtime-context.js +1 -1
- package/dist/src/execution/session.js +2 -2
- package/dist/src/execution/tasks/parent/hitl-proxy-steps.d.ts +5 -1
- package/dist/src/execution/tasks/parent/hitl-proxy-steps.js +1 -1
- package/dist/src/execution/tasks/parent/tool-execution.js +1 -1
- package/dist/src/execution/tools/sleep-workflow.js +1 -1
- package/dist/src/execution/tools/subagent/invoke-step.d.ts +4 -0
- package/dist/src/execution/tools/subagent/invoke-step.js +1 -1
- package/dist/src/execution/tools/subagent/start.d.ts +2 -2
- package/dist/src/execution/tools/subagent/start.js +1 -1
- package/dist/src/execution/tools/subagent/task-agent-requests.js +1 -1
- package/dist/src/execution/tools/todo.d.ts +2 -2
- package/dist/src/execution/tools/todo.js +2 -2
- package/dist/src/execution/turn-workflow.js +1 -1
- package/dist/src/execution/workflow-runtime.js +1 -1
- package/dist/src/execution/workflow-steps.js +1 -1
- package/dist/src/harness/compaction.js +1 -1
- package/dist/src/harness/current-messages.d.ts +7 -6
- package/dist/src/harness/current-messages.js +1 -1
- package/dist/src/harness/messages.d.ts +36 -0
- package/dist/src/harness/messages.js +1 -1
- package/dist/src/harness/session-limit-enforcement.d.ts +2 -15
- package/dist/src/harness/tool-loop.js +2 -2
- package/dist/src/harness/types.d.ts +6 -4
- package/dist/src/instrumentation/ai-sdk-hook-bridge.js +1 -1
- package/dist/src/instrumentation/background-task-runtime.d.ts +18 -0
- package/dist/src/instrumentation/background-task-runtime.js +1 -0
- package/dist/src/instrumentation/channel-delivery.js +1 -1
- package/dist/src/instrumentation/lifecycle.d.ts +13 -0
- package/dist/src/instrumentation/lifecycle.js +1 -1
- package/dist/src/instrumentation/native-events.d.ts +7 -0
- package/dist/src/instrumentation/native-events.js +1 -1
- package/dist/src/instrumentation/parent-lineage.d.ts +2 -2
- package/dist/src/instrumentation/parent-lineage.js +1 -1
- package/dist/src/instrumentation/prepare-trace-context.d.ts +3 -11
- package/dist/src/instrumentation/prepare-trace-context.js +1 -1
- package/dist/src/instrumentation/principal-summary.d.ts +11 -0
- package/dist/src/instrumentation/principal-summary.js +1 -0
- package/dist/src/instrumentation/runtime.d.ts +8 -7
- package/dist/src/instrumentation/runtime.js +1 -1
- package/dist/src/instrumentation/session-context.d.ts +22 -0
- package/dist/src/instrumentation/session-context.js +1 -0
- package/dist/src/instrumentation/state.d.ts +7 -2
- package/dist/src/instrumentation/state.js +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/logging.js +1 -1
- package/dist/src/internal/nitro/routes/channel-dispatch.js +1 -1
- package/dist/src/internal/nitro/routes/channel-request-instrumentation.d.ts +4 -5
- package/dist/src/internal/nitro/routes/channel-request-instrumentation.js +1 -1
- package/dist/src/protocol/baggage.d.ts +15 -2
- package/dist/src/protocol/baggage.js +1 -1
- package/dist/src/public/instrumentation/index.d.ts +5 -4
- package/dist/src/runtime/agent/bootstrap.d.ts +2 -2
- package/dist/src/runtime/agent/bootstrap.js +1 -1
- package/dist/src/self-modification/agent.js +1 -1
- package/dist/src/self-modification/extension/instructions.js +21 -20
- package/dist/src/self-modification/extension/tools/edit_file.js +1 -1
- package/dist/src/self-modification/extension/tools/search_registry.d.ts +1 -1
- package/dist/src/self-modification/extension/tools/search_registry.js +1 -1
- package/dist/src/setup/integrations/self-modification/setup.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/shared/memory-state.js +1 -1
- package/dist/src/shared/serialized-observability-state.d.ts +12 -0
- package/dist/src/shared/serialized-observability-state.js +1 -0
- package/dist/src/subagents/invocation.d.ts +9 -0
- package/dist/src/subagents/remote-dispatch.d.ts +3 -3
- package/dist/src/subagents/remote-dispatch.js +1 -1
- package/dist/src/subagents/start-local.d.ts +2 -6
- package/dist/src/subagents/start-local.js +1 -1
- package/dist/src/subagents/start-remote.d.ts +2 -8
- package/dist/src/subagents/start-remote.js +1 -1
- package/dist/src/subagents/tool.d.ts +3 -13
- package/dist/src/subagents/tool.js +1 -1
- package/dist/src/tasks/delivery-context.d.ts +10 -1
- package/dist/src/tasks/delivery-context.js +2 -2
- package/dist/src/tracing/agent-action-instrumentation.d.ts +3 -2
- package/dist/src/tracing/agent-action-instrumentation.js +1 -1
- package/dist/src/tracing/agent-approval-instrumentation.js +1 -1
- package/dist/src/tracing/agent-channel-delivery-instrumentation.d.ts +1 -6
- package/dist/src/tracing/agent-channel-delivery-instrumentation.js +1 -1
- package/dist/src/tracing/agent-invocation-coordinator.d.ts +28 -0
- package/dist/src/tracing/agent-invocation-coordinator.js +1 -0
- package/dist/src/tracing/agent-invocation-terminal.d.ts +18 -0
- package/dist/src/tracing/agent-invocation-terminal.js +1 -0
- package/dist/src/tracing/agent-otel-attributes.d.ts +4 -0
- package/dist/src/tracing/agent-otel-attributes.js +1 -0
- package/dist/src/tracing/agent-otel-content.js +1 -1
- package/dist/src/tracing/agent-otel-provider.d.ts +4 -6
- package/dist/src/tracing/agent-otel-provider.js +2 -2
- package/dist/src/tracing/agent-otel-runtime-context.d.ts +9 -0
- package/dist/src/tracing/agent-otel-runtime-context.js +1 -1
- package/dist/src/tracing/agent-otel-session-context.d.ts +4 -3
- package/dist/src/tracing/agent-otel-session-context.js +1 -1
- package/dist/src/tracing/agent-otel-usage.d.ts +4 -10
- package/dist/src/tracing/agent-otel-usage.js +1 -1
- package/dist/src/tracing/agent-span-contract.d.ts +25 -0
- package/dist/src/tracing/agent-span-contract.js +1 -0
- package/dist/src/tracing/agent-span-error.d.ts +3 -0
- package/dist/src/tracing/agent-span-error.js +1 -0
- package/dist/src/tracing/agent-span-id-generator.d.ts +3 -0
- package/dist/src/tracing/agent-span-id-generator.js +1 -1
- package/dist/src/tracing/agent-tool-instrumentation.js +1 -1
- package/dist/src/tracing/agent-trace-context-codec.d.ts +12 -0
- package/dist/src/tracing/agent-trace-context-codec.js +1 -0
- package/dist/src/tracing/agent-trace-context-store.d.ts +35 -8
- package/dist/src/tracing/agent-trace-context-store.js +1 -1
- package/dist/src/tracing/agent-trace-span-processor.d.ts +5 -7
- package/dist/src/tracing/agent-trace-span-processor.js +1 -1
- package/dist/src/tracing/agent-trace-state.d.ts +41 -3
- package/dist/src/tracing/agent-trace-state.js +1 -1
- package/dist/src/tracing/bounded-error.d.ts +1 -0
- package/dist/src/tracing/bounded-error.js +1 -0
- package/dist/src/tracing/content-span-processor.js +1 -1
- package/dist/src/tracing/conversation-context.d.ts +4 -0
- package/dist/src/tracing/conversation-context.js +1 -0
- package/dist/src/tracing/error-content-context.d.ts +3 -0
- package/dist/src/tracing/error-content-context.js +1 -0
- package/dist/src/tracing/install-instrumentation-runtime.js +1 -1
- package/dist/src/tracing/local-trace-reader.d.ts +6 -6
- package/dist/src/tracing/local-trace-reader.js +1 -1
- package/dist/src/tracing/local-traces.d.ts +6 -8
- package/dist/src/tracing/local-traces.js +1 -1
- package/dist/src/tracing/otel-declaration.d.ts +5 -3
- package/dist/src/tracing/otel-registration.d.ts +2 -1
- package/dist/src/tracing/otel-registration.js +1 -1
- package/dist/src/tracing/telemetry-budget.d.ts +4 -0
- package/dist/src/tracing/telemetry-budget.js +1 -0
- package/docs/guides/instrumentation-providers.md +5 -0
- package/docs/guides/instrumentation.md +144 -14
- package/docs/guides/remote-agents.md +11 -0
- package/docs/reference/cli.md +8 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# eve
|
|
2
2
|
|
|
3
|
+
## 0.54.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 879d4e5: Advance `agent.trace.schema.version` from 3 to 4 and remove `agent.session` and `agent.channel.delivery`: update dashboards to use per-activation `invoke_agent` spans, linked to callers and grouped by `gen_ai.conversation.id`. Single turn-bound channel deliveries annotate their activation and link it to the active upstream request or function span; `traceChannelRequests` only adds an eve-owned server span as the link target. Other delivery lifecycles do not emit agent spans. Dispatch uses `agent.action` and `execute_tool`, preserves standard GenAI usage totals and trace-content restrictions, and rejects baggage overflow; settlement materializes spans without draining exporters, and conversation IDs remain available without instrumentation.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- f60c64b: Brand every user-role model message in `gen_ai.input.messages`. Real user input is `user`; framework-authored messages use namespaced provenance such as `context.instruction` and `execution.background_task`.
|
|
12
|
+
- 84c9604: Make self-modification source edits more efficient by clarifying file and documentation discovery, guarded reads, edit selection, contract preservation, outbound request safety, registry scope, and concise completion reports. Memory providers can now be selected as a registry search category.
|
|
13
|
+
- dea8cd8: The local dev TUI now reconnects idle session streams, so approvals and questions from long-running background tasks still interrupt the prompt after an earlier transport stream closes.
|
|
14
|
+
- 47bd3d7: Preserve one observability conversation ID across local and remote agent dispatch, accepting incoming correlation only on callback-marked remote session creation. Apply the live delivery's trace-content ceiling to the selected caller context, including fallback when its action span is unavailable.
|
|
15
|
+
- 6d0485b: Expose current and initiating principals in Agent Runs turn metadata, including channel-driven and resumed activations. Principal types remain bounded; IDs require a content-visible audience and a resolved trace policy permitting both input and output content, including any forwarded ceiling, and oversized IDs are omitted.
|
|
16
|
+
- 9381078: Keep `agent.action` spans for background tools and subagents open until their tasks complete, fail, or are cancelled, and record the task's final outcome and policy-controlled error details instead of treating its receipt as completion.
|
|
17
|
+
|
|
3
18
|
## 0.53.1
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -449,6 +449,8 @@ export interface RunInput {
|
|
|
449
449
|
readonly outputSchema?: JsonObject;
|
|
450
450
|
};
|
|
451
451
|
readonly mode: RunMode;
|
|
452
|
+
/** Observability correlation only; never grants delegated-session privileges. */
|
|
453
|
+
readonly conversationId?: string;
|
|
452
454
|
readonly parent?: SessionParent;
|
|
453
455
|
/**
|
|
454
456
|
* Dispatching parent's open trace window. Handed down rather than looked up
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{sanitizeForTerminal}from"#cli/ui/output.js";import{formatElapsed}from"#cli/format-elapsed.js";import{formatCompactTokenCount}from"#cli/dev/tui/stream-format.js";import{formatAttributeContent}from"#cli/dev/tui/traces/trace-content.js";function spanMetricChips(e){let t=[],n=numberAttribute(e,`agent.usage.input_tokens`),r=numberAttribute(e,`agent.usage.output_tokens`);n!==void 0&&t.push(`↑${formatCompactTokenCount(n)}`),r!==void 0&&t.push(`↓${formatCompactTokenCount(r)}`);let i=spanCostUsd(e);return i!==void 0&&t.push(formatCostUsd(i)),t}function summarizeLocalTrace(e){let t=[],n=0,r=0,i,a=0,o=0,s=0;for(let c of e){let e=stringAttribute(c,`agent.model.id`)??stringAttribute(c,`gen_ai.request.model`);if(e!==void 0&&!t.includes(e)&&t.push(e),c.statusCode===2&&(a+=1),c.name!==`agent.step`)continue;o+=numberAttribute(c,`agent.usage.input_tokens`)??0,s+=numberAttribute(c,`agent.usage.output_tokens`)??0,n+=numberAttribute(c,`gen_ai.usage.cache_read.input_tokens`)??0,r+=numberAttribute(c,`gen_ai.usage.cache_creation.input_tokens`)??0;let l=spanCostUsd(c);l!==void 0&&(i=(i??0)+l)}return{cacheReadTokens:n,cacheWriteTokens:r,costUsd:i,errorCount:a,inputTokens:o,models:t,outputTokens:s}}function formatTokenSummary(e){let t=[`↑${formatCompactTokenCount(e.inputTokens)} in`,`↓${formatCompactTokenCount(e.outputTokens)} out`];return e.cacheReadTokens>0&&t.push(`${formatCompactTokenCount(e.cacheReadTokens)} cached`),e.cacheWriteTokens>0&&t.push(`${formatCompactTokenCount(e.cacheWriteTokens)} cache write`),t.join(` · `)}function formatCostUsd(e){return e>=1?`$${e.toFixed(2)}`:`$${e.toFixed(4)}`}function renderSpanDetailTree(e,t){let n=spanDetailEntries(e,t.width-t.margin.length-3),r=[];return n.forEach((e,r)=>{let i=r===n.length-1&&!t.childrenFollow;emit(e,t.margin,i?`└─ `:`├─ `)}),r;function emit(e,n,i){r.push(t.mute(`${n}${i}${e.head}`));let a=`${n}${i===`└─ `?` `:`│ `}`;for(let n of e.lines)r.push(t.mute(`${a} ${n}`));e.entries.forEach((t,n)=>{emit(t,a,n===e.entries.length-1?`└─ `:`├─ `)})}}function spanDetailEntries(e,t){let dim=e=>e,n=Math.max(40,t),r=[],push=(e,t=[],n=[])=>{r.push({entries:n,head:e,lines:t})},i=e.statusCode===2;push(`status: ${i&&e.statusMessage!==void 0?`ERROR — ${sanitizeForTerminal(e.statusMessage)}`:i?`ERROR`:`ok`}`),push(`duration: ${formatElapsed(durationMs(e.startTimeNs,e.endTimeNs))}`),push(`started: ${new Date(Number(e.startTimeNs/1000000n)).toISOString()}`),push(`span: ${e.spanId}`),e.parentSpanId!==void 0&&push(`parent: ${e.parentSpanId}`),e.scope!==void 0&&push(`scope: ${sanitizeForTerminal(e.scope)}`),e.kind!==void 0&&e.kind!==1&&push(`kind: ${spanKind(e.kind)}`);for(let t of Object.keys(e.attributes).sort()){let r=formatAttributeContent(t,e.attributes[t],dim,n-2),i=sanitizeForTerminal(t);r.length===1?push(`${i}: ${r[0]}`):push(`${i}:`,r)}return e.events.length>0&&push(`events:`,[],e.events.map(t=>{let r=Math.max(0,durationMs(e.startTimeNs,t.timeNs)),i=[];for(let e of Object.keys(t.attributes).sort()){let r=formatAttributeContent(e,t.attributes[e],dim,n-6),a=sanitizeForTerminal(e);r.length===1?i.push(`${a}: ${r[0]}`):i.push(`${a}:`,...r.map(e=>` ${e}`))}return{entries:[],head:`${sanitizeForTerminal(t.name)} +${formatElapsed(r)}`,lines:i}})),r}function spanCostUsd(e){return numberAttribute(e,`gen_ai.usage.gateway_cost`)??numberAttribute(e,`gen_ai.usage.cost`)}function spanKind(e){switch(e){case 2:return`server`;case 3:return`client`;case 4:return`producer`;case 5:return`consumer`;default:return`unknown (${e})`}}function numberAttribute(e,t){let n=e.attributes[t];if(typeof n==`number`)return n;if(typeof n==`string`&&n!==``){let e=Number(n);return Number.isFinite(e)?e:void 0}}function stringAttribute(e,t){let n=e.attributes[t];return typeof n==`string`&&n.length>0?n:void 0}function durationMs(e,t){return Number(t-e)/1e6}export{formatCostUsd,formatTokenSummary,renderSpanDetailTree,spanMetricChips,summarizeLocalTrace};
|
|
1
|
+
import{sanitizeForTerminal}from"#cli/ui/output.js";import{formatElapsed}from"#cli/format-elapsed.js";import{formatCompactTokenCount}from"#cli/dev/tui/stream-format.js";import{formatAttributeContent}from"#cli/dev/tui/traces/trace-content.js";import{AGENT_USAGE_ATTRIBUTES}from"#tracing/agent-span-contract.js";function spanMetricChips(e){let t=[],n=numberAttribute(e,`agent.usage.input_tokens`),r=numberAttribute(e,`agent.usage.output_tokens`);n!==void 0&&t.push(`↑${formatCompactTokenCount(n)}`),r!==void 0&&t.push(`↓${formatCompactTokenCount(r)}`);let i=spanCostUsd(e);return i!==void 0&&t.push(formatCostUsd(i)),t}function summarizeLocalTrace(e){let t=[],n=0,r=0,i,a=0,o=0,s=0;for(let c of e){let e=stringAttribute(c,`agent.model.id`)??stringAttribute(c,`gen_ai.request.model`);if(e!==void 0&&!t.includes(e)&&t.push(e),c.statusCode===2&&(a+=1),c.name!==`agent.step`)continue;o+=numberAttribute(c,`agent.usage.input_tokens`)??0,s+=numberAttribute(c,`agent.usage.output_tokens`)??0,n+=numberAttribute(c,AGENT_USAGE_ATTRIBUTES.cacheReadTokens)??numberAttribute(c,`gen_ai.usage.cache_read.input_tokens`)??0,r+=numberAttribute(c,AGENT_USAGE_ATTRIBUTES.cacheWriteTokens)??numberAttribute(c,`gen_ai.usage.cache_creation.input_tokens`)??0;let l=spanCostUsd(c);l!==void 0&&(i=(i??0)+l)}return{cacheReadTokens:n,cacheWriteTokens:r,costUsd:i,errorCount:a,inputTokens:o,models:t,outputTokens:s}}function formatTokenSummary(e){let t=[`↑${formatCompactTokenCount(e.inputTokens)} in`,`↓${formatCompactTokenCount(e.outputTokens)} out`];return e.cacheReadTokens>0&&t.push(`${formatCompactTokenCount(e.cacheReadTokens)} cached`),e.cacheWriteTokens>0&&t.push(`${formatCompactTokenCount(e.cacheWriteTokens)} cache write`),t.join(` · `)}function formatCostUsd(e){return e>=1?`$${e.toFixed(2)}`:`$${e.toFixed(4)}`}function renderSpanDetailTree(e,t){let n=spanDetailEntries(e,t.width-t.margin.length-3),r=[];return n.forEach((e,r)=>{let i=r===n.length-1&&!t.childrenFollow;emit(e,t.margin,i?`└─ `:`├─ `)}),r;function emit(e,n,i){r.push(t.mute(`${n}${i}${e.head}`));let a=`${n}${i===`└─ `?` `:`│ `}`;for(let n of e.lines)r.push(t.mute(`${a} ${n}`));e.entries.forEach((t,n)=>{emit(t,a,n===e.entries.length-1?`└─ `:`├─ `)})}}function spanDetailEntries(e,t){let dim=e=>e,n=Math.max(40,t),r=[],push=(e,t=[],n=[])=>{r.push({entries:n,head:e,lines:t})},i=e.statusCode===2;push(`status: ${i&&e.statusMessage!==void 0?`ERROR — ${sanitizeForTerminal(e.statusMessage)}`:i?`ERROR`:`ok`}`),push(`duration: ${formatElapsed(durationMs(e.startTimeNs,e.endTimeNs))}`),push(`started: ${new Date(Number(e.startTimeNs/1000000n)).toISOString()}`),push(`span: ${e.spanId}`),e.parentSpanId!==void 0&&push(`parent: ${e.parentSpanId}`),e.scope!==void 0&&push(`scope: ${sanitizeForTerminal(e.scope)}`),e.kind!==void 0&&e.kind!==1&&push(`kind: ${spanKind(e.kind)}`);for(let t of Object.keys(e.attributes).sort()){let r=formatAttributeContent(t,e.attributes[t],dim,n-2),i=sanitizeForTerminal(t);r.length===1?push(`${i}: ${r[0]}`):push(`${i}:`,r)}return e.events.length>0&&push(`events:`,[],e.events.map(t=>{let r=Math.max(0,durationMs(e.startTimeNs,t.timeNs)),i=[];for(let e of Object.keys(t.attributes).sort()){let r=formatAttributeContent(e,t.attributes[e],dim,n-6),a=sanitizeForTerminal(e);r.length===1?i.push(`${a}: ${r[0]}`):i.push(`${a}:`,...r.map(e=>` ${e}`))}return{entries:[],head:`${sanitizeForTerminal(t.name)} +${formatElapsed(r)}`,lines:i}})),r}function spanCostUsd(e){return numberAttribute(e,`gen_ai.usage.gateway_cost`)??numberAttribute(e,`gen_ai.usage.cost`)}function spanKind(e){switch(e){case 2:return`server`;case 3:return`client`;case 4:return`producer`;case 5:return`consumer`;default:return`unknown (${e})`}}function numberAttribute(e,t){let n=e.attributes[t];if(typeof n==`number`)return n;if(typeof n==`string`&&n!==``){let e=Number(n);return Number.isFinite(e)?e:void 0}}function stringAttribute(e,t){let n=e.attributes[t];return typeof n==`string`&&n.length>0?n:void 0}function durationMs(e,t){return Number(t-e)/1e6}export{formatCostUsd,formatTokenSummary,renderSpanDetailTree,spanMetricChips,summarizeLocalTrace};
|
|
@@ -4,8 +4,8 @@ interface CliTraceLogger {
|
|
|
4
4
|
log(message: string): void;
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
|
-
* Resolves an exact trace/
|
|
8
|
-
* can match several traces, since
|
|
7
|
+
* Resolves an exact trace/conversation id or an unambiguous prefix. One
|
|
8
|
+
* conversation ID can match several traces, since each turn is separate.
|
|
9
9
|
*/
|
|
10
10
|
export declare function resolveLocalTraces(traces: readonly LocalTrace[], reference: string): readonly LocalTrace[];
|
|
11
11
|
export declare function runTraceListCommand(logger: CliTraceLogger, appRoot: string, options?: {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{basename}from"node:path";import{createCliTheme,renderCliSection,sanitizeForTerminal}from"#cli/ui/output.js";import{formatElapsed}from"#cli/format-elapsed.js";import{formatCostUsd,formatTokenSummary,renderSpanDetailTree,spanMetricChips,summarizeLocalTrace}from"#cli/commands/trace-detail.js";import{compareLocalTraceSpans,describeLocalTraceSpan,listLocalTraces}from"#tracing/local-trace-reader.js";const TRACE_DISPLAY_DIRECTORY=`.eve/traces/v1`;function resolveLocalTraces(e,t){let n=t.replaceAll(`\\`,`/`),r=basename(n),i=n===r?[n]:[n,r],a=e.find(e=>i.includes(e.traceId));if(a!==void 0)return[a];let o=e.filter(e=>e.
|
|
1
|
+
import{basename}from"node:path";import{createCliTheme,renderCliSection,sanitizeForTerminal}from"#cli/ui/output.js";import{formatElapsed}from"#cli/format-elapsed.js";import{formatCostUsd,formatTokenSummary,renderSpanDetailTree,spanMetricChips,summarizeLocalTrace}from"#cli/commands/trace-detail.js";import{compareLocalTraceSpans,describeLocalTraceSpan,listLocalTraces}from"#tracing/local-trace-reader.js";const TRACE_DISPLAY_DIRECTORY=`.eve/traces/v1`;function resolveLocalTraces(e,t){let n=t.replaceAll(`\\`,`/`),r=basename(n),i=n===r?[n]:[n,r],a=e.find(e=>i.includes(e.traceId));if(a!==void 0)return[a];let o=e.filter(e=>e.conversationIds.some(e=>i.includes(e)));if(o.length>0)return orderWindows(o);let s=e.filter(e=>i.some(t=>e.traceId.startsWith(t)||e.conversationIds.some(e=>e.startsWith(t))));if(s.length===0)throw Error(`No local trace matches "${sanitizeForTerminal(t)}". Run \`eve traces ls\` to list traces.`);if(s.length===1)return s;if(new Set(s.map(e=>e.conversationId??e.traceId)).size>1)throw ambiguousTraceError(s,t);return orderWindows(s)}function orderWindows(e){return[...e].sort((e,t)=>e.startTimeNs===t.startTimeNs?e.traceId.localeCompare(t.traceId):e.startTimeNs<t.startTimeNs?-1:1)}async function runTraceListCommand(e,t,n={}){let r=await listLocalTraces(t);if(n.json===!0){e.log(JSON.stringify(r.map(e=>({agentName:e.agentName??null,durationMs:durationMs(e.startTimeNs,e.endTimeNs),conversationId:e.conversationId??null,spanCount:e.spans.length,startedAt:toDate(e.startTimeNs).toISOString(),traceId:e.traceId})),null,2));return}if(r.length===0){e.log(`No local traces found under ${TRACE_DISPLAY_DIRECTORY}.`);return}let i=r.map(e=>[e.traceId,sanitizeForTerminal(e.conversationId??`unknown`),sanitizeForTerminal(e.agentName??`unknown`),toDate(e.startTimeNs).toISOString(),formatElapsed(durationMs(e.startTimeNs,e.endTimeNs)),String(e.spans.length)]),a=[`TRACE`,`CONVERSATION`,`AGENT`,`STARTED`,`DURATION`,`SPANS`],o=a.map((e,t)=>Math.max(e.length,...i.map(e=>e[t].length)));e.log([a,...i].map(e=>e.map((e,t)=>e.padEnd(o[t])).join(` `).trimEnd()).join(`
|
|
2
2
|
`))}async function runTraceShowCommand(e,t,n,r={}){let i=await listLocalTraces(t);if(i.length===0){let t=`No local traces found under ${TRACE_DISPLAY_DIRECTORY}.`;if(n!==void 0)throw Error(t);e.log(t);return}let a=n===void 0?[i[0]]:resolveLocalTraces(i,n);if(r.json===!0){e.log(JSON.stringify(a.map(serializeTraceForJson),null,2));return}let o=createCliTheme();e.log(a.map(e=>[renderCliSection(o,{rows:traceHeaderRows(e),title:`Trace`}),`${o.accent(`Spans`)}\n${renderSpanTree(e.spans,{dim:o.muted,verbose:r.verbose===!0})}`].join(`
|
|
3
3
|
|
|
4
4
|
`)).join(`
|
|
5
5
|
|
|
6
|
-
`))}function traceHeaderRows(e){let t=summarizeLocalTrace(e.spans);return[{label:`Trace ID`,value:e.traceId},{label:`
|
|
7
|
-
`)}function subtreeExtents(e,t){let n=new Map,r=new Set,visit=e=>{let i=n.get(e.spanId);if(i!==void 0)return i;if(r.has(e.spanId))return{endTimeNs:e.endTimeNs,startTimeNs:e.startTimeNs};r.add(e.spanId);let a=e.endTimeNs,o=e.startTimeNs;for(let n of t.get(e.spanId)??[]){let e=visit(n);e.startTimeNs<o&&(o=e.startTimeNs),e.endTimeNs>a&&(a=e.endTimeNs)}r.delete(e.spanId);let s={endTimeNs:a,startTimeNs:o};return n.set(e.spanId,s),s};for(let t of e)visit(t);return n}function spanLabel(e,t){let n=describeLocalTraceSpan(e).map(sanitizeForTerminal),r=n.length===0?``:` [${n.join(`, `)}]`,i=spanMetricChips(e).map(sanitizeForTerminal),a=i.length===0?``:` ${i.join(` `)}`,o=e.statusCode===2?` ERROR`:``,s=durationMs(e.startTimeNs,e.endTimeNs),c=s===0&&t!==void 0?durationMs(t.startTimeNs,t.endTimeNs):s;return`${sanitizeForTerminal(e.name)}${r} ${formatElapsed(c)}${a}${o}`}function terminalWidth(){let e=process.stdout.columns;return typeof e==`number`&&e>=40?e:100}function durationMs(e,t){return Number(t-e)/1e6}function toDate(e){return new Date(Number(e/1000000n))}function ambiguousTraceError(e,t){return Error([`"${sanitizeForTerminal(t)}" matches ${e.length} local traces:`,...e.map(e=>` ${e.traceId} ${sanitizeForTerminal(e.
|
|
6
|
+
`))}function traceHeaderRows(e){let t=summarizeLocalTrace(e.spans);return[{label:`Trace ID`,value:e.traceId},{label:`Conversation ID`,value:e.conversationId??`unknown`},{label:`Agent`,value:e.agentName??`unknown`},{label:`Started`,value:toDate(e.startTimeNs).toISOString()},{label:`Duration`,value:formatElapsed(durationMs(e.startTimeNs,e.endTimeNs))},{label:`Spans`,value:String(e.spans.length)},...t.models.length===0?[]:[{label:`Models`,value:t.models.join(`, `)}],...t.inputTokens===0&&t.outputTokens===0?[]:[{label:`Tokens`,value:formatTokenSummary(t)}],...t.costUsd===void 0?[]:[{label:`Cost`,value:formatCostUsd(t.costUsd)}],...t.errorCount===0?[]:[{label:`Errors`,value:`${t.errorCount} span${t.errorCount===1?``:`s`}`}]]}function serializeTraceForJson(e){return{agentName:e.agentName??null,durationMs:durationMs(e.startTimeNs,e.endTimeNs),conversationId:e.conversationId??null,conversationIds:e.conversationIds,spanCount:e.spans.length,spans:e.spans.map(e=>({attributes:e.attributes,durationMs:durationMs(e.startTimeNs,e.endTimeNs),endTimeNs:e.endTimeNs.toString(),events:e.events.map(e=>({attributes:e.attributes,name:e.name,timeNs:e.timeNs.toString()})),kind:e.kind??null,name:e.name,parentSpanId:e.parentSpanId??null,scope:e.scope??null,spanId:e.spanId,startTimeNs:e.startTimeNs.toString(),statusCode:e.statusCode,statusMessage:e.statusMessage??null})),startedAt:toDate(e.startTimeNs).toISOString(),traceId:e.traceId}}function renderSpanTree(e,t={}){let n=new Map(e.map(e=>[e.spanId,e])),r=new Map,i=[];for(let t of e)if(t.parentSpanId===void 0||!n.has(t.parentSpanId))i.push(t);else{let e=r.get(t.parentSpanId)??[];e.push(t),r.set(t.parentSpanId,e)}i.sort(compareLocalTraceSpans);for(let e of r.values())e.sort(compareLocalTraceSpans);let a=subtreeExtents(e,r),o=terminalWidth(),s=[],c=new Set,l=t.dim??(e=>e),render=(e,n,i)=>{if(c.has(e.spanId))return;c.add(e.spanId);let u=`${n}${i}`;s.push(`${u===``?``:l(u)}${spanLabel(e,a.get(e.spanId))}`);let d=`${n}${i===``?``:i===`└─ `?` `:`│ `}`,f=r.get(e.spanId)??[];if(t.verbose===!0)for(let t of renderSpanDetailTree(e,{childrenFollow:f.length>0,margin:d,mute:l,width:o}))s.push(t);f.forEach((e,t)=>{let n=t===f.length-1;render(e,d,n?`└─ `:`├─ `)})};for(let e of i)render(e,``,``);for(let t of[...e].sort(compareLocalTraceSpans))c.has(t.spanId)||render(t,``,``);return s.join(`
|
|
7
|
+
`)}function subtreeExtents(e,t){let n=new Map,r=new Set,visit=e=>{let i=n.get(e.spanId);if(i!==void 0)return i;if(r.has(e.spanId))return{endTimeNs:e.endTimeNs,startTimeNs:e.startTimeNs};r.add(e.spanId);let a=e.endTimeNs,o=e.startTimeNs;for(let n of t.get(e.spanId)??[]){let e=visit(n);e.startTimeNs<o&&(o=e.startTimeNs),e.endTimeNs>a&&(a=e.endTimeNs)}r.delete(e.spanId);let s={endTimeNs:a,startTimeNs:o};return n.set(e.spanId,s),s};for(let t of e)visit(t);return n}function spanLabel(e,t){let n=describeLocalTraceSpan(e).map(sanitizeForTerminal),r=n.length===0?``:` [${n.join(`, `)}]`,i=spanMetricChips(e).map(sanitizeForTerminal),a=i.length===0?``:` ${i.join(` `)}`,o=e.statusCode===2?` ERROR`:``,s=durationMs(e.startTimeNs,e.endTimeNs),c=s===0&&t!==void 0?durationMs(t.startTimeNs,t.endTimeNs):s;return`${sanitizeForTerminal(e.name)}${r} ${formatElapsed(c)}${a}${o}`}function terminalWidth(){let e=process.stdout.columns;return typeof e==`number`&&e>=40?e:100}function durationMs(e,t){return Number(t-e)/1e6}function toDate(e){return new Date(Number(e/1000000n))}function ambiguousTraceError(e,t){return Error([`"${sanitizeForTerminal(t)}" matches ${e.length} local traces:`,...e.map(e=>` ${e.traceId} ${sanitizeForTerminal(e.conversationId??`unknown conversation`)}`),`Pass a longer prefix or the full trace/conversation id.`].join(`
|
|
8
8
|
`))}export{resolveLocalTraces,runTraceListCommand,runTraceShowCommand};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{PROMPT_COMMANDS,formatPromptCommandHelp,parsePromptCommand}from"./prompt-commands.js";import{pickAgentHeaderTip}from"./agent-header.js";import{failureKey,formatFailureDetail,formatFailureHint,formatFailureMessage,isInterruptedError,localFailureHint}from"./errors.js";import{parseLogDisplayMode}from"./log-display-mode.js";import{createMcpConnectionStatusTracker}from"./mcp-connection-status.js";import{createRemoteConnectionController}from"./remote-connection.js";import{SubagentPump}from"./subagent-pump.js";import{BOOT_DETECTIONS,CLI_MISSING_SETUP_ISSUE,LOGIN_SETUP_ISSUE,detectSetupIssues,formatSetupIssuesLine,normalizeLocalModelEndpoint,orderedSetupIssues}from"./setup-issues.js";import{TerminalRenderer}from"./terminal-renderer.js";import{createVercelStatusTracker}from"./vercel-status.js";import"#client/index.js";import{loadDevelopmentEnvironmentFiles}from"#cli/dev/environment.js";import{inspectApplication}from"#services/inspect-application.js";import{devBootPhase}from"#internal/dev-boot-progress.js";import{toErrorMessage}from"#shared/errors.js";import{getVercelAuthStatus}from"#setup/vercel-project.js";import{probeAgentInfo}from"#services/dev-client/agent-info-probe.js";import{renderApplicationInfo}from"#cli/commands/info.js";import{subscribeDevelopmentSandboxPrewarmLogs}from"#execution/sandbox/development-prewarm.js";import{createEventDeduper}from"#protocol/event-dedupe.js";import{isCurrentTurnBoundaryEvent}from"#protocol/message.js";import{createDevelopmentRuntimeArtifactRefresher}from"#services/dev-client.js";async function delayMs(e){await new Promise(t=>{setTimeout(t,e).unref?.()})}function authIssueForStatus(e){if(e===`logged-out`)return LOGIN_SETUP_ISSUE;if(e===`cli-missing`)return CLI_MISSING_SETUP_ISSUE}var EveTUIRunner=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m;#h;#g;#_;#v;#y=!1;#b;#x;#S;#C;#w;#T;#E;#D;#O=!1;#k=new AbortController;#A=!1;#j=[];#M;#N;#P;#F;#I;#L=new Map;#R;#z=[];#B;#V=!1;#H;#U=new Map;#W=new Set;#G;#K;#q;constructor(e){this.#e=e.session,e.client!==void 0&&(this.#t=e.client),e.lifecycle!==void 0&&(this.#q=e.lifecycle),this.#n=createRenderer(e);let t={formatActionResultError};if(this.#t!==void 0&&(t.client=this.#t),this.#n.subagents!==void 0&&(t.view=this.#n.subagents),e.appRoot!==void 0&&(t.onToolCompleted=async(e,t)=>{let n=registryHandoffAddress(e,t);n!==void 0&&this.#ce(n)}),this.#H=new SubagentPump(t),this.#r=e.name??`eve`,this.#F=e.startup?.headerTip??pickAgentHeaderTip(),this.#S=e.withExclusiveTerminal,this.#i=e.tools??`full`,this.#a=e.reasoning??`full`,this.#o=e.subagents??`full`,this.#s=e.connectionAuth??`full`,this.#c=e.assistantResponseStats??`tokensPerSecond`,this.#l=e.contextSize,this.#u=e.formatTransportError??toErrorMessage,e.initialInput!==void 0&&(this.#m=e.initialInput),e.startup!==void 0&&(this.#h=e.startup),this.#g=e.onboard===!0,this.#_=e.onOnboardingStep,this.#v=e.onOnboardingTerminal,e.appRoot!==void 0){this.#p=e.appRoot;let t={appRoot:e.appRoot,onChange:e=>this.#n.setVercelStatus?.(e)};e.detectProjectIdentity!==void 0&&(t.detectIdentity=e.detectProjectIdentity),this.#N=createVercelStatusTracker(t),e.probeMcpConnection!==void 0&&(this.#P=createMcpConnectionStatusTracker({onChange:()=>{},probe:e.probeMcpConnection}))}if(e.promptCommandHandler!==void 0&&(this.#b=e.promptCommandHandler),this.#x=e.availablePromptCommands??PROMPT_COMMANDS,e.remote!==void 0){if(this.#t===void 0)throw Error(`A remote TUI requires a configured development client.`);this.#C=createRemoteConnectionController({client:this.#t,credentials:e.remote.credentials,target:e.remote.target,onChange:e=>this.#n.setRemoteConnectionStatus?.(e),resolveOidcToken:e.remote.resolveOidcToken,resolveDeployment:e.remote.resolveDeployment})}this.#w=e.bootDetections??BOOT_DETECTIONS,this.#T=e.getVercelAuthStatus??getVercelAuthStatus,this.#E=e.inspectApplication??inspectApplication,e.onBootProgress!==void 0&&(this.#D=e.onBootProgress),e.serverUrl!==void 0&&(this.#f=e.serverUrl),e.serverUrl!==void 0&&e.remote===void 0&&(this.#d=createDevelopmentRuntimeArtifactRefresher({serverUrl:e.serverUrl}))}async#J(){if(this.#f===void 0)return this.#X(),this.#g||await this.#ue(void 0),this.#h?.finish()??this.#m;let e;if(this.#C!==void 0){let t=await this.#C.check();t.state===`ready`&&(e=t.info)}else{let t=this.#t;if(t!==void 0)try{let n=await devBootPhase(`connecting to agent`,()=>probeAgentInfo({client:t}),this.#D);n.kind===`ready`&&(e=n.info)}catch{e=void 0}}let t=this.#h?.finish()??this.#m;this.#X();let n=this.#Y(e);return this.#g||await this.#ue(n),t}#Y(e){let t=this.#p===void 0?e:normalizeLocalModelEndpoint(e,process.env);this.#I=t;let n=this.#f;if(n===void 0||this.#y)return t;let r={name:this.#r,serverUrl:n};return t!==void 0&&(r.info=t),this.#p!==void 0&&(r.tip=this.#F),this.#n.renderAgentHeader?.(r),t}#X(){let e=this.#D;this.#D=void 0,e?.({type:`before-first-paint`})}async run(){let onStop=()=>this.#n.requestInterrupt?.();this.#q?.signal.aborted===!0?onStop():this.#q?.signal.addEventListener(`abort`,onStop,{once:!0});try{await this.#Z()}finally{this.#q?.signal.removeEventListener(`abort`,onStop),this.#O=!0,this.#k.abort(),this.#H.abortAll(),this.#K?.(),this.#K=void 0,this.#n.shutdown?.(),this.#N?.dispose(),this.#P?.dispose(),this.#C?.dispose()}}async#Z(){let e=this.#r,t,n,r=!1,i=!1,a=!1,o=await this.#J();if(this.#C?.current().connection.state===`auth-required`&&await this.#ye({type:`extension`,name:`vc:login`,argument:``},e,{trigger:`startup`}),this.#me(),this.#N?.refreshIdentity(),this.#P?.refresh(),this.#g&&this.#p!==void 0&&this.#b!==void 0&&this.#n.setupFlow!==void 0){o=void 0,this.#y=!0;try{await this.#xe(e)}finally{this.#y=!1}}for(;;){if(this.#q?.signal.aborted===!0||this.#n.exitRequested?.()===!0)return;let s=this.#z[0];if(s!==void 0&&n===void 0&&this.#R===void 0){this.#z.shift(),this.#B=s;try{await this.#le(s)}finally{this.#B=void 0}i=!1,a=!1,t=void 0;continue}if(!a){if(t==null){if(!this.#n.readPrompt){if(r)return;throw Error(`No prompt was provided and the renderer does not support prompt input.`)}let n={title:e};o!==void 0&&(n.initialDraft=o,o=void 0);try{this.#V=!0,t=await this.#ne(n)}catch(e){if(isInterruptedError(e)){if(this.#R===void 0&&this.#z.length===0)return;a=!0,t=``}else throw e}finally{this.#V=!1}if(this.#z.length>0&&this.#R===void 0){t=void 0;continue}if(t==null&&this.#R===void 0)return}let s=this.#R===void 0?parsePromptCommand(t):null;if(s?.type===`exit`){this.#q?.requestStop();return}if(s?.type===`cancel`){if(this.#e===void 0){this.#he(`No active turn to cancel.`),n=void 0,i=!1,a=!1,t=void 0;continue}try{let e=await this.#e.cancel();if(this.#he(e.status===`accepted`?`Turn cancellation requested.`:`No active turn to cancel.`),e.status===`no_active_turn`){n=void 0,i=!1,a=!1,t=void 0;continue}}catch(e){this.#he(`Couldn't cancel the turn: ${toErrorMessage(e)}`),n=void 0,i=!1,a=!1,t=void 0;continue}n=void 0,i=!0,a=!1,t=void 0}if(s?.type===`reset`){if(!await this.#ee()){n=void 0,a=!1,t=void 0;continue}n=void 0,a=!1,t=void 0;continue}if(s?.type===`compact`){if(this.#e===void 0){this.#he(`No active session to compact.`),n=void 0,i=!1,a=!1,t=void 0;continue}try{let e=await this.#e.compact();if(this.#he(e.status===`accepted`?`Compaction requested.`:`No active session to compact.`),e.status===`no_active_session`){n=void 0,i=!1,a=!1,t=void 0;continue}}catch(e){this.#he(`Couldn't compact the session: ${toErrorMessage(e)}`),n=void 0,i=!1,a=!1,t=void 0;continue}n=void 0,i=!0,a=!1,t=void 0}if(s?.type===`clear`){if(this.#e===void 0){this.#he(`No active session to clear.`),n=void 0,i=!1,a=!1,t=void 0;continue}try{let e=await this.#e.clear();if(this.#he(e.status===`accepted`?`Context clear requested.`:`No active session to clear.`),e.status===`no_active_session`){n=void 0,i=!1,a=!1,t=void 0;continue}}catch(e){this.#he(`Couldn't clear the session: ${toErrorMessage(e)}`),n=void 0,i=!1,a=!1,t=void 0;continue}n=void 0,i=!0,a=!1,t=void 0}if(s?.type===`help`){this.#he(formatPromptCommandHelp(this.#x)),n=void 0,a=!1,t=void 0;continue}if(s?.type===`info`){await this.#we(),n=void 0,a=!1,t=void 0;continue}if(s?.type===`loglevel`){this.#he(this.#Te(s.argument)),n=void 0,a=!1,t=void 0;continue}if(s?.type===`traces`){await this.#Ce(s.argument),n=void 0,a=!1,t=void 0;continue}if(s?.type===`extension`){try{await this.#ye(s,e,{trigger:`command`})}catch(e){if(isInterruptedError(e))return;throw e}n=void 0,t=void 0,a=!1;continue}r=!0}let c=this.#R;this.#R=void 0;let l=c??(i?this.#oe():await(async()=>(this.#$(),await this.#ie({prompt:a?void 0:t,inputResponses:n})))()),u=this.#e?.state.sessionId;u!==void 0&&this.#n.setSessionId?.(u);let d=t,f=!1;try{for(;;){await this.#n.renderStream(l,{title:e,submittedPrompt:d,continueSession:!!this.#n.readPrompt,tools:this.#i,reasoning:this.#a,subagents:this.#o,connectionAuth:this.#s,assistantResponseStats:this.#c,contextSize:this.#l});let r=l.turnState?.pendingApprovals??[],i=l.turnState?.pendingQuestions??[];if(r.length>0||i.length>0){let o=[];if(r.length>0){if(!this.#n.readToolApproval)throw Error(`Tool approval was requested, but the renderer does not support tool approval input.`);for(let t of r){let n=await this.#n.readToolApproval(t,{title:e});o.push({requestId:t.approvalId,optionId:n.approved?`approve`:`cancel`}),this.#L.delete(t.approvalId)}}if(i.length>0){if(!this.#n.readInputQuestion)throw Error(`An interactive question was requested, but the renderer does not support input questions.`);for(let t of i){let n=toAgentTUIInputQuestion(t),r=await this.#n.readInputQuestion(n,{title:e});if(r===void 0)continue;let i={requestId:t.requestId};r.optionId!==void 0&&(i.optionId=r.optionId),r.text!==void 0&&(i.text=r.text),o.push(i),this.#L.delete(t.requestId)}}if(o.length===0)break;a=!0,n=o,t=void 0,f=!0;break}if(this.#Ae(l)){l=this.#oe(),d=void 0;continue}if(l.turnState&&l.turnState.boundaryEvent===void 0&&!l.turnState.aborted){let e=this.#e?.state.sessionId;this.#n.renderNotice?.(e?`Lost the event stream — the turn may still be running on the server (session ${e}). Your next message resumes this session; use /cancel to stop the turn.`:`Lost the connection to the running turn.`)}break}}catch(e){if(isInterruptedError(e))return;throw e}if(f)continue;i=!1,a=!1,n=void 0,t=void 0;let p=l.turnState?.boundaryEvent;this.#G!==this.#e&&(p===`session.waiting`||p===`session.completed`)&&(t=this.#n.takeQueuedPrompt?.()),this.#$(l.turnState?.aborted===!0)}}#Q(){this.#H.abortAll(),this.#L.clear(),this.#U.clear(),this.#W.clear(),this.#n.setConnectionAuthPendingCount?.(0),this.#e=void 0,this.#d?.clear()}#$(e=!1){let t=this.#G;t!==void 0&&(this.#G=void 0,this.#e===t&&(this.#Q(),e?this.#n.renderNotice?.(`Stopped following the turn and started a new session. Earlier context was cleared; the interrupted turn may still be running on the server.`):this.#n.renderSessionBoundary===void 0?this.#n.renderNotice?.(`Session ended — started a new session. Earlier context was cleared.`):this.#n.renderSessionBoundary()))}async#ee(){if(this.#e===void 0)return this.#Q(),this.#n.reset?.(),!0;try{await this.#e.reset()}catch(e){return this.#n.renderNotice?.(`Couldn't reset the session: ${toErrorMessage(e)}`),!1}return this.#Q(),this.#n.reset?.(),!0}async#te(e){if(!this.#n.readPrompt)return;let t=this.#n.readPrompt(e),n=this.#d;if(n===void 0)return await t;let r=!1,i=!1,a,o=0,refresh=async()=>{if(!(r||i)){i=!0;try{await n.refreshIdle({onRuntimeArtifactsChanged:()=>this.#Oe()});let e=this.#I?.agent.model.endpoint,t=e?.kind===`chatgpt`&&(e.state===`signed-out`||e.state===`reauth-required`),r=Date.now();if(t&&r-o>=5e3){o=r;let e=await this.#De();e!==void 0&&this.#Y(e)}}finally{i=!1}}},startRefresh=()=>{if(r||i)return;let e=refresh().finally(()=>{a===e&&(a=void 0)});a=e};startRefresh();let s=setInterval(()=>{startRefresh()},500);s.unref?.();try{return await t}finally{r=!0,clearInterval(s),await a}}async#ne(e){let t=this.#te(e);if(this.#n.renderIdleStream===void 0||this.#e?.state.sessionId===void 0)return await t;let n=new AbortController,r=this.#re(n.signal,e).catch(e=>{n.signal.aborted||this.#n.renderNotice?.(`Stopped following session updates: ${toErrorMessage(e)}`)});try{return await t}finally{n.abort(),await r}}async#re(e,t){let n=this.#e;if(n===void 0)return;let r=n.stream({signal:e})[Symbol.asyncIterator]();try{for(;!e.aborted;){let i=!1,a={async*[Symbol.asyncIterator](){for(;!e.aborted;){let e=await r.next();if(e.done===!0||(i=!0,yield e.value,isCurrentTurnBoundaryEvent(e.value)))return}}},o=this.#se(a,()=>{},n);if(await this.#n.renderIdleStream(o,{...t,continueSession:!0}),this.#Ae(o),(o.turnState?.pendingApprovals.length??0)>0||(o.turnState?.pendingQuestions.length??0)>0){this.#R={events:(async function*(){})(),turnState:o.turnState},this.#n.suspendPromptForInput?.();return}if(!i)return}}finally{await r.return?.()}}async#ie(e){let t=new AbortController,n={signal:t.signal};e.prompt!==void 0&&(n.message=e.prompt),e.inputResponses!==void 0&&e.inputResponses.length>0&&(n.inputResponses=e.inputResponses);let r,i=this.#e;try{if(this.#d!==void 0&&await this.#d.refresh({inputResponses:n.inputResponses,message:n.message,onRuntimeArtifactsChanged:()=>this.#Oe()}),n.message!==void 0&&(n.inputResponses?.length??0)===0&&this.#n.flushDelayedDevBuildErrors?.(),this.#e===void 0){if(this.#t===void 0)throw Error(`Cannot create a session without an eve client.`);if(n.message===void 0)throw Error(`Cannot answer an input request before the session starts.`);let e=await this.#t.sessions.create({...n,message:n.message});this.#e=e.session,r=e.response}else r=n.inputResponses===void 0?await this.#e.send(n.message,{signal:n.signal,turnPolicy:`queue`}):await this.#e.respond(n.inputResponses,{signal:n.signal})}catch(e){if(isInterruptedError(e))throw e;return this.#C?.reportFailure(e),this.#G=i,{events:errorOnlyTUIStream({errorText:this.#u(e)}),turnState:createTurnState()}}return this.#se(r,()=>t.abort(),this.#e)}async#ae(e,t){if(e.cancelInFlight!==!0){e.cancelInFlight=!0;try{for(let n=0;n<8;n+=1){if(e.boundaryEvent!==void 0||e.aborted===!0)return;let n=e.turnId;try{if((await t?.cancel(n===void 0?void 0:{turnId:n}))?.status===`accepted`)return}catch{}await delayMs(250)}}finally{e.cancelInFlight=!1}}}#oe(){if(this.#e===void 0)throw Error(`Cannot stream a session before its first turn is accepted.`);let e=new AbortController,t=this.#e;return this.#se(t.stream({signal:e.signal}),()=>e.abort(),t)}#se(e,t,n){let r=createTurnState();return{abort:()=>{r.aborted=!0,this.#G=n,t()},cancel:()=>{this.#ae(r,n)},events:eveEventsToTUIStream({events:e,pendingInputRequests:this.#L,turnState:r,onSubagentCalled:e=>this.#H.begin(e),onSubagentBackgrounded:e=>this.#H.background(e),onSubagentCompleted:e=>this.#H.settle(e),onTurnCancelled:e=>this.#H.settleCancelledTurn(e),onConnectionAuthRequired:e=>this.#ke(e),onConnectionAuthCompleted:e=>this.#je(e),onRegistryHandoff:this.#p===void 0?void 0:async e=>this.#ce(e),onTerminalFailure:()=>{this.#G=n},failureHintOverride:this.#p===void 0?void 0:localFailureHint}),turnState:r}}#ce(e){this.#B===e||this.#z.includes(e)||(this.#z.push(e),this.#V&&this.#n.suspendPromptForInput?.())}async#le(e){await this.#ye({type:`extension`,name:`add`,argument:e},`Add to your agent`,{trigger:`command`})}async#ue(e){if(this.#p===void 0)return;let t={appRoot:this.#p,env:process.env};e!==void 0&&(t.info=e),this.#j=await detectSetupIssues(t,this.#w),this.#n.renderSetupWarning!==void 0&&(this.#de(),this.#fe())}#de(){let e=orderedSetupIssues(this.#j,this.#M);e.length>0?this.#n.renderSetupWarning?.(formatSetupIssuesLine(e)):this.#n.clearSetupWarning?.()}async#fe(){let e=this.#p;if(e===void 0)return;let t;try{t=await this.#T(e,{signal:this.#k.signal})}catch{return}this.#O||this.#A||(this.#M=authIssueForStatus(t),this.#de())}async#pe(e){let t=this.#p;if(t===void 0||this.#n.renderSetupWarning===void 0)return;let n={appRoot:t,env:process.env};e!==void 0&&(n.info=e);try{this.#j=await detectSetupIssues(n,this.#w);let e=await this.#T(t,{signal:this.#k.signal});this.#M=authIssueForStatus(e)}catch{return}this.#O||this.#de()}#me(){this.#p!==void 0&&this.#n.renderSandboxLog!==void 0&&this.#K===void 0&&(this.#K=subscribeDevelopmentSandboxPrewarmLogs({appRoot:this.#p,log:e=>this.#n.renderSandboxLog?.(e)}))}#he(e,t){if(e!==void 0){if(this.#n.renderCommandResult!==void 0){this.#n.renderCommandResult(e,t);return}this.#n.renderNotice?.(e)}}async#ge(e,t){let n=this.#b;if(n===void 0)return{message:`/${e.name} is not available in this session.`};let r=this.#I?.agent.model.endpoint,i={...t,renderer:this.#n,chatGptAccountLabel:r?.kind===`chatgpt`&&r.state===`ready`?r.accountLabel:void 0,remoteConnection:this.#C,withExclusiveTerminal:this.#S},a=this.#P?.current(),o=a!==void 0&&Object.keys(a).length>0?{...i,disabledConnectionReasons:a}:i;return t.keepSetupFlowOpen===!0?await n.handle(e,{...o,keepSetupFlowOpen:!0}):await n.handle(e,o)}#_e(e,t,n){if(t!==`startup`)return;let r=this.#C?.current().connection.state,i=n===`error`||r===`auth-failed`||r===`unavailable`?`failed`:void 0,a=e.argument.length===0?``:` ${e.argument}`;this.#n.renderCommandInvocation?.(`/${e.name}${a}`,i)}async#ve(e){if(e?.kind===`model-access-changed`){this.#N?.applyEffect({kind:`refresh-identity`}),this.#A=!0,await this.#Ee();return}e!==void 0&&(this.#N?.applyEffect(e),this.#A=!0,this.#pe(this.#I))}async#ye(e,t,n){let r=await this.#ge(e,{...n,title:t}),i=n.suppressSuccessfulTranscript===!0&&r?.tone!==`error`||n.suppressCancelledTranscript===!0&&r?.cancelled===!0;return i||this.#_e(e,n.trigger,r?.tone),i||this.#he(r?.message,r?.tone),await this.#ve(r?.effect),this.#Se(),r}#be(e){return{kind:`planner`,activeStep:e,firstNavigableStep:1,steps:[{label:`Model`,complete:e>0},{label:`Channels`},{label:`Integrations`},{label:`Review`}]}}async#xe(e){let t={keepSetupFlowOpen:!0,setupFlowTitle:`Set up ${e}`,trigger:`startup`},n=`model_provider`,onOnboardingScreen=e=>{n=e.screen,this.#_?.({flow:`onboarding`,step:e.screen,registrySelectedCount:e.registrySelectedCount})};onOnboardingScreen({screen:`model_provider`});let r;try{r=await this.#ye({type:`extension`,name:`model`,argument:``},e,{...t,suppressSuccessfulTranscript:!0,initialModelStep:`provider`,setupFlowNavigation:this.#be(0),onOnboardingScreen})}catch(e){throw this.#v?.({flow:`onboarding`,step:n,result:`error`}),e}if(r?.tone===`error`||r?.cancelled===!0){this.#v?.({flow:`onboarding`,step:n,result:r.cancelled===!0?`cancelled`:`error`}),this.#n.setupFlow?.end({preserveDiagnostics:r.tone===`error`});return}let i;n=`registry_channels`;let onRegistryScreen=e=>{n=e.screen,this.#_?.({flow:`onboarding`,step:e.screen,registrySelectedCount:e.registrySelectedCount})};try{onRegistryScreen({screen:`registry_channels`}),i=await this.#ye({type:`extension`,name:`add`,argument:``},e,{...t,onOnboardingScreen:onRegistryScreen,registryPlannerContext:{prefixSteps:[{label:`Model`,complete:!0}],reviewMessage:`Review your agent`,primaryActionLabel:`Install and finish setup`,emptyActionLabel:`Finish setup`}})}catch(e){throw this.#v?.({flow:`onboarding`,step:n,result:`error`}),e}finally{i!==void 0&&this.#v?.({flow:`onboarding`,step:n,result:i.cancelled===!0?`cancelled`:i.tone===`error`?`error`:`completed`}),this.#n.setupFlow?.end({preserveDiagnostics:i?.tone===`error`})}}#Se(){if(this.#y)return;let e=this.#C?.current().connection;e?.state===`ready`&&e.info!==this.#I&&(this.#I=e.info,this.#f!==void 0&&this.#n.renderAgentHeader?.({info:e.info,name:this.#r,serverUrl:this.#f}))}async#Ce(e){if(this.#p===void 0||this.#n.traceViewer===void 0){this.#he(`/traces is only available in local dev sessions.`);return}try{await this.#n.traceViewer.open({appRoot:this.#p,sessionId:this.#e?.state.sessionId,reference:e===``?void 0:e})}catch(e){if(isInterruptedError(e))return;throw e}}async#we(){let e=this.#p;if(e===void 0){this.#he(`/info is only available in local dev sessions.`);return}try{this.#he(renderApplicationInfo(await this.#E(e)))}catch(e){this.#he(`Couldn't inspect the application: ${toErrorMessage(e)}`,`error`)}}#Te(e){let t=this.#n;if(t.logDisplayMode===void 0||t.setLogDisplayMode===void 0)return`/loglevel is not available in this session.`;if(e===``)return`Logs: ${t.logDisplayMode()}. Use /loglevel all|stderr|sandbox|none — logs stay buffered, so switching also hides or restores past lines.`;let n=parseLogDisplayMode(e);if(n===void 0)return`Unknown log level "${e}". Use all, stderr, sandbox, or none.`;if(n===t.logDisplayMode())return`Logs already set to ${n}.`;switch(t.setLogDisplayMode(n),n){case`none`:return`Logs hidden. Output stays buffered — /loglevel all restores it.`;case`stderr`:return`Showing stderr logs only.`;case`sandbox`:return`Showing sandbox logs only.`;case`all`:return`Showing all logs.`}}async#Ee(){let e=this.#p;if(e===void 0)return;await loadDevelopmentEnvironmentFiles(e),await this.#d?.refreshAfterSourceChange({});let t=this.#Y(await this.#De());this.#pe(t)}async#De(){let e=this.#t;if(e===void 0)return;let t=await probeAgentInfo({client:e});return t.kind===`ready`?t.info:void 0}async#Oe(){let e=this.#I,t=await this.#De();t!==void 0&&this.#Y(t),(!this.#n.renderAgentHeader||t===void 0)&&this.#n.renderNotice?.(formatAgentUpdateNotice(e,t))}#ke(e){let t={name:e.data.name,description:e.data.description,state:`required`};e.data.authorization!==void 0&&(t.challenge=e.data.authorization),e.data.webhookUrl!==void 0&&(t.webhookUrl=e.data.webhookUrl),this.#U.set(e.data.name,t),this.#Me(t)}#Ae(e){if(e.turnState?.boundaryEvent!==`session.waiting`)return!1;let t=!1;for(let e of this.#U.values())e.state===`required`&&e.webhookUrl!==void 0&&(e.state=`pending`,this.#W.add(e.name),this.#Me(e),t=!0);return t&&this.#n.setConnectionAuthPendingCount?.(this.#W.size),this.#W.size>0}#je(e){let t=this.#U.get(e.data.name)??{name:e.data.name,description:``,state:e.data.outcome};t.state=e.data.outcome,e.data.reason!==void 0&&(t.reason=e.data.reason),this.#U.set(e.data.name,t),this.#W.delete(e.data.name),this.#Me(t),this.#n.setConnectionAuthPendingCount?.(this.#W.size)}#Me(e){let t={name:e.name,description:e.description,state:e.state};e.challenge!==void 0&&(t.challenge=e.challenge),e.reason!==void 0&&(t.reason=e.reason),this.#n.upsertConnectionAuth?.(t)}};function createRenderer(e){return e.renderer?e.renderer:new TerminalRenderer({tools:e.tools,reasoning:e.reasoning,subagents:e.subagents,connectionAuth:e.connectionAuth,assistantResponseStats:e.assistantResponseStats,contextSize:e.contextSize,logs:e.logs,availablePromptCommands:e.availablePromptCommands,input:e.userInput,output:e.screen,diagnostics:e.diagnostics,onExitRequest:e.lifecycle?.requestStop})}function formatAgentUpdateNotice(e,t){let n=e?.agent.model.id,r=t?.agent.model.id;return n!==void 0&&r!==void 0&&n!==r?`Agent updated: Model ${n} -> ${r}`:`Agent updated.`}function registryHandoffAddress(e,t){if(e!==`selfmod__registry_add`||typeof t!=`object`||!t)return;let n=t;return n.status===`needs-terminal`&&typeof n.address==`string`?n.address:void 0}async function*eveEventsToTUIStream(e){let{events:t,pendingInputRequests:n,turnState:r,onSubagentCalled:i,onSubagentBackgrounded:a,onSubagentCompleted:o,onTurnCancelled:s,onConnectionAuthRequired:c,onConnectionAuthCompleted:l,onRegistryHandoff:u,onTerminalFailure:d,failureHintOverride:f}=e,p=new Map,m=new Map,h=new Map,g=createEventDeduper(),_=0,v=new Set,y=new Set,b=new Set,x=!1,S=!1,C;for await(let e of t)if(g.admit(e)&&!(S&&isPostTurnVisibleEvent(e)))switch(e.type){case`session.started`:case`message.received`:break;case`turn.started`:r.turnId=e.data.turnId;break;case`step.started`:_+=1,yield{type:`step-start`};break;case`step.completed`:{let t=e;C=t.data.usage,yield*closeOpenParts(p,`assistant-complete`,_),yield*closeOpenParts(m,`reasoning-complete`,_),yield{type:`step-finish`,usage:t.data.usage};break}case`message.appended`:{let t=e,n=textPartId(t.data.turnId,t.data.stepIndex),r=partStateFor(p,n);if(r.completed){if(_<=r.completedEpoch)break;r.generation+=1,r.text=``,r.completed=!1}let i=t.data.messageDelta;if(i.length===0)break;r.text+=i,yield{type:`assistant-delta`,id:partGenerationId(n,r.generation),delta:i};break}case`message.completed`:{let t=textPartId(e.data.turnId,e.data.stepIndex),n=partStateFor(p,t),r=e.data.message;if(n.completed){if(r===null||_<=n.completedEpoch)break;n.generation+=1,n.text=r,n.completedEpoch=_,yield{type:`assistant-complete`,id:partGenerationId(t,n.generation),text:r};break}let i=partGenerationId(t,n.generation);if(r!==null){if(n.text.length===0)n.text=r,n.completed=!0,n.completedEpoch=_,yield{type:`assistant-complete`,id:i,text:r};else if(r.startsWith(n.text)){let e=r.slice(n.text.length);e.length>0&&(yield{type:`assistant-delta`,id:i,delta:e}),n.text=r,n.completed=!0,n.completedEpoch=_,yield{type:`assistant-complete`,id:i}}else n.text=r,n.completed=!0,n.completedEpoch=_,yield{type:`assistant-complete`,id:i,text:r}}else n.text.length>0&&(n.completed=!0,n.completedEpoch=_,yield{type:`assistant-complete`,id:i});break}case`reasoning.appended`:{let t=e,n=reasoningPartId(t.data.turnId,t.data.stepIndex),r=partStateFor(m,n);if(r.completed){if(_<=r.completedEpoch)break;r.generation+=1,r.text=``,r.completed=!1}let i=t.data.reasoningDelta;if(i.length===0)break;r.text+=i,yield{type:`reasoning-delta`,id:partGenerationId(n,r.generation),delta:i};break}case`reasoning.completed`:{let t=reasoningPartId(e.data.turnId,e.data.stepIndex),n=partStateFor(m,t),r=e.data.reasoning;if(n.completed){if(r.length===0||_<=n.completedEpoch)break;n.generation+=1,n.text=r,n.completedEpoch=_;let e=partGenerationId(t,n.generation);yield{type:`reasoning-delta`,id:e,delta:r},yield{type:`reasoning-complete`,id:e};break}let i=partGenerationId(t,n.generation);if(n.text.length===0&&r.length>0)n.text=r,yield{type:`reasoning-delta`,id:i,delta:r};else if(r.length>0&&!r.startsWith(n.text)){yield{type:`reasoning-complete`,id:i},n.generation+=1,n.text=r,n.completed=!0,n.completedEpoch=_;let e=partGenerationId(t,n.generation);yield{type:`reasoning-delta`,id:e,delta:r},yield{type:`reasoning-complete`,id:e};break}n.completed=!0,n.completedEpoch=_,yield{type:`reasoning-complete`,id:i};break}case`actions.requested`:{let t=e.data.actions.filter(e=>e.kind===`tool-call`);if(t.length===0)break;for(let e of t)h.set(e.callId,e.toolName),!v.has(e.callId)&&(v.add(e.callId),yield{type:`tool-call`,toolCallId:e.callId,toolName:e.toolName,input:e.input});break}case`input.requested`:{let t=e.data.requests.filter(e=>e.action.kind===`tool-call`);if(t.length===0)break;for(let e of t){let t=e.action.callId;if(h.set(t,e.action.toolName),e.kind!==`session-limit`&&!v.has(t)&&(v.add(t),yield{type:`tool-call`,toolCallId:t,toolName:e.action.toolName,input:e.action.input}),!y.has(e.requestId)){if(y.add(e.requestId),n.set(e.requestId,e),e.kind!==`tool-approval`){upsertPendingQuestion(r,e);continue}upsertPendingApproval(r,e),yield{type:`tool-approval-request`,approvalId:e.requestId,toolCallId:t}}}break}case`action.result`:{let t=e;if(t.data.result.kind!==`tool-result`)break;let n=t.data.result.callId;if(!v.has(n))break;switch(t.data.status){case`completed`:{let e=t.data.result.output;yield{type:`tool-result`,toolCallId:n,output:e};let r=registryHandoffAddress(h.get(n),e);r!==void 0&&await u?.(r);break}case`failed`:yield{type:`tool-error`,toolCallId:n,errorText:formatActionResultError(t)};break;case`rejected`:yield{type:`tool-rejected`,toolCallId:n,reason:formatActionResultError(t)}}break}case`step.failed`:case`turn.failed`:{let t=toFailureEvent(e,b,f);t&&(yield t);break}case`session.failed`:{r.sawSessionFailure=!0,d?.(e);let t=toFailureEvent(e,b,f);t&&(yield t),r.boundaryEvent=e.type,yield*closeOpenParts(p,`assistant-complete`,_),yield*closeOpenParts(m,`reasoning-complete`,_),yield{type:`finish`,usage:C},x=!0;return}case`session.waiting`:case`session.completed`:r.boundaryEvent=e.type,yield*closeOpenParts(p,`assistant-complete`,_),yield*closeOpenParts(m,`reasoning-complete`,_),yield{type:`finish`,usage:C},x=!0;return;case`turn.completed`:S=!0,yield*closeOpenParts(p,`assistant-complete`,_),yield*closeOpenParts(m,`reasoning-complete`,_);break;case`turn.cancelled`:s?.(e.data.turnId),yield*closeOpenParts(p,`assistant-complete`,_),yield*closeOpenParts(m,`reasoning-complete`,_),yield{type:`turn-cancelled`};break;case`subagent.called`:i?.(e);break;case`subagent.started`:case`subagent.event`:break;case`subagent.completed`:{let t=e;t.data.backgroundTask===void 0?o?.(t.data.callId):a?.(t.data.callId);break}case`authorization.required`:c?.(e);break;case`authorization.completed`:l?.(e)}x||(yield*closeOpenParts(p,`assistant-complete`,_),yield*closeOpenParts(m,`reasoning-complete`,_),yield{type:`finish`,usage:C})}async function*errorOnlyTUIStream(e){yield{type:`error`,errorText:e.errorText},yield{type:`finish`}}function createTurnState(){return{aborted:!1,pendingApprovals:[],pendingQuestions:[],sawSessionFailure:!1}}function upsertPendingApproval(e,t){let n=toAgentTUIToolApprovalRequest(t),r=e.pendingApprovals.findIndex(e=>e.approvalId===n.approvalId);r===-1?e.pendingApprovals.push(n):e.pendingApprovals[r]=n}function toAgentTUIToolApprovalRequest(e){return{approvalId:e.requestId,toolCallId:e.action.callId,toolName:e.action.toolName,input:e.action.input}}function upsertPendingQuestion(e,t){let n=e.pendingQuestions.findIndex(e=>e.requestId===t.requestId);n===-1?e.pendingQuestions.push(t):e.pendingQuestions[n]=t}function textPartId(e,t){return`text:${e}:${t}`}function reasoningPartId(e,t){return`reasoning:${e}:${t}`}function partStateFor(e,t){let n=e.get(t);return n===void 0&&(n={generation:0,text:``,completed:!1,completedEpoch:0},e.set(t,n)),n}function partGenerationId(e,t){return t===0?e:`${e}#${t}`}function*closeOpenParts(e,t,n){for(let[r,i]of e)i.completed||i.text.length===0||(i.completed=!0,i.completedEpoch=n,yield{type:t,id:partGenerationId(r,i.generation)})}function isPostTurnVisibleEvent(e){switch(e.type){case`actions.requested`:case`authorization.completed`:case`authorization.required`:case`input.requested`:case`message.appended`:case`message.completed`:case`reasoning.appended`:case`reasoning.completed`:case`result.completed`:case`step.completed`:case`step.failed`:case`step.started`:case`subagent.called`:case`subagent.completed`:case`subagent.event`:case`subagent.started`:case`turn.completed`:case`turn.failed`:return!0;default:return!1}}function formatActionResultError(e){if(e.data.error?.message)return e.data.error.message;let t=e.data.result.output;if(typeof t==`string`)return t;try{return JSON.stringify(t)}catch{return`Tool execution failed.`}}function toFailureEvent(e,t,n){let r=failureKey(e);if(t.has(r))return;t.add(r);let i={type:`error`,errorText:formatFailureMessage(e)},a=n?.(e)??formatFailureHint(e);a!==void 0&&(i.hint=a);let o=formatFailureDetail(e);return o!==void 0&&(i.detail=o),i}function toAgentTUIInputQuestion(e){let t=e.display===`text`?`text`:e.display===`select`||e.options!==void 0&&e.options.length>0?`select`:`text`,n={requestId:e.requestId,prompt:e.prompt,display:t};return e.options!==void 0&&(n.options=e.options.map(e=>{let t={id:e.id,label:e.label};return e.description!==void 0&&(t.description=e.description),e.style!==void 0&&(t.style=e.style),t})),e.allowFreeform!==void 0&&(n.allowFreeform=e.allowFreeform),n}export{EveTUIRunner,parsePromptCommand,registryHandoffAddress};
|
|
1
|
+
import{PROMPT_COMMANDS,formatPromptCommandHelp,parsePromptCommand}from"./prompt-commands.js";import{pickAgentHeaderTip}from"./agent-header.js";import{failureKey,formatFailureDetail,formatFailureHint,formatFailureMessage,isInterruptedError,localFailureHint}from"./errors.js";import{parseLogDisplayMode}from"./log-display-mode.js";import{createMcpConnectionStatusTracker}from"./mcp-connection-status.js";import{createRemoteConnectionController}from"./remote-connection.js";import{SubagentPump}from"./subagent-pump.js";import{BOOT_DETECTIONS,CLI_MISSING_SETUP_ISSUE,LOGIN_SETUP_ISSUE,detectSetupIssues,formatSetupIssuesLine,normalizeLocalModelEndpoint,orderedSetupIssues}from"./setup-issues.js";import{TerminalRenderer}from"./terminal-renderer.js";import{createVercelStatusTracker}from"./vercel-status.js";import"#client/index.js";import{loadDevelopmentEnvironmentFiles}from"#cli/dev/environment.js";import{inspectApplication}from"#services/inspect-application.js";import{devBootPhase}from"#internal/dev-boot-progress.js";import{toErrorMessage}from"#shared/errors.js";import{getVercelAuthStatus}from"#setup/vercel-project.js";import{probeAgentInfo}from"#services/dev-client/agent-info-probe.js";import{renderApplicationInfo}from"#cli/commands/info.js";import{subscribeDevelopmentSandboxPrewarmLogs}from"#execution/sandbox/development-prewarm.js";import{createEventDeduper}from"#protocol/event-dedupe.js";import{isCurrentTurnBoundaryEvent}from"#protocol/message.js";import{createDevelopmentRuntimeArtifactRefresher}from"#services/dev-client.js";async function delayMs(e){await new Promise(t=>{setTimeout(t,e).unref?.()})}async function abortableDelay(e,t){t.aborted||await new Promise(n=>{let r=setTimeout(done,e);r.unref?.(),t.addEventListener(`abort`,done,{once:!0});function done(){clearTimeout(r),t.removeEventListener(`abort`,done),n()}})}function authIssueForStatus(e){if(e===`logged-out`)return LOGIN_SETUP_ISSUE;if(e===`cli-missing`)return CLI_MISSING_SETUP_ISSUE}var EveTUIRunner=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m;#h;#g;#_;#v;#y=!1;#b;#x;#S;#C;#w;#T;#E;#D;#O=!1;#k=new AbortController;#A=!1;#j=[];#M;#N;#P;#F;#I;#L=new Map;#R;#z=[];#B;#V=!1;#H;#U=new Map;#W=new Set;#G;#K;#q;constructor(e){this.#e=e.session,e.client!==void 0&&(this.#t=e.client),e.lifecycle!==void 0&&(this.#q=e.lifecycle),this.#n=createRenderer(e);let t={formatActionResultError};if(this.#t!==void 0&&(t.client=this.#t),this.#n.subagents!==void 0&&(t.view=this.#n.subagents),e.appRoot!==void 0&&(t.onToolCompleted=async(e,t)=>{let n=registryHandoffAddress(e,t);n!==void 0&&this.#ce(n)}),this.#H=new SubagentPump(t),this.#r=e.name??`eve`,this.#F=e.startup?.headerTip??pickAgentHeaderTip(),this.#S=e.withExclusiveTerminal,this.#i=e.tools??`full`,this.#a=e.reasoning??`full`,this.#o=e.subagents??`full`,this.#s=e.connectionAuth??`full`,this.#c=e.assistantResponseStats??`tokensPerSecond`,this.#l=e.contextSize,this.#u=e.formatTransportError??toErrorMessage,e.initialInput!==void 0&&(this.#m=e.initialInput),e.startup!==void 0&&(this.#h=e.startup),this.#g=e.onboard===!0,this.#_=e.onOnboardingStep,this.#v=e.onOnboardingTerminal,e.appRoot!==void 0){this.#p=e.appRoot;let t={appRoot:e.appRoot,onChange:e=>this.#n.setVercelStatus?.(e)};e.detectProjectIdentity!==void 0&&(t.detectIdentity=e.detectProjectIdentity),this.#N=createVercelStatusTracker(t),e.probeMcpConnection!==void 0&&(this.#P=createMcpConnectionStatusTracker({onChange:()=>{},probe:e.probeMcpConnection}))}if(e.promptCommandHandler!==void 0&&(this.#b=e.promptCommandHandler),this.#x=e.availablePromptCommands??PROMPT_COMMANDS,e.remote!==void 0){if(this.#t===void 0)throw Error(`A remote TUI requires a configured development client.`);this.#C=createRemoteConnectionController({client:this.#t,credentials:e.remote.credentials,target:e.remote.target,onChange:e=>this.#n.setRemoteConnectionStatus?.(e),resolveOidcToken:e.remote.resolveOidcToken,resolveDeployment:e.remote.resolveDeployment})}this.#w=e.bootDetections??BOOT_DETECTIONS,this.#T=e.getVercelAuthStatus??getVercelAuthStatus,this.#E=e.inspectApplication??inspectApplication,e.onBootProgress!==void 0&&(this.#D=e.onBootProgress),e.serverUrl!==void 0&&(this.#f=e.serverUrl),e.serverUrl!==void 0&&e.remote===void 0&&(this.#d=createDevelopmentRuntimeArtifactRefresher({serverUrl:e.serverUrl}))}async#J(){if(this.#f===void 0)return this.#X(),this.#g||await this.#ue(void 0),this.#h?.finish()??this.#m;let e;if(this.#C!==void 0){let t=await this.#C.check();t.state===`ready`&&(e=t.info)}else{let t=this.#t;if(t!==void 0)try{let n=await devBootPhase(`connecting to agent`,()=>probeAgentInfo({client:t}),this.#D);n.kind===`ready`&&(e=n.info)}catch{e=void 0}}let t=this.#h?.finish()??this.#m;this.#X();let n=this.#Y(e);return this.#g||await this.#ue(n),t}#Y(e){let t=this.#p===void 0?e:normalizeLocalModelEndpoint(e,process.env);this.#I=t;let n=this.#f;if(n===void 0||this.#y)return t;let r={name:this.#r,serverUrl:n};return t!==void 0&&(r.info=t),this.#p!==void 0&&(r.tip=this.#F),this.#n.renderAgentHeader?.(r),t}#X(){let e=this.#D;this.#D=void 0,e?.({type:`before-first-paint`})}async run(){let onStop=()=>this.#n.requestInterrupt?.();this.#q?.signal.aborted===!0?onStop():this.#q?.signal.addEventListener(`abort`,onStop,{once:!0});try{await this.#Z()}finally{this.#q?.signal.removeEventListener(`abort`,onStop),this.#O=!0,this.#k.abort(),this.#H.abortAll(),this.#K?.(),this.#K=void 0,this.#n.shutdown?.(),this.#N?.dispose(),this.#P?.dispose(),this.#C?.dispose()}}async#Z(){let e=this.#r,t,n,r=!1,i=!1,a=!1,o=await this.#J();if(this.#C?.current().connection.state===`auth-required`&&await this.#ye({type:`extension`,name:`vc:login`,argument:``},e,{trigger:`startup`}),this.#me(),this.#N?.refreshIdentity(),this.#P?.refresh(),this.#g&&this.#p!==void 0&&this.#b!==void 0&&this.#n.setupFlow!==void 0){o=void 0,this.#y=!0;try{await this.#xe(e)}finally{this.#y=!1}}for(;;){if(this.#q?.signal.aborted===!0||this.#n.exitRequested?.()===!0)return;let s=this.#z[0];if(s!==void 0&&n===void 0&&this.#R===void 0){this.#z.shift(),this.#B=s;try{await this.#le(s)}finally{this.#B=void 0}i=!1,a=!1,t=void 0;continue}if(!a){if(t==null){if(!this.#n.readPrompt){if(r)return;throw Error(`No prompt was provided and the renderer does not support prompt input.`)}let n={title:e};o!==void 0&&(n.initialDraft=o,o=void 0);try{this.#V=!0,t=await this.#ne(n)}catch(e){if(isInterruptedError(e)){if(this.#R===void 0&&this.#z.length===0)return;a=!0,t=``}else throw e}finally{this.#V=!1}if(this.#z.length>0&&this.#R===void 0){t=void 0;continue}if(t==null&&this.#R===void 0)return}let s=this.#R===void 0?parsePromptCommand(t):null;if(s?.type===`exit`){this.#q?.requestStop();return}if(s?.type===`cancel`){if(this.#e===void 0){this.#he(`No active turn to cancel.`),n=void 0,i=!1,a=!1,t=void 0;continue}try{let e=await this.#e.cancel();if(this.#he(e.status===`accepted`?`Turn cancellation requested.`:`No active turn to cancel.`),e.status===`no_active_turn`){n=void 0,i=!1,a=!1,t=void 0;continue}}catch(e){this.#he(`Couldn't cancel the turn: ${toErrorMessage(e)}`),n=void 0,i=!1,a=!1,t=void 0;continue}n=void 0,i=!0,a=!1,t=void 0}if(s?.type===`reset`){if(!await this.#ee()){n=void 0,a=!1,t=void 0;continue}n=void 0,a=!1,t=void 0;continue}if(s?.type===`compact`){if(this.#e===void 0){this.#he(`No active session to compact.`),n=void 0,i=!1,a=!1,t=void 0;continue}try{let e=await this.#e.compact();if(this.#he(e.status===`accepted`?`Compaction requested.`:`No active session to compact.`),e.status===`no_active_session`){n=void 0,i=!1,a=!1,t=void 0;continue}}catch(e){this.#he(`Couldn't compact the session: ${toErrorMessage(e)}`),n=void 0,i=!1,a=!1,t=void 0;continue}n=void 0,i=!0,a=!1,t=void 0}if(s?.type===`clear`){if(this.#e===void 0){this.#he(`No active session to clear.`),n=void 0,i=!1,a=!1,t=void 0;continue}try{let e=await this.#e.clear();if(this.#he(e.status===`accepted`?`Context clear requested.`:`No active session to clear.`),e.status===`no_active_session`){n=void 0,i=!1,a=!1,t=void 0;continue}}catch(e){this.#he(`Couldn't clear the session: ${toErrorMessage(e)}`),n=void 0,i=!1,a=!1,t=void 0;continue}n=void 0,i=!0,a=!1,t=void 0}if(s?.type===`help`){this.#he(formatPromptCommandHelp(this.#x)),n=void 0,a=!1,t=void 0;continue}if(s?.type===`info`){await this.#we(),n=void 0,a=!1,t=void 0;continue}if(s?.type===`loglevel`){this.#he(this.#Te(s.argument)),n=void 0,a=!1,t=void 0;continue}if(s?.type===`traces`){await this.#Ce(s.argument),n=void 0,a=!1,t=void 0;continue}if(s?.type===`extension`){try{await this.#ye(s,e,{trigger:`command`})}catch(e){if(isInterruptedError(e))return;throw e}n=void 0,t=void 0,a=!1;continue}r=!0}let c=this.#R;this.#R=void 0;let l=c??(i?this.#oe():await(async()=>(this.#$(),await this.#ie({prompt:a?void 0:t,inputResponses:n})))()),u=this.#e?.state.sessionId;u!==void 0&&this.#n.setSessionId?.(u);let d=t,f=!1;try{for(;;){await this.#n.renderStream(l,{title:e,submittedPrompt:d,continueSession:!!this.#n.readPrompt,tools:this.#i,reasoning:this.#a,subagents:this.#o,connectionAuth:this.#s,assistantResponseStats:this.#c,contextSize:this.#l});let r=l.turnState?.pendingApprovals??[],i=l.turnState?.pendingQuestions??[];if(r.length>0||i.length>0){let o=[];if(r.length>0){if(!this.#n.readToolApproval)throw Error(`Tool approval was requested, but the renderer does not support tool approval input.`);for(let t of r){let n=await this.#n.readToolApproval(t,{title:e});o.push({requestId:t.approvalId,optionId:n.approved?`approve`:`cancel`}),this.#L.delete(t.approvalId)}}if(i.length>0){if(!this.#n.readInputQuestion)throw Error(`An interactive question was requested, but the renderer does not support input questions.`);for(let t of i){let n=toAgentTUIInputQuestion(t),r=await this.#n.readInputQuestion(n,{title:e});if(r===void 0)continue;let i={requestId:t.requestId};r.optionId!==void 0&&(i.optionId=r.optionId),r.text!==void 0&&(i.text=r.text),o.push(i),this.#L.delete(t.requestId)}}if(o.length===0)break;a=!0,n=o,t=void 0,f=!0;break}if(this.#Ae(l)){l=this.#oe(),d=void 0;continue}if(l.turnState&&l.turnState.boundaryEvent===void 0&&!l.turnState.aborted){let e=this.#e?.state.sessionId;this.#n.renderNotice?.(e?`Lost the event stream — the turn may still be running on the server (session ${e}). Your next message resumes this session; use /cancel to stop the turn.`:`Lost the connection to the running turn.`)}break}}catch(e){if(isInterruptedError(e))return;throw e}if(f)continue;i=!1,a=!1,n=void 0,t=void 0;let p=l.turnState?.boundaryEvent;this.#G!==this.#e&&(p===`session.waiting`||p===`session.completed`)&&(t=this.#n.takeQueuedPrompt?.()),this.#$(l.turnState?.aborted===!0)}}#Q(){this.#H.abortAll(),this.#L.clear(),this.#U.clear(),this.#W.clear(),this.#n.setConnectionAuthPendingCount?.(0),this.#e=void 0,this.#d?.clear()}#$(e=!1){let t=this.#G;t!==void 0&&(this.#G=void 0,this.#e===t&&(this.#Q(),e?this.#n.renderNotice?.(`Stopped following the turn and started a new session. Earlier context was cleared; the interrupted turn may still be running on the server.`):this.#n.renderSessionBoundary===void 0?this.#n.renderNotice?.(`Session ended — started a new session. Earlier context was cleared.`):this.#n.renderSessionBoundary()))}async#ee(){if(this.#e===void 0)return this.#Q(),this.#n.reset?.(),!0;try{await this.#e.reset()}catch(e){return this.#n.renderNotice?.(`Couldn't reset the session: ${toErrorMessage(e)}`),!1}return this.#Q(),this.#n.reset?.(),!0}async#te(e){if(!this.#n.readPrompt)return;let t=this.#n.readPrompt(e),n=this.#d;if(n===void 0)return await t;let r=!1,i=!1,a,o=0,refresh=async()=>{if(!(r||i)){i=!0;try{await n.refreshIdle({onRuntimeArtifactsChanged:()=>this.#Oe()});let e=this.#I?.agent.model.endpoint,t=e?.kind===`chatgpt`&&(e.state===`signed-out`||e.state===`reauth-required`),r=Date.now();if(t&&r-o>=5e3){o=r;let e=await this.#De();e!==void 0&&this.#Y(e)}}finally{i=!1}}},startRefresh=()=>{if(r||i)return;let e=refresh().finally(()=>{a===e&&(a=void 0)});a=e};startRefresh();let s=setInterval(()=>{startRefresh()},500);s.unref?.();try{return await t}finally{r=!0,clearInterval(s),await a}}async#ne(e){let t=this.#te(e);if(this.#n.renderIdleStream===void 0||this.#e?.state.sessionId===void 0)return await t;let n=new AbortController,r=this.#re(n.signal,e).catch(e=>{n.signal.aborted||this.#n.renderNotice?.(`Stopped following session updates: ${toErrorMessage(e)}`)});try{return await t}finally{n.abort(),await r}}async#re(e,t){let n=this.#e;if(n===void 0)return;let r=100;for(;!e.aborted;){let i=n.stream({signal:e})[Symbol.asyncIterator](),a=!1;try{for(;!e.aborted;){let r=!1,o={async*[Symbol.asyncIterator](){for(;!e.aborted;){let e=await i.next();if(e.done===!0||(r=!0,a=!0,yield e.value,isCurrentTurnBoundaryEvent(e.value)))return}}},s=this.#se(o,()=>{},n);if(await this.#n.renderIdleStream(s,{...t,continueSession:!0}),this.#Ae(s),(s.turnState?.pendingApprovals.length??0)>0||(s.turnState?.pendingQuestions.length??0)>0){this.#R={events:(async function*(){})(),turnState:s.turnState},this.#n.suspendPromptForInput?.();return}if(s.turnState?.boundaryEvent===`session.completed`||s.turnState?.boundaryEvent===`session.failed`)return;if(!r)break}}finally{await i.return?.()}r=a?100:Math.min(r*2,2e3),e.aborted||await abortableDelay(r,e)}}async#ie(e){let t=new AbortController,n={signal:t.signal};e.prompt!==void 0&&(n.message=e.prompt),e.inputResponses!==void 0&&e.inputResponses.length>0&&(n.inputResponses=e.inputResponses);let r,i=this.#e;try{if(this.#d!==void 0&&await this.#d.refresh({inputResponses:n.inputResponses,message:n.message,onRuntimeArtifactsChanged:()=>this.#Oe()}),n.message!==void 0&&(n.inputResponses?.length??0)===0&&this.#n.flushDelayedDevBuildErrors?.(),this.#e===void 0){if(this.#t===void 0)throw Error(`Cannot create a session without an eve client.`);if(n.message===void 0)throw Error(`Cannot answer an input request before the session starts.`);let e=await this.#t.sessions.create({...n,message:n.message});this.#e=e.session,r=e.response}else r=n.inputResponses===void 0?await this.#e.send(n.message,{signal:n.signal,turnPolicy:`queue`}):await this.#e.respond(n.inputResponses,{signal:n.signal})}catch(e){if(isInterruptedError(e))throw e;return this.#C?.reportFailure(e),this.#G=i,{events:errorOnlyTUIStream({errorText:this.#u(e)}),turnState:createTurnState()}}return this.#se(r,()=>t.abort(),this.#e)}async#ae(e,t){if(e.cancelInFlight!==!0){e.cancelInFlight=!0;try{for(let n=0;n<8;n+=1){if(e.boundaryEvent!==void 0||e.aborted===!0)return;let n=e.turnId;try{if((await t?.cancel(n===void 0?void 0:{turnId:n}))?.status===`accepted`)return}catch{}await delayMs(250)}}finally{e.cancelInFlight=!1}}}#oe(){if(this.#e===void 0)throw Error(`Cannot stream a session before its first turn is accepted.`);let e=new AbortController,t=this.#e;return this.#se(t.stream({signal:e.signal}),()=>e.abort(),t)}#se(e,t,n){let r=createTurnState();return{abort:()=>{r.aborted=!0,this.#G=n,t()},cancel:()=>{this.#ae(r,n)},events:eveEventsToTUIStream({events:e,pendingInputRequests:this.#L,turnState:r,onSubagentCalled:e=>this.#H.begin(e),onSubagentBackgrounded:e=>this.#H.background(e),onSubagentCompleted:e=>this.#H.settle(e),onTurnCancelled:e=>this.#H.settleCancelledTurn(e),onConnectionAuthRequired:e=>this.#ke(e),onConnectionAuthCompleted:e=>this.#je(e),onRegistryHandoff:this.#p===void 0?void 0:async e=>this.#ce(e),onTerminalFailure:()=>{this.#G=n},failureHintOverride:this.#p===void 0?void 0:localFailureHint}),turnState:r}}#ce(e){this.#B===e||this.#z.includes(e)||(this.#z.push(e),this.#V&&this.#n.suspendPromptForInput?.())}async#le(e){await this.#ye({type:`extension`,name:`add`,argument:e},`Add to your agent`,{trigger:`command`})}async#ue(e){if(this.#p===void 0)return;let t={appRoot:this.#p,env:process.env};e!==void 0&&(t.info=e),this.#j=await detectSetupIssues(t,this.#w),this.#n.renderSetupWarning!==void 0&&(this.#de(),this.#fe())}#de(){let e=orderedSetupIssues(this.#j,this.#M);e.length>0?this.#n.renderSetupWarning?.(formatSetupIssuesLine(e)):this.#n.clearSetupWarning?.()}async#fe(){let e=this.#p;if(e===void 0)return;let t;try{t=await this.#T(e,{signal:this.#k.signal})}catch{return}this.#O||this.#A||(this.#M=authIssueForStatus(t),this.#de())}async#pe(e){let t=this.#p;if(t===void 0||this.#n.renderSetupWarning===void 0)return;let n={appRoot:t,env:process.env};e!==void 0&&(n.info=e);try{this.#j=await detectSetupIssues(n,this.#w);let e=await this.#T(t,{signal:this.#k.signal});this.#M=authIssueForStatus(e)}catch{return}this.#O||this.#de()}#me(){this.#p!==void 0&&this.#n.renderSandboxLog!==void 0&&this.#K===void 0&&(this.#K=subscribeDevelopmentSandboxPrewarmLogs({appRoot:this.#p,log:e=>this.#n.renderSandboxLog?.(e)}))}#he(e,t){if(e!==void 0){if(this.#n.renderCommandResult!==void 0){this.#n.renderCommandResult(e,t);return}this.#n.renderNotice?.(e)}}async#ge(e,t){let n=this.#b;if(n===void 0)return{message:`/${e.name} is not available in this session.`};let r=this.#I?.agent.model.endpoint,i={...t,renderer:this.#n,chatGptAccountLabel:r?.kind===`chatgpt`&&r.state===`ready`?r.accountLabel:void 0,remoteConnection:this.#C,withExclusiveTerminal:this.#S},a=this.#P?.current(),o=a!==void 0&&Object.keys(a).length>0?{...i,disabledConnectionReasons:a}:i;return t.keepSetupFlowOpen===!0?await n.handle(e,{...o,keepSetupFlowOpen:!0}):await n.handle(e,o)}#_e(e,t,n){if(t!==`startup`)return;let r=this.#C?.current().connection.state,i=n===`error`||r===`auth-failed`||r===`unavailable`?`failed`:void 0,a=e.argument.length===0?``:` ${e.argument}`;this.#n.renderCommandInvocation?.(`/${e.name}${a}`,i)}async#ve(e){if(e?.kind===`model-access-changed`){this.#N?.applyEffect({kind:`refresh-identity`}),this.#A=!0,await this.#Ee();return}e!==void 0&&(this.#N?.applyEffect(e),this.#A=!0,this.#pe(this.#I))}async#ye(e,t,n){let r=await this.#ge(e,{...n,title:t}),i=n.suppressSuccessfulTranscript===!0&&r?.tone!==`error`||n.suppressCancelledTranscript===!0&&r?.cancelled===!0;return i||this.#_e(e,n.trigger,r?.tone),i||this.#he(r?.message,r?.tone),await this.#ve(r?.effect),this.#Se(),r}#be(e){return{kind:`planner`,activeStep:e,firstNavigableStep:1,steps:[{label:`Model`,complete:e>0},{label:`Channels`},{label:`Integrations`},{label:`Review`}]}}async#xe(e){let t={keepSetupFlowOpen:!0,setupFlowTitle:`Set up ${e}`,trigger:`startup`},n=`model_provider`,onOnboardingScreen=e=>{n=e.screen,this.#_?.({flow:`onboarding`,step:e.screen,registrySelectedCount:e.registrySelectedCount})};onOnboardingScreen({screen:`model_provider`});let r;try{r=await this.#ye({type:`extension`,name:`model`,argument:``},e,{...t,suppressSuccessfulTranscript:!0,initialModelStep:`provider`,setupFlowNavigation:this.#be(0),onOnboardingScreen})}catch(e){throw this.#v?.({flow:`onboarding`,step:n,result:`error`}),e}if(r?.tone===`error`||r?.cancelled===!0){this.#v?.({flow:`onboarding`,step:n,result:r.cancelled===!0?`cancelled`:`error`}),this.#n.setupFlow?.end({preserveDiagnostics:r.tone===`error`});return}let i;n=`registry_channels`;let onRegistryScreen=e=>{n=e.screen,this.#_?.({flow:`onboarding`,step:e.screen,registrySelectedCount:e.registrySelectedCount})};try{onRegistryScreen({screen:`registry_channels`}),i=await this.#ye({type:`extension`,name:`add`,argument:``},e,{...t,onOnboardingScreen:onRegistryScreen,registryPlannerContext:{prefixSteps:[{label:`Model`,complete:!0}],reviewMessage:`Review your agent`,primaryActionLabel:`Install and finish setup`,emptyActionLabel:`Finish setup`}})}catch(e){throw this.#v?.({flow:`onboarding`,step:n,result:`error`}),e}finally{i!==void 0&&this.#v?.({flow:`onboarding`,step:n,result:i.cancelled===!0?`cancelled`:i.tone===`error`?`error`:`completed`}),this.#n.setupFlow?.end({preserveDiagnostics:i?.tone===`error`})}}#Se(){if(this.#y)return;let e=this.#C?.current().connection;e?.state===`ready`&&e.info!==this.#I&&(this.#I=e.info,this.#f!==void 0&&this.#n.renderAgentHeader?.({info:e.info,name:this.#r,serverUrl:this.#f}))}async#Ce(e){if(this.#p===void 0||this.#n.traceViewer===void 0){this.#he(`/traces is only available in local dev sessions.`);return}try{await this.#n.traceViewer.open({appRoot:this.#p,sessionId:this.#e?.state.sessionId,reference:e===``?void 0:e})}catch(e){if(isInterruptedError(e))return;throw e}}async#we(){let e=this.#p;if(e===void 0){this.#he(`/info is only available in local dev sessions.`);return}try{this.#he(renderApplicationInfo(await this.#E(e)))}catch(e){this.#he(`Couldn't inspect the application: ${toErrorMessage(e)}`,`error`)}}#Te(e){let t=this.#n;if(t.logDisplayMode===void 0||t.setLogDisplayMode===void 0)return`/loglevel is not available in this session.`;if(e===``)return`Logs: ${t.logDisplayMode()}. Use /loglevel all|stderr|sandbox|none — logs stay buffered, so switching also hides or restores past lines.`;let n=parseLogDisplayMode(e);if(n===void 0)return`Unknown log level "${e}". Use all, stderr, sandbox, or none.`;if(n===t.logDisplayMode())return`Logs already set to ${n}.`;switch(t.setLogDisplayMode(n),n){case`none`:return`Logs hidden. Output stays buffered — /loglevel all restores it.`;case`stderr`:return`Showing stderr logs only.`;case`sandbox`:return`Showing sandbox logs only.`;case`all`:return`Showing all logs.`}}async#Ee(){let e=this.#p;if(e===void 0)return;await loadDevelopmentEnvironmentFiles(e),await this.#d?.refreshAfterSourceChange({});let t=this.#Y(await this.#De());this.#pe(t)}async#De(){let e=this.#t;if(e===void 0)return;let t=await probeAgentInfo({client:e});return t.kind===`ready`?t.info:void 0}async#Oe(){let e=this.#I,t=await this.#De();t!==void 0&&this.#Y(t),(!this.#n.renderAgentHeader||t===void 0)&&this.#n.renderNotice?.(formatAgentUpdateNotice(e,t))}#ke(e){let t={name:e.data.name,description:e.data.description,state:`required`};e.data.authorization!==void 0&&(t.challenge=e.data.authorization),e.data.webhookUrl!==void 0&&(t.webhookUrl=e.data.webhookUrl),this.#U.set(e.data.name,t),this.#Me(t)}#Ae(e){if(e.turnState?.boundaryEvent!==`session.waiting`)return!1;let t=!1;for(let e of this.#U.values())e.state===`required`&&e.webhookUrl!==void 0&&(e.state=`pending`,this.#W.add(e.name),this.#Me(e),t=!0);return t&&this.#n.setConnectionAuthPendingCount?.(this.#W.size),this.#W.size>0}#je(e){let t=this.#U.get(e.data.name)??{name:e.data.name,description:``,state:e.data.outcome};t.state=e.data.outcome,e.data.reason!==void 0&&(t.reason=e.data.reason),this.#U.set(e.data.name,t),this.#W.delete(e.data.name),this.#Me(t),this.#n.setConnectionAuthPendingCount?.(this.#W.size)}#Me(e){let t={name:e.name,description:e.description,state:e.state};e.challenge!==void 0&&(t.challenge=e.challenge),e.reason!==void 0&&(t.reason=e.reason),this.#n.upsertConnectionAuth?.(t)}};function createRenderer(e){return e.renderer?e.renderer:new TerminalRenderer({tools:e.tools,reasoning:e.reasoning,subagents:e.subagents,connectionAuth:e.connectionAuth,assistantResponseStats:e.assistantResponseStats,contextSize:e.contextSize,logs:e.logs,availablePromptCommands:e.availablePromptCommands,input:e.userInput,output:e.screen,diagnostics:e.diagnostics,onExitRequest:e.lifecycle?.requestStop})}function formatAgentUpdateNotice(e,t){let n=e?.agent.model.id,r=t?.agent.model.id;return n!==void 0&&r!==void 0&&n!==r?`Agent updated: Model ${n} -> ${r}`:`Agent updated.`}function registryHandoffAddress(e,t){if(e!==`selfmod__registry_add`||typeof t!=`object`||!t)return;let n=t;return n.status===`needs-terminal`&&typeof n.address==`string`?n.address:void 0}async function*eveEventsToTUIStream(e){let{events:t,pendingInputRequests:n,turnState:r,onSubagentCalled:i,onSubagentBackgrounded:a,onSubagentCompleted:o,onTurnCancelled:s,onConnectionAuthRequired:c,onConnectionAuthCompleted:l,onRegistryHandoff:u,onTerminalFailure:d,failureHintOverride:f}=e,p=new Map,m=new Map,h=new Map,g=createEventDeduper(),_=0,v=new Set,y=new Set,b=new Set,x=!1,S=!1,C;for await(let e of t)if(g.admit(e)&&!(S&&isPostTurnVisibleEvent(e)))switch(e.type){case`session.started`:case`message.received`:break;case`turn.started`:r.turnId=e.data.turnId;break;case`step.started`:_+=1,yield{type:`step-start`};break;case`step.completed`:{let t=e;C=t.data.usage,yield*closeOpenParts(p,`assistant-complete`,_),yield*closeOpenParts(m,`reasoning-complete`,_),yield{type:`step-finish`,usage:t.data.usage};break}case`message.appended`:{let t=e,n=textPartId(t.data.turnId,t.data.stepIndex),r=partStateFor(p,n);if(r.completed){if(_<=r.completedEpoch)break;r.generation+=1,r.text=``,r.completed=!1}let i=t.data.messageDelta;if(i.length===0)break;r.text+=i,yield{type:`assistant-delta`,id:partGenerationId(n,r.generation),delta:i};break}case`message.completed`:{let t=textPartId(e.data.turnId,e.data.stepIndex),n=partStateFor(p,t),r=e.data.message;if(n.completed){if(r===null||_<=n.completedEpoch)break;n.generation+=1,n.text=r,n.completedEpoch=_,yield{type:`assistant-complete`,id:partGenerationId(t,n.generation),text:r};break}let i=partGenerationId(t,n.generation);if(r!==null){if(n.text.length===0)n.text=r,n.completed=!0,n.completedEpoch=_,yield{type:`assistant-complete`,id:i,text:r};else if(r.startsWith(n.text)){let e=r.slice(n.text.length);e.length>0&&(yield{type:`assistant-delta`,id:i,delta:e}),n.text=r,n.completed=!0,n.completedEpoch=_,yield{type:`assistant-complete`,id:i}}else n.text=r,n.completed=!0,n.completedEpoch=_,yield{type:`assistant-complete`,id:i,text:r}}else n.text.length>0&&(n.completed=!0,n.completedEpoch=_,yield{type:`assistant-complete`,id:i});break}case`reasoning.appended`:{let t=e,n=reasoningPartId(t.data.turnId,t.data.stepIndex),r=partStateFor(m,n);if(r.completed){if(_<=r.completedEpoch)break;r.generation+=1,r.text=``,r.completed=!1}let i=t.data.reasoningDelta;if(i.length===0)break;r.text+=i,yield{type:`reasoning-delta`,id:partGenerationId(n,r.generation),delta:i};break}case`reasoning.completed`:{let t=reasoningPartId(e.data.turnId,e.data.stepIndex),n=partStateFor(m,t),r=e.data.reasoning;if(n.completed){if(r.length===0||_<=n.completedEpoch)break;n.generation+=1,n.text=r,n.completedEpoch=_;let e=partGenerationId(t,n.generation);yield{type:`reasoning-delta`,id:e,delta:r},yield{type:`reasoning-complete`,id:e};break}let i=partGenerationId(t,n.generation);if(n.text.length===0&&r.length>0)n.text=r,yield{type:`reasoning-delta`,id:i,delta:r};else if(r.length>0&&!r.startsWith(n.text)){yield{type:`reasoning-complete`,id:i},n.generation+=1,n.text=r,n.completed=!0,n.completedEpoch=_;let e=partGenerationId(t,n.generation);yield{type:`reasoning-delta`,id:e,delta:r},yield{type:`reasoning-complete`,id:e};break}n.completed=!0,n.completedEpoch=_,yield{type:`reasoning-complete`,id:i};break}case`actions.requested`:{let t=e.data.actions.filter(e=>e.kind===`tool-call`);if(t.length===0)break;for(let e of t)h.set(e.callId,e.toolName),!v.has(e.callId)&&(v.add(e.callId),yield{type:`tool-call`,toolCallId:e.callId,toolName:e.toolName,input:e.input});break}case`input.requested`:{let t=e.data.requests.filter(e=>e.action.kind===`tool-call`);if(t.length===0)break;for(let e of t){let t=e.action.callId;if(h.set(t,e.action.toolName),e.kind!==`session-limit`&&!v.has(t)&&(v.add(t),yield{type:`tool-call`,toolCallId:t,toolName:e.action.toolName,input:e.action.input}),!y.has(e.requestId)){if(y.add(e.requestId),n.set(e.requestId,e),e.kind!==`tool-approval`){upsertPendingQuestion(r,e);continue}upsertPendingApproval(r,e),yield{type:`tool-approval-request`,approvalId:e.requestId,toolCallId:t}}}break}case`action.result`:{let t=e;if(t.data.result.kind!==`tool-result`)break;let n=t.data.result.callId;if(!v.has(n))break;switch(t.data.status){case`completed`:{let e=t.data.result.output;yield{type:`tool-result`,toolCallId:n,output:e};let r=registryHandoffAddress(h.get(n),e);r!==void 0&&await u?.(r);break}case`failed`:yield{type:`tool-error`,toolCallId:n,errorText:formatActionResultError(t)};break;case`rejected`:yield{type:`tool-rejected`,toolCallId:n,reason:formatActionResultError(t)}}break}case`step.failed`:case`turn.failed`:{let t=toFailureEvent(e,b,f);t&&(yield t);break}case`session.failed`:{r.sawSessionFailure=!0,d?.(e);let t=toFailureEvent(e,b,f);t&&(yield t),r.boundaryEvent=e.type,yield*closeOpenParts(p,`assistant-complete`,_),yield*closeOpenParts(m,`reasoning-complete`,_),yield{type:`finish`,usage:C},x=!0;return}case`session.waiting`:case`session.completed`:r.boundaryEvent=e.type,yield*closeOpenParts(p,`assistant-complete`,_),yield*closeOpenParts(m,`reasoning-complete`,_),yield{type:`finish`,usage:C},x=!0;return;case`turn.completed`:S=!0,yield*closeOpenParts(p,`assistant-complete`,_),yield*closeOpenParts(m,`reasoning-complete`,_);break;case`turn.cancelled`:s?.(e.data.turnId),yield*closeOpenParts(p,`assistant-complete`,_),yield*closeOpenParts(m,`reasoning-complete`,_),yield{type:`turn-cancelled`};break;case`subagent.called`:i?.(e);break;case`subagent.started`:case`subagent.event`:break;case`subagent.completed`:{let t=e;t.data.backgroundTask===void 0?o?.(t.data.callId):a?.(t.data.callId);break}case`authorization.required`:c?.(e);break;case`authorization.completed`:l?.(e)}x||(yield*closeOpenParts(p,`assistant-complete`,_),yield*closeOpenParts(m,`reasoning-complete`,_),yield{type:`finish`,usage:C})}async function*errorOnlyTUIStream(e){yield{type:`error`,errorText:e.errorText},yield{type:`finish`}}function createTurnState(){return{aborted:!1,pendingApprovals:[],pendingQuestions:[],sawSessionFailure:!1}}function upsertPendingApproval(e,t){let n=toAgentTUIToolApprovalRequest(t),r=e.pendingApprovals.findIndex(e=>e.approvalId===n.approvalId);r===-1?e.pendingApprovals.push(n):e.pendingApprovals[r]=n}function toAgentTUIToolApprovalRequest(e){return{approvalId:e.requestId,toolCallId:e.action.callId,toolName:e.action.toolName,input:e.action.input}}function upsertPendingQuestion(e,t){let n=e.pendingQuestions.findIndex(e=>e.requestId===t.requestId);n===-1?e.pendingQuestions.push(t):e.pendingQuestions[n]=t}function textPartId(e,t){return`text:${e}:${t}`}function reasoningPartId(e,t){return`reasoning:${e}:${t}`}function partStateFor(e,t){let n=e.get(t);return n===void 0&&(n={generation:0,text:``,completed:!1,completedEpoch:0},e.set(t,n)),n}function partGenerationId(e,t){return t===0?e:`${e}#${t}`}function*closeOpenParts(e,t,n){for(let[r,i]of e)i.completed||i.text.length===0||(i.completed=!0,i.completedEpoch=n,yield{type:t,id:partGenerationId(r,i.generation)})}function isPostTurnVisibleEvent(e){switch(e.type){case`actions.requested`:case`authorization.completed`:case`authorization.required`:case`input.requested`:case`message.appended`:case`message.completed`:case`reasoning.appended`:case`reasoning.completed`:case`result.completed`:case`step.completed`:case`step.failed`:case`step.started`:case`subagent.called`:case`subagent.completed`:case`subagent.event`:case`subagent.started`:case`turn.completed`:case`turn.failed`:return!0;default:return!1}}function formatActionResultError(e){if(e.data.error?.message)return e.data.error.message;let t=e.data.result.output;if(typeof t==`string`)return t;try{return JSON.stringify(t)}catch{return`Tool execution failed.`}}function toFailureEvent(e,t,n){let r=failureKey(e);if(t.has(r))return;t.add(r);let i={type:`error`,errorText:formatFailureMessage(e)},a=n?.(e)??formatFailureHint(e);a!==void 0&&(i.hint=a);let o=formatFailureDetail(e);return o!==void 0&&(i.detail=o),i}function toAgentTUIInputQuestion(e){let t=e.display===`text`?`text`:e.display===`select`||e.options!==void 0&&e.options.length>0?`select`:`text`,n={requestId:e.requestId,prompt:e.prompt,display:t};return e.options!==void 0&&(n.options=e.options.map(e=>{let t={id:e.id,label:e.label};return e.description!==void 0&&(t.description=e.description),e.style!==void 0&&(t.style=e.style),t})),e.allowFreeform!==void 0&&(n.allowFreeform=e.allowFreeform),n}export{EveTUIRunner,parsePromptCommand,registryHandoffAddress};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Conversation view for the `/traces` viewer: the same trace, re-told as a
|
|
3
3
|
* flow of user messages, assistant replies, and tool calls instead of a
|
|
4
|
-
* latency waterfall.
|
|
5
|
-
*
|
|
4
|
+
* latency waterfall. Activation and action spans provide the user and tool
|
|
5
|
+
* cards directly; model response spans provide assistant cards.
|
|
6
6
|
*/
|
|
7
7
|
import type { LocalTrace, LocalTraceSpan } from "#tracing/local-trace-reader.js";
|
|
8
8
|
import type { Theme } from "../theme.js";
|
|
@@ -33,16 +33,16 @@ export interface ConversationItem {
|
|
|
33
33
|
readonly durationMs: number;
|
|
34
34
|
readonly error: boolean;
|
|
35
35
|
}
|
|
36
|
-
/** Dispatch lineage
|
|
36
|
+
/** Dispatch lineage available on a subagent activation or its caller. */
|
|
37
37
|
export interface ConversationSubagent {
|
|
38
38
|
/** Subagent name, when the turn arrived through the subagent adapter. */
|
|
39
39
|
readonly name?: string;
|
|
40
40
|
/** Turn id of the dispatching parent turn. */
|
|
41
|
-
readonly parentTurnId
|
|
41
|
+
readonly parentTurnId?: string;
|
|
42
42
|
/** Tool call id of the dispatch, when recorded. */
|
|
43
43
|
readonly parentCallId?: string;
|
|
44
44
|
}
|
|
45
|
-
/** Builds the conversation flow from eve's
|
|
45
|
+
/** Builds the conversation flow from eve's activation, model, and action spans. */
|
|
46
46
|
export declare function buildConversationItems(trace: LocalTrace): ConversationItem[];
|
|
47
47
|
/**
|
|
48
48
|
* Renders one conversation card, width-clipped: a title row (bold kind plus
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{formatCompactTokenCount}from"../stream-format.js";import{formatPayloadContent,wrapPlainText}from"./trace-content.js";import{SURFACE_CLOSE}from"./trace-surfaces.js";import{formatElapsed}from"#cli/format-elapsed.js";import{clipVisible,stripTerminalControls,visibleLength}from"#cli/ui/terminal-text.js";import{compareLocalTraceSpans,isAgentTurnSpan}from"#tracing/local-trace-reader.js";function buildConversationItems(e){let t=new Map(e.spans.map(e=>[e.spanId,e])),n=new Map;for(let r of e.spans){if(!isAgentTurnSpan(r))continue;let e=
|
|
1
|
+
import{formatCompactTokenCount}from"../stream-format.js";import{formatPayloadContent,wrapPlainText}from"./trace-content.js";import{SURFACE_CLOSE}from"./trace-surfaces.js";import{formatElapsed}from"#cli/format-elapsed.js";import{clipVisible,stripTerminalControls,visibleLength}from"#cli/ui/terminal-text.js";import{agentTurnIdentity}from"#tracing/agent-span-contract.js";import{compareLocalTraceSpans,isAgentTurnSpan}from"#tracing/local-trace-reader.js";function buildConversationItems(e){let t=new Map(e.spans.map(e=>[e.spanId,e])),n=new Map;for(let r of e.spans){if(!isAgentTurnSpan(r))continue;let e=agentTurnIdentity(r),i=turnSubagent(r,t);e!==void 0&&i!==void 0&&n.set(e,i)}let r=[],i=[...e.spans].sort(compareLocalTraceSpans).find(e=>isModelSpan(e)&&typeof e.attributes[`ai.prompt.system`]==`string`),a=i?.attributes[`ai.prompt.system`];i!==void 0&&typeof a==`string`&&a.length>0&&r.push({item:{kind:`system`,durationMs:0,error:!1,span:i,subagent:subagentFor(i,n,t),text:a},order:0n});for(let i of e.spans){let e=subagentFor(i,n,t),a=stringAttribute(i,`agent.channel.delivery.input`);if(a!==void 0){let t=deliveryText(a);if(t===void 0)continue;r.push({item:{kind:`user`,durationMs:0,error:!1,span:i,subagent:e,text:t},order:i.startTimeNs});continue}if(isModelSpan(i)){let n=stringAttribute(i,`ai.response.text`),a=stringAttribute(i,`ai.response.reasoning`),o=numberAttribute(i,`agent.usage.input_tokens`)!==void 0||numberAttribute(i,`agent.usage.output_tokens`)!==void 0,s=i.attributes[`ai.response.tool_calls`]!==void 0;if((n===void 0||n.trim().length===0)&&(a===void 0||a.trim().length===0)&&!o&&!s&&i.statusCode!==2)continue;r.push({item:{kind:`assistant`,costUsd:stepCostUsd(i,t),durationMs:spanDurationMs(i),error:i.statusCode===2,inputTokens:numberAttribute(i,`agent.usage.input_tokens`),model:stringAttribute(i,`gen_ai.request.model`),outputTokens:numberAttribute(i,`agent.usage.output_tokens`),reasoning:a,span:i,subagent:e,text:n,toolCallNames:s?parseToolCallNames(stringAttribute(i,`ai.response.tool_calls`)):void 0},order:i.startTimeNs});for(let t of parseProviderToolResults(stringAttribute(i,`ai.response.tool_results`)))r.push({item:{kind:`tool`,args:t.args,durationMs:0,error:t.error,name:stripTerminalControls(t.name),result:t.result,span:i,subagent:e},order:i.startTimeNs});continue}i.name===`agent.action`&&r.push({item:{kind:`tool`,args:stringAttribute(i,`gen_ai.tool.call.arguments`),durationMs:spanDurationMs(i),error:i.statusCode===2,name:stripTerminalControls(stringAttribute(i,`agent.action.name`)??`action`),result:unwrapJsonString(stringAttribute(i,`gen_ai.tool.call.result`)),span:i,subagent:e},order:i.startTimeNs})}return r.sort((e,t)=>e.order===t.order?0:e.order<t.order?-1:1).map(e=>e.item)}function subagentFor(e,t,n){let r=e;for(;r!==void 0;){let e=agentTurnIdentity(r);if(e!==void 0)return t.get(e);r=r.parentSpanId===void 0?void 0:n.get(r.parentSpanId)}}function turnSubagent(e,t){let n=stringAttribute(e,`agent.subagent.name`);if(n!==void 0){let t=n??stringAttribute(e,`gen_ai.agent.name`);return{name:t===void 0?void 0:stripTerminalControls(t)}}let r=e.parentSpanId===void 0?void 0:t.get(e.parentSpanId);if(r===void 0||r.name!==`agent.action`)return;let i=stringAttribute(r,`agent.action.kind`);if(i!==`subagent-call`&&i!==`remote-agent-call`)return;let a=stringAttribute(r,`agent.turn.id`);if(a===void 0)return;let o=stringAttribute(r,`agent.action.name`);return{name:o===void 0?void 0:stripTerminalControls(o),parentCallId:stringAttribute(r,`agent.action.call_id`),parentTurnId:a}}function renderConversationItem(e,t,n,r,i,a){let{colors:o,glyph:s}=n,c=Math.max(8,t-8),l=conversationItemExpandable(e,t),u=n.color?a:void 0,d=u?.primaryText??o.white,f,p,m=[];if(e.kind===`tool`){let t=o.bold(d(e.name??`tool`));f=`${foldMarker(i,l,n)}${t}`,p=e.durationMs>0?o.dim(formatElapsed(e.durationMs)):``;let r=e.args===void 0?[]:formatPayloadContent(e.args,c),a=e.result===void 0?[]:formatPayloadContent(e.result,c),s=i?r:capLines(r,c),u=i?a:capLines(a,c);s.length>0&&m.push(``,o.dim(`Input:`),``,...s),u.length>0&&m.push(``,o.dim(`Output:`),``,...u)}else if(e.kind===`system`){f=`${foldMarker(i,l,n)}${o.bold(d(`system`))}`,p=o.dim(`~${formatCompactTokenCount(estimateTokens(e.text??``))} tokens`);let t=wrapPlainText(e.text??``,c);m.push(...i?t:capLines(t,c))}else if(e.kind===`assistant`){f=`${foldMarker(i,l,n)}${o.bold(d(`assistant`))}${e.model===void 0?``:o.dim(` · ${stripTerminalControls(e.model)}`)}`,p=assistantMetrics(e,s,o);let t=e.reasoning===void 0||e.reasoning.trim().length===0?[]:wrapPlainText(e.reasoning,c),r=e.text===void 0||e.text.trim().length===0?[]:wrapPlainText(e.text,c),a=(i?t:capLines(t,c)).map(e=>o.dim(e)),u=i?r:capLines(r,c);if(a.length>0&&(m.push(o.dim(`Thought:`),``,...a),u.length>0&&m.push(``)),m.push(...u),(e.text===void 0||e.text.trim().length===0)&&e.toolCallNames!==void 0&&e.toolCallNames.length>0){a.length>0&&m.push(``);for(let t of e.toolCallNames)m.push(o.dim(`→ ${t}`))}}else{let t=e.kind===`user`&&e.subagent!==void 0?`task`:e.kind;f=`${foldMarker(i,l,n)}${o.bold(d(t))}`,p=``;let r=e.text===void 0||e.text.trim().length===0?[]:wrapPlainText(e.text,c);m.push(...i?r:capLines(r,c))}if(e.subagent!==void 0){let t=e.subagent.name===void 0?`subagent`:`subagent:${e.subagent.name}`;f+=o.dim(` · ${t}`)}e.error&&(f+=` ${o.red(s.error)}`),!i&&l?m.push(`…`,``,o.dim(`Click to expand`)):i&&l&&m.push(``,o.dim(`Click to collapse`));let h=u===void 0?void 0:e.error?u.errorHeader:u.header,g=u===void 0?void 0:e.error?u.errorBody:u.body,_=railCell(n,r,e.error,u);return[cardRow(``,t,n,_,h),cardSplitRow(f,p,t,n,_,h),cardRow(``,t,n,_,h),cardRow(``,t,n,_,g),...m.map(e=>cardRow(e,t,n,_,g)),cardRow(``,t,n,_,g)]}function cardRow(e,t,n,r,i){let a=clipVisible(e,Math.max(1,t-8)),o=` `.repeat(Math.max(0,t-8-visibleLength(a)));return i===void 0||!n.color?` ${r} ${a}${o} `:` ${r}${i} ${a.replaceAll(`\x1B[0m`,`\x1b[0m${i}`)}\x1b[0m${i}${o} ${SURFACE_CLOSE} `}function railCell(e,t,n,r){let{colors:i,glyph:a}=e;if(t){let t=e.unicode?`▌`:a.rule;return r===void 0?i.white(t):r.primaryText(t)}return r===void 0?n?i.red(a.rule):i.dim(a.rule):` `}function cardSplitRow(e,t,n,r,i,a){if(visibleLength(t)===0)return cardRow(e,n,r,i,a);let o=Math.max(1,n-8),s=visibleLength(t),c=Math.max(1,o-s-2),l=clipVisible(e,c);return cardRow(`${l}${` `.repeat(Math.max(2,o-visibleLength(l)-s))}${t}`,n,r,i,a)}function assistantMetrics(e,t,n){let r=[];return e.durationMs>0&&r.push(formatElapsed(e.durationMs)),e.inputTokens!==void 0&&r.push(`${t.arrowUp}${formatCompactTokenCount(e.inputTokens)}`),e.outputTokens!==void 0&&r.push(`${t.arrowDown}${formatCompactTokenCount(e.outputTokens)}`),e.costUsd!==void 0&&r.push(formatCost(e.costUsd)),r.length===0?``:n.dim(r.join(` · `))}function formatCost(e){return e>=.01?`$${e.toFixed(2)}`:`$${e.toFixed(4)}`}function stepCostUsd(e,t){let n=e;for(;n.parentSpanId!==void 0;){if(n=t.get(n.parentSpanId),n===void 0)return;if(n.name===`agent.step`)return numberAttribute(n,`gen_ai.usage.cost`)}}function foldMarker(e,t,n){return e?`${n.colors.dim(`▾`)} `:t?`${n.colors.dim(`▸`)} `:``}function capLines(e,t){return e.length<=3?[...e]:[...e.slice(0,2),clipVisible(e[2],Math.max(1,t))]}function conversationItemLineCount(e,t,n,r){return renderConversationItem(e,t,n,!1,r).length}function conversationItemExpandable(e,t){let n=Math.max(8,t-8);if(e.kind===`tool`){let t=e.args===void 0?0:formatPayloadContent(e.args,n-2).length,r=e.result===void 0?0:formatPayloadContent(e.result,n-2).length;return t>3||r>3}if(e.kind===`system`)return wrapPlainText(e.text??``,n).length>3;if(e.kind===`user`)return(e.text===void 0||e.text.trim().length===0?0:wrapPlainText(e.text,n).length)>3;let r=e.reasoning===void 0||e.reasoning.trim().length===0?0:wrapPlainText(e.reasoning,n).length,i=e.text===void 0||e.text.trim().length===0?0:wrapPlainText(e.text,n).length;return r>3||i>3}function estimateTokens(e){return Math.ceil(e.length/4)}function deliveryText(e){if(e!==void 0)try{let t=JSON.parse(e);return isRecord(t)&&typeof t.message==`string`?t.message:void 0}catch{return e}}function unwrapJsonString(e){if(e!==void 0)try{let t=JSON.parse(e);return typeof t==`string`?t:e}catch{return e}}function isModelSpan(e){return e.name.startsWith(`ai.`)&&e.name.includes(`do`)||e.attributes[`gen_ai.operation.name`]===`chat`}function parseToolCallNames(e){if(e!==void 0)try{let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>isRecord(e)&&typeof e.toolName==`string`).map(e=>e.toolName):void 0}catch{return}}function parseProviderToolResults(e){if(e===void 0)return[];try{let t=JSON.parse(e);if(!Array.isArray(t))return[];let asText=e=>typeof e==`string`?e:e===void 0?void 0:JSON.stringify(e);return t.filter(isRecord).map(e=>{let t=`error`in e;return{args:asText(e.input),error:t,name:typeof e.toolName==`string`?e.toolName:`tool`,result:asText(t?e.error:e.output)}})}catch{return[]}}function stringAttribute(e,t){let n=e.attributes[t];return typeof n==`string`?n:void 0}function numberAttribute(e,t){let n=e.attributes[t];return typeof n==`number`?n:void 0}function spanDurationMs(e){return Math.max(0,Number(e.endTimeNs-e.startTimeNs)/1e6)}function isRecord(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}export{buildConversationItems,conversationItemExpandable,conversationItemLineCount,renderConversationItem};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{formatAttributeContent}from"./trace-content.js";import{renderConversationItem}from"./trace-conversation.js";import{orderedTextSelection,selectedTraceViewerSpan}from"./trace-viewer-state.js";import{formatElapsed}from"#cli/format-elapsed.js";import{clipVisible,sliceVisible,stripAnsi,stripTerminalControls,visibleLength,wrapVisibleLine}from"#cli/ui/terminal-text.js";import{describeLocalTraceSpan}from"#tracing/local-trace-reader.js";function renderTraceViewer(e,t){let{width:n,height:r,theme:i}=t,a=chromeStyles(i,t.surfaces),o=Math.max(1,r-3-3),s=e.panelOpen?panelWidthFor(n):0,c=Math.max(20,n-(s===0?0:s+1)),l=panelDetailLines(e,s,i,t.surfaces),u=o,d=[];if(d.push(...renderHeader(e,t)),e.traces.length===0)d.push(...renderEmptyState(t,i,o));else if(e.trace===void 0)d.push(...center(o,a.muted(`Loading trace…`)));else{let r=renderConversation(e,t,c,o);for(let t=0;t<o;t+=1){let i=r[t]??``;if(s===0){d.push(i);continue}let a=l[e.panelScroll+t]??``;e.textSelection!==void 0&&e.textSelection.region===`panel`&&(a=highlightSelection(a,e.panelScroll+t,e.textSelection,s)),d.push(joinPanels(i,c,a,n))}}return d.push(...renderFooter(e,n,i,t.surfaces)),t.toast!==void 0&&overlayToast(d,t.toast,n,i,t.surfaces),{rows:d,panelTotalRows:l.length,timelineViewportRows:o,panelViewportRows:u,contentWidth:c}}function chromeStyles(e,t){let n=e.color?t:void 0;return{muted:n?.mutedText??e.colors.dim,primary:n?.primaryText??(e=>e)}}function overlayToast(e,t,n,r,i){let a=` ${stripTerminalControls(t)} `,o=visibleLength(a),s=r.unicode?`▌`:r.glyph.rule,c=r.color?i:void 0,l=c===void 0?``:c.body,u=c?.primaryText??r.colors.white,d=r.color?`\x1B[0m`:``,f=[`${l}${u(s)}${` `.repeat(o)}${d}`,`${l}${u(s)}${u(a)}${d}`,`${l}${u(s)}${` `.repeat(o)}${d}`];for(let[t,r]of f.entries()){let i=2+t;if(i>=e.length)break;e[i]=overlayRight(e[i],r,n,1)}}function overlayRight(e,t,n,r){let i=Math.max(0,n-r-visibleLength(t)),a=visibleLength(e),o=a<i?e+` `.repeat(i-a):e;return`${sliceVisible(o,i)}\x1b[0m${t}`}const CONVERSATION_CONTENT_KEYS=new Set([`ai.prompt.messages`,`ai.prompt.system`,`ai.response.reasoning`,`ai.response.text`,`ai.response.tool_calls`,`ai.response.tool_results`,`gen_ai.tool.call.arguments`,`gen_ai.tool.call.result`]);function renderSpanDetail(e,t,n,r){let{colors:i}=n,{muted:a,primary:o}=chromeStyles(n,r?.surfaces),s=[],c=stripTerminalControls(e.name);s.push(...wrapVisibleLine(i.bold(o(c)),t));let l=describeLocalTraceSpan(e).map(stripTerminalControls);l.length>0&&s.push(a(l.join(`, `))),s.push(``);let fact=(e,t)=>`${a(e.padEnd(10))}${t}`,u=e.statusCode===2;s.push(fact(`status`,u?i.red(`ERROR`):i.green(`ok`))),s.push(fact(`duration`,formatElapsed(durationMs(e.startTimeNs,e.endTimeNs)))),s.push(fact(`started`,clockTime(e.startTimeNs))),s.push(fact(`span`,e.spanId)),e.parentSpanId!==void 0&&s.push(fact(`parent`,e.parentSpanId)),e.scope!==void 0&&s.push(fact(`scope`,stripTerminalControls(e.scope))),s.push(``);let d=Object.keys(e.attributes).filter(e=>r?.excludeKeys?.has(e)!==!0).sort();if(d.length===0)s.push(a(`no attributes`));else{s.push(a(`attributes (${d.length})`));for(let n of d){let r=formatAttributeContent(n,e.attributes[n],i.dim,t-2),o=stripTerminalControls(n);if(r.length===1)s.push(...wrapVisibleLine(`${a(o)} ${r[0]}`,t));else{s.push(a(o));for(let e of r)s.push(` ${e}`)}}}return s.map(e=>clipVisible(e,t))}function renderHeader(e,t){let{theme:n,width:r}=t,{colors:i,glyph:a}=n,{muted:o,primary:s}=chromeStyles(n,t.surfaces),c=[];if(e.trace?.agentName!==void 0&&c.push(stripTerminalControls(e.trace.agentName)),e.trace?.
|
|
1
|
+
import{formatAttributeContent}from"./trace-content.js";import{renderConversationItem}from"./trace-conversation.js";import{orderedTextSelection,selectedTraceViewerSpan}from"./trace-viewer-state.js";import{formatElapsed}from"#cli/format-elapsed.js";import{clipVisible,sliceVisible,stripAnsi,stripTerminalControls,visibleLength,wrapVisibleLine}from"#cli/ui/terminal-text.js";import{describeLocalTraceSpan}from"#tracing/local-trace-reader.js";function renderTraceViewer(e,t){let{width:n,height:r,theme:i}=t,a=chromeStyles(i,t.surfaces),o=Math.max(1,r-3-3),s=e.panelOpen?panelWidthFor(n):0,c=Math.max(20,n-(s===0?0:s+1)),l=panelDetailLines(e,s,i,t.surfaces),u=o,d=[];if(d.push(...renderHeader(e,t)),e.traces.length===0)d.push(...renderEmptyState(t,i,o));else if(e.trace===void 0)d.push(...center(o,a.muted(`Loading trace…`)));else{let r=renderConversation(e,t,c,o);for(let t=0;t<o;t+=1){let i=r[t]??``;if(s===0){d.push(i);continue}let a=l[e.panelScroll+t]??``;e.textSelection!==void 0&&e.textSelection.region===`panel`&&(a=highlightSelection(a,e.panelScroll+t,e.textSelection,s)),d.push(joinPanels(i,c,a,n))}}return d.push(...renderFooter(e,n,i,t.surfaces)),t.toast!==void 0&&overlayToast(d,t.toast,n,i,t.surfaces),{rows:d,panelTotalRows:l.length,timelineViewportRows:o,panelViewportRows:u,contentWidth:c}}function chromeStyles(e,t){let n=e.color?t:void 0;return{muted:n?.mutedText??e.colors.dim,primary:n?.primaryText??(e=>e)}}function overlayToast(e,t,n,r,i){let a=` ${stripTerminalControls(t)} `,o=visibleLength(a),s=r.unicode?`▌`:r.glyph.rule,c=r.color?i:void 0,l=c===void 0?``:c.body,u=c?.primaryText??r.colors.white,d=r.color?`\x1B[0m`:``,f=[`${l}${u(s)}${` `.repeat(o)}${d}`,`${l}${u(s)}${u(a)}${d}`,`${l}${u(s)}${` `.repeat(o)}${d}`];for(let[t,r]of f.entries()){let i=2+t;if(i>=e.length)break;e[i]=overlayRight(e[i],r,n,1)}}function overlayRight(e,t,n,r){let i=Math.max(0,n-r-visibleLength(t)),a=visibleLength(e),o=a<i?e+` `.repeat(i-a):e;return`${sliceVisible(o,i)}\x1b[0m${t}`}const CONVERSATION_CONTENT_KEYS=new Set([`ai.prompt.messages`,`ai.prompt.system`,`ai.response.reasoning`,`ai.response.text`,`ai.response.tool_calls`,`ai.response.tool_results`,`gen_ai.tool.call.arguments`,`gen_ai.tool.call.result`]);function renderSpanDetail(e,t,n,r){let{colors:i}=n,{muted:a,primary:o}=chromeStyles(n,r?.surfaces),s=[],c=stripTerminalControls(e.name);s.push(...wrapVisibleLine(i.bold(o(c)),t));let l=describeLocalTraceSpan(e).map(stripTerminalControls);l.length>0&&s.push(a(l.join(`, `))),s.push(``);let fact=(e,t)=>`${a(e.padEnd(10))}${t}`,u=e.statusCode===2;s.push(fact(`status`,u?i.red(`ERROR`):i.green(`ok`))),s.push(fact(`duration`,formatElapsed(durationMs(e.startTimeNs,e.endTimeNs)))),s.push(fact(`started`,clockTime(e.startTimeNs))),s.push(fact(`span`,e.spanId)),e.parentSpanId!==void 0&&s.push(fact(`parent`,e.parentSpanId)),e.scope!==void 0&&s.push(fact(`scope`,stripTerminalControls(e.scope))),s.push(``);let d=Object.keys(e.attributes).filter(e=>r?.excludeKeys?.has(e)!==!0).sort();if(d.length===0)s.push(a(`no attributes`));else{s.push(a(`attributes (${d.length})`));for(let n of d){let r=formatAttributeContent(n,e.attributes[n],i.dim,t-2),o=stripTerminalControls(n);if(r.length===1)s.push(...wrapVisibleLine(`${a(o)} ${r[0]}`,t));else{s.push(a(o));for(let e of r)s.push(` ${e}`)}}}return s.map(e=>clipVisible(e,t))}function renderHeader(e,t){let{theme:n,width:r}=t,{colors:i,glyph:a}=n,{muted:o,primary:s}=chromeStyles(n,t.surfaces),c=[];if(e.trace?.agentName!==void 0&&c.push(stripTerminalControls(e.trace.agentName)),e.trace?.conversationId!==void 0&&c.push(`conversation ${stripTerminalControls(e.trace.conversationId)}`),e.trace!==void 0){let n=t.activeWindowEndNs!==void 0&&t.activeWindowEndNs>e.trace.endTimeNs?t.activeWindowEndNs:e.trace.endTimeNs;c.push(clockTime(e.trace.startTimeNs),`${e.trace.spans.length} span${e.trace.spans.length===1?``:`s`}`,formatElapsed(durationMs(e.trace.startTimeNs,n)))}let l=`${i.bold(s(`${a.brand} traces`))}${c.length===0?``:o(` · ${c.join(` · `)}`)}`,u=e.traces.length===0?``:o(`[${e.traceIndex+1}/${e.traces.length}]`),d=[t.activeWindowEndNs===void 0?``:i.green(`● live`),u].filter(e=>e.length>0).join(` `),f=joinRight(` ${clipVisible(l,Math.max(0,r-visibleLength(d)-2))}`,d,r);return[``,clipVisible(f,r),``]}function renderConversation(e,t,n,r){let{theme:i}=t;if(e.conversationItems.length===0)return[chromeStyles(i,t.surfaces).muted(` No conversation content in this trace; its export policy may have redacted it.`)];let a=conversationLines(e,n,i,t.surfaces).slice(e.scrollRow,e.scrollRow+r);return e.textSelection===void 0||e.textSelection.region!==`conversation`?a:a.map((t,r)=>highlightSelection(t,e.scrollRow+r,e.textSelection,n))}function conversationLines(e,t,n,r){let i=[];for(let a=0;a<e.conversationItems.length;a+=1)i.push(...renderConversationItem(e.conversationItems[a],t,n,a===e.selectedRow,e.expandedItems.has(a),r),``);return i}function panelDetailLines(e,t,n,r){let i=selectedTraceViewerSpan(e);return!e.panelOpen||t<=0||i===void 0?[]:[``,...renderSpanDetail(i,Math.max(16,t-3),n,{excludeKeys:CONVERSATION_CONTENT_KEYS,surfaces:r}).map(e=>` ${e}`)]}function conversationSelectionText(e,t,n,r,i){return selectionText(conversationLines(e,t,n,i),r)}function panelSelectionText(e,t,n,r){return selectionText(panelDetailLines(e,e.panelOpen?panelWidthFor(t):0,n),r)}function selectionText(e,t){let{start:n,end:r}=orderedTextSelection(t),i=[];for(let t=Math.max(0,n.line);t<=r.line&&t<e.length;t+=1){let a=stripAnsi(e[t]),o=t===n.line?n.column:0,s=t===r.line?r.column+1:1/0,c=s===1/0?a:sliceVisible(a,s),l=sliceVisible(a,o).length;i.push(c.slice(l).trimEnd())}return i.join(`
|
|
2
2
|
`)}function highlightSelection(e,t,n,r){let{start:i,end:a}=orderedTextSelection(n);if(t<i.line||t>a.line)return e;let o=t===i.line?i.column:0,s=t===a.line?a.column+1:r,c=visibleLength(e),l=c<s?e+` `.repeat(s-c):e,u=sliceVisible(l,o),d=sliceVisible(l,s),f=d.slice(u.length),p=l.slice(d.length);return f.length===0?e:`${u}\x1b[7m${f.replaceAll(`\x1B[0m`,`\x1B[0m\x1B[7m`)}\x1b[27m${p}`}function renderFooter(e,t,n,r){let{colors:i}=n,{muted:a}=chromeStyles(n,r),[o,s]=n.unicode?[`↑↓`,`←→`]:[`^/v`,`</>`],c=e.panelFocus?`${o} scroll · tab cards · esc back`:`${o} select · ${s} expand · enter attrs · tab focus · [ ] traces · q close`,l=e.conversationItems.length,u=l===0?``:a(`item ${e.selectedRow+1}/${l}`),d=[e.notice===void 0?``:i.yellow(e.notice),u].filter(e=>e.length>0).join(a(` · `));return[``,clipVisible(` ${a(c)}`,t),clipVisible(d.length===0?``:` ${d}`,t)]}function renderEmptyState(e,t,n){let{muted:r,primary:i}=chromeStyles(t,e.surfaces),[a,o]=e.tracingDisabled===!0?[`Tracing is disabled (EVE_TRACES=off).`,`Re-enable it and spans stream in live.`]:[`No local traces yet.`,`Chat with your agent — spans stream in live.`];return center(n,t.colors.bold(i(a)),r(o))}function center(e,...t){let n=Array.from({length:e},()=>``),r=Math.max(0,Math.floor(e/2)-1);return t.forEach((t,i)=>{r+i<e&&(n[r+i]=t)}),n}function joinPanels(e,t,n,r){let i=Math.max(0,r-t-1);return`${padTo(e,t)} ${clipVisible(n,i)}`}function joinRight(e,t,n){if(t.length===0)return e;let r=Math.max(1,n-visibleLength(e)-visibleLength(t));return`${e}${` `.repeat(r)}${t}`}function padTo(e,t){let n=visibleLength(e);return n>=t?clipVisible(e,t):e+` `.repeat(t-n)}function panelWidthFor(e){return e<42?0:Math.min(64,Math.max(20,Math.floor(e*.42)),e-20-1)}function durationMs(e,t){return Math.max(0,Number(t-e)/1e6)}function clockTime(e){let t=new Date(Number(e/1000000n)),pad=(e,t=2)=>String(e).padStart(t,`0`);return`${pad(t.getHours())}:${pad(t.getMinutes())}:${pad(t.getSeconds())}.${pad(t.getMilliseconds(),3)}`}export{conversationSelectionText,panelSelectionText,renderSpanDetail,renderTraceViewer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createTraceStore}from"./trace-store.js";import{deriveTraceViewerSurfaces}from"./trace-surfaces.js";import{conversationItemLineCount}from"./trace-conversation.js";import{applyLoadedTrace,applyTraceList,createTraceViewerState,reduceTraceViewerKey}from"./trace-viewer-state.js";import{conversationSelectionText,panelSelectionText,renderTraceViewer}from"./trace-view.js";var TraceViewerSession=class{#e;#t;#n=createTraceViewerState();#r;#i;#a;#o;#s;#c=!1;#l=!1;#u=!1;#d;#f={timelineViewportRows:0,panelViewportRows:0,panelTotalRows:0,contentWidth:0};constructor(e){this.#e=e,this.#t=e.store??createTraceStore({appRoot:e.appRoot}),e.terminalBackground!==void 0&&e.theme.color&&(this.#d=deriveTraceViewerSurfaces(e.terminalBackground)),e.sessionId!==void 0&&(this.#i=e.sessionId),e.reference!==void 0&&(this.#i=void 0,this.#n={...this.#n,notice:`No local trace matches "${e.reference}" yet.`})}start(){this.repaint(),this.#m(),this.#a=setInterval(()=>void this.#m(),1e3),this.#a.unref?.()}handleKey(e){if(this.#c)return`close`;e.type===`text`&&(e.value===`[`||e.value===`]`)&&(this.#r=void 0,this.#i=void 0);let t=this.#n.trace!==void 0,{state:n,effect:r,copySelection:i}=reduceTraceViewerKey(this.#n,e,this.#f);if(this.#n=n,r===`close`)return`close`;i!==void 0&&this.#p(i),this.repaint(),t&&n.trace===void 0&&this.#m()}setTerminalBackground(e){this.#c||!this.#e.theme.color||(this.#d=deriveTraceViewerSurfaces(e),this.repaint())}repaint(){if(this.#c)return;let{width:e,height:t}=this.#e.dimensions(),n=renderTraceViewer(this.#n,{width:e,height:t,theme:this.#e.theme,tracingDisabled:this.#e.tracingDisabled,activeWindowEndNs:this.#_(),toast:this.#o,surfaces:this.#d});this.#f={timelineViewportRows:n.timelineViewportRows,panelViewportRows:n.panelViewportRows,panelTotalRows:n.panelTotalRows,contentWidth:n.contentWidth,conversationLineCounts:this.#n.conversationItems.map((e,t)=>conversationItemLineCount(e,n.contentWidth,this.#e.theme,this.#n.expandedItems.has(t)))},this.#e.paint(n.rows)}dispose(){this.#c=!0,this.#a!==void 0&&(clearInterval(this.#a),this.#a=void 0),this.#s!==void 0&&(clearTimeout(this.#s),this.#s=void 0)}#p(e){let t=e.region===`panel`?panelSelectionText(this.#n,this.#e.dimensions().width,this.#e.theme,e):conversationSelectionText(this.#n,this.#f.contentWidth,this.#e.theme,e,this.#d);t.trim().length!==0&&(this.#e.copyText?.(t),this.#o=`Copied to clipboard`,this.#s!==void 0&&clearTimeout(this.#s),this.#s=setTimeout(()=>{this.#s=void 0,this.#o=void 0,this.repaint()},2e3),this.#s.unref?.())}async#m(){if(!this.#c){if(this.#l){this.#u=!0;return}this.#l=!0;try{do this.#u=!1,await this.#h();while(this.#u&&!this.#c)}finally{this.#l=!1}}}async#h(){try{let e=await this.#t.list(),t=this.#r,n=this.#e.reference;if(t===void 0&&n!==void 0&&(t=e.find(e=>e.traceId.startsWith(n))?.traceId),t===void 0&&this.#i!==void 0&&(t=await this.#g(e,this.#i)),this.#c)return;t!==void 0&&(this.#r=t);let r=e[applyTraceList(this.#n,e,{preferTraceId:t}).traceIndex]?.traceId,i=r===void 0?void 0:await this.#t.read(r);if(this.#c)return;let a=applyTraceList(this.#n,e,{preferTraceId:this.#r});this.#r!==void 0&&e[a.traceIndex]?.traceId===this.#r&&(this.#r=void 0,this.#i=void 0,a.notice?.startsWith(`No local trace matches`)&&(a={...a,notice:void 0})),e[a.traceIndex]?.traceId===r&&(a=applyLoadedTrace(a,i)),this.#n=a,this.repaint()}catch{}}async#g(e,t){for(let n of e){let e=await this.#t.read(n.traceId);if(this.#c)return;if(e?.
|
|
1
|
+
import{createTraceStore}from"./trace-store.js";import{deriveTraceViewerSurfaces}from"./trace-surfaces.js";import{conversationItemLineCount}from"./trace-conversation.js";import{applyLoadedTrace,applyTraceList,createTraceViewerState,reduceTraceViewerKey}from"./trace-viewer-state.js";import{conversationSelectionText,panelSelectionText,renderTraceViewer}from"./trace-view.js";var TraceViewerSession=class{#e;#t;#n=createTraceViewerState();#r;#i;#a;#o;#s;#c=!1;#l=!1;#u=!1;#d;#f={timelineViewportRows:0,panelViewportRows:0,panelTotalRows:0,contentWidth:0};constructor(e){this.#e=e,this.#t=e.store??createTraceStore({appRoot:e.appRoot}),e.terminalBackground!==void 0&&e.theme.color&&(this.#d=deriveTraceViewerSurfaces(e.terminalBackground)),e.sessionId!==void 0&&(this.#i=e.sessionId),e.reference!==void 0&&(this.#i=void 0,this.#n={...this.#n,notice:`No local trace matches "${e.reference}" yet.`})}start(){this.repaint(),this.#m(),this.#a=setInterval(()=>void this.#m(),1e3),this.#a.unref?.()}handleKey(e){if(this.#c)return`close`;e.type===`text`&&(e.value===`[`||e.value===`]`)&&(this.#r=void 0,this.#i=void 0);let t=this.#n.trace!==void 0,{state:n,effect:r,copySelection:i}=reduceTraceViewerKey(this.#n,e,this.#f);if(this.#n=n,r===`close`)return`close`;i!==void 0&&this.#p(i),this.repaint(),t&&n.trace===void 0&&this.#m()}setTerminalBackground(e){this.#c||!this.#e.theme.color||(this.#d=deriveTraceViewerSurfaces(e),this.repaint())}repaint(){if(this.#c)return;let{width:e,height:t}=this.#e.dimensions(),n=renderTraceViewer(this.#n,{width:e,height:t,theme:this.#e.theme,tracingDisabled:this.#e.tracingDisabled,activeWindowEndNs:this.#_(),toast:this.#o,surfaces:this.#d});this.#f={timelineViewportRows:n.timelineViewportRows,panelViewportRows:n.panelViewportRows,panelTotalRows:n.panelTotalRows,contentWidth:n.contentWidth,conversationLineCounts:this.#n.conversationItems.map((e,t)=>conversationItemLineCount(e,n.contentWidth,this.#e.theme,this.#n.expandedItems.has(t)))},this.#e.paint(n.rows)}dispose(){this.#c=!0,this.#a!==void 0&&(clearInterval(this.#a),this.#a=void 0),this.#s!==void 0&&(clearTimeout(this.#s),this.#s=void 0)}#p(e){let t=e.region===`panel`?panelSelectionText(this.#n,this.#e.dimensions().width,this.#e.theme,e):conversationSelectionText(this.#n,this.#f.contentWidth,this.#e.theme,e,this.#d);t.trim().length!==0&&(this.#e.copyText?.(t),this.#o=`Copied to clipboard`,this.#s!==void 0&&clearTimeout(this.#s),this.#s=setTimeout(()=>{this.#s=void 0,this.#o=void 0,this.repaint()},2e3),this.#s.unref?.())}async#m(){if(!this.#c){if(this.#l){this.#u=!0;return}this.#l=!0;try{do this.#u=!1,await this.#h();while(this.#u&&!this.#c)}finally{this.#l=!1}}}async#h(){try{let e=await this.#t.list(),t=this.#r,n=this.#e.reference;if(t===void 0&&n!==void 0&&(t=e.find(e=>e.traceId.startsWith(n))?.traceId),t===void 0&&this.#i!==void 0&&(t=await this.#g(e,this.#i)),this.#c)return;t!==void 0&&(this.#r=t);let r=e[applyTraceList(this.#n,e,{preferTraceId:t}).traceIndex]?.traceId,i=r===void 0?void 0:await this.#t.read(r);if(this.#c)return;let a=applyTraceList(this.#n,e,{preferTraceId:this.#r});this.#r!==void 0&&e[a.traceIndex]?.traceId===this.#r&&(this.#r=void 0,this.#i=void 0,a.notice?.startsWith(`No local trace matches`)&&(a={...a,notice:void 0})),e[a.traceIndex]?.traceId===r&&(a=applyLoadedTrace(a,i)),this.#n=a,this.repaint()}catch{}}async#g(e,t){for(let n of e){let e=await this.#t.read(n.traceId);if(this.#c)return;if(e?.conversationIds.includes(t))return n.traceId}}#_(){let e=this.#n.traces[this.#n.traceIndex];if(e!==void 0&&this.#n.trace!==void 0&&!(Date.now()-e.lastActivityMs>3e3))return BigInt(Date.now())*1000000n}};export{TraceViewerSession};
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"zod": "4.5.4",
|
|
55
55
|
"zod-validation-error": "5.0.0"
|
|
56
56
|
},
|
|
57
|
-
"scriptHash": "
|
|
57
|
+
"scriptHash": "27e3d453161fbc02f05c49128489620a13db80a1a652a8ff96db5051fc8a46fb",
|
|
58
58
|
"toolVersions": {
|
|
59
59
|
"rolldown": "1.2.7",
|
|
60
60
|
"typescript": "7.0.2"
|
|
@@ -11,8 +11,8 @@ declare const EXTENSION_CAPABILITY_CONTRACTS: {
|
|
|
11
11
|
readonly dropped: {};
|
|
12
12
|
};
|
|
13
13
|
readonly tool: {
|
|
14
|
-
readonly current:
|
|
15
|
-
readonly supported: readonly [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 28, 29, 30, 31, 32, 34];
|
|
14
|
+
readonly current: 35;
|
|
15
|
+
readonly supported: readonly [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 28, 29, 30, 31, 32, 34, 35];
|
|
16
16
|
readonly dropped: {
|
|
17
17
|
readonly 14: "TaskExec.delegated was removed; migrate to workflow-backed background tools";
|
|
18
18
|
readonly 15: "TaskExec replaces stageEffect with send";
|
|
@@ -32,8 +32,8 @@ declare const EXTENSION_CAPABILITY_CONTRACTS: {
|
|
|
32
32
|
};
|
|
33
33
|
};
|
|
34
34
|
readonly dynamicTool: {
|
|
35
|
-
readonly current:
|
|
36
|
-
readonly supported: readonly [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 28, 29, 30, 31, 32];
|
|
35
|
+
readonly current: 33;
|
|
36
|
+
readonly supported: readonly [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 28, 29, 30, 31, 32, 33];
|
|
37
37
|
readonly dropped: {
|
|
38
38
|
readonly 21: "Message and reasoning append events now expose deltas instead of cumulative snapshots.";
|
|
39
39
|
readonly 23: "TaskExec.delegated was removed; migrate to workflow-backed background tools";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readFile,writeFile}from"node:fs/promises";import{z}from"#compiled/zod/index.js";import{join}from"node:path";import{formatValidationError}from"#runtime/validation.js";const EXTENSION_COMPATIBILITY_MANIFEST_KIND=`eve-extension`,EXTENSION_COMPATIBILITY_MANIFEST_FORMAT_VERSION=2,EXTENSION_COMPATIBILITY_MANIFEST_FILENAME=`_manifest.json`,EXTENSION_CAPABILITY_CONTRACTS={extension:{current:1,supported:[1],dropped:{}},tool:{current:
|
|
1
|
+
import{readFile,writeFile}from"node:fs/promises";import{z}from"#compiled/zod/index.js";import{join}from"node:path";import{formatValidationError}from"#runtime/validation.js";const EXTENSION_COMPATIBILITY_MANIFEST_KIND=`eve-extension`,EXTENSION_COMPATIBILITY_MANIFEST_FORMAT_VERSION=2,EXTENSION_COMPATIBILITY_MANIFEST_FILENAME=`_manifest.json`,EXTENSION_CAPABILITY_CONTRACTS={extension:{current:1,supported:[1],dropped:{}},tool:{current:35,supported:[1,2,3,4,5,6,7,8,9,10,11,12,13,28,29,30,31,32,34,35],dropped:{14:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,15:`TaskExec replaces stageEffect with send`,16:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,17:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,18:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,19:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,20:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,21:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,22:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,23:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,24:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,25:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,26:`Background tools now use task yield descriptors`,27:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,33:`ctx.agent now accepts the subagent name as its first argument, derives invocation identity internally, and infers structured output types`}},dynamicTool:{current:33,supported:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,22,28,29,30,31,32,33],dropped:{21:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`,23:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,24:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,25:`TaskExec.delegated was removed; migrate to workflow-backed background tools`,26:`Background tools now use task yield descriptors`,27:`TaskExec.delegated was removed; migrate to workflow-backed background tools`}},channel:{current:19,supported:[1,2,3,4,5,6,7,8,9,10,11,13,14,15,16,17,18,19],dropped:{12:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`}},schedule:{current:11,supported:[1,2,3,4,6,7,8,9,10,11],dropped:{5:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`}},subagent:{current:12,supported:[3,4,6,7,8,9,10,11,12],dropped:{1:`Persistent subagent sessions are now the default and the experimental opt-in was removed`,2:`Persistent subagent sessions are now the default and the experimental opt-in was removed`,5:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`}},connection:{current:15,supported:[1,2,3,4,5,6,7,8,11,12,13,14,15],dropped:{9:`Dynamic connection resolvers no longer receive conversation or channel continuation data`,10:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`}},hook:{current:22,supported:[10,11,12,13,14,15,17,18,19,20,21,22],dropped:{1:`Model identity moved from session.started runtime metadata to step.started call attribution.`,2:`Model identity moved from session.started runtime metadata to step.started call attribution.`,3:`Model identity moved from session.started runtime metadata to step.started call attribution.`,4:`Model identity moved from session.started runtime metadata to step.started call attribution.`,5:`Model identity moved from session.started runtime metadata to step.started call attribution.`,6:`Model identity moved from session.started runtime metadata to step.started call attribution.`,7:`Model identity moved from session.started runtime metadata to step.started call attribution.`,8:`Model identity moved from session.started runtime metadata to step.started call attribution.`,9:`Model identity moved from session.started runtime metadata to step.started call attribution.`,16:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`}},skill:{current:1,supported:[1],dropped:{}},dynamicSkill:{current:17,supported:[1,2,3,4,5,6,7,8,9,10,11,12,14,15,16,17],dropped:{13:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`}},instructions:{current:2,supported:[1,2],dropped:{}},dynamicInstructions:{current:18,supported:[1,2,3,4,5,6,7,8,9,10,11,12,13,15,16,17,18],dropped:{14:`Message and reasoning append events now expose deltas instead of cumulative snapshots.`}},config:{current:1,supported:[1],dropped:{}},state:{current:5,supported:[1,2,3,4,5],dropped:{}}},EXTENSION_CAPABILITY_VERSIONS=Object.fromEntries(Object.entries(EXTENSION_CAPABILITY_CONTRACTS).map(([e,t])=>[e,t.current])),EXTENSION_CAPABILITY_SUPPORT=Object.keys(EXTENSION_CAPABILITY_CONTRACTS).reduce((e,t)=>(e[t]=EXTENSION_CAPABILITY_CONTRACTS[t].supported,e),{}),extensionCompatibilityManifestV1Schema=z.object({kind:z.literal(EXTENSION_COMPATIBILITY_MANIFEST_KIND),formatVersion:z.literal(1),builtWithEve:z.string().min(1),requires:z.record(z.string(),z.number().int().positive())}).strict(),extensionCompatibilityManifestV2Schema=extensionCompatibilityManifestV1Schema.extend({formatVersion:z.literal(2),build:z.object({externalDependencies:z.array(z.string().min(1)).readonly()}).strict().optional()}),extensionCompatibilityManifestSchema=z.union([extensionCompatibilityManifestV1Schema,extensionCompatibilityManifestV2Schema]);function serializeExtensionCompatibilityManifest(e){return`${JSON.stringify(e,null,2)}\n`}function parseExtensionCompatibilityManifest(e,t){let n;try{n=JSON.parse(e)}catch(e){throw Error(`Extension compatibility manifest "${t}" is not valid JSON: ${e instanceof Error?e.message:String(e)}`)}let r=extensionCompatibilityManifestSchema.safeParse(n);if(!r.success)throw Error(`Extension compatibility manifest "${t}" is invalid. ${formatValidationError(r.error)}`);return r.data}async function readExtensionCompatibilityManifest(e){return parseExtensionCompatibilityManifest(await readFile(e,`utf8`),e)}async function writeExtensionCompatibilityManifest(e,t){await writeFile(join(e,EXTENSION_COMPATIBILITY_MANIFEST_FILENAME),serializeExtensionCompatibilityManifest(t),`utf8`)}function findUnsupportedExtensionCapabilities(e,t=EXTENSION_CAPABILITY_SUPPORT){return Object.entries(e.requires).flatMap(([e,n])=>{let r=Object.hasOwn(t,e)?t[e]??[]:[];return r.includes(n)?[]:[{capability:e,requiredVersion:n,supportedVersions:r}]}).sort((e,t)=>e.capability.localeCompare(t.capability))}export{EXTENSION_CAPABILITY_SUPPORT,EXTENSION_CAPABILITY_VERSIONS,EXTENSION_COMPATIBILITY_MANIFEST_FILENAME,EXTENSION_COMPATIBILITY_MANIFEST_FORMAT_VERSION,EXTENSION_COMPATIBILITY_MANIFEST_KIND,findUnsupportedExtensionCapabilities,parseExtensionCompatibilityManifest,readExtensionCompatibilityManifest,serializeExtensionCompatibilityManifest,writeExtensionCompatibilityManifest};
|
|
@@ -3,6 +3,7 @@ import type { UnstampedMessageStreamEvent } from "#protocol/message.js";
|
|
|
3
3
|
import type { ResolvedDynamicInstructionsResolver } from "#runtime/types.js";
|
|
4
4
|
import type { AlsContext, ContextContainer } from "#context/container.js";
|
|
5
5
|
import type { ContextKey } from "#context/key.js";
|
|
6
|
+
import { type UserModelMessage } from "#harness/messages.js";
|
|
6
7
|
/**
|
|
7
8
|
* Builds the flattened system messages from session + turn durable keys.
|
|
8
9
|
* Session-scoped entries appear first.
|
|
@@ -13,7 +14,7 @@ export declare function buildDynamicInstructionMessages(ctx: {
|
|
|
13
14
|
/** Starts the instructions-only virtual context for one lifecycle preamble. */
|
|
14
15
|
export declare function prepareDynamicInstructionPreamble(ctx: AlsContext, messages: readonly ModelMessage[]): void;
|
|
15
16
|
/** Drains user-role results and clears the instructions-only virtual context. */
|
|
16
|
-
export declare function drainDynamicInstructionUserMessages(ctx: AlsContext):
|
|
17
|
+
export declare function drainDynamicInstructionUserMessages(ctx: AlsContext): UserModelMessage[];
|
|
17
18
|
/**
|
|
18
19
|
* Dispatches a stream event to dynamic instruction resolvers.
|
|
19
20
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createLogger}from"#internal/logging.js";import{DynamicInstructionResolveMessagesKey,PendingDynamicInstructionUserMessagesKey,SessionDynamicInstructionsKey,TurnDynamicInstructionsKey}from"#context/keys.js";import{toErrorMessage}from"#shared/errors.js";import{normalizeInstructionsDefinition}from"#internal/authored-definition/core.js";import{ALLOWED_DYNAMIC_INSTRUCTION_EVENTS}from"#dynamic/definition.js";import{isBrandedInstructionsEntry}from"#shared/instructions-definition.js";import{buildResolveContext}from"#context/dynamic-resolve-context.js";const log=createLogger(`dynamic-instructions`);function lowerInstruction(e){let t=normalizeInstructionsDefinition(e,`Expected dynamic instructions to match the public eve shape.`),n=t.content.trim();if(n.length!==0)return t.role===`system`?{role:`system`,message:{role:`system`,content:n}}:{role:`user`,message:
|
|
1
|
+
import{createLogger}from"#internal/logging.js";import{DynamicInstructionResolveMessagesKey,PendingDynamicInstructionUserMessagesKey,SessionDynamicInstructionsKey,TurnDynamicInstructionsKey}from"#context/keys.js";import{toErrorMessage}from"#shared/errors.js";import{normalizeInstructionsDefinition}from"#internal/authored-definition/core.js";import{ALLOWED_DYNAMIC_INSTRUCTION_EVENTS}from"#dynamic/definition.js";import{isBrandedInstructionsEntry}from"#shared/instructions-definition.js";import{buildResolveContext}from"#context/dynamic-resolve-context.js";import{createFrameworkUserMessage}from"#harness/messages.js";const log=createLogger(`dynamic-instructions`);function lowerInstruction(e){let t=normalizeInstructionsDefinition(e,`Expected dynamic instructions to match the public eve shape.`),n=t.content.trim();if(n.length!==0)return t.role===`system`?{role:`system`,message:{role:`system`,content:n}}:{role:`user`,message:createFrameworkUserMessage(`context.instruction`,n)}}function durableKeyForEvent(e){switch(e){case`session.started`:return SessionDynamicInstructionsKey;case`turn.started`:return TurnDynamicInstructionsKey;default:return}}function buildDynamicInstructionMessages(e){let t=e.get(SessionDynamicInstructionsKey)??{},n=e.get(TurnDynamicInstructionsKey)??{};return[...Object.values(t).flat(),...Object.values(n).flat()]}function prepareDynamicInstructionPreamble(e,t){e.setVirtualContext(DynamicInstructionResolveMessagesKey,[...t]),e.setVirtualContext(PendingDynamicInstructionUserMessagesKey,[])}function drainDynamicInstructionUserMessages(e){let t=[...e.get(PendingDynamicInstructionUserMessagesKey)??[]];return e.delete(DynamicInstructionResolveMessagesKey),e.delete(PendingDynamicInstructionUserMessagesKey),t}async function dispatchDynamicInstructionEvent(e){let{ctx:t,resolvers:n,event:r,messages:i}=e;if(!ALLOWED_DYNAMIC_INSTRUCTION_EVENTS.has(r.type))return;r.type===`turn.started`&&t.set(TurnDynamicInstructionsKey,{});let a=n.filter(e=>e.eventNames.includes(r.type));if(a.length===0)return;let o=durableKeyForEvent(r.type);if(o===void 0)return;let s=t.get(DynamicInstructionResolveMessagesKey)??i,c=t.get(PendingDynamicInstructionUserMessagesKey)??[],l=buildResolveContext(t,[...s,...c]),u=await Promise.allSettled(a.map(async e=>{let t=e.events[r.type];if(t===void 0)return null;let n=await t(r,l);if(n==null)return{resolver:e,instruction:void 0};if(!isBrandedInstructionsEntry(n))return log.error(`Dynamic instructions resolver "${e.slug}" returned an unbranded value — wrap with defineInstructions().`),null;try{return{resolver:e,instruction:lowerInstruction(n)}}catch(t){return log.error(`Dynamic instructions resolver "${e.slug}" returned an invalid value.`,{error:toErrorMessage(t)}),null}})),d={...t.get(o)};for(let e of u){if(e.status===`rejected`){log.error(`Dynamic instructions resolver (${r.type}) threw — skipping.`,{error:toErrorMessage(e.reason)});continue}if(e.value===null)continue;let{resolver:n,instruction:i}=e.value;delete d[n.slug],i?.role===`system`?d[n.slug]=[i.message]:i?.role===`user`&&t.setVirtualContext(PendingDynamicInstructionUserMessagesKey,[...t.get(PendingDynamicInstructionUserMessagesKey)??[],i.message])}t.set(o,d)}export{buildDynamicInstructionMessages,dispatchDynamicInstructionEvent,drainDynamicInstructionUserMessages,prepareDynamicInstructionPreamble};
|
|
@@ -8,6 +8,7 @@ import type { ActivityObserverConfig, ChannelDeliveryMetadata, ChannelInstrument
|
|
|
8
8
|
import { ContextKey } from "#context/key.js";
|
|
9
9
|
import { type SessionInboxAddress } from "#execution/wire/session-inbox-contract.js";
|
|
10
10
|
import type { InstrumentationChannelDeliveryRef } from "#instrumentation/lifecycle.js";
|
|
11
|
+
import type { UserModelMessage } from "#harness/messages.js";
|
|
11
12
|
import type { HandleEventFn } from "#harness/types.js";
|
|
12
13
|
import type { PersistedDynamicToolMetadata } from "#context/dynamic-tool-metadata.js";
|
|
13
14
|
import type { DynamicSubagentAgentConfig } from "#runtime/subagents/dynamic-agent-config.js";
|
|
@@ -45,6 +46,7 @@ export interface Session {
|
|
|
45
46
|
export declare const AuthKey: ContextKey<SessionAuthContext | null>;
|
|
46
47
|
export declare const InitiatorAuthKey: ContextKey<SessionAuthContext | null>;
|
|
47
48
|
export declare const SessionIdKey: ContextKey<string>;
|
|
49
|
+
export declare const ConversationIdKey: ContextKey<string>;
|
|
48
50
|
export declare const SessionInboxKey: ContextKey<SessionInboxAddress>;
|
|
49
51
|
export declare const ContinuationTokenKey: ContextKey<string>;
|
|
50
52
|
export declare const ChannelRequestIdKey: ContextKey<string>;
|
|
@@ -208,4 +210,4 @@ export declare const TurnDynamicInstructionsKey: ContextKey<Record<string, reado
|
|
|
208
210
|
/** Existing history exposed only to instructions resolvers during a preamble. */
|
|
209
211
|
export declare const DynamicInstructionResolveMessagesKey: ContextKey<readonly ModelMessage[]>;
|
|
210
212
|
/** User-role results waiting to be committed immediately after a preamble. */
|
|
211
|
-
export declare const PendingDynamicInstructionUserMessagesKey: ContextKey<readonly
|
|
213
|
+
export declare const PendingDynamicInstructionUserMessagesKey: ContextKey<readonly UserModelMessage[]>;
|
package/dist/src/context/keys.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ContextKey}from"#context/key.js";import{SESSION_INBOX_CONTEXT_KEY}from"#execution/wire/session-inbox-contract.js";import{SESSION_CALLBACK_CONTEXT_KEY_NAME}from"#context/key-names.js";const AuthKey=new ContextKey(`eve.auth`),InitiatorAuthKey=new ContextKey(`eve.initiatorAuth`),SessionIdKey=new ContextKey(`eve.sessionId`),SessionInboxKey=new ContextKey(SESSION_INBOX_CONTEXT_KEY),ContinuationTokenKey=new ContextKey(`eve.continuationToken`),ChannelRequestIdKey=new ContextKey(`eve.channelRequestId`),LocalDevRequestKey=new ContextKey(`eve.internal.localDevRequest`),ScheduleIdKey=new ContextKey(`eve.scheduleId`),ChannelDeliveryKey=new ContextKey(`eve.channelDelivery`),TurnDeliveryIdsKey=new ContextKey(`eve.turnDeliveryIds`),TurnTaskDeliveryKey=new ContextKey(`eve.turnTaskDelivery`),HistoryStateKey=new ContextKey(`eve.historyState`),ActiveChannelDeliveriesKey=new ContextKey(`eve.activeChannelDeliveries`),ChannelInstrumentationKey=new ContextKey(`eve.channelInstrumentation`),ModeKey=new ContextKey(`eve.mode`),ParentSessionKey=new ContextKey(`eve.parentSession`),ParentTraceContextKey=new ContextKey(`eve.parentTraceContext`),SessionTraceSeedKey=new ContextKey(`eve.sessionTraceSeed`),OtelTraceEnabledKey=new ContextKey(`eve.otelTraceEnabled`),CapabilitiesKey=new ContextKey(`eve.capabilities`),ActivityObserverKey=new ContextKey(`eve.activityObserver`),ActivityRootTurnIdKey=new ContextKey(`eve.activityRootTurnId`),ActivityPendingBlockersKey=new ContextKey(`eve.activityPendingBlockers`),SessionCallbackKey=new ContextKey(SESSION_CALLBACK_CONTEXT_KEY_NAME),SessionKey=new ContextKey(`eve.session`),SandboxKey=new ContextKey(`eve.sandbox`),HandleEventKey=new ContextKey(`eve.internal.handleEvent`),SessionDynamicModelReferenceKey=new ContextKey(`eve.sessionDynamicModelReference`),TurnDynamicModelReferenceKey=new ContextKey(`eve.turnDynamicModelReference`),RuntimeModelMetadataCacheKey=new ContextKey(`eve.runtimeModelMetadataCache`),LiveStepDynamicModelSelectionKey=new ContextKey(`eve.liveStepDynamicModelSelection`),SessionDynamicToolMetadataKey=new ContextKey(`eve.sessionDynamicToolMetadata`),SessionDynamicToolRuntimeRevisionKey=new ContextKey(`eve.sessionDynamicToolRuntimeRevision`),TurnDynamicToolMetadataKey=new ContextKey(`eve.turnDynamicToolMetadata`),TurnMemoryLocksKey=new ContextKey(`eve.memory.turnLocks`),PreparedMemoryPreambleKey=new ContextKey(`eve.memory.preparedPreamble`),PendingMemoryCommitKey=new ContextKey(`eve.memory.pendingCommit`),PreparedMemoryCompactionKey=new ContextKey(`eve.memory.preparedCompaction`),StepDynamicToolMetadataKey=new ContextKey(`eve.stepDynamicToolMetadata`),SessionDynamicSubagentSelectionsKey=new ContextKey(`eve.sessionDynamicSubagentSelections`),TurnDynamicSubagentSelectionsKey=new ContextKey(`eve.turnDynamicSubagentSelections`),SessionDynamicSubagentRuntimeRevisionKey=new ContextKey(`eve.sessionDynamicSubagentRuntimeRevision`),DynamicSubagentAgentConfigKey=new ContextKey(`eve.dynamicSubagentAgentConfig`),DynamicSkillManifestKey=new ContextKey(`eve.dynamicSkillManifest`),SessionDynamicInstructionsKey=new ContextKey(`eve.sessionDynamicInstructions`),TurnDynamicInstructionsKey=new ContextKey(`eve.turnDynamicInstructions`),DynamicInstructionResolveMessagesKey=new ContextKey(`eve.dynamicInstructionResolveMessages`),PendingDynamicInstructionUserMessagesKey=new ContextKey(`eve.pendingDynamicInstructionUserMessages`);export{ActiveChannelDeliveriesKey,ActivityObserverKey,ActivityPendingBlockersKey,ActivityRootTurnIdKey,AuthKey,CapabilitiesKey,ChannelDeliveryKey,ChannelInstrumentationKey,ChannelRequestIdKey,ContinuationTokenKey,DynamicInstructionResolveMessagesKey,DynamicSkillManifestKey,DynamicSubagentAgentConfigKey,HandleEventKey,HistoryStateKey,InitiatorAuthKey,LiveStepDynamicModelSelectionKey,LocalDevRequestKey,ModeKey,OtelTraceEnabledKey,ParentSessionKey,ParentTraceContextKey,PendingDynamicInstructionUserMessagesKey,PendingMemoryCommitKey,PreparedMemoryCompactionKey,PreparedMemoryPreambleKey,RuntimeModelMetadataCacheKey,SandboxKey,ScheduleIdKey,SessionCallbackKey,SessionDynamicInstructionsKey,SessionDynamicModelReferenceKey,SessionDynamicSubagentRuntimeRevisionKey,SessionDynamicSubagentSelectionsKey,SessionDynamicToolMetadataKey,SessionDynamicToolRuntimeRevisionKey,SessionIdKey,SessionInboxKey,SessionKey,SessionTraceSeedKey,StepDynamicToolMetadataKey,TurnDeliveryIdsKey,TurnDynamicInstructionsKey,TurnDynamicModelReferenceKey,TurnDynamicSubagentSelectionsKey,TurnDynamicToolMetadataKey,TurnMemoryLocksKey,TurnTaskDeliveryKey};
|
|
1
|
+
import{ContextKey}from"#context/key.js";import{SESSION_INBOX_CONTEXT_KEY}from"#execution/wire/session-inbox-contract.js";import{SESSION_CALLBACK_CONTEXT_KEY_NAME}from"#context/key-names.js";const AuthKey=new ContextKey(`eve.auth`),InitiatorAuthKey=new ContextKey(`eve.initiatorAuth`),SessionIdKey=new ContextKey(`eve.sessionId`),ConversationIdKey=new ContextKey(`eve.conversationId`),SessionInboxKey=new ContextKey(SESSION_INBOX_CONTEXT_KEY),ContinuationTokenKey=new ContextKey(`eve.continuationToken`),ChannelRequestIdKey=new ContextKey(`eve.channelRequestId`),LocalDevRequestKey=new ContextKey(`eve.internal.localDevRequest`),ScheduleIdKey=new ContextKey(`eve.scheduleId`),ChannelDeliveryKey=new ContextKey(`eve.channelDelivery`),TurnDeliveryIdsKey=new ContextKey(`eve.turnDeliveryIds`),TurnTaskDeliveryKey=new ContextKey(`eve.turnTaskDelivery`),HistoryStateKey=new ContextKey(`eve.historyState`),ActiveChannelDeliveriesKey=new ContextKey(`eve.activeChannelDeliveries`),ChannelInstrumentationKey=new ContextKey(`eve.channelInstrumentation`),ModeKey=new ContextKey(`eve.mode`),ParentSessionKey=new ContextKey(`eve.parentSession`),ParentTraceContextKey=new ContextKey(`eve.parentTraceContext`),SessionTraceSeedKey=new ContextKey(`eve.sessionTraceSeed`),OtelTraceEnabledKey=new ContextKey(`eve.otelTraceEnabled`),CapabilitiesKey=new ContextKey(`eve.capabilities`),ActivityObserverKey=new ContextKey(`eve.activityObserver`),ActivityRootTurnIdKey=new ContextKey(`eve.activityRootTurnId`),ActivityPendingBlockersKey=new ContextKey(`eve.activityPendingBlockers`),SessionCallbackKey=new ContextKey(SESSION_CALLBACK_CONTEXT_KEY_NAME),SessionKey=new ContextKey(`eve.session`),SandboxKey=new ContextKey(`eve.sandbox`),HandleEventKey=new ContextKey(`eve.internal.handleEvent`),SessionDynamicModelReferenceKey=new ContextKey(`eve.sessionDynamicModelReference`),TurnDynamicModelReferenceKey=new ContextKey(`eve.turnDynamicModelReference`),RuntimeModelMetadataCacheKey=new ContextKey(`eve.runtimeModelMetadataCache`),LiveStepDynamicModelSelectionKey=new ContextKey(`eve.liveStepDynamicModelSelection`),SessionDynamicToolMetadataKey=new ContextKey(`eve.sessionDynamicToolMetadata`),SessionDynamicToolRuntimeRevisionKey=new ContextKey(`eve.sessionDynamicToolRuntimeRevision`),TurnDynamicToolMetadataKey=new ContextKey(`eve.turnDynamicToolMetadata`),TurnMemoryLocksKey=new ContextKey(`eve.memory.turnLocks`),PreparedMemoryPreambleKey=new ContextKey(`eve.memory.preparedPreamble`),PendingMemoryCommitKey=new ContextKey(`eve.memory.pendingCommit`),PreparedMemoryCompactionKey=new ContextKey(`eve.memory.preparedCompaction`),StepDynamicToolMetadataKey=new ContextKey(`eve.stepDynamicToolMetadata`),SessionDynamicSubagentSelectionsKey=new ContextKey(`eve.sessionDynamicSubagentSelections`),TurnDynamicSubagentSelectionsKey=new ContextKey(`eve.turnDynamicSubagentSelections`),SessionDynamicSubagentRuntimeRevisionKey=new ContextKey(`eve.sessionDynamicSubagentRuntimeRevision`),DynamicSubagentAgentConfigKey=new ContextKey(`eve.dynamicSubagentAgentConfig`),DynamicSkillManifestKey=new ContextKey(`eve.dynamicSkillManifest`),SessionDynamicInstructionsKey=new ContextKey(`eve.sessionDynamicInstructions`),TurnDynamicInstructionsKey=new ContextKey(`eve.turnDynamicInstructions`),DynamicInstructionResolveMessagesKey=new ContextKey(`eve.dynamicInstructionResolveMessages`),PendingDynamicInstructionUserMessagesKey=new ContextKey(`eve.pendingDynamicInstructionUserMessages`);export{ActiveChannelDeliveriesKey,ActivityObserverKey,ActivityPendingBlockersKey,ActivityRootTurnIdKey,AuthKey,CapabilitiesKey,ChannelDeliveryKey,ChannelInstrumentationKey,ChannelRequestIdKey,ContinuationTokenKey,ConversationIdKey,DynamicInstructionResolveMessagesKey,DynamicSkillManifestKey,DynamicSubagentAgentConfigKey,HandleEventKey,HistoryStateKey,InitiatorAuthKey,LiveStepDynamicModelSelectionKey,LocalDevRequestKey,ModeKey,OtelTraceEnabledKey,ParentSessionKey,ParentTraceContextKey,PendingDynamicInstructionUserMessagesKey,PendingMemoryCommitKey,PreparedMemoryCompactionKey,PreparedMemoryPreambleKey,RuntimeModelMetadataCacheKey,SandboxKey,ScheduleIdKey,SessionCallbackKey,SessionDynamicInstructionsKey,SessionDynamicModelReferenceKey,SessionDynamicSubagentRuntimeRevisionKey,SessionDynamicSubagentSelectionsKey,SessionDynamicToolMetadataKey,SessionDynamicToolRuntimeRevisionKey,SessionIdKey,SessionInboxKey,SessionKey,SessionTraceSeedKey,StepDynamicToolMetadataKey,TurnDeliveryIdsKey,TurnDynamicInstructionsKey,TurnDynamicModelReferenceKey,TurnDynamicSubagentSelectionsKey,TurnDynamicToolMetadataKey,TurnMemoryLocksKey,TurnTaskDeliveryKey};
|