@0perator/operator 0.1.222 → 0.1.261
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 +6 -5
- package/dashboard/server.mjs +1 -1
- package/dist/acp/agent.js +320 -53
- package/dist/acp/auth.js +44 -0
- package/dist/acp/config-options.js +34 -0
- package/dist/acp/prompt.js +41 -0
- package/dist/acp/run.js +116 -10
- package/dist/acp/tool-map.js +48 -0
- package/dist/auth/byo.js +125 -0
- package/dist/auth/client.js +12 -6
- package/dist/auth/commands.js +71 -3
- package/dist/auth/identity.js +136 -0
- package/dist/auth/store.js +7 -5
- package/dist/autonomy/board.js +3 -2
- package/dist/autonomy/cron.js +332 -0
- package/dist/autonomy/delegate.js +168 -0
- package/dist/autonomy/dream.js +1 -1
- package/dist/autonomy/index.js +16 -2
- package/dist/autonomy/media-robot.js +137 -0
- package/dist/autonomy/profile.js +77 -0
- package/dist/autonomy/routines.js +5 -4
- package/dist/autonomy/session-factory.js +19 -10
- package/dist/background/index.js +8 -1
- package/dist/browser/cdp.js +266 -0
- package/dist/browser/session.js +286 -0
- package/dist/cli.js +207 -106
- package/dist/compose/client.js +56 -0
- package/dist/config/brand.js +3 -3
- package/dist/config/home.js +70 -0
- package/dist/config/managed.js +230 -0
- package/dist/config/persona.js +243 -21
- package/dist/config/scaffold.js +142 -0
- package/dist/config/settings.js +87 -20
- package/dist/config/skills-index.js +175 -0
- package/dist/consolidation/scheduler.js +10 -7
- package/dist/consolidation/sleep.js +17 -3
- package/dist/engine/agent.js +231 -21
- package/dist/engine/aurora.js +79 -14
- package/dist/engine/batch-scheduler.js +128 -0
- package/dist/engine/compaction.js +129 -2
- package/dist/engine/computer-event.js +139 -0
- package/dist/engine/continuation.js +55 -0
- package/dist/engine/contract.js +3 -1
- package/dist/engine/grandmaster.js +13 -3
- package/dist/engine/json-repair.js +105 -0
- package/dist/engine/messages.js +52 -5
- package/dist/engine/redact.js +25 -0
- package/dist/engine/rolling-summary.js +28 -11
- package/dist/engine/router-adapter.js +2 -0
- package/dist/engine/unrestricted.js +51 -0
- package/dist/engine/verify-gate.js +6 -0
- package/dist/enterprise/cli.js +137 -0
- package/dist/flywheel/processor.js +30 -2
- package/dist/flywheel/secret-gate.js +123 -0
- package/dist/index.browser.js +4 -0
- package/dist/index.js +4 -0
- package/dist/mcp/index.js +18 -24
- package/dist/memory/index.js +0 -0
- package/dist/memory/session-index.js +324 -0
- package/dist/memory/session-rewind.js +92 -0
- package/dist/memory/state-maintenance.js +441 -0
- package/dist/observability/index.js +3 -3
- package/dist/permissions/audit.js +4 -1
- package/dist/permissions/index.js +24 -12
- package/dist/permissions/policy.js +4 -3
- package/dist/permissions/tier.js +31 -14
- package/dist/remote/host.js +9 -2
- package/dist/router/models.js +62 -2
- package/dist/selfimprove/index.js +9 -7
- package/dist/session.js +129 -42
- package/dist/skills/catalogue.js +167 -0
- package/dist/telemetry/audit-verify.js +94 -0
- package/dist/telemetry/events.js +92 -7
- package/dist/telemetry/lifecycle.js +18 -0
- package/dist/tools/computer.js +1 -1
- package/dist/tools/deferred.js +117 -0
- package/dist/tools/executor.js +27 -23
- package/dist/tools/memory.js +117 -0
- package/dist/tools/mutating.js +6 -0
- package/dist/tools/registry.js +1022 -46
- package/dist/tools/sandbox.js +63 -17
- package/dist/tools/searxng.js +2 -2
- package/dist/tools/shell-session.js +36 -1
- package/dist/tools/tool-output-spill.js +4 -4
- package/dist/ui/ActivitySpinner.js +17 -6
- package/dist/ui/App.js +36 -14
- package/dist/ui/ArtifactPicker.js +109 -0
- package/dist/ui/Composer.js +39 -8
- package/dist/ui/Markdown.js +5 -3
- package/dist/ui/MouseProvider.js +99 -19
- package/dist/ui/QuestionPrompt.js +24 -3
- package/dist/ui/ThinkingSpinner.js +9 -5
- package/dist/ui/ToolStep.js +17 -12
- package/dist/ui/Transcript.js +28 -9
- package/dist/ui/capabilities.js +0 -9
- package/dist/ui/listhit.js +23 -0
- package/dist/ui/mouse.js +22 -0
- package/dist/ui/osc.js +7 -4
- package/dist/ui/progressbar.js +46 -0
- package/dist/ui/shimmer.js +43 -0
- package/dist/ui/theme.js +2 -0
- package/dist/ui/tick.js +48 -0
- package/dist/ui/toolicons.js +69 -0
- package/dist/ui/useInputHistory.js +3 -3
- package/dist/util/slash.js +1 -0
- package/dist/vault/cli.js +48 -0
- package/dist/vault/store.js +157 -0
- package/dist/vault/tool.js +50 -0
- package/package.json +3 -5
- package/CHANGELOG.md +0 -1629
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// Per-ACTION visual language for tool rows. The old rows used ONE status glyph (○◐✓✗) for every tool, so a
|
|
2
|
+
// file read looked identical to a web fetch. Here each tool KIND gets its own icon (what it's doing) plus its
|
|
3
|
+
// own "working" animation; the STATUS is carried by color (muted → amber running → green done → red error).
|
|
4
|
+
//
|
|
5
|
+
// Font safety: every glyph is drawn ONLY from the Geometric Shapes (U+25xx), Dingbats (U+27xx) and Braille
|
|
6
|
+
// (U+28xx) blocks that the existing star + braille spinners already prove render in Menlo/Terminal.app — no
|
|
7
|
+
// tofu. Icons are centralized here so the whole vocabulary is swappable in one place.
|
|
8
|
+
// name → kind. First match wins; names are matched loosely so vendor/alias variants land in the right bucket.
|
|
9
|
+
// Order matters: more specific prefixes first. `web_*` must be tested BEFORE the generic `search` rule, or
|
|
10
|
+
// "web_search" (which contains "search") would be miscategorized as a search. `media` is tested FIRST of
|
|
11
|
+
// all: image_generate/video_generate would otherwise fall into the generic default spinner with no
|
|
12
|
+
// progress indication (ToolStep.tsx's media-gen bar keys off toolKind() === "media").
|
|
13
|
+
const KIND_RULES = [
|
|
14
|
+
[/(image_generate|video_generate|img_gen|vid_gen|^generate|diffusion|flux|ltx)/i, "media"],
|
|
15
|
+
[/(read_file|read_files|^read$|^cat$|open_file|file_read)/i, "read"],
|
|
16
|
+
[/(file_write|write_file|^write$|edit|apply_patch|str_replace|notebook|create_file|insert)/i, "write"],
|
|
17
|
+
[/(web_search|web_fetch|^web|http|browser|^fetch$|curl|^url|download)/i, "web"],
|
|
18
|
+
[/(skill_fetch|skill_save|^skill$)/i, "skill"],
|
|
19
|
+
[/(search|grep|ripgrep|glob|^find$|skill_list|lookup)/i, "search"],
|
|
20
|
+
[/(^git|git_|checkpoint|^commit|^diff|^branch)/i, "git"], // before shell: "git_command" contains "command"
|
|
21
|
+
[/(bash|shell|^run$|exec|command|script)/i, "shell"],
|
|
22
|
+
[/(spawn_agent|^agent|sub_?agent|delegate|^task)/i, "agent"],
|
|
23
|
+
];
|
|
24
|
+
export function toolKind(name) {
|
|
25
|
+
for (const [re, k] of KIND_RULES)
|
|
26
|
+
if (re.test(name))
|
|
27
|
+
return k;
|
|
28
|
+
return "default";
|
|
29
|
+
}
|
|
30
|
+
// Settled / static icon per kind (shown tinted by status).
|
|
31
|
+
export const KIND_ICON = {
|
|
32
|
+
read: "▤", write: "✒", search: "◎", shell: "▶", web: "◍", git: "❖", skill: "◆", agent: "✺", media: "◈", default: "●",
|
|
33
|
+
};
|
|
34
|
+
// Per-situation HUE for a RUNNING tool row's glyph — the colour language: you can tell what Operator is doing
|
|
35
|
+
// by the colour of the live glyph (media=magenta, shell=green, search=cyan, web=blue, read=teal, write=gold,
|
|
36
|
+
// git=violet, agent=pink). Thinking stays pearl (shimmer.ts); settled rows keep status colour (done=green,
|
|
37
|
+
// error=red), so the hue signals KIND only while running. Matches the shimmer palette shown in the artifact.
|
|
38
|
+
export const KIND_HUE = {
|
|
39
|
+
read: "#6ee4d8", write: "#ffd278", search: "#78ecf4", shell: "#64eb8c", web: "#6eaaff",
|
|
40
|
+
git: "#b48cff", skill: "#ffd778", agent: "#ff8cbe", media: "#ff6edc", default: "#e0a84a",
|
|
41
|
+
};
|
|
42
|
+
// Running animation frames per kind — single-glyph, driven by the ONE shared ticker (see tick.ts), so N
|
|
43
|
+
// animating rows coalesce into a single redraw per frame. Motion chosen to EVOKE the action.
|
|
44
|
+
export const KIND_FRAMES = {
|
|
45
|
+
read: ["⠁", "⠃", "⠇", "⠧", "⠷", "⠿", "⠷", "⠧", "⠇", "⠃"], // a page filling with lines
|
|
46
|
+
write: ["✎", "✏", "✐", "✎"], // pen strokes
|
|
47
|
+
search: ["◜", "◠", "◝", "◞", "◡", "◟"], // a sweep scanning around
|
|
48
|
+
shell: ["▶", "▷", "▶", "▷"], // a play button pulsing — running a command
|
|
49
|
+
web: ["◴", "◷", "◶", "◵"], // a dial turning — fetching
|
|
50
|
+
git: ["❖", "◈", "❖", "◇"], // a branch node shimmering
|
|
51
|
+
skill: ["◆", "◈", "◆", "◇"], // a gem catching light
|
|
52
|
+
agent: ["✺", "✷", "✹", "✸"], // a burst — delegated work underway
|
|
53
|
+
media: ["◐", "◓", "◑", "◒"], // an aperture/shutter cycling — rendering
|
|
54
|
+
default: ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"], // the classic braille run-spinner
|
|
55
|
+
};
|
|
56
|
+
/** The glyph to render for a tool row: the action's live animation while running, its settled icon when done,
|
|
57
|
+
* an unmistakable ✗ on error, and a hollow ○ while still pending/selected. `frame` comes from useTick(). */
|
|
58
|
+
export function glyphFor(name, status, frame) {
|
|
59
|
+
if (status === "error")
|
|
60
|
+
return "✗";
|
|
61
|
+
if (status === "selected")
|
|
62
|
+
return "○";
|
|
63
|
+
const kind = toolKind(name);
|
|
64
|
+
if (status === "running") {
|
|
65
|
+
const frames = KIND_FRAMES[kind];
|
|
66
|
+
return frames[frame % frames.length];
|
|
67
|
+
}
|
|
68
|
+
return KIND_ICON[kind]; // done → the action icon, tinted green by the caller
|
|
69
|
+
}
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
// slot. Typing anything after a recall snaps the cursor back to the live slot and edits it (bash's
|
|
7
7
|
// "any edit forks a fresh draft" behavior) rather than mutating the recalled history entry in place.
|
|
8
8
|
import { appendFile, mkdir, readFile } from "node:fs/promises";
|
|
9
|
-
import { dirname
|
|
10
|
-
import {
|
|
11
|
-
const DEFAULT_FILE = process.env.KODE_HISTORY_FILE ??
|
|
9
|
+
import { dirname } from "node:path";
|
|
10
|
+
import { operatorPath } from "../config/home.js";
|
|
11
|
+
const DEFAULT_FILE = process.env.KODE_HISTORY_FILE ?? operatorPath("history");
|
|
12
12
|
const MAX_ENTRIES = 200;
|
|
13
13
|
export class InputHistory {
|
|
14
14
|
file;
|
package/dist/util/slash.js
CHANGED
|
@@ -5,6 +5,7 @@ const KNOWN = new Set([
|
|
|
5
5
|
"help", "model", "route", "endpoints", "services", "audit", "dashboard", "plan", "mode",
|
|
6
6
|
"think", "ultrathink", "compact", "remember", "memory", "mcp", "whoami", "agents", "monitor",
|
|
7
7
|
"bg", "new", "clear", "exit", "quit", "stats", "login", "logout", "remote", "remotecontrol", "rc",
|
|
8
|
+
"artifacts",
|
|
8
9
|
]);
|
|
9
10
|
export function isSlashCommand(text) {
|
|
10
11
|
const t = text.trim();
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// `operator vault ...` — owner-side credential management on the TTY.
|
|
2
|
+
// The secret path NEVER touches argv or model context: macOS uses the keychain's own hidden
|
|
3
|
+
// prompt (`security add-generic-password -w` with no value), CI/test fallbacks read stdin.
|
|
4
|
+
import { vaultAddInteractive, vaultList, vaultDelete } from "./store.js";
|
|
5
|
+
export async function runVault(argv) {
|
|
6
|
+
const cmd = argv[0] ?? "list";
|
|
7
|
+
if (cmd === "list") {
|
|
8
|
+
const items = vaultList();
|
|
9
|
+
if (!items.length) {
|
|
10
|
+
console.log("vault: empty");
|
|
11
|
+
return 0;
|
|
12
|
+
}
|
|
13
|
+
for (const i of items)
|
|
14
|
+
console.log(`${i.handle}\n user: ${i.username}`);
|
|
15
|
+
return 0;
|
|
16
|
+
}
|
|
17
|
+
if (cmd === "add") {
|
|
18
|
+
const origin = argv[1];
|
|
19
|
+
if (!origin) {
|
|
20
|
+
console.error("usage: operator vault add <origin-or-url> [--user <username>] [--label <name>]");
|
|
21
|
+
return 2;
|
|
22
|
+
}
|
|
23
|
+
const flag = (name, dflt) => {
|
|
24
|
+
const i = argv.indexOf(name);
|
|
25
|
+
return i >= 0 && argv[i + 1] ? argv[i + 1] : dflt;
|
|
26
|
+
};
|
|
27
|
+
const username = flag("--user", "");
|
|
28
|
+
const label = flag("--label", new URL(origin.includes("://") ? origin : `https://${origin}`).hostname || origin);
|
|
29
|
+
const r = await vaultAddInteractive(origin, username, label);
|
|
30
|
+
if (!r.ok) {
|
|
31
|
+
console.error(`vault add failed: ${r.hint ?? "unknown"}`);
|
|
32
|
+
return 1;
|
|
33
|
+
}
|
|
34
|
+
console.log(`saved ${r.handle}`);
|
|
35
|
+
return 0;
|
|
36
|
+
}
|
|
37
|
+
if (cmd === "rm") {
|
|
38
|
+
const handle = argv[1];
|
|
39
|
+
if (!handle) {
|
|
40
|
+
console.error("usage: operator vault rm <handle>");
|
|
41
|
+
return 2;
|
|
42
|
+
}
|
|
43
|
+
console.log(vaultDelete(handle) ? `removed ${handle}` : `no such handle: ${handle}`);
|
|
44
|
+
return 0;
|
|
45
|
+
}
|
|
46
|
+
console.error("usage: operator vault [list | add <origin> [--user u] [--label l] | rm <handle>]");
|
|
47
|
+
return 2;
|
|
48
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
// Credential vault (HV3-02b) — origin-bound website logins for the browser, keychain-first.
|
|
2
|
+
// THE CONTRACT (inherited from the Hermes playbook and enforced by test):
|
|
3
|
+
// 1. Secrets NEVER enter model context: they are not returned by any tool, not accepted as tool
|
|
4
|
+
// arguments, and not logged. Save happens on the CLI TTY (operator vault add); fill takes a
|
|
5
|
+
// HANDLE + selectors only — the password goes straight from keychain into the page over CDP.
|
|
6
|
+
// 2. Fill is origin-bound: the ACTIVE tab's origin must match the stored item's origin exactly
|
|
7
|
+
// (scheme+host+port). A page cannot trick the agent into spraying credentials elsewhere.
|
|
8
|
+
// 3. Storage mirrors src/auth/byo.ts: macOS keychain (security) → Linux secret-tool → 0600 file
|
|
9
|
+
// under $KODE_HOME/vault/secrets.json (fallback + CI via KODE_VAULT_NO_KEYCHAIN=1). The
|
|
10
|
+
// metadata index ($KODE_HOME/vault/index.json) holds ONLY origin/label/username — no secrets.
|
|
11
|
+
import { execFileSync, spawnSync } from "node:child_process";
|
|
12
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
13
|
+
import { platform } from "node:os";
|
|
14
|
+
import { dirname } from "node:path";
|
|
15
|
+
import { operatorPath } from "../config/home.js";
|
|
16
|
+
const SERVICE = "axe-operator-vault";
|
|
17
|
+
const NO_KEYCHAIN = process.env.KODE_VAULT_NO_KEYCHAIN === "1";
|
|
18
|
+
const secretsFile = () => operatorPath("vault", "secrets.json");
|
|
19
|
+
const indexFile = () => operatorPath("vault", "index.json");
|
|
20
|
+
function readJson(path, fallback) {
|
|
21
|
+
try {
|
|
22
|
+
return existsSync(path) ? JSON.parse(readFileSync(path, "utf8")) : fallback;
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return fallback;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function writeJson(path, data, mode = 0o600) {
|
|
29
|
+
mkdirSync(dirname(path), { recursive: true, mode: 0o700 });
|
|
30
|
+
writeFileSync(path, JSON.stringify(data, null, 1), { mode });
|
|
31
|
+
}
|
|
32
|
+
function keychainFind(handle) {
|
|
33
|
+
if (NO_KEYCHAIN)
|
|
34
|
+
return undefined;
|
|
35
|
+
try {
|
|
36
|
+
if (platform() === "darwin") {
|
|
37
|
+
const out = execFileSync("security", ["find-generic-password", "-s", SERVICE, "-a", handle, "-w"], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] });
|
|
38
|
+
if (out.trim())
|
|
39
|
+
return out.trim();
|
|
40
|
+
}
|
|
41
|
+
else if (platform() === "linux") {
|
|
42
|
+
const out = execFileSync("secret-tool", ["lookup", "service", SERVICE, "account", handle], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] });
|
|
43
|
+
if (out.trim())
|
|
44
|
+
return out.trim();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
catch { /* not stored there */ }
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
function keychainSet(handle, secret) {
|
|
51
|
+
if (NO_KEYCHAIN)
|
|
52
|
+
return false;
|
|
53
|
+
try {
|
|
54
|
+
if (platform() === "darwin") {
|
|
55
|
+
const r = spawnSync("security", ["add-generic-password", "-U", "-s", SERVICE, "-a", handle, "-w", secret], { stdio: "ignore" });
|
|
56
|
+
return r.status === 0;
|
|
57
|
+
}
|
|
58
|
+
if (platform() === "linux") {
|
|
59
|
+
const r = spawnSync("secret-tool", ["store", "--label", `operator vault ${handle}`, "service", SERVICE, "account", handle], { input: secret, encoding: "utf8" });
|
|
60
|
+
return r.status === 0;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch { /* fall through */ }
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
function keychainDelete(handle) {
|
|
67
|
+
if (NO_KEYCHAIN)
|
|
68
|
+
return;
|
|
69
|
+
try {
|
|
70
|
+
if (platform() === "darwin")
|
|
71
|
+
spawnSync("security", ["delete-generic-password", "-s", SERVICE, "-a", handle], { stdio: "ignore" });
|
|
72
|
+
else if (platform() === "linux")
|
|
73
|
+
spawnSync("secret-tool", ["clear", "service", SERVICE, "account", handle], { stdio: "ignore" });
|
|
74
|
+
}
|
|
75
|
+
catch { /* best-effort */ }
|
|
76
|
+
}
|
|
77
|
+
// ── Public surface (metadata-only where the model can see it) ───────────────
|
|
78
|
+
export function vaultList() {
|
|
79
|
+
return readJson(indexFile(), []);
|
|
80
|
+
}
|
|
81
|
+
export function vaultGet(handle) {
|
|
82
|
+
return vaultList().find((i) => i.handle === handle);
|
|
83
|
+
}
|
|
84
|
+
/** The SECRET — call ONLY from the fill path; never return this to a model, log, or transcript. */
|
|
85
|
+
export function vaultSecret(handle) {
|
|
86
|
+
const kc = keychainFind(handle);
|
|
87
|
+
if (kc)
|
|
88
|
+
return kc;
|
|
89
|
+
return readJson(secretsFile(), {})[handle] || undefined;
|
|
90
|
+
}
|
|
91
|
+
/** Programmatic store (used by tests + CLI). Tries keychain first; falls back to the 0600 file. */
|
|
92
|
+
export function vaultPut(meta, secret) {
|
|
93
|
+
if (!originOf(meta.origin))
|
|
94
|
+
throw new Error(`vault: bad origin '${meta.origin}'`);
|
|
95
|
+
const idx = vaultList().filter((i) => i.handle !== meta.handle);
|
|
96
|
+
idx.push(meta);
|
|
97
|
+
writeJson(indexFile(), idx, 0o644); // index carries no secrets
|
|
98
|
+
if (!keychainSet(meta.handle, secret)) {
|
|
99
|
+
const b = readJson(secretsFile(), {});
|
|
100
|
+
b[meta.handle] = secret;
|
|
101
|
+
writeJson(secretsFile(), b, 0o600);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
export function vaultDelete(handle) {
|
|
105
|
+
const idx = vaultList();
|
|
106
|
+
const kept = idx.filter((i) => i.handle !== handle);
|
|
107
|
+
if (kept.length === idx.length)
|
|
108
|
+
return false;
|
|
109
|
+
writeJson(indexFile(), kept, 0o644);
|
|
110
|
+
keychainDelete(handle);
|
|
111
|
+
const b = readJson(secretsFile(), {});
|
|
112
|
+
if (handle in b) {
|
|
113
|
+
delete b[handle];
|
|
114
|
+
writeJson(secretsFile(), b, 0o600);
|
|
115
|
+
}
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
/** Interactive CLI add — the secret is read off the TTY (macOS: the keychain's own hidden prompt),
|
|
119
|
+
* NEVER via argv or model context. The fallback path reads one stdin line (documented for CI). */
|
|
120
|
+
export async function vaultAddInteractive(origin, username, label) {
|
|
121
|
+
const o = originOf(origin);
|
|
122
|
+
if (!o)
|
|
123
|
+
return { ok: false, handle: "", hint: `invalid origin: ${origin} (expect https://host)` };
|
|
124
|
+
const handle = `${o}#${label}`;
|
|
125
|
+
let secret;
|
|
126
|
+
if (platform() === "darwin" && !NO_KEYCHAIN) {
|
|
127
|
+
// `security ... -w` with NO value prompts on the TTY with hidden input (same contract as byo.ts)
|
|
128
|
+
const r = spawnSync("security", ["add-generic-password", "-U", "-s", SERVICE, "-a", handle, "-w", "-l", `operator vault ${o}`], { stdio: "inherit" });
|
|
129
|
+
if (r.status !== 0)
|
|
130
|
+
return { ok: false, handle, hint: "keychain add declined" };
|
|
131
|
+
secret = keychainFind(handle);
|
|
132
|
+
if (!secret)
|
|
133
|
+
return { ok: false, handle, hint: "keychain round-trip failed" };
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
const rl = await import("node:readline");
|
|
137
|
+
const iface = rl.createInterface({ input: process.stdin, output: process.stderr });
|
|
138
|
+
secret = await new Promise((res) => iface.question("vault password (CI fallback — may echo) > ", (a) => { iface.close(); res(a.trim()); }));
|
|
139
|
+
if (!secret)
|
|
140
|
+
return { ok: false, handle, hint: "empty password" };
|
|
141
|
+
}
|
|
142
|
+
vaultPut({ handle, origin: o, label, username }, secret);
|
|
143
|
+
return { ok: true, handle };
|
|
144
|
+
}
|
|
145
|
+
/** scheme://host[:port] from any URL/origin input; null when malformed. Exported for tests + tool. */
|
|
146
|
+
export function originOf(raw) {
|
|
147
|
+
try {
|
|
148
|
+
const u = new URL(raw.includes("://") ? raw : `https://${raw}`);
|
|
149
|
+
if (!u.hostname)
|
|
150
|
+
return null;
|
|
151
|
+
return `${u.protocol}//${u.host}`;
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
export const VAULT_SERVICE = SERVICE;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// browser_vault tool surface (HV3-02b). Reached ONLY via registry's dynamic nodeImport(m) — this
|
|
2
|
+
// module may statically import node-touching code (vault/store) because esbuild never resolves a
|
|
3
|
+
// variable specifier, keeping the neutral bundle clean (purity gate).
|
|
4
|
+
// CONTRACT: no secret ever crosses this file's boundaries toward the model — list returns metadata
|
|
5
|
+
// only; fill resolves the handle, verifies the ACTIVE TAB ORIGIN against the stored origin, and
|
|
6
|
+
// pushes the secret straight into the page over CDP. Result strings are scrubbed by construction:
|
|
7
|
+
// they echo selectors/handles but never values.
|
|
8
|
+
import { vaultList, vaultSecret, vaultGet, originOf } from "./store.js";
|
|
9
|
+
function metaLine(i) {
|
|
10
|
+
return `${i.handle} | user=${i.username}`;
|
|
11
|
+
}
|
|
12
|
+
/** run() body for the `browser_vault` tool (gated, safe:false). */
|
|
13
|
+
export async function runBrowserVault(args, deps) {
|
|
14
|
+
const action = String(args.action ?? "list");
|
|
15
|
+
if (action === "list") {
|
|
16
|
+
const items = vaultList();
|
|
17
|
+
if (!items.length)
|
|
18
|
+
return "vault: empty — owner can add with `operator vault add <origin> --user <u> --label <l>`";
|
|
19
|
+
return `vault (${items.length}):\n` + items.map(metaLine).join("\n");
|
|
20
|
+
}
|
|
21
|
+
if (action === "fill") {
|
|
22
|
+
const handle = String(args.handle ?? "");
|
|
23
|
+
const item = vaultGet(handle);
|
|
24
|
+
if (!item)
|
|
25
|
+
return `vault: no item '${handle}' (see browser_vault list — never guess credentials)`;
|
|
26
|
+
const userSel = String(args.user_selector ?? "");
|
|
27
|
+
const passSel = String(args.password_selector ?? "");
|
|
28
|
+
if (!userSel || !passSel)
|
|
29
|
+
return "vault fill needs user_selector + password_selector (CSS) — read the page first";
|
|
30
|
+
let href;
|
|
31
|
+
try {
|
|
32
|
+
href = await deps.activeHref();
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
return `vault: no active browser page (${e.message}) — open the login page first`;
|
|
36
|
+
}
|
|
37
|
+
const pageOrigin = originOf(href);
|
|
38
|
+
if (!pageOrigin)
|
|
39
|
+
return `vault: cannot read page origin from '${href}'`;
|
|
40
|
+
if (pageOrigin !== item.origin) {
|
|
41
|
+
return `vault: BLOCKED — page origin ${pageOrigin} does not match the item's bound origin ${item.origin}. Refusing to fill off-site.`;
|
|
42
|
+
}
|
|
43
|
+
const secret = vaultSecret(handle);
|
|
44
|
+
if (secret === undefined)
|
|
45
|
+
return `vault: item '${handle}' has no stored secret (owner must re-add)`;
|
|
46
|
+
await deps.fillPair(userSel, item.username, passSel, secret);
|
|
47
|
+
return `filled ${userSel} (username) + ${passSel} (password — value withheld) on ${pageOrigin}; submit when ready`;
|
|
48
|
+
}
|
|
49
|
+
return `vault: unknown action '${action}'`;
|
|
50
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0perator/operator",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Operator (KODE) — TypeScript + Ink terminal coding agent. Full-frame render, single-engine core shared across CLI/web/mobile; runs against a local Aurora model.",
|
|
3
|
+
"version": "0.1.261",
|
|
5
4
|
"type": "module",
|
|
6
5
|
"bin": {
|
|
7
6
|
"operator": "dist/cli.js",
|
|
@@ -10,8 +9,7 @@
|
|
|
10
9
|
"files": [
|
|
11
10
|
"dist",
|
|
12
11
|
"dashboard",
|
|
13
|
-
"README.md"
|
|
14
|
-
"CHANGELOG.md"
|
|
12
|
+
"README.md"
|
|
15
13
|
],
|
|
16
14
|
"engines": {
|
|
17
15
|
"node": ">=20"
|
|
@@ -51,7 +49,7 @@
|
|
|
51
49
|
"url": "https://github.com/memjar/kode/issues"
|
|
52
50
|
},
|
|
53
51
|
"main": "dist/index.js",
|
|
54
|
-
"license": "
|
|
52
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
55
53
|
"private": false,
|
|
56
54
|
"publishConfig": {
|
|
57
55
|
"access": "restricted",
|