@0perator/operator 0.1.354 → 0.1.355-next.0

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 CHANGED
@@ -71,7 +71,7 @@ npm install -g @0perator/operator # every box runs the release; `operator up
71
71
  operator # interactive session (`0p` is the short name)
72
72
  operator --resume # reload the last conversation in this directory
73
73
  ```
74
- Dev: `npm install && npm run dev`, or `scripts/operator-dev.sh` installed as `operator-dev` for unreleased `main`.
74
+ Dev: `npm install && npm run dev`, or `scripts/operator-dev.sh` installed as `operator-dev` for unreleased `develop`.
75
75
 
76
76
  ### Headless — `operator run`
77
77
  One task, no terminal UI, for SSH, CI, cron and other agents (the shape of `codex exec` and `hermes -z`):
@@ -8,7 +8,7 @@ const KINDS = {
8
8
  file_read: "read", read_files: "read", list_directory: "read", git_status: "read", session_read: "read",
9
9
  skill_fetch: "read", skill_list: "read", task_list: "read", image_analyze: "read", video_analyze: "read",
10
10
  grep_search: "search", search: "search", find_files: "search", memory_search: "search", session_search: "search", web_search: "search",
11
- file_write: "edit", file_edit: "edit", memory_store: "edit", skill_save: "edit", scratchpad: "edit", session_handoff: "edit",
11
+ file_write: "edit", file_edit: "edit", memory_store: "edit", skill_save: "edit", skill_publish: "edit", scratchpad: "edit", session_handoff: "edit",
12
12
  bash: "execute", shell_exec: "execute", shell_background: "execute", bash_kill: "execute", bash_output: "execute",
13
13
  git_command: "execute", checkpoint: "execute", cronjob: "execute",
14
14
  web_fetch: "fetch", http_request: "fetch", browser: "fetch", browser_read: "fetch",
@@ -174,7 +174,7 @@ function sendWithTimeout(send, ms, interrupt) {
174
174
  const msg = (e) => (e instanceof Error ? e.message : String(e));
175
175
  // ── The `delegate_task` tool (registry wires run: runDelegateTask) ──────────
176
176
  /**
177
- * Run `args.task` on a sub-agent backed by `args.model` (default: autonomy/subagent-model.ts — the MoA specialist, the owner's setting, else gpt-oss-20b) and return its final answer, or an
177
+ * Run `args.task` on a sub-agent backed by `args.model` (default: autonomy/subagent-model.ts — the MoA specialist, the owner's setting, else the `subagent` capability) and return its final answer, or an
178
178
  * `error: ...` string (the tool contract: never throws). Result size is bounded downstream — the executor's
179
179
  * capToolResult spills anything over 40KB to disk and hands the planner a re-readable pointer.
180
180
  */
@@ -1,9 +1,10 @@
1
1
  // Which model a sub-agent runs on — one answer for delegate_task and spawn_agent, resolved per spawn: the MoA
2
- // specialist under /model moa, else the owner's setting, else gpt-oss-20b, the shipped default (owner, 10/31: "make this
3
- // application wide so me and others can test"; arena: 35/36 tasks, median 47 s). Every install's registry has it, reached
4
- // through the local router or api.0perator.co. Node-free (pure).
2
+ // specialist under /model moa, else the owner's setting, else the `subagent` capability, the shipped default. A capability
3
+ // is a name the gateway resolves (the portal's aliases), so the fleet picks the best healthy model and no client names one
4
+ // (owner, 11/04; supersedes the 10/31 default of gpt-oss-20b, arena: 35/36 tasks, median 47 s). Every install's registry has
5
+ // it, reached through the local router or api.0perator.co. Node-free (pure).
5
6
  import { moaTeam } from "../engine/moa.js";
6
- export const DEFAULT_SUBAGENT_MODEL = "gpt-oss-20b";
7
+ export const DEFAULT_SUBAGENT_MODEL = "subagent";
7
8
  export function subagentModelFor(settings, activeModel) {
8
9
  activeModel ??= settings.activeModel;
9
10
  if (activeModel === "moa") {
package/dist/cli.js CHANGED
@@ -141,7 +141,7 @@ if (process.argv.includes("--version") || process.argv.includes("-V")) {
141
141
  }
142
142
  if (process.argv.includes("--help")) {
143
143
  process.stdout.write(mastheadLines(`v${VERSION}`).join("\n") +
144
- "\n\nUsage:\n operator start the interactive session\n 0p short for operator (every subcommand works)\n operator --resume resume the last session in this directory\n operator update update to the latest release\n operator --fullscreen fullscreen layout: composer pinned to the bottom (or settings.ui.fullscreen)\n operator auth sign in / manage your AXE account\n operator gateway the local model runtime: start | stop | status | health | logs\n operator toolchain the llama-server store: status | verify | install | activate | rollback | migrate | which\n operator run <task>|- run one task headless (--model, --permissions, --output json, --cwd)\n operator selfimprove backfill [--since YYYY-MM-DD] [--dry-run]\n turn looped turns and mentor pairs into lessons\n operator --version print the version\n");
144
+ "\n\nUsage:\n operator start the interactive session\n 0p short for operator (every subcommand works)\n operator --resume resume the last session in this directory\n operator update update to the latest release\n operator update --next install the next prerelease (built from develop); --latest goes back\n operator --fullscreen fullscreen layout: composer pinned to the bottom (or settings.ui.fullscreen)\n operator auth sign in / manage your AXE account\n operator gateway the local model runtime: start | stop | status | health | logs\n operator toolchain the llama-server store: status | verify | install | activate | rollback | migrate | which\n operator run <task>|- run one task headless (--model, --permissions, --output json, --cwd)\n operator selfimprove backfill [--since YYYY-MM-DD] [--dry-run]\n turn looped turns and mentor pairs into lessons\n operator --version print the version\n");
145
145
  process.exit(0);
146
146
  }
147
147
  // `operator selfimprove backfill …` — offline: folds the flywheel's looped turns and the mentor pairs into the global
@@ -3633,10 +3633,10 @@ if (process.argv[2] === "toolchain") {
3633
3633
  const { runToolchain } = await import("./toolchain-cli.js");
3634
3634
  process.exit(runToolchain(process.argv.slice(3)));
3635
3635
  }
3636
- // `operator update` (bareword) and `operator --update` both self-update.
3636
+ // `operator update` (bareword) and `operator --update` both self-update; `--next` / `--latest` pick the npm channel.
3637
3637
  if (process.argv[2] === "update" || process.argv.includes("--update")) {
3638
3638
  const { runUpdate } = await import("./update.js");
3639
- process.exit(await runUpdate());
3639
+ process.exit(await runUpdate(process.argv.slice(2)));
3640
3640
  }
3641
3641
  // Autonomous operation (autonomy/**): `operator run/loop/board/routine/dream` run headless, WITHOUT the
3642
3642
  // Ink TUI — the same pre-shell dispatch pattern as auth/update above. dispatchAutonomy returns an exit
@@ -250,7 +250,7 @@ export function loadHandoff() {
250
250
  // cli.tsx (interactive) and the headless factory call it — so an unattended run behaves like the TUI.
251
251
  // `ctxTokens` is the active model's real window; `interactive` adds the sections only a foreground
252
252
  // session can act on (spawn_agent).
253
- export function basePersona(cwd = process.cwd(), opts = {}) {
253
+ export function basePersona(_cwd = process.cwd(), opts = {}) {
254
254
  const ctx = opts.ctxTokens;
255
255
  const ctxLine = ctx !== undefined && Number.isFinite(ctx) && ctx > 0
256
256
  ? `\nContext window: ${Math.round(ctx).toLocaleString("en-US")} tokens (${Math.round(ctx / 1024)}K) — the real limit of ` +
@@ -139,6 +139,13 @@ export const BUILTIN_MODELS = [
139
139
  // the V1 vendor keys ship, reintroduce a byo:"axe" SKU as a SEPARATE connector id, never by re-gating this one.
140
140
  { id: "axe-aurora-300k", tier: "power", label: "Aurora Code 1", params: "35B-A3B", box: "cloud", kind: "single", desc: "remote shared slot via api.0perator.co (api.axe.onl as fallback) — contended decode measured 1-4.6 tok/s vs local 24-47; cold >~100K prefills can hit the Cloudflare ~125s edge cutoff", endpoint: GATEWAY_BASE, endpoints: [GATEWAY_BASE, LEGACY_GATEWAY_BASE], model: "aurora-code-1", ctx: 307200, transport: "openai", hidden: true },
141
141
  { id: "operator-128k", tier: "economy", label: "Aurora Code 1", params: "35B-A3B", box: "JL2", kind: "single", desc: "128K context, lighter RAM (:8096) — slot not served on this fleet today; hidden from the picker, resolves by id when the slot comes up", endpoint: "http://127.0.0.1:8096/v1", model: "aurora-code-1", ctx: 131072, hidden: true },
142
+ // ── capabilities (0.1.355) ──────────────────────────────────────────────────────────────────────────────
143
+ // A capability is a name the gateway resolves (the portal's aliases and routes), so the owner asks for a KIND of worker and
144
+ // the fleet answers with its best healthy model: the strongest resident one first, parallel delegations spilling down the
145
+ // chain instead of queueing. Swapping or promoting a model moves a pointer on the server and no client changes. Hidden: never
146
+ // a picker row and never offered by tier (profilesByTier skips hidden rows), reached by id (delegate_task, spawn_agent). `ctx`
147
+ // is the smallest window any model in the chain serves, so compaction is safe wherever the request lands.
148
+ { id: "subagent", tier: "power", label: "Sub-agent", box: "fleet", kind: "single", desc: "capability: the default sub-agent — the gateway picks the best healthy model", endpoint: LOCAL_GATEWAY_BASE, endpoints: [LOCAL_GATEWAY_BASE, GATEWAY_BASE], endpointModels: ["subagent", "subagent"], model: "subagent", ctx: 262144, hidden: true },
142
149
  // ── orchestrated ────────────────────────────────────────────────────────────────────────────────────────
143
150
  { id: "moa", tier: "power_turbo", label: "MOA", box: "mixture of agents", kind: "orchestrated", desc: "the team slot — Cortana plans each request into steps and hands them to gpt-oss-20b specialists, checks their work, writes the answer and reads any images (settings.moa overrides)" },
144
151
  ];
@@ -12,6 +12,7 @@ import { listLocalSkills } from "../config/skills-index.js";
12
12
  import { listCatalogue, catalogueDir } from "./catalogue.js";
13
13
  import { OPERATOR_URLS, operatorToken, registry } from "../tools/registry.js";
14
14
  import { operatorTrustedUrl } from "../engine/aurora.js";
15
+ import { PRODUCT_API_HOST } from "../config/product-hosts.js";
15
16
  const words = (q) => q.toLowerCase().split(/\s+/).filter(Boolean);
16
17
  /** Every query word appears in the haystack — the same AND rule session search uses. */
17
18
  const matches = (q, ...hay) => {
@@ -63,7 +64,9 @@ export function toolSource() {
63
64
  },
64
65
  };
65
66
  }
66
- /** The hub bases, in the order they are tried. */
67
+ /** The hub bases, in the order they are tried.
68
+ * An explicit override (env, then the home's skills.json) wins; otherwise the marketplace gateway (api.0perator.co) is
69
+ * tried first, for signed-in subscribers. An unauthenticated caller or a 401/403/404 falls through to the next base. */
67
70
  export function hubBases(env = process.env) {
68
71
  const fromEnv = (env.KODE_SKILLS_HUB ?? "").split(",").map((s) => s.trim()).filter(Boolean);
69
72
  let fromHome = [];
@@ -73,7 +76,8 @@ export function hubBases(env = process.env) {
73
76
  fromHome = cfg.hub.endpoints.filter((x) => typeof x === "string");
74
77
  }
75
78
  catch { /* no hub config in this home */ }
76
- return [...new Set([...fromEnv, ...fromHome, ...OPERATOR_URLS].map((b) => b.replace(/\/+$/, "")))];
79
+ const gateway = `https://${PRODUCT_API_HOST}`;
80
+ return [...new Set([...fromEnv, ...fromHome, gateway, ...OPERATOR_URLS].map((b) => b.replace(/\/+$/, "")))];
77
81
  }
