@mantyx/sdk 0.24.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.
Files changed (47) hide show
  1. package/CHANGELOG.md +28 -1
  2. package/LICENSE +201 -0
  3. package/README.md +35 -12
  4. package/dist/a2a-server.cjs +11 -1
  5. package/dist/a2a-server.d.ts +2 -1
  6. package/dist/a2a-server.js +3 -2
  7. package/dist/{chunk-OUK6ZZ5H.js → chunk-XMNAWLMF.js} +75 -2
  8. package/dist/client.d.ts +59 -7
  9. package/dist/computer-use.d.ts +0 -1
  10. package/dist/errors.d.ts +13 -1
  11. package/dist/index.cjs +76 -3
  12. package/dist/index.d.ts +2 -2
  13. package/dist/index.js +2 -3
  14. package/dist/local-resolver.d.ts +0 -1
  15. package/dist/oauth.d.ts +0 -1
  16. package/dist/playwright.cjs +0 -1
  17. package/dist/playwright.d.ts +0 -1
  18. package/dist/playwright.js +0 -1
  19. package/dist/sse.d.ts +0 -1
  20. package/dist/structured-output.d.ts +11 -0
  21. package/dist/tools.d.ts +0 -1
  22. package/dist/version.d.ts +2 -3
  23. package/dist/zod-to-json-schema.d.ts +0 -1
  24. package/docs/agent-runs-protocol.md +238 -89
  25. package/docs/wire-protocol.md +201 -82
  26. package/package.json +17 -18
  27. package/CONTRIBUTING.md +0 -72
  28. package/EXTRACT.md +0 -70
  29. package/dist/a2a-server.cjs.map +0 -1
  30. package/dist/a2a-server.d.ts.map +0 -1
  31. package/dist/a2a-server.js.map +0 -1
  32. package/dist/chunk-OUK6ZZ5H.js.map +0 -1
  33. package/dist/client.d.ts.map +0 -1
  34. package/dist/computer-use.d.ts.map +0 -1
  35. package/dist/errors.d.ts.map +0 -1
  36. package/dist/index.cjs.map +0 -1
  37. package/dist/index.d.ts.map +0 -1
  38. package/dist/index.js.map +0 -1
  39. package/dist/local-resolver.d.ts.map +0 -1
  40. package/dist/oauth.d.ts.map +0 -1
  41. package/dist/playwright.cjs.map +0 -1
  42. package/dist/playwright.d.ts.map +0 -1
  43. package/dist/playwright.js.map +0 -1
  44. package/dist/sse.d.ts.map +0 -1
  45. package/dist/tools.d.ts.map +0 -1
  46. package/dist/version.d.ts.map +0 -1
  47. package/dist/zod-to-json-schema.d.ts.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,7 +1,32 @@
1
1
  # Changelog
2
2
 
