dsh-zhou 3.18.0 → 3.18.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/lib/chief/core.js +18 -9
- package/lib/chief/handoff.js +16 -4
- package/locale/zh.json +1 -1
- package/package.json +1 -1
package/lib/chief/core.js
CHANGED
|
@@ -1335,6 +1335,23 @@ export class ChiefCore {
|
|
|
1335
1335
|
...(this.config.standInReadOnly === true ? { sandboxMode: 'read-only' } : {}),
|
|
1336
1336
|
});
|
|
1337
1337
|
if (opened.ok !== true) {
|
|
1338
|
+
if (opened.code === 'E_STAND_IN_UNLOCKED') {
|
|
1339
|
+
// 3.18.1: fail closed. The question is not delivered at all — an unlocked
|
|
1340
|
+
// stand-in with write and command tools is worse than a visible failure.
|
|
1341
|
+
return {
|
|
1342
|
+
ok: false,
|
|
1343
|
+
code: 'E_STAND_IN_UNLOCKED',
|
|
1344
|
+
delivered: false,
|
|
1345
|
+
sessionId: busyTarget.sessionId,
|
|
1346
|
+
targetRunning: true,
|
|
1347
|
+
crossWorkspace: false,
|
|
1348
|
+
waitedMs: 0,
|
|
1349
|
+
standIn: { sessionId: String(opened.sessionId ?? ''), target: busyTarget.sessionId },
|
|
1350
|
+
reason: opened.reason ?? 'the sandbox mode event was not written',
|
|
1351
|
+
note: `the stand-in for "${busyTarget.sessionId}" was created but could not be locked to read-only, so this message was not delivered. Retry later, or set standInReadOnly to false to accept a writable stand-in.`,
|
|
1352
|
+
message: `stand-in ${String(opened.sessionId ?? '')} is not read-only: ${opened.reason ?? 'the sandbox mode event was not written'}`,
|
|
1353
|
+
};
|
|
1354
|
+
}
|
|
1338
1355
|
return {
|
|
1339
1356
|
ok: false,
|
|
1340
1357
|
code: opened.code ?? 'E_STANDIN_FAILED',
|
|
@@ -1348,14 +1365,6 @@ export class ChiefCore {
|
|
|
1348
1365
|
};
|
|
1349
1366
|
}
|
|
1350
1367
|
const standInId = String(opened.sessionId ?? '');
|
|
1351
|
-
// A lock that could not be written is reported once and never blocks the
|
|
1352
|
-
// answer: an unlocked stand-in still answers, and a lost question does not.
|
|
1353
|
-
let lockNote = '';
|
|
1354
|
-
if (this.config.standInReadOnly === true && opened.sandboxMode !== 'read-only') {
|
|
1355
|
-
const reason = opened.sandboxModeSkipped ?? 'the sandbox mode event was not written';
|
|
1356
|
-
this.#warn(`just_ask stand-in ${standInId} could not be locked to read-only: ${reason}; the answer proceeds unlocked`);
|
|
1357
|
-
lockNote = ` read-only lock: skipped (${reason}).`;
|
|
1358
|
-
}
|
|
1359
1368
|
void this.#audit({
|
|
1360
1369
|
event: 'stand-in',
|
|
1361
1370
|
action: 'spawned',
|
|
@@ -1373,7 +1382,7 @@ export class ChiefCore {
|
|
|
1373
1382
|
crossWorkspace: false,
|
|
1374
1383
|
waitedMs: 0,
|
|
1375
1384
|
standIn: { sessionId: standInId, target: busyTarget.sessionId },
|
|
1376
|
-
note: `"${busyTarget.sessionId}" was running a turn, so a read-only stand-in (${STAND_IN_PRESET}) will answer: ${standInId}. The target was not interrupted and did not receive this message; the stand-in was told to reply to ${sender?.id ?? 'the caller'}
|
|
1385
|
+
note: `"${busyTarget.sessionId}" was running a turn, so a read-only stand-in (${STAND_IN_PRESET}) will answer: ${standInId}. The target was not interrupted and did not receive this message; the stand-in was told to reply to ${sender?.id ?? 'the caller'}.`,
|
|
1377
1386
|
};
|
|
1378
1387
|
}
|
|
1379
1388
|
|
package/lib/chief/handoff.js
CHANGED
|
@@ -414,17 +414,30 @@ async function openSessionInner(core, args) {
|
|
|
414
414
|
let noticeInjected = false;
|
|
415
415
|
let messageInjected = false;
|
|
416
416
|
let sandboxModeApplied = false;
|
|
417
|
-
let sandboxModeSkipped;
|
|
418
417
|
try {
|
|
419
418
|
const agent = await findAgent(core, sessionId);
|
|
420
419
|
if (agent === undefined || agent === null) throw new Error(`no live Agent for ${sessionId}`);
|
|
421
420
|
// 3.18.0: the mode has to be on the ledger *before* the first message, or the
|
|
422
421
|
// stand-in's first turn is composed against the preset's default sandbox and
|
|
423
422
|
// the lock arrives one turn too late to stop a write.
|
|
423
|
+
// 3.18.1: and if it cannot be written, nothing is delivered. A stand-in that
|
|
424
|
+
// quietly runs unlocked is the worse failure: the caller believes the question
|
|
425
|
+
// was asked, while it sits in a Session with write and command tools.
|
|
424
426
|
if (sandboxMode !== undefined) {
|
|
425
427
|
const locked = applySandboxMode(agent, sandboxMode, warnings);
|
|
426
|
-
if (locked.ok === true)
|
|
427
|
-
|
|
428
|
+
if (locked.ok === true) {
|
|
429
|
+
sandboxModeApplied = true;
|
|
430
|
+
} else {
|
|
431
|
+
return {
|
|
432
|
+
ok: false,
|
|
433
|
+
code: 'E_STAND_IN_UNLOCKED',
|
|
434
|
+
message: `could not set sandbox mode "${sandboxMode}" on ${sessionId}: ${locked.reason}`,
|
|
435
|
+
reason: locked.reason,
|
|
436
|
+
sessionId,
|
|
437
|
+
warnings,
|
|
438
|
+
note: `${sessionId} 已建出,但没锁成 ${sandboxMode},首条消息没有注入。`,
|
|
439
|
+
};
|
|
440
|
+
}
|
|
428
441
|
}
|
|
429
442
|
await touchRoster(core, {
|
|
430
443
|
sessionId,
|
|
@@ -474,7 +487,6 @@ async function openSessionInner(core, args) {
|
|
|
474
487
|
warnings,
|
|
475
488
|
...(isTemp ? { is_temp: true } : {}),
|
|
476
489
|
...(sandboxModeApplied ? { sandboxMode } : {}),
|
|
477
|
-
...(sandboxModeSkipped === undefined ? {} : { sandboxModeSkipped }),
|
|
478
490
|
note: `已通过 ${path} 打开 ${sessionId},首条消息已作为 agent-message 卡片注入。`,
|
|
479
491
|
};
|
|
480
492
|
}
|
package/locale/zh.json
CHANGED