react-devbelt 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/NOTICE +16 -0
- package/README.md +292 -2
- package/dist/announce-6XECDMRI.js +12 -0
- package/dist/announce-6XECDMRI.js.map +1 -0
- package/dist/chunk-3SXZJ6OP.js +65 -0
- package/dist/chunk-3SXZJ6OP.js.map +1 -0
- package/dist/chunk-63DO3YVL.js +330 -0
- package/dist/chunk-63DO3YVL.js.map +1 -0
- package/dist/chunk-6PAFI4BJ.js +14615 -0
- package/dist/chunk-6PAFI4BJ.js.map +1 -0
- package/dist/chunk-7JLNVGRQ.js +164 -0
- package/dist/chunk-7JLNVGRQ.js.map +1 -0
- package/dist/chunk-C7RMX5PF.js +57 -0
- package/dist/chunk-C7RMX5PF.js.map +1 -0
- package/dist/chunk-GNJF3UHO.js +1030 -0
- package/dist/chunk-GNJF3UHO.js.map +1 -0
- package/dist/chunk-PRTINXUT.js +105 -0
- package/dist/chunk-PRTINXUT.js.map +1 -0
- package/dist/chunk-QRXHNBFY.js +22 -0
- package/dist/chunk-QRXHNBFY.js.map +1 -0
- package/dist/chunk-QT3YSHQA.js +18 -0
- package/dist/chunk-QT3YSHQA.js.map +1 -0
- package/dist/chunk-UBSHMGMV.js +8016 -0
- package/dist/chunk-UBSHMGMV.js.map +1 -0
- package/dist/context-D2euxPc4.d.ts +6 -0
- package/dist/core.d.ts +266 -0
- package/dist/core.js +1070 -0
- package/dist/core.js.map +1 -0
- package/dist/findable-rows-UQBKFZ45.js +356 -0
- package/dist/findable-rows-UQBKFZ45.js.map +1 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.js +47 -0
- package/dist/index.js.map +1 -0
- package/dist/install.d.ts +2 -0
- package/dist/install.js +21 -0
- package/dist/install.js.map +1 -0
- package/dist/next.d.ts +18 -0
- package/dist/next.js +13 -0
- package/dist/next.js.map +1 -0
- package/dist/plugin-C8VytW9X.d.ts +162 -0
- package/dist/plugins.d.ts +118 -0
- package/dist/plugins.js +36 -0
- package/dist/plugins.js.map +1 -0
- package/dist/sheet-presentation-S6GGOKMB.js +2667 -0
- package/dist/sheet-presentation-S6GGOKMB.js.map +1 -0
- package/dist/styles.css +2 -0
- package/dist/toolbar-entry-XIOWCGBL.js +1685 -0
- package/dist/toolbar-entry-XIOWCGBL.js.map +1 -0
- package/dist/ui.d.ts +37 -0
- package/dist/ui.js +126 -0
- package/dist/ui.js.map +1 -0
- package/licenses/motion-MIT.txt +21 -0
- package/licenses/ui-sdk-APACHE-2.0.txt +202 -0
- package/package.json +115 -3
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
type AiTool = {
|
|
2
|
+
/** Unique, lowercase, e.g. `cursor`. Also the saved choice in Grab's menu. */
|
|
3
|
+
id: string;
|
|
4
|
+
/** Shown on buttons and menu items, e.g. `Cursor`. */
|
|
5
|
+
label: string;
|
|
6
|
+
/** The link that opens the tool with `prompt` filled in. */
|
|
7
|
+
link: (prompt: string) => string;
|
|
8
|
+
/**
|
|
9
|
+
* A link that opens the tool with no prompt, used with the clipboard when the
|
|
10
|
+
* prompt is too long for `link`. Leave it out if the tool has none.
|
|
11
|
+
*/
|
|
12
|
+
openLink?: string;
|
|
13
|
+
/** Longest prompt `link` can carry, in characters. Default 5000. */
|
|
14
|
+
maxPrompt?: number;
|
|
15
|
+
};
|
|
16
|
+
/** https://cursor.com/docs/reference/deeplinks */
|
|
17
|
+
declare const cursor: AiTool;
|
|
18
|
+
/**
|
|
19
|
+
* https://code.claude.com/docs/en/deep-links. Works once Claude Code has run
|
|
20
|
+
* an interactive session on this machine, which registers the handler.
|
|
21
|
+
*/
|
|
22
|
+
declare const claudeCode: AiTool;
|
|
23
|
+
/** The Codex app. `codex://new` needs a prompt, so a long one is copied instead. */
|
|
24
|
+
declare const codex: AiTool;
|
|
25
|
+
/** Cursor, Claude Code and Codex. Apps add their own, e.g. a team's editor, through `aiTools`. */
|
|
26
|
+
declare const defaultAiTools: readonly AiTool[];
|
|
27
|
+
/**
|
|
28
|
+
* `opened`: the tool was asked to open with the prompt filled in.
|
|
29
|
+
* `copied`: the prompt was too long for a link, so it is on the clipboard.
|
|
30
|
+
* `failed`: the prompt was too long and could not be copied either.
|
|
31
|
+
*/
|
|
32
|
+
type AiOpenResult = "opened" | "copied" | "failed";
|
|
33
|
+
type AiOpenDeps = {
|
|
34
|
+
/** Follows a deep link. Default: clicks an anchor, which hands it to the OS. */
|
|
35
|
+
open?: (url: string) => void;
|
|
36
|
+
/** Default: `navigator.clipboard.writeText`. */
|
|
37
|
+
copy?: (text: string) => Promise<void>;
|
|
38
|
+
};
|
|
39
|
+
/** Opens `tool` with `prompt` filled in, or copies the prompt when it won't fit in a link. */
|
|
40
|
+
declare function openInAiTool(tool: AiTool, prompt: string, deps?: AiOpenDeps): Promise<AiOpenResult>;
|
|
41
|
+
/** A short line for the toolbar: "Opened in Cursor", "Copied · paste into Codex". */
|
|
42
|
+
declare function describeAiResult(tool: AiTool, result: AiOpenResult): string;
|
|
43
|
+
|
|
44
|
+
type ToolResult = {
|
|
45
|
+
content: {
|
|
46
|
+
type: "text";
|
|
47
|
+
text: string;
|
|
48
|
+
}[];
|
|
49
|
+
/** True when the call failed; the text says why. */
|
|
50
|
+
isError?: boolean;
|
|
51
|
+
_meta?: Record<string, unknown>;
|
|
52
|
+
};
|
|
53
|
+
/** Key in a result's `_meta` that says the content came from the page. */
|
|
54
|
+
declare const UNTRUSTED_META_KEY = "devbelt/untrusted";
|
|
55
|
+
/**
|
|
56
|
+
* Marks everything a tool returns from the page as untrusted: a notice before
|
|
57
|
+
* the text and a flag in `_meta`, so an agent treats it as data.
|
|
58
|
+
*/
|
|
59
|
+
declare function markUntrusted(result: ToolResult): ToolResult;
|
|
60
|
+
/**
|
|
61
|
+
* `Context` is whatever the host hands every tool when it runs (the toolbar
|
|
62
|
+
* passes its API), so a tool can read live state without a global.
|
|
63
|
+
*/
|
|
64
|
+
type AgentTool<Context = void> = {
|
|
65
|
+
name: string;
|
|
66
|
+
description: string;
|
|
67
|
+
inputSchema: object;
|
|
68
|
+
annotations?: Record<string, boolean>;
|
|
69
|
+
/**
|
|
70
|
+
* True when the tool changes state. Writing tools are only offered to
|
|
71
|
+
* agents once the Plugin sets `agent: { write: true }` (ADR 0003).
|
|
72
|
+
*/
|
|
73
|
+
writes?: boolean;
|
|
74
|
+
run: (input: Record<string, unknown>, context: Context) => ToolResult | Promise<ToolResult>;
|
|
75
|
+
};
|
|
76
|
+
declare const text: (value: string) => ToolResult;
|
|
77
|
+
/** A failed call: the text explains what went wrong, `isError` marks it. */
|
|
78
|
+
declare const errorResult: (value: string) => ToolResult;
|
|
79
|
+
declare const clampLimit: (value: unknown, fallback: number) => number;
|
|
80
|
+
/** The tools of these plugins that agents may use: writing ones only when the plugin opts in. */
|
|
81
|
+
declare function exposedAgentTools<Context>(plugins: readonly {
|
|
82
|
+
agent?: {
|
|
83
|
+
write?: boolean;
|
|
84
|
+
};
|
|
85
|
+
agentTools?: AgentTool<Context>[];
|
|
86
|
+
}[]): AgentTool<Context>[];
|
|
87
|
+
/**
|
|
88
|
+
* Registers the tools with the browser's agent where WebMCP exists, and puts
|
|
89
|
+
* them on `window.devbelt`. Returns a cleanup.
|
|
90
|
+
*/
|
|
91
|
+
declare function registerAgentTools<Context>(tools: AgentTool<Context>[], getContext: () => Context): () => void;
|
|
92
|
+
|
|
93
|
+
type ConsoleLevel = "error" | "warn";
|
|
94
|
+
type ConsoleEntry = {
|
|
95
|
+
id: number;
|
|
96
|
+
level: ConsoleLevel;
|
|
97
|
+
message: string;
|
|
98
|
+
stack: string | null;
|
|
99
|
+
at: number;
|
|
100
|
+
pageUrl: string;
|
|
101
|
+
viewport: string;
|
|
102
|
+
count: number;
|
|
103
|
+
};
|
|
104
|
+
declare const subscribeConsoleLog: (listener: () => void) => () => void;
|
|
105
|
+
declare const getConsoleEntries: () => ConsoleEntry[];
|
|
106
|
+
declare const clearConsoleLog: () => void;
|
|
107
|
+
declare function installConsoleLog(): void;
|
|
108
|
+
/** Markdown an AI assistant reads well, one section per entry. */
|
|
109
|
+
declare function formatConsoleForAgent(entries: ConsoleEntry[], { depth }?: {
|
|
110
|
+
depth?: number;
|
|
111
|
+
}): string;
|
|
112
|
+
|
|
113
|
+
type NetworkEntry = {
|
|
114
|
+
id: number;
|
|
115
|
+
method: string;
|
|
116
|
+
url: string;
|
|
117
|
+
status: number | null;
|
|
118
|
+
startedAt: number;
|
|
119
|
+
duration: number | null;
|
|
120
|
+
pageUrl: string;
|
|
121
|
+
viewport: string;
|
|
122
|
+
requestHeaders: Record<string, string>;
|
|
123
|
+
requestBody: string | null;
|
|
124
|
+
responseHeaders: Record<string, string>;
|
|
125
|
+
responseBody: string | null;
|
|
126
|
+
};
|
|
127
|
+
declare const subscribeNetworkLog: (listener: () => void) => () => void;
|
|
128
|
+
declare const getNetworkEntries: () => NetworkEntry[];
|
|
129
|
+
declare const clearNetworkLog: () => void;
|
|
130
|
+
type NetworkLogOptions = {
|
|
131
|
+
/**
|
|
132
|
+
* Header names whose values are masked in the log (case-insensitive).
|
|
133
|
+
* Defaults to credentials: authorization, cookies and API keys.
|
|
134
|
+
*/
|
|
135
|
+
redactHeaders?: string[];
|
|
136
|
+
/**
|
|
137
|
+
* Decides what a replayed request sends for a header. `value` is what the
|
|
138
|
+
* log holds, which is masked for redacted headers. Return the real value
|
|
139
|
+
* (for example the current session's token), or null to leave it out.
|
|
140
|
+
* By default redacted headers are left out of a replay.
|
|
141
|
+
*/
|
|
142
|
+
replayHeaders?: (name: string, value: string) => string | null | undefined;
|
|
143
|
+
/** Also record `fetch` calls. Default true. */
|
|
144
|
+
fetch?: boolean;
|
|
145
|
+
};
|
|
146
|
+
declare const DEFAULT_REDACTED_HEADERS: string[];
|
|
147
|
+
declare function installNetworkLog(options?: NetworkLogOptions): void;
|
|
148
|
+
type CopyParts = {
|
|
149
|
+
url: boolean;
|
|
150
|
+
request: boolean;
|
|
151
|
+
response: boolean;
|
|
152
|
+
headers: boolean;
|
|
153
|
+
context: boolean;
|
|
154
|
+
};
|
|
155
|
+
declare function isFailedEntry(entry: NetworkEntry): boolean;
|
|
156
|
+
type FormatOptions = {
|
|
157
|
+
depth?: number;
|
|
158
|
+
bodyLimit?: number;
|
|
159
|
+
};
|
|
160
|
+
/** Markdown an AI assistant reads well: facts first, then fenced sections. */
|
|
161
|
+
declare function formatEntryForAgent(entry: NetworkEntry, parts?: CopyParts, options?: FormatOptions): string;
|
|
162
|
+
declare function formatAsCurl(entry: NetworkEntry): string;
|
|
163
|
+
declare function formatAsFetch(entry: NetworkEntry): string;
|
|
164
|
+
/**
|
|
165
|
+
* Sends the request again through XHR, so it is logged like any other call.
|
|
166
|
+
* See `replayHeaders` for how redacted headers are handled.
|
|
167
|
+
*/
|
|
168
|
+
declare function replayEntry(entry: NetworkEntry): void;
|
|
169
|
+
|
|
170
|
+
/** One line of the bundle's header, e.g. `{ label: "Viewport", value: "iPad 820×1180" }`. */
|
|
171
|
+
type DebugEntry = {
|
|
172
|
+
label: string;
|
|
173
|
+
value: string;
|
|
174
|
+
};
|
|
175
|
+
type DebugContext = DebugEntry[];
|
|
176
|
+
/**
|
|
177
|
+
* Everything an assistant needs to start debugging, in one paste: where the
|
|
178
|
+
* page is, what it logged, which requests failed and what the last ones did.
|
|
179
|
+
*/
|
|
180
|
+
declare function formatDebugBundle(context: DebugContext, network?: NetworkEntry[], logs?: ConsoleEntry[], now?: number, extraSections?: string[]): string;
|
|
181
|
+
/**
|
|
182
|
+
* A short note for the end of a Grab: console errors and failed requests from
|
|
183
|
+
* the last few minutes, since the element someone points at is often the one
|
|
184
|
+
* that broke. Empty when nothing went wrong.
|
|
185
|
+
*/
|
|
186
|
+
declare function formatRecentProblems(network?: NetworkEntry[], logs?: ConsoleEntry[], now?: number): string;
|
|
187
|
+
|
|
188
|
+
type Options<T> = {
|
|
189
|
+
max: number;
|
|
190
|
+
persistKey?: string;
|
|
191
|
+
maxSaved?: number;
|
|
192
|
+
trim?: (entry: T) => T;
|
|
193
|
+
revive?: (entry: T) => T;
|
|
194
|
+
deferPublish?: boolean;
|
|
195
|
+
};
|
|
196
|
+
declare function createHostStore<T extends {
|
|
197
|
+
id: number;
|
|
198
|
+
}>(name: string, options: Options<T>): {
|
|
199
|
+
add(entry: Omit<T, "id">): number;
|
|
200
|
+
update(id: number, patch: Partial<T>): void;
|
|
201
|
+
clear(): void;
|
|
202
|
+
subscribe(listener: () => void): () => void;
|
|
203
|
+
getSnapshot(): T[];
|
|
204
|
+
getServerSnapshot(): T[];
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
declare const storageKey: (name: string) => string;
|
|
208
|
+
declare function readString(name: string): string | null;
|
|
209
|
+
declare function writeString(name: string, value: string | null): void;
|
|
210
|
+
declare function readJson<T>(name: string, fallback: T): T;
|
|
211
|
+
declare function writeJson(name: string, value: unknown): void;
|
|
212
|
+
|
|
213
|
+
declare const DEFAULT_REDACTION_PATTERN: RegExp;
|
|
214
|
+
/** Whether the value stored under `key` must be Redacted. */
|
|
215
|
+
declare function isRedacted(key: string, pattern?: RegExp): boolean;
|
|
216
|
+
/** The hidden form of a value: its length only, never its content. */
|
|
217
|
+
declare const redactedForm: (value: string) => string;
|
|
218
|
+
/** `value` unchanged, or its hidden form when `key` is Redacted. */
|
|
219
|
+
declare function redact(key: string, value: string, pattern?: RegExp): string;
|
|
220
|
+
|
|
221
|
+
type StorageStore = "localStorage" | "sessionStorage" | "cookies";
|
|
222
|
+
declare const STORAGE_STORES: StorageStore[];
|
|
223
|
+
type StorageEntry = {
|
|
224
|
+
store: StorageStore;
|
|
225
|
+
key: string;
|
|
226
|
+
value: string;
|
|
227
|
+
size: number;
|
|
228
|
+
};
|
|
229
|
+
type StorageUnavailable = Partial<Record<StorageStore, string>>;
|
|
230
|
+
/** Every visible entry of the three stores, grouped in store order. */
|
|
231
|
+
declare function readStorageEntries(): StorageEntry[];
|
|
232
|
+
type StorageViewOptions = {
|
|
233
|
+
/** Keys matching this are Redacted. Default: the shared Redaction pattern. */
|
|
234
|
+
pattern?: RegExp;
|
|
235
|
+
/** Stores that could not be read; they are reported instead of shown as empty. */
|
|
236
|
+
unavailable?: StorageUnavailable;
|
|
237
|
+
/** Stores to include. Default: localStorage, sessionStorage and cookies. */
|
|
238
|
+
stores?: readonly StorageStore[];
|
|
239
|
+
};
|
|
240
|
+
declare const HTTP_ONLY_NOTE = "HttpOnly cookies cannot be seen: the browser hides them from page scripts.";
|
|
241
|
+
/**
|
|
242
|
+
* Markdown for an Agent tool: values, with Redacted ones reduced to name and
|
|
243
|
+
* length. Narrow with `store` and `prefix`; at most `limit` entries (default
|
|
244
|
+
* 50, never more than 100) are listed.
|
|
245
|
+
*/
|
|
246
|
+
declare function formatStorageForAgent(entries: StorageEntry[], { pattern, unavailable, store, prefix, limit, stores, }?: StorageViewOptions & {
|
|
247
|
+
store?: StorageStore;
|
|
248
|
+
prefix?: string;
|
|
249
|
+
limit?: number;
|
|
250
|
+
}): string;
|
|
251
|
+
/**
|
|
252
|
+
* The Debug bundle section: key names and sizes only. Values join in when
|
|
253
|
+
* `includeValues` is set, and Redacted ones still stay hidden.
|
|
254
|
+
*/
|
|
255
|
+
declare function formatStorageBundleSection(entries: StorageEntry[], { pattern, unavailable, includeValues, stores, }?: StorageViewOptions & {
|
|
256
|
+
includeValues?: boolean;
|
|
257
|
+
}): string;
|
|
258
|
+
/** Sets or replaces one value. Redacted values are replaced blind: nothing is read back. */
|
|
259
|
+
declare function setStorageEntry(store: StorageStore, key: string, value: string): void;
|
|
260
|
+
/** Removes one entry. */
|
|
261
|
+
declare function deleteStorageEntry(store: StorageStore, key: string): void;
|
|
262
|
+
/** Removes every visible entry of one store. The toolbar's own `devbelt:*` keys stay. */
|
|
263
|
+
declare function clearStorageStore(store: StorageStore): void;
|
|
264
|
+
|
|
265
|
+
export { DEFAULT_REDACTED_HEADERS, DEFAULT_REDACTION_PATTERN, HTTP_ONLY_NOTE, STORAGE_STORES, UNTRUSTED_META_KEY, clampLimit, claudeCode, clearConsoleLog, clearNetworkLog, clearStorageStore, codex, createHostStore, cursor, defaultAiTools, deleteStorageEntry, describeAiResult, errorResult, exposedAgentTools, formatAsCurl, formatAsFetch, formatConsoleForAgent, formatDebugBundle, formatEntryForAgent, formatRecentProblems, formatStorageBundleSection, formatStorageForAgent, getConsoleEntries, getNetworkEntries, installConsoleLog, installNetworkLog, isFailedEntry, isRedacted, markUntrusted, openInAiTool, readJson, readStorageEntries, readString, redact, redactedForm, registerAgentTools, replayEntry, setStorageEntry, storageKey, subscribeConsoleLog, subscribeNetworkLog, text, writeJson, writeString };
|
|
266
|
+
export type { AgentTool, AiOpenDeps, AiOpenResult, AiTool, ConsoleEntry, ConsoleLevel, DebugContext, DebugEntry, NetworkEntry, NetworkLogOptions, StorageEntry, StorageStore, StorageViewOptions, ToolResult };
|