@mantyx/sdk 0.25.0 → 2026.9.2
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 +21 -1
- package/LICENSE +201 -0
- package/README.md +20 -7
- package/dist/a2a-server.cjs +2 -1
- package/dist/a2a-server.d.ts +2 -1
- package/dist/a2a-server.js +3 -2
- package/dist/{chunk-4EJRV6KZ.js → chunk-XMNAWLMF.js} +36 -2
- package/dist/client.d.ts +40 -1
- package/dist/computer-use.d.ts +0 -1
- package/dist/errors.d.ts +0 -1
- package/dist/index.cjs +37 -3
- package/dist/index.d.ts +1 -2
- package/dist/index.js +2 -3
- package/dist/local-resolver.d.ts +0 -1
- package/dist/oauth.d.ts +0 -1
- package/dist/playwright.cjs +0 -1
- package/dist/playwright.d.ts +0 -1
- package/dist/playwright.js +0 -1
- package/dist/sse.d.ts +0 -1
- package/dist/structured-output.d.ts +0 -1
- package/dist/tools.d.ts +0 -1
- package/dist/version.d.ts +2 -3
- package/dist/zod-to-json-schema.d.ts +0 -1
- package/docs/agent-runs-protocol.md +69 -4
- package/package.json +17 -18
- package/CONTRIBUTING.md +0 -72
- package/EXTRACT.md +0 -70
- package/dist/a2a-server.cjs.map +0 -1
- package/dist/a2a-server.d.ts.map +0 -1
- package/dist/a2a-server.js.map +0 -1
- package/dist/chunk-4EJRV6KZ.js.map +0 -1
- package/dist/client.d.ts.map +0 -1
- package/dist/computer-use.d.ts.map +0 -1
- package/dist/errors.d.ts.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/local-resolver.d.ts.map +0 -1
- package/dist/oauth.d.ts.map +0 -1
- package/dist/playwright.cjs.map +0 -1
- package/dist/playwright.d.ts.map +0 -1
- package/dist/playwright.js.map +0 -1
- package/dist/sse.d.ts.map +0 -1
- package/dist/structured-output.d.ts.map +0 -1
- package/dist/tools.d.ts.map +0 -1
- package/dist/version.d.ts.map +0 -1
- package/dist/zod-to-json-schema.d.ts.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -945,6 +945,7 @@ var MantyxClient = class {
|
|
|
945
945
|
if (opts.status) query.status = opts.status;
|
|
946
946
|
if (typeof opts.limit === "number") query.limit = opts.limit;
|
|
947
947
|
if (typeof opts.offset === "number") query.offset = opts.offset;
|
|
948
|
+
if (opts.cursor) query.cursor = opts.cursor;
|
|
948
949
|
return this.request({
|
|
949
950
|
method: "GET",
|
|
950
951
|
path: "/agent-sessions",
|
|
@@ -971,6 +972,28 @@ var MantyxClient = class {
|
|
|
971
972
|
});
|
|
972
973
|
return res.events ?? [];
|
|
973
974
|
}
|
|
975
|
+
/**
|
|
976
|
+
* Fetch one bounded page of session events. Pages are returned in ascending
|
|
977
|
+
* sequence order; follow `nextBeforeSeq` to walk backward through history.
|
|
978
|
+
*/
|
|
979
|
+
async getSessionEventsPage(sessionId, opts = {}) {
|
|
980
|
+
const query = {
|
|
981
|
+
lastMessages: opts.lastMessages ?? 100,
|
|
982
|
+
beforeSeq: opts.beforeSeq
|
|
983
|
+
};
|
|
984
|
+
const res = await this.request({
|
|
985
|
+
method: "GET",
|
|
986
|
+
path: `/agent-sessions/${encodeURIComponent(sessionId)}/events`,
|
|
987
|
+
query
|
|
988
|
+
});
|
|
989
|
+
return {
|
|
990
|
+
sessionId: res.sessionId,
|
|
991
|
+
total: res.total,
|
|
992
|
+
events: res.events ?? [],
|
|
993
|
+
nextBeforeSeq: res.nextBeforeSeq ?? null,
|
|
994
|
+
truncated: res.truncated ?? false
|
|
995
|
+
};
|
|
996
|
+
}
|
|
974
997
|
// ----------------------------------------------------------- Internals
|
|
975
998
|
/** Drive an existing run to completion (collect events, dispatch local tools). */
|
|
976
999
|
async driveRun(runId, handlers, opts = {}) {
|
|
@@ -1290,7 +1313,7 @@ var MantyxClient = class {
|
|
|
1290
1313
|
const agentRunId = typeof record.agentRunId === "string" ? record.agentRunId : typeof nested?.agentRunId === "string" ? nested.agentRunId : "";
|
|
1291
1314
|
if (agentRunId) {
|
|
1292
1315
|
const localEv = evalEventToLocalToolCall(ev);
|
|
1293
|
-
|
|
1316
|
+
await this.dispatchLocalTool(agentRunId, localEv, handlers);
|
|
1294
1317
|
}
|
|
1295
1318
|
}
|
|
1296
1319
|
options.onEvent?.(ev);
|
|
@@ -1478,6 +1501,7 @@ var AgentSession = class {
|
|
|
1478
1501
|
}
|
|
1479
1502
|
if (this.tools.length > 0) body.tools = serializeToolRefs(this.tools);
|
|
1480
1503
|
if (opts.metadata && Object.keys(opts.metadata).length > 0) body.metadata = opts.metadata;
|
|
1504
|
+
if (opts.newLoop !== void 0) body.newLoop = opts.newLoop;
|
|
1481
1505
|
if (opts.reasoningLevel !== void 0) {
|
|
1482
1506
|
body.reasoningLevel = normalizeReasoningLevel(opts.reasoningLevel);
|
|
1483
1507
|
}
|
|
@@ -1518,6 +1542,12 @@ var AgentSession = class {
|
|
|
1518
1542
|
async info() {
|
|
1519
1543
|
return this.client.getSessionInfo(this.id);
|
|
1520
1544
|
}
|
|
1545
|
+
async events(opts = {}) {
|
|
1546
|
+
return this.client.getSessionEvents(this.id, opts);
|
|
1547
|
+
}
|
|
1548
|
+
async eventsPage(opts = {}) {
|
|
1549
|
+
return this.client.getSessionEventsPage(this.id, opts);
|
|
1550
|
+
}
|
|
1521
1551
|
async end() {
|
|
1522
1552
|
try {
|
|
1523
1553
|
await this.client.endSession(this.id);
|
|
@@ -1557,6 +1587,7 @@ function serializeAgentSpec(spec, extra = {}) {
|
|
|
1557
1587
|
if (spec.agentId) body.agentId = spec.agentId;
|
|
1558
1588
|
if (spec.name) body.name = spec.name;
|
|
1559
1589
|
if (spec.modelId) body.modelId = spec.modelId;
|
|
1590
|
+
if (spec.newLoop !== void 0) body.newLoop = spec.newLoop;
|
|
1560
1591
|
if (spec.reasoningLevel !== void 0) {
|
|
1561
1592
|
body.reasoningLevel = normalizeReasoningLevel(spec.reasoningLevel);
|
|
1562
1593
|
}
|
|
@@ -1596,6 +1627,7 @@ function serializeCreateEvalRunRequest(spec) {
|
|
|
1596
1627
|
throw new MantyxError("createEvalRun accepts only one of `agentId` or `agent`");
|
|
1597
1628
|
}
|
|
1598
1629
|
const body = {};
|
|
1630
|
+
if (spec.newLoop !== void 0) body.newLoop = spec.newLoop;
|
|
1599
1631
|
if (spec.datasetId) body.datasetId = spec.datasetId;
|
|
1600
1632
|
if (spec.dataset) body.dataset = spec.dataset;
|
|
1601
1633
|
if (spec.agentId) body.agentId = spec.agentId;
|
|
@@ -1761,6 +1793,9 @@ function normalizeOutputSchema(value) {
|
|
|
1761
1793
|
}
|
|
1762
1794
|
out.enforcement = value.enforcement;
|
|
1763
1795
|
}
|
|
1796
|
+
if (value.schema == null) {
|
|
1797
|
+
throw new MantyxError("outputSchema.schema must be a Zod schema or a non-null JSON object");
|
|
1798
|
+
}
|
|
1764
1799
|
const schema = toToolParametersWire(
|
|
1765
1800
|
value.schema
|
|
1766
1801
|
);
|
|
@@ -2712,7 +2747,7 @@ async function runComputerUse(opts) {
|
|
|
2712
2747
|
}
|
|
2713
2748
|
|
|
2714
2749
|
// src/version.ts
|
|
2715
|
-
var SDK_VERSION = "
|
|
2750
|
+
var SDK_VERSION = "2026.9.2";
|
|
2716
2751
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2717
2752
|
0 && (module.exports = {
|
|
2718
2753
|
AgentSession,
|
|
@@ -2755,4 +2790,3 @@ var SDK_VERSION = "0.25.0";
|
|
|
2755
2790
|
toToolParametersWire,
|
|
2756
2791
|
zodToJsonSchema
|
|
2757
2792
|
});
|
|
2758
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/index.d.ts
CHANGED
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
* console.log(result.text);
|
|
35
35
|
*/
|
|
36
36
|
export { MantyxClient, AgentSession, DEFAULT_BASE_URL, parseRunOutput, planOnly, taskPlanFromEventData, inputFileAttachment, inputFileUrlAttachment, } from "./client.js";
|
|
37
|
-
export type { MantyxClientOptions, ModelInfo, ModelCatalog, AgentSpecBase, RunSpec, SessionSpec, OutputSchema, OutputSchemaValue, LoopDetection, ToolBudget, ToolBudgets, Supervisor, SupervisorAction, SupervisorPhase, ReasoningTrigger, PlanOptions, PlanMode, PlanSpec, TaskPlan, TaskPlanStep, TaskPlanStepStatus, TaskPlanTransition, RunResult, RunTokenUsage, RunModelInfo, RunEvent, RunEventBase, AssistantDeltaEvent, ThinkingDeltaEvent, AssistantMessageEvent, UserMessageEvent, InputFileAttachment, InputFileUrlAttachment, MessageAttachment, InputFileAttachmentMetadata, InputFileUrlAttachmentMetadata, AttachmentMetadata, ConversationMessage, ServerToolResultEvent, LocalToolCallEvent, LocalToolResultInEvent, LoopDetectedEvent, ToolBudgetExceededEvent, SupervisorEvent, TaskPlanEvent, ResultEvent, ErrorEvent, CancelledEvent, SessionInfo, SessionSummary, SessionListResult, LocalHandlers, RunFeedbackVerdict, RunFeedbackInput, RunFeedbackResult, EvalRunStatus, InlineEvalCaseSpec, InlineEvalDatasetSpec, AgentEvalOverrides, CreateEvalRunRequest, EvalDatasetSummary, EvalDatasetList, EvalCase, EvalDatasetDetail, EvalRunAccepted, EvalRunSummary, EvalCaseResult, EvalRunDetail, EvalRunList, EvalRunCompareSide, EvalRunCompareCase, EvalRunCompare, EvalRunEvent, ListEvalRunsOptions, RunEvalOptions, } from "./client.js";
|
|
37
|
+
export type { MantyxClientOptions, ModelInfo, ModelCatalog, AgentSpecBase, RunSpec, SessionSpec, OutputSchema, OutputSchemaValue, LoopDetection, ToolBudget, ToolBudgets, Supervisor, SupervisorAction, SupervisorPhase, ReasoningTrigger, PlanOptions, PlanMode, PlanSpec, TaskPlan, TaskPlanStep, TaskPlanStepStatus, TaskPlanTransition, RunResult, RunTokenUsage, RunModelInfo, RunEvent, RunEventBase, AssistantDeltaEvent, ThinkingDeltaEvent, AssistantMessageEvent, UserMessageEvent, InputFileAttachment, InputFileUrlAttachment, MessageAttachment, InputFileAttachmentMetadata, InputFileUrlAttachmentMetadata, AttachmentMetadata, ConversationMessage, ServerToolResultEvent, LocalToolCallEvent, LocalToolResultInEvent, LoopDetectedEvent, ToolBudgetExceededEvent, SupervisorEvent, TaskPlanEvent, ResultEvent, ErrorEvent, CancelledEvent, SessionInfo, SessionSummary, SessionListResult, SessionEventsPage, LocalHandlers, RunFeedbackVerdict, RunFeedbackInput, RunFeedbackResult, EvalRunStatus, InlineEvalCaseSpec, InlineEvalDatasetSpec, AgentEvalOverrides, CreateEvalRunRequest, EvalDatasetSummary, EvalDatasetList, EvalCase, EvalDatasetDetail, EvalRunAccepted, EvalRunSummary, EvalCaseResult, EvalRunDetail, EvalRunList, EvalRunCompareSide, EvalRunCompareCase, EvalRunCompare, EvalRunEvent, ListEvalRunsOptions, RunEvalOptions, } from "./client.js";
|
|
38
38
|
export { defineLocalTool, mantyxTool, mantyxPluginTool, mantyxA2A, defineLocalA2A, mantyxMcp, defineLocalMcp, isLocalTool, isLocalA2ATool, isLocalMcpServer, } from "./tools.js";
|
|
39
39
|
export type { LocalTool, LocalToolResult, LocalToolOutput, ToolResultFile, MantyxToolRef, MantyxPluginToolRef, ToolRef, ZodLikeObject, DefineLocalToolOptions, ReasoningLevel, A2AToolRef, LocalA2ATool, McpToolRef, LocalMcpServer, LocalMcpHttpTransport, LocalMcpStdioTransport, MantyxA2AOptions, DefineLocalA2AOptions, MantyxMcpOptions, DefineLocalMcpOptions, } from "./tools.js";
|
|
40
40
|
export { MantyxError, MantyxAuthError, MantyxNetworkError, MantyxParseError, MantyxScopeError, MantyxToolError, MantyxRunError, } from "./errors.js";
|
|
@@ -48,4 +48,3 @@ export { zodToJsonSchema, toToolParametersWire } from "./zod-to-json-schema.js";
|
|
|
48
48
|
export { readSseStream } from "./sse.js";
|
|
49
49
|
export type { SseEvent, SseStreamOptions } from "./sse.js";
|
|
50
50
|
export { SDK_VERSION } from "./version.js";
|
|
51
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
taskPlanFromEventData,
|
|
28
28
|
toToolParametersWire,
|
|
29
29
|
zodToJsonSchema
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-XMNAWLMF.js";
|
|
31
31
|
|
|
32
32
|
// src/oauth.ts
|
|
33
33
|
var DEFAULT_OAUTH_BASE_URL = "https://app.mantyx.io";
|
|
@@ -603,7 +603,7 @@ async function runComputerUse(opts) {
|
|
|
603
603
|
}
|
|
604
604
|
|
|
605
605
|
// src/version.ts
|
|
606
|
-
var SDK_VERSION = "
|
|
606
|
+
var SDK_VERSION = "2026.9.2";
|
|
607
607
|
export {
|
|
608
608
|
AgentSession,
|
|
609
609
|
COMPUTER_USE_ACTIONS,
|
|
@@ -645,4 +645,3 @@ export {
|
|
|
645
645
|
toToolParametersWire,
|
|
646
646
|
zodToJsonSchema
|
|
647
647
|
};
|
|
648
|
-
//# sourceMappingURL=index.js.map
|
package/dist/local-resolver.d.ts
CHANGED
package/dist/oauth.d.ts
CHANGED
package/dist/playwright.cjs
CHANGED
package/dist/playwright.d.ts
CHANGED
|
@@ -80,4 +80,3 @@ export declare class PlaywrightController implements BrowserController {
|
|
|
80
80
|
}
|
|
81
81
|
/** @internal Exported for unit tests. */
|
|
82
82
|
export declare function scrollDelta(direction: ScrollDirection, magnitude: number): [number, number];
|
|
83
|
-
//# sourceMappingURL=playwright.d.ts.map
|
package/dist/playwright.js
CHANGED
package/dist/sse.d.ts
CHANGED
|
@@ -24,4 +24,3 @@ export interface SseStreamOptions {
|
|
|
24
24
|
* Comment frames (`:keep-alive`) are dropped.
|
|
25
25
|
*/
|
|
26
26
|
export declare function readSseStream(body: ReadableStream<Uint8Array> | null, opts?: SseStreamOptions): AsyncGenerator<SseEvent, void, void>;
|
|
27
|
-
//# sourceMappingURL=sse.d.ts.map
|
package/dist/tools.d.ts
CHANGED
package/dist/version.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Release version — synced from
|
|
2
|
+
* Release version — synced from sdk/VERSION (`pnpm run sync-version`).
|
|
3
3
|
*/
|
|
4
|
-
export declare const SDK_VERSION = "
|
|
5
|
-
//# sourceMappingURL=version.d.ts.map
|
|
4
|
+
export declare const SDK_VERSION = "2026.9.2";
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Agent Runs — wire protocol
|
|
2
2
|
|
|
3
|
+
See [harness loop opt-in](#harness-loop-opt-in) for `newLoop: true` opt-in, session inheritance, A2A/MCP parameters, and completion-review events.
|
|
4
|
+
|
|
3
5
|
This document specifies the public wire protocol that the MANTYX agent-runs API
|
|
4
6
|
speaks with SDKs. It is the source of truth for anyone implementing a new
|
|
5
7
|
client (Python, Rust, Java…) and is shipped with each first-party SDK so the
|
|
@@ -119,6 +121,7 @@ two differences:
|
|
|
119
121
|
| ------------------------------------------------ | ---------------------- |
|
|
120
122
|
| `GET .../models` | `models:read` |
|
|
121
123
|
| `POST .../agent-runs` | `runs:write` |
|
|
124
|
+
| `GET .../agent-runs` | `runs:read` |
|
|
122
125
|
| `GET .../agent-runs/{runId}` | `runs:read` |
|
|
123
126
|
| `GET .../agent-runs/{runId}/stream` | `runs:read` |
|
|
124
127
|
| `POST .../agent-runs/{runId}/cancel` | `runs:write` |
|
|
@@ -1146,6 +1149,7 @@ public `GET /agent-sessions` endpoint and the admin list endpoints; see
|
|
|
1146
1149
|
|
|
1147
1150
|
```
|
|
1148
1151
|
POST /api/v1/workspaces/{slug}/agent-runs
|
|
1152
|
+
GET /api/v1/workspaces/{slug}/agent-runs
|
|
1149
1153
|
GET /api/v1/workspaces/{slug}/agent-runs/{runId}
|
|
1150
1154
|
GET /api/v1/workspaces/{slug}/agent-runs/{runId}/stream
|
|
1151
1155
|
POST /api/v1/workspaces/{slug}/agent-runs/{runId}/tool-results
|
|
@@ -1164,6 +1168,52 @@ POST /api/v1/workspaces/{slug}/agent-runs/{runId}/feedback
|
|
|
1164
1168
|
|
|
1165
1169
|
`GET .../stream` is the canonical event channel; see §7.
|
|
1166
1170
|
|
|
1171
|
+
`GET /agent-runs` returns compact calls newest-first. Pass its opaque
|
|
1172
|
+
`nextCursor` value back as `cursor` for stable keyset pagination. Supported
|
|
1173
|
+
filters are `status`, `modelId`, `agentId`, and repeatable, AND-combined
|
|
1174
|
+
`metadata=key:value`; `limit` defaults to 50 (max 200). Exact counts are
|
|
1175
|
+
skipped by default; `includeTotal=1` adds `total`.
|
|
1176
|
+
|
|
1177
|
+
```json
|
|
1178
|
+
{
|
|
1179
|
+
"total": null,
|
|
1180
|
+
"limit": 50,
|
|
1181
|
+
"nextCursor": "eyJjcmVhdGVkQXQiOiIyMDI5…",
|
|
1182
|
+
"runs": [
|
|
1183
|
+
{
|
|
1184
|
+
"id": "run_abc",
|
|
1185
|
+
"sessionId": null,
|
|
1186
|
+
"status": "succeeded",
|
|
1187
|
+
"specName": "support-bot",
|
|
1188
|
+
"agentId": null,
|
|
1189
|
+
"modelId": "platform:demo",
|
|
1190
|
+
"inputPreview": "Where is my order?",
|
|
1191
|
+
"outputPreview": "It shipped on Tuesday.",
|
|
1192
|
+
"error": null,
|
|
1193
|
+
"tokens": {
|
|
1194
|
+
"inputTokens": 812,
|
|
1195
|
+
"cachedTokens": 0,
|
|
1196
|
+
"reasoningTokens": 0,
|
|
1197
|
+
"outputTokens": 96
|
|
1198
|
+
},
|
|
1199
|
+
"turns": 2,
|
|
1200
|
+
"durationMs": 4213,
|
|
1201
|
+
"toolCallCount": 1,
|
|
1202
|
+
"metadata": { "customer": "acme" },
|
|
1203
|
+
"createdAt": "2029-01-05T13:00:00.000Z",
|
|
1204
|
+
"completedAt": "2029-01-05T13:00:04.213Z"
|
|
1205
|
+
}
|
|
1206
|
+
]
|
|
1207
|
+
}
|
|
1208
|
+
```
|
|
1209
|
+
|
|
1210
|
+
The list is a projection, not a snapshot: `inputPreview` / `outputPreview` /
|
|
1211
|
+
`error` are truncated, and `total` is `null` unless `includeTotal=1`. Fetch
|
|
1212
|
+
`GET /agent-runs/{runId}` for full text, the spec, and `model`. `modelId`,
|
|
1213
|
+
`durationMs`, and `toolCallCount` are populated when the run reaches a
|
|
1214
|
+
terminal state; `agentId` is `null` for runs that did not target a saved
|
|
1215
|
+
workspace agent.
|
|
1216
|
+
|
|
1167
1217
|
`GET /agent-runs/{runId}` returns the run snapshot (status, final text, error,
|
|
1168
1218
|
spec, plus the cost-attribution triple `tokens` / `turns` / `model` —
|
|
1169
1219
|
see §7.1) without subscribing to live events. Useful for polling long
|
|
@@ -1199,7 +1249,9 @@ application identifiers they attached at create time (see §4.9).
|
|
|
1199
1249
|
| `metadata` | Repeatable `key:value` filter; AND-combined. Malformed entries return `400 invalid_request`. |
|
|
1200
1250
|
| `status` | Optional exact match (`active` / `ended`). |
|
|
1201
1251
|
| `limit` | Default `50`, max `200`. |
|
|
1202
|
-
| `
|
|
1252
|
+
| `cursor` | Opaque `nextCursor` from the prior page; preferred for deep paging. |
|
|
1253
|
+
| `offset` | Legacy fallback, default `0`; ignored when `cursor` is present. |
|
|
1254
|
+
| `includeTotal` | Defaults to true; set `0` to skip the exact count query. |
|
|
1203
1255
|
|
|
1204
1256
|
```http
|
|
1205
1257
|
GET /api/v1/workspaces/acme/agent-sessions?metadata=customer:acme&metadata=env:prod&limit=20
|
|
@@ -1210,6 +1262,7 @@ GET /api/v1/workspaces/acme/agent-sessions?metadata=customer:acme&metadata=env:p
|
|
|
1210
1262
|
"total": 1,
|
|
1211
1263
|
"limit": 20,
|
|
1212
1264
|
"offset": 0,
|
|
1265
|
+
"nextCursor": null,
|
|
1213
1266
|
"sessions": [
|
|
1214
1267
|
{
|
|
1215
1268
|
"sessionId": "ses_abc",
|
|
@@ -1235,8 +1288,13 @@ stream (§7). Unknown session ids return `404 not_found`.
|
|
|
1235
1288
|
|
|
1236
1289
|
| Query param | Notes |
|
|
1237
1290
|
| -------------- | ------------------------------------------------------------------------------- |
|
|
1238
|
-
| `full` | `1` / `true` returns
|
|
1239
|
-
| `lastMessages` |
|
|
1291
|
+
| `full` | `1` / `true` returns the complete history and overrides paging parameters. |
|
|
1292
|
+
| `lastMessages` | Opt into paging and return the last `N` messages (max 500). |
|
|
1293
|
+
| `beforeSeq` | Page backward from an earlier message sequence (default page size 100). |
|
|
1294
|
+
|
|
1295
|
+
For backwards compatibility, omitting all three parameters returns the complete
|
|
1296
|
+
history. New clients should use `lastMessages` and follow `nextBeforeSeq` for
|
|
1297
|
+
bounded reads.
|
|
1240
1298
|
|
|
1241
1299
|
```http
|
|
1242
1300
|
GET /api/v1/workspaces/acme/agent-sessions/ses_abc/events?lastMessages=2
|
|
@@ -1250,12 +1308,15 @@ GET /api/v1/workspaces/acme/agent-sessions/ses_abc/events?lastMessages=2
|
|
|
1250
1308
|
{ "seq": 3, "type": "user_message", "text": "three" },
|
|
1251
1309
|
{ "seq": 4, "type": "assistant_message", "text": "four" },
|
|
1252
1310
|
],
|
|
1311
|
+
"nextBeforeSeq": 3,
|
|
1312
|
+
"truncated": true,
|
|
1253
1313
|
}
|
|
1254
1314
|
```
|
|
1255
1315
|
|
|
1256
1316
|
Frames use the flattened wire shape clients already consume from SSE
|
|
1257
1317
|
(`{ seq, type, ...payload }`). `seq` is the message's position in the full
|
|
1258
|
-
conversation (stable across paging).
|
|
1318
|
+
conversation (stable across paging). `truncated` is true while older messages
|
|
1319
|
+
remain. Reconstructed turns map as:
|
|
1259
1320
|
|
|
1260
1321
|
| Stored role | Frame `type` |
|
|
1261
1322
|
| ----------- | ---------------------------------- |
|
|
@@ -1765,3 +1826,7 @@ A reference SDK should:
|
|
|
1765
1826
|
The npm package [`@mantyx/sdk`](https://www.npmjs.com/package/@mantyx/sdk) and the Go module
|
|
1766
1827
|
[`github.com/mantyx/mantyx-go-sdk`](https://github.com/mantyx/mantyx-go-sdk) are reference implementations of this protocol
|
|
1767
1828
|
(maintained in the official **mantyx-sdk** repositories).
|
|
1829
|
+
|
|
1830
|
+
## Harness loop opt-in
|
|
1831
|
+
|
|
1832
|
+
External agent runs and new sessions use the existing loop unless `newLoop: true` is supplied. The same optional boolean is supported by eval creation. Session messages inherit the stored session setting when omitted; explicit `false` selects the existing loop for that turn. A2A server wrappers forward the configured selection. Harness events such as `completion_review` and `harness_decision` are available through normal event callbacks.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mantyx/sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2026.9.2",
|
|
4
4
|
"description": "MANTYX as a hosted agent runtime: define ephemeral agents, mix server-side MANTYX tools with locally-executed tools, run them remotely.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -28,24 +28,14 @@
|
|
|
28
28
|
"docs",
|
|
29
29
|
"README.md",
|
|
30
30
|
"CHANGELOG.md",
|
|
31
|
-
"
|
|
32
|
-
"EXTRACT.md"
|
|
31
|
+
"LICENSE"
|
|
33
32
|
],
|
|
34
|
-
"scripts": {
|
|
35
|
-
"sync-version": "node ../scripts/sync-version.mjs",
|
|
36
|
-
"build": "tsup --config tsup.config.ts && tsc -p tsconfig.build.json",
|
|
37
|
-
"dev": "tsup --config tsup.config.ts --watch",
|
|
38
|
-
"typecheck": "tsc --noEmit",
|
|
39
|
-
"test": "vitest run",
|
|
40
|
-
"test:watch": "vitest",
|
|
41
|
-
"prepublishOnly": "npm run build"
|
|
42
|
-
},
|
|
43
33
|
"engines": {
|
|
44
34
|
"node": ">=18.17.0"
|
|
45
35
|
},
|
|
46
36
|
"dependencies": {
|
|
47
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
48
|
-
"zod": "^4.
|
|
37
|
+
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
38
|
+
"zod": "^4.6.5"
|
|
49
39
|
},
|
|
50
40
|
"peerDependencies": {
|
|
51
41
|
"@a2a-js/sdk": "^0.3.0",
|
|
@@ -66,12 +56,12 @@
|
|
|
66
56
|
"devDependencies": {
|
|
67
57
|
"@a2a-js/sdk": "^0.3.14",
|
|
68
58
|
"@types/express": "^5.0.6",
|
|
69
|
-
"@types/node": "^26.
|
|
59
|
+
"@types/node": "^26.6.1",
|
|
70
60
|
"express": "^5.2.1",
|
|
71
61
|
"playwright": "^1.61.1",
|
|
72
62
|
"tsup": "^8.5.1",
|
|
73
|
-
"typescript": "
|
|
74
|
-
"vitest": "^4.1.
|
|
63
|
+
"typescript": "~7.0.2",
|
|
64
|
+
"vitest": "^4.1.11"
|
|
75
65
|
},
|
|
76
66
|
"keywords": [
|
|
77
67
|
"mantyx",
|
|
@@ -85,5 +75,14 @@
|
|
|
85
75
|
"license": "Apache-2.0",
|
|
86
76
|
"publishConfig": {
|
|
87
77
|
"access": "public"
|
|
78
|
+
},
|
|
79
|
+
"homepage": "https://mantyx-io.github.io/mantyx-sdk/",
|
|
80
|
+
"scripts": {
|
|
81
|
+
"sync-version": "node ../scripts/sync-version.mjs",
|
|
82
|
+
"build": "tsup --config tsup.config.ts && tsc -p tsconfig.build.json",
|
|
83
|
+
"dev": "tsup --config tsup.config.ts --watch",
|
|
84
|
+
"typecheck": "tsc --noEmit",
|
|
85
|
+
"test": "vitest run",
|
|
86
|
+
"test:watch": "vitest"
|
|
88
87
|
}
|
|
89
|
-
}
|
|
88
|
+
}
|
package/CONTRIBUTING.md
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
# Contributing to `@mantyx/sdk`
|
|
2
|
-
|
|
3
|
-
Thanks for considering a contribution! This SDK is a small, dependency-light
|
|
4
|
-
client for the [MANTYX](https://mantyx.com) agent-runs HTTP/SSE protocol; the
|
|
5
|
-
goal is to keep it that way.
|
|
6
|
-
|
|
7
|
-
## Ground rules
|
|
8
|
-
|
|
9
|
-
1. **Public-protocol only.** The SDK MUST NOT depend on any MANTYX-internal
|
|
10
|
-
package, type, or repository layout. Anything it does is a side effect of
|
|
11
|
-
sending HTTP requests against the public protocol documented in
|
|
12
|
-
[`docs/agent-runs-protocol.md`](./docs/agent-runs-protocol.md).
|
|
13
|
-
2. **No `workspace:*`.** The SDK ships to npm as a standalone package. Pull
|
|
14
|
-
requests that introduce a `workspace:*` dependency in `package.json` will
|
|
15
|
-
not be merged.
|
|
16
|
-
3. **Tiny dep tree.** The only runtime dependency today is `zod`. Adding a
|
|
17
|
-
new runtime dependency requires a strong justification.
|
|
18
|
-
4. **Standalone tests.** `pnpm test` must pass with `node_modules/` populated
|
|
19
|
-
from this package's own `package.json`, with no MANTYX server running.
|
|
20
|
-
5. **Backwards compatibility.** Bump the SDK version per
|
|
21
|
-
[SemVer](https://semver.org/spec/v2.0.0.html). Breaking changes need a
|
|
22
|
-
major version bump and a `CHANGELOG.md` entry.
|
|
23
|
-
|
|
24
|
-
## Local setup
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
pnpm install
|
|
28
|
-
pnpm test
|
|
29
|
-
pnpm typecheck
|
|
30
|
-
pnpm build
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
The repository is a pnpm monorepo, but this package is a leaf with no
|
|
34
|
-
internal consumers, so it is safe to develop in isolation.
|
|
35
|
-
|
|
36
|
-
## Adding tests
|
|
37
|
-
|
|
38
|
-
Tests live under [`test/`](./test) and use Vitest. Network calls are routed
|
|
39
|
-
through the in-process mock server in
|
|
40
|
-
[`test/helpers/mock-server.ts`](./test/helpers/mock-server.ts) — extend it
|
|
41
|
-
when you need to exercise a new server behaviour rather than reaching out to
|
|
42
|
-
a real MANTYX instance.
|
|
43
|
-
|
|
44
|
-
When fixing a bug, prefer a regression test against the mock server. When
|
|
45
|
-
adding a feature, add an example under [`examples/`](./examples) that
|
|
46
|
-
exercises it end-to-end.
|
|
47
|
-
|
|
48
|
-
## Style
|
|
49
|
-
|
|
50
|
-
- TypeScript strict mode. No `any` unless there's no choice.
|
|
51
|
-
- Public types are re-exported from [`src/index.ts`](./src/index.ts). Keep
|
|
52
|
-
the public surface minimal and well-typed.
|
|
53
|
-
- Use `MantyxError` (and its subclasses) for thrown errors so callers can
|
|
54
|
-
branch on `instanceof`.
|
|
55
|
-
- Prefer the Web `fetch` / `ReadableStream` APIs over Node-only modules so
|
|
56
|
-
the SDK keeps working in edge / browser-like runtimes.
|
|
57
|
-
|
|
58
|
-
## Pull requests
|
|
59
|
-
|
|
60
|
-
1. Fork and create a feature branch.
|
|
61
|
-
2. Add or update tests.
|
|
62
|
-
3. `pnpm test && pnpm typecheck && pnpm build`.
|
|
63
|
-
4. Use [Conventional Commits](https://www.conventionalcommits.org/) with scope `ts` — `CHANGELOG.md` is regenerated from git history on release (do not edit it by hand).
|
|
64
|
-
5. Open a PR. Describe the change and any protocol implications.
|
|
65
|
-
|
|
66
|
-
## Releasing
|
|
67
|
-
|
|
68
|
-
Releases are handled by the shared **Publish** GitHub Actions workflow on `main` (lockstep across all three SDKs). See the [top-level CONTRIBUTING.md](../CONTRIBUTING.md#releasing). The npm tag is `vX.Y.Z`; do not publish or tag manually from this package.
|
|
69
|
-
|
|
70
|
-
## Code of Conduct
|
|
71
|
-
|
|
72
|
-
Be kind. Assume good intent. Be patient with reviewers and maintainers.
|
package/EXTRACT.md
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
# Extracting `@mantyx/sdk` into its own repository
|
|
2
|
-
|
|
3
|
-
The `@mantyx/sdk` package is intentionally self-contained. Lifting it out of
|
|
4
|
-
the MANTYX monorepo into a public repository is a five-minute job:
|
|
5
|
-
|
|
6
|
-
## Steps
|
|
7
|
-
|
|
8
|
-
1. Copy this folder verbatim:
|
|
9
|
-
|
|
10
|
-
```bash
|
|
11
|
-
cp -r packages/mantyx-sdk/ts ~/code/mantyx-sdk
|
|
12
|
-
cd ~/code/mantyx-sdk
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
2. Initialize git:
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
git init -b main
|
|
19
|
-
git add .
|
|
20
|
-
git commit -m "Import @mantyx/sdk from monorepo"
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
3. Re-generate the lockfile against npm:
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
rm -rf node_modules
|
|
27
|
-
pnpm install # or: npm install
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
4. Update `examples/*/package.json` so each example installs `@mantyx/sdk`
|
|
31
|
-
from npm rather than via the monorepo's pnpm workspace symlink. Each
|
|
32
|
-
example already sets the dep to `"@mantyx/sdk": "*"`; replace `"*"` with
|
|
33
|
-
the published version once you've cut a release.
|
|
34
|
-
|
|
35
|
-
5. Confirm the test suite still passes:
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
pnpm test
|
|
39
|
-
pnpm typecheck
|
|
40
|
-
pnpm build
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
6. Push to a new GitHub repo and (optionally) wire up CI by copying
|
|
44
|
-
`.github/workflows/sdk-typescript.yml` from the monorepo into
|
|
45
|
-
`.github/workflows/ci.yml` in the new repo.
|
|
46
|
-
|
|
47
|
-
## What you can leave behind
|
|
48
|
-
|
|
49
|
-
The following monorepo-only files do **not** apply to a standalone repo:
|
|
50
|
-
|
|
51
|
-
- The MANTYX monorepo's root `pnpm-workspace.yaml`, `AGENTS.md`, `run.sh`,
|
|
52
|
-
`infra/`, `mobile/`, etc. None of them are required by the SDK.
|
|
53
|
-
|
|
54
|
-
## Things to update once extracted
|
|
55
|
-
|
|
56
|
-
- `package.json` `repository`, `homepage`, and `bugs` URLs.
|
|
57
|
-
- `README.md` install instructions if the package name changes (e.g. you
|
|
58
|
-
publish under a different scope).
|
|
59
|
-
- The `DEFAULT_BASE_URL` constant in `src/client.ts` if you intend to talk to
|
|
60
|
-
a non-default MANTYX deployment.
|
|
61
|
-
|
|
62
|
-
## What stays the same
|
|
63
|
-
|
|
64
|
-
- The wire protocol the SDK speaks (`docs/agent-runs-protocol.md`).
|
|
65
|
-
- The `MantyxClient` API surface.
|
|
66
|
-
- The example projects.
|
|
67
|
-
- Tests and the mock server (zero MANTYX dependencies).
|
|
68
|
-
|
|
69
|
-
That's it. The extracted package can be built, tested, and published from
|
|
70
|
-
any environment with Node.js 18.17+ installed.
|