@useorgx/openclaw-plugin 0.4.6 → 0.4.9

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 (137) hide show
  1. package/README.md +310 -24
  2. package/dashboard/dist/assets/B5NEElEI.css +1 -0
  3. package/dashboard/dist/assets/BhapSNAs.js +215 -0
  4. package/dashboard/dist/assets/iFdvE7lx.js +1 -0
  5. package/dashboard/dist/assets/jRJsmpYM.js +1 -0
  6. package/dashboard/dist/index.html +2 -2
  7. package/dist/activity-actor-fields.d.ts +3 -0
  8. package/dist/activity-actor-fields.js +128 -0
  9. package/dist/activity-store.js +12 -19
  10. package/dist/agent-context-store.js +5 -25
  11. package/dist/agent-run-store.js +5 -25
  12. package/dist/agent-suite.js +1 -8
  13. package/dist/artifacts/register-artifact.d.ts +47 -0
  14. package/dist/artifacts/register-artifact.js +271 -0
  15. package/dist/auth/flows.d.ts +47 -0
  16. package/dist/auth/flows.js +169 -0
  17. package/dist/auth-store.js +14 -39
  18. package/dist/byok-store.js +5 -19
  19. package/dist/cli/orgx.d.ts +66 -0
  20. package/dist/cli/orgx.js +91 -0
  21. package/dist/config/refresh.d.ts +32 -0
  22. package/dist/config/refresh.js +55 -0
  23. package/dist/config/resolution.d.ts +37 -0
  24. package/dist/config/resolution.js +178 -0
  25. package/dist/contracts/client.d.ts +1 -0
  26. package/dist/contracts/client.js +7 -5
  27. package/dist/contracts/shared-types.d.ts +147 -0
  28. package/dist/contracts/shared-types.js +3 -0
  29. package/dist/contracts/types.d.ts +1 -130
  30. package/dist/contracts/types.js +5 -0
  31. package/dist/entities/auto-assignment.d.ts +36 -0
  32. package/dist/entities/auto-assignment.js +115 -0
  33. package/dist/entity-comment-store.js +5 -25
  34. package/dist/hash-utils.d.ts +2 -0
  35. package/dist/hash-utils.js +12 -0
  36. package/dist/http/helpers/activity-headline.d.ts +10 -0
  37. package/dist/http/helpers/activity-headline.js +192 -0
  38. package/dist/http/helpers/artifact-fallback.d.ts +13 -0
  39. package/dist/http/helpers/artifact-fallback.js +148 -0
  40. package/dist/http/helpers/auto-continue-engine.d.ts +298 -0
  41. package/dist/http/helpers/auto-continue-engine.js +1218 -0
  42. package/dist/http/helpers/autopilot-operations.d.ts +157 -0
  43. package/dist/http/helpers/autopilot-operations.js +403 -0
  44. package/dist/http/helpers/autopilot-runtime.d.ts +42 -0
  45. package/dist/http/helpers/autopilot-runtime.js +319 -0
  46. package/dist/http/helpers/autopilot-slice-utils.d.ts +38 -0
  47. package/dist/http/helpers/autopilot-slice-utils.js +476 -0
  48. package/dist/http/helpers/decision-mapper.d.ts +12 -0
  49. package/dist/http/helpers/decision-mapper.js +44 -0
  50. package/dist/http/helpers/dispatch-lifecycle.d.ts +102 -0
  51. package/dist/http/helpers/dispatch-lifecycle.js +604 -0
  52. package/dist/http/helpers/hash-utils.d.ts +1 -0
  53. package/dist/http/helpers/hash-utils.js +1 -0
  54. package/dist/http/helpers/kickoff-context.d.ts +12 -0
  55. package/dist/http/helpers/kickoff-context.js +154 -0
  56. package/dist/http/helpers/mission-control.d.ts +94 -0
  57. package/dist/http/helpers/mission-control.js +894 -0
  58. package/dist/http/helpers/openclaw-cli.d.ts +37 -0
  59. package/dist/http/helpers/openclaw-cli.js +283 -0
  60. package/dist/http/helpers/runtime-sse.d.ts +20 -0
  61. package/dist/http/helpers/runtime-sse.js +110 -0
  62. package/dist/http/helpers/value-utils.d.ts +6 -0
  63. package/dist/http/helpers/value-utils.js +67 -0
  64. package/dist/http/index.d.ts +88 -0
  65. package/dist/http/index.js +2353 -0
  66. package/dist/http/router.d.ts +23 -0
  67. package/dist/http/router.js +23 -0
  68. package/dist/http/routes/agent-control.d.ts +79 -0
  69. package/dist/http/routes/agent-control.js +684 -0
  70. package/dist/http/routes/agent-suite.d.ts +29 -0
  71. package/dist/http/routes/agent-suite.js +198 -0
  72. package/dist/http/routes/agents-catalog.d.ts +40 -0
  73. package/dist/http/routes/agents-catalog.js +83 -0
  74. package/dist/http/routes/billing.d.ts +23 -0
  75. package/dist/http/routes/billing.js +55 -0
  76. package/dist/http/routes/debug.d.ts +14 -0
  77. package/dist/http/routes/debug.js +21 -0
  78. package/dist/http/routes/decision-actions.d.ts +13 -0
  79. package/dist/http/routes/decision-actions.js +66 -0
  80. package/dist/http/routes/delegation.d.ts +19 -0
  81. package/dist/http/routes/delegation.js +32 -0
  82. package/dist/http/routes/entities.d.ts +47 -0
  83. package/dist/http/routes/entities.js +152 -0
  84. package/dist/http/routes/entity-dynamic.d.ts +25 -0
  85. package/dist/http/routes/entity-dynamic.js +191 -0
  86. package/dist/http/routes/health.d.ts +22 -0
  87. package/dist/http/routes/health.js +49 -0
  88. package/dist/http/routes/live-legacy.d.ts +110 -0
  89. package/dist/http/routes/live-legacy.js +598 -0
  90. package/dist/http/routes/live-misc.d.ts +69 -0
  91. package/dist/http/routes/live-misc.js +206 -0
  92. package/dist/http/routes/live-snapshot.d.ts +90 -0
  93. package/dist/http/routes/live-snapshot.js +297 -0
  94. package/dist/http/routes/mission-control-actions.d.ts +83 -0
  95. package/dist/http/routes/mission-control-actions.js +541 -0
  96. package/dist/http/routes/mission-control-read.d.ts +28 -0
  97. package/dist/http/routes/mission-control-read.js +67 -0
  98. package/dist/http/routes/onboarding.d.ts +34 -0
  99. package/dist/http/routes/onboarding.js +101 -0
  100. package/dist/http/routes/run-control.d.ts +24 -0
  101. package/dist/http/routes/run-control.js +86 -0
  102. package/dist/http/routes/runtime-hooks.d.ts +69 -0
  103. package/dist/http/routes/runtime-hooks.js +437 -0
  104. package/dist/http/routes/settings-byok.d.ts +23 -0
  105. package/dist/http/routes/settings-byok.js +163 -0
  106. package/dist/http/routes/summary.d.ts +18 -0
  107. package/dist/http/routes/summary.js +42 -0
  108. package/dist/http/routes/work-artifacts.d.ts +9 -0
  109. package/dist/http/routes/work-artifacts.js +36 -0
  110. package/dist/http/shared-state.d.ts +16 -0
  111. package/dist/http/shared-state.js +1 -0
  112. package/dist/http-handler.d.ts +1 -88
  113. package/dist/http-handler.js +1 -9664
  114. package/dist/index.js +122 -2121
  115. package/dist/json-utils.d.ts +1 -0
  116. package/dist/json-utils.js +8 -0
  117. package/dist/local-openclaw.js +8 -0
  118. package/dist/mcp-client-setup.js +75 -90
  119. package/dist/next-up-queue-store.js +4 -18
  120. package/dist/runtime-instance-store.js +8 -34
  121. package/dist/services/background.d.ts +23 -0
  122. package/dist/services/background.js +23 -0
  123. package/dist/services/instrumentation.d.ts +29 -0
  124. package/dist/services/instrumentation.js +136 -0
  125. package/dist/snapshot-store.js +5 -25
  126. package/dist/stores/json-store.d.ts +11 -0
  127. package/dist/stores/json-store.js +42 -0
  128. package/dist/sync/outbox-replay.d.ts +55 -0
  129. package/dist/sync/outbox-replay.js +514 -0
  130. package/dist/tools/core-tools.d.ts +76 -0
  131. package/dist/tools/core-tools.js +1005 -0
  132. package/dist/worker-supervisor.js +15 -0
  133. package/package.json +6 -1
  134. package/dashboard/dist/assets/0tOC3wSN.js +0 -214
  135. package/dashboard/dist/assets/Bm8QnMJ_.js +0 -1
  136. package/dashboard/dist/assets/CyxZio4Y.js +0 -1
  137. package/dashboard/dist/assets/DaAIOik3.css +0 -1
