eve 0.22.2 → 0.22.4
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 +36 -0
- package/dist/src/chunks/{use-eve-agent-CM24ZUEI.js → use-eve-agent-CFBTHlPx.js} +43 -14
- package/dist/src/chunks/{use-eve-agent-CxcKypLZ.js → use-eve-agent-dEGV09g_.js} +43 -14
- package/dist/src/cli/dev/url.js +1 -1
- package/dist/src/client/agent-host.d.ts +4 -0
- package/dist/src/client/agent-host.js +1 -0
- 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/compiler/manifest.d.ts +44 -6
- 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/normalize-subagent.js +1 -1
- package/dist/src/compiler/remote-agent-node.d.ts +1 -1
- package/dist/src/compiler/remote-agent-node.js +1 -1
- 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 +2 -2
- 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/discover/project.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/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/create-application-nitro.js +1 -1
- package/dist/src/internal/workflow-bundle/eve-service-route-output.d.ts +1 -2
- package/dist/src/internal/workflow-bundle/eve-service-route-output.js +1 -54
- package/dist/src/internal/workflow-bundle/vercel-workflow-output.js +1 -1
- package/dist/src/packages/eve-catalog/src/index.js +1 -1
- package/dist/src/public/channels/discord/discordChannel.js +1 -1
- package/dist/src/public/channels/slack/api.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/definitions/extension.d.ts +68 -0
- package/dist/src/public/definitions/extension.js +1 -0
- package/dist/src/public/definitions/remote-agent.d.ts +11 -2
- package/dist/src/public/extension/index.d.ts +10 -0
- package/dist/src/public/extension/index.js +1 -0
- package/dist/src/public/index.d.ts +1 -1
- package/dist/src/public/next/index.d.ts +38 -3
- package/dist/src/public/next/index.js +1 -1
- package/dist/src/public/next/server.d.ts +1 -0
- package/dist/src/public/next/server.js +2 -1
- package/dist/src/public/next/vercel-output-config.d.ts +12 -3
- package/dist/src/public/next/vercel-output-config.js +1 -1
- package/dist/src/react/use-eve-agent.d.ts +8 -1
- package/dist/src/react/use-eve-agent.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-agent-graph.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/connections/catalog.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +3 -3
- package/dist/src/svelte/index.js +1 -1
- package/dist/src/svelte/use-eve-agent.d.ts +8 -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.d.ts +8 -1
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/channels/custom.mdx +2 -2
- package/docs/channels/linear.mdx +1 -1
- package/docs/channels/slack.mdx +2 -0
- package/docs/concepts/context-control.md +1 -1
- package/docs/connections/openapi.mdx +3 -1
- package/docs/evals/assertions.mdx +4 -2
- package/docs/extensions.md +176 -0
- package/docs/guides/client/overview.mdx +1 -1
- package/docs/guides/dev-tui.md +4 -0
- package/docs/guides/dynamic-capabilities.md +3 -3
- package/docs/guides/frontend/nextjs.mdx +32 -7
- package/docs/guides/frontend/overview.mdx +7 -1
- package/docs/guides/hooks.md +9 -0
- package/docs/guides/instrumentation.md +1 -1
- package/docs/guides/remote-agents.md +23 -8
- package/docs/guides/state.md +3 -3
- package/docs/instructions.mdx +1 -1
- 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/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 +6 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# eve
|
|
2
2
|
|
|
3
|
+
## 0.22.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- b5aedaf: The shared integrations catalog gains 33 curated MCP connections from the Vercel Connect preset directory (Airtable, Stripe, Sentry, Supabase, Zapier, and more) for the docs integrations gallery, and the connection scaffolder now skips gallery-only catalog entries, so the `eve connections add` picker is unchanged.
|
|
8
|
+
- edc93cc: Keep the mounted extensions guide out of the docs sidebar for now. The page stays at `/docs/extensions`, but the feature isn't surfaced in the nav while its API stabilizes.
|
|
9
|
+
- f00f084: Add named multi-agent routing to `withEve` and `useEveAgent`. Next.js apps can now configure multiple eve roots with `agents`, then target one from the frontend with `useEveAgent({ agent: "name" })`.
|
|
10
|
+
- f83d47d: `defineRemoteAgent` now accepts a function for `url`, resolved at runtime instead of baked at compile time. Return a `string` (or `Promise<string>`) from `() => process.env.MY_SERVICE_URL` to target an endpoint supplied by a runtime env var, known only once the deployment runs.
|
|
11
|
+
|
|
12
|
+
## 0.22.3
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- 8223498: Start remote authentication when a credentialed Vercel deployment returns an `UNAUTHORIZED` protection response.
|
|
17
|
+
- 79df338: feat(eve): scaffold projects with bundler module resolution
|
|
18
|
+
|
|
19
|
+
`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"`).
|
|
20
|
+
|
|
21
|
+
- 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.
|
|
22
|
+
- 89cd2d6: Eval assertion `count` options now accept predicates, allowing ranges such as “at least two” while preserving exact numeric counts.
|
|
23
|
+
- fdf56ef: feat(eve): mounted extensions
|
|
24
|
+
|
|
25
|
+
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.
|
|
26
|
+
|
|
27
|
+
- 89f13e0: Hardened frontmatter parsing and OpenAPI connection loading.
|
|
28
|
+
|
|
29
|
+
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.
|
|
30
|
+
|
|
31
|
+
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.
|
|
32
|
+
|
|
33
|
+
- aff35e2: Stop `eve dev` source snapshots from copying nested Git repositories and worktrees, preventing duplicate checkouts from inflating each development snapshot.
|
|
34
|
+
- 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.
|
|
35
|
+
- 72c58ae: Recover `eve dev <url>` authentication when Vercel Deployment Protection returns an SSO redirect or a structured protected-deployment response.
|
|
36
|
+
- 87688f9: Slack outbound messages now preserve literal bare `@` tokens, including scoped package names, while explicit `<@USER_ID>` mention syntax continues to pass through unchanged.
|
|
37
|
+
- c1c4ee5: Preserve query parameters passed to `eve dev` and send them on every agent request, including session POSTs and streams.
|
|
38
|
+
|
|
3
39
|
## 0.22.2
|
|
4
40
|
|
|
5
41
|
### 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 {
|
|
@@ -1114,6 +1126,20 @@ function toTerminalStreamFailureError(event) {
|
|
|
1114
1126
|
return error;
|
|
1115
1127
|
}
|
|
1116
1128
|
|
|
1129
|
+
//#endregion
|
|
1130
|
+
//#region src/client/agent-host.ts
|
|
1131
|
+
const AGENT_NAME_PATTERN = /^[a-z0-9][a-z0-9_-]*$/;
|
|
1132
|
+
const EVE_NAMED_AGENT_ROUTE_PREFIX = "/eve/agents";
|
|
1133
|
+
function resolveEveAgentHost(input) {
|
|
1134
|
+
if (input.agent === void 0) return input.host ?? "";
|
|
1135
|
+
if (input.host !== void 0) throw new Error("useEveAgent cannot combine agent and host. Use one target option.");
|
|
1136
|
+
assertValidAgentName(input.agent);
|
|
1137
|
+
return `${EVE_NAMED_AGENT_ROUTE_PREFIX}/${input.agent}`;
|
|
1138
|
+
}
|
|
1139
|
+
function assertValidAgentName(name) {
|
|
1140
|
+
if (!AGENT_NAME_PATTERN.test(name)) throw new Error(`eve agent name ${JSON.stringify(name)} is invalid. Use lowercase letters, numbers, underscores, or hyphens, starting with a letter or number.`);
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1117
1143
|
//#endregion
|
|
1118
1144
|
//#region src/client/authorization-message-parts.ts
|
|
1119
1145
|
function createAuthorizationRequiredPart(event) {
|
|
@@ -1569,7 +1595,10 @@ function useEveAgent(options = {}) {
|
|
|
1569
1595
|
const store = new EveAgentStore({
|
|
1570
1596
|
auth: options.auth,
|
|
1571
1597
|
headers: options.headers,
|
|
1572
|
-
host:
|
|
1598
|
+
host: resolveEveAgentHost({
|
|
1599
|
+
agent: options.agent,
|
|
1600
|
+
host: options.host
|
|
1601
|
+
}),
|
|
1573
1602
|
initialEvents: options.initialEvents,
|
|
1574
1603
|
initialSession: options.initialSession,
|
|
1575
1604
|
maxReconnectAttempts: options.maxReconnectAttempts,
|
|
@@ -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 {
|
|
@@ -1114,6 +1126,20 @@ function toTerminalStreamFailureError(event) {
|
|
|
1114
1126
|
return error;
|
|
1115
1127
|
}
|
|
1116
1128
|
|
|
1129
|
+
//#endregion
|
|
1130
|
+
//#region src/client/agent-host.ts
|
|
1131
|
+
const AGENT_NAME_PATTERN = /^[a-z0-9][a-z0-9_-]*$/;
|
|
1132
|
+
const EVE_NAMED_AGENT_ROUTE_PREFIX = "/eve/agents";
|
|
1133
|
+
function resolveEveAgentHost(input) {
|
|
1134
|
+
if (input.agent === void 0) return input.host ?? "";
|
|
1135
|
+
if (input.host !== void 0) throw new Error("useEveAgent cannot combine agent and host. Use one target option.");
|
|
1136
|
+
assertValidAgentName(input.agent);
|
|
1137
|
+
return `${EVE_NAMED_AGENT_ROUTE_PREFIX}/${input.agent}`;
|
|
1138
|
+
}
|
|
1139
|
+
function assertValidAgentName(name) {
|
|
1140
|
+
if (!AGENT_NAME_PATTERN.test(name)) throw new Error(`eve agent name ${JSON.stringify(name)} is invalid. Use lowercase letters, numbers, underscores, or hyphens, starting with a letter or number.`);
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1117
1143
|
//#endregion
|
|
1118
1144
|
//#region src/client/authorization-message-parts.ts
|
|
1119
1145
|
function createAuthorizationRequiredPart(event) {
|
|
@@ -1618,7 +1644,10 @@ function useEveAgent(options = {}) {
|
|
|
1618
1644
|
const store = new EveAgentStore({
|
|
1619
1645
|
auth: options.auth,
|
|
1620
1646
|
headers: options.headers,
|
|
1621
|
-
host:
|
|
1647
|
+
host: resolveEveAgentHost({
|
|
1648
|
+
agent: options.agent,
|
|
1649
|
+
host: options.host
|
|
1650
|
+
}),
|
|
1622
1651
|
initialEvents: options.initialEvents,
|
|
1623
1652
|
initialSession: options.initialSession,
|
|
1624
1653
|
maxReconnectAttempts: options.maxReconnectAttempts,
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const AGENT_NAME_PATTERN=/^[a-z0-9][a-z0-9_-]*$/;function resolveEveAgentHost(e){if(e.agent===void 0)return e.host??``;if(e.host!==void 0)throw Error(`useEveAgent cannot combine agent and host. Use one target option.`);return assertValidAgentName(e.agent),`/eve/agents/${e.agent}`}function assertValidAgentName(t){if(!AGENT_NAME_PATTERN.test(t))throw Error(`eve agent name ${JSON.stringify(t)} is invalid. Use lowercase letters, numbers, underscores, or hyphens, starting with a letter or number.`)}export{resolveEveAgentHost};
|
|
@@ -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};
|
|
@@ -20,7 +20,7 @@ export declare const ROOT_COMPILED_AGENT_NODE_ID = "__root__";
|
|
|
20
20
|
/**
|
|
21
21
|
* Current compiled manifest schema version.
|
|
22
22
|
*/
|
|
23
|
-
export declare const COMPILED_AGENT_MANIFEST_VERSION =
|
|
23
|
+
export declare const COMPILED_AGENT_MANIFEST_VERSION = 35;
|
|
24
24
|
/**
|
|
25
25
|
* Compiled channel entry preserved in the compiled manifest.
|
|
26
26
|
*/
|
|
@@ -141,6 +141,13 @@ export type CompiledToolDefinition = InternalToolDefinition & ModuleSourceRef;
|
|
|
141
141
|
export interface CompiledDynamicToolDefinition extends ModuleSourceRef {
|
|
142
142
|
readonly slug: string;
|
|
143
143
|
readonly eventNames: readonly string[];
|
|
144
|
+
/**
|
|
145
|
+
* Mount namespace when this resolver comes from an extension. The runtime
|
|
146
|
+
* prefixes the names of tools the resolver produces (`forecast` →
|
|
147
|
+
* `crm__forecast`) so extension-produced tools are namespaced like every
|
|
148
|
+
* other extension contribution. Absent for consumer-authored resolvers.
|
|
149
|
+
*/
|
|
150
|
+
readonly extensionNamespace?: string;
|
|
144
151
|
}
|
|
145
152
|
/**
|
|
146
153
|
* Compiled dynamic skill resolver entry. Mirrors
|
|
@@ -150,6 +157,11 @@ export interface CompiledDynamicToolDefinition extends ModuleSourceRef {
|
|
|
150
157
|
export interface CompiledDynamicSkillDefinition extends ModuleSourceRef {
|
|
151
158
|
readonly slug: string;
|
|
152
159
|
readonly eventNames: readonly string[];
|
|
160
|
+
/**
|
|
161
|
+
* Mount namespace when this resolver comes from an extension. Names of skills
|
|
162
|
+
* a map resolver produces are prefixed with `${extensionNamespace}__`.
|
|
163
|
+
*/
|
|
164
|
+
readonly extensionNamespace?: string;
|
|
153
165
|
}
|
|
154
166
|
/**
|
|
155
167
|
* Compiled dynamic instructions resolver entry. The resolver produces
|
|
@@ -314,7 +326,7 @@ declare const compiledAgentNodeManifestSchema: z.ZodObject<{
|
|
|
314
326
|
outputSchema?: import("../shared/json.ts").JsonObject;
|
|
315
327
|
path: string;
|
|
316
328
|
rootPath: string;
|
|
317
|
-
url
|
|
329
|
+
url?: string;
|
|
318
330
|
}>, unknown, z.core.$ZodTypeInternals<Readonly<ModuleSourceRef & Node & {
|
|
319
331
|
description: string;
|
|
320
332
|
entryPath: string;
|
|
@@ -322,7 +334,7 @@ declare const compiledAgentNodeManifestSchema: z.ZodObject<{
|
|
|
322
334
|
outputSchema?: import("../shared/json.ts").JsonObject;
|
|
323
335
|
path: string;
|
|
324
336
|
rootPath: string;
|
|
325
|
-
url
|
|
337
|
+
url?: string;
|
|
326
338
|
}>, unknown>>>;
|
|
327
339
|
skills: z.ZodReadonly<z.ZodArray<z.ZodType<CompiledSkillDefinition, unknown, z.core.$ZodTypeInternals<CompiledSkillDefinition, unknown>>>>;
|
|
328
340
|
instructions: z.ZodOptional<z.ZodType<CompiledInstructionsDefinition, unknown, z.core.$ZodTypeInternals<CompiledInstructionsDefinition, unknown>>>;
|
|
@@ -342,12 +354,37 @@ declare const compiledAgentNodeManifestSchema: z.ZodObject<{
|
|
|
342
354
|
rootEntries: z.ZodReadonly<z.ZodArray<z.ZodString>>;
|
|
343
355
|
}, z.core.$strict>;
|
|
344
356
|
}, z.core.$strict>;
|
|
357
|
+
/**
|
|
358
|
+
* One mounted extension recorded on the root compiled manifest. The runtime
|
|
359
|
+
* evaluates {@link mountLogicalPath} at module-map load so the mount's factory
|
|
360
|
+
* call binds the extension's config before any tool runs.
|
|
361
|
+
*/
|
|
362
|
+
export interface CompiledExtensionMount {
|
|
363
|
+
/** Mount-derived namespace that prefixes the extension's tool/skill names. */
|
|
364
|
+
readonly namespace: string;
|
|
365
|
+
readonly packageName: string;
|
|
366
|
+
/**
|
|
367
|
+
* Package-derived namespace that scopes the extension's durable state keys and
|
|
368
|
+
* config binding. Distinct from {@link namespace}: state stays keyed to the
|
|
369
|
+
* package so a consumer renaming the mount file cannot orphan persisted state.
|
|
370
|
+
*/
|
|
371
|
+
readonly packageNamespace: string;
|
|
372
|
+
/**
|
|
373
|
+
* Absolute path to the extension's source root on disk. The extension-scope
|
|
374
|
+
* bundler plugin treats any module under this root as extension-owned and
|
|
375
|
+
* rewrites its `eve/context`/`eve/extension` imports to bake in the namespace.
|
|
376
|
+
*/
|
|
377
|
+
readonly sourceRoot: string;
|
|
378
|
+
readonly mountSourceId: string;
|
|
379
|
+
readonly mountLogicalPath: string;
|
|
380
|
+
}
|
|
345
381
|
/**
|
|
346
382
|
* Zod schema for the versioned compiled manifest emitted by the compiler.
|
|
347
383
|
*/
|
|
348
384
|
export declare const compiledAgentManifestSchema: z.ZodObject<{
|
|
349
385
|
agentRoot: z.ZodString;
|
|
350
386
|
appRoot: z.ZodString;
|
|
387
|
+
extensionMounts: z.ZodDefault<z.ZodArray<z.ZodType<CompiledExtensionMount, unknown, z.core.$ZodTypeInternals<CompiledExtensionMount, unknown>>>>;
|
|
351
388
|
channels: z.ZodArray<z.ZodType<CompiledChannelEntry, unknown, z.core.$ZodTypeInternals<CompiledChannelEntry, unknown>>>;
|
|
352
389
|
config: z.ZodType<CompiledAgentDefinition, unknown, z.core.$ZodTypeInternals<CompiledAgentDefinition, unknown>>;
|
|
353
390
|
connections: z.ZodArray<z.ZodObject<{
|
|
@@ -384,7 +421,7 @@ export declare const compiledAgentManifestSchema: z.ZodObject<{
|
|
|
384
421
|
outputSchema?: import("../shared/json.ts").JsonObject;
|
|
385
422
|
path: string;
|
|
386
423
|
rootPath: string;
|
|
387
|
-
url
|
|
424
|
+
url?: string;
|
|
388
425
|
}>, unknown, z.core.$ZodTypeInternals<Readonly<ModuleSourceRef & Node & {
|
|
389
426
|
description: string;
|
|
390
427
|
entryPath: string;
|
|
@@ -392,7 +429,7 @@ export declare const compiledAgentManifestSchema: z.ZodObject<{
|
|
|
392
429
|
outputSchema?: import("../shared/json.ts").JsonObject;
|
|
393
430
|
path: string;
|
|
394
431
|
rootPath: string;
|
|
395
|
-
url
|
|
432
|
+
url?: string;
|
|
396
433
|
}>, unknown>>>;
|
|
397
434
|
sandbox: z.ZodNullable<z.ZodObject<{
|
|
398
435
|
backendName: z.ZodOptional<z.ZodString>;
|
|
@@ -445,7 +482,7 @@ export declare const compiledAgentManifestSchema: z.ZodObject<{
|
|
|
445
482
|
sourceId: z.ZodString;
|
|
446
483
|
sourceKind: z.ZodLiteral<"module">;
|
|
447
484
|
}, z.core.$strict>>;
|
|
448
|
-
version: z.ZodLiteral<
|
|
485
|
+
version: z.ZodLiteral<35>;
|
|
449
486
|
workspaceResourceRoot: z.ZodObject<{
|
|
450
487
|
contentHash: z.ZodOptional<z.ZodString>;
|
|
451
488
|
logicalPath: z.ZodString;
|
|
@@ -518,4 +555,5 @@ export declare function createCompiledAgentManifest(input: {
|
|
|
518
555
|
readonly subagents?: readonly CompiledSubagentNode[];
|
|
519
556
|
readonly instructions?: CompiledInstructionsDefinition;
|
|
520
557
|
readonly tools?: readonly CompiledToolDefinition[];
|
|
558
|
+
readonly extensionMounts?: readonly CompiledExtensionMount[];
|
|
521
559
|
}): CompiledAgentManifest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z}from"#compiled/zod/index.js";import{discoverDiagnosticsSummarySchema}from"#discover/diagnostics.js";import{compiledRemoteAgentNodeSchema}from"#compiler/remote-agent-node.js";import{jsonObjectSchema}from"#shared/json-schemas.js";const COMPILED_AGENT_MANIFEST_KIND=`eve-agent-compiled-manifest`,ROOT_COMPILED_AGENT_NODE_ID=`__root__`,COMPILED_AGENT_MANIFEST_VERSION=33,moduleSourceRefSchema=z.object({exportName:z.string().optional(),sourceKind:z.literal(`module`),logicalPath:z.string(),sourceId:z.string()}).strict(),compiledDynamicModelDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),sourceKind:z.literal(`module`),logicalPath:z.string(),sourceId:z.string()}).strict(),channelMethodSchema=z.union([z.literal(`GET`),z.literal(`POST`),z.literal(`PUT`),z.literal(`PATCH`),z.literal(`DELETE`),z.literal(`WEBSOCKET`)]),compiledChannelCorsSchema=z.object({origin:z.union([z.literal(`*`),z.literal(`null`),z.array(z.string())]).optional(),methods:z.union([z.literal(`*`),z.array(z.string())]).optional(),allowHeaders:z.union([z.literal(`*`),z.array(z.string())]).optional(),exposeHeaders:z.union([z.literal(`*`),z.array(z.string())]).optional(),credentials:z.boolean().optional(),maxAge:z.union([z.string(),z.literal(!1)]).optional(),preflight:z.object({statusCode:z.number().int().min(100).max(599).optional()}).strict().optional()}).strict(),compiledChannelDefinitionSchema=z.object({kind:z.literal(`channel`),name:z.string(),logicalPath:z.string(),method:channelMethodSchema,urlPath:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`),exportName:z.string().optional(),adapterKind:z.string().optional(),cors:compiledChannelCorsSchema.optional()}).strict(),disabledCompiledChannelEntrySchema=z.object({kind:z.literal(`disabled`),name:z.string(),logicalPath:z.string()}).strict(),compiledChannelEntrySchema=z.union([compiledChannelDefinitionSchema,disabledCompiledChannelEntrySchema]),modelRoutingSchema=z.union([z.object({kind:z.literal(`gateway`),target:z.string(),byok:z.string().optional()}).strict(),z.object({kind:z.literal(`external`),provider:z.string()}).strict()]),compiledRuntimeModelReferenceSchema=z.object({contextWindowTokens:z.number().int().positive().optional(),id:z.string(),source:moduleSourceRefSchema.optional(),providerOptions:z.record(z.string(),jsonObjectSchema).optional(),routing:modelRoutingSchema}).strict(),compiledAgentBuildDefinitionSchema=z.object({externalDependencies:z.array(z.string()).optional()}).strict(),compiledAgentWorkflowWorldDefinitionSchema=z.string(),compiledAgentWorkflowDefinitionSchema=z.object({world:compiledAgentWorkflowWorldDefinitionSchema.optional()}).strict(),compiledAgentCompactionDefinitionSchema=z.object({model:compiledRuntimeModelReferenceSchema.optional(),thresholdPercent:z.number().finite().min(0).max(1).optional()}).strict(),sessionTokenLimitSchema=z.union([z.number().int().positive(),z.literal(!1)]),compiledAgentLimitsDefinitionSchema=z.object({maxSubagentDepth:z.number().int().positive().optional(),maxSubagents:z.number().int().positive().optional(),maxInputTokensPerSession:sessionTokenLimitSchema.optional(),maxOutputTokensPerSession:sessionTokenLimitSchema.optional()}).strict(),compiledAgentConfigSchema=z.object({build:compiledAgentBuildDefinitionSchema.optional(),compaction:compiledAgentCompactionDefinitionSchema.optional(),description:z.string().optional(),dynamicModel:compiledDynamicModelDefinitionSchema.optional(),experimental:z.object({workflow:compiledAgentWorkflowDefinitionSchema.optional()}).strict().optional(),model:compiledRuntimeModelReferenceSchema,name:z.string(),outputSchema:jsonObjectSchema.optional(),reasoning:z.enum([`provider-default`,`none`,`minimal`,`low`,`medium`,`high`,`xhigh`]).optional(),source:moduleSourceRefSchema.optional(),limits:compiledAgentLimitsDefinitionSchema.optional()}).strict(),compiledInstructionsSchema=z.object({name:z.string(),logicalPath:z.string(),markdown:z.string(),sourceId:z.string(),sourceKind:z.union([z.literal(`markdown`),z.literal(`module`)])}).strict(),compiledSkillBaseFields={name:z.string(),description:z.string(),license:z.string().optional(),markdown:z.string(),metadata:z.record(z.string(),z.string()).optional(),sourceId:z.string(),logicalPath:z.string()},compiledSkillSourceSchema=z.discriminatedUnion(`sourceKind`,[z.object({...compiledSkillBaseFields,sourceKind:z.literal(`markdown`)}).strict(),z.object({...compiledSkillBaseFields,sourceKind:z.literal(`module`),exportName:z.string().optional()}).strict(),z.object({...compiledSkillBaseFields,sourceKind:z.literal(`skill-package`),skillId:z.string(),skillFilePath:z.string(),rootPath:z.string(),assetsPath:z.string().optional(),referencesPath:z.string().optional(),scriptsPath:z.string().optional()}).strict()]),compiledScheduleDefinitionSchema=z.object({cron:z.string(),hasRun:z.boolean(),name:z.string(),logicalPath:z.string(),markdown:z.string().optional(),sourceId:z.string(),sourceKind:z.union([z.literal(`markdown`),z.literal(`module`)])}).strict(),compiledSandboxDefinitionSchema=z.object({backendName:z.string().optional(),description:z.string().optional(),exportName:z.string().optional(),logicalPath:z.string(),revalidationKey:z.string().optional(),sourceHash:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledSandboxWorkspaceSchema=z.object({logicalPath:z.string(),rootEntries:z.array(z.string()).readonly(),sourceId:z.string(),sourcePath:z.string()}).strict(),compiledWorkspaceResourceRootSchema=z.object({contentHash:z.string().optional(),logicalPath:z.string(),rootEntries:z.array(z.string()).readonly()}).strict(),compiledConnectionDefinitionSchema=z.object({connectionName:z.string(),description:z.string(),exportName:z.string().optional(),logicalPath:z.string(),protocol:z.enum([`mcp`,`openapi`]).default(`mcp`),sourceId:z.string(),sourceKind:z.literal(`module`),url:z.string(),vercelConnect:z.object({connector:z.string()}).strict().optional()}).strict(),compiledToolDefinitionSchema=z.object({description:z.string(),exportName:z.string().optional(),inputSchema:jsonObjectSchema.nullable(),logicalPath:z.string(),name:z.string(),outputSchema:jsonObjectSchema.optional(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledDynamicToolDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledDynamicSkillDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledDynamicInstructionsDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledHookDefinitionSchema=z.object({exportName:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledAgentNodeManifestSchema=z.object({agentRoot:z.string(),appRoot:z.string(),channels:z.array(compiledChannelEntrySchema),config:compiledAgentConfigSchema,connections:z.array(compiledConnectionDefinitionSchema),diagnosticsSummary:discoverDiagnosticsSummarySchema,disabledFrameworkTools:z.array(z.string()).readonly(),workflowEnabled:z.boolean().default(!1),dynamicInstructions:z.array(compiledDynamicInstructionsDefinitionSchema).default([]),dynamicSkills:z.array(compiledDynamicSkillDefinitionSchema).default([]),dynamicTools:z.array(compiledDynamicToolDefinitionSchema).default([]),hooks:z.array(compiledHookDefinitionSchema),sandbox:compiledSandboxDefinitionSchema.nullable(),sandboxWorkspaces:z.array(compiledSandboxWorkspaceSchema),schedules:z.array(compiledScheduleDefinitionSchema),remoteAgents:z.array(compiledRemoteAgentNodeSchema),skills:z.array(compiledSkillSourceSchema).readonly(),instructions:compiledInstructionsSchema.optional(),tools:z.array(compiledToolDefinitionSchema),workspaceResourceRoot:compiledWorkspaceResourceRootSchema}).strict(),compiledSubagentNodeSchema=z.object({agent:compiledAgentNodeManifestSchema,description:z.string(),entryPath:z.string(),logicalPath:z.string(),name:z.string(),nodeId:z.string(),rootPath:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`),exportName:z.string().optional()}).strict(),compiledSubagentEdgeSchema=z.object({childNodeId:z.string(),parentNodeId:z.string()}).strict(),compiledAgentManifestSchema=z.object({agentRoot:z.string(),appRoot:z.string(),channels:z.array(compiledChannelEntrySchema),config:compiledAgentConfigSchema,connections:z.array(compiledConnectionDefinitionSchema),diagnosticsSummary:discoverDiagnosticsSummarySchema,disabledFrameworkTools:z.array(z.string()).readonly(),workflowEnabled:z.boolean().default(!1),dynamicInstructions:z.array(compiledDynamicInstructionsDefinitionSchema).default([]),dynamicSkills:z.array(compiledDynamicSkillDefinitionSchema).default([]),dynamicTools:z.array(compiledDynamicToolDefinitionSchema).default([]),hooks:z.array(compiledHookDefinitionSchema),kind:z.literal(COMPILED_AGENT_MANIFEST_KIND),remoteAgents:z.array(compiledRemoteAgentNodeSchema),sandbox:compiledSandboxDefinitionSchema.nullable(),sandboxWorkspaces:z.array(compiledSandboxWorkspaceSchema),schedules:z.array(compiledScheduleDefinitionSchema),skills:z.array(compiledSkillSourceSchema).readonly(),subagentEdges:z.array(compiledSubagentEdgeSchema),subagents:z.array(compiledSubagentNodeSchema),instructions:compiledInstructionsSchema.optional(),tools:z.array(compiledToolDefinitionSchema),version:z.literal(33),workspaceResourceRoot:compiledWorkspaceResourceRootSchema}).strict();function createCompiledAgentNodeManifest(e){let t={agentRoot:e.agentRoot,appRoot:e.appRoot,channels:[...e.channels??[]],connections:[...e.connections??[]],config:{build:e.config.build===void 0?void 0:{externalDependencies:e.config.build.externalDependencies===void 0?void 0:[...e.config.build.externalDependencies]},compaction:{model:e.config.compaction?.model===void 0?void 0:cloneCompiledRuntimeModelReference(e.config.compaction.model),thresholdPercent:e.config.compaction?.thresholdPercent},description:e.config.description,dynamicModel:e.config.dynamicModel===void 0?void 0:{...e.config.dynamicModel},experimental:e.config.experimental===void 0?void 0:{workflow:e.config.experimental.workflow===void 0?void 0:{world:e.config.experimental.workflow.world}},model:cloneCompiledRuntimeModelReference(e.config.model),name:e.config.name,outputSchema:e.config.outputSchema,reasoning:e.config.reasoning,limits:e.config.limits===void 0?void 0:{maxInputTokensPerSession:e.config.limits.maxInputTokensPerSession,maxOutputTokensPerSession:e.config.limits.maxOutputTokensPerSession,maxSubagentDepth:e.config.limits.maxSubagentDepth,maxSubagents:e.config.limits.maxSubagents},source:e.config.source===void 0?void 0:{...e.config.source}},diagnosticsSummary:e.diagnosticsSummary??{errors:0,warnings:0},disabledFrameworkTools:[...e.disabledFrameworkTools??[]],workflowEnabled:e.workflowEnabled??!1,dynamicInstructions:[...e.dynamicInstructions??[]],dynamicSkills:[...e.dynamicSkills??[]],dynamicTools:[...e.dynamicTools??[]],hooks:[...e.hooks??[]],remoteAgents:[...e.remoteAgents??[]],sandbox:e.sandbox??null,sandboxWorkspaces:[...e.sandboxWorkspaces??[]],schedules:[...e.schedules??[]],skills:[...e.skills??[]],tools:[...e.tools??[]],workspaceResourceRoot:e.workspaceResourceRoot??{logicalPath:``,rootEntries:deriveResourceRootEntries({sandboxWorkspaces:e.sandboxWorkspaces,skills:e.skills})}};return e.instructions!==void 0&&(t.instructions=e.instructions),t}function deriveResourceRootEntries(e){let t=new Set;for(let n of e.sandboxWorkspaces??[])for(let e of n.rootEntries)t.add(e);return[...t].sort((e,t)=>e.localeCompare(t))}function createCompiledSubagentNodeId(e,t){return e===`__root__`?t:`${e}::${t}`}function createCompiledAgentManifest(e){return{...createCompiledAgentNodeManifest(e),kind:COMPILED_AGENT_MANIFEST_KIND,subagentEdges:[...e.subagentEdges??[]],subagents:[...e.subagents??[]],version:33}}function cloneCompiledRuntimeModelReference(e){let t={id:e.id,routing:cloneModelRouting(e.routing)};return e.contextWindowTokens!==void 0&&(t.contextWindowTokens=e.contextWindowTokens),e.providerOptions!==void 0&&(t.providerOptions={...e.providerOptions}),e.source!==void 0&&(t.source={...e.source}),t}function cloneModelRouting(e){return e.kind===`external`?{kind:`external`,provider:e.provider}:e.byok===void 0?{kind:`gateway`,target:e.target}:{kind:`gateway`,target:e.target,byok:e.byok}}export{COMPILED_AGENT_MANIFEST_KIND,COMPILED_AGENT_MANIFEST_VERSION,ROOT_COMPILED_AGENT_NODE_ID,compiledAgentManifestSchema,createCompiledAgentManifest,createCompiledAgentNodeManifest,createCompiledSubagentNodeId,deriveResourceRootEntries};
|
|
1
|
+
import{z}from"#compiled/zod/index.js";import{discoverDiagnosticsSummarySchema}from"#discover/diagnostics.js";import{compiledRemoteAgentNodeSchema}from"#compiler/remote-agent-node.js";import{jsonObjectSchema}from"#shared/json-schemas.js";const COMPILED_AGENT_MANIFEST_KIND=`eve-agent-compiled-manifest`,ROOT_COMPILED_AGENT_NODE_ID=`__root__`,COMPILED_AGENT_MANIFEST_VERSION=35,moduleSourceRefSchema=z.object({exportName:z.string().optional(),sourceKind:z.literal(`module`),logicalPath:z.string(),sourceId:z.string()}).strict(),compiledDynamicModelDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),sourceKind:z.literal(`module`),logicalPath:z.string(),sourceId:z.string()}).strict(),channelMethodSchema=z.union([z.literal(`GET`),z.literal(`POST`),z.literal(`PUT`),z.literal(`PATCH`),z.literal(`DELETE`),z.literal(`WEBSOCKET`)]),compiledChannelCorsSchema=z.object({origin:z.union([z.literal(`*`),z.literal(`null`),z.array(z.string())]).optional(),methods:z.union([z.literal(`*`),z.array(z.string())]).optional(),allowHeaders:z.union([z.literal(`*`),z.array(z.string())]).optional(),exposeHeaders:z.union([z.literal(`*`),z.array(z.string())]).optional(),credentials:z.boolean().optional(),maxAge:z.union([z.string(),z.literal(!1)]).optional(),preflight:z.object({statusCode:z.number().int().min(100).max(599).optional()}).strict().optional()}).strict(),compiledChannelDefinitionSchema=z.object({kind:z.literal(`channel`),name:z.string(),logicalPath:z.string(),method:channelMethodSchema,urlPath:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`),exportName:z.string().optional(),adapterKind:z.string().optional(),cors:compiledChannelCorsSchema.optional()}).strict(),disabledCompiledChannelEntrySchema=z.object({kind:z.literal(`disabled`),name:z.string(),logicalPath:z.string()}).strict(),compiledChannelEntrySchema=z.union([compiledChannelDefinitionSchema,disabledCompiledChannelEntrySchema]),modelRoutingSchema=z.union([z.object({kind:z.literal(`gateway`),target:z.string(),byok:z.string().optional()}).strict(),z.object({kind:z.literal(`external`),provider:z.string()}).strict()]),compiledRuntimeModelReferenceSchema=z.object({contextWindowTokens:z.number().int().positive().optional(),id:z.string(),source:moduleSourceRefSchema.optional(),providerOptions:z.record(z.string(),jsonObjectSchema).optional(),routing:modelRoutingSchema}).strict(),compiledAgentBuildDefinitionSchema=z.object({externalDependencies:z.array(z.string()).optional()}).strict(),compiledAgentWorkflowWorldDefinitionSchema=z.string(),compiledAgentWorkflowDefinitionSchema=z.object({world:compiledAgentWorkflowWorldDefinitionSchema.optional()}).strict(),compiledAgentCompactionDefinitionSchema=z.object({model:compiledRuntimeModelReferenceSchema.optional(),thresholdPercent:z.number().finite().min(0).max(1).optional()}).strict(),sessionTokenLimitSchema=z.union([z.number().int().positive(),z.literal(!1)]),compiledAgentLimitsDefinitionSchema=z.object({maxSubagentDepth:z.number().int().positive().optional(),maxSubagents:z.number().int().positive().optional(),maxInputTokensPerSession:sessionTokenLimitSchema.optional(),maxOutputTokensPerSession:sessionTokenLimitSchema.optional()}).strict(),compiledAgentConfigSchema=z.object({build:compiledAgentBuildDefinitionSchema.optional(),compaction:compiledAgentCompactionDefinitionSchema.optional(),description:z.string().optional(),dynamicModel:compiledDynamicModelDefinitionSchema.optional(),experimental:z.object({workflow:compiledAgentWorkflowDefinitionSchema.optional()}).strict().optional(),model:compiledRuntimeModelReferenceSchema,name:z.string(),outputSchema:jsonObjectSchema.optional(),reasoning:z.enum([`provider-default`,`none`,`minimal`,`low`,`medium`,`high`,`xhigh`]).optional(),source:moduleSourceRefSchema.optional(),limits:compiledAgentLimitsDefinitionSchema.optional()}).strict(),compiledInstructionsSchema=z.object({name:z.string(),logicalPath:z.string(),markdown:z.string(),sourceId:z.string(),sourceKind:z.union([z.literal(`markdown`),z.literal(`module`)])}).strict(),compiledSkillBaseFields={name:z.string(),description:z.string(),license:z.string().optional(),markdown:z.string(),metadata:z.record(z.string(),z.string()).optional(),sourceId:z.string(),logicalPath:z.string()},compiledSkillSourceSchema=z.discriminatedUnion(`sourceKind`,[z.object({...compiledSkillBaseFields,sourceKind:z.literal(`markdown`)}).strict(),z.object({...compiledSkillBaseFields,sourceKind:z.literal(`module`),exportName:z.string().optional()}).strict(),z.object({...compiledSkillBaseFields,sourceKind:z.literal(`skill-package`),skillId:z.string(),skillFilePath:z.string(),rootPath:z.string(),assetsPath:z.string().optional(),referencesPath:z.string().optional(),scriptsPath:z.string().optional()}).strict()]),compiledScheduleDefinitionSchema=z.object({cron:z.string(),hasRun:z.boolean(),name:z.string(),logicalPath:z.string(),markdown:z.string().optional(),sourceId:z.string(),sourceKind:z.union([z.literal(`markdown`),z.literal(`module`)])}).strict(),compiledSandboxDefinitionSchema=z.object({backendName:z.string().optional(),description:z.string().optional(),exportName:z.string().optional(),logicalPath:z.string(),revalidationKey:z.string().optional(),sourceHash:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledSandboxWorkspaceSchema=z.object({logicalPath:z.string(),rootEntries:z.array(z.string()).readonly(),sourceId:z.string(),sourcePath:z.string()}).strict(),compiledWorkspaceResourceRootSchema=z.object({contentHash:z.string().optional(),logicalPath:z.string(),rootEntries:z.array(z.string()).readonly()}).strict(),compiledConnectionDefinitionSchema=z.object({connectionName:z.string(),description:z.string(),exportName:z.string().optional(),logicalPath:z.string(),protocol:z.enum([`mcp`,`openapi`]).default(`mcp`),sourceId:z.string(),sourceKind:z.literal(`module`),url:z.string(),vercelConnect:z.object({connector:z.string()}).strict().optional()}).strict(),compiledToolDefinitionSchema=z.object({description:z.string(),exportName:z.string().optional(),inputSchema:jsonObjectSchema.nullable(),logicalPath:z.string(),name:z.string(),outputSchema:jsonObjectSchema.optional(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledDynamicToolDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),extensionNamespace:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledDynamicSkillDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),extensionNamespace:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledDynamicInstructionsDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledHookDefinitionSchema=z.object({exportName:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledAgentNodeManifestSchema=z.object({agentRoot:z.string(),appRoot:z.string(),channels:z.array(compiledChannelEntrySchema),config:compiledAgentConfigSchema,connections:z.array(compiledConnectionDefinitionSchema),diagnosticsSummary:discoverDiagnosticsSummarySchema,disabledFrameworkTools:z.array(z.string()).readonly(),workflowEnabled:z.boolean().default(!1),dynamicInstructions:z.array(compiledDynamicInstructionsDefinitionSchema).default([]),dynamicSkills:z.array(compiledDynamicSkillDefinitionSchema).default([]),dynamicTools:z.array(compiledDynamicToolDefinitionSchema).default([]),hooks:z.array(compiledHookDefinitionSchema),sandbox:compiledSandboxDefinitionSchema.nullable(),sandboxWorkspaces:z.array(compiledSandboxWorkspaceSchema),schedules:z.array(compiledScheduleDefinitionSchema),remoteAgents:z.array(compiledRemoteAgentNodeSchema),skills:z.array(compiledSkillSourceSchema).readonly(),instructions:compiledInstructionsSchema.optional(),tools:z.array(compiledToolDefinitionSchema),workspaceResourceRoot:compiledWorkspaceResourceRootSchema}).strict(),compiledSubagentNodeSchema=z.object({agent:compiledAgentNodeManifestSchema,description:z.string(),entryPath:z.string(),logicalPath:z.string(),name:z.string(),nodeId:z.string(),rootPath:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`),exportName:z.string().optional()}).strict(),compiledSubagentEdgeSchema=z.object({childNodeId:z.string(),parentNodeId:z.string()}).strict(),compiledExtensionMountSchema=z.object({namespace:z.string(),packageName:z.string(),packageNamespace:z.string(),sourceRoot:z.string(),mountSourceId:z.string(),mountLogicalPath:z.string()}).strict(),compiledAgentManifestSchema=z.object({agentRoot:z.string(),appRoot:z.string(),extensionMounts:z.array(compiledExtensionMountSchema).default([]),channels:z.array(compiledChannelEntrySchema),config:compiledAgentConfigSchema,connections:z.array(compiledConnectionDefinitionSchema),diagnosticsSummary:discoverDiagnosticsSummarySchema,disabledFrameworkTools:z.array(z.string()).readonly(),workflowEnabled:z.boolean().default(!1),dynamicInstructions:z.array(compiledDynamicInstructionsDefinitionSchema).default([]),dynamicSkills:z.array(compiledDynamicSkillDefinitionSchema).default([]),dynamicTools:z.array(compiledDynamicToolDefinitionSchema).default([]),hooks:z.array(compiledHookDefinitionSchema),kind:z.literal(COMPILED_AGENT_MANIFEST_KIND),remoteAgents:z.array(compiledRemoteAgentNodeSchema),sandbox:compiledSandboxDefinitionSchema.nullable(),sandboxWorkspaces:z.array(compiledSandboxWorkspaceSchema),schedules:z.array(compiledScheduleDefinitionSchema),skills:z.array(compiledSkillSourceSchema).readonly(),subagentEdges:z.array(compiledSubagentEdgeSchema),subagents:z.array(compiledSubagentNodeSchema),instructions:compiledInstructionsSchema.optional(),tools:z.array(compiledToolDefinitionSchema),version:z.literal(35),workspaceResourceRoot:compiledWorkspaceResourceRootSchema}).strict();function createCompiledAgentNodeManifest(e){let t={agentRoot:e.agentRoot,appRoot:e.appRoot,channels:[...e.channels??[]],connections:[...e.connections??[]],config:{build:e.config.build===void 0?void 0:{externalDependencies:e.config.build.externalDependencies===void 0?void 0:[...e.config.build.externalDependencies]},compaction:{model:e.config.compaction?.model===void 0?void 0:cloneCompiledRuntimeModelReference(e.config.compaction.model),thresholdPercent:e.config.compaction?.thresholdPercent},description:e.config.description,dynamicModel:e.config.dynamicModel===void 0?void 0:{...e.config.dynamicModel},experimental:e.config.experimental===void 0?void 0:{workflow:e.config.experimental.workflow===void 0?void 0:{world:e.config.experimental.workflow.world}},model:cloneCompiledRuntimeModelReference(e.config.model),name:e.config.name,outputSchema:e.config.outputSchema,reasoning:e.config.reasoning,limits:e.config.limits===void 0?void 0:{maxInputTokensPerSession:e.config.limits.maxInputTokensPerSession,maxOutputTokensPerSession:e.config.limits.maxOutputTokensPerSession,maxSubagentDepth:e.config.limits.maxSubagentDepth,maxSubagents:e.config.limits.maxSubagents},source:e.config.source===void 0?void 0:{...e.config.source}},diagnosticsSummary:e.diagnosticsSummary??{errors:0,warnings:0},disabledFrameworkTools:[...e.disabledFrameworkTools??[]],workflowEnabled:e.workflowEnabled??!1,dynamicInstructions:[...e.dynamicInstructions??[]],dynamicSkills:[...e.dynamicSkills??[]],dynamicTools:[...e.dynamicTools??[]],hooks:[...e.hooks??[]],remoteAgents:[...e.remoteAgents??[]],sandbox:e.sandbox??null,sandboxWorkspaces:[...e.sandboxWorkspaces??[]],schedules:[...e.schedules??[]],skills:[...e.skills??[]],tools:[...e.tools??[]],workspaceResourceRoot:e.workspaceResourceRoot??{logicalPath:``,rootEntries:deriveResourceRootEntries({sandboxWorkspaces:e.sandboxWorkspaces,skills:e.skills})}};return e.instructions!==void 0&&(t.instructions=e.instructions),t}function deriveResourceRootEntries(e){let t=new Set;for(let n of e.sandboxWorkspaces??[])for(let e of n.rootEntries)t.add(e);return[...t].sort((e,t)=>e.localeCompare(t))}function createCompiledSubagentNodeId(e,t){return e===`__root__`?t:`${e}::${t}`}function createCompiledAgentManifest(e){return{...createCompiledAgentNodeManifest(e),kind:COMPILED_AGENT_MANIFEST_KIND,extensionMounts:[...e.extensionMounts??[]],subagentEdges:[...e.subagentEdges??[]],subagents:[...e.subagents??[]],version:35}}function cloneCompiledRuntimeModelReference(e){let t={id:e.id,routing:cloneModelRouting(e.routing)};return e.contextWindowTokens!==void 0&&(t.contextWindowTokens=e.contextWindowTokens),e.providerOptions!==void 0&&(t.providerOptions={...e.providerOptions}),e.source!==void 0&&(t.source={...e.source}),t}function cloneModelRouting(e){return e.kind===`external`?{kind:`external`,provider:e.provider}:e.byok===void 0?{kind:`gateway`,target:e.target}:{kind:`gateway`,target:e.target,byok:e.byok}}export{COMPILED_AGENT_MANIFEST_KIND,COMPILED_AGENT_MANIFEST_VERSION,ROOT_COMPILED_AGENT_NODE_ID,compiledAgentManifestSchema,createCompiledAgentManifest,createCompiledAgentNodeManifest,createCompiledSubagentNodeId,deriveResourceRootEntries};
|