@a5c-ai/babysitter-sdk 5.0.1-staging.dc0fcf07 → 5.0.1-staging.dc2dc1847
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/dist/breakpoints/evaluator.js +1 -1
- package/dist/cli/commands/detectExistingRun.d.ts +14 -0
- package/dist/cli/commands/detectExistingRun.d.ts.map +1 -0
- package/dist/cli/commands/detectExistingRun.js +89 -0
- package/dist/cli/commands/hooks/log.d.ts.map +1 -1
- package/dist/cli/commands/hooks/log.js +4 -1
- package/dist/cli/commands/instructions.d.ts.map +1 -1
- package/dist/cli/commands/instructions.js +24 -44
- package/dist/cli/commands/mcpServe.js +1 -1
- package/dist/cli/commands/session/checkIteration.d.ts.map +1 -1
- package/dist/cli/commands/session/checkIteration.js +0 -22
- package/dist/cli/commands/session/init.d.ts.map +1 -1
- package/dist/cli/commands/session/init.js +2 -1
- package/dist/cli/commands/session/resume.js +1 -1
- package/dist/cli/commands/session/update.d.ts +0 -1
- package/dist/cli/commands/session/update.d.ts.map +1 -1
- package/dist/cli/commands/session/update.js +0 -12
- package/dist/cli/commands/skill/remoteDiscovery.js +1 -1
- package/dist/cli/main/argFlags.d.ts.map +1 -1
- package/dist/cli/main/argFlags.js +0 -3
- package/dist/cli/main/argPositionals.d.ts.map +1 -1
- package/dist/cli/main/argPositionals.js +1 -0
- package/dist/cli/main/dispatchRunSession.d.ts.map +1 -1
- package/dist/cli/main/dispatchRunSession.js +2 -1
- package/dist/cli/main/program.js +2 -2
- package/dist/cli/main/runAssignProcess.d.ts +3 -0
- package/dist/cli/main/runAssignProcess.d.ts.map +1 -0
- package/dist/cli/main/runAssignProcess.js +169 -0
- package/dist/cli/main/runCommands.d.ts +1 -0
- package/dist/cli/main/runCommands.d.ts.map +1 -1
- package/dist/cli/main/runCommands.js +3 -1
- package/dist/cli/main/runCreate.d.ts.map +1 -1
- package/dist/cli/main/runCreate.js +31 -27
- package/dist/cli/main/types.d.ts +0 -1
- package/dist/cli/main/types.d.ts.map +1 -1
- package/dist/cli/main/usage.d.ts.map +1 -1
- package/dist/cli/main/usage.js +6 -5
- package/dist/cli/render/events/index.d.ts.map +1 -1
- package/dist/cli/render/events/index.js +2 -0
- package/dist/cli/render/events/processAssigned.d.ts +3 -0
- package/dist/cli/render/events/processAssigned.d.ts.map +1 -0
- package/dist/cli/render/events/processAssigned.js +22 -0
- package/dist/config/defaults.js +1 -1
- package/dist/harness/adapters/claude-code.d.ts.map +1 -1
- package/dist/harness/adapters/claude-code.js +1 -0
- package/dist/harness/amuxFallbackMetadata.d.ts.map +1 -1
- package/dist/harness/amuxFallbackMetadata.js +10 -2
- package/dist/harness/hooks/promptContexts.d.ts +6 -1
- package/dist/harness/hooks/promptContexts.d.ts.map +1 -1
- package/dist/harness/hooks/promptContexts.js +65 -142
- package/dist/harness/hooks/sessionBinding.d.ts.map +1 -1
- package/dist/harness/hooks/sessionBinding.js +10 -2
- package/dist/harness/hooks/stopHookHandler.d.ts.map +1 -1
- package/dist/harness/hooks/stopHookHandler.js +8 -25
- package/dist/harness/hooks/utils.d.ts +1 -1
- package/dist/harness/hooks/utils.d.ts.map +1 -1
- package/dist/harness/hooks/utils.js +15 -8
- package/dist/harness/install.d.ts +0 -4
- package/dist/harness/install.d.ts.map +1 -1
- package/dist/harness/install.js +79 -0
- package/dist/harness/installSupport.js +11 -11
- package/dist/harness/registry.d.ts.map +1 -1
- package/dist/harness/registry.js +64 -68
- package/dist/harness/unified/adapter.d.ts.map +1 -1
- package/dist/harness/unified/adapter.js +31 -0
- package/dist/hooks/dispatcher.d.ts +2 -2
- package/dist/hooks/dispatcher.d.ts.map +1 -1
- package/dist/hooks/dispatcher.js +56 -15
- package/dist/logging/runLogger.d.ts.map +1 -1
- package/dist/logging/runLogger.js +2 -0
- package/dist/mcp/tools/discovery.js +6 -6
- package/dist/mcp/tools/runs.js +18 -18
- package/dist/mcp/tools/sessions.d.ts.map +1 -1
- package/dist/mcp/tools/sessions.js +21 -20
- package/dist/mcp/tools/tasks.js +13 -13
- package/dist/prompts/capabilityCollector.d.ts.map +1 -1
- package/dist/prompts/capabilityCollector.js +23 -14
- package/dist/prompts/compose.d.ts.map +1 -1
- package/dist/prompts/compose.js +13 -2
- package/dist/prompts/context.d.ts +2 -2
- package/dist/prompts/context.d.ts.map +1 -1
- package/dist/prompts/context.js +4 -11
- package/dist/prompts/index.d.ts +1 -1
- package/dist/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js +3 -6
- package/dist/prompts/parts/criticalRules.d.ts.map +1 -1
- package/dist/prompts/parts/criticalRules.js +14 -1
- package/dist/prompts/parts/runCreation.d.ts.map +1 -1
- package/dist/prompts/parts/runCreation.js +25 -4
- package/dist/prompts/parts/taskKinds.d.ts.map +1 -1
- package/dist/prompts/parts/taskKinds.js +11 -3
- package/dist/prompts/templates/commands/assimilate.md +1 -1
- package/dist/prompts/templates/commands/cleanup.md +31 -9
- package/dist/prompts/templates/commands/contrib.md +1 -1
- package/dist/prompts/templates/commands/doctor.md +3 -4
- package/dist/prompts/templates/commands/forever.md +1 -1
- package/dist/prompts/templates/commands/project-install.md +1 -1
- package/dist/prompts/templates/commands/retrospect.md +1 -1
- package/dist/prompts/templates/commands/user-install.md +1 -1
- package/dist/prompts/templates/quick-reference.md +5 -0
- package/dist/prompts/templates/run-creation.md +45 -1
- package/dist/runtime/createRun.d.ts.map +1 -1
- package/dist/runtime/createRun.js +5 -3
- package/dist/runtime/intrinsics/breakpoint.js +1 -1
- package/dist/runtime/orchestrateIteration.d.ts.map +1 -1
- package/dist/runtime/orchestrateIteration.js +3 -0
- package/dist/runtime/processContext.d.ts.map +1 -1
- package/dist/runtime/processContext.js +12 -0
- package/dist/runtime/replay/stateCache.d.ts +2 -0
- package/dist/runtime/replay/stateCache.d.ts.map +1 -1
- package/dist/runtime/replay/stateCache.js +14 -3
- package/dist/runtime/types.d.ts +13 -1
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/sdkVersion.d.ts +5 -0
- package/dist/sdkVersion.d.ts.map +1 -0
- package/dist/sdkVersion.js +49 -0
- package/dist/session/index.d.ts +1 -1
- package/dist/session/index.d.ts.map +1 -1
- package/dist/session/index.js +1 -3
- package/dist/session/parse.d.ts.map +1 -1
- package/dist/session/parse.js +5 -1
- package/dist/session/types.d.ts +3 -7
- package/dist/session/types.d.ts.map +1 -1
- package/dist/session/write.d.ts +1 -10
- package/dist/session/write.d.ts.map +1 -1
- package/dist/session/write.js +4 -31
- package/dist/storage/createRunDir.d.ts.map +1 -1
- package/dist/storage/createRunDir.js +2 -1
- package/dist/storage/index.d.ts +1 -1
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +2 -1
- package/dist/storage/journal.d.ts.map +1 -1
- package/dist/storage/journal.js +4 -2
- package/dist/storage/runFiles.d.ts +1 -0
- package/dist/storage/runFiles.d.ts.map +1 -1
- package/dist/storage/runFiles.js +5 -0
- package/dist/storage/tasks.d.ts.map +1 -1
- package/dist/storage/tasks.js +3 -2
- package/dist/storage/types.d.ts +3 -0
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/tasks/defineTask.d.ts +28 -0
- package/dist/tasks/defineTask.d.ts.map +1 -1
- package/dist/tasks/defineTask.js +42 -1
- package/package.json +13 -10
|
@@ -15,7 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.evaluateAutoApproval = evaluateAutoApproval;
|
|
16
16
|
const patterns_1 = require("./patterns");
|
|
17
17
|
// ---------------------------------------------------------------------------
|
|
18
|
-
// Inlined posture helpers (canonical implementation moved to babysitter-
|
|
18
|
+
// Inlined posture helpers (canonical implementation moved to babysitter-agent)
|
|
19
19
|
// ---------------------------------------------------------------------------
|
|
20
20
|
const DEFAULT_POSTURES = {
|
|
21
21
|
read: { name: 'permissive', allowAutoApprove: true, minConsecutiveApprovalsForAutoN: 0, requireExplicitRule: false, requiredApproverLevel: 'any' },
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface ExistingRunInfo {
|
|
2
|
+
runId: string;
|
|
3
|
+
runDir: string;
|
|
4
|
+
processId: string;
|
|
5
|
+
isBareRun: boolean;
|
|
6
|
+
entrypoint: {
|
|
7
|
+
importPath: string;
|
|
8
|
+
exportName?: string;
|
|
9
|
+
};
|
|
10
|
+
completionProof?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function detectExistingRun(): Promise<ExistingRunInfo | undefined>;
|
|
13
|
+
export declare function formatExistingRunBlock(existingRun: ExistingRunInfo): string;
|
|
14
|
+
//# sourceMappingURL=detectExistingRun.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detectExistingRun.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/detectExistingRun.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACxD,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,CA0B9E;AAED,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,eAAe,GAAG,MAAM,CAiB3E"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.detectExistingRun = detectExistingRun;
|
|
37
|
+
exports.formatExistingRunBlock = formatExistingRunBlock;
|
|
38
|
+
const node_fs_1 = require("node:fs");
|
|
39
|
+
const path = __importStar(require("node:path"));
|
|
40
|
+
const config_1 = require("../../config");
|
|
41
|
+
async function detectExistingRun() {
|
|
42
|
+
try {
|
|
43
|
+
const runsDir = (0, config_1.resolveRunsDir)();
|
|
44
|
+
const entries = await node_fs_1.promises.readdir(runsDir, { withFileTypes: true });
|
|
45
|
+
const dirs = entries.filter((e) => e.isDirectory()).map((e) => e.name).sort().reverse();
|
|
46
|
+
for (const runId of dirs.slice(0, 5)) {
|
|
47
|
+
const runFile = path.join(runsDir, runId, "run.json");
|
|
48
|
+
try {
|
|
49
|
+
const raw = await node_fs_1.promises.readFile(runFile, "utf8");
|
|
50
|
+
const meta = JSON.parse(raw);
|
|
51
|
+
const entrypoint = meta["entrypoint"];
|
|
52
|
+
const processId = meta["processId"] ?? "";
|
|
53
|
+
const isBareRun = entrypoint?.importPath === "bare-run";
|
|
54
|
+
return {
|
|
55
|
+
runId,
|
|
56
|
+
runDir: path.join(runsDir, runId),
|
|
57
|
+
processId,
|
|
58
|
+
isBareRun,
|
|
59
|
+
entrypoint: { importPath: entrypoint?.importPath ?? "", exportName: entrypoint?.exportName },
|
|
60
|
+
completionProof: meta["completionProof"]
|
|
61
|
+
?? meta["metadata"]?.["completionProof"],
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch { /* no runs dir */ }
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
function formatExistingRunBlock(existingRun) {
|
|
73
|
+
return [
|
|
74
|
+
'## Existing Run State',
|
|
75
|
+
'',
|
|
76
|
+
`- Run ID: \`${existingRun.runId}\``,
|
|
77
|
+
`- Run Dir: \`${existingRun.runDir}\``,
|
|
78
|
+
`- Process ID: \`${existingRun.processId}\``,
|
|
79
|
+
`- Bare Run: \`${existingRun.isBareRun}\``,
|
|
80
|
+
`- Entrypoint: \`${existingRun.entrypoint.importPath}${existingRun.entrypoint.exportName ? '#' + existingRun.entrypoint.exportName : ''}\``,
|
|
81
|
+
'',
|
|
82
|
+
existingRun.isBareRun
|
|
83
|
+
? `**This is a bare run.** Use \`run:assign-process ${existingRun.runDir} --entry <path>#<export>\` to assign a process before iterating.`
|
|
84
|
+
: `This run already has a process assigned. Use \`run:iterate ${existingRun.runDir} --json\` to continue.`,
|
|
85
|
+
'',
|
|
86
|
+
'---',
|
|
87
|
+
'',
|
|
88
|
+
].join('\n');
|
|
89
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/hooks/log.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/hooks/log.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAYH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,OAAO,CAAC;CACf;AA8LD,wBAAsB,aAAa,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,CAwG7E"}
|
|
@@ -45,6 +45,7 @@ exports.handleHookLog = handleHookLog;
|
|
|
45
45
|
const node_fs_1 = require("node:fs");
|
|
46
46
|
const path = __importStar(require("node:path"));
|
|
47
47
|
const resolveInputPath_1 = require("../../resolveInputPath");
|
|
48
|
+
const sdkVersion_1 = require("../../../sdkVersion");
|
|
48
49
|
// ---------------------------------------------------------------------------
|
|
49
50
|
// Event label mapping (matches the label used in the original logger.sh)
|
|
50
51
|
// ---------------------------------------------------------------------------
|
|
@@ -174,7 +175,9 @@ const FIELD_EXTRACTORS = {
|
|
|
174
175
|
// ---------------------------------------------------------------------------
|
|
175
176
|
function formatLogLine(hookType, eventLabel, fields) {
|
|
176
177
|
const timestamp = new Date().toISOString();
|
|
177
|
-
const kvPairs = fields
|
|
178
|
+
const kvPairs = [...fields, ["sdkVersion", sdkVersion_1.BABYSITTER_SDK_VERSION]]
|
|
179
|
+
.map(([k, v]) => `${k}=${v}`)
|
|
180
|
+
.join(" ");
|
|
178
181
|
return `[${timestamp}] [${eventLabel}] hook=${hookType} ${kvPairs}`;
|
|
179
182
|
}
|
|
180
183
|
// ---------------------------------------------------------------------------
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instructions.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/instructions.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"instructions.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/instructions.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAoCH,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,eAAe,GAAG,gBAAgB,GAAG,aAAa,GAAG,qBAAqB,CAAC;IACvF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,OAAO,GAAG,SAAS,CAAC;IACjC,IAAI,EAAE,OAAO,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AA4MD;;GAEG;AACH,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE,uBAAuB,GAC5B,OAAO,CAAC,MAAM,CAAC,CAwGjB"}
|
|
@@ -16,6 +16,7 @@ const registry_1 = require("../../harness/registry");
|
|
|
16
16
|
const discovery_1 = require("../../harness/discovery");
|
|
17
17
|
const parse_1 = require("../../session/parse");
|
|
18
18
|
const contextShared_1 = require("../../prompts/contextShared");
|
|
19
|
+
const detectExistingRun_1 = require("./detectExistingRun");
|
|
19
20
|
const COMPOSERS = {
|
|
20
21
|
"babysit-skill": {
|
|
21
22
|
fn: prompts_1.composeBabysitSkillPrompt,
|
|
@@ -169,18 +170,6 @@ async function tryResolveProcessLibraryRoot() {
|
|
|
169
170
|
}
|
|
170
171
|
return {};
|
|
171
172
|
}
|
|
172
|
-
/**
|
|
173
|
-
* Detect whether the session-start hook has actually run by checking for the
|
|
174
|
-
* session state file it creates (`<stateDir>/<sessionId>.md`).
|
|
175
|
-
*
|
|
176
|
-
* The definitive signal is now the PID-scoped session marker written by the
|
|
177
|
-
* session-start hook; absence of the marker (even when env vars like
|
|
178
|
-
* GEMINI_SESSION_ID / CODEX_SESSION_ID / AGENT_SESSION_ID are present)
|
|
179
|
-
* usually means hooks did not fire. Env-var-only resolution is a fallback
|
|
180
|
-
* path that may bind to stale IDs inherited from ancestor shells, so it
|
|
181
|
-
* cannot be trusted as proof that hooks are active. The hook writes the
|
|
182
|
-
* state file as a side effect of `babysitter hook:run --hook-type session-start`.
|
|
183
|
-
*/
|
|
184
173
|
function detectHooksActive(harness) {
|
|
185
174
|
const adapter = (0, registry_1.getAdapterByName)(harness);
|
|
186
175
|
if (!adapter)
|
|
@@ -230,9 +219,9 @@ async function handleInstructionsCommand(args) {
|
|
|
230
219
|
// Resolve the active process-library root before composing the prompt
|
|
231
220
|
const libraryInfo = await tryResolveProcessLibraryRoot();
|
|
232
221
|
// Detect whether hooks are actually active in this session.
|
|
233
|
-
//
|
|
234
|
-
//
|
|
235
|
-
const hooksActive = detectHooksActive(resolvedHarness.harness);
|
|
222
|
+
// hookDriven=false when: non-interactive mode, or session-start hook never ran.
|
|
223
|
+
// Non-interactive mode never has hooks — the agent must drive the loop in-turn.
|
|
224
|
+
const hooksActive = args.interactive !== false && detectHooksActive(resolvedHarness.harness);
|
|
236
225
|
const hookOverride = {};
|
|
237
226
|
if (!hooksActive) {
|
|
238
227
|
hookOverride.hookDriven = false;
|
|
@@ -243,6 +232,7 @@ async function handleInstructionsCommand(args) {
|
|
|
243
232
|
// scheduled reporting, local-dev relaxations).
|
|
244
233
|
const executionContext = (0, prompts_1.detectExecutionContext)();
|
|
245
234
|
const capabilityFlags = (0, prompts_1.deriveCapabilityFlags)(executionContext);
|
|
235
|
+
const existingRun = await (0, detectExistingRun_1.detectExistingRun)();
|
|
246
236
|
const ctx = factory({
|
|
247
237
|
interactive: args.interactive,
|
|
248
238
|
...libraryInfo,
|
|
@@ -272,41 +262,31 @@ async function handleInstructionsCommand(args) {
|
|
|
272
262
|
executionContext,
|
|
273
263
|
capabilityFlags,
|
|
274
264
|
suggestedProcesses: (0, prompts_1.processPathsForCapabilities)(capabilityFlags),
|
|
265
|
+
existingRun: existingRun ?? null,
|
|
275
266
|
content,
|
|
276
267
|
partsIncluded: composer.partsIncluded,
|
|
277
268
|
}, null, 2));
|
|
278
269
|
}
|
|
279
270
|
else {
|
|
280
|
-
for (const warning of resolvedHarness.warnings)
|
|
271
|
+
for (const warning of resolvedHarness.warnings)
|
|
281
272
|
console.error(`[instructions] Warning: ${warning}`);
|
|
282
|
-
|
|
283
|
-
if (!hooksActive && ctx.hookDriven !== false) {
|
|
284
|
-
// Context factory defaulted hookDriven to true, but we overrode it.
|
|
285
|
-
// This is a no-op because the override already happened, but it
|
|
286
|
-
// clarifies the JSON output. The text output is self-explanatory
|
|
287
|
-
// from the generated instructions.
|
|
288
|
-
}
|
|
289
|
-
const activeCapabilities = Object.entries(capabilityFlags)
|
|
290
|
-
.filter(([, v]) => v === true)
|
|
291
|
-
.map(([k]) => k);
|
|
292
|
-
const contextHeader = [
|
|
293
|
-
'## Execution Context',
|
|
294
|
-
'',
|
|
295
|
-
`- CI: \`${executionContext.ci}\``,
|
|
296
|
-
`- Trigger: \`${executionContext.trigger}\``,
|
|
297
|
-
executionContext.branch.ref ? `- Branch: \`${executionContext.branch.ref}\`` : undefined,
|
|
298
|
-
executionContext.repo ? `- Repo: \`${executionContext.repo.owner}/${executionContext.repo.name}\`` : undefined,
|
|
299
|
-
executionContext.actor ? `- Actor: \`${executionContext.actor.login}\`${executionContext.actor.isBot ? ' (bot)' : ''}` : undefined,
|
|
300
|
-
'',
|
|
301
|
-
`Active context capabilities: ${activeCapabilities.length > 0 ? activeCapabilities.map(c => `\`${c}\``).join(', ') : '_(none)_'}`,
|
|
302
|
-
'',
|
|
303
|
-
'When selecting library processes to dispatch, prefer those whose triggers match the active capabilities above.',
|
|
304
|
-
'',
|
|
305
|
-
'---',
|
|
306
|
-
'',
|
|
307
|
-
].filter((l) => l !== undefined).join('\n');
|
|
308
|
-
const processGuide = (0, prompts_1.renderCapabilityProcessGuide)(capabilityFlags);
|
|
309
|
-
console.log(contextHeader + processGuide + content);
|
|
273
|
+
console.log(formatTextOutput(executionContext, capabilityFlags, existingRun, content));
|
|
310
274
|
}
|
|
311
275
|
return 0;
|
|
312
276
|
}
|
|
277
|
+
function formatTextOutput(executionContext, capabilityFlags, existingRun, content) {
|
|
278
|
+
const caps = Object.entries(capabilityFlags).filter(([, v]) => v).map(([k]) => k);
|
|
279
|
+
const header = [
|
|
280
|
+
'## Execution Context', '',
|
|
281
|
+
`- CI: \`${executionContext.ci}\``,
|
|
282
|
+
`- Trigger: \`${executionContext.trigger}\``,
|
|
283
|
+
executionContext.branch.ref ? `- Branch: \`${executionContext.branch.ref}\`` : undefined,
|
|
284
|
+
executionContext.repo ? `- Repo: \`${executionContext.repo.owner}/${executionContext.repo.name}\`` : undefined,
|
|
285
|
+
executionContext.actor ? `- Actor: \`${executionContext.actor.login}\`${executionContext.actor.isBot ? ' (bot)' : ''}` : undefined,
|
|
286
|
+
'', `Active context capabilities: ${caps.length > 0 ? caps.map(c => `\`${c}\``).join(', ') : '_(none)_'}`,
|
|
287
|
+
'', 'When selecting library processes to dispatch, prefer those whose triggers match the active capabilities above.', '', '---', '',
|
|
288
|
+
].filter((l) => l !== undefined).join('\n');
|
|
289
|
+
const guide = (0, prompts_1.renderCapabilityProcessGuide)(capabilityFlags);
|
|
290
|
+
const runBlock = existingRun ? (0, detectExistingRun_1.formatExistingRunBlock)(existingRun) : '';
|
|
291
|
+
return header + guide + runBlock + content;
|
|
292
|
+
}
|
|
@@ -17,7 +17,7 @@ async function handleMcpServe(args) {
|
|
|
17
17
|
const transportType = args.transport ?? "stdio";
|
|
18
18
|
if (transportType === "ws" || transportType === "websocket") {
|
|
19
19
|
process.stderr.write("WebSocket transport has moved to @a5c-ai/babysitter-agent.\n" +
|
|
20
|
-
"Use babysitter-
|
|
20
|
+
"Use babysitter-agent mcp:serve --transport websocket instead.\n");
|
|
21
21
|
return 1;
|
|
22
22
|
}
|
|
23
23
|
const server = (0, mcp_1.createBabysitterMcpServer)();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkIteration.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/session/checkIteration.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"checkIteration.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/session/checkIteration.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,yBAAyB;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC;CACf;AAED,wBAAsB,2BAA2B,CAC/C,IAAI,EAAE,yBAAyB,GAC9B,OAAO,CAAC,MAAM,CAAC,CA2EjB"}
|
|
@@ -56,28 +56,6 @@ async function handleSessionCheckIteration(args) {
|
|
|
56
56
|
const updatedTimes = state.iteration >= 5
|
|
57
57
|
? (0, session_1.updateIterationTimes)(state.iterationTimes, state.lastIterationAt, now)
|
|
58
58
|
: state.iterationTimes;
|
|
59
|
-
if ((0, session_1.isIterationTooFast)(updatedTimes)) {
|
|
60
|
-
const averageTime = updatedTimes.reduce((sum, value) => sum + value, 0) / updatedTimes.length;
|
|
61
|
-
const result = {
|
|
62
|
-
found: true,
|
|
63
|
-
shouldContinue: false,
|
|
64
|
-
reason: "iteration_too_fast",
|
|
65
|
-
averageTime,
|
|
66
|
-
threshold: 15,
|
|
67
|
-
iteration: state.iteration,
|
|
68
|
-
maxIterations: state.maxIterations,
|
|
69
|
-
runId: state.runId ?? "",
|
|
70
|
-
prompt: file.prompt ?? "",
|
|
71
|
-
stopMessage: `Average iteration time too fast (${averageTime}s <= 15s)`,
|
|
72
|
-
};
|
|
73
|
-
if (args.json) {
|
|
74
|
-
console.log(JSON.stringify(result, null, 2));
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
console.log(`[session:check-iteration] shouldContinue=false reason=iteration_too_fast avg=${averageTime}s`);
|
|
78
|
-
}
|
|
79
|
-
return 0;
|
|
80
|
-
}
|
|
81
59
|
const result = {
|
|
82
60
|
found: true,
|
|
83
61
|
shouldContinue: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/session/init.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/session/init.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,OAAO,CAAC;CACf;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAyF9E"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.handleSessionInit = handleSessionInit;
|
|
4
|
+
const config_1 = require("../../../config");
|
|
4
5
|
const session_1 = require("../../../session");
|
|
5
6
|
const common_1 = require("./common");
|
|
6
7
|
async function handleSessionInit(args) {
|
|
@@ -9,7 +10,7 @@ async function handleSessionInit(args) {
|
|
|
9
10
|
return required;
|
|
10
11
|
}
|
|
11
12
|
const { sessionId, stateDir } = required;
|
|
12
|
-
const maxIterations = args.maxIterations ??
|
|
13
|
+
const maxIterations = args.maxIterations ?? config_1.DEFAULTS.maxIterations;
|
|
13
14
|
const runId = args.runId ?? "";
|
|
14
15
|
const prompt = args.prompt ?? "";
|
|
15
16
|
const filePath = (0, session_1.getSessionFilePath)(stateDir, sessionId);
|
|
@@ -60,7 +60,7 @@ async function handleSessionResume(args) {
|
|
|
60
60
|
return emitError(json, { error: 'MISSING_RUN_ID', message: '--run-id is required' }, ['❌ Error: --run-id is required']);
|
|
61
61
|
}
|
|
62
62
|
const stateDir = args.stateDir ?? (0, config_1.getGlobalStateDir)();
|
|
63
|
-
const maxIterations = args.maxIterations ??
|
|
63
|
+
const maxIterations = args.maxIterations ?? config_1.DEFAULTS.maxIterations;
|
|
64
64
|
const runsDir = args.runsDir ?? (0, config_1.resolveRunsDir)();
|
|
65
65
|
const runDir = (0, config_1.resolveExistingRunDir)(runId, { override: runsDir });
|
|
66
66
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/session/update.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/session/update.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,iBAAiB;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,EAAE,OAAO,CAAC;CACf;AAED,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,CAyDlF"}
|
|
@@ -9,18 +9,6 @@ async function handleSessionUpdate(args) {
|
|
|
9
9
|
return required;
|
|
10
10
|
}
|
|
11
11
|
const filePath = (0, session_1.getSessionFilePath)(required.stateDir, required.sessionId);
|
|
12
|
-
if (args.delete) {
|
|
13
|
-
const deleted = await (0, session_1.deleteSessionFile)(filePath);
|
|
14
|
-
const result = { success: true, deleted, stateFile: filePath };
|
|
15
|
-
if (args.json) {
|
|
16
|
-
console.log(JSON.stringify(result, null, 2));
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
console.log(`[session:update] deleted=${deleted}`);
|
|
20
|
-
console.log(` stateFile: ${filePath}`);
|
|
21
|
-
}
|
|
22
|
-
return 0;
|
|
23
|
-
}
|
|
24
12
|
let existing;
|
|
25
13
|
try {
|
|
26
14
|
existing = await (0, session_1.readSessionFile)(filePath);
|
|
@@ -128,7 +128,7 @@ async function discoverWellKnown(url) {
|
|
|
128
128
|
async function fetchRemoteSkillSources(_pluginRoot) {
|
|
129
129
|
const remoteSkills = [];
|
|
130
130
|
const sources = [
|
|
131
|
-
{ type: 'github', url: 'https://github.com/
|
|
131
|
+
{ type: 'github', url: 'https://github.com/a5c-ai/babysitter/tree/main/plugins/babysitter-unified/skills' },
|
|
132
132
|
];
|
|
133
133
|
try {
|
|
134
134
|
const content = await node_fs_1.promises.readFile('.a5c/skill-sources.json', 'utf8');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"argFlags.d.ts","sourceRoot":"","sources":["../../../src/cli/main/argFlags.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,
|
|
1
|
+
{"version":3,"file":"argFlags.d.ts","sourceRoot":"","sources":["../../../src/cli/main/argFlags.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAuEtE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"argPositionals.d.ts","sourceRoot":"","sources":["../../../src/cli/main/argPositionals.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"argPositionals.d.ts","sourceRoot":"","sources":["../../../src/cli/main/argPositionals.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,QA6F5E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatchRunSession.d.ts","sourceRoot":"","sources":["../../../src/cli/main/dispatchRunSession.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"dispatchRunSession.d.ts","sourceRoot":"","sources":["../../../src/cli/main/dispatchRunSession.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAoD1C,wBAAsB,wBAAwB,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAM9F"}
|
|
@@ -66,6 +66,8 @@ async function executeRunTaskCommand(parsed) {
|
|
|
66
66
|
switch (parsed.command) {
|
|
67
67
|
case "run:create":
|
|
68
68
|
return await (0, runCommands_1.handleRunCreate)(parsed);
|
|
69
|
+
case "run:assign-process":
|
|
70
|
+
return await (0, runCommands_1.handleRunAssignProcess)(parsed);
|
|
69
71
|
case "run:rebuild-state":
|
|
70
72
|
return await (0, runCommands_1.handleRunRebuildState)(parsed);
|
|
71
73
|
case "run:repair-journal":
|
|
@@ -178,7 +180,6 @@ async function executeSupportCommand(parsed) {
|
|
|
178
180
|
iteration: parsed.iteration,
|
|
179
181
|
lastIterationAt: parsed.lastIterationAt,
|
|
180
182
|
iterationTimes: parsed.iterationTimes,
|
|
181
|
-
delete: parsed.deleteSession,
|
|
182
183
|
json: parsed.json,
|
|
183
184
|
});
|
|
184
185
|
}
|
package/dist/cli/main/program.js
CHANGED
|
@@ -11,7 +11,7 @@ exports.CORE_PROGRAM = {
|
|
|
11
11
|
};
|
|
12
12
|
exports.HARNESS_PROGRAM = {
|
|
13
13
|
variant: "harness",
|
|
14
|
-
commandName: "babysitter-
|
|
14
|
+
commandName: "babysitter-agent",
|
|
15
15
|
packageName: "@a5c-ai/babysitter-agent",
|
|
16
16
|
};
|
|
17
17
|
exports.HARNESS_RUNTIME_COMMANDS = [
|
|
@@ -51,7 +51,7 @@ exports.HARNESS_INSTALL_COMMANDS = [
|
|
|
51
51
|
"harness:install-plugin",
|
|
52
52
|
];
|
|
53
53
|
const SHARED_VALID_COMMANDS = [
|
|
54
|
-
"run:create", "run:status", "run:iterate", "run:events", "run:rebuild-state", "run:repair-journal",
|
|
54
|
+
"run:create", "run:assign-process", "run:status", "run:iterate", "run:events", "run:rebuild-state", "run:repair-journal",
|
|
55
55
|
"task:post", "task:cancel", "task:list", "task:show",
|
|
56
56
|
"log", "hook:log", "hook:run", "skill:discover", "skill:fetch-remote",
|
|
57
57
|
"process-library:clone", "process-library:update", "process-library:use", "process-library:active",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runAssignProcess.d.ts","sourceRoot":"","sources":["../../../src/cli/main/runAssignProcess.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAU1C,wBAAsB,sBAAsB,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAoIhF"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.handleRunAssignProcess = handleRunAssignProcess;
|
|
37
|
+
const path = __importStar(require("node:path"));
|
|
38
|
+
const runFiles_1 = require("../../storage/runFiles");
|
|
39
|
+
const journal_1 = require("../../storage/journal");
|
|
40
|
+
const lock_1 = require("../../storage/lock");
|
|
41
|
+
const args_1 = require("./args");
|
|
42
|
+
const runSupport_1 = require("./runSupport");
|
|
43
|
+
const usage_1 = require("./usage");
|
|
44
|
+
async function handleRunAssignProcess(parsed) {
|
|
45
|
+
if (!parsed.runDirArg) {
|
|
46
|
+
console.error("run:assign-process requires a <runDir> positional argument");
|
|
47
|
+
console.error(usage_1.USAGE);
|
|
48
|
+
return 1;
|
|
49
|
+
}
|
|
50
|
+
if (!parsed.entrySpecifier) {
|
|
51
|
+
console.error("--entry is required for run:assign-process");
|
|
52
|
+
console.error(usage_1.USAGE);
|
|
53
|
+
return 1;
|
|
54
|
+
}
|
|
55
|
+
let entrypoint;
|
|
56
|
+
try {
|
|
57
|
+
entrypoint = (0, runSupport_1.parseEntrypointSpecifier)(parsed.entrySpecifier);
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
61
|
+
return 1;
|
|
62
|
+
}
|
|
63
|
+
const runsDir = (0, args_1.collapseDoubledA5cRuns)(path.resolve(parsed.runsDir));
|
|
64
|
+
const runDir = (0, args_1.resolveRunDir)(runsDir, parsed.runDirArg);
|
|
65
|
+
const absoluteImportPath = path.resolve(entrypoint.importPath);
|
|
66
|
+
const resolvedEntry = (0, runSupport_1.formatResolvedEntrypoint)(absoluteImportPath, entrypoint.exportName);
|
|
67
|
+
(0, runSupport_1.logVerbose)("run:assign-process", parsed, {
|
|
68
|
+
runDir,
|
|
69
|
+
entry: resolvedEntry,
|
|
70
|
+
processId: parsed.processId,
|
|
71
|
+
force: parsed.sessionForce,
|
|
72
|
+
dryRun: parsed.dryRun,
|
|
73
|
+
json: parsed.json,
|
|
74
|
+
});
|
|
75
|
+
let metadata;
|
|
76
|
+
try {
|
|
77
|
+
metadata = await (0, runFiles_1.readRunMetadata)(runDir);
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
const err = error;
|
|
81
|
+
if (err.code === "ENOENT") {
|
|
82
|
+
const message = `Run directory not found: ${runDir}`;
|
|
83
|
+
if (parsed.json) {
|
|
84
|
+
console.log(JSON.stringify({ error: "RUN_NOT_FOUND", message }));
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
console.error(message);
|
|
88
|
+
}
|
|
89
|
+
return 1;
|
|
90
|
+
}
|
|
91
|
+
throw error;
|
|
92
|
+
}
|
|
93
|
+
const isBareRun = metadata.entrypoint.importPath === "bare-run";
|
|
94
|
+
if (!isBareRun && !parsed.sessionForce) {
|
|
95
|
+
const message = `Run already has a process assigned (entrypoint: ${metadata.entrypoint.importPath}). Use --force to override.`;
|
|
96
|
+
if (parsed.json) {
|
|
97
|
+
console.log(JSON.stringify({ error: "PROCESS_ALREADY_ASSIGNED", message, currentEntrypoint: metadata.entrypoint }));
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
console.error(message);
|
|
101
|
+
}
|
|
102
|
+
return 1;
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
await (0, runSupport_1.validateProcessEntrypoint)(absoluteImportPath, entrypoint.exportName);
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
109
|
+
return 1;
|
|
110
|
+
}
|
|
111
|
+
const processId = parsed.processId ?? metadata.processId;
|
|
112
|
+
if (parsed.dryRun) {
|
|
113
|
+
const summary = {
|
|
114
|
+
dryRun: true,
|
|
115
|
+
runDir,
|
|
116
|
+
runId: metadata.runId,
|
|
117
|
+
entry: resolvedEntry,
|
|
118
|
+
processId,
|
|
119
|
+
previousEntrypoint: metadata.entrypoint,
|
|
120
|
+
force: parsed.sessionForce ?? false,
|
|
121
|
+
};
|
|
122
|
+
if (parsed.json) {
|
|
123
|
+
console.log(JSON.stringify(summary, null, 2));
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
console.log(`[run:assign-process] dry-run runDir=${runDir} entry=${resolvedEntry} processId=${processId}`);
|
|
127
|
+
}
|
|
128
|
+
return 0;
|
|
129
|
+
}
|
|
130
|
+
await (0, lock_1.withRunLock)(runDir, "run:assign-process", async () => {
|
|
131
|
+
const current = await (0, runFiles_1.readRunMetadata)(runDir);
|
|
132
|
+
const previousEntrypoint = { ...current.entrypoint };
|
|
133
|
+
current.entrypoint = {
|
|
134
|
+
importPath: absoluteImportPath,
|
|
135
|
+
exportName: entrypoint.exportName,
|
|
136
|
+
};
|
|
137
|
+
current.processPath = absoluteImportPath;
|
|
138
|
+
current.processId = processId;
|
|
139
|
+
if (parsed.processRevision) {
|
|
140
|
+
current.processRevision = parsed.processRevision;
|
|
141
|
+
}
|
|
142
|
+
await (0, runFiles_1.writeRunMetadata)(runDir, current);
|
|
143
|
+
await (0, journal_1.appendEvent)({
|
|
144
|
+
runDir,
|
|
145
|
+
eventType: "PROCESS_ASSIGNED",
|
|
146
|
+
event: {
|
|
147
|
+
processId,
|
|
148
|
+
entrypoint: current.entrypoint,
|
|
149
|
+
previousEntrypoint,
|
|
150
|
+
force: parsed.sessionForce ?? false,
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
const updatedMetadata = await (0, runFiles_1.readRunMetadata)(runDir);
|
|
155
|
+
if (parsed.json) {
|
|
156
|
+
console.log(JSON.stringify({
|
|
157
|
+
runId: updatedMetadata.runId,
|
|
158
|
+
runDir,
|
|
159
|
+
entry: resolvedEntry,
|
|
160
|
+
processId,
|
|
161
|
+
previousEntrypoint: metadata.entrypoint,
|
|
162
|
+
assigned: true,
|
|
163
|
+
}, null, 2));
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
console.log(`[run:assign-process] runId=${updatedMetadata.runId} runDir=${runDir} entry=${resolvedEntry} processId=${processId}`);
|
|
167
|
+
}
|
|
168
|
+
return 0;
|
|
169
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { handleRunCreate, handleRunRebuildState, handleRunRepairJournal, } from "./runCreate";
|
|
2
|
+
export { handleRunAssignProcess } from "./runAssignProcess";
|
|
2
3
|
export { handleRunEvents, handleRunIterate, handleRunStatus } from "./runInspection";
|
|
3
4
|
//# sourceMappingURL=runCommands.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runCommands.d.ts","sourceRoot":"","sources":["../../../src/cli/main/runCommands.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"runCommands.d.ts","sourceRoot":"","sources":["../../../src/cli/main/runCommands.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC"}
|