@0perator/operator 0.1.59 → 0.1.60

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/CHANGELOG.md CHANGED
@@ -4,6 +4,23 @@ Operator is AXE's terminal coding agent (npm `@0perator/operator`), running on t
4
4
  Newest first. Every release bumps `src/cli.tsx` VERSION + `package.json`, adds an entry here, and ships to
5
5
  npm + both git remotes (memjar/kode, axetechnologies/kode). Test counts are the full suite at that release.
6
6
 
7
+ ## 0.1.60 — 2026-09-22
8
+ - **`http_request` tool (capability #5).** A real HTTP client beyond `web_fetch`'s GET-and-scrape: any method
9
+ (GET/POST/PUT/PATCH/DELETE/HEAD), custom headers, a JSON (`json`) or raw (`body`) payload, bearer/basic auth,
10
+ redirects, timeout. Returns status + response headers + the capped body verbatim (no HTML stripping) — for
11
+ authenticated REST/GraphQL/webhook calls. safe:false (can mutate → gated when the policy is on).
12
+ - **`file_upload` tool (capability #7).** The push side Operator lacked: POST multipart/form-data (default,
13
+ `field` names the part) or PUT raw bytes (S3 presigned-PUT style), same bearer/basic auth as http_request.
14
+ safe:false (exfiltrates a file → gated; confirm the destination). btoa (not node Buffer) keeps both tools
15
+ neutral-bundle-safe; resolved auth secrets are never echoed into the result.
16
+ - **Drivable operating mode across host + web** (folds in the landed remote-control commit): `/mode
17
+ [plan|manual|auto]` (autonomous→auto, gated→manual); single `applyMode()` path for Shift+Tab / /mode / /plan
18
+ / follower frame keeps policy + plan flag + badge + capabilities in lockstep; `RemoteCapabilities.mode` is the
19
+ live 3-state ("gated" back-compat alias); "mode" in REMOTE_SAFE_COMMANDS. Web (0perator.co/remote) drives it.
20
+ - Capability roadmap (`docs/capabilities/`): #5 and #7 now SHIPPED; cloud/docker/ssh/monitoring/media-processing
21
+ are reachable via the fleet MCP gateway (`mcp:true`); webhook receiver (#8) + super daemon (#9) remain to build.
22
+ - Tests: 379/379 (5 new: http_request GET/POST-json/basic-auth, file_upload multipart + raw PUT).
23
+
7
24
  ## 0.1.59 — 2026-09-22
8
25
  Efficiency fixes for the failure the live screenshot caught: a filesystem-hunt task ran ~40 rounds of
9
26
  `find ~/ | grep | grep`, hit the per-command timeout, killed + reset the persistent shell (losing cwd/env)
package/dist/cli.js CHANGED
@@ -24,7 +24,7 @@ import { homedir, hostname } from "node:os";
24
24
  import { createHash } from "node:crypto";
25
25
  // RELEASE CHECKLIST (every bump): update this + package.json "version", ADD A CHANGELOG.md ENTRY
26
26
  // (improvements / fixes / tests), run the suite, then publish to npm + push both remotes.
27
- const VERSION = "0.1.59";
27
+ const VERSION = "0.1.60";
28
28
  // operator/settings.json (override path via KODE_TSI_SETTINGS), env vars still win — see config/settings.ts.
29
29
  const settings = loadSettings();
30
30
  // Propagate the resolved sandbox mode to the tool layer (registry reads KODE_SANDBOX at exec time).
@@ -262,6 +262,7 @@ const HELP = [
262
262
  " /audit [n] recent tool + control-plane events from the audit trail (default 15)",
263
263
  " /dashboard launch the live swarm console (watches every Operator session)",
264
264
  " /plan plan mode: read-only research + propose a plan (/plan again to execute)",
265
+ " /mode [plan|manual|auto] set operating mode (plan · manual · autonomous); also Shift+Tab to cycle",
265
266
  " /think extended reasoning: Aurora thinks before answering (/think again = off)",
266
267
  " /ultrathink deep, exhaustive reasoning for hard problems (/ultrathink again = off)",
267
268
  " /compact force-compact the conversation now",
@@ -293,6 +294,7 @@ const REMOTE_SAFE_COMMANDS = [
293
294
  { name: "audit", description: "recent tool + control-plane events from the audit trail", args: "[n]" },
294
295
  { name: "dashboard", description: "launch the live swarm console" },
295
296
  { name: "plan", description: "toggle plan mode (read-only research + propose a plan)" },
297
+ { name: "mode", description: "set operating mode: plan · manual · autonomous", args: "[plan|manual|auto]" },
296
298
  { name: "think", description: "toggle extended reasoning" },
297
299
  { name: "ultrathink", description: "toggle deep, exhaustive reasoning" },
298
300
  { name: "compact", description: "force-compact the conversation now" },
@@ -336,6 +338,9 @@ function Root() {
336
338
  // Operating mode, cycled with Shift+Tab (like Claude Code): auto (no gate) → manual (approve mutations)
337
339
  // → plan (read-only + propose) → auto. Auto=bypass policy, Manual=gated policy, Plan=session plan mode.
338
340
  const [opMode, setOpMode] = useState(settings.permissions.mode === "gated" ? "manual" : "auto");
341
+ // Ref mirror of opMode so buildCapabilities() reflects the LIVE mode synchronously (a follower's mode
342
+ // selector must light up the instant it changes, before React flushes the setOpMode state update).
343
+ const opModeRef = useRef(opMode);
339
344
  const [thinkMode, setThinkMode] = useState("off"); // /think, /ultrathink badge
340
345
  const [elapsed, setElapsed] = useState(0); // live seconds since the current turn started (ticked by a
341
346
  const turnStartRef = useRef(0); // timer, so the clock advances even during a long reasoning
@@ -478,7 +483,7 @@ function Root() {
478
483
  skills: [...skillsRef.current.entries()].map(([name, description]) => ({ name, description })),
479
484
  mcpServers: session.mcpServers().map((s) => ({ name: s.name, toolCount: s.tools.length, tools: s.tools })),
480
485
  models: session.modelRegistry().map((m) => ({ id: m.id, label: m.label, ctx: m.ctx ?? 0, kind: m.kind })),
481
- mode: settings.permissions.mode === "gated" ? "gated" : "auto", // "bypass"/"audit" both drive with no approval gate from a follower's POV
486
+ mode: opModeRef.current, // live operating mode (Plan/Manual/Autonomous) — a follower can read + drive it via /mode
482
487
  cwd: process.cwd(),
483
488
  model: session.currentModel(),
484
489
  });
@@ -703,6 +708,29 @@ function Root() {
703
708
  push({ kind: "message", message: { id: nextId(), role: "system", content: text } });
704
709
  remoteRef.current?.system(text);
705
710
  }, []);
711
+ // Single code path for a mode change — Shift+Tab (onCycleMode), the /mode slash command (local or
712
+ // driven by a remote follower), and /plan all funnel here so the policy, the plan flag, the status
713
+ // badge, and the follower-facing capabilities stay in lockstep. auto=Autonomous (bypass policy, no
714
+ // approvals), manual=gated (mutations ask), plan=read-only research (session plan mode).
715
+ const applyMode = useCallback((next, quiet) => {
716
+ if (next === "plan") {
717
+ session.setPlanMode(true);
718
+ }
719
+ else {
720
+ session.setPlanMode(false);
721
+ session.setPermissionMode(next === "auto" ? "bypass" : "gated");
722
+ }
723
+ opModeRef.current = next;
724
+ setPlanMode(next === "plan");
725
+ setOpMode(next);
726
+ if (!quiet)
727
+ sys(next === "auto"
728
+ ? "◆ mode → AUTONOMOUS — I execute without asking (shift+tab to cycle)"
729
+ : next === "manual"
730
+ ? "◈ mode → MANUAL — I ask before mutating (writes/edits/shell) (shift+tab to cycle)"
731
+ : "◔ mode → PLAN — read-only research + a proposed plan; nothing runs (shift+tab to cycle)");
732
+ remoteRef.current?.setCapabilities(buildCapabilities()); // re-sync attached followers' mode selector
733
+ }, [sys]);
706
734
  const handleSlash = useCallback(async (cmd) => {
707
735
  const [name, ...rest] = cmd.slice(1).split(/\s+/);
708
736
  const arg = rest.join(" ").trim();
@@ -849,13 +877,27 @@ function Root() {
849
877
  }
850
878
  case "plan": {
851
879
  const on = !s.inPlanMode();
852
- s.setPlanMode(on);
853
- setPlanMode(on);
880
+ applyMode(on ? "plan" : "auto", true); // policy + follower caps sync; custom message below
854
881
  sys(on
855
882
  ? "◔ plan mode ON — I'll research read-only and propose a plan; writes/edits/shell mutations are blocked. /plan again to approve + execute."
856
883
  : "plan mode OFF — back to normal execution.");
857
884
  break;
858
885
  }
886
+ case "mode": {
887
+ // Set the operating mode by name (owner OR a remote follower via a `command` frame). Mirrors
888
+ // Shift+Tab's cycle but addressable: /mode plan | manual | autonomous. No arg → report current.
889
+ const a = arg.toLowerCase();
890
+ const target = a === "plan" ? "plan"
891
+ : (a === "manual" || a === "gated") ? "manual"
892
+ : (a === "auto" || a === "autonomous" || a === "bypass") ? "auto"
893
+ : null;
894
+ if (!target) {
895
+ sys(`mode is ${opModeRef.current === "auto" ? "AUTONOMOUS" : opModeRef.current.toUpperCase()} — usage: /mode plan | manual | autonomous`);
896
+ break;
897
+ }
898
+ applyMode(target);
899
+ break;
900
+ }
859
901
  case "think": {
860
902
  const on = s.currentThinkMode() !== "think";
861
903
  s.setThinkMode(on ? "think" : "off");
@@ -1034,7 +1076,7 @@ function Root() {
1034
1076
  }
1035
1077
  default: sys(`unknown command /${name} — try /help`);
1036
1078
  }
1037
- }, [exit, sys, bg, authUser, approval, settleApproval, settleQuestion]);
1079
+ }, [exit, sys, bg, authUser, approval, settleApproval, settleQuestion, applyMode]);
1038
1080
  const onSubmit = useCallback((text) => {
1039
1081
  const t = text.trim();
1040
1082
  if (t.startsWith("/")) {
@@ -1048,22 +1090,10 @@ function Root() {
1048
1090
  // Shift+Tab cycles the operating mode (Claude-Code parity). auto→manual→plan→auto. Auto drives with
1049
1091
  // no approval gate; Manual gates mutating tools through the approve() bridge; Plan is read-only research.
1050
1092
  const onCycleMode = useCallback(() => {
1051
- setOpMode((cur) => {
1052
- const next = cur === "auto" ? "manual" : cur === "manual" ? "plan" : "auto";
1053
- if (next === "plan") {
1054
- session.setPlanMode(true);
1055
- }
1056
- else {
1057
- session.setPlanMode(false);
1058
- session.setPermissionMode(next === "auto" ? "bypass" : "gated");
1059
- }
1060
- setPlanMode(next === "plan");
1061
- sys(next === "auto" ? "◆ mode → AUTO — I execute without asking (shift+tab to cycle)"
1062
- : next === "manual" ? "◈ mode → MANUAL — I ask before mutating (writes/edits/shell) (shift+tab to cycle)"
1063
- : "◔ mode → PLAN — read-only research + a proposed plan; nothing runs (shift+tab to cycle)");
1064
- return next;
1065
- });
1066
- }, [sys]);
1093
+ const cur = opModeRef.current;
1094
+ const next = cur === "auto" ? "manual" : cur === "manual" ? "plan" : "auto";
1095
+ applyMode(next);
1096
+ }, [applyMode]);
1067
1097
  const onInterrupt = useCallback(() => {
1068
1098
  if (statusRef.current === "idle") {
1069
1099
  bg.dispose();
@@ -469,6 +469,116 @@ async function webFetch(args) {
469
469
  clearTimeout(timer);
470
470
  }
471
471
  }
472
+ // Shared auth-header builder for the HTTP tools. `bearer` → Authorization: Bearer; `basic` {user,pass} →
473
+ // Authorization: Basic base64. btoa (not node Buffer) keeps this neutral-bundle-safe. The resolved secret
474
+ // is set on the outgoing request only — never returned in the tool result.
475
+ function authHeaders(args) {
476
+ const h = {};
477
+ if (args.bearer)
478
+ h["Authorization"] = `Bearer ${str(args.bearer)}`;
479
+ else if (args.basic && typeof args.basic === "object") {
480
+ const b = args.basic;
481
+ h["Authorization"] = "Basic " + btoa(`${str(b.user)}:${str(b.pass)}`);
482
+ }
483
+ return h;
484
+ }
485
+ const HTTP_BODY_CAP = 200_000; // cap a response body so one huge payload can't balloon the model's context
486
+ // Real HTTP client — the capability gap beyond web_fetch's dumb GET-and-scrape. Any method, custom
487
+ // headers, JSON or raw body, bearer/basic auth, follow redirects, timeout. Returns status + headers +
488
+ // (capped) body verbatim (no HTML-stripping — this is for APIs, not pages). safe:false: it can POST/PUT/
489
+ // DELETE (mutation), so it's gated when the permission policy is on.
490
+ async function httpRequest(args) {
491
+ const url = str(args.url);
492
+ if (!/^https?:\/\//i.test(url))
493
+ return "error: http_request needs an http(s) URL";
494
+ const method = str(args.method, "GET").toUpperCase();
495
+ const headers = { "User-Agent": "operator/kode-tsi", ...authHeaders(args) };
496
+ if (args.headers && typeof args.headers === "object") {
497
+ for (const [k, v] of Object.entries(args.headers))
498
+ headers[k] = String(v);
499
+ }
500
+ let body;
501
+ if (args.json !== undefined) {
502
+ body = JSON.stringify(args.json);
503
+ if (!Object.keys(headers).some((k) => k.toLowerCase() === "content-type"))
504
+ headers["Content-Type"] = "application/json";
505
+ }
506
+ else if (args.body !== undefined) {
507
+ body = str(args.body);
508
+ }
509
+ const noBody = method === "GET" || method === "HEAD";
510
+ const timeoutMs = Number(args.timeout_ms ?? 30_000);
511
+ const ctrl = new AbortController();
512
+ const timer = setTimeout(() => ctrl.abort(), timeoutMs);
513
+ try {
514
+ const res = await fetch(url, { method, headers, body: noBody ? undefined : body, signal: ctrl.signal, redirect: "follow" });
515
+ const text = await res.text().catch(() => "");
516
+ const hdrs = [...res.headers.entries()].map(([k, v]) => `${k}: ${v}`).slice(0, 50).join("\n");
517
+ const capped = text.length > HTTP_BODY_CAP ? `${text.slice(0, HTTP_BODY_CAP)}\n…[body truncated, ${text.length - HTTP_BODY_CAP} more chars]` : text;
518
+ return `HTTP ${res.status} ${res.statusText}\n${hdrs}\n\n${capped}`.trim();
519
+ }
520
+ catch (e) {
521
+ const m = e instanceof Error ? e.message : String(e);
522
+ return `error: http_request ${method} ${url}: ${/abort/i.test(m) ? `timed out after ${timeoutMs}ms` : m}`;
523
+ }
524
+ finally {
525
+ clearTimeout(timer);
526
+ }
527
+ }
528
+ // Upload a local file to a URL — the missing push side (Operator could download, never upload). POST
529
+ // multipart/form-data (default, the common upload contract) or PUT raw bytes. Supports the same
530
+ // bearer/basic auth + custom headers as http_request. safe:false: it exfiltrates a file to an external
531
+ // service, so it's gated when the policy is on and should confirm the destination.
532
+ async function fileUpload(args) {
533
+ const path = expandPath(str(args.path));
534
+ const url = str(args.url);
535
+ if (!path)
536
+ return "error: file_upload needs a path";
537
+ if (!/^https?:\/\//i.test(url))
538
+ return "error: file_upload needs an http(s) url";
539
+ const method = str(args.method, "POST").toUpperCase();
540
+ const field = str(args.field, "file");
541
+ const headers = { ...authHeaders(args) };
542
+ if (args.headers && typeof args.headers === "object") {
543
+ for (const [k, v] of Object.entries(args.headers))
544
+ headers[k] = String(v);
545
+ }
546
+ const { readFile } = await nodeImport("node:fs/promises");
547
+ const { basename } = await nodeImport("node:path");
548
+ let data;
549
+ try {
550
+ data = await readFile(path);
551
+ }
552
+ catch (e) {
553
+ return `error: cannot read ${path}: ${e.message}`;
554
+ }
555
+ const timeoutMs = Number(args.timeout_ms ?? 120_000); // uploads can be large — generous default
556
+ const ctrl = new AbortController();
557
+ const timer = setTimeout(() => ctrl.abort(), timeoutMs);
558
+ try {
559
+ let bodyInit;
560
+ if (method === "PUT") {
561
+ bodyInit = data; // raw bytes (S3 presigned-PUT style); node accepts Uint8Array
562
+ if (!Object.keys(headers).some((k) => k.toLowerCase() === "content-type"))
563
+ headers["Content-Type"] = "application/octet-stream";
564
+ }
565
+ else {
566
+ const form = new FormData();
567
+ form.append(field, new Blob([data]), basename(path));
568
+ bodyInit = form; // multipart; fetch sets the Content-Type boundary itself
569
+ }
570
+ const res = await fetch(url, { method, headers, body: bodyInit, signal: ctrl.signal, redirect: "follow" });
571
+ const text = (await res.text().catch(() => "")).slice(0, HTTP_BODY_CAP);
572
+ return `HTTP ${res.status} ${res.statusText} — uploaded ${basename(path)} (${data.byteLength} bytes)${text ? `\n\n${text}` : ""}`.trim();
573
+ }
574
+ catch (e) {
575
+ const m = e instanceof Error ? e.message : String(e);
576
+ return `error: file_upload ${method} ${url}: ${/abort/i.test(m) ? `timed out after ${timeoutMs}ms` : m}`;
577
+ }
578
+ finally {
579
+ clearTimeout(timer);
580
+ }
581
+ }
472
582
  const bgJobs = new Map();
473
583
  let bgSeq = 0;
474
584
  const BG_MAX_RUNNING = 8; // cap concurrent live jobs — a background tool must never let the agent fork-bomb the host
@@ -727,6 +837,34 @@ const TOOLS = [
727
837
  }, required: ["url"] },
728
838
  run: webFetch,
729
839
  },
840
+ {
841
+ name: "http_request", safe: false,
842
+ description: "Make a real HTTP request to any API — full control beyond web_fetch's dumb GET. Any method (GET/POST/PUT/PATCH/DELETE/HEAD), custom headers, a JSON body (`json`) or raw `body`, and bearer/basic auth. Returns status + response headers + the (capped) body verbatim (no HTML stripping). Use for authenticated REST/GraphQL calls, webhooks, and service integrations.",
843
+ parameters: { type: "object", properties: {
844
+ url: { type: "string", description: "the http(s) URL" },
845
+ method: { type: "string", description: "HTTP method (default GET)" },
846
+ headers: { type: "object", description: "request headers as a flat object" },
847
+ json: { description: "a JSON-serializable body (sets Content-Type: application/json)" },
848
+ body: { type: "string", description: "raw request body (ignored if `json` is set)" },
849
+ bearer: { type: "string", description: "convenience: sets Authorization: Bearer <token>" },
850
+ basic: { type: "object", description: "convenience: {user, pass} → Authorization: Basic" },
851
+ timeout_ms: { type: "number", description: "default 30000" },
852
+ }, required: ["url"] },
853
+ run: httpRequest,
854
+ },
855
+ {
856
+ name: "file_upload", safe: false,
857
+ description: "Upload a local file to a URL — the push side web_fetch/download lacks. POST multipart/form-data (default; set `field` for the form field name) or PUT raw bytes (S3 presigned-PUT style). Supports the same bearer/basic auth + custom headers as http_request. Confirm the destination — this sends your file to an external service.",
858
+ parameters: { type: "object", properties: {
859
+ path: { type: "string", description: "local file path to upload" },
860
+ url: { type: "string", description: "destination http(s) URL" },
861
+ method: { type: "string", enum: ["POST", "PUT"], description: "POST=multipart (default), PUT=raw bytes" },
862
+ field: { type: "string", description: "multipart form field name (default \"file\")" },
863
+ headers: { type: "object" }, bearer: { type: "string" }, basic: { type: "object" },
864
+ timeout_ms: { type: "number", description: "default 120000" },
865
+ }, required: ["path", "url"] },
866
+ run: fileUpload,
867
+ },
730
868
  {
731
869
  name: "web_search", safe: true,
732
870
  description: "Search the web (via the AXE autopilot SERP service, or a self-hosted SearXNG) and return ranked title/url/snippet results. Read-only. Follow up with web_fetch to read a result.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0perator/operator",
3
- "version": "0.1.59",
3
+ "version": "0.1.60",
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": {