@opentabs-dev/plugin-sdk 0.0.16 → 0.0.17
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/dist/dom.d.ts +1 -1
- package/dist/dom.d.ts.map +1 -1
- package/dist/dom.js.map +1 -1
- package/dist/errors.d.ts +10 -10
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +15 -15
- package/dist/errors.js.map +1 -1
- package/dist/fetch.d.ts +82 -3
- package/dist/fetch.d.ts.map +1 -1
- package/dist/fetch.js +93 -15
- package/dist/fetch.js.map +1 -1
- package/dist/index.d.ts +66 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/page-state.d.ts +1 -2
- package/dist/page-state.d.ts.map +1 -1
- package/dist/page-state.js +1 -2
- package/dist/page-state.js.map +1 -1
- package/dist/storage.d.ts +15 -0
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +36 -0
- package/dist/storage.js.map +1 -1
- package/package.json +2 -2
package/dist/dom.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export interface ObserveDOMOptions {
|
|
|
15
15
|
* Uses MutationObserver for efficient detection, falls back to an
|
|
16
16
|
* initial querySelector check for elements already present.
|
|
17
17
|
*/
|
|
18
|
-
export declare const waitForSelector: (selector: string, opts?: WaitForSelectorOptions) => Promise<
|
|
18
|
+
export declare const waitForSelector: <T extends Element = Element>(selector: string, opts?: WaitForSelectorOptions) => Promise<T>;
|
|
19
19
|
/**
|
|
20
20
|
* Waits for an element matching `selector` to be removed from the DOM.
|
|
21
21
|
* Resolves immediately if no matching element exists.
|
package/dist/dom.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../src/dom.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,sBAAsB;IACrC,+CAA+C;IAC/C,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB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AAM,IAAI,CAcb,CAAC"}
|
package/dist/dom.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom.js","sourceRoot":"","sources":["../src/dom.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,mCAAmC;AACnC,8EAA8E;AAgB9E;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,
|
|
1
|
+
{"version":3,"file":"dom.js","sourceRoot":"","sources":["../src/dom.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,mCAAmC;AACnC,8EAA8E;AAgB9E;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,QAAgB,EAChB,IAA6B,EACjB,EAAE;IACd,MAAM,OAAO,GAAG,IAAI,EAAE,OAAO,IAAI,MAAM,CAAC;IAExC,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACxC,MAAM,QAAQ,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAClD,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,CAAC,QAAa,CAAC,CAAC;YACvB,OAAO;QACT,CAAC;QAED,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;YAC5B,IAAI,OAAO;gBAAE,OAAO;YACpB,OAAO,GAAG,IAAI,CAAC;YACf,QAAQ,CAAC,UAAU,EAAE,CAAC;YACtB,MAAM,CAAC,IAAI,KAAK,CAAC,oCAAoC,OAAO,mBAAmB,QAAQ,GAAG,CAAC,CAAC,CAAC;QAC/F,CAAC,EAAE,OAAO,CAAC,CAAC;QAEZ,MAAM,QAAQ,GAAG,IAAI,gBAAgB,CAAC,GAAG,EAAE;YACzC,MAAM,EAAE,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;YAC5C,IAAI,EAAE,EAAE,CAAC;gBACP,IAAI,OAAO;oBAAE,OAAO;gB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GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;AACrC,CAAC,CAAC"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -22,17 +22,17 @@ export declare class ToolError extends Error {
|
|
|
22
22
|
constructor(message: string,
|
|
23
23
|
/** Machine-readable error code (e.g., 'CHANNEL_NOT_FOUND') */
|
|
24
24
|
code: string, opts?: ToolErrorOptions);
|
|
25
|
-
/** Authentication or authorization error (not retryable). */
|
|
26
|
-
static auth(message: string): ToolError;
|
|
25
|
+
/** Authentication or authorization error (not retryable). Accepts an optional domain-specific code. */
|
|
26
|
+
static auth(message: string, code?: string): ToolError;
|
|
27
27
|
/** Resource not found (not retryable). Accepts an optional domain-specific code. */
|
|
28
28
|
static notFound(message: string, code?: string): ToolError;
|
|
29
|
-
/** Rate limited (retryable). Accepts an optional retry delay in milliseconds. */
|
|
30
|
-
static rateLimited(message: string, retryAfterMs?: number): ToolError;
|
|
31
|
-
/** Input validation error (not retryable). */
|
|
32
|
-
static validation(message: string): ToolError;
|
|
33
|
-
/** Operation timed out (retryable). */
|
|
34
|
-
static timeout(message: string): ToolError;
|
|
35
|
-
/** Internal/unexpected error (not retryable). */
|
|
36
|
-
static internal(message: string): ToolError;
|
|
29
|
+
/** Rate limited (retryable). Accepts an optional retry delay in milliseconds and an optional domain-specific code. */
|
|
30
|
+
static rateLimited(message: string, retryAfterMs?: number, code?: string): ToolError;
|
|
31
|
+
/** Input validation error (not retryable). Accepts an optional domain-specific code. */
|
|
32
|
+
static validation(message: string, code?: string): ToolError;
|
|
33
|
+
/** Operation timed out (retryable). Accepts an optional domain-specific code. */
|
|
34
|
+
static timeout(message: string, code?: string): ToolError;
|
|
35
|
+
/** Internal/unexpected error (not retryable). Accepts an optional domain-specific code. */
|
|
36
|
+
static internal(message: string, code?: string): ToolError;
|
|
37
37
|
}
|
|
38
38
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAIA,+DAA+D;AAC/D,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,YAAY,GAAG,WAAW,GAAG,YAAY,GAAG,UAAU,GAAG,SAAS,CAAC;AAExG,kDAAkD;AAClD,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,aAAa,CAAC;CAC1B;AAED;;;GAGG;AACH,qBAAa,SAAU,SAAQ,KAAK;IAUhC,8DAA8D;aAC9C,IAAI,EAAE,MAAM;IAV9B,2DAA2D;IAC3D,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,wDAAwD;IACxD,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1C,0DAA0D;IAC1D,QAAQ,CAAC,QAAQ,EAAE,aAAa,GAAG,SAAS,CAAC;gBAG3C,OAAO,EAAE,MAAM;IACf,8DAA8D;IAC9C,IAAI,EAAE,MAAM,EAC5B,IAAI,CAAC,EAAE,gBAAgB;IASzB,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAIA,+DAA+D;AAC/D,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,YAAY,GAAG,WAAW,GAAG,YAAY,GAAG,UAAU,GAAG,SAAS,CAAC;AAExG,kDAAkD;AAClD,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,aAAa,CAAC;CAC1B;AAED;;;GAGG;AACH,qBAAa,SAAU,SAAQ,KAAK;IAUhC,8DAA8D;aAC9C,IAAI,EAAE,MAAM;IAV9B,2DAA2D;IAC3D,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,wDAAwD;IACxD,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1C,0DAA0D;IAC1D,QAAQ,CAAC,QAAQ,EAAE,aAAa,GAAG,SAAS,CAAC;gBAG3C,OAAO,EAAE,MAAM;IACf,8DAA8D;IAC9C,IAAI,EAAE,MAAM,EAC5B,IAAI,CAAC,EAAE,gBAAgB;IASzB,uGAAuG;IACvG,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS;IAItD,oFAAoF;IACpF,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS;IAI1D,sHAAsH;IACtH,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS;IAIpF,wFAAwF;IACxF,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS;IAI5D,iFAAiF;IACjF,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS;IAIzD,2FAA2F;IAC3F,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS;CAG3D"}
|
package/dist/errors.js
CHANGED
|
@@ -23,29 +23,29 @@ export class ToolError extends Error {
|
|
|
23
23
|
this.retryAfterMs = opts?.retryAfterMs;
|
|
24
24
|
this.category = opts?.category;
|
|
25
25
|
}
|
|
26
|
-
/** Authentication or authorization error (not retryable). */
|
|
27
|
-
static auth(message) {
|
|
28
|
-
return new ToolError(message, 'AUTH_ERROR', { category: 'auth', retryable: false });
|
|
26
|
+
/** Authentication or authorization error (not retryable). Accepts an optional domain-specific code. */
|
|
27
|
+
static auth(message, code) {
|
|
28
|
+
return new ToolError(message, code ?? 'AUTH_ERROR', { category: 'auth', retryable: false });
|
|
29
29
|
}
|
|
30
30
|
/** Resource not found (not retryable). Accepts an optional domain-specific code. */
|
|
31
31
|
static notFound(message, code) {
|
|
32
32
|
return new ToolError(message, code ?? 'NOT_FOUND', { category: 'not_found', retryable: false });
|
|
33
33
|
}
|
|
34
|
-
/** Rate limited (retryable). Accepts an optional retry delay in milliseconds. */
|
|
35
|
-
static rateLimited(message, retryAfterMs) {
|
|
36
|
-
return new ToolError(message, 'RATE_LIMITED', { category: 'rate_limit', retryable: true, retryAfterMs });
|
|
34
|
+
/** Rate limited (retryable). Accepts an optional retry delay in milliseconds and an optional domain-specific code. */
|
|
35
|
+
static rateLimited(message, retryAfterMs, code) {
|
|
36
|
+
return new ToolError(message, code ?? 'RATE_LIMITED', { category: 'rate_limit', retryable: true, retryAfterMs });
|
|
37
37
|
}
|
|
38
|
-
/** Input validation error (not retryable). */
|
|
39
|
-
static validation(message) {
|
|
40
|
-
return new ToolError(message, 'VALIDATION_ERROR', { category: 'validation', retryable: false });
|
|
38
|
+
/** Input validation error (not retryable). Accepts an optional domain-specific code. */
|
|
39
|
+
static validation(message, code) {
|
|
40
|
+
return new ToolError(message, code ?? 'VALIDATION_ERROR', { category: 'validation', retryable: false });
|
|
41
41
|
}
|
|
42
|
-
/** Operation timed out (retryable). */
|
|
43
|
-
static timeout(message) {
|
|
44
|
-
return new ToolError(message, 'TIMEOUT', { category: 'timeout', retryable: true });
|
|
42
|
+
/** Operation timed out (retryable). Accepts an optional domain-specific code. */
|
|
43
|
+
static timeout(message, code) {
|
|
44
|
+
return new ToolError(message, code ?? 'TIMEOUT', { category: 'timeout', retryable: true });
|
|
45
45
|
}
|
|
46
|
-
/** Internal/unexpected error (not retryable). */
|
|
47
|
-
static internal(message) {
|
|
48
|
-
return new ToolError(message, 'INTERNAL_ERROR', { category: 'internal', retryable: false });
|
|
46
|
+
/** Internal/unexpected error (not retryable). Accepts an optional domain-specific code. */
|
|
47
|
+
static internal(message, code) {
|
|
48
|
+
return new ToolError(message, code ?? 'INTERNAL_ERROR', { category: 'internal', retryable: false });
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
//# sourceMappingURL=errors.js.map
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,iCAAiC;AACjC,8EAA8E;AAY9E;;;GAGG;AACH,MAAM,OAAO,SAAU,SAAQ,KAAK;IAWhB;IAVlB,2DAA2D;IAClD,SAAS,CAAU;IAC5B,wDAAwD;IAC/C,YAAY,CAAqB;IAC1C,0DAA0D;IACjD,QAAQ,CAA4B;IAE7C,YACE,OAAe;IACf,8DAA8D;IAC9C,IAAY,EAC5B,IAAuB;QAEvB,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,SAAI,GAAJ,IAAI,CAAQ;QAI5B,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,IAAI,CAAC,SAAS,GAAG,IAAI,EAAE,SAAS,IAAI,KAAK,CAAC;QAC1C,IAAI,CAAC,YAAY,GAAG,IAAI,EAAE,YAAY,CAAC;QACvC,IAAI,CAAC,QAAQ,GAAG,IAAI,EAAE,QAAQ,CAAC;IACjC,CAAC;IAED,
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,iCAAiC;AACjC,8EAA8E;AAY9E;;;GAGG;AACH,MAAM,OAAO,SAAU,SAAQ,KAAK;IAWhB;IAVlB,2DAA2D;IAClD,SAAS,CAAU;IAC5B,wDAAwD;IAC/C,YAAY,CAAqB;IAC1C,0DAA0D;IACjD,QAAQ,CAA4B;IAE7C,YACE,OAAe;IACf,8DAA8D;IAC9C,IAAY,EAC5B,IAAuB;QAEvB,KAAK,CAAC,OAAO,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OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7F,CAAC;IAED,2FAA2F;IAC3F,MAAM,CAAC,QAAQ,CAAC,OAAe,EAAE,IAAa;QAC5C,OAAO,IAAI,SAAS,CAAC,OAAO,EAAE,IAAI,IAAI,gBAAgB,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;IACtG,CAAC;CACF"}
|
package/dist/fetch.d.ts
CHANGED
|
@@ -1,21 +1,100 @@
|
|
|
1
|
+
import { ToolError } from './errors.js';
|
|
2
|
+
import type { z } from 'zod';
|
|
1
3
|
export interface FetchFromPageOptions extends RequestInit {
|
|
2
4
|
/** Request timeout in milliseconds (default: 30000) */
|
|
3
5
|
timeout?: number;
|
|
4
6
|
}
|
|
7
|
+
/** Maps an HTTP error response to a ToolError with the appropriate category. */
|
|
8
|
+
export declare const httpStatusToToolError: (response: Response, message: string) => ToolError;
|
|
9
|
+
/** Parses a Retry-After header value (seconds or HTTP-date) into milliseconds. */
|
|
10
|
+
export declare const parseRetryAfterMs: (value: string) => number | undefined;
|
|
5
11
|
/**
|
|
6
12
|
* Fetches a URL using the page's authenticated session (credentials: 'include').
|
|
7
13
|
* Provides built-in timeout via AbortSignal and throws a descriptive ToolError
|
|
8
14
|
* on non-ok HTTP status codes.
|
|
9
15
|
*/
|
|
10
16
|
export declare const fetchFromPage: (url: string, init?: FetchFromPageOptions) => Promise<Response>;
|
|
17
|
+
/** Shared implementation for fetchJSON and postJSON — fetches, parses JSON, optionally validates. */
|
|
18
|
+
export declare const fetchJSONImpl: (url: string, init?: FetchFromPageOptions, schema?: z.ZodType) => Promise<unknown>;
|
|
19
|
+
/**
|
|
20
|
+
* Overloaded call signature for fetchJSON — validates against a Zod schema
|
|
21
|
+
* when provided, or returns an unchecked cast when omitted.
|
|
22
|
+
*/
|
|
23
|
+
export interface FetchJSON {
|
|
24
|
+
/** Fetch JSON and validate against a Zod schema. Returns the validated, typed result. */
|
|
25
|
+
<T extends z.ZodType>(url: string, init: FetchFromPageOptions | undefined, schema: T): Promise<z.infer<T>>;
|
|
26
|
+
/** Fetch JSON with an unchecked cast to T (backward compatible). */
|
|
27
|
+
<T>(url: string, init?: FetchFromPageOptions): Promise<T>;
|
|
28
|
+
}
|
|
11
29
|
/**
|
|
12
30
|
* Fetches a URL and parses the response as JSON. Uses the page's session
|
|
13
31
|
* cookies (credentials: 'include') and provides timeout + error handling.
|
|
32
|
+
* When a Zod schema is provided as the third argument, the parsed JSON is
|
|
33
|
+
* validated against it and a ToolError.validation is thrown on failure.
|
|
14
34
|
*/
|
|
15
|
-
export declare const fetchJSON:
|
|
35
|
+
export declare const fetchJSON: FetchJSON;
|
|
36
|
+
/**
|
|
37
|
+
* Overloaded call signature for postJSON — validates against a Zod schema
|
|
38
|
+
* when provided, or returns an unchecked cast when omitted.
|
|
39
|
+
*/
|
|
40
|
+
export interface PostJSON {
|
|
41
|
+
/** POST JSON and validate the response against a Zod schema. Returns the validated, typed result. */
|
|
42
|
+
<T extends z.ZodType>(url: string, body: unknown, init: FetchFromPageOptions | undefined, schema: T): Promise<z.infer<T>>;
|
|
43
|
+
/** POST JSON with an unchecked cast to T (backward compatible). */
|
|
44
|
+
<T>(url: string, body: unknown, init?: FetchFromPageOptions): Promise<T>;
|
|
45
|
+
}
|
|
16
46
|
/**
|
|
17
47
|
* Convenience wrapper for POST requests with a JSON body. Sets Content-Type,
|
|
18
|
-
* stringifies the body, and parses the JSON response.
|
|
48
|
+
* stringifies the body, and parses the JSON response. When a Zod schema is
|
|
49
|
+
* provided as the fourth argument, the parsed JSON is validated against it.
|
|
50
|
+
*/
|
|
51
|
+
export declare const postJSON: PostJSON;
|
|
52
|
+
/**
|
|
53
|
+
* Overloaded call signature for putJSON — validates against a Zod schema
|
|
54
|
+
* when provided, or returns an unchecked cast when omitted.
|
|
55
|
+
*/
|
|
56
|
+
export interface PutJSON {
|
|
57
|
+
/** PUT JSON and validate the response against a Zod schema. Returns the validated, typed result. */
|
|
58
|
+
<T extends z.ZodType>(url: string, body: unknown, init: FetchFromPageOptions | undefined, schema: T): Promise<z.infer<T>>;
|
|
59
|
+
/** PUT JSON with an unchecked cast to T (backward compatible). */
|
|
60
|
+
<T>(url: string, body: unknown, init?: FetchFromPageOptions): Promise<T>;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Convenience wrapper for PUT requests with a JSON body. Sets Content-Type,
|
|
64
|
+
* stringifies the body, and parses the JSON response. When a Zod schema is
|
|
65
|
+
* provided as the fourth argument, the parsed JSON is validated against it.
|
|
66
|
+
*/
|
|
67
|
+
export declare const putJSON: PutJSON;
|
|
68
|
+
/**
|
|
69
|
+
* Overloaded call signature for patchJSON — validates against a Zod schema
|
|
70
|
+
* when provided, or returns an unchecked cast when omitted.
|
|
71
|
+
*/
|
|
72
|
+
export interface PatchJSON {
|
|
73
|
+
/** PATCH JSON and validate the response against a Zod schema. Returns the validated, typed result. */
|
|
74
|
+
<T extends z.ZodType>(url: string, body: unknown, init: FetchFromPageOptions | undefined, schema: T): Promise<z.infer<T>>;
|
|
75
|
+
/** PATCH JSON with an unchecked cast to T (backward compatible). */
|
|
76
|
+
<T>(url: string, body: unknown, init?: FetchFromPageOptions): Promise<T>;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Convenience wrapper for PATCH requests with a JSON body. Sets Content-Type,
|
|
80
|
+
* stringifies the body, and parses the JSON response. When a Zod schema is
|
|
81
|
+
* provided as the fourth argument, the parsed JSON is validated against it.
|
|
82
|
+
*/
|
|
83
|
+
export declare const patchJSON: PatchJSON;
|
|
84
|
+
/**
|
|
85
|
+
* Overloaded call signature for deleteJSON — validates against a Zod schema
|
|
86
|
+
* when provided, or returns an unchecked cast when omitted.
|
|
87
|
+
*/
|
|
88
|
+
export interface DeleteJSON {
|
|
89
|
+
/** DELETE and validate the response against a Zod schema. Returns the validated, typed result. */
|
|
90
|
+
<T extends z.ZodType>(url: string, init: FetchFromPageOptions | undefined, schema: T): Promise<z.infer<T>>;
|
|
91
|
+
/** DELETE with an unchecked cast to T (backward compatible). */
|
|
92
|
+
<T>(url: string, init?: FetchFromPageOptions): Promise<T>;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Convenience wrapper for DELETE requests. Parses the JSON response.
|
|
96
|
+
* When a Zod schema is provided as the third argument, the parsed JSON
|
|
97
|
+
* is validated against it.
|
|
19
98
|
*/
|
|
20
|
-
export declare const
|
|
99
|
+
export declare const deleteJSON: DeleteJSON;
|
|
21
100
|
//# sourceMappingURL=fetch.d.ts.map
|
package/dist/fetch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,MAAM,WAAW,oBAAqB,SAAQ,WAAW;IACvD,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,gFAAgF;AAChF,eAAO,MAAM,qBAAqB,GAAI,UAAU,QAAQ,EAAE,SAAS,MAAM,KAAG,SAc3E,CAAC;AAEF,kFAAkF;AAClF,eAAO,MAAM,iBAAiB,GAAI,OAAO,MAAM,KAAG,MAAM,GAAG,SAW1D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAU,KAAK,MAAM,EAAE,OAAO,oBAAoB,KAAG,OAAO,CAAC,QAAQ,CAkC9F,CAAC;AAEF,qGAAqG;AACrG,eAAO,MAAM,aAAa,GAAU,KAAK,MAAM,EAAE,OAAO,oBAAoB,EAAE,SAAS,CAAC,CA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------------------------------------------------------------------
|
|
4
4
|
import { ToolError } from './errors.js';
|
|
5
|
+
/** Maps an HTTP error response to a ToolError with the appropriate category. */
|
|
6
|
+
export const httpStatusToToolError = (response, message) => {
|
|
7
|
+
const status = response.status;
|
|
8
|
+
if (status === 401 || status === 403) {
|
|
9
|
+
return ToolError.auth(message);
|
|
10
|
+
}
|
|
11
|
+
if (status === 404) {
|
|
12
|
+
return ToolError.notFound(message);
|
|
13
|
+
}
|
|
14
|
+
if (status === 429) {
|
|
15
|
+
const retryAfter = response.headers.get('Retry-After');
|
|
16
|
+
const retryAfterMs = retryAfter !== null ? parseRetryAfterMs(retryAfter) : undefined;
|
|
17
|
+
return ToolError.rateLimited(message, retryAfterMs);
|
|
18
|
+
}
|
|
19
|
+
return new ToolError(message, 'http_error', { category: 'internal' });
|
|
20
|
+
};
|
|
21
|
+
/** Parses a Retry-After header value (seconds or HTTP-date) into milliseconds. */
|
|
22
|
+
export const parseRetryAfterMs = (value) => {
|
|
23
|
+
const seconds = Number(value);
|
|
24
|
+
if (!Number.isNaN(seconds) && seconds >= 0) {
|
|
25
|
+
return seconds * 1000;
|
|
26
|
+
}
|
|
27
|
+
const date = Date.parse(value);
|
|
28
|
+
if (!Number.isNaN(date)) {
|
|
29
|
+
const ms = date - Date.now();
|
|
30
|
+
return ms > 0 ? ms : undefined;
|
|
31
|
+
}
|
|
32
|
+
return undefined;
|
|
33
|
+
};
|
|
5
34
|
/**
|
|
6
35
|
* Fetches a URL using the page's authenticated session (credentials: 'include').
|
|
7
36
|
* Provides built-in timeout via AbortSignal and throws a descriptive ToolError
|
|
@@ -21,43 +50,92 @@ export const fetchFromPage = async (url, init) => {
|
|
|
21
50
|
}
|
|
22
51
|
catch (error) {
|
|
23
52
|
if (error instanceof DOMException && error.name === 'TimeoutError') {
|
|
24
|
-
throw
|
|
53
|
+
throw ToolError.timeout(`fetchFromPage: request timed out after ${timeout}ms for ${url}`);
|
|
25
54
|
}
|
|
26
55
|
if (error instanceof DOMException && error.name === 'AbortError') {
|
|
27
56
|
throw new ToolError(`fetchFromPage: request aborted for ${url}`, 'aborted');
|
|
28
57
|
}
|
|
29
|
-
throw new ToolError(`fetchFromPage: network error for ${url}: ${error instanceof Error ? error.message : String(error)}`, 'network_error');
|
|
58
|
+
throw new ToolError(`fetchFromPage: network error for ${url}: ${error instanceof Error ? error.message : String(error)}`, 'network_error', { category: 'internal', retryable: true });
|
|
30
59
|
}
|
|
31
60
|
if (!response.ok) {
|
|
32
61
|
const errorText = await response.text().catch(() => response.statusText);
|
|
33
|
-
|
|
62
|
+
const msg = `fetchFromPage: HTTP ${response.status} for ${url}: ${errorText}`;
|
|
63
|
+
throw httpStatusToToolError(response, msg);
|
|
34
64
|
}
|
|
35
65
|
return response;
|
|
36
66
|
};
|
|
37
|
-
/**
|
|
38
|
-
|
|
39
|
-
* cookies (credentials: 'include') and provides timeout + error handling.
|
|
40
|
-
*/
|
|
41
|
-
export const fetchJSON = async (url, init) => {
|
|
67
|
+
/** Shared implementation for fetchJSON and postJSON — fetches, parses JSON, optionally validates. */
|
|
68
|
+
export const fetchJSONImpl = async (url, init, schema) => {
|
|
42
69
|
const response = await fetchFromPage(url, init);
|
|
70
|
+
let data;
|
|
43
71
|
try {
|
|
44
|
-
|
|
72
|
+
data = await response.json();
|
|
45
73
|
}
|
|
46
74
|
catch {
|
|
47
|
-
throw
|
|
75
|
+
throw ToolError.validation(`fetchJSON: failed to parse JSON response from ${url}`);
|
|
76
|
+
}
|
|
77
|
+
if (schema) {
|
|
78
|
+
const result = schema.safeParse(data);
|
|
79
|
+
if (!result.success) {
|
|
80
|
+
throw ToolError.validation(`fetchJSON: response from ${url} failed schema validation: ${result.error.message}`);
|
|
81
|
+
}
|
|
82
|
+
return result.data;
|
|
48
83
|
}
|
|
84
|
+
return data;
|
|
49
85
|
};
|
|
86
|
+
/**
|
|
87
|
+
* Fetches a URL and parses the response as JSON. Uses the page's session
|
|
88
|
+
* cookies (credentials: 'include') and provides timeout + error handling.
|
|
89
|
+
* When a Zod schema is provided as the third argument, the parsed JSON is
|
|
90
|
+
* validated against it and a ToolError.validation is thrown on failure.
|
|
91
|
+
*/
|
|
92
|
+
export const fetchJSON = fetchJSONImpl;
|
|
50
93
|
/**
|
|
51
94
|
* Convenience wrapper for POST requests with a JSON body. Sets Content-Type,
|
|
52
|
-
* stringifies the body, and parses the JSON response.
|
|
95
|
+
* stringifies the body, and parses the JSON response. When a Zod schema is
|
|
96
|
+
* provided as the fourth argument, the parsed JSON is validated against it.
|
|
53
97
|
*/
|
|
54
|
-
export const postJSON = async (url, body, init) => {
|
|
98
|
+
export const postJSON = (async (url, body, init, schema) => {
|
|
55
99
|
const extraHeaders = init?.headers ? Object.fromEntries(new Headers(init.headers).entries()) : {};
|
|
56
|
-
return
|
|
100
|
+
return fetchJSONImpl(url, {
|
|
57
101
|
...init,
|
|
58
102
|
method: 'POST',
|
|
59
103
|
headers: { 'Content-Type': 'application/json', ...extraHeaders },
|
|
60
104
|
body: JSON.stringify(body),
|
|
61
|
-
});
|
|
62
|
-
};
|
|
105
|
+
}, schema);
|
|
106
|
+
});
|
|
107
|
+
/**
|
|
108
|
+
* Convenience wrapper for PUT requests with a JSON body. Sets Content-Type,
|
|
109
|
+
* stringifies the body, and parses the JSON response. When a Zod schema is
|
|
110
|
+
* provided as the fourth argument, the parsed JSON is validated against it.
|
|
111
|
+
*/
|
|
112
|
+
export const putJSON = (async (url, body, init, schema) => {
|
|
113
|
+
const extraHeaders = init?.headers ? Object.fromEntries(new Headers(init.headers).entries()) : {};
|
|
114
|
+
return fetchJSONImpl(url, {
|
|
115
|
+
...init,
|
|
116
|
+
method: 'PUT',
|
|
117
|
+
headers: { 'Content-Type': 'application/json', ...extraHeaders },
|
|
118
|
+
body: JSON.stringify(body),
|
|
119
|
+
}, schema);
|
|
120
|
+
});
|
|
121
|
+
/**
|
|
122
|
+
* Convenience wrapper for PATCH requests with a JSON body. Sets Content-Type,
|
|
123
|
+
* stringifies the body, and parses the JSON response. When a Zod schema is
|
|
124
|
+
* provided as the fourth argument, the parsed JSON is validated against it.
|
|
125
|
+
*/
|
|
126
|
+
export const patchJSON = (async (url, body, init, schema) => {
|
|
127
|
+
const extraHeaders = init?.headers ? Object.fromEntries(new Headers(init.headers).entries()) : {};
|
|
128
|
+
return fetchJSONImpl(url, {
|
|
129
|
+
...init,
|
|
130
|
+
method: 'PATCH',
|
|
131
|
+
headers: { 'Content-Type': 'application/json', ...extraHeaders },
|
|
132
|
+
body: JSON.stringify(body),
|
|
133
|
+
}, schema);
|
|
134
|
+
});
|
|
135
|
+
/**
|
|
136
|
+
* Convenience wrapper for DELETE requests. Parses the JSON response.
|
|
137
|
+
* When a Zod schema is provided as the third argument, the parsed JSON
|
|
138
|
+
* is validated against it.
|
|
139
|
+
*/
|
|
140
|
+
export const deleteJSON = (async (url, init, schema) => fetchJSONImpl(url, { ...init, method: 'DELETE' }, schema));
|
|
63
141
|
//# sourceMappingURL=fetch.js.map
|
package/dist/fetch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,qCAAqC;AACrC,8EAA8E;AAE9E,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,qCAAqC;AACrC,8EAA8E;AAE9E,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAQxC,gFAAgF;AAChF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,QAAkB,EAAE,OAAe,EAAa,EAAE;IACtF,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;IAC/B,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;QACrC,OAAO,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC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AAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAClG,OAAO,aAAa,CAClB,GAAG,EACH;QACE,GAAG,IAAI;QACP,MAAM,EAAE,OAAO;QACf,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE,GAAG,YAAY,EAAE;QAChE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;KAC3B,EACD,MAAM,CACP,CAAC;AACJ,CAAC,CAAc,CAAC;AAahB;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAe,CAAC,KAAK,EAC1C,GAAW,EACX,IAA2B,EAC3B,MAAkB,EACA,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,MAAM,CAAC,CAAe,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,10 +6,10 @@ export type { LucideIconName } from './lucide-icon-names.js';
|
|
|
6
6
|
export { LUCIDE_ICON_NAMES } from './lucide-icon-names.js';
|
|
7
7
|
/** Options for reporting incremental progress during long-running tool operations. */
|
|
8
8
|
export interface ProgressOptions {
|
|
9
|
-
/** Current progress value (e.g., 3 of 10 items processed). */
|
|
10
|
-
progress
|
|
11
|
-
/** Total expected value (e.g., 10 items total). */
|
|
12
|
-
total
|
|
9
|
+
/** Current progress value (e.g., 3 of 10 items processed). Omit for indeterminate progress. */
|
|
10
|
+
progress?: number;
|
|
11
|
+
/** Total expected value (e.g., 10 items total). Omit for indeterminate progress. */
|
|
12
|
+
total?: number;
|
|
13
13
|
/** Optional human-readable message describing the current step. */
|
|
14
14
|
message?: string;
|
|
15
15
|
}
|
|
@@ -30,7 +30,7 @@ export interface ResourceContent {
|
|
|
30
30
|
mimeType?: string;
|
|
31
31
|
}
|
|
32
32
|
/** A plugin resource definition. The read() handler executes in the browser page context. */
|
|
33
|
-
export interface ResourceDefinition {
|
|
33
|
+
export interface ResourceDefinition<TContent extends z.ZodType = z.ZodType> {
|
|
34
34
|
/** Resource URI (e.g., 'slack://channels'). Must be non-empty. */
|
|
35
35
|
uri: string;
|
|
36
36
|
/** Human-readable name for the resource. */
|
|
@@ -39,11 +39,36 @@ export interface ResourceDefinition {
|
|
|
39
39
|
description?: string;
|
|
40
40
|
/** MIME type of the resource content (e.g., 'application/json'). */
|
|
41
41
|
mimeType?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Optional Zod schema describing the shape of the resource content.
|
|
44
|
+
* Provides a type-level contract for documentation and autocomplete — the
|
|
45
|
+
* runtime dispatch path does not validate against this schema.
|
|
46
|
+
*
|
|
47
|
+
* Use it for documentation and to derive content types:
|
|
48
|
+
* ```ts
|
|
49
|
+
* const schema = z.object({ channels: z.array(channelSchema) });
|
|
50
|
+
* const myResource = defineResource({ schema, ... });
|
|
51
|
+
* type Content = ResourceContentType<typeof myResource>; // { channels: Channel[] }
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
schema?: TContent;
|
|
42
55
|
/** Read the resource content. Runs in the browser page context. */
|
|
43
56
|
read(uri: string): Promise<ResourceContent>;
|
|
44
57
|
}
|
|
45
|
-
/** Type-safe factory —
|
|
46
|
-
export declare const defineResource: (config: ResourceDefinition) => ResourceDefinition
|
|
58
|
+
/** Type-safe factory — provides generic inference when `schema` is present, and plain type checking otherwise. */
|
|
59
|
+
export declare const defineResource: <TContent extends z.ZodType = z.ZodType>(config: ResourceDefinition<TContent>) => ResourceDefinition<TContent>;
|
|
60
|
+
/**
|
|
61
|
+
* Extracts the content type from a ResourceDefinition's schema.
|
|
62
|
+
* Useful for deriving typed content from resource definitions.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* const myResource = defineResource({
|
|
66
|
+
* schema: z.object({ channels: z.array(z.string()) }),
|
|
67
|
+
* // ...
|
|
68
|
+
* });
|
|
69
|
+
* type Content = ResourceContentType<typeof myResource>; // { channels: string[] }
|
|
70
|
+
*/
|
|
71
|
+
export type ResourceContentType<R extends ResourceDefinition> = R extends ResourceDefinition<infer T> ? z.infer<T> : unknown;
|
|
47
72
|
/** A single argument for a prompt. Aligns with MCP PromptArgument. */
|
|
48
73
|
export interface PromptArgument {
|
|
49
74
|
/** Argument name. */
|
|
@@ -69,22 +94,45 @@ export interface PromptDefinition {
|
|
|
69
94
|
name: string;
|
|
70
95
|
/** Human-readable description of the prompt. */
|
|
71
96
|
description?: string;
|
|
72
|
-
/**
|
|
97
|
+
/**
|
|
98
|
+
* Optional Zod schema for prompt arguments. When provided and passed to
|
|
99
|
+
* `definePrompt`, the render() function receives a typed object inferred
|
|
100
|
+
* from the schema. Argument metadata is auto-generated during build when
|
|
101
|
+
* the explicit `arguments` array is not provided.
|
|
102
|
+
*/
|
|
103
|
+
args?: z.ZodObject<z.ZodRawShape>;
|
|
104
|
+
/** Arguments the prompt accepts (metadata for MCP registration). Auto-generated from `args` schema during build when not provided. */
|
|
73
105
|
arguments?: PromptArgument[];
|
|
74
106
|
/** Render the prompt messages. Runs in the browser page context. */
|
|
75
107
|
render(args: Record<string, string>): Promise<PromptMessage[]>;
|
|
76
108
|
}
|
|
77
|
-
/**
|
|
78
|
-
|
|
109
|
+
/**
|
|
110
|
+
* Config type for definePrompt when `args` Zod schema is provided. The render
|
|
111
|
+
* function parameter is typed from the schema.
|
|
112
|
+
*/
|
|
113
|
+
export interface TypedPromptConfig<TArgs extends z.ZodObject<z.ZodRawShape>> {
|
|
114
|
+
name: string;
|
|
115
|
+
description?: string;
|
|
116
|
+
args: TArgs;
|
|
117
|
+
arguments?: PromptArgument[];
|
|
118
|
+
render(args: z.infer<TArgs>): Promise<PromptMessage[]>;
|
|
119
|
+
}
|
|
120
|
+
/** Overloaded call signature for definePrompt — typed when `args` is present, plain otherwise. */
|
|
121
|
+
export interface DefinePrompt {
|
|
122
|
+
<TArgs extends z.ZodObject<z.ZodRawShape>>(config: TypedPromptConfig<TArgs>): PromptDefinition;
|
|
123
|
+
(config: PromptDefinition): PromptDefinition;
|
|
124
|
+
}
|
|
125
|
+
/** Type-safe factory — provides generic inference when `args` schema is present, and plain type checking otherwise. */
|
|
126
|
+
export declare const definePrompt: DefinePrompt;
|
|
79
127
|
export interface ToolDefinition<TInput extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>, TOutput extends z.ZodType = z.ZodType> {
|
|
80
128
|
/** Tool name — auto-prefixed with plugin name (e.g., 'send_message' → 'slack_send_message') */
|
|
81
129
|
name: string;
|
|
82
|
-
/** Human-readable display name shown in the side panel (e.g., 'Send Message') */
|
|
83
|
-
displayName
|
|
130
|
+
/** Human-readable display name shown in the side panel (e.g., 'Send Message'). Auto-derived from name during build when omitted. */
|
|
131
|
+
displayName?: string;
|
|
84
132
|
/** Human-readable description shown to MCP clients / AI agents */
|
|
85
133
|
description: string;
|
|
86
|
-
/** Lucide icon name (kebab-case) displayed in the side panel. See https://lucide.dev/icons */
|
|
87
|
-
icon
|
|
134
|
+
/** Lucide icon name (kebab-case) displayed in the side panel. Defaults to 'wrench' during build when omitted. See https://lucide.dev/icons */
|
|
135
|
+
icon?: LucideIconName;
|
|
88
136
|
/** Zod schema — used for MCP registration + server-side input validation */
|
|
89
137
|
input: TInput;
|
|
90
138
|
/** Zod schema describing the tool output shape. Used for manifest generation and MCP tool registration. */
|
|
@@ -186,12 +234,12 @@ export { ToolError } from './errors.js';
|
|
|
186
234
|
export type { ErrorCategory, ToolErrorOptions } from './errors.js';
|
|
187
235
|
export { waitForSelector, waitForSelectorRemoval, querySelectorAll, getTextContent, observeDOM } from './dom.js';
|
|
188
236
|
export type { WaitForSelectorOptions, ObserveDOMOptions } from './dom.js';
|
|
189
|
-
export { fetchFromPage, fetchJSON, postJSON } from './fetch.js';
|
|
190
|
-
export type { FetchFromPageOptions } from './fetch.js';
|
|
237
|
+
export { fetchFromPage, fetchJSON, fetchJSONImpl, httpStatusToToolError, parseRetryAfterMs, postJSON, putJSON, patchJSON, deleteJSON, } from './fetch.js';
|
|
238
|
+
export type { FetchFromPageOptions, FetchJSON, PostJSON, PutJSON, PatchJSON, DeleteJSON } from './fetch.js';
|
|
191
239
|
export { retry, sleep, waitUntil } from './timing.js';
|
|
192
240
|
export type { RetryOptions, WaitUntilOptions } from './timing.js';
|
|
193
|
-
export { getLocalStorage, setLocalStorage, getSessionStorage, getCookie } from './storage.js';
|
|
241
|
+
export { getLocalStorage, setLocalStorage, removeLocalStorage, getSessionStorage, setSessionStorage, removeSessionStorage, getCookie, } from './storage.js';
|
|
194
242
|
export { getPageGlobal, getCurrentUrl, getPageTitle } from './page-state.js';
|
|
195
|
-
export { log
|
|
243
|
+
export { log } from './log.js';
|
|
196
244
|
export type { LogLevel, LogEntry, LogTransport } from './log.js';
|
|
197
245
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAM7B,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1G,YAAY,EAAE,YAAY,EAAE,cAAc,IAAI,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrF,YAAY,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAM3D,sFAAsF;AACtF,MAAM,WAAW,eAAe;IAC9B
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAM7B,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,k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// ---------------------------------------------------------------------------
|
|
4
4
|
export { NAME_REGEX, RESERVED_NAMES, validatePluginName, validateUrlPattern } from '@opentabs-dev/shared';
|
|
5
5
|
export { LUCIDE_ICON_NAMES } from './lucide-icon-names.js';
|
|
6
|
-
/** Type-safe factory —
|
|
6
|
+
/** Type-safe factory — provides generic inference when `schema` is present, and plain type checking otherwise. */
|
|
7
7
|
export const defineResource = (config) => config;
|
|
8
|
-
/** Type-safe factory —
|
|
8
|
+
/** Type-safe factory — provides generic inference when `args` schema is present, and plain type checking otherwise. */
|
|
9
9
|
export const definePrompt = (config) => config;
|
|
10
10
|
/** Type-safe factory — identity function that provides generic inference */
|
|
11
11
|
export const defineTool = (config) => config;
|
|
@@ -30,7 +30,7 @@ export { waitForSelector, waitForSelectorRemoval, querySelectorAll, getTextConte
|
|
|
30
30
|
// ---------------------------------------------------------------------------
|
|
31
31
|
// SDK utilities — Fetch
|
|
32
32
|
// ---------------------------------------------------------------------------
|
|
33
|
-
export { fetchFromPage, fetchJSON, postJSON } from './fetch.js';
|
|
33
|
+
export { fetchFromPage, fetchJSON, fetchJSONImpl, httpStatusToToolError, parseRetryAfterMs, postJSON, putJSON, patchJSON, deleteJSON, } from './fetch.js';
|
|
34
34
|
// ---------------------------------------------------------------------------
|
|
35
35
|
// SDK utilities — Timing
|
|
36
36
|
// ---------------------------------------------------------------------------
|
|
@@ -38,7 +38,7 @@ export { retry, sleep, waitUntil } from './timing.js';
|
|
|
38
38
|
// ---------------------------------------------------------------------------
|
|
39
39
|
// SDK utilities — Storage
|
|
40
40
|
// ---------------------------------------------------------------------------
|
|
41
|
-
export { getLocalStorage, setLocalStorage, getSessionStorage, getCookie } from './storage.js';
|
|
41
|
+
export { getLocalStorage, setLocalStorage, removeLocalStorage, getSessionStorage, setSessionStorage, removeSessionStorage, getCookie, } from './storage.js';
|
|
42
42
|
// ---------------------------------------------------------------------------
|
|
43
43
|
// SDK utilities — Page State
|
|
44
44
|
// ---------------------------------------------------------------------------
|
|
@@ -46,5 +46,5 @@ export { getPageGlobal, getCurrentUrl, getPageTitle } from './page-state.js';
|
|
|
46
46
|
// ---------------------------------------------------------------------------
|
|
47
47
|
// SDK utilities — Logging
|
|
48
48
|
// ---------------------------------------------------------------------------
|
|
49
|
-
export { log
|
|
49
|
+
export { log } from './log.js';
|
|
50
50
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,8EAA8E;AAC9E,gEAAgE;AAChE,8EAA8E;AAE9E,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG1G,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,8EAA8E;AAC9E,gEAAgE;AAChE,8EAA8E;AAE9E,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG1G,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAiE3D,kHAAkH;AAClH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,MAAoC,EACN,EAAE,CAAC,MAAM,CAAC;AA2E1C,uHAAuH;AACvH,MAAM,CAAC,MAAM,YAAY,GAAiB,CAAC,MAAwB,EAAoB,EAAE,CAAC,MAAM,CAAC;AA0BjG,4EAA4E;AAC5E,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,MAAuC,EACN,EAAE,CAAC,MAAM,CAAC;AAE7C;;;GAGG;AACH,MAAM,OAAgB,cAAc;IAclC,uDAAuD;IAC9C,SAAS,CAAwB;IAC1C,qDAAqD;IAC5C,OAAO,CAAsB;CAkEvC;AAED,8EAA8E;AAC9E,SAAS;AACT,8EAA8E;AAE9E,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,8EAA8E;AAC9E,sBAAsB;AACtB,8EAA8E;AAE9E,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAGjH,8EAA8E;AAC9E,wBAAwB;AACxB,8EAA8E;AAE9E,OAAO,EACL,aAAa,EACb,SAAS,EACT,aAAa,EACb,qBAAqB,EACrB,iBAAiB,EACjB,QAAQ,EACR,OAAO,EACP,SAAS,EACT,UAAU,GACX,MAAM,YAAY,CAAC;AAGpB,8EAA8E;AAC9E,yBAAyB;AACzB,8EAA8E;AAE9E,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGtD,8EAA8E;AAC9E,0BAA0B;AAC1B,8EAA8E;AAE9E,OAAO,EACL,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,SAAS,GACV,MAAM,cAAc,CAAC;AAEtB,8EAA8E;AAC9E,6BAA6B;AAC7B,8EAA8E;AAE9E,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE7E,8EAA8E;AAC9E,0BAA0B;AAC1B,8EAA8E;AAE9E,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/page-state.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Safe deep property access on `globalThis` using dot-notation path.
|
|
3
|
-
* Returns `undefined` if any segment in the path is missing or if a getter
|
|
4
|
-
* throws. Callers can narrow the result with `as` at the call site.
|
|
3
|
+
* Returns `undefined` if any segment in the path is missing or if a getter throws.
|
|
5
4
|
*
|
|
6
5
|
* @example
|
|
7
6
|
* const token = getPageGlobal('TS.boot_data.api_token') as string | undefined;
|
package/dist/page-state.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-state.d.ts","sourceRoot":"","sources":["../src/page-state.ts"],"names":[],"mappings":"AAIA
|
|
1
|
+
{"version":3,"file":"page-state.d.ts","sourceRoot":"","sources":["../src/page-state.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,KAAG,OAY5C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,QAAO,MAA8B,CAAC;AAEhE;;GAEG;AACH,eAAO,MAAM,YAAY,QAAO,MAAwB,CAAC"}
|
package/dist/page-state.js
CHANGED
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
// ---------------------------------------------------------------------------
|
|
4
4
|
/**
|
|
5
5
|
* Safe deep property access on `globalThis` using dot-notation path.
|
|
6
|
-
* Returns `undefined` if any segment in the path is missing or if a getter
|
|
7
|
-
* throws. Callers can narrow the result with `as` at the call site.
|
|
6
|
+
* Returns `undefined` if any segment in the path is missing or if a getter throws.
|
|
8
7
|
*
|
|
9
8
|
* @example
|
|
10
9
|
* const token = getPageGlobal('TS.boot_data.api_token') as string | undefined;
|
package/dist/page-state.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-state.js","sourceRoot":"","sources":["../src/page-state.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,0CAA0C;AAC1C,8EAA8E;AAE9E
|
|
1
|
+
{"version":3,"file":"page-state.js","sourceRoot":"","sources":["../src/page-state.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,0CAA0C;AAC1C,8EAA8E;AAE9E;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAY,EAAW,EAAE;IACrD,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACjC,IAAI,OAAO,GAAY,UAAU,CAAC;QAClC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC/B,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,OAAO,KAAK,QAAQ;gBAAE,OAAO,SAAS,CAAC;YAC/F,OAAO,GAAI,OAAmC,CAAC,OAAO,CAAC,CAAC;QAC1D,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,GAAW,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;AAEhE;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,GAAW,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC"}
|
package/dist/storage.d.ts
CHANGED
|
@@ -13,6 +13,21 @@ export declare const setLocalStorage: (key: string, value: string) => void;
|
|
|
13
13
|
* if storage access throws (e.g., SecurityError in sandboxed iframes).
|
|
14
14
|
*/
|
|
15
15
|
export declare const getSessionStorage: (key: string) => string | null;
|
|
16
|
+
/**
|
|
17
|
+
* Writes a value to sessionStorage. Silently fails if storage access throws
|
|
18
|
+
* (e.g., SecurityError in sandboxed iframes or when storage is full).
|
|
19
|
+
*/
|
|
20
|
+
export declare const setSessionStorage: (key: string, value: string) => void;
|
|
21
|
+
/**
|
|
22
|
+
* Removes a key from localStorage. Silently fails if storage access throws
|
|
23
|
+
* (e.g., SecurityError in sandboxed iframes).
|
|
24
|
+
*/
|
|
25
|
+
export declare const removeLocalStorage: (key: string) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Removes a key from sessionStorage. Silently fails if storage access throws
|
|
28
|
+
* (e.g., SecurityError in sandboxed iframes).
|
|
29
|
+
*/
|
|
30
|
+
export declare const removeSessionStorage: (key: string) => void;
|
|
16
31
|
/**
|
|
17
32
|
* Reads a cookie by name from `document.cookie`. Handles URI-encoded values.
|
|
18
33
|
* Returns null if the cookie is not found.
|
package/dist/storage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,KAAK,MAAM,KAAG,MAAM,GAAG,IAMtD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,KAAK,MAAM,EAAE,OAAO,MAAM,KAAG,IAM5D,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAI,KAAK,MAAM,KAAG,MAAM,GAAG,IAMxD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,KAAG,MAAM,GAAG,IAajD,CAAC"}
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,KAAK,MAAM,KAAG,MAAM,GAAG,IAMtD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,KAAK,MAAM,EAAE,OAAO,MAAM,KAAG,IAM5D,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAI,KAAK,MAAM,KAAG,MAAM,GAAG,IAMxD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAI,KAAK,MAAM,EAAE,OAAO,MAAM,KAAG,IAM9D,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,KAAK,MAAM,KAAG,IAMhD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAAI,KAAK,MAAM,KAAG,IAMlD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,KAAG,MAAM,GAAG,IAajD,CAAC"}
|
package/dist/storage.js
CHANGED
|
@@ -37,6 +37,42 @@ export const getSessionStorage = (key) => {
|
|
|
37
37
|
return null;
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* Writes a value to sessionStorage. Silently fails if storage access throws
|
|
42
|
+
* (e.g., SecurityError in sandboxed iframes or when storage is full).
|
|
43
|
+
*/
|
|
44
|
+
export const setSessionStorage = (key, value) => {
|
|
45
|
+
try {
|
|
46
|
+
sessionStorage.setItem(key, value);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
// Silently fail on SecurityError or QuotaExceededError
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Removes a key from localStorage. Silently fails if storage access throws
|
|
54
|
+
* (e.g., SecurityError in sandboxed iframes).
|
|
55
|
+
*/
|
|
56
|
+
export const removeLocalStorage = (key) => {
|
|
57
|
+
try {
|
|
58
|
+
localStorage.removeItem(key);
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
// Silently fail on SecurityError
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Removes a key from sessionStorage. Silently fails if storage access throws
|
|
66
|
+
* (e.g., SecurityError in sandboxed iframes).
|
|
67
|
+
*/
|
|
68
|
+
export const removeSessionStorage = (key) => {
|
|
69
|
+
try {
|
|
70
|
+
sessionStorage.removeItem(key);
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
// Silently fail on SecurityError
|
|
74
|
+
}
|
|
75
|
+
};
|
|
40
76
|
/**
|
|
41
77
|
* Reads a cookie by name from `document.cookie`. Handles URI-encoded values.
|
|
42
78
|
* Returns null if the cookie is not found.
|
package/dist/storage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,uCAAuC;AACvC,8EAA8E;AAE9E;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAAW,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CAAC;AACH,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,GAAW,EAAQ,EAAE;IACxD,IAAI,CAAC;QACH,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC;IAAC,MAAM,CAAC;QACP,iCAAiC;IACnC,CAAC;AACH,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,IAAY,EAAiB,EAAE;IACvD,MAAM,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC;IAC1B,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC5C,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,IAAI,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;YAC7B,IAAI,CAAC;gBACH,OAAO,kBAAkB,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;YACxD,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YACpC,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentabs-dev/plugin-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"generate:icons": "bun scripts/generate-icon-names.ts"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@opentabs-dev/shared": "^0.0.
|
|
23
|
+
"@opentabs-dev/shared": "^0.0.17"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"zod": "^4.0.0"
|