@0perator/operator 0.1.235 → 0.1.262

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.
Files changed (68) hide show
  1. package/README.md +2 -1
  2. package/dashboard/server.mjs +1 -1
  3. package/dist/acp/agent.js +290 -62
  4. package/dist/acp/auth.js +44 -0
  5. package/dist/acp/prompt.js +41 -0
  6. package/dist/acp/run.js +40 -15
  7. package/dist/acp/tool-map.js +48 -0
  8. package/dist/auth/byo.js +15 -8
  9. package/dist/auth/client.js +12 -6
  10. package/dist/auth/commands.js +39 -4
  11. package/dist/auth/identity.js +136 -0
  12. package/dist/auth/store.js +7 -5
  13. package/dist/autonomy/board.js +3 -2
  14. package/dist/autonomy/cron.js +332 -0
  15. package/dist/autonomy/delegate.js +168 -0
  16. package/dist/autonomy/media-robot.js +2 -3
  17. package/dist/autonomy/routines.js +5 -4
  18. package/dist/autonomy/session-factory.js +6 -1
  19. package/dist/browser/cdp.js +266 -0
  20. package/dist/browser/session.js +286 -0
  21. package/dist/cli.js +75 -11
  22. package/dist/config/brand.js +3 -3
  23. package/dist/config/home.js +70 -0
  24. package/dist/config/managed.js +230 -0
  25. package/dist/config/persona.js +59 -9
  26. package/dist/config/scaffold.js +142 -0
  27. package/dist/config/settings.js +38 -4
  28. package/dist/config/skills-index.js +175 -0
  29. package/dist/consolidation/scheduler.js +3 -3
  30. package/dist/consolidation/sleep.js +3 -3
  31. package/dist/engine/agent.js +104 -17
  32. package/dist/engine/aurora.js +6 -0
  33. package/dist/engine/batch-scheduler.js +128 -0
  34. package/dist/engine/json-repair.js +105 -0
  35. package/dist/engine/messages.js +50 -3
  36. package/dist/engine/rolling-summary.js +7 -5
  37. package/dist/enterprise/cli.js +137 -0
  38. package/dist/flywheel/processor.js +30 -2
  39. package/dist/flywheel/secret-gate.js +123 -0
  40. package/dist/mcp/index.js +18 -24
  41. package/dist/memory/index.js +0 -0
  42. package/dist/memory/session-index.js +324 -0
  43. package/dist/memory/session-rewind.js +92 -0
  44. package/dist/memory/state-maintenance.js +441 -0
  45. package/dist/observability/index.js +3 -3
  46. package/dist/permissions/index.js +24 -12
  47. package/dist/router/models.js +27 -8
  48. package/dist/selfimprove/index.js +9 -7
  49. package/dist/session.js +16 -6
  50. package/dist/skills/catalogue.js +167 -0
  51. package/dist/telemetry/audit-verify.js +94 -0
  52. package/dist/telemetry/events.js +86 -6
  53. package/dist/telemetry/lifecycle.js +18 -0
  54. package/dist/tools/deferred.js +117 -0
  55. package/dist/tools/executor.js +19 -20
  56. package/dist/tools/memory.js +117 -0
  57. package/dist/tools/registry.js +152 -21
  58. package/dist/tools/sandbox.js +63 -17
  59. package/dist/tools/searxng.js +2 -2
  60. package/dist/tools/tool-output-spill.js +2 -2
  61. package/dist/ui/Transcript.js +14 -2
  62. package/dist/ui/useInputHistory.js +3 -3
  63. package/dist/vault/cli.js +48 -0
  64. package/dist/vault/store.js +157 -0
  65. package/dist/vault/tool.js +50 -0
  66. package/package.json +3 -5
  67. package/CHANGELOG.md +0 -2487
  68. package/dist/ui/BusTray.js +0 -70
@@ -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, join } from "node:path";
10
- import { homedir } from "node:os";
11
- const DEFAULT_FILE = process.env.KODE_HISTORY_FILE ?? join(homedir(), ".axe", "operator", "history");
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;
@@ -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.235",
4
- "description": "Operator — 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.262",
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": "UNLICENSED",
52
+ "license": "SEE LICENSE IN LICENSE",
55
53
  "private": false,
56
54
  "publishConfig": {
57
55
  "access": "restricted",