@0perator/operator 0.1.285 → 0.1.321
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 +24 -2
- package/dist/acp/agent.js +2 -1
- package/dist/acp/config-options.js +3 -1
- package/dist/acp/tool-map.js +2 -1
- package/dist/auth/commands.js +69 -13
- package/dist/autonomy/agent-cli.js +308 -0
- package/dist/autonomy/cloud-agent.js +439 -0
- package/dist/autonomy/cron-lifecycle.js +78 -0
- package/dist/autonomy/cron-lock.js +121 -0
- package/dist/autonomy/cron.js +217 -44
- package/dist/autonomy/delegate.js +34 -5
- package/dist/autonomy/incidents.js +135 -0
- package/dist/autonomy/index.js +22 -0
- package/dist/autonomy/profile.js +1 -1
- package/dist/autonomy/session-factory.js +25 -16
- package/dist/background/index.js +40 -0
- package/dist/browser/cdp.js +1 -1
- package/dist/bus/inbox.js +20 -0
- package/dist/classifier/config.js +47 -0
- package/dist/classifier/modes.js +41 -0
- package/dist/classifier/types.js +1 -0
- package/dist/cli.js +645 -93
- package/dist/config/features.js +69 -0
- package/dist/config/persona.js +143 -107
- package/dist/config/scaffold.js +15 -0
- package/dist/config/settings.js +107 -12
- package/dist/consolidation/sleep.js +73 -11
- package/dist/engine/agent.js +279 -20
- package/dist/engine/anthropic-chat.js +343 -0
- package/dist/engine/aurora.js +109 -16
- package/dist/engine/batch-scheduler.js +41 -9
- package/dist/engine/classifier.js +85 -0
- package/dist/engine/compaction.js +25 -6
- package/dist/engine/fast-start.js +25 -0
- package/dist/engine/loop-guard.js +448 -0
- package/dist/engine/net-error.js +24 -0
- package/dist/engine/repetition-guard.js +180 -0
- package/dist/engine/router-adapter.js +1 -0
- package/dist/engine/selfheal.js +8 -0
- package/dist/engine/toolcalls.js +51 -1
- package/dist/engine/verify-gate.js +2 -0
- package/dist/flywheel/processor.js +78 -31
- package/dist/flywheel/srft.js +13 -0
- package/dist/hooks/index.js +196 -0
- package/dist/idle/activity.js +20 -0
- package/dist/idle/index.js +5 -0
- package/dist/idle/monitor.js +71 -0
- package/dist/idle/policy.js +66 -0
- package/dist/idle/proc.js +22 -0
- package/dist/idle/reaper.js +69 -0
- package/dist/idle/session-record.js +59 -0
- package/dist/index.js +1 -1
- package/dist/mcp/config.js +93 -15
- package/dist/mcp/index.js +9 -2
- package/dist/memory/index.js +0 -0
- package/dist/memory/providers.js +210 -0
- package/dist/memory/session-catalog.js +422 -0
- package/dist/memory/session-providers.js +121 -0
- package/dist/memory/session-sources.js +335 -0
- package/dist/memory/skylark.js +131 -0
- package/dist/models/bench.js +103 -0
- package/dist/models/registry.js +144 -0
- package/dist/models/switch.js +69 -0
- package/dist/observability/blackbox.js +37 -0
- package/dist/permissions/index.js +22 -7
- package/dist/permissions/policy.js +31 -6
- package/dist/permissions/tier.js +1 -1
- package/dist/remote/host.js +20 -2
- package/dist/remote/safe-commands.js +38 -0
- package/dist/router/discovery.js +127 -0
- package/dist/router/models.js +107 -16
- package/dist/router/portal.js +100 -0
- package/dist/router/router.js +1 -1
- package/dist/services/preflight.js +108 -8
- package/dist/services/store-sync.js +111 -0
- package/dist/session-teardown.js +10 -1
- package/dist/session.js +338 -46
- package/dist/skills/catalogue.js +1 -1
- package/dist/tools/chauffeur-native.js +155 -0
- package/dist/tools/chauffeur.js +26 -3
- package/dist/tools/download.js +229 -0
- package/dist/tools/executor.js +19 -9
- package/dist/tools/find-files.js +483 -0
- package/dist/tools/git-pr.js +94 -0
- package/dist/tools/incident-tools.js +82 -0
- package/dist/tools/memory.js +12 -2
- package/dist/tools/monitoring-tools.js +312 -0
- package/dist/tools/paths.js +154 -0
- package/dist/tools/registry.js +582 -95
- package/dist/tools/semantic-compress.js +124 -0
- package/dist/tools/shell-context.js +1 -0
- package/dist/tools/shell-jobs.js +163 -0
- package/dist/tools/shell-session.js +174 -6
- package/dist/tools/tool-output-spill.js +1 -1
- package/dist/tools/wave-tools.js +609 -0
- package/dist/tools/wave2-tools.js +411 -0
- package/dist/ui/App.js +15 -4
- package/dist/ui/BgPanel.js +30 -6
- package/dist/ui/Composer.js +15 -2
- package/dist/ui/QuestionPrompt.js +32 -12
- package/dist/ui/SessionPicker.js +86 -0
- package/dist/ui/StatusRule.js +5 -5
- package/dist/ui/ToolStep.js +17 -1
- package/dist/ui/Transcript.js +17 -1
- package/dist/ui/index.js +1 -1
- package/dist/ui/liveTools.js +21 -3
- package/dist/ui/slashCommands.js +2 -0
- package/dist/util/mentions.js +1 -1
- package/dist/util/screenshots.js +74 -8
- package/dist/util/slash.js +2 -2
- package/dist/vault/store.js +1 -1
- package/mcp/README.md +88 -0
- package/mcp/ocr-macos.swift +45 -0
- package/mcp/powertools-media.mjs +464 -0
- package/mcp/powertools-toolbox.mjs +1114 -0
- package/mcp/powertools.md +210 -0
- package/mcp/powertools.mjs +861 -0
- package/package.json +9 -2
package/dist/background/index.js
CHANGED
|
@@ -23,6 +23,33 @@ function summarizeTask(task) {
|
|
|
23
23
|
s = s.charAt(0).toUpperCase() + s.slice(1);
|
|
24
24
|
return s.length > 56 ? s.slice(0, 55) + "…" : (s || task.replace(/\s+/g, " ").slice(0, 56));
|
|
25
25
|
}
|
|
26
|
+
const PROGRESS_MAX = 80; // chars of the derived mission line kept for the panel
|
|
27
|
+
// Turn a chunk of the child's live reasoning into a one-line "what I'm doing now" mission phrase: the LAST
|
|
28
|
+
// sentence-like clause is its most recent intent. Pure + exported so the derivation is unit-testable without a
|
|
29
|
+
// running sub-agent. Returns undefined when there's nothing meaningful yet, so the caller keeps the prior line.
|
|
30
|
+
export function progressFromReasoning(reasoning) {
|
|
31
|
+
if (!reasoning)
|
|
32
|
+
return undefined;
|
|
33
|
+
const t = reasoning.replace(/^…\s*/, "").replace(/\s+/g, " ").trim();
|
|
34
|
+
if (!t)
|
|
35
|
+
return undefined;
|
|
36
|
+
const clauses = t.split(/(?<=[.!?。!?])\s+/).map((s) => s.trim()).filter(Boolean);
|
|
37
|
+
const last = (clauses.length ? clauses[clauses.length - 1] : t).replace(/^[-*•\d.)\s]+/, "").trim();
|
|
38
|
+
if (!last)
|
|
39
|
+
return undefined;
|
|
40
|
+
return last.length > PROGRESS_MAX ? last.slice(0, PROGRESS_MAX - 1) + "…" : last;
|
|
41
|
+
}
|
|
42
|
+
const OUTPUT_TAIL_MAX = 72; // chars of the latest tool result surfaced in the panel
|
|
43
|
+
// The last non-blank line of a tool result, whitespace-collapsed and capped — a glanceable "what came back"
|
|
44
|
+
// without dumping a multi-KB payload into the live frame. Pure + exported for testing.
|
|
45
|
+
export function outputTail(result) {
|
|
46
|
+
const lines = result.split("\n").map((l) => l.trim()).filter(Boolean);
|
|
47
|
+
const last = lines.length ? lines[lines.length - 1] : "";
|
|
48
|
+
if (!last)
|
|
49
|
+
return undefined;
|
|
50
|
+
const one = last.replace(/\s+/g, " ");
|
|
51
|
+
return one.length > OUTPUT_TAIL_MAX ? one.slice(0, OUTPUT_TAIL_MAX - 1) + "…" : one;
|
|
52
|
+
}
|
|
26
53
|
export class BackgroundAgents {
|
|
27
54
|
makeSession;
|
|
28
55
|
onChange;
|
|
@@ -237,6 +264,11 @@ export class BackgroundAgents {
|
|
|
237
264
|
onReasoning: (chunk) => {
|
|
238
265
|
const t = ((info.thought ?? "") + chunk).replace(/\s+/g, " ");
|
|
239
266
|
info.thought = t.length > THOUGHT_MAX ? "…" + t.slice(-(THOUGHT_MAX - 1)) : t;
|
|
267
|
+
// Continually-updating mission line ("what I'm doing now") — persists across tool batches (unlike
|
|
268
|
+
// thought, cleared below) so the owner always sees the current objective, not just the raw tool.
|
|
269
|
+
const p = progressFromReasoning(info.thought);
|
|
270
|
+
if (p)
|
|
271
|
+
info.progress = p;
|
|
240
272
|
const now = Date.now();
|
|
241
273
|
if (now - lastThoughtEmit > THOUGHT_EMIT_MS) {
|
|
242
274
|
lastThoughtEmit = now;
|
|
@@ -255,6 +287,10 @@ export class BackgroundAgents {
|
|
|
255
287
|
info.round = (info.round ?? 0) + 1;
|
|
256
288
|
const settled = events.map((e) => ({ name: e.name, arg: shortArg(e.args), running: false }));
|
|
257
289
|
info.steps = [...(info.steps ?? []).filter((s) => !s.running), ...settled].slice(-RECENT_STEPS);
|
|
290
|
+
// Keep a short tail of the latest tool's output so the owner sees the work's EFFECT, not just its name
|
|
291
|
+
// — the "I have no visibility on what anyone is doing" gap. Skipped for an empty/errored result.
|
|
292
|
+
const lastOut = events.length ? String(events[events.length - 1].result ?? "").trim() : "";
|
|
293
|
+
info.lastOutput = lastOut ? outputTail(lastOut) : undefined;
|
|
258
294
|
info.thought = undefined;
|
|
259
295
|
this.touchProgress(id); // a completed round is unambiguous progress — reset the stall clock
|
|
260
296
|
this.onChange();
|
|
@@ -311,6 +347,8 @@ export class BackgroundAgents {
|
|
|
311
347
|
info.tokens = total; // authoritative llama.cpp count summed across sends
|
|
312
348
|
info.durationMs = r.durationMs ?? (Date.now() - (info.startedAt ?? Date.now()));
|
|
313
349
|
info.thought = undefined; // no live thinking once finished
|
|
350
|
+
info.progress = undefined;
|
|
351
|
+
info.lastOutput = undefined; // live mission/output lines belong to a WORKING agent
|
|
314
352
|
if (info.steps)
|
|
315
353
|
info.steps = info.steps.map((s) => ({ ...s, running: false }));
|
|
316
354
|
this.clearStallTimer(id);
|
|
@@ -338,6 +376,8 @@ export class BackgroundAgents {
|
|
|
338
376
|
catch (e) {
|
|
339
377
|
info.status = "stopped";
|
|
340
378
|
info.thought = undefined;
|
|
379
|
+
info.progress = undefined;
|
|
380
|
+
info.lastOutput = undefined;
|
|
341
381
|
if (info.steps)
|
|
342
382
|
info.steps = info.steps.map((s) => ({ ...s, running: false }));
|
|
343
383
|
this.clearStallTimer(id);
|
package/dist/browser/cdp.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Browser automation core (HV3-02) — a zero-new-dependency Chrome DevTools Protocol client.
|
|
2
2
|
// WHY: web_fetch is a dumb GET; agents need a REAL page — JS-rendered content, forms, clicks, and
|
|
3
|
-
// session state across calls. The discipline inherited from
|
|
3
|
+
// session state across calls. The discipline inherited from the reference browser layer: TEXT-FIRST —
|
|
4
4
|
// read pages as DOM text / JS eval; screenshots only when a human must see pixels.
|
|
5
5
|
// Purity: EVERY node builtin is reached via lazy getBuiltinModule/import (same contract as
|
|
6
6
|
// src/tools/shell-session.ts) — registry.ts imports this module's wrapper, and run() bodies only
|
package/dist/bus/inbox.js
CHANGED
|
@@ -58,6 +58,26 @@ export function pollBus(agent = selfAgent(), opts = {}) {
|
|
|
58
58
|
}
|
|
59
59
|
return out;
|
|
60
60
|
}
|
|
61
|
+
/** Build the wake-prompt text for an idle autonomous session from a batch of incoming bus messages, applying an
|
|
62
|
+
* optional sender allowlist. Returns null when nothing should wake a turn (empty batch, or none match the
|
|
63
|
+
* allowlist). PURE + tested — the cli.tsx poller calls this, then routes the text to the submit/queue path.
|
|
64
|
+
* Contract: a rendered bus message is only displayed; THIS is what puts a peer message into the model's context
|
|
65
|
+
* as an actionable turn. `allow` unset/empty = any sender wakes; otherwise only senders in the list. */
|
|
66
|
+
export function buildMentorWake(incoming, allow) {
|
|
67
|
+
const toWake = allow && allow.length ? incoming.filter((m) => allow.includes(m.from)) : incoming;
|
|
68
|
+
if (!toWake.length)
|
|
69
|
+
return null;
|
|
70
|
+
return (`[mentor-wake] ${toWake.length} new bus message(s) arrived — review and act on them now:\n\n` +
|
|
71
|
+
toWake.map((m) => `--- from ${m.from}${m.subject ? ` · ${m.subject}` : ""} (${m.ts}) ---\n${m.body}`).join("\n\n"));
|
|
72
|
+
}
|
|
73
|
+
/** Per-source cooldown selection for wake-on-mentor (ping-pong guard). From a buffer of pending wake messages,
|
|
74
|
+
* return the subset whose source last woke the session at least `cooldownMs` ago — a source's FIRST message is
|
|
75
|
+
* always ready (no prior stamp). The caller stamps `lastBySource` for each returned source and drops them from
|
|
76
|
+
* the buffer; messages NOT returned stay buffered and coalesce into the next wake after the window, so a source
|
|
77
|
+
* firing rapidly can't drive back-to-back turns and nothing is lost. Pure + tested. */
|
|
78
|
+
export function selectReadyWakes(buffer, lastBySource, now, cooldownMs) {
|
|
79
|
+
return buffer.filter((m) => now - (lastBySource.get(m.from) ?? 0) >= cooldownMs);
|
|
80
|
+
}
|
|
61
81
|
/** Read the archive of messages `agent` SENT — the switchboard CLI/lib mirrors a copy into sent/ on every
|
|
62
82
|
* send so this session can surface its OWN outbound traffic ("you sent X to Y") inline, the counterpart to
|
|
63
83
|
* pollBus. Same oldest-first, consume-once (move to sent-read/), corrupt-skip discipline. [] when no bus. */
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** The single "proceed" label for the act-vs-ask gate; every OTHER candidate is an ASK signal. */
|
|
2
|
+
export const ACT_LABEL = "act now";
|
|
3
|
+
/** Default ASK signals — overridable via settings.classifier.askLabels without touching code. */
|
|
4
|
+
export const DEFAULT_ASK_LABELS = [
|
|
5
|
+
"needs user options or confirmation",
|
|
6
|
+
"ambiguous scope",
|
|
7
|
+
"heavy or irreversible work",
|
|
8
|
+
];
|
|
9
|
+
const MODE_DEFAULTS = {
|
|
10
|
+
fast: { askMinScore: 0.60, tauAbs: 0.40, tauMargin: 0.15, onAbstain: "act", onDegraded: "act" },
|
|
11
|
+
safe: { askMinScore: 0.30, tauAbs: 0.55, tauMargin: 0.25, onAbstain: "ask", onDegraded: "ask" },
|
|
12
|
+
};
|
|
13
|
+
const IRREVERSIBLE_DEFAULTS = {
|
|
14
|
+
labels: ["pentest", "fleet_ops", "delete_destructive"],
|
|
15
|
+
tauIrrev: { fast: 0.20, safe: 0.10 },
|
|
16
|
+
keywordPrefilter: ["rm -rf", "find -delete", "DROP ", "DELETE ", "TRUNCATE", "force-push", "systemctl", "launchctl bootout", "rotate key"],
|
|
17
|
+
};
|
|
18
|
+
/** The 9 intent-route labels (topic axis). Kept here as the single source; the tier map lives with the job. */
|
|
19
|
+
export const ROUTE_LABELS = [
|
|
20
|
+
"research", "tool_call", "chat_simple", "chat_complex", "code", "creative", "nl_to_sql", "pentest", "fleet_ops",
|
|
21
|
+
];
|
|
22
|
+
export const DEFAULT_ENDPOINT = "http://127.0.0.1:8400";
|
|
23
|
+
/** Resolve the full classifier config for the current settings. */
|
|
24
|
+
export function classifierConfig(s) {
|
|
25
|
+
const c = s?.classifier ?? {};
|
|
26
|
+
return {
|
|
27
|
+
endpoint: c.endpoint ?? DEFAULT_ENDPOINT,
|
|
28
|
+
apiKey: c.apiKey,
|
|
29
|
+
actAsk: {
|
|
30
|
+
actLabel: ACT_LABEL,
|
|
31
|
+
askLabels: c.askLabels ?? [...DEFAULT_ASK_LABELS],
|
|
32
|
+
/** legacy single knob; still honored as a per-mode askMinScore override when set */
|
|
33
|
+
legacyMinScore: c.gateMinScore,
|
|
34
|
+
},
|
|
35
|
+
intentRoute: { labels: [...ROUTE_LABELS] },
|
|
36
|
+
irreversible: IRREVERSIBLE_DEFAULTS,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/** Mode thresholds, with the legacy `gateMinScore` honored as an askMinScore override if the caller set it. */
|
|
40
|
+
export function modeThresholds(mode, s) {
|
|
41
|
+
const base = MODE_DEFAULTS[mode];
|
|
42
|
+
const legacy = s?.classifier?.gateMinScore;
|
|
43
|
+
return typeof legacy === "number" ? { ...base, askMinScore: legacy } : base;
|
|
44
|
+
}
|
|
45
|
+
export function irreversibleConfig(_s) {
|
|
46
|
+
return IRREVERSIBLE_DEFAULTS;
|
|
47
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { isFeatureEnabled } from "../config/features.js";
|
|
2
|
+
const MODES = ["off", "fast", "safe"];
|
|
3
|
+
/** Parse a mode string (env or settings); undefined (unset/unrecognized) lets resolution fall through. */
|
|
4
|
+
function parseMode(v) {
|
|
5
|
+
if (!v)
|
|
6
|
+
return undefined;
|
|
7
|
+
const t = v.trim().toLowerCase();
|
|
8
|
+
return MODES.includes(t) ? t : undefined;
|
|
9
|
+
}
|
|
10
|
+
/** Resolve the active mode. FIRST decisive wins:
|
|
11
|
+
* 1. KODE_FEATURES_OFF=1 → off (the master kill-switch still rules everything).
|
|
12
|
+
* 2. env KODE_CLASSIFIER_MODE ∈ off|fast|safe.
|
|
13
|
+
* 3. settings.classifier.mode.
|
|
14
|
+
* 4. BACK-COMPAT: legacy `classifierGate` feature on (settings or KODE_FEATURE_CLASSIFIER_GATE) → safe,
|
|
15
|
+
* so the one knob people already set keeps meaning what it meant.
|
|
16
|
+
* 5. default off. */
|
|
17
|
+
export function resolveMode(settings) {
|
|
18
|
+
if (process.env.KODE_FEATURES_OFF === "1")
|
|
19
|
+
return "off";
|
|
20
|
+
const env = parseMode(process.env.KODE_CLASSIFIER_MODE);
|
|
21
|
+
if (env)
|
|
22
|
+
return env;
|
|
23
|
+
const configured = parseMode(settings?.classifier?.mode);
|
|
24
|
+
if (configured)
|
|
25
|
+
return configured;
|
|
26
|
+
if (isFeatureEnabled("classifierGate", settings))
|
|
27
|
+
return "safe"; // legacy flag → safe, nobody's config changes silently
|
|
28
|
+
return "off";
|
|
29
|
+
}
|
|
30
|
+
/** Which jobs each mode runs, and whether a job may block the turn. Adding a mode = one row; adding a job to a
|
|
31
|
+
* mode = one entry. `blocking:false` everywhere today — a job surfaces a directive, it never hard-blocks.
|
|
32
|
+
* NOTE `safe` does NOT drop the speed job: being careful and being fast-routed aren't exclusive; `fast` is
|
|
33
|
+
* the one that drops safety. */
|
|
34
|
+
export const MODE_JOBS = {
|
|
35
|
+
off: [],
|
|
36
|
+
fast: [{ job: "intent-route", blocking: false }],
|
|
37
|
+
safe: [
|
|
38
|
+
{ job: "intent-route", blocking: false },
|
|
39
|
+
{ job: "act-ask", blocking: false },
|
|
40
|
+
],
|
|
41
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|