eve 0.79.0 → 0.79.2
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 +47 -0
- package/dist/src/channel/pending-authorization.d.ts +10 -0
- package/dist/src/channel/pending-authorization.js +1 -0
- package/dist/src/chunks/{use-eve-agent-BSYe_Re7.js → use-eve-agent-Ch-Q-s12.js} +43 -13
- package/dist/src/chunks/{use-eve-agent-B8brxCk-.js → use-eve-agent-Vsl-S0yI.js} +43 -13
- package/dist/src/client/abort-signal.d.ts +2 -0
- package/dist/src/client/abort-signal.js +1 -0
- package/dist/src/client/conversation-client.d.ts +2 -0
- package/dist/src/client/conversation-client.js +1 -1
- package/dist/src/client/eve-agent-store-state.d.ts +9 -0
- package/dist/src/client/eve-agent-store.js +1 -1
- package/dist/src/client/ndjson.js +1 -1
- package/dist/src/client/open-stream.js +1 -1
- package/dist/src/client/session-turn-dispatch.js +1 -1
- package/dist/src/client/session-utils.js +1 -1
- package/dist/src/client/session.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +2 -2
- package/dist/src/compiled/@eve/tracing/adapters/serialization.d.ts +2 -2
- package/dist/src/compiled/@eve/tracing/core/types.d.ts +6 -1
- package/dist/src/compiled/@eve/tracing/index.js +1 -1
- package/dist/src/compiled/@eve/tracing/otel.js +1 -1
- package/dist/src/compiled/_chunks/workflow/mcp-Bwx_LQ4q.js +5 -0
- package/dist/src/compiler/extension-compatibility.d.ts +18 -18
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/compiler/project-sources.js +1 -1
- package/dist/src/context/memory-tools.js +1 -1
- package/dist/src/evals/runner/reporters/assertion-scores.d.ts +6 -4
- package/dist/src/evals/runner/reporters/assertion-scores.js +1 -1
- package/dist/src/evals/runner/reporters/braintrust.js +1 -1
- package/dist/src/eve-channel/request.js +1 -1
- package/dist/src/execution/authorization-callback-match.d.ts +2 -2
- package/dist/src/execution/authorization-callback-match.js +1 -1
- package/dist/src/execution/durable-session-store.js +1 -1
- package/dist/src/execution/dynamic-workflow/tool.js +1 -1
- package/dist/src/execution/forward-session-input.js +1 -1
- package/dist/src/execution/proxied-deliver-step.js +1 -1
- package/dist/src/execution/publish-session-events.d.ts +26 -5
- package/dist/src/execution/publish-session-events.js +1 -1
- package/dist/src/execution/sandbox/bindings/microsandbox-runtime.js +1 -1
- package/dist/src/execution/sandbox/bindings/vercel-create-sdk.js +1 -1
- package/dist/src/execution/sandbox/bindings/vercel-credentials.d.ts +2 -0
- package/dist/src/execution/sandbox/bindings/vercel-credentials.js +1 -1
- package/dist/src/execution/sandbox/bindings/vercel-lifecycle.js +1 -1
- package/dist/src/execution/sandbox/bindings/vercel-lookup.js +1 -1
- package/dist/src/execution/sandbox/bindings/vercel.d.ts +3 -6
- package/dist/src/execution/sandbox/bindings/vercel.js +1 -1
- package/dist/src/execution/session/active-turn.d.ts +2 -1
- package/dist/src/execution/session/active-turn.js +1 -1
- package/dist/src/execution/session/checkpoint-migrations.js +1 -1
- package/dist/src/execution/session/handoff-steps.js +1 -1
- package/dist/src/execution/session/handoff.d.ts +1 -1
- package/dist/src/execution/session/handoff.js +1 -1
- package/dist/src/execution/session/input-queue.d.ts +13 -6
- package/dist/src/execution/session/input-queue.js +1 -1
- package/dist/src/execution/session/pending-turn-state.js +1 -1
- package/dist/src/execution/session/turn-step.js +1 -1
- package/dist/src/execution/session/turn.d.ts +5 -1
- package/dist/src/execution/session/turn.js +1 -1
- package/dist/src/execution/tasks/steps.d.ts +1 -1
- package/dist/src/execution/tasks/steps.js +1 -1
- package/dist/src/execution/tasks/task-id-input.js +1 -1
- package/dist/src/execution/tool-auth.js +1 -1
- package/dist/src/execution/tools/agent-router-workflow.js +1 -1
- package/dist/src/execution/tools/workflow/answer.d.ts +1 -1
- package/dist/src/execution/tools/workflow/apply-run-messages-step.d.ts +6 -2
- package/dist/src/execution/tools/workflow/apply-run-messages-step.js +1 -1
- package/dist/src/execution/tools/workflow/body.d.ts +10 -1
- package/dist/src/execution/tools/workflow/body.js +1 -1
- package/dist/src/execution/tools/workflow/owner-inbox.js +1 -1
- package/dist/src/execution/tools/workflow/serve.js +1 -1
- package/dist/src/execution/tools/workflow/withdraw-step.d.ts +2 -2
- package/dist/src/execution/tools/workflow/withdraw-step.js +1 -1
- package/dist/src/execution/workflow-callback-url.d.ts +10 -1
- package/dist/src/execution/workflow-callback-url.js +1 -1
- package/dist/src/harness/action-result-helpers.js +1 -1
- package/dist/src/harness/attachment-staging.js +1 -1
- package/dist/src/harness/authorization.d.ts +3 -13
- package/dist/src/harness/authorization.js +1 -1
- package/dist/src/harness/compaction/engine.js +3 -1
- package/dist/src/harness/compaction/prompt.d.ts +7 -0
- package/dist/src/harness/compaction/prompt.js +1 -1
- package/dist/src/harness/compaction/step.d.ts +1 -0
- package/dist/src/harness/compaction/step.js +1 -1
- package/dist/src/harness/coordination.js +1 -1
- package/dist/src/harness/hitl/approvals.d.ts +1 -1
- package/dist/src/harness/hitl/approvals.js +1 -1
- package/dist/src/harness/hitl/approved-calls.d.ts +3 -0
- package/dist/src/harness/hitl/approved-calls.js +1 -1
- package/dist/src/harness/hitl/candidates.d.ts +13 -0
- package/dist/src/harness/hitl/candidates.js +1 -1
- package/dist/src/harness/hitl/coordinator.js +1 -1
- package/dist/src/harness/hitl/index.d.ts +2 -5
- package/dist/src/harness/hitl/index.js +1 -1
- package/dist/src/harness/hitl/intake.js +1 -1
- package/dist/src/harness/{proxy-input-requests.d.ts → hitl/relays.d.ts} +3 -39
- package/dist/src/harness/hitl/relays.js +1 -0
- package/dist/src/harness/hitl/requests.d.ts +64 -0
- package/dist/src/harness/hitl/requests.js +1 -0
- package/dist/src/harness/hitl/sign-ins.d.ts +9 -0
- package/dist/src/harness/hitl/sign-ins.js +1 -0
- package/dist/src/harness/inline-tool-authorization.js +1 -1
- package/dist/src/harness/input-request-resolution.d.ts +2 -1
- package/dist/src/harness/input-request-resolution.js +1 -1
- package/dist/src/harness/model-call/call.js +1 -1
- package/dist/src/harness/model-call/model.d.ts +3 -1
- package/dist/src/harness/model-call/model.js +1 -1
- package/dist/src/harness/session-machine/commit.d.ts +14 -3
- package/dist/src/harness/session-machine/commit.js +1 -1
- package/dist/src/harness/session-machine/transitions.d.ts +16 -0
- package/dist/src/harness/session-machine/transitions.js +1 -1
- package/dist/src/instrumentation/native-events.js +1 -1
- package/dist/src/instrumentation/runtime.d.ts +1 -0
- package/dist/src/instrumentation/runtime.js +1 -1
- package/dist/src/internal/application/optional-package-import.d.ts +5 -0
- package/dist/src/internal/application/optional-package-import.js +1 -1
- package/dist/src/internal/application/stamped-package-version.js +1 -1
- package/dist/src/internal/authored-definition/source-identity.d.ts +6 -0
- package/dist/src/internal/authored-definition/source-identity.js +1 -1
- package/dist/src/internal/authored-module-map-loader.js +1 -1
- package/dist/src/internal/helpers/markdown.js +1 -1
- package/dist/src/internal/nitro/host/start-production-server.js +2 -2
- package/dist/src/internal/workflow/is-inactive-workflow-run-error.d.ts +2 -0
- package/dist/src/internal/workflow/is-inactive-workflow-run-error.js +1 -1
- package/dist/src/protocol/baggage.d.ts +1 -0
- package/dist/src/protocol/baggage.js +1 -1
- package/dist/src/protocol/message.d.ts +2 -0
- package/dist/src/protocol/message.js +1 -1
- package/dist/src/public/channels/teams/authorization.d.ts +53 -0
- package/dist/src/public/channels/teams/authorization.js +1 -0
- package/dist/src/public/channels/teams/defaults.js +2 -2
- package/dist/src/public/channels/teams/hitl.d.ts +2 -1
- package/dist/src/public/channels/teams/teamsChannel.js +1 -1
- package/dist/src/public/channels/telegram/authorization-callback.js +1 -1
- package/dist/src/public/definitions/connections/mcp.js +1 -1
- package/dist/src/public/definitions/connections/openapi.js +1 -1
- package/dist/src/public/next/index.js +1 -1
- package/dist/src/public/next/server.d.ts +11 -2
- package/dist/src/public/next/server.js +1 -1
- package/dist/src/public/sandbox/vercel.d.ts +2 -0
- package/dist/src/public/tools/index.d.ts +1 -1
- package/dist/src/public/tools/result.d.ts +10 -7
- package/dist/src/react/use-eve-agent.d.ts +6 -0
- package/dist/src/react/use-eve-agent.js +1 -1
- package/dist/src/runtime/authorization-context.d.ts +5 -0
- package/dist/src/runtime/authorization-context.js +1 -1
- package/dist/src/runtime/connections/mcp-tracing.js +1 -1
- package/dist/src/runtime/connections/openapi-operations.js +1 -1
- package/dist/src/runtime/connections/scoped-authorization.d.ts +6 -0
- package/dist/src/runtime/connections/scoped-authorization.js +1 -1
- package/dist/src/runtime/resolve-connection.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/setup/scaffold/create/web-template.d.ts +1 -1
- package/dist/src/setup/scaffold/create/web-template.js +18 -10
- package/dist/src/shared/action-types.d.ts +1 -0
- package/dist/src/shared/action-types.js +1 -1
- package/dist/src/shared/git.js +1 -1
- package/dist/src/shared/instrumentation-content.d.ts +1 -1
- package/dist/src/shared/instrumentation-content.js +1 -1
- package/dist/src/shared/instrumentation-decision.d.ts +3 -0
- package/dist/src/shared/instrumentation-decision.js +1 -1
- package/dist/src/shared/skill-package.js +1 -1
- package/dist/src/shared/trace-policy.js +1 -1
- package/dist/src/subagents/adapter.js +1 -1
- package/dist/src/subagents/event-proxy-step.d.ts +1 -1
- package/dist/src/subagents/event-proxy-step.js +1 -1
- package/dist/src/subagents/hitl-proxy.d.ts +1 -1
- package/dist/src/subagents/hitl-proxy.js +1 -1
- package/dist/src/svelte/index.js +1 -1
- package/dist/src/svelte/use-eve-agent.d.ts +6 -0
- package/dist/src/svelte/use-eve-agent.js +1 -1
- package/dist/src/tools/definition.d.ts +38 -1
- package/dist/src/tools/provided/ask-question-workflow.js +1 -1
- package/dist/src/tools/provided/sleep-workflow.js +1 -1
- package/dist/src/tools/signature.d.ts +4 -2
- package/dist/src/tools/signature.js +1 -1
- package/dist/src/tracing/eve/agent-otel-provider.js +1 -1
- package/dist/src/tracing/eve/gateway.d.ts +2 -1
- package/dist/src/tracing/eve/gateway.js +1 -1
- package/dist/src/tracing/eve/invoke-tool-span.js +1 -1
- package/dist/src/tracing/eve/otel-declaration.d.ts +9 -8
- package/dist/src/tracing/eve/policy.js +1 -1
- package/dist/src/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.d.ts +6 -0
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/agent-config.md +48 -0
- package/docs/channels/eve.mdx +2 -0
- package/docs/channels/teams.mdx +6 -0
- package/docs/concepts/built-in-tools.md +1 -1
- package/docs/connections/overview.mdx +9 -6
- package/docs/guides/frontend/overview.mdx +10 -1
- package/docs/guides/hooks.md +6 -2
- package/docs/guides/instrumentation/instrumentation.mdx +2 -0
- package/docs/guides/instrumentation/otel.mdx +3 -0
- package/docs/reference/cli.md +1 -1
- package/docs/reference/typescript-api.md +7 -6
- package/docs/sandbox/vercel.mdx +9 -0
- package/docs/skills.mdx +1 -1
- package/docs/tools/human-in-the-loop.md +21 -0
- package/package.json +1 -1
- package/dist/src/compiled/_chunks/workflow/mcp-CrGp4EC8.js +0 -5
- package/dist/src/harness/proxy-input-requests.js +0 -1
package/dist/src/vue/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as conversationProjection, i as openConversationInputs, n as conversationReducer, o as callStatus, r as defaultMessageReducer, t as useEveAgent } from "../chunks/use-eve-agent-
|
|
1
|
+
import { a as conversationProjection, i as openConversationInputs, n as conversationReducer, o as callStatus, r as defaultMessageReducer, t as useEveAgent } from "../chunks/use-eve-agent-Vsl-S0yI.js";
|
|
2
2
|
|
|
3
3
|
//#region src/client/tool-call-state.ts
|
|
4
4
|
function toolCallState(conversation, callId, options = {}) {
|
|
@@ -104,6 +104,12 @@ export interface UseEveAgentOptions<TData> extends EveAgentStoreCallbacks<TData>
|
|
|
104
104
|
readonly optimistic?: boolean;
|
|
105
105
|
/** Follow each subagent call's session into `conversation.agents` while mounted. @default false */
|
|
106
106
|
readonly followSubagents?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Keep the session stream open between turns to show events that arrive from schedules,
|
|
109
|
+
* channels, or other clients. Set to false to close it once the session is idle and reopen it
|
|
110
|
+
* on the next send, answer, or resume. @default true
|
|
111
|
+
*/
|
|
112
|
+
readonly followIdle?: boolean;
|
|
107
113
|
/** Prewarm an owned session on mount and after reset. @default false */
|
|
108
114
|
readonly prewarm?: boolean;
|
|
109
115
|
/**
|
package/docs/agent-config.md
CHANGED
|
@@ -75,6 +75,54 @@ prefix. Each subagent session gets its own key. An authored
|
|
|
75
75
|
in the `session-id` header, which the Codex backend uses for cache routing.
|
|
76
76
|
Gateway-routed calls do not receive the option.
|
|
77
77
|
|
|
78
|
+
### Use a local model
|
|
79
|
+
|
|
80
|
+
To test against a model running on your own machine, point the AI SDK
|
|
81
|
+
[OpenAI-compatible provider](https://ai-sdk.dev/providers/openai-compatible-providers)
|
|
82
|
+
at a local server. This works with any server that implements the OpenAI Chat
|
|
83
|
+
Completions API, such as Ollama, LM Studio, llama.cpp, or vLLM. With
|
|
84
|
+
[Ollama](https://docs.ollama.com/api/openai-compatibility):
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
pnpm add @ai-sdk/openai-compatible
|
|
88
|
+
ollama pull gpt-oss:20b
|
|
89
|
+
OLLAMA_CONTEXT_LENGTH=64000 ollama serve
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
```ts title="agent/agent.ts"
|
|
93
|
+
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
|
|
94
|
+
import { defineAgent } from "eve";
|
|
95
|
+
|
|
96
|
+
const ollama = createOpenAICompatible({
|
|
97
|
+
name: "ollama",
|
|
98
|
+
baseURL: "http://localhost:11434/v1",
|
|
99
|
+
includeUsage: true, // report token usage while streaming
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
export default defineAgent({
|
|
103
|
+
model: ollama("gpt-oss:20b"),
|
|
104
|
+
modelContextWindowTokens: 64_000,
|
|
105
|
+
});
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
- **Context window.** AI Gateway has no metadata for local models, so set
|
|
109
|
+
`modelContextWindowTokens` to the context length your server allocates, not
|
|
110
|
+
the model's maximum. eve uses it to decide when to compact. Ollama allocates
|
|
111
|
+
as little as 4K tokens by default; raise it to at least 64K for agents, as
|
|
112
|
+
above.
|
|
113
|
+
- **Tool calling.** eve agents call tools on most turns, so pick a model with
|
|
114
|
+
native tool-calling support. `gpt-oss:20b`, `qwen3`, and `gemma4` are good
|
|
115
|
+
starting points on Ollama.
|
|
116
|
+
- **Usage.** `includeUsage: true` lets token usage reach eve's
|
|
117
|
+
[session limits](#runtime-limits). Local models report no cost, so
|
|
118
|
+
`maxTokenCostUsdPerSession` does not apply.
|
|
119
|
+
- **Other servers.** Change `baseURL`, for example to
|
|
120
|
+
`http://localhost:1234/v1` for LM Studio. Pass `apiKey` for a remote
|
|
121
|
+
OpenAI-compatible server that requires one.
|
|
122
|
+
|
|
123
|
+
A deployment cannot reach a server on your machine, so use a Gateway or hosted
|
|
124
|
+
provider model when you deploy.
|
|
125
|
+
|
|
78
126
|
### Choose the model dynamically
|
|
79
127
|
|
|
80
128
|
To select a model from the incoming prompt with an AI SDK decision model, use
|
package/docs/channels/eve.mdx
CHANGED
|
@@ -203,6 +203,8 @@ Stream a session as newline-delimited JSON from `GET /eve/v1/session/:sessionId/
|
|
|
203
203
|
|
|
204
204
|
Following a stranded session's stream returns `409 session_stranded`, just like a send. The TypeScript client reports `ClientSessionStrandedError` without retrying. Pass `follow=false` to read the recorded history instead: the response ends at the durable tail, carries the `x-eve-stream-tail-index` header, and never inspects or changes the session, so it works before a reset. A reset attempts to append `session.failed` with code `session_stranded` and close the stream. Existing readers finish when they receive that terminal event.
|
|
205
205
|
|
|
206
|
+
After a session ends, the World keeps its stream only for its retention period. Reading a stream past that point returns `410 session_expired`. The history is gone, so the TypeScript client fails on the first response with a `ClientError` whose `code` is `"session_expired"`, without retrying.
|
|
207
|
+
|
|
206
208
|
### Cancel a turn
|
|
207
209
|
|
|
208
210
|
Post to `/eve/v1/session/:sessionId/cancel` to request cancellation of the active turn. You can include the observed `turnId` to keep a late request from cancelling a newer turn. Cancellation is asynchronous; confirm the turn boundary on the stream as `turn.cancelled` followed by `session.waiting`.
|
package/docs/channels/teams.mdx
CHANGED
|
@@ -87,6 +87,12 @@ By default, submissions use the Teams identity of the user who clicked the card.
|
|
|
87
87
|
|
|
88
88
|
When a tool approval settles, eve replaces its Adaptive Card with the outcome and responder name. A response rejected by an approval policy leaves the shared card unchanged.
|
|
89
89
|
|
|
90
|
+
### Connection sign-ins
|
|
91
|
+
|
|
92
|
+
When a connection needs the person to sign in, eve's `authorization.required` handler posts an Adaptive Card. In a personal chat, the card includes the sign-in link and any confirmation code. In group chats and channels, the shared card only says who has to sign in and has a **Sign in** button (`Action.Execute`). When someone presses it, eve resolves who they are the same way it does for HITL submissions (`onInputResponse`). If that's the person who needs to sign in, eve sends back a card with the link and code, and Teams shows that card only to them. Anyone else is told they can't open it. That way another member can't finish the sign-in with their own account and have it saved under the requester's identity.
|
|
93
|
+
|
|
94
|
+
If you customize `onMessage` without also setting `onInputResponse`, nobody can open a sign-in from a group chat or channel, because eve rejects every press.
|
|
95
|
+
|
|
90
96
|
For invokes that aren't HITL, handle them in `onInvoke(ctx, activity)`.
|
|
91
97
|
|
|
92
98
|
### Proactive sessions
|
|
@@ -310,7 +310,7 @@ These tools let the model reach what isn't in its tool list. `eve__search` finds
|
|
|
310
310
|
|
|
311
311
|
Entries the agent declares count from the session's first step. An entry a dynamic resolver returns counts from the step where it first appears, so a resolver in `agent/tools/` that returns only tools without `deferred: true` adds no catalog tools. Once a session's tool list includes a catalog tool, the session keeps it, even after a resolver stops returning the entry that brought it. The catalog tools change only when the session first reaches a new kind of entry, such as its first deferred tool or its first connection.
|
|
312
312
|
|
|
313
|
-
- `eve__search({ query, limit? })` returns the best matches, up to `limit` (default 10, at most 50). `query` is required and must contain a word. A tool match has its exact `tool` name, its `description`, and a TypeScript `signature` rendered from its schemas. A deferred skill's match has its `skill` name, its `description`, and the `path` of its `SKILL.md` when it has supporting files. A result with `tool` is called with `eve__tool`, and one with `skill` is loaded with `eve__skill`. Next to `results`, `searched` counts the entries the query covered, the whole catalog or one namespace, and `remaining` counts the matches past `limit`. A connection behind sign-in counts as its one sign-in result until the user signs in, and an unavailable connection counts as none. Tools and skills rank together, in tiers: an entry whose name is exactly the query, then one whose name after its last `__` is the query, such as `linear__create_issue` or `sre__create_issue` for `create_issue`, then the tools of a connection named by the query, then entries whose names, or names after their last `__`, start with the query, then keyword matches in names, parameters, and descriptions. So `eve__search({ query: "linear" })` lists the `linear` connection's tools first. One-letter and filler words such as `a` and `the` don't count toward keyword matches unless the query has nothing else.
|
|
313
|
+
- `eve__search({ query, limit? })` returns the best matches, up to `limit` (default 10, at most 50). `query` is required and must contain a word. A tool match has its exact `tool` name, its `description`, and a TypeScript `signature` rendered from its schemas. A very long signature drops its property descriptions before any property name. A deferred skill's match has its `skill` name, its `description`, and the `path` of its `SKILL.md` when it has supporting files. A result with `tool` is called with `eve__tool`, and one with `skill` is loaded with `eve__skill`. Next to `results`, `searched` counts the entries the query covered, the whole catalog or one namespace, and `remaining` counts the matches past `limit`. A connection behind sign-in counts as its one sign-in result until the user signs in, and an unavailable connection counts as none. Tools and skills rank together, in tiers: an entry whose name is exactly the query, then one whose name after its last `__` is the query, such as `linear__create_issue` or `sre__create_issue` for `create_issue`, then the tools of a connection named by the query, then entries whose names, or names after their last `__`, start with the query, then keyword matches in names, parameters, and descriptions. So `eve__search({ query: "linear" })` lists the `linear` connection's tools first. One-letter and filler words such as `a` and `the` don't count toward keyword matches unless the query has nothing else.
|
|
314
314
|
- A query whose first word contains `__` searches one namespace: everything before its last `__`, without trailing underscores. The namespace only filters. `eve__search` keeps names under `<namespace>__` and anything named exactly the namespace, such as a connection's sign-in entry, then ranks them by the whole query, so `eve__search({ query: "linear__" })` returns only the `linear` connection's tools, or its sign-in result, and an exact name that contains `__` still ranks first. eve lists only the connections that can own names in that namespace, so other connections make no network call and don't appear in `unavailable`. A namespace that matches nothing fails with the closest connection names. Characters that can't appear in a name, such as a leading `^`, are ignored; `query` isn't a regular expression.
|
|
315
315
|
- `eve__search` never asks the user to sign in. A connection whose server won't list its tools until the user signs in appears as one result named after the connection, such as `linear`; a connection whose server lists its tools without a token is searched like any other. A connection whose tools fail to load, or don't load within 10 seconds, appears under `unavailable` with its `error`, such as `"crm" did not list its tools within 10s. Try again later.` Matches from everything else are still returned, so a slow server doesn't hold up the search. An `eve__tool` call on that connection's tools fails with the same error.
|
|
316
316
|
- `eve__tool({ name: "linear" })`, with a connection's own name, asks the user to sign in to that connection when its tools need it, and returns once they can be listed, so the next `eve__search` finds them. On a server that lists its tools without sign-in, it confirms the tools are available without asking.
|
|
@@ -254,12 +254,13 @@ App-scoped Connect auth is non-interactive. eve asks Vercel Connect for an app t
|
|
|
254
254
|
|
|
255
255
|
### Troubleshooting Vercel Connect auth
|
|
256
256
|
|
|
257
|
-
| Symptom
|
|
258
|
-
|
|
|
259
|
-
| `reason: "principal_required"`
|
|
260
|
-
| `authorization.required` appears but no UI
|
|
261
|
-
| OAuth works locally but fails after deploy
|
|
262
|
-
| A scheduled or internal run needs user OAuth
|
|
257
|
+
| Symptom | What it means | Fix |
|
|
258
|
+
| ------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
259
|
+
| `reason: "principal_required"` | A user-scoped connection ran without an authenticated user on the active session. | Return `principalType: "user"` from the channel's route auth, or use `connect({ connector, principalType: "app" })` if the Connect credential should be shared. |
|
|
260
|
+
| `authorization.required` appears but no UI | eve parked the turn for OAuth, but the channel or frontend is not rendering the challenge. | Render the challenge from the stream event and continue the same session after the callback. |
|
|
261
|
+
| OAuth works locally but fails after deploy | The project may not be linked to the Connect client, or the deployed runtime may not have the expected Vercel OIDC/project scope. | Run Connect setup from the consuming project directory, link the project, deploy again, and verify the connector UID in `connect("...")`. |
|
|
262
|
+
| A scheduled or internal run needs user OAuth | Schedules and runtime callers do not automatically carry an end-user principal. | Dispatch through a user-authenticated channel when work is user-owned, or use app-scoped auth for agent-owned background work. |
|
|
263
|
+
| Sign-in ends on a Vercel login or protection page | The deployment is behind Deployment Protection, and sign-in callback URLs never carry the automation bypass secret. | Have the user sign in to Vercel with access to the project, or add a Deployment Protection Exception for the domain. |
|
|
263
264
|
|
|
264
265
|
## Self-hosted interactive OAuth
|
|
265
266
|
|
|
@@ -316,6 +317,8 @@ export default defineMcpClientConnection({
|
|
|
316
317
|
|
|
317
318
|
Drop `resume` when the provider keeps flow state server-side, so nothing has to cross the step boundary.
|
|
318
319
|
|
|
320
|
+
The callback URL never carries `VERCEL_AUTOMATION_BYPASS_SECRET`, because the user's browser and the provider both see it. On a deployment behind [Deployment Protection](https://vercel.com/docs/deployment-protection), the person signing in must pass protection on their own, for example through Vercel Authentication or a [Deployment Protection Exception](https://vercel.com/docs/deployment-protection/methods-to-bypass-deployment-protection/deployment-protection-exceptions).
|
|
321
|
+
|
|
319
322
|
`displayName` is presentation-only. The connection's resolved name still keys
|
|
320
323
|
the callback URL, while eve scopes token caching and authorization completion
|
|
321
324
|
to the opaque resolved instance identity. You can also set `displayName` on the
|
|
@@ -165,6 +165,15 @@ its cursor after a disconnect or the
|
|
|
165
165
|
server's renewable 60-second lease; lease renewal does not start a turn or clear UI state.
|
|
166
166
|
Unmounting or resetting closes the local stream without cancelling the old durable session.
|
|
167
167
|
|
|
168
|
+
An open stream reconnects for as long as the chat stays mounted, even when nothing happens. If
|
|
169
|
+
your UI only shows replies to its own messages, such as a help sidebar that stays mounted across
|
|
170
|
+
pages, pass `followIdle: false`. The binding then closes the stream once the session is idle: no
|
|
171
|
+
turn is running or parked, no task is working, and no sign-in is pending. A prewarmed session
|
|
172
|
+
opens no stream until its first message. The next `send()`, `respond()`, or `resume()` reopens
|
|
173
|
+
the stream from the session cursor, so events that arrived in between are applied then. Leave
|
|
174
|
+
`followIdle` on when other sources, such as schedules, channels, or another tab, can start turns
|
|
175
|
+
in the session while your UI is idle.
|
|
176
|
+
|
|
168
177
|
`reset()` reuses the hook instance and clears the conversation. When `prewarm` is true after
|
|
169
178
|
the reset, it prepares the next owned session; otherwise, the next send creates it. An explicitly
|
|
170
179
|
supplied `session` remains externally owned and is never replaced by prewarming or reset. Use
|
|
@@ -399,7 +408,7 @@ then save a final snapshot in `onFinish`.
|
|
|
399
408
|
|
|
400
409
|
`initialEvents` must be an ordered prefix of the same session's stream, but its endpoint does not have to line up exactly with where the stream resumes. When the event count matches `initialSession.streamIndex`, catch-up continues from that cursor. A partial or overlapping saved log falls back to index `0`. Every event carries a stable [`meta.id`](/docs/concepts/sessions-runs-and-streaming#the-event-envelope), and the store drops any event whose id it has already applied, so an overlapping replay renders once and `onEvent` only fires for events your UI has not seen.
|
|
401
410
|
|
|
402
|
-
For multiple chat threads, keep one saved event log and session cursor per thread. `agent`, `host`, `reducer`, `session`, `initialEvents`, `initialSession`, `auth`, `headers`, `optimistic`, and `resume` are read when the hook creates its store, so remount the chat component when switching threads, for example with `key={chat.id}`. React reads `prewarm` on every render.
|
|
411
|
+
For multiple chat threads, keep one saved event log and session cursor per thread. `agent`, `host`, `reducer`, `session`, `initialEvents`, `initialSession`, `auth`, `headers`, `optimistic`, `followIdle`, and `resume` are read when the hook creates its store, so remount the chat component when switching threads, for example with `key={chat.id}`. React reads `prewarm` on every render.
|
|
403
412
|
|
|
404
413
|
Pass `resume: true` with `initialSession` to rebuild the projection from the durable stream after mount. While `status` is `"resuming"`, render hydrated `data` but disable message and HITL submission; do not present cancellation or active-turn progress controls. If catch-up finds an in-flight turn, `status` changes to `"streaming"` before the binding follows it to a boundary. The stream reports its initial durable tail so catch-up can finish without closing the connection or waiting for an idle timeout. A settled tail changes directly to `"ready"`; a newer turn or pending authorization remains `"streaming"`. The connection stays open to receive later events. A terminal session failure changes to `"error"`.
|
|
405
414
|
|
package/docs/guides/hooks.md
CHANGED
|
@@ -97,7 +97,7 @@ when the parent's current model step ends if one is running.
|
|
|
97
97
|
|
|
98
98
|
### Narrowing tool results
|
|
99
99
|
|
|
100
|
-
`toolResultFrom` narrows an `action.result` event to a specific authored tool or MCP
|
|
100
|
+
`toolResultFrom` narrows an `action.result` event to a specific authored tool or connection (MCP or OpenAPI) and returns typed output. Import it from `eve/tools`:
|
|
101
101
|
|
|
102
102
|
```ts
|
|
103
103
|
import { defineHook } from "eve/hooks";
|
|
@@ -114,7 +114,7 @@ export default defineHook({
|
|
|
114
114
|
console.log(weather.output.temperature);
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
//
|
|
117
|
+
// Connection: output is unknown, toolName is qualified
|
|
118
118
|
const linearResult = toolResultFrom(event.data.result, linear);
|
|
119
119
|
if (linearResult) {
|
|
120
120
|
console.log(linearResult.connectionToolName, linearResult.output);
|
|
@@ -219,6 +219,10 @@ export default defineHook({
|
|
|
219
219
|
|
|
220
220
|
The remaining subscribers for the event still run. Then eve cancels the turn the same way [`session.cancel()`](./client/streaming) does: in-flight model and tool work is aborted, delegated child turns are cancelled, and the turn ends with `turn.cancelled` followed by `session.waiting`. No failure event is emitted. A cancel from `turn.started` or `step.started` takes effect before that model call. In a conversation, the next message starts a new turn. A delegated task reports the cancellation to its caller.
|
|
221
221
|
|
|
222
|
+
A plain-text message that answers a pending question, such as one from `ask_question`, is recorded as `message.received` before eve delivers it. Calling `ctx.cancel()` from that event's hook cancels the turn instead: the question resolves as `cancelled`, and the waiting tool call never receives the text.
|
|
223
|
+
|
|
224
|
+
The same goes for the `action.partial` a workflow tool reports while the turn waits on it: `ctx.cancel()` from its hook cancels the turn, and the run's result never reaches the model.
|
|
225
|
+
|
|
222
226
|
`ctx.cancel()` returns `void` rather than a promise. The turn stops after the hook returns, so there is nothing to await. Call it before the handler's promise settles: eve ignores a call from work the handler does not await and logs a warning.
|
|
223
227
|
|
|
224
228
|
`ctx.cancel()` only stops a running turn. eve logs a warning and ignores the call on `step.failed`, `turn.completed`, `turn.failed`, `turn.cancelled`, `turn.waiting`, `session.waiting`, `session.completed`, `session.failed`, `context.cleared`, `task.started`, `task.settled`, and `agent.started`, and during clear or compact requests.
|
|
@@ -170,6 +170,8 @@ Each call emits one `tool.call.*` lifecycle to authored providers. SDK execution
|
|
|
170
170
|
|
|
171
171
|
For local and remote subagents, `tool.call.completed` and `tool.call.failed` include the child turn's `usage` directly. Token counts are always present when the child reports usage; `usage.costUsd` is present only when the model provider reports a price.
|
|
172
172
|
|
|
173
|
+
When a tool throws and outputs are recorded, `tool.call.failed` carries an `Error` with the thrown error's `name` and `message`, so a provider can classify the failure by `error.name`. It is rebuilt from the durable session record rather than being the object the tool threw, so `instanceof` checks against your own error classes do not match.
|
|
174
|
+
|
|
173
175
|
When upgrading, replace `action.started`, `action.completed`, and `action.failed` handlers with their `tool.call.*` equivalents. Read `event.toolName` instead of `event.name` on start events. The OpenTelemetry trace schema remains version 4.
|
|
174
176
|
|
|
175
177
|
Handlers from different files run concurrently and are failure-isolated. Do
|
|
@@ -174,6 +174,9 @@ each turn. Remote requests carry the conversation ID in W3C Baggage.
|
|
|
174
174
|
`trustedForwarders` controls whether the receiver accepts parent session data
|
|
175
175
|
and the trace-content policy. See
|
|
176
176
|
[Remote agents](../guides/remote-agents#preserving-trace-content).
|
|
177
|
+
Gateway-routed model calls propagate the configured OpenTelemetry context at
|
|
178
|
+
each provider request. Eve-owned baggage is removed before forwarding. Gateway
|
|
179
|
+
controls whether its spans are sampled and which destinations receive them.
|
|
177
180
|
|
|
178
181
|
## Local traces
|
|
179
182
|
|
package/docs/reference/cli.md
CHANGED
|
@@ -403,7 +403,7 @@ Each root agent turn starts a new trace. With local caller trace context, that t
|
|
|
403
403
|
|
|
404
404
|
Every span carries a real duration. A turn's root `invoke_agent` span is written when the turn settles, so a running turn shows only its steps.
|
|
405
405
|
|
|
406
|
-
Model, `execute_tool`, and memory spans retain their content by default. Set `EVE_TRACES_CONTENT=off` to omit system prompts, prompt messages, and response text for models; call arguments and results for tools; and recalled memory records. Each captured value is capped at 32 KB.
|
|
406
|
+
Model, `execute_tool`, and memory spans retain their content by default. Set `EVE_TRACES_CONTENT=off` to omit system prompts, prompt messages, and response text for models; call arguments and results for tools; and recalled memory records. Each captured value is capped at 32 KB. When a model call's prompt messages exceed the cap, the oldest are dropped first and `agent.input.messages.omitted` records how many.
|
|
407
407
|
|
|
408
408
|
Step spans carry token counts under `agent.usage.*`, and cost when Vercel AI Gateway served the call. Model spans also expose `gen_ai.usage.*` token counters. The CLI sums step-level counters only, so model and delegated-call totals are not counted twice.
|
|
409
409
|
|
|
@@ -103,12 +103,13 @@ import template from "../../prompts/template.txt?raw";
|
|
|
103
103
|
|
|
104
104
|
`ctx` is passed to your tool `execute`, hook handlers, channel event handlers, and connection auth/header resolvers. It is live only while authored code is running, so reaching for it at module top level throws. See [Session context](../guides/session-context) for the full model.
|
|
105
105
|
|
|
106
|
-
| Member | Use
|
|
107
|
-
| --------------------------- |
|
|
108
|
-
| `ctx.session` | Current session, turn, auth, and optional parent lineage (read-only)
|
|
109
|
-
| `ctx.getSandbox()` | Live sandbox handle; `stop()` releases compute but preserves durable state
|
|
110
|
-
| `ctx.getToken(provider)` | Resolve a bearer token for an inline auth provider such as `connect("...")`
|
|
111
|
-
| `ctx.requireAuth(provider)` | Evict and re-authorize an inline provider, commonly after a downstream `401`
|
|
106
|
+
| Member | Use |
|
|
107
|
+
| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
108
|
+
| `ctx.session` | Current session, turn, auth, and optional parent lineage (read-only) |
|
|
109
|
+
| `ctx.getSandbox()` | Live sandbox handle; `stop()` releases compute but preserves durable state |
|
|
110
|
+
| `ctx.getToken(provider)` | Resolve a bearer token for an inline auth provider such as `connect("...")` |
|
|
111
|
+
| `ctx.requireAuth(provider)` | Evict and re-authorize an inline provider, commonly after a downstream `401` |
|
|
112
|
+
| `ctx.approval` | Present only while a call runs after a person approved it: `responder` is who approved it and `responder.getToken(provider)` resolves their token. The call still runs as `ctx.session.auth.current`; see [Human-in-the-loop](/docs/human-in-the-loop) |
|
|
112
113
|
|
|
113
114
|
Tool definitions accept `availableInSubagents: false` to restrict the tool to top-level root sessions, and `deferred: true` to keep the tool out of the model's tool list so the model finds it with `eve__search` and calls it with `eve__tool`; see [Tools](../tools#keep-a-tool-out-of-the-tool-list). `defineTool` definitions accept `endsTurn: true`, or a function that receives the `execute` output, to end the turn without a reply after a successful call; see [Tools](../tools#end-the-turn-after-a-tool-call). Authored workflow bodies also receive `ctx.agents`, a replay-stable map of callable-agent metadata, and `ctx.agent(name)`, which returns an `AgentSession` whose `send(message, options?)` resolves to a response with `result()`. A `"use step"` helper that receives the context directly should type it as `WorkflowStepToolContext`, which excludes `agents`, `agent`, and `ask`. The root-copy `agent` entry has an empty description when the root omits `description`. See [Workflows as tools](../tools/workflows#delegate-work-ctxagent) for the workflow-only context.
|
|
114
115
|
|
package/docs/sandbox/vercel.mdx
CHANGED
|
@@ -95,6 +95,15 @@ await sandbox.setNetworkPolicy("deny-all");
|
|
|
95
95
|
return sandbox;
|
|
96
96
|
```
|
|
97
97
|
|
|
98
|
+
## Live sandbox name
|
|
99
|
+
|
|
100
|
+
Sessions returned by `environment.open()` and `ctx.getSandbox(environment)` expose a read-only `name` property. The name identifies the live Vercel Sandbox and stays stable across stop/resume for the session. Use it as `sandboxName` when creating Vercel git-credential-broker grants scoped to that sandbox:
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
const sandbox = await ctx.getSandbox(environment);
|
|
104
|
+
const sandboxName = sandbox.name;
|
|
105
|
+
```
|
|
106
|
+
|
|
98
107
|
## Live sandbox options
|
|
99
108
|
|
|
100
109
|
`open()` also accepts Vercel compute resources, timeout, and Drive mounts. Configure project credentials and custom fetch behavior on the environment, not in `open()`, because resume does not reconstruct start-only options.
|
package/docs/skills.mdx
CHANGED
|
@@ -44,7 +44,7 @@ A skill's name comes from its path and must use only ASCII letters, digits, unde
|
|
|
44
44
|
|
|
45
45
|
A flat markdown skill can skip the `description` frontmatter. When it does, eve advertises the first non-empty, non-code-fence line of the body with any leading `#`, `>`, `*`, or `-` marker stripped. If the body has no such line, eve falls back to the literal `Instructions for the <name> skill.`, which is a weak routing hint, so add a `description` when you want the model to route on intent.
|
|
46
46
|
|
|
47
|
-
A packaged skill is a directory with a `SKILL.md` plus sibling files like `references/`, `assets/`, and `scripts/`. The packaged `SKILL.md` must carry `description` frontmatter; it has no filename slug to fall back on.
|
|
47
|
+
A packaged skill is a directory with a `SKILL.md` plus sibling files like `references/`, `assets/`, and `scripts/`. The packaged `SKILL.md` must carry `description` frontmatter; it has no filename slug to fall back on. eve ignores frontmatter it does not use so skills authored for other Agent Skills clients remain importable.
|
|
48
48
|
|
|
49
49
|
```md title="agent/skills/research/SKILL.md"
|
|
50
50
|
---
|
|
@@ -256,6 +256,27 @@ When a subagent requests input, eve emits the same `input.requested` event on it
|
|
|
256
256
|
|
|
257
257
|
Approval is consent only. An approved tool call runs with the requesting user's identity, connections, and credentials, including its policy recheck. The approver's access is never lent to the call. Subsequent tool calls in the turn also stay with the original owner.
|
|
258
258
|
|
|
259
|
+
A `defineTool` tool can still act on the approver's behalf when it chooses to. While an approved `defineTool` call runs, `ctx.approval.responder` is the principal who approved it, and `ctx.approval.responder.getToken(provider)` resolves that person's token for an inline provider, as `ctx.getToken(provider)` does for the requester. `ctx.session.auth.current` stays the requester. `ctx.approval` is absent for calls that needed no approval, and workflow tools don't receive it. `ctx.approval.responder.getToken(provider)` never starts a sign-in: when the approver has no token, it throws a `ConnectionAuthorizationFailedError` with `reason: "approver_authorization_required"`.
|
|
260
|
+
|
|
261
|
+
```ts
|
|
262
|
+
export default defineTool({
|
|
263
|
+
description: "Grant the requester access to a repository.",
|
|
264
|
+
inputSchema: z.object({ repo: z.string() }),
|
|
265
|
+
approval: {
|
|
266
|
+
request: always(),
|
|
267
|
+
response: ({ response }) =>
|
|
268
|
+
itAdmins.includes(response.principal.principalId)
|
|
269
|
+
? { status: "allowed" }
|
|
270
|
+
: { status: "rejected" },
|
|
271
|
+
},
|
|
272
|
+
async execute({ repo }, ctx) {
|
|
273
|
+
const admin = await ctx.approval?.responder.getToken(github);
|
|
274
|
+
if (admin === undefined) throw new Error("An IT admin must approve this grant.");
|
|
275
|
+
return await grantAccess(repo, ctx.session.auth.current, admin.token);
|
|
276
|
+
},
|
|
277
|
+
});
|
|
278
|
+
```
|
|
279
|
+
|
|
259
280
|
For approval requests, a follow-up message that doesn't match an option steers the turn instead of answering it. eve cancels the turn's pending approval, so the call doesn't run and `input.resolved` reports `outcome: "ignored"`, and the model reads the message next. This happens even when the message is sent with `turnPolicy: "queue"`, because a turn held on a person can't end until they act. Calls the person already approved in the same batch still run. A message from someone other than the person the turn serves waits until the turn ends. Cancelling the turn withdraws its approval: the call doesn't run, `input.resolved` reports `outcome: "cancelled"`, and a later answer to it approves nothing.
|
|
260
281
|
|
|
261
282
|
### Several requests at once
|
package/package.json
CHANGED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{D as e,E as t,c as n,l as r,r as i,s as a,u as o}from"./esm-DtrPCf49.js";const s=32768,c={json:p,text:m,inputMessages:e=>ne(e,e=>typeof e==`string`?e:void 0),instructions:re,toolDefinitions:se,outputMessages:ie,toolResults:ae},l=new TextEncoder,u=new TextDecoder;function d(e){return l.encode(e).length}function f(e,t){let n=e.slice(0,t+1),r=l.encode(n);if(n.length===e.length&&r.length<=t)return e;let i=`... [truncated]`.slice(0,t),a=Math.max(0,t-i.length);for(;a>0&&(r[a]&192)==128;)--a;return u.decode(r.subarray(0,a))+i}function ee(e){return typeof e==`string`&&e.length>0&&e.length<=1024&&d(e)<=1024?e:void 0}function te(e){let t=Error(f(e.message,4096));return t.name=f(e.name,128),t.stack=e.stack===void 0?void 0:f(e.stack,8192),t}function p(e){if(e===void 0)return;let t;try{t=JSON.stringify(e)}catch{return}if(t!==void 0)return m(t)}function ne(e,t){if(!Array.isArray(e))return;let n=e.flatMap(e=>{if(!x(e)||e.role===`system`||typeof e.role!=`string`)return[];let n=y(e.content);if(n.length===0)return[];let r=e.role===`user`?t?.(e.kind):void 0;return[r===void 0?{parts:n,role:e.role}:{kind:r,parts:n,role:e.role}]});for(let e=0;e<n.length;e+=1){let t=g(n.slice(e));if(t!==void 0)return t}return le(n)??g([])}function re(e){let t=ce(e);if(t!==void 0)return _(t,e=>[{content:e,type:`text`}])}function ie(e,t){let n=y(e),r=t===`tool-calls`?`tool_call`:t,i=e=>[{finish_reason:r,parts:e,role:`assistant`}];return g(i(n))??_(v(n),e=>i([{content:e,type:`text`}]),!0)}function ae(e){if(e.length===0)return;let t=h(e);if(t!==void 0&&t.length<=32768)return t;for(let t=s;t>=0;t=t>=256?Math.floor(t/2):-1){let n=h(e.map(e=>oe(e,t)));if(n!==void 0&&n.length<=32768)return n}}function oe(e,t){let n={toolName:e.toolName};for(let r of[`input`,`output`,`error`]){if(!(r in e))continue;let i=e[r],a=typeof i==`string`?i:h(i)??``;n[r]=a.length<=t?a:`${a.slice(0,t)}… [truncated]`}return n}function se(e){if(!Array.isArray(e))return;let t=e.flatMap(e=>{if(!x(e)||typeof e.name!=`string`)return[];let t={name:e.name};return typeof e.description==`string`&&(t.description=e.description),e.inputSchema!==void 0&&(t.parameters=e.inputSchema),[t]});if(t.length===0)return;let n=[],r=2;for(let e of t){let t=h(e);if(t===void 0)break;let i=r+(n.length===0?0:1)+t.length;if(i>32768)break;n.push(t),r=i}return`[${n.join(`,`)}]`}function ce(e){if(typeof e==`string`)return e.length===0?void 0:e;if(!x(e)&&!Array.isArray(e))return;let t=Array.isArray(e)?e:[e],n=[];for(let e of t)if(x(e)){if(typeof e.content==`string`)n.push(e.content);else if(Array.isArray(e.content))for(let t of e.content)x(t)&&t.type===`text`&&typeof t.text==`string`&&n.push(t.text)}let r=n.join(`
|
|
2
|
-
|
|
3
|
-
`).trim();return r.length===0?void 0:r}function m(e){if(e.length!==0)return e.length<=32768?e:`${e.slice(0,s)}… [truncated]`}function h(e){try{return JSON.stringify(e)}catch{return}}function g(e){let t=h(e);return t!==void 0&&t.length<=32768?t:void 0}function le(e){let t=e.at(-1);if(t===void 0||typeof t.role!=`string`)return;let n=v(t.parts),r=typeof t.kind==`string`?{kind:t.kind,role:t.role}:{role:t.role};return _(n,e=>[{...r,parts:[{content:e,type:`text`}]}],!0)}function _(e,t,n=!1){if(!n&&e.length<=32768){let n=g(t(e));if(n!==void 0)return n}for(let n=Math.min(e.length,s);n>0;n-=256){let r=g(t(`${e.slice(0,n)}… [truncated]`));if(r!==void 0)return r}return g(t(`… [truncated]`))}function v(e){if(!Array.isArray(e))return``;let t=``;for(let n of e){if(!x(n)||n.type!==`text`||typeof n.content!=`string`)continue;let e=t.length===0?``:`
|
|
4
|
-
`,r=32769-t.length-e.length;if(r<=0)break;t+=e+n.content.slice(0,r)}return t}function y(e){if(typeof e==`string`)return[{content:e,type:`text`}];if(!Array.isArray(e))return[];let t=[];for(let n of e){let e=ue(n);e!==void 0&&t.push(e)}return t}function ue(e){if(x(e)&&typeof e.type==`string`)switch(e.type){case`text`:case`reasoning`:{let t=typeof e.text==`string`?e.text:e.content;return typeof t==`string`?{content:t,type:e.type}:void 0}case`tool-call`:return{arguments:e.input,id:b(e.toolCallId)??b(e.callId)??null,name:e.toolName,type:`tool_call`};case`tool-result`:return{id:b(e.toolCallId)??b(e.callId)??null,response:de(e.output),type:`tool_call_response`};case`tool-error`:return{id:b(e.toolCallId)??b(e.callId)??null,response:e.error instanceof Error?e.error.message:e.error,type:`tool_call_response`};default:return{type:e.type}}}function de(e){return x(e)?(e.type===`text`||e.type===`error-text`||e.type===`json`||e.type===`error-json`)&&`value`in e?e.value:e.type===`execution-denied`?{denied:!0,reason:e.reason}:e:e}function b(e){return typeof e==`string`?e:void 0}function x(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function fe(e,t,n){e.setAttribute(`error.type`,f(n??(t instanceof Error?t.name:`_OTHER`),128));let i=t!==void 0&&!(t instanceof Error);if(i){let e=p(t),n=typeof t==`object`&&t?Reflect.get(t,`message`):void 0,r=typeof t==`string`?m(t):typeof n==`string`?m(e===void 0?n:`${n}\n${e}`):e;r!==void 0&&(t=Error(r))}if(t instanceof Error){let a=te(t);i&&n!==void 0&&(a.name=f(n,128)),e.recordException(a),e.setStatus({code:r.ERROR,message:a.message})}else e.setStatus({code:r.ERROR})}function S(e,t){let n=e.emit&&(t?.emit??!0);return{emit:n,recordInputs:n&&e.recordInputs&&(t?.recordInputs??!0),recordOutputs:n&&e.recordOutputs&&(t?.recordOutputs??!0)}}function pe(e,t){let n=e.mcp;return{type:e.type,reference:e.reference,capture:t,mcp:n===void 0?void 0:{update:e=>n.update(e),error:(e,r)=>n.error(t.recordOutputs?e:void 0,r??(e instanceof Error?e.name:void 0)),arguments:e=>{t.recordInputs&&n.arguments(e)},result:e=>{t.recordOutputs&&n.result(e)}}}}const C=e(`agent.tracing.capture`);function me(){return a.active().getValue(C)}function w(e,t){return e.setValue(C,t)}const T=e(`agent.tracing.active-operation`),E=e(`OpenTelemetry SDK Context Key SUPPRESS_TRACING`);function D(e,t){return w(e,{emit:!0,recordInputs:t,recordOutputs:t})}function O(e){return e.setValue(E,!0)}function k(e=a.active()){return typeof e.getValue==`function`?e.getValue(T):void 0}function he(e,n){let r=n??t;return e===void 0?r:i.setSpan(r,i.wrapSpanContext(A(e)))}function A(e){return{...e,traceState:e.tracestate===void 0?void 0:n(e.tracestate)}}function ge(e){return{traceId:e.traceId,spanId:e.spanId,traceFlags:e.traceFlags,isRemote:e.isRemote,tracestate:e.traceState?.serialize()}}function j(e,t,n){return e?.attributes(t,n)??n}const _e={attributes(e,t){let n=t[`agent.run.id`];return ve()&&typeof n==`string`&&t[`vercel.session_id`]===void 0?{...t,"vercel.session_id":n}:t},link:(e,t)=>({"agent.link.type":t.relationship})};function ve(){return globalThis.process?.env?.VERCEL_ENV!==void 0}function M(e={}){let n=e.provider??i.getTracerProvider(),s=n.getTracer(e.tracerName??`agent.tracing`,e.tracerVersion),c=e.mapping??_e,l=e.idGenerator;function u(t){return e[t]??(async()=>{let e=n[t];if(e===void 0)throw Error(`The tracer provider does not support ${t}.`);await e.call(n)})}function d(e,t){let n=s.startSpan(e.name,{attributes:j(c,e,e.attributes),kind:e.kind===void 0?void 0:o[e.kind],root:e.root,startTime:e.startTimeMs,links:e.links?.map(t=>({context:A(t.context),attributes:c?.link(e,t)??{"agent.link.type":t.relationship}}))},he(e.root?void 0:e.parent,t));return{reference:ge(n.spanContext()),setAttribute(t,r){for(let[i,a]of Object.entries(j(c,e,{[t]:r})))a!==void 0&&n.setAttribute(i,a)},addEvent:(e,t,r)=>{n.addEvent(e,t,r)},fail:(e,t)=>fe(n,e,t),setStatus:e=>{n.setStatus({code:r[e]})},end:e=>{n.end(e)}}}return{startSpan(e,{reference:t,context:n}={}){if(t===void 0||l===void 0)return d(e,n);let r=l.withTraceId(t.traceId,()=>l.withSpanId(t.spanId,()=>d(e,n)));if(r.reference.spanId!==t.spanId||r.reference.traceId!==t.traceId)throw Error(`The tracer provider must use the telemetry's ID generator.`);return r},active:()=>k(),suppressed(e){return a.with(D(O(t),!1),e)},run(e,t,n){let r=S(e.capture,k()?.capture),o=i.setSpan(n??a.active(),i.wrapSpanContext(A(e.reference)));return r=S(r,o.getValue(T)?.capture),o=o.setValue(T,pe(e,r)),o=w(o,r),(!r.emit||!(e.reference.traceFlags&1))&&(o=O(o)),a.with(o,t)},samples:(t,n)=>e.samplesTrace?.(t,{name:n.name,attributes:j(c,n,n.attributes)})??!0,ids:l===void 0?void 0:{traceId:e=>l.deriveTraceId(e),spanId:e=>l.deriveSpanId(e)},forceFlush:u(`forceFlush`),shutdown:u(`shutdown`)}}const N=new Set([`agent.channel.delivery.input`,`agent.session.title`,`agent.approval.request`,`ai.documents`,`ai.prompt`,`ai.prompt.toolChoice`,`ai.prompt.tools`,`ai.value`,`ai.values`,`gen_ai.input.messages`,`gen_ai.memory.records`,`gen_ai.system_instructions`,`gen_ai.tool.call.arguments`,`gen_ai.tool.definitions`]),P=new Set([`agent.approval.response`,`ai.embedding`,`ai.embeddings`,`ai.ranking`,`ai.response.files`,`ai.response.object`,`ai.response.reasoning`,`ai.response.text`,`ai.response.toolCalls`,`ai.response.tool_calls`,`ai.response.tool_results`,`ai.toolCall.args`,`ai.toolCall.result`,`gen_ai.output.messages`,`gen_ai.tool.call.result`]),F=`agent.trace.content.input`,I=`agent.trace.content.output`;function L(e,t){return!t.recordInputs&&N.has(e)?!0:!t.recordOutputs&&P.has(e)}function R(e,t){return!t.recordInputs&&e[F]===!0||!t.recordOutputs&&e[I]===!0}function ye(e,t,n){return e===F&&t===!0&&!n.recordInputs||e===I&&t===!0&&!n.recordOutputs?!1:t}function z(e,t){let n=Object.keys(e);if(!n.some(e=>L(e,t))&&!R(e,t))return;let r={};for(let i of n)L(i,t)||(r[i]=ye(i,e[i],t));return r}const B={costUsd:`agent.usage.cost_usd`,inputTokens:`agent.usage.input_tokens`,outputTokens:`agent.usage.output_tokens`,cacheReadTokens:`agent.usage.cache_read_tokens`,cacheWriteTokens:`agent.usage.cache_write_tokens`};function be(e){return{"agent.run.id":e.runId,"agent.trace.schema.version":4,"gen_ai.conversation.id":e.conversationId}}function V(e,t=e){return{"operation.name":t,"resource.name":e}}function H(e){return{"agent.framework.name":e?.name||void 0,"agent.framework.version":e?.version||void 0}}function U(e,t=!1){return t?{[B.costUsd]:e.costUsd,"gen_ai.usage.input_tokens":e.inputTokens,"gen_ai.usage.output_tokens":e.outputTokens,"gen_ai.usage.cache_read.input_tokens":e.inputTokenDetails?.cacheReadTokens,"gen_ai.usage.cache_write.input_tokens":e.inputTokenDetails?.cacheWriteTokens}:{[B.costUsd]:e.costUsd,[B.inputTokens]:e.inputTokens,[B.outputTokens]:e.outputTokens,[B.cacheReadTokens]:e.inputTokenDetails?.cacheReadTokens,[B.cacheWriteTokens]:e.inputTokenDetails?.cacheWriteTokens}}function W(e){let t={},n=new WeakSet,r=256;function i(e,a,o){if(!(r<=0||o>8||a==null)){if(typeof a==`string`||typeof a==`number`||typeof a==`boolean`)t[e]=a,--r;else if(Array.isArray(a))a.length<=256&&a.every(e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`)&&new Set(a.map(e=>typeof e)).size===1&&(t[e]=a,--r);else if(typeof a==`object`&&!n.has(a)){n.add(a);for(let t of Object.keys(a)){if(r<=0)break;i(`${e}.${t}`,Reflect.get(a,t),o+1)}n.delete(a)}}}return e!==void 0&&i(`ai.settings.context`,e,0),t}const G=e=>e===void 0?`invoke_agent`:`invoke_agent ${e}`,K=e=>`chat ${e}`,q=e=>`execute_tool ${e}`,J={approval:`agent.approval`,step:`agent.step`},Y={toolArguments:`gen_ai.tool.call.arguments`,toolResult:`gen_ai.tool.call.result`,approvalRequest:`agent.approval.request`,approvalResponse:`agent.approval.response`,memoryRecords:`gen_ai.memory.records`};function X(e,t){for(let[n,r]of Object.entries(t))r!==void 0&&e.setAttribute(n,r)}function Z(e){return{"agent.turn.id":e.attempt.turnId,"agent.step.index":e.attempt.index,"agent.step.attempt":e.attempt.attempt}}function Q(e,t){return z(e??{},t)??e}function xe(e,t){return{[Y.toolArguments]:t.capture.recordInputs?t.serializer.json(e):void 0}}function Se(e,t,n){n.capture.recordOutputs&&X(e,{[Y.toolResult]:n.serializer.json(t.output)})}const Ce={activation:{parents:[],prepare({options:e},t){let{identity:n,capture:r}=t;return{name:G(n.agentName),attributes:{...t.attributes,...H(n.framework),...V(G(n.agentName),`invoke_agent`),"agent.channel.kind":e.channel?.kind,"agent.session.origin":e.channel?.origin,"agent.name":n.agentName,"gen_ai.agent.name":n.agentName,"gen_ai.operation.name":`invoke_agent`,"agent.turn.id":n.turnId,"agent.turn.sequence":e.sequence,"agent.run.type":e.subagent?`subagent`:`session`,"agent.parent_call.id":e.parentCallId,"agent.parent_run.id":e.parentRunId,"agent.subagent.name":e.subagentName,"agent.trace.content.input":r.recordInputs,"agent.trace.content.output":r.recordOutputs,...Q(e.attributes,r)}}},complete(e,t,n,r){e.addEvent(`turn.started`,void 0,r.startTimeMs),(n.outcomeUnknown!==!0||n.failed===!0)&&e.addEvent(`turn.${r.outcome}`,void 0,n.endTimeMs)},redact(e,t){return{...e,options:{...e.options,attributes:Q(e.options.attributes,t)}}}},step:{parents:[`activation`],prepare({options:e},t){return{name:J.step,attributes:{...t.attributes,...H(t.identity.framework),...Z(t),...V(J.step,`workflow`),"gen_ai.operation.name":`workflow`,"agent.name":t.identity.agentName,"agent.channel.kind":e.channel?.kind===`unknown`?void 0:e.channel?.kind,"agent.session.origin":e.channel?.kind===`unknown`?void 0:e.channel?.origin,...W(e.runtimeContext)}}},complete(e,t,n){e.addEvent(n.failed?`step.failed`:`step.completed`,void 0,n.endTimeMs)}},model:{parents:[`step`],prepare({options:e},t){return{name:K(e.modelId),kind:`CLIENT`,attributes:{...t.attributes,...V(K(e.modelId),`chat`),"gen_ai.agent.name":t.identity.agentName,"gen_ai.operation.name":`chat`,"gen_ai.provider.name":e.provider,"gen_ai.request.model":e.modelId,...W(e.runtimeContext),...t.capture.recordInputs&&e.messages!==void 0?{"gen_ai.input.messages":t.serializer.inputMessages(e.messages),"gen_ai.system_instructions":t.serializer.instructions(e.instructions)}:void 0,"gen_ai.tool.definitions":t.capture.recordInputs?t.serializer.toolDefinitions(e.tools):void 0}}},complete(e,t,n,r){n.model!==void 0&&X(e,Oe(n.model,r.serializer,r.capture.recordOutputs))},redact(e,t){return t.recordInputs?e:{...e,options:{...e.options,messages:void 0,instructions:void 0,tools:void 0}}}},tool:{parents:[`step`,`tool`],prepare({options:e},t){let n=e.kind===`subagent-call`||e.kind===`remote-agent-call`;return{name:q(e.name),kind:e.kind===`remote-agent-call`?`CLIENT`:`INTERNAL`,attributes:{...t.attributes,...H(t.identity.framework),...Z(t),...V(q(e.name),`execute_tool`),"gen_ai.agent.name":n?e.name:t.identity.agentName,"gen_ai.operation.name":`execute_tool`,"gen_ai.tool.call.id":e.callId,"gen_ai.tool.name":e.name,"gen_ai.tool.type":`function`,"agent.action.kind":e.kind,"agent.action.name":e.kind===void 0?void 0:e.name,"agent.invocation.role":n?`caller`:void 0,...xe(e.arguments,t)}}},complete(e,t,n,r){n.outcome!==void 0&&X(e,{"agent.action.outcome":n.outcome}),Se(e,n,r)},redact(e,t){return t.recordInputs?e:{...e,options:{...e.options,arguments:void 0}}}},approval:{parents:[`tool`],prepare({options:e},t){return{name:J.approval,attributes:{...t.attributes,...H(t.identity.framework),...Z(t),...V(J.approval,`workflow`),"gen_ai.operation.name":`workflow`,"gen_ai.tool.call.id":e.callId,"agent.action.name":e.toolName,"agent.approval.kind":`tool-approval`,"agent.approval.request_id":e.requestId,[Y.approvalRequest]:t.capture.recordInputs?t.serializer.json(e.request):void 0}}},complete(e,t,n,r){r.capture.recordOutputs&&X(e,{[Y.approvalResponse]:r.serializer.json(n.response)})},redact(e,t){return t.recordInputs?e:{...e,options:{...e.options,request:void 0}}}},memory:{parents:[`activation`,`step`,`tool`],prepare({options:e},t){return{name:e.operation,kind:`CLIENT`,attributes:{...t.attributes,...V(e.operation),"gen_ai.operation.name":e.operation,"gen_ai.memory.store.id":e.storeId,"agent.memory.phase":e.phase,"agent.memory.slot":e.slot,"agent.turn.id":t.identity.turnId}}},complete(e,t,n,r){n.recordCount!==void 0&&X(e,{"gen_ai.memory.record.count":n.recordCount}),r.capture.recordInputs&&X(e,{[Y.memoryRecords]:r.serializer.json(n.records)})}}};function $(e){return Ce[e.type]}function we(e){return $(e).parents}function Te(e,t){let n={identity:e.identity,attributes:be(e.identity),attempt:{turnId:e.identity.turnId,index:e.attempt?.index??0,attempt:e.attempt?.attempt??0},capture:e.capture,serializer:t};return{type:e.data.type,operationId:e.key,kind:`INTERNAL`,...$(e.data).prepare(e.data,n),parent:e.parent,root:e.data.type===`activation`&&e.parent===void 0,startTimeMs:e.startTimeMs,links:e.links}}function Ee(e,t,n,r,i,a){let o=n.outcome??(n.failed?`failed`:`completed`),s=n.outcomeUnknown!==!0||n.failed===!0;(t.type===`activation`||t.type===`approval`)&&s&&X(e,{[t.type===`activation`?`agent.turn.outcome`:`agent.approval.outcome`]:o}),n.usage!==void 0&&X(e,U(n.usage,t.type===`activation`||t.type===`model`)),$(t).complete?.(e,t,n,{capture:r,startTimeMs:i,serializer:a,outcome:o}),n.failed&&e.fail(n.error,n.errorCode)}function De(e,t){return t.emit||(t={emit:!1,recordInputs:!1,recordOutputs:!1}),$(e).redact?.(e,t)??e}function Oe(e,t,n){let r={...U(e.usage,!0),"gen_ai.response.id":e.responseId,"gen_ai.response.model":e.responseModelId,"gen_ai.response.finish_reasons":[e.finishReason]};if(!n)return r;r[`ai.response.finish_reason`]=e.finishReason;let i=e.content;if(i===void 0)return r;r[`gen_ai.output.messages`]=t.outputMessages(i,e.finishReason),r[`ai.response.reasoning`]=t.text(i.filter(e=>e.type===`reasoning`).map(e=>e.text).filter(e=>e.trim().length>0).join(`
|
|
5
|
-
`)),r[`ai.response.text`]=t.text(i.filter(e=>e.type===`text`).map(e=>e.text).join(``));let a=i.filter(e=>e.type===`tool-call`).map(e=>({callId:e.callId,input:e.input,toolName:e.toolName}));a.length>0&&(r[`ai.response.tool_calls`]=t.json(a));let o=i.filter(e=>e.type===`tool-result`||e.type===`tool-error`).map(e=>e.type===`tool-result`?{callId:e.callId,input:e.input,output:e.output,toolName:e.toolName}:{callId:e.callId,input:e.input,error:e.error instanceof Error?e.error.message:e.error,toolName:e.toolName});return o.length>0&&(r[`ai.response.tool_results`]=t.toolResults(o)),r}function ke(e){return{update(t){t.connectionName!==void 0&&t.method!==void 0&&e.write({"agent.connection.name":t.connectionName,"mcp.method.name":t.method,"network.protocol.name":`http`,"network.transport":`tcp`,"mcp.protocol.version":t.protocolVersion,"jsonrpc.request.id":t.requestId,"gen_ai.operation.name":t.method===`tools/call`?`execute_tool`:void 0,"gen_ai.tool.name":t.method===`tools/call`?t.toolName:void 0}),t.sessionId!==void 0&&e.write({"mcp.session.id":t.sessionId}),t.statusCode!==void 0&&e.write({"rpc.response.status_code":t.statusCode})},error(t,n){e.error(e.recordOutputs?t:void 0,n??(t instanceof Error?t.name:void 0))},arguments(t){e.recordInputs&&e.write({"gen_ai.tool.call.arguments":e.serializer.json(t)})},result(t){e.recordOutputs&&e.write({"gen_ai.tool.call.result":e.serializer.json(t)})}}}export{f as S,s as _,G as a,p as b,B as c,k as d,M as f,S as g,w as h,Ee as i,U as l,me as m,X as n,we as o,D as p,De as r,Te as s,ke as t,z as u,c as v,d as x,ee as y};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{isSessionInboxAddress}from"#execution/session-inbox/address.js";import{inputOptionSchema}from"#shared/input.js";const PROXY_INPUT_REQUESTS_KEY=`eve.runtime.proxyInputRequests`,PROXY_INPUT_REQUEST_KINDS={question:!0,"session-limit":!0,"tool-approval":!0};function resolvedByChild(e){return e===`tool-approval`}function resolvedForParent(e){let t=e.resolutions.filter(({kind:e})=>resolvedByChild(e));return t.length===0?void 0:{...e,resolutions:t}}function getProxyInputRequests(e){return new Map(Object.entries(readMap(e)))}function hasProxyInputRequests(e){for(let t of Object.keys(readMap(e)))return!0;return!1}function upsertProxyInputRequests(e){return{...e.session,state:upsertProxyInputRequestState({entries:e.entries,forChildContinuationToken:e.forChildContinuationToken,inputSource:e.inputSource,state:e.session.state})}}function upsertProxyInputRequestState(e){let t={};for(let[n,r]of Object.entries(readMap(e.state)))(r.childContinuationToken!==e.forChildContinuationToken||r.inputSource!==e.inputSource)&&(t[n]=r);for(let[n,r]of e.entries)t[n]=r;let n={...e.state};return Object.keys(t).length===0?delete n[PROXY_INPUT_REQUESTS_KEY]:n[PROXY_INPUT_REQUESTS_KEY]=t,Object.keys(n).length>0?n:void 0}function clearProxyInputRequestsWhere(e,t){return retireProxyInputRequests(e,Object.entries(readMap(e.state)).filter(([e,n])=>t(n,e)).map(([e])=>e))}function retireProxyInputRequests(e,t){let n={...readMap(e.state)},r=!1;for(let e of t)Object.hasOwn(n,e)&&(delete n[e],r=!0);return r?writeMap(e,n):e}function toProxyInputRequestEntries(e){let t={approvalRequestIds:e.event.requests.flatMap(e=>e.kind===`tool-approval`?[e.requestId]:[]),requestIds:e.event.requests.map(e=>e.requestId)},n={sequence:e.event.sequence,stepIndex:e.event.stepIndex,turnId:e.event.turnId};return e.event.requests.map(r=>{let i={batch:t,childContinuationToken:e.childContinuationToken,...e.inputSource!==void 0&&{inputSource:e.inputSource},...e.remote!==void 0&&{remote:e.remote},event:n,kind:r.kind,reply:{...r.allowFreeform!==void 0&&{allowFreeform:r.allowFreeform},...r.options!==void 0&&{options:[...r.options]}}};return e.childSessionInbox?.sessionId===e.childSessionId&&(i.childSessionInbox=e.childSessionInbox),[r.requestId,i]})}function readMap(e){let t=e?.[PROXY_INPUT_REQUESTS_KEY];if(typeof t!=`object`||!t||Array.isArray(t))return{};let n={};for(let[e,r]of Object.entries(t)){let t=parseProxyInputRequest(r,e);t!==void 0&&(n[e]=t)}return n}function writeMap(e,t){let n={...e.state};return Object.keys(t).length===0?(delete n[PROXY_INPUT_REQUESTS_KEY],{...e,state:Object.keys(n).length>0?n:void 0}):(n[PROXY_INPUT_REQUESTS_KEY]=t,{...e,state:n})}function parseProxyInputRequest(e,t){if(typeof e!=`object`||!e||Array.isArray(e)||!(`childContinuationToken`in e)||!(`kind`in e)||typeof e.childContinuationToken!=`string`||!isInputRequestKind(e.kind))return;let n=`remote`in e?parseRemoteAgentBinding(e.remote):void 0;if(`remote`in e&&n===void 0)return;let r=`inputSource`in e?e.inputSource:void 0;if(r!==void 0&&(typeof r!=`string`||r.length===0))return;let i=`event`in e?parseInputRequestEvent(e.event):void 0;if(i===void 0)return;let a=`batch`in e?parseProxyInputRequestBatch(e.batch):void 0,o=`workflowAsk`in e?parseWorkflowAskRoute(e.workflowAsk):void 0;if(`workflowAsk`in e&&o===void 0)return;let s=`runId`in e?e.runId:void 0;if(s!==void 0&&(typeof s!=`string`||s.length===0))return;let c=`reply`in e?parseProxyInputReply(e.reply):void 0;if(`reply`in e&&c===void 0)return;let l=`childSessionInbox`in e?e.childSessionInbox:void 0;if(l!==void 0&&!isSessionInboxAddress(l))return;let u={childContinuationToken:e.childContinuationToken,event:i,kind:e.kind};return typeof r==`string`&&(u.inputSource=r),n!==void 0&&(u.remote=n),o!==void 0&&(u.workflowAsk=o),typeof s==`string`&&(u.runId=s),l!==void 0&&(u.childSessionInbox=l),a!==void 0&&a.requestIds.includes(t)&&(u.batch=a),c!==void 0&&(u.reply=c),u}function parseInputRequestEvent(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=Reflect.get(e,`sequence`),n=Reflect.get(e,`stepIndex`),r=Reflect.get(e,`turnId`);if(typeof t==`number`&&typeof n==`number`&&typeof r==`string`)return{sequence:t,stepIndex:n,turnId:r}}function parseWorkflowAskRoute(e){if(typeof e!=`object`||!e)return;let t=Reflect.get(e,`control`);if(typeof t==`string`&&t.length!==0)return{control:t}}function parseRemoteAgentBinding(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=Reflect.get(e,`name`),n=Reflect.get(e,`url`),r=Reflect.get(e,`resolverId`),i=Reflect.get(e,`forwardPrincipal`),a=Reflect.get(e,`sessionId`);if(typeof t==`string`&&t&&typeof n==`string`&&n&&typeof a==`string`&&a&&(r===void 0||typeof r==`string`&&r)&&(i===void 0||typeof i==`boolean`))return{name:t,url:n,sessionId:a,...r!==void 0&&{resolverId:r},...i!==void 0&&{forwardPrincipal:i}}}function parseProxyInputReply(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t={},n=Reflect.get(e,`allowFreeform`);if(n!==void 0){if(typeof n!=`boolean`)return;t.allowFreeform=n}let r=Reflect.get(e,`options`);if(r!==void 0){let e=inputOptionSchema.array().safeParse(r);if(!e.success)return;t.options=e.data}return t}function parseProxyInputRequestBatch(e){if(typeof e!=`object`||!e||Array.isArray(e)||!(`approvalRequestIds`in e)||!(`requestIds`in e)||!isStringArray(e.approvalRequestIds)||!isStringArray(e.requestIds))return;let t=new Set(e.requestIds);if(!(t.size!==e.requestIds.length||e.approvalRequestIds.some(e=>!t.has(e))))return{approvalRequestIds:e.approvalRequestIds,requestIds:e.requestIds}}function isStringArray(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function isInputRequestKind(e){return typeof e==`string`&&Object.hasOwn(PROXY_INPUT_REQUEST_KINDS,e)}export{clearProxyInputRequestsWhere,getProxyInputRequests,hasProxyInputRequests,resolvedByChild,resolvedForParent,retireProxyInputRequests,toProxyInputRequestEntries,upsertProxyInputRequestState,upsertProxyInputRequests};
|