chatroom-cli 1.13.0 → 1.13.1
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/index.js +46 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13548,41 +13548,58 @@ async function createWorkflow(chatroomId, options, deps) {
|
|
|
13548
13548
|
process.exit(1);
|
|
13549
13549
|
return;
|
|
13550
13550
|
}
|
|
13551
|
-
|
|
13551
|
+
const ALLOWED_STEP_FIELDS = new Set(["stepKey", "description", "dependsOn", "order"]);
|
|
13552
|
+
for (let i2 = 0;i2 < stepsData.steps.length; i2++) {
|
|
13553
|
+
const step = stepsData.steps[i2];
|
|
13554
|
+
const stepLabel = step.stepKey ? `"${step.stepKey}"` : `at index ${i2}`;
|
|
13552
13555
|
if (!step.stepKey || typeof step.stepKey !== "string") {
|
|
13553
|
-
console.error(
|
|
13556
|
+
console.error(`❌ Step ${stepLabel} must have a "stepKey" (string)`);
|
|
13557
|
+
console.error(" All steps require: stepKey, description, dependsOn, order");
|
|
13554
13558
|
process.exit(1);
|
|
13555
13559
|
return;
|
|
13556
13560
|
}
|
|
13557
13561
|
if (!step.description || typeof step.description !== "string") {
|
|
13558
|
-
console.error(`❌ Step
|
|
13562
|
+
console.error(`❌ Step ${stepLabel} must have a "description" (string)`);
|
|
13563
|
+
console.error(" All steps require: stepKey, description, dependsOn, order");
|
|
13559
13564
|
process.exit(1);
|
|
13560
13565
|
return;
|
|
13561
13566
|
}
|
|
13562
13567
|
if (!Array.isArray(step.dependsOn)) {
|
|
13563
|
-
console.error(`❌ Step
|
|
13568
|
+
console.error(`❌ Step ${stepLabel} must have a "dependsOn" (array of strings)`);
|
|
13569
|
+
console.error(" All steps require: stepKey, description, dependsOn, order");
|
|
13564
13570
|
process.exit(1);
|
|
13565
13571
|
return;
|
|
13566
13572
|
}
|
|
13567
13573
|
if (typeof step.order !== "number") {
|
|
13568
|
-
console.error(`❌ Step
|
|
13574
|
+
console.error(`❌ Step ${stepLabel} must have an "order" (number)`);
|
|
13575
|
+
console.error(" All steps require: stepKey, description, dependsOn, order");
|
|
13569
13576
|
process.exit(1);
|
|
13570
13577
|
return;
|
|
13571
13578
|
}
|
|
13579
|
+
const extraFields = Object.keys(step).filter((k) => !ALLOWED_STEP_FIELDS.has(k));
|
|
13580
|
+
if (extraFields.length > 0) {
|
|
13581
|
+
console.error(`⚠️ Stripped unknown fields from step "${step.stepKey}": ${extraFields.join(", ")}`);
|
|
13582
|
+
}
|
|
13572
13583
|
}
|
|
13584
|
+
const cleanSteps = stepsData.steps.map((step) => ({
|
|
13585
|
+
stepKey: step.stepKey,
|
|
13586
|
+
description: step.description,
|
|
13587
|
+
dependsOn: step.dependsOn,
|
|
13588
|
+
order: step.order
|
|
13589
|
+
}));
|
|
13573
13590
|
try {
|
|
13574
13591
|
const result = await d.backend.mutation(api.workflows.createWorkflow, {
|
|
13575
13592
|
sessionId,
|
|
13576
13593
|
chatroomId,
|
|
13577
13594
|
workflowKey: options.workflowKey,
|
|
13578
|
-
steps:
|
|
13595
|
+
steps: cleanSteps,
|
|
13579
13596
|
createdBy: options.role
|
|
13580
13597
|
});
|
|
13581
13598
|
console.log("");
|
|
13582
13599
|
console.log("✅ Workflow created");
|
|
13583
13600
|
console.log(` Key: ${options.workflowKey}`);
|
|
13584
13601
|
console.log(` Workflow ID: ${result.workflowId}`);
|
|
13585
|
-
console.log(` Steps: ${
|
|
13602
|
+
console.log(` Steps: ${cleanSteps.length}`);
|
|
13586
13603
|
console.log(` Status: draft`);
|
|
13587
13604
|
console.log("");
|
|
13588
13605
|
} catch (error) {
|
|
@@ -14838,6 +14855,15 @@ async function onRequestStartAgent(ctx, event) {
|
|
|
14838
14855
|
});
|
|
14839
14856
|
if (!result.success) {
|
|
14840
14857
|
console.log(`[daemon] Agent start rejected for role=${event.role}: ${result.error ?? "unknown"}`);
|
|
14858
|
+
ctx.deps.backend.mutation(api.machines.emitAgentStartFailed, {
|
|
14859
|
+
sessionId: ctx.sessionId,
|
|
14860
|
+
machineId: ctx.machineId,
|
|
14861
|
+
chatroomId: event.chatroomId,
|
|
14862
|
+
role: event.role,
|
|
14863
|
+
error: result.error ?? "unknown"
|
|
14864
|
+
}).catch((err) => {
|
|
14865
|
+
console.log(` ⚠️ Failed to emit startFailed event: ${err.message}`);
|
|
14866
|
+
});
|
|
14841
14867
|
} else {
|
|
14842
14868
|
ctx.deps.backend.mutation(api.workspaces.registerWorkspace, {
|
|
14843
14869
|
sessionId: ctx.sessionId,
|
|
@@ -15864,6 +15890,19 @@ class AgentProcessManager {
|
|
|
15864
15890
|
const key = agentKey2(opts.chatroomId, opts.role);
|
|
15865
15891
|
const slot = this.slots.get(key);
|
|
15866
15892
|
if (!slot || slot.state === "idle") {
|
|
15893
|
+
this.deps.backend.mutation(api.machines.recordAgentExited, {
|
|
15894
|
+
sessionId: this.deps.sessionId,
|
|
15895
|
+
machineId: this.deps.machineId,
|
|
15896
|
+
chatroomId: opts.chatroomId,
|
|
15897
|
+
role: opts.role,
|
|
15898
|
+
pid: 0,
|
|
15899
|
+
stopReason: opts.reason,
|
|
15900
|
+
exitCode: undefined,
|
|
15901
|
+
signal: undefined,
|
|
15902
|
+
agentHarness: undefined
|
|
15903
|
+
}).catch((err) => {
|
|
15904
|
+
console.log(` ⚠️ Failed to record agent exit (idle cleanup): ${err.message}`);
|
|
15905
|
+
});
|
|
15867
15906
|
return { success: true };
|
|
15868
15907
|
}
|
|
15869
15908
|
if (slot.state === "stopping" && slot.pendingOperation) {
|