@mantyx/sdk 0.21.0 → 0.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/a2a-server.cjs.map +1 -1
- package/dist/a2a-server.d.ts +13 -16
- package/dist/a2a-server.d.ts.map +1 -0
- package/dist/a2a-server.js +1 -1
- package/dist/{chunk-QMUVI3Y3.js → chunk-STB4Z6F4.js} +54 -8
- package/dist/chunk-STB4Z6F4.js.map +1 -0
- package/dist/{client-C7TzTpNW.d.ts → client.d.ts} +83 -831
- package/dist/client.d.ts.map +1 -0
- package/dist/{computer-use-4QzI3lGU.d.ts → computer-use.d.ts} +21 -22
- package/dist/computer-use.d.ts.map +1 -0
- package/dist/errors.d.ts +153 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/index.cjs +54 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +44 -55
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/local-resolver.d.ts +49 -0
- package/dist/local-resolver.d.ts.map +1 -0
- package/dist/oauth.d.ts +189 -0
- package/dist/oauth.d.ts.map +1 -0
- package/dist/playwright.d.ts +6 -11
- package/dist/playwright.d.ts.map +1 -0
- package/dist/sse.d.ts +27 -0
- package/dist/sse.d.ts.map +1 -0
- package/dist/tools.d.ts +426 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/version.d.ts +5 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/zod-to-json-schema.d.ts +25 -0
- package/dist/zod-to-json-schema.d.ts.map +1 -0
- package/package.json +11 -11
- package/dist/a2a-server.d.cts +0 -176
- package/dist/chunk-QMUVI3Y3.js.map +0 -1
- package/dist/client-C7TzTpNW.d.cts +0 -2033
- package/dist/computer-use-1m6E_VIl.d.cts +0 -193
- package/dist/index.d.cts +0 -61
- package/dist/playwright.d.cts +0 -88
package/dist/a2a-server.d.ts
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
import { AgentCard } from '@a2a-js/sdk';
|
|
2
|
-
export { AgentCard, Message, MessageSendParams, Task, TaskArtifactUpdateEvent, TaskStatusUpdateEvent } from '@a2a-js/sdk';
|
|
3
|
-
import { AgentExecutor, RequestContext, ExecutionEventBus } from '@a2a-js/sdk/server';
|
|
4
|
-
export { AgentExecutor, ExecutionEventBus, RequestContext } from '@a2a-js/sdk/server';
|
|
5
|
-
import { M as MantyxClient, T as ToolRef, R as ReasoningLevel, O as OutputSchema } from './client-C7TzTpNW.js';
|
|
6
|
-
import 'zod';
|
|
7
|
-
|
|
8
1
|
/**
|
|
9
2
|
* Expose a MANTYX agent over the [Agent2Agent (A2A)](https://google-a2a.github.io/A2A/)
|
|
10
3
|
* protocol so other agents can talk to it as a peer.
|
|
@@ -44,7 +37,10 @@ import 'zod';
|
|
|
44
37
|
*
|
|
45
38
|
* console.log(`Listening on ${server.url}`);
|
|
46
39
|
*/
|
|
47
|
-
|
|
40
|
+
import type { AgentCard } from "@a2a-js/sdk";
|
|
41
|
+
import type { AgentExecutor, ExecutionEventBus, RequestContext } from "@a2a-js/sdk/server";
|
|
42
|
+
import { type MantyxClient, type OutputSchema } from "./client.js";
|
|
43
|
+
import type { ReasoningLevel, ToolRef } from "./tools.js";
|
|
48
44
|
/**
|
|
49
45
|
* Description of the MANTYX agent that should answer A2A requests.
|
|
50
46
|
*
|
|
@@ -55,7 +51,7 @@ import 'zod';
|
|
|
55
51
|
*
|
|
56
52
|
* Either `agentId` or `systemPrompt` is required.
|
|
57
53
|
*/
|
|
58
|
-
interface MantyxAgentSpec {
|
|
54
|
+
export interface MantyxAgentSpec {
|
|
59
55
|
/** Reference to a persisted MANTYX agent. Mutually exclusive with `systemPrompt`. */
|
|
60
56
|
agentId?: string;
|
|
61
57
|
/** System prompt for an inline / ephemeral agent. Mutually exclusive with `agentId`. */
|
|
@@ -79,7 +75,7 @@ interface MantyxAgentSpec {
|
|
|
79
75
|
*/
|
|
80
76
|
name?: string;
|
|
81
77
|
}
|
|
82
|
-
interface MantyxAgentExecutorOptions {
|
|
78
|
+
export interface MantyxAgentExecutorOptions {
|
|
83
79
|
client: MantyxClient;
|
|
84
80
|
agent: MantyxAgentSpec;
|
|
85
81
|
/**
|
|
@@ -107,7 +103,7 @@ interface MantyxAgentExecutorOptions {
|
|
|
107
103
|
*/
|
|
108
104
|
onAssistantDelta?: (delta: string, ctx: RequestContext, eventBus: ExecutionEventBus) => void;
|
|
109
105
|
}
|
|
110
|
-
interface ServeAgentOverA2AOptions extends MantyxAgentExecutorOptions {
|
|
106
|
+
export interface ServeAgentOverA2AOptions extends MantyxAgentExecutorOptions {
|
|
111
107
|
/** A2A Agent Card published at `/.well-known/agent-card.json`. */
|
|
112
108
|
agentCard: AgentCard;
|
|
113
109
|
/** TCP port to listen on. Default: 0 (let the OS pick). */
|
|
@@ -124,7 +120,7 @@ interface ServeAgentOverA2AOptions extends MantyxAgentExecutorOptions {
|
|
|
124
120
|
*/
|
|
125
121
|
restPath?: string | false;
|
|
126
122
|
}
|
|
127
|
-
interface ServeAgentOverA2AHandle {
|
|
123
|
+
export interface ServeAgentOverA2AHandle {
|
|
128
124
|
/** Origin of the running server, e.g. `"http://localhost:4000"`. */
|
|
129
125
|
url: string;
|
|
130
126
|
/** Resolved port number (useful when you let the OS pick one). */
|
|
@@ -139,7 +135,7 @@ interface ServeAgentOverA2AHandle {
|
|
|
139
135
|
* when you need to mount the executor inside an existing Express, Fastify, or
|
|
140
136
|
* Connect app.
|
|
141
137
|
*/
|
|
142
|
-
declare class MantyxAgentExecutor implements AgentExecutor {
|
|
138
|
+
export declare class MantyxAgentExecutor implements AgentExecutor {
|
|
143
139
|
readonly client: MantyxClient;
|
|
144
140
|
readonly agent: MantyxAgentSpec;
|
|
145
141
|
readonly conversation: "auto" | "stateless";
|
|
@@ -171,6 +167,7 @@ declare class MantyxAgentExecutor implements AgentExecutor {
|
|
|
171
167
|
* Throws if `express` / `@a2a-js/sdk` aren't installed; install them as peer
|
|
172
168
|
* deps with `npm install express @a2a-js/sdk`.
|
|
173
169
|
*/
|
|
174
|
-
declare function serveAgentOverA2A(options: ServeAgentOverA2AOptions): Promise<ServeAgentOverA2AHandle>;
|
|
175
|
-
|
|
176
|
-
export
|
|
170
|
+
export declare function serveAgentOverA2A(options: ServeAgentOverA2AOptions): Promise<ServeAgentOverA2AHandle>;
|
|
171
|
+
export type { AgentCard, Message, MessageSendParams, Task, TaskArtifactUpdateEvent, TaskStatusUpdateEvent, } from "@a2a-js/sdk";
|
|
172
|
+
export type { AgentExecutor, ExecutionEventBus, RequestContext } from "@a2a-js/sdk/server";
|
|
173
|
+
//# sourceMappingURL=a2a-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a2a-server.d.ts","sourceRoot":"","sources":["../src/a2a-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,KAAK,EACV,SAAS,EAOV,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EACjB,cAAc,EACf,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,YAAY,EAIlB,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAI1D;;;;;;;;;GASG;AACH,MAAM,WAAW,eAAe;IAC9B,qFAAqF;IACrF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wFAAwF;IACxF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC;IAClB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC;;;;OAIG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC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G,WAAW,CAAC;IAC5C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,gBAAgB,CAAC,EAAE,0BAA0B,CAAC,kBAAkB,CAAC,CAAC;IAE3E,kEAAkE;IAClE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAmC;IAC5D,iEAAiE;IACjE,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAqB;IAC/C,sEAAsE;IACtE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAsC;IAE/D,YAAY,OAAO,EAAE,0BAA0B,EAU9C;IAEK,OAAO,CAAC,cAAc,EAAE,cAAc,EAAE,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CA0DxF;IAEK,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAO3E;IAED;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAI3B;YAIa,OAAO;YAoBP,kBAAkB;YAelB,aAAa;CAa5B;AAED;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,uBAAuB,CAAC,CAiElC;AA4MD,YAAY,EACV,SAAS,EACT,OAAO,EACP,iBAAiB,EACjB,IAAI,EACJ,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/a2a-server.js
CHANGED
|
@@ -328,12 +328,34 @@ function isZodSchema(value) {
|
|
|
328
328
|
const o = value;
|
|
329
329
|
return typeof o._def !== "undefined" || typeof o._zod !== "undefined";
|
|
330
330
|
}
|
|
331
|
+
function normalizeWireJsonSchema(out, schema) {
|
|
332
|
+
const normalized = { ...out };
|
|
333
|
+
delete normalized.$schema;
|
|
334
|
+
delete normalized.additionalProperties;
|
|
335
|
+
const def = schema._def;
|
|
336
|
+
const kind = schemaKind(def);
|
|
337
|
+
if (kind === "ZodObject" || kind === "object") {
|
|
338
|
+
const shape = def?.shape;
|
|
339
|
+
const fields = typeof shape === "function" ? shape() : shape;
|
|
340
|
+
if (fields) {
|
|
341
|
+
const required = [];
|
|
342
|
+
for (const [key, value] of Object.entries(fields)) {
|
|
343
|
+
if (!isOptionalField(value)) {
|
|
344
|
+
required.push(key);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
if (required.length > 0) normalized.required = required;
|
|
348
|
+
else delete normalized.required;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
return normalized;
|
|
352
|
+
}
|
|
331
353
|
function zodToJsonSchema(schema) {
|
|
332
354
|
const instance = schema;
|
|
333
355
|
if (typeof instance.toJSONSchema === "function") {
|
|
334
356
|
try {
|
|
335
357
|
const out = instance.toJSONSchema();
|
|
336
|
-
if (out && typeof out === "object") return out;
|
|
358
|
+
if (out && typeof out === "object") return normalizeWireJsonSchema(out, schema);
|
|
337
359
|
} catch {
|
|
338
360
|
}
|
|
339
361
|
}
|
|
@@ -341,7 +363,7 @@ function zodToJsonSchema(schema) {
|
|
|
341
363
|
if (typeof builtIn === "function") {
|
|
342
364
|
try {
|
|
343
365
|
const out = builtIn.call(z, schema);
|
|
344
|
-
if (out && typeof out === "object") return out;
|
|
366
|
+
if (out && typeof out === "object") return normalizeWireJsonSchema(out, schema);
|
|
345
367
|
} catch {
|
|
346
368
|
}
|
|
347
369
|
}
|
|
@@ -1019,11 +1041,23 @@ var MantyxClient = class {
|
|
|
1019
1041
|
}
|
|
1020
1042
|
}
|
|
1021
1043
|
async postToolResult(runId, toolUseId, payload) {
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1044
|
+
const path = `/agent-runs/${encodeURIComponent(runId)}/tool-results`;
|
|
1045
|
+
const body = { toolUseId, ...payload };
|
|
1046
|
+
for (let attempt = 0; attempt < TOOL_RESULT_POST_MAX_ATTEMPTS; attempt++) {
|
|
1047
|
+
try {
|
|
1048
|
+
await this.request({
|
|
1049
|
+
method: "POST",
|
|
1050
|
+
path,
|
|
1051
|
+
body
|
|
1052
|
+
});
|
|
1053
|
+
return;
|
|
1054
|
+
} catch (err) {
|
|
1055
|
+
if (attempt === TOOL_RESULT_POST_MAX_ATTEMPTS - 1 || !isToolResultPostRetryable(err)) {
|
|
1056
|
+
return;
|
|
1057
|
+
}
|
|
1058
|
+
await sleep(toolResultPostBackoffMs(attempt));
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1027
1061
|
}
|
|
1028
1062
|
async cancelRun(runId) {
|
|
1029
1063
|
await this.request({
|
|
@@ -1862,6 +1896,18 @@ function parseRunOutput(result, validator) {
|
|
|
1862
1896
|
function sleep(ms) {
|
|
1863
1897
|
return new Promise((r) => setTimeout(r, ms));
|
|
1864
1898
|
}
|
|
1899
|
+
var TOOL_RESULT_POST_MAX_ATTEMPTS = 6;
|
|
1900
|
+
function toolResultPostBackoffMs(attempt) {
|
|
1901
|
+
return Math.min(500 * 2 ** attempt, 8e3);
|
|
1902
|
+
}
|
|
1903
|
+
function isToolResultPostRetryable(err) {
|
|
1904
|
+
if (err instanceof MantyxNetworkError) return true;
|
|
1905
|
+
if (err instanceof MantyxError && typeof err.status === "number") {
|
|
1906
|
+
if (err.status === 429) return true;
|
|
1907
|
+
if (err.status >= 500) return true;
|
|
1908
|
+
}
|
|
1909
|
+
return false;
|
|
1910
|
+
}
|
|
1865
1911
|
function parseRunTokens(value) {
|
|
1866
1912
|
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
1867
1913
|
const v = value;
|
|
@@ -1958,4 +2004,4 @@ export {
|
|
|
1958
2004
|
AgentSession,
|
|
1959
2005
|
parseRunOutput
|
|
1960
2006
|
};
|
|
1961
|
-
//# sourceMappingURL=chunk-
|
|
2007
|
+
//# sourceMappingURL=chunk-STB4Z6F4.js.map
|