@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.
Files changed (118) hide show
  1. package/README.md +24 -2
  2. package/dist/acp/agent.js +2 -1
  3. package/dist/acp/config-options.js +3 -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 +308 -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 +217 -44
  11. package/dist/autonomy/delegate.js +34 -5
  12. package/dist/autonomy/incidents.js +135 -0
  13. package/dist/autonomy/index.js +22 -0
  14. package/dist/autonomy/profile.js +1 -1
  15. package/dist/autonomy/session-factory.js +25 -16
  16. package/dist/background/index.js +40 -0
  17. package/dist/browser/cdp.js +1 -1
  18. package/dist/bus/inbox.js +20 -0
  19. package/dist/classifier/config.js +47 -0
  20. package/dist/classifier/modes.js +41 -0
  21. package/dist/classifier/types.js +1 -0
  22. package/dist/cli.js +645 -93
  23. package/dist/config/features.js +69 -0
  24. package/dist/config/persona.js +143 -107
  25. package/dist/config/scaffold.js +15 -0
  26. package/dist/config/settings.js +107 -12
  27. package/dist/consolidation/sleep.js +73 -11
  28. package/dist/engine/agent.js +279 -20
  29. package/dist/engine/anthropic-chat.js +343 -0
  30. package/dist/engine/aurora.js +109 -16
  31. package/dist/engine/batch-scheduler.js +41 -9
  32. package/dist/engine/classifier.js +85 -0
  33. package/dist/engine/compaction.js +25 -6
  34. package/dist/engine/fast-start.js +25 -0
  35. package/dist/engine/loop-guard.js +448 -0
  36. package/dist/engine/net-error.js +24 -0
  37. package/dist/engine/repetition-guard.js +180 -0
  38. package/dist/engine/router-adapter.js +1 -0
  39. package/dist/engine/selfheal.js +8 -0
  40. package/dist/engine/toolcalls.js +51 -1
  41. package/dist/engine/verify-gate.js +2 -0
  42. package/dist/flywheel/processor.js +78 -31
  43. package/dist/flywheel/srft.js +13 -0
  44. package/dist/hooks/index.js +196 -0
  45. package/dist/idle/activity.js +20 -0
  46. package/dist/idle/index.js +5 -0
  47. package/dist/idle/monitor.js +71 -0
  48. package/dist/idle/policy.js +66 -0
  49. package/dist/idle/proc.js +22 -0
  50. package/dist/idle/reaper.js +69 -0
  51. package/dist/idle/session-record.js +59 -0
  52. package/dist/index.js +1 -1
  53. package/dist/mcp/config.js +93 -15
  54. package/dist/mcp/index.js +9 -2
  55. package/dist/memory/index.js +0 -0
  56. package/dist/memory/providers.js +210 -0
  57. package/dist/memory/session-catalog.js +422 -0
  58. package/dist/memory/session-providers.js +121 -0
  59. package/dist/memory/session-sources.js +335 -0
  60. package/dist/memory/skylark.js +131 -0
  61. package/dist/models/bench.js +103 -0
  62. package/dist/models/registry.js +144 -0
  63. package/dist/models/switch.js +69 -0
  64. package/dist/observability/blackbox.js +37 -0
  65. package/dist/permissions/index.js +22 -7
  66. package/dist/permissions/policy.js +31 -6
  67. package/dist/permissions/tier.js +1 -1
  68. package/dist/remote/host.js +20 -2
  69. package/dist/remote/safe-commands.js +38 -0
  70. package/dist/router/discovery.js +127 -0
  71. package/dist/router/models.js +107 -16
  72. package/dist/router/portal.js +100 -0
  73. package/dist/router/router.js +1 -1
  74. package/dist/services/preflight.js +108 -8
  75. package/dist/services/store-sync.js +111 -0
  76. package/dist/session-teardown.js +10 -1
  77. package/dist/session.js +338 -46
  78. package/dist/skills/catalogue.js +1 -1
  79. package/dist/tools/chauffeur-native.js +155 -0
  80. package/dist/tools/chauffeur.js +26 -3
  81. package/dist/tools/download.js +229 -0
  82. package/dist/tools/executor.js +19 -9
  83. package/dist/tools/find-files.js +483 -0
  84. package/dist/tools/git-pr.js +94 -0
  85. package/dist/tools/incident-tools.js +82 -0
  86. package/dist/tools/memory.js +12 -2
  87. package/dist/tools/monitoring-tools.js +312 -0
  88. package/dist/tools/paths.js +154 -0
  89. package/dist/tools/registry.js +582 -95
  90. package/dist/tools/semantic-compress.js +124 -0
  91. package/dist/tools/shell-context.js +1 -0
  92. package/dist/tools/shell-jobs.js +163 -0
  93. package/dist/tools/shell-session.js +174 -6
  94. package/dist/tools/tool-output-spill.js +1 -1
  95. package/dist/tools/wave-tools.js +609 -0
  96. package/dist/tools/wave2-tools.js +411 -0
  97. package/dist/ui/App.js +15 -4
  98. package/dist/ui/BgPanel.js +30 -6
  99. package/dist/ui/Composer.js +15 -2
  100. package/dist/ui/QuestionPrompt.js +32 -12
  101. package/dist/ui/SessionPicker.js +86 -0
  102. package/dist/ui/StatusRule.js +5 -5
  103. package/dist/ui/ToolStep.js +17 -1
  104. package/dist/ui/Transcript.js +17 -1
  105. package/dist/ui/index.js +1 -1
  106. package/dist/ui/liveTools.js +21 -3
  107. package/dist/ui/slashCommands.js +2 -0
  108. package/dist/util/mentions.js +1 -1
  109. package/dist/util/screenshots.js +74 -8
  110. package/dist/util/slash.js +2 -2
  111. package/dist/vault/store.js +1 -1
  112. package/mcp/README.md +88 -0
  113. package/mcp/ocr-macos.swift +45 -0
  114. package/mcp/powertools-media.mjs +464 -0
  115. package/mcp/powertools-toolbox.mjs +1114 -0
  116. package/mcp/powertools.md +210 -0
  117. package/mcp/powertools.mjs +861 -0
  118. package/package.json +9 -2
