@mantyx/sdk 0.17.0 → 0.19.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.
@@ -381,6 +381,50 @@ type ZodLikeObject = z.ZodType<Record<string, unknown>> & {
381
381
  * integer in `0..100` (where `0` explicitly disables provider thinking).
382
382
  */
383
383
  type ReasoningLevel = "off" | "low" | "medium" | "high" | number;
384
+ /**
385
+ * A file produced by a client-resolved tool, returned alongside the textual
386
+ * `result`. The bytes are surfaced to the model on the next turn as native
387
+ * file parts (Anthropic / Gemini / Bedrock inside the `tool_result`; OpenAI
388
+ * as a synthetic follow-up user turn) — the same pipeline used by
389
+ * server-resolved tools that return files.
390
+ *
391
+ * Limits (enforced server-side): up to 20 files per result, `mimeType` must
392
+ * be an allowed attachment type, and the combined decoded size is capped
393
+ * (currently 5 MB). Files over the inline threshold are persisted to object
394
+ * storage and forwarded by reference. For larger artifacts, upload them out
395
+ * of band and reference a URL in `result` instead. See
396
+ * `docs/agent-runs-protocol.md` §8 and `docs/wire-protocol.md` §4.
397
+ */
398
+ interface ToolResultFile {
399
+ /** Display filename surfaced to the model (e.g. `"chart.png"`). */
400
+ filename: string;
401
+ /** Allowed attachment MIME type (e.g. `"image/png"`, `"text/plain"`). */
402
+ mimeType: string;
403
+ /** Base64-encoded file bytes — **no** `data:` URL prefix. */
404
+ data: string;
405
+ }
406
+ /**
407
+ * Rich return value for a {@link LocalTool}'s `execute`. Return this (instead
408
+ * of a bare string) when the tool needs to hand files back to the model in
409
+ * addition to — or instead of — its textual result.
410
+ *
411
+ * `result` is the same string a tool would normally return; omit it (or pass
412
+ * the empty string) when the files are the whole payload. `files` is ignored
413
+ * when the tool throws — errors are surfaced to the model as a tool-error
414
+ * response with no attachments.
415
+ */
416
+ interface LocalToolResult {
417
+ /** Textual result. Optional when `files` carries the payload. */
418
+ result?: string;
419
+ /** Files to surface to the model on the next turn. */
420
+ files?: ToolResultFile[];
421
+ }
422
+ /**
423
+ * What a {@link LocalTool}'s `execute` may return: a bare string (the common
424
+ * case) or a {@link LocalToolResult} carrying files. Non-string, non-result
425
+ * values are JSON-serialized by the SDK before being posted back.
426
+ */
427
+ type LocalToolOutput = string | LocalToolResult;
384
428
  /**
385
429
  * Either a Zod schema (auto-converted to JSON Schema by the SDK) or a
386
430
  * pre-shaped JSON Schema object. Used for both `parameters` and the new
@@ -420,7 +464,16 @@ interface LocalTool<TArgs = Record<string, unknown>> {
420
464
  * `docs/agent-runs-protocol.md` §4.1.1.
421
465
  */
422
466
  readonly readOnly: boolean;
423
- readonly execute: (args: TArgs) => Promise<string> | string;
467
+ /**
468
+ * When `true`, the tool's result is **persisted with the session and
469
+ * replayed to the model on later turns** — reconstructed as a
470
+ * `tool_use` + `tool_result` pair in its original place in the
471
+ * transcript. Only meaningful for session-scoped runs. Keep outputs
472
+ * small (text only, ~8 KB cap). See `docs/agent-runs-protocol.md`
473
+ * §4.1.1.
474
+ */
475
+ readonly retain: boolean;
476
+ readonly execute: (args: TArgs) => Promise<LocalToolOutput> | LocalToolOutput;
424
477
  }
