@mantyx/sdk 0.16.0 → 0.17.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 +7 -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-DNJYOHTJ.js} +31 -2
- package/dist/chunk-DNJYOHTJ.js.map +1 -0
- package/dist/{client-DgBXj6Dh.d.cts → client-IjrvboaL.d.cts} +42 -2
- package/dist/{client-DgBXj6Dh.d.ts → client-IjrvboaL.d.ts} +42 -2
- package/dist/computer-use-B9eNnX_y.d.ts +193 -0
- package/dist/computer-use-yH7ohjLl.d.cts +193 -0
- package/dist/index.cjs +397 -2
- 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 +46 -6
- package/package.json +12 -2
- package/dist/chunk-EEVTNG4C.js.map +0 -1
|
@@ -410,6 +410,16 @@ interface LocalTool<TArgs = Record<string, unknown>> {
|
|
|
410
410
|
* declarative — MANTYX does not change scheduling.
|
|
411
411
|
*/
|
|
412
412
|
readonly longRunning: boolean;
|
|
413
|
+
/**
|
|
414
|
+
* When `true`, this tool may run **in parallel** with other read-only
|
|
415
|
+
* tools the model emits in the same turn: MANTYX publishes every such
|
|
416
|
+
* `local_tool_call` concurrently and resolves them together instead of
|
|
417
|
+
* one-at-a-time in model-emit order. Set this only for side-effect-free
|
|
418
|
+
* tools whose results don't depend on each other. Mutating tools (the
|
|
419
|
+
* default, `false`) stay strictly sequential. See
|
|
420
|
+
* `docs/agent-runs-protocol.md` §4.1.1.
|
|
421
|
+
*/
|
|
422
|
+
readonly readOnly: boolean;
|
|
413
423
|
readonly execute: (args: TArgs) => Promise<string> | string;
|
|
414
424
|
}
|
|
415
425
|
interface DefineLocalToolOptions<T extends ZodLikeObject | undefined> {
|
|
@@ -428,6 +438,12 @@ interface DefineLocalToolOptions<T extends ZodLikeObject | undefined> {
|
|
|
428
438
|
* {@link LocalTool.longRunning}.
|
|
429
439
|
*/
|
|
430
440
|
longRunning?: boolean;
|
|
441
|
+
/**
|
|
442
|
+
* Mark the tool as read-only so MANTYX may run it in parallel with other
|
|
443
|
+
* read-only tools the model emits in the same turn. See
|
|
444
|
+
* {@link LocalTool.readOnly}.
|
|
445
|
+
*/
|
|
446
|
+
readOnly?: boolean;
|
|
431
447
|
execute: (args: T extends ZodLikeObject ? z.infer<T> : Record<string, unknown>) => Promise<string> | string;
|
|
432
448
|
}
|
|
433
449
|
declare function defineLocalTool<T extends ZodLikeObject | undefined>(opts: DefineLocalToolOptions<T>): LocalTool;
|
|
@@ -723,6 +739,23 @@ declare function inputFileUrlAttachment(opts: {
|
|
|
723
739
|
mimeType?: string;
|
|
724
740
|
filename?: string;
|
|
725
741
|
}): InputFileUrlAttachment;
|
|
742
|
+
/** Thumbs up/down verdict for {@link MantyxClient.submitRunFeedback}. */
|
|
743
|
+
type RunFeedbackVerdict = "UP" | "DOWN";
|
|
744
|
+
/** Body for `POST /agent-runs/:runId/feedback`. See §9a. */
|
|
745
|
+
interface RunFeedbackInput {
|
|
746
|
+
verdict: RunFeedbackVerdict;
|
|
747
|
+
/** Optional free-text note (≤ 8000 characters). */
|
|
748
|
+
explanation?: string;
|
|
749
|
+
/** Optional snapshot of the rated content; defaults to the run's final text. */
|
|
750
|
+
contentSnapshot?: string;
|
|
751
|
+
}
|
|
752
|
+
/** Response from `POST /agent-runs/:runId/feedback`. */
|
|
753
|
+
interface RunFeedbackResult {
|
|
754
|
+
id: string;
|
|
755
|
+
verdict: RunFeedbackVerdict;
|
|
756
|
+
targetKind: string;
|
|
757
|
+
agentRunId: string;
|
|
758
|
+
}
|
|
726
759
|
interface MantyxClientOptions {
|
|
727
760
|
/**
|
|
728
761
|
* Workspace API key (token prefix `mantyx_`) **or** a MANTYX OAuth 2.0
|
|
@@ -756,7 +789,7 @@ interface MantyxClientOptions {
|
|
|
756
789
|
*
|
|
757
790
|
* OAuth tokens additionally enforce per-route **scopes**
|
|
758
791
|
* (`runs:read`, `runs:write`, `sessions:read`, `sessions:write`,
|
|
759
|
-
* `models:read`, `mantyx.identity:read`); see
|
|
792
|
+
* `models:read`, `feedback:write`, `mantyx.identity:read`); see
|
|
760
793
|
* `docs/agent-runs-protocol.md` §2.2 for the table. Missing scopes
|
|
761
794
|
* land as {@link MantyxScopeError} so callers can route the user
|
|
762
795
|
* back to a re-consent flow.
|
|
@@ -1579,6 +1612,13 @@ declare class MantyxClient {
|
|
|
1579
1612
|
error?: string;
|
|
1580
1613
|
}): Promise<void>;
|
|
1581
1614
|
cancelRun(runId: string): Promise<void>;
|
|
1615
|
+
/**
|
|
1616
|
+
* Record thumbs up/down feedback on a run. Requires the `feedback:write`
|
|
1617
|
+
* OAuth scope (workspace API keys have implicit access). Idempotent per
|
|
1618
|
+
* run — the first call returns HTTP 201, updates return 200; both carry
|
|
1619
|
+
* the same response body. See `docs/agent-runs-protocol.md` §9a.
|
|
1620
|
+
*/
|
|
1621
|
+
submitRunFeedback(runId: string, input: RunFeedbackInput): Promise<RunFeedbackResult>;
|
|
1582
1622
|
private absoluteUrl;
|
|
1583
1623
|
/**
|
|
1584
1624
|
* Resolve the bearer credential to send on the next request. With a
|
|
@@ -1741,4 +1781,4 @@ interface LocalHandlers {
|
|
|
1741
1781
|
*/
|
|
1742
1782
|
declare function parseRunOutput<T = unknown>(result: RunResult, validator?: (value: unknown) => T): T;
|
|
1743
1783
|
|
|
1744
|
-
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
|
|
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 };
|
|
@@ -410,6 +410,16 @@ interface LocalTool<TArgs = Record<string, unknown>> {
|
|
|
410
410
|
* declarative — MANTYX does not change scheduling.
|
|
411
411
|
*/
|
|
412
412
|
readonly longRunning: boolean;
|
|
413
|
+
/**
|
|
414
|
+
* When `true`, this tool may run **in parallel** with other read-only
|
|
415
|
+
* tools the model emits in the same turn: MANTYX publishes every such
|
|
416
|
+
* `local_tool_call` concurrently and resolves them together instead of
|
|
417
|
+
* one-at-a-time in model-emit order. Set this only for side-effect-free
|
|
418
|
+
* tools whose results don't depend on each other. Mutating tools (the
|
|
419
|
+
* default, `false`) stay strictly sequential. See
|
|
420
|
+
* `docs/agent-runs-protocol.md` §4.1.1.
|
|
421
|
+
*/
|
|
422
|
+
readonly readOnly: boolean;
|
|
413
423
|
readonly execute: (args: TArgs) => Promise<string> | string;
|
|
414
424
|
}
|
|
415
425
|
interface DefineLocalToolOptions<T extends ZodLikeObject | undefined> {
|
|
@@ -428,6 +438,12 @@ interface DefineLocalToolOptions<T extends ZodLikeObject | undefined> {
|
|
|
428
438
|
* {@link LocalTool.longRunning}.
|
|
429
439
|
*/
|
|
430
440
|
longRunning?: boolean;
|
|
441
|
+
/**
|
|
442
|
+
* Mark the tool as read-only so MANTYX may run it in parallel with other
|
|
443
|
+
* read-only tools the model emits in the same turn. See
|
|
444
|
+
* {@link LocalTool.readOnly}.
|
|
445
|
+
*/
|
|
446
|
+
readOnly?: boolean;
|
|
431
447
|
execute: (args: T extends ZodLikeObject ? z.infer<T> : Record<string, unknown>) => Promise<string> | string;
|
|
432
448
|
}
|
|
433
449
|
declare function defineLocalTool<T extends ZodLikeObject | undefined>(opts: DefineLocalToolOptions<T>): LocalTool;
|
|
@@ -723,6 +739,23 @@ declare function inputFileUrlAttachment(opts: {
|
|
|
723
739
|
mimeType?: string;
|
|
724
740
|
filename?: string;
|
|
725
741
|
}): InputFileUrlAttachment;
|
|
742
|
+
/** Thumbs up/down verdict for {@link MantyxClient.submitRunFeedback}. */
|
|
743
|
+
type RunFeedbackVerdict = "UP" | "DOWN";
|
|
744
|
+
/** Body for `POST /agent-runs/:runId/feedback`. See §9a. */
|
|
745
|
+
interface RunFeedbackInput {
|
|
746
|
+
verdict: RunFeedbackVerdict;
|
|
747
|
+
/** Optional free-text note (≤ 8000 characters). */
|
|
748
|
+
explanation?: string;
|
|
749
|
+
/** Optional snapshot of the rated content; defaults to the run's final text. */
|
|
750
|
+
contentSnapshot?: string;
|
|
751
|
+
}
|
|
752
|
+
/** Response from `POST /agent-runs/:runId/feedback`. */
|
|
753
|
+
interface RunFeedbackResult {
|
|
754
|
+
id: string;
|
|
755
|
+
verdict: RunFeedbackVerdict;
|
|
756
|
+
targetKind: string;
|
|
757
|
+
agentRunId: string;
|
|
758
|
+
}
|
|
726
759
|
interface MantyxClientOptions {
|
|
727
760
|
/**
|
|
728
761
|
* Workspace API key (token prefix `mantyx_`) **or** a MANTYX OAuth 2.0
|
|
@@ -756,7 +789,7 @@ interface MantyxClientOptions {
|
|
|
756
789
|
*
|
|
757
790
|
* OAuth tokens additionally enforce per-route **scopes**
|
|
758
791
|
* (`runs:read`, `runs:write`, `sessions:read`, `sessions:write`,
|
|
759
|
-
* `models:read`, `mantyx.identity:read`); see
|
|
792
|
+
* `models:read`, `feedback:write`, `mantyx.identity:read`); see
|
|
760
793
|
* `docs/agent-runs-protocol.md` §2.2 for the table. Missing scopes
|
|
761
794
|
* land as {@link MantyxScopeError} so callers can route the user
|
|
762
795
|
* back to a re-consent flow.
|
|
@@ -1579,6 +1612,13 @@ declare class MantyxClient {
|
|
|
1579
1612
|
error?: string;
|
|
1580
1613
|
}): Promise<void>;
|
|
1581
1614
|
cancelRun(runId: string): Promise<void>;
|
|
1615
|
+
/**
|
|
1616
|
+
* Record thumbs up/down feedback on a run. Requires the `feedback:write`
|
|
1617
|
+
* OAuth scope (workspace API keys have implicit access). Idempotent per
|
|
1618
|
+
* run — the first call returns HTTP 201, updates return 200; both carry
|
|
1619
|
+
* the same response body. See `docs/agent-runs-protocol.md` §9a.
|
|
1620
|
+
*/
|
|
1621
|
+
submitRunFeedback(runId: string, input: RunFeedbackInput): Promise<RunFeedbackResult>;
|
|
1582
1622
|
private absoluteUrl;
|
|
1583
1623
|
/**
|
|
1584
1624
|
* Resolve the bearer credential to send on the next request. With a
|
|
@@ -1741,4 +1781,4 @@ interface LocalHandlers {
|
|
|
1741
1781
|
*/
|
|
1742
1782
|
declare function parseRunOutput<T = unknown>(result: RunResult, validator?: (value: unknown) => T): T;
|
|
1743
1783
|
|
|
1744
|
-
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
|
|
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 };
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { ag as RunResult, M as MantyxClient, R as ReasoningLevel, s as LocalTool } from './client-IjrvboaL.js';
|
|
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 };
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { ag as RunResult, M as MantyxClient, R as ReasoningLevel, s as LocalTool } from './client-IjrvboaL.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 };
|