@@ -0,0 +1,111 @@
1
+ import { hostname } from "node:os";
2
+ import { readFileSync } from "node:fs";
3
+ const POST_TIMEOUT = 5_000;
4
+ const GET_TIMEOUT = 5_000;
5
+ const HEALTH_TIMEOUT = 3_000;
6
+ export function resolveStoreKey(store) {
7
+ if (store.key)
8
+ return store.key;
9
+ const envName = store.keyEnv || "OPERATOR_STORE_KEY";
10
+ if (process.env[envName])
11
+ return process.env[envName];
12
+ if (store.keyFile) {
13
+ try {
14
+ return readFileSync(store.keyFile.replace(/^~/, process.env.HOME || "~"), "utf8").trim();
15
+ }
16
+ catch { /* unreadable */ }
17
+ }
18
+ return "";
19
+ }
20
+ export function createStoreClient(endpoint, key) {
21
+ const base = endpoint.replace(/\/+$/, "");
22
+ const headers = { "Content-Type": "application/json" };
23
+ if (key)
24
+ headers["Authorization"] = `Bearer ${key}`;
25
+ const node = hostname();
26
+ return {
27
+ async push(archive) {
28
+ try {
29
+ const body = JSON.stringify({
30
+ id: archive.id,
31
+ node,
32
+ cwd: archive.cwd,
33
+ title: archive.title,
34
+ model: archive.model || "",
35
+ started_at: archive.startedAt,
36
+ updated_at: archive.updatedAt,
37
+ messages: archive.messages,
38
+ version: archive.version,
39
+ });
40
+ const res = await fetch(`${base}/v1/sessions`, {
41
+ method: "POST",
42
+ headers,
43
+ body,
44
+ signal: AbortSignal.timeout(POST_TIMEOUT),
45
+ });
46
+ return res.ok;
47
+ }
48
+ catch {
49
+ return false;
50
+ }
51
+ },
52
+ async list(opts) {
53
+ try {
54
+ const params = new URLSearchParams();
55
+ if (opts?.node)
56
+ params.set("node", opts.node);
57
+ if (opts?.cwd)
58
+ params.set("cwd", opts.cwd);
59
+ if (opts?.limit)
60
+ params.set("limit", String(opts.limit));
61
+ const qs = params.toString();
62
+ const res = await fetch(`${base}/v1/sessions${qs ? `?${qs}` : ""}`, {
63
+ headers,
64
+ signal: AbortSignal.timeout(GET_TIMEOUT),
65
+ });
66
+ if (!res.ok)
67
+ return [];
68
+ const data = await res.json();
69
+ return data.sessions || [];
70
+ }
71
+ catch {
72
+ return [];
73
+ }
74
+ },
75
+ async fetch(id) {
76
+ try {
77
+ const res = await fetch(`${base}/v1/sessions/${encodeURIComponent(id)}`, {
78
+ headers,
79
+ signal: AbortSignal.timeout(GET_TIMEOUT),
80
+ });
81
+ if (!res.ok)
82
+ return null;
83
+ const data = await res.json();
84
+ return {
85
+ version: 1,
86
+ id: data.id,
87
+ cwd: data.cwd,
88
+ title: data.title,
89
+ model: data.model,
90
+ startedAt: data.started_at,
91
+ updatedAt: data.updated_at,
92
+ messages: data.messages,
93
+ };
94
+ }
95
+ catch {
96
+ return null;
97
+ }
98
+ },
99
+ async healthy() {
100
+ try {
101
+ const res = await fetch(`${base}/health`, {
102
+ signal: AbortSignal.timeout(HEALTH_TIMEOUT),
103
+ });
104
+ return res.ok;
105
+ }
106
+ catch {
107
+ return false;
108
+ }
109
+ },
110
+ };
111
+ }
@@ -1,11 +1,20 @@
1
1
  import { killOwnedChildren, killOwnedChildrenSync, removePidfile } from "./util/owned-children.js";
