osborn 0.9.290 → 0.9.292
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/.claude/skills/browser-apply/SKILL.md +5 -4
- package/.claude/skills/browser-apply/candidate.example.env +4 -1
- package/.claude/skills/browser-apply/fill.mjs +13 -2
- package/.claude/skills/meetings/SKILL.md +26 -7
- package/.env.example +6 -0
- package/dist/agent-store.d.ts +6 -0
- package/dist/agent-store.js +36 -6
- package/dist/approval-policy.d.ts +99 -0
- package/dist/approval-policy.js +196 -0
- package/dist/claude-llm.d.ts +6 -2
- package/dist/claude-llm.js +68 -20
- package/dist/config.d.ts +12 -16
- package/dist/config.js +75 -21
- package/dist/content/compaction-lens-worker.d.ts +5 -0
- package/dist/content/compaction-lens-worker.js +78 -7
- package/dist/content/content-llm.d.ts +14 -3
- package/dist/content/content-llm.js +33 -142
- package/dist/content/lens-db.d.ts +16 -5
- package/dist/content/lens-db.js +58 -11
- package/dist/content/lens-ingest.d.ts +1 -0
- package/dist/content/lens-ingest.js +1 -1
- package/dist/content/lens-launch.d.ts +42 -1
- package/dist/content/lens-launch.js +202 -40
- package/dist/content/lens-library-digest.d.ts +85 -0
- package/dist/content/lens-library-digest.js +305 -0
- package/dist/content/lens-library-index.d.ts +14 -3
- package/dist/content/lens-library-index.js +35 -8
- package/dist/content/lens-library-select.d.ts +1 -1
- package/dist/content/lens-library-select.js +1 -1
- package/dist/content/lens-library-sweep.d.ts +36 -0
- package/dist/content/lens-library-sweep.js +331 -0
- package/dist/content/lens-library.d.ts +29 -0
- package/dist/content/lens-library.js +130 -20
- package/dist/content/lens-model.d.ts +4 -0
- package/dist/content/lens-model.js +5 -0
- package/dist/content/lens-paths.d.ts +72 -0
- package/dist/content/lens-paths.js +248 -5
- package/dist/content/period-run.js +2 -2
- package/dist/content/secret-rules.d.ts +51 -0
- package/dist/content/secret-rules.js +185 -0
- package/dist/content/transcript-sanitizer.d.ts +1 -41
- package/dist/content/transcript-sanitizer.js +4 -171
- package/dist/data-sender-auth.d.ts +112 -3
- package/dist/data-sender-auth.js +165 -39
- package/dist/env-keys.d.ts +10 -2
- package/dist/env-keys.js +26 -5
- package/dist/index.js +616 -109
- package/dist/phone-code.d.ts +76 -0
- package/dist/phone-code.js +124 -0
- package/dist/phone-voice-actions.d.ts +132 -0
- package/dist/phone-voice-actions.js +223 -0
- package/dist/pipeline-direct-llm.d.ts +8 -1
- package/dist/pipeline-direct-llm.js +13 -1
- package/dist/prompts/library-digest.md +11 -0
- package/dist/prompts.d.ts +4 -0
- package/dist/prompts.js +6 -2
- package/dist/pushover.d.ts +2 -1
- package/dist/pushover.js +7 -6
- package/dist/risk-tier.d.ts +14 -0
- package/dist/risk-tier.js +140 -0
- package/dist/session-store.d.ts +1 -0
- package/dist/session-store.js +3 -2
- package/dist/session-switch.d.ts +22 -7
- package/dist/session-switch.js +58 -24
- package/dist/steward-verdict.d.ts +16 -3
- package/dist/steward-verdict.js +37 -18
- package/dist/watch-gateway.js +3 -1
- package/package.json +1 -1
- package/dist/bridge-llm.d.ts +0 -22
- package/dist/bridge-llm.js +0 -39
- package/dist/codex-handler.d.ts +0 -38
- package/dist/codex-handler.js +0 -83
- package/dist/codex-llm.d.ts +0 -40
- package/dist/codex-llm.js +0 -144
- package/dist/fast-brain.d.ts +0 -176
- package/dist/fast-brain.js +0 -1887
- package/dist/index-3-2-26-legacy.d.ts +0 -1
- package/dist/index-3-2-26-legacy.js +0 -2233
- package/dist/leagcyprompts2.d.ts +0 -0
- package/dist/leagcyprompts2.js +0 -573
- package/dist/prompts-2-25-26.d.ts +0 -0
- package/dist/prompts-2-25-26.js +0 -518
- package/dist/prompts-3-2-26.d.ts +0 -78
- package/dist/prompts-3-2-26.js +0 -1319
- package/dist/summary-index.d.ts +0 -90
- package/dist/summary-index.js +0 -585
|
@@ -31,7 +31,7 @@ This approach catches rendering issues, unexpected fields, and errors before the
|
|
|
31
31
|
|
|
32
32
|
Candidate values (email, password, phone, address, work history, education) are filled by the `fill.mjs` helper, not by the MCP tools. The helper and the Playwright MCP must drive the SAME browser, which means both attach to one Chrome over CDP on loopback.
|
|
33
33
|
|
|
34
|
-
1. Secret file. The user creates it and types the values in their own editor
|
|
34
|
+
1. Secret file. The user creates it in their own terminal and types the values in their own editor. Whatever is in it is submitted to employers as the user's record, so you never create, copy, write or edit it: not with `cp`, `touch`, `tee`, `echo`/`printf`, a heredoc, `Write` or `Edit`, and not with placeholders. That holds even when the user tells you their jobs, schools or dates in conversation, or asks you to "just put them in": a detail spoken in chat is not a checked record. Say plainly that whatever goes in the file is what employers receive, give them these commands to run themselves, and wait:
|
|
35
35
|
```bash
|
|
36
36
|
mkdir -p ~/.osborn
|
|
37
37
|
cp ~/.claude/skills/browser-apply/candidate.example.env ~/.osborn/candidate.env
|
|
@@ -53,7 +53,8 @@ Candidate values (email, password, phone, address, work history, education) are
|
|
|
53
53
|
|
|
54
54
|
### Step 0 — Check the helper, then open the browser
|
|
55
55
|
Run `node ~/.claude/skills/browser-apply/fill.mjs check` first. It prints variable names (including an `extra:` line listing every other `CANDIDATE_*` key the user set — work history, education, anything else) and `cdp: reachable` or `cdp: unreachable`, never values.
|
|
56
|
-
- File missing / refused: point the user at "One-time setup" step 1 and wait.
|
|
56
|
+
- File missing / refused: point the user at "One-time setup" step 1 and wait. Do not create the file yourself, from the template or from anything said in the conversation.
|
|
57
|
+
- Show the user the `set:`, `extra:` and `placeholder:` lines before the first fill (names only) and ask them to confirm that list is exactly what they meant to set; a misspelled key shows up there as an unexpected name. A key under `placeholder:` still holds the template value: it counts as unset, the helper refuses to fill it, and only the user replaces it.
|
|
57
58
|
- `cdp: unreachable`: you can still navigate and click with the MCP tools, but every value from the secret file — email, password, phone, address, and every work-history and education field — must be typed by the user themselves. You have no copy of any of them; do not reconstruct one.
|
|
58
59
|
|
|
59
60
|
Use: `mcp__playwright__browser_navigate` with the applyManually URL
|
|
@@ -159,9 +160,9 @@ node ~/.claude/skills/browser-apply/fill.mjs fill --confirm-host acme.wd1.mywork
|
|
|
159
160
|
Rules:
|
|
160
161
|
- NEVER `cat`, `less`, `head`, `echo`, `printenv`, `env`, `grep`, `Read` or otherwise print the secret file or the `CANDIDATE_*` variables.
|
|
161
162
|
- NEVER pass a value to an MCP browser tool or put one in a command line; pass env NAMES only.
|
|
162
|
-
- If `check` reports the file missing or too open, tell the user to create it from `candidate.example.env` and run `chmod 600
|
|
163
|
+
- If `check` reports the file missing or too open, tell the user to create it from `candidate.example.env` and run `chmod 600` themselves; do not create, copy or `chmod` it yourself.
|
|
163
164
|
- If `check` says `cdp: unreachable`, or `fill` refuses (no browser, wrong host, wrong field type), do not work around it: ask the user to type the secret fields themselves.
|
|
164
|
-
- Never edit `~/.osborn/candidate.env
|
|
165
|
+
- Never create or edit `~/.osborn/candidate.env`, and never turn details from the conversation (what the user said, a résumé, a repo, an earlier application) into its contents. Only the user writes its values or its `CANDIDATE_CDP_URL` line. If they want an entry added, they add it; you ask and wait.
|
|
165
166
|
- Never reuse an earlier confirmation for a different host or a later fill; ask again each time.
|
|
166
167
|
|
|
167
168
|
## Workday data-automation-id Selector Reference
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# browser-apply candidate data. PLACEHOLDERS ONLY: never commit real values.
|
|
2
2
|
# Copy to ~/.osborn/candidate.env (fixed path), fill it in yourself, then: chmod 600 ~/.osborn/candidate.env
|
|
3
|
+
# Only you write this file: whatever is in it is submitted to employers as your record. The
|
|
4
|
+
# assistant is instructed never to create or edit it, even from details you tell it in conversation.
|
|
5
|
+
# A value still left as a placeholder below is treated as unset and is never filled.
|
|
3
6
|
# The fill.mjs helper refuses the file if it is a symlink, not yours, or readable by group or other.
|
|
4
7
|
# It reads no environment variables; this file is its only input.
|
|
5
8
|
CANDIDATE_EMAIL=you@example.com
|
|
@@ -14,7 +17,7 @@ CANDIDATE_ZIP=YOUR_ZIP
|
|
|
14
17
|
|
|
15
18
|
# Work history. The skill ships NO employment values: if a job is not here, the
|
|
16
19
|
# model must ask you instead of filling anything. Number the entries from 1 and
|
|
17
|
-
# add as many as you need (
|
|
20
|
+
# add as many as you need (JOB_2, JOB_3, …); delete the ones you do not use.
|
|
18
21
|
CANDIDATE_JOB_1_TITLE=YOUR_JOB_TITLE
|
|
19
22
|
CANDIDATE_JOB_1_COMPANY=YOUR_EMPLOYER
|
|
20
23
|
CANDIDATE_JOB_1_START=YOUR_START_DATE
|
|
@@ -39,6 +39,11 @@ export const EXPECTED_VARS = [
|
|
|
39
39
|
export const CONFIG_KEYS = ['CANDIDATE_CDP_URL']
|
|
40
40
|
export const DEFAULT_CDP_URL = 'http://127.0.0.1:9222'
|
|
41
41
|
const LOOPBACK_HOSTS = new Set(['127.0.0.1', 'localhost', '::1', '[::1]'])
|
|
42
|
+
// The placeholder values candidate.example.env ships with. A file copied from the template and not
|
|
43
|
+
// filled in would otherwise type "YOUR_EMPLOYER" into a real application, so such a key counts as
|
|
44
|
+
// unset: check lists it under `placeholder:` and fill refuses it.
|
|
45
|
+
const TEMPLATE_PLACEHOLDER_RE = /^(YOUR_[A-Za-z0-9_]*|WHAT_YOU_DID|you@example\.com)$/
|
|
46
|
+
export const isTemplatePlaceholder = (v) => TEMPLATE_PLACEHOLDER_RE.test(String(v ?? '').trim())
|
|
42
47
|
|
|
43
48
|
/** Fixed secret-file path. Uses the passwd home directory so $HOME cannot redirect it. */
|
|
44
49
|
export function secretPath() {
|
|
@@ -241,6 +246,7 @@ export async function runFill(args, fileEnv, deps = {}) {
|
|
|
241
246
|
for (const [name] of pairs) {
|
|
242
247
|
if (!/^CANDIDATE_[A-Z0-9_]+$/.test(name) || CONFIG_KEYS.includes(name)) throw new Error(`only CANDIDATE_* values may be filled: ${name.slice(0, 40)}`)
|
|
243
248
|
if (!fileEnv[name]) throw new Error(`${name} is not set in the secret file`)
|
|
249
|
+
if (isTemplatePlaceholder(fileEnv[name])) throw new Error(`${name} still holds the template placeholder; ask the user to replace it in the secret file themselves`)
|
|
244
250
|
}
|
|
245
251
|
// Validate the target before loading Playwright or opening any connection.
|
|
246
252
|
const cdp = cdpFrom(fileEnv)
|
|
@@ -266,18 +272,23 @@ export async function runFill(args, fileEnv, deps = {}) {
|
|
|
266
272
|
|
|
267
273
|
/** check command output lines (names and config only, never values). */
|
|
268
274
|
export async function checkReport(path, fileEnv, fetchImpl = fetch) {
|
|
269
|
-
const
|
|
275
|
+
const real = k => fileEnv[k] && !isTemplatePlaceholder(fileEnv[k])
|
|
276
|
+
const set = EXPECTED_VARS.filter(real)
|
|
270
277
|
const missing = EXPECTED_VARS.filter(k => !fileEnv[k])
|
|
278
|
+
const placeholder = Object.keys(fileEnv)
|
|
279
|
+
.filter(k => k.startsWith('CANDIDATE_') && !CONFIG_KEYS.includes(k) && fileEnv[k] && isTemplatePlaceholder(fileEnv[k]))
|
|
280
|
+
.sort()
|
|
271
281
|
const cdp = cdpFrom(fileEnv)
|
|
272
282
|
// Anything else the user put in the file: work history, education, and any
|
|
273
283
|
// key a future form needs. Per-entry and open-ended, so deliberately not in
|
|
274
284
|
// EXPECTED_VARS (one job and no degree must not read as "missing"); listed by
|
|
275
285
|
// NAME so the model can see what it may fill and never invents an employer.
|
|
276
286
|
const extra = Object.keys(fileEnv)
|
|
277
|
-
.filter(k => k.startsWith('CANDIDATE_') &&
|
|
287
|
+
.filter(k => k.startsWith('CANDIDATE_') && real(k) && !EXPECTED_VARS.includes(k) && !CONFIG_KEYS.includes(k))
|
|
278
288
|
.sort()
|
|
279
289
|
const lines = [`ok: ${path} is a regular file owned by you, mode 600`, `set: ${set.join(', ') || '(none)'}`]
|
|
280
290
|
if (missing.length) lines.push(`missing: ${missing.join(', ')}`)
|
|
291
|
+
if (placeholder.length) lines.push(`placeholder: ${placeholder.join(', ')} (still the template value; only the user may replace them, never fill or edit them yourself)`)
|
|
281
292
|
lines.push(`extra: ${extra.join(', ') || '(none — ask the user for any work history, education or other field the form needs)'}`)
|
|
282
293
|
lines.push(`cdp: ${(await probeCdp(cdp, fetchImpl)) ? 'reachable' : 'unreachable'} (${cdp})`)
|
|
283
294
|
return lines
|
|
@@ -64,7 +64,9 @@ curl -sS -X POST http://localhost:8741/canvas -H 'Content-Type: application/json
|
|
|
64
64
|
-d '{"kind":"show","mode":"notes","title":"...","items":["...","..."]}'
|
|
65
65
|
```
|
|
66
66
|
`mode` = `idle` | `notes` (title+items) | `link` (url) | `web` (iframe url) | `text` (title+text)
|
|
67
|
-
| `stream` (url — renders `<img src="{url}/stream">`, a live MJPEG browser feed
|
|
67
|
+
| `stream` (url — renders `<img src="{url}/stream">`, a live MJPEG browser feed;
|
|
68
|
+
the engine shows only a tab its driver cast with `/tab {"op":"cast","i":n}`, else
|
|
69
|
+
"Nothing is being shared" — cast first).
|
|
68
70
|
|
|
69
71
|
**`stream` mode — NO TUNNELS policy:** the feed URL must be PUBLIC. Never
|
|
70
72
|
tunnel a local browser engine to get one (ngrok's free tier burned its entire
|
|
@@ -119,14 +121,31 @@ flip the canvas to `link`/`web` mode — that silently replaces the live browser
|
|
|
119
121
|
feed with a static card (observed failure 2026-08-01: "PULLING UP youtube.com"
|
|
120
122
|
card replaced the stream).
|
|
121
123
|
|
|
122
|
-
|
|
124
|
+
The engine's public feed shows ONLY a tab its owner cast, so set the cast up
|
|
125
|
+
once per meeting, always with the same driver id (`x-driver-id: meeting`).
|
|
126
|
+
Tab 0 (the voice room) cannot be cast (409 `room_tab`), nor can other drivers'
|
|
127
|
+
tabs (409 `not_your_tab`). Needs `OSBORN_ENGINE_TOKEN` env.
|
|
123
128
|
```bash
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
129
|
+
E=https://osborn-voice-e2e-n.fly.dev:8781
|
|
130
|
+
H=(-H "x-engine-token: $OSBORN_ENGINE_TOKEN" -H 'Content-Type: application/json' -H 'x-driver-id: meeting')
|
|
131
|
+
# 1. Open your own tab. The reply's activeTab.i is its index.
|
|
132
|
+
curl -sS -X POST "$E/tab" "${H[@]}" -d '{"op":"open","url":"https://example.com","reuse":false}'
|
|
133
|
+
# 2. Cast that index: the bot camera now shows it.
|
|
134
|
+
curl -sS -X POST "$E/tab" "${H[@]}" -d '{"op":"cast","i":<activeTab.i>}'
|
|
135
|
+
# 3. Put the canvas in stream mode (once).
|
|
136
|
+
curl -sS -X POST http://localhost:8741/canvas -H 'Content-Type: application/json' \
|
|
137
|
+
-d '{"kind":"show","mode":"stream","url":"https://osborn-voice-e2e-n.fly.dev"}'
|
|
138
|
+
```
|
|
139
|
+
**Drive the cast tab** with the same headers, in one Bash call:
|
|
140
|
+
```bash
|
|
141
|
+
curl -sS -X POST "$E/act" "${H[@]}" -d '{"instruction":"go to youtube.com"}'
|
|
142
|
+
curl -sS -X POST "$E/tab" "${H[@]}" -d '{"op":"navigate","url":"https://youtube.com"}' # no "i": your tab
|
|
127
143
|
```
|
|
128
|
-
|
|
129
|
-
|
|
144
|
+
Do NOT `/tab open` another tab for a new site: the cast stays on the old tab.
|
|
145
|
+
Navigate the cast tab instead (or cast the new tab's index). If a person takes
|
|
146
|
+
control of the tab, the cast stops; cast it again after they hand it back.
|
|
147
|
+
When the demo is over: `curl -sS -X POST "$E/tab" "${H[@]}" -d '{"op":"uncast"}'`.
|
|
148
|
+
The cast keeps showing a REAL browser doing the thing — that's the product.
|
|
130
149
|
|
|
131
150
|
If `OSBORN_ENGINE_TOKEN` isn't set, SAY so ("I can't reach the browser engine
|
|
132
151
|
from here — the engine token isn't configured on this machine") instead of
|
package/.env.example
CHANGED
|
@@ -13,6 +13,12 @@ OPENAI_API_KEY=sk-...
|
|
|
13
13
|
# Get your key at: https://aistudio.google.com/apikey
|
|
14
14
|
GOOGLE_API_KEY=AIzaSy...
|
|
15
15
|
|
|
16
|
+
# Soniox (required: default speech-to-text and voice for the pipeline)
|
|
17
|
+
# Get your key at: https://console.soniox.com
|
|
18
|
+
SONIOX_API_KEY=your-soniox-key
|
|
19
|
+
# Deepgram is only needed if you set OSBORN_STT_PROVIDER / OSBORN_TTS_PROVIDER=deepgram
|
|
20
|
+
# DEEPGRAM_API_KEY=your-deepgram-key
|
|
21
|
+
|
|
16
22
|
# Anthropic (required for Claude Agent SDK + Fast Brain)
|
|
17
23
|
ANTHROPIC_API_KEY=sk-ant-...
|
|
18
24
|
|
package/dist/agent-store.d.ts
CHANGED
|
@@ -143,6 +143,12 @@ export declare function parseFrontMatter(md: string): {
|
|
|
143
143
|
meta: Record<string, unknown>;
|
|
144
144
|
body: string;
|
|
145
145
|
};
|
|
146
|
+
/** A SKILL.md body's first `# ` heading outside fenced code (a template inside a fence
|
|
147
|
+
* is not the skill's title), less a leading "Skill:", and the paragraph line after it. */
|
|
148
|
+
export declare function skillHeading(body: string): {
|
|
149
|
+
title?: string;
|
|
150
|
+
paragraph?: string;
|
|
151
|
+
};
|
|
146
152
|
/** Folder names of the skills shipped with the package. */
|
|
147
153
|
export declare function coreSkillNames(pkgSkillsDir: string): Set<string>;
|
|
148
154
|
export declare function skillForkedFrom(skillsDir: string, folder: string): string | undefined;
|
package/dist/agent-store.js
CHANGED
|
@@ -112,12 +112,14 @@ export function parseUserAgents(rows, core) {
|
|
|
112
112
|
continue;
|
|
113
113
|
const reason = !name ? 'no name'
|
|
114
114
|
: Object.hasOwn(core, name) ? 'is a core agent (fork it under a new name)'
|
|
115
|
-
:
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
115
|
+
// Hardening against a hand-made set_agents message: the DB (migration 004) already keeps names unique and normalised.
|
|
116
|
+
: Object.hasOwn(agents, name) ? 'same name as another of your agents (rename one)'
|
|
117
|
+
: name.length > AGENT_LIMITS.name ? `name longer than ${AGENT_LIMITS.name}`
|
|
118
|
+
: !description ? 'no description'
|
|
119
|
+
: description.length > AGENT_LIMITS.description ? `description longer than ${AGENT_LIMITS.description}`
|
|
120
|
+
: !prompt ? 'no prompt'
|
|
121
|
+
: prompt.length > AGENT_LIMITS.prompt ? `prompt longer than ${AGENT_LIMITS.prompt}`
|
|
122
|
+
: '';
|
|
121
123
|
if (reason) {
|
|
122
124
|
dropped.push({ name: name || '(unnamed)', reason });
|
|
123
125
|
continue;
|
|
@@ -230,6 +232,34 @@ export function parseFrontMatter(md) {
|
|
|
230
232
|
return { meta, body: md.slice(m[0].length) };
|
|
231
233
|
}
|
|
232
234
|
// ── Skills ───────────────────────────────────────────────────────────────────
|
|
235
|
+
const FENCE = /^\s{0,3}(`{3,}|~{3,})/;
|
|
236
|
+
/** A SKILL.md body's first `# ` heading outside fenced code (a template inside a fence
|
|
237
|
+
* is not the skill's title), less a leading "Skill:", and the paragraph line after it. */
|
|
238
|
+
export function skillHeading(body) {
|
|
239
|
+
const lines = body.split(/\r?\n/);
|
|
240
|
+
let fence = null;
|
|
241
|
+
for (let i = 0; i < lines.length; i++) {
|
|
242
|
+
const f = FENCE.exec(lines[i]);
|
|
243
|
+
if (f) {
|
|
244
|
+
if (!fence)
|
|
245
|
+
fence = f[1];
|
|
246
|
+
else if (f[1][0] === fence[0] && f[1].length >= fence.length && !lines[i].trim().slice(f[1].length).trim())
|
|
247
|
+
fence = null;
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
if (fence)
|
|
251
|
+
continue;
|
|
252
|
+
const h = /^#\s+(?:Skill:\s*)?(.+)/.exec(lines[i]);
|
|
253
|
+
if (!h)
|
|
254
|
+
continue;
|
|
255
|
+
let j = i + 1;
|
|
256
|
+
while (j < lines.length && !lines[j].trim())
|
|
257
|
+
j++;
|
|
258
|
+
const next = lines[j]?.trim();
|
|
259
|
+
return { title: h[1].trim(), ...(next && !next.startsWith('#') && !FENCE.test(next) ? { paragraph: next } : {}) };
|
|
260
|
+
}
|
|
261
|
+
return {};
|
|
262
|
+
}
|
|
233
263
|
/** Folder names of the skills shipped with the package. */
|
|
234
264
|
export function coreSkillNames(pkgSkillsDir) {
|
|
235
265
|
try {
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* approval-policy.ts — what happens to a tool permission request, whoever
|
|
3
|
+
* answers it (browser card, watch, phone keypad).
|
|
4
|
+
*
|
|
5
|
+
* Pure (no LiveKit, no SDK), so the rules are testable on their own:
|
|
6
|
+
* - the approval mode (Ask me / Auto-review / Allow all), saved on the agent
|
|
7
|
+
* and applied here for the browser and phone calls alike (#364),
|
|
8
|
+
* - the plain-words description of a request (browser card and phone prompt),
|
|
9
|
+
* - the session's always-allow list ("Always" in the browser, keypad 3) and what it covers.
|
|
10
|
+
*/
|
|
11
|
+
import { type RiskTier } from './risk-tier.js';
|
|
12
|
+
/** An answer to a pending permission, from any surface. */
|
|
13
|
+
export type PermissionAnswer = 'allow' | 'deny' | 'always_allow';
|
|
14
|
+
/**
|
|
15
|
+
* 'ask' → every request asks (browser card, or the keypad on a call).
|
|
16
|
+
* 'auto-review' → low-risk requests (classifyRisk) are approved; the rest ask.
|
|
17
|
+
* 'allow-all' → every request is approved.
|
|
18
|
+
* It only answers requests the agent raises: the PreToolUse / canUseTool gate
|
|
19
|
+
* still denies what it denies, and on a phone call the phone policy runs first.
|
|
20
|
+
*/
|
|
21
|
+
export type ApprovalMode = 'ask' | 'auto-review' | 'allow-all';
|
|
22
|
+
export declare const DEFAULT_APPROVAL_MODE: ApprovalMode;
|
|
23
|
+
export declare function isApprovalMode(v: unknown): v is ApprovalMode;
|
|
24
|
+
/** The mode's name as the app shows it. */
|
|
25
|
+
export declare function approvalModeLabel(mode: ApprovalMode): string;
|
|
26
|
+
/**
|
|
27
|
+
* Whether the mode approves this request without asking, and its risk tier.
|
|
28
|
+
* `workspaceRoot` is the session's working directory (in-workspace edits are low risk).
|
|
29
|
+
*/
|
|
30
|
+
export declare function autoApproval(mode: ApprovalMode, toolName: string, input: ToolInput, workspaceRoot: string | undefined): {
|
|
31
|
+
approve: boolean;
|
|
32
|
+
tier: RiskTier;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* What a phone caller hears at the start of the call about approvals (#364).
|
|
36
|
+
* It says what actually happens on the call: with phone tools off nothing
|
|
37
|
+
* runs; with keypad approvals off every request that needs an OK is declined
|
|
38
|
+
* (the phone policy runs before the mode), so the mode is not claimed.
|
|
39
|
+
*/
|
|
40
|
+
export declare function approvalModeAnnouncement(mode: ApprovalMode, call: {
|
|
41
|
+
toolsOn: boolean;
|
|
42
|
+
keypadOn: boolean;
|
|
43
|
+
}): string;
|
|
44
|
+
type ToolInput = Record<string, unknown> | null | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* The browser card's one-line description of a request (sent as
|
|
47
|
+
* permission_request.description).
|
|
48
|
+
*/
|
|
49
|
+
export declare function describePermission(toolName: string, input: ToolInput): string;
|
|
50
|
+
/** The same request in words that read well aloud (short: a caller hears all of it). */
|
|
51
|
+
export declare function speakablePermission(toolName: string, input: ToolInput): string;
|
|
52
|
+
/** What a phone caller hears for a pending request (keypad approvals, #363). */
|
|
53
|
+
export declare function phoneApprovalPrompt(toolName: string, input: ToolInput): string;
|
|
54
|
+
/**
|
|
55
|
+
* What "always allow" covers for this request, and its plain-words label
|
|
56
|
+
* (shown on the browser's Always button and read out on a call):
|
|
57
|
+
* - Write/Edit/MultiEdit: writing this file;
|
|
58
|
+
* - Read/NotebookRead: reading this file; LS: listing this folder (a read
|
|
59
|
+
* approval never covers a write, nor another file);
|
|
60
|
+
* - Bash: this exact command;
|
|
61
|
+
* - Grep/Glob: this exact search (same pattern, path and options);
|
|
62
|
+
* - anything else: this exact request (same tool, same input).
|
|
63
|
+
* No tool is ever allowed as a whole. `key` is null when nothing can be
|
|
64
|
+
* recorded (a file tool with no file).
|
|
65
|
+
*/
|
|
66
|
+
export declare function alwaysScope(toolName: string, input: ToolInput): {
|
|
67
|
+
key: string | null;
|
|
68
|
+
label: string;
|
|
69
|
+
};
|
|
70
|
+
/** What answerPending needs from an LLM holding a permission request (ClaudeLLM / PipelineDirectLLM). */
|
|
71
|
+
export interface PermissionHolder {
|
|
72
|
+
getPendingPermission?(): {
|
|
73
|
+
toolName: string;
|
|
74
|
+
input: any;
|
|
75
|
+
requestId: string;
|
|
76
|
+
} | null;
|
|
77
|
+
respondToPermission(allow: boolean, message?: string, requestId?: string): boolean | void;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Answers ONE request: the one `requestId` names, if `holder` still has it
|
|
81
|
+
* pending. A late answer (its request already settled, or a different one
|
|
82
|
+
* pending now, a parked brain's included) settles nothing. 'always_allow'
|
|
83
|
+
* records that request's alwaysScope. True when it was settled.
|
|
84
|
+
*/
|
|
85
|
+
export declare function answerPending(holder: PermissionHolder | null | undefined, answer: PermissionAnswer, requestId: unknown, allows: SessionAllows): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* An answer with no requestId, from a browser tab or mobile build older than
|
|
88
|
+
* request ids. Settles only the LIVE session's request, only when it is the one
|
|
89
|
+
* request pending anywhere (a parked brain with a pending request blocks it),
|
|
90
|
+
* and never records an always-allow: a no-id Always is allow-once. True when settled.
|
|
91
|
+
*/
|
|
92
|
+
export declare function answerPendingWithoutId(live: PermissionHolder | null | undefined, parked: PermissionHolder | null | undefined, answer: PermissionAnswer): boolean;
|
|
93
|
+
/** The session's always-allow list (keys from alwaysScope). Cleared with each new voice session. */
|
|
94
|
+
export type SessionAllows = Set<string>;
|
|
95
|
+
export declare function newSessionAllows(): SessionAllows;
|
|
96
|
+
export declare function isAlwaysAllowed(allows: SessionAllows, toolName: string, input: ToolInput): boolean;
|
|
97
|
+
/** Records an "always allow" for this request. Returns what was added, for the log. */
|
|
98
|
+
export declare function recordAlwaysAllow(allows: SessionAllows, toolName: string, input: ToolInput): string | null;
|
|
99
|
+
export {};
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* approval-policy.ts — what happens to a tool permission request, whoever
|
|
3
|
+
* answers it (browser card, watch, phone keypad).
|
|
4
|
+
*
|
|
5
|
+
* Pure (no LiveKit, no SDK), so the rules are testable on their own:
|
|
6
|
+
* - the approval mode (Ask me / Auto-review / Allow all), saved on the agent
|
|
7
|
+
* and applied here for the browser and phone calls alike (#364),
|
|
8
|
+
* - the plain-words description of a request (browser card and phone prompt),
|
|
9
|
+
* - the session's always-allow list ("Always" in the browser, keypad 3) and what it covers.
|
|
10
|
+
*/
|
|
11
|
+
import { classifyRisk } from './risk-tier.js';
|
|
12
|
+
export const DEFAULT_APPROVAL_MODE = 'ask';
|
|
13
|
+
export function isApprovalMode(v) {
|
|
14
|
+
return v === 'ask' || v === 'auto-review' || v === 'allow-all';
|
|
15
|
+
}
|
|
16
|
+
const MODE_LABELS = { 'ask': 'Ask me', 'auto-review': 'Auto-review', 'allow-all': 'Allow all' };
|
|
17
|
+
/** The mode's name as the app shows it. */
|
|
18
|
+
export function approvalModeLabel(mode) {
|
|
19
|
+
return MODE_LABELS[mode];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Whether the mode approves this request without asking, and its risk tier.
|
|
23
|
+
* `workspaceRoot` is the session's working directory (in-workspace edits are low risk).
|
|
24
|
+
*/
|
|
25
|
+
export function autoApproval(mode, toolName, input, workspaceRoot) {
|
|
26
|
+
// No known cwd → nothing is provably inside it → nothing is low risk.
|
|
27
|
+
const tier = workspaceRoot ? classifyRisk(toolName, input, workspaceRoot) : 'high';
|
|
28
|
+
return { approve: mode === 'allow-all' || (mode === 'auto-review' && tier === 'low'), tier };
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* What a phone caller hears at the start of the call about approvals (#364).
|
|
32
|
+
* It says what actually happens on the call: with phone tools off nothing
|
|
33
|
+
* runs; with keypad approvals off every request that needs an OK is declined
|
|
34
|
+
* (the phone policy runs before the mode), so the mode is not claimed.
|
|
35
|
+
*/
|
|
36
|
+
export function approvalModeAnnouncement(mode, call) {
|
|
37
|
+
if (!call.toolsOn)
|
|
38
|
+
return 'Tools are off on phone calls for now, so on this call I can only talk.';
|
|
39
|
+
if (!call.keypadOn)
|
|
40
|
+
return 'Approvals are off on phone calls for now: anything that needs your OK is declined, so approve it in the app.';
|
|
41
|
+
const how = mode === 'allow-all'
|
|
42
|
+
? 'I will run actions without asking.'
|
|
43
|
+
: mode === 'auto-review'
|
|
44
|
+
? 'I will run low-risk actions and ask you about anything risky: press 1 to allow, 2 to deny, 3 to always allow.'
|
|
45
|
+
: 'I will ask you before each action: press 1 to allow, 2 to deny, 3 to always allow.';
|
|
46
|
+
return `${approvalModeLabel(mode)} is on. ${how}`;
|
|
47
|
+
}
|
|
48
|
+
// File tools whose "always allow" covers one file, not the whole tool.
|
|
49
|
+
const PATH_SCOPED_TOOLS = new Set(['Write', 'Edit', 'MultiEdit']);
|
|
50
|
+
const str = (v) => (typeof v === 'string' ? v : '');
|
|
51
|
+
const baseName = (p) => p.split('/').filter(Boolean).pop() || p;
|
|
52
|
+
/**
|
|
53
|
+
* The browser card's one-line description of a request (sent as
|
|
54
|
+
* permission_request.description).
|
|
55
|
+
*/
|
|
56
|
+
export function describePermission(toolName, input) {
|
|
57
|
+
const cmd = str(input?.command);
|
|
58
|
+
const file = str(input?.file_path);
|
|
59
|
+
const url = str(input?.url);
|
|
60
|
+
if (toolName === 'Bash' && cmd)
|
|
61
|
+
return `I want to run the command: ${cmd.substring(0, 60)}${cmd.length > 60 ? '...' : ''}`;
|
|
62
|
+
if (toolName === 'Write' && file)
|
|
63
|
+
return `I want to create or overwrite the file: ${file}`;
|
|
64
|
+
if (toolName === 'Edit' && file)
|
|
65
|
+
return `I want to edit the file: ${file}`;
|
|
66
|
+
if (toolName === 'WebFetch' && url)
|
|
67
|
+
return `I want to fetch content from: ${url}`;
|
|
68
|
+
return `I need permission to use ${toolName}.`;
|
|
69
|
+
}
|
|
70
|
+
/** The same request in words that read well aloud (short: a caller hears all of it). */
|
|
71
|
+
export function speakablePermission(toolName, input) {
|
|
72
|
+
const cmd = str(input?.command).trim();
|
|
73
|
+
const file = str(input?.file_path) || str(input?.notebook_path);
|
|
74
|
+
const url = str(input?.url);
|
|
75
|
+
if (toolName === 'Bash' && cmd) {
|
|
76
|
+
const words = cmd.split(/\s+/).slice(0, 8).join(' ');
|
|
77
|
+
return `run the command ${words}${cmd.split(/\s+/).length > 8 ? ' and so on' : ''}`;
|
|
78
|
+
}
|
|
79
|
+
if (toolName === 'Write' && file)
|
|
80
|
+
return `create or overwrite the file ${baseName(file)}`;
|
|
81
|
+
if ((toolName === 'Edit' || toolName === 'MultiEdit' || toolName === 'NotebookEdit') && file)
|
|
82
|
+
return `edit the file ${baseName(file)}`;
|
|
83
|
+
if (toolName === 'WebFetch' && url) {
|
|
84
|
+
try {
|
|
85
|
+
return `fetch a page from ${new URL(url).hostname}`;
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
return 'fetch a web page';
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (toolName === 'WebSearch')
|
|
92
|
+
return 'search the web';
|
|
93
|
+
if (toolName === 'Task' || toolName === 'Agent') {
|
|
94
|
+
const who = str(input?.subagent_type);
|
|
95
|
+
return who ? `start the ${who} agent` : 'start a helper agent';
|
|
96
|
+
}
|
|
97
|
+
const mcp = /^mcp__(.+?)__(.+)$/.exec(toolName);
|
|
98
|
+
if (mcp)
|
|
99
|
+
return `use ${mcp[2].replace(/[_-]+/g, ' ')} from ${mcp[1].replace(/[_-]+/g, ' ')}`;
|
|
100
|
+
return `use the ${toolName.replace(/[_-]+/g, ' ')} tool`;
|
|
101
|
+
}
|
|
102
|
+
/** What a phone caller hears for a pending request (keypad approvals, #363). */
|
|
103
|
+
export function phoneApprovalPrompt(toolName, input) {
|
|
104
|
+
return `Osborn wants to ${speakablePermission(toolName, input)}. Press 1 to allow, 2 to deny, or 3 to always allow ${alwaysScope(toolName, input).label} for this call.`;
|
|
105
|
+
}
|
|
106
|
+
/** JSON with sorted keys, so the same input always gives the same key. */
|
|
107
|
+
function stableJson(v) {
|
|
108
|
+
if (Array.isArray(v))
|
|
109
|
+
return `[${v.map(stableJson).join(',')}]`;
|
|
110
|
+
if (v && typeof v === 'object') {
|
|
111
|
+
return `{${Object.keys(v).sort().map((k) => `${JSON.stringify(k)}:${stableJson(v[k])}`).join(',')}}`;
|
|
112
|
+
}
|
|
113
|
+
return JSON.stringify(v) ?? 'null';
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* What "always allow" covers for this request, and its plain-words label
|
|
117
|
+
* (shown on the browser's Always button and read out on a call):
|
|
118
|
+
* - Write/Edit/MultiEdit: writing this file;
|
|
119
|
+
* - Read/NotebookRead: reading this file; LS: listing this folder (a read
|
|
120
|
+
* approval never covers a write, nor another file);
|
|
121
|
+
* - Bash: this exact command;
|
|
122
|
+
* - Grep/Glob: this exact search (same pattern, path and options);
|
|
123
|
+
* - anything else: this exact request (same tool, same input).
|
|
124
|
+
* No tool is ever allowed as a whole. `key` is null when nothing can be
|
|
125
|
+
* recorded (a file tool with no file).
|
|
126
|
+
*/
|
|
127
|
+
export function alwaysScope(toolName, input) {
|
|
128
|
+
if (PATH_SCOPED_TOOLS.has(toolName)) {
|
|
129
|
+
const file = str(input?.file_path);
|
|
130
|
+
return { key: file ? `path:${file}` : null, label: 'this file' };
|
|
131
|
+
}
|
|
132
|
+
if (toolName === 'Read' || toolName === 'NotebookRead') {
|
|
133
|
+
const file = str(input?.file_path) || str(input?.notebook_path);
|
|
134
|
+
return { key: file ? `read:${file}` : null, label: 'reading this file' };
|
|
135
|
+
}
|
|
136
|
+
if (toolName === 'LS') {
|
|
137
|
+
const dir = str(input?.path);
|
|
138
|
+
return { key: dir ? `ls:${dir}` : null, label: 'listing this folder' };
|
|
139
|
+
}
|
|
140
|
+
if (toolName === 'Bash') {
|
|
141
|
+
const cmd = str(input?.command);
|
|
142
|
+
return { key: cmd ? `bash:${cmd}` : null, label: 'this exact command' };
|
|
143
|
+
}
|
|
144
|
+
const exact = `exact:${toolName}:${stableJson(input ?? {})}`;
|
|
145
|
+
if (toolName === 'Grep' || toolName === 'Glob')
|
|
146
|
+
return { key: exact, label: 'this exact search' };
|
|
147
|
+
return { key: exact, label: 'this exact request' };
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Answers ONE request: the one `requestId` names, if `holder` still has it
|
|
151
|
+
* pending. A late answer (its request already settled, or a different one
|
|
152
|
+
* pending now, a parked brain's included) settles nothing. 'always_allow'
|
|
153
|
+
* records that request's alwaysScope. True when it was settled.
|
|
154
|
+
*/
|
|
155
|
+
export function answerPending(holder, answer, requestId, allows) {
|
|
156
|
+
if (typeof requestId !== 'string' || !requestId || !holder)
|
|
157
|
+
return false;
|
|
158
|
+
const pending = holder.getPendingPermission?.();
|
|
159
|
+
if (!pending || pending.requestId !== requestId)
|
|
160
|
+
return false;
|
|
161
|
+
if (answer === 'always_allow') {
|
|
162
|
+
const added = recordAlwaysAllow(allows, pending.toolName, pending.input);
|
|
163
|
+
if (added)
|
|
164
|
+
console.log(`🔒 Always-allow added for session: ${added}`);
|
|
165
|
+
}
|
|
166
|
+
return holder.respondToPermission(answer !== 'deny', undefined, requestId) !== false;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* An answer with no requestId, from a browser tab or mobile build older than
|
|
170
|
+
* request ids. Settles only the LIVE session's request, only when it is the one
|
|
171
|
+
* request pending anywhere (a parked brain with a pending request blocks it),
|
|
172
|
+
* and never records an always-allow: a no-id Always is allow-once. True when settled.
|
|
173
|
+
*/
|
|
174
|
+
export function answerPendingWithoutId(live, parked, answer) {
|
|
175
|
+
const pending = live?.getPendingPermission?.();
|
|
176
|
+
if (!live || !pending)
|
|
177
|
+
return false;
|
|
178
|
+
if (parked && parked !== live && parked.getPendingPermission?.())
|
|
179
|
+
return false;
|
|
180
|
+
return live.respondToPermission(answer !== 'deny', undefined, pending.requestId) !== false;
|
|
181
|
+
}
|
|
182
|
+
export function newSessionAllows() {
|
|
183
|
+
return new Set();
|
|
184
|
+
}
|
|
185
|
+
export function isAlwaysAllowed(allows, toolName, input) {
|
|
186
|
+
const { key } = alwaysScope(toolName, input);
|
|
187
|
+
return !!key && allows.has(key);
|
|
188
|
+
}
|
|
189
|
+
/** Records an "always allow" for this request. Returns what was added, for the log. */
|
|
190
|
+
export function recordAlwaysAllow(allows, toolName, input) {
|
|
191
|
+
const { key } = alwaysScope(toolName, input);
|
|
192
|
+
if (!key)
|
|
193
|
+
return null;
|
|
194
|
+
allows.add(key);
|
|
195
|
+
return key;
|
|
196
|
+
}
|
package/dist/claude-llm.d.ts
CHANGED
|
@@ -153,7 +153,7 @@ export declare class ClaudeLLM extends llm.LLM {
|
|
|
153
153
|
* Respond to a pending permission request
|
|
154
154
|
* Call this after receiving 'permission_request' event
|
|
155
155
|
*/
|
|
156
|
-
respondToPermission(allow: boolean, message?: string):
|
|
156
|
+
respondToPermission(allow: boolean, message?: string, requestId?: string): boolean;
|
|
157
157
|
/**
|
|
158
158
|
* Check if there's a pending permission request
|
|
159
159
|
*/
|
|
@@ -164,6 +164,7 @@ export declare class ClaudeLLM extends llm.LLM {
|
|
|
164
164
|
getPendingPermission(): {
|
|
165
165
|
toolName: string;
|
|
166
166
|
input: any;
|
|
167
|
+
requestId: string;
|
|
167
168
|
} | null;
|
|
168
169
|
/**
|
|
169
170
|
* Guarded, fire-and-forget write-through to the embedded session.db. Called from the
|
|
@@ -172,7 +173,7 @@ export declare class ClaudeLLM extends llm.LLM {
|
|
|
172
173
|
* The guard lives here (on the long-lived ClaudeLLM, not the per-turn stream) so a slow
|
|
173
174
|
* write can't overlap the next turn's write. Never throws; never blocks the caller.
|
|
174
175
|
*/
|
|
175
|
-
triggerStoreUpdate(sessionId: string, workingDir: string): void;
|
|
176
|
+
triggerStoreUpdate(sessionId: string, workingDir: string, mainOnly?: boolean): void;
|
|
176
177
|
/**
|
|
177
178
|
* Get all currently enabled MCP servers
|
|
178
179
|
*/
|
|
@@ -211,6 +212,9 @@ export declare class ClaudeLLM extends llm.LLM {
|
|
|
211
212
|
setTurbo(on: boolean): void;
|
|
212
213
|
/** Read-only accessor used by ClaudeLLMStream (private fields are class-scoped). */
|
|
213
214
|
get turbo(): boolean;
|
|
215
|
+
/** A phone caller holds this session (index.ts sets it per voice session): tools are denied. */
|
|
216
|
+
setPhoneCall(on: boolean): void;
|
|
217
|
+
get phoneCall(): boolean;
|
|
214
218
|
permissionPending: boolean;
|
|
215
219
|
compacting: boolean;
|
|
216
220
|
/**
|