@mantyx/sdk 0.16.0 → 0.18.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 +8 -0
- package/README.md +4 -1
- package/dist/a2a-server.cjs.map +1 -1
- package/dist/a2a-server.d.cts +1 -1
- package/dist/a2a-server.d.ts +1 -1
- package/dist/a2a-server.js +1 -1
- package/dist/{chunk-EEVTNG4C.js → chunk-JRENMLOL.js} +62 -5
- package/dist/chunk-JRENMLOL.js.map +1 -0
- package/dist/{client-DgBXj6Dh.d.cts → client-CLT46vp5.d.cts} +89 -4
- package/dist/{client-DgBXj6Dh.d.ts → client-CLT46vp5.d.ts} +89 -4
- package/dist/computer-use-CEiw-nJw.d.cts +193 -0
- package/dist/computer-use-CRcsRq8T.d.ts +193 -0
- package/dist/index.cjs +428 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +362 -2
- package/dist/index.js.map +1 -1
- package/dist/playwright.cjs +139 -0
- package/dist/playwright.cjs.map +1 -0
- package/dist/playwright.d.cts +88 -0
- package/dist/playwright.d.ts +88 -0
- package/dist/playwright.js +113 -0
- package/dist/playwright.js.map +1 -0
- package/docs/agent-runs-protocol.md +62 -8
- package/docs/wire-protocol.md +5 -1
- package/package.json +12 -2
- package/dist/chunk-EEVTNG4C.js.map +0 -1
|
@@ -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
|
|
@@ -410,7 +454,17 @@ interface LocalTool<TArgs = Record<string, unknown>> {
|
|
|
410
454
|
* declarative — MANTYX does not change scheduling.
|
|
411
455
|
*/
|
|
412
456
|
readonly longRunning: boolean;
|
|
413
|
-
|
|
457
|
+
/**
|
|
458
|
+
* When `true`, this tool may run **in parallel** with other read-only
|
|
459
|
+
* tools the model emits in the same turn: MANTYX publishes every such
|
|
460
|
+
* `local_tool_call` concurrently and resolves them together instead of
|
|
461
|
+
* one-at-a-time in model-emit order. Set this only for side-effect-free
|
|
462
|
+
* tools whose results don't depend on each other. Mutating tools (the
|
|
463
|
+
* default, `false`) stay strictly sequential. See
|
|
464
|
+
* `docs/agent-runs-protocol.md` §4.1.1.
|
|
465
|
+
*/
|
|
466
|
+
readonly readOnly: boolean;
|
|
467
|
+
readonly execute: (args: TArgs) => Promise<LocalToolOutput> | LocalToolOutput;
|
|
414
468
|
}
|
|
415
469
|
interface DefineLocalToolOptions<T extends ZodLikeObject | undefined> {
|
|
416
470
|
/** Lowercase alphanumeric + underscore, max 64 chars. */
|
|
@@ -428,7 +482,13 @@ interface DefineLocalToolOptions<T extends ZodLikeObject | undefined> {
|
|
|
428
482
|
* {@link LocalTool.longRunning}.
|
|
429
483
|
*/
|
|
430
484
|
longRunning?: boolean;
|
|
431
|
-
|
|
485
|
+
/**
|
|
486
|
+
* Mark the tool as read-only so MANTYX may run it in parallel with other
|
|
487
|
+
* read-only tools the model emits in the same turn. See
|
|
488
|
+
* {@link LocalTool.readOnly}.
|
|
489
|
+
*/
|
|
490
|
+
readOnly?: boolean;
|
|
491
|
+
execute: (args: T extends ZodLikeObject ? z.infer<T> : Record<string, unknown>) => Promise<LocalToolOutput> | LocalToolOutput;
|
|
432
492
|
}
|
|
433
493
|
declare function defineLocalTool<T extends ZodLikeObject | undefined>(opts: DefineLocalToolOptions<T>): LocalTool;
|
|
434
494
|
interface MantyxToolRef {
|
|
@@ -723,6 +783,23 @@ declare function inputFileUrlAttachment(opts: {
|
|
|
723
783
|
mimeType?: string;
|
|
724
784
|
filename?: string;
|
|
725
785
|
}): InputFileUrlAttachment;
|
|
786
|
+
/** Thumbs up/down verdict for {@link MantyxClient.submitRunFeedback}. */
|
|
787
|
+
type RunFeedbackVerdict = "UP" | "DOWN";
|
|
788
|
+
/** Body for `POST /agent-runs/:runId/feedback`. See §9a. */
|
|
789
|
+
interface RunFeedbackInput {
|
|
790
|
+
verdict: RunFeedbackVerdict;
|
|
791
|
+
/** Optional free-text note (≤ 8000 characters). */
|
|
792
|
+
explanation?: string;
|
|
793
|
+
/** Optional snapshot of the rated content; defaults to the run's final text. */
|
|
794
|
+
contentSnapshot?: string;
|
|
795
|
+
}
|
|
796
|
+
/** Response from `POST /agent-runs/:runId/feedback`. */
|
|
797
|
+
interface RunFeedbackResult {
|
|
798
|
+
id: string;
|
|
799
|
+
verdict: RunFeedbackVerdict;
|
|
800
|
+
targetKind: string;
|
|
801
|
+
agentRunId: string;
|
|
802
|
+
}
|
|
726
803
|
interface MantyxClientOptions {
|
|
727
804
|
/**
|
|
728
805
|
* Workspace API key (token prefix `mantyx_`) **or** a MANTYX OAuth 2.0
|
|
@@ -756,7 +833,7 @@ interface MantyxClientOptions {
|
|
|
756
833
|
*
|
|
757
834
|
* OAuth tokens additionally enforce per-route **scopes**
|
|
758
835
|
* (`runs:read`, `runs:write`, `sessions:read`, `sessions:write`,
|
|
759
|
-
* `models:read`, `mantyx.identity:read`); see
|
|
836
|
+
* `models:read`, `feedback:write`, `mantyx.identity:read`); see
|
|
760
837
|
* `docs/agent-runs-protocol.md` §2.2 for the table. Missing scopes
|
|
761
838
|
* land as {@link MantyxScopeError} so callers can route the user
|
|
762
839
|
* back to a re-consent flow.
|
|
@@ -1577,8 +1654,16 @@ declare class MantyxClient {
|
|
|
1577
1654
|
postToolResult(runId: string, toolUseId: string, payload: {
|
|
1578
1655
|
result?: string;
|
|
1579
1656
|
error?: string;
|
|
1657
|
+
files?: ToolResultFile[];
|
|
1580
1658
|
}): Promise<void>;
|
|
1581
1659
|
cancelRun(runId: string): Promise<void>;
|
|
1660
|
+
/**
|
|
1661
|
+
* Record thumbs up/down feedback on a run. Requires the `feedback:write`
|
|
1662
|
+
* OAuth scope (workspace API keys have implicit access). Idempotent per
|
|
1663
|
+
* run — the first call returns HTTP 201, updates return 200; both carry
|
|
1664
|
+
* the same response body. See `docs/agent-runs-protocol.md` §9a.
|
|
1665
|
+
*/
|
|
1666
|
+
submitRunFeedback(runId: string, input: RunFeedbackInput): Promise<RunFeedbackResult>;
|
|
1582
1667
|
private absoluteUrl;
|
|
1583
1668
|
/**
|
|
1584
1669
|
* Resolve the bearer credential to send on the next request. With a
|
|
@@ -1741,4 +1826,4 @@ interface LocalHandlers {
|
|
|
1741
1826
|
*/
|
|
1742
1827
|
declare function parseRunOutput<T = unknown>(result: RunResult, validator?: (value: unknown) => T): T;
|
|
1743
1828
|
|
|
1744
|
-
export { type
|
|
1829
|
+
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
|
|
@@ -410,7 +454,17 @@ interface LocalTool<TArgs = Record<string, unknown>> {
|
|
|
410
454
|
* declarative — MANTYX does not change scheduling.
|
|
411
455
|
*/
|
|
412
456
|
readonly longRunning: boolean;
|
|
413
|
-
|
|
457
|
+
/**
|
|
458
|
+
* When `true`, this tool may run **in parallel** with other read-only
|
|
459
|
+
* tools the model emits in the same turn: MANTYX publishes every such
|
|
460
|
+
* `local_tool_call` concurrently and resolves them together instead of
|
|
461
|
+
* one-at-a-time in model-emit order. Set this only for side-effect-free
|
|
462
|
+
* tools whose results don't depend on each other. Mutating tools (the
|
|
463
|
+
* default, `false`) stay strictly sequential. See
|
|
464
|
+
* `docs/agent-runs-protocol.md` §4.1.1.
|
|
465
|
+
*/
|
|
466
|
+
readonly readOnly: boolean;
|
|
467
|
+
readonly execute: (args: TArgs) => Promise<LocalToolOutput> | LocalToolOutput;
|
|
414
468
|
}
|
|
415
469
|
interface DefineLocalToolOptions<T extends ZodLikeObject | undefined> {
|
|
416
470
|
/** Lowercase alphanumeric + underscore, max 64 chars. */
|
|
@@ -428,7 +482,13 @@ interface DefineLocalToolOptions<T extends ZodLikeObject | undefined> {
|
|
|
428
482
|
* {@link LocalTool.longRunning}.
|
|
429
483
|
*/
|
|
430
484
|
longRunning?: boolean;
|
|
431
|
-
|
|
485
|
+
/**
|
|
486
|
+
* Mark the tool as read-only so MANTYX may run it in parallel with other
|
|
487
|
+
* read-only tools the model emits in the same turn. See
|
|
488
|
+
* {@link LocalTool.readOnly}.
|
|
489
|
+
*/
|
|
490
|
+
readOnly?: boolean;
|
|
491
|
+
execute: (args: T extends ZodLikeObject ? z.infer<T> : Record<string, unknown>) => Promise<LocalToolOutput> | LocalToolOutput;
|
|
432
492
|
}
|
|
433
493
|
declare function defineLocalTool<T extends ZodLikeObject | undefined>(opts: DefineLocalToolOptions<T>): LocalTool;
|
|
434
494
|
interface MantyxToolRef {
|
|
@@ -723,6 +783,23 @@ declare function inputFileUrlAttachment(opts: {
|
|
|
723
783
|
mimeType?: string;
|
|
724
784
|
filename?: string;
|
|
725
785
|
}): InputFileUrlAttachment;
|
|
786
|
+
/** Thumbs up/down verdict for {@link MantyxClient.submitRunFeedback}. */
|
|
787
|
+
type RunFeedbackVerdict = "UP" | "DOWN";
|
|
788
|
+
/** Body for `POST /agent-runs/:runId/feedback`. See §9a. */
|
|
789
|
+
interface RunFeedbackInput {
|
|
790
|
+
verdict: RunFeedbackVerdict;
|
|
791
|
+
/** Optional free-text note (≤ 8000 characters). */
|
|
792
|
+
explanation?: string;
|
|
793
|
+
/** Optional snapshot of the rated content; defaults to the run's final text. */
|
|
794
|
+
contentSnapshot?: string;
|
|
795
|
+
}
|
|
796
|
+
/** Response from `POST /agent-runs/:runId/feedback`. */
|
|
797
|
+
interface RunFeedbackResult {
|
|
798
|
+
id: string;
|
|
799
|
+
verdict: RunFeedbackVerdict;
|
|
800
|
+
targetKind: string;
|
|
801
|
+
agentRunId: string;
|
|
802
|
+
}
|
|
726
803
|
interface MantyxClientOptions {
|
|
727
804
|
/**
|
|
728
805
|
* Workspace API key (token prefix `mantyx_`) **or** a MANTYX OAuth 2.0
|
|
@@ -756,7 +833,7 @@ interface MantyxClientOptions {
|
|
|
756
833
|
*
|
|
757
834
|
* OAuth tokens additionally enforce per-route **scopes**
|
|
758
835
|
* (`runs:read`, `runs:write`, `sessions:read`, `sessions:write`,
|
|
759
|
-
* `models:read`, `mantyx.identity:read`); see
|
|
836
|
+
* `models:read`, `feedback:write`, `mantyx.identity:read`); see
|
|
760
837
|
* `docs/agent-runs-protocol.md` §2.2 for the table. Missing scopes
|
|
761
838
|
* land as {@link MantyxScopeError} so callers can route the user
|
|
762
839
|
* back to a re-consent flow.
|
|
@@ -1577,8 +1654,16 @@ declare class MantyxClient {
|
|
|
1577
1654
|
postToolResult(runId: string, toolUseId: string, payload: {
|
|
1578
1655
|
result?: string;
|
|
1579
1656
|
error?: string;
|
|
1657
|
+
files?: ToolResultFile[];
|
|
1580
1658
|
}): Promise<void>;
|
|
1581
1659
|
cancelRun(runId: string): Promise<void>;
|
|
1660
|
+
/**
|
|
1661
|
+
* Record thumbs up/down feedback on a run. Requires the `feedback:write`
|
|
1662
|
+
* OAuth scope (workspace API keys have implicit access). Idempotent per
|
|
1663
|
+
* run — the first call returns HTTP 201, updates return 200; both carry
|
|
1664
|
+
* the same response body. See `docs/agent-runs-protocol.md` §9a.
|
|
1665
|
+
*/
|
|
1666
|
+
submitRunFeedback(runId: string, input: RunFeedbackInput): Promise<RunFeedbackResult>;
|
|
1582
1667
|
private absoluteUrl;
|
|
1583
1668
|
/**
|
|
1584
1669
|
* Resolve the bearer credential to send on the next request. With a
|
|
@@ -1741,4 +1826,4 @@ interface LocalHandlers {
|
|
|
1741
1826
|
*/
|
|
1742
1827
|
declare function parseRunOutput<T = unknown>(result: RunResult, validator?: (value: unknown) => T): T;
|
|
1743
1828
|
|
|
1744
|
-
export { type
|
|
1829
|
+
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 };
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { ai as RunResult, M as MantyxClient, R as ReasoningLevel, s as LocalTool } from './client-CLT46vp5.cjs';
|
|
2
|
+
|
|
3
|
+
/** Scroll direction shared by `scroll_at` / `scroll_document`. */
|
|
4
|
+
type ScrollDirection = "up" | "down" | "left" | "right";
|
|
5
|
+
/** Pixel viewport of the controlled surface, used to denormalize coordinates. */
|
|
6
|
+
interface Viewport {
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
}
|
|
10
|
+
/** A captured screenshot, base64-encoded (no `data:` prefix). */
|
|
11
|
+
interface Screenshot {
|
|
12
|
+
/** Base64-encoded image bytes (no `data:` URL prefix). */
|
|
13
|
+
data: string;
|
|
14
|
+
/** Image MIME type, e.g. `"image/jpeg"` or `"image/png"`. */
|
|
15
|
+
mimeType: string;
|
|
16
|
+
/** Optional filename for the attachment; a default is generated otherwise. */
|
|
17
|
+
filename?: string;
|
|
18
|
+
}
|
|
19
|
+
/** Options forwarded to {@link BrowserController.typeTextAt}. */
|
|
20
|
+
interface TypeTextOptions {
|
|
21
|
+
/** Press Enter after typing. */
|
|
22
|
+
pressEnter: boolean;
|
|
23
|
+
/** Clear the field before typing. */
|
|
24
|
+
clearBeforeTyping: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The execution surface the computer-use tools drive. Coordinates passed to
|
|
28
|
+
* these methods are **already denormalized to pixels** against
|
|
29
|
+
* {@link viewport}. Implement this with Playwright, Puppeteer, a remote
|
|
30
|
+
* browser, a mobile driver, etc. For Playwright, use
|
|
31
|
+
* {@link PlaywrightController} from `@mantyx/sdk/playwright`.
|
|
32
|
+
*
|
|
33
|
+
* Every method may be sync or async. Methods for actions you exclude via
|
|
34
|
+
* {@link DefineComputerUseToolsOptions.excludeActions} are never called and
|
|
35
|
+
* can be omitted.
|
|
36
|
+
*/
|
|
37
|
+
interface BrowserController {
|
|
38
|
+
/** Current pixel viewport. Used to denormalize the model's 0-1000 coords. */
|
|
39
|
+
viewport(): Viewport | Promise<Viewport>;
|
|
40
|
+
/** Capture the current screen. Called once per loop step. */
|
|
41
|
+
screenshot(): Screenshot | Promise<Screenshot>;
|
|
42
|
+
/** Current page URL, if meaningful for the environment. Optional. */
|
|
43
|
+
currentUrl?(): string | Promise<string>;
|
|
44
|
+
/** Navigate directly to a URL. */
|
|
45
|
+
navigate?(url: string): void | Promise<void>;
|
|
46
|
+
/** Click at a pixel coordinate. */
|
|
47
|
+
clickAt(x: number, y: number): void | Promise<void>;
|
|
48
|
+
/** Hover at a pixel coordinate. */
|
|
49
|
+
hoverAt?(x: number, y: number): void | Promise<void>;
|
|
50
|
+
/** Type `text` at a pixel coordinate. */
|
|
51
|
+
typeTextAt(x: number, y: number, text: string, opts: TypeTextOptions): void | Promise<void>;
|
|
52
|
+
/** Press a key or chord, e.g. `"Enter"` or `"Control+C"`. */
|
|
53
|
+
keyCombination?(keys: string): void | Promise<void>;
|
|
54
|
+
/** Scroll the element at a pixel coordinate by `magnitude` pixels. */
|
|
55
|
+
scrollAt?(x: number, y: number, direction: ScrollDirection, magnitude: number): void | Promise<void>;
|
|
56
|
+
/** Scroll the whole document. */
|
|
57
|
+
scrollDocument?(direction: ScrollDirection): void | Promise<void>;
|
|
58
|
+
/** Drag from one pixel coordinate to another. */
|
|
59
|
+
dragAndDrop?(x: number, y: number, destinationX: number, destinationY: number): void | Promise<void>;
|
|
60
|
+
/** Navigate back in history. */
|
|
61
|
+
goBack?(): void | Promise<void>;
|
|
62
|
+
/** Navigate forward in history. */
|
|
63
|
+
goForward?(): void | Promise<void>;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Convert a normalized coordinate (0-1000 grid, matching the convention used
|
|
67
|
+
* by GUI-control models) to an actual pixel value.
|
|
68
|
+
*/
|
|
69
|
+
declare function denormalizeCoordinate(value: number, size: number): number;
|
|
70
|
+
/** The canonical computer-use action tool names. */
|
|
71
|
+
declare const COMPUTER_USE_ACTIONS: readonly ["navigate", "click_at", "hover_at", "type_text_at", "key_combination", "scroll_at", "scroll_document", "drag_and_drop", "go_back", "go_forward", "wait"];
|
|
72
|
+
type ComputerUseAction = (typeof COMPUTER_USE_ACTIONS)[number];
|
|
73
|
+
interface DefineComputerUseToolsOptions {
|
|
74
|
+
/**
|
|
75
|
+
* Predefined actions to omit (mirrors a dedicated model's
|
|
76
|
+
* `excluded_predefined_functions`). Useful when an environment cannot
|
|
77
|
+
* support an action, e.g. excluding `drag_and_drop` or the navigation
|
|
78
|
+
* actions for a kiosk.
|
|
79
|
+
*/
|
|
80
|
+
excludeActions?: ComputerUseAction[];
|
|
81
|
+
/**
|
|
82
|
+
* Include a `request_confirmation` tool the model is told to call before
|
|
83
|
+
* consequential or irreversible actions. The returned promise/boolean from
|
|
84
|
+
* `confirm` decides whether the model is cleared to proceed. Defaults to
|
|
85
|
+
* `true`; when no `confirm` is supplied, confirmation requests are denied.
|
|
86
|
+
*/
|
|
87
|
+
requestConfirmation?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Human-in-the-loop gate invoked by the `request_confirmation` tool. Return
|
|
90
|
+
* `true` to allow the model to continue with the action it described.
|
|
91
|
+
*/
|
|
92
|
+
confirm?: (reason: string) => boolean | Promise<boolean>;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Build the set of computer-use action tools bound to a
|
|
96
|
+
* {@link BrowserController}. Pass the result as `tools` on a session / run, or
|
|
97
|
+
* let {@link runComputerUse} wire everything for you.
|
|
98
|
+
*/
|
|
99
|
+
declare function defineComputerUseTools(controller: BrowserController, opts?: DefineComputerUseToolsOptions): LocalTool[];
|
|
100
|
+
interface ComputerUseSystemPromptOptions {
|
|
101
|
+
/** Environment label injected into the prompt, e.g. `"web browser"`. */
|
|
102
|
+
environment?: string;
|
|
103
|
+
/** Extra task-specific context appended to the standard instructions. */
|
|
104
|
+
extraInstructions?: string;
|
|
105
|
+
/** Whether the `request_confirmation` tool is available (adds safety rules). */
|
|
106
|
+
requestConfirmation?: boolean;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Build the system prompt that drives the loop: it teaches the model the
|
|
110
|
+
* screenshot-per-step protocol, the 0-1000 coordinate grid, the one-action-per-turn
|
|
111
|
+
* discipline, when to stop, and the human-in-the-loop safety rules.
|
|
112
|
+
*/
|
|
113
|
+
declare function buildComputerUseSystemPrompt(opts?: ComputerUseSystemPromptOptions): string;
|
|
114
|
+
/** One action the model invoked on a turn (derived from `local_tool_call` events). */
|
|
115
|
+
interface ComputerUseActionCall {
|
|
116
|
+
name: string;
|
|
117
|
+
input: Record<string, unknown>;
|
|
118
|
+
}
|
|
119
|
+
/** A single iteration of the computer-use loop. */
|
|
120
|
+
interface ComputerUseStep {
|
|
121
|
+
/** 1-based step index. */
|
|
122
|
+
step: number;
|
|
123
|
+
/** The screenshot sent to the model at the start of this step. */
|
|
124
|
+
screenshot: Screenshot;
|
|
125
|
+
/** The full run result for the turn. */
|
|
126
|
+
result: RunResult;
|
|
127
|
+
/** Actions the model invoked this turn (empty when it produced a final answer). */
|
|
128
|
+
actions: ComputerUseActionCall[];
|
|
129
|
+
}
|
|
130
|
+
interface RunComputerUseOptions {
|
|
131
|
+
/** MANTYX client used to open the session. */
|
|
132
|
+
client: MantyxClient;
|
|
133
|
+
/** The user's goal, sent on the first turn. */
|
|
134
|
+
goal: string;
|
|
135
|
+
/** Drives the actual UI actions and screenshots. */
|
|
136
|
+
controller: BrowserController;
|
|
137
|
+
/** Vision-capable model id (`modelId`). Omit to use the workspace default. */
|
|
138
|
+
model?: string;
|
|
139
|
+
/** Max loop iterations before stopping. Default 20. */
|
|
140
|
+
maxSteps?: number;
|
|
141
|
+
/** Override the generated system prompt entirely. */
|
|
142
|
+
systemPrompt?: string;
|
|
143
|
+
/** Tweaks for the generated system prompt (ignored when `systemPrompt` is set). */
|
|
144
|
+
systemPromptOptions?: ComputerUseSystemPromptOptions;
|
|
145
|
+
/** Actions to omit from the tool surface. */
|
|
146
|
+
excludeActions?: ComputerUseAction[];
|
|
147
|
+
/** Human-in-the-loop gate for `request_confirmation`. Omit to disable confirmations. */
|
|
148
|
+
confirm?: (reason: string) => boolean | Promise<boolean>;
|
|
149
|
+
/** Disable the `request_confirmation` tool entirely. Default false (it is included). */
|
|
150
|
+
disableConfirmation?: boolean;
|
|
151
|
+
/** Provider reasoning strength for the session. */
|
|
152
|
+
reasoningLevel?: ReasoningLevel;
|
|
153
|
+
/** Observability metadata stored on the session. */
|
|
154
|
+
metadata?: Record<string, string>;
|
|
155
|
+
/** Text sent alongside the screenshot on every turn after the first. */
|
|
156
|
+
continueText?: string;
|
|
157
|
+
/** Invoked after each step (await is honored), e.g. for logging. */
|
|
158
|
+
onStep?: (step: ComputerUseStep) => void | Promise<void>;
|
|
159
|
+
/** Streams assistant text deltas. */
|
|
160
|
+
onAssistantDelta?: (delta: string) => void;
|
|
161
|
+
/** Aborts the loop and the in-flight turn. */
|
|
162
|
+
signal?: AbortSignal;
|
|
163
|
+
}
|
|
164
|
+
interface ComputerUseResult {
|
|
165
|
+
/** The model's final plain-text answer (text of the last turn). */
|
|
166
|
+
finalText: string;
|
|
167
|
+
/** Every step taken, in order. */
|
|
168
|
+
steps: ComputerUseStep[];
|
|
169
|
+
/** The session that ran the loop (already ended). */
|
|
170
|
+
sessionId: string;
|
|
171
|
+
/** Why the loop stopped. */
|
|
172
|
+
stoppedReason: "completed" | "max_steps";
|
|
173
|
+
}
|
|
174
|
+
/** Pull the actions the model invoked this turn from the run's events. */
|
|
175
|
+
declare function extractActions(result: RunResult): ComputerUseActionCall[];
|
|
176
|
+
/**
|
|
177
|
+
* Run a model-agnostic computer-use loop: screenshot → send → one action →
|
|
178
|
+
* repeat, until the model answers in plain text or `maxSteps` is reached. The
|
|
179
|
+
* session is created internally and ended on return.
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* const out = await runComputerUse({
|
|
183
|
+
* client,
|
|
184
|
+
* model: "google/gemini-3-flash",
|
|
185
|
+
* goal: "Find the cheapest 2-door smart fridge on the site and report its price.",
|
|
186
|
+
* controller: playwrightController, // implements BrowserController
|
|
187
|
+
* confirm: async (reason) => askOperator(reason),
|
|
188
|
+
* });
|
|
189
|
+
* console.log(out.finalText);
|
|
190
|
+
*/
|
|
191
|
+
declare function runComputerUse(opts: RunComputerUseOptions): Promise<ComputerUseResult>;
|
|
192
|
+
|
|
193
|
+
export { type BrowserController as B, COMPUTER_USE_ACTIONS as C, type DefineComputerUseToolsOptions as D, type RunComputerUseOptions as R, type Screenshot as S, type TypeTextOptions as T, type Viewport as V, type ComputerUseAction as a, type ComputerUseActionCall as b, type ComputerUseResult as c, type ComputerUseStep as d, type ComputerUseSystemPromptOptions as e, type ScrollDirection as f, buildComputerUseSystemPrompt as g, defineComputerUseTools as h, denormalizeCoordinate as i, extractActions as j, runComputerUse as r };
|