2
- export const asEndReason = (r) => (r === "quit" || r === "error" ? r : "interrupted");
2
+ import { removeSessionRecord } from "./idle/session-record.js";
3
+ export const asEndReason = (r) => (r === "quit" || r === "idle" || r === "error" ? r : "interrupted");
3
4
  export function installProcessTeardown(t, d) {
4
5
  t.add("session-end", (r) => d.recordEnd(asEndReason(r)), { order: 10 }); // first: record before anything is killed
6
+ t.add("store-sync", async () => {
7
+ if (!d.storeClient || !d.buildArchive)
8
+ return;
9
+ const archive = d.buildArchive();
10
+ if (archive)
11
+ await d.storeClient.push(archive).catch(() => { });
12
+ }, { order: 12 });
5
13
  t.add("shells", () => d.disposeShells(), { order: 80 });
6
14
  t.add("browser", () => d.disposeBrowser(), { order: 81 });
7
15
  // The sweep: whatever this process spawned and still owns (background jobs, MCP servers, Chrome, shells) — waited for, then SIGKILLed.
8
16
  t.add("owned-children", () => killOwnedChildren().then(() => undefined), { sync: () => { killOwnedChildrenSync(); }, order: 90 });
9
17
  t.add("telemetry-flush", () => d.flushTelemetry(), { sync: () => d.flushTelemetrySync(), order: 95 });
10
18
  t.add("pidfile", () => removePidfile(), { order: 99 });
19
+ t.add("session-record", () => removeSessionRecord(), { order: 99 }); // the idle reaper judges only pids that still have one
11
20
  }