@0perator/operator 0.1.31 → 0.1.33

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/dist/cli.js CHANGED
@@ -18,7 +18,7 @@ import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
18
18
  import { join } from "node:path";
19
19
  import { homedir, hostname } from "node:os";
20
20
  import { createHash } from "node:crypto";
21
- const VERSION = "0.1.31";
21
+ const VERSION = "0.1.33";
22
22
  // operator/settings.json (override path via KODE_TSI_SETTINGS), env vars still win — see config/settings.ts.
23
23
  const settings = loadSettings();
24
24
  // Propagate the resolved sandbox mode to the tool layer (registry reads KODE_SANDBOX at exec time).
@@ -104,7 +104,7 @@ function buildRouter() {
104
104
  }
105
105
  // Project context: auto-load a per-repo instructions file (AGENTS.md / CLAUDE.md / .operator/AGENTS.md)
106
106
  // from the working dir and append it to the system prompt, so Operator picks up house rules, conventions
107
- // and build commands the way Claude Code / Codex do. First match wins; capped so a huge file can't blow
107
+ // and build commands the way modern coding agents do. First match wins; capped so a huge file can't blow
108
108
  // the prompt. Best-effort — a missing file is normal.
109
109
  function loadProjectContext() {
110
110
  for (const name of ["AGENTS.md", "CLAUDE.md", ".operator/AGENTS.md", "OPERATOR.md"]) {
@@ -118,7 +118,11 @@ function loadProjectContext() {
118
118
  return "";
119
119
  }
120
120
  const SYSTEM_PROMPT = (settings.systemPrompt ??
121
- `You are Operator, a terse local terminal coding agent. Use your tools to inspect and edit the ` +
121
+ `You are Operator, AXE's terminal coding agent — built by AXE, running on AXE's Aurora model. Refer to ` +
122
+ `yourself as Operator and to the platform as AXE; never call yourself or the platform Claude, ` +
123
+ `Anthropic, or any other vendor. When you encounter files or directories on disk named "claude", ` +
124
+ `".claude", "anthropic", etc., describe them neutrally (by their literal path, or as "AI tooling ` +
125
+ `files") — do not attribute them to a vendor. Use your tools to inspect and edit the ` +
122
126
  `workspace; prefer doing over explaining. Answer concisely.\n## This machine\nWorking dir: ${process.cwd()}` +
123
127
  `\nContext window: 1,048,576 tokens (1M) — you run on the Aurora model served locally with a full ` +
124
128
  `1M-token context. You can hold very large files and long histories; do not claim a smaller limit.` +
@@ -289,12 +293,17 @@ function Root() {
289
293
  // health, so a cold box self-heals instead of dropping the owner at "start it yourself and relaunch".
290
294
  let reports = [];
291
295
  try {
292
- const { ensureServices } = await import("./services/preflight.js");
293
- reports = await ensureServices({
296
+ const preflight = await import("./services/preflight.js");
297
+ reports = await preflight.ensureServices({
294
298
  aurora: { base: settings.endpoints.aurora.base, ...settings.services?.aurora },
295
299
  autopilot: settings.services?.autopilot,
296
300
  onProgress: setBootDetail,
297
301
  });
302
+ // If the lever COLD-STARTED Aurora, prime it (fire-and-forget) so the first real turn doesn't
303
+ // eat the graph/Metal warmup. Skipped when Aurora was already up (state "up").
304
+ if (reports.find((r) => r.name === "aurora")?.state === "started") {
305
+ void preflight.warmAurora(settings.endpoints.aurora.base, settings.endpoints.aurora.model);
306
+ }
298
307
  }
299
308
  catch { /* preflight is best-effort — fall through to the authoritative health check */ }
300
309
  const ok = await session.health().catch(() => false);
@@ -733,7 +742,7 @@ if (process.argv[2] === "auth") {
733
742
  const { runAuth } = await import("./auth/commands.js");
734
743
  process.exit(await runAuth(process.argv.slice(3)));
735
744
  }
736
- // `operator update` (bareword, like `claude update`) and `operator --update` both self-update.
745
+ // `operator update` (bareword) and `operator --update` both self-update.
737
746
  if (process.argv[2] === "update" || process.argv.includes("--update")) {
738
747
  const { runUpdate } = await import("./update.js");
739
748
  process.exit(await runUpdate());
@@ -107,6 +107,19 @@ export async function ensureServices(cfg) {
107
107
  }
108
108
  return reports;
109
109
  }
110
+ /** Prime a just-started (cold) Aurora with a 1-token request so the FIRST real turn doesn't pay the
111
+ * graph/Metal-shader warmup (the plist runs --no-warmup, so otherwise the owner's first turn eats it).
112
+ * Fire-and-forget: never awaited from boot, never throws — a failed warmup just means the old behavior. */
113
+ export async function warmAurora(base, model) {
114
+ try {
115
+ await fetch(`${base.replace(/\/$/, "")}/v1/chat/completions`, {
116
+ method: "POST",
117
+ headers: { "content-type": "application/json" },
118
+ body: JSON.stringify({ model, messages: [{ role: "user", content: "warmup" }], max_tokens: 1, temperature: 0 }),
119
+ });
120
+ }
121
+ catch { /* best-effort — warmup failing just restores the cold-first-turn behavior */ }
122
+ }
110
123
  /** Tear down ONLY the session-scoped services on exit. Aurora and autopilot are shared, always-on, and
111
124
  * owned by launchd — Operator never stops them (other clients depend on :8097). SearXNG is the one
112
125
  * service Operator owns end to end. Best-effort; safe to call more than once. */
@@ -137,16 +137,30 @@ async function grepSearch(args) {
137
137
  const path = str(args.path, ".");
138
138
  if (!pattern)
139
139
  return "error: no pattern given";
140
- const flags = ["-rn", "-I", "--exclude-dir=.git", "--exclude-dir=node_modules", "--exclude=.operator-session.json"];
140
+ // -s suppresses errors for unreadable/special files (sockets, FIFOs, permission-denied) that a
141
+ // recursive grep over a real dir (e.g. /private/tmp, full of IPC sockets) inevitably hits; without it
142
+ // grep exits 2 and the tool used to report a hard failure even when it HAD found matches.
143
+ const flags = ["-rns", "-I", "--exclude-dir=.git", "--exclude-dir=node_modules", "--exclude=.operator-session.json"];
141
144
  if (args.glob)
142
145
  flags.push(`--include=${str(args.glob)}`);
143
146
  try {
144
- const { stdout } = await pexecFile("grep", [...flags, "-E", pattern, path], { maxBuffer: 10 * 1024 * 1024 });
147
+ // A hard timeout+SIGKILL guards against a pathological special file grep can BLOCK on: a socket
148
+ // errors immediately, but a FIFO with no writer hangs grep on open forever. Killed grep still leaves
149
+ // whatever it matched in stdout (handled in the catch), so a real dir with a stray pipe can't wedge
150
+ // the agent.
151
+ const { stdout } = await pexecFile("grep", [...flags, "-E", pattern, path], { maxBuffer: 10 * 1024 * 1024, timeout: 20_000, killSignal: "SIGKILL" });
145
152
  return capMatches(stdout);
146
153
  }
147
154
  catch (e) {
155
+ // grep exit codes: 0=match, 1=no match, 2=error. With -r, grep still emits every match it DID find
156
+ // before exiting 2 on an unreadable file (or being killed on timeout) — so prefer stdout when present;
157
+ // only a truly empty result is an error worth surfacing.
158
+ if (e.stdout && String(e.stdout).trim())
159
+ return capMatches(String(e.stdout));
148
160
  if (e.code === 1)
149
161
  return "(no matches)";
162
+ if (e.killed)
163
+ return "(search timed out — narrow the path; a blocking special file may be present)";
150
164
  return `error: ${e.stderr || e.message}`;
151
165
  }
152
166
  }
package/dist/update.js CHANGED
@@ -1,4 +1,4 @@
1
- // `operator update` — self-update, mirroring `claude update`. Two install shapes:
1
+ // `operator update` — self-update (bareword, like a CLI self-updater). Two install shapes:
2
2
  // • npm-global → the published package on the registry; update = reinstall @latest.
3
3
  // • source/dev → a git checkout linked via `npm link`; update = pull + rebuild.
4
4
  // We detect the shape from where THIS module resolves: a checkout still has a .git above it;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0perator/operator",
3
- "version": "0.1.31",
3
+ "version": "0.1.33",
4
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.",
5
5
  "type": "module",
6
6
  "bin": {