78
82
  const hubOrigin = (src) => {
79
83
  if (!src)
@@ -10,6 +10,7 @@ import { indexSessions, readSession, searchSessions } from "../memory/session-in
10
10
  import { formatHits, indexCatalog, readCatalogSession, searchCatalog, sessionSearchConfig, SESSION_SCOPES } from "../memory/session-catalog.js";
11
11
  import { listLocalSkills, localSkillsDir as profileSkillsDir, resolveSkillFile } from "../config/skills-index.js";
12
12
  import { operatorPath } from "../config/home.js";
13
+ import { PRODUCT_API_HOST } from "../config/product-hosts.js";
13
14
  import { ownChild } from "../util/owned-children.js";
14
15
  import { BG_MAX_RUNNING, createJob, finishJob, newJobId, pruneShellJobs, runningJobCount, shellJobs, stopShellJob, trackJobOutput } from "./shell-jobs.js";
15
16
  import { pexecFile } from "./exec.js";
@@ -2791,6 +2792,16 @@ const TOOLS = [
2791
2792
  }, required: ["name", "content"] },
2792
2793
  run: (a) => skillSave(str(a.name), str(a.content)),
2793
2794
  },
2795
+ {
2796
+ name: "skill_publish", safe: false,
2797
+ contract: { v: 1, effects: ["read", "egress"], audit: ["name", "version"] },
2798
+ description: "Publish one of your profile skills to the AXE marketplace under your account. Needs sign-in and an active subscription; it lands quarantined and unverified, visible to you (skill_fetch scope mine) until it is reviewed.",
2799
+ parameters: { type: "object", properties: {
2800
+ name: { type: "string", description: "the profile skill to publish (as saved by skill_save)" },
2801
+ version: { type: "string", description: "semantic version, default 1.0.0; a published version cannot be replaced" },
2802
+ }, required: ["name"] },
2803
+ run: (a) => skillPublish(str(a.name), str(a.version).trim() || "1.0.0"),
2804
+ },
2794
2805
  {
2795
2806
  name: "memory", safe: false,
2796
2807
  description: "Batch-edit memories/MEMORY.md or memories/USER.md: each operation adds, replaces or removes text; budget-checked, one atomic write.",
@@ -2858,7 +2869,7 @@ const TOOLS = [
2858
2869
  },
2859
2870
  {
2860
2871
  name: "delegate_task", safe: false,
2861
- description: `Run ONE self-contained subtask on a sub-agent (a headless Operator session with its own tools) and get its final answer; blocks. It has NO memory of this conversation and cannot ask — \`task\` must carry every path, constraint and the exact output wanted. \`model\`: any /model id; OMIT IT to use the owner's configured default sub-agent (almost always right). Never name a model you have not seen answer in this fleet (an unloaded one fails); tool-heavy work (repo review, exploration, web research, debugging) needs a strong tool-driver such as "cortana". Connected cloud providers work too ("claude-sonnet", BYO: ${BYO_DELEGATE_PROVIDERS}); one without a stored key is refused with the command to store it. Don't delegate a single tool call; sub-agents cannot delegate further and can mutate the workspace.`,
2872
+ description: `Run ONE self-contained subtask on a sub-agent (a headless Operator session with its own tools) and get its final answer; blocks. It has NO memory of this conversation and cannot ask — \`task\` must carry every path, constraint and the exact output wanted. \`model\`: any /model id; OMIT IT to use the owner's configured default sub-agent (almost always right). Never name a model you have not seen answer in this fleet (an unloaded one fails); tool-heavy work (repo review, exploration, web research, debugging) belongs on the default, which the gateway fills with a strong tool-driver and spills parallel delegations across the fleet. Connected cloud providers work too ("claude-sonnet", BYO: ${BYO_DELEGATE_PROVIDERS}); one without a stored key is refused with the command to store it. Don't delegate a single tool call; sub-agents cannot delegate further and can mutate the workspace.`,
2862
2873
  parameters: { type: "object", properties: {
2863
2874
  task: { type: "string", description: "the complete, self-contained subtask — the sub-agent sees only this" },
2864
2875
  model: { type: "string", description: "registry model id; omit for the owner's configured default sub-agent" },
@@ -3159,6 +3170,40 @@ async function skillSave(name, content) {
3159
3170
  return `error saving skill: ${e.message}`;
3160
3171
  }
3161
3172
  }
3173
+ const MARKETPLACE_URL = (process.env.KODE_MARKETPLACE_URL ?? `https://${PRODUCT_API_HOST}`).replace(/\/+$/, "");
3174
+ const publishFailures = {
3175
+ 401: "sign in first (operator login)",
3176
+ 403: "the marketplace needs an active subscription on your account",
3177
+ 409: "that version is already published; bump the version",
3178
+ 413: "the skill is too large for the marketplace",
3179
+ 429: "too many publishes this hour; try again later",
3180
+ };
3181
+ async function skillPublish(name, version) {
3182
+ if (!name)
3183
+ return "error: skill_publish needs a name";
3184
+ const local = (await localSkills()).find((ls) => ls.name === name || slugify(ls.name) === slugify(name));
3185
+ if (!local)
3186
+ return `error: no profile skill '${name}'; save it with skill_save first`;
3187
+ const token = await operatorToken();
3188
+ if (!token)
3189
+ return publishFailures[401];
3190
+ try {
3191
+ const { readFile } = await nodeImport("node:fs/promises");
3192
+ const content = await readFile(local.file, "utf8");
3193
+ const res = await fetch(`${MARKETPLACE_URL}/v1/skills`, {
3194
+ method: "POST",
3195
+ headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}`, "User-Agent": "KODE/0.9 (axe-tsi)" },
3196
+ body: JSON.stringify({ name: slugify(local.name), version, content, format: "skillmd" }),
3197
+ signal: AbortSignal.timeout(20000),
3198
+ });
3199
+ if (res.ok)
3200
+ return `published ${slugify(local.name)}@${version} to the marketplace (quarantined until reviewed; skill_fetch ${slugify(local.name)} scope mine reads it back).`;
3201
+ return `error: ${publishFailures[res.status] ?? `the marketplace answered ${res.status}`}`;
3202
+ }
3203
+ catch (e) {
3204
+ return `error publishing skill: ${e.message}`;
3205
+ }
3206
+ }
3162
3207
  export async function localSkills() {
3163
3208
  return listLocalSkills();
3164
3209
  }
@@ -15,7 +15,7 @@ const KIND_RULES = [
15
15
  [/(read_file|read_files|^read$|^cat$|open_file|file_read)/i, "read"],
16
16
  [/(file_write|write_file|^write$|edit|apply_patch|str_replace|notebook|create_file|insert)/i, "write"],
17
17
  [/(web_search|web_fetch|^web|http|browser|^fetch$|curl|^url|download)/i, "web"],
18
- [/(skill_fetch|skill_save|^skill$)/i, "skill"],
18
+ [/(skill_fetch|skill_save|skill_publish|^skill$)/i, "skill"],
19
19
  [/(search|grep|ripgrep|glob|^find$|skill_list|lookup)/i, "search"],
20
20
  [/(^git|git_|checkpoint|^commit|^diff|^branch)/i, "git"], // before shell: "git_command" contains "command"
21
21
  [/(bash|shell|^run$|exec|command|script)/i, "shell"],
package/dist/update.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // `operator update` — self-update (bareword, like a CLI self-updater). Two install shapes:
2
- // • npm-global → the published package on the registry; update = reinstall @latest.
2
+ // • npm-global → the published package on the registry; update = reinstall a channel's dist-tag: @latest (main's
3
+ // releases, the default and `--latest`) or @next (`--next`: 0.1.N-next.K prereleases from develop).
3
4
  // • source/dev → a git checkout linked via `npm link`; update = pull + rebuild.
4
5
  // We detect the shape from where THIS module resolves: a checkout still has a .git above it;
5
6
  // a global install lives under a node_modules tree with no repo around it.
@@ -8,6 +9,15 @@ import { existsSync, readFileSync } from "node:fs";
8
9
  import { dirname, join, resolve } from "node:path";
9
10
  import { fileURLToPath } from "node:url";
10
11
  const PKG = "@0perator/operator"; // published (private) scope/name — keep in sync with package.json
12
+ /** `--next` or `--latest` (the default); `explicit` says a flag picked it. Both flags is a usage error. */
13
+ export function updateChannel(args) {
14
+ const next = args.includes("--next"), latest = args.includes("--latest");
15
+ if (next && latest)
16
+ return { error: "operator update: --next and --latest are two channels — pass one.\n" };
17
+ return { channel: next ? "next" : "latest", explicit: next || latest };
18
+ }
19
+ // A next build is a 0.1.N-next.K prerelease; a release is a plain 0.1.N.
20
+ const channelOf = (version) => (/-next\.\d+$/.test(version) ? "next" : "latest");
11
21
  // Walk up from the running file looking for a .git dir (source checkout) before we hit a
12
22
  // node_modules boundary (global install). Returns the repo root, or null for a packaged install.
13
23
  function findRepoRoot() {
@@ -28,8 +38,78 @@ function run(cmd, args, cwd) {
28
38
  const r = spawnSync(cmd, args, { stdio: "inherit", cwd });
29
39
  return r.status ?? 1;
30
40
  }
31
- export async function runUpdate() {
41
+ /** The registry's dist-tags for PKG (`{ latest: "0.1.352", next: "0.1.353-next.0" }`), or why they can't be read. */
42
+ function distTags() {
43
+ const r = spawnSync("npm", ["view", PKG, "dist-tags", "--json"], { encoding: "utf8" });
44
+ let out;
45
+ try {
46
+ const parsed = JSON.parse(r.stdout);
47
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed))
48
+ out = parsed;
49
+ }
50
+ catch { /* not JSON */ }
51
+ if (r.status === 0 && out && !("error" in out))
52
+ return { tags: out };
53
+ // With --json npm puts its own error on stdout ({ error: { code, summary } }); stderr ends with the log file's path.
54
+ const e = out?.error;
55
+ if (e?.code || e?.summary)
56
+ return { error: [e.code, e.summary].filter(Boolean).join(" ") };
57
+ const lines = `${r.stderr ?? ""}`.split("\n").map((l) => l.trim()).filter((l) => l && !/complete log of this run/i.test(l));
58
+ return { error: lines.slice(0, 2).join(" · ") || `npm exited ${r.status ?? r.signal}` };
59
+ }
60
+ function versionAt(pkgJson) {
61
+ try {
62
+ return JSON.parse(readFileSync(pkgJson, "utf8")).version;
63
+ }
64
+ catch {
65
+ return undefined;
66
+ }
67
+ }
68
+ /** npm-global update: reinstall PKG@<channel>, naming the channel and version before and after. It never falls back to
69
+ * the other channel: a tag the registry doesn't have, or a registry it can't read, installs nothing and exits 1.
70
+ * Before and after are read from THIS install's package.json (npm replaces it in place), not from `npm root -g`: npm
71
+ * redacts UUID-shaped path segments in its output as `***`. */
72
+ export function installChannel(channel, pkgJson = fileURLToPath(new URL("../package.json", import.meta.url))) {
73
+ const current = versionAt(pkgJson) ?? "?";
74
+ const read = distTags();
75
+ if ("error" in read) {
76
+ process.stderr.write(`operator update: can't read ${PKG}'s channels from the registry (${read.error}) — nothing installed. ` +
77
+ `If ${PKG} is private, run \`npm login\` for the 0perator org first.\n`);
78
+ return 1;
79
+ }
80
+ const target = read.tags[channel];
81
+ if (!target) {
82
+ const has = Object.entries(read.tags).map(([tag, v]) => `${tag} ${v}`).join(", ") || "no tags";
83
+ process.stderr.write(`operator update: ${PKG} has no ${channel} channel on the registry yet (it has ${has}) — nothing installed.\n`);
84
+ return 1;
85
+ }
86
+ process.stderr.write(`operator update: v${current} (${channelOf(current)}) → ${PKG}@${channel} (v${target})\n`);
87
+ const code = run("npm", ["install", "-g", `${PKG}@${channel}`]);
88
+ if (code !== 0) {
89
+ process.stderr.write(`operator update: failed. If ${PKG} is private, run \`npm login\` for the 0perator org first.\n`);
90
+ return code;
91
+ }
92
+ const now = versionAt(pkgJson);
93
+ if (now !== target) {
94
+ process.stderr.write(`operator update: npm finished, but this operator (${dirname(pkgJson)}) is v${now ?? "?"}, not v${target} — npm's ` +
95
+ `global prefix may hold another install: check \`which -a operator\` and \`npm ls -g ${PKG}\`.\n`);
96
+ return 1;
97
+ }
98
+ process.stderr.write(`operator update: done — now v${now} (${channel}).\n`);
99
+ return 0;
100
+ }
101
+ export async function runUpdate(args = []) {
102
+ const pick = updateChannel(args);
103
+ if ("error" in pick) {
104
+ process.stderr.write(pick.error);
105
+ return 2;
106
+ }
32
107
  const repo = findRepoRoot();
108
+ if (repo && pick.explicit) {
109
+ process.stderr.write(`operator update: --${pick.channel} picks an npm channel, but this operator runs from the source checkout at ${repo}, ` +
110
+ `which updates by git. To install the ${pick.channel} channel instead: npm install -g ${PKG}@${pick.channel}\n`);
111
+ return 1;
112
+ }
33
113
  if (repo) {
34
114
  // kode-tsi lives in a subdir of the kode repo; build happens where package.json is.
35
115
  const pkgDir = existsSync(join(repo, "kode-tsi", "package.json")) ? join(repo, "kode-tsi") : repo;
@@ -77,11 +157,5 @@ export async function runUpdate() {
77
157
  }
78
158
  return code;
79
159
  }
80
- process.stderr.write(`operator update: reinstalling ${PKG}@latest from the registry\n`);
81
- const code = run("npm", ["install", "-g", `${PKG}@latest`]);
82
- if (code === 0)
83
- process.stderr.write("operator update: done.\n");
84
- else
85
- process.stderr.write(`operator update: failed. If ${PKG} is private, run \`npm login\` for the 0perator org first.\n`);
86
- return code;
160
+ return installChannel(pick.channel);
87
161
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0perator/operator",
3
- "version": "0.1.354",
3
+ "version": "0.1.355-next.0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "operator": "dist/cli.js",