@asap-protocol/mastra 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/asap-mastra-agent.d.ts +29 -0
- package/dist/commonjs/asap-mastra-agent.d.ts.map +1 -0
- package/dist/commonjs/asap-mastra-agent.js +33 -0
- package/dist/commonjs/asap-to-mastra-tool.d.ts +26 -0
- package/dist/commonjs/asap-to-mastra-tool.d.ts.map +1 -0
- package/dist/commonjs/asap-to-mastra-tool.js +127 -0
- package/dist/commonjs/errors.d.ts +28 -0
- package/dist/commonjs/errors.d.ts.map +1 -0
- package/dist/commonjs/errors.js +54 -0
- package/dist/commonjs/index.d.ts +6 -0
- package/dist/commonjs/index.d.ts.map +1 -0
- package/dist/commonjs/index.js +26 -0
- package/dist/commonjs/json-schema-to-zod.d.ts +6 -0
- package/dist/commonjs/json-schema-to-zod.d.ts.map +1 -0
- package/dist/commonjs/json-schema-to-zod.js +56 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/commonjs/streaming.d.ts +10 -0
- package/dist/commonjs/streaming.d.ts.map +1 -0
- package/dist/commonjs/streaming.js +39 -0
- package/dist/esm/asap-mastra-agent.d.ts +29 -0
- package/dist/esm/asap-mastra-agent.d.ts.map +1 -0
- package/dist/esm/asap-mastra-agent.js +30 -0
- package/dist/esm/asap-to-mastra-tool.d.ts +26 -0
- package/dist/esm/asap-to-mastra-tool.d.ts.map +1 -0
- package/dist/esm/asap-to-mastra-tool.js +123 -0
- package/dist/esm/errors.d.ts +28 -0
- package/dist/esm/errors.d.ts.map +1 -0
- package/dist/esm/errors.js +45 -0
- package/dist/esm/index.d.ts +6 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/json-schema-to-zod.d.ts +6 -0
- package/dist/esm/json-schema-to-zod.d.ts.map +1 -0
- package/dist/esm/json-schema-to-zod.js +53 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/streaming.d.ts +10 -0
- package/dist/esm/streaming.d.ts.map +1 -0
- package/dist/esm/streaming.js +36 -0
- package/package.json +69 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Agent, type AgentConfig } from "@mastra/core/agent";
|
|
2
|
+
import type { AsapExecuteClient } from "@asap-protocol/client/adapters/shared";
|
|
3
|
+
import { type AsapToolsForMastraOptions } from "./asap-to-mastra-tool.js";
|
|
4
|
+
/** Mastra {@link Agent} model slot — sourced from Mastra's {@link AgentConfig} instead of `ConstructorParameters`. */
|
|
5
|
+
export type AsapMastraAgentModel = AgentConfig["model"];
|
|
6
|
+
export interface CreateAsapMastraAgentParams {
|
|
7
|
+
readonly client: AsapExecuteClient;
|
|
8
|
+
readonly capabilities: readonly string[];
|
|
9
|
+
/** Mastra model id or config (passed through to {@link Agent}). */
|
|
10
|
+
readonly model: AsapMastraAgentModel;
|
|
11
|
+
/** Optional hooks / schema overrides forwarded to {@link asapToolsForMastra}. */
|
|
12
|
+
readonly toolsOptions?: AsapToolsForMastraOptions;
|
|
13
|
+
/** Overrides {@link Agent} id (default: `asap-mastra-agent`). */
|
|
14
|
+
readonly agentId?: string;
|
|
15
|
+
/** Overrides display name (default: `ASAP Mastra Agent`). */
|
|
16
|
+
readonly name?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Overrides default system instructions. When omitted, instructions list the capability URNs
|
|
19
|
+
* and tell the model to call tools with valid JSON arguments.
|
|
20
|
+
*/
|
|
21
|
+
readonly instructions?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Convenience wrapper that mounts ASAP-derived tools on a Mastra {@link Agent}.
|
|
25
|
+
*
|
|
26
|
+
* @see sprint task 3.1 for wiring {@link asapToolsForMastra}.
|
|
27
|
+
*/
|
|
28
|
+
export declare function createAsapMastraAgent(params: CreateAsapMastraAgentParams): Promise<Agent>;
|
|
29
|
+
//# sourceMappingURL=asap-mastra-agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asap-mastra-agent.d.ts","sourceRoot":"","sources":["../../src/asap-mastra-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAE7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAE/E,OAAO,EAAE,KAAK,yBAAyB,EAAsB,MAAM,0BAA0B,CAAC;AAE9F,sHAAsH;AACtH,MAAM,MAAM,oBAAoB,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;AAExD,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IACnC,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,mEAAmE;IACnE,QAAQ,CAAC,KAAK,EAAE,oBAAoB,CAAC;IACrC,iFAAiF;IACjF,QAAQ,CAAC,YAAY,CAAC,EAAE,yBAAyB,CAAC;IAClD,iEAAiE;IACjE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,6DAA6D;IAC7D,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAChC;AAYD;;;;GAIG;AACH,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,2BAA2B,GAAG,OAAO,CAAC,KAAK,CAAC,CAgB/F"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createAsapMastraAgent = createAsapMastraAgent;
|
|
4
|
+
const agent_1 = require("@mastra/core/agent");
|
|
5
|
+
const asap_to_mastra_tool_js_1 = require("./asap-to-mastra-tool.js");
|
|
6
|
+
function defaultInstructions(capabilities) {
|
|
7
|
+
const list = capabilities.length > 0 ? capabilities.join(", ") : "(none configured)";
|
|
8
|
+
return [
|
|
9
|
+
"You have access to ASAP capabilities exposed as Mastra tools.",
|
|
10
|
+
"When the user asks to run a capability on the ASAP provider, call the matching tool with valid JSON arguments derived from the capability schema.",
|
|
11
|
+
`Capability URNs available on this agent: ${list}.`,
|
|
12
|
+
"Answer concisely in natural language after tools return.",
|
|
13
|
+
].join(" ");
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Convenience wrapper that mounts ASAP-derived tools on a Mastra {@link Agent}.
|
|
17
|
+
*
|
|
18
|
+
* @see sprint task 3.1 for wiring {@link asapToolsForMastra}.
|
|
19
|
+
*/
|
|
20
|
+
async function createAsapMastraAgent(params) {
|
|
21
|
+
const asapTools = await (0, asap_to_mastra_tool_js_1.asapToolsForMastra)({ ...params.client, capabilities: params.capabilities }, params.toolsOptions);
|
|
22
|
+
const tools = {};
|
|
23
|
+
for (const t of asapTools) {
|
|
24
|
+
tools[t.id] = t;
|
|
25
|
+
}
|
|
26
|
+
return new agent_1.Agent({
|
|
27
|
+
id: params.agentId ?? "asap-mastra-agent",
|
|
28
|
+
name: params.name ?? "ASAP Mastra Agent",
|
|
29
|
+
instructions: params.instructions ?? defaultInstructions(params.capabilities),
|
|
30
|
+
model: params.model,
|
|
31
|
+
tools,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type AsapExecuteClient } from "@asap-protocol/client/adapters/shared";
|
|
2
|
+
import { type Tool } from "@mastra/core/tools";
|
|
3
|
+
export interface AsapToolsForMastraOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Invoked when the provider returns `403` with `error.code === "capability_not_granted"`.
|
|
6
|
+
* Use this to trigger `request-capability` / host approval flows.
|
|
7
|
+
*/
|
|
8
|
+
readonly requestCapability?: (requiredCapability: string) => void | Promise<void>;
|
|
9
|
+
/** Pre-fetched per-capability input schemas (parity with adapters/openai|anthropic). */
|
|
10
|
+
readonly inputSchemas?: Readonly<Record<string, unknown>>;
|
|
11
|
+
/** Pre-fetched per-capability output schemas. */
|
|
12
|
+
readonly outputSchemas?: Readonly<Record<string, unknown>>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Build Mastra {@link createTool} instances for each ASAP capability on the client.
|
|
16
|
+
*
|
|
17
|
+
* When {@link AsapToolsForMastraOptions.inputSchemas} does not define a capability entry, this calls
|
|
18
|
+
* {@link describeCapability} once per capability to recover JSON Schemas and descriptions.
|
|
19
|
+
*/
|
|
20
|
+
export declare function asapToolsForMastra(client: AsapExecuteClient, options?: AsapToolsForMastraOptions): Promise<readonly Tool[]>;
|
|
21
|
+
/**
|
|
22
|
+
* Synchronous variant for callers that already have per-capability {@link AsapToolsForMastraOptions.inputSchemas}
|
|
23
|
+
* / {@link AsapToolsForMastraOptions.outputSchemas} and want to avoid {@link describeCapability} round-trips.
|
|
24
|
+
*/
|
|
25
|
+
export declare function asapToolsForMastraSync(client: AsapExecuteClient, options?: AsapToolsForMastraOptions): readonly Tool[];
|
|
26
|
+
//# sourceMappingURL=asap-to-mastra-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asap-to-mastra-tool.d.ts","sourceRoot":"","sources":["../../src/asap-to-mastra-tool.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAc,KAAK,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAK3D,MAAM,WAAW,yBAAyB;IACxC;;;OAGG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC,kBAAkB,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClF,wFAAwF;IACxF,QAAQ,CAAC,YAAY,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC1D,iDAAiD;IACjD,QAAQ,CAAC,aAAa,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC5D;AAsGD;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,iBAAiB,EACzB,OAAO,CAAC,EAAE,yBAAyB,GAClC,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC,CAkC1B;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,iBAAiB,EACzB,OAAO,CAAC,EAAE,yBAAyB,GAClC,SAAS,IAAI,EAAE,CAejB"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.asapToolsForMastra = asapToolsForMastra;
|
|
4
|
+
exports.asapToolsForMastraSync = asapToolsForMastraSync;
|
|
5
|
+
const client_1 = require("@asap-protocol/client");
|
|
6
|
+
const shared_1 = require("@asap-protocol/client/adapters/shared");
|
|
7
|
+
const tools_1 = require("@mastra/core/tools");
|
|
8
|
+
const errors_js_1 = require("./errors.js");
|
|
9
|
+
const json_schema_to_zod_js_1 = require("./json-schema-to-zod.js");
|
|
10
|
+
function isRecord(x) {
|
|
11
|
+
return typeof x === "object" && x !== null && !Array.isArray(x);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Wraps a {@link CapabilityFetch} to map select provider HTTP 403 JSON error payloads into typed errors.
|
|
15
|
+
*
|
|
16
|
+
* Unary JSON only: non-403 responses are returned as-is so bodies are not buffered. Do not use this
|
|
17
|
+
* wrapper for SSE or other streaming responses; the contract assumes small JSON payloads suitable for
|
|
18
|
+
* `describeCapability` / `executeCapability`.
|
|
19
|
+
*/
|
|
20
|
+
function wrapFetchWithCapabilityErrors(base, options) {
|
|
21
|
+
const impl = base ?? globalThis.fetch;
|
|
22
|
+
return async (input, init) => {
|
|
23
|
+
const res = await impl(input, init);
|
|
24
|
+
if (res.status !== 403) {
|
|
25
|
+
return res;
|
|
26
|
+
}
|
|
27
|
+
const text = await res.clone().text();
|
|
28
|
+
let parsed;
|
|
29
|
+
try {
|
|
30
|
+
parsed = text.length === 0 ? {} : JSON.parse(text);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return new Response(text, { status: res.status, statusText: res.statusText, headers: res.headers });
|
|
34
|
+
}
|
|
35
|
+
if (!isRecord(parsed)) {
|
|
36
|
+
return new Response(text, { status: res.status, statusText: res.statusText, headers: res.headers });
|
|
37
|
+
}
|
|
38
|
+
if (parsed.error === "constraint_violated") {
|
|
39
|
+
return new Response(text, { status: res.status, statusText: res.statusText, headers: res.headers });
|
|
40
|
+
}
|
|
41
|
+
const errObj = parsed.error;
|
|
42
|
+
if (!isRecord(errObj)) {
|
|
43
|
+
return new Response(text, { status: res.status, statusText: res.statusText, headers: res.headers });
|
|
44
|
+
}
|
|
45
|
+
const code = errObj.code;
|
|
46
|
+
if (code === "capability_not_granted") {
|
|
47
|
+
const data = isRecord(errObj.data) ? errObj.data : undefined;
|
|
48
|
+
const required = typeof data?.required_capability === "string" ? data.required_capability : "";
|
|
49
|
+
const msg = typeof errObj.message === "string" ? errObj.message : undefined;
|
|
50
|
+
throw new errors_js_1.CapabilityNotGrantedError(required, options?.requestCapability, msg);
|
|
51
|
+
}
|
|
52
|
+
if (code === "approval_required") {
|
|
53
|
+
const msg = typeof errObj.message === "string" ? errObj.message : "Capability execution requires approval";
|
|
54
|
+
throw new errors_js_1.ApprovalRequiredError(msg, errObj.data);
|
|
55
|
+
}
|
|
56
|
+
return new Response(text, { status: res.status, statusText: res.statusText, headers: res.headers });
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function buildTools(client, fetchFn, describedByCapability, options) {
|
|
60
|
+
const tools = [];
|
|
61
|
+
for (const capabilityId of client.capabilities) {
|
|
62
|
+
const id = (0, shared_1.capabilityToolKey)(capabilityId);
|
|
63
|
+
const described = describedByCapability.get(capabilityId);
|
|
64
|
+
const inputJson = (0, shared_1.jsonSchemaForCapabilityInput)(options?.inputSchemas?.[capabilityId] ?? described?.input_schema);
|
|
65
|
+
const outputRaw = options?.outputSchemas?.[capabilityId] ?? described?.output_schema;
|
|
66
|
+
const outputJson = (0, shared_1.jsonSchemaForCapabilityOutput)(outputRaw);
|
|
67
|
+
tools.push((0, tools_1.createTool)({
|
|
68
|
+
id,
|
|
69
|
+
description: described?.description ?? `ASAP capability: ${capabilityId}`,
|
|
70
|
+
inputSchema: (0, json_schema_to_zod_js_1.zodFromJsonSchema)(inputJson),
|
|
71
|
+
outputSchema: (0, json_schema_to_zod_js_1.zodFromJsonSchema)(outputJson),
|
|
72
|
+
execute: async (inputData) => {
|
|
73
|
+
const ctx = typeof inputData === "object" && inputData !== null && !Array.isArray(inputData)
|
|
74
|
+
? inputData
|
|
75
|
+
: {};
|
|
76
|
+
return (0, client_1.executeCapability)(client.provider, capabilityId, ctx, {
|
|
77
|
+
agentJwt: client.agentJwt,
|
|
78
|
+
fetch: fetchFn,
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
83
|
+
return tools;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Build Mastra {@link createTool} instances for each ASAP capability on the client.
|
|
87
|
+
*
|
|
88
|
+
* When {@link AsapToolsForMastraOptions.inputSchemas} does not define a capability entry, this calls
|
|
89
|
+
* {@link describeCapability} once per capability to recover JSON Schemas and descriptions.
|
|
90
|
+
*/
|
|
91
|
+
async function asapToolsForMastra(client, options) {
|
|
92
|
+
const fetchFn = wrapFetchWithCapabilityErrors(client.fetch, options);
|
|
93
|
+
const describedByCapability = new Map();
|
|
94
|
+
for (const capabilityId of client.capabilities) {
|
|
95
|
+
if (options?.inputSchemas?.[capabilityId] !== undefined) {
|
|
96
|
+
describedByCapability.set(capabilityId, undefined);
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
const described = await (0, client_1.describeCapability)(client.provider, capabilityId, {
|
|
100
|
+
fetch: fetchFn,
|
|
101
|
+
agentJwt: client.agentJwt,
|
|
102
|
+
}).catch(() => undefined);
|
|
103
|
+
if (described === undefined) {
|
|
104
|
+
describedByCapability.set(capabilityId, undefined);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
describedByCapability.set(capabilityId, {
|
|
108
|
+
description: described.description,
|
|
109
|
+
input_schema: described.input_schema,
|
|
110
|
+
output_schema: described.output_schema,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return buildTools(client, fetchFn, describedByCapability, options);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Synchronous variant for callers that already have per-capability {@link AsapToolsForMastraOptions.inputSchemas}
|
|
118
|
+
* / {@link AsapToolsForMastraOptions.outputSchemas} and want to avoid {@link describeCapability} round-trips.
|
|
119
|
+
*/
|
|
120
|
+
function asapToolsForMastraSync(client, options) {
|
|
121
|
+
const fetchFn = wrapFetchWithCapabilityErrors(client.fetch, options);
|
|
122
|
+
const describedByCapability = new Map();
|
|
123
|
+
for (const capabilityId of client.capabilities) {
|
|
124
|
+
describedByCapability.set(capabilityId, undefined);
|
|
125
|
+
}
|
|
126
|
+
return buildTools(client, fetchFn, describedByCapability, options);
|
|
127
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export { FatalError, RecoverableError, RemoteFatalRPCError, RemoteRecoverableRPCError, } from "@asap-protocol/client";
|
|
2
|
+
/**
|
|
3
|
+
* Structured `approval_required` payload (`error.data`) from an ASAP provider JSON body.
|
|
4
|
+
*/
|
|
5
|
+
export interface ApprovalRequiredDetail {
|
|
6
|
+
readonly reason?: string;
|
|
7
|
+
readonly approval_url?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Raised when the provider indicates an approval step is required before the capability can run.
|
|
11
|
+
*/
|
|
12
|
+
export declare class ApprovalRequiredError extends Error {
|
|
13
|
+
readonly name = "ApprovalRequiredError";
|
|
14
|
+
readonly detail?: ApprovalRequiredDetail;
|
|
15
|
+
constructor(message?: string, detail?: unknown);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Raised when the agent JWT is valid but the capability is not granted (HTTP 403 `capability_not_granted`).
|
|
19
|
+
* Call {@link CapabilityNotGrantedError.requestCapability} to run the optional `requestCapability` hook supplied to `asapToolsForMastra` options.
|
|
20
|
+
*/
|
|
21
|
+
export declare class CapabilityNotGrantedError extends Error {
|
|
22
|
+
readonly name = "CapabilityNotGrantedError";
|
|
23
|
+
readonly requiredCapability: string;
|
|
24
|
+
private readonly hook?;
|
|
25
|
+
constructor(requiredCapability: string, requestCapability?: (capability: string) => void | Promise<void>, message?: string);
|
|
26
|
+
requestCapability(): void | Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,mBAAmB,EACnB,yBAAyB,GAC1B,MAAM,uBAAuB,CAAC;AAE/B;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAChC;AAmBD;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,SAAkB,IAAI,2BAA2B;IAEjD,QAAQ,CAAC,MAAM,CAAC,EAAE,sBAAsB,CAAC;gBAE7B,OAAO,SAA2C,EAAE,MAAM,CAAC,EAAE,OAAO;CAIjF;AAED;;;GAGG;AACH,qBAAa,yBAA0B,SAAQ,KAAK;IAClD,SAAkB,IAAI,+BAA+B;IAErD,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IAEpC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAA+C;gBAGnE,kBAAkB,EAAE,MAAM,EAC1B,iBAAiB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAChE,OAAO,CAAC,EAAE,MAAM;IAOlB,iBAAiB,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CAG1C"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CapabilityNotGrantedError = exports.ApprovalRequiredError = exports.RemoteRecoverableRPCError = exports.RemoteFatalRPCError = exports.RecoverableError = exports.FatalError = void 0;
|
|
4
|
+
var client_1 = require("@asap-protocol/client");
|
|
5
|
+
Object.defineProperty(exports, "FatalError", { enumerable: true, get: function () { return client_1.FatalError; } });
|
|
6
|
+
Object.defineProperty(exports, "RecoverableError", { enumerable: true, get: function () { return client_1.RecoverableError; } });
|
|
7
|
+
Object.defineProperty(exports, "RemoteFatalRPCError", { enumerable: true, get: function () { return client_1.RemoteFatalRPCError; } });
|
|
8
|
+
Object.defineProperty(exports, "RemoteRecoverableRPCError", { enumerable: true, get: function () { return client_1.RemoteRecoverableRPCError; } });
|
|
9
|
+
function approvalDetailFromUnknown(data) {
|
|
10
|
+
if (!data || typeof data !== "object" || Array.isArray(data)) {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
const rec = data;
|
|
14
|
+
const reason = rec.reason;
|
|
15
|
+
const approval_url = rec.approval_url;
|
|
16
|
+
const detail = {};
|
|
17
|
+
if (typeof reason === "string") {
|
|
18
|
+
detail.reason = reason;
|
|
19
|
+
}
|
|
20
|
+
if (typeof approval_url === "string") {
|
|
21
|
+
detail.approval_url = approval_url;
|
|
22
|
+
}
|
|
23
|
+
return Object.keys(detail).length > 0 ? detail : undefined;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Raised when the provider indicates an approval step is required before the capability can run.
|
|
27
|
+
*/
|
|
28
|
+
class ApprovalRequiredError extends Error {
|
|
29
|
+
name = "ApprovalRequiredError";
|
|
30
|
+
detail;
|
|
31
|
+
constructor(message = "Capability execution requires approval", detail) {
|
|
32
|
+
super(message);
|
|
33
|
+
this.detail = approvalDetailFromUnknown(detail);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.ApprovalRequiredError = ApprovalRequiredError;
|
|
37
|
+
/**
|
|
38
|
+
* Raised when the agent JWT is valid but the capability is not granted (HTTP 403 `capability_not_granted`).
|
|
39
|
+
* Call {@link CapabilityNotGrantedError.requestCapability} to run the optional `requestCapability` hook supplied to `asapToolsForMastra` options.
|
|
40
|
+
*/
|
|
41
|
+
class CapabilityNotGrantedError extends Error {
|
|
42
|
+
name = "CapabilityNotGrantedError";
|
|
43
|
+
requiredCapability;
|
|
44
|
+
hook;
|
|
45
|
+
constructor(requiredCapability, requestCapability, message) {
|
|
46
|
+
super(message ?? `Capability not granted: ${requiredCapability}`);
|
|
47
|
+
this.requiredCapability = requiredCapability;
|
|
48
|
+
this.hook = requestCapability;
|
|
49
|
+
}
|
|
50
|
+
requestCapability() {
|
|
51
|
+
return this.hook?.(this.requiredCapability);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.CapabilityNotGrantedError = CapabilityNotGrantedError;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Mastra integration: ASAP capabilities as Mastra `createTool` definitions. */
|
|
2
|
+
export { asapToolsForMastra, asapToolsForMastraSync, type AsapToolsForMastraOptions, } from "./asap-to-mastra-tool.js";
|
|
3
|
+
export { createAsapMastraAgent, type AsapMastraAgentModel, type CreateAsapMastraAgentParams } from "./asap-mastra-agent.js";
|
|
4
|
+
export { asapStreamToMastraTextStream } from "./streaming.js";
|
|
5
|
+
export * from "./errors.js";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAEhF,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,KAAK,yBAAyB,GAC/B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,qBAAqB,EAAE,KAAK,oBAAoB,EAAE,KAAK,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAC5H,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAC9D,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** Mastra integration: ASAP capabilities as Mastra `createTool` definitions. */
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.asapStreamToMastraTextStream = exports.createAsapMastraAgent = exports.asapToolsForMastraSync = exports.asapToolsForMastra = void 0;
|
|
19
|
+
var asap_to_mastra_tool_js_1 = require("./asap-to-mastra-tool.js");
|
|
20
|
+
Object.defineProperty(exports, "asapToolsForMastra", { enumerable: true, get: function () { return asap_to_mastra_tool_js_1.asapToolsForMastra; } });
|
|
21
|
+
Object.defineProperty(exports, "asapToolsForMastraSync", { enumerable: true, get: function () { return asap_to_mastra_tool_js_1.asapToolsForMastraSync; } });
|
|
22
|
+
var asap_mastra_agent_js_1 = require("./asap-mastra-agent.js");
|
|
23
|
+
Object.defineProperty(exports, "createAsapMastraAgent", { enumerable: true, get: function () { return asap_mastra_agent_js_1.createAsapMastraAgent; } });
|
|
24
|
+
var streaming_js_1 = require("./streaming.js");
|
|
25
|
+
Object.defineProperty(exports, "asapStreamToMastraTextStream", { enumerable: true, get: function () { return streaming_js_1.asapStreamToMastraTextStream; } });
|
|
26
|
+
__exportStar(require("./errors.js"), exports);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type ZodType } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Minimal JSON Schema → Zod bridge for adapter tool schemas (subset only; see tests for `oneOf` / `$ref`).
|
|
4
|
+
*/
|
|
5
|
+
export declare function zodFromJsonSchema(schema: Record<string, unknown>): ZodType<unknown>;
|
|
6
|
+
//# sourceMappingURL=json-schema-to-zod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-schema-to-zod.d.ts","sourceRoot":"","sources":["../../src/json-schema-to-zod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAK,KAAK,OAAO,EAAE,MAAM,KAAK,CAAC;AAEtC;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAoDnF"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.zodFromJsonSchema = zodFromJsonSchema;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
/**
|
|
6
|
+
* Minimal JSON Schema → Zod bridge for adapter tool schemas (subset only; see tests for `oneOf` / `$ref`).
|
|
7
|
+
*/
|
|
8
|
+
function zodFromJsonSchema(schema) {
|
|
9
|
+
if ("$ref" in schema) {
|
|
10
|
+
return zod_1.z.record(zod_1.z.string(), zod_1.z.unknown());
|
|
11
|
+
}
|
|
12
|
+
if ("oneOf" in schema && Array.isArray(schema.oneOf)) {
|
|
13
|
+
const branches = schema.oneOf
|
|
14
|
+
.filter((s) => typeof s === "object" && s !== null && !Array.isArray(s))
|
|
15
|
+
.map((s) => zodFromJsonSchema(s));
|
|
16
|
+
return branches.length === 0
|
|
17
|
+
? zod_1.z.unknown()
|
|
18
|
+
: branches.length === 1
|
|
19
|
+
? branches[0]
|
|
20
|
+
: zod_1.z.union(branches);
|
|
21
|
+
}
|
|
22
|
+
switch (schema.type) {
|
|
23
|
+
case "object": {
|
|
24
|
+
const maybeProps = schema.properties;
|
|
25
|
+
if (maybeProps !== undefined &&
|
|
26
|
+
typeof maybeProps === "object" &&
|
|
27
|
+
maybeProps !== null &&
|
|
28
|
+
!Array.isArray(maybeProps)) {
|
|
29
|
+
const propsRecord = maybeProps;
|
|
30
|
+
const required = new Set(Array.isArray(schema.required) ? schema.required.filter((k) => typeof k === "string") : []);
|
|
31
|
+
const shape = {};
|
|
32
|
+
for (const [key, val] of Object.entries(propsRecord)) {
|
|
33
|
+
if (typeof val === "object" && val !== null && !Array.isArray(val)) {
|
|
34
|
+
const child = zodFromJsonSchema(val);
|
|
35
|
+
shape[key] = required.has(key) ? child : child.optional();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (Object.keys(shape).length > 0) {
|
|
39
|
+
return zod_1.z.object(shape);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return zod_1.z.record(zod_1.z.string(), zod_1.z.unknown());
|
|
43
|
+
}
|
|
44
|
+
case "string":
|
|
45
|
+
return zod_1.z.string();
|
|
46
|
+
case "number":
|
|
47
|
+
case "integer":
|
|
48
|
+
return zod_1.z.number();
|
|
49
|
+
case "boolean":
|
|
50
|
+
return zod_1.z.boolean();
|
|
51
|
+
case "array":
|
|
52
|
+
return zod_1.z.array(zod_1.z.unknown());
|
|
53
|
+
default:
|
|
54
|
+
return zod_1.z.record(zod_1.z.string(), zod_1.z.unknown());
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridge ASAP streaming payloads into Mastra-compatible text chunks.
|
|
3
|
+
*
|
|
4
|
+
* Async generator iteration propagates consumer backpressure: the upstream `source` iterator
|
|
5
|
+
* only advances after each `yield`, so a slow consumer naturally throttles reads.
|
|
6
|
+
*
|
|
7
|
+
* @see sprint task 4.1 for SSE parsing and backpressure.
|
|
8
|
+
*/
|
|
9
|
+
export declare function asapStreamToMastraTextStream(source: AsyncIterable<unknown>): AsyncIterable<string>;
|
|
10
|
+
//# sourceMappingURL=streaming.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming.d.ts","sourceRoot":"","sources":["../../src/streaming.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,wBAAuB,4BAA4B,CAAC,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,CAuBzG"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Bridge ASAP streaming payloads into Mastra-compatible text chunks.
|
|
4
|
+
*
|
|
5
|
+
* Async generator iteration propagates consumer backpressure: the upstream `source` iterator
|
|
6
|
+
* only advances after each `yield`, so a slow consumer naturally throttles reads.
|
|
7
|
+
*
|
|
8
|
+
* @see sprint task 4.1 for SSE parsing and backpressure.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.asapStreamToMastraTextStream = asapStreamToMastraTextStream;
|
|
12
|
+
function isRecord(x) {
|
|
13
|
+
return typeof x === "object" && x !== null && !Array.isArray(x);
|
|
14
|
+
}
|
|
15
|
+
async function* asapStreamToMastraTextStream(source) {
|
|
16
|
+
const it = source[Symbol.asyncIterator]();
|
|
17
|
+
try {
|
|
18
|
+
while (true) {
|
|
19
|
+
const { value: event, done } = await it.next();
|
|
20
|
+
if (done) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (!isRecord(event) || event.type !== "task_stream") {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
const payload = event.payload;
|
|
27
|
+
if (!isRecord(payload)) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
const chunk = payload.chunk;
|
|
31
|
+
if (typeof chunk === "string") {
|
|
32
|
+
yield chunk;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
finally {
|
|
37
|
+
await it.return?.();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Agent, type AgentConfig } from "@mastra/core/agent";
|
|
2
|
+
import type { AsapExecuteClient } from "@asap-protocol/client/adapters/shared";
|
|
3
|
+
import { type AsapToolsForMastraOptions } from "./asap-to-mastra-tool.js";
|
|
4
|
+
/** Mastra {@link Agent} model slot — sourced from Mastra's {@link AgentConfig} instead of `ConstructorParameters`. */
|
|
5
|
+
export type AsapMastraAgentModel = AgentConfig["model"];
|
|
6
|
+
export interface CreateAsapMastraAgentParams {
|
|
7
|
+
readonly client: AsapExecuteClient;
|
|
8
|
+
readonly capabilities: readonly string[];
|
|
9
|
+
/** Mastra model id or config (passed through to {@link Agent}). */
|
|
10
|
+
readonly model: AsapMastraAgentModel;
|
|
11
|
+
/** Optional hooks / schema overrides forwarded to {@link asapToolsForMastra}. */
|
|
12
|
+
readonly toolsOptions?: AsapToolsForMastraOptions;
|
|
13
|
+
/** Overrides {@link Agent} id (default: `asap-mastra-agent`). */
|
|
14
|
+
readonly agentId?: string;
|
|
15
|
+
/** Overrides display name (default: `ASAP Mastra Agent`). */
|
|
16
|
+
readonly name?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Overrides default system instructions. When omitted, instructions list the capability URNs
|
|
19
|
+
* and tell the model to call tools with valid JSON arguments.
|
|
20
|
+
*/
|
|
21
|
+
readonly instructions?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Convenience wrapper that mounts ASAP-derived tools on a Mastra {@link Agent}.
|
|
25
|
+
*
|
|
26
|
+
* @see sprint task 3.1 for wiring {@link asapToolsForMastra}.
|
|
27
|
+
*/
|
|
28
|
+
export declare function createAsapMastraAgent(params: CreateAsapMastraAgentParams): Promise<Agent>;
|
|
29
|
+
//# sourceMappingURL=asap-mastra-agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asap-mastra-agent.d.ts","sourceRoot":"","sources":["../../src/asap-mastra-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAE7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAE/E,OAAO,EAAE,KAAK,yBAAyB,EAAsB,MAAM,0BAA0B,CAAC;AAE9F,sHAAsH;AACtH,MAAM,MAAM,oBAAoB,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;AAExD,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IACnC,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,mEAAmE;IACnE,QAAQ,CAAC,KAAK,EAAE,oBAAoB,CAAC;IACrC,iFAAiF;IACjF,QAAQ,CAAC,YAAY,CAAC,EAAE,yBAAyB,CAAC;IAClD,iEAAiE;IACjE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,6DAA6D;IAC7D,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAChC;AAYD;;;;GAIG;AACH,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,2BAA2B,GAAG,OAAO,CAAC,KAAK,CAAC,CAgB/F"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Agent } from "@mastra/core/agent";
|
|
2
|
+
import { asapToolsForMastra } from "./asap-to-mastra-tool.js";
|
|
3
|
+
function defaultInstructions(capabilities) {
|
|
4
|
+
const list = capabilities.length > 0 ? capabilities.join(", ") : "(none configured)";
|
|
5
|
+
return [
|
|
6
|
+
"You have access to ASAP capabilities exposed as Mastra tools.",
|
|
7
|
+
"When the user asks to run a capability on the ASAP provider, call the matching tool with valid JSON arguments derived from the capability schema.",
|
|
8
|
+
`Capability URNs available on this agent: ${list}.`,
|
|
9
|
+
"Answer concisely in natural language after tools return.",
|
|
10
|
+
].join(" ");
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Convenience wrapper that mounts ASAP-derived tools on a Mastra {@link Agent}.
|
|
14
|
+
*
|
|
15
|
+
* @see sprint task 3.1 for wiring {@link asapToolsForMastra}.
|
|
16
|
+
*/
|
|
17
|
+
export async function createAsapMastraAgent(params) {
|
|
18
|
+
const asapTools = await asapToolsForMastra({ ...params.client, capabilities: params.capabilities }, params.toolsOptions);
|
|
19
|
+
const tools = {};
|
|
20
|
+
for (const t of asapTools) {
|
|
21
|
+
tools[t.id] = t;
|
|
22
|
+
}
|
|
23
|
+
return new Agent({
|
|
24
|
+
id: params.agentId ?? "asap-mastra-agent",
|
|
25
|
+
name: params.name ?? "ASAP Mastra Agent",
|
|
26
|
+
instructions: params.instructions ?? defaultInstructions(params.capabilities),
|
|
27
|
+
model: params.model,
|
|
28
|
+
tools,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type AsapExecuteClient } from "@asap-protocol/client/adapters/shared";
|
|
2
|
+
import { type Tool } from "@mastra/core/tools";
|
|
3
|
+
export interface AsapToolsForMastraOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Invoked when the provider returns `403` with `error.code === "capability_not_granted"`.
|
|
6
|
+
* Use this to trigger `request-capability` / host approval flows.
|
|
7
|
+
*/
|
|
8
|
+
readonly requestCapability?: (requiredCapability: string) => void | Promise<void>;
|
|
9
|
+
/** Pre-fetched per-capability input schemas (parity with adapters/openai|anthropic). */
|
|
10
|
+
readonly inputSchemas?: Readonly<Record<string, unknown>>;
|
|
11
|
+
/** Pre-fetched per-capability output schemas. */
|
|
12
|
+
readonly outputSchemas?: Readonly<Record<string, unknown>>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Build Mastra {@link createTool} instances for each ASAP capability on the client.
|
|
16
|
+
*
|
|
17
|
+
* When {@link AsapToolsForMastraOptions.inputSchemas} does not define a capability entry, this calls
|
|
18
|
+
* {@link describeCapability} once per capability to recover JSON Schemas and descriptions.
|
|
19
|
+
*/
|
|
20
|
+
export declare function asapToolsForMastra(client: AsapExecuteClient, options?: AsapToolsForMastraOptions): Promise<readonly Tool[]>;
|
|
21
|
+
/**
|
|
22
|
+
* Synchronous variant for callers that already have per-capability {@link AsapToolsForMastraOptions.inputSchemas}
|
|
23
|
+
* / {@link AsapToolsForMastraOptions.outputSchemas} and want to avoid {@link describeCapability} round-trips.
|
|
24
|
+
*/
|
|
25
|
+
export declare function asapToolsForMastraSync(client: AsapExecuteClient, options?: AsapToolsForMastraOptions): readonly Tool[];
|
|
26
|
+
//# sourceMappingURL=asap-to-mastra-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asap-to-mastra-tool.d.ts","sourceRoot":"","sources":["../../src/asap-to-mastra-tool.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAc,KAAK,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAK3D,MAAM,WAAW,yBAAyB;IACxC;;;OAGG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC,kBAAkB,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClF,wFAAwF;IACxF,QAAQ,CAAC,YAAY,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC1D,iDAAiD;IACjD,QAAQ,CAAC,aAAa,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC5D;AAsGD;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,iBAAiB,EACzB,OAAO,CAAC,EAAE,yBAAyB,GAClC,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC,CAkC1B;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,iBAAiB,EACzB,OAAO,CAAC,EAAE,yBAAyB,GAClC,SAAS,IAAI,EAAE,CAejB"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { describeCapability, executeCapability } from "@asap-protocol/client";
|
|
2
|
+
import { capabilityToolKey, jsonSchemaForCapabilityInput, jsonSchemaForCapabilityOutput, } from "@asap-protocol/client/adapters/shared";
|
|
3
|
+
import { createTool } from "@mastra/core/tools";
|
|
4
|
+
import { ApprovalRequiredError, CapabilityNotGrantedError } from "./errors.js";
|
|
5
|
+
import { zodFromJsonSchema } from "./json-schema-to-zod.js";
|
|
6
|
+
function isRecord(x) {
|
|
7
|
+
return typeof x === "object" && x !== null && !Array.isArray(x);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Wraps a {@link CapabilityFetch} to map select provider HTTP 403 JSON error payloads into typed errors.
|
|
11
|
+
*
|
|
12
|
+
* Unary JSON only: non-403 responses are returned as-is so bodies are not buffered. Do not use this
|
|
13
|
+
* wrapper for SSE or other streaming responses; the contract assumes small JSON payloads suitable for
|
|
14
|
+
* `describeCapability` / `executeCapability`.
|
|
15
|
+
*/
|
|
16
|
+
function wrapFetchWithCapabilityErrors(base, options) {
|
|
17
|
+
const impl = base ?? globalThis.fetch;
|
|
18
|
+
return async (input, init) => {
|
|
19
|
+
const res = await impl(input, init);
|
|
20
|
+
if (res.status !== 403) {
|
|
21
|
+
return res;
|
|
22
|
+
}
|
|
23
|
+
const text = await res.clone().text();
|
|
24
|
+
let parsed;
|
|
25
|
+
try {
|
|
26
|
+
parsed = text.length === 0 ? {} : JSON.parse(text);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return new Response(text, { status: res.status, statusText: res.statusText, headers: res.headers });
|
|
30
|
+
}
|
|
31
|
+
if (!isRecord(parsed)) {
|
|
32
|
+
return new Response(text, { status: res.status, statusText: res.statusText, headers: res.headers });
|
|
33
|
+
}
|
|
34
|
+
if (parsed.error === "constraint_violated") {
|
|
35
|
+
return new Response(text, { status: res.status, statusText: res.statusText, headers: res.headers });
|
|
36
|
+
}
|
|
37
|
+
const errObj = parsed.error;
|
|
38
|
+
if (!isRecord(errObj)) {
|
|
39
|
+
return new Response(text, { status: res.status, statusText: res.statusText, headers: res.headers });
|
|
40
|
+
}
|
|
41
|
+
const code = errObj.code;
|
|
42
|
+
if (code === "capability_not_granted") {
|
|
43
|
+
const data = isRecord(errObj.data) ? errObj.data : undefined;
|
|
44
|
+
const required = typeof data?.required_capability === "string" ? data.required_capability : "";
|
|
45
|
+
const msg = typeof errObj.message === "string" ? errObj.message : undefined;
|
|
46
|
+
throw new CapabilityNotGrantedError(required, options?.requestCapability, msg);
|
|
47
|
+
}
|
|
48
|
+
if (code === "approval_required") {
|
|
49
|
+
const msg = typeof errObj.message === "string" ? errObj.message : "Capability execution requires approval";
|
|
50
|
+
throw new ApprovalRequiredError(msg, errObj.data);
|
|
51
|
+
}
|
|
52
|
+
return new Response(text, { status: res.status, statusText: res.statusText, headers: res.headers });
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function buildTools(client, fetchFn, describedByCapability, options) {
|
|
56
|
+
const tools = [];
|
|
57
|
+
for (const capabilityId of client.capabilities) {
|
|
58
|
+
const id = capabilityToolKey(capabilityId);
|
|
59
|
+
const described = describedByCapability.get(capabilityId);
|
|
60
|
+
const inputJson = jsonSchemaForCapabilityInput(options?.inputSchemas?.[capabilityId] ?? described?.input_schema);
|
|
61
|
+
const outputRaw = options?.outputSchemas?.[capabilityId] ?? described?.output_schema;
|
|
62
|
+
const outputJson = jsonSchemaForCapabilityOutput(outputRaw);
|
|
63
|
+
tools.push(createTool({
|
|
64
|
+
id,
|
|
65
|
+
description: described?.description ?? `ASAP capability: ${capabilityId}`,
|
|
66
|
+
inputSchema: zodFromJsonSchema(inputJson),
|
|
67
|
+
outputSchema: zodFromJsonSchema(outputJson),
|
|
68
|
+
execute: async (inputData) => {
|
|
69
|
+
const ctx = typeof inputData === "object" && inputData !== null && !Array.isArray(inputData)
|
|
70
|
+
? inputData
|
|
71
|
+
: {};
|
|
72
|
+
return executeCapability(client.provider, capabilityId, ctx, {
|
|
73
|
+
agentJwt: client.agentJwt,
|
|
74
|
+
fetch: fetchFn,
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
return tools;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Build Mastra {@link createTool} instances for each ASAP capability on the client.
|
|
83
|
+
*
|
|
84
|
+
* When {@link AsapToolsForMastraOptions.inputSchemas} does not define a capability entry, this calls
|
|
85
|
+
* {@link describeCapability} once per capability to recover JSON Schemas and descriptions.
|
|
86
|
+
*/
|
|
87
|
+
export async function asapToolsForMastra(client, options) {
|
|
88
|
+
const fetchFn = wrapFetchWithCapabilityErrors(client.fetch, options);
|
|
89
|
+
const describedByCapability = new Map();
|
|
90
|
+
for (const capabilityId of client.capabilities) {
|
|
91
|
+
if (options?.inputSchemas?.[capabilityId] !== undefined) {
|
|
92
|
+
describedByCapability.set(capabilityId, undefined);
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
const described = await describeCapability(client.provider, capabilityId, {
|
|
96
|
+
fetch: fetchFn,
|
|
97
|
+
agentJwt: client.agentJwt,
|
|
98
|
+
}).catch(() => undefined);
|
|
99
|
+
if (described === undefined) {
|
|
100
|
+
describedByCapability.set(capabilityId, undefined);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
describedByCapability.set(capabilityId, {
|
|
104
|
+
description: described.description,
|
|
105
|
+
input_schema: described.input_schema,
|
|
106
|
+
output_schema: described.output_schema,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return buildTools(client, fetchFn, describedByCapability, options);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Synchronous variant for callers that already have per-capability {@link AsapToolsForMastraOptions.inputSchemas}
|
|
114
|
+
* / {@link AsapToolsForMastraOptions.outputSchemas} and want to avoid {@link describeCapability} round-trips.
|
|
115
|
+
*/
|
|
116
|
+
export function asapToolsForMastraSync(client, options) {
|
|
117
|
+
const fetchFn = wrapFetchWithCapabilityErrors(client.fetch, options);
|
|
118
|
+
const describedByCapability = new Map();
|
|
119
|
+
for (const capabilityId of client.capabilities) {
|
|
120
|
+
describedByCapability.set(capabilityId, undefined);
|
|
121
|
+
}
|
|
122
|
+
return buildTools(client, fetchFn, describedByCapability, options);
|
|
123
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export { FatalError, RecoverableError, RemoteFatalRPCError, RemoteRecoverableRPCError, } from "@asap-protocol/client";
|
|
2
|
+
/**
|
|
3
|
+
* Structured `approval_required` payload (`error.data`) from an ASAP provider JSON body.
|
|
4
|
+
*/
|
|
5
|
+
export interface ApprovalRequiredDetail {
|
|
6
|
+
readonly reason?: string;
|
|
7
|
+
readonly approval_url?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Raised when the provider indicates an approval step is required before the capability can run.
|
|
11
|
+
*/
|
|
12
|
+
export declare class ApprovalRequiredError extends Error {
|
|
13
|
+
readonly name = "ApprovalRequiredError";
|
|
14
|
+
readonly detail?: ApprovalRequiredDetail;
|
|
15
|
+
constructor(message?: string, detail?: unknown);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Raised when the agent JWT is valid but the capability is not granted (HTTP 403 `capability_not_granted`).
|
|
19
|
+
* Call {@link CapabilityNotGrantedError.requestCapability} to run the optional `requestCapability` hook supplied to `asapToolsForMastra` options.
|
|
20
|
+
*/
|
|
21
|
+
export declare class CapabilityNotGrantedError extends Error {
|
|
22
|
+
readonly name = "CapabilityNotGrantedError";
|
|
23
|
+
readonly requiredCapability: string;
|
|
24
|
+
private readonly hook?;
|
|
25
|
+
constructor(requiredCapability: string, requestCapability?: (capability: string) => void | Promise<void>, message?: string);
|
|
26
|
+
requestCapability(): void | Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,mBAAmB,EACnB,yBAAyB,GAC1B,MAAM,uBAAuB,CAAC;AAE/B;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAChC;AAmBD;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,SAAkB,IAAI,2BAA2B;IAEjD,QAAQ,CAAC,MAAM,CAAC,EAAE,sBAAsB,CAAC;gBAE7B,OAAO,SAA2C,EAAE,MAAM,CAAC,EAAE,OAAO;CAIjF;AAED;;;GAGG;AACH,qBAAa,yBAA0B,SAAQ,KAAK;IAClD,SAAkB,IAAI,+BAA+B;IAErD,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IAEpC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAA+C;gBAGnE,kBAAkB,EAAE,MAAM,EAC1B,iBAAiB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAChE,OAAO,CAAC,EAAE,MAAM;IAOlB,iBAAiB,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CAG1C"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export { FatalError, RecoverableError, RemoteFatalRPCError, RemoteRecoverableRPCError, } from "@asap-protocol/client";
|
|
2
|
+
function approvalDetailFromUnknown(data) {
|
|
3
|
+
if (!data || typeof data !== "object" || Array.isArray(data)) {
|
|
4
|
+
return undefined;
|
|
5
|
+
}
|
|
6
|
+
const rec = data;
|
|
7
|
+
const reason = rec.reason;
|
|
8
|
+
const approval_url = rec.approval_url;
|
|
9
|
+
const detail = {};
|
|
10
|
+
if (typeof reason === "string") {
|
|
11
|
+
detail.reason = reason;
|
|
12
|
+
}
|
|
13
|
+
if (typeof approval_url === "string") {
|
|
14
|
+
detail.approval_url = approval_url;
|
|
15
|
+
}
|
|
16
|
+
return Object.keys(detail).length > 0 ? detail : undefined;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Raised when the provider indicates an approval step is required before the capability can run.
|
|
20
|
+
*/
|
|
21
|
+
export class ApprovalRequiredError extends Error {
|
|
22
|
+
name = "ApprovalRequiredError";
|
|
23
|
+
detail;
|
|
24
|
+
constructor(message = "Capability execution requires approval", detail) {
|
|
25
|
+
super(message);
|
|
26
|
+
this.detail = approvalDetailFromUnknown(detail);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Raised when the agent JWT is valid but the capability is not granted (HTTP 403 `capability_not_granted`).
|
|
31
|
+
* Call {@link CapabilityNotGrantedError.requestCapability} to run the optional `requestCapability` hook supplied to `asapToolsForMastra` options.
|
|
32
|
+
*/
|
|
33
|
+
export class CapabilityNotGrantedError extends Error {
|
|
34
|
+
name = "CapabilityNotGrantedError";
|
|
35
|
+
requiredCapability;
|
|
36
|
+
hook;
|
|
37
|
+
constructor(requiredCapability, requestCapability, message) {
|
|
38
|
+
super(message ?? `Capability not granted: ${requiredCapability}`);
|
|
39
|
+
this.requiredCapability = requiredCapability;
|
|
40
|
+
this.hook = requestCapability;
|
|
41
|
+
}
|
|
42
|
+
requestCapability() {
|
|
43
|
+
return this.hook?.(this.requiredCapability);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Mastra integration: ASAP capabilities as Mastra `createTool` definitions. */
|
|
2
|
+
export { asapToolsForMastra, asapToolsForMastraSync, type AsapToolsForMastraOptions, } from "./asap-to-mastra-tool.js";
|
|
3
|
+
export { createAsapMastraAgent, type AsapMastraAgentModel, type CreateAsapMastraAgentParams } from "./asap-mastra-agent.js";
|
|
4
|
+
export { asapStreamToMastraTextStream } from "./streaming.js";
|
|
5
|
+
export * from "./errors.js";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAEhF,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,KAAK,yBAAyB,GAC/B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,qBAAqB,EAAE,KAAK,oBAAoB,EAAE,KAAK,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAC5H,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAC9D,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Mastra integration: ASAP capabilities as Mastra `createTool` definitions. */
|
|
2
|
+
export { asapToolsForMastra, asapToolsForMastraSync, } from "./asap-to-mastra-tool.js";
|
|
3
|
+
export { createAsapMastraAgent } from "./asap-mastra-agent.js";
|
|
4
|
+
export { asapStreamToMastraTextStream } from "./streaming.js";
|
|
5
|
+
export * from "./errors.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type ZodType } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Minimal JSON Schema → Zod bridge for adapter tool schemas (subset only; see tests for `oneOf` / `$ref`).
|
|
4
|
+
*/
|
|
5
|
+
export declare function zodFromJsonSchema(schema: Record<string, unknown>): ZodType<unknown>;
|
|
6
|
+
//# sourceMappingURL=json-schema-to-zod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-schema-to-zod.d.ts","sourceRoot":"","sources":["../../src/json-schema-to-zod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAK,KAAK,OAAO,EAAE,MAAM,KAAK,CAAC;AAEtC;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAoDnF"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Minimal JSON Schema → Zod bridge for adapter tool schemas (subset only; see tests for `oneOf` / `$ref`).
|
|
4
|
+
*/
|
|
5
|
+
export function zodFromJsonSchema(schema) {
|
|
6
|
+
if ("$ref" in schema) {
|
|
7
|
+
return z.record(z.string(), z.unknown());
|
|
8
|
+
}
|
|
9
|
+
if ("oneOf" in schema && Array.isArray(schema.oneOf)) {
|
|
10
|
+
const branches = schema.oneOf
|
|
11
|
+
.filter((s) => typeof s === "object" && s !== null && !Array.isArray(s))
|
|
12
|
+
.map((s) => zodFromJsonSchema(s));
|
|
13
|
+
return branches.length === 0
|
|
14
|
+
? z.unknown()
|
|
15
|
+
: branches.length === 1
|
|
16
|
+
? branches[0]
|
|
17
|
+
: z.union(branches);
|
|
18
|
+
}
|
|
19
|
+
switch (schema.type) {
|
|
20
|
+
case "object": {
|
|
21
|
+
const maybeProps = schema.properties;
|
|
22
|
+
if (maybeProps !== undefined &&
|
|
23
|
+
typeof maybeProps === "object" &&
|
|
24
|
+
maybeProps !== null &&
|
|
25
|
+
!Array.isArray(maybeProps)) {
|
|
26
|
+
const propsRecord = maybeProps;
|
|
27
|
+
const required = new Set(Array.isArray(schema.required) ? schema.required.filter((k) => typeof k === "string") : []);
|
|
28
|
+
const shape = {};
|
|
29
|
+
for (const [key, val] of Object.entries(propsRecord)) {
|
|
30
|
+
if (typeof val === "object" && val !== null && !Array.isArray(val)) {
|
|
31
|
+
const child = zodFromJsonSchema(val);
|
|
32
|
+
shape[key] = required.has(key) ? child : child.optional();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (Object.keys(shape).length > 0) {
|
|
36
|
+
return z.object(shape);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return z.record(z.string(), z.unknown());
|
|
40
|
+
}
|
|
41
|
+
case "string":
|
|
42
|
+
return z.string();
|
|
43
|
+
case "number":
|
|
44
|
+
case "integer":
|
|
45
|
+
return z.number();
|
|
46
|
+
case "boolean":
|
|
47
|
+
return z.boolean();
|
|
48
|
+
case "array":
|
|
49
|
+
return z.array(z.unknown());
|
|
50
|
+
default:
|
|
51
|
+
return z.record(z.string(), z.unknown());
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridge ASAP streaming payloads into Mastra-compatible text chunks.
|
|
3
|
+
*
|
|
4
|
+
* Async generator iteration propagates consumer backpressure: the upstream `source` iterator
|
|
5
|
+
* only advances after each `yield`, so a slow consumer naturally throttles reads.
|
|
6
|
+
*
|
|
7
|
+
* @see sprint task 4.1 for SSE parsing and backpressure.
|
|
8
|
+
*/
|
|
9
|
+
export declare function asapStreamToMastraTextStream(source: AsyncIterable<unknown>): AsyncIterable<string>;
|
|
10
|
+
//# sourceMappingURL=streaming.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming.d.ts","sourceRoot":"","sources":["../../src/streaming.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,wBAAuB,4BAA4B,CAAC,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,CAuBzG"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridge ASAP streaming payloads into Mastra-compatible text chunks.
|
|
3
|
+
*
|
|
4
|
+
* Async generator iteration propagates consumer backpressure: the upstream `source` iterator
|
|
5
|
+
* only advances after each `yield`, so a slow consumer naturally throttles reads.
|
|
6
|
+
*
|
|
7
|
+
* @see sprint task 4.1 for SSE parsing and backpressure.
|
|
8
|
+
*/
|
|
9
|
+
function isRecord(x) {
|
|
10
|
+
return typeof x === "object" && x !== null && !Array.isArray(x);
|
|
11
|
+
}
|
|
12
|
+
export async function* asapStreamToMastraTextStream(source) {
|
|
13
|
+
const it = source[Symbol.asyncIterator]();
|
|
14
|
+
try {
|
|
15
|
+
while (true) {
|
|
16
|
+
const { value: event, done } = await it.next();
|
|
17
|
+
if (done) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (!isRecord(event) || event.type !== "task_stream") {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
const payload = event.payload;
|
|
24
|
+
if (!isRecord(payload)) {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
const chunk = payload.chunk;
|
|
28
|
+
if (typeof chunk === "string") {
|
|
29
|
+
yield chunk;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
finally {
|
|
34
|
+
await it.return?.();
|
|
35
|
+
}
|
|
36
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@asap-protocol/mastra",
|
|
3
|
+
"version": "2.3.1",
|
|
4
|
+
"description": "ASAP Protocol capabilities as Mastra tools (@mastra/core)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/adriannoes/asap-protocol"
|
|
13
|
+
},
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=18"
|
|
16
|
+
},
|
|
17
|
+
"peerDependencies": {
|
|
18
|
+
"@asap-protocol/client": "^2.3.0",
|
|
19
|
+
"@mastra/core": "^1.5.0",
|
|
20
|
+
"zod": "^3.25.76 || ^4.1.8"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tshy",
|
|
28
|
+
"test": "vitest run --coverage",
|
|
29
|
+
"test:no-coverage": "vitest run",
|
|
30
|
+
"lint": "eslint .",
|
|
31
|
+
"check:treeshake": "pnpm run build && agadoo ./dist/esm/index.js",
|
|
32
|
+
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@asap-protocol/client": "workspace:*",
|
|
36
|
+
"@eslint/js": "9.18.0",
|
|
37
|
+
"@mastra/core": "^1.35.0",
|
|
38
|
+
"@types/node": "^20.19.0",
|
|
39
|
+
"@vitest/coverage-v8": "4.1.5",
|
|
40
|
+
"agadoo": "3.0.0",
|
|
41
|
+
"eslint": "9.18.0",
|
|
42
|
+
"tshy": "^3.3.2",
|
|
43
|
+
"typescript": "^5.8.3",
|
|
44
|
+
"typescript-eslint": "8.59.1",
|
|
45
|
+
"vitest": "^4.1.1",
|
|
46
|
+
"zod": "^3.25.76"
|
|
47
|
+
},
|
|
48
|
+
"tshy": {
|
|
49
|
+
"project": "./tsconfig.build.json",
|
|
50
|
+
"exports": {
|
|
51
|
+
".": "./src/index.ts"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"exports": {
|
|
55
|
+
".": {
|
|
56
|
+
"import": {
|
|
57
|
+
"types": "./dist/esm/index.d.ts",
|
|
58
|
+
"default": "./dist/esm/index.js"
|
|
59
|
+
},
|
|
60
|
+
"require": {
|
|
61
|
+
"types": "./dist/commonjs/index.d.ts",
|
|
62
|
+
"default": "./dist/commonjs/index.js"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"main": "./dist/commonjs/index.js",
|
|
67
|
+
"types": "./dist/commonjs/index.d.ts",
|
|
68
|
+
"module": "./dist/esm/index.js"
|
|
69
|
+
}
|