experimental-ash 0.61.0 → 0.63.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +72 -0
- package/dist/docs/public/advanced/hooks.mdx +8 -2
- package/dist/docs/public/advanced/runs-and-streaming.md +6 -3
- package/dist/docs/public/advanced/typescript-api.md +32 -0
- package/dist/docs/public/channels/custom.mdx +23 -0
- package/dist/docs/public/frontend/README.md +8 -4
- package/dist/docs/public/frontend/meta.json +9 -1
- package/dist/docs/public/frontend/nextjs.md +4 -4
- package/dist/docs/public/frontend/nuxt.md +168 -0
- package/dist/docs/public/frontend/sveltekit.md +177 -0
- package/dist/docs/public/frontend/use-ash-agent-svelte.md +185 -0
- package/dist/docs/public/frontend/use-ash-agent-vue.md +236 -0
- package/dist/docs/public/frontend/use-ash-agent.md +14 -14
- package/dist/docs/public/getting-started.mdx +2 -0
- package/dist/skills/ash-add-agent/SKILL.md +29 -17
- package/dist/skills/ash-add-next/SKILL.md +58 -8
- package/dist/src/channel/websocket-upgrade-server.d.ts +26 -0
- package/dist/src/channel/websocket-upgrade-server.js +1 -0
- package/dist/src/chunks/use-ash-agent-BQJLh7KU.js +1224 -0
- package/dist/src/chunks/use-ash-agent-CRWVA4i-.js +1192 -0
- package/dist/src/client/ash-agent-store.d.ts +61 -0
- package/dist/src/client/ash-agent-store.js +2 -0
- package/dist/src/client/index.d.ts +2 -0
- package/dist/src/client/index.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +9 -9
- package/dist/src/compiled/@ai-sdk/anthropic/_provider-utils.d.ts +1 -1
- package/dist/src/compiled/@ai-sdk/anthropic/index.d.ts +3 -3
- package/dist/src/compiled/@ai-sdk/anthropic/index.js +2 -2
- package/dist/src/compiled/@ai-sdk/google/index.d.ts +52 -2
- package/dist/src/compiled/@ai-sdk/google/index.js +6 -6
- package/dist/src/compiled/@ai-sdk/mcp/index.js +1 -1
- package/dist/src/compiled/@ai-sdk/openai/index.d.ts +32 -2
- package/dist/src/compiled/@ai-sdk/openai/index.js +2 -2
- package/dist/src/compiled/@ai-sdk/provider/index.d.ts +507 -1
- package/dist/src/compiled/@chat-adapter/slack/index.js +25 -25
- package/dist/src/compiled/@workflow/core/events-consumer.d.ts +8 -0
- package/dist/src/compiled/@workflow/core/index.js +2 -2
- package/dist/src/compiled/@workflow/core/runtime/constants.d.ts +1 -0
- package/dist/src/compiled/@workflow/core/runtime.js +29 -29
- package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/workflow.js +1 -1
- package/dist/src/compiled/@workflow/errors/error-codes.d.ts +2 -0
- package/dist/src/compiled/@workflow/errors/index.d.ts +14 -0
- package/dist/src/compiled/@workflow/errors/index.js +1 -1
- package/dist/src/compiled/@workflow/world/queue.d.ts +8 -0
- package/dist/src/compiled/_chunks/workflow/{dist-Chj-QcBs.js → dist-gEXVSMPU.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/dist-zpK2YVVA.js +3 -0
- package/dist/src/compiled/_chunks/workflow/resume-hook-BFK9mgsb.js +12 -0
- package/dist/src/compiled/_chunks/workflow/{sleep-Bg0t23kF.js → sleep-CeJckNg2.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{symbols-u476uwyR.js → symbols-BWCAoPHE.js} +1 -1
- package/dist/src/compiler/manifest.d.ts +12 -0
- package/dist/src/compiler/manifest.js +1 -1
- package/dist/src/compiler/normalize-connection.d.ts +10 -2
- package/dist/src/compiler/normalize-connection.js +1 -1
- package/dist/src/execution/sandbox/bindings/local.js +1 -1
- package/dist/src/execution/sandbox/bindings/vercel.js +1 -1
- package/dist/src/internal/application/package.d.ts +1 -0
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/authored-definition/connection.d.ts +9 -0
- package/dist/src/internal/authored-definition/connection.js +1 -1
- package/dist/src/internal/nitro/host/build-application.js +1 -1
- package/dist/src/internal/nitro/host/build-vercel-agent-summary.js +1 -1
- package/dist/src/internal/nitro/host/channel-routes.js +2 -2
- package/dist/src/internal/vercel-agent-summary.d.ts +6 -4
- package/dist/src/internal/workflow-bundle/ash-service-route-output.js +11 -1
- package/dist/src/packages/ash-scaffold/src/channels.js +1 -1
- package/dist/src/public/channels/auth.d.ts +1 -1
- package/dist/src/public/channels/index.d.ts +1 -0
- package/dist/src/public/channels/index.js +1 -1
- package/dist/src/public/connections/index.d.ts +3 -2
- package/dist/src/public/connections/index.js +1 -1
- package/dist/src/public/definitions/connections/mcp.d.ts +4 -12
- package/dist/src/public/definitions/connections/mcp.js +1 -1
- package/dist/src/public/definitions/connections/openapi.d.ts +100 -0
- package/dist/src/public/definitions/connections/openapi.js +1 -0
- package/dist/src/public/definitions/connections/protocol.d.ts +12 -0
- package/dist/src/public/definitions/connections/protocol.js +1 -0
- package/dist/src/public/next/index.d.ts +6 -6
- package/dist/src/public/next/index.js +1 -1
- package/dist/src/public/next/{vercel-json.d.ts → vercel-output-config.d.ts} +3 -3
- package/dist/src/public/next/vercel-output-config.js +1 -0
- package/dist/src/public/nuxt/dev-server.d.ts +24 -0
- package/dist/src/public/nuxt/dev-server.js +1 -0
- package/dist/src/public/nuxt/index.d.ts +1 -0
- package/dist/src/public/nuxt/index.js +1 -0
- package/dist/src/public/nuxt/module.d.ts +31 -0
- package/dist/src/public/nuxt/module.js +1 -0
- package/dist/src/public/nuxt/routing.d.ts +55 -0
- package/dist/src/public/nuxt/routing.js +1 -0
- package/dist/src/public/nuxt/vercel-json.d.ts +17 -0
- package/dist/src/public/{next → nuxt}/vercel-json.js +1 -1
- package/dist/src/public/sveltekit/dev-server.d.ts +24 -0
- package/dist/src/public/sveltekit/dev-server.js +1 -0
- package/dist/src/public/sveltekit/index.d.ts +39 -0
- package/dist/src/public/sveltekit/index.js +1 -0
- package/dist/src/public/sveltekit/routing.d.ts +32 -0
- package/dist/src/public/sveltekit/routing.js +1 -0
- package/dist/src/public/sveltekit/vercel-json.d.ts +17 -0
- package/dist/src/public/sveltekit/vercel-json.js +1 -0
- package/dist/src/react/use-ash-agent.d.ts +5 -27
- package/dist/src/react/use-ash-agent.js +1 -2
- package/dist/src/runtime/connections/openapi-client.d.ts +43 -0
- package/dist/src/runtime/connections/openapi-client.js +1 -0
- package/dist/src/runtime/connections/openapi-operations.d.ts +30 -0
- package/dist/src/runtime/connections/openapi-operations.js +1 -0
- package/dist/src/runtime/connections/openapi-schema.d.ts +39 -0
- package/dist/src/runtime/connections/openapi-schema.js +1 -0
- package/dist/src/runtime/connections/openapi-security.d.ts +41 -0
- package/dist/src/runtime/connections/openapi-security.js +1 -0
- package/dist/src/runtime/connections/openapi-spec.d.ts +20 -0
- package/dist/src/runtime/connections/openapi-spec.js +1 -0
- package/dist/src/runtime/connections/registry.d.ts +5 -7
- package/dist/src/runtime/connections/registry.js +1 -1
- package/dist/src/runtime/connections/types.d.ts +23 -0
- package/dist/src/runtime/resolve-connection.js +1 -1
- package/dist/src/runtime/types.d.ts +15 -1
- package/dist/src/shared/sandbox-session.d.ts +1 -1
- package/dist/src/shared/vercel-output-directory.d.ts +2 -0
- package/dist/src/shared/vercel-output-directory.js +1 -0
- package/dist/src/svelte/index.d.ts +3 -0
- package/dist/src/svelte/index.js +3 -0
- package/dist/src/svelte/use-ash-agent.d.ts +80 -0
- package/dist/src/svelte/use-ash-agent.js +3 -0
- package/dist/src/vue/index.d.ts +3 -0
- package/dist/src/vue/index.js +3 -0
- package/dist/src/vue/use-ash-agent.d.ts +78 -0
- package/dist/src/vue/use-ash-agent.js +3 -0
- package/package.json +59 -14
- package/dist/src/compiled/_chunks/workflow/dist-C4EHshZE.js +0 -3
- package/dist/src/compiled/_chunks/workflow/resume-hook-BlALLgSA.js +0 -12
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ResolvedConnectionDefinition } from "#runtime/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* How the connection's resolved credential is placed on a request,
|
|
4
|
+
* derived from the operation's effective `security` requirement and the
|
|
5
|
+
* document's `securitySchemes`.
|
|
6
|
+
*
|
|
7
|
+
* - `bearer` — `Authorization: Bearer <token>` (the default; also covers
|
|
8
|
+
* `oauth2` / `openIdConnect`, whose access tokens are bearer tokens).
|
|
9
|
+
* - `basic` — `Authorization: Basic <token>` (the author supplies the
|
|
10
|
+
* base64-encoded `user:pass` as the token).
|
|
11
|
+
* - `apiKey` — the token is placed in the named header, query param, or
|
|
12
|
+
* cookie instead of `Authorization`.
|
|
13
|
+
*/
|
|
14
|
+
export type SecurityPlacement = {
|
|
15
|
+
readonly kind: "bearer";
|
|
16
|
+
} | {
|
|
17
|
+
readonly kind: "basic";
|
|
18
|
+
} | {
|
|
19
|
+
readonly kind: "apiKey";
|
|
20
|
+
readonly in: "header" | "query" | "cookie";
|
|
21
|
+
readonly name: string;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Resolves how an operation's credential should be placed, from its
|
|
25
|
+
* effective `security` requirement (operation-level overrides the
|
|
26
|
+
* document-level default) and the document's `securitySchemes`.
|
|
27
|
+
*
|
|
28
|
+
* Returns `undefined` when no requirement applies, in which case the
|
|
29
|
+
* default `Authorization: Bearer` behavior is used. The first recognized
|
|
30
|
+
* scheme in the first requirement object wins.
|
|
31
|
+
*/
|
|
32
|
+
export declare function resolveSecurity(document: Record<string, unknown>, operation: Record<string, unknown>): SecurityPlacement | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Reshapes the resolved credential according to the operation's
|
|
35
|
+
* {@link SecurityPlacement}. The credential is resolved once by
|
|
36
|
+
* `resolveHeaders` as `Authorization: Bearer <token>`; this moves
|
|
37
|
+
* it where the scheme says (api-key header/query/cookie) or rewrites the
|
|
38
|
+
* `Authorization` scheme (basic). A `bearer` placement, a missing
|
|
39
|
+
* placement, or a connection without `authorization` is a no-op.
|
|
40
|
+
*/
|
|
41
|
+
export declare function applySecurity(placement: SecurityPlacement | undefined, connection: ResolvedConnectionDefinition, headers: Record<string, string>, query: URLSearchParams, cookies: string[]): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isObject}from"#shared/guards.js";import{deref,isArray}from"#runtime/connections/openapi-schema.js";function resolveSecurity(r,i){let a=isArray(i.security)?i.security:isArray(r.security)?r.security:void 0;if(a===void 0||a.length===0)return;let o=isObject(r.components)?r.components:void 0,s=o!==void 0&&isObject(o.securitySchemes)?o.securitySchemes:void 0;if(s!==void 0)for(let n of a){if(!isObject(n))continue;let i=Object.keys(n)[0];if(i===void 0)continue;let a=s[i],o=isObject(a)?deref(r,a):void 0;if(!isObject(o))continue;let c=mapSecurityScheme(o);if(c!==void 0)return c}}function mapSecurityScheme(e){if(e.type===`apiKey`){let t=e.in;return(t===`header`||t===`query`||t===`cookie`)&&typeof e.name==`string`&&e.name.length>0?{kind:`apiKey`,in:t,name:e.name}:void 0}if(e.type===`http`)return(typeof e.scheme==`string`?e.scheme.toLowerCase():``)===`basic`?{kind:`basic`}:{kind:`bearer`};if(e.type===`oauth2`||e.type===`openIdConnect`)return{kind:`bearer`}}function applySecurity(e,t,n,r,i){if(e===void 0||t.authorization===void 0)return;let a=extractBearerToken(n);if(a!==void 0&&e.kind!==`bearer`){if(e.kind===`basic`){n.Authorization=`Basic ${a}`;return}delete n.Authorization,e.in===`header`?n[e.name]=a:e.in===`query`?r.set(e.name,a):i.push(`${e.name}=${a}`)}}function extractBearerToken(e){let t=e.Authorization??e.authorization;return typeof t==`string`?/^Bearer\s+(.+)$/i.exec(t)?.[1]:void 0}export{applySecurity,resolveSecurity};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses a fetched spec body as either JSON or YAML.
|
|
3
|
+
*
|
|
4
|
+
* JSON is tried first (the common case and fastest path); on a parse
|
|
5
|
+
* failure the body is treated as YAML. YAML is parsed by wrapping the
|
|
6
|
+
* document in front-matter delimiters so the bundled `gray-matter`
|
|
7
|
+
* engine reads the whole file — the same approach the eval YAML loader
|
|
8
|
+
* uses, avoiding a second YAML dependency.
|
|
9
|
+
*/
|
|
10
|
+
export declare function parseSpecDocument(text: string): unknown;
|
|
11
|
+
/**
|
|
12
|
+
* Picks a base URL from an OpenAPI document's `servers` array.
|
|
13
|
+
*
|
|
14
|
+
* Returns the first server whose URL resolves to an absolute `http(s)`
|
|
15
|
+
* origin: `{var}` placeholders are substituted with each variable's
|
|
16
|
+
* `default`, and a relative URL (e.g. `/api/v3`) is resolved against
|
|
17
|
+
* `specSource` when the spec was supplied as a URL. Returns `undefined`
|
|
18
|
+
* when no entry yields an absolute URL.
|
|
19
|
+
*/
|
|
20
|
+
export declare function extractServerUrl(document: Record<string, unknown>, specSource: string | Record<string, unknown> | undefined): string | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isObject}from"#shared/guards.js";import matter from"#compiled/gray-matter/index.js";import{isArray}from"#runtime/connections/openapi-schema.js";function parseSpecDocument(e){try{return JSON.parse(e)}catch{}let n=e.replace(/^\uFEFF/,``);return matter(n.trimStart().startsWith(`---`)?n:`---\n${n}\n---`).data??{}}function extractServerUrl(t,r){let i=t.servers;if(isArray(i))for(let t of i){if(!isObject(t)||typeof t.url!=`string`||t.url.length===0)continue;let n=isObject(t.variables)?substituteServerVariables(t.url,t.variables):t.url;if(n.startsWith(`http://`)||n.startsWith(`https://`))return n;if(typeof r==`string`&&URL.canParse(r))try{return new URL(n,r).toString()}catch{}}}function substituteServerVariables(t,n){return t.replace(/\{([^}]+)\}/g,(t,r)=>{let i=n[r];return isObject(i)&&typeof i.default==`string`?i.default:t})}export{extractServerUrl,parseSpecDocument};
|
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
import type { NeedsApprovalContext } from "#public/definitions/tool.js";
|
|
2
2
|
import type { ResolvedConnectionDefinition } from "#runtime/types.js";
|
|
3
|
-
import {
|
|
4
|
-
import type { ConnectionRegistry } from "#runtime/connections/types.js";
|
|
3
|
+
import type { ConnectionClient, ConnectionRegistry } from "#runtime/connections/types.js";
|
|
5
4
|
/**
|
|
6
5
|
* Per-session container mapping connection names to lazily-initialized
|
|
7
6
|
* client wrappers.
|
|
8
7
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* protocols (e.g. OpenAPI) are supported.
|
|
8
|
+
* The registry is protocol-agnostic: it dispatches to the client
|
|
9
|
+
* implementation matching each connection's `protocol` (MCP or OpenAPI).
|
|
12
10
|
*/
|
|
13
11
|
export declare class ConnectionRegistryImpl implements ConnectionRegistry {
|
|
14
12
|
#private;
|
|
15
13
|
constructor(connections: readonly ResolvedConnectionDefinition[]);
|
|
16
14
|
/**
|
|
17
15
|
* Returns the client for the named connection, creating it on first
|
|
18
|
-
* access.
|
|
16
|
+
* access. The connection's `protocol` selects the client type.
|
|
19
17
|
*/
|
|
20
|
-
getClient(connectionName: string):
|
|
18
|
+
getClient(connectionName: string): ConnectionClient;
|
|
21
19
|
/**
|
|
22
20
|
* Returns the authored approval function for the named connection,
|
|
23
21
|
* or `undefined` if the connection did not specify one.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{McpConnectionClient}from"#runtime/connections/mcp-client.js";var ConnectionRegistryImpl=class{#e=new Map;#t;constructor(e){this.#t=e}getClient(
|
|
1
|
+
import{McpConnectionClient}from"#runtime/connections/mcp-client.js";import{OpenApiConnectionClient}from"#runtime/connections/openapi-client.js";var ConnectionRegistryImpl=class{#e=new Map;#t;constructor(e){this.#t=e}getClient(n){let r=this.#e.get(n);if(r!==void 0)return r;let i=this.#t.find(e=>e.connectionName===n);if(i===void 0)throw Error(`Connection "${n}" is not registered.`);let a=i.protocol===`openapi`?new OpenApiConnectionClient(i):new McpConnectionClient(i);return this.#e.set(n,a),a}getConnectionApproval(e){return this.#t.find(t=>t.connectionName===e)?.approval}getConnectionNames(){return this.#t.map(e=>e.connectionName)}getConnections(){return this.#t}async dispose(){let e=[...this.#e.values()].map(e=>e.close());await Promise.allSettled(e),this.#e.clear()}};export{ConnectionRegistryImpl};
|
|
@@ -25,6 +25,16 @@ export interface TokenResult {
|
|
|
25
25
|
readonly token: string;
|
|
26
26
|
readonly expiresAt?: number;
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Wire protocol a connection speaks.
|
|
30
|
+
*
|
|
31
|
+
* Stamped onto a connection definition by the `define*` factory that
|
|
32
|
+
* produced it (`defineMcpClientConnection` → `"mcp"`,
|
|
33
|
+
* `defineOpenAPIConnection` → `"openapi"`) and carried through the
|
|
34
|
+
* compiled manifest so the runtime registry can pick the matching
|
|
35
|
+
* client implementation. Never authored directly.
|
|
36
|
+
*/
|
|
37
|
+
export type ConnectionProtocol = "mcp" | "openapi";
|
|
28
38
|
/** A single header value, supporting static strings and dynamic resolution. */
|
|
29
39
|
export type HeaderValue = string | Promise<string> | (() => string | Promise<string>);
|
|
30
40
|
/**
|
|
@@ -123,6 +133,19 @@ export interface ConnectionAuthorizationContext {
|
|
|
123
133
|
* JSON-serializable.
|
|
124
134
|
*/
|
|
125
135
|
export type AuthorizationDefinition<State extends JsonValue = JsonValue> = NonInteractiveAuthorizationDefinition | InteractiveAuthorizationDefinition<State>;
|
|
136
|
+
/**
|
|
137
|
+
* Protocol-agnostic `auth` shape accepted by every connection
|
|
138
|
+
* `define*` factory (`defineMcpClientConnection`,
|
|
139
|
+
* `defineOpenAPIConnection`, …).
|
|
140
|
+
*
|
|
141
|
+
* Identical to {@link AuthorizationDefinition} except the
|
|
142
|
+
* non-interactive form may omit `principalType`; normalization
|
|
143
|
+
* defaults it to `"app"`. The resolved token is sent as
|
|
144
|
+
* `Authorization: Bearer <token>`.
|
|
145
|
+
*/
|
|
146
|
+
export type ConnectionAuthDefinition = (Omit<NonInteractiveAuthorizationDefinition, "principalType"> & {
|
|
147
|
+
readonly principalType?: NonInteractiveAuthorizationDefinition["principalType"];
|
|
148
|
+
}) | AuthorizationDefinition;
|
|
126
149
|
/**
|
|
127
150
|
* Fields shared by every {@link AuthorizationDefinition} shape.
|
|
128
151
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{expectObjectRecord}from"#internal/authored-module.js";import{toErrorMessage}from"#shared/errors.js";import{normalizeAuthorizationSpec}from"#runtime/connections/validate-authorization.js";import{ResolveAgentError,loadResolvedModuleExport}from"#runtime/resolve-helpers.js";import{registerDefinitionSource,stampDefinitionKey}from"#public/tool-result-narrowing.js";async function resolveConnectionDefinition(t,n,r){try{let i=expectObjectRecord(await loadResolvedModuleExport({definition:t,kindLabel:`connection`,moduleMap:n,nodeId:r}),`Expected the connection export "${t.exportName??`default`}" from "${t.logicalPath}" to return an object.`),a={kind:`connection`,logicalPath:t.logicalPath,name:t.connectionName},o=`connection-source:${t.sourceId}`;stampDefinitionKey(i,o),registerDefinitionSource(o,a),registerDefinitionSource(`connection:${
|
|
1
|
+
import{expectObjectRecord}from"#internal/authored-module.js";import{toErrorMessage}from"#shared/errors.js";import{normalizeAuthorizationSpec}from"#runtime/connections/validate-authorization.js";import{ResolveAgentError,loadResolvedModuleExport}from"#runtime/resolve-helpers.js";import{registerDefinitionSource,stampDefinitionKey}from"#public/tool-result-narrowing.js";async function resolveConnectionDefinition(t,n,r){try{let i=expectObjectRecord(await loadResolvedModuleExport({definition:t,kindLabel:`connection`,moduleMap:n,nodeId:r}),`Expected the connection export "${t.exportName??`default`}" from "${t.logicalPath}" to return an object.`),a={kind:`connection`,logicalPath:t.logicalPath,name:t.connectionName},o=`connection-source:${t.sourceId}`;stampDefinitionKey(i,o),registerDefinitionSource(o,a),registerDefinitionSource(`connection:${t.url}`,a);let s=i.auth!==void 0,c=i.headers!==void 0,l=t.protocol===`openapi`?i.operations:i.tools,u={connectionName:t.connectionName,description:t.description,exportName:t.exportName,logicalPath:t.logicalPath,protocol:t.protocol,sourceId:t.sourceId,sourceKind:`module`,url:t.url};if(s)try{u.authorization=normalizeAuthorizationSpec(i.auth,`Connection "${t.connectionName}" at "${t.logicalPath}":`)}catch(e){throw new ResolveAgentError(toErrorMessage(e),{logicalPath:t.logicalPath,sourceId:t.sourceId})}return c&&(u.headers=i.headers),l!==void 0&&(u.tools=l),t.protocol===`openapi`&&i.spec!==void 0&&(u.spec=i.spec),typeof i.approval==`function`&&(u.approval=i.approval),u}catch(e){throw e instanceof ResolveAgentError?e:new ResolveAgentError(`Failed to resolve connection "${t.connectionName}" from "${t.logicalPath}": ${toErrorMessage(e)}`,{logicalPath:t.logicalPath,sourceId:t.sourceId})}}export{resolveConnectionDefinition};
|
|
@@ -8,7 +8,8 @@ import type { RouteHandler, WebSocketRouteHandler } from "#channel/routes.js";
|
|
|
8
8
|
import type { OutboundAuthFn } from "#public/agents/auth.js";
|
|
9
9
|
import type { StreamEventHook } from "#public/definitions/hook.js";
|
|
10
10
|
import type { CompactionInput, CompactionHookResult, NeedsApprovalContext, ToolModelOutput } from "#public/definitions/tool.js";
|
|
11
|
-
import type { AuthorizationDefinition, HeadersDefinition, ToolFilterDefinition } from "#runtime/connections/types.js";
|
|
11
|
+
import type { AuthorizationDefinition, ConnectionProtocol, HeadersDefinition, ToolFilterDefinition } from "#runtime/connections/types.js";
|
|
12
|
+
import type { OpenAPISpecSource } from "#public/definitions/connections/openapi.js";
|
|
12
13
|
import type { CompiledWorkspaceResourceRoot } from "#compiler/manifest.js";
|
|
13
14
|
import type { WorkspaceRuntimeSpec } from "#runtime/workspace/types.js";
|
|
14
15
|
import type { JsonObject } from "#shared/json.js";
|
|
@@ -72,6 +73,19 @@ export interface ResolvedConnectionDefinition extends ResolvedModuleSourceRef {
|
|
|
72
73
|
readonly connectionName: string;
|
|
73
74
|
readonly description: string;
|
|
74
75
|
readonly headers?: Readonly<HeadersDefinition>;
|
|
76
|
+
/**
|
|
77
|
+
* Wire protocol. Selects the runtime client implementation. `tools`
|
|
78
|
+
* carries the connection's operation/tool filter regardless of
|
|
79
|
+
* protocol (sourced from `tools` on MCP connections, `operations` on
|
|
80
|
+
* OpenAPI connections).
|
|
81
|
+
*/
|
|
82
|
+
readonly protocol: ConnectionProtocol;
|
|
83
|
+
/**
|
|
84
|
+
* OpenAPI document source (URL or inline object). Present only for
|
|
85
|
+
* `protocol: "openapi"` connections; the OpenAPI client fetches and
|
|
86
|
+
* parses it on first use.
|
|
87
|
+
*/
|
|
88
|
+
readonly spec?: OpenAPISpecSource;
|
|
75
89
|
readonly tools?: Readonly<ToolFilterDefinition>;
|
|
76
90
|
readonly url: string;
|
|
77
91
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Experimental_SandboxSession as AiSdkSandbox } from "ai";
|
|
2
2
|
import type { SandboxNetworkPolicy } from "#shared/sandbox-network-policy.js";
|
|
3
3
|
/**
|
|
4
4
|
* Options for running one command in a sandbox. Shape mirrors the AI
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{dirname,join}from"node:path";import{stat}from"node:fs/promises";async function fileExists(e){try{return(await stat(e)).isFile()}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return!1;throw e}}async function findClosestDirectoryWithFile(t){let n=t.start;for(;;){let r=join(n,t.directoryName);if(await fileExists(join(r,t.fileName)))return r;let i=dirname(n);if(i===n)return;n=i}}async function findClosestLinkedVercelDirectory(e){return findClosestDirectoryWithFile({start:e,directoryName:`.vercel`,fileName:`project.json`})}async function findClosestVercelOutputDirectory(e){return findClosestDirectoryWithFile({start:e,directoryName:`output`,fileName:`builds.json`})}export{findClosestLinkedVercelDirectory,findClosestVercelOutputDirectory};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { useAshAgent, type PrepareSend, type UseAshAgentOptions, type UseAshAgentReturn, type UseAshAgentSnapshot, type UseAshAgentStatus, } from "#svelte/use-ash-agent.js";
|
|
2
|
+
export { type AshAgentReducer, type AshAgentReducerEvent, type ClientInputRespondedEvent, type ClientMessageFailedEvent, type ClientMessageSubmittedEvent, } from "#client/reducer.js";
|
|
3
|
+
export { defaultMessageReducer, type AshMessageData, type AshDynamicToolPart, type AshMessageInputRequest, type AshMessage, type AshMessageMetadata, type AshMessagePart, type AshMessageToolMetadata, } from "#client/message-reducer.js";
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { type AshAgentStoreCallbacks, type AshAgentStoreSnapshot, type AshAgentStoreStatus, type PrepareSend } from "#client/ash-agent-store.js";
|
|
2
|
+
import { type AshMessageData } from "#client/message-reducer.js";
|
|
3
|
+
import type { AshAgentReducer } from "#client/reducer.js";
|
|
4
|
+
import type { ClientSession } from "#client/session.js";
|
|
5
|
+
import type { ClientAuth, HeadersValue, SendMessageOptions, SendTurnInput, SessionState } from "#client/types.js";
|
|
6
|
+
import type { HandleMessageStreamEvent } from "#protocol/message.js";
|
|
7
|
+
export type { PrepareSend };
|
|
8
|
+
export type UseAshAgentStatus = AshAgentStoreStatus;
|
|
9
|
+
export type UseAshAgentSnapshot<TData> = AshAgentStoreSnapshot<TData>;
|
|
10
|
+
/**
|
|
11
|
+
* Reactive return value from `useAshAgent`.
|
|
12
|
+
*
|
|
13
|
+
* The state properties are Svelte 5 rune-friendly getters. Read them from a
|
|
14
|
+
* template, `$derived`, or `$effect` and Svelte will update when Ash streams
|
|
15
|
+
* new events.
|
|
16
|
+
*/
|
|
17
|
+
export interface UseAshAgentReturn<TData> {
|
|
18
|
+
/** Projected state built by reducing every stream event through the reducer. */
|
|
19
|
+
readonly data: TData;
|
|
20
|
+
/** Last transport-level error, or `undefined` when healthy. */
|
|
21
|
+
readonly error: Error | undefined;
|
|
22
|
+
/** Raw server events received during this session (authoritative stream). */
|
|
23
|
+
readonly events: readonly HandleMessageStreamEvent[];
|
|
24
|
+
/** Clear all state and start a new session. */
|
|
25
|
+
readonly reset: () => void;
|
|
26
|
+
/** Send a turn with full structured input (message, attachments, input responses). */
|
|
27
|
+
readonly send: (input: SendTurnInput, options?: SendMessageOptions) => Promise<void>;
|
|
28
|
+
/** Shorthand: send a plain text message. */
|
|
29
|
+
readonly sendMessage: (message: string, options?: SendMessageOptions) => Promise<void>;
|
|
30
|
+
/** Current session identity and stream cursor. */
|
|
31
|
+
readonly session: SessionState;
|
|
32
|
+
/** Lifecycle phase: `"ready"` (idle), `"submitted"` (request sent, awaiting first event), `"streaming"` (events arriving), or `"error"`. */
|
|
33
|
+
readonly status: UseAshAgentStatus;
|
|
34
|
+
/** Abort the in-flight request. */
|
|
35
|
+
readonly stop: () => void;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Configuration for creating or binding a Svelte Ash agent session.
|
|
39
|
+
*
|
|
40
|
+
* Session configuration is read once when `useAshAgent` creates its internal
|
|
41
|
+
* store. To point the binding at a different host, reducer, or session, create
|
|
42
|
+
* a new binding instance. Lifecycle callbacks are installed on creation.
|
|
43
|
+
*
|
|
44
|
+
* For credentials or headers that must change without recreating the binding,
|
|
45
|
+
* pass function values to `auth` or `headers`; the underlying client resolves
|
|
46
|
+
* those before each HTTP request.
|
|
47
|
+
*/
|
|
48
|
+
export interface UseAshAgentOptions<TData> extends AshAgentStoreCallbacks<TData> {
|
|
49
|
+
readonly auth?: ClientAuth;
|
|
50
|
+
readonly headers?: HeadersValue;
|
|
51
|
+
/**
|
|
52
|
+
* Base URL used for Ash client requests.
|
|
53
|
+
*
|
|
54
|
+
* By default, requests target same-origin Ash routes such as `/ash/v1/...`.
|
|
55
|
+
* Pass a same-origin prefix such as `/api` to use an app-owned proxy, or an
|
|
56
|
+
* absolute origin to talk to an Ash server directly.
|
|
57
|
+
*
|
|
58
|
+
* @default ""
|
|
59
|
+
*/
|
|
60
|
+
readonly host?: string;
|
|
61
|
+
readonly initialEvents?: readonly HandleMessageStreamEvent[];
|
|
62
|
+
readonly initialSession?: SessionState;
|
|
63
|
+
readonly maxReconnectAttempts?: number;
|
|
64
|
+
/**
|
|
65
|
+
* Project submitted user messages before Ash confirms them with a
|
|
66
|
+
* `message.received` stream event.
|
|
67
|
+
*
|
|
68
|
+
* Optimistic events are reducer-facing projection events only. They are not
|
|
69
|
+
* exposed through `events`, which remains the authoritative Ash stream.
|
|
70
|
+
*
|
|
71
|
+
* @default true
|
|
72
|
+
*/
|
|
73
|
+
readonly optimistic?: boolean;
|
|
74
|
+
readonly reducer?: AshAgentReducer<TData>;
|
|
75
|
+
readonly session?: ClientSession;
|
|
76
|
+
}
|
|
77
|
+
export declare function useAshAgent(options?: UseAshAgentOptions<AshMessageData>): UseAshAgentReturn<AshMessageData>;
|
|
78
|
+
export declare function useAshAgent<TData>(options: UseAshAgentOptions<TData> & {
|
|
79
|
+
readonly reducer: AshAgentReducer<TData>;
|
|
80
|
+
}): UseAshAgentReturn<TData>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { useAshAgent, type PrepareSend, type UseAshAgentOptions, type UseAshAgentReturn, type UseAshAgentSnapshot, type UseAshAgentStatus, } from "#vue/use-ash-agent.js";
|
|
2
|
+
export { type AshAgentReducer, type AshAgentReducerEvent, type ClientInputRespondedEvent, type ClientMessageFailedEvent, type ClientMessageSubmittedEvent, } from "#client/reducer.js";
|
|
3
|
+
export { defaultMessageReducer, type AshMessageData, type AshDynamicToolPart, type AshMessageInputRequest, type AshMessage, type AshMessageMetadata, type AshMessagePart, type AshMessageToolMetadata, } from "#client/message-reducer.js";
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { type ComputedRef } from "vue";
|
|
2
|
+
import { type AshAgentStoreCallbacks, type AshAgentStoreSnapshot, type AshAgentStoreStatus, type PrepareSend } from "#client/ash-agent-store.js";
|
|
3
|
+
import type { AshAgentReducer } from "#client/reducer.js";
|
|
4
|
+
import type { ClientSession } from "#client/session.js";
|
|
5
|
+
import { type AshMessageData } from "#client/message-reducer.js";
|
|
6
|
+
import type { HandleMessageStreamEvent } from "#protocol/message.js";
|
|
7
|
+
import type { ClientAuth, HeadersValue, SendMessageOptions, SendTurnInput, SessionState } from "#client/types.js";
|
|
8
|
+
export type { PrepareSend };
|
|
9
|
+
export type UseAshAgentStatus = AshAgentStoreStatus;
|
|
10
|
+
export type UseAshAgentSnapshot<TData> = AshAgentStoreSnapshot<TData>;
|
|
11
|
+
/**
|
|
12
|
+
* Reactive return value from `useAshAgent`.
|
|
13
|
+
*/
|
|
14
|
+
export interface UseAshAgentReturn<TData> {
|
|
15
|
+
/** Projected state built by reducing every stream event through the reducer. */
|
|
16
|
+
readonly data: ComputedRef<TData>;
|
|
17
|
+
/** Last transport-level error, or `undefined` when healthy. */
|
|
18
|
+
readonly error: ComputedRef<Error | undefined>;
|
|
19
|
+
/** Raw server events received during this session (authoritative stream). */
|
|
20
|
+
readonly events: ComputedRef<readonly HandleMessageStreamEvent[]>;
|
|
21
|
+
/** Clear all state and start a new session. */
|
|
22
|
+
readonly reset: () => void;
|
|
23
|
+
/** Send a turn with full structured input (message, attachments, input responses). */
|
|
24
|
+
readonly send: (input: SendTurnInput, options?: SendMessageOptions) => Promise<void>;
|
|
25
|
+
/** Shorthand: send a plain text message. */
|
|
26
|
+
readonly sendMessage: (message: string, options?: SendMessageOptions) => Promise<void>;
|
|
27
|
+
/** Current session identity and stream cursor. */
|
|
28
|
+
readonly session: ComputedRef<SessionState>;
|
|
29
|
+
/** Lifecycle phase: `"ready"` (idle), `"submitted"` (request sent, awaiting first event), `"streaming"` (events arriving), or `"error"`. */
|
|
30
|
+
readonly status: ComputedRef<UseAshAgentStatus>;
|
|
31
|
+
/** Abort the in-flight request. */
|
|
32
|
+
readonly stop: () => void;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Configuration for creating or binding a Vue Ash agent session.
|
|
36
|
+
*
|
|
37
|
+
* Session configuration is read once when the composable creates its internal
|
|
38
|
+
* store. To point the composable at a different host, reducer, or session,
|
|
39
|
+
* unmount and remount the component that calls it. Lifecycle callbacks are
|
|
40
|
+
* synced on every call to `setCallbacks`.
|
|
41
|
+
*
|
|
42
|
+
* For credentials or headers that must change without remounting, pass function
|
|
43
|
+
* values to `auth` or `headers`; the underlying client resolves those before
|
|
44
|
+
* each HTTP request.
|
|
45
|
+
*/
|
|
46
|
+
export interface UseAshAgentOptions<TData> extends AshAgentStoreCallbacks<TData> {
|
|
47
|
+
readonly auth?: ClientAuth;
|
|
48
|
+
readonly headers?: HeadersValue;
|
|
49
|
+
/**
|
|
50
|
+
* Base URL used for Ash client requests.
|
|
51
|
+
*
|
|
52
|
+
* By default, requests target same-origin Ash routes such as `/ash/v1/...`.
|
|
53
|
+
* Pass a same-origin prefix such as `/api` to use an app-owned proxy, or an
|
|
54
|
+
* absolute origin to talk to an Ash server directly.
|
|
55
|
+
*
|
|
56
|
+
* @default ""
|
|
57
|
+
*/
|
|
58
|
+
readonly host?: string;
|
|
59
|
+
readonly initialEvents?: readonly HandleMessageStreamEvent[];
|
|
60
|
+
readonly initialSession?: SessionState;
|
|
61
|
+
readonly maxReconnectAttempts?: number;
|
|
62
|
+
/**
|
|
63
|
+
* Project submitted user messages before Ash confirms them with a
|
|
64
|
+
* `message.received` stream event.
|
|
65
|
+
*
|
|
66
|
+
* Optimistic events are reducer-facing projection events only. They are not
|
|
67
|
+
* exposed through `events`, which remains the authoritative Ash stream.
|
|
68
|
+
*
|
|
69
|
+
* @default true
|
|
70
|
+
*/
|
|
71
|
+
readonly optimistic?: boolean;
|
|
72
|
+
readonly reducer?: AshAgentReducer<TData>;
|
|
73
|
+
readonly session?: ClientSession;
|
|
74
|
+
}
|
|
75
|
+
export declare function useAshAgent(options?: UseAshAgentOptions<AshMessageData>): UseAshAgentReturn<AshMessageData>;
|
|
76
|
+
export declare function useAshAgent<TData>(options: UseAshAgentOptions<TData> & {
|
|
77
|
+
readonly reducer: AshAgentReducer<TData>;
|
|
78
|
+
}): UseAshAgentReturn<TData>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "experimental-ash",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.63.0",
|
|
4
4
|
"description": "Filesystem-first framework for durable backend AI agents that run anywhere.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent-framework",
|
|
@@ -60,11 +60,31 @@
|
|
|
60
60
|
"import": "./dist/src/react/index.js",
|
|
61
61
|
"default": "./dist/src/react/index.js"
|
|
62
62
|
},
|
|
63
|
+
"./vue": {
|
|
64
|
+
"types": "./dist/src/vue/index.d.ts",
|
|
65
|
+
"import": "./dist/src/vue/index.js",
|
|
66
|
+
"default": "./dist/src/vue/index.js"
|
|
67
|
+
},
|
|
68
|
+
"./svelte": {
|
|
69
|
+
"types": "./dist/src/svelte/index.d.ts",
|
|
70
|
+
"import": "./dist/src/svelte/index.js",
|
|
71
|
+
"default": "./dist/src/svelte/index.js"
|
|
72
|
+
},
|
|
63
73
|
"./next": {
|
|
64
74
|
"types": "./dist/src/public/next/index.d.ts",
|
|
65
75
|
"import": "./dist/src/public/next/index.js",
|
|
66
76
|
"default": "./dist/src/public/next/index.js"
|
|
67
77
|
},
|
|
78
|
+
"./nuxt": {
|
|
79
|
+
"types": "./dist/src/public/nuxt/index.d.ts",
|
|
80
|
+
"import": "./dist/src/public/nuxt/index.js",
|
|
81
|
+
"default": "./dist/src/public/nuxt/index.js"
|
|
82
|
+
},
|
|
83
|
+
"./sveltekit": {
|
|
84
|
+
"types": "./dist/src/public/sveltekit/index.d.ts",
|
|
85
|
+
"import": "./dist/src/public/sveltekit/index.js",
|
|
86
|
+
"default": "./dist/src/public/sveltekit/index.js"
|
|
87
|
+
},
|
|
68
88
|
"./tools/approval": {
|
|
69
89
|
"types": "./dist/src/public/tools/approval/index.d.ts",
|
|
70
90
|
"import": "./dist/src/public/tools/approval/index.js",
|
|
@@ -204,25 +224,27 @@
|
|
|
204
224
|
"nitro": "3.0.260522-beta"
|
|
205
225
|
},
|
|
206
226
|
"devDependencies": {
|
|
207
|
-
"@ai-sdk/anthropic": "4.0.0-canary.
|
|
208
|
-
"@ai-sdk/google": "4.0.0-canary.
|
|
209
|
-
"@ai-sdk/mcp": "2.0.0-canary.
|
|
210
|
-
"@ai-sdk/openai": "4.0.0-canary.
|
|
211
|
-
"@ai-sdk/otel": "1.0.0-canary.
|
|
212
|
-
"@ai-sdk/provider": "4.0.0-canary.
|
|
227
|
+
"@ai-sdk/anthropic": "4.0.0-canary.63",
|
|
228
|
+
"@ai-sdk/google": "4.0.0-canary.79",
|
|
229
|
+
"@ai-sdk/mcp": "2.0.0-canary.59",
|
|
230
|
+
"@ai-sdk/openai": "4.0.0-canary.69",
|
|
231
|
+
"@ai-sdk/otel": "1.0.0-canary.111",
|
|
232
|
+
"@ai-sdk/provider": "4.0.0-canary.18",
|
|
213
233
|
"@chat-adapter/slack": "4.29.0",
|
|
214
234
|
"@chat-adapter/state-memory": "4.29.0",
|
|
235
|
+
"@nuxt/kit": "^4.0.0",
|
|
215
236
|
"@standard-schema/spec": "1.1.0",
|
|
237
|
+
"@sveltejs/kit": "^2.0.0",
|
|
216
238
|
"@types/json-schema": "7.0.15",
|
|
217
239
|
"@types/react": "19.2.15",
|
|
218
240
|
"@types/react-test-renderer": "19.1.0",
|
|
219
241
|
"@vercel/oidc": "3.5.0",
|
|
220
242
|
"@vercel/sandbox": "2.1.0",
|
|
221
|
-
"@workflow/core": "5.0.0-beta.
|
|
222
|
-
"@workflow/errors": "5.0.0-beta.
|
|
223
|
-
"@workflow/world": "5.0.0-beta.
|
|
224
|
-
"@workflow/world-local": "5.0.0-beta.
|
|
225
|
-
"ai": "7.0.0-canary.
|
|
243
|
+
"@workflow/core": "5.0.0-beta.12",
|
|
244
|
+
"@workflow/errors": "5.0.0-beta.7",
|
|
245
|
+
"@workflow/world": "5.0.0-beta.7",
|
|
246
|
+
"@workflow/world-local": "5.0.0-beta.13",
|
|
247
|
+
"ai": "7.0.0-canary.165",
|
|
226
248
|
"autoevals": "0.0.132",
|
|
227
249
|
"chat": "4.29.0",
|
|
228
250
|
"chokidar": "5.0.0",
|
|
@@ -236,30 +258,53 @@
|
|
|
236
258
|
"picocolors": "1.1.1",
|
|
237
259
|
"react": "19.2.6",
|
|
238
260
|
"react-test-renderer": "19.2.6",
|
|
261
|
+
"svelte": "^5.0.0",
|
|
239
262
|
"turndown": "7.2.4",
|
|
263
|
+
"vite": "^8.0.0",
|
|
264
|
+
"vue": "^3.5.0",
|
|
240
265
|
"zod": "4.4.3",
|
|
241
266
|
"zod-validation-error": "5.0.0",
|
|
242
267
|
"@vercel/ash-scaffold": "0.0.0"
|
|
243
268
|
},
|
|
244
269
|
"peerDependencies": {
|
|
245
270
|
"@opentelemetry/api": "^1.0.0",
|
|
246
|
-
"
|
|
271
|
+
"@sveltejs/kit": "^2.0.0",
|
|
272
|
+
"ai": "7.0.0-canary.165",
|
|
247
273
|
"braintrust": "^3.0.0",
|
|
248
274
|
"next": "^16.0.0",
|
|
249
|
-
"
|
|
275
|
+
"nuxt": "^4.0.0",
|
|
276
|
+
"react": "^19.0.0",
|
|
277
|
+
"svelte": "^5.0.0",
|
|
278
|
+
"vite": "^8.0.0",
|
|
279
|
+
"vue": "^3.5.0"
|
|
250
280
|
},
|
|
251
281
|
"peerDependenciesMeta": {
|
|
252
282
|
"@opentelemetry/api": {
|
|
253
283
|
"optional": true
|
|
254
284
|
},
|
|
285
|
+
"@sveltejs/kit": {
|
|
286
|
+
"optional": true
|
|
287
|
+
},
|
|
255
288
|
"braintrust": {
|
|
256
289
|
"optional": true
|
|
257
290
|
},
|
|
258
291
|
"next": {
|
|
259
292
|
"optional": true
|
|
260
293
|
},
|
|
294
|
+
"nuxt": {
|
|
295
|
+
"optional": true
|
|
296
|
+
},
|
|
261
297
|
"react": {
|
|
262
298
|
"optional": true
|
|
299
|
+
},
|
|
300
|
+
"svelte": {
|
|
301
|
+
"optional": true
|
|
302
|
+
},
|
|
303
|
+
"vite": {
|
|
304
|
+
"optional": true
|
|
305
|
+
},
|
|
306
|
+
"vue": {
|
|
307
|
+
"optional": true
|
|
263
308
|
}
|
|
264
309
|
},
|
|
265
310
|
"engines": {
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{i as e,t}from"./chunk-DSjMdhoD.js";function n(e,t,n){return n===1?e:t}function r(e,t){if(typeof t!=`string`)return null;let[n,r,...i]=t.split(`//`);if(n!==e||!r||i.length===0)return null;let a=i.join(`//`),o=a.split(`/`).at(-1)??``,s=``;return s=r.startsWith(`./`)?r.split(`/`).at(-1)??``:(r.split(`@`).slice(0,-1).join(`@`)||r.split(`@`)[0])?.split(`/`).at(-1)??``,[`default`,`__default`].includes(o)&&s&&(o=s),{shortName:o,moduleSpecifier:r,functionName:a}}function i(e){return r(`workflow`,e)}function a(e){return r(`step`,e)}function o(e){return c(a(e),e)}function s(e){return c(i(e),e)}function c(e,t){return e?`${e.shortName} (${e.moduleSpecifier})`:t}function l(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function u(e){let t={get value(){let n=e();return Object.defineProperty(t,"value",{value:n}),n}};return t}var d=e(t(((e,t)=>{var n=1e3,r=n*60,i=r*60,a=i*24,o=a*7,s=a*365.25;t.exports=function(e,t){t||={};var n=typeof e;if(n===`string`&&e.length>0)return c(e);if(n===`number`&&isFinite(e))return t.long?u(e):l(e);throw Error(`val is not a non-empty string or a valid number. val=`+JSON.stringify(e))};function c(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var c=parseFloat(t[1]);switch((t[2]||`ms`).toLowerCase()){case`years`:case`year`:case`yrs`:case`yr`:case`y`:return c*s;case`weeks`:case`week`:case`w`:return c*o;case`days`:case`day`:case`d`:return c*a;case`hours`:case`hour`:case`hrs`:case`hr`:case`h`:return c*i;case`minutes`:case`minute`:case`mins`:case`min`:case`m`:return c*r;case`seconds`:case`second`:case`secs`:case`sec`:case`s`:return c*n;case`milliseconds`:case`millisecond`:case`msecs`:case`msec`:case`ms`:return c;default:return}}}}function l(e){var t=Math.abs(e);return t>=a?Math.round(e/a)+`d`:t>=i?Math.round(e/i)+`h`:t>=r?Math.round(e/r)+`m`:t>=n?Math.round(e/n)+`s`:e+`ms`}function u(e){var t=Math.abs(e);return t>=a?d(e,t,a,`day`):t>=i?d(e,t,i,`hour`):t>=r?d(e,t,r,`minute`):t>=n?d(e,t,n,`second`):e+` ms`}function d(e,t,n,r){var i=t>=n*1.5;return Math.round(e/n)+` `+r+(i?`s`:``)}}))(),1);function f(e){if(typeof e==`string`){let t=(0,d.default)(e);if(typeof t!=`number`||t<0)throw Error(`Invalid duration: "${e}". Expected a valid duration string like "1s", "1m", "1h", etc.`);return new Date(Date.now()+t)}else if(typeof e==`number`){if(e<0||!Number.isFinite(e))throw Error(`Invalid duration: ${e}. Expected a non-negative finite number of milliseconds.`);return new Date(Date.now()+e)}else if(e instanceof Date||e&&typeof e==`object`&&typeof e.getTime==`function`)return e instanceof Date?e:new Date(e.getTime());else throw Error(`Invalid duration parameter. Expected a duration string, number (milliseconds), or Date object.`)}function p(e=process.env){return e.WORKFLOW_TARGET_WORLD||(e.VERCEL_DEPLOYMENT_ID?`vercel`:`local`)}function m(e){return e===`vercel`||e===`@workflow/world-vercel`}const h={USER_ERROR:`USER_ERROR`,RUNTIME_ERROR:`RUNTIME_ERROR`,CORRUPTED_EVENT_LOG:`CORRUPTED_EVENT_LOG`,MAX_DELIVERIES_EXCEEDED:`MAX_DELIVERIES_EXCEEDED`,REPLAY_TIMEOUT:`REPLAY_TIMEOUT`,WORLD_CONTRACT_ERROR:`WORLD_CONTRACT_ERROR`};function g(e){return typeof e==`object`&&!!e&&`name`in e&&`message`in e}function _(e,t){if(t.length===0)return e;let n=[e];return t.forEach((e,r)=>{let i=r===t.length-1,a=i?`╰▶ `:`├▶ `,o=i?` `:`│ `;`${e.label}: ${e.value}`.split(`
|
|
2
|
-
`).forEach((e,t)=>n.push(`${t===0?a:o}${e}`))}),n.join(`
|
|
3
|
-
`)}function v(e,t){let n=[];return e&&n.push({label:`hint`,value:e}),t&&n.push({label:`docs`,value:`https://workflow-sdk.dev/err/${t}`}),n}const y={NODE_JS_MODULE_IN_WORKFLOW:`node-js-module-in-workflow`,START_INVALID_WORKFLOW_FUNCTION:`start-invalid-workflow-function`,SERIALIZATION_FAILED:`serialization-failed`,WEBHOOK_INVALID_RESPOND_WITH_VALUE:`webhook-invalid-respond-with-value`,WEBHOOK_RESPONSE_NOT_SENT:`webhook-response-not-sent`,FETCH_IN_WORKFLOW_FUNCTION:`fetch-in-workflow`,TIMEOUT_FUNCTIONS_IN_WORKFLOW:`timeout-in-workflow`,HOOK_CONFLICT:`hook-conflict`,CORRUPTED_EVENT_LOG:`corrupted-event-log`,STEP_NOT_REGISTERED:`step-not-registered`,WORKFLOW_NOT_REGISTERED:`workflow-not-registered`,RUNTIME_DECRYPTION_FAILED:`runtime-decryption-failed`};var b=class extends Error{cause;constructor(e,t){let n=_(e,v(void 0,t?.slug));super(n,{cause:t?.cause}),t?.cause!==void 0&&(this.cause=t.cause),t?.cause instanceof Error&&(this.stack=`${this.stack}\nCaused by: ${t.cause.stack}`)}static is(e){return g(e)&&e.name===`WorkflowError`}},x=class extends b{status;code;url;retryAfter;constructor(e,t){super(e,{cause:t?.cause}),this.name=`WorkflowWorldError`,this.status=t?.status,this.code=t?.code,this.url=t?.url,this.retryAfter=t?.retryAfter}static is(e){return g(e)&&e.name===`WorkflowWorldError`}},S=class extends b{runId;errorCode;constructor(e,t,n={}){let r=t instanceof Error?t.message:typeof t==`string`?t:t&&typeof t==`object`&&`message`in t?String(t.message):`Unknown error`;super(`Workflow run "${e}" failed: ${r}`,{cause:t}),this.name=`WorkflowRunFailedError`,this.runId=e,n.errorCode!==void 0&&(this.errorCode=n.errorCode)}static is(e){return g(e)&&e.name===`WorkflowRunFailedError`}},C=class extends b{runId;status;constructor(e,t){super(`Workflow run "${e}" has not completed`,{}),this.name=`WorkflowRunNotCompletedError`,this.runId=e,this.status=t}static is(e){return g(e)&&e.name===`WorkflowRunNotCompletedError`}},w=class extends b{constructor(e,t){super(e,{...t}),this.name=`WorkflowRuntimeError`}static is(e){return g(e)&&e.name===`WorkflowRuntimeError`}},T=class extends w{constructor(e,t){super(e,{...t,slug:y.CORRUPTED_EVENT_LOG}),this.name=`CorruptedEventLogError`}static is(e){return g(e)&&e.name===`CorruptedEventLogError`}},E=class extends w{context;constructor(e,t){super(e,{cause:t?.cause,slug:y.RUNTIME_DECRYPTION_FAILED}),this.name=`RuntimeDecryptionError`,t?.context!==void 0&&(this.context=t.context)}static is(e){return g(e)&&e.name===`RuntimeDecryptionError`}},D=class extends b{hint;constructor(e,t){let n=_(e,v(t?.hint,void 0));super(n,{cause:t?.cause}),this.name=`WorkflowBuildError`,this.hint=t?.hint}static is(e){return g(e)&&e.name===`WorkflowBuildError`}},O=class extends b{hint;fatal=!0;constructor(e,t){let n=_(e,v(t?.hint,void 0));super(n,{cause:t?.cause}),this.name=`SerializationError`,this.hint=t?.hint}static is(e){return g(e)&&e.name===`SerializationError`}},k=class extends w{stepName;constructor(e){super(`Step "${e}" is not registered in the current deployment. This usually indicates a build or bundling issue that caused the step to not be included in the deployment.`,{slug:y.STEP_NOT_REGISTERED}),this.name=`StepNotRegisteredError`,this.stepName=e}static is(e){return g(e)&&e.name===`StepNotRegisteredError`}},A=class extends w{workflowName;constructor(e){super(`Workflow "${e}" is not registered in the current deployment. This usually means a run was started against a deployment that does not have this workflow, or there was a build/bundling issue.`,{slug:y.WORKFLOW_NOT_REGISTERED}),this.name=`WorkflowNotRegisteredError`,this.workflowName=e}static is(e){return g(e)&&e.name===`WorkflowNotRegisteredError`}},j=class extends b{runId;constructor(e){super(`Workflow run "${e}" not found`,{}),this.name=`WorkflowRunNotFoundError`,this.runId=e}static is(e){return g(e)&&e.name===`WorkflowRunNotFoundError`}},M=class extends b{token;conflictingRunId;constructor(e,t){super(`Hook token "${e}" is already in use by another workflow${t?` (run "${t}")`:``}`,{slug:y.HOOK_CONFLICT}),this.name=`HookConflictError`,this.token=e,t!==void 0&&(this.conflictingRunId=t)}static is(e){return g(e)&&e.name===`HookConflictError`}},N=class extends b{token;constructor(e){super(`Hook not found`,{}),this.name=`HookNotFoundError`,this.token=e}static is(e){return g(e)&&e.name===`HookNotFoundError`}},P=class extends x{constructor(e){super(e),this.name=`EntityConflictError`}static is(e){return g(e)&&e.name===`EntityConflictError`}},F=class extends x{constructor(e){super(e),this.name=`RunExpiredError`}static is(e){return g(e)&&e.name===`RunExpiredError`}},I=class extends x{constructor(e,t){super(e,{retryAfter:t?.retryAfter}),this.name=`TooEarlyError`}static is(e){return g(e)&&e.name===`TooEarlyError`}},L=class extends x{retryAfter;constructor(e,t){super(e),this.name=`ThrottleError`,this.retryAfter=t?.retryAfter}static is(e){return g(e)&&e.name===`ThrottleError`}},R=class extends b{runId;constructor(e){super(`Workflow run "${e}" cancelled`,{}),this.name=`WorkflowRunCancelledError`,this.runId=e}static is(e){return g(e)&&e.name===`WorkflowRunCancelledError`}},z=class extends b{runSpecVersion;worldSpecVersion;constructor(e,t){super(`Run requires spec version ${e}, but world supports version ${t}. Please upgrade 'workflow' package.`),this.name=`RunNotSupportedError`,this.runSpecVersion=e,this.worldSpecVersion=t}static is(e){return g(e)&&e.name===`RunNotSupportedError`}},B=class extends Error{fatal=!0;constructor(e){super(e),this.name=`FatalError`}static is(e){return g(e)?e.name===`FatalError`?!0:e.fatal===!0:!1}},V=class extends Error{retryAfter;constructor(e,t={}){super(e),this.name=`RetryableError`,t.retryAfter===void 0?this.retryAfter=new Date(Date.now()+1e3):this.retryAfter=f(t.retryAfter)}static is(e){return g(e)&&e.name===`RetryableError`}};const H="Your current vercel account does not have access to this resource. Use `vercel login` or `vercel switch` to ensure you are linked to the right account.",U=Symbol.for(`@workflow/errors//FatalError`),W=Symbol.for(`@workflow/errors//RetryableError`),G=Symbol.for(`@workflow/errors//HookConflictError`),K=Symbol.for(`@workflow/errors//RuntimeDecryptionError`);typeof globalThis<`u`&&(Object.hasOwn(globalThis,U)||Object.defineProperty(globalThis,U,{value:B,writable:!1,enumerable:!1,configurable:!1}),Object.hasOwn(globalThis,W)||Object.defineProperty(globalThis,W,{value:V,writable:!1,enumerable:!1,configurable:!1}),Object.hasOwn(globalThis,G)||Object.defineProperty(globalThis,G,{value:M,writable:!1,enumerable:!1,configurable:!1}),Object.hasOwn(globalThis,K)||Object.defineProperty(globalThis,K,{value:E,writable:!1,enumerable:!1,configurable:!1}));export{l as A,w as C,p as D,m as E,n as F,s as M,a as N,f as O,i as P,j as S,h as T,b as _,M as a,S as b,F as c,O as d,k as f,D as g,H as h,B as i,o as j,u as k,z as l,I as m,y as n,N as o,L as p,P as r,V as s,T as t,E as u,A as v,x as w,C as x,R as y};
|