@0perator/operator 0.1.284 → 0.1.313

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 (99) hide show
  1. package/README.md +24 -2
  2. package/dist/acp/agent.js +3 -2
  3. package/dist/acp/config-options.js +15 -1
  4. package/dist/acp/tool-map.js +2 -1
  5. package/dist/auth/commands.js +69 -13
  6. package/dist/autonomy/agent-cli.js +304 -0
  7. package/dist/autonomy/cloud-agent.js +439 -0
  8. package/dist/autonomy/cron-lifecycle.js +78 -0
  9. package/dist/autonomy/cron-lock.js +121 -0
  10. package/dist/autonomy/cron.js +216 -43
  11. package/dist/autonomy/delegate.js +5 -1
  12. package/dist/autonomy/incidents.js +135 -0
  13. package/dist/autonomy/session-factory.js +25 -16
  14. package/dist/background/index.js +40 -0
  15. package/dist/bus/inbox.js +20 -0
  16. package/dist/classifier/config.js +47 -0
  17. package/dist/classifier/modes.js +41 -0
  18. package/dist/classifier/types.js +1 -0
  19. package/dist/cli.js +529 -53
  20. package/dist/config/features.js +69 -0
  21. package/dist/config/persona.js +118 -99
  22. package/dist/config/scaffold.js +15 -0
  23. package/dist/config/settings.js +96 -6
  24. package/dist/consolidation/sleep.js +73 -11
  25. package/dist/engine/agent.js +275 -18
  26. package/dist/engine/anthropic-chat.js +343 -0
  27. package/dist/engine/aurora.js +101 -13
  28. package/dist/engine/batch-scheduler.js +41 -9
  29. package/dist/engine/classifier.js +85 -0
  30. package/dist/engine/compaction.js +24 -5
  31. package/dist/engine/fast-start.js +25 -0
  32. package/dist/engine/loop-guard.js +448 -0
  33. package/dist/engine/moa.js +5 -1
  34. package/dist/engine/net-error.js +24 -0
  35. package/dist/engine/repetition-guard.js +180 -0
  36. package/dist/engine/selfheal.js +8 -0
  37. package/dist/engine/toolcalls.js +51 -1
  38. package/dist/engine/verify-gate.js +2 -0
  39. package/dist/flywheel/processor.js +78 -31
  40. package/dist/flywheel/srft.js +13 -0
  41. package/dist/hooks/index.js +196 -0
  42. package/dist/mcp/config.js +21 -1
  43. package/dist/memory/index.js +0 -0
  44. package/dist/memory/providers.js +210 -0
  45. package/dist/memory/session-catalog.js +422 -0
  46. package/dist/memory/session-providers.js +121 -0
  47. package/dist/memory/session-sources.js +335 -0
  48. package/dist/memory/skylark.js +131 -0
  49. package/dist/models/bench.js +103 -0
  50. package/dist/models/registry.js +144 -0
  51. package/dist/models/switch.js +69 -0
  52. package/dist/observability/blackbox.js +37 -0
  53. package/dist/permissions/policy.js +31 -6
  54. package/dist/router/discovery.js +127 -0
  55. package/dist/router/models.js +117 -24
  56. package/dist/router/portal.js +100 -0
  57. package/dist/router/router.js +1 -1
  58. package/dist/services/preflight.js +55 -7
  59. package/dist/session.js +316 -46
  60. package/dist/tools/chauffeur.js +12 -0
  61. package/dist/tools/executor.js +19 -9
  62. package/dist/tools/find-files.js +483 -0
  63. package/dist/tools/git-pr.js +94 -0
  64. package/dist/tools/incident-tools.js +82 -0
  65. package/dist/tools/memory.js +12 -2
  66. package/dist/tools/registry.js +281 -85
  67. package/dist/tools/semantic-compress.js +124 -0
  68. package/dist/tools/shell-context.js +1 -0
  69. package/dist/tools/shell-jobs.js +160 -0
  70. package/dist/tools/shell-session.js +170 -4
  71. package/dist/tools/wave-tools.js +609 -0
  72. package/dist/tools/wave2-tools.js +411 -0
  73. package/dist/ui/App.js +15 -4
  74. package/dist/ui/BgPanel.js +30 -6
  75. package/dist/ui/Composer.js +11 -1
  76. package/dist/ui/QuestionPrompt.js +31 -11
  77. package/dist/ui/SessionPicker.js +86 -0
  78. package/dist/ui/StatusRule.js +5 -5
  79. package/dist/ui/ToolStep.js +2 -1
  80. package/dist/ui/Transcript.js +17 -1
  81. package/dist/ui/index.js +1 -1
  82. package/dist/ui/liveTools.js +21 -3
  83. package/dist/ui/slashCommands.js +2 -0
  84. package/dist/util/screenshots.js +74 -8
  85. package/dist/util/slash.js +2 -2
  86. package/package.json +8 -2
  87. package/dist/engine/cli.js +0 -1171
  88. package/dist/router/models.js.bak +0 -78
  89. package/dist/router/models.js.bak-1791259923 +0 -78
  90. package/dist/router/models.js.bak-pre-gateway +0 -78
  91. package/dist/router/models.js.bak-pre-patch2 +0 -78
  92. package/dist/router/models.js.bak2 +0 -78
  93. package/dist/services/model-autodetect.js +0 -240
  94. package/dist/tools/native-redirect.js +0 -140
  95. package/dist/tools/power-tools.js +0 -627
  96. package/dist/tools/registry.js.bak-1791259948 +0 -1914
  97. package/dist/tools/registry.js.bak-pre-plugins +0 -1914
  98. package/dist/ui/BusTray.js +0 -70
  99. package/dist/ui/resize.js +0 -160
