@anweat/dsh-browser 0.1.17 → 0.2.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +238 -71
- package/assets/skills/dsh-browser/SKILL.md +120 -0
- package/assets/skills/dsh-browser/references/develop.md +48 -0
- package/assets/skills/dsh-browser/references/observe.md +91 -0
- package/assets/skills/dsh-browser/references/opencli.md +25 -0
- package/assets/skills/dsh-browser/references/recipes.md +149 -0
- package/assets/skills/dsh-browser/references/userscripts.md +44 -0
- package/cordis.patch.yml +4 -0
- package/lib/actions/act.d.ts +3 -0
- package/lib/actions/act.js +147 -0
- package/lib/actions/act.js.map +1 -0
- package/lib/actions/automation.d.ts +3 -0
- package/lib/actions/automation.js +356 -0
- package/lib/actions/automation.js.map +1 -0
- package/lib/actions/crawl.d.ts +3 -0
- package/lib/actions/crawl.js +28 -0
- package/lib/actions/crawl.js.map +1 -0
- package/lib/actions/errors.d.ts +53 -0
- package/lib/actions/errors.js +178 -0
- package/lib/actions/errors.js.map +1 -0
- package/lib/actions/index-view.d.ts +42 -0
- package/lib/actions/index-view.js +268 -0
- package/lib/actions/index-view.js.map +1 -0
- package/lib/actions/inspect.d.ts +3 -0
- package/lib/actions/inspect.js +35 -0
- package/lib/actions/inspect.js.map +1 -0
- package/lib/actions/observe.d.ts +3 -0
- package/lib/actions/observe.js +121 -0
- package/lib/actions/observe.js.map +1 -0
- package/lib/actions/opencli.d.ts +3 -0
- package/lib/actions/opencli.js +51 -0
- package/lib/actions/opencli.js.map +1 -0
- package/lib/actions/registry.d.ts +35 -0
- package/lib/actions/registry.js +89 -0
- package/lib/actions/registry.js.map +1 -0
- package/lib/actions/run.d.ts +34 -0
- package/lib/actions/run.js +226 -0
- package/lib/actions/run.js.map +1 -0
- package/lib/actions/runtime.d.ts +3 -0
- package/lib/actions/runtime.js +33 -0
- package/lib/actions/runtime.js.map +1 -0
- package/lib/actions/schema.d.ts +31 -0
- package/lib/actions/schema.js +309 -0
- package/lib/actions/schema.js.map +1 -0
- package/lib/actions/script.d.ts +3 -0
- package/lib/actions/script.js +97 -0
- package/lib/actions/script.js.map +1 -0
- package/lib/actions/shared.d.ts +31 -0
- package/lib/actions/shared.js +45 -0
- package/lib/actions/shared.js.map +1 -0
- package/lib/actions/surface.d.ts +22 -0
- package/lib/actions/surface.js +18 -0
- package/lib/actions/surface.js.map +1 -0
- package/lib/actions/target.d.ts +3 -0
- package/lib/actions/target.js +66 -0
- package/lib/actions/target.js.map +1 -0
- package/lib/actions/types.d.ts +181 -0
- package/lib/actions/types.js +48 -0
- package/lib/actions/types.js.map +1 -0
- package/lib/activation-rules.d.ts +29 -0
- package/lib/activation-rules.js +33 -0
- package/lib/activation-rules.js.map +1 -0
- package/lib/approval-policy.d.ts +40 -2
- package/lib/approval-policy.js +184 -97
- package/lib/approval-policy.js.map +1 -1
- package/lib/automation-assets-rpc.d.ts +8 -2
- package/lib/automation-assets-rpc.js +67 -6
- package/lib/automation-assets-rpc.js.map +1 -1
- package/lib/automation-assets.d.ts +152 -4
- package/lib/automation-assets.js +255 -15
- package/lib/automation-assets.js.map +1 -1
- package/lib/automation-convert.d.ts +23 -0
- package/lib/automation-convert.js +110 -0
- package/lib/automation-convert.js.map +1 -0
- package/lib/automation-development.d.ts +26 -0
- package/lib/automation-development.js +47 -0
- package/lib/automation-development.js.map +1 -1
- package/lib/automation-execution.d.ts +57 -1
- package/lib/automation-execution.js +167 -11
- package/lib/automation-execution.js.map +1 -1
- package/lib/automation-journal.d.ts +92 -0
- package/lib/automation-journal.js +449 -0
- package/lib/automation-journal.js.map +1 -0
- package/lib/automation-v2.d.ts +138 -0
- package/lib/automation-v2.js +631 -0
- package/lib/automation-v2.js.map +1 -0
- package/lib/automation.d.ts +82 -5
- package/lib/automation.js +239 -82
- package/lib/automation.js.map +1 -1
- package/lib/browser-service.d.ts +304 -32
- package/lib/browser-service.js +631 -182
- package/lib/browser-service.js.map +1 -1
- package/lib/client/SettingsCard.js +95 -57
- package/lib/client/SettingsCard.js.map +1 -1
- package/lib/client/asset-editor.d.ts +55 -0
- package/lib/client/asset-editor.js +101 -0
- package/lib/client/asset-editor.js.map +1 -0
- package/lib/client/automation-assets-client.d.ts +99 -2
- package/lib/client/automation-assets-client.js +243 -10
- package/lib/client/automation-assets-client.js.map +1 -1
- package/lib/client/form.d.ts +48 -4
- package/lib/client/form.js +142 -29
- package/lib/client/form.js.map +1 -1
- package/lib/client/index.d.ts +25 -2
- package/lib/client/index.js +5 -1
- package/lib/client/index.js.map +1 -1
- package/lib/client/locales.d.ts +85 -6
- package/lib/client/locales.js +64 -12
- package/lib/client/locales.js.map +1 -1
- package/lib/client/prompts-form.d.ts +67 -0
- package/lib/client/prompts-form.js +140 -0
- package/lib/client/prompts-form.js.map +1 -0
- package/lib/client/prompts-status-client.d.ts +34 -0
- package/lib/client/prompts-status-client.js +53 -0
- package/lib/client/prompts-status-client.js.map +1 -0
- package/lib/client.js +1914 -329
- package/lib/client.js.map +1 -1
- package/lib/config.d.ts +50 -1
- package/lib/config.js +31 -1
- package/lib/config.js.map +1 -1
- package/lib/dialogs.d.ts +37 -0
- package/lib/dialogs.js +73 -0
- package/lib/dialogs.js.map +1 -0
- package/lib/freedom.d.ts +23 -7
- package/lib/freedom.js +48 -59
- package/lib/freedom.js.map +1 -1
- package/lib/index.d.ts +4 -4
- package/lib/index.js +36 -10
- package/lib/index.js.map +1 -1
- package/lib/journal.d.ts +109 -0
- package/lib/journal.js +238 -0
- package/lib/journal.js.map +1 -0
- package/lib/locator.d.ts +82 -0
- package/lib/locator.js +190 -0
- package/lib/locator.js.map +1 -0
- package/lib/observe-script.d.ts +27 -0
- package/lib/observe-script.js +565 -0
- package/lib/observe-script.js.map +1 -0
- package/lib/observe.d.ts +179 -0
- package/lib/observe.js +368 -0
- package/lib/observe.js.map +1 -0
- package/lib/policy-keys.d.ts +30 -0
- package/lib/policy-keys.js +34 -0
- package/lib/policy-keys.js.map +1 -0
- package/lib/prompt-limits.d.ts +30 -0
- package/lib/prompt-limits.js +31 -0
- package/lib/prompt-limits.js.map +1 -0
- package/lib/prompts.d.ts +131 -0
- package/lib/prompts.js +295 -0
- package/lib/prompts.js.map +1 -0
- package/lib/skill.d.ts +100 -0
- package/lib/skill.js +181 -0
- package/lib/skill.js.map +1 -0
- package/lib/tool-defs.d.ts +72 -0
- package/lib/tool-defs.js +67 -0
- package/lib/tool-defs.js.map +1 -0
- package/lib/tools.d.ts +19 -4
- package/lib/tools.js +124 -922
- package/lib/tools.js.map +1 -1
- package/package.json +5 -1
- package/scripts/dump-prompts.mjs +29 -0
- package/scripts/measure-tool-surface.mjs +190 -0
package/lib/skill.js
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The bundled `dsh-browser` skill: usage guidance for the browser tools.
|
|
3
|
+
*
|
|
4
|
+
* The skill is registered with the Host's skill registry when that service
|
|
5
|
+
* exists. It must never be a hard dependency of the plugin: Cordis 4.0.4 treats
|
|
6
|
+
* every declared `inject` as required, so a missing `skills` service would hang
|
|
7
|
+
* the whole plugin. The plugin therefore asks for it through a scoped
|
|
8
|
+
* `ctx.inject(['skills'], …)` and works the same without it.
|
|
9
|
+
* @module dsh-browser/skill
|
|
10
|
+
*/
|
|
11
|
+
import fs from 'node:fs';
|
|
12
|
+
import { fileURLToPath } from 'node:url';
|
|
13
|
+
import { SKILL_BODY_FILE_LIMIT } from "./prompt-limits.js";
|
|
14
|
+
export const SKILL_NAME = 'dsh-browser';
|
|
15
|
+
const PROVIDER_NAME = 'dsh-browser';
|
|
16
|
+
/** Same rank the Host gives packaged skills (`BUNDLED_SKILL_RANK`). */
|
|
17
|
+
const BUNDLED_SKILL_RANK = 600;
|
|
18
|
+
/** `assets/skills/dsh-browser/`, resolved next to `src/` or the built `lib/`. */
|
|
19
|
+
export const SKILL_DIR = fileURLToPath(new URL('../assets/skills/dsh-browser/', import.meta.url));
|
|
20
|
+
/** Parse `name` and `description` out of a SKILL.md and return the body without the front matter. */
|
|
21
|
+
export function parseSkillFile(raw) {
|
|
22
|
+
const match = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/.exec(raw);
|
|
23
|
+
if (!match)
|
|
24
|
+
throw new Error('SKILL.md is missing its front matter');
|
|
25
|
+
const field = (key) => {
|
|
26
|
+
const line = new RegExp(`^${key}:\\s*(.*)$`, 'm').exec(match[1]);
|
|
27
|
+
return line ? line[1].trim().replace(/^["']|["']$/g, '') : '';
|
|
28
|
+
};
|
|
29
|
+
return { name: field('name'), description: field('description'), body: match[2].replace(/^\s+/, '') };
|
|
30
|
+
}
|
|
31
|
+
export function readSkill(dir = SKILL_DIR) {
|
|
32
|
+
return parseSkillFile(fs.readFileSync(dir + 'SKILL.md', 'utf8'));
|
|
33
|
+
}
|
|
34
|
+
export { SKILL_BODY_FILE_LIMIT };
|
|
35
|
+
/**
|
|
36
|
+
* Read a replacement skill body. A leading front matter block is dropped (the name and description come from the
|
|
37
|
+
* packaged file or `prompts.skill.description`). Never throws: a missing, unreadable, empty or oversized file is
|
|
38
|
+
* reported as a reason, and the caller falls back to the packaged body.
|
|
39
|
+
*/
|
|
40
|
+
export function loadSkillBodyFile(file) {
|
|
41
|
+
let raw;
|
|
42
|
+
try {
|
|
43
|
+
raw = fs.readFileSync(file, 'utf8');
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
const code = error?.code;
|
|
47
|
+
return { ok: false, reason: code === 'ENOENT' ? `skill.bodyFile does not exist: ${file}` : `skill.bodyFile cannot be read (${code ?? 'error'}): ${file}` };
|
|
48
|
+
}
|
|
49
|
+
const front = /^---\r?\n[\s\S]*?\r?\n---\r?\n?([\s\S]*)$/.exec(raw);
|
|
50
|
+
const body = (front ? front[1] : raw).replace(/^\s+/, '');
|
|
51
|
+
if (body.trim() === '')
|
|
52
|
+
return { ok: false, reason: `skill.bodyFile is empty: ${file}` };
|
|
53
|
+
if (body.length > SKILL_BODY_FILE_LIMIT)
|
|
54
|
+
return { ok: false, reason: `skill.bodyFile is ${body.length} characters, over the limit of ${SKILL_BODY_FILE_LIMIT}: ${file}` };
|
|
55
|
+
return { ok: true, body };
|
|
56
|
+
}
|
|
57
|
+
/** What the skill says right now: the packaged file with the `prompts.skill` overrides applied. */
|
|
58
|
+
export function currentSkill(dir = SKILL_DIR, prompts) {
|
|
59
|
+
const packaged = readSkill(dir);
|
|
60
|
+
const overrides = prompts?.current().skill;
|
|
61
|
+
if (!overrides)
|
|
62
|
+
return packaged;
|
|
63
|
+
let body = packaged.body;
|
|
64
|
+
if (overrides.bodyFile) {
|
|
65
|
+
const loaded = loadSkillBodyFile(overrides.bodyFile);
|
|
66
|
+
if (loaded.ok)
|
|
67
|
+
body = loaded.body;
|
|
68
|
+
}
|
|
69
|
+
if (overrides.append)
|
|
70
|
+
body = body.replace(/\s+$/, '') + '\n\n' + overrides.append;
|
|
71
|
+
return { name: packaged.name, description: overrides.description ?? packaged.description, body };
|
|
72
|
+
}
|
|
73
|
+
/** Identifies the skill text in force, so a change (config edit or an edited body file) can be noticed. */
|
|
74
|
+
function skillSignature(prompts) {
|
|
75
|
+
const skill = prompts?.current().skill;
|
|
76
|
+
if (!skill)
|
|
77
|
+
return '';
|
|
78
|
+
let file = '';
|
|
79
|
+
if (skill.bodyFile) {
|
|
80
|
+
try {
|
|
81
|
+
const stat = fs.statSync(skill.bodyFile);
|
|
82
|
+
file = `${stat.mtimeMs}:${stat.size}`;
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
file = 'missing';
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return JSON.stringify([skill.enabled, skill.description, skill.bodyFile, skill.append, file]);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* A provider object shaped like the Host's `SkillProvider` (declared locally to avoid a build-time dependency).
|
|
92
|
+
* It reads the packaged file and the `prompts.skill` overrides on every call, so it is never stale.
|
|
93
|
+
*/
|
|
94
|
+
export function createSkillProvider(dir = SKILL_DIR, prompts) {
|
|
95
|
+
const resourceBase = { kind: 'directory', path: dir };
|
|
96
|
+
const invocation = { modelInvocable: true, userInvocable: true };
|
|
97
|
+
// Fail at creation, as before, when the packaged file is missing or malformed.
|
|
98
|
+
readSkill(dir);
|
|
99
|
+
return {
|
|
100
|
+
name: PROVIDER_NAME,
|
|
101
|
+
list: async () => {
|
|
102
|
+
const skill = currentSkill(dir, prompts);
|
|
103
|
+
return [{
|
|
104
|
+
name: skill.name,
|
|
105
|
+
description: skill.description,
|
|
106
|
+
invocation,
|
|
107
|
+
provider: PROVIDER_NAME,
|
|
108
|
+
source: 'bundled',
|
|
109
|
+
resourceBase,
|
|
110
|
+
rank: BUNDLED_SKILL_RANK,
|
|
111
|
+
locator: dir + 'SKILL.md',
|
|
112
|
+
}];
|
|
113
|
+
},
|
|
114
|
+
// Re-read on each load so edits to the packaged file are never stale.
|
|
115
|
+
get: async () => {
|
|
116
|
+
const current = currentSkill(dir, prompts);
|
|
117
|
+
return { name: current.name, description: current.description, invocation, provider: PROVIDER_NAME, source: 'bundled', resourceBase, content: current.body };
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Register the skill when the Host provides a skill registry, and track whether
|
|
123
|
+
* it is registered so the index can fall back to its compact guide otherwise.
|
|
124
|
+
* With `prompts.skill.enabled=false` nothing is registered.
|
|
125
|
+
*/
|
|
126
|
+
export function registerSkillWhenAvailable(ctx, dir = SKILL_DIR, prompts) {
|
|
127
|
+
let available = false;
|
|
128
|
+
let sync = () => { };
|
|
129
|
+
ctx.inject(['skills'], (skillCtx) => {
|
|
130
|
+
let provider;
|
|
131
|
+
try {
|
|
132
|
+
provider = createSkillProvider(dir, prompts);
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
skillCtx.logger?.(PROVIDER_NAME)?.warn?.('dsh-browser skill not registered: ' + String(error));
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
let unregister;
|
|
139
|
+
let invalidate;
|
|
140
|
+
let signature = '';
|
|
141
|
+
let alive = true;
|
|
142
|
+
const register = () => {
|
|
143
|
+
const handle = skillCtx.skills.registerProvider((control) => {
|
|
144
|
+
invalidate = control?.invalidate?.bind(control);
|
|
145
|
+
return provider;
|
|
146
|
+
});
|
|
147
|
+
unregister = typeof handle === 'function' ? handle : () => { };
|
|
148
|
+
available = true;
|
|
149
|
+
};
|
|
150
|
+
const withdraw = () => {
|
|
151
|
+
try {
|
|
152
|
+
unregister?.();
|
|
153
|
+
}
|
|
154
|
+
catch { /* the Host may already have dropped it */ }
|
|
155
|
+
unregister = undefined;
|
|
156
|
+
invalidate = undefined;
|
|
157
|
+
available = false;
|
|
158
|
+
};
|
|
159
|
+
sync = () => {
|
|
160
|
+
if (!alive)
|
|
161
|
+
return;
|
|
162
|
+
const enabled = prompts?.current().skill.enabled !== false;
|
|
163
|
+
const next = skillSignature(prompts);
|
|
164
|
+
if (enabled && !available)
|
|
165
|
+
register();
|
|
166
|
+
else if (!enabled && available)
|
|
167
|
+
withdraw();
|
|
168
|
+
else if (available && next !== signature) {
|
|
169
|
+
try {
|
|
170
|
+
invalidate?.();
|
|
171
|
+
}
|
|
172
|
+
catch { /* a stale handle is harmless */ }
|
|
173
|
+
}
|
|
174
|
+
signature = next;
|
|
175
|
+
};
|
|
176
|
+
sync();
|
|
177
|
+
skillCtx.effect?.(() => () => { alive = false; withdraw(); });
|
|
178
|
+
});
|
|
179
|
+
return { isAvailable: () => available, refresh: () => sync() };
|
|
180
|
+
}
|
|
181
|
+
//# sourceMappingURL=skill.js.map
|
package/lib/skill.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill.js","sourceRoot":"","sources":["../src/skill.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAGxC,OAAO,EAAE,qB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AA;QACnB,CAAC,CAAA;QACD,IAAI,GAAG,GAAG,EAAE;YACV,IAAI,CAAC,KAAK;gBAAE,OAAM;YAClB,MAAM,OAAO,GAAG,OAAO,EAAE,OAAO,EAAE,CAAC,KAAK,CAAC,OAAO,KAAK,KAAK,CAAA;YAC1D,MAAM,IAAI,GAAG,cAAc,CAAC,OAAO,CAAC,CAAA;YACpC,IAAI,OAAO,IAAI,CAAC,SAAS;gBAAE,QAAQ,EAAE,CAAA;iBAChC,IAAI,CAAC,OAAO,IAAI,SAAS;gBAAE,QAAQ,EAAE,CAAA;iBACrC,IAAI,SAAS,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;gBAAC,IAAI,CAAC;oBAAC,UAAU,EAAE,EAAE,CAAA;gBAAC,CAAC;gBAAC,MAAM,CAAC,CAAC,gCAAgC,CAAC,CAAC;YAAC,CAAC;YAC/G,SAAS,GAAG,IAAI,CAAA;QAClB,CAAC,CAAA;QACD,IAAI,EAAE,CAAA;QACN,QAAQ,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,GAAG,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAA,CAAC,CAAC,CAAC,CAAA;IAC9D,CAAC,CAAC,CAAA;IACF,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,SAAS,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,CAAA;AAChE,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The model-facing definitions of the two `indexed` tools (L0): name, description and parameter schema.
|
|
3
|
+
*
|
|
4
|
+
* Kept apart from `tools.ts` so the plugin registers them, the budget check measures them, and
|
|
5
|
+
* `prompts:dump` lists their defaults from one definition. Only the description is configurable
|
|
6
|
+
* (`prompts.tools.<name>.description`); the parameter schema is structural and fixed.
|
|
7
|
+
* @module dsh-browser/tool-defs
|
|
8
|
+
*/
|
|
9
|
+
/** Default `browser_index` description. */
|
|
10
|
+
export declare const DEFAULT_INDEX_DESCRIPTION = "Browser capability index. No args: groups and environment state. {group}: that group's actions. {action}: one action's full schema. {query}: keyword search.";
|
|
11
|
+
/**
|
|
12
|
+
* Default `browser_call` description, WITHOUT the compliance notice. The notice is appended to whatever
|
|
13
|
+
* description is in force (configured or default): it states who is responsible for how the capability is used,
|
|
14
|
+
* so a deployment can reword the guidance around it but cannot drop it.
|
|
15
|
+
*/
|
|
16
|
+
export declare const DEFAULT_CALL_DESCRIPTION = "Run one browser action; browser_index shows the names. Args are validated server-side: INVALID_ARGS replies include the schema. Reply: {ok, action, executionStatus, result | error{code,message,hint}}.";
|
|
17
|
+
export declare const INDEX_PARAMETERS: {
|
|
18
|
+
readonly group: {
|
|
19
|
+
readonly type: "string";
|
|
20
|
+
readonly description: "Group name, e.g. act.";
|
|
21
|
+
};
|
|
22
|
+
readonly action: {
|
|
23
|
+
readonly type: "string";
|
|
24
|
+
readonly description: "Action name, e.g. act.click.";
|
|
25
|
+
};
|
|
26
|
+
readonly query: {
|
|
27
|
+
readonly type: "string";
|
|
28
|
+
readonly description: "Keywords.";
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export declare const CALL_PARAMETERS: {
|
|
32
|
+
readonly action: {
|
|
33
|
+
readonly type: "string";
|
|
34
|
+
readonly required: true;
|
|
35
|
+
readonly description: "Action name, e.g. target.open.";
|
|
36
|
+
};
|
|
37
|
+
readonly args: {
|
|
38
|
+
readonly type: "object";
|
|
39
|
+
readonly additionalProperties: true;
|
|
40
|
+
readonly description: "Arguments for the action.";
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
/** The two overridable tool names. */
|
|
44
|
+
export declare const PROMPT_TOOL_NAMES: readonly ["browser_index", "browser_call"];
|
|
45
|
+
export type PromptToolName = typeof PROMPT_TOOL_NAMES[number];
|
|
46
|
+
export declare function indexDescription(override?: string): string;
|
|
47
|
+
export declare function callDescription(override?: string): string;
|
|
48
|
+
/** One tool as the host sends it to the model. */
|
|
49
|
+
export interface ModelFacingTool {
|
|
50
|
+
name: string;
|
|
51
|
+
description: string;
|
|
52
|
+
parameters: unknown;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* What the host sends to the model for the two indexed tools (name + description + parameters).
|
|
56
|
+
* The parameters are the JSON Schema form (`type`/`properties`/`required`), which is what is registered and what the
|
|
57
|
+
* model is billed for, not the shorthand map the tools are declared with.
|
|
58
|
+
*/
|
|
59
|
+
export declare function indexedToolDefinitions(overrides?: {
|
|
60
|
+
browser_index?: string;
|
|
61
|
+
browser_call?: string;
|
|
62
|
+
}): ModelFacingTool[];
|
|
63
|
+
/** Characters per token of the surface estimate. */
|
|
64
|
+
export declare const CHARS_PER_TOKEN = 3.5;
|
|
65
|
+
/** Estimated tokens of a character count. The one rounding rule for the settings card, `runtime.status` and the measure script. */
|
|
66
|
+
export declare function estimateTokens(chars: number): number;
|
|
67
|
+
/** Serialized size of tools as the host sends them: the one input of every L0 estimate. */
|
|
68
|
+
export declare function modelFacingChars(tools: readonly {
|
|
69
|
+
name: string;
|
|
70
|
+
description?: unknown;
|
|
71
|
+
parameters?: unknown;
|
|
72
|
+
}[]): number;
|
package/lib/tool-defs.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The model-facing definitions of the two `indexed` tools (L0): name, description and parameter schema.
|
|
3
|
+
*
|
|
4
|
+
* Kept apart from `tools.ts` so the plugin registers them, the budget check measures them, and
|
|
5
|
+
* `prompts:dump` lists their defaults from one definition. Only the description is configurable
|
|
6
|
+
* (`prompts.tools.<name>.description`); the parameter schema is structural and fixed.
|
|
7
|
+
* @module dsh-browser/tool-defs
|
|
8
|
+
*/
|
|
9
|
+
import { CALL_TOOL, INDEX_TOOL } from "./actions/registry.js";
|
|
10
|
+
import { COMPLIANCE_NOTICE } from "./actions/shared.js";
|
|
11
|
+
/** Default `browser_index` description. */
|
|
12
|
+
export const DEFAULT_INDEX_DESCRIPTION = 'Browser capability index. No args: groups and environment state. {group}: that group\'s actions. {action}: one action\'s full schema. {query}: keyword search.';
|
|
13
|
+
/**
|
|
14
|
+
* Default `browser_call` description, WITHOUT the compliance notice. The notice is appended to whatever
|
|
15
|
+
* description is in force (configured or default): it states who is responsible for how the capability is used,
|
|
16
|
+
* so a deployment can reword the guidance around it but cannot drop it.
|
|
17
|
+
*/
|
|
18
|
+
export const DEFAULT_CALL_DESCRIPTION = 'Run one browser action; browser_index shows the names. Args are validated server-side: INVALID_ARGS replies include the schema. Reply: {ok, action, executionStatus, result | error{code,message,hint}}.';
|
|
19
|
+
export const INDEX_PARAMETERS = {
|
|
20
|
+
group: { type: 'string', description: 'Group name, e.g. act.' },
|
|
21
|
+
action: { type: 'string', description: 'Action name, e.g. act.click.' },
|
|
22
|
+
query: { type: 'string', description: 'Keywords.' },
|
|
23
|
+
};
|
|
24
|
+
export const CALL_PARAMETERS = {
|
|
25
|
+
action: { type: 'string', required: true, description: 'Action name, e.g. target.open.' },
|
|
26
|
+
args: { type: 'object', additionalProperties: true, description: 'Arguments for the action.' },
|
|
27
|
+
};
|
|
28
|
+
/** The two overridable tool names. */
|
|
29
|
+
export const PROMPT_TOOL_NAMES = [INDEX_TOOL, CALL_TOOL];
|
|
30
|
+
export function indexDescription(override) {
|
|
31
|
+
return override ?? DEFAULT_INDEX_DESCRIPTION;
|
|
32
|
+
}
|
|
33
|
+
export function callDescription(override) {
|
|
34
|
+
return `${(override ?? DEFAULT_CALL_DESCRIPTION).trimEnd()} ${COMPLIANCE_NOTICE}`;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The JSON Schema `defineTool` produces from a parameter shorthand map: `required: true` moves to a `required` list.
|
|
38
|
+
* Kept here, not imported, so the budget code does not need the tool runtime; test/l0-estimate.test.ts holds it equal
|
|
39
|
+
* to what `defineTool` really registers.
|
|
40
|
+
*/
|
|
41
|
+
function jsonSchemaOf(shorthand) {
|
|
42
|
+
const properties = Object.fromEntries(Object.entries(shorthand).map(([name, spec]) => [name, Object.fromEntries(Object.entries(spec).filter(([key]) => key !== 'required'))]));
|
|
43
|
+
const required = Object.entries(shorthand).filter(([, spec]) => spec.required === true).map(([name]) => name);
|
|
44
|
+
return { type: 'object', properties, ...required.length ? { required } : {} };
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* What the host sends to the model for the two indexed tools (name + description + parameters).
|
|
48
|
+
* The parameters are the JSON Schema form (`type`/`properties`/`required`), which is what is registered and what the
|
|
49
|
+
* model is billed for, not the shorthand map the tools are declared with.
|
|
50
|
+
*/
|
|
51
|
+
export function indexedToolDefinitions(overrides = {}) {
|
|
52
|
+
return [
|
|
53
|
+
{ name: INDEX_TOOL, description: indexDescription(overrides.browser_index), parameters: jsonSchemaOf(INDEX_PARAMETERS) },
|
|
54
|
+
{ name: CALL_TOOL, description: callDescription(overrides.browser_call), parameters: jsonSchemaOf(CALL_PARAMETERS) },
|
|
55
|
+
];
|
|
56
|
+
}
|
|
57
|
+
/** Characters per token of the surface estimate. */
|
|
58
|
+
export const CHARS_PER_TOKEN = 3.5;
|
|
59
|
+
/** Estimated tokens of a character count. The one rounding rule for the settings card, `runtime.status` and the measure script. */
|
|
60
|
+
export function estimateTokens(chars) {
|
|
61
|
+
return Math.round(chars / CHARS_PER_TOKEN);
|
|
62
|
+
}
|
|
63
|
+
/** Serialized size of tools as the host sends them: the one input of every L0 estimate. */
|
|
64
|
+
export function modelFacingChars(tools) {
|
|
65
|
+
return tools.reduce((sum, tool) => sum + JSON.stringify({ name: tool.name, description: tool.description, parameters: tool.parameters }).length, 0);
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=tool-defs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-defs.js","sourceRoot":"","sources":["../src/tool-defs.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAC7D,O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9G,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;AACrJ,CAAC"}
|
package/lib/tools.d.ts
CHANGED
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Model-facing
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Model-facing tool surfaces for dsh-browser.
|
|
3
|
+
*
|
|
4
|
+
* Every capability is an action in the registry (`src/actions/`). This module
|
|
5
|
+
* only projects that registry into tools:
|
|
6
|
+
*
|
|
7
|
+
* - `indexed` (default): two small tools, `browser_index` for progressive
|
|
8
|
+
* disclosure and `browser_call` to run an action. Constant, tiny context cost.
|
|
9
|
+
* - `flat`: one tool per usable action, named `browser_<group>_<action>`.
|
|
10
|
+
* Every action is described up front; useful for comparison and debugging.
|
|
11
|
+
*
|
|
12
|
+
* Both surfaces dispatch through the same {@link runAction}, so validation,
|
|
13
|
+
* the result envelope, and the error codes are identical.
|
|
5
14
|
* @module dsh-browser/tools
|
|
6
15
|
*/
|
|
7
16
|
import type { Context } from '@deepseek-ai/cordis';
|
|
8
17
|
import type { ResolvedConfig } from './config.ts';
|
|
9
18
|
import type { BrowserService } from './browser-service.ts';
|
|
10
19
|
import type { AutomationAssetStore } from './automation-assets.ts';
|
|
11
|
-
export
|
|
20
|
+
export interface ToolRuntime {
|
|
21
|
+
/** Whether the `dsh-browser` skill is currently registered; read at call time. */
|
|
22
|
+
skillAvailable?: () => boolean;
|
|
23
|
+
/** Bring the skill registration in line with the current `prompts.skill` (called at the start of each index/call). */
|
|
24
|
+
refreshSkill?: () => void;
|
|
25
|
+
}
|
|
26
|
+
export declare function registerTools(ctx: Context, config: ResolvedConfig, service: BrowserService, assets?: AutomationAssetStore, runtime?: ToolRuntime): void;
|