@liyuera/dsh-chrome-browser 0.3.0 → 0.5.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/README.md +238 -12
- package/extension/icons/icon-128.png +0 -0
- package/extension/icons/icon-16.png +0 -0
- package/extension/icons/icon-32.png +0 -0
- package/extension/icons/icon-48.png +0 -0
- package/extension/manifest.json +12 -5
- package/extension/service-worker.js +772 -70
- package/lib/activity.d.ts +65 -0
- package/lib/activity.d.ts.map +1 -0
- package/lib/activity.js +111 -0
- package/lib/activity.js.map +1 -0
- package/lib/backend.d.ts +235 -11
- package/lib/backend.d.ts.map +1 -1
- package/lib/backend.js +429 -40
- package/lib/backend.js.map +1 -1
- package/lib/cdp.d.ts +7 -1
- package/lib/cdp.d.ts.map +1 -1
- package/lib/cdp.js +17 -1
- package/lib/cdp.js.map +1 -1
- package/lib/chrome.d.ts +8 -0
- package/lib/chrome.d.ts.map +1 -1
- package/lib/chrome.js +20 -0
- package/lib/chrome.js.map +1 -1
- package/lib/client/BrowserActivity.d.ts +22 -0
- package/lib/client/BrowserActivity.d.ts.map +1 -0
- package/lib/client/BrowserActivity.js +100 -0
- package/lib/client/BrowserActivity.js.map +1 -0
- package/lib/client/activity.d.ts +27 -0
- package/lib/client/activity.d.ts.map +1 -0
- package/lib/client/activity.js +57 -0
- package/lib/client/activity.js.map +1 -0
- package/lib/client/index.d.ts +4 -6
- package/lib/client/index.d.ts.map +1 -1
- package/lib/client/index.js +13 -19
- package/lib/client/index.js.map +1 -1
- package/lib/client/tab-catalog.d.ts +11 -1
- package/lib/client/tab-catalog.d.ts.map +1 -1
- package/lib/client/tab-catalog.js.map +1 -1
- package/lib/client/tab-source.d.ts +8 -2
- package/lib/client/tab-source.d.ts.map +1 -1
- package/lib/client/tab-source.js.map +1 -1
- package/lib/client.js +177 -13
- package/lib/client.js.map +1 -1
- package/lib/console-events.d.ts +32 -0
- package/lib/console-events.d.ts.map +1 -0
- package/lib/console-events.js +106 -0
- package/lib/console-events.js.map +1 -0
- package/lib/console-log.d.ts +107 -0
- package/lib/console-log.d.ts.map +1 -0
- package/lib/console-log.js +158 -0
- package/lib/console-log.js.map +1 -0
- package/lib/expressions.d.ts +71 -2
- package/lib/expressions.d.ts.map +1 -1
- package/lib/expressions.js +277 -14
- package/lib/expressions.js.map +1 -1
- package/lib/extension-package.d.ts +49 -0
- package/lib/extension-package.d.ts.map +1 -1
- package/lib/extension-package.js +115 -0
- package/lib/extension-package.js.map +1 -1
- package/lib/help.d.ts +89 -0
- package/lib/help.d.ts.map +1 -0
- package/lib/help.js +94 -0
- package/lib/help.js.map +1 -0
- package/lib/index.d.ts +4 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +30 -9
- package/lib/index.js.map +1 -1
- package/lib/presentation.d.ts +130 -0
- package/lib/presentation.d.ts.map +1 -0
- package/lib/presentation.js +361 -0
- package/lib/presentation.js.map +1 -0
- package/lib/routes.d.ts +3 -8
- package/lib/routes.d.ts.map +1 -1
- package/lib/routes.js +24 -109
- package/lib/routes.js.map +1 -1
- package/lib/skill.d.ts +50 -0
- package/lib/skill.d.ts.map +1 -0
- package/lib/skill.js +164 -0
- package/lib/skill.js.map +1 -0
- package/lib/text.d.ts +21 -0
- package/lib/text.d.ts.map +1 -1
- package/lib/text.js +18 -0
- package/lib/text.js.map +1 -1
- package/lib/tools.d.ts +22 -4
- package/lib/tools.d.ts.map +1 -1
- package/lib/tools.js +493 -75
- package/lib/tools.js.map +1 -1
- package/lib/ws.d.ts +9 -2
- package/lib/ws.d.ts.map +1 -1
- package/lib/ws.js +49 -19
- package/lib/ws.js.map +1 -1
- package/package.json +5 -3
- package/lib/bindings.d.ts +0 -23
- package/lib/bindings.d.ts.map +0 -1
- package/lib/bindings.js +0 -49
- package/lib/bindings.js.map +0 -1
- package/lib/client/TabPicker.d.ts +0 -54
- package/lib/client/TabPicker.d.ts.map +0 -1
- package/lib/client/TabPicker.js +0 -329
- package/lib/client/TabPicker.js.map +0 -1
package/lib/extension-package.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* unpacking the archive yields a directory Chrome accepts directly.
|
|
8
8
|
* @module @liyuera/dsh-chrome-browser/extension-package
|
|
9
9
|
*/
|
|
10
|
+
import { createHash } from 'node:crypto';
|
|
10
11
|
import { readFileSync, readdirSync } from 'node:fs';
|
|
11
12
|
import { join, relative, sep } from 'node:path';
|
|
12
13
|
import { fileURLToPath } from 'node:url';
|
|
@@ -50,6 +51,120 @@ export function crc32(data) {
|
|
|
50
51
|
export function extensionDir(moduleUrl) {
|
|
51
52
|
return fileURLToPath(new URL('../extension/', moduleUrl));
|
|
52
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Version the loaded extension must report to be current.
|
|
56
|
+
*
|
|
57
|
+
* Read from the packaged manifest rather than duplicated as a constant, so the
|
|
58
|
+
* manifest stays the single source of truth. Compared against what the
|
|
59
|
+
* extension reports about itself on connect, which is the only way to tell a
|
|
60
|
+
* stale unpacked extension apart from a current one — Chrome never re-reads
|
|
61
|
+
* those files on its own.
|
|
62
|
+
* @param moduleUrl - `import.meta.url` of the module resolving the folder.
|
|
63
|
+
* @returns the manifest's version, or '' when it cannot be read.
|
|
64
|
+
*/
|
|
65
|
+
export function extensionVersion(moduleUrl) {
|
|
66
|
+
try {
|
|
67
|
+
const manifest = JSON.parse(readFileSync(join(extensionDir(moduleUrl), 'manifest.json'), 'utf8'));
|
|
68
|
+
const version = manifest.version;
|
|
69
|
+
return typeof version === 'string' ? version : '';
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
// A missing or malformed manifest is reported by the zip route; here it
|
|
73
|
+
// only means "no expectation to compare against".
|
|
74
|
+
if (!/ENOENT|JSON/u.test(String(error.message)))
|
|
75
|
+
throw error;
|
|
76
|
+
return '';
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Every file the extension is made of, as sorted relative paths.
|
|
81
|
+
*
|
|
82
|
+
* Sorted so both sides of the version handshake hash the same byte order, and
|
|
83
|
+
* the whole tree rather than a list so a file added to the folder is covered
|
|
84
|
+
* without an edit here. extension/service-worker.js carries the same set; a
|
|
85
|
+
* test keeps the two equal.
|
|
86
|
+
* @param directory - the extension folder.
|
|
87
|
+
* @returns relative paths, `/`-separated and sorted.
|
|
88
|
+
*/
|
|
89
|
+
export function extensionFiles(directory) {
|
|
90
|
+
const found = [];
|
|
91
|
+
const walk = (current) => {
|
|
92
|
+
for (const item of readdirSync(current, { withFileTypes: true })) {
|
|
93
|
+
const absolute = join(current, item.name);
|
|
94
|
+
if (item.isDirectory()) {
|
|
95
|
+
walk(absolute);
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (item.isFile())
|
|
99
|
+
found.push(relative(directory, absolute).split(sep).join('/'));
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
walk(directory);
|
|
103
|
+
return found.sort();
|
|
104
|
+
}
|
|
105
|
+
/** The value `scripts/stamp-extension.mjs` writes into the worker. */
|
|
106
|
+
const STAMP_LINE = /const BUILD_HASH = '[0-9a-f]{64}'/u;
|
|
107
|
+
/**
|
|
108
|
+
* One file's bytes with the stamp blanked, so the stamp is not self-referential.
|
|
109
|
+
* @param bytes - the file's contents.
|
|
110
|
+
* @returns the same bytes with any stamp value removed.
|
|
111
|
+
*/
|
|
112
|
+
function unstamped(bytes) {
|
|
113
|
+
return Buffer.from(bytes.toString('utf8').replace(STAMP_LINE, "const BUILD_HASH = ''"), 'utf8');
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Fingerprint of one extension folder, as lowercase hex SHA-256.
|
|
117
|
+
*
|
|
118
|
+
* A stamp rather than a version number someone has to remember to bump, and a
|
|
119
|
+
* stamp rather than a hash the extension computes at runtime: measured on a
|
|
120
|
+
* real browser, `fetch(chrome.runtime.getURL(...))` inside the worker returns
|
|
121
|
+
* the files on DISK, not the copy Chrome loaded, so a runtime self-hash reports
|
|
122
|
+
* the new bytes while the old code is still running and nothing ever looks
|
|
123
|
+
* stale. The worker therefore carries this value as a constant and reports it;
|
|
124
|
+
* the host compares that constant against this function's answer.
|
|
125
|
+
* @param directory - the extension folder.
|
|
126
|
+
* @returns the digest of every file, name and bytes, in sorted order.
|
|
127
|
+
*/
|
|
128
|
+
export function extensionStampOf(directory) {
|
|
129
|
+
const hash = createHash('sha256');
|
|
130
|
+
for (const name of extensionFiles(directory)) {
|
|
131
|
+
hash.update(Buffer.from(name, 'utf8'));
|
|
132
|
+
hash.update(Buffer.from([0]));
|
|
133
|
+
hash.update(unstamped(readFileSync(join(directory, name))));
|
|
134
|
+
}
|
|
135
|
+
return hash.digest('hex');
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* The stamp this package's extension files should carry.
|
|
139
|
+
* @param moduleUrl - `import.meta.url` of the module resolving the folder.
|
|
140
|
+
* @returns the digest, or '' when the folder cannot be read.
|
|
141
|
+
*/
|
|
142
|
+
export function extensionStamp(moduleUrl) {
|
|
143
|
+
try {
|
|
144
|
+
return extensionStampOf(extensionDir(moduleUrl));
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
if (!/ENOENT/u.test(String(error.message)))
|
|
148
|
+
throw error;
|
|
149
|
+
return '';
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* The stamp actually written into the worker beside this module.
|
|
154
|
+
* @param moduleUrl - `import.meta.url` of the module resolving the folder.
|
|
155
|
+
* @returns the constant's value, or '' when it cannot be read.
|
|
156
|
+
*/
|
|
157
|
+
export function extensionStampedValue(moduleUrl) {
|
|
158
|
+
try {
|
|
159
|
+
const text = readFileSync(join(extensionDir(moduleUrl), 'service-worker.js'), 'utf8');
|
|
160
|
+
return /const BUILD_HASH = '([0-9a-f]{64})'/u.exec(text)?.[1] ?? '';
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
if (!/ENOENT/u.test(String(error.message)))
|
|
164
|
+
throw error;
|
|
165
|
+
return '';
|
|
166
|
+
}
|
|
167
|
+
}
|
|
53
168
|
/** Collect every regular file under one directory, sorted for a stable archive. */
|
|
54
169
|
function collectFiles(root, current) {
|
|
55
170
|
const entries = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension-package.js","sourceRoot":"","sources":["../src/extension-package.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACnD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAExC,sEAAsE;AACtE,MAAM,CAAC,MAAM,kBAAkB,GAAG,8BAA8B,CAAA;AAEhE;;;GAGG;AACH,MAAM,QAAQ,GAAG,CAAC,CAAA;AAClB,MAAM,QAAQ,GAAG,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAA;AAUpD,uCAAuC;AACvC,MAAM,SAAS,GAAG,CAAC,GAAgB,EAAE;IACnC,MAAM,KAAK,GAAG,IAAI,WAAW,CAAC,GAAG,CAAC,CAAA;IAClC,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,GAAG,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QAC5C,IAAI,KAAK,GAAG,KAAK,CAAA;QACjB,KAAK,IAAI,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;YACpC,KAAK,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAA;QACtE,CAAC;QACD,KAAK,CA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AAE,CAAC,CAAC,CAAA;IAChC,GAAG,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IACvB,GAAG,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IACvB,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;IAClC,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;IACnC,GAAG,CAAC,aAAa,CAAC,cAAc,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;IAC5C,GAAG,CAAC,aAAa,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;IAC7B,GAAG,CAAC,aAAa,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IAExB,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,EAAE,cAAc,EAAE,GAAG,CAAC,CAAC,CAAA;AACvD,CAAC"}
|
package/lib/help.d.ts
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The human-help channel behind `chrome_request_help`: the model asks the user
|
|
3
|
+
* to do a step only they can do — sign in, solve a CAPTCHA, approve a prompt —
|
|
4
|
+
* and waits for the answer instead of guessing at a login wall.
|
|
5
|
+
*
|
|
6
|
+
* The question service is reached structurally and through `ctx.inject`, so a
|
|
7
|
+
* composition without one keeps every other tool working and answers this one
|
|
8
|
+
* with a clear error rather than hanging or silently doing nothing.
|
|
9
|
+
* @module @liyuera/dsh-chrome-browser/help
|
|
10
|
+
*/
|
|
11
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
12
|
+
/** Label the human picks to say the step is done; the answer is compared against it. */
|
|
13
|
+
export declare const HELP_DONE_LABEL = "\u5DF2\u5B8C\u6210,\u7EE7\u7EED";
|
|
14
|
+
/** Label the human picks to stop this line of work. */
|
|
15
|
+
export declare const HELP_SKIP_LABEL = "\u8DF3\u8FC7,\u505C\u6B62\u8FD9\u6761\u8DEF\u5F84";
|
|
16
|
+
/** One question as the question service takes it. */
|
|
17
|
+
export interface HelpQuestion {
|
|
18
|
+
readonly id: string;
|
|
19
|
+
readonly header?: string;
|
|
20
|
+
readonly question: string;
|
|
21
|
+
readonly detail?: string;
|
|
22
|
+
readonly options?: readonly {
|
|
23
|
+
readonly label: string;
|
|
24
|
+
readonly description?: string;
|
|
25
|
+
}[];
|
|
26
|
+
}
|
|
27
|
+
/** Structural view of the question service (`ctx.userQuestions`). */
|
|
28
|
+
export interface UserQuestionsLike {
|
|
29
|
+
/** Ask the scoped answerer waterfall and wait for the human's answer. */
|
|
30
|
+
ask(request: {
|
|
31
|
+
questions: readonly HelpQuestion[];
|
|
32
|
+
agent?: unknown;
|
|
33
|
+
signal?: AbortSignal;
|
|
34
|
+
}): Promise<{
|
|
35
|
+
answers: readonly {
|
|
36
|
+
id: string;
|
|
37
|
+
selected: readonly string[];
|
|
38
|
+
custom?: string;
|
|
39
|
+
}[];
|
|
40
|
+
}>;
|
|
41
|
+
}
|
|
42
|
+
/** What one help request produced. */
|
|
43
|
+
export interface HelpOutcome {
|
|
44
|
+
/** Whether the human reported the step done. */
|
|
45
|
+
completed: boolean;
|
|
46
|
+
/** Free text the human added, when they added any. */
|
|
47
|
+
note?: string;
|
|
48
|
+
}
|
|
49
|
+
/** Ask the human one thing and resolve with what they answered. */
|
|
50
|
+
export type HelpAsker = (reason: string, agent: unknown) => Promise<HelpOutcome>;
|
|
51
|
+
/**
|
|
52
|
+
* Build the asker over a live question service.
|
|
53
|
+
*
|
|
54
|
+
* The question offers exactly two answers, so the model cannot read an
|
|
55
|
+
* ambiguous reply as permission: anything that is not the done label — a skip,
|
|
56
|
+
* or a dismissal that comes back empty — means the step did not happen.
|
|
57
|
+
* @param questions - the resolved `ctx.userQuestions`.
|
|
58
|
+
* @returns the asker {@link HelpChannel.wire} takes.
|
|
59
|
+
*/
|
|
60
|
+
export declare function questionAsker(questions: UserQuestionsLike): HelpAsker;
|
|
61
|
+
/**
|
|
62
|
+
* The channel `chrome_request_help` speaks to. It starts unwired, because the
|
|
63
|
+
* question service may be absent or may resolve after this plugin applies;
|
|
64
|
+
* {@link registerHelpChannel} installs the asker once it exists.
|
|
65
|
+
*/
|
|
66
|
+
export declare class HelpChannel {
|
|
67
|
+
private asker;
|
|
68
|
+
/** Install the asker; the last wiring wins. */
|
|
69
|
+
wire(asker: HelpAsker): void;
|
|
70
|
+
/** Whether this composition can reach a human at all. */
|
|
71
|
+
get wired(): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Ask the human to do a step and wait for their answer.
|
|
74
|
+
* @param reason - what the human must do, in their own language.
|
|
75
|
+
* @param agent - the asking agent, when the caller has one.
|
|
76
|
+
* @returns what the human answered.
|
|
77
|
+
* @throws when this composition exposes no question service.
|
|
78
|
+
*/
|
|
79
|
+
request(reason: string, agent: unknown): Promise<HelpOutcome>;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Wire the channel once a question service exists in this composition. A
|
|
83
|
+
* composition without one never runs the callback, which is the intended
|
|
84
|
+
* degradation: the tool stays registered and explains itself.
|
|
85
|
+
* @param ctx - the plugin's Cordis context.
|
|
86
|
+
* @param channel - the channel `chrome_request_help` reads.
|
|
87
|
+
*/
|
|
88
|
+
export declare function registerHelpChannel(ctx: Context, channel: HelpChannel): void;
|
|
89
|
+
//# sourceMappingURL=help.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../src/help.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAElD,wFAAwF;AACxF,eAAO,MAAM,eAAe,oCAAW,CAAA;AAEvC,uDAAuD;AACvD,eAAO,MAAM,eAAe,sDAAc,CAAA;AAE1C,qDAAqD;AACrD,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ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;;OAMG;IACG,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC;CAUpE;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI,CAM5E"}
|
package/lib/help.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The human-help channel behind `chrome_request_help`: the model asks the user
|
|
3
|
+
* to do a step only they can do — sign in, solve a CAPTCHA, approve a prompt —
|
|
4
|
+
* and waits for the answer instead of guessing at a login wall.
|
|
5
|
+
*
|
|
6
|
+
* The question service is reached structurally and through `ctx.inject`, so a
|
|
7
|
+
* composition without one keeps every other tool working and answers this one
|
|
8
|
+
* with a clear error rather than hanging or silently doing nothing.
|
|
9
|
+
* @module @liyuera/dsh-chrome-browser/help
|
|
10
|
+
*/
|
|
11
|
+
/** Label the human picks to say the step is done; the answer is compared against it. */
|
|
12
|
+
export const HELP_DONE_LABEL = '已完成,继续';
|
|
13
|
+
/** Label the human picks to stop this line of work. */
|
|
14
|
+
export const HELP_SKIP_LABEL = '跳过,停止这条路径';
|
|
15
|
+
/**
|
|
16
|
+
* Build the asker over a live question service.
|
|
17
|
+
*
|
|
18
|
+
* The question offers exactly two answers, so the model cannot read an
|
|
19
|
+
* ambiguous reply as permission: anything that is not the done label — a skip,
|
|
20
|
+
* or a dismissal that comes back empty — means the step did not happen.
|
|
21
|
+
* @param questions - the resolved `ctx.userQuestions`.
|
|
22
|
+
* @returns the asker {@link HelpChannel.wire} takes.
|
|
23
|
+
*/
|
|
24
|
+
export function questionAsker(questions) {
|
|
25
|
+
return async (reason, agent) => {
|
|
26
|
+
const answer = await questions.ask({
|
|
27
|
+
questions: [{
|
|
28
|
+
id: 'chrome-request-help',
|
|
29
|
+
header: '需要你在浏览器里操作一下',
|
|
30
|
+
question: reason,
|
|
31
|
+
detail: '做完后选「' + HELP_DONE_LABEL + '」,模型会接着往下走;'
|
|
32
|
+
+ '选「' + HELP_SKIP_LABEL + '」它会停下这条路径,不会反复重试。',
|
|
33
|
+
options: [
|
|
34
|
+
{ label: HELP_DONE_LABEL, description: '我已经做完了,继续' },
|
|
35
|
+
{ label: HELP_SKIP_LABEL, description: '不做了,让模型停止' },
|
|
36
|
+
],
|
|
37
|
+
}],
|
|
38
|
+
...(agent === undefined ? {} : { agent }),
|
|
39
|
+
});
|
|
40
|
+
const first = answer.answers[0];
|
|
41
|
+
const note = first?.custom;
|
|
42
|
+
return {
|
|
43
|
+
completed: first?.selected?.[0] === HELP_DONE_LABEL,
|
|
44
|
+
...(note === undefined || note === '' ? {} : { note }),
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The channel `chrome_request_help` speaks to. It starts unwired, because the
|
|
50
|
+
* question service may be absent or may resolve after this plugin applies;
|
|
51
|
+
* {@link registerHelpChannel} installs the asker once it exists.
|
|
52
|
+
*/
|
|
53
|
+
export class HelpChannel {
|
|
54
|
+
asker;
|
|
55
|
+
/** Install the asker; the last wiring wins. */
|
|
56
|
+
wire(asker) {
|
|
57
|
+
this.asker = asker;
|
|
58
|
+
}
|
|
59
|
+
/** Whether this composition can reach a human at all. */
|
|
60
|
+
get wired() {
|
|
61
|
+
return this.asker !== undefined;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Ask the human to do a step and wait for their answer.
|
|
65
|
+
* @param reason - what the human must do, in their own language.
|
|
66
|
+
* @param agent - the asking agent, when the caller has one.
|
|
67
|
+
* @returns what the human answered.
|
|
68
|
+
* @throws when this composition exposes no question service.
|
|
69
|
+
*/
|
|
70
|
+
async request(reason, agent) {
|
|
71
|
+
const asker = this.asker;
|
|
72
|
+
if (asker === undefined) {
|
|
73
|
+
throw new Error('chrome_request_help: this dsh composition exposes no user-question service, so the plugin cannot reach'
|
|
74
|
+
+ ' you. Continue without the step — and say in your reply what you needed the user to do.');
|
|
75
|
+
}
|
|
76
|
+
return await asker(reason, agent);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Wire the channel once a question service exists in this composition. A
|
|
81
|
+
* composition without one never runs the callback, which is the intended
|
|
82
|
+
* degradation: the tool stays registered and explains itself.
|
|
83
|
+
* @param ctx - the plugin's Cordis context.
|
|
84
|
+
* @param channel - the channel `chrome_request_help` reads.
|
|
85
|
+
*/
|
|
86
|
+
export function registerHelpChannel(ctx, channel) {
|
|
87
|
+
ctx.inject(['userQuestions'], (scoped) => {
|
|
88
|
+
const questions = scoped.get('userQuestions');
|
|
89
|
+
if (questions === undefined)
|
|
90
|
+
return;
|
|
91
|
+
channel.wire(questionAsker(questions));
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=help.js.map
|
package/lib/help.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.js","sourceRoot":"","sources":["../src/help.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,wFAAwF;AACxF,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAA;AAEvC,uDAAuD;AACvD,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CAAA;AAgC1C;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAAC,SAA4B;IACxD,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE;QAC7B,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,GAAG,CAAC;YACjC,SAAS,EAAE,CAAC;oBACV,EAAE,EAAE,qBAAqB;oBACzB,MAAM,EAAE,cAAc;oBACtB,QAAQ,EAAE,MAAM;oBAChB,MAAM,EAAE,OAAO,GAAG,eAAe,GAAG,aAAa;0BAC7C,IAAI,GAAG,eAAe,GAAG,mBAAmB;oBAChD,OAAO,EAAE;wBACP,EAAE,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,WAAW,EAAE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,EAAE,CAAC,MAAM,EAAE,EAAE;QACvC,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,eAAe,CAAkC,CAAA;QAC9E,IAAI,SAAS,KAAK,SAAS;YAAE,OAAM;QACnC,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAA;IACxC,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
* Protocol (cdp fallback): list tabs, read page content, navigate, open
|
|
5
5
|
* tabs, capture screenshots, click, type, and evaluate JS — plus the
|
|
6
6
|
* same-origin routes the browser half uses to list tabs, bind them per
|
|
7
|
-
* session, and serve the extension bridge WebSocket,
|
|
8
|
-
*
|
|
7
|
+
* session, and serve the extension bridge WebSocket, the pre-step hook that
|
|
8
|
+
* expands a tab citation into a context message, the `chrome-browser` agent
|
|
9
|
+
* skill (when this composition exposes a skill registry), and the human-help
|
|
10
|
+
* channel behind `chrome_request_help` (when it exposes a question service).
|
|
9
11
|
* @module @liyuera/dsh-chrome-browser
|
|
10
12
|
*/
|
|
11
13
|
import type { Context } from '@deepseek-ai/cordis';
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAElD,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAIxC,OAAO,KAAK,EAAE,UAAU,EAAwB,MAAM,aAAa,CAAA;AAQnE,uBAAuB;AACvB,eAAO,MAAM,IAAI,mBAAmB,CAAA;AAEpC;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,UAAyB,CAAA;AAE5C,4EAA4E;AAC5E,MAAM,WAAW,kBAAkB;IACjC,wGAAwG;IACxG,OAAO,CAAC,EAAE,WAAW,GAAG,KAAK,CAAA;IAC7B,oDAAoD;IACpD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,yEAAyE;IACzE,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,oDAAoD;IACpD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,8FAA8F;IAC9F,IAAI,CAAC,EAAE,UAAU,CAAA;IACjB,iFAAiF;IACjF,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,8FAA8F;IAC9F,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,4DAA4D;IAC5D,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,2EAA2E;IAC3E,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,+DAA+D;IAC/D,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,uEAAuE;IACvE,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;AAED,mDAAmD;AACnD,eAAO,MAAM,MAAM,EAAE,CAAC,CAAC,kBAAkB,CAYvC,CAAA;AAEF;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,GAAE,kBAAuB,GAAG,IAAI,CA0CzE"}
|
package/lib/index.js
CHANGED
|
@@ -4,16 +4,21 @@
|
|
|
4
4
|
* Protocol (cdp fallback): list tabs, read page content, navigate, open
|
|
5
5
|
* tabs, capture screenshots, click, type, and evaluate JS — plus the
|
|
6
6
|
* same-origin routes the browser half uses to list tabs, bind them per
|
|
7
|
-
* session, and serve the extension bridge WebSocket,
|
|
8
|
-
*
|
|
7
|
+
* session, and serve the extension bridge WebSocket, the pre-step hook that
|
|
8
|
+
* expands a tab citation into a context message, the `chrome-browser` agent
|
|
9
|
+
* skill (when this composition exposes a skill registry), and the human-help
|
|
10
|
+
* channel behind `chrome_request_help` (when it exposes a question service).
|
|
9
11
|
* @module @liyuera/dsh-chrome-browser
|
|
10
12
|
*/
|
|
11
13
|
import z from '@deepseek-ai/schemastery';
|
|
14
|
+
import { ActivityTracker, withActivity } from "./activity.js";
|
|
12
15
|
import { buildBackend } from "./backend.js";
|
|
13
|
-
import { SessionBindings } from "./bindings.js";
|
|
14
16
|
import { resolveChromeConfig } from "./chrome.js";
|
|
17
|
+
import { ConsoleLog } from "./console-log.js";
|
|
18
|
+
import { HelpChannel, registerHelpChannel } from "./help.js";
|
|
15
19
|
import { expandTabMentions } from "./mentions.js";
|
|
16
20
|
import { registerChromeRoutes } from "./routes.js";
|
|
21
|
+
import { registerChromeSkill } from "./skill.js";
|
|
17
22
|
import { chromeToolDefinitions } from "./tools.js";
|
|
18
23
|
/** Plugin identity. */
|
|
19
24
|
export const name = 'chrome-browser';
|
|
@@ -49,14 +54,26 @@ export const Config = z.object({
|
|
|
49
54
|
*/
|
|
50
55
|
export function apply(ctx, config = {}) {
|
|
51
56
|
const resolved = resolveChromeConfig(config);
|
|
52
|
-
|
|
57
|
+
// The console buffer lives here, in the long-lived host: the extension's
|
|
58
|
+
// service worker is suspended by Chrome and would lose it silently.
|
|
59
|
+
const consoleLog = new ConsoleLog();
|
|
60
|
+
const { backend, chrome } = buildBackend(resolved, (tabId, message) => {
|
|
61
|
+
consoleLog.append(tabId, message);
|
|
62
|
+
});
|
|
53
63
|
if (chrome !== undefined)
|
|
54
64
|
chrome.reclaimOwnedLeftover();
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
65
|
+
// The help channel reaches the user through the harness's question service;
|
|
66
|
+
// it stays unwired (and says so) when this composition has none.
|
|
67
|
+
const help = new HelpChannel();
|
|
68
|
+
// Every tool execution is recorded here so the browser half can show what the
|
|
69
|
+
// agent is doing without reading the session stream itself.
|
|
70
|
+
const activity = new ActivityTracker();
|
|
71
|
+
for (const definition of chromeToolDefinitions(backend, resolved, consoleLog, help)) {
|
|
72
|
+
ctx.tools.register(withActivity(definition, activity));
|
|
58
73
|
}
|
|
59
|
-
|
|
74
|
+
registerHelpChannel(ctx, help);
|
|
75
|
+
registerChromeRoutes(ctx, backend, config.screenshotDir ?? resolveChromeConfig(config).screenshotDir, activity);
|
|
76
|
+
registerChromeSkill(ctx);
|
|
60
77
|
// A message citing tabs gains one context message carrying their URLs and
|
|
61
78
|
// ids. Only the messages this step admits are scanned, and the context
|
|
62
79
|
// message's own source keeps it out of the next scan.
|
|
@@ -67,6 +84,10 @@ export function apply(ctx, config = {}) {
|
|
|
67
84
|
const messages = await expandTabMentions(decision.messages, () => backend.listTabs());
|
|
68
85
|
return messages === undefined ? decision : { ...decision, messages };
|
|
69
86
|
}, { prepend: true });
|
|
70
|
-
ctx.effect(() => () =>
|
|
87
|
+
ctx.effect(() => () => {
|
|
88
|
+
consoleLog.releaseAll();
|
|
89
|
+
activity.clear();
|
|
90
|
+
backend.dispose();
|
|
91
|
+
}, 'chrome-browser: backend lifecycle');
|
|
71
92
|
}
|
|
72
93
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,CAAC,MAAM,0BAA0B,CAAA;AACxC,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEjD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAA;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAClD,OAA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IAAI,mBAAmB,CAAC,MAAM,CAAC,CAAC,aAAa,EACjE,QAAQ,CACT,CAAA;IACD,mBAAmB,CAAC,GAAG,CAAC,CAAA;IAExB,0EAA0E;IAC1E,uEAAuE;IACvE,sDAAsD;IACtD,GAAG,CAAC,EAAE,CAAC,gBAAgB,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAA4B,EAAE;QAC1E,MAAM,QAAQ,GAAG,MAAM,IAAI,EAAE,CAAA;QAC7B,IAAI,QAAQ,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO,QAAQ,CAAA;QAC/C,MAAM,QAAQ,GAAG,MAAM,iBAAiB,CAAC,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAA;QACrF,OAAO,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,QAAQ,EAAE,QAAQ,EAAE,CAAA;IACtE,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAA;IAErB,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE;QACpB,UAAU,CAAC,UAAU,EAAE,CAAA;QACvB,QAAQ,CAAC,KAAK,EAAE,CAAA;QAChB,OAAO,CAAC,OAAO,EAAE,CAAA;IACnB,CAAC,EAAE,mCAAmC,CAAC,CAAA;AACzC,CAAC"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UI-facing presentation for the eight `chrome_*` tools: the pending-call title,
|
|
3
|
+
* the completed card, and the concurrency classification the scheduler reads.
|
|
4
|
+
*
|
|
5
|
+
* This module is UI-only — the model still receives exactly the JSON `render`
|
|
6
|
+
* output, so a card may reformat freely without touching the model contract.
|
|
7
|
+
* Each presenter reads back the JSON this plugin's own `render` produced rather
|
|
8
|
+
* than declaring `output.presentationMeta`: that projection is persisted verbatim
|
|
9
|
+
* on the session log, and re-projecting values we already render losslessly would
|
|
10
|
+
* duplicate page text and evaluated values into every log.
|
|
11
|
+
* @module @liyuera/dsh-chrome-browser/presentation
|
|
12
|
+
*/
|
|
13
|
+
import type { GenericCallView, GenericResultView, ToolCallKind, ToolResult } from '@deepseek-ai/dsh-tools';
|
|
14
|
+
/** Tab rows one card lists; a long listing stays complete in the model-facing result. */
|
|
15
|
+
export declare const CARD_TAB_LIMIT = 20;
|
|
16
|
+
/** One pending call with a semantic title. */
|
|
17
|
+
export declare function call(title: string, kind: ToolCallKind): GenericCallView;
|
|
18
|
+
/** One completed call with a semantic title and a reformatted body. */
|
|
19
|
+
export declare function result(title: string, text?: string): GenericResultView;
|
|
20
|
+
/**
|
|
21
|
+
* Parse the JSON object this plugin's `render` serialized.
|
|
22
|
+
* @param outcome - the settled tool result.
|
|
23
|
+
* @returns the parsed object, or undefined for an error, a multi-block result, or non-JSON text.
|
|
24
|
+
*/
|
|
25
|
+
export declare function renderedJson(outcome: ToolResult): Record<string, unknown> | undefined;
|
|
26
|
+
/** One tab id argument as a card names it. */
|
|
27
|
+
export declare function tabLabel(tabId: unknown): string;
|
|
28
|
+
/** `chrome_tabs` pending call. */
|
|
29
|
+
export declare function tabsCall(): GenericCallView;
|
|
30
|
+
/** `chrome_tabs` completed card: the listing, capped at {@link CARD_TAB_LIMIT} rows. */
|
|
31
|
+
export declare function tabsResult(outcome: ToolResult): GenericResultView | undefined;
|
|
32
|
+
/** `chrome_read` pending call. */
|
|
33
|
+
export declare function readCall(args: {
|
|
34
|
+
tabId?: string;
|
|
35
|
+
}): GenericCallView;
|
|
36
|
+
/** `chrome_read` completed card: the page identity plus what the model received. */
|
|
37
|
+
export declare function readResult(outcome: ToolResult): GenericResultView | undefined;
|
|
38
|
+
/** `chrome_navigate` pending call. */
|
|
39
|
+
export declare function navigateCall(args: {
|
|
40
|
+
url: string;
|
|
41
|
+
tabId?: string;
|
|
42
|
+
}): GenericCallView;
|
|
43
|
+
/** `chrome_navigate` completed card. */
|
|
44
|
+
export declare function navigateResult(outcome: ToolResult): GenericResultView | undefined;
|
|
45
|
+
/** `chrome_open` pending call. */
|
|
46
|
+
export declare function openCall(args: {
|
|
47
|
+
url?: string;
|
|
48
|
+
}): GenericCallView;
|
|
49
|
+
/** `chrome_open` completed card. */
|
|
50
|
+
export declare function openResult(outcome: ToolResult): GenericResultView | undefined;
|
|
51
|
+
/** `chrome_screenshot` pending call. */
|
|
52
|
+
export declare function screenshotCall(args: {
|
|
53
|
+
tabId?: string;
|
|
54
|
+
}): GenericCallView;
|
|
55
|
+
/** `chrome_screenshot` completed card: the file the model was told to read. */
|
|
56
|
+
export declare function screenshotResult(outcome: ToolResult): GenericResultView | undefined;
|
|
57
|
+
/** `chrome_click` pending call. */
|
|
58
|
+
export declare function clickCall(args: {
|
|
59
|
+
selector: string;
|
|
60
|
+
all?: boolean;
|
|
61
|
+
tabId?: string;
|
|
62
|
+
}): GenericCallView;
|
|
63
|
+
/** `chrome_hover` pending call. */
|
|
64
|
+
export declare function hoverCall(args: {
|
|
65
|
+
selector: string;
|
|
66
|
+
tabId?: string;
|
|
67
|
+
}): GenericCallView;
|
|
68
|
+
/** `chrome_hover` completed card. */
|
|
69
|
+
export declare function hoverResult(outcome: ToolResult): GenericResultView | undefined;
|
|
70
|
+
/** `chrome_wait` pending call. */
|
|
71
|
+
export declare function waitCall(args: {
|
|
72
|
+
selector: string;
|
|
73
|
+
state?: string;
|
|
74
|
+
tabId?: string;
|
|
75
|
+
}): GenericCallView;
|
|
76
|
+
/** `chrome_wait` completed card: whether the condition held, never "how it went". */
|
|
77
|
+
export declare function waitResult(outcome: ToolResult): GenericResultView | undefined;
|
|
78
|
+
/** `chrome_press` pending call. */
|
|
79
|
+
export declare function pressCall(args: {
|
|
80
|
+
key: string;
|
|
81
|
+
selector?: string;
|
|
82
|
+
tabId?: string;
|
|
83
|
+
}): GenericCallView;
|
|
84
|
+
/** `chrome_press` completed card, naming the submit that synthetic keys make necessary. */
|
|
85
|
+
export declare function pressResult(outcome: ToolResult): GenericResultView | undefined;
|
|
86
|
+
/** `chrome_request_help` pending call. */
|
|
87
|
+
export declare function helpCall(args: {
|
|
88
|
+
reason: string;
|
|
89
|
+
}): GenericCallView;
|
|
90
|
+
/** `chrome_request_help` completed card. */
|
|
91
|
+
export declare function helpResult(outcome: ToolResult): GenericResultView | undefined;
|
|
92
|
+
/** `chrome_close` pending call. */
|
|
93
|
+
export declare function closeCall(args: {
|
|
94
|
+
tabId: string;
|
|
95
|
+
}): GenericCallView;
|
|
96
|
+
/** `chrome_close` completed card. */
|
|
97
|
+
export declare function closeResult(outcome: ToolResult): GenericResultView | undefined;
|
|
98
|
+
/** `chrome_select` pending call. */
|
|
99
|
+
export declare function selectCall(args: {
|
|
100
|
+
value: string;
|
|
101
|
+
selector: string;
|
|
102
|
+
tabId?: string;
|
|
103
|
+
}): GenericCallView;
|
|
104
|
+
/** `chrome_select` completed card. */
|
|
105
|
+
export declare function selectResult(outcome: ToolResult): GenericResultView | undefined;
|
|
106
|
+
/** `chrome_click` completed card. Surfaces the warnings that explain a click the page may have ignored. */
|
|
107
|
+
export declare function clickResult(outcome: ToolResult): GenericResultView | undefined;
|
|
108
|
+
/** `chrome_type` pending call. Never carries the typed text: it may be a credential. */
|
|
109
|
+
export declare function typeCall(args: {
|
|
110
|
+
selector: string;
|
|
111
|
+
text: string;
|
|
112
|
+
tabId?: string;
|
|
113
|
+
}): GenericCallView;
|
|
114
|
+
/** `chrome_type` completed card. The typed text stays out of the card, as in the call view. */
|
|
115
|
+
export declare function typeResult(outcome: ToolResult): GenericResultView | undefined;
|
|
116
|
+
/** `chrome_eval` pending call. */
|
|
117
|
+
export declare function evalCall(args: {
|
|
118
|
+
expression: string;
|
|
119
|
+
tabId?: string;
|
|
120
|
+
}): GenericCallView;
|
|
121
|
+
/** `chrome_eval` completed card: the serialized value the model received. */
|
|
122
|
+
export declare function evalResult(outcome: ToolResult): GenericResultView | undefined;
|
|
123
|
+
/** `chrome_console` pending call, titled by the lifecycle step it performs. */
|
|
124
|
+
export declare function consoleCall(args: {
|
|
125
|
+
action: string;
|
|
126
|
+
tabId?: string;
|
|
127
|
+
}): GenericCallView;
|
|
128
|
+
/** `chrome_console` completed card: the lifecycle result, or the entries read. */
|
|
129
|
+
export declare function consoleResult(outcome: ToolResult): GenericResultView | undefined;
|
|
130
|
+
//# sourceMappingURL=presentation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presentation.d.ts","sourceRoot":"","sources":["../src/presentation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAE1G,yFAAyF;AACzF,eAAO,MAAM,cAAc,KAAK,CAAA;AAEhC,8CAA8C;AAC9C,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,eAAe,CAEvE;AAED,uEAAuE;AACvE,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,iBAAiB,CAItE;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAUrF;AAcD,8CAA8C;AAC9C,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAI/C;AAmBD,kCAAkC;AAClC,wBAAgB,QAAQ,IAAI,eAAe,CAE1C;AAED,wFAAwF;AACxF,wBAAgB,UAAU,CAAC,OAAO,EAAE,UAAU,GAAG,iBAAiB,GAAG,SAAS,CAc7E;AAED,kCAAkC;AAClC,wBAAgB,QAAQ,CAAC,IAAI,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,eAAe,CAElE;AAkBD,oFAAoF;AACpF,wBAAgB,UAAU,CAAC,OA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