eve 0.22.1 → 0.22.3
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 +38 -0
- package/dist/src/chunks/{use-eve-agent-CM24ZUEI.js → use-eve-agent-Cojyfr4X.js} +25 -13
- package/dist/src/chunks/{use-eve-agent-CxcKypLZ.js → use-eve-agent-D-S1TPCW.js} +25 -13
- package/dist/src/cli/commands/init-repl.d.ts +6 -5
- package/dist/src/cli/dev/url.js +1 -1
- package/dist/src/client/client-error.d.ts +5 -1
- package/dist/src/client/client-error.js +1 -1
- package/dist/src/client/client.js +1 -1
- package/dist/src/client/open-stream.js +1 -1
- package/dist/src/client/session.js +1 -1
- package/dist/src/client/types.d.ts +2 -1
- package/dist/src/client/url.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +6 -4
- package/dist/src/compiled/@workflow/core/create-hook.d.ts +2 -2
- package/dist/src/compiled/@workflow/core/events-consumer.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/index.js +2 -2
- package/dist/src/compiled/@workflow/core/private.js +1 -1
- package/dist/src/compiled/@workflow/core/runtime/constants.d.ts +14 -0
- package/dist/src/compiled/@workflow/core/runtime/get-world-lazy.d.ts +3 -12
- package/dist/src/compiled/@workflow/core/runtime/wait-continuation.d.ts +2 -2
- package/dist/src/compiled/@workflow/core/runtime/world-compatibility.d.ts +5 -0
- package/dist/src/compiled/@workflow/core/runtime/world-init.d.ts +16 -41
- package/dist/src/compiled/@workflow/core/runtime/world-target.d.ts +11 -0
- package/dist/src/compiled/@workflow/core/runtime/world.d.ts +21 -9
- package/dist/src/compiled/@workflow/core/runtime.d.ts +2 -1
- package/dist/src/compiled/@workflow/core/runtime.js +3 -141
- package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/workflow/world-init-stub.d.ts +2 -2
- package/dist/src/compiled/@workflow/core/workflow.js +1 -1
- package/dist/src/compiled/@workflow/errors/index.js +1 -1
- package/dist/src/compiled/@workflow/world/analytics.d.ts +182 -0
- package/dist/src/compiled/@workflow/world/env-config.d.ts +39 -0
- package/dist/src/compiled/@workflow/world/events.d.ts +25 -0
- package/dist/src/compiled/@workflow/world/index.d.ts +6 -3
- package/dist/src/compiled/@workflow/world/interfaces.d.ts +14 -7
- package/dist/src/compiled/@workflow/world/runs.d.ts +9 -1
- package/dist/src/compiled/@workflow/world/shared.d.ts +15 -0
- package/dist/src/compiled/@workflow/world/steps.d.ts +8 -0
- package/dist/src/compiled/@workflow/world-local/LICENSE.md +201 -0
- package/dist/src/compiled/@workflow/world-local/index.js +4 -0
- package/dist/src/compiled/@workflow/world-vercel/LICENSE.md +201 -0
- package/dist/src/compiled/@workflow/world-vercel/index.js +42 -0
- package/dist/src/compiled/_chunks/workflow/attribute-changes-BnKD8Y3m.js +20 -0
- package/dist/src/compiled/_chunks/workflow/{dist-FLIfyJ4Y.js → dist-CttsoN4D.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/dist-DJU_7R9s.js +40 -0
- package/dist/src/compiled/_chunks/workflow/dist-DpDDcpTl.js +3 -0
- package/dist/src/compiled/_chunks/workflow/resume-hook-DjPY9VGg.js +1 -0
- package/dist/src/compiled/_chunks/workflow/run-BSANnUPR.js +1 -0
- package/dist/src/compiled/_chunks/workflow/sleep-phozDCW8.js +1 -0
- package/dist/src/compiled/_chunks/workflow/token-CaY0nA5J.js +1 -0
- package/dist/src/compiled/_chunks/workflow/token-D4VIwGlD.js +1 -0
- package/dist/src/compiled/_chunks/workflow/undici-fb54XL8i.js +95 -0
- package/dist/src/compiler/manifest.d.ts +40 -2
- package/dist/src/compiler/manifest.js +1 -1
- package/dist/src/compiler/module-map.js +2 -2
- package/dist/src/compiler/normalize-extension.d.ts +68 -0
- package/dist/src/compiler/normalize-extension.js +1 -0
- package/dist/src/compiler/normalize-manifest.js +2 -2
- package/dist/src/compiler/workspace-resources.js +1 -1
- package/dist/src/context/dynamic-skill-lifecycle.js +1 -1
- package/dist/src/context/dynamic-tool-lifecycle.js +1 -1
- package/dist/src/discover/discover-agent.d.ts +14 -1
- package/dist/src/discover/discover-agent.js +1 -1
- package/dist/src/discover/extension-specifier.d.ts +15 -0
- package/dist/src/discover/extension-specifier.js +1 -0
- package/dist/src/discover/extensions.d.ts +109 -0
- package/dist/src/discover/extensions.js +1 -0
- package/dist/src/discover/filesystem.d.ts +1 -1
- package/dist/src/discover/filesystem.js +1 -1
- package/dist/src/discover/grammar.d.ts +27 -0
- package/dist/src/discover/grammar.js +1 -1
- package/dist/src/discover/manifest.d.ts +46 -0
- package/dist/src/discover/manifest.js +1 -1
- package/dist/src/evals/assertions/run.d.ts +3 -2
- package/dist/src/evals/assertions/run.js +2 -2
- package/dist/src/evals/index.d.ts +1 -1
- package/dist/src/evals/loaders/yaml.js +1 -1
- package/dist/src/evals/match.d.ts +11 -6
- package/dist/src/execution/sandbox/bindings/microsandbox-network.js +1 -1
- package/dist/src/harness/emission.js +1 -1
- package/dist/src/harness/model-call-error.d.ts +5 -0
- package/dist/src/harness/model-call-error.js +1 -1
- package/dist/src/harness/prompt-cache.d.ts +18 -9
- package/dist/src/harness/prompt-cache.js +1 -1
- package/dist/src/harness/tool-loop.js +1 -1
- package/dist/src/internal/application/compiled-artifacts.d.ts +4 -0
- package/dist/src/internal/application/compiled-artifacts.js +5 -4
- package/dist/src/internal/application/package.d.ts +9 -5
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/authored-module-loader.d.ts +14 -0
- package/dist/src/internal/authored-module-loader.js +2 -2
- package/dist/src/internal/authored-module-map-loader.js +1 -1
- package/dist/src/internal/bundler/extension-scope-plugin.d.ts +37 -0
- package/dist/src/internal/bundler/extension-scope-plugin.js +3 -0
- package/dist/src/internal/helpers/gray-matter.d.ts +25 -0
- package/dist/src/internal/helpers/gray-matter.js +1 -0
- package/dist/src/internal/helpers/markdown.js +1 -1
- package/dist/src/internal/nitro/dev-runtime-source-snapshot-copy.js +1 -1
- package/dist/src/internal/nitro/host/build-application.js +1 -1
- package/dist/src/internal/nitro/host/build-extension.d.ts +24 -0
- package/dist/src/internal/nitro/host/build-extension.js +4 -0
- package/dist/src/internal/nitro/host/configure-nitro-routes.js +2 -2
- package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
- package/dist/src/internal/nitro/routes/health.d.ts +3 -3
- package/dist/src/internal/workflow/runtime.js +1 -1
- package/dist/src/internal/workflow/validate-world.d.ts +16 -0
- package/dist/src/internal/workflow/validate-world.js +1 -0
- package/dist/src/internal/workflow/world-compatibility.d.ts +1 -12
- package/dist/src/node_modules/.pnpm/@workflow_utils@5.0.0-beta.6/node_modules/@workflow/utils/dist/index.js +1 -0
- package/dist/src/node_modules/.pnpm/@workflow_utils@5.0.0-beta.6/node_modules/@workflow/utils/dist/parse-name.js +1 -0
- package/dist/src/node_modules/.pnpm/@workflow_utils@5.0.0-beta.6/node_modules/@workflow/utils/dist/pluralize.js +1 -0
- package/dist/src/node_modules/.pnpm/@workflow_utils@5.0.0-beta.6/node_modules/@workflow/utils/dist/promise.js +1 -0
- package/dist/src/node_modules/.pnpm/@workflow_utils@5.0.0-beta.6/node_modules/@workflow/utils/dist/time.js +1 -0
- package/dist/src/node_modules/.pnpm/@workflow_utils@5.0.0-beta.6/node_modules/@workflow/utils/dist/workflow-routes.js +1 -0
- package/dist/src/node_modules/.pnpm/@workflow_utils@5.0.0-beta.6/node_modules/@workflow/utils/dist/world-target.js +1 -0
- package/dist/src/node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js +1 -0
- package/dist/src/public/channels/discord/discordChannel.js +1 -1
- package/dist/src/public/channels/slack/action-status.d.ts +19 -0
- package/dist/src/public/channels/slack/action-status.js +1 -0
- package/dist/src/public/channels/slack/api.js +1 -1
- package/dist/src/public/channels/slack/defaults.js +2 -2
- package/dist/src/public/channels/slack/index.d.ts +1 -0
- package/dist/src/public/channels/slack/index.js +1 -1
- package/dist/src/public/channels/slack/mrkdwn.d.ts +0 -2
- package/dist/src/public/channels/slack/mrkdwn.js +1 -1
- package/dist/src/public/channels/slack/slackChannel.d.ts +1 -1
- package/dist/src/public/definitions/extension.d.ts +68 -0
- package/dist/src/public/definitions/extension.js +1 -0
- package/dist/src/public/extension/index.d.ts +10 -0
- package/dist/src/public/extension/index.js +1 -0
- package/dist/src/public/next/index.d.ts +9 -9
- package/dist/src/public/next/index.js +1 -1
- package/dist/src/public/next/vercel-output-config.js +1 -1
- package/dist/src/runtime/connections/openapi-client.js +1 -1
- package/dist/src/runtime/connections/openapi-spec.js +1 -1
- package/dist/src/runtime/resolve-dynamic-skill.js +1 -1
- package/dist/src/runtime/resolve-dynamic-tool.js +1 -1
- package/dist/src/runtime/types.d.ts +10 -0
- package/dist/src/services/dev-client/vercel-auth-error.d.ts +2 -2
- package/dist/src/services/dev-client/vercel-auth-error.js +3 -3
- package/dist/src/setup/scaffold/create/project.js +4 -4
- package/dist/src/svelte/index.js +1 -1
- package/dist/src/svelte/use-eve-agent.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 +1 -1
- package/docs/channels/custom.mdx +2 -2
- package/docs/channels/github.mdx +35 -2
- package/docs/channels/linear.mdx +36 -6
- package/docs/channels/slack.mdx +5 -3
- package/docs/concepts/context-control.md +1 -1
- package/docs/concepts/execution-model-and-durability.md +1 -1
- package/docs/connections/openapi.mdx +3 -1
- package/docs/evals/assertions.mdx +4 -2
- package/docs/extensions.md +155 -0
- package/docs/guides/client/overview.mdx +1 -1
- package/docs/guides/deployment.md +1 -1
- package/docs/guides/dev-tui.md +4 -0
- package/docs/guides/dynamic-capabilities.md +3 -3
- package/docs/guides/frontend/nextjs.mdx +7 -7
- package/docs/guides/instrumentation.md +1 -1
- package/docs/guides/state.md +3 -3
- package/docs/instructions.mdx +1 -1
- package/docs/meta.json +1 -0
- package/docs/patterns/dynamic-scheduling.md +11 -11
- package/docs/patterns/multi-tenant-approvals.md +6 -6
- package/docs/patterns/multi-tenant-auth.md +13 -13
- package/docs/patterns/multi-tenant-memory.md +9 -9
- package/docs/schedules.mdx +1 -1
- package/docs/subagents.mdx +2 -0
- package/docs/tutorial/guard-the-spend.mdx +2 -2
- package/docs/tutorial/query-sample-data.mdx +1 -1
- package/docs/tutorial/remember-definitions.mdx +2 -2
- package/docs/tutorial/ship-it.mdx +1 -1
- package/package.json +12 -5
- package/dist/src/compiled/_chunks/workflow/attribute-changes-zAifvEhb.js +0 -59
- package/dist/src/compiled/_chunks/workflow/dist-Dxrjttr2.js +0 -3
- package/dist/src/compiled/_chunks/workflow/resume-hook-C15uJ2ik.js +0 -1
- package/dist/src/compiled/_chunks/workflow/run-BJUPZ0Ni.js +0 -1
- package/dist/src/compiled/_chunks/workflow/sleep-C8B-TYir.js +0 -1
- package/dist/src/compiled/_chunks/workflow/token-Bm-WLAUB.js +0 -1
- package/dist/src/compiled/_chunks/workflow/token-J7YP0s9a.js +0 -1
- package/dist/src/internal/workflow/configure-world.d.ts +0 -18
- package/dist/src/internal/workflow/configure-world.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# eve
|
|
2
2
|
|
|
3
|
+
## 0.22.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8223498: Start remote authentication when a credentialed Vercel deployment returns an `UNAUTHORIZED` protection response.
|
|
8
|
+
- 79df338: feat(eve): scaffold projects with bundler module resolution
|
|
9
|
+
|
|
10
|
+
`eve init` now writes a `tsconfig.json` using `"moduleResolution": "bundler"` (and `"module": "esnext"`), which matches how eve compiles authored agents and extensions. Relative imports in your agent and extension source no longer need `.js` extensions (e.g. `import extension from "../extension"`).
|
|
11
|
+
|
|
12
|
+
- 173fa5d: Restore the `DISCORD_BOT_TOKEN` environment fallback for proactive Discord messages, typing indicators, and bot-authenticated requests when `discordChannel()` is configured without explicit credentials.
|
|
13
|
+
- 89cd2d6: Eval assertion `count` options now accept predicates, allowing ranges such as “at least two” while preserving exact numeric counts.
|
|
14
|
+
- fdf56ef: feat(eve): mounted extensions
|
|
15
|
+
|
|
16
|
+
Package eve capabilities — tools, connections, skills, instructions, hooks — as a reusable package and mount it under `agent/extensions/`, as a file (`crm.ts`) or a directory with co-located override slots that shadow the extension's own contributions. Contributions compose into the agent under a `<namespace>__` prefix. Author with `defineExtension` from `eve/extension`, taking an optional Standard-Schema `config` read via `extension.config`; `defineState` is auto-scoped to the package. `eve build` compiles the package to runnable JavaScript with type declarations and fills its `exports`, so a published extension installs and mounts with no second compiler. `eve` is a peer dependency whose declared range eve enforces at mount; an extension cannot declare a sandbox, agent config, schedules, or limits, or mount other extensions.
|
|
17
|
+
|
|
18
|
+
- 89f13e0: Hardened frontmatter parsing and OpenAPI connection loading.
|
|
19
|
+
|
|
20
|
+
All frontmatter parsing now runs through a single safe-by-default helper with gray-matter's code-capable engines disabled, so a `---js` / `---javascript` fence throws instead of being `eval()`d. Previously only authored markdown (skills, schedules, instructions) was hardened; the eval YAML loader and the OpenAPI spec loader used gray-matter's defaults and would execute such a fence. This closes that path for OpenAPI specs, which are fetched over the network. Parsing untrusted frontmatter as code is now opt-in only, and a direct import of the bundled gray-matter outside the wrapper fails CI.
|
|
21
|
+
|
|
22
|
+
OpenAPI spec URLs and the resolved base URL are now required to use `https` (plain `http` is still allowed for loopback hosts during local development), so neither the spec fetch nor the credentialed operation calls run over cleartext; the spec transport is also re-checked after redirects.
|
|
23
|
+
|
|
24
|
+
- aff35e2: Stop `eve dev` source snapshots from copying nested Git repositories and worktrees, preventing duplicate checkouts from inflating each development snapshot.
|
|
25
|
+
- 9087496: Prevent brokered credential values from being exposed to commands running in Microsandbox. Guest Git configuration continues to use broker-managed placeholders for authenticated requests.
|
|
26
|
+
- 72c58ae: Recover `eve dev <url>` authentication when Vercel Deployment Protection returns an SSO redirect or a structured protected-deployment response.
|
|
27
|
+
- 87688f9: Slack outbound messages now preserve literal bare `@` tokens, including scoped package names, while explicit `<@USER_ID>` mention syntax continues to pass through unchanged.
|
|
28
|
+
- c1c4ee5: Preserve query parameters passed to `eve dev` and send them on every agent request, including session POSTs and streams.
|
|
29
|
+
|
|
30
|
+
## 0.22.2
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- 4da4d86: Fixed Anthropic prompt caching placing the final cache breakpoint one message too early. Fresh tool results were billed as uncached input every turn and only entered the cache on the following request, capping the effective cache hit rate near 50%; the breakpoint now sits on the last message of each request, so agentic tool loops get near-full prefix hits.
|
|
35
|
+
- 4446f96: Update the vendored Workflow SDK packages to the latest 5.0 beta releases. eve now delegates world target selection and construction to the upstream SDK instead of maintaining parallel factory and compatibility logic, and no longer disables stable Workflow Turbo mode.
|
|
36
|
+
- 3da5def: Retry transient provider overload errors delivered inside model streams. Classified transient failures get at most three fresh model-call attempts, while other recoverable task-mode errors fall back to Workflow's durable step retries without multiplying retry budgets.
|
|
37
|
+
- 2afed3b: Update `withEve()` to generate Vercel Build Output service routes for eve instead of the legacy Next.js rewrite setup. The generated output now uses the stable `services` field and service routes, including in hosted Vercel builds where no local `.vercel/project.json` exists, so Vercel builds the eve service without Next.js rewrites.
|
|
38
|
+
- 3983d36: The Slack channel's default typing indicator for `actions.requested` now shows the action's contents instead of a generic `Running <tool>...` label: the tool name plus its most telling argument (`grep useEveAgent`, `read_file agent/agent.ts`), the subagent or remote-agent name for dispatched calls, and `+N more` for batches. The label helpers are exported from `eve/channels/slack` as `describeActionRequest` and `describeActionRequests` for use in custom handlers.
|
|
39
|
+
- 15309f3: New projects created with `eve init` now use stable TypeScript 7.0.2 instead of the release candidate.
|
|
40
|
+
|
|
3
41
|
## 0.22.1
|
|
4
42
|
|
|
5
43
|
### Patch Changes
|
|
@@ -238,7 +238,8 @@ function isObject(value) {
|
|
|
238
238
|
var ClientError = class extends Error {
|
|
239
239
|
status;
|
|
240
240
|
body;
|
|
241
|
-
|
|
241
|
+
headers;
|
|
242
|
+
constructor(status, body, headers) {
|
|
242
243
|
let message = body || `Server returned ${status}.`;
|
|
243
244
|
try {
|
|
244
245
|
const parsed = JSON.parse(body);
|
|
@@ -248,6 +249,7 @@ var ClientError = class extends Error {
|
|
|
248
249
|
this.name = "ClientError";
|
|
249
250
|
this.status = status;
|
|
250
251
|
this.body = body;
|
|
252
|
+
this.headers = Object.freeze(Object.fromEntries(new Headers(headers).entries()));
|
|
251
253
|
}
|
|
252
254
|
};
|
|
253
255
|
|
|
@@ -476,15 +478,17 @@ async function* readNdjsonStream(body) {
|
|
|
476
478
|
//#region src/client/url.ts
|
|
477
479
|
function createClientUrl(host, routePath, searchParams) {
|
|
478
480
|
const normalizedRoute = routePath.startsWith("/") ? routePath : `/${routePath}`;
|
|
479
|
-
const search = formatSearch(searchParams);
|
|
480
481
|
if (isAbsoluteUrl(host)) {
|
|
481
482
|
const url = new URL(host);
|
|
482
483
|
url.pathname = `${trimTrailingSlash(url.pathname)}${normalizedRoute}`;
|
|
483
|
-
url.
|
|
484
|
+
mergeSearchParams(url.searchParams, searchParams);
|
|
484
485
|
url.hash = "";
|
|
485
486
|
return url.toString();
|
|
486
487
|
}
|
|
487
|
-
|
|
488
|
+
const url = new URL(host, "http://eve.local");
|
|
489
|
+
const basePath = trimTrailingSlash(url.pathname);
|
|
490
|
+
mergeSearchParams(url.searchParams, searchParams);
|
|
491
|
+
return `${basePath}${normalizedRoute}${formatSearch(url.searchParams)}`;
|
|
488
492
|
}
|
|
489
493
|
function isAbsoluteUrl(value) {
|
|
490
494
|
return /^[a-z][a-z\d+\-.]*:/i.test(value);
|
|
@@ -493,9 +497,13 @@ function trimTrailingSlash(value) {
|
|
|
493
497
|
if (value === "/") return "";
|
|
494
498
|
return value.endsWith("/") ? value.slice(0, -1) : value;
|
|
495
499
|
}
|
|
500
|
+
function mergeSearchParams(target, searchParams) {
|
|
501
|
+
if (searchParams === void 0) return;
|
|
502
|
+
for (const [name, value] of Object.entries(searchParams)) target.set(name, value);
|
|
503
|
+
}
|
|
496
504
|
function formatSearch(searchParams) {
|
|
497
|
-
|
|
498
|
-
return `?${
|
|
505
|
+
const value = searchParams.toString();
|
|
506
|
+
return value.length === 0 ? "" : `?${value}`;
|
|
499
507
|
}
|
|
500
508
|
|
|
501
509
|
//#endregion
|
|
@@ -536,6 +544,7 @@ async function* openStreamIterable(input) {
|
|
|
536
544
|
async function openStreamBody(input) {
|
|
537
545
|
let lastStatus;
|
|
538
546
|
let lastBody;
|
|
547
|
+
let lastHeaders;
|
|
539
548
|
for (let attempt = 0; attempt < STREAM_OPEN_RETRY_ATTEMPTS; attempt += 1) {
|
|
540
549
|
const url = createClientUrl(input.host, createEveMessageStreamRoutePath(input.sessionId), input.startIndex > 0 ? { startIndex: String(input.startIndex) } : void 0);
|
|
541
550
|
const headers = await input.resolveHeaders();
|
|
@@ -545,15 +554,16 @@ async function openStreamBody(input) {
|
|
|
545
554
|
signal: input.signal ?? null
|
|
546
555
|
});
|
|
547
556
|
if (response.ok) {
|
|
548
|
-
if (!response.body) throw new ClientError(response.status, "Response body is null.");
|
|
557
|
+
if (!response.body) throw new ClientError(response.status, "Response body is null.", response.headers);
|
|
549
558
|
return response.body;
|
|
550
559
|
}
|
|
551
560
|
lastStatus = response.status;
|
|
552
561
|
lastBody = await response.text();
|
|
553
|
-
|
|
562
|
+
lastHeaders = response.headers;
|
|
563
|
+
if (!STREAM_OPEN_RETRYABLE_STATUS.has(response.status)) throw new ClientError(response.status, lastBody, response.headers);
|
|
554
564
|
if (attempt < STREAM_OPEN_RETRY_ATTEMPTS - 1) await sleep$1(STREAM_OPEN_RETRY_DELAY_MS);
|
|
555
565
|
}
|
|
556
|
-
throw new ClientError(lastStatus ?? 0, lastBody ?? "Failed to open message stream.");
|
|
566
|
+
throw new ClientError(lastStatus ?? 0, lastBody ?? "Failed to open message stream.", lastHeaders);
|
|
557
567
|
}
|
|
558
568
|
async function sleep$1(ms) {
|
|
559
569
|
await new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -697,6 +707,7 @@ async function postTurnWithRetry(input) {
|
|
|
697
707
|
const attempts = input.mustDeliver ? DELIVER_RETRY_ATTEMPTS : 1;
|
|
698
708
|
let lastStatus;
|
|
699
709
|
let lastBody;
|
|
710
|
+
let lastHeaders;
|
|
700
711
|
for (let attempt = 0; attempt < attempts; attempt += 1) {
|
|
701
712
|
const response = await fetch(input.url, {
|
|
702
713
|
body: input.body,
|
|
@@ -708,10 +719,11 @@ async function postTurnWithRetry(input) {
|
|
|
708
719
|
if (response.ok) return response;
|
|
709
720
|
lastStatus = response.status;
|
|
710
721
|
lastBody = await response.text();
|
|
711
|
-
|
|
722
|
+
lastHeaders = response.headers;
|
|
723
|
+
if (!isRetryableDeliveryFailure(response.status, lastBody)) throw new ClientError(response.status, lastBody, response.headers);
|
|
712
724
|
if (attempt < attempts - 1) await sleep(DELIVER_RETRY_DELAY_MS);
|
|
713
725
|
}
|
|
714
|
-
throw new ClientError(lastStatus ?? 0, lastBody ?? "Failed to deliver session turn.");
|
|
726
|
+
throw new ClientError(lastStatus ?? 0, lastBody ?? "Failed to deliver session turn.", lastHeaders);
|
|
715
727
|
}
|
|
716
728
|
function isRetryableDeliveryFailure(status, body) {
|
|
717
729
|
return status === 500 && /target session was not found/i.test(body);
|
|
@@ -762,7 +774,7 @@ var Client = class {
|
|
|
762
774
|
const response = await fetch(url, withRedirectPolicy({ headers }, this.#redirect));
|
|
763
775
|
if (!response.ok) {
|
|
764
776
|
const body = await response.text();
|
|
765
|
-
throw new ClientError(response.status, body);
|
|
777
|
+
throw new ClientError(response.status, body, response.headers);
|
|
766
778
|
}
|
|
767
779
|
return await response.json();
|
|
768
780
|
}
|
|
@@ -770,7 +782,7 @@ var Client = class {
|
|
|
770
782
|
const response = await this.fetch(EVE_INFO_ROUTE_PATH);
|
|
771
783
|
if (!response.ok) {
|
|
772
784
|
const body = await response.text();
|
|
773
|
-
throw new ClientError(response.status, body);
|
|
785
|
+
throw new ClientError(response.status, body, response.headers);
|
|
774
786
|
}
|
|
775
787
|
let payload;
|
|
776
788
|
try {
|
|
@@ -238,7 +238,8 @@ function isObject(value) {
|
|
|
238
238
|
var ClientError = class extends Error {
|
|
239
239
|
status;
|
|
240
240
|
body;
|
|
241
|
-
|
|
241
|
+
headers;
|
|
242
|
+
constructor(status, body, headers) {
|
|
242
243
|
let message = body || `Server returned ${status}.`;
|
|
243
244
|
try {
|
|
244
245
|
const parsed = JSON.parse(body);
|
|
@@ -248,6 +249,7 @@ var ClientError = class extends Error {
|
|
|
248
249
|
this.name = "ClientError";
|
|
249
250
|
this.status = status;
|
|
250
251
|
this.body = body;
|
|
252
|
+
this.headers = Object.freeze(Object.fromEntries(new Headers(headers).entries()));
|
|
251
253
|
}
|
|
252
254
|
};
|
|
253
255
|
|
|
@@ -476,15 +478,17 @@ async function* readNdjsonStream(body) {
|
|
|
476
478
|
//#region src/client/url.ts
|
|
477
479
|
function createClientUrl(host, routePath, searchParams) {
|
|
478
480
|
const normalizedRoute = routePath.startsWith("/") ? routePath : `/${routePath}`;
|
|
479
|
-
const search = formatSearch(searchParams);
|
|
480
481
|
if (isAbsoluteUrl(host)) {
|
|
481
482
|
const url = new URL(host);
|
|
482
483
|
url.pathname = `${trimTrailingSlash(url.pathname)}${normalizedRoute}`;
|
|
483
|
-
url.
|
|
484
|
+
mergeSearchParams(url.searchParams, searchParams);
|
|
484
485
|
url.hash = "";
|
|
485
486
|
return url.toString();
|
|
486
487
|
}
|
|
487
|
-
|
|
488
|
+
const url = new URL(host, "http://eve.local");
|
|
489
|
+
const basePath = trimTrailingSlash(url.pathname);
|
|
490
|
+
mergeSearchParams(url.searchParams, searchParams);
|
|
491
|
+
return `${basePath}${normalizedRoute}${formatSearch(url.searchParams)}`;
|
|
488
492
|
}
|
|
489
493
|
function isAbsoluteUrl(value) {
|
|
490
494
|
return /^[a-z][a-z\d+\-.]*:/i.test(value);
|
|
@@ -493,9 +497,13 @@ function trimTrailingSlash(value) {
|
|
|
493
497
|
if (value === "/") return "";
|
|
494
498
|
return value.endsWith("/") ? value.slice(0, -1) : value;
|
|
495
499
|
}
|
|
500
|
+
function mergeSearchParams(target, searchParams) {
|
|
501
|
+
if (searchParams === void 0) return;
|
|
502
|
+
for (const [name, value] of Object.entries(searchParams)) target.set(name, value);
|
|
503
|
+
}
|
|
496
504
|
function formatSearch(searchParams) {
|
|
497
|
-
|
|
498
|
-
return `?${
|
|
505
|
+
const value = searchParams.toString();
|
|
506
|
+
return value.length === 0 ? "" : `?${value}`;
|
|
499
507
|
}
|
|
500
508
|
|
|
501
509
|
//#endregion
|
|
@@ -536,6 +544,7 @@ async function* openStreamIterable(input) {
|
|
|
536
544
|
async function openStreamBody(input) {
|
|
537
545
|
let lastStatus;
|
|
538
546
|
let lastBody;
|
|
547
|
+
let lastHeaders;
|
|
539
548
|
for (let attempt = 0; attempt < STREAM_OPEN_RETRY_ATTEMPTS; attempt += 1) {
|
|
540
549
|
const url = createClientUrl(input.host, createEveMessageStreamRoutePath(input.sessionId), input.startIndex > 0 ? { startIndex: String(input.startIndex) } : void 0);
|
|
541
550
|
const headers = await input.resolveHeaders();
|
|
@@ -545,15 +554,16 @@ async function openStreamBody(input) {
|
|
|
545
554
|
signal: input.signal ?? null
|
|
546
555
|
});
|
|
547
556
|
if (response.ok) {
|
|
548
|
-
if (!response.body) throw new ClientError(response.status, "Response body is null.");
|
|
557
|
+
if (!response.body) throw new ClientError(response.status, "Response body is null.", response.headers);
|
|
549
558
|
return response.body;
|
|
550
559
|
}
|
|
551
560
|
lastStatus = response.status;
|
|
552
561
|
lastBody = await response.text();
|
|
553
|
-
|
|
562
|
+
lastHeaders = response.headers;
|
|
563
|
+
if (!STREAM_OPEN_RETRYABLE_STATUS.has(response.status)) throw new ClientError(response.status, lastBody, response.headers);
|
|
554
564
|
if (attempt < STREAM_OPEN_RETRY_ATTEMPTS - 1) await sleep$1(STREAM_OPEN_RETRY_DELAY_MS);
|
|
555
565
|
}
|
|
556
|
-
throw new ClientError(lastStatus ?? 0, lastBody ?? "Failed to open message stream.");
|
|
566
|
+
throw new ClientError(lastStatus ?? 0, lastBody ?? "Failed to open message stream.", lastHeaders);
|
|
557
567
|
}
|
|
558
568
|
async function sleep$1(ms) {
|
|
559
569
|
await new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -697,6 +707,7 @@ async function postTurnWithRetry(input) {
|
|
|
697
707
|
const attempts = input.mustDeliver ? DELIVER_RETRY_ATTEMPTS : 1;
|
|
698
708
|
let lastStatus;
|
|
699
709
|
let lastBody;
|
|
710
|
+
let lastHeaders;
|
|
700
711
|
for (let attempt = 0; attempt < attempts; attempt += 1) {
|
|
701
712
|
const response = await fetch(input.url, {
|
|
702
713
|
body: input.body,
|
|
@@ -708,10 +719,11 @@ async function postTurnWithRetry(input) {
|
|
|
708
719
|
if (response.ok) return response;
|
|
709
720
|
lastStatus = response.status;
|
|
710
721
|
lastBody = await response.text();
|
|
711
|
-
|
|
722
|
+
lastHeaders = response.headers;
|
|
723
|
+
if (!isRetryableDeliveryFailure(response.status, lastBody)) throw new ClientError(response.status, lastBody, response.headers);
|
|
712
724
|
if (attempt < attempts - 1) await sleep(DELIVER_RETRY_DELAY_MS);
|
|
713
725
|
}
|
|
714
|
-
throw new ClientError(lastStatus ?? 0, lastBody ?? "Failed to deliver session turn.");
|
|
726
|
+
throw new ClientError(lastStatus ?? 0, lastBody ?? "Failed to deliver session turn.", lastHeaders);
|
|
715
727
|
}
|
|
716
728
|
function isRetryableDeliveryFailure(status, body) {
|
|
717
729
|
return status === 500 && /target session was not found/i.test(body);
|
|
@@ -762,7 +774,7 @@ var Client = class {
|
|
|
762
774
|
const response = await fetch(url, withRedirectPolicy({ headers }, this.#redirect));
|
|
763
775
|
if (!response.ok) {
|
|
764
776
|
const body = await response.text();
|
|
765
|
-
throw new ClientError(response.status, body);
|
|
777
|
+
throw new ClientError(response.status, body, response.headers);
|
|
766
778
|
}
|
|
767
779
|
return await response.json();
|
|
768
780
|
}
|
|
@@ -770,7 +782,7 @@ var Client = class {
|
|
|
770
782
|
const response = await this.fetch(EVE_INFO_ROUTE_PATH);
|
|
771
783
|
if (!response.ok) {
|
|
772
784
|
const body = await response.text();
|
|
773
|
-
throw new ClientError(response.status, body);
|
|
785
|
+
throw new ClientError(response.status, body, response.headers);
|
|
774
786
|
}
|
|
775
787
|
let payload;
|
|
776
788
|
try {
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { type Prompter } from "#setup/prompter.js";
|
|
2
|
+
declare const positional: (prompt: string) => string[];
|
|
2
3
|
declare const CODING_AGENT_REPLS: readonly [{
|
|
3
4
|
readonly command: "claude";
|
|
4
5
|
readonly label: "Claude Code";
|
|
5
|
-
readonly promptArgs:
|
|
6
|
+
readonly promptArgs: typeof positional;
|
|
6
7
|
}, {
|
|
7
8
|
readonly command: "codex";
|
|
8
9
|
readonly label: "Codex";
|
|
9
|
-
readonly promptArgs:
|
|
10
|
+
readonly promptArgs: typeof positional;
|
|
10
11
|
}, {
|
|
11
12
|
readonly command: "cursor-agent";
|
|
12
13
|
readonly label: "Cursor";
|
|
13
|
-
readonly promptArgs:
|
|
14
|
+
readonly promptArgs: typeof positional;
|
|
14
15
|
}, {
|
|
15
16
|
readonly command: "droid";
|
|
16
17
|
readonly label: "Droid";
|
|
17
|
-
readonly promptArgs:
|
|
18
|
+
readonly promptArgs: typeof positional;
|
|
18
19
|
}, {
|
|
19
20
|
readonly command: "gemini";
|
|
20
21
|
readonly label: "Gemini CLI";
|
|
@@ -26,7 +27,7 @@ declare const CODING_AGENT_REPLS: readonly [{
|
|
|
26
27
|
}, {
|
|
27
28
|
readonly command: "pi";
|
|
28
29
|
readonly label: "Pi";
|
|
29
|
-
readonly promptArgs:
|
|
30
|
+
readonly promptArgs: typeof positional;
|
|
30
31
|
}];
|
|
31
32
|
type CodingAgentReplDefinition = (typeof CODING_AGENT_REPLS)[number];
|
|
32
33
|
/** A coding-agent REPL that can take over the terminal after `eve init`. */
|
package/dist/src/cli/dev/url.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{InvalidArgumentError}from"#compiled/commander/index.js";import{isLocalEveServerUrl}from"#services/dev-client/local-host.js";const DEVELOPMENT_SERVER_PROTOCOLS=new Set([`http:`,`https:`]);function assertDevelopmentServerProtocol(t,r){if(!DEVELOPMENT_SERVER_PROTOCOLS.has(t.protocol))throw new InvalidArgumentError(`Expected an absolute http(s) URL, received "${r}".`)}function assertSecureRemoteProtocol(n,r){if(n.protocol===`http:`&&!isLocalEveServerUrl(n))throw new InvalidArgumentError(`Remote servers must use https://; received "${r}". Only local hosts may use http://.`)}function parseDevelopmentServerUrl(t){let n=t.trim();try{let e=new URL(n);return assertDevelopmentServerProtocol(e,t),assertSecureRemoteProtocol(e,t),e.hash=``,e.
|
|
1
|
+
import{InvalidArgumentError}from"#compiled/commander/index.js";import{isLocalEveServerUrl}from"#services/dev-client/local-host.js";const DEVELOPMENT_SERVER_PROTOCOLS=new Set([`http:`,`https:`]);function assertDevelopmentServerProtocol(t,r){if(!DEVELOPMENT_SERVER_PROTOCOLS.has(t.protocol))throw new InvalidArgumentError(`Expected an absolute http(s) URL, received "${r}".`)}function assertSecureRemoteProtocol(n,r){if(n.protocol===`http:`&&!isLocalEveServerUrl(n))throw new InvalidArgumentError(`Remote servers must use https://; received "${r}". Only local hosts may use http://.`)}function parseDevelopmentServerUrl(t){let n=t.trim();try{let e=new URL(n);return assertDevelopmentServerProtocol(e,t),assertSecureRemoteProtocol(e,t),e.hash=``,e.toString()}catch(n){throw n instanceof InvalidArgumentError?n:new InvalidArgumentError(`Expected an absolute http(s) URL, received "${t}".`)}}export{parseDevelopmentServerUrl};
|
|
@@ -10,5 +10,9 @@ export declare class ClientError extends Error {
|
|
|
10
10
|
* Raw response body text.
|
|
11
11
|
*/
|
|
12
12
|
readonly body: string;
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Response headers, normalized to lowercase names.
|
|
15
|
+
*/
|
|
16
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
17
|
+
constructor(status: number, body: string, headers?: ConstructorParameters<typeof Headers>[0]);
|
|
14
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isObject}from"#shared/guards.js";var ClientError=class extends Error{status;body;constructor(e,t){let
|
|
1
|
+
import{isObject}from"#shared/guards.js";var ClientError=class extends Error{status;body;headers;constructor(e,t,n){let r=t||`Server returned ${e}.`;try{let e=JSON.parse(t);isObject(e)&&typeof e.error==`string`&&(r=e.error)}catch{}super(r),this.name=`ClientError`,this.status=e,this.body=t,this.headers=Object.freeze(Object.fromEntries(new Headers(n).entries()))}};export{ClientError};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EVE_HEALTH_ROUTE_PATH,EVE_INFO_ROUTE_PATH}from"#protocol/routes.js";import{encodeBasicCredentials}from"#internal/http/basic-auth.js";import{AgentInfoResponseError}from"#client/agent-info-error.js";import{AgentInfoResultSchema}from"#client/agent-info-schema.js";import{ClientError}from"#client/client-error.js";import{ClientSession}from"#client/session.js";import{createInitialSessionState}from"#client/session-utils.js";import{createClientUrl}from"#client/url.js";import{VERCEL_TRUSTED_OIDC_IDP_TOKEN_HEADER}from"#client/types.js";var Client=class{#e;#t;#n;#r;#i;#a;constructor(e){this.#n=e.host,this.#e=e.auth,this.#t=e.headers,this.#r=e.maxReconnectAttempts??3,this.#i=e.preserveCompletedSessions??!1,this.#a=e.redirect}async health(){let t=createClientUrl(this.#n,EVE_HEALTH_ROUTE_PATH),n=await this.#o(),r=await fetch(t,withRedirectPolicy({headers:n},this.#a));if(!r.ok){let e=await r.text();throw new ClientError(r.status,e)}return await r.json()}async info(){let e=await this.fetch(EVE_INFO_ROUTE_PATH);if(!e.ok){let t=await e.text();throw new ClientError(e.status,t)}let n;try{n=await e.json()}catch{throw new AgentInfoResponseError}let i=AgentInfoResultSchema.safeParse(n);if(!i.success)throw new AgentInfoResponseError(i.error.issues.slice(0,5).map(e=>{let t=e.path.join(`.`);return t.length===0?e.message:`${t}: ${e.message}`}));return i.data}async fetch(e,t={}){let n=createClientUrl(this.#n,e),r=await this.#o(headersInitToRecord(t.headers));return await fetch(n,withRedirectPolicy({...t,headers:r},this.#a))}session(e){let t;return t=typeof e==`string`?{continuationToken:e,streamIndex:0}:e||createInitialSessionState(),new ClientSession({host:this.#n,maxReconnectAttempts:this.#r,preserveCompletedSessions:this.#i,redirect:this.#a,resolveHeaders:e=>this.#o(e)},t)}async#o(e){let t=new Headers,[n,r]=await Promise.all([resolveHeadersValue(this.#t),this.#s()]);for(let[e,r]of Object.entries(n))t.set(e,r);if(e)for(let[n,r]of Object.entries(e))t.set(n,r);for(let[e,n]of Object.entries(r))t.set(e,n);return t}async#s(){let e=this.#e;if(!e)return{};if(`vercelOidc`in e){let t=(await resolveTokenValue(e.vercelOidc.token)).trim();return t.length===0?{}:{authorization:`Bearer ${t}`,[VERCEL_TRUSTED_OIDC_IDP_TOKEN_HEADER]:t}}if(`bearer`in e){let t=(await resolveTokenValue(e.bearer)).trim();return t.length===0?{}:{authorization:`Bearer ${t}`}}if(`basic`in e){let t=await resolveTokenValue(e.basic.password);return{authorization:`Basic ${encodeBasicCredentials(e.basic.username,t)}`}}return{}}};async function resolveTokenValue(e){return typeof e==`function`?e():e}async function resolveHeadersValue(e){return e===void 0?{}:typeof e==`function`?await e():e}function headersInitToRecord(e){return e===void 0?{}:Object.fromEntries(new Headers(e).entries())}function withRedirectPolicy(e,t){return t===void 0?e:{...e,redirect:t}}export{Client};
|
|
1
|
+
import{EVE_HEALTH_ROUTE_PATH,EVE_INFO_ROUTE_PATH}from"#protocol/routes.js";import{encodeBasicCredentials}from"#internal/http/basic-auth.js";import{AgentInfoResponseError}from"#client/agent-info-error.js";import{AgentInfoResultSchema}from"#client/agent-info-schema.js";import{ClientError}from"#client/client-error.js";import{ClientSession}from"#client/session.js";import{createInitialSessionState}from"#client/session-utils.js";import{createClientUrl}from"#client/url.js";import{VERCEL_TRUSTED_OIDC_IDP_TOKEN_HEADER}from"#client/types.js";var Client=class{#e;#t;#n;#r;#i;#a;constructor(e){this.#n=e.host,this.#e=e.auth,this.#t=e.headers,this.#r=e.maxReconnectAttempts??3,this.#i=e.preserveCompletedSessions??!1,this.#a=e.redirect}async health(){let t=createClientUrl(this.#n,EVE_HEALTH_ROUTE_PATH),n=await this.#o(),r=await fetch(t,withRedirectPolicy({headers:n},this.#a));if(!r.ok){let e=await r.text();throw new ClientError(r.status,e,r.headers)}return await r.json()}async info(){let e=await this.fetch(EVE_INFO_ROUTE_PATH);if(!e.ok){let t=await e.text();throw new ClientError(e.status,t,e.headers)}let n;try{n=await e.json()}catch{throw new AgentInfoResponseError}let i=AgentInfoResultSchema.safeParse(n);if(!i.success)throw new AgentInfoResponseError(i.error.issues.slice(0,5).map(e=>{let t=e.path.join(`.`);return t.length===0?e.message:`${t}: ${e.message}`}));return i.data}async fetch(e,t={}){let n=createClientUrl(this.#n,e),r=await this.#o(headersInitToRecord(t.headers));return await fetch(n,withRedirectPolicy({...t,headers:r},this.#a))}session(e){let t;return t=typeof e==`string`?{continuationToken:e,streamIndex:0}:e||createInitialSessionState(),new ClientSession({host:this.#n,maxReconnectAttempts:this.#r,preserveCompletedSessions:this.#i,redirect:this.#a,resolveHeaders:e=>this.#o(e)},t)}async#o(e){let t=new Headers,[n,r]=await Promise.all([resolveHeadersValue(this.#t),this.#s()]);for(let[e,r]of Object.entries(n))t.set(e,r);if(e)for(let[n,r]of Object.entries(e))t.set(n,r);for(let[e,n]of Object.entries(r))t.set(e,n);return t}async#s(){let e=this.#e;if(!e)return{};if(`vercelOidc`in e){let t=(await resolveTokenValue(e.vercelOidc.token)).trim();return t.length===0?{}:{authorization:`Bearer ${t}`,[VERCEL_TRUSTED_OIDC_IDP_TOKEN_HEADER]:t}}if(`bearer`in e){let t=(await resolveTokenValue(e.bearer)).trim();return t.length===0?{}:{authorization:`Bearer ${t}`}}if(`basic`in e){let t=await resolveTokenValue(e.basic.password);return{authorization:`Basic ${encodeBasicCredentials(e.basic.username,t)}`}}return{}}};async function resolveTokenValue(e){return typeof e==`function`?e():e}async function resolveHeadersValue(e){return e===void 0?{}:typeof e==`function`?await e():e}function headersInitToRecord(e){return e===void 0?{}:Object.fromEntries(new Headers(e).entries())}function withRedirectPolicy(e,t){return t===void 0?e:{...e,redirect:t}}export{Client};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createEveMessageStreamRoutePath}from"#protocol/routes.js";import{ClientError}from"#client/client-error.js";import{createClientUrl}from"#client/url.js";import{isStreamDisconnectError,readNdjsonStream}from"#client/ndjson.js";const STREAM_OPEN_RETRYABLE_STATUS=new Set([404,409,425,500,502,503,504]);async function*openStreamIterable(e){let t=e.startIndex,n=e.maxReconnectAttempts;for(;;){let a=await openStreamBody({...e,startIndex:t}),o=!1;try{for await(let e of readNdjsonStream(a))t+=1,yield e}catch(e){if(!isStreamDisconnectError(e))throw e;o=!0}if(!o||e.signal?.aborted||n<=0)return;--n}}async function openStreamBody(r){let i,o;for(let
|
|
1
|
+
import{createEveMessageStreamRoutePath}from"#protocol/routes.js";import{ClientError}from"#client/client-error.js";import{createClientUrl}from"#client/url.js";import{isStreamDisconnectError,readNdjsonStream}from"#client/ndjson.js";const STREAM_OPEN_RETRYABLE_STATUS=new Set([404,409,425,500,502,503,504]);async function*openStreamIterable(e){let t=e.startIndex,n=e.maxReconnectAttempts;for(;;){let a=await openStreamBody({...e,startIndex:t}),o=!1;try{for await(let e of readNdjsonStream(a))t+=1,yield e}catch(e){if(!isStreamDisconnectError(e))throw e;o=!0}if(!o||e.signal?.aborted||n<=0)return;--n}}async function openStreamBody(r){let i,o,s;for(let c=0;c<12;c+=1){let l=createClientUrl(r.host,createEveMessageStreamRoutePath(r.sessionId),r.startIndex>0?{startIndex:String(r.startIndex)}:void 0),u=await r.resolveHeaders(),d=await fetch(l,{headers:u,redirect:r.redirect,signal:r.signal??null});if(d.ok){if(!d.body)throw new ClientError(d.status,`Response body is null.`,d.headers);return d.body}if(i=d.status,o=await d.text(),s=d.headers,!STREAM_OPEN_RETRYABLE_STATUS.has(d.status))throw new ClientError(d.status,o,d.headers);c<11&&await sleep(250)}throw new ClientError(i??0,o??`Failed to open message stream.`,s)}async function sleep(e){await new Promise(t=>setTimeout(t,e))}export{openStreamBody,openStreamIterable};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EVE_CREATE_SESSION_ROUTE_PATH,createEveContinueSessionRoutePath}from"#protocol/routes.js";import{ClientError}from"#client/client-error.js";import{advanceSession}from"#client/session-utils.js";import{createClientUrl}from"#client/url.js";import{MessageResponse}from"#client/message-response.js";import{EVE_SESSION_ID_HEADER,isCurrentTurnBoundaryEvent}from"#protocol/message.js";import{normalizeOutputSchemaForRequest}from"#client/output-schema.js";import{isStreamDisconnectError,readNdjsonStream}from"#client/ndjson.js";import{openStreamBody,openStreamIterable}from"#client/open-stream.js";var ClientSession=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get state(){return this.#t}async send(e){let t=normalizeSendTurnInput(e),n=this.#t,{continuationToken:r,sessionId:i}=await this.#n(t,n);return new MessageResponse({continuationToken:r,createStream:()=>this.#r(i,r,n,t),sessionId:i})}stream(e){let t=this.#t.sessionId;if(!t)throw Error(`Session has no session ID. Send a message first.`);return this.#a(t,e)}async#n(n,r){let a=r.sessionId?createEveContinueSessionRoutePath(r.sessionId):EVE_CREATE_SESSION_ROUTE_PATH,s=createClientUrl(this.#e.host,a),c=await this.#e.resolveHeaders(n.headers);c.set(`content-type`,`application/json`);let l=createHandleMessageBody({input:n,outputSchema:normalizeOutputSchemaForRequest(n.outputSchema),session:r});if(l===null)throw Error(`Session.send requires a non-empty message, inputResponses, or both.`);let u=await postTurnWithRetry({body:JSON.stringify(l),headers:c,mustDeliver:(n.inputResponses?.length??0)>0,redirect:this.#e.redirect,signal:n.signal,url:s}),d=await u.json(),f=(typeof d.sessionId==`string`?d.sessionId:void 0)??u.headers.get(EVE_SESSION_ID_HEADER)?.trim()??r.sessionId;if(!f)throw Error(`Message route did not return a session id.`);return{continuationToken:typeof d.continuationToken==`string`?d.continuationToken:void 0,sessionId:f}}async*#r(e,t,n,i){let a=[];try{let t=n.sessionId===e?n.streamIndex:0,r=this.#e.maxReconnectAttempts;for(;;){let n=await this.#i(e,t,i.signal,i.headers),o=!1;try{for await(let e of readNdjsonStream(n))if(a.push(e),t+=1,yield e,isCurrentTurnBoundaryEvent(e)){o=!0;break}}catch(e){if(!isStreamDisconnectError(e))throw e}if(o||i.signal?.aborted||r<=0)break;--r}}finally{this.#t=advanceSession({continuationToken:t,events:a,preserveCompletedSessions:this.#e.preserveCompletedSessions,sessionId:e,session:n})}}async#i(e,t,n,r){return await openStreamBody({host:this.#e.host,resolveHeaders:()=>this.#e.resolveHeaders(r),redirect:this.#e.redirect,sessionId:e,signal:n,startIndex:t})}async*#a(e,t){let n=this.#t,i=t?.startIndex??n.streamIndex,a=[];try{for await(let n of openStreamIterable({host:this.#e.host,maxReconnectAttempts:this.#e.maxReconnectAttempts,resolveHeaders:()=>this.#e.resolveHeaders(),redirect:this.#e.redirect,sessionId:e,signal:t?.signal,startIndex:i}))a.push(n),yield n}finally{this.#t=advanceSession({continuationToken:n.continuationToken,events:a,preserveCompletedSessions:this.#e.preserveCompletedSessions,session:{...n,sessionId:e,streamIndex:i},sessionId:e})}}};async function postTurnWithRetry(e){let t=e.mustDeliver?10:1,r,i;for(let
|
|
1
|
+
import{EVE_CREATE_SESSION_ROUTE_PATH,createEveContinueSessionRoutePath}from"#protocol/routes.js";import{ClientError}from"#client/client-error.js";import{advanceSession}from"#client/session-utils.js";import{createClientUrl}from"#client/url.js";import{MessageResponse}from"#client/message-response.js";import{EVE_SESSION_ID_HEADER,isCurrentTurnBoundaryEvent}from"#protocol/message.js";import{normalizeOutputSchemaForRequest}from"#client/output-schema.js";import{isStreamDisconnectError,readNdjsonStream}from"#client/ndjson.js";import{openStreamBody,openStreamIterable}from"#client/open-stream.js";var ClientSession=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get state(){return this.#t}async send(e){let t=normalizeSendTurnInput(e),n=this.#t,{continuationToken:r,sessionId:i}=await this.#n(t,n);return new MessageResponse({continuationToken:r,createStream:()=>this.#r(i,r,n,t),sessionId:i})}stream(e){let t=this.#t.sessionId;if(!t)throw Error(`Session has no session ID. Send a message first.`);return this.#a(t,e)}async#n(n,r){let a=r.sessionId?createEveContinueSessionRoutePath(r.sessionId):EVE_CREATE_SESSION_ROUTE_PATH,s=createClientUrl(this.#e.host,a),c=await this.#e.resolveHeaders(n.headers);c.set(`content-type`,`application/json`);let l=createHandleMessageBody({input:n,outputSchema:normalizeOutputSchemaForRequest(n.outputSchema),session:r});if(l===null)throw Error(`Session.send requires a non-empty message, inputResponses, or both.`);let u=await postTurnWithRetry({body:JSON.stringify(l),headers:c,mustDeliver:(n.inputResponses?.length??0)>0,redirect:this.#e.redirect,signal:n.signal,url:s}),d=await u.json(),f=(typeof d.sessionId==`string`?d.sessionId:void 0)??u.headers.get(EVE_SESSION_ID_HEADER)?.trim()??r.sessionId;if(!f)throw Error(`Message route did not return a session id.`);return{continuationToken:typeof d.continuationToken==`string`?d.continuationToken:void 0,sessionId:f}}async*#r(e,t,n,i){let a=[];try{let t=n.sessionId===e?n.streamIndex:0,r=this.#e.maxReconnectAttempts;for(;;){let n=await this.#i(e,t,i.signal,i.headers),o=!1;try{for await(let e of readNdjsonStream(n))if(a.push(e),t+=1,yield e,isCurrentTurnBoundaryEvent(e)){o=!0;break}}catch(e){if(!isStreamDisconnectError(e))throw e}if(o||i.signal?.aborted||r<=0)break;--r}}finally{this.#t=advanceSession({continuationToken:t,events:a,preserveCompletedSessions:this.#e.preserveCompletedSessions,sessionId:e,session:n})}}async#i(e,t,n,r){return await openStreamBody({host:this.#e.host,resolveHeaders:()=>this.#e.resolveHeaders(r),redirect:this.#e.redirect,sessionId:e,signal:n,startIndex:t})}async*#a(e,t){let n=this.#t,i=t?.startIndex??n.streamIndex,a=[];try{for await(let n of openStreamIterable({host:this.#e.host,maxReconnectAttempts:this.#e.maxReconnectAttempts,resolveHeaders:()=>this.#e.resolveHeaders(),redirect:this.#e.redirect,sessionId:e,signal:t?.signal,startIndex:i}))a.push(n),yield n}finally{this.#t=advanceSession({continuationToken:n.continuationToken,events:a,preserveCompletedSessions:this.#e.preserveCompletedSessions,session:{...n,sessionId:e,streamIndex:i},sessionId:e})}}};async function postTurnWithRetry(e){let t=e.mustDeliver?10:1,r,i,a;for(let o=0;o<t;o+=1){let s=await fetch(e.url,{body:e.body,headers:e.headers,method:`POST`,redirect:e.redirect,signal:e.signal??null});if(s.ok)return s;if(r=s.status,i=await s.text(),a=s.headers,!isRetryableDeliveryFailure(s.status,i))throw new ClientError(s.status,i,s.headers);o<t-1&&await sleep(200)}throw new ClientError(r??0,i??`Failed to deliver session turn.`,a)}function isRetryableDeliveryFailure(e,t){return e===500&&/target session was not found/i.test(t)}async function sleep(e){await new Promise(t=>setTimeout(t,e))}function normalizeSendTurnInput(e){return typeof e==`string`?{message:e}:e}function createHandleMessageBody(e){let t={};return e.input.message!==void 0&&(t.message=e.input.message),e.input.inputResponses!==void 0&&e.input.inputResponses.length>0&&(t.inputResponses=e.input.inputResponses),e.input.clientContext!==void 0&&(t.clientContext=e.input.clientContext),e.outputSchema!==void 0&&(t.outputSchema=e.outputSchema),e.session.continuationToken!==void 0&&(t.continuationToken=e.session.continuationToken),Object.keys(t).length===0||e.session.continuationToken===void 0&&t.message===void 0||e.session.continuationToken!==void 0&&t.message===void 0&&t.inputResponses===void 0?null:t}export{ClientSession};
|
|
@@ -44,7 +44,8 @@ export type ClientRedirectPolicy = NonNullable<RequestInit["redirect"]>;
|
|
|
44
44
|
*/
|
|
45
45
|
export interface ClientOptions {
|
|
46
46
|
/**
|
|
47
|
-
* Base URL of the eve agent server.
|
|
47
|
+
* Base URL of the eve agent server. Query parameters are included on every
|
|
48
|
+
* request; request-specific parameters override parameters with the same name.
|
|
48
49
|
*/
|
|
49
50
|
readonly host: string;
|
|
50
51
|
/**
|
package/dist/src/client/url.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function createClientUrl(e,t,n){let r=t.startsWith(`/`)?t:`/${t}
|
|
1
|
+
function createClientUrl(e,t,n){let r=t.startsWith(`/`)?t:`/${t}`;if(isAbsoluteUrl(e)){let t=new URL(e);return t.pathname=`${trimTrailingSlash(t.pathname)}${r}`,mergeSearchParams(t.searchParams,n),t.hash=``,t.toString()}let i=new URL(e,`http://eve.local`),a=trimTrailingSlash(i.pathname);return mergeSearchParams(i.searchParams,n),`${a}${r}${formatSearch(i.searchParams)}`}function isAbsoluteUrl(e){return/^[a-z][a-z\d+\-.]*:/i.test(e)}function trimTrailingSlash(e){return e===`/`?``:e.endsWith(`/`)?e.slice(0,-1):e}function mergeSearchParams(e,t){if(t!==void 0)for(let[n,r]of Object.entries(t))e.set(n,r)}function formatSearch(e){let t=e.toString();return t.length===0?``:`?${t}`}export{createClientUrl};
|
|
@@ -27,12 +27,14 @@
|
|
|
27
27
|
"@vercel/detect-agent": "1.2.3",
|
|
28
28
|
"@vercel/oidc": "3.5.0",
|
|
29
29
|
"@vercel/sandbox": "2.3.0",
|
|
30
|
-
"@workflow/core": "5.0.0-beta.
|
|
31
|
-
"@workflow/errors": "5.0.0-beta.
|
|
30
|
+
"@workflow/core": "5.0.0-beta.28",
|
|
31
|
+
"@workflow/errors": "5.0.0-beta.10",
|
|
32
32
|
"@workflow/serde": "5.0.0-beta.2",
|
|
33
|
-
"@workflow/world": "5.0.0-beta.
|
|
33
|
+
"@workflow/world": "5.0.0-beta.16",
|
|
34
|
+
"@workflow/world-local": "5.0.0-beta.24",
|
|
35
|
+
"@workflow/world-vercel": "5.0.0-beta.24",
|
|
34
36
|
"zod": "4.4.3",
|
|
35
37
|
"zod-validation-error": "5.0.0"
|
|
36
38
|
},
|
|
37
|
-
"scriptHash": "
|
|
39
|
+
"scriptHash": "b46518404fb685affcfcac4ee0dd5559c3e7b1b1472e79a6d8ecf043b445c792"
|
|
38
40
|
}
|
|
@@ -156,8 +156,8 @@ export interface HookOptions {
|
|
|
156
156
|
* Whether this hook can be resumed via the public webhook endpoint.
|
|
157
157
|
*
|
|
158
158
|
* When `true`, the hook can be triggered by sending an HTTP request to the
|
|
159
|
-
* public
|
|
160
|
-
*
|
|
159
|
+
* public workflow webhook URL. This is automatically set when using
|
|
160
|
+
* `createWebhook()`.
|
|
161
161
|
*
|
|
162
162
|
* When `false` (the default), the hook can only be resumed server-side
|
|
163
163
|
* via `resumeHook()`.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Event } from '#compiled/@workflow/world/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Delay before firing the deferred unconsumed-event check after the promise
|
|
4
4
|
* queue has drained. Must be long enough for cross-VM microtask chains to
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as e,i as t}from"../../_chunks/workflow/dist-
|
|
2
|
-
`)}`)}return await v(t,r.value)}}}async function C(e,n={}){let
|
|
1
|
+
import{c as e,i as t}from"../../_chunks/workflow/dist-DpDDcpTl.js";import{C as n,Dn as r,En as i,R as a,Sn as o,T as s,Tn as c,bn as l,cn as u,h as d,ln as f,sn as p,t as m,vn as h,xn as g,z as _}from"../../_chunks/workflow/attribute-changes-BnKD8Y3m.js";import"../../_chunks/workflow/dist-DJU_7R9s.js";import{n as v}from"../../_chunks/workflow/resume-hook-DjPY9VGg.js";import{t as y}from"../../_chunks/workflow/sleep-phozDCW8.js";function b(e){i(`createHook()`,`https://workflow-sdk.dev/docs/api-reference/workflow/create-hook`,b)}function x(e){i(`createWebhook()`,`https://workflow-sdk.dev/docs/api-reference/workflow/create-webhook`,x)}function S({schema:e}={}){function t(e){i(`defineHook().create()`,`https://workflow-sdk.dev/docs/api-reference/workflow/define-hook`,t)}return{create:t,async resume(t,n){if(!e?.[`~standard`])return await v(t,n);let r=e[`~standard`].validate(n);if(r instanceof Promise&&(r=await r),r.issues){let e=r.issues.map(e=>{let t=e.path?.map(e=>String(typeof e==`object`&&e?e.key:e)).join(`.`);return t?` at "${t}": ${e.message}`:` ${e.message}`});throw Error(`Hook payload did not match the defined schema:\n${e.join(`
|
|
2
|
+
`)}`)}return await v(t,r.value)}}}async function C(e,n={}){let r=_.getStore(),i=r?.workflowMetadata?.workflowRunId;if(!i)throw new t(`experimental_setAttributes() must be called from a 'use workflow' or 'use step' function. Calling it from plain host code is not supported.`);let a=m(e,n);if(a.length!==0){if(r.runReadyBarrier)try{await r.runReadyBarrier}catch{}await(await h()).events.create(i,{eventType:`attr_set`,specVersion:5,eventData:{changes:a,writer:{type:`step`,stepId:r.stepMetadata.stepId,attempt:r.stepMetadata.attempt},...n.allowReservedAttributes===!0?{allowReservedAttributes:!0}:{}}})}}function w(){let e=_.getStore();return e||c(`getStepMetadata()`,`https://workflow-sdk.dev/docs/api-reference/workflow/get-step-metadata`,w),e.stepMetadata}function T(){let e=_.getStore();return e||r(`getWorkflowMetadata()`,`https://workflow-sdk.dev/docs/api-reference/workflow/get-workflow-metadata`,T),e.workflowMetadata}function E(e={}){let t=_.getStore();t||r(`getWritable()`,`https://workflow-sdk.dev/docs/api-reference/workflow/get-writable`,E);let{namespace:i}=e,c=t.workflowMetadata.workflowRunId,m=a(c,i),h=t.writables??=new Map,v=h.get(m);if(v)return v.writable;let y=s(n(globalThis,t.ops,c,t.encryptionKey,!0,t.runReadyBarrier),t.encryptionKey),b=new d(c,m,t.runReadyBarrier),x=l();return t.ops.push(x.promise),g(y.readable,b,x).catch(()=>{}),o(y.writable,x),Object.defineProperty(y.writable,p,{value:m,writable:!1}),Object.defineProperty(y.writable,f,{value:c,writable:!1}),t.workflowDeploymentId&&Object.defineProperty(y.writable,u,{value:t.workflowDeploymentId,writable:!1}),h.set(m,{writable:y.writable,state:x}),y.writable}export{t as FatalError,e as RetryableError,b as createHook,x as createWebhook,S as defineHook,C as experimental_setAttributes,w as getStepMetadata,T as getWorkflowMetadata,E as getWritable,y as sleep};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{c as e}from"../../_chunks/workflow/dist-CttsoN4D.js";const t=Symbol.for(`@workflow/core//registeredSteps`),n=globalThis,r=n[t]??=new Map,i=new Set([`__builtin_response_array_buffer`,`__builtin_response_json`,`__builtin_response_text`]);function a(e){let t=e.split(`//`);if(t.length!==3||t[0]!==`step`)return[];let n=t[1],r=t[2],i=new Set,a=e=>{e!==n&&i.add(e)};if(n.startsWith(`./workflows/`)){let e=n.slice(2);a(`./example/${e}`),a(`./src/${e}`)}else if(n.startsWith(`./example/workflows/`)){let e=n.slice(10);a(`./${e}`),a(`./src/${e}`)}else if(n.startsWith(`./src/workflows/`)){let e=n.slice(6);a(`./${e}`),a(`./example/${e}`)}return Array.from(i,e=>`step//${e}//${r}`)}function o(e){if(i.has(e)){for(let[t,n]of r.entries())if(t.endsWith(`//${e}`))return n}}function s(e,t){r.set(e,t),t.stepId=e}function c(e){let t=r.get(e);if(t)return t;for(let t of a(e)){let e=r.get(t);if(e)return e}let n=o(e);if(n)return n}async function l(e,t,n){if(t===void 0||!e.pendingDeliveryBarriers||e.pendingDeliveryBarriers.size===0)return;let r=[];for(let[i,a]of e.pendingDeliveryBarriers)i<t&&n.includes(a.kind)&&r.push(a.delivered);r.length>0&&await Promise.all(r)}function u(t,n,r){let i=t.pendingDeliveryBarriers;if(!i||n===void 0)return{markDelivered:()=>{}};let a=!1,{promise:o,resolve:s}=e(),c={kind:r,delivered:o};i.set(n,c);let l=()=>{a||(a=!0,i.get(n)===c&&i.delete(n),s())};return d(t,l),{markDelivered:l}}function d(e,t){let n=()=>{e.pendingDeliveries>0?e.promiseQueue.then(()=>{setTimeout(n,0)}):t()};setTimeout(n,0)}export{l as awaitEarlierDeliveries,c as getStepFunction,u as registerDeliveryBarrier,s as registerStepFunction,d as scheduleWhenIdle};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export declare const MAX_QUEUE_DELIVERIES = 48;
|
|
2
|
+
/**
|
|
3
|
+
* Effective max queue deliveries. Override via `WORKFLOW_MAX_QUEUE_DELIVERIES`.
|
|
4
|
+
*/
|
|
5
|
+
export declare function getMaxQueueDeliveries(): number;
|
|
2
6
|
/**
|
|
3
7
|
* Default maximum time allowed for the *replay* portion of a single workflow
|
|
4
8
|
* handler invocation (in ms). This budget only covers deterministic-replay
|
|
@@ -48,6 +52,11 @@ export declare function getReplayTimeoutMs(): number;
|
|
|
48
52
|
*/
|
|
49
53
|
export declare function _resetReplayTimeoutWarnCacheForTests(): void;
|
|
50
54
|
export declare const REPLAY_TIMEOUT_MAX_RETRIES = 3;
|
|
55
|
+
/**
|
|
56
|
+
* Effective replay-timeout retry budget. Override via
|
|
57
|
+
* `WORKFLOW_REPLAY_TIMEOUT_MAX_RETRIES`.
|
|
58
|
+
*/
|
|
59
|
+
export declare function getReplayTimeoutMaxRetries(): number;
|
|
51
60
|
/**
|
|
52
61
|
* Default maximum number of steps the owned-inline path runs inline (in
|
|
53
62
|
* parallel) per suspension. The rest are queued to background handlers. Each
|
|
@@ -122,4 +131,9 @@ export declare function isOptimisticInlineStartExplicitlyDisabled(): boolean;
|
|
|
122
131
|
*/
|
|
123
132
|
export declare function isTurboEnabled(): boolean;
|
|
124
133
|
export declare const REPLAY_DIVERGENCE_MAX_RETRIES = 3;
|
|
134
|
+
/**
|
|
135
|
+
* Effective replay-divergence recovery budget. Override via
|
|
136
|
+
* `WORKFLOW_REPLAY_DIVERGENCE_MAX_RETRIES`.
|
|
137
|
+
*/
|
|
138
|
+
export declare function getReplayDivergenceMaxRetries(): number;
|
|
125
139
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -13,19 +13,10 @@
|
|
|
13
13
|
* `getWorld()` call. This is the steady-state hot path.
|
|
14
14
|
* 2. `globalThis[GetWorldFnKey]` — populated by the module-load side
|
|
15
15
|
* effect at the bottom of `./world.ts`. Fires on every server bundle
|
|
16
|
-
* that reaches this file via `workflow/api` (which
|
|
16
|
+
* that reaches this file via `workflow` or `workflow/api` (which import
|
|
17
17
|
* `./world-init.ts` for its side effect; see that file for the full
|
|
18
|
-
* rationale). This is the cold-start path for routes that consume
|
|
19
|
-
*
|
|
20
|
-
* 3. Dynamic `import('./world.js')` — last-resort fallback for
|
|
21
|
-
* environments where neither (1) nor (2) is available (CJS test
|
|
22
|
-
* runners, scripts that import deeply into `@workflow/core` without
|
|
23
|
-
* going through `workflow/api`, future bundlers we haven't validated).
|
|
24
|
-
* The specifier is built at runtime so esbuild can't trace it into
|
|
25
|
-
* step bundles. Note: this branch is unreliable in webpack-bundled
|
|
26
|
-
* routes because webpack inlines this module into the route file and
|
|
27
|
-
* the relative path resolves against the bundle location — paths (1)
|
|
28
|
-
* and (2) cover those cases instead.
|
|
18
|
+
* rationale). This is the cold-start path for routes that consume host
|
|
19
|
+
* helpers without any prior workflow run.
|
|
29
20
|
*/
|
|
30
21
|
import type { World } from '#compiled/@workflow/world/index.js';
|
|
31
22
|
export declare function getWorldLazy(): Promise<World>;
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
*/
|
|
59
59
|
/**
|
|
60
60
|
* Maximum `delaySeconds` for a single wait-continuation message. Waits
|
|
61
|
-
* longer than this are chained across multiple hops. 23 hours
|
|
62
|
-
*
|
|
61
|
+
* longer than this are chained across multiple hops. 23 hours leaves a 1h
|
|
62
|
+
* buffer under Vercel Queues' default 24h message TTL and mirrors
|
|
63
63
|
* world-vercel's `MAX_DELAY_SECONDS`.
|
|
64
64
|
*/
|
|
65
65
|
export declare const WAIT_CONTINUATION_MAX_DELAY_SECONDS = 82800;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { World } from '#compiled/@workflow/world/index.js';
|
|
2
|
+
type WorldSpecVersionMetadata = Pick<World, 'specVersion'>;
|
|
3
|
+
export declare function assertWorldSupportsRuntimeProtocol(world: WorldSpecVersionMetadata): void;
|
|
4
|
+
export {};
|
|
5
|
+
//# sourceMappingURL=world-compatibility.d.ts.map
|