3
3
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
4
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
4
+ and new releases use calendar versions (`YYYY.M.RELEASE`). Historical versions retain their original identifiers.
5
+
6
+ ## [Unreleased]
7
+
8
+ ### Added
9
+
10
+ - Cursor-based session pagination and bounded session event pages (SDK PR #9).
11
+ - Explicit new-loop opt-in for runs, sessions, session turns, evals and A2A server wrappers.
12
+
13
+ ### Changed
14
+
15
+ - Calendar versioning with automatic SDK publication after successful deployments when SDK code or build inputs change.
16
+ - Develop and release SDKs from the private MANTYX platform repository.
17
+ - Export `SessionEventsPage`; wait for eval local tool callbacks; reject null output schemas.
18
+
19
+ ## [0.25.0] — 2026-08-01
20
+
21
+ ### Added
22
+
23
+ - Expose structured output enforcement
24
+
25
+ ## [0.24.0] — 2026-07-24
26
+
27
+ ### Documentation
28
+
29
+ - Add audio attachment support_(protocol)_
5
30
 
6
31
  ## [0.23.0] — 2026-07-15
7
32
 
@@ -175,6 +200,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
175
200
 
176
201
  ## [0.1.0] — 2026-05-02
177
202
 
203
+ [0.25.0]: https://github.com/mantyx-io/mantyx-sdk/compare/v0.24.0..v0.25.0
204
+ [0.24.0]: https://github.com/mantyx-io/mantyx-sdk/compare/v0.23.0..v0.24.0
178
205
  [0.23.0]: https://github.com/mantyx-io/mantyx-sdk/compare/v0.22.1..v0.23.0
179
206
  [0.22.1]: https://github.com/mantyx-io/mantyx-sdk/compare/v0.22.0..v0.22.1
180
207
  [0.22.0]: https://github.com/mantyx-io/mantyx-sdk/compare/v0.21.0..v0.22.0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 MANTYX
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -24,6 +24,10 @@ and the messaging-layer reference in [`docs/wire-protocol.md`](./docs/wire-proto
24
24
  resolved data structures (`a2a_local` Agent Card, `mcp_local` `Tool[]`)
25
25
  that this SDK ships.
26
26
 
27
+ ## Harness loop selection
28
+
29
+ Pass `newLoop: true` when running an agent, creating a session, or starting an eval to opt into the reviewed harness loop. Omission keeps external runs on the existing loop. Session turns inherit the session setting; an explicit false overrides it for that turn. Use `session.send(prompt, { newLoop: false })`.
30
+
27
31
  ## Install
28
32
 
29
33
  ```bash
@@ -306,10 +310,10 @@ inherits from the session and can be overridden per `session.send`.
306
310
 
307
311
  ## Structured output (`outputSchema`)
308
312
 
309
- Constrain the assistant's **final reply** to a JSON document matching a
310
- JSON Schema. The wire still ships the reply as `text: string`, but that
311
- string is guaranteed-parseable JSON. Pair with `parseRunOutput` for a
312
- typed value with a clean error path:
313
+ Ask the provider to constrain the assistant's **final reply** to a JSON
314
+ document matching a JSON Schema. The wire still ships the reply as
315
+ `text: string`. Set `enforcement: "strict"` when an unsupported schema or
316
+ unconstrained fallback must fail, and pair it with `parseRunOutput`:
313
317
 
314
318
  ```ts
315
319
  import { z } from "zod";
@@ -329,7 +333,11 @@ const WeatherJsonSchema = {
329
333
  const result = await client.runAgent({
330
334
  systemPrompt: "Return the weather as JSON.",
331
335
  prompt: "What's the weather in San Francisco right now?",
332
- outputSchema: { name: "weather_report", schema: WeatherJsonSchema },
336
+ outputSchema: {
337
+ name: "weather_report",
338
+ schema: WeatherJsonSchema,
339
+ enforcement: "strict",
340
+ },
333
341
  });
334
342
 
335
343
  const report = parseRunOutput(result, (v) => Weather.parse(v));
@@ -342,6 +350,12 @@ typed `MantyxError` up front instead of a server round-trip rejection.
342
350
  On parse failure (rare; bad model output), `parseRunOutput` throws
343
351
  `MantyxParseError` with the original `text` preserved.
344
352
 
353
+ On success, `result.structuredOutput` reports whether enforcement actually
354
+ occurred, its `native_schema` / `synthetic_tool` mechanism, and whether a
355
+ best-effort unconstrained fallback occurred. Strict provider rejection raises
356
+ `MantyxRunError` with `errorClass === "structured_output_schema_rejected"` and
357
+ preserves `apiStatus`, `apiCode`, and the provider message.
358
+
345
359
  `outputSchema` is independent of `reasoningLevel` — combine them for
346
360
  deep-reasoning JSON outputs. On sessions it inherits from
347
361
  `createSession({ outputSchema })` and can be overridden per
@@ -491,12 +505,14 @@ live stream.
491
505
 
492
506
  ```ts
493
507
  // Find sessions by your own identifiers (AND-combined server-side)
494
- const { sessions, total } = await client.listSessions({
508
+ const { sessions, total, nextCursor } = await client.listSessions({
495
509
  metadata: { customer: "acme" },
496
510
  status: "active", // optional: "active" | "ended"
497
511
  limit: 50, // optional pagination
498
- offset: 0,
499
512
  });
513
+ const nextPage = nextCursor
514
+ ? await client.listSessions({ limit: 50, cursor: nextCursor })
515
+ : null;
500
516
  // Each row: { sessionId, creationDate, lastInteractionDate, summary, metadata, status }
501
517
 
502
518
  // Replay a session as realtime-style frames so a UI can rebuild the thread.
@@ -507,6 +523,14 @@ const events = await client.getSessionEvents(sessions[0].sessionId);
507
523
  const recent = await client.getSessionEvents(sessions[0].sessionId, {
508
524
  lastMessages: 10,
509
525
  });
526
+
527
+ // For bounded backward paging, use the page response metadata:
528
+ const page = await client.getSessionEventsPage(sessions[0].sessionId);
529
+ const older = page.nextBeforeSeq
530
+ ? await client.getSessionEventsPage(sessions[0].sessionId, {
531
+ beforeSeq: page.nextBeforeSeq,
532
+ })
533
+ : null;
510
534
  ```
511
535
 
512
536
  Resuming a session from a different process re-binds your local tool
@@ -553,8 +577,9 @@ Opt-in multi-step checklists. Pass `plan: true` (auto-classify + live tracking)
553
577
  | `streamAgent(spec)` | `AsyncIterable<RunEvent>` |
554
578
  | `createSession(spec)` | `Promise<AgentSession>` |
555
579
  | `resumeSession(sessionId, { tools? })` | `Promise<AgentSession>` |
556
- | `listSessions({ metadata?, status?, limit?, offset? })` | `Promise<SessionListResult>` |
580
+ | `listSessions({ metadata?, status?, limit?, offset?, cursor? })` | `Promise<SessionListResult>` |
557
581
  | `getSessionEvents(sessionId, { full?, lastMessages? })` | `Promise<RunEvent[]>` |
582
+ | `getSessionEventsPage(sessionId, { lastMessages?, beforeSeq? })` | `Promise<SessionEventsPage>` |
558
583
  | `endSession(sessionId)` | `Promise<void>` |
559
584
  | `cancelRun(runId)` | `Promise<void>` |
560
585
 
@@ -684,10 +709,8 @@ pnpm build # emits dist/ (ESM + CJS + d.ts)
684
709
  The SDK has zero internal `workspace:*` dependencies. `pnpm build` produces a
685
710
  self-contained `dist/` ready for `npm publish`.
686
711
 
687
- See [`CONTRIBUTING.md`](./CONTRIBUTING.md) for the contribution flow and
688
- [`EXTRACT.md`](./EXTRACT.md) for the (very small) steps to lift this folder
689
- into its own public repository.
712
+ See [`CONTRIBUTING.md`](./CONTRIBUTING.md) for development and the shared release guide in the private repository for publishing.
690
713
 
691
714
  ## License
692
715
 
693
- [Apache-2.0](../LICENSE)
716
+ [Apache-2.0](./LICENSE)
@@ -65,6 +65,12 @@ var MantyxRunError = class extends MantyxError {
65
65
  turns;
66
66
  /** See {@link MantyxRunErrorInit.model}. */
67
67
  model;
68
+ /** Provider HTTP status associated with the failure, when available. */
69
+ apiStatus;
70
+ /** Provider-specific error code associated with the failure, when available. */
71
+ apiCode;
72
+ /** Structured-output enforcement metadata, when reported by the server. */
73
+ structuredOutput;
68
74
  constructor(runId, subtype, message, init = {}) {
69
75
  super(message, { code: subtype });
70
76
  this.name = "MantyxRunError";
@@ -77,6 +83,9 @@ var MantyxRunError = class extends MantyxError {
77
83
  this.tokens = init.tokens;
78
84
  this.turns = init.turns;
79
85
  this.model = init.model;
86
+ this.apiStatus = init.apiStatus;
87
+ this.apiCode = init.apiCode;
88
+ this.structuredOutput = init.structuredOutput;
80
89
  }
81
90
  };
82
91
 
@@ -339,6 +348,7 @@ function specForRun(spec) {
339
348
  if (spec.systemPrompt) out.systemPrompt = spec.systemPrompt;
340
349
  if (spec.modelId) out.modelId = spec.modelId;
341
350
  if (spec.tools) out.tools = spec.tools;
351
+ if (spec.newLoop !== void 0) out.newLoop = spec.newLoop;
342
352
  if (spec.reasoningLevel !== void 0) out.reasoningLevel = spec.reasoningLevel;
343
353
  if (spec.outputSchema !== void 0) out.outputSchema = spec.outputSchema;
344
354
  if (spec.metadata) out.metadata = spec.metadata;
@@ -352,6 +362,7 @@ function specForSession(spec, contextId) {
352
362
  if (spec.systemPrompt) out.systemPrompt = spec.systemPrompt;
353
363
  if (spec.modelId) out.modelId = spec.modelId;
354
364
  if (spec.tools) out.tools = spec.tools;
365
+ if (spec.newLoop !== void 0) out.newLoop = spec.newLoop;
355
366
  if (spec.reasoningLevel !== void 0) out.reasoningLevel = spec.reasoningLevel;
356
367
  if (spec.outputSchema !== void 0) out.outputSchema = spec.outputSchema;
357
368
  const meta = { ...spec.metadata ?? {} };
@@ -427,4 +438,3 @@ async function loadServerSdk() {
427
438
  MantyxAgentExecutor,
428
439
  serveAgentOverA2A
429
440
  });
430
- //# sourceMappingURL=a2a-server.cjs.map
@@ -58,6 +58,8 @@ export interface MantyxAgentSpec {
58
58
  systemPrompt?: string;
59
59
  modelId?: string;
60
60
  tools?: ToolRef[];
61
+ /** Opt into the verified loop; omission preserves legacy behavior or session inheritance. */
62
+ newLoop?: boolean;
61
63
  reasoningLevel?: ReasoningLevel;
62
64
  /**
63
65
  * Constrains the model's final assistant text to a JSON document matching
@@ -170,4 +172,3 @@ export declare class MantyxAgentExecutor implements AgentExecutor {
170
172
  export declare function serveAgentOverA2A(options: ServeAgentOverA2AOptions): Promise<ServeAgentOverA2AHandle>;
171
173
  export type { AgentCard, Message, MessageSendParams, Task, TaskArtifactUpdateEvent, TaskStatusUpdateEvent, } from "@a2a-js/sdk";
172
174
  export type { AgentExecutor, ExecutionEventBus, RequestContext } from "@a2a-js/sdk/server";
173
- //# sourceMappingURL=a2a-server.d.ts.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  MantyxError,
3
3
  MantyxRunError
4
- } from "./chunk-OUK6ZZ5H.js";
4
+ } from "./chunk-XMNAWLMF.js";
5
5
 
6
6
  // src/a2a-server.ts
7
7
  var MantyxAgentExecutor = class {
@@ -256,6 +256,7 @@ function specForRun(spec) {
256
256
  if (spec.systemPrompt) out.systemPrompt = spec.systemPrompt;
257
257
  if (spec.modelId) out.modelId = spec.modelId;
258
258
  if (spec.tools) out.tools = spec.tools;
259
+ if (spec.newLoop !== void 0) out.newLoop = spec.newLoop;
259
260
  if (spec.reasoningLevel !== void 0) out.reasoningLevel = spec.reasoningLevel;
260
261
  if (spec.outputSchema !== void 0) out.outputSchema = spec.outputSchema;
261
262
  if (spec.metadata) out.metadata = spec.metadata;
@@ -269,6 +270,7 @@ function specForSession(spec, contextId) {
269
270
  if (spec.systemPrompt) out.systemPrompt = spec.systemPrompt;
270
271
  if (spec.modelId) out.modelId = spec.modelId;
271
272
  if (spec.tools) out.tools = spec.tools;
273
+ if (spec.newLoop !== void 0) out.newLoop = spec.newLoop;
272
274
  if (spec.reasoningLevel !== void 0) out.reasoningLevel = spec.reasoningLevel;
273
275
  if (spec.outputSchema !== void 0) out.outputSchema = spec.outputSchema;
274
276
  const meta = { ...spec.metadata ?? {} };
@@ -343,4 +345,3 @@ export {
343
345
  MantyxAgentExecutor,
344
346
  serveAgentOverA2A
345
347
  };
346
- //# sourceMappingURL=a2a-server.js.map
@@ -65,6 +65,12 @@ var MantyxRunError = class extends MantyxError {
65
65
  turns;
66
66
  /** See {@link MantyxRunErrorInit.model}. */
67
67
  model;
68
+ /** Provider HTTP status associated with the failure, when available. */
69
+ apiStatus;
70
+ /** Provider-specific error code associated with the failure, when available. */
71
+ apiCode;
72
+ /** Structured-output enforcement metadata, when reported by the server. */
73
+ structuredOutput;
68
74
  constructor(runId, subtype, message, init = {}) {
69
75
  super(message, { code: subtype });
70
76
  this.name = "MantyxRunError";
@@ -77,6 +83,9 @@ var MantyxRunError = class extends MantyxError {
77
83
  this.tokens = init.tokens;
78
84
  this.turns = init.turns;
79
85
  this.model = init.model;
86
+ this.apiStatus = init.apiStatus;
87
+ this.apiCode = init.apiCode;
88
+ this.structuredOutput = init.structuredOutput;
80
89
  }
81
90
  };
82
91
  var MantyxParseError = class extends MantyxError {
@@ -862,6 +871,7 @@ var MantyxClient = class {
862
871
  if (opts.status) query.status = opts.status;
863
872
  if (typeof opts.limit === "number") query.limit = opts.limit;
864
873
  if (typeof opts.offset === "number") query.offset = opts.offset;
874
+ if (opts.cursor) query.cursor = opts.cursor;
865
875
  return this.request({
866
876
  method: "GET",
867
877
  path: "/agent-sessions",
@@ -888,6 +898,28 @@ var MantyxClient = class {
888
898
  });
889
899
  return res.events ?? [];
890
900
  }
901
+ /**
902
+ * Fetch one bounded page of session events. Pages are returned in ascending
903
+ * sequence order; follow `nextBeforeSeq` to walk backward through history.
904
+ */
905
+ async getSessionEventsPage(sessionId, opts = {}) {
906
+ const query = {
907
+ lastMessages: opts.lastMessages ?? 100,
908
+ beforeSeq: opts.beforeSeq
909
+ };
910
+ const res = await this.request({
911
+ method: "GET",
912
+ path: `/agent-sessions/${encodeURIComponent(sessionId)}/events`,
913
+ query
914
+ });
915
+ return {
916
+ sessionId: res.sessionId,
917
+ total: res.total,
918
+ events: res.events ?? [],
919
+ nextBeforeSeq: res.nextBeforeSeq ?? null,
920
+ truncated: res.truncated ?? false
921
+ };
922
+ }
891
923
  // ----------------------------------------------------------- Internals
892
924
  /** Drive an existing run to completion (collect events, dispatch local tools). */
893
925
  async driveRun(runId, handlers, opts = {}) {
@@ -896,6 +928,7 @@ var MantyxClient = class {
896
928
  let tokens;
897
929
  let turns;
898
930
  let modelInfo;
931
+ let structuredOutput;
899
932
  let plan;
900
933
  for await (const ev of this.streamRunEvents(runId, handlers, opts.signal)) {
901
934
  collected.push(ev);
@@ -908,6 +941,7 @@ var MantyxClient = class {
908
941
  tokens = parseRunTokens(r.tokens) ?? tokens;
909
942
  turns = parseRunTurns(r.turns) ?? turns;
910
943
  modelInfo = parseRunModel(r.model) ?? modelInfo;
944
+ structuredOutput = parseStructuredOutputInfo(r.structuredOutput) ?? structuredOutput;
911
945
  if (r.subtype === "success") {
912
946
  finalText = typeof r.text === "string" ? r.text : "";
913
947
  const parsedPlan = parseTaskPlan(r.plan);
@@ -919,6 +953,7 @@ var MantyxClient = class {
919
953
  if (tokens !== void 0) errInit.tokens = tokens;
920
954
  if (turns !== void 0) errInit.turns = turns;
921
955
  if (modelInfo !== void 0) errInit.model = modelInfo;
956
+ if (structuredOutput !== void 0) errInit.structuredOutput = structuredOutput;
922
957
  throw new MantyxRunError(runId, r.subtype, r.error ?? r.subtype, errInit);
923
958
  }
924
959
  } else if (ev.type === "error") {
@@ -929,12 +964,16 @@ var MantyxClient = class {
929
964
  if (e.finishReason !== void 0) errInit.finishReason = e.finishReason;
930
965
  if (typeof e.partialText === "string") errInit.partialText = e.partialText;
931
966
  if (typeof e.retryable === "boolean") errInit.retryable = e.retryable;
967
+ if (typeof e.apiStatus === "number") errInit.apiStatus = e.apiStatus;
968
+ if (typeof e.apiCode === "string") errInit.apiCode = e.apiCode;
932
969
  const errTokens = parseRunTokens(e.tokens);
933
970
  if (errTokens !== void 0) errInit.tokens = errTokens;
934
971
  const errTurns = parseRunTurns(e.turns);
935
972
  if (errTurns !== void 0) errInit.turns = errTurns;
936
973
  const errModel = parseRunModel(e.model);
937
974
  if (errModel !== void 0) errInit.model = errModel;
975
+ const errStructuredOutput = parseStructuredOutputInfo(e.structuredOutput);
976
+ if (errStructuredOutput !== void 0) errInit.structuredOutput = errStructuredOutput;
938
977
  throw new MantyxRunError(runId, subtype, e.error, errInit);
939
978
  } else if (ev.type === "cancelled") {
940
979
  throw new MantyxRunError(runId, "cancelled", "Run was cancelled");
@@ -944,6 +983,7 @@ var MantyxClient = class {
944
983
  if (tokens !== void 0) result.tokens = tokens;
945
984
  if (turns !== void 0) result.turns = turns;
946
985
  if (modelInfo !== void 0) result.model = modelInfo;
986
+ if (structuredOutput !== void 0) result.structuredOutput = structuredOutput;
947
987
  if (plan !== void 0) result.plan = plan;
948
988
  return result;
949
989
  }
@@ -1199,7 +1239,7 @@ var MantyxClient = class {
1199
1239
  const agentRunId = typeof record.agentRunId === "string" ? record.agentRunId : typeof nested?.agentRunId === "string" ? nested.agentRunId : "";
1200
1240
  if (agentRunId) {
1201
1241
  const localEv = evalEventToLocalToolCall(ev);
1202
- void this.dispatchLocalTool(agentRunId, localEv, handlers).catch(() => void 0);
1242
+ await this.dispatchLocalTool(agentRunId, localEv, handlers);
1203
1243
  }
1204
1244
  }
1205
1245
  options.onEvent?.(ev);
@@ -1387,6 +1427,7 @@ var AgentSession = class {
1387
1427
  }
1388
1428
  if (this.tools.length > 0) body.tools = serializeToolRefs(this.tools);
1389
1429
  if (opts.metadata && Object.keys(opts.metadata).length > 0) body.metadata = opts.metadata;
1430
+ if (opts.newLoop !== void 0) body.newLoop = opts.newLoop;
1390
1431
  if (opts.reasoningLevel !== void 0) {
1391
1432
  body.reasoningLevel = normalizeReasoningLevel(opts.reasoningLevel);
1392
1433
  }
@@ -1427,6 +1468,12 @@ var AgentSession = class {
1427
1468
  async info() {
1428
1469
  return this.client.getSessionInfo(this.id);
1429
1470
  }
1471
+ async events(opts = {}) {
1472
+ return this.client.getSessionEvents(this.id, opts);
1473
+ }
1474
+ async eventsPage(opts = {}) {
1475
+ return this.client.getSessionEventsPage(this.id, opts);
1476
+ }
1430
1477
  async end() {
1431
1478
  try {
1432
1479
  await this.client.endSession(this.id);
@@ -1466,6 +1513,7 @@ function serializeAgentSpec(spec, extra = {}) {
1466
1513
  if (spec.agentId) body.agentId = spec.agentId;
1467
1514
  if (spec.name) body.name = spec.name;
1468
1515
  if (spec.modelId) body.modelId = spec.modelId;
1516
+ if (spec.newLoop !== void 0) body.newLoop = spec.newLoop;
1469
1517
  if (spec.reasoningLevel !== void 0) {
1470
1518
  body.reasoningLevel = normalizeReasoningLevel(spec.reasoningLevel);
1471
1519
  }
@@ -1505,6 +1553,7 @@ function serializeCreateEvalRunRequest(spec) {
1505
1553
  throw new MantyxError("createEvalRun accepts only one of `agentId` or `agent`");
1506
1554
  }
1507
1555
  const body = {};
1556
+ if (spec.newLoop !== void 0) body.newLoop = spec.newLoop;
1508
1557
  if (spec.datasetId) body.datasetId = spec.datasetId;
1509
1558
  if (spec.dataset) body.dataset = spec.dataset;
1510
1559
  if (spec.agentId) body.agentId = spec.agentId;
@@ -1662,6 +1711,17 @@ function normalizeOutputSchema(value) {
1662
1711
  }
1663
1712
  out.name = value.name;
1664
1713
  }
1714
+ if (value.enforcement !== void 0) {
1715
+ if (value.enforcement !== "best_effort" && value.enforcement !== "strict") {
1716
+ throw new MantyxError(
1717
+ `outputSchema.enforcement must be "best_effort" or "strict", got ${JSON.stringify(value.enforcement)}`
1718
+ );
1719
+ }
1720
+ out.enforcement = value.enforcement;
1721
+ }
1722
+ if (value.schema == null) {
1723
+ throw new MantyxError("outputSchema.schema must be a Zod schema or a non-null JSON object");
1724
+ }
1665
1725
  const schema = toToolParametersWire(
1666
1726
  value.schema
1667
1727
  );
@@ -1972,6 +2032,20 @@ function parseRunTurns(value) {
1972
2032
  if (typeof value !== "number" || !Number.isFinite(value)) return void 0;
1973
2033
  return Math.max(0, Math.trunc(value));
1974
2034
  }
2035
+ function parseStructuredOutputInfo(value) {
2036
+ if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
2037
+ const v = value;
2038
+ const mechanism = v.enforcementMechanism;
2039
+ if (typeof v.schemaRequested !== "boolean" || typeof v.schemaEnforced !== "boolean" || mechanism !== "native_schema" && mechanism !== "synthetic_tool" && mechanism !== "none" || typeof v.unconstrainedFallbackOccurred !== "boolean") {
2040
+ return void 0;
2041
+ }
2042
+ return {
2043
+ schemaRequested: v.schemaRequested,
2044
+ schemaEnforced: v.schemaEnforced,
2045
+ enforcementMechanism: mechanism,
2046
+ unconstrainedFallbackOccurred: v.unconstrainedFallbackOccurred
2047
+ };
2048
+ }
1975
2049
  function parseRunModel(value) {
1976
2050
  if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
1977
2051
  const v = value;
@@ -2055,4 +2129,3 @@ export {
2055
2129
  taskPlanFromEventData,
2056
2130
  parseRunOutput
2057
2131
  };
2058
- //# sourceMappingURL=chunk-OUK6ZZ5H.js.map