@mantyx/sdk 0.22.0 → 0.22.1
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/dist/a2a-server.cjs.map +1 -1
- package/dist/a2a-server.d.ts +13 -16
- package/dist/a2a-server.d.ts.map +1 -0
- package/dist/a2a-server.js +1 -1
- package/dist/{chunk-5NKXV5XZ.js → chunk-STB4Z6F4.js} +25 -3
- package/dist/chunk-STB4Z6F4.js.map +1 -0
- package/dist/{client-C7TzTpNW.d.ts → client.d.ts} +83 -831
- package/dist/client.d.ts.map +1 -0
- package/dist/{computer-use-4QzI3lGU.d.ts → computer-use.d.ts} +21 -22
- package/dist/computer-use.d.ts.map +1 -0
- package/dist/errors.d.ts +153 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/index.cjs +25 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +44 -55
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/local-resolver.d.ts +49 -0
- package/dist/local-resolver.d.ts.map +1 -0
- package/dist/oauth.d.ts +189 -0
- package/dist/oauth.d.ts.map +1 -0
- package/dist/playwright.d.ts +6 -11
- package/dist/playwright.d.ts.map +1 -0
- package/dist/sse.d.ts +27 -0
- package/dist/sse.d.ts.map +1 -0
- package/dist/tools.d.ts +426 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/version.d.ts +5 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/zod-to-json-schema.d.ts +25 -0
- package/dist/zod-to-json-schema.d.ts.map +1 -0
- package/package.json +11 -11
- package/dist/a2a-server.d.cts +0 -176
- package/dist/chunk-5NKXV5XZ.js.map +0 -1
- package/dist/client-C7TzTpNW.d.cts +0 -2033
- package/dist/computer-use-1m6E_VIl.d.cts +0 -193
- package/dist/index.d.cts +0 -61
- package/dist/playwright.d.cts +0 -88
package/dist/oauth.d.ts
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MANTYX OAuth 2.0 refresh client: trade a stored refresh token for
|
|
3
|
+
* short-lived access tokens, revoke tokens at sign-out, and expose
|
|
4
|
+
* a {@link TokenSource} the {@link MantyxClient} HTTP layer calls
|
|
5
|
+
* before every request (and again on 401).
|
|
6
|
+
*
|
|
7
|
+
* The library is intentionally **refresh-only**. It assumes the caller
|
|
8
|
+
* already obtained the refresh token through their own sign-in flow
|
|
9
|
+
* (Authorization Code + PKCE in a browser, native redirect, server-
|
|
10
|
+
* side exchange — whatever fits the host application). The SDK does
|
|
11
|
+
* not drive consent, does not initiate auth-code exchanges, and does
|
|
12
|
+
* not bundle PKCE helpers.
|
|
13
|
+
*
|
|
14
|
+
* Wire contract (`docs/oauth.md`):
|
|
15
|
+
*
|
|
16
|
+
* - Token endpoint: `POST <baseUrl>/api/oauth/token`, form-encoded,
|
|
17
|
+
* `grant_type=refresh_token`. Echoes back the same `refresh_token`
|
|
18
|
+
* the client sent (refresh tokens are persistent and non-rotating).
|
|
19
|
+
* - Revoke endpoint: `POST <baseUrl>/api/oauth/revoke`, form-encoded.
|
|
20
|
+
* - Access tokens (`mantyx_at_…`) live 1 hour (`expires_in: 3600`).
|
|
21
|
+
* - Refresh tokens (`mantyx_rt_…`) are long-lived; the caller persists
|
|
22
|
+
* them once at first sign-in (encrypted at rest) and the SDK re-mints
|
|
23
|
+
* access tokens from the same value on demand.
|
|
24
|
+
*/
|
|
25
|
+
import { MantyxError } from "./errors.js";
|
|
26
|
+
export declare const DEFAULT_OAUTH_BASE_URL = "https://app.mantyx.io";
|
|
27
|
+
/** Skew (ms) before `expiresAt` at which a TokenSource will pre-emptively refresh. Default 60s. */
|
|
28
|
+
export declare const DEFAULT_REFRESH_SKEW_MS = 60000;
|
|
29
|
+
/**
|
|
30
|
+
* Raised on a non-2xx response from `POST /api/oauth/token` or
|
|
31
|
+
* `POST /api/oauth/revoke`. Carries the RFC 6749 `error` discriminator
|
|
32
|
+
* (`"invalid_grant"`, `"invalid_client"`, `"unsupported_grant_type"`,
|
|
33
|
+
* …) and the optional `error_description` so callers can branch on
|
|
34
|
+
* machine-readable values without parsing the human message.
|
|
35
|
+
*
|
|
36
|
+
* `invalid_grant` from the refresh path specifically signals that the
|
|
37
|
+
* refresh token has been revoked (or the OAuth grant / application
|
|
38
|
+
* was deleted). The SDK never loops on this — callers should route
|
|
39
|
+
* the user back to a fresh sign-in.
|
|
40
|
+
*/
|
|
41
|
+
export declare class MantyxOAuthError extends MantyxError {
|
|
42
|
+
readonly oauthError: string;
|
|
43
|
+
readonly oauthErrorDescription: string | undefined;
|
|
44
|
+
constructor(oauthError: string, oauthErrorDescription: string | undefined, status: number);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Decoded `POST /api/oauth/token` response, augmented with an absolute
|
|
48
|
+
* `expiresAt` timestamp the SDK uses to decide when to refresh.
|
|
49
|
+
*
|
|
50
|
+
* On the refresh grant the response's `refreshToken` is identical to
|
|
51
|
+
* the value the client just sent (refresh tokens never rotate). The
|
|
52
|
+
* field is surfaced for symmetry with whatever the calling app's
|
|
53
|
+
* sign-in flow already does.
|
|
54
|
+
*/
|
|
55
|
+
export interface OAuthToken {
|
|
56
|
+
readonly accessToken: string;
|
|
57
|
+
readonly refreshToken: string | undefined;
|
|
58
|
+
readonly tokenType: string;
|
|
59
|
+
readonly expiresIn: number;
|
|
60
|
+
/** Absolute Unix-ms timestamp set when the SDK parsed the response. */
|
|
61
|
+
readonly expiresAt: number;
|
|
62
|
+
readonly scope: string | undefined;
|
|
63
|
+
}
|
|
64
|
+
/** Why the SDK asked the {@link TokenSource} for the current access token. */
|
|
65
|
+
export type TokenRequestReason = "initial" | "expired" | "unauthorized";
|
|
66
|
+
/**
|
|
67
|
+
* A `TokenSource` produces the current access token on demand. The
|
|
68
|
+
* {@link MantyxClient} HTTP layer calls it before every request. When
|
|
69
|
+
* called with `reason: "unauthorized"` the source MUST force a refresh
|
|
70
|
+
* (do not return a cached value); this is how the SDK recovers from
|
|
71
|
+
* 401s caused by a token that the server already invalidated.
|
|
72
|
+
*
|
|
73
|
+
* Implementations should be safe to call from many concurrent requests.
|
|
74
|
+
*/
|
|
75
|
+
export type TokenSource = (reason?: TokenRequestReason) => Promise<string>;
|
|
76
|
+
/** Caller-supplied options for `MantyxOAuthClient`. */
|
|
77
|
+
export interface MantyxOAuthClientOptions {
|
|
78
|
+
/**
|
|
79
|
+
* OAuth `client_id` issued at app registration (token prefix
|
|
80
|
+
* `mantyx_oa_`).
|
|
81
|
+
*/
|
|
82
|
+
clientId: string;
|
|
83
|
+
/**
|
|
84
|
+
* OAuth `client_secret` issued at app registration (token prefix
|
|
85
|
+
* `mantyx_oas_`). Every MANTYX OAuth app is a confidential client,
|
|
86
|
+
* so this is always required for token + revoke calls. Treat as a
|
|
87
|
+
* deployment secret — do not bundle into browser builds.
|
|
88
|
+
*/
|
|
89
|
+
clientSecret: string;
|
|
90
|
+
/**
|
|
91
|
+
* Origin of the MANTYX deployment. Defaults to `https://app.mantyx.io`.
|
|
92
|
+
* The OAuth endpoints are mounted at `<baseUrl>/api/oauth/...`.
|
|
93
|
+
*/
|
|
94
|
+
baseUrl?: string;
|
|
95
|
+
/** Optional `fetch` override (e.g. node-fetch wrapper). Default: global `fetch`. */
|
|
96
|
+
fetch?: typeof fetch;
|
|
97
|
+
/** Default per-request timeout in milliseconds. Default: 30s. */
|
|
98
|
+
timeoutMs?: number;
|
|
99
|
+
}
|
|
100
|
+
export interface RefreshOptions {
|
|
101
|
+
refreshToken: string;
|
|
102
|
+
/**
|
|
103
|
+
* Optional scope narrowing. Must be a subset of the scopes already
|
|
104
|
+
* granted to the refresh token (server enforces this). Useful when
|
|
105
|
+
* an SDK consumer wants a short-scope access token for a specific
|
|
106
|
+
* sub-operation.
|
|
107
|
+
*/
|
|
108
|
+
scope?: string | readonly string[];
|
|
109
|
+
}
|
|
110
|
+
export interface RevokeOptions {
|
|
111
|
+
token: string;
|
|
112
|
+
}
|
|
113
|
+
export interface RefreshTokenSourceOptions {
|
|
114
|
+
refreshToken: string;
|
|
115
|
+
/** Optional scope narrowing applied on every refresh. */
|
|
116
|
+
scope?: string | readonly string[];
|
|
117
|
+
/**
|
|
118
|
+
* How many ms before `expiresAt` the source proactively refreshes.
|
|
119
|
+
* Defaults to {@link DEFAULT_REFRESH_SKEW_MS} (60s).
|
|
120
|
+
*/
|
|
121
|
+
refreshSkewMs?: number;
|
|
122
|
+
/**
|
|
123
|
+
* Optional initial access token + expiry to seed the source's cache
|
|
124
|
+
* with (e.g. the token already in hand from the host application's
|
|
125
|
+
* sign-in flow). When omitted, the source mints one on the first
|
|
126
|
+
* call.
|
|
127
|
+
*/
|
|
128
|
+
initialToken?: OAuthToken;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Refresh-only wrapper around the MANTYX OAuth 2.0 authorization-server
|
|
132
|
+
* endpoints. App-scoped (one per `{clientId, clientSecret}` pair);
|
|
133
|
+
* construct independently of {@link MantyxClient}, then either call
|
|
134
|
+
* {@link refresh} / {@link revoke} directly or hand a `TokenSource`
|
|
135
|
+
* produced by {@link refreshTokenSource} to `MantyxClient` for fully
|
|
136
|
+
* transparent refresh on every request.
|
|
137
|
+
*
|
|
138
|
+
* The client deliberately does **not** drive the authorization-code
|
|
139
|
+
* exchange or any other "initiate sign-in" grant. The caller is
|
|
140
|
+
* expected to obtain the refresh token through their own consent flow
|
|
141
|
+
* and persist it before constructing this client.
|
|
142
|
+
*/
|
|
143
|
+
export declare class MantyxOAuthClient {
|
|
144
|
+
readonly clientId: string;
|
|
145
|
+
readonly baseUrl: string;
|
|
146
|
+
private readonly clientSecret;
|
|
147
|
+
private readonly fetchImpl;
|
|
148
|
+
private readonly timeoutMs;
|
|
149
|
+
constructor(opts: MantyxOAuthClientOptions);
|
|
150
|
+
/**
|
|
151
|
+
* Mint a fresh access token from a stored refresh token. The
|
|
152
|
+
* returned `refreshToken` is identical to the input — refresh
|
|
153
|
+
* tokens are persistent and non-rotating, so the field is
|
|
154
|
+
* surfaced only for symmetry with the response shape.
|
|
155
|
+
*
|
|
156
|
+
* On `400 invalid_grant` the refresh token has been revoked (or its
|
|
157
|
+
* grant / app was deleted); the SDK surfaces a
|
|
158
|
+
* {@link MantyxOAuthError} and callers must drive a fresh sign-in.
|
|
159
|
+
*/
|
|
160
|
+
refresh(opts: RefreshOptions): Promise<OAuthToken>;
|
|
161
|
+
/**
|
|
162
|
+
* Revoke an access or refresh token (RFC 7009). The server always
|
|
163
|
+
* returns 200, even for unknown tokens. Revoking a **refresh**
|
|
164
|
+
* token kills the refresh and every live access token tied to its
|
|
165
|
+
* grant; revoking an **access** token kills only that one.
|
|
166
|
+
*/
|
|
167
|
+
revoke(opts: RevokeOptions): Promise<void>;
|
|
168
|
+
/**
|
|
169
|
+
* Build a long-lived {@link TokenSource} that re-mints access
|
|
170
|
+
* tokens from the supplied refresh token. Pass the returned source
|
|
171
|
+
* to `new MantyxClient({ tokenSource, workspaceSlug, ... })`. The
|
|
172
|
+
* source caches the access token in-memory and refreshes
|
|
173
|
+
* proactively when the cached value is within `refreshSkewMs` of
|
|
174
|
+
* `expiresAt`, or eagerly when `MantyxClient` reports a 401.
|
|
175
|
+
*
|
|
176
|
+
* Pass `initialToken` if the calling app already has a non-expired
|
|
177
|
+
* access token in hand (e.g. straight out of the sign-in flow) to
|
|
178
|
+
* avoid an extra round-trip on the first request.
|
|
179
|
+
*/
|
|
180
|
+
refreshTokenSource(opts: RefreshTokenSourceOptions): TokenSource;
|
|
181
|
+
/**
|
|
182
|
+
* POST `application/x-www-form-urlencoded` to `/api/oauth/token` and
|
|
183
|
+
* decode the {@link OAuthToken} response. Always injects `client_id`
|
|
184
|
+
* + `client_secret` from the constructor.
|
|
185
|
+
*/
|
|
186
|
+
private token;
|
|
187
|
+
private formPost;
|
|
188
|
+
}
|
|
189
|
+
//# sourceMappingURL=oauth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"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
|
1
|
-
import { Page } from 'playwright';
|
|
2
|
-
import { B as BrowserController, V as Viewport, S as Screenshot, T as TypeTextOptions, f as ScrollDirection } from './computer-use-4QzI3lGU.js';
|
|
3
|
-
import './client-C7TzTpNW.js';
|
|
4
|
-
import 'zod';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* Playwright-backed {@link BrowserController} for computer use.
|
|
8
3
|
*
|
|
@@ -28,8 +23,9 @@ import 'zod';
|
|
|
28
23
|
* controller,
|
|
29
24
|
* });
|
|
30
25
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
import type { Page } from "playwright";
|
|
27
|
+
import type { BrowserController, Screenshot, ScrollDirection, TypeTextOptions, Viewport } from "./computer-use.js";
|
|
28
|
+
export interface PlaywrightControllerOptions {
|
|
33
29
|
/**
|
|
34
30
|
* Viewport width in pixels. Should match the browser context viewport so
|
|
35
31
|
* denormalized coordinates from the model land on the right pixels.
|
|
@@ -59,7 +55,7 @@ interface PlaywrightControllerOptions {
|
|
|
59
55
|
* arrive already denormalized to pixels by the computer-use tools, so this
|
|
60
56
|
* class drives Playwright directly.
|
|
61
57
|
*/
|
|
62
|
-
declare class PlaywrightController implements BrowserController {
|
|
58
|
+
export declare class PlaywrightController implements BrowserController {
|
|
63
59
|
private readonly page;
|
|
64
60
|
private readonly width;
|
|
65
61
|
private readonly height;
|
|
@@ -83,6 +79,5 @@ declare class PlaywrightController implements BrowserController {
|
|
|
83
79
|
private settle;
|
|
84
80
|
}
|
|
85
81
|
/** @internal Exported for unit tests. */
|
|
86
|
-
declare function scrollDelta(direction: ScrollDirection, magnitude: number): [number, number];
|
|
87
|
-
|
|
88
|
-
export { PlaywrightController, type PlaywrightControllerOptions, scrollDelta };
|
|
82
|
+
export declare function scrollDelta(direction: ScrollDirection, magnitude: number): [number, number];
|
|
83
|
+
//# sourceMappingURL=playwright.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playwright.d.ts","sourceRoot":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AAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEjD;IAEK,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CASzF;IAEK,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGhD;IAEK,QAAQ,CACZ,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,SAAS,EAAE,eAAe,EAC1B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC,CAKf;IAEK,cAAc,CAAC,SAAS,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAI9D;IAEK,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAMnF;IAEK,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAG5B;IAEK,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAG/B;YAEa,MAAM;CAQrB;AAED,yCAAyC;AACzC,wBAAgB,WAAW,CAAC,SAAS,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAW3F"}
|
package/dist/sse.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal Server-Sent Events parser.
|
|
3
|
+
*
|
|
4
|
+
* Reads a `ReadableStream<Uint8Array>` (the body of a `fetch()` response) and
|
|
5
|
+
* yields parsed events with `id`, `event` and `data` fields. We deliberately
|
|
6
|
+
* keep this dependency-free instead of pulling in `eventsource` / `eventsource-parser`
|
|
7
|
+
* so the SDK has the smallest possible install footprint.
|
|
8
|
+
*
|
|
9
|
+
* Reconnect/replay is handled at a higher layer using `Last-Event-ID` (the
|
|
10
|
+
* default for browsers' `EventSource`) plus a `?lastSeq=` query param so curl
|
|
11
|
+
* users and SSE-via-fetch consumers both work.
|
|
12
|
+
*/
|
|
13
|
+
export interface SseEvent {
|
|
14
|
+
id?: string;
|
|
15
|
+
event?: string;
|
|
16
|
+
data: string;
|
|
17
|
+
}
|
|
18
|
+
export interface SseStreamOptions {
|
|
19
|
+
/** AbortSignal for cancellation. */
|
|
20
|
+
signal?: AbortSignal;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Async generator yielding parsed SSE events from a fetch response body.
|
|
24
|
+
* Comment frames (`:keep-alive`) are dropped.
|
|
25
|
+
*/
|
|
26
|
+
export declare function readSseStream(body: ReadableStream<Uint8Array> | null, opts?: SseStreamOptions): AsyncGenerator<SseEvent, void, void>;
|
|
27
|
+
//# sourceMappingURL=sse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sse.d.ts","sourceRoot":"","sources":["../src/sse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,MAAM,WAAW,QAAQ;IACvB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,gBAAgB;IAC/B,oCAAoC;IACpC,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;GAGG;AACH,wBAAuB,aAAa,CAClC,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,IAAI,EACvC,IAAI,GAAE,gBAAqB,GAC1B,cAAc,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,CA6CtC"}
|