@@ -0,0 +1,82 @@
1
+ import { openIncident, ackIncident, resolveIncident, formatIncidents } from "../autonomy/incidents.js";
2
+ const SEVERITIES = ["low", "medium", "high", "critical"];
3
+ const STATES = ["open", "acknowledged", "resolved"];
4
+ async function incidentOpenRun(args) {
5
+ const title = String(args.title ?? "").trim();
6
+ if (!title)
7
+ return "error: title required";
8
+ const severity = args.severity;
9
+ if (severity && !SEVERITIES.includes(severity))
10
+ return `error: severity must be one of ${SEVERITIES.join("|")}`;
11
+ const inc = await openIncident({
12
+ source: String(args.source ?? "operator"),
13
+ title,
14
+ detail: args.detail ? String(args.detail) : undefined,
15
+ severity,
16
+ jobId: args.job_id ? String(args.job_id) : undefined,
17
+ runId: args.run_id ? String(args.run_id) : undefined,
18
+ });
19
+ return `incident ${inc.id} [${inc.severity}] ${inc.state} — ${inc.title}`;
20
+ }
21
+ async function incidentAckRun(args) {
22
+ const id = String(args.id ?? "").trim();
23
+ if (!id)
24
+ return "error: id required";
25
+ return ackIncident(id);
26
+ }
27
+ async function incidentResolveRun(args) {
28
+ const id = String(args.id ?? "").trim();
29
+ const resolution = String(args.resolution ?? "").trim();
30
+ if (!id || !resolution)
31
+ return "error: id and resolution required";
32
+ return resolveIncident(id, resolution, args.resolved_by ? String(args.resolved_by) : undefined);
33
+ }
34
+ async function incidentListRun(args) {
35
+ const state = args.state;
36
+ if (state && !STATES.includes(state))
37
+ return `error: state must be one of ${STATES.join("|")}`;
38
+ const severity = args.severity;
39
+ if (severity && !SEVERITIES.includes(severity))
40
+ return `error: severity must be one of ${SEVERITIES.join("|")}`;
41
+ return formatIncidents({ state, severity });
42
+ }
43
+ export const INCIDENT_TOOLS = [
44
+ {
45
+ name: "incident_open", safe: false,
46
+ description: "Open an operational incident (or absorb into the existing open one for the same source+job). Cron failures open incidents automatically — use this for ad-hoc issues.",
47
+ parameters: { type: "object", properties: {
48
+ title: { type: "string" },
49
+ source: { type: "string", description: "source system (default: operator)" },
50
+ detail: { type: "string" },
51
+ severity: { type: "string", description: "low | medium | high | critical (default: medium)" },
52
+ job_id: { type: "string", description: "related cron job id (enables dedupe)" },
53
+ run_id: { type: "string", description: "related run id" },
54
+ }, required: ["title"] },
55
+ run: incidentOpenRun,
56
+ },
57
+ {
58
+ name: "incident_ack", safe: false,
59
+ description: "Acknowledge an open incident by id.",
60
+ parameters: { type: "object", properties: { id: { type: "string" } }, required: ["id"] },
61
+ run: incidentAckRun,
62
+ },
63
+ {
64
+ name: "incident_resolve", safe: false,
65
+ description: "Resolve an incident with a resolution note.",
66
+ parameters: { type: "object", properties: {
67
+ id: { type: "string" },
68
+ resolution: { type: "string" },
69
+ resolved_by: { type: "string" },
70
+ }, required: ["id", "resolution"] },
71
+ run: incidentResolveRun,
72
+ },
73
+ {
74
+ name: "incident_list", safe: true,
75
+ description: "List incidents, optionally filtered by state (open|acknowledged|resolved) or severity (low|medium|high|critical).",
76
+ parameters: { type: "object", properties: {
77
+ state: { type: "string" },
78
+ severity: { type: "string" },
79
+ } },
80
+ run: incidentListRun,
81
+ },
82
+ ];
@@ -78,6 +78,7 @@ export async function runMemoryTool(args) {
78
78
  text = fs.readFileSync(fp, "utf8");
79
79
  }
80
80
  catch { /* file may not exist yet */ }
81
+ const before = text.length; // headroom is computed against what was ALREADY there, not the op's own size
81
82
  for (const op of ops) {
82
83
  switch (op.action) {
83
84
  case "add":
@@ -105,8 +106,17 @@ export async function runMemoryTool(args) {
105
106
  }
106
107
  text = text.replace(/\n{3,}/g, "\n\n").trim() + "\n";
107
108
  const budget = BUDGETS[target];
108
- if (text.length > budget)
109
- return `error: result is ${text.length} chars, exceeds ${target} budget of ${budget} — reduce content`;
109
+ if (text.length > budget) {
110
+ // A retry that only trims the ADD's own content can never converge when the file was
111
+ // already near the cap — the error must say so, or an agent loops shrinking the wrong
112
+ // number forever (lived bug: MEMORY.md sat at 2164/2200, 8 retries, all still "too big").
113
+ const headroom = Math.max(0, budget - before);
114
+ const overBy = text.length - budget;
115
+ return `error: result is ${text.length} chars, exceeds ${target} budget of ${budget} by ${overBy} — ` +
116
+ `${TARGETS[target]} already holds ${before}/${budget} chars (${headroom} headroom before this op). ` +
117
+ `Shrinking only the new content will not be enough unless it fits in ${headroom} chars — ` +
118
+ `free room with action:"remove"/"replace" on a stale entry first, or write this elsewhere (it's unbounded there).`;
119
+ }
110
120
  fs.mkdirSync(path.dirname(fp), { recursive: true });
111
121
  fs.writeFileSync(fp, text);
112
122
  return `wrote ${TARGETS[target]} (${text.length}/${budget} chars, ${ops.length} op${ops.length === 1 ? "" : "s"} applied)`;