425
478
  interface DefineLocalToolOptions<T extends ZodLikeObject | undefined> {
426
479
  /** Lowercase alphanumeric + underscore, max 64 chars. */
@@ -444,7 +497,13 @@ interface DefineLocalToolOptions<T extends ZodLikeObject | undefined> {
444
497
  * {@link LocalTool.readOnly}.
445
498
  */
446
499
  readOnly?: boolean;
447
- execute: (args: T extends ZodLikeObject ? z.infer<T> : Record<string, unknown>) => Promise<string> | string;
500
+ /**
501
+ * Persist the tool result across session turns so follow-ups can
502
+ * reference values the model can no longer recompute. See
503
+ * {@link LocalTool.retain}.
504
+ */
505
+ retain?: boolean;
506
+ execute: (args: T extends ZodLikeObject ? z.infer<T> : Record<string, unknown>) => Promise<LocalToolOutput> | LocalToolOutput;
448
507
  }
449
508
  declare function defineLocalTool<T extends ZodLikeObject | undefined>(opts: DefineLocalToolOptions<T>): LocalTool;
450
509
  interface MantyxToolRef {
@@ -1610,6 +1669,7 @@ declare class MantyxClient {
1610
1669
  postToolResult(runId: string, toolUseId: string, payload: {
1611
1670
  result?: string;
1612
1671
  error?: string;
1672
+ files?: ToolResultFile[];
1613
1673
  }): Promise<void>;
1614
1674
  cancelRun(runId: string): Promise<void>;
1615
1675
  /**
@@ -1781,4 +1841,4 @@ interface LocalHandlers {
1781
1841
  */
1782
1842
  declare function parseRunOutput<T = unknown>(result: RunResult, validator?: (value: unknown) => T): T;
1783
1843
 
1784
- export { type ModelCatalog as $, type A2AToolRef as A, MantyxError as B, type CancelledEvent as C, DEFAULT_BASE_URL as D, type ErrorEvent as E, type MantyxMcpOptions as F, MantyxNetworkError as G, MantyxOAuthClient as H, type InputFileAttachment as I, type MantyxOAuthClientOptions as J, MantyxOAuthError as K, type LocalA2ATool as L, MantyxClient as M, MantyxParseError as N, type OutputSchema as O, type MantyxPluginToolRef as P, MantyxRunError as Q, type ReasoningLevel as R, type MantyxRunErrorInit as S, type ToolRef as T, type MantyxRunErrorModel as U, type MantyxRunErrorTokens as V, MantyxScopeError as W, MantyxToolError as X, type MantyxToolRef as Y, type McpToolRef as Z, type MessageAttachment as _, AgentSession as a, type ModelInfo as a0, type OAuthToken as a1, type OutputSchemaValue as a2, type PlanOptions as a3, type PlanSpec as a4, type ReasoningTrigger as a5, type RefreshOptions as a6, type RefreshTokenSourceOptions as a7, type ResultEvent as a8, type RevokeOptions as a9, type ToolBudgetExceededEvent as aA, type ToolBudgets as aB, type UserMessageEvent as aC, type ZodLikeObject as aD, defineLocalA2A as aE, defineLocalMcp as aF, defineLocalTool as aG, inputFileAttachment as aH, inputFileUrlAttachment as aI, isLocalA2ATool as aJ, isLocalMcpServer as aK, isLocalTool as aL, mantyxA2A as aM, mantyxMcp as aN, mantyxPluginTool as aO, mantyxTool as aP, parseRunOutput as aQ, planOnly as aR, type RunEvent as aa, type RunEventBase as ab, type RunFeedbackInput as ac, type RunFeedbackResult as ad, type RunFeedbackVerdict as ae, type RunModelInfo as af, type RunResult as ag, type RunSpec as ah, type RunTokenUsage as ai, type ServerToolResultEvent as aj, type SessionInfo as ak, type SessionListResult as al, type SessionSpec as am, type SessionSummary as an, type Supervisor as ao, type SupervisorAction as ap, type SupervisorEvent as aq, type SupervisorPhase as ar, type TaskPlan as as, type TaskPlanEvent as at, type TaskPlanStep as au, type TaskPlanStepStatus as av, type ThinkingDeltaEvent as aw, type TokenRequestReason as ax, type TokenSource as ay, type ToolBudget as az, type AgentSpecBase as b, type AssistantDeltaEvent as c, type AssistantMessageEvent as d, type AttachmentMetadata as e, type ConversationMessage as f, DEFAULT_OAUTH_BASE_URL as g, DEFAULT_REFRESH_SKEW_MS as h, type DefineLocalA2AOptions as i, type DefineLocalMcpOptions as j, type DefineLocalToolOptions as k, type InputFileAttachmentMetadata as l, type InputFileUrlAttachment as m, type InputFileUrlAttachmentMetadata as n, type LocalHandlers as o, type LocalMcpHttpTransport as p, type LocalMcpServer as q, type LocalMcpStdioTransport as r, type LocalTool as s, type LocalToolCallEvent as t, type LocalToolResultInEvent as u, type LoopDetectedEvent as v, type LoopDetection as w, type MantyxA2AOptions as x, MantyxAuthError as y, type MantyxClientOptions as z };
1844
+ export { type McpToolRef as $, type A2AToolRef as A, MantyxAuthError as B, type CancelledEvent as C, DEFAULT_BASE_URL as D, type ErrorEvent as E, type MantyxClientOptions as F, MantyxError as G, type MantyxMcpOptions as H, type InputFileAttachment as I, MantyxNetworkError as J, MantyxOAuthClient as K, type LocalA2ATool as L, MantyxClient as M, type MantyxOAuthClientOptions as N, type OutputSchema as O, MantyxOAuthError as P, MantyxParseError as Q, type ReasoningLevel as R, type MantyxPluginToolRef as S, type ToolRef as T, MantyxRunError as U, type MantyxRunErrorInit as V, type MantyxRunErrorModel as W, type MantyxRunErrorTokens as X, MantyxScopeError as Y, MantyxToolError as Z, type MantyxToolRef as _, AgentSession as a, type MessageAttachment as a0, type ModelCatalog as a1, type ModelInfo as a2, type OAuthToken as a3, type OutputSchemaValue as a4, type PlanOptions as a5, type PlanSpec as a6, type ReasoningTrigger as a7, type RefreshOptions as a8, type RefreshTokenSourceOptions as a9, type TokenSource as aA, type ToolBudget as aB, type ToolBudgetExceededEvent as aC, type ToolBudgets as aD, type ToolResultFile as aE, type UserMessageEvent as aF, type ZodLikeObject as aG, defineLocalA2A as aH, defineLocalMcp as aI, defineLocalTool as aJ, inputFileAttachment as aK, inputFileUrlAttachment as aL, isLocalA2ATool as aM, isLocalMcpServer as aN, isLocalTool as aO, mantyxA2A as aP, mantyxMcp as aQ, mantyxPluginTool as aR, mantyxTool as aS, parseRunOutput as aT, planOnly as aU, type ResultEvent as aa, type RevokeOptions as ab, type RunEvent as ac, type RunEventBase as ad, type RunFeedbackInput as ae, type RunFeedbackResult as af, type RunFeedbackVerdict as ag, type RunModelInfo as ah, type RunResult as ai, type RunSpec as aj, type RunTokenUsage as ak, type ServerToolResultEvent as al, type SessionInfo as am, type SessionListResult as an, type SessionSpec as ao, type SessionSummary as ap, type Supervisor as aq, type SupervisorAction as ar, type SupervisorEvent as as, type SupervisorPhase as at, type TaskPlan as au, type TaskPlanEvent as av, type TaskPlanStep as aw, type TaskPlanStepStatus as ax, type ThinkingDeltaEvent as ay, type TokenRequestReason as az, type AgentSpecBase as b, type AssistantDeltaEvent as c, type AssistantMessageEvent as d, type AttachmentMetadata as e, type ConversationMessage as f, DEFAULT_OAUTH_BASE_URL as g, DEFAULT_REFRESH_SKEW_MS as h, type DefineLocalA2AOptions as i, type DefineLocalMcpOptions as j, type DefineLocalToolOptions as k, type InputFileAttachmentMetadata as l, type InputFileUrlAttachment as m, type InputFileUrlAttachmentMetadata as n, type LocalHandlers as o, type LocalMcpHttpTransport as p, type LocalMcpServer as q, type LocalMcpStdioTransport as r, type LocalTool as s, type LocalToolCallEvent as t, type LocalToolOutput as u, type LocalToolResult as v, type LocalToolResultInEvent as w, type LoopDetectedEvent as x, type LoopDetection as y, type MantyxA2AOptions as z };
@@ -381,6 +381,50 @@ type ZodLikeObject = z.ZodType<Record<string, unknown>> & {
381
381
  * integer in `0..100` (where `0` explicitly disables provider thinking).
382
382
  */
383
383
  type ReasoningLevel = "off" | "low" | "medium" | "high" | number;
384
+ /**
385
+ * A file produced by a client-resolved tool, returned alongside the textual
386
+ * `result`. The bytes are surfaced to the model on the next turn as native
387
+ * file parts (Anthropic / Gemini / Bedrock inside the `tool_result`; OpenAI
388
+ * as a synthetic follow-up user turn) — the same pipeline used by
389
+ * server-resolved tools that return files.
390
+ *
391
+ * Limits (enforced server-side): up to 20 files per result, `mimeType` must
392
+ * be an allowed attachment type, and the combined decoded size is capped
393
+ * (currently 5 MB). Files over the inline threshold are persisted to object
394
+ * storage and forwarded by reference. For larger artifacts, upload them out
395
+ * of band and reference a URL in `result` instead. See
396
+ * `docs/agent-runs-protocol.md` §8 and `docs/wire-protocol.md` §4.
397
+ */
398
+ interface ToolResultFile {
399
+ /** Display filename surfaced to the model (e.g. `"chart.png"`). */
400
+ filename: string;
401
+ /** Allowed attachment MIME type (e.g. `"image/png"`, `"text/plain"`). */
402
+ mimeType: string;
403
+ /** Base64-encoded file bytes — **no** `data:` URL prefix. */
404
+ data: string;
405
+ }
406
+ /**
407
+ * Rich return value for a {@link LocalTool}'s `execute`. Return this (instead
408
+ * of a bare string) when the tool needs to hand files back to the model in
409
+ * addition to — or instead of — its textual result.
410
+ *
411
+ * `result` is the same string a tool would normally return; omit it (or pass
412
+ * the empty string) when the files are the whole payload. `files` is ignored
413
+ * when the tool throws — errors are surfaced to the model as a tool-error
414
+ * response with no attachments.
415
+ */
416
+ interface LocalToolResult {
417
+ /** Textual result. Optional when `files` carries the payload. */
418
+ result?: string;
419
+ /** Files to surface to the model on the next turn. */
420
+ files?: ToolResultFile[];
421
+ }
422
+ /**
423
+ * What a {@link LocalTool}'s `execute` may return: a bare string (the common
424
+ * case) or a {@link LocalToolResult} carrying files. Non-string, non-result
425
+ * values are JSON-serialized by the SDK before being posted back.
426
+ */
427
+ type LocalToolOutput = string | LocalToolResult;
384
428
  /**
385
429
  * Either a Zod schema (auto-converted to JSON Schema by the SDK) or a
386
430
  * pre-shaped JSON Schema object. Used for both `parameters` and the new
@@ -420,7 +464,16 @@ interface LocalTool<TArgs = Record<string, unknown>> {
420
464
  * `docs/agent-runs-protocol.md` §4.1.1.
421
465
  */
422
466
  readonly readOnly: boolean;
423
- readonly execute: (args: TArgs) => Promise<string> | string;
467
+ /**
468
+ * When `true`, the tool's result is **persisted with the session and
469
+ * replayed to the model on later turns** — reconstructed as a
470
+ * `tool_use` + `tool_result` pair in its original place in the
471
+ * transcript. Only meaningful for session-scoped runs. Keep outputs
472
+ * small (text only, ~8 KB cap). See `docs/agent-runs-protocol.md`
473
+ * §4.1.1.
474
+ */
475
+ readonly retain: boolean;
476
+ readonly execute: (args: TArgs) => Promise<LocalToolOutput> | LocalToolOutput;
424
477
  }
425
478
  interface DefineLocalToolOptions<T extends ZodLikeObject | undefined> {
426
479
  /** Lowercase alphanumeric + underscore, max 64 chars. */
@@ -444,7 +497,13 @@ interface DefineLocalToolOptions<T extends ZodLikeObject | undefined> {
444
497
  * {@link LocalTool.readOnly}.
445
498
  */
446
499
  readOnly?: boolean;
447
- execute: (args: T extends ZodLikeObject ? z.infer<T> : Record<string, unknown>) => Promise<string> | string;
500
+ /**
501
+ * Persist the tool result across session turns so follow-ups can
502
+ * reference values the model can no longer recompute. See
503
+ * {@link LocalTool.retain}.
504
+ */
505
+ retain?: boolean;
506
+ execute: (args: T extends ZodLikeObject ? z.infer<T> : Record<string, unknown>) => Promise<LocalToolOutput> | LocalToolOutput;
448
507
  }
449
508
  declare function defineLocalTool<T extends ZodLikeObject | undefined>(opts: DefineLocalToolOptions<T>): LocalTool;
450
509
  interface MantyxToolRef {
@@ -1610,6 +1669,7 @@ declare class MantyxClient {
1610
1669
  postToolResult(runId: string, toolUseId: string, payload: {
1611
1670
  result?: string;
1612
1671
  error?: string;
1672
+ files?: ToolResultFile[];
1613
1673
  }): Promise<void>;
1614
1674
  cancelRun(runId: string): Promise<void>;
1615
1675
  /**
@@ -1781,4 +1841,4 @@ interface LocalHandlers {
1781
1841
  */
1782
1842
  declare function parseRunOutput<T = unknown>(result: RunResult, validator?: (value: unknown) => T): T;
1783
1843
 
1784
- export { type ModelCatalog as $, type A2AToolRef as A, MantyxError as B, type CancelledEvent as C, DEFAULT_BASE_URL as D, type ErrorEvent as E, type MantyxMcpOptions as F, MantyxNetworkError as G, MantyxOAuthClient as H, type InputFileAttachment as I, type MantyxOAuthClientOptions as J, MantyxOAuthError as K, type LocalA2ATool as L, MantyxClient as M, MantyxParseError as N, type OutputSchema as O, type MantyxPluginToolRef as P, MantyxRunError as Q, type ReasoningLevel as R, type MantyxRunErrorInit as S, type ToolRef as T, type MantyxRunErrorModel as U, type MantyxRunErrorTokens as V, MantyxScopeError as W, MantyxToolError as X, type MantyxToolRef as Y, type McpToolRef as Z, type MessageAttachment as _, AgentSession as a, type ModelInfo as a0, type OAuthToken as a1, type OutputSchemaValue as a2, type PlanOptions as a3, type PlanSpec as a4, type ReasoningTrigger as a5, type RefreshOptions as a6, type RefreshTokenSourceOptions as a7, type ResultEvent as a8, type RevokeOptions as a9, type ToolBudgetExceededEvent as aA, type ToolBudgets as aB, type UserMessageEvent as aC, type ZodLikeObject as aD, defineLocalA2A as aE, defineLocalMcp as aF, defineLocalTool as aG, inputFileAttachment as aH, inputFileUrlAttachment as aI, isLocalA2ATool as aJ, isLocalMcpServer as aK, isLocalTool as aL, mantyxA2A as aM, mantyxMcp as aN, mantyxPluginTool as aO, mantyxTool as aP, parseRunOutput as aQ, planOnly as aR, type RunEvent as aa, type RunEventBase as ab, type RunFeedbackInput as ac, type RunFeedbackResult as ad, type RunFeedbackVerdict as ae, type RunModelInfo as af, type RunResult as ag, type RunSpec as ah, type RunTokenUsage as ai, type ServerToolResultEvent as aj, type SessionInfo as ak, type SessionListResult as al, type SessionSpec as am, type SessionSummary as an, type Supervisor as ao, type SupervisorAction as ap, type SupervisorEvent as aq, type SupervisorPhase as ar, type TaskPlan as as, type TaskPlanEvent as at, type TaskPlanStep as au, type TaskPlanStepStatus as av, type ThinkingDeltaEvent as aw, type TokenRequestReason as ax, type TokenSource as ay, type ToolBudget as az, type AgentSpecBase as b, type AssistantDeltaEvent as c, type AssistantMessageEvent as d, type AttachmentMetadata as e, type ConversationMessage as f, DEFAULT_OAUTH_BASE_URL as g, DEFAULT_REFRESH_SKEW_MS as h, type DefineLocalA2AOptions as i, type DefineLocalMcpOptions as j, type DefineLocalToolOptions as k, type InputFileAttachmentMetadata as l, type InputFileUrlAttachment as m, type InputFileUrlAttachmentMetadata as n, type LocalHandlers as o, type LocalMcpHttpTransport as p, type LocalMcpServer as q, type LocalMcpStdioTransport as r, type LocalTool as s, type LocalToolCallEvent as t, type LocalToolResultInEvent as u, type LoopDetectedEvent as v, type LoopDetection as w, type MantyxA2AOptions as x, MantyxAuthError as y, type MantyxClientOptions as z };
1844
+ export { type McpToolRef as $, type A2AToolRef as A, MantyxAuthError as B, type CancelledEvent as C, DEFAULT_BASE_URL as D, type ErrorEvent as E, type MantyxClientOptions as F, MantyxError as G, type MantyxMcpOptions as H, type InputFileAttachment as I, MantyxNetworkError as J, MantyxOAuthClient as K, type LocalA2ATool as L, MantyxClient as M, type MantyxOAuthClientOptions as N, type OutputSchema as O, MantyxOAuthError as P, MantyxParseError as Q, type ReasoningLevel as R, type MantyxPluginToolRef as S, type ToolRef as T, MantyxRunError as U, type MantyxRunErrorInit as V, type MantyxRunErrorModel as W, type MantyxRunErrorTokens as X, MantyxScopeError as Y, MantyxToolError as Z, type MantyxToolRef as _, AgentSession as a, type MessageAttachment as a0, type ModelCatalog as a1, type ModelInfo as a2, type OAuthToken as a3, type OutputSchemaValue as a4, type PlanOptions as a5, type PlanSpec as a6, type ReasoningTrigger as a7, type RefreshOptions as a8, type RefreshTokenSourceOptions as a9, type TokenSource as aA, type ToolBudget as aB, type ToolBudgetExceededEvent as aC, type ToolBudgets as aD, type ToolResultFile as aE, type UserMessageEvent as aF, type ZodLikeObject as aG, defineLocalA2A as aH, defineLocalMcp as aI, defineLocalTool as aJ, inputFileAttachment as aK, inputFileUrlAttachment as aL, isLocalA2ATool as aM, isLocalMcpServer as aN, isLocalTool as aO, mantyxA2A as aP, mantyxMcp as aQ, mantyxPluginTool as aR, mantyxTool as aS, parseRunOutput as aT, planOnly as aU, type ResultEvent as aa, type RevokeOptions as ab, type RunEvent as ac, type RunEventBase as ad, type RunFeedbackInput as ae, type RunFeedbackResult as af, type RunFeedbackVerdict as ag, type RunModelInfo as ah, type RunResult as ai, type RunSpec as aj, type RunTokenUsage as ak, type ServerToolResultEvent as al, type SessionInfo as am, type SessionListResult as an, type SessionSpec as ao, type SessionSummary as ap, type Supervisor as aq, type SupervisorAction as ar, type SupervisorEvent as as, type SupervisorPhase as at, type TaskPlan as au, type TaskPlanEvent as av, type TaskPlanStep as aw, type TaskPlanStepStatus as ax, type ThinkingDeltaEvent as ay, type TokenRequestReason as az, type AgentSpecBase as b, type AssistantDeltaEvent as c, type AssistantMessageEvent as d, type AttachmentMetadata as e, type ConversationMessage as f, DEFAULT_OAUTH_BASE_URL as g, DEFAULT_REFRESH_SKEW_MS as h, type DefineLocalA2AOptions as i, type DefineLocalMcpOptions as j, type DefineLocalToolOptions as k, type InputFileAttachmentMetadata as l, type InputFileUrlAttachment as m, type InputFileUrlAttachmentMetadata as n, type LocalHandlers as o, type LocalMcpHttpTransport as p, type LocalMcpServer as q, type LocalMcpStdioTransport as r, type LocalTool as s, type LocalToolCallEvent as t, type LocalToolOutput as u, type LocalToolResult as v, type LocalToolResultInEvent as w, type LoopDetectedEvent as x, type LoopDetection as y, type MantyxA2AOptions as z };
@@ -1,4 +1,4 @@
1
- import { ag as RunResult, M as MantyxClient, R as ReasoningLevel, s as LocalTool } from './client-IjrvboaL.cjs';
1
+ import { ai as RunResult, M as MantyxClient, R as ReasoningLevel, s as LocalTool } from './client-IcPVJ_lf.cjs';
2
2
 
3
3
  /** Scroll direction shared by `scroll_at` / `scroll_document`. */
4
4
  type ScrollDirection = "up" | "down" | "left" | "right";
@@ -1,4 +1,4 @@
1
- import { ag as RunResult, M as MantyxClient, R as ReasoningLevel, s as LocalTool } from './client-IjrvboaL.js';
1
+ import { ai as RunResult, M as MantyxClient, R as ReasoningLevel, s as LocalTool } from './client-IcPVJ_lf.js';
2
2
 
3
3
  /** Scroll direction shared by `scroll_at` / `scroll_document`. */
4
4
  type ScrollDirection = "up" | "down" | "left" | "right";
package/dist/index.cjs CHANGED
@@ -175,6 +175,7 @@ function defineLocalTool(opts) {
175
175
  outputSchema: opts.outputSchema,
176
176
  longRunning: opts.longRunning ?? false,
177
177
  readOnly: opts.readOnly ?? false,
178
+ retain: opts.retain ?? false,
178
179
  execute: opts.execute
179
180
  };
180
181
  }
@@ -291,6 +292,32 @@ function prefixedMcpToolName(serverName, toolName) {
291
292
  const prefix = `${serverName}_`;
292
293
  return toolName.startsWith(prefix) ? toolName : `${prefix}${toolName}`;
293
294
  }
295
+ function normalizeLocalToolOutput(out) {
296
+ if (typeof out === "string") return { result: out };
297
+ if (isLocalToolResult(out)) {
298
+ const files = sanitizeToolResultFiles(out.files);
299
+ const result = typeof out.result === "string" ? out.result : "";
300
+ return files ? { result, files } : { result };
301
+ }
302
+ return { result: JSON.stringify(out) };
303
+ }
304
+ function isLocalToolResult(out) {
305
+ if (out === null || typeof out !== "object" || Array.isArray(out)) return false;
306
+ const o = out;
307
+ return (typeof o.result === "string" || o.result === void 0) && ("files" in o || "result" in o);
308
+ }
309
+ function sanitizeToolResultFiles(files) {
310
+ if (!Array.isArray(files) || files.length === 0) return void 0;
311
+ const out = [];
312
+ for (const f of files) {
313
+ if (!f || typeof f !== "object") continue;
314
+ const file = f;
315
+ if (typeof file.filename === "string" && typeof file.mimeType === "string" && typeof file.data === "string") {
316
+ out.push({ filename: file.filename, mimeType: file.mimeType, data: file.data });
317
+ }
318
+ }
319
+ return out.length > 0 ? out : void 0;
320
+ }
294
321
 
295
322
  // src/local-resolver.ts
296
323
  async function resolveLocalRefs(tools, opts = { fetch: globalThis.fetch }) {
@@ -1018,6 +1045,7 @@ var MantyxClient = class {
1018
1045
  const kind = ev.kind ?? "local";
1019
1046
  try {
1020
1047
  let out;
1048
+ let files;
1021
1049
  if (kind === "a2a_local") {
1022
1050
  const tool = handlers.a2aTools.get(ev.name);
1023
1051
  if (!tool) {
@@ -1049,10 +1077,11 @@ var MantyxClient = class {
1049
1077
  return;
1050
1078
  }
1051
1079
  const args = handler.parameters ? handler.parameters.parse?.(ev.args) ?? ev.args : ev.args;
1052
- const result = await handler.execute(args);
1053
- out = typeof result === "string" ? result : JSON.stringify(result);
1080
+ const normalized = normalizeLocalToolOutput(await handler.execute(args));
1081
+ out = normalized.result;
1082
+ files = normalized.files;
1054
1083
  }
1055
- await this.postToolResult(runId, ev.toolUseId, { result: out });
1084
+ await this.postToolResult(runId, ev.toolUseId, files ? { result: out, files } : { result: out });
1056
1085
  } catch (err) {
1057
1086
  const message = err instanceof Error ? err.message : String(err);
1058
1087
  const handlerName = describeHandlerName(ev);
@@ -1380,7 +1409,8 @@ function serializeToolRefs(tools) {
1380
1409
  parameters: toToolParametersWire(t.parameters),
1381
1410
  ...t.outputSchema !== void 0 ? { outputSchema: toToolParametersWire(t.outputSchema) } : {},
1382
1411
  ...t.longRunning ? { longRunning: true } : {},
1383
- ...t.readOnly ? { readOnly: true } : {}
1412
+ ...t.readOnly ? { readOnly: true } : {},
1413
+ ...t.retain ? { retain: true } : {}
1384
1414
  };
1385
1415
  case "a2a":
1386
1416
  return {
@@ -2371,7 +2401,7 @@ async function runComputerUse(opts) {
2371
2401
  }
2372
2402
 
2373
2403
  // src/version.ts
2374
- var SDK_VERSION = "0.17.0";
2404
+ var SDK_VERSION = "0.19.0";
2375
2405
  // Annotate the CommonJS export names for ESM import in node:
2376
2406
  0 && (module.exports = {
2377
2407
  AgentSession,