eve 0.84.0 → 0.84.1
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 +16 -0
- package/dist/src/channel/cross-channel-receive.d.ts +4 -1
- package/dist/src/channel/cross-channel-receive.js +1 -1
- package/dist/src/channel/delivery.js +1 -1
- package/dist/src/channel/session.js +1 -1
- package/dist/src/channel/types.d.ts +2 -0
- package/dist/src/chunks/{use-eve-agent-BbbguIdB.js → use-eve-agent-DMeP0JOF.js} +26 -10
- package/dist/src/chunks/{use-eve-agent-DWjyzplb.js → use-eve-agent-DP5Rso9C.js} +26 -10
- package/dist/src/cli/commands/init.js +1 -1
- package/dist/src/client/delivery.d.ts +2 -0
- package/dist/src/client/delivery.js +1 -1
- package/dist/src/client/optimistic-message-submissions.js +1 -1
- package/dist/src/client/session-store.js +1 -1
- package/dist/src/client/session.js +1 -1
- package/dist/src/client/sessions.d.ts +1 -0
- package/dist/src/client/sessions.js +1 -1
- package/dist/src/client/types.d.ts +2 -0
- package/dist/src/compiled/.vendor-stamp.json +2 -2
- package/dist/src/compiled/@chat-adapter/slack/index.js +13 -13
- package/dist/src/compiled/@vercel/sandbox/api-client/api-client.d.ts +75 -0
- package/dist/src/compiled/@vercel/sandbox/api-client/validators.d.ts +4 -0
- package/dist/src/compiled/@vercel/sandbox/command.d.ts +78 -0
- package/dist/src/compiled/@vercel/sandbox/drive.d.ts +41 -1
- package/dist/src/compiled/@vercel/sandbox/index.js +13 -13
- package/dist/src/compiled/@vercel/sandbox/network-policy.d.ts +35 -4
- package/dist/src/compiled/@vercel/sandbox/sandbox.d.ts +18 -4
- package/dist/src/compiled/@vercel/sandbox/session.d.ts +29 -3
- package/dist/src/compiled/@vercel/sandbox/utils/pipe-stdin.d.ts +19 -0
- package/dist/src/compiled/_chunks/client/{core-CspsxXR-.js → core-BsvaaMUJ.js} +1 -1
- package/dist/src/compiled/_chunks/node/{auth-Dztlx9pE.js → auth-v5pS3mLo.js} +1 -1
- package/dist/src/compiled/_chunks/node/is-stream-DsuQX_bd.js +1 -0
- package/dist/src/compiled/_chunks/node/token-DHGH-jVc.js +1 -0
- package/dist/src/compiled/_chunks/node/token-util-BH2pw9Qm.js +25 -0
- package/dist/src/compiled/_chunks/node/token-util-CcvxNv76.js +1 -0
- package/dist/src/compiled/_chunks/node/version-C2PfNyEv.js +1 -0
- package/dist/src/compiled/zod/index.js +1 -1
- package/dist/src/compiled/zod/v4/core.js +1 -1
- package/dist/src/compiled/zod-validation-error/index.js +1 -1
- package/dist/src/compiler/artifacts.d.ts +1 -0
- package/dist/src/compiler/artifacts.js +1 -1
- package/dist/src/compiler/manifest.d.ts +2 -2
- package/dist/src/compiler/manifest.js +1 -1
- package/dist/src/compiler/model-catalog.d.ts +8 -18
- package/dist/src/compiler/model-catalog.js +1 -1
- package/dist/src/compiler/normalize-agent-config.js +1 -1
- package/dist/src/compiler/normalize-manifest-types.d.ts +3 -0
- package/dist/src/compiler/normalize-manifest.js +1 -1
- package/dist/src/context/keys.d.ts +0 -8
- package/dist/src/context/keys.js +1 -1
- package/dist/src/eve-channel/index.js +1 -1
- package/dist/src/eve-channel/request.d.ts +1 -0
- package/dist/src/eve-channel/request.js +1 -1
- package/dist/src/eve-channel/support.js +1 -1
- package/dist/src/execution/agent-sessions/steps.js +1 -1
- package/dist/src/execution/dynamic-workflow/tool.js +1 -1
- package/dist/src/execution/sandbox/bindings/docker-cli.d.ts +2 -0
- package/dist/src/execution/sandbox/bindings/docker-cli.js +1 -1
- package/dist/src/execution/sandbox/bindings/docker-connection.js +1 -1
- package/dist/src/execution/sandbox/bindings/just-bash-runtime.js +1 -1
- package/dist/src/execution/sandbox/bindings/vercel.js +1 -1
- package/dist/src/execution/sandbox/multiplexed-command.d.ts +11 -1
- package/dist/src/execution/sandbox/multiplexed-command.js +1 -1
- package/dist/src/execution/sandbox/session.js +1 -1
- package/dist/src/execution/session-inbox/address.d.ts +1 -0
- package/dist/src/execution/session-inbox/handle.d.ts +7 -0
- package/dist/src/execution/session-inbox/handle.js +1 -0
- package/dist/src/execution/session-inbox/owner.d.ts +4 -4
- package/dist/src/execution/session-inbox/owner.js +1 -1
- package/dist/src/execution/session-inbox/resume.d.ts +1 -0
- package/dist/src/execution/session-inbox/resume.js +1 -1
- package/dist/src/execution/tools/agent-router-workflow.js +1 -1
- package/dist/src/execution/workflow-runtime.js +1 -1
- package/dist/src/harness/model-call/call.d.ts +3 -1
- package/dist/src/harness/model-call/call.js +1 -1
- package/dist/src/harness/model-call/run.js +1 -1
- package/dist/src/harness/semantic-errors/rules/gateway.js +1 -1
- package/dist/src/internal/application/compiled-artifacts.d.ts +2 -0
- package/dist/src/internal/application/compiled-artifacts.js +2 -2
- package/dist/src/internal/application/optional-package-install.js +1 -1
- package/dist/src/internal/application/stamped-package-version.js +1 -1
- package/dist/src/internal/model-catalog.d.ts +39 -16
- package/dist/src/internal/model-catalog.js +1 -1
- package/dist/src/internal/nitro/host/dev-build-host.js +1 -1
- package/dist/src/internal/nitro/routes/channel-dispatch.js +1 -1
- package/dist/src/protocol/delivery.d.ts +1 -0
- package/dist/src/public/nuxt/module.js +1 -1
- package/dist/src/reactions/kinds/model.js +1 -1
- package/dist/src/reactions/kinds/subagent.js +1 -1
- package/dist/src/runtime/agent/resolve-model.d.ts +3 -4
- package/dist/src/runtime/agent/resolve-model.js +1 -1
- package/dist/src/runtime/loaders/artifact-paths.d.ts +1 -0
- package/dist/src/runtime/loaders/artifact-paths.js +1 -1
- package/dist/src/runtime/loaders/bundled-artifacts.d.ts +2 -0
- package/dist/src/runtime/loaders/bundled-artifacts.js +1 -1
- package/dist/src/runtime/loaders/model-metadata.d.ts +4 -0
- package/dist/src/runtime/loaders/model-metadata.js +1 -0
- package/dist/src/runtime/resolve-agent.js +1 -1
- package/dist/src/runtime/sessions/compiled-agent-cache.d.ts +3 -0
- package/dist/src/runtime/sessions/compiled-agent-cache.js +1 -1
- package/dist/src/runtime/subagents/dynamic-agent-config.d.ts +2 -2
- package/dist/src/runtime/subagents/dynamic-agent-config.js +1 -1
- package/dist/src/runtime/subagents/workflow.js +1 -1
- package/dist/src/sandbox/provider.d.ts +2 -0
- package/dist/src/setup/flows/model-source-change.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/shared/agent-definition.d.ts +0 -1
- package/dist/src/shared/sandbox-session.d.ts +4 -0
- package/dist/src/svelte/index.js +1 -1
- package/dist/src/svelte/use-eve-agent.js +1 -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/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/agent-config.md +5 -4
- package/docs/concepts/default-harness.md +6 -0
- package/docs/evals/judge.mdx +13 -0
- package/docs/guides/client/overview.mdx +23 -1
- package/docs/reference/cli.md +1 -1
- package/docs/sandbox/custom-providers.mdx +1 -1
- package/docs/sandbox/index.mdx +1 -1
- package/docs/tools/workflows.mdx +4 -0
- package/package.json +2 -2
- package/dist/src/compiled/_chunks/node/token-Bedbhv5z.js +0 -1
- package/dist/src/compiled/_chunks/node/token-util-DpJNusVS.js +0 -1
- package/dist/src/compiled/_chunks/node/token-util-DwHQ2a3c.js +0 -1
- package/dist/src/compiled/_chunks/node/version-C__MqbLM.js +0 -1
- package/dist/src/runtime/agent/model-catalog.d.ts +0 -10
- package/dist/src/runtime/agent/model-catalog.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# eve
|
|
2
2
|
|
|
3
|
+
## 0.84.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 41916a5: Dynamic models, dynamic subagent configs, and `ctx.agent(name, { model })` overrides now read context windows from the AI Gateway model catalog recorded at build time instead of downloading it at runtime; a model that catalog doesn't list fails until you return `modelContextWindowTokens` or rebuild. Builds no longer carry built-in limits for `anthropic/claude-opus-4.7`, `openai/gpt-5.4`, and `openai/gpt-5.4-mini`, so a static model needs the catalog, a cached copy, or `modelContextWindowTokens` to compile offline.
|
|
8
|
+
- b322096: A compaction that fails during a turn, for example on a provider 429 that outlasts its retries, now fails that turn with `MODEL_CALL_FAILED` and leaves the session waiting with its history uncompacted. Previously the error escaped the turn step, so eve replayed the step and then ended the session. Thanks @gshost1 for the report and reproduction in #5350.
|
|
9
|
+
- 4276727: Messages a route forwards with `ctx.to()` now carry the deployment and request that accepted them, so an idle session reached that way hands off to the new deployment like one reached with `from()`. Thanks @haydenbleasel for reporting this in #5408.
|
|
10
|
+
- bea10fd: Model calls that AI Gateway rejects with a 402 because it temporarily throttled the credit balance check now retry with backoff. They previously reported "AI Gateway credit balance exhausted", told users to add credits, and parked the session without retrying.
|
|
11
|
+
- 105bf60: `eve init apps/my-agent` now creates missing parent directories such as `apps/` instead of failing with `ENOENT` from `mkdtemp`. Thanks @otakusboy for reporting this in #5422.
|
|
12
|
+
- 5bb6d43: Nuxt apps that call the auto-imported `useEveAgent()` now hydrate in `nuxt dev`. The `eve/nuxt` module pre-bundles `eve/vue` with Vite, which previously served its CommonJS dependencies to the browser unbundled and failed with `does not provide an export named 'getContext'`.
|
|
13
|
+
- cb1db12: Sending a message from a web client served over plain HTTP on a host other than `localhost` no longer fails with `crypto.randomUUID is not a function`. Thanks @KingAmo for reporting this in #5415.
|
|
14
|
+
- 5458bc4: Reuse signed inbox routing information between client turns when the Workflow SDK and adapter support guarded resumes and `EVE_INBOX_HANDLE_SECRET` is configured. Refresh stale routing after a confirmed refusal without retrying uncertain deliveries.
|
|
15
|
+
- a5328b4: `sandbox.spawn({ stdin: true })` returns a process with a writable `stdin` stream; closing it sends EOF. The Vercel and Docker sandboxes support it, and just-bash and custom providers without stdin support reject the call.
|
|
16
|
+
- 66103be: `eve dev` on Windows no longer opens a console window for each Docker command, dev build process, or optional package install. Thanks @satish860 for reporting this in #5291.
|
|
17
|
+
- 040519a: The browser client no longer triggers a Content Security Policy `eval` violation on pages whose `script-src` omits `'unsafe-eval'`. eve's bundled Zod now skips its `Function("")` probe and always uses its interpreted parser. Your app's own Zod and `z.config()` are not affected. Thanks @wasimxyz for reporting this in #5365.
|
|
18
|
+
|
|
3
19
|
## 0.84.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { MessageContent } from "#shared/message-content.js";
|
|
2
2
|
import type { ChannelAdapter } from "#channel/adapter.js";
|
|
3
3
|
import { type ChannelReference, type CompiledChannel } from "#channel/compiled-channel.js";
|
|
4
|
+
import type { ChannelDeliverySource } from "#channel/delivery-metadata.js";
|
|
4
5
|
import type { InferReceiveTarget } from "#channel/receive-target.js";
|
|
5
6
|
import type { Delivery } from "#shared/delivery.js";
|
|
6
7
|
import type { Runtime, SessionAuthContext, TurnPolicy } from "#channel/types.js";
|
|
@@ -30,6 +31,8 @@ export interface CrossChannelTarget {
|
|
|
30
31
|
readonly adapter?: ChannelAdapter;
|
|
31
32
|
readonly turnPolicy?: CompiledChannel["turnPolicy"];
|
|
32
33
|
}
|
|
34
|
+
/** What a forwarded delivery inherits from the caller; the target channel supplies its own name. */
|
|
35
|
+
type CrossChannelDeliverySource = Omit<ChannelDeliverySource, "channelKind" | "channelName">;
|
|
33
36
|
/**
|
|
34
37
|
* Projects an agent's resolved channels into the receiver-input shape.
|
|
35
38
|
*
|
|
@@ -41,5 +44,5 @@ export declare function toCrossChannelTargets(channels: readonly ResolvedChannel
|
|
|
41
44
|
/**
|
|
42
45
|
* Builds the `ctx.to(channel, target)` closure used by route and schedule handlers.
|
|
43
46
|
*/
|
|
44
|
-
export declare function createCrossChannelToFn(runtime: Runtime, channels: readonly CrossChannelTarget[]): CrossChannelToFn;
|
|
47
|
+
export declare function createCrossChannelToFn(runtime: Runtime, channels: readonly CrossChannelTarget[], source?: CrossChannelDeliverySource): CrossChannelToFn;
|
|
45
48
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createChannelOperations}from"#channel/channel-operations.js";import{isCompiledChannel}from"#channel/compiled-channel.js";function toCrossChannelTargets(e){return e.flatMap(e=>e.definition===void 0?[]:[{name:e.name,definition:e.definition,receive:e.receive,adapter:e.adapter,turnPolicy:e.turnPolicy}])}function createCrossChannelToFn(e,t){return(
|
|
1
|
+
import{createChannelOperations}from"#channel/channel-operations.js";import{isCompiledChannel}from"#channel/compiled-channel.js";function toCrossChannelTargets(e){return e.flatMap(e=>e.definition===void 0?[]:[{name:e.name,definition:e.definition,receive:e.receive,adapter:e.adapter,turnPolicy:e.turnPolicy}])}function createCrossChannelToFn(e,t,n={}){return(r,i)=>{let a=resolveTargetByReference(r,t);return{async send(t,r){return await invokeChannelReceive({runtime:e,source:n,target:a,input:{message:t,target:i,auth:r.auth},turnPolicy:r.turnPolicy,describeMissingReceive:()=>`ctx.to(): channel "${a.name}" does not implement receive(). Declare a receive hook on the channel to accept cross-channel sessions.`,describeMissingAdapter:()=>`ctx.to(): channel "${a.name}" has no adapter — cannot build ctx.from().`})}}}}async function invokeChannelReceive(e){if(!e.target.receive)throw Error(e.describeMissingReceive());if(!e.target.adapter)throw Error(e.describeMissingAdapter());let t=createChannelOperations({adapter:e.target.adapter,channelName:e.target.name,metadata:{...e.source,channelKind:`channel:${e.target.name}`,channelName:e.target.name},runtime:e.runtime,turnPolicy:e.turnPolicy??e.target.turnPolicy});return await e.target.receive(e.input,t)}function resolveTargetByReference(e,t){for(let n of t)if(n.definition===e)return n;let n=resolveTargetByRouteFingerprint(e,t);if(n!==null)return n;throw Error(`ctx.to(): the channel passed as the first argument is not registered in this agent's channels/. Import the channel module's default export from agent/channels/<name>.ts and pass that value.`)}function resolveTargetByRouteFingerprint(e,t){if(!isCompiledChannel(e))return null;let n=createRouteFingerprint(e);if(n===null)return null;let r=new Map;for(let e of t)createRouteFingerprint(e.definition)===n&&r.set(e.name,e);if(r.size===1)return[...r.values()][0];if(r.size>1)throw Error(`ctx.to(): the channel passed as the first argument matches multiple registered channels by route shape. Import a channel with a unique route set from agent/channels/<name>.ts before passing it to ctx.to().`);return null}function createRouteFingerprint(e){return e.routes.length===0?null:e.routes.map(e=>`${e.method.toUpperCase()} ${e.path}`).sort().join(`
|
|
2
2
|
`)}export{createCrossChannelToFn,toCrossChannelTargets};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SessionNotActiveError}from"#channel/session-not-active-error.js";import{StreamDelivery}from"#client/delivery.js";import{deliveryEvents}from"#client/delivery-events.js";function commandDelivery(e,t,n,r={}){if(t.status!==`accepted`&&t.status!==`reset`)throw new SessionNotActiveError({retryable:`retryable`in t&&t.retryable===!0});let i=t.status===`reset`?t.previousSessionId:t.sessionId;return new StreamDelivery({sessionId:i,deliveryId:n,createStream:async function*(t){yield*deliveryEvents(await e.getEventStream(i,{...r,signal:t?.signal}),n,t?.signal)}})}export{commandDelivery};
|
|
1
|
+
import{SessionNotActiveError}from"#channel/session-not-active-error.js";import{StreamDelivery}from"#client/delivery.js";import{deliveryEvents}from"#client/delivery-events.js";function commandDelivery(e,t,n,r={}){if(t.status!==`accepted`&&t.status!==`reset`)throw new SessionNotActiveError({retryable:`retryable`in t&&t.retryable===!0});let i=t.status===`reset`?t.previousSessionId:t.sessionId;return new StreamDelivery({inbox:`inbox`in t?t.inbox:void 0,sessionId:i,deliveryId:n,createStream:async function*(t){yield*deliveryEvents(await e.getEventStream(i,{...r,signal:t?.signal}),n,t?.signal)}})}export{commandDelivery};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{attachClientContext,readClientContext}from"#internal/client-context.js";import{commandDelivery}from"#channel/delivery.js";import{validateDeliveryIdempotencyKey}from"#channel/delivery-idempotency.js";import{createChannelDeliveryMetadata}from"#channel/delivery-metadata.js";import{serializeFilePartsInMessage}from"#channel/send-input.js";import{DEFAULT_TURN_POLICY,controlCommand}from"#channel/types.js";import{validateSessionHistory}from"#shared/session-history.js";import{parseAnswers}from"#shared/input.js";import{AuthKey,ContinuationHookTokensKey,ContinuationTokenKey,InitiatorAuthKey,SessionIdKey}from"#context/keys.js";import{toChannelLocalContinuationToken}from"#shared/continuation-token.js";function internalSession(e){return e}function createSession(e,t,n={}){return{id:e,async send(r,i){validateDeliveryIdempotencyKey(i.idempotencyKey);let a=createDelivery(n,i.deliveryId),o=sessionCallbackToTurnCaller(i.callback),s=validateSessionHistory(i.history),c=attachClientContext({message:serializeFilePartsInMessage(r)},readClientContext(i));i.context!==void 0&&(c.context=i.context),s!==void 0&&(c.history=s),i.outputSchema!==void 0&&(c.outputSchema=i.outputSchema);let l={idempotencyKey:i.idempotencyKey,auth:i.auth,delivery:a,kind:`send`,payload:c,requestId:n.requestId,turnPolicy:i.turnPolicy??n.turnPolicy??DEFAULT_TURN_POLICY,title:i.title},u=await t.dispatchSession({command:o===void 0?l:{...l,caller:o},sessionId:e});return commandDelivery(t,u,a.deliveryId)},async respond(r,i){if(validateDeliveryIdempotencyKey(i.idempotencyKey),r.length===0)throw Error(`respond() requires at least one answer.`);let a=parseAnswers(r),o=sessionCallbackToTurnCaller(i.callback),s=createDelivery(n,i.deliveryId),c=attachClientContext({answers:a},readClientContext(i));i.context!==void 0&&(c.context=i.context),i.outputSchema!==void 0&&(c.outputSchema=i.outputSchema);let l={idempotencyKey:i.idempotencyKey,auth:i.auth,delivery:s,kind:`send`,payload:c,requestId:n.requestId},u=await t.dispatchSession({command:o===void 0?l:{...l,caller:o},sessionId:e});return commandDelivery(t,u,s.deliveryId)},async cancel(n){let r=controlCommand({kind:`cancel`,turnId:n?.turnId},n),i=await t.dispatchSession({command:r,sessionId:e});return commandDelivery(t,i,r.deliveryId)},async prewarm(){return await t.dispatchSession({command:{kind:`prewarm`,targetDeploymentId:n.acceptedDeploymentId},sessionId:e})},async compact(n){let r=controlCommand({kind:`compact`},n),i=await t.dispatchSession({command:r,sessionId:e});return commandDelivery(t,i,r.deliveryId)},async clear(n){let r=controlCommand({kind:`clear`},n),i=await t.dispatchSession({command:r,sessionId:e});return commandDelivery(t,i,r.deliveryId)},async reset(n){let r=controlCommand({kind:`reset`,reason:n?.reason},n),i=await t.dispatchSession({command:r,sessionId:e});return commandDelivery(t,i,r.deliveryId,{follow:!1})},async*stream(n){yield*await t.getEventStream(e,n)},async getLineStream(n){return t.getLineStream(e,n)},async getStreamTailIndex(){return t.getStreamTailIndex(e)},async hasRunnableOwner(){return await t.hasRunnableOwner?.(e)??!0},async getChildBinding(n){return await t.readChildBinding?.(e,n)}}}function createAttachSessionFn(e,t={}){return n=>createSession(n,e,t)}function createDelivery(e,t){let n=createChannelDeliveryMetadata({channelKind:`http`,channelName:`http`,...e});return t===void 0?n:{...n,deliveryId:t}}function buildChannelContext(e){return{session:{get id(){return e.get(SessionIdKey)??``},get auth(){return{current:e.get(AuthKey)??null,initiator:e.get(InitiatorAuthKey)??null}}},get continuation(){let t=e.get(ContinuationTokenKey);if(t!==void 0&&t.length!==0)return{token:toChannelLocalContinuationToken(t),alias(n){if(n.length===0)throw Error(`A session alias requires a nonempty token.`);let r=namespaceContinuationToken(t,n);t!==r&&(e.set(ContinuationHookTokensKey,e=>{let n=e??[t];return n.includes(r)?n:[...n,r]}),e.set(ContinuationTokenKey,r))}}}}}function namespaceContinuationToken(e,t){let n=e.indexOf(`:`);if(n<=0)throw Error(`Cannot set session continuation token without an existing namespaced continuation token. Start the session with a placeholder continuationToken.`);return`${e.slice(0,n+1)}${t}`}function sessionCallbackToTurnCaller(e){return e===void 0?void 0:{callId:e.callId,replyTo:{kind:`callback`,token:e.token,url:e.url},subagentName:e.subagentName}}export{buildChannelContext,createAttachSessionFn,createSession,internalSession,sessionCallbackToTurnCaller};
|
|
1
|
+
import{attachClientContext,readClientContext}from"#internal/client-context.js";import{commandDelivery}from"#channel/delivery.js";import{validateDeliveryIdempotencyKey}from"#channel/delivery-idempotency.js";import{createChannelDeliveryMetadata}from"#channel/delivery-metadata.js";import{serializeFilePartsInMessage}from"#channel/send-input.js";import{DEFAULT_TURN_POLICY,controlCommand}from"#channel/types.js";import{validateSessionHistory}from"#shared/session-history.js";import{parseAnswers}from"#shared/input.js";import{AuthKey,ContinuationHookTokensKey,ContinuationTokenKey,InitiatorAuthKey,SessionIdKey}from"#context/keys.js";import{toChannelLocalContinuationToken}from"#shared/continuation-token.js";function internalSession(e){return e}function createSession(e,t,n={}){return{id:e,async send(r,i){validateDeliveryIdempotencyKey(i.idempotencyKey);let a=createDelivery(n,i.deliveryId),o=sessionCallbackToTurnCaller(i.callback),s=validateSessionHistory(i.history),c=attachClientContext({message:serializeFilePartsInMessage(r)},readClientContext(i));i.context!==void 0&&(c.context=i.context),s!==void 0&&(c.history=s),i.outputSchema!==void 0&&(c.outputSchema=i.outputSchema);let l={idempotencyKey:i.idempotencyKey,auth:i.auth,delivery:a,kind:`send`,payload:c,requestId:n.requestId,turnPolicy:i.turnPolicy??n.turnPolicy??DEFAULT_TURN_POLICY,title:i.title},u=await t.dispatchSession({command:o===void 0?l:{...l,caller:o},sessionId:e,inbox:i.inbox});return commandDelivery(t,u,a.deliveryId)},async respond(r,i){if(validateDeliveryIdempotencyKey(i.idempotencyKey),r.length===0)throw Error(`respond() requires at least one answer.`);let a=parseAnswers(r),o=sessionCallbackToTurnCaller(i.callback),s=createDelivery(n,i.deliveryId),c=attachClientContext({answers:a},readClientContext(i));i.context!==void 0&&(c.context=i.context),i.outputSchema!==void 0&&(c.outputSchema=i.outputSchema);let l={idempotencyKey:i.idempotencyKey,auth:i.auth,delivery:s,kind:`send`,payload:c,requestId:n.requestId},u=await t.dispatchSession({command:o===void 0?l:{...l,caller:o},sessionId:e,inbox:i.inbox});return commandDelivery(t,u,s.deliveryId)},async cancel(n){let r=controlCommand({kind:`cancel`,turnId:n?.turnId},n),i=await t.dispatchSession({command:r,sessionId:e});return commandDelivery(t,i,r.deliveryId)},async prewarm(){return await t.dispatchSession({command:{kind:`prewarm`,targetDeploymentId:n.acceptedDeploymentId},sessionId:e})},async compact(n){let r=controlCommand({kind:`compact`},n),i=await t.dispatchSession({command:r,sessionId:e});return commandDelivery(t,i,r.deliveryId)},async clear(n){let r=controlCommand({kind:`clear`},n),i=await t.dispatchSession({command:r,sessionId:e});return commandDelivery(t,i,r.deliveryId)},async reset(n){let r=controlCommand({kind:`reset`,reason:n?.reason},n),i=await t.dispatchSession({command:r,sessionId:e});return commandDelivery(t,i,r.deliveryId,{follow:!1})},async*stream(n){yield*await t.getEventStream(e,n)},async getLineStream(n){return t.getLineStream(e,n)},async getStreamTailIndex(){return t.getStreamTailIndex(e)},async hasRunnableOwner(){return await t.hasRunnableOwner?.(e)??!0},async getChildBinding(n){return await t.readChildBinding?.(e,n)}}}function createAttachSessionFn(e,t={}){return n=>createSession(n,e,t)}function createDelivery(e,t){let n=createChannelDeliveryMetadata({channelKind:`http`,channelName:`http`,...e});return t===void 0?n:{...n,deliveryId:t}}function buildChannelContext(e){return{session:{get id(){return e.get(SessionIdKey)??``},get auth(){return{current:e.get(AuthKey)??null,initiator:e.get(InitiatorAuthKey)??null}}},get continuation(){let t=e.get(ContinuationTokenKey);if(t!==void 0&&t.length!==0)return{token:toChannelLocalContinuationToken(t),alias(n){if(n.length===0)throw Error(`A session alias requires a nonempty token.`);let r=namespaceContinuationToken(t,n);t!==r&&(e.set(ContinuationHookTokensKey,e=>{let n=e??[t];return n.includes(r)?n:[...n,r]}),e.set(ContinuationTokenKey,r))}}}}}function namespaceContinuationToken(e,t){let n=e.indexOf(`:`);if(n<=0)throw Error(`Cannot set session continuation token without an existing namespaced continuation token. Start the session with a placeholder continuationToken.`);return`${e.slice(0,n+1)}${t}`}function sessionCallbackToTurnCaller(e){return e===void 0?void 0:{callId:e.callId,replyTo:{kind:`callback`,token:e.token,url:e.url},subagentName:e.subagentName}}export{buildChannelContext,createAttachSessionFn,createSession,internalSession,sessionCallbackToTurnCaller};
|
|
@@ -199,6 +199,7 @@ export type SessionSendCommandResult = {
|
|
|
199
199
|
readonly status: "accepted";
|
|
200
200
|
readonly sessionId: string;
|
|
201
201
|
readonly deliveryId?: string;
|
|
202
|
+
readonly inbox?: string;
|
|
202
203
|
} | {
|
|
203
204
|
readonly status: "session_not_active";
|
|
204
205
|
/** The workflow exists but its inbox is not yet available; no delivery was accepted. */
|
|
@@ -232,6 +233,7 @@ export interface DispatchContinuationInput<TCommand extends SessionCommand = Ses
|
|
|
232
233
|
readonly successor?: RunInput;
|
|
233
234
|
}
|
|
234
235
|
export interface DispatchSessionInput<TCommand extends SessionCommand = SessionCommand> {
|
|
236
|
+
readonly inbox?: string;
|
|
235
237
|
readonly command: TCommand;
|
|
236
238
|
readonly sessionId: string;
|
|
237
239
|
}
|
|
@@ -2447,10 +2447,12 @@ const sendReceipts = /* @__PURE__ */ new WeakMap();
|
|
|
2447
2447
|
var StreamDelivery = class {
|
|
2448
2448
|
sessionId;
|
|
2449
2449
|
deliveryId;
|
|
2450
|
+
inbox;
|
|
2450
2451
|
#createStream;
|
|
2451
2452
|
#result;
|
|
2452
2453
|
constructor(input) {
|
|
2453
2454
|
this.sessionId = input.sessionId;
|
|
2455
|
+
this.inbox = input.inbox;
|
|
2454
2456
|
this.deliveryId = input.deliveryId;
|
|
2455
2457
|
if (input.receipt !== void 0) sendReceipts.set(this, input.receipt);
|
|
2456
2458
|
this.#createStream = input.createStream;
|
|
@@ -3010,9 +3012,13 @@ var ClientSession = class ClientSession {
|
|
|
3010
3012
|
async #send(input, retrySessionNotReady) {
|
|
3011
3013
|
const initialStreamIndex = this.#state.streamIndex;
|
|
3012
3014
|
const path = createEveSessionRoutePath(this.#state.sessionId);
|
|
3013
|
-
const { response, timing } = await postSessionSend(this.#context, path, input, retrySessionNotReady);
|
|
3014
|
-
const { sessionId: responseSessionId, deliveryId } = await readAcceptedMessage(response, this.#state.sessionId);
|
|
3015
|
+
const { response, timing } = await postSessionSend(this.#context, path, input, retrySessionNotReady, this.#state.inbox);
|
|
3016
|
+
const { sessionId: responseSessionId, deliveryId, inbox } = await readAcceptedMessage(response, this.#state.sessionId);
|
|
3015
3017
|
if (responseSessionId !== this.#state.sessionId) throw new Error("Message route returned a different session id.");
|
|
3018
|
+
this.#state = {
|
|
3019
|
+
...this.#state,
|
|
3020
|
+
inbox
|
|
3021
|
+
};
|
|
3016
3022
|
if (deliveryId === void 0) throw new Error("Message route did not return a delivery id. Update the server before sending with this client.");
|
|
3017
3023
|
return this.#messageResponse(response, input, initialStreamIndex, deliveryId, {
|
|
3018
3024
|
...timing,
|
|
@@ -3100,7 +3106,7 @@ var ClientSession = class ClientSession {
|
|
|
3100
3106
|
}
|
|
3101
3107
|
#advanceStreamIndex(streamIndex) {
|
|
3102
3108
|
this.#state = {
|
|
3103
|
-
|
|
3109
|
+
...this.#state,
|
|
3104
3110
|
streamIndex: Math.max(this.#state.streamIndex, streamIndex)
|
|
3105
3111
|
};
|
|
3106
3112
|
}
|
|
@@ -3122,7 +3128,7 @@ var ClientSession = class ClientSession {
|
|
|
3122
3128
|
function followClientSession(session, options) {
|
|
3123
3129
|
return session[followSession](options);
|
|
3124
3130
|
}
|
|
3125
|
-
async function postSessionSend(context, path, input, retrySessionNotReady) {
|
|
3131
|
+
async function postSessionSend(context, path, input, retrySessionNotReady, inbox) {
|
|
3126
3132
|
const startedAt = Date.now();
|
|
3127
3133
|
const readyDeadline = startedAt + SESSION_SEND_READY_TIMEOUT_MS;
|
|
3128
3134
|
let retryDelayMs = SESSION_SEND_RETRY_BASE_DELAY_MS;
|
|
@@ -3130,7 +3136,7 @@ async function postSessionSend(context, path, input, retrySessionNotReady) {
|
|
|
3130
3136
|
const attemptAt = Date.now();
|
|
3131
3137
|
try {
|
|
3132
3138
|
return {
|
|
3133
|
-
response: await postTurn(context, path, input, false),
|
|
3139
|
+
response: await postTurn(context, path, input, false, void 0, inbox),
|
|
3134
3140
|
timing: {
|
|
3135
3141
|
startedAt,
|
|
3136
3142
|
notReadyMs: attemptAt - startedAt,
|
|
@@ -3167,10 +3173,11 @@ async function postCreateSession(context, options) {
|
|
|
3167
3173
|
function isSessionNotReady(error) {
|
|
3168
3174
|
return SessionNotActiveError.is(error) && error.retryable;
|
|
3169
3175
|
}
|
|
3170
|
-
async function postTurn(context, path, input, requireMessage, stubs) {
|
|
3176
|
+
async function postTurn(context, path, input, requireMessage, stubs, inbox) {
|
|
3171
3177
|
const body = createMessageBody(input, requireMessage);
|
|
3172
3178
|
if (body === null) throw new Error(requireMessage ? "Creating a session requires a non-empty message." : "A session turn requires a non-empty message or answers.");
|
|
3173
3179
|
if (stubs !== void 0) body.stubs = stubs;
|
|
3180
|
+
if (inbox !== void 0) body.inbox = inbox;
|
|
3174
3181
|
const headers = await context.resolveHeaders(input.headers);
|
|
3175
3182
|
headers.set("content-type", "application/json");
|
|
3176
3183
|
const response = await fetch(createClientUrl(context.baseUrl, path), {
|
|
@@ -3192,6 +3199,7 @@ async function readAcceptedMessage(response, expected) {
|
|
|
3192
3199
|
if (!sessionId) throw new Error("Message route did not return a session id.");
|
|
3193
3200
|
return {
|
|
3194
3201
|
sessionId,
|
|
3202
|
+
inbox: typeof payload.inbox === "string" ? payload.inbox : void 0,
|
|
3195
3203
|
deliveryId: typeof payload.deliveryId === "string" && payload.deliveryId.length > 0 ? payload.deliveryId : void 0
|
|
3196
3204
|
};
|
|
3197
3205
|
}
|
|
@@ -3223,6 +3231,7 @@ var ClientSessions = class {
|
|
|
3223
3231
|
if (sessionId.length === 0) throw new Error("sessionId must be a non-empty string.");
|
|
3224
3232
|
return new ClientSession(this.#context, {
|
|
3225
3233
|
sessionId,
|
|
3234
|
+
inbox: options?.inbox,
|
|
3226
3235
|
streamIndex: options?.streamIndex ?? 0
|
|
3227
3236
|
});
|
|
3228
3237
|
}
|
|
@@ -3443,6 +3452,7 @@ function isAbortError(error) {
|
|
|
3443
3452
|
|
|
3444
3453
|
//#endregion
|
|
3445
3454
|
//#region src/client/optimistic-message-submissions.ts
|
|
3455
|
+
let submissionSequence = 0;
|
|
3446
3456
|
var OptimisticMessageSubmissions = class {
|
|
3447
3457
|
#optimistic;
|
|
3448
3458
|
#show;
|
|
@@ -3457,7 +3467,7 @@ var OptimisticMessageSubmissions = class {
|
|
|
3457
3467
|
}
|
|
3458
3468
|
submit(input, turnId) {
|
|
3459
3469
|
if (input.message === void 0) return void 0;
|
|
3460
|
-
const id = crypto.randomUUID()
|
|
3470
|
+
const id = crypto.randomUUID?.() ?? `submission_${(submissionSequence += 1).toString()}`;
|
|
3461
3471
|
this.#submissions.set(id, {
|
|
3462
3472
|
id,
|
|
3463
3473
|
message: summarizeMessage(input.message),
|
|
@@ -4494,7 +4504,10 @@ var SessionStore = class {
|
|
|
4494
4504
|
this.#conversationClient = new ConversationClient(() => this.#publish());
|
|
4495
4505
|
this.#events = (init.initialEvents ?? []).filter((event) => this.#conversationClient.hydrate(event));
|
|
4496
4506
|
this.#messageSubmissions = new OptimisticMessageSubmissions((submissions) => this.#conversationClient.showSubmissions(submissions), init.optimistic ?? true);
|
|
4497
|
-
this.#session = init.session ?? (init.initialSession === void 0 ? void 0 : this.#client?.sessions.attach(init.initialSession.sessionId, {
|
|
4507
|
+
this.#session = init.session ?? (init.initialSession === void 0 ? void 0 : this.#client?.sessions.attach(init.initialSession.sessionId, {
|
|
4508
|
+
streamIndex: init.initialSession.streamIndex,
|
|
4509
|
+
inbox: init.initialSession.inbox
|
|
4510
|
+
}));
|
|
4498
4511
|
this.#error = this.#recordedFailure();
|
|
4499
4512
|
this.#snapshot = this.#createSnapshot();
|
|
4500
4513
|
}
|
|
@@ -4569,6 +4582,7 @@ var SessionStore = class {
|
|
|
4569
4582
|
this.#messageSubmissions.correlate(submissionId, deliveryId);
|
|
4570
4583
|
}
|
|
4571
4584
|
this.#acceptReceipt(deliveryId);
|
|
4585
|
+
this.#callbacks.onSessionChange?.(this.#sessionState);
|
|
4572
4586
|
}
|
|
4573
4587
|
accepted.resolve(deliveryId);
|
|
4574
4588
|
return new StreamDelivery({
|
|
@@ -4901,9 +4915,11 @@ var SessionStore = class {
|
|
|
4901
4915
|
if (this.#session === void 0) return this.#observedSession = void 0;
|
|
4902
4916
|
const sessionId = this.#session.id;
|
|
4903
4917
|
const streamIndex = this.#conversationClient.view.position;
|
|
4904
|
-
|
|
4918
|
+
const { inbox } = this.#session.state;
|
|
4919
|
+
if (this.#observedSession?.sessionId !== sessionId || this.#observedSession.streamIndex !== streamIndex || this.#observedSession.inbox !== inbox) this.#observedSession = {
|
|
4905
4920
|
sessionId,
|
|
4906
|
-
streamIndex
|
|
4921
|
+
streamIndex,
|
|
4922
|
+
inbox
|
|
4907
4923
|
};
|
|
4908
4924
|
return this.#observedSession;
|
|
4909
4925
|
}
|
|
@@ -2448,10 +2448,12 @@ const sendReceipts = /* @__PURE__ */ new WeakMap();
|
|
|
2448
2448
|
var StreamDelivery = class {
|
|
2449
2449
|
sessionId;
|
|
2450
2450
|
deliveryId;
|
|
2451
|
+
inbox;
|
|
2451
2452
|
#createStream;
|
|
2452
2453
|
#result;
|
|
2453
2454
|
constructor(input) {
|
|
2454
2455
|
this.sessionId = input.sessionId;
|
|
2456
|
+
this.inbox = input.inbox;
|
|
2455
2457
|
this.deliveryId = input.deliveryId;
|
|
2456
2458
|
if (input.receipt !== void 0) sendReceipts.set(this, input.receipt);
|
|
2457
2459
|
this.#createStream = input.createStream;
|
|
@@ -3011,9 +3013,13 @@ var ClientSession = class ClientSession {
|
|
|
3011
3013
|
async #send(input, retrySessionNotReady) {
|
|
3012
3014
|
const initialStreamIndex = this.#state.streamIndex;
|
|
3013
3015
|
const path = createEveSessionRoutePath(this.#state.sessionId);
|
|
3014
|
-
const { response, timing } = await postSessionSend(this.#context, path, input, retrySessionNotReady);
|
|
3015
|
-
const { sessionId: responseSessionId, deliveryId } = await readAcceptedMessage(response, this.#state.sessionId);
|
|
3016
|
+
const { response, timing } = await postSessionSend(this.#context, path, input, retrySessionNotReady, this.#state.inbox);
|
|
3017
|
+
const { sessionId: responseSessionId, deliveryId, inbox } = await readAcceptedMessage(response, this.#state.sessionId);
|
|
3016
3018
|
if (responseSessionId !== this.#state.sessionId) throw new Error("Message route returned a different session id.");
|
|
3019
|
+
this.#state = {
|
|
3020
|
+
...this.#state,
|
|
3021
|
+
inbox
|
|
3022
|
+
};
|
|
3017
3023
|
if (deliveryId === void 0) throw new Error("Message route did not return a delivery id. Update the server before sending with this client.");
|
|
3018
3024
|
return this.#messageResponse(response, input, initialStreamIndex, deliveryId, {
|
|
3019
3025
|
...timing,
|
|
@@ -3101,7 +3107,7 @@ var ClientSession = class ClientSession {
|
|
|
3101
3107
|
}
|
|
3102
3108
|
#advanceStreamIndex(streamIndex) {
|
|
3103
3109
|
this.#state = {
|
|
3104
|
-
|
|
3110
|
+
...this.#state,
|
|
3105
3111
|
streamIndex: Math.max(this.#state.streamIndex, streamIndex)
|
|
3106
3112
|
};
|
|
3107
3113
|
}
|
|
@@ -3123,7 +3129,7 @@ var ClientSession = class ClientSession {
|
|
|
3123
3129
|
function followClientSession(session, options) {
|
|
3124
3130
|
return session[followSession](options);
|
|
3125
3131
|
}
|
|
3126
|
-
async function postSessionSend(context, path, input, retrySessionNotReady) {
|
|
3132
|
+
async function postSessionSend(context, path, input, retrySessionNotReady, inbox) {
|
|
3127
3133
|
const startedAt = Date.now();
|
|
3128
3134
|
const readyDeadline = startedAt + SESSION_SEND_READY_TIMEOUT_MS;
|
|
3129
3135
|
let retryDelayMs = SESSION_SEND_RETRY_BASE_DELAY_MS;
|
|
@@ -3131,7 +3137,7 @@ async function postSessionSend(context, path, input, retrySessionNotReady) {
|
|
|
3131
3137
|
const attemptAt = Date.now();
|
|
3132
3138
|
try {
|
|
3133
3139
|
return {
|
|
3134
|
-
response: await postTurn(context, path, input, false),
|
|
3140
|
+
response: await postTurn(context, path, input, false, void 0, inbox),
|
|
3135
3141
|
timing: {
|
|
3136
3142
|
startedAt,
|
|
3137
3143
|
notReadyMs: attemptAt - startedAt,
|
|
@@ -3168,10 +3174,11 @@ async function postCreateSession(context, options) {
|
|
|
3168
3174
|
function isSessionNotReady(error) {
|
|
3169
3175
|
return SessionNotActiveError.is(error) && error.retryable;
|
|
3170
3176
|
}
|
|
3171
|
-
async function postTurn(context, path, input, requireMessage, stubs) {
|
|
3177
|
+
async function postTurn(context, path, input, requireMessage, stubs, inbox) {
|
|
3172
3178
|
const body = createMessageBody(input, requireMessage);
|
|
3173
3179
|
if (body === null) throw new Error(requireMessage ? "Creating a session requires a non-empty message." : "A session turn requires a non-empty message or answers.");
|
|
3174
3180
|
if (stubs !== void 0) body.stubs = stubs;
|
|
3181
|
+
if (inbox !== void 0) body.inbox = inbox;
|
|
3175
3182
|
const headers = await context.resolveHeaders(input.headers);
|
|
3176
3183
|
headers.set("content-type", "application/json");
|
|
3177
3184
|
const response = await fetch(createClientUrl(context.baseUrl, path), {
|
|
@@ -3193,6 +3200,7 @@ async function readAcceptedMessage(response, expected) {
|
|
|
3193
3200
|
if (!sessionId) throw new Error("Message route did not return a session id.");
|
|
3194
3201
|
return {
|
|
3195
3202
|
sessionId,
|
|
3203
|
+
inbox: typeof payload.inbox === "string" ? payload.inbox : void 0,
|
|
3196
3204
|
deliveryId: typeof payload.deliveryId === "string" && payload.deliveryId.length > 0 ? payload.deliveryId : void 0
|
|
3197
3205
|
};
|
|
3198
3206
|
}
|
|
@@ -3224,6 +3232,7 @@ var ClientSessions = class {
|
|
|
3224
3232
|
if (sessionId.length === 0) throw new Error("sessionId must be a non-empty string.");
|
|
3225
3233
|
return new ClientSession(this.#context, {
|
|
3226
3234
|
sessionId,
|
|
3235
|
+
inbox: options?.inbox,
|
|
3227
3236
|
streamIndex: options?.streamIndex ?? 0
|
|
3228
3237
|
});
|
|
3229
3238
|
}
|
|
@@ -3444,6 +3453,7 @@ function isAbortError(error) {
|
|
|
3444
3453
|
|
|
3445
3454
|
//#endregion
|
|
3446
3455
|
//#region src/client/optimistic-message-submissions.ts
|
|
3456
|
+
let submissionSequence = 0;
|
|
3447
3457
|
var OptimisticMessageSubmissions = class {
|
|
3448
3458
|
#optimistic;
|
|
3449
3459
|
#show;
|
|
@@ -3458,7 +3468,7 @@ var OptimisticMessageSubmissions = class {
|
|
|
3458
3468
|
}
|
|
3459
3469
|
submit(input, turnId) {
|
|
3460
3470
|
if (input.message === void 0) return void 0;
|
|
3461
|
-
const id = crypto.randomUUID()
|
|
3471
|
+
const id = crypto.randomUUID?.() ?? `submission_${(submissionSequence += 1).toString()}`;
|
|
3462
3472
|
this.#submissions.set(id, {
|
|
3463
3473
|
id,
|
|
3464
3474
|
message: summarizeMessage(input.message),
|
|
@@ -4495,7 +4505,10 @@ var SessionStore = class {
|
|
|
4495
4505
|
this.#conversationClient = new ConversationClient(() => this.#publish());
|
|
4496
4506
|
this.#events = (init.initialEvents ?? []).filter((event) => this.#conversationClient.hydrate(event));
|
|
4497
4507
|
this.#messageSubmissions = new OptimisticMessageSubmissions((submissions) => this.#conversationClient.showSubmissions(submissions), init.optimistic ?? true);
|
|
4498
|
-
this.#session = init.session ?? (init.initialSession === void 0 ? void 0 : this.#client?.sessions.attach(init.initialSession.sessionId, {
|
|
4508
|
+
this.#session = init.session ?? (init.initialSession === void 0 ? void 0 : this.#client?.sessions.attach(init.initialSession.sessionId, {
|
|
4509
|
+
streamIndex: init.initialSession.streamIndex,
|
|
4510
|
+
inbox: init.initialSession.inbox
|
|
4511
|
+
}));
|
|
4499
4512
|
this.#error = this.#recordedFailure();
|
|
4500
4513
|
this.#snapshot = this.#createSnapshot();
|
|
4501
4514
|
}
|
|
@@ -4570,6 +4583,7 @@ var SessionStore = class {
|
|
|
4570
4583
|
this.#messageSubmissions.correlate(submissionId, deliveryId);
|
|
4571
4584
|
}
|
|
4572
4585
|
this.#acceptReceipt(deliveryId);
|
|
4586
|
+
this.#callbacks.onSessionChange?.(this.#sessionState);
|
|
4573
4587
|
}
|
|
4574
4588
|
accepted.resolve(deliveryId);
|
|
4575
4589
|
return new StreamDelivery({
|
|
@@ -4902,9 +4916,11 @@ var SessionStore = class {
|
|
|
4902
4916
|
if (this.#session === void 0) return this.#observedSession = void 0;
|
|
4903
4917
|
const sessionId = this.#session.id;
|
|
4904
4918
|
const streamIndex = this.#conversationClient.view.position;
|
|
4905
|
-
|
|
4919
|
+
const { inbox } = this.#session.state;
|
|
4920
|
+
if (this.#observedSession?.sessionId !== sessionId || this.#observedSession.streamIndex !== streamIndex || this.#observedSession.inbox !== inbox) this.#observedSession = {
|
|
4906
4921
|
sessionId,
|
|
4907
|
-
streamIndex
|
|
4922
|
+
streamIndex,
|
|
4923
|
+
inbox
|
|
4908
4924
|
};
|
|
4909
4925
|
return this.#observedSession;
|
|
4910
4926
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{initAgentDevHandoff,initAgentReadySummary}from"./agent-instructions.js";import{hasInteractiveTerminal}from"./preconditions.js";import{tryInitializeGit}from"./init-git.js";import{InitTargetError}from"./init-telemetry.js";import{addAgentsToWorkspace,convertScaffoldToAgentWorkspace,formatWorkspaceRootMutationWarning}from"./init-agent-workspace.js";import{createInstallDiagnostics,packageManagerInstallFailureCode}from"./init-install.js";import{reportExistingProjectChanges}from"./init-project.js";import{cleanupFreshInitTarget,workspaceFailureNote}from"./init-recovery.js";import{resolveInitTarget}from"./init-target.js";import{mkdtemp,readdir,rename,rm}from"node:fs/promises";import{createLogger,isLogLevelEnabled}from"#internal/logging.js";import{basename,join,resolve}from"node:path";import pc from"#compiled/picocolors/index.js";import{resolveInitAgentSettings}from"#shared/default-agent-model.js";import{ensureChannel,scaffoldBaseProject}from"#setup/scaffold/index.js";import{eveDevArguments,packageManagerInstallFailureMessage,packageManagerInstallSucceeded,resultSucceeded,runPackageManagerInstall,spawnPackageManager}from"#setup/primitives/index.js";import{performance}from"node:perf_hooks";import{isCodingAgentLaunch}from"#cli/agent-detection.js";import{EVE_WORDMARK,eveCliBanner}from"#cli/banner.js";import{formatElapsed}from"#cli/format-elapsed.js";import{startCliLiveRow}from"#cli/ui/live-row.js";import{detectInvokingPackageManager,detectPackageManager}from"#setup/package-manager.js";import{pathExists}from"#setup/path-exists.js";import{DEFAULT_EVE_PACKAGE_CONTRACT}from"#setup/scaffold/create/project.js";import{validateModelSlug}from"#setup/flows/model-source-change.js";import{addAgentToProject}from"#setup/scaffold/create/add-to-project.js";import{WizardCancelledError}from"#setup/step.js";import{isPackageManagerWorkspaceMember}from"#setup/scaffold/workspace-root.js";const defaultDependencies={addAgentToProject,detectInvokingPackageManager,detectPackageManager,ensureChannel,isCodingAgentLaunch,now:()=>performance.now(),runPackageManagerInstall,scaffoldBaseProject,hasInteractiveTerminal,spawnPackageManager,tryInitializeGit,validateModelSlug},EVE_INIT_PACKAGE_SPEC_ENV=`EVE_INIT_PACKAGE_SPEC`,initLog=createLogger(`init`);async function moveDirectoryContents(e,t){for(let n of await readdir(e))await rename(join(e,n),join(t,n))}function uniqueWorkspaceRootMutations(e){let t=new Map;for(let n of e){let e=`${n.kind}:${n.path}`,r=t.get(e);t.set(e,{...n,nodeEngineOverride:n.nodeEngineOverride??r?.nodeEngineOverride})}return[...t.values()]}async function addToExistingProject(e,t,n,r){if(t.channelWebNextjs===!0)throw Error("`--channel-web-nextjs` is not supported when adding an agent to an existing project. Run `eve add channel/web` from the project afterwards instead.");if(t.model!==void 0){let r=await n.validateModelSlug(e,t.model);if(r!==null)throw Error(r)}let i=await n.detectPackageManager(e),a=await n.addAgentToProject({projectRoot:e,...resolveInitAgentSettings(t),packageManager:i.kind,evePackage:r});return{configurationFilesChanged:a.configurationFilesChanged,dependenciesAdded:a.dependenciesAdded,filesWritten:a.filesWritten,packageManager:i.kind,nodeEngineOverride:a.nodeEngineOverride}}async function resolveScaffoldPackageManager(e,t){let n=await t.detectPackageManager(e);return n.source==="default"?t.detectInvokingPackageManager()??`pnpm`:n.kind}async function scaffoldProject(e,t,n,r,i,a,o,s){let c=resolve(e,`..`),l=!n&&await pathExists(e)&&(await readdir(e)).length===0;if(!n&&await pathExists(e)&&!l)throw Error(`Cannot create project because "${e}" already exists.`);let u=n&&s?void 0:await mkdtemp(join(c,`.eve-init-`)),d=[];try{let c=u??e;if(i.model!==void 0){let e=await a.validateModelSlug(c,i.model);if(e!==null)throw Error(e)}let f={projectName:u===void 0?`.`:n?basename(e):t,...resolveInitAgentSettings(i),evePackage:o,targetDirectory:c,overwriteExisting:s,workspaceProbeDirectory:e,packageManager:r,onWorkspaceRootMutation:e=>{d.push(e)}},p=await a.scaffoldBaseProject(f);return i.agents!==void 0&&await convertScaffoldToAgentWorkspace(p,i.agents,i),i.channelWebNextjs===!0&&await a.ensureChannel({projectRoot:p,kind:`web`,packageManager:r,force:s,workspaceProbeDirectory:e,configureVercelServices:!1,onWorkspaceRootMutation:e=>{d.push(e)}}),u!==void 0&&(n||l?await moveDirectoryContents(p,e):await rename(p,e)),{projectPath:e,workspaceRootMutations:uniqueWorkspaceRootMutations(d)}}finally{u!==void 0&&await rm(u,{recursive:!0,force:!0})}}async function runInitSteps(e){let{agentLaunched:t,dependencies:n,interactive:r,logger:i,options:a,parentDirectory:o,target:s,trackStep:c,trackTerminal:l}=e,u=isLogLevelEnabled(`debug`),d=await resolveInitTarget({parentDirectory:o,target:s}),f=resolveInitEvePackageOverride(),p=n.now(),m={animate:r&&!t&&!process.env.CI&&process.env.TERM!==`dumb`,elapsed:!0,logPhases:!0},h=startCliLiveRow(i,m),g=`scaffold`,_;try{let e=d.kind===`fresh`?`creating agent`:`adding agent`;c?.(g),h.update(d.kind===`fresh`?`Creating agent`:`Adding agent`),initLog.debug(e);let r=n.now(),o;if(d.kind===`fresh`){let e=await resolveScaffoldPackageManager(d.projectPath,n),t=isPackageManagerWorkspaceMember(e,d.projectPath),r;try{r=await scaffoldProject(d.projectPath,d.projectName,d.createInPlace,e,a,n,f,d.overwriteExisting)}catch(e){if(d.failurePolicy===`clear`){let n=await cleanupFreshInitTarget(d.projectPath,d.failurePolicy,d.preservedEntries),r=e instanceof Error?e.message:String(e),i=n?`eve restored "${d.projectPath}" to its original state.`:`eve could not completely clean "${d.projectPath}".`;throw Error(`${r}\n\n${i}${workspaceFailureNote(t)}`)}if(d.failurePolicy===`remove`&&t){let t=e instanceof Error?e.message:String(e);throw Error(`${t}${workspaceFailureNote(!0)}`)}throw e}o={failurePolicy:d.failurePolicy,kind:`created`,packageManager:e,preservedTargetEntries:d.preservedEntries,projectPath:r.projectPath,retryCommand:`eve init ${d.projectPath}`,workspaceMember:t,workspaceRootMutations:r.workspaceRootMutations}}else{let e=await addToExistingProject(d.projectPath,a,n,f);o=e.nodeEngineOverride===void 0?{configurationFilesChanged:e.configurationFilesChanged,dependenciesAdded:e.dependenciesAdded,failurePolicy:`preserve`,filesWritten:e.filesWritten,kind:`added`,packageManager:e.packageManager,projectPath:d.projectPath}:{configurationFilesChanged:e.configurationFilesChanged,dependenciesAdded:e.dependenciesAdded,failurePolicy:`preserve`,filesWritten:e.filesWritten,kind:`added`,nodeEngineOverride:e.nodeEngineOverride,packageManager:e.packageManager,projectPath:d.projectPath}}let s=n.now()-r;initLog.debug(`${e} done`,{ms:s}),o.kind===`added`&&(h.stop(),reportExistingProjectChanges(i,o),h=startCliLiveRow(i,m)),g=`install_dependencies`,c?.(g),h.update(`Installing dependencies`,o.packageManager),initLog.debug(`installing dependencies with ${o.packageManager}`);let l=n.now(),v=createInstallDiagnostics(),y=await n.runPackageManagerInstall(o.packageManager,o.projectPath,{autoApprove:!0,bypassMinimumReleaseAge:!0,progressDetails:!1,onOutput:e=>{v.append(e.text),u&&initLog.debug(e.text)}}),b=n.now()-l;if(!packageManagerInstallSucceeded(y)){_=packageManagerInstallFailureCode(y),initLog.debug(`dependency installation failed`,{ms:b}),h.stop();let{lines:e,truncated:t}=v.result();t&&i.error(`Earlier install output omitted; showing the final diagnostics.`);for(let t of e)i.error(t);if(e.length===0){let e=packageManagerInstallFailureMessage(y);e!==void 0&&i.error(e)}if(o.failurePolicy!==`preserve`){if(await cleanupFreshInitTarget(o.projectPath,o.failurePolicy,o.preservedTargetEntries)){let e=o.failurePolicy===`remove`?`eve removed the incomplete project at "${o.projectPath}".`:`eve restored "${o.projectPath}" to its original state.`,t=o.workspaceMember||o.workspaceRootMutations.length>0;throw Error(`Failed to install dependencies.\n\n${e}\n\nResolve the package-manager error above, then retry:\n ${o.retryCommand}${workspaceFailureNote(t)}`)}let e=o.workspaceMember||o.workspaceRootMutations.length>0;throw Error(`Failed to install dependencies, and eve could not completely clean "${o.projectPath}".\n\nResolve the package-manager error above, then install dependencies with ${o.packageManager} in that directory. Or clean the target manually before rerunning eve init.${workspaceFailureNote(e)}`)}throw Error(`The eve agent was added, but dependency installation failed.\n\nResolve the package-manager error above, then install dependencies with ${o.packageManager} in "${o.projectPath}".\n\nDo not rerun eve init; the agent is already configured.`)}if(initLog.debug(`dependencies installed`,{ms:b}),o.kind===`created`){g=`initialize_git`,c?.(g),h.update(`Initializing Git`),initLog.debug(`initializing git repository`);let e=await n.tryInitializeGit(o.projectPath);return{...o,elapsedMs:n.now()-p,agentLaunched:t,gitResult:e}}return{...o,elapsedMs:n.now()-p,agentLaunched:t}}catch(e){throw l?.(g,`error`,g===`install_dependencies`?_:void 0),e}finally{h.stop()}}async function runInitCommand(e,t,n,r,i=defaultDependencies,a,o){let s=await i.isCodingAgentLaunch(),c=i.hasInteractiveTerminal(),l=c&&!s&&!r.nonInteractive;c&&!s&&e.log(``),a?.(`resolve_target`);let u;try{if(await addAgentsToWorkspace(e,t,n,r,i.validateModelSlug)){a?.(`handoff`),o?.(`handoff`,`completed`);return}l||e.log(eveCliBanner()),u=await runInitSteps({agentLaunched:s,interactive:c,dependencies:i,logger:e,options:r,parentDirectory:t,target:n,trackStep:a,trackTerminal:o})}catch(e){if(e instanceof WizardCancelledError){o?.(`resolve_target`,`cancelled`);return}throw e instanceof InitTargetError&&o?.(`resolve_target`,`error`,e.failureCode),e}if(a?.(`handoff`),u.kind===`created`){e.log(`${pc.green(`✓`)} Created an ${EVE_WORDMARK} agent in ${pc.bold(u.projectPath)} ${pc.dim(`in ${formatElapsed(u.elapsedMs)}`)}`);for(let t of u.workspaceRootMutations)e.log(pc.yellow(`⚠ ${formatWorkspaceRootMutationWarning(t)}`))}else e.log(`${pc.green(`✓`)} Added an ${EVE_WORDMARK} agent to ${pc.bold(u.projectPath)} ${pc.dim(`in ${formatElapsed(u.elapsedMs)}`)}`);u.kind===`created`&&u.gitResult.kind===`failed`&&(e.error(pc.yellow(`Git initialization failed during ${u.gitResult.stage}: ${u.gitResult.reason}`)),u.gitResult.stage===`commit`&&e.error(pc.yellow(`The eve agent was created successfully. Git repository metadata and staged files were preserved at "${u.projectPath}"; the initial commit is optional.\n\nTo create it later, configure Git identity and run:\n git -C ${JSON.stringify(u.projectPath)} commit -m "Initial commit from eve"`)));let d=eveDevArguments(u.packageManager),f=[u.packageManager,...d].join(` `),p=initAgentDevHandoff({projectPath:u.projectPath,devCommand:f});if(u.agentLaunched){e.log(initAgentReadySummary(r.model,u.projectPath,{workspace:r.agents!==void 0})),e.log(p);return}if(!l){e.log(p);return}let m=u.kind===`created`,h=[...u.packageManager===`pnpm`?[`--reporter=silent`]:[],...d,...m?[`--onboard`]:[]];if(e.log(``),!resultSucceeded(await i.spawnPackageManager(u.packageManager,u.projectPath,h)))throw Error(`Development server exited unsuccessfully in "${u.projectPath}".`)}function resolveInitEvePackageOverride(){let e=process.env[EVE_INIT_PACKAGE_SPEC_ENV]?.trim();if(e!==void 0&&e.length!==0)return{nodeEngine:DEFAULT_EVE_PACKAGE_CONTRACT.nodeEngine,version:e}}export{EVE_INIT_PACKAGE_SPEC_ENV,runInitCommand};
|
|
1
|
+
import{initAgentDevHandoff,initAgentReadySummary}from"./agent-instructions.js";import{hasInteractiveTerminal}from"./preconditions.js";import{tryInitializeGit}from"./init-git.js";import{InitTargetError}from"./init-telemetry.js";import{addAgentsToWorkspace,convertScaffoldToAgentWorkspace,formatWorkspaceRootMutationWarning}from"./init-agent-workspace.js";import{createInstallDiagnostics,packageManagerInstallFailureCode}from"./init-install.js";import{reportExistingProjectChanges}from"./init-project.js";import{cleanupFreshInitTarget,workspaceFailureNote}from"./init-recovery.js";import{resolveInitTarget}from"./init-target.js";import{mkdir,mkdtemp,readdir,rename,rm}from"node:fs/promises";import{createLogger,isLogLevelEnabled}from"#internal/logging.js";import{basename,join,resolve}from"node:path";import pc from"#compiled/picocolors/index.js";import{resolveInitAgentSettings}from"#shared/default-agent-model.js";import{ensureChannel,scaffoldBaseProject}from"#setup/scaffold/index.js";import{eveDevArguments,packageManagerInstallFailureMessage,packageManagerInstallSucceeded,resultSucceeded,runPackageManagerInstall,spawnPackageManager}from"#setup/primitives/index.js";import{performance}from"node:perf_hooks";import{isCodingAgentLaunch}from"#cli/agent-detection.js";import{EVE_WORDMARK,eveCliBanner}from"#cli/banner.js";import{formatElapsed}from"#cli/format-elapsed.js";import{startCliLiveRow}from"#cli/ui/live-row.js";import{detectInvokingPackageManager,detectPackageManager}from"#setup/package-manager.js";import{pathExists}from"#setup/path-exists.js";import{DEFAULT_EVE_PACKAGE_CONTRACT}from"#setup/scaffold/create/project.js";import{validateModelSlug}from"#setup/flows/model-source-change.js";import{addAgentToProject}from"#setup/scaffold/create/add-to-project.js";import{WizardCancelledError}from"#setup/step.js";import{isPackageManagerWorkspaceMember}from"#setup/scaffold/workspace-root.js";const defaultDependencies={addAgentToProject,detectInvokingPackageManager,detectPackageManager,ensureChannel,isCodingAgentLaunch,now:()=>performance.now(),runPackageManagerInstall,scaffoldBaseProject,hasInteractiveTerminal,spawnPackageManager,tryInitializeGit,validateModelSlug},EVE_INIT_PACKAGE_SPEC_ENV=`EVE_INIT_PACKAGE_SPEC`,initLog=createLogger(`init`);async function moveDirectoryContents(e,t){for(let n of await readdir(e))await rename(join(e,n),join(t,n))}function uniqueWorkspaceRootMutations(e){let t=new Map;for(let n of e){let e=`${n.kind}:${n.path}`,r=t.get(e);t.set(e,{...n,nodeEngineOverride:n.nodeEngineOverride??r?.nodeEngineOverride})}return[...t.values()]}async function addToExistingProject(e,t,n,r){if(t.channelWebNextjs===!0)throw Error("`--channel-web-nextjs` is not supported when adding an agent to an existing project. Run `eve add channel/web` from the project afterwards instead.");if(t.model!==void 0){let r=await n.validateModelSlug(e,t.model);if(r!==null)throw Error(r)}let i=await n.detectPackageManager(e),a=await n.addAgentToProject({projectRoot:e,...resolveInitAgentSettings(t),packageManager:i.kind,evePackage:r});return{configurationFilesChanged:a.configurationFilesChanged,dependenciesAdded:a.dependenciesAdded,filesWritten:a.filesWritten,packageManager:i.kind,nodeEngineOverride:a.nodeEngineOverride}}async function resolveScaffoldPackageManager(e,t){let n=await t.detectPackageManager(e);return n.source==="default"?t.detectInvokingPackageManager()??`pnpm`:n.kind}async function scaffoldProject(e,t,n,r,i,a,o,s){let c=resolve(e,`..`),l=!n&&await pathExists(e)&&(await readdir(e)).length===0;if(!n&&await pathExists(e)&&!l)throw Error(`Cannot create project because "${e}" already exists.`);await mkdir(c,{recursive:!0});let u=n&&s?void 0:await mkdtemp(join(c,`.eve-init-`)),d=[];try{let c=u??e;if(i.model!==void 0){let e=await a.validateModelSlug(c,i.model);if(e!==null)throw Error(e)}let f={projectName:u===void 0?`.`:n?basename(e):t,...resolveInitAgentSettings(i),evePackage:o,targetDirectory:c,overwriteExisting:s,workspaceProbeDirectory:e,packageManager:r,onWorkspaceRootMutation:e=>{d.push(e)}},p=await a.scaffoldBaseProject(f);return i.agents!==void 0&&await convertScaffoldToAgentWorkspace(p,i.agents,i),i.channelWebNextjs===!0&&await a.ensureChannel({projectRoot:p,kind:`web`,packageManager:r,force:s,workspaceProbeDirectory:e,configureVercelServices:!1,onWorkspaceRootMutation:e=>{d.push(e)}}),u!==void 0&&(n||l?await moveDirectoryContents(p,e):await rename(p,e)),{projectPath:e,workspaceRootMutations:uniqueWorkspaceRootMutations(d)}}finally{u!==void 0&&await rm(u,{recursive:!0,force:!0})}}async function runInitSteps(e){let{agentLaunched:t,dependencies:n,interactive:r,logger:i,options:a,parentDirectory:o,target:s,trackStep:c,trackTerminal:l}=e,u=isLogLevelEnabled(`debug`),d=await resolveInitTarget({parentDirectory:o,target:s}),f=resolveInitEvePackageOverride(),p=n.now(),m={animate:r&&!t&&!process.env.CI&&process.env.TERM!==`dumb`,elapsed:!0,logPhases:!0},h=startCliLiveRow(i,m),g=`scaffold`,_;try{let e=d.kind===`fresh`?`creating agent`:`adding agent`;c?.(g),h.update(d.kind===`fresh`?`Creating agent`:`Adding agent`),initLog.debug(e);let r=n.now(),o;if(d.kind===`fresh`){let e=await resolveScaffoldPackageManager(d.projectPath,n),t=isPackageManagerWorkspaceMember(e,d.projectPath),r;try{r=await scaffoldProject(d.projectPath,d.projectName,d.createInPlace,e,a,n,f,d.overwriteExisting)}catch(e){if(d.failurePolicy===`clear`){let n=await cleanupFreshInitTarget(d.projectPath,d.failurePolicy,d.preservedEntries),r=e instanceof Error?e.message:String(e),i=n?`eve restored "${d.projectPath}" to its original state.`:`eve could not completely clean "${d.projectPath}".`;throw Error(`${r}\n\n${i}${workspaceFailureNote(t)}`)}if(d.failurePolicy===`remove`&&t){let t=e instanceof Error?e.message:String(e);throw Error(`${t}${workspaceFailureNote(!0)}`)}throw e}o={failurePolicy:d.failurePolicy,kind:`created`,packageManager:e,preservedTargetEntries:d.preservedEntries,projectPath:r.projectPath,retryCommand:`eve init ${d.projectPath}`,workspaceMember:t,workspaceRootMutations:r.workspaceRootMutations}}else{let e=await addToExistingProject(d.projectPath,a,n,f);o=e.nodeEngineOverride===void 0?{configurationFilesChanged:e.configurationFilesChanged,dependenciesAdded:e.dependenciesAdded,failurePolicy:`preserve`,filesWritten:e.filesWritten,kind:`added`,packageManager:e.packageManager,projectPath:d.projectPath}:{configurationFilesChanged:e.configurationFilesChanged,dependenciesAdded:e.dependenciesAdded,failurePolicy:`preserve`,filesWritten:e.filesWritten,kind:`added`,nodeEngineOverride:e.nodeEngineOverride,packageManager:e.packageManager,projectPath:d.projectPath}}let s=n.now()-r;initLog.debug(`${e} done`,{ms:s}),o.kind===`added`&&(h.stop(),reportExistingProjectChanges(i,o),h=startCliLiveRow(i,m)),g=`install_dependencies`,c?.(g),h.update(`Installing dependencies`,o.packageManager),initLog.debug(`installing dependencies with ${o.packageManager}`);let l=n.now(),v=createInstallDiagnostics(),y=await n.runPackageManagerInstall(o.packageManager,o.projectPath,{autoApprove:!0,bypassMinimumReleaseAge:!0,progressDetails:!1,onOutput:e=>{v.append(e.text),u&&initLog.debug(e.text)}}),b=n.now()-l;if(!packageManagerInstallSucceeded(y)){_=packageManagerInstallFailureCode(y),initLog.debug(`dependency installation failed`,{ms:b}),h.stop();let{lines:e,truncated:t}=v.result();t&&i.error(`Earlier install output omitted; showing the final diagnostics.`);for(let t of e)i.error(t);if(e.length===0){let e=packageManagerInstallFailureMessage(y);e!==void 0&&i.error(e)}if(o.failurePolicy!==`preserve`){if(await cleanupFreshInitTarget(o.projectPath,o.failurePolicy,o.preservedTargetEntries)){let e=o.failurePolicy===`remove`?`eve removed the incomplete project at "${o.projectPath}".`:`eve restored "${o.projectPath}" to its original state.`,t=o.workspaceMember||o.workspaceRootMutations.length>0;throw Error(`Failed to install dependencies.\n\n${e}\n\nResolve the package-manager error above, then retry:\n ${o.retryCommand}${workspaceFailureNote(t)}`)}let e=o.workspaceMember||o.workspaceRootMutations.length>0;throw Error(`Failed to install dependencies, and eve could not completely clean "${o.projectPath}".\n\nResolve the package-manager error above, then install dependencies with ${o.packageManager} in that directory. Or clean the target manually before rerunning eve init.${workspaceFailureNote(e)}`)}throw Error(`The eve agent was added, but dependency installation failed.\n\nResolve the package-manager error above, then install dependencies with ${o.packageManager} in "${o.projectPath}".\n\nDo not rerun eve init; the agent is already configured.`)}if(initLog.debug(`dependencies installed`,{ms:b}),o.kind===`created`){g=`initialize_git`,c?.(g),h.update(`Initializing Git`),initLog.debug(`initializing git repository`);let e=await n.tryInitializeGit(o.projectPath);return{...o,elapsedMs:n.now()-p,agentLaunched:t,gitResult:e}}return{...o,elapsedMs:n.now()-p,agentLaunched:t}}catch(e){throw l?.(g,`error`,g===`install_dependencies`?_:void 0),e}finally{h.stop()}}async function runInitCommand(e,t,n,r,i=defaultDependencies,a,o){let s=await i.isCodingAgentLaunch(),c=i.hasInteractiveTerminal(),l=c&&!s&&!r.nonInteractive;c&&!s&&e.log(``),a?.(`resolve_target`);let u;try{if(await addAgentsToWorkspace(e,t,n,r,i.validateModelSlug)){a?.(`handoff`),o?.(`handoff`,`completed`);return}l||e.log(eveCliBanner()),u=await runInitSteps({agentLaunched:s,interactive:c,dependencies:i,logger:e,options:r,parentDirectory:t,target:n,trackStep:a,trackTerminal:o})}catch(e){if(e instanceof WizardCancelledError){o?.(`resolve_target`,`cancelled`);return}throw e instanceof InitTargetError&&o?.(`resolve_target`,`error`,e.failureCode),e}if(a?.(`handoff`),u.kind===`created`){e.log(`${pc.green(`✓`)} Created an ${EVE_WORDMARK} agent in ${pc.bold(u.projectPath)} ${pc.dim(`in ${formatElapsed(u.elapsedMs)}`)}`);for(let t of u.workspaceRootMutations)e.log(pc.yellow(`⚠ ${formatWorkspaceRootMutationWarning(t)}`))}else e.log(`${pc.green(`✓`)} Added an ${EVE_WORDMARK} agent to ${pc.bold(u.projectPath)} ${pc.dim(`in ${formatElapsed(u.elapsedMs)}`)}`);u.kind===`created`&&u.gitResult.kind===`failed`&&(e.error(pc.yellow(`Git initialization failed during ${u.gitResult.stage}: ${u.gitResult.reason}`)),u.gitResult.stage===`commit`&&e.error(pc.yellow(`The eve agent was created successfully. Git repository metadata and staged files were preserved at "${u.projectPath}"; the initial commit is optional.\n\nTo create it later, configure Git identity and run:\n git -C ${JSON.stringify(u.projectPath)} commit -m "Initial commit from eve"`)));let d=eveDevArguments(u.packageManager),f=[u.packageManager,...d].join(` `),p=initAgentDevHandoff({projectPath:u.projectPath,devCommand:f});if(u.agentLaunched){e.log(initAgentReadySummary(r.model,u.projectPath,{workspace:r.agents!==void 0})),e.log(p);return}if(!l){e.log(p);return}let m=u.kind===`created`,h=[...u.packageManager===`pnpm`?[`--reporter=silent`]:[],...d,...m?[`--onboard`]:[]];if(e.log(``),!resultSucceeded(await i.spawnPackageManager(u.packageManager,u.projectPath,h)))throw Error(`Development server exited unsuccessfully in "${u.projectPath}".`)}function resolveInitEvePackageOverride(){let e=process.env[EVE_INIT_PACKAGE_SPEC_ENV]?.trim();if(e!==void 0&&e.length!==0)return{nodeEngine:DEFAULT_EVE_PACKAGE_CONTRACT.nodeEngine,version:e}}export{EVE_INIT_PACKAGE_SPEC_ENV,runInitCommand};
|
|
@@ -15,6 +15,7 @@ export interface ClientSendReceipt {
|
|
|
15
15
|
readonly acceptedAt: number;
|
|
16
16
|
}
|
|
17
17
|
interface DeliveryInput {
|
|
18
|
+
readonly inbox?: string;
|
|
18
19
|
readonly createStream: (options?: DeliveryReadOptions) => AsyncIterable<SessionStreamEvent>;
|
|
19
20
|
readonly deliveryId: string;
|
|
20
21
|
readonly receipt?: ClientSendReceipt;
|
|
@@ -25,6 +26,7 @@ export declare class StreamDelivery<TOutput = unknown> implements Delivery<TOutp
|
|
|
25
26
|
#private;
|
|
26
27
|
readonly sessionId: string;
|
|
27
28
|
readonly deliveryId: string;
|
|
29
|
+
readonly inbox?: string;
|
|
28
30
|
/** @internal */
|
|
29
31
|
constructor(input: DeliveryInput);
|
|
30
32
|
/** Independent, replayable read; exiting it never consumes the handle. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{turnSummary}from"#client/session-utils.js";import{throwIfAborted}from"#client/abort-signal.js";const sendReceipts=new WeakMap;var StreamDelivery=class{sessionId;deliveryId;#e;#t;constructor(e){this.sessionId=e.sessionId,this.deliveryId=e.deliveryId,e.receipt!==void 0&&sendReceipts.set(this,e.receipt),this.#e=e.createStream}async*stream(e){throwIfAborted(e?.signal);for await(let t of this.#e(e))throwIfAborted(e?.signal),yield t;throwIfAborted(e?.signal)}async result(e){if(throwIfAborted(e?.signal),this.#t!==void 0)return this.#t;let t=turnSummary(this.deliveryId);for await(let n of this.stream(e))t.observe(n);let n=t.result();if(n.status===`working`||n.outcome===void 0)throw Error(`The stream ended before the accepted delivery settled.`);let r={data:n.result,deliveryId:this.deliveryId,interactions:n.interactions,outcome:n.outcome,reply:n.message,sessionEnded:n.sessionEnded,sessionId:this.sessionId},i=n.status===`failed`?{...r,status:`failed`,error:n.failure??{code:`DELIVERY_FAILED`,message:`The delivery failed.`}}:{...r,status:n.status};return this.#t=i,i}};function getDeliveryReceipt(e){return sendReceipts.get(e)}export{StreamDelivery,getDeliveryReceipt};
|
|
1
|
+
import{turnSummary}from"#client/session-utils.js";import{throwIfAborted}from"#client/abort-signal.js";const sendReceipts=new WeakMap;var StreamDelivery=class{sessionId;deliveryId;inbox;#e;#t;constructor(e){this.sessionId=e.sessionId,this.inbox=e.inbox,this.deliveryId=e.deliveryId,e.receipt!==void 0&&sendReceipts.set(this,e.receipt),this.#e=e.createStream}async*stream(e){throwIfAborted(e?.signal);for await(let t of this.#e(e))throwIfAborted(e?.signal),yield t;throwIfAborted(e?.signal)}async result(e){if(throwIfAborted(e?.signal),this.#t!==void 0)return this.#t;let t=turnSummary(this.deliveryId);for await(let n of this.stream(e))t.observe(n);let n=t.result();if(n.status===`working`||n.outcome===void 0)throw Error(`The stream ended before the accepted delivery settled.`);let r={data:n.result,deliveryId:this.deliveryId,interactions:n.interactions,outcome:n.outcome,reply:n.message,sessionEnded:n.sessionEnded,sessionId:this.sessionId},i=n.status===`failed`?{...r,status:`failed`,error:n.failure??{code:`DELIVERY_FAILED`,message:`The delivery failed.`}}:{...r,status:n.status};return this.#t=i,i}};function getDeliveryReceipt(e){return sendReceipts.get(e)}export{StreamDelivery,getDeliveryReceipt};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{summarizeMessage}from"#client/session-store-helpers.js";var OptimisticMessageSubmissions=class{#e;#t;#n=new Map;constructor(e,t){this.#t=e,this.#e=t}reset(){this.#n.clear(),this.#r()}submit(e,t){if(e.message===void 0)return;let n=crypto.randomUUID()
|
|
1
|
+
import{summarizeMessage}from"#client/session-store-helpers.js";let submissionSequence=0;var OptimisticMessageSubmissions=class{#e;#t;#n=new Map;constructor(e,t){this.#t=e,this.#e=t}reset(){this.#n.clear(),this.#r()}submit(e,t){if(e.message===void 0)return;let n=crypto.randomUUID?.()??`submission_${(submissionSequence+=1).toString()}`;return this.#n.set(n,{id:n,message:summarizeMessage(e.message),turnId:t}),this.#r(),n}resubmit(e,t){if(e===void 0)return this.submit(t);let n=this.#n.get(e);return t.message===void 0?this.#n.delete(e):this.#n.set(e,{...n,id:e,message:summarizeMessage(t.message)}),this.#r(),t.message===void 0?void 0:e}correlate(e,t){if(e===void 0)return;let n=this.#n.get(e);n!==void 0&&this.#n.set(e,{...n,deliveryId:t})}reconcile(e){for(let[t,n]of this.#n){let r=n.deliveryId===void 0?void 0:e.deliveries[n.deliveryId];n.turnId===void 0&&r?.turnId!==void 0&&this.#n.set(t,{...n,turnId:r.turnId}),r?.consumedAt===void 0?(r?.status===`settled`||e.session.status===`ended`)&&n.error===void 0&&this.fail(Error(r?.reason??`The message was not consumed.`),t):this.#n.delete(t)}this.#r()}fail(e,t){if(t===void 0)return;let n=this.#n.get(t);n!==void 0&&(this.#n.set(t,{...n,error:{message:e.message}}),this.#r())}get awaitingReceipt(){return[...this.#n.values()].some(e=>e.deliveryId===void 0&&e.error===void 0)}#r(){this.#t([...this.#n.values()].filter(e=>this.#e||e.error!==void 0))}};export{OptimisticMessageSubmissions};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{activeTurn,failure,idle}from"#protocol/session-projection/selectors.js";import{SessionNotActiveError}from"#channel/session-not-active-error.js";import{StreamDelivery}from"#client/delivery.js";import{toError}from"#shared/errors.js";import{assertAnswerable,assertExclusiveTurnInput,isAbortError}from"#client/session-store-helpers.js";import{throwIfAborted}from"#client/abort-signal.js";import{Client}from"#client/client.js";import{OptimisticMessageSubmissions}from"#client/optimistic-message-submissions.js";import{ConversationClient}from"#client/conversation-client.js";import{waitWithSignal}from"#shared/wait-with-signal.js";const detachStore=Symbol(`detachSessionStore`),attachStore=Symbol(`attachSessionStore`);var SessionStore=class{#e;#t;#n;#r;#i;#a=new Set;#o=new Set;#s;#c;#l=new Set;#u=new Set;#d=!1;#f=!1;#p=0;#m=!1;#h={};#g=new AbortController;#_;#v;#y;#b;#x;#S;#C;#w;#T=!1;#E=0;#D=0;#O=new Set;#k=[];constructor(e){this.#t=e.prewarm??!1,this.#n=e.followAgents??!1,this.#r=e.followWhile??(()=>!0),this.#i=e.session!==void 0,this.#e=this.#i?void 0:e.client??new Client({auth:e.auth,headers:e.headers,baseUrl:e.baseUrl??``}),this.#s=new ConversationClient(()=>this.#Z()),this.#S=(e.initialEvents??[]).filter(e=>this.#s.hydrate(e)),this.#c=new OptimisticMessageSubmissions(e=>this.#s.showSubmissions(e),e.optimistic??!0),this.#b=e.session??(e.initialSession===void 0?void 0:this.#e?.sessions.attach(e.initialSession.sessionId,{streamIndex:e.initialSession.streamIndex})),this.#x=this.#q(),this.#C=this.#X()}get snapshot(){return this.#C}observe(){this.#p+=1,this.#M();let e=!1;return()=>{e||(e=!0,--this.#p,!this.#f&&this.#p===0&&this.#N())}}setCallbacks(e){this.#h=e}subscribe(e){return this.#a.add(e),()=>void this.#a.delete(e)}async prewarm(){if(this.#b!==void 0)return await this.#L(this.#b);let e=this.#g;try{await this.#I()}catch(t){throw e===this.#g&&!isAbortError(t)&&this.#l.size===0&&this.#J(t),t}e===this.#g&&this.#r(this.#s.conversation.view)&&this.#z()}async send(e){if(this.#y!==void 0)throw Error(`eve session is resuming.`);assertExclusiveTurnInput(e),assertAnswerable(e,this.#s.conversation);let t=this.#g,n=e.signal?AbortSignal.any([t.signal,e.signal]):t.signal,r=Promise.withResolvers();this.#l.add(r.promise),this.#x=void 0;let i=this.#c.submit(e,e.turnPolicy===`steer`?activeTurn(this.#s.view)?.turnId:void 0),a=this.#s.projectAnswers(e.answers);this.#Z();let o=!1;try{let s=this.#h.prepareSend===void 0?e:await waitWithSignal(Promise.resolve(this.#h.prepareSend(e)),n);throwIfAborted(n),assertExclusiveTurnInput(s),s!==e&&(i=this.#c.resubmit(i,s),a=this.#s.replaceAnswers(a,s),this.#Z()),o=!0,this.#E+=1;let c=await this.#R({...s,signal:n});throwIfAborted(n);let l=c.deliveryId;if(l===void 0)throw Error(`The server did not identify the accepted delivery.`);return a?.accept(l),a=void 0,t===this.#g&&(i!==void 0&&(this.#s.confirmSubmission(i,l),this.#c.correlate(i,l)),this.#H(l)),r.resolve(l),new StreamDelivery({sessionId:c.sessionId,deliveryId:l,createStream:e=>c.stream(e)})}catch(e){throw t===this.#g&&(a?.(),this.#c.fail(toError(e),i),isAbortError(e)||this.#J(e)),e}finally{r.resolve(void 0),t===this.#g&&(this.#l.delete(r.promise),o&&--this.#E,this.#Z(),this.#G())}}follow(e){if(this.#b===void 0)throw Error(`An eve session is required before following.`);if(e.sessionId!==this.#b.id)throw Error(`The delivery belongs to a different eve session.`);let t=this.#s.view,n=t.deliveries[e.deliveryId];t.session.status!==`ended`&&n?.status!==`settled`&&(this.#x=void 0,this.#H(e.deliveryId),this.#u.has(e.deliveryId)&&this.#z(),this.#Z())}resume(){if(this.#y!==void 0)return this.#y;if(this.#b===void 0)return Promise.reject(Error(`An eve session is required before resuming.`));if(this.#l.size>0)return Promise.reject(Error(`eve session has pending submissions.`));let e=this.#g;this.#x=void 0;let t=this.#z({startIndex:this.#s.view.position}).caughtUp.then(()=>{e===this.#g&&(this.#x??=this.#q())}).finally(()=>{e===this.#g&&(this.#y=void 0,this.#Z(),this.#G())});return this.#y=t,this.#Z(!0),t}async cancel(){let e=this.#g,t=activeTurn(this.#s.view)?.turnId??await this.#A(e.signal);return throwIfAborted(e.signal),this.#j(e=>e.cancel({turnId:t??null}))}async#A(e){let t=new Set(this.#u.keys()),n=[...this.#l],r=n.length,i=Promise.withResolvers(),check=()=>{let e=this.#s.view;if(e.session.status===`ended`)return i.resolve(void 0);for(let n of t){let r=e.deliveries[n],a=r?.turnId===void 0?void 0:e.turns[r.turnId];if(a?.status===`running`)return i.resolve(a.turnId);(r?.status===`settled`||a?.status===`settled`)&&t.delete(n)}r===0&&t.size===0?i.resolve(void 0):this.#x!==void 0&&i.reject(this.#x)};this.#o.add(check);for(let e of n)e.then(e=>{--r,e!==void 0&&t.add(e),check()});try{return check(),await waitWithSignal(i.promise,e)}finally{this.#o.delete(check)}}compact(){return this.#j(e=>e.compact())}clear(){return this.#j(e=>e.clear())}reset(){return this.#j(e=>e.reset())}async#j(e){let t=this.#b;if(t===void 0)throw new SessionNotActiveError;let n=this.#g;this.#E+=1,this.#z(),this.#Z();try{let r=await e(t);return throwIfAborted(n.signal),this.#H(r.deliveryId),r}finally{n===this.#g&&(--this.#E,this.#Z(),this.#G())}}[attachStore](){this.#f=!0,this.#M()}#M(){if(this.#d)return;this.#d=!0,this.#B();let e=this.#m&&this.#r(this.#s.conversation.view);this.#m=!1,this.#b!==void 0&&(this.#W||e)&&this.#z(),this.#t&&this.#b===void 0&&this.prewarm().catch(()=>{})}[detachStore](){this.#f=!1,this.#p===0&&this.#N()}#N(){this.#d=!1,this.#m=this.#s.streaming,this.#P()}newSession(){this.#P(),this.#i||(this.#b=void 0),this.#u.clear(),this.#O.clear(),this.#S=[],this.#s.reset(),this.#c.reset(),this.#x=void 0,this.#d&&this.#B(),this.#h.onSessionChange?.(this.#Y),this.#Z(),this.#t&&this.#d&&this.prewarm().catch(()=>{})}#P(){this.#s.stop(),this.#g.abort(),this.#g=new AbortController,this.#_=void 0,this.#y=void 0,this.#l.clear(),this.#E=0,this.#D=0,this.#F()}#F(){this.#s.closeStream();let e=this.#S.length;for(;e>0&&this.#S[e-1].meta.endOfLine===!1;)--e;e<this.#S.length&&(this.#S=this.#S.slice(0,e)),this.#k=[],this.#T=!1}#I(e){if(this.#_!==void 0)return this.#_;let t=this.#e;if(t===void 0)return Promise.reject(Error(`This store cannot create a session.`));let n=this.#g,r=e?.signal??n.signal,i=(async()=>{let i,a;return e?.message===void 0?{session:i}=await t.sessions.create({signal:r}):{session:i,delivery:a}=await t.sessions.create({...e,message:e.message,signal:r}),throwIfAborted(n.signal),this.#b=i,this.#x=void 0,this.#h.onSessionChange?.(this.#Y),this.#B(),this.#Z(),a})();this.#_=i;let clear=()=>{this.#_===i&&(this.#_=void 0)};return i.then(clear,clear),i}#L(e){let t=this.#g;if(this.#v?.lifetime===t)return this.#v.promise;let n=e.prewarm({signal:t.signal}).then(()=>void 0),r={lifetime:t,promise:n};this.#v=r;let clear=()=>{this.#v===r&&(this.#v=void 0)};return n.then(clear,clear),n}async#R(e){if(this.#_!==void 0&&await waitWithSignal(this.#_.catch(()=>void 0),e.signal),throwIfAborted(e.signal),this.#b===void 0){if(e.message===void 0)throw Error(`Cannot answer before the session starts.`);let t=await this.#I(e);if(this.#z(e),t===void 0)throw Error(`The session was created without accepting a message.`);return t}return this.#z(e),e.answers===void 0?await this.#b.send(e.message,e):await this.#b.respond(e.answers,e)}#z(e={}){if(this.#b===void 0)throw Error(`A session is required before opening its stream.`);this.#B();let t=this.#g;return this.#s.stream(this.#b,{startIndex:this.#s.view.position,...e,onEvent:(e,n)=>{t===this.#g&&this.#V(e,n)},onError:e=>{t===this.#g&&(this.#F(),this.#J(e))}})}#B(){this.#n&&this.#b&&this.#s.follow(this.#b,this.#n)}#V(e,t){let n=this.#g;if(this.#T=e.meta.endOfLine===!1,!this.#s.observe(e,{notify:!1})||(this.#S=[...this.#S,e],this.#h.onEvent?.(e),n!==this.#g)||(e.type===`turn.started`&&!t&&(this.#x=void 0),(e.type===`turn.settled`||e.type===`session.ended`)&&this.#k.push({event:e,historical:t}),this.#T))return;let r=this.#s.view,i=new Set([...this.#u].map(e=>r.deliveries[e]?.turnId).filter(e=>e!==void 0));this.#U();for(let e of this.#k.splice(0)){if(e.event.type===`turn.settled`)e.historical?i.has(e.event.data.turnId)&&this.#l.size===0&&(this.#x??=this.#q(e.event.data.turnId)):this.#K(e.event.data.turnId);else if(e.event.data.outcome===`failed`){let t=Object.assign(Error(e.event.data.error?.message??`The session failed.`),{name:e.event.data.error?.code??`SESSION_FAILED`});e.historical?this.#l.size===0&&(this.#x??=t):this.#J(t)}if(n!==this.#g)return}for(let e of this.#o)e();this.#h.onSessionChange?.(this.#Y),n===this.#g&&(this.#Z(),n===this.#g&&(this.#s.reconcileFollowing(),n===this.#g&&this.#G()))}#H(e){this.#u.add(e),this.#U();let t=this.#s.view,n=t.deliveries[e]?.turnId;n!==void 0&&t.turns[n]?.status===`settled`&&(this.#x??=this.#q(n)),t.session.status===`ended`&&(this.#x??=this.#q())}#U(){let e=this.#s.view;e.session.status===`ended`&&this.#u.clear(),this.#c.reconcile(e);for(let t of this.#u)e.deliveries[t]?.status===`settled`&&this.#u.delete(t)}get#W(){return this.#y!==void 0||this.#E>0||this.#l.size>0||this.#u.size>0}#G(){this.#T||this.#W||this.#r(this.#s.conversation.view)||this.#s.closeStream()}#K(e){if(this.#O.has(e)||this.#s.view.turns[e]?.status!==`settled`)return;this.#O.add(e),this.#D+=1;let t=failure(this.#s.view,e);t!==void 0&&this.#J(Object.assign(Error(t.message),{name:t.code}))}#q(e=this.#s.view.session.latestTurnId){let t=this.#s.view,n=failure(t,e);return n===void 0?void 0:Object.assign(Error(n.message),{name:n.code})}#J(e){let t=this.#x!==void 0;this.#x=toError(e);for(let e of this.#o)e();t||this.#h.onError?.(this.#x),this.#Z()}get#Y(){if(this.#b===void 0)return this.#w=void 0;let e=this.#b.id,t=this.#s.view.position;return(this.#w?.sessionId!==e||this.#w.streamIndex!==t)&&(this.#w={sessionId:e,streamIndex:t}),this.#w}#X(){this.#s.holdUnconfirmedMessages(this.#E>0&&this.#c.awaitingReceipt);let e=this.#s.conversation,{view:t}=e;return{...e,view:t,error:this.#x,events:this.#S,session:this.#Y,status:this.#y===void 0?this.#W||!idle(this.#s.view)?`busy`:`idle`:`resuming`}}#Z(e=!1){if(this.#y!==void 0&&!e)return;if(this.#T){if(this.#x===void 0&&!this.#W)return;this.#C={...this.#C,error:this.#x,status:this.#y===void 0?this.#W?`busy`:this.#C.status:`resuming`};for(let e of this.#a)e();return}this.#C=this.#X();let t=this.#D,n=this.#g;this.#D=0;for(let e of this.#a)e();for(let e=0;e<t&&n===this.#g;e+=1)this.#h.onFinish?.(this.#C)}};function detachSessionStore(e){e[detachStore]()}function attachSessionStore(e){e[attachStore]()}export{SessionStore,attachSessionStore,detachSessionStore};
|
|
1
|
+
import{activeTurn,failure,idle}from"#protocol/session-projection/selectors.js";import{SessionNotActiveError}from"#channel/session-not-active-error.js";import{StreamDelivery}from"#client/delivery.js";import{toError}from"#shared/errors.js";import{assertAnswerable,assertExclusiveTurnInput,isAbortError}from"#client/session-store-helpers.js";import{throwIfAborted}from"#client/abort-signal.js";import{Client}from"#client/client.js";import{OptimisticMessageSubmissions}from"#client/optimistic-message-submissions.js";import{ConversationClient}from"#client/conversation-client.js";import{waitWithSignal}from"#shared/wait-with-signal.js";const detachStore=Symbol(`detachSessionStore`),attachStore=Symbol(`attachSessionStore`);var SessionStore=class{#e;#t;#n;#r;#i;#a=new Set;#o=new Set;#s;#c;#l=new Set;#u=new Set;#d=!1;#f=!1;#p=0;#m=!1;#h={};#g=new AbortController;#_;#v;#y;#b;#x;#S;#C;#w;#T=!1;#E=0;#D=0;#O=new Set;#k=[];constructor(e){this.#t=e.prewarm??!1,this.#n=e.followAgents??!1,this.#r=e.followWhile??(()=>!0),this.#i=e.session!==void 0,this.#e=this.#i?void 0:e.client??new Client({auth:e.auth,headers:e.headers,baseUrl:e.baseUrl??``}),this.#s=new ConversationClient(()=>this.#Z()),this.#S=(e.initialEvents??[]).filter(e=>this.#s.hydrate(e)),this.#c=new OptimisticMessageSubmissions(e=>this.#s.showSubmissions(e),e.optimistic??!0),this.#b=e.session??(e.initialSession===void 0?void 0:this.#e?.sessions.attach(e.initialSession.sessionId,{streamIndex:e.initialSession.streamIndex,inbox:e.initialSession.inbox})),this.#x=this.#q(),this.#C=this.#X()}get snapshot(){return this.#C}observe(){this.#p+=1,this.#M();let e=!1;return()=>{e||(e=!0,--this.#p,!this.#f&&this.#p===0&&this.#N())}}setCallbacks(e){this.#h=e}subscribe(e){return this.#a.add(e),()=>void this.#a.delete(e)}async prewarm(){if(this.#b!==void 0)return await this.#L(this.#b);let e=this.#g;try{await this.#I()}catch(t){throw e===this.#g&&!isAbortError(t)&&this.#l.size===0&&this.#J(t),t}e===this.#g&&this.#r(this.#s.conversation.view)&&this.#z()}async send(e){if(this.#y!==void 0)throw Error(`eve session is resuming.`);assertExclusiveTurnInput(e),assertAnswerable(e,this.#s.conversation);let t=this.#g,n=e.signal?AbortSignal.any([t.signal,e.signal]):t.signal,r=Promise.withResolvers();this.#l.add(r.promise),this.#x=void 0;let i=this.#c.submit(e,e.turnPolicy===`steer`?activeTurn(this.#s.view)?.turnId:void 0),a=this.#s.projectAnswers(e.answers);this.#Z();let o=!1;try{let s=this.#h.prepareSend===void 0?e:await waitWithSignal(Promise.resolve(this.#h.prepareSend(e)),n);throwIfAborted(n),assertExclusiveTurnInput(s),s!==e&&(i=this.#c.resubmit(i,s),a=this.#s.replaceAnswers(a,s),this.#Z()),o=!0,this.#E+=1;let c=await this.#R({...s,signal:n});throwIfAborted(n);let l=c.deliveryId;if(l===void 0)throw Error(`The server did not identify the accepted delivery.`);return a?.accept(l),a=void 0,t===this.#g&&(i!==void 0&&(this.#s.confirmSubmission(i,l),this.#c.correlate(i,l)),this.#H(l),this.#h.onSessionChange?.(this.#Y)),r.resolve(l),new StreamDelivery({sessionId:c.sessionId,deliveryId:l,createStream:e=>c.stream(e)})}catch(e){throw t===this.#g&&(a?.(),this.#c.fail(toError(e),i),isAbortError(e)||this.#J(e)),e}finally{r.resolve(void 0),t===this.#g&&(this.#l.delete(r.promise),o&&--this.#E,this.#Z(),this.#G())}}follow(e){if(this.#b===void 0)throw Error(`An eve session is required before following.`);if(e.sessionId!==this.#b.id)throw Error(`The delivery belongs to a different eve session.`);let t=this.#s.view,n=t.deliveries[e.deliveryId];t.session.status!==`ended`&&n?.status!==`settled`&&(this.#x=void 0,this.#H(e.deliveryId),this.#u.has(e.deliveryId)&&this.#z(),this.#Z())}resume(){if(this.#y!==void 0)return this.#y;if(this.#b===void 0)return Promise.reject(Error(`An eve session is required before resuming.`));if(this.#l.size>0)return Promise.reject(Error(`eve session has pending submissions.`));let e=this.#g;this.#x=void 0;let t=this.#z({startIndex:this.#s.view.position}).caughtUp.then(()=>{e===this.#g&&(this.#x??=this.#q())}).finally(()=>{e===this.#g&&(this.#y=void 0,this.#Z(),this.#G())});return this.#y=t,this.#Z(!0),t}async cancel(){let e=this.#g,t=activeTurn(this.#s.view)?.turnId??await this.#A(e.signal);return throwIfAborted(e.signal),this.#j(e=>e.cancel({turnId:t??null}))}async#A(e){let t=new Set(this.#u.keys()),n=[...this.#l],r=n.length,i=Promise.withResolvers(),check=()=>{let e=this.#s.view;if(e.session.status===`ended`)return i.resolve(void 0);for(let n of t){let r=e.deliveries[n],a=r?.turnId===void 0?void 0:e.turns[r.turnId];if(a?.status===`running`)return i.resolve(a.turnId);(r?.status===`settled`||a?.status===`settled`)&&t.delete(n)}r===0&&t.size===0?i.resolve(void 0):this.#x!==void 0&&i.reject(this.#x)};this.#o.add(check);for(let e of n)e.then(e=>{--r,e!==void 0&&t.add(e),check()});try{return check(),await waitWithSignal(i.promise,e)}finally{this.#o.delete(check)}}compact(){return this.#j(e=>e.compact())}clear(){return this.#j(e=>e.clear())}reset(){return this.#j(e=>e.reset())}async#j(e){let t=this.#b;if(t===void 0)throw new SessionNotActiveError;let n=this.#g;this.#E+=1,this.#z(),this.#Z();try{let r=await e(t);return throwIfAborted(n.signal),this.#H(r.deliveryId),r}finally{n===this.#g&&(--this.#E,this.#Z(),this.#G())}}[attachStore](){this.#f=!0,this.#M()}#M(){if(this.#d)return;this.#d=!0,this.#B();let e=this.#m&&this.#r(this.#s.conversation.view);this.#m=!1,this.#b!==void 0&&(this.#W||e)&&this.#z(),this.#t&&this.#b===void 0&&this.prewarm().catch(()=>{})}[detachStore](){this.#f=!1,this.#p===0&&this.#N()}#N(){this.#d=!1,this.#m=this.#s.streaming,this.#P()}newSession(){this.#P(),this.#i||(this.#b=void 0),this.#u.clear(),this.#O.clear(),this.#S=[],this.#s.reset(),this.#c.reset(),this.#x=void 0,this.#d&&this.#B(),this.#h.onSessionChange?.(this.#Y),this.#Z(),this.#t&&this.#d&&this.prewarm().catch(()=>{})}#P(){this.#s.stop(),this.#g.abort(),this.#g=new AbortController,this.#_=void 0,this.#y=void 0,this.#l.clear(),this.#E=0,this.#D=0,this.#F()}#F(){this.#s.closeStream();let e=this.#S.length;for(;e>0&&this.#S[e-1].meta.endOfLine===!1;)--e;e<this.#S.length&&(this.#S=this.#S.slice(0,e)),this.#k=[],this.#T=!1}#I(e){if(this.#_!==void 0)return this.#_;let t=this.#e;if(t===void 0)return Promise.reject(Error(`This store cannot create a session.`));let n=this.#g,r=e?.signal??n.signal,i=(async()=>{let i,a;return e?.message===void 0?{session:i}=await t.sessions.create({signal:r}):{session:i,delivery:a}=await t.sessions.create({...e,message:e.message,signal:r}),throwIfAborted(n.signal),this.#b=i,this.#x=void 0,this.#h.onSessionChange?.(this.#Y),this.#B(),this.#Z(),a})();this.#_=i;let clear=()=>{this.#_===i&&(this.#_=void 0)};return i.then(clear,clear),i}#L(e){let t=this.#g;if(this.#v?.lifetime===t)return this.#v.promise;let n=e.prewarm({signal:t.signal}).then(()=>void 0),r={lifetime:t,promise:n};this.#v=r;let clear=()=>{this.#v===r&&(this.#v=void 0)};return n.then(clear,clear),n}async#R(e){if(this.#_!==void 0&&await waitWithSignal(this.#_.catch(()=>void 0),e.signal),throwIfAborted(e.signal),this.#b===void 0){if(e.message===void 0)throw Error(`Cannot answer before the session starts.`);let t=await this.#I(e);if(this.#z(e),t===void 0)throw Error(`The session was created without accepting a message.`);return t}return this.#z(e),e.answers===void 0?await this.#b.send(e.message,e):await this.#b.respond(e.answers,e)}#z(e={}){if(this.#b===void 0)throw Error(`A session is required before opening its stream.`);this.#B();let t=this.#g;return this.#s.stream(this.#b,{startIndex:this.#s.view.position,...e,onEvent:(e,n)=>{t===this.#g&&this.#V(e,n)},onError:e=>{t===this.#g&&(this.#F(),this.#J(e))}})}#B(){this.#n&&this.#b&&this.#s.follow(this.#b,this.#n)}#V(e,t){let n=this.#g;if(this.#T=e.meta.endOfLine===!1,!this.#s.observe(e,{notify:!1})||(this.#S=[...this.#S,e],this.#h.onEvent?.(e),n!==this.#g)||(e.type===`turn.started`&&!t&&(this.#x=void 0),(e.type===`turn.settled`||e.type===`session.ended`)&&this.#k.push({event:e,historical:t}),this.#T))return;let r=this.#s.view,i=new Set([...this.#u].map(e=>r.deliveries[e]?.turnId).filter(e=>e!==void 0));this.#U();for(let e of this.#k.splice(0)){if(e.event.type===`turn.settled`)e.historical?i.has(e.event.data.turnId)&&this.#l.size===0&&(this.#x??=this.#q(e.event.data.turnId)):this.#K(e.event.data.turnId);else if(e.event.data.outcome===`failed`){let t=Object.assign(Error(e.event.data.error?.message??`The session failed.`),{name:e.event.data.error?.code??`SESSION_FAILED`});e.historical?this.#l.size===0&&(this.#x??=t):this.#J(t)}if(n!==this.#g)return}for(let e of this.#o)e();this.#h.onSessionChange?.(this.#Y),n===this.#g&&(this.#Z(),n===this.#g&&(this.#s.reconcileFollowing(),n===this.#g&&this.#G()))}#H(e){this.#u.add(e),this.#U();let t=this.#s.view,n=t.deliveries[e]?.turnId;n!==void 0&&t.turns[n]?.status===`settled`&&(this.#x??=this.#q(n)),t.session.status===`ended`&&(this.#x??=this.#q())}#U(){let e=this.#s.view;e.session.status===`ended`&&this.#u.clear(),this.#c.reconcile(e);for(let t of this.#u)e.deliveries[t]?.status===`settled`&&this.#u.delete(t)}get#W(){return this.#y!==void 0||this.#E>0||this.#l.size>0||this.#u.size>0}#G(){this.#T||this.#W||this.#r(this.#s.conversation.view)||this.#s.closeStream()}#K(e){if(this.#O.has(e)||this.#s.view.turns[e]?.status!==`settled`)return;this.#O.add(e),this.#D+=1;let t=failure(this.#s.view,e);t!==void 0&&this.#J(Object.assign(Error(t.message),{name:t.code}))}#q(e=this.#s.view.session.latestTurnId){let t=this.#s.view,n=failure(t,e);return n===void 0?void 0:Object.assign(Error(n.message),{name:n.code})}#J(e){let t=this.#x!==void 0;this.#x=toError(e);for(let e of this.#o)e();t||this.#h.onError?.(this.#x),this.#Z()}get#Y(){if(this.#b===void 0)return this.#w=void 0;let e=this.#b.id,t=this.#s.view.position,{inbox:n}=this.#b.state;return(this.#w?.sessionId!==e||this.#w.streamIndex!==t||this.#w.inbox!==n)&&(this.#w={sessionId:e,streamIndex:t,inbox:n}),this.#w}#X(){this.#s.holdUnconfirmedMessages(this.#E>0&&this.#c.awaitingReceipt);let e=this.#s.conversation,{view:t}=e;return{...e,view:t,error:this.#x,events:this.#S,session:this.#Y,status:this.#y===void 0?this.#W||!idle(this.#s.view)?`busy`:`idle`:`resuming`}}#Z(e=!1){if(this.#y!==void 0&&!e)return;if(this.#T){if(this.#x===void 0&&!this.#W)return;this.#C={...this.#C,error:this.#x,status:this.#y===void 0?this.#W?`busy`:this.#C.status:`resuming`};for(let e of this.#a)e();return}this.#C=this.#X();let t=this.#D,n=this.#g;this.#D=0;for(let e of this.#a)e();for(let e=0;e<t&&n===this.#g;e+=1)this.#h.onFinish?.(this.#C)}};function detachSessionStore(e){e[detachStore]()}function attachSessionStore(e){e[attachStore]()}export{SessionStore,attachSessionStore,detachSessionStore};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SessionNotActiveError}from"#channel/session-not-active-error.js";import{StreamDelivery}from"#client/delivery.js";import{deliveryEvents}from"#client/delivery-events.js";import{EVE_SESSION_ROUTE_PATH,createEveSessionRoutePath,createEveSessionStreamRoutePath}from"#protocol/routes.js";import{ClientError,createClientError}from"#client/client-error.js";import{EVE_SESSION_ID_HEADER}from"#protocol/session-http.js";import{followStreamIterable,sleep}from"#client/open-stream.js";import{createClientUrl}from"#client/url.js";import{throwIfAborted}from"#client/abort-signal.js";import{ClientAgentSession}from"#client/agent-session.js";import{messageForRequest}from"#client/file-parts.js";import{prewarmClientSession,sendClientControl}from"#client/session-controls.js";import{serializeOutputSchema}from"#tools/schema.js";const followSession=Symbol(`followClientSession`);var ClientSession=class ClientSession{#e;#t;constructor(e,t){this.#e=e,this.#t=t}static async create(e,t){let n=Date.now(),r=await postTurn(e,EVE_SESSION_ROUTE_PATH,t,!0,t.stubs),i=Date.now(),{sessionId:a,deliveryId:o}=await readAcceptedMessage(r),s=new ClientSession(e,{sessionId:a,streamIndex:0}),c={deliveryId:o,startedAt:n,notReadyMs:0,acceptedAt:i};return{delivery:s.#i(r,t,0,o,c),session:s}}static async prewarm(e,t={}){let{sessionId:n}=await readAcceptedMessage(await postCreateSession(e,t));return new ClientSession(e,{sessionId:n,streamIndex:0})}get id(){return this.#t.sessionId}get state(){return this.#t}async snapshot(e){throwIfAborted(e?.signal);let t=[],n=0;for await(let{cursor:r,event:i}of this.#c({follow:!1,signal:e?.signal,startIndex:0}))t.push(i),n=r;return throwIfAborted(e?.signal),{events:t,session:{sessionId:this.#t.sessionId,streamIndex:n}}}async send(e,t={}){return await this.#n({...t,message:e},!0)}async respond(e,t={}){if(e.length===0)throw Error(`ClientSession.respond() requires at least one answer.`);return await this.#n({...t,answers:e},!1)}async#n(e,t){let n=this.#t.streamIndex,r=createEveSessionRoutePath(this.#t.sessionId),{response:i,timing:a}=await postSessionSend(this.#e,r,e,t),{sessionId:o,deliveryId:s}=await readAcceptedMessage(i,this.#t.sessionId);if(o!==this.#t.sessionId)throw Error(`Message route returned a different session id.`);if(s===void 0)throw Error(`Message route did not return a delivery id. Update the server before sending with this client.`);return this.#i(i,e,n,s,{...a,deliveryId:s})}async prewarm(e){return await prewarmClientSession({context:this.#e,sessionId:this.#t.sessionId,signal:e?.signal})}async cancel(e){return this.#r(`cancel`,e)}async clear(e){return this.#r(`clear`,e)}async compact(e){return this.#r(`compact`,e)}async reset(e){return this.#r(`reset`,e)}async#r(e,t){let n=this.#t.streamIndex,r=await sendClientControl({context:this.#e,kind:e,options:t,sessionId:this.#t.sessionId});return new StreamDelivery({...r,createStream:t=>this.#a(n,{signal:t?.signal},r.deliveryId,e!==`reset`)})}stream(e){return this.#o(e)}agent(e){return new ClientAgentSession(this.#e,this.id,e)}[followSession](e){return this.#o(e)}#i(e,t,n,r,i){if(e.body?.cancel().catch(()=>{}),r===void 0)throw Error(`Message route did not return a delivery id.`);return new StreamDelivery({createStream:e=>this.#a(n,{...t,signal:e?.signal},r),deliveryId:r,receipt:i,sessionId:this.#t.sessionId})}#a(e,t,n,r=!0){return deliveryEvents(this.#o({follow:r,headers:t.headers,signal:t.signal,startIndex:e,streamReconnectPolicy:t.streamReconnectPolicy}),n,t.signal)}async*#o(e){let t=e?.startIndex??this.#t.streamIndex;for await(let{cursor:n,event:r}of this.#c({follow:e?.follow,headers:e?.headers,onCaughtUp:e?.onCaughtUp,resolveHeaders:e?.resolveHeaders,resolveReconnectPolicy:e?.resolveReconnectPolicy,signal:e?.signal,startIndex:t,streamReconnectPolicy:e?.streamReconnectPolicy}))this.#s(n),yield r}#s(e){this.#t={
|
|
1
|
+
import{SessionNotActiveError}from"#channel/session-not-active-error.js";import{StreamDelivery}from"#client/delivery.js";import{deliveryEvents}from"#client/delivery-events.js";import{EVE_SESSION_ROUTE_PATH,createEveSessionRoutePath,createEveSessionStreamRoutePath}from"#protocol/routes.js";import{ClientError,createClientError}from"#client/client-error.js";import{EVE_SESSION_ID_HEADER}from"#protocol/session-http.js";import{followStreamIterable,sleep}from"#client/open-stream.js";import{createClientUrl}from"#client/url.js";import{throwIfAborted}from"#client/abort-signal.js";import{ClientAgentSession}from"#client/agent-session.js";import{messageForRequest}from"#client/file-parts.js";import{prewarmClientSession,sendClientControl}from"#client/session-controls.js";import{serializeOutputSchema}from"#tools/schema.js";const followSession=Symbol(`followClientSession`);var ClientSession=class ClientSession{#e;#t;constructor(e,t){this.#e=e,this.#t=t}static async create(e,t){let n=Date.now(),r=await postTurn(e,EVE_SESSION_ROUTE_PATH,t,!0,t.stubs),i=Date.now(),{sessionId:a,deliveryId:o}=await readAcceptedMessage(r),s=new ClientSession(e,{sessionId:a,streamIndex:0}),c={deliveryId:o,startedAt:n,notReadyMs:0,acceptedAt:i};return{delivery:s.#i(r,t,0,o,c),session:s}}static async prewarm(e,t={}){let{sessionId:n}=await readAcceptedMessage(await postCreateSession(e,t));return new ClientSession(e,{sessionId:n,streamIndex:0})}get id(){return this.#t.sessionId}get state(){return this.#t}async snapshot(e){throwIfAborted(e?.signal);let t=[],n=0;for await(let{cursor:r,event:i}of this.#c({follow:!1,signal:e?.signal,startIndex:0}))t.push(i),n=r;return throwIfAborted(e?.signal),{events:t,session:{sessionId:this.#t.sessionId,streamIndex:n}}}async send(e,t={}){return await this.#n({...t,message:e},!0)}async respond(e,t={}){if(e.length===0)throw Error(`ClientSession.respond() requires at least one answer.`);return await this.#n({...t,answers:e},!1)}async#n(e,t){let n=this.#t.streamIndex,r=createEveSessionRoutePath(this.#t.sessionId),{response:i,timing:a}=await postSessionSend(this.#e,r,e,t,this.#t.inbox),{sessionId:o,deliveryId:s,inbox:c}=await readAcceptedMessage(i,this.#t.sessionId);if(o!==this.#t.sessionId)throw Error(`Message route returned a different session id.`);if(this.#t={...this.#t,inbox:c},s===void 0)throw Error(`Message route did not return a delivery id. Update the server before sending with this client.`);return this.#i(i,e,n,s,{...a,deliveryId:s})}async prewarm(e){return await prewarmClientSession({context:this.#e,sessionId:this.#t.sessionId,signal:e?.signal})}async cancel(e){return this.#r(`cancel`,e)}async clear(e){return this.#r(`clear`,e)}async compact(e){return this.#r(`compact`,e)}async reset(e){return this.#r(`reset`,e)}async#r(e,t){let n=this.#t.streamIndex,r=await sendClientControl({context:this.#e,kind:e,options:t,sessionId:this.#t.sessionId});return new StreamDelivery({...r,createStream:t=>this.#a(n,{signal:t?.signal},r.deliveryId,e!==`reset`)})}stream(e){return this.#o(e)}agent(e){return new ClientAgentSession(this.#e,this.id,e)}[followSession](e){return this.#o(e)}#i(e,t,n,r,i){if(e.body?.cancel().catch(()=>{}),r===void 0)throw Error(`Message route did not return a delivery id.`);return new StreamDelivery({createStream:e=>this.#a(n,{...t,signal:e?.signal},r),deliveryId:r,receipt:i,sessionId:this.#t.sessionId})}#a(e,t,n,r=!0){return deliveryEvents(this.#o({follow:r,headers:t.headers,signal:t.signal,startIndex:e,streamReconnectPolicy:t.streamReconnectPolicy}),n,t.signal)}async*#o(e){let t=e?.startIndex??this.#t.streamIndex;for await(let{cursor:n,event:r}of this.#c({follow:e?.follow,headers:e?.headers,onCaughtUp:e?.onCaughtUp,resolveHeaders:e?.resolveHeaders,resolveReconnectPolicy:e?.resolveReconnectPolicy,signal:e?.signal,startIndex:t,streamReconnectPolicy:e?.streamReconnectPolicy}))this.#s(n),yield r}#s(e){this.#t={...this.#t,streamIndex:Math.max(this.#t.streamIndex,e)}}#c(e){return followStreamIterable({onCaughtUp:e.onCaughtUp,follow:e.follow,baseUrl:this.#e.baseUrl,resolveHeaders:()=>this.#e.resolveHeaders(e.resolveHeaders?.()??e.headers),path:createEveSessionStreamRoutePath(this.#t.sessionId),redirect:this.#e.redirect,signal:e.signal,startIndex:e.startIndex,streamReconnectPolicy:e.streamReconnectPolicy,resolveReconnectPolicy:e.resolveReconnectPolicy})}};function followClientSession(e,t){return e[followSession](t)}async function postSessionSend(e,t,n,r,i){let a=Date.now(),o=a+2e4,s=250;for(;;){let c=Date.now();try{return{response:await postTurn(e,t,n,!1,void 0,i),timing:{startedAt:a,notReadyMs:c-a,acceptedAt:Date.now()}}}catch(e){if(!r||!isSessionNotReady(e))throw e;let t=o-Date.now();if(t<=0)throw e;await sleep(Math.min(s,t),n.signal)}throwIfAborted(n.signal),s=Math.min(s*2,2e3)}}async function postCreateSession(e,t){let n=await e.resolveHeaders(t.headers),r=t.stubs===void 0?void 0:JSON.stringify({stubs:t.stubs});r!==void 0&&n.set(`content-type`,`application/json`);let i=await fetch(createClientUrl(e.baseUrl,EVE_SESSION_ROUTE_PATH),{body:r,headers:n,method:`POST`,redirect:e.redirect,signal:t.signal??null});if(!i.ok){let e=await i.text();throw new ClientError(i.status,e,i.headers)}return i}function isSessionNotReady(e){return SessionNotActiveError.is(e)&&e.retryable}async function postTurn(e,t,n,r,i,a){let o=createMessageBody(n,r);if(o===null)throw Error(r?`Creating a session requires a non-empty message.`:`A session turn requires a non-empty message or answers.`);i!==void 0&&(o.stubs=i),a!==void 0&&(o.inbox=a);let s=await e.resolveHeaders(n.headers);s.set(`content-type`,`application/json`);let c=await fetch(createClientUrl(e.baseUrl,t),{body:JSON.stringify(o),headers:s,method:`POST`,redirect:e.redirect,signal:n.signal??null});if(!c.ok){let e=await c.text();throw createClientError(c.status,e,c.headers)}return c}async function readAcceptedMessage(e,t){let n=await e.json(),r=(typeof n.sessionId==`string`?n.sessionId:void 0)??e.headers.get(EVE_SESSION_ID_HEADER)?.trim()??t;if(!r)throw Error(`Message route did not return a session id.`);return{sessionId:r,inbox:typeof n.inbox==`string`?n.inbox:void 0,deliveryId:typeof n.deliveryId==`string`&&n.deliveryId.length>0?n.deliveryId:void 0}}function createMessageBody(e,t){let n={};e.message!==void 0&&(n.message=messageForRequest(e.message)),e.answers!==void 0&&e.answers.length>0&&(n.answers=e.answers),!t&&e.message!==void 0&&e.turnPolicy!==void 0&&(n.turnPolicy=e.turnPolicy),e.clientContext!==void 0&&(n.clientContext=e.clientContext);let r=serializeOutputSchema(e.outputSchema);return r!==void 0&&(n.outputSchema=r),t&&n.message===void 0||n.message===void 0&&n.answers===void 0?null:n}export{ClientSession,followClientSession};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ClientSession}from"#client/session.js";var ClientSessions=class{#e;constructor(e){this.#e=e}async create(e={}){return`message`in e?await ClientSession.create(this.#e,e):{session:await ClientSession.prewarm(this.#e,e)}}attach(e,t){if(e.length===0)throw Error(`sessionId must be a non-empty string.`);return new ClientSession(this.#e,{sessionId:e,streamIndex:t?.streamIndex??0})}};export{ClientSessions};
|
|
1
|
+
import{ClientSession}from"#client/session.js";var ClientSessions=class{#e;constructor(e){this.#e=e}async create(e={}){return`message`in e?await ClientSession.create(this.#e,e):{session:await ClientSession.prewarm(this.#e,e)}}attach(e,t){if(e.length===0)throw Error(`sessionId must be a non-empty string.`);return new ClientSession(this.#e,{sessionId:e,inbox:t?.inbox,streamIndex:t?.streamIndex??0})}};export{ClientSessions};
|
|
@@ -203,6 +203,8 @@ export type { Delivery, DeliveryResult } from "#shared/delivery.js";
|
|
|
203
203
|
* Serializable cursor for one fixed, ID-addressed client session.
|
|
204
204
|
*/
|
|
205
205
|
export interface ClientSessionState {
|
|
206
|
+
/** Opaque delivery routing hint; preserve it when saving and restoring a session. */
|
|
207
|
+
readonly inbox?: string;
|
|
206
208
|
readonly sessionId: string;
|
|
207
209
|
readonly streamIndex: number;
|
|
208
210
|
}
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@vercel/oidc": "3.8.0",
|
|
50
50
|
"@vercel/otel": "2.1.3",
|
|
51
51
|
"@vercel/queue": "0.5.1",
|
|
52
|
-
"@vercel/sandbox": "3.
|
|
52
|
+
"@vercel/sandbox": "3.9.0",
|
|
53
53
|
"@vercel/sdk": "1.28.8",
|
|
54
54
|
"@vercel/schedules": "0.0.0-alpha.11",
|
|
55
55
|
"@workflow/core": "5.2.3",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"zod": "4.5.4",
|
|
62
62
|
"zod-validation-error": "5.0.0"
|
|
63
63
|
},
|
|
64
|
-
"scriptHash": "
|
|
64
|
+
"scriptHash": "cb6b617bbc0dc933c6c8c99f99382c7b96a55e11f69edc3eb77cb07e0c2a5bbd",
|
|
65
65
|
"toolVersions": {
|
|
66
66
|
"rolldown": "1.2.9",
|
|
67
67
|
"typescript": "7.0.2"
|