@@ -0,0 +1,319 @@
1
+ import { chmodSync, createWriteStream, mkdirSync, writeFileSync, } from "node:fs";
2
+ import { spawn } from "node:child_process";
3
+ import { dirname, resolve, sep } from "node:path";
4
+ import { normalizeCodexArgs } from "./autopilot-slice-utils.js";
5
+ export function createAutopilotRuntime(deps) {
6
+ function ensurePrivateDirForFile(pathname) {
7
+ const dir = dirname(pathname);
8
+ mkdirSync(dir, { recursive: true, mode: 0o700 });
9
+ try {
10
+ chmodSync(dir, 0o700);
11
+ }
12
+ catch {
13
+ // best effort
14
+ }
15
+ }
16
+ function spawnCodexSliceWorker(input) {
17
+ ensurePrivateDirForFile(input.logPath);
18
+ ensurePrivateDirForFile(input.outputPath);
19
+ const workerKind = (process.env.ORGX_AUTOPILOT_WORKER_KIND ?? "").trim().toLowerCase();
20
+ if (workerKind === "mock") {
21
+ const scriptPath = resolve(dirname(deps.filename), "..", "..", "scripts", "mock-autopilot-slice-worker.mjs");
22
+ const logStream = createWriteStream(input.logPath, { flags: "a" });
23
+ const outStream = createWriteStream(input.outputPath, { flags: "a" });
24
+ logStream.write(`\n==== ${new Date().toISOString()} :: mock slice ${input.runId} ====\n`);
25
+ const child = spawn("node", [scriptPath], {
26
+ cwd: input.cwd,
27
+ env: {
28
+ ...process.env,
29
+ ...input.env,
30
+ },
31
+ stdio: ["ignore", "pipe", "pipe"],
32
+ // Keep the mock worker as a normal child so stdout/stderr capture is deterministic.
33
+ detached: false,
34
+ });
35
+ deps.autoContinueSliceChildren.set(input.runId, child);
36
+ try {
37
+ logStream.write(`spawned pid=${String(child.pid ?? "")} stdout=${String(Boolean(child.stdout))} stderr=${String(Boolean(child.stderr))}\n`);
38
+ }
39
+ catch {
40
+ // ignore
41
+ }
42
+ child.stdout?.on("data", (chunk) => {
43
+ try {
44
+ logStream.write(chunk);
45
+ }
46
+ catch {
47
+ // ignore
48
+ }
49
+ try {
50
+ outStream.write(chunk);
51
+ }
52
+ catch {
53
+ // ignore
54
+ }
55
+ });
56
+ child.stderr?.on("data", (chunk) => {
57
+ try {
58
+ logStream.write(chunk);
59
+ }
60
+ catch {
61
+ // ignore
62
+ }
63
+ });
64
+ child.on("close", (code, signal) => {
65
+ deps.autoContinueSliceChildren.delete(input.runId);
66
+ const stamp = new Date().toISOString();
67
+ try {
68
+ logStream.write(`\n==== ${stamp} :: exit code=${String(code)} signal=${String(signal)} ====\n`);
69
+ }
70
+ catch {
71
+ // ignore
72
+ }
73
+ try {
74
+ logStream.end();
75
+ }
76
+ catch {
77
+ // ignore
78
+ }
79
+ try {
80
+ outStream.end();
81
+ }
82
+ catch {
83
+ // ignore
84
+ }
85
+ });
86
+ child.on("error", (error) => {
87
+ deps.autoContinueSliceChildren.delete(input.runId);
88
+ const msg = deps.safeErrorMessage(error);
89
+ try {
90
+ logStream.write(`\nworker error: ${msg}\n`);
91
+ }
92
+ catch {
93
+ // ignore
94
+ }
95
+ try {
96
+ outStream.write(`${JSON.stringify({
97
+ status: "error",
98
+ summary: `Worker spawn error: ${msg}`,
99
+ workstream_id: input.env.ORGX_WORKSTREAM_ID ?? "unknown",
100
+ workstream_title: input.env.ORGX_WORKSTREAM_TITLE ?? null,
101
+ slice_id: input.runId,
102
+ }, null, 2)}\n`);
103
+ }
104
+ catch {
105
+ // ignore
106
+ }
107
+ });
108
+ return { pid: child.pid ?? null };
109
+ }
110
+ if (workerKind === "claude-code" || workerKind === "claude_code") {
111
+ const claudeBin = (process.env.ORGX_CLAUDE_CODE_BIN ?? "").trim() || "claude";
112
+ const rawArgs = (process.env.ORGX_CLAUDE_CODE_ARGS ?? "").trim();
113
+ const args = rawArgs.length > 0 ? rawArgs.split(/\s+/).filter(Boolean) : [];
114
+ const logStream = createWriteStream(input.logPath, { flags: "a" });
115
+ const outStream = createWriteStream(input.outputPath, { flags: "a" });
116
+ logStream.write(`\n==== ${new Date().toISOString()} :: claude slice ${input.runId} ====\n`);
117
+ // Claude Code invocation is environment-specific; ORGX_CLAUDE_CODE_ARGS should be set to
118
+ // a headless-compatible command shape. We pass the prompt as the final argument.
119
+ const child = spawn(claudeBin, [...args, input.prompt], {
120
+ cwd: input.cwd,
121
+ env: {
122
+ ...process.env,
123
+ ...deps.resolveByokEnvOverrides(),
124
+ ...input.env,
125
+ },
126
+ stdio: ["ignore", "pipe", "pipe"],
127
+ detached: true,
128
+ });
129
+ deps.autoContinueSliceChildren.set(input.runId, child);
130
+ child.stdout?.on("data", (chunk) => {
131
+ try {
132
+ logStream.write(chunk);
133
+ }
134
+ catch {
135
+ // ignore
136
+ }
137
+ try {
138
+ outStream.write(chunk);
139
+ }
140
+ catch {
141
+ // ignore
142
+ }
143
+ });
144
+ child.stderr?.on("data", (chunk) => {
145
+ try {
146
+ logStream.write(chunk);
147
+ }
148
+ catch {
149
+ // ignore
150
+ }
151
+ });
152
+ child.on("close", (code, signal) => {
153
+ deps.autoContinueSliceChildren.delete(input.runId);
154
+ const stamp = new Date().toISOString();
155
+ try {
156
+ logStream.write(`\n==== ${stamp} :: exit code=${String(code)} signal=${String(signal)} ====\n`);
157
+ }
158
+ catch {
159
+ // ignore
160
+ }
161
+ try {
162
+ logStream.end();
163
+ }
164
+ catch {
165
+ // ignore
166
+ }
167
+ try {
168
+ outStream.end();
169
+ }
170
+ catch {
171
+ // ignore
172
+ }
173
+ });
174
+ child.on("error", (error) => {
175
+ deps.autoContinueSliceChildren.delete(input.runId);
176
+ const msg = deps.safeErrorMessage(error);
177
+ try {
178
+ logStream.write(`\nworker error: ${msg}\n`);
179
+ }
180
+ catch {
181
+ // ignore
182
+ }
183
+ try {
184
+ outStream.write(`${JSON.stringify({
185
+ status: "error",
186
+ summary: `Worker spawn error: ${msg}`,
187
+ workstream_id: input.env.ORGX_WORKSTREAM_ID ?? "unknown",
188
+ workstream_title: input.env.ORGX_WORKSTREAM_TITLE ?? null,
189
+ slice_id: input.runId,
190
+ }, null, 2)}\n`);
191
+ }
192
+ catch {
193
+ // ignore
194
+ }
195
+ });
196
+ child.unref();
197
+ return { pid: child.pid ?? null };
198
+ }
199
+ const codexInfo = deps.resolveCodexBinInfo();
200
+ const codexBin = codexInfo.bin;
201
+ const rawArgs = (process.env.ORGX_CODEX_ARGS ?? "").trim();
202
+ const args = normalizeCodexArgs(rawArgs.length > 0 ? rawArgs.split(/\s+/).filter(Boolean) : ["--full-auto"]);
203
+ // Autopilot slices should not fail just because an unrelated MCP server is flaky.
204
+ // Default: disable firecrawl unless explicitly re-enabled.
205
+ const disableFirecrawlRaw = (process.env.ORGX_AUTOPILOT_DISABLE_FIRECRAWL ?? "").trim().toLowerCase();
206
+ const disableFirecrawl = disableFirecrawlRaw !== "false" && disableFirecrawlRaw !== "0" && disableFirecrawlRaw !== "no";
207
+ const hasFirecrawlOverride = args.some((arg) => String(arg).includes("mcp_servers.firecrawl"));
208
+ const extraArgs = [];
209
+ if (disableFirecrawl && !hasFirecrawlOverride) {
210
+ extraArgs.push("-c", "mcp_servers.firecrawl.enabled=false");
211
+ }
212
+ const logStream = createWriteStream(input.logPath, { flags: "a" });
213
+ logStream.write(`\n==== ${new Date().toISOString()} :: slice ${input.runId} ====\n`);
214
+ logStream.write(`codex_bin: ${codexBin}${codexInfo.versionString ? ` (${codexInfo.versionString})` : ""}\n`);
215
+ const childEnv = {
216
+ ...process.env,
217
+ ...deps.resolveByokEnvOverrides(),
218
+ ...input.env,
219
+ };
220
+ if (codexBin.includes(sep)) {
221
+ const binDir = dirname(codexBin);
222
+ childEnv.PATH = childEnv.PATH ? `${binDir}:${childEnv.PATH}` : binDir;
223
+ }
224
+ const hasOutputLastMessage = args.includes("--output-last-message") ||
225
+ args.some((arg) => typeof arg === "string" && arg.startsWith("--output-last-message="));
226
+ const outputArgs = hasOutputLastMessage
227
+ ? []
228
+ : ["--output-last-message", input.outputPath];
229
+ const child = spawn(codexBin, [...args, ...extraArgs, ...outputArgs, input.prompt], {
230
+ cwd: input.cwd,
231
+ env: childEnv,
232
+ stdio: ["ignore", "pipe", "pipe"],
233
+ detached: true,
234
+ });
235
+ deps.autoContinueSliceChildren.set(input.runId, child);
236
+ child.stdout?.on("data", (chunk) => {
237
+ try {
238
+ logStream.write(chunk);
239
+ }
240
+ catch {
241
+ // ignore
242
+ }
243
+ });
244
+ child.stderr?.on("data", (chunk) => {
245
+ try {
246
+ logStream.write(chunk);
247
+ }
248
+ catch {
249
+ // ignore
250
+ }
251
+ });
252
+ child.on("close", (code, signal) => {
253
+ deps.autoContinueSliceChildren.delete(input.runId);
254
+ const stamp = new Date().toISOString();
255
+ try {
256
+ logStream.write(`\n==== ${stamp} :: exit code=${String(code)} signal=${String(signal)} ====\n`);
257
+ }
258
+ catch {
259
+ // ignore
260
+ }
261
+ try {
262
+ logStream.end();
263
+ }
264
+ catch {
265
+ // ignore
266
+ }
267
+ });
268
+ child.on("error", (error) => {
269
+ deps.autoContinueSliceChildren.delete(input.runId);
270
+ const msg = deps.safeErrorMessage(error);
271
+ try {
272
+ logStream.write(`\nworker error: ${msg}\n`);
273
+ }
274
+ catch {
275
+ // ignore
276
+ }
277
+ try {
278
+ writeFileSync(input.outputPath, `${JSON.stringify({
279
+ status: "error",
280
+ summary: `Worker spawn error: ${msg}`,
281
+ workstream_id: input.env.ORGX_WORKSTREAM_ID ?? "unknown",
282
+ workstream_title: input.env.ORGX_WORKSTREAM_TITLE ?? null,
283
+ slice_id: input.runId,
284
+ }, null, 2)}\n`, { encoding: "utf8" });
285
+ }
286
+ catch {
287
+ // ignore
288
+ }
289
+ });
290
+ child.unref();
291
+ return { pid: child.pid ?? null };
292
+ }
293
+ function writeRuntimeEvent(input) {
294
+ const instance = deps.upsertRuntimeInstanceFromHook({
295
+ source_client: input.sourceClient,
296
+ event: input.event ?? null,
297
+ run_id: input.runId,
298
+ correlation_id: input.runId,
299
+ initiative_id: input.initiativeId,
300
+ workstream_id: input.workstreamId,
301
+ task_id: input.taskId,
302
+ agent_id: input.agentId,
303
+ agent_name: input.agentName,
304
+ phase: input.phase,
305
+ progress_pct: input.progressPct ?? null,
306
+ message: input.message ?? null,
307
+ metadata: input.metadata ?? null,
308
+ timestamp: input.timestamp ?? new Date().toISOString(),
309
+ });
310
+ // Make runtime updates feel instantaneous (don't wait for the 15s staleness timer).
311
+ deps.broadcastRuntimeSse("runtime.updated", instance);
312
+ deps.clearSnapshotResponseCache();
313
+ return instance;
314
+ }
315
+ return {
316
+ spawnCodexSliceWorker,
317
+ writeRuntimeEvent,
318
+ };
319
+ }
@@ -0,0 +1,38 @@
1
+ export declare function ensureAutopilotSliceSchemaPath(schemaFilename: string): string;
2
+ export declare function parseSliceResult<T extends object>(raw: string): T | null;
3
+ export declare function readSliceOutputFile(pathname: string): string | null;
4
+ export declare function readFileTailSafe(pathname: string, maxChars?: number): string;
5
+ export declare function fileUpdatedAtEpochMs(pathname: string, fallbackEpochMs: number): number;
6
+ export type CodexBinInfo = {
7
+ bin: string;
8
+ version: [number, number, number] | null;
9
+ versionString: string | null;
10
+ };
11
+ export declare function normalizeCodexArgs(args: string[]): string[];
12
+ export declare function createCodexBinResolver(): {
13
+ resolveCodexBinInfo: () => CodexBinInfo;
14
+ getCachedCodexProbeSummary: () => string | null;
15
+ };
16
+ export declare function buildWorkstreamSlicePrompt(input: {
17
+ initiativeTitle: string;
18
+ initiativeId: string;
19
+ workstreamId: string;
20
+ workstreamTitle: string;
21
+ milestoneSummaries: Array<{
22
+ id: string;
23
+ title: string;
24
+ status: string;
25
+ }>;
26
+ taskSummaries: Array<{
27
+ id: string;
28
+ title: string;
29
+ status: string;
30
+ milestoneId: string | null;
31
+ }>;
32
+ executionPolicy: {
33
+ domain: string;
34
+ requiredSkills: string[];
35
+ };
36
+ runId: string;
37
+ schemaPath: string;
38
+ }): string;