@mantyx/sdk 0.22.0 → 0.23.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 +10 -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-5NKXV5XZ.js → chunk-OUK6ZZ5H.js} +87 -14
- package/dist/chunk-OUK6ZZ5H.js.map +1 -0
- package/dist/{client-C7TzTpNW.d.ts → client.d.ts} +131 -840
- 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 +88 -14
- 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 +4 -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/docs/agent-runs-protocol.md +52 -16
- package/package.json +11 -11
- package/dist/a2a-server.d.cts +0 -176
- package/dist/chunk-5NKXV5XZ.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;IAC5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AQ,CAAC,YAAY,EAAE,MAAM,GAAG,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
|
}
|
|
@@ -946,7 +968,8 @@ var MantyxClient = class {
|
|
|
946
968
|
const evType = sseEvent.event ?? data.type ?? "message";
|
|
947
969
|
const seq = typeof data.seq === "number" ? data.seq : lastSeq;
|
|
948
970
|
if (typeof seq === "number" && seq > lastSeq) lastSeq = seq;
|
|
949
|
-
const
|
|
971
|
+
const payload = runEventPayload(data);
|
|
972
|
+
const ev = { seq, type: evType, ...payload };
|
|
950
973
|
yield ev;
|
|
951
974
|
if (evType === "local_tool_call") {
|
|
952
975
|
const localEv = ev;
|
|
@@ -1752,14 +1775,41 @@ function normalizeSupervisor(value) {
|
|
|
1752
1775
|
}
|
|
1753
1776
|
return out;
|
|
1754
1777
|
}
|
|
1778
|
+
var PLAN_MODES = /* @__PURE__ */ new Set(["off", "auto", "required"]);
|
|
1779
|
+
var TASK_PLAN_STEP_STATUSES = /* @__PURE__ */ new Set([
|
|
1780
|
+
"pending",
|
|
1781
|
+
"in_progress",
|
|
1782
|
+
"done",
|
|
1783
|
+
"blocked",
|
|
1784
|
+
"skipped"
|
|
1785
|
+
]);
|
|
1786
|
+
function assertPlanMode(field, value) {
|
|
1787
|
+
if (typeof value !== "string" || !PLAN_MODES.has(value)) {
|
|
1788
|
+
throw new MantyxError(
|
|
1789
|
+
`${field} must be "off", "auto", or "required", got ${JSON.stringify(value)}`
|
|
1790
|
+
);
|
|
1791
|
+
}
|
|
1792
|
+
return value;
|
|
1793
|
+
}
|
|
1794
|
+
function runEventPayload(data) {
|
|
1795
|
+
const nested = data.data;
|
|
1796
|
+
if (nested && typeof nested === "object" && !Array.isArray(nested)) {
|
|
1797
|
+
return nested;
|
|
1798
|
+
}
|
|
1799
|
+
return data;
|
|
1800
|
+
}
|
|
1755
1801
|
function normalizePlan(value) {
|
|
1756
1802
|
if (value === true || value === false) return value;
|
|
1803
|
+
if (typeof value === "string") return assertPlanMode("plan", value);
|
|
1757
1804
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
1758
1805
|
throw new MantyxError(
|
|
1759
|
-
`plan must be \`true\`, \`false\`, or an object { planOnly?, brief?, steps? }, got ${JSON.stringify(value)}`
|
|
1806
|
+
`plan must be "off", "auto", "required", \`true\`, \`false\`, or an object { mode?, planOnly?, brief?, steps? }, got ${JSON.stringify(value)}`
|
|
1760
1807
|
);
|
|
1761
1808
|
}
|
|
1762
1809
|
const out = {};
|
|
1810
|
+
if (value.mode !== void 0) {
|
|
1811
|
+
out.mode = assertPlanMode("plan.mode", value.mode);
|
|
1812
|
+
}
|
|
1763
1813
|
if (value.planOnly !== void 0) {
|
|
1764
1814
|
if (typeof value.planOnly !== "boolean") {
|
|
1765
1815
|
throw new MantyxError(`plan.planOnly must be a boolean, got ${JSON.stringify(value.planOnly)}`);
|
|
@@ -1788,6 +1838,17 @@ function normalizePlan(value) {
|
|
|
1788
1838
|
}
|
|
1789
1839
|
return out;
|
|
1790
1840
|
}
|
|
1841
|
+
function parseTaskPlanStep(entry) {
|
|
1842
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry)) return void 0;
|
|
1843
|
+
const row = entry;
|
|
1844
|
+
const title = row.title;
|
|
1845
|
+
const status = row.status;
|
|
1846
|
+
if (typeof title !== "string" || typeof status !== "string") return void 0;
|
|
1847
|
+
if (!TASK_PLAN_STEP_STATUSES.has(status)) return void 0;
|
|
1848
|
+
const step = { title, status };
|
|
1849
|
+
if (typeof row.id === "string" && row.id) step.id = row.id;
|
|
1850
|
+
return step;
|
|
1851
|
+
}
|
|
1791
1852
|
function parseTaskPlan(raw) {
|
|
1792
1853
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
1793
1854
|
const obj = raw;
|
|
@@ -1795,17 +1856,28 @@ function parseTaskPlan(raw) {
|
|
|
1795
1856
|
if (!Array.isArray(stepsRaw)) return void 0;
|
|
1796
1857
|
const steps = [];
|
|
1797
1858
|
for (const entry of stepsRaw) {
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1859
|
+
const step = parseTaskPlanStep(entry);
|
|
1860
|
+
if (step !== void 0) steps.push(step);
|
|
1861
|
+
}
|
|
1862
|
+
const out = { steps };
|
|
1863
|
+
if (typeof obj.v === "number") out.v = obj.v;
|
|
1864
|
+
if (typeof obj.planId === "string" && obj.planId) out.planId = obj.planId;
|
|
1865
|
+
if (typeof obj.revision === "number") out.revision = obj.revision;
|
|
1866
|
+
if (typeof obj.mode === "string" && PLAN_MODES.has(obj.mode)) {
|
|
1867
|
+
out.mode = obj.mode;
|
|
1805
1868
|
}
|
|
1869
|
+
if (typeof obj.source === "string" && obj.source) out.source = obj.source;
|
|
1806
1870
|
const briefRaw = obj.brief;
|
|
1807
|
-
|
|
1808
|
-
return
|
|
1871
|
+
if (typeof briefRaw === "string" && briefRaw) out.brief = briefRaw;
|
|
1872
|
+
return out;
|
|
1873
|
+
}
|
|
1874
|
+
function taskPlanFromEventData(data) {
|
|
1875
|
+
const canonical = data.plan;
|
|
1876
|
+
if (canonical !== void 0) {
|
|
1877
|
+
const parsed = parseTaskPlan(canonical);
|
|
1878
|
+
if (parsed !== void 0) return parsed;
|
|
1879
|
+
}
|
|
1880
|
+
return parseTaskPlan(data);
|
|
1809
1881
|
}
|
|
1810
1882
|
function normalizeToolBudgets(value) {
|
|
1811
1883
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
@@ -1980,6 +2052,7 @@ export {
|
|
|
1980
2052
|
planOnly,
|
|
1981
2053
|
MantyxClient,
|
|
1982
2054
|
AgentSession,
|
|
2055
|
+
taskPlanFromEventData,
|
|
1983
2056
|
parseRunOutput
|
|
1984
2057
|
};
|
|
1985
|
-
//# sourceMappingURL=chunk-
|
|
2058
|
+
//# sourceMappingURL=chunk-OUK6ZZ5H.js.map
|