chatroom-cli 1.65.13 → 1.65.14
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 +100 -9
- package/dist/index.js.map +7 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -84820,6 +84820,50 @@ var init_participant = __esm(() => {
|
|
|
84820
84820
|
]);
|
|
84821
84821
|
});
|
|
84822
84822
|
|
|
84823
|
+
// src/commands/machine/daemon-start/native-delivery-ledger.ts
|
|
84824
|
+
class NativeDeliveryLedger {
|
|
84825
|
+
delivered = new Set;
|
|
84826
|
+
inFlight = new Set;
|
|
84827
|
+
deliveryKey(taskId, harnessSessionId) {
|
|
84828
|
+
return `${taskId}\x00${harnessSessionId}`;
|
|
84829
|
+
}
|
|
84830
|
+
isDelivered(taskId, harnessSessionId) {
|
|
84831
|
+
return this.delivered.has(this.deliveryKey(taskId, harnessSessionId));
|
|
84832
|
+
}
|
|
84833
|
+
tryAcquire(taskId, harnessSessionId) {
|
|
84834
|
+
const key = this.deliveryKey(taskId, harnessSessionId);
|
|
84835
|
+
if (this.delivered.has(key) || this.inFlight.has(key)) {
|
|
84836
|
+
return false;
|
|
84837
|
+
}
|
|
84838
|
+
this.inFlight.add(key);
|
|
84839
|
+
return true;
|
|
84840
|
+
}
|
|
84841
|
+
markDelivered(taskId, harnessSessionId) {
|
|
84842
|
+
const key = this.deliveryKey(taskId, harnessSessionId);
|
|
84843
|
+
this.inFlight.delete(key);
|
|
84844
|
+
this.delivered.add(key);
|
|
84845
|
+
}
|
|
84846
|
+
clearDelivery(taskId, harnessSessionId) {
|
|
84847
|
+
const key = this.deliveryKey(taskId, harnessSessionId);
|
|
84848
|
+
this.inFlight.delete(key);
|
|
84849
|
+
this.delivered.delete(key);
|
|
84850
|
+
}
|
|
84851
|
+
clearSession(harnessSessionId) {
|
|
84852
|
+
const suffix = `\x00${harnessSessionId}`;
|
|
84853
|
+
for (const key of [...this.delivered, ...this.inFlight]) {
|
|
84854
|
+
if (key.endsWith(suffix)) {
|
|
84855
|
+
this.delivered.delete(key);
|
|
84856
|
+
this.inFlight.delete(key);
|
|
84857
|
+
}
|
|
84858
|
+
}
|
|
84859
|
+
}
|
|
84860
|
+
}
|
|
84861
|
+
function getNativeDeliveryLedger() {
|
|
84862
|
+
sharedLedger ??= new NativeDeliveryLedger;
|
|
84863
|
+
return sharedLedger;
|
|
84864
|
+
}
|
|
84865
|
+
var sharedLedger;
|
|
84866
|
+
|
|
84823
84867
|
// src/commands/machine/daemon-start/native-ready-invariant.ts
|
|
84824
84868
|
function isAgentReadyForNativeDelivery(task, slot) {
|
|
84825
84869
|
return explainAgentReadyForNativeDeliveryBlock(task, slot) === null;
|
|
@@ -84950,6 +84994,12 @@ function explainNativeDeliveryBlock(task, opts) {
|
|
|
84950
84994
|
}
|
|
84951
84995
|
return explainAgentReadyForNativeDeliveryBlock(task, opts.slot);
|
|
84952
84996
|
}
|
|
84997
|
+
function explainLedgerDeliveryBlock(taskId, harnessSessionId, ledger) {
|
|
84998
|
+
if (ledger.isDelivered(taskId, harnessSessionId)) {
|
|
84999
|
+
return "already_delivered_this_session";
|
|
85000
|
+
}
|
|
85001
|
+
return null;
|
|
85002
|
+
}
|
|
84953
85003
|
function buildNativeInjectionPrompt(params) {
|
|
84954
85004
|
const { taskDeliveryOutput, augmentationMode } = params;
|
|
84955
85005
|
if (augmentationMode === "compact") {
|
|
@@ -85254,6 +85304,9 @@ var init_assigned_task_snapshot_store = __esm(() => {
|
|
|
85254
85304
|
class NativeTaskDeliveryCoordinator {
|
|
85255
85305
|
onSessionLost(params) {
|
|
85256
85306
|
getRoleDeliveryState().resetDeliveryState(params.chatroomId, params.role);
|
|
85307
|
+
if (params.harnessSessionId) {
|
|
85308
|
+
getNativeDeliveryLedger().clearSession(params.harnessSessionId);
|
|
85309
|
+
}
|
|
85257
85310
|
}
|
|
85258
85311
|
resetRoleDeliveryState(chatroomId, role) {
|
|
85259
85312
|
getRoleDeliveryState().resetDeliveryState(chatroomId, role);
|
|
@@ -85280,6 +85333,7 @@ class NativeTaskDeliveryCoordinator {
|
|
|
85280
85333
|
reconcileAssignedTasks(params) {
|
|
85281
85334
|
const { tasks, runtime: runtime4, effectContext: effectContext2, agentMgr, sessionDeps, machineId } = params;
|
|
85282
85335
|
const deliveryState = getRoleDeliveryState();
|
|
85336
|
+
const ledger = getNativeDeliveryLedger();
|
|
85283
85337
|
const pendingFirst = [...tasks].sort((a, b) => {
|
|
85284
85338
|
if (a.status === "pending" && b.status !== "pending")
|
|
85285
85339
|
return -1;
|
|
@@ -85297,11 +85351,28 @@ class NativeTaskDeliveryCoordinator {
|
|
|
85297
85351
|
}
|
|
85298
85352
|
continue;
|
|
85299
85353
|
}
|
|
85354
|
+
const harnessSessionId = slot?.harnessSessionId;
|
|
85355
|
+
if (!harnessSessionId) {
|
|
85356
|
+
logNativeDeliverySkip(role, row.chatroomId, row.taskId, "harness_session_missing (pre-gate)");
|
|
85357
|
+
continue;
|
|
85358
|
+
}
|
|
85359
|
+
const ledgerBlock = explainLedgerDeliveryBlock(row.taskId, harnessSessionId, ledger);
|
|
85360
|
+
if (ledgerBlock) {
|
|
85361
|
+
logNativeDeliverySkip(role, row.chatroomId, row.taskId, ledgerBlock);
|
|
85362
|
+
continue;
|
|
85363
|
+
}
|
|
85364
|
+
if (!ledger.tryAcquire(row.taskId, harnessSessionId)) {
|
|
85365
|
+
logNativeDeliverySkip(role, row.chatroomId, row.taskId, "delivery_ledger_busy (duplicate inject in flight)");
|
|
85366
|
+
continue;
|
|
85367
|
+
}
|
|
85300
85368
|
if (!deliveryState.tryAcquireDelivery(row.chatroomId, role)) {
|
|
85369
|
+
ledger.clearDelivery(row.taskId, harnessSessionId);
|
|
85301
85370
|
logNativeDeliveryMutexSkip(role, row.chatroomId, row.taskId);
|
|
85302
85371
|
continue;
|
|
85303
85372
|
}
|
|
85304
85373
|
logNativeDeliveryInjecting(role, row.chatroomId, row.taskId);
|
|
85374
|
+
const taskId = row.taskId;
|
|
85375
|
+
let deliveredToHarness = false;
|
|
85305
85376
|
exports_Runtime.runFork(runtime4)(exports_Effect.gen(function* () {
|
|
85306
85377
|
const full = yield* exports_Effect.tryPromise(() => sessionDeps.backend.query(api.machines.getAssignedTaskForAction, {
|
|
85307
85378
|
sessionId: sessionDeps.sessionId,
|
|
@@ -85313,11 +85384,6 @@ class NativeTaskDeliveryCoordinator {
|
|
|
85313
85384
|
console.warn(`[NativeDelivery:skip] ${role}@${row.chatroomId} task ${row.taskId} — task_hydrate_missing (deleted or not assigned)`);
|
|
85314
85385
|
return;
|
|
85315
85386
|
}
|
|
85316
|
-
const harnessSessionId = slot?.harnessSessionId;
|
|
85317
|
-
if (!harnessSessionId) {
|
|
85318
|
-
console.warn(`[NativeDelivery:skip] ${role}@${row.chatroomId} task ${row.taskId} — harness_session_missing (post-gate)`);
|
|
85319
|
-
return;
|
|
85320
|
-
}
|
|
85321
85387
|
yield* runNativeInjectionEffect(full, harnessSessionId, {
|
|
85322
85388
|
sessionId: sessionDeps.sessionId,
|
|
85323
85389
|
machineId: sessionDeps.machineId,
|
|
@@ -85326,12 +85392,19 @@ class NativeTaskDeliveryCoordinator {
|
|
|
85326
85392
|
resumeTurnForSlot: (args2) => exports_Effect.runPromise(agentMgr.resumeTurnForSlot(args2))
|
|
85327
85393
|
},
|
|
85328
85394
|
convexUrl: sessionDeps.convexUrl,
|
|
85329
|
-
onTaskDelivered: ({ chatroomId, role: role2, taskId }) => {
|
|
85330
|
-
|
|
85395
|
+
onTaskDelivered: ({ chatroomId, role: role2, taskId: deliveredTaskId }) => {
|
|
85396
|
+
deliveredToHarness = true;
|
|
85397
|
+
ledger.markDelivered(deliveredTaskId, harnessSessionId);
|
|
85398
|
+
exports_Effect.runSync(agentMgr.setLastInFlightTask(chatroomId, role2, deliveredTaskId));
|
|
85331
85399
|
deliveryState.clearNativeNudgeFailures(chatroomId, role2);
|
|
85332
85400
|
}
|
|
85333
85401
|
});
|
|
85334
|
-
}).pipe(exports_Effect.provide(effectContext2), exports_Effect.catchAll((err) => exports_Effect.sync(() => console.warn(`[NativeTaskDelivery] delivery failed for ${row.agentConfig.role}@${row.chatroomId}: ${getErrorMessage2(err)}`))), exports_Effect.ensuring(exports_Effect.sync(() =>
|
|
85402
|
+
}).pipe(exports_Effect.provide(effectContext2), exports_Effect.catchAll((err) => exports_Effect.sync(() => console.warn(`[NativeTaskDelivery] delivery failed for ${row.agentConfig.role}@${row.chatroomId}: ${getErrorMessage2(err)}`))), exports_Effect.ensuring(exports_Effect.sync(() => {
|
|
85403
|
+
deliveryState.releaseDelivery(row.chatroomId, row.agentConfig.role);
|
|
85404
|
+
if (!deliveredToHarness) {
|
|
85405
|
+
ledger.clearDelivery(taskId, harnessSessionId);
|
|
85406
|
+
}
|
|
85407
|
+
}))));
|
|
85335
85408
|
break;
|
|
85336
85409
|
}
|
|
85337
85410
|
}
|
|
@@ -85445,6 +85518,17 @@ async function deliverOneTask(deps, event, snapshot) {
|
|
|
85445
85518
|
});
|
|
85446
85519
|
if (!full)
|
|
85447
85520
|
return false;
|
|
85521
|
+
const ledger = getNativeDeliveryLedger();
|
|
85522
|
+
const ledgerBlock = explainLedgerDeliveryBlock(snapshot.taskId, harnessSessionId, ledger);
|
|
85523
|
+
if (ledgerBlock) {
|
|
85524
|
+
console.warn(`[RestartOrchestrator] skip task ${snapshot.taskId} — ${ledgerBlock}`);
|
|
85525
|
+
return false;
|
|
85526
|
+
}
|
|
85527
|
+
if (!ledger.tryAcquire(snapshot.taskId, harnessSessionId)) {
|
|
85528
|
+
console.warn(`[RestartOrchestrator] skip task ${snapshot.taskId} — delivery_ledger_busy`);
|
|
85529
|
+
return false;
|
|
85530
|
+
}
|
|
85531
|
+
let deliveredToHarness = false;
|
|
85448
85532
|
try {
|
|
85449
85533
|
await exports_Effect.runPromise(runNativeInjectionEffect(full, harnessSessionId, {
|
|
85450
85534
|
sessionId: deps.session.sessionId,
|
|
@@ -85457,6 +85541,8 @@ async function deliverOneTask(deps, event, snapshot) {
|
|
|
85457
85541
|
}
|
|
85458
85542
|
},
|
|
85459
85543
|
onTaskDelivered: ({ chatroomId, role, taskId }) => {
|
|
85544
|
+
deliveredToHarness = true;
|
|
85545
|
+
ledger.markDelivered(taskId, harnessSessionId);
|
|
85460
85546
|
deps.agentMgr.setLastInFlightTask(chatroomId, role, taskId);
|
|
85461
85547
|
}
|
|
85462
85548
|
}));
|
|
@@ -85464,6 +85550,10 @@ async function deliverOneTask(deps, event, snapshot) {
|
|
|
85464
85550
|
} catch (err) {
|
|
85465
85551
|
console.warn(`[RestartOrchestrator] deliver failed for task ${snapshot.taskId}: ${getErrorMessage2(err)}`);
|
|
85466
85552
|
return false;
|
|
85553
|
+
} finally {
|
|
85554
|
+
if (!deliveredToHarness) {
|
|
85555
|
+
ledger.clearDelivery(snapshot.taskId, harnessSessionId);
|
|
85556
|
+
}
|
|
85467
85557
|
}
|
|
85468
85558
|
}
|
|
85469
85559
|
async function deliverPendingTasks(deps, event) {
|
|
@@ -85541,6 +85631,7 @@ var init_restart_orchestrator = __esm(() => {
|
|
|
85541
85631
|
init_esm();
|
|
85542
85632
|
init_native_ready_invariant();
|
|
85543
85633
|
init_native_task_delivery_coordinator();
|
|
85634
|
+
init_native_task_injector_logic();
|
|
85544
85635
|
init_native_task_injector();
|
|
85545
85636
|
init_api3();
|
|
85546
85637
|
init_convex_error();
|
|
@@ -112092,4 +112183,4 @@ program2.hook("preAction", async (_thisCommand, actionCommand) => {
|
|
|
112092
112183
|
});
|
|
112093
112184
|
program2.parse();
|
|
112094
112185
|
|
|
112095
|
-
//# debugId=
|
|
112186
|
+
//# debugId=79E3EED5683A0EFF64756E2164756E21
|