@useorgx/openclaw-plugin 0.7.20 → 0.7.23
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/dashboard/dist/assets/9gFmK3Kr.js +1 -0
- package/dashboard/dist/assets/9gFmK3Kr.js.br +0 -0
- package/dashboard/dist/assets/9gFmK3Kr.js.gz +0 -0
- package/dashboard/dist/assets/{BoDhb8_y.js → BrMXbzQ-.js} +2 -2
- package/dashboard/dist/assets/BrMXbzQ-.js.br +0 -0
- package/dashboard/dist/assets/BrMXbzQ-.js.gz +0 -0
- package/dashboard/dist/assets/By0MIBj_.js +1 -0
- package/dashboard/dist/assets/By0MIBj_.js.br +0 -0
- package/dashboard/dist/assets/By0MIBj_.js.gz +0 -0
- package/dashboard/dist/assets/C1u2SGin.css +1 -0
- package/dashboard/dist/assets/C1u2SGin.css.br +0 -0
- package/dashboard/dist/assets/C1u2SGin.css.gz +0 -0
- package/dashboard/dist/assets/{DAr4MfFk.js → CGJiHCIx.js} +1 -1
- package/dashboard/dist/assets/CGJiHCIx.js.br +0 -0
- package/dashboard/dist/assets/CGJiHCIx.js.gz +0 -0
- package/dashboard/dist/assets/CSd4rSuU.js +212 -0
- package/dashboard/dist/assets/CSd4rSuU.js.br +0 -0
- package/dashboard/dist/assets/CSd4rSuU.js.gz +0 -0
- package/dashboard/dist/assets/{DibzNd0I.js → CZXS5i_5.js} +1 -1
- package/dashboard/dist/assets/CZXS5i_5.js.br +0 -0
- package/dashboard/dist/assets/CZXS5i_5.js.gz +0 -0
- package/dashboard/dist/assets/{wa4jJQK9.js → CbVWL74-.js} +1 -1
- package/dashboard/dist/assets/CbVWL74-.js.br +0 -0
- package/dashboard/dist/assets/CbVWL74-.js.gz +0 -0
- package/dashboard/dist/assets/{Dm0CfDGr.js → D-FuHfT8.js} +1 -1
- package/dashboard/dist/assets/D-FuHfT8.js.br +0 -0
- package/dashboard/dist/assets/D-FuHfT8.js.gz +0 -0
- package/dashboard/dist/assets/{DXVs61e1.js → D0PN5_vY.js} +1 -1
- package/dashboard/dist/assets/D0PN5_vY.js.br +0 -0
- package/dashboard/dist/assets/D0PN5_vY.js.gz +0 -0
- package/dashboard/dist/assets/{_zpQCpjm.js → DDCPrZRt.js} +1 -1
- package/dashboard/dist/assets/DDCPrZRt.js.br +0 -0
- package/dashboard/dist/assets/DDCPrZRt.js.gz +0 -0
- package/dashboard/dist/assets/{BYb6DARX.js → DNQ-iFO2.js} +1 -1
- package/dashboard/dist/assets/DNQ-iFO2.js.br +0 -0
- package/dashboard/dist/assets/DNQ-iFO2.js.gz +0 -0
- package/dashboard/dist/assets/{BGY6oI8h.js → DhPuHPK7.js} +1 -1
- package/dashboard/dist/assets/DhPuHPK7.js.br +0 -0
- package/dashboard/dist/assets/DhPuHPK7.js.gz +0 -0
- package/dashboard/dist/assets/Dhz7qPtn.js +1 -0
- package/dashboard/dist/assets/Dhz7qPtn.js.br +0 -0
- package/dashboard/dist/assets/Dhz7qPtn.js.gz +0 -0
- package/dashboard/dist/assets/LOFrVoPD.js +1 -0
- package/dashboard/dist/assets/LOFrVoPD.js.br +0 -0
- package/dashboard/dist/assets/LOFrVoPD.js.gz +0 -0
- package/dashboard/dist/assets/OlLPtzdz.js +1 -0
- package/dashboard/dist/assets/OlLPtzdz.js.br +0 -0
- package/dashboard/dist/assets/OlLPtzdz.js.gz +0 -0
- package/dashboard/dist/assets/{B014hrCe.js → RN4M9u9W.js} +2 -2
- package/dashboard/dist/assets/RN4M9u9W.js.br +0 -0
- package/dashboard/dist/assets/RN4M9u9W.js.gz +0 -0
- package/dashboard/dist/assets/VCHu272d.js +1 -0
- package/dashboard/dist/assets/VCHu272d.js.br +0 -0
- package/dashboard/dist/assets/VCHu272d.js.gz +0 -0
- package/dashboard/dist/assets/m2smti3F.js +1 -0
- package/dashboard/dist/assets/m2smti3F.js.br +0 -0
- package/dashboard/dist/assets/m2smti3F.js.gz +0 -0
- package/dashboard/dist/assets/{CV0sWMbv.js → nra1yvJX.js} +1 -1
- package/dashboard/dist/assets/nra1yvJX.js.br +0 -0
- package/dashboard/dist/assets/nra1yvJX.js.gz +0 -0
- package/dashboard/dist/assets/qLX6NZ-J.js +1 -0
- package/dashboard/dist/assets/qLX6NZ-J.js.br +0 -0
- package/dashboard/dist/assets/qLX6NZ-J.js.gz +0 -0
- package/dashboard/dist/index.html +2 -2
- package/dashboard/dist/index.html.br +0 -0
- package/dashboard/dist/index.html.gz +0 -0
- package/dist/agent-run-store.js +162 -24
- package/dist/cli/orgx.d.ts +3 -0
- package/dist/config/resolution.d.ts +7 -0
- package/dist/config/resolution.js +13 -5
- package/dist/contracts/onboarding-state.d.ts +2 -0
- package/dist/contracts/onboarding-state.js +23 -0
- package/dist/contracts/shared-types.d.ts +17 -0
- package/dist/http/helpers/auto-continue-engine.d.ts +23 -0
- package/dist/http/helpers/auto-continue-engine.js +233 -53
- package/dist/http/helpers/autopilot-runtime.js +5 -1
- package/dist/http/helpers/autopilot-slice-utils.js +25 -1
- package/dist/http/helpers/decision-mapper.d.ts +1 -0
- package/dist/http/helpers/decision-mapper.js +19 -2
- package/dist/http/helpers/dispatch-lifecycle.js +3 -0
- package/dist/http/helpers/mission-control.d.ts +1 -0
- package/dist/http/helpers/mission-control.js +5 -2
- package/dist/http/helpers/slice-run-projections.d.ts +27 -0
- package/dist/http/helpers/slice-run-projections.js +198 -10
- package/dist/http/helpers/triage-mapper.js +220 -6
- package/dist/http/index.d.ts +1 -0
- package/dist/http/index.js +92 -45
- package/dist/http/router.js +64 -9
- package/dist/http/routes/live-legacy.d.ts +19 -2
- package/dist/http/routes/live-legacy.js +110 -27
- package/dist/http/routes/live-snapshot.d.ts +16 -2
- package/dist/http/routes/live-snapshot.js +169 -25
- package/dist/http/routes/mission-control-actions.js +28 -0
- package/dist/http/routes/mission-control-read.d.ts +4 -0
- package/dist/http/routes/mission-control-read.js +67 -219
- package/dist/http/routes/onboarding.d.ts +1 -0
- package/dist/http/routes/onboarding.js +17 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +199 -123
- package/dist/outbox.d.ts +0 -2
- package/dist/outbox.js +259 -148
- package/dist/reporting/rollups.js +18 -11
- package/dist/runtime-instance-store.js +212 -58
- package/dist/stores/materialized-snapshot-store.d.ts +18 -0
- package/dist/stores/materialized-snapshot-store.js +91 -0
- package/dist/stores/sqlite-state.d.ts +6 -0
- package/dist/stores/sqlite-state.js +179 -0
- package/package.json +5 -1
- package/dashboard/dist/assets/B014hrCe.js.br +0 -0
- package/dashboard/dist/assets/B014hrCe.js.gz +0 -0
- package/dashboard/dist/assets/BCudUvwg.js +0 -1
- package/dashboard/dist/assets/BCudUvwg.js.br +0 -0
- package/dashboard/dist/assets/BCudUvwg.js.gz +0 -0
- package/dashboard/dist/assets/BGY6oI8h.js.br +0 -0
- package/dashboard/dist/assets/BGY6oI8h.js.gz +0 -0
- package/dashboard/dist/assets/BJI1Iy5v.css +0 -1
- package/dashboard/dist/assets/BJI1Iy5v.css.br +0 -0
- package/dashboard/dist/assets/BJI1Iy5v.css.gz +0 -0
- package/dashboard/dist/assets/BUvcp_7V.js +0 -1
- package/dashboard/dist/assets/BUvcp_7V.js.br +0 -0
- package/dashboard/dist/assets/BUvcp_7V.js.gz +0 -0
- package/dashboard/dist/assets/BV2Tf8S2.js +0 -212
- package/dashboard/dist/assets/BV2Tf8S2.js.br +0 -0
- package/dashboard/dist/assets/BV2Tf8S2.js.gz +0 -0
- package/dashboard/dist/assets/BYb6DARX.js.br +0 -0
- package/dashboard/dist/assets/BYb6DARX.js.gz +0 -0
- package/dashboard/dist/assets/BoDhb8_y.js.br +0 -0
- package/dashboard/dist/assets/BoDhb8_y.js.gz +0 -0
- package/dashboard/dist/assets/Bqk_l0k6.js +0 -1
- package/dashboard/dist/assets/Bqk_l0k6.js.br +0 -0
- package/dashboard/dist/assets/Bqk_l0k6.js.gz +0 -0
- package/dashboard/dist/assets/C-MOJWHs.js +0 -1
- package/dashboard/dist/assets/C-MOJWHs.js.br +0 -0
- package/dashboard/dist/assets/C-MOJWHs.js.gz +0 -0
- package/dashboard/dist/assets/CV0sWMbv.js.br +0 -0
- package/dashboard/dist/assets/CV0sWMbv.js.gz +0 -0
- package/dashboard/dist/assets/CaAkScfa.js +0 -1
- package/dashboard/dist/assets/CaAkScfa.js.br +0 -0
- package/dashboard/dist/assets/CaAkScfa.js.gz +0 -0
- package/dashboard/dist/assets/Ck5KlsPN.js +0 -1
- package/dashboard/dist/assets/Ck5KlsPN.js.br +0 -0
- package/dashboard/dist/assets/Ck5KlsPN.js.gz +0 -0
- package/dashboard/dist/assets/D2G51wQm.js +0 -1
- package/dashboard/dist/assets/D2G51wQm.js.br +0 -0
- package/dashboard/dist/assets/D2G51wQm.js.gz +0 -0
- package/dashboard/dist/assets/DAr4MfFk.js.br +0 -0
- package/dashboard/dist/assets/DAr4MfFk.js.gz +0 -0
- package/dashboard/dist/assets/DXVs61e1.js.br +0 -0
- package/dashboard/dist/assets/DXVs61e1.js.gz +0 -0
- package/dashboard/dist/assets/DibzNd0I.js.br +0 -0
- package/dashboard/dist/assets/DibzNd0I.js.gz +0 -0
- package/dashboard/dist/assets/Dm0CfDGr.js.br +0 -0
- package/dashboard/dist/assets/Dm0CfDGr.js.gz +0 -0
- package/dashboard/dist/assets/_zpQCpjm.js.br +0 -0
- package/dashboard/dist/assets/_zpQCpjm.js.gz +0 -0
- package/dashboard/dist/assets/uNGpYMSH.js +0 -1
- package/dashboard/dist/assets/uNGpYMSH.js.br +0 -0
- package/dashboard/dist/assets/uNGpYMSH.js.gz +0 -0
- package/dashboard/dist/assets/wa4jJQK9.js.br +0 -0
- package/dashboard/dist/assets/wa4jJQK9.js.gz +0 -0
|
@@ -137,6 +137,7 @@ export interface CreateAutoContinueEngineDeps {
|
|
|
137
137
|
export declare function createAutoContinueEngine(deps: CreateAutoContinueEngineDeps): {
|
|
138
138
|
autoContinueRuns: Map<string, {
|
|
139
139
|
initiativeId: string;
|
|
140
|
+
workspaceId: string | null;
|
|
140
141
|
agentId: string;
|
|
141
142
|
agentName: string | null;
|
|
142
143
|
includeVerification: boolean;
|
|
@@ -173,6 +174,8 @@ export declare function createAutoContinueEngine(deps: CreateAutoContinueEngineD
|
|
|
173
174
|
activeTaskId: string | null;
|
|
174
175
|
activeRunId: string | null;
|
|
175
176
|
activeTaskTokenEstimate: number | null;
|
|
177
|
+
workerEnvOverrides: Record<string, string | undefined> | null;
|
|
178
|
+
lastInitiativeStatus: string | null;
|
|
176
179
|
}>;
|
|
177
180
|
autoContinueSliceRuns: Map<string, {
|
|
178
181
|
runId: string;
|
|
@@ -243,6 +246,7 @@ export declare function createAutoContinueEngine(deps: CreateAutoContinueEngineD
|
|
|
243
246
|
initiativeId: string;
|
|
244
247
|
run: {
|
|
245
248
|
initiativeId: string;
|
|
249
|
+
workspaceId: string | null;
|
|
246
250
|
agentId: string;
|
|
247
251
|
agentName: string | null;
|
|
248
252
|
includeVerification: boolean;
|
|
@@ -279,11 +283,14 @@ export declare function createAutoContinueEngine(deps: CreateAutoContinueEngineD
|
|
|
279
283
|
activeTaskId: string | null;
|
|
280
284
|
activeRunId: string | null;
|
|
281
285
|
activeTaskTokenEstimate: number | null;
|
|
286
|
+
workerEnvOverrides: Record<string, string | undefined> | null;
|
|
287
|
+
lastInitiativeStatus: string | null;
|
|
282
288
|
};
|
|
283
289
|
}) => Promise<void>;
|
|
284
290
|
stopAutoContinueRun: (input: {
|
|
285
291
|
run: {
|
|
286
292
|
initiativeId: string;
|
|
293
|
+
workspaceId: string | null;
|
|
287
294
|
agentId: string;
|
|
288
295
|
agentName: string | null;
|
|
289
296
|
includeVerification: boolean;
|
|
@@ -320,6 +327,8 @@ export declare function createAutoContinueEngine(deps: CreateAutoContinueEngineD
|
|
|
320
327
|
activeTaskId: string | null;
|
|
321
328
|
activeRunId: string | null;
|
|
322
329
|
activeTaskTokenEstimate: number | null;
|
|
330
|
+
workerEnvOverrides: Record<string, string | undefined> | null;
|
|
331
|
+
lastInitiativeStatus: string | null;
|
|
323
332
|
};
|
|
324
333
|
reason: "error" | "blocked" | "completed" | "stopped" | "budget_exhausted";
|
|
325
334
|
error?: string | null;
|
|
@@ -328,6 +337,7 @@ export declare function createAutoContinueEngine(deps: CreateAutoContinueEngineD
|
|
|
328
337
|
}) => Promise<void>;
|
|
329
338
|
tickAutoContinueRun: (run: {
|
|
330
339
|
initiativeId: string;
|
|
340
|
+
workspaceId: string | null;
|
|
331
341
|
agentId: string;
|
|
332
342
|
agentName: string | null;
|
|
333
343
|
includeVerification: boolean;
|
|
@@ -364,11 +374,14 @@ export declare function createAutoContinueEngine(deps: CreateAutoContinueEngineD
|
|
|
364
374
|
activeTaskId: string | null;
|
|
365
375
|
activeRunId: string | null;
|
|
366
376
|
activeTaskTokenEstimate: number | null;
|
|
377
|
+
workerEnvOverrides: Record<string, string | undefined> | null;
|
|
378
|
+
lastInitiativeStatus: string | null;
|
|
367
379
|
}) => Promise<void>;
|
|
368
380
|
tickAllAutoContinue: () => Promise<void>;
|
|
369
381
|
isInitiativeActiveStatus: (status: string | null | undefined) => boolean;
|
|
370
382
|
runningAutoContinueForWorkstream: (initiativeId: string, workstreamId: string) => {
|
|
371
383
|
initiativeId: string;
|
|
384
|
+
workspaceId: string | null;
|
|
372
385
|
agentId: string;
|
|
373
386
|
agentName: string | null;
|
|
374
387
|
includeVerification: boolean;
|
|
@@ -405,6 +418,8 @@ export declare function createAutoContinueEngine(deps: CreateAutoContinueEngineD
|
|
|
405
418
|
activeTaskId: string | null;
|
|
406
419
|
activeRunId: string | null;
|
|
407
420
|
activeTaskTokenEstimate: number | null;
|
|
421
|
+
workerEnvOverrides: Record<string, string | undefined> | null;
|
|
422
|
+
lastInitiativeStatus: string | null;
|
|
408
423
|
} | null;
|
|
409
424
|
getAutoContinueLaneForWorkstream: (initiativeId: string, workstreamId: string) => {
|
|
410
425
|
workstreamId: string;
|
|
@@ -436,6 +451,7 @@ export declare function createAutoContinueEngine(deps: CreateAutoContinueEngineD
|
|
|
436
451
|
}>;
|
|
437
452
|
startAutoContinueRun: (input: {
|
|
438
453
|
initiativeId: string;
|
|
454
|
+
workspaceId?: string | null;
|
|
439
455
|
agentId: string;
|
|
440
456
|
agentName?: string | null;
|
|
441
457
|
tokenBudget: unknown;
|
|
@@ -446,8 +462,10 @@ export declare function createAutoContinueEngine(deps: CreateAutoContinueEngineD
|
|
|
446
462
|
stopAfterSlice?: boolean;
|
|
447
463
|
ignoreSpawnGuardRateLimit?: boolean;
|
|
448
464
|
scope?: SliceScope;
|
|
465
|
+
workerEnvOverrides?: Record<string, string | undefined> | null;
|
|
449
466
|
}) => Promise<{
|
|
450
467
|
initiativeId: string;
|
|
468
|
+
workspaceId: string | null;
|
|
451
469
|
agentId: string;
|
|
452
470
|
agentName: string | null;
|
|
453
471
|
includeVerification: boolean;
|
|
@@ -484,9 +502,12 @@ export declare function createAutoContinueEngine(deps: CreateAutoContinueEngineD
|
|
|
484
502
|
activeTaskId: string | null;
|
|
485
503
|
activeRunId: string | null;
|
|
486
504
|
activeTaskTokenEstimate: number | null;
|
|
505
|
+
workerEnvOverrides: Record<string, string | undefined> | null;
|
|
506
|
+
lastInitiativeStatus: string | null;
|
|
487
507
|
}>;
|
|
488
508
|
restoreAutoContinueRun: (initiativeId: string) => Promise<{
|
|
489
509
|
initiativeId: string;
|
|
510
|
+
workspaceId: string | null;
|
|
490
511
|
agentId: string;
|
|
491
512
|
agentName: string | null;
|
|
492
513
|
includeVerification: boolean;
|
|
@@ -523,6 +544,8 @@ export declare function createAutoContinueEngine(deps: CreateAutoContinueEngineD
|
|
|
523
544
|
activeTaskId: string | null;
|
|
524
545
|
activeRunId: string | null;
|
|
525
546
|
activeTaskTokenEstimate: number | null;
|
|
547
|
+
workerEnvOverrides: Record<string, string | undefined> | null;
|
|
548
|
+
lastInitiativeStatus: string | null;
|
|
526
549
|
} | null>;
|
|
527
550
|
skipCurrentWorkstream: (initiativeId: string, workstreamId: string, reason?: string) => Promise<{
|
|
528
551
|
ok: boolean;
|
|
@@ -3,7 +3,7 @@ import { existsSync } from "node:fs";
|
|
|
3
3
|
import { readdir, stat, unlink } from "node:fs/promises";
|
|
4
4
|
import { homedir } from "node:os";
|
|
5
5
|
import { dirname, join } from "node:path";
|
|
6
|
-
import { normalizeActivityActionPhase, normalizeActivityActionType, } from "../../contracts/shared-types.js";
|
|
6
|
+
import { normalizeActivityActionPhase, normalizeActivityActionType, normalizeDecisionActionType, } from "../../contracts/shared-types.js";
|
|
7
7
|
import { upsertAgentContext, upsertRunContext } from "../../agent-context-store.js";
|
|
8
8
|
import { appendTeamCompletion } from "../../team-context-store.js";
|
|
9
9
|
import { readOpenClawGatewayPort, readOpenClawSettingsSnapshot, } from "../../openclaw-settings.js";
|
|
@@ -11,7 +11,7 @@ import { resolveRuntimeHookToken, } from "../../runtime-instance-store.js";
|
|
|
11
11
|
import { detectMcpHandshakeFailure, shouldKillWorker } from "../../worker-supervisor.js";
|
|
12
12
|
import { humanizeSliceFailure, humanizeSliceFailureSummary } from "./humanize-slice-failure.js";
|
|
13
13
|
import { getOrgxPluginConfigDir } from "../../paths.js";
|
|
14
|
-
import { buildMissionControlGraph, DEFAULT_TOKEN_BUDGET_ASSUMPTIONS, dedupeStrings, detectBehaviorConfigDrift, deriveBehaviorAutomationLevel, deriveBehaviorConfigContext, deriveExecutionPolicy, evaluateScopeCompletion, isDispatchableWorkstreamStatus, isDoneStatus, isTodoStatus, readBudgetEnvNumber, selectSliceTasksByScope, SLICE_SCOPE_TIMEOUT_MULTIPLIER, spawnGuardIsRateLimited, summarizeSpawnGuardBlockReason, } from "./mission-control.js";
|
|
14
|
+
import { buildMissionControlGraph, DEFAULT_TOKEN_BUDGET_ASSUMPTIONS, dedupeStrings, detectBehaviorConfigDrift, deriveBehaviorAutomationLevel, deriveBehaviorConfigContext, deriveInitiativeLifecycleStatus, deriveExecutionPolicy, evaluateScopeCompletion, isDispatchableWorkstreamStatus, isDoneStatus, isTodoStatus, readBudgetEnvNumber, selectSliceTasksByScope, SLICE_SCOPE_TIMEOUT_MULTIPLIER, spawnGuardIsRateLimited, summarizeSpawnGuardBlockReason, } from "./mission-control.js";
|
|
15
15
|
import { createAutopilotRuntime } from "./autopilot-runtime.js";
|
|
16
16
|
import { buildScopeDirective, buildSliceOutputInstructions, buildWorkstreamSlicePrompt, createCodexBinResolver, ensureAutopilotSliceSchemaPath, extractSessionIdFromLog, extractSessionIdFromOutput, fileUpdatedAtEpochMs, parseSliceResult, readFileTailSafe, readSliceOutputFile, } from "./autopilot-slice-utils.js";
|
|
17
17
|
import { pickString } from "./value-utils.js";
|
|
@@ -28,7 +28,18 @@ function resolveAutopilotDefaultCwd(filename) {
|
|
|
28
28
|
}
|
|
29
29
|
return homedir();
|
|
30
30
|
}
|
|
31
|
+
function captureAutopilotWorkerEnv() {
|
|
32
|
+
return {
|
|
33
|
+
ORGX_AUTOPILOT_CWD: (process.env.ORGX_AUTOPILOT_CWD ?? "").trim() || undefined,
|
|
34
|
+
ORGX_AUTOPILOT_EXECUTOR: (process.env.ORGX_AUTOPILOT_EXECUTOR ?? "").trim() || undefined,
|
|
35
|
+
ORGX_AUTOPILOT_WORKER_KIND: (process.env.ORGX_AUTOPILOT_WORKER_KIND ?? "").trim() || undefined,
|
|
36
|
+
ORGX_AUTOPILOT_MOCK_SCENARIO: (process.env.ORGX_AUTOPILOT_MOCK_SCENARIO ?? "").trim() || undefined,
|
|
37
|
+
ORGX_AUTOPILOT_MOCK_SLEEP_MS: (process.env.ORGX_AUTOPILOT_MOCK_SLEEP_MS ?? "").trim() || undefined,
|
|
38
|
+
ORGX_AUTOPILOT_SESSION_RESUME: (process.env.ORGX_AUTOPILOT_SESSION_RESUME ?? "").trim() || undefined,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
31
41
|
export function createAutoContinueEngine(deps) {
|
|
42
|
+
const defaultWorkerEnvOverrides = captureAutopilotWorkerEnv();
|
|
32
43
|
const { client, safeErrorMessage, pidAlive, stopProcess, resolveOrgxAgentForDomain, checkSpawnGuardSafe, syncParentRollupsForTask, emitActivitySafe, requestDecisionSafe, registerArtifactSafe, applyAgentStatusUpdatesSafe, upsertRuntimeInstanceFromHook, broadcastRuntimeSse, clearSnapshotResponseCache, resolveByokEnvOverrides, } = deps;
|
|
33
44
|
const randomUUID = deps.randomUUID ?? randomUuidFn;
|
|
34
45
|
const fetchKickoffContextSafeFn = deps.fetchKickoffContextSafe ?? null;
|
|
@@ -731,6 +742,35 @@ export function createAutoContinueEngine(deps) {
|
|
|
731
742
|
}
|
|
732
743
|
return { queued: false, decisionIds: [] };
|
|
733
744
|
};
|
|
745
|
+
const defaultInterventionDecisionOptions = () => [
|
|
746
|
+
{
|
|
747
|
+
id: "retry_slice",
|
|
748
|
+
label: "Retry this workstream slice",
|
|
749
|
+
description: "Retry once with the latest context and logs.",
|
|
750
|
+
consequences: "Autopilot retries this workstream slice immediately.",
|
|
751
|
+
implied_status: "approved",
|
|
752
|
+
action_type: "retry",
|
|
753
|
+
requires_note: false,
|
|
754
|
+
},
|
|
755
|
+
{
|
|
756
|
+
id: "pause_and_investigate",
|
|
757
|
+
label: "Pause autopilot and investigate",
|
|
758
|
+
description: "Pause orchestration and capture operator notes for handoff.",
|
|
759
|
+
consequences: "Autopilot pauses and waits for new operator guidance.",
|
|
760
|
+
implied_status: "declined",
|
|
761
|
+
action_type: "pause",
|
|
762
|
+
requires_note: true,
|
|
763
|
+
},
|
|
764
|
+
{
|
|
765
|
+
id: "skip_for_now",
|
|
766
|
+
label: "Skip this workstream for now",
|
|
767
|
+
description: "Defer this lane and keep other workstreams moving.",
|
|
768
|
+
consequences: "This lane is deferred while the rest of the queue continues.",
|
|
769
|
+
implied_status: "declined",
|
|
770
|
+
action_type: "defer",
|
|
771
|
+
requires_note: true,
|
|
772
|
+
},
|
|
773
|
+
];
|
|
734
774
|
const __filename = deps.filename;
|
|
735
775
|
const autoContinueRuns = new Map();
|
|
736
776
|
/**
|
|
@@ -780,6 +820,9 @@ export function createAutoContinueEngine(deps) {
|
|
|
780
820
|
const now = new Date().toISOString();
|
|
781
821
|
const run = {
|
|
782
822
|
initiativeId,
|
|
823
|
+
workspaceId: typeof meta.workspace_id === "string" && meta.workspace_id.trim().length > 0
|
|
824
|
+
? meta.workspace_id.trim()
|
|
825
|
+
: null,
|
|
783
826
|
agentId: "",
|
|
784
827
|
agentName: null,
|
|
785
828
|
includeVerification: Boolean(meta.auto_continue_include_verification),
|
|
@@ -817,6 +860,10 @@ export function createAutoContinueEngine(deps) {
|
|
|
817
860
|
activeTaskTokenEstimate: typeof meta.auto_continue_active_task_token_estimate === "number"
|
|
818
861
|
? meta.auto_continue_active_task_token_estimate
|
|
819
862
|
: null,
|
|
863
|
+
workerEnvOverrides: null,
|
|
864
|
+
lastInitiativeStatus: typeof meta.status === "string" && meta.status.trim().length > 0
|
|
865
|
+
? meta.status.trim()
|
|
866
|
+
: null,
|
|
820
867
|
};
|
|
821
868
|
ensureRunInternals(run);
|
|
822
869
|
syncLegacyRunPointers(run);
|
|
@@ -1024,6 +1071,38 @@ export function createAutoContinueEngine(deps) {
|
|
|
1024
1071
|
autoContinueSliceChildren.delete(id);
|
|
1025
1072
|
autoContinueSliceLastHeartbeatMs.delete(id);
|
|
1026
1073
|
};
|
|
1074
|
+
const stopActiveSliceProcesses = async (sliceRunIds) => {
|
|
1075
|
+
for (const rawRunId of sliceRunIds) {
|
|
1076
|
+
const sliceRunId = rawRunId.trim();
|
|
1077
|
+
if (!sliceRunId)
|
|
1078
|
+
continue;
|
|
1079
|
+
const child = autoContinueSliceChildren.get(sliceRunId) ?? null;
|
|
1080
|
+
try {
|
|
1081
|
+
if (child && child.exitCode === null && !child.killed) {
|
|
1082
|
+
child.kill("SIGTERM");
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
catch {
|
|
1086
|
+
// best effort
|
|
1087
|
+
}
|
|
1088
|
+
const slice = autoContinueSliceRuns.get(sliceRunId) ?? null;
|
|
1089
|
+
const pid = slice?.pid ?? child?.pid ?? null;
|
|
1090
|
+
if (pid && pidAlive(pid)) {
|
|
1091
|
+
try {
|
|
1092
|
+
await stopProcess(pid);
|
|
1093
|
+
}
|
|
1094
|
+
catch {
|
|
1095
|
+
// best effort
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
if (slice) {
|
|
1099
|
+
slice.pid = null;
|
|
1100
|
+
slice.updatedAt = new Date().toISOString();
|
|
1101
|
+
autoContinueSliceRuns.set(sliceRunId, slice);
|
|
1102
|
+
}
|
|
1103
|
+
clearAutoContinueSliceTransientState(sliceRunId);
|
|
1104
|
+
}
|
|
1105
|
+
};
|
|
1027
1106
|
const AUTO_CONTINUE_SLICE_TIMEOUT_MS = readBudgetEnvNumber("ORGX_AUTOPILOT_SLICE_TIMEOUT_MS", 55 * 60_000,
|
|
1028
1107
|
// Keep test runs fast; real-world defaults are still ~1h unless overridden.
|
|
1029
1108
|
{ min: 250, max: 6 * 60 * 60_000 });
|
|
@@ -1211,6 +1290,57 @@ export function createAutoContinueEngine(deps) {
|
|
|
1211
1290
|
run.maxParallelSlices = normalizeMaxParallelSlices(run.maxParallelSlices, AUTO_CONTINUE_MAX_PARALLEL_DEFAULT);
|
|
1212
1291
|
run.parallelMode = normalizeParallelMode(run.parallelMode);
|
|
1213
1292
|
run.tokenBudget = normalizeTokenBudget(run.tokenBudget, defaultAutoContinueTokenBudget());
|
|
1293
|
+
if (!run.workerEnvOverrides || typeof run.workerEnvOverrides !== "object") {
|
|
1294
|
+
run.workerEnvOverrides = null;
|
|
1295
|
+
}
|
|
1296
|
+
run.workspaceId =
|
|
1297
|
+
typeof run.workspaceId === "string" && run.workspaceId.trim().length > 0
|
|
1298
|
+
? run.workspaceId.trim()
|
|
1299
|
+
: null;
|
|
1300
|
+
run.lastInitiativeStatus =
|
|
1301
|
+
typeof run.lastInitiativeStatus === "string" && run.lastInitiativeStatus.trim().length > 0
|
|
1302
|
+
? run.lastInitiativeStatus.trim()
|
|
1303
|
+
: null;
|
|
1304
|
+
};
|
|
1305
|
+
const laneStateToChildStatus = (laneState) => {
|
|
1306
|
+
if (laneState === LaneState.RUNNING)
|
|
1307
|
+
return "in_progress";
|
|
1308
|
+
if (laneState === LaneState.BLOCKED)
|
|
1309
|
+
return "blocked";
|
|
1310
|
+
if (laneState === LaneState.WAITING_DEPENDENCY || laneState === LaneState.RATE_LIMITED) {
|
|
1311
|
+
return "paused";
|
|
1312
|
+
}
|
|
1313
|
+
if (laneState === LaneState.COMPLETED)
|
|
1314
|
+
return "completed";
|
|
1315
|
+
return "todo";
|
|
1316
|
+
};
|
|
1317
|
+
const deriveInitiativeStatusFromRun = (run) => {
|
|
1318
|
+
ensureRunInternals(run);
|
|
1319
|
+
const childStatuses = Object.values(run.laneByWorkstreamId ?? {}).map((lane) => laneStateToChildStatus(lane.state));
|
|
1320
|
+
if (run.status === RunStatus.RUNNING || run.status === RunStatus.STOPPING) {
|
|
1321
|
+
return deriveInitiativeLifecycleStatus("active", childStatuses.length > 0 ? childStatuses : ["in_progress"]);
|
|
1322
|
+
}
|
|
1323
|
+
if (run.stopReason === "blocked" || run.stopReason === "error") {
|
|
1324
|
+
return "blocked";
|
|
1325
|
+
}
|
|
1326
|
+
if (run.stopReason === "completed") {
|
|
1327
|
+
const scopedRun = run.stopAfterSlice ||
|
|
1328
|
+
(Array.isArray(run.allowedWorkstreamIds) && run.allowedWorkstreamIds.length > 0);
|
|
1329
|
+
return scopedRun ? "paused" : "completed";
|
|
1330
|
+
}
|
|
1331
|
+
if (run.stopReason === "budget_exhausted" || run.stopReason === "stopped") {
|
|
1332
|
+
return "paused";
|
|
1333
|
+
}
|
|
1334
|
+
return childStatuses.length > 0
|
|
1335
|
+
? deriveInitiativeLifecycleStatus("paused", childStatuses)
|
|
1336
|
+
: "paused";
|
|
1337
|
+
};
|
|
1338
|
+
const syncInitiativeLifecycleStatus = async (run) => {
|
|
1339
|
+
const nextStatus = deriveInitiativeStatusFromRun(run);
|
|
1340
|
+
if (run.lastInitiativeStatus === nextStatus)
|
|
1341
|
+
return;
|
|
1342
|
+
await client.updateEntity("initiative", run.initiativeId, { status: nextStatus });
|
|
1343
|
+
run.lastInitiativeStatus = nextStatus;
|
|
1214
1344
|
};
|
|
1215
1345
|
const recordLocalStatusOverrides = (input) => {
|
|
1216
1346
|
const initiativeId = input.initiativeId.trim();
|
|
@@ -1485,6 +1615,7 @@ export function createAutoContinueEngine(deps) {
|
|
|
1485
1615
|
updated_at: lane.updatedAt,
|
|
1486
1616
|
}));
|
|
1487
1617
|
const patch = {
|
|
1618
|
+
...(input.run.workspaceId ? { workspace_id: input.run.workspaceId } : {}),
|
|
1488
1619
|
auto_continue_enabled: input.run.status === RunStatus.RUNNING || input.run.status === RunStatus.STOPPING,
|
|
1489
1620
|
auto_continue_status: input.run.status,
|
|
1490
1621
|
auto_continue_stop_reason: input.run.stopReason,
|
|
@@ -1510,6 +1641,7 @@ export function createAutoContinueEngine(deps) {
|
|
|
1510
1641
|
...(input.run.lastError ? { auto_continue_last_error: input.run.lastError } : {}),
|
|
1511
1642
|
};
|
|
1512
1643
|
await updateInitiativeMetadata(input.initiativeId, patch);
|
|
1644
|
+
await syncInitiativeLifecycleStatus(input.run);
|
|
1513
1645
|
}
|
|
1514
1646
|
async function stopAutoContinueRun(input) {
|
|
1515
1647
|
const decisionRequired = input.reason === "blocked" && input.decisionRequired === true;
|
|
@@ -1524,6 +1656,7 @@ export function createAutoContinueEngine(deps) {
|
|
|
1524
1656
|
const now = new Date().toISOString();
|
|
1525
1657
|
ensureRunInternals(input.run);
|
|
1526
1658
|
const activeRunIds = listActiveSliceRunIds(input.run);
|
|
1659
|
+
await stopActiveSliceProcesses(activeRunIds);
|
|
1527
1660
|
input.run.status = RunStatus.STOPPED;
|
|
1528
1661
|
input.run.stopReason = input.reason;
|
|
1529
1662
|
input.run.stoppedAt = now;
|
|
@@ -1553,18 +1686,6 @@ export function createAutoContinueEngine(deps) {
|
|
|
1553
1686
|
for (const runId of activeRunIds) {
|
|
1554
1687
|
clearAutoContinueSliceTransientState(runId);
|
|
1555
1688
|
}
|
|
1556
|
-
// Only pause the initiative on non-terminal stops (error, blocked, user-requested).
|
|
1557
|
-
// Completed / budget-exhausted runs should not override the initiative status.
|
|
1558
|
-
if (input.reason !== "completed" && input.reason !== "budget_exhausted") {
|
|
1559
|
-
try {
|
|
1560
|
-
await client.updateEntity("initiative", input.run.initiativeId, {
|
|
1561
|
-
status: "paused",
|
|
1562
|
-
});
|
|
1563
|
-
}
|
|
1564
|
-
catch {
|
|
1565
|
-
// best effort
|
|
1566
|
-
}
|
|
1567
|
-
}
|
|
1568
1689
|
try {
|
|
1569
1690
|
await updateInitiativeAutoContinueState({
|
|
1570
1691
|
initiativeId: input.run.initiativeId,
|
|
@@ -1685,7 +1806,7 @@ export function createAutoContinueEngine(deps) {
|
|
|
1685
1806
|
old_state: LaneState.RUNNING,
|
|
1686
1807
|
new_state: input.reason === "completed" || input.reason === "stopped" ? "idle" : input.reason === "blocked" ? "blocked" : input.reason === "error" ? "error" : "idle",
|
|
1687
1808
|
reason: input.reason,
|
|
1688
|
-
workspace_id: input.run.
|
|
1809
|
+
workspace_id: input.run.workspaceId ?? null,
|
|
1689
1810
|
},
|
|
1690
1811
|
});
|
|
1691
1812
|
}
|
|
@@ -1843,11 +1964,7 @@ export function createAutoContinueEngine(deps) {
|
|
|
1843
1964
|
title: `Agent couldn't connect to tools: ${slice.workstreamTitle ?? slice.workstreamId}`,
|
|
1844
1965
|
summary: humanizeSliceFailureSummary(`MCP handshake failed${mcpHandshake.server ? ` for ${mcpHandshake.server}` : ""}.`),
|
|
1845
1966
|
urgency: "high",
|
|
1846
|
-
options:
|
|
1847
|
-
"Retry this workstream slice",
|
|
1848
|
-
"Pause autopilot and investigate",
|
|
1849
|
-
"Skip this workstream for now",
|
|
1850
|
-
],
|
|
1967
|
+
options: defaultInterventionDecisionOptions(),
|
|
1851
1968
|
blocking: true,
|
|
1852
1969
|
decisionType: "autopilot_failure",
|
|
1853
1970
|
workstreamId: slice.workstreamId,
|
|
@@ -1965,11 +2082,7 @@ export function createAutoContinueEngine(deps) {
|
|
|
1965
2082
|
title: stallDecisionTitle,
|
|
1966
2083
|
summary: humanizeSliceFailureSummary(slice.lastError ?? `Autopilot slice ${humanLabel}`),
|
|
1967
2084
|
urgency: "high",
|
|
1968
|
-
options:
|
|
1969
|
-
"Retry this workstream slice",
|
|
1970
|
-
"Pause autopilot and investigate",
|
|
1971
|
-
"Skip this workstream for now",
|
|
1972
|
-
],
|
|
2085
|
+
options: defaultInterventionDecisionOptions(),
|
|
1973
2086
|
blocking: true,
|
|
1974
2087
|
decisionType: "autopilot_failure",
|
|
1975
2088
|
workstreamId: slice.workstreamId,
|
|
@@ -2067,6 +2180,68 @@ export function createAutoContinueEngine(deps) {
|
|
|
2067
2180
|
}
|
|
2068
2181
|
}
|
|
2069
2182
|
const defaultDecisionBlocking = parsedStatus === "completed" ? false : true;
|
|
2183
|
+
const normalizeDecisionOptions = (value) => {
|
|
2184
|
+
if (!Array.isArray(value))
|
|
2185
|
+
return [];
|
|
2186
|
+
const normalized = [];
|
|
2187
|
+
for (const rawOption of value) {
|
|
2188
|
+
if (typeof rawOption === "string") {
|
|
2189
|
+
const label = rawOption.trim();
|
|
2190
|
+
if (label.length > 0)
|
|
2191
|
+
normalized.push(label);
|
|
2192
|
+
continue;
|
|
2193
|
+
}
|
|
2194
|
+
if (!rawOption || typeof rawOption !== "object" || Array.isArray(rawOption)) {
|
|
2195
|
+
continue;
|
|
2196
|
+
}
|
|
2197
|
+
const optionRecord = rawOption;
|
|
2198
|
+
const label = (typeof optionRecord.label === "string" && optionRecord.label.trim()) ||
|
|
2199
|
+
(typeof optionRecord.title === "string" && optionRecord.title.trim()) ||
|
|
2200
|
+
(typeof optionRecord.name === "string" && optionRecord.name.trim()) ||
|
|
2201
|
+
null;
|
|
2202
|
+
if (!label)
|
|
2203
|
+
continue;
|
|
2204
|
+
const normalizedRecord = { label };
|
|
2205
|
+
const id = (typeof optionRecord.id === "string" && optionRecord.id.trim()) ||
|
|
2206
|
+
(typeof optionRecord.option_id === "string" && optionRecord.option_id.trim()) ||
|
|
2207
|
+
null;
|
|
2208
|
+
if (id)
|
|
2209
|
+
normalizedRecord.id = id;
|
|
2210
|
+
const description = (typeof optionRecord.description === "string" && optionRecord.description.trim()) ||
|
|
2211
|
+
null;
|
|
2212
|
+
if (description)
|
|
2213
|
+
normalizedRecord.description = description;
|
|
2214
|
+
const consequences = (typeof optionRecord.consequences === "string" && optionRecord.consequences.trim()) ||
|
|
2215
|
+
(typeof optionRecord.impact === "string" && optionRecord.impact.trim()) ||
|
|
2216
|
+
null;
|
|
2217
|
+
if (consequences)
|
|
2218
|
+
normalizedRecord.consequences = consequences;
|
|
2219
|
+
const impliedStatusRaw = typeof optionRecord.implied_status === "string"
|
|
2220
|
+
? optionRecord.implied_status
|
|
2221
|
+
: typeof optionRecord.status === "string"
|
|
2222
|
+
? optionRecord.status
|
|
2223
|
+
: null;
|
|
2224
|
+
if (impliedStatusRaw) {
|
|
2225
|
+
const implied = impliedStatusRaw.trim().toLowerCase();
|
|
2226
|
+
if (implied === "approved" ||
|
|
2227
|
+
implied === "declined" ||
|
|
2228
|
+
implied === "cancelled" ||
|
|
2229
|
+
implied === "rejected") {
|
|
2230
|
+
normalizedRecord.implied_status = implied;
|
|
2231
|
+
}
|
|
2232
|
+
}
|
|
2233
|
+
const actionType = normalizeDecisionActionType(optionRecord.action_type ?? optionRecord.type ?? optionRecord.verb ?? optionRecord.action);
|
|
2234
|
+
if (actionType)
|
|
2235
|
+
normalizedRecord.action_type = actionType;
|
|
2236
|
+
if (optionRecord.requires_note === true ||
|
|
2237
|
+
optionRecord.requiresNote === true ||
|
|
2238
|
+
optionRecord.note_required === true) {
|
|
2239
|
+
normalizedRecord.requires_note = true;
|
|
2240
|
+
}
|
|
2241
|
+
normalized.push(normalizedRecord);
|
|
2242
|
+
}
|
|
2243
|
+
return normalized.slice(0, 8);
|
|
2244
|
+
};
|
|
2070
2245
|
const allDecisions = Array.isArray(parsed?.decisions_needed)
|
|
2071
2246
|
? (parsed?.decisions_needed ?? [])
|
|
2072
2247
|
.filter((item) => Boolean(item && typeof item.question === "string" && item.question.trim()))
|
|
@@ -2210,9 +2385,7 @@ export function createAutoContinueEngine(deps) {
|
|
|
2210
2385
|
title: normalizedQuestion,
|
|
2211
2386
|
summary: decision.summary ?? parsed?.summary ?? null,
|
|
2212
2387
|
urgency: decision.urgency ?? "high",
|
|
2213
|
-
options:
|
|
2214
|
-
? decision.options.filter((opt) => typeof opt === "string" && opt.trim())
|
|
2215
|
-
: [],
|
|
2388
|
+
options: normalizeDecisionOptions(decision.options),
|
|
2216
2389
|
blocking: isBlocking,
|
|
2217
2390
|
decisionType: isBlocking
|
|
2218
2391
|
? "autopilot_blocking_decision"
|
|
@@ -2606,11 +2779,7 @@ export function createAutoContinueEngine(deps) {
|
|
|
2606
2779
|
title: fallbackDecisionTitle,
|
|
2607
2780
|
summary: fallbackDecisionSummary,
|
|
2608
2781
|
urgency: "high",
|
|
2609
|
-
options:
|
|
2610
|
-
"Retry this workstream slice",
|
|
2611
|
-
"Pause autopilot and investigate",
|
|
2612
|
-
"Skip this workstream for now",
|
|
2613
|
-
],
|
|
2782
|
+
options: defaultInterventionDecisionOptions(),
|
|
2614
2783
|
blocking: true,
|
|
2615
2784
|
decisionType: looksLikeNoOutcome
|
|
2616
2785
|
? "autopilot_completed_without_outcome"
|
|
@@ -2692,11 +2861,7 @@ export function createAutoContinueEngine(deps) {
|
|
|
2692
2861
|
title: attentionTitle,
|
|
2693
2862
|
summary: attentionSummary,
|
|
2694
2863
|
urgency: "high",
|
|
2695
|
-
options:
|
|
2696
|
-
"Retry this workstream slice",
|
|
2697
|
-
"Pause autopilot and investigate",
|
|
2698
|
-
"Skip this workstream for now",
|
|
2699
|
-
],
|
|
2864
|
+
options: defaultInterventionDecisionOptions(),
|
|
2700
2865
|
blocking: true,
|
|
2701
2866
|
decisionType: completionHadNoOutcome
|
|
2702
2867
|
? "autopilot_completed_without_outcome"
|
|
@@ -3704,16 +3869,27 @@ export function createAutoContinueEngine(deps) {
|
|
|
3704
3869
|
const logsDir = join(getOrgxPluginConfigDir(), AUTO_CONTINUE_SLICE_LOG_DIRNAME);
|
|
3705
3870
|
const logPath = join(logsDir, `${sliceRunId}.log`);
|
|
3706
3871
|
const outputPath = join(logsDir, `${sliceRunId}.output.json`);
|
|
3707
|
-
const
|
|
3872
|
+
const workerEnvOverrides = run.workerEnvOverrides ?? defaultWorkerEnvOverrides;
|
|
3873
|
+
const configuredWorkerCwd = (workerEnvOverrides?.ORGX_AUTOPILOT_CWD ??
|
|
3874
|
+
process.env.ORGX_AUTOPILOT_CWD ??
|
|
3875
|
+
"").trim();
|
|
3708
3876
|
let workerCwd = configuredWorkerCwd || resolveAutopilotDefaultCwd(__filename);
|
|
3709
3877
|
// LaunchAgents sometimes start with cwd="/". Fall back to plugin root (or home if unresolved).
|
|
3710
3878
|
if (!workerCwd || workerCwd === "/") {
|
|
3711
3879
|
workerCwd = resolveAutopilotDefaultCwd(__filename);
|
|
3712
3880
|
}
|
|
3713
3881
|
const sliceAgent = resolveOrgxAgentForDomain(executionPolicy.domain);
|
|
3714
|
-
const workerKind = (
|
|
3882
|
+
const workerKind = (workerEnvOverrides?.ORGX_AUTOPILOT_WORKER_KIND ??
|
|
3883
|
+
process.env.ORGX_AUTOPILOT_WORKER_KIND ??
|
|
3884
|
+
"")
|
|
3885
|
+
.trim()
|
|
3886
|
+
.toLowerCase();
|
|
3715
3887
|
const inferredExecutor = workerKind === "claude-code" || workerKind === "claude_code" ? "claude-code" : "codex";
|
|
3716
|
-
const executorRaw = (
|
|
3888
|
+
const executorRaw = (workerEnvOverrides?.ORGX_AUTOPILOT_EXECUTOR ??
|
|
3889
|
+
process.env.ORGX_AUTOPILOT_EXECUTOR ??
|
|
3890
|
+
"")
|
|
3891
|
+
.trim()
|
|
3892
|
+
.toLowerCase() || inferredExecutor;
|
|
3717
3893
|
const executorSourceClient = executorRaw === "claude-code" || executorRaw === "claude_code" ? "claude-code" : "codex";
|
|
3718
3894
|
let runtimeHookUrl = null;
|
|
3719
3895
|
let runtimeHookToken = null;
|
|
@@ -3738,6 +3914,7 @@ export function createAutoContinueEngine(deps) {
|
|
|
3738
3914
|
outputSchemaPath: schemaPath,
|
|
3739
3915
|
resumeSessionId: resumedFromSessionId,
|
|
3740
3916
|
env: {
|
|
3917
|
+
...(workerEnvOverrides ?? {}),
|
|
3741
3918
|
ORGX_SOURCE_CLIENT: executorSourceClient,
|
|
3742
3919
|
ORGX_RUN_ID: sliceRunId,
|
|
3743
3920
|
ORGX_CORRELATION_ID: sliceRunId,
|
|
@@ -3915,12 +4092,6 @@ export function createAutoContinueEngine(deps) {
|
|
|
3915
4092
|
// Clear stale errors when a new slice dispatches successfully.
|
|
3916
4093
|
run.lastError = null;
|
|
3917
4094
|
run.updatedAt = now;
|
|
3918
|
-
try {
|
|
3919
|
-
await client.updateEntity("initiative", run.initiativeId, { status: "active" });
|
|
3920
|
-
}
|
|
3921
|
-
catch {
|
|
3922
|
-
// best effort
|
|
3923
|
-
}
|
|
3924
4095
|
try {
|
|
3925
4096
|
await updateInitiativeAutoContinueState({
|
|
3926
4097
|
initiativeId: run.initiativeId,
|
|
@@ -4013,6 +4184,7 @@ export function createAutoContinueEngine(deps) {
|
|
|
4013
4184
|
const sourceEvent = (input.event ?? "").trim() || null;
|
|
4014
4185
|
const requestedByAgentId = (input.requestedByAgentId ?? "").trim() || null;
|
|
4015
4186
|
const requestedByAgentName = (input.requestedByAgentName ?? "").trim() || null;
|
|
4187
|
+
const autoFixWorkerEnv = captureAutopilotWorkerEnv();
|
|
4016
4188
|
const providedGraceMs = typeof input.graceMs === "number" && Number.isFinite(input.graceMs)
|
|
4017
4189
|
? Math.floor(input.graceMs)
|
|
4018
4190
|
: null;
|
|
@@ -4188,6 +4360,7 @@ export function createAutoContinueEngine(deps) {
|
|
|
4188
4360
|
null;
|
|
4189
4361
|
const dispatchRun = await startAutoContinueRun({
|
|
4190
4362
|
initiativeId,
|
|
4363
|
+
workspaceId: latestRun?.workspaceId ?? null,
|
|
4191
4364
|
agentId: dispatchAgentId,
|
|
4192
4365
|
agentName: dispatchAgentName,
|
|
4193
4366
|
// Auto-fix retries should follow current defaults unless an operator explicitly
|
|
@@ -4199,6 +4372,7 @@ export function createAutoContinueEngine(deps) {
|
|
|
4199
4372
|
parallelMode: latestRun?.parallelMode ?? "iwmt",
|
|
4200
4373
|
stopAfterSlice: true,
|
|
4201
4374
|
ignoreSpawnGuardRateLimit: latestRun?.ignoreSpawnGuardRateLimit ?? false,
|
|
4375
|
+
workerEnvOverrides: autoFixWorkerEnv,
|
|
4202
4376
|
});
|
|
4203
4377
|
await tickAutoContinueRun(dispatchRun);
|
|
4204
4378
|
await emitActivitySafe({
|
|
@@ -4293,11 +4467,15 @@ export function createAutoContinueEngine(deps) {
|
|
|
4293
4467
|
}
|
|
4294
4468
|
async function startAutoContinueRun(input) {
|
|
4295
4469
|
const now = new Date().toISOString();
|
|
4470
|
+
const nextWorkerEnvOverrides = input.workerEnvOverrides && typeof input.workerEnvOverrides === "object"
|
|
4471
|
+
? { ...input.workerEnvOverrides }
|
|
4472
|
+
: { ...defaultWorkerEnvOverrides };
|
|
4296
4473
|
const existing = autoContinueRuns.get(input.initiativeId) ?? null;
|
|
4297
4474
|
const existingIsLive = existing?.status === RunStatus.RUNNING || existing?.status === RunStatus.STOPPING;
|
|
4298
4475
|
const run = existing ??
|
|
4299
4476
|
{
|
|
4300
4477
|
initiativeId: input.initiativeId,
|
|
4478
|
+
workspaceId: null,
|
|
4301
4479
|
agentId: input.agentId,
|
|
4302
4480
|
agentName: input.agentName ?? null,
|
|
4303
4481
|
includeVerification: false,
|
|
@@ -4325,8 +4503,14 @@ export function createAutoContinueEngine(deps) {
|
|
|
4325
4503
|
activeTaskId: null,
|
|
4326
4504
|
activeRunId: null,
|
|
4327
4505
|
activeTaskTokenEstimate: null,
|
|
4506
|
+
workerEnvOverrides: null,
|
|
4507
|
+
lastInitiativeStatus: null,
|
|
4328
4508
|
};
|
|
4329
4509
|
ensureRunInternals(run);
|
|
4510
|
+
run.workspaceId =
|
|
4511
|
+
typeof input.workspaceId === "string" && input.workspaceId.trim().length > 0
|
|
4512
|
+
? input.workspaceId.trim()
|
|
4513
|
+
: run.workspaceId;
|
|
4330
4514
|
run.agentId = input.agentId;
|
|
4331
4515
|
run.agentName =
|
|
4332
4516
|
typeof input.agentName === "string" && input.agentName.trim().length > 0
|
|
@@ -4339,6 +4523,7 @@ export function createAutoContinueEngine(deps) {
|
|
|
4339
4523
|
run.stopAfterSlice = Boolean(input.stopAfterSlice);
|
|
4340
4524
|
run.ignoreSpawnGuardRateLimit = Boolean(input.ignoreSpawnGuardRateLimit);
|
|
4341
4525
|
run.scope = input.scope ?? "task";
|
|
4526
|
+
run.workerEnvOverrides = nextWorkerEnvOverrides;
|
|
4342
4527
|
const hasExplicitTokenBudgetInput = input.tokenBudget !== null &&
|
|
4343
4528
|
input.tokenBudget !== undefined &&
|
|
4344
4529
|
!(typeof input.tokenBudget === "string" && input.tokenBudget.trim().length === 0);
|
|
@@ -4375,11 +4560,6 @@ export function createAutoContinueEngine(deps) {
|
|
|
4375
4560
|
}
|
|
4376
4561
|
syncLegacyRunPointers(run);
|
|
4377
4562
|
autoContinueRuns.set(input.initiativeId, run);
|
|
4378
|
-
void client
|
|
4379
|
-
.updateEntity("initiative", input.initiativeId, { status: "active" })
|
|
4380
|
-
.catch(() => {
|
|
4381
|
-
// best effort
|
|
4382
|
-
});
|
|
4383
4563
|
void updateInitiativeAutoContinueState({
|
|
4384
4564
|
initiativeId: input.initiativeId,
|
|
4385
4565
|
run,
|
|
@@ -4438,7 +4618,7 @@ export function createAutoContinueEngine(deps) {
|
|
|
4438
4618
|
old_state: LaneState.IDLE,
|
|
4439
4619
|
new_state: LaneState.RUNNING,
|
|
4440
4620
|
reason: "started",
|
|
4441
|
-
workspace_id: run.
|
|
4621
|
+
workspace_id: run.workspaceId ?? null,
|
|
4442
4622
|
},
|
|
4443
4623
|
});
|
|
4444
4624
|
}
|
|
@@ -199,7 +199,11 @@ export function createAutopilotRuntime(deps) {
|
|
|
199
199
|
function spawnCodexSliceWorker(input) {
|
|
200
200
|
ensurePrivateDirForFile(input.logPath);
|
|
201
201
|
ensurePrivateDirForFile(input.outputPath);
|
|
202
|
-
const workerKind = (
|
|
202
|
+
const workerKind = (input.env.ORGX_AUTOPILOT_WORKER_KIND ??
|
|
203
|
+
process.env.ORGX_AUTOPILOT_WORKER_KIND ??
|
|
204
|
+
"")
|
|
205
|
+
.trim()
|
|
206
|
+
.toLowerCase();
|
|
203
207
|
if (workerKind === "mock") {
|
|
204
208
|
const scriptPath = resolve(dirname(deps.filename), "..", "..", "scripts", "mock-autopilot-slice-worker.mjs");
|
|
205
209
|
const logStream = createSafeAppendStream(input.logPath);
|