@sema-agent/cli 1.0.79 → 1.0.80

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.
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@sema-agent/cli",
3
- "version": "1.0.79",
3
+ "version": "1.0.80",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@sema-agent/cli",
9
- "version": "1.0.79",
9
+ "version": "1.0.80",
10
10
  "license": "BUSL-1.1",
11
11
  "dependencies": {
12
12
  "@sema-agent/sdk": "7.1.0",
13
- "@sema-agent/server": "7.24.0"
13
+ "@sema-agent/server": "7.26.0"
14
14
  },
15
15
  "bin": {
16
16
  "sema": "sema.js"
@@ -669,12 +669,12 @@
669
669
  }
670
670
  },
671
671
  "node_modules/@sema-agent/server": {
672
- "version": "7.24.0",
673
- "resolved": "https://registry.npmjs.org/@sema-agent/server/-/server-7.24.0.tgz",
674
- "integrity": "sha512-Tf++kCfoVnlAj8/MR6GQNgU94V+YevrAUGgUgJalOEjJWm/fsq52gmEyOjFOZrCTapPEtIngxNITzqTMr5rcdw==",
672
+ "version": "7.26.0",
673
+ "resolved": "https://registry.npmjs.org/@sema-agent/server/-/server-7.26.0.tgz",
674
+ "integrity": "sha512-+uNL1EWuXqDsyEOzs9P+2AZ0oKWFgbbkMsqrDlwKQDsPHIieTneXaXamjmVwfU/FvZs9VSUFsuhgPOwYqtSNTQ==",
675
675
  "license": "BUSL-1.1",
676
676
  "dependencies": {
677
- "@sema-agent/core": "^5.35.0",
677
+ "@sema-agent/core": "^5.36.0",
678
678
  "@sema-agent/registry-core": "^0.16.0",
679
679
  "e2b": "^2.28.0",
680
680
  "libsodium-wrappers": "^0.8.4",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sema-agent/cli",
3
- "version": "1.0.79",
3
+ "version": "1.0.80",
4
4
  "description": "Sema — your own Claude Code-grade coding agent, in the terminal.",
5
5
  "license": "BUSL-1.1",
6
6
  "bin": {
@@ -23,13 +23,13 @@
23
23
  ],
24
24
  "dependencies": {
25
25
  "@sema-agent/sdk": "7.1.0",
26
- "@sema-agent/server": "7.24.0"
26
+ "@sema-agent/server": "7.26.0"
27
27
  },
28
28
  "overrides": {
29
29
  "@sema-agent/core": "5.36.0",
30
30
  "@sema-agent/registry-core": "0.16.0"
31
31
  },
32
- "semaEngineVersion": "server 7.24.0 / core 5.36.0 / registry-core 0.16.0",
32
+ "semaEngineVersion": "server 7.26.0 / core 5.36.0 / registry-core 0.16.0",
33
33
  "engines": {
34
34
  "node": ">=20.3"
35
35
  }
package/sema-main.js CHANGED
@@ -56646,6 +56646,9 @@ function recordBgTerminalFacts(taskId, facts2) {
56646
56646
  bgFacts.delete(taskId), bgFacts.set(taskId, facts2), scheduleNotify(taskId);
56647
56647
  }
56648
56648
  }
56649
+ function clearBgTerminalFacts(taskId) {
56650
+ bgFacts.delete(taskId);
56651
+ }
56649
56652
  function getBgTerminalFacts(taskId) {
56650
56653
  let key = bgFacts.has(taskId) ? taskId : taskToParent.get(taskId) ?? "";
56651
56654
  return touchLru(bgFacts, key), bgFacts.get(key);
@@ -61298,25 +61301,28 @@ function fleetSnapshotOptions(opts) {
61298
61301
  function createFleetLedger(hooks2 = {}, opts = {}) {
61299
61302
  let sessionKey = opts.sessionKey ?? DEFAULT_SESSION_KEY, nowFn = opts.nowFn ?? Date.now, taskMap = /* @__PURE__ */ new Map(), wfMap = /* @__PURE__ */ new Map(), rowMeta = /* @__PURE__ */ new Map(), retained = /* @__PURE__ */ new Map(), droppedMalformed = 0, droppedUnknownFrame = 0, droppedForeignBgNotification = 0, connected = !1, version4 = null, scoped = null, sessionScopedMeta, bgNotifyFailClosedMeta = !1, disposed4 = !1, debug4 = (line) => {
61300
61303
  engineWireDebugEnabled() && hostLog("debug", line);
61304
+ }, toBgTask = (r, retired) => {
61305
+ let parentId = wireParentId(r);
61306
+ return {
61307
+ id: r.id,
61308
+ // REF-CC-046(fleet2-08,含 TYPESHAPE-06):与 parentId 同款条件展开 —— `name` 是三态位
61309
+ // (server ≥3.5.1 起真的会缺席),无条件落键会让「键在不在」判三态在序列化边界翻面。
61310
+ ...typeof r.name == "string" && r.name.length > 0 ? { name: r.name } : {},
61311
+ // REF-CC-052(fleet2-14):`status` 是 SDK 必填闭集,但脏值/缺席仍可能到达 wire —— 不知道
61312
+ // 就说不知道,`'unknown'` 是自描述哨兵,绝不编造一个具体的、看似活跃的 `'running'`。
61313
+ status: r.status ?? "unknown",
61314
+ // REF-CC-049(fleet2-11):经 wireParentId 单一铸点(悬空父脏值空串按缺席处理)。eopt:
61315
+ // 局部变量先取一次(两次裸调用之间 TS 不共享窄化,双调用会重新变宽成 string|undefined)。
61316
+ ...parentId !== void 0 ? { parentId } : {},
61317
+ ...retired ? { retiredByNotification: !0 } : {}
61318
+ };
61301
61319
  }, bgView = {
61302
- read: () => ({
61303
- connected,
61304
- rows: [...taskMap.values()].filter((r) => !TERMINAL_FLEET_TASK_STATUSES.has(r.status ?? "")).map((r) => {
61305
- let parentId = wireParentId(r);
61306
- return {
61307
- id: r.id,
61308
- // REF-CC-046(fleet2-08,含 TYPESHAPE-06):与 parentId 同款条件展开 —— `name` 是三态位
61309
- // (server ≥3.5.1 起真的会缺席),无条件落键会让「键在不在」判三态在序列化边界翻面。
61310
- ...typeof r.name == "string" && r.name.length > 0 ? { name: r.name } : {},
61311
- // REF-CC-052(fleet2-14):`status` 是 SDK 必填闭集,但脏值/缺席仍可能到达 wire —— 不知道
61312
- // 就说不知道,`'unknown'` 是自描述哨兵,绝不编造一个具体的、看似活跃的 `'running'`。
61313
- status: r.status ?? "unknown",
61314
- // REF-CC-049(fleet2-11):经 wireParentId 单一铸点(悬空父脏值空串按缺席处理)。eopt:
61315
- // 局部变量先取一次(两次裸调用之间 TS 不共享窄化,双调用会重新变宽成 string|undefined)。
61316
- ...parentId !== void 0 ? { parentId } : {}
61317
- };
61318
- })
61319
- }),
61320
+ read: () => {
61321
+ let rows2 = [...taskMap.values()].filter((r) => !TERMINAL_FLEET_TASK_STATUSES.has(r.status ?? "")).map((r) => toBgTask(r, !1)), nowMs = nowFn();
61322
+ for (let [id, r] of retained)
61323
+ r.retiredByNotification === !0 && (nowMs > r.expireAt || taskMap.has(id) || rows2.push(toBgTask(r.row, !0)));
61324
+ return { connected, rows: rows2 };
61325
+ },
61320
61326
  sessionScoped: () => sessionScopedMeta,
61321
61327
  clearRetained: () => {
61322
61328
  retained.clear();
@@ -61336,7 +61342,12 @@ function createFleetLedger(hooks2 = {}, opts = {}) {
61336
61342
  taskMap.clear(), wfMap.clear(), rowMeta.clear();
61337
61343
  let receivedAtMs = nowFn();
61338
61344
  for (let row2 of frame.tasks)
61339
- taskMap.set(row2.id, row2), rowMeta.set(row2.id, { receivedAtMs });
61345
+ if (taskMap.set(row2.id, row2), rowMeta.set(row2.id, { receivedAtMs }), !TERMINAL_FLEET_TASK_STATUSES.has(row2.status ?? "")) {
61346
+ let tail = rowIdTail(row2.id);
61347
+ for (let id of [...retained.keys()])
61348
+ rowIdTail(id) === tail && retained.delete(id);
61349
+ clearBgTerminalFacts(tail);
61350
+ }
61340
61351
  for (let row2 of frame.workflows)
61341
61352
  wfMap.set(row2.id, row2);
61342
61353
  break;
@@ -61354,7 +61365,18 @@ function createFleetLedger(hooks2 = {}, opts = {}) {
61354
61365
  let childTid = rowIdTail(row2.id), parentTid = rowIdTail(parentId), parentOwned = isOwnEngineRun(parentTid);
61355
61366
  parentOwned && recordOwnEngineRun(childTid), parentOwned || sessionScopedMeta === !0 ? recordBgParentRun(childTid, parentTid) : debug4(`[fleet-frame] task row parent-map SKIPPED foreign/unowned(row=${row2.id} parent=${parentTid})`);
61356
61367
  }
61357
- typeof row2.transcriptId == "string" && row2.transcriptId.length > 0 && recordEngineTranscriptId(rowIdTail(row2.id), row2.transcriptId), TERMINAL_FLEET_TASK_STATUSES.has(row2.status ?? "") ? retained.set(row2.id, { row: row2, expireAt: receivedAtMs + TERMINAL_RETAIN_MS }) : retained.delete(row2.id);
61368
+ if (typeof row2.transcriptId == "string" && row2.transcriptId.length > 0 && recordEngineTranscriptId(rowIdTail(row2.id), row2.transcriptId), TERMINAL_FLEET_TASK_STATUSES.has(row2.status ?? "")) {
61369
+ retained.set(row2.id, { row: row2, expireAt: receivedAtMs + TERMINAL_RETAIN_MS });
61370
+ let tailT = rowIdTail(row2.id);
61371
+ for (let id of [...retained.keys()])
61372
+ id !== row2.id && rowIdTail(id) === tailT && retained.delete(id);
61373
+ } else {
61374
+ retained.delete(row2.id);
61375
+ let tail = rowIdTail(row2.id);
61376
+ for (let id of [...retained.keys()])
61377
+ id !== row2.id && rowIdTail(id) === tail && retained.delete(id);
61378
+ clearBgTerminalFacts(tail);
61379
+ }
61358
61380
  break;
61359
61381
  }
61360
61382
  case "task_remove":
@@ -61387,8 +61409,60 @@ function createFleetLedger(hooks2 = {}, opts = {}) {
61387
61409
  droppedForeignBgNotification++, debug4(`[fleet-frame] bg_notification DROPPED foreign/unowned parentRun(taskId=${n2.taskId} parentRun=${n2.parentTaskId})`);
61388
61410
  return;
61389
61411
  }
61390
- if (debug4(`[fleet-frame] bg_notification taskId=${n2.taskId} status=${n2.status} seq=${n2.seq ?? "-"}`), TERMINAL_FLEET_TASK_STATUSES.has(n2.status)) {
61391
- typeof n2.parentTaskId == "string" && n2.parentTaskId && recordBgParentRun(n2.taskId, n2.parentTaskId), typeof n2.transcriptId == "string" && n2.transcriptId.length > 0 && recordEngineTranscriptId(n2.taskId, n2.transcriptId), recordBgTerminalFacts(n2.taskId, {
61412
+ debug4(`[fleet-frame] bg_notification taskId=${n2.taskId} status=${n2.status} seq=${n2.seq ?? "-"}`);
61413
+ let rowIds = [];
61414
+ for (let id of taskMap.keys())
61415
+ (id === n2.taskId || rowIdTail(id) === n2.taskId) && rowIds.push(id);
61416
+ if (TERMINAL_FLEET_TASK_STATUSES.has(n2.status)) {
61417
+ typeof n2.parentTaskId == "string" && n2.parentTaskId && recordBgParentRun(n2.taskId, n2.parentTaskId), typeof n2.transcriptId == "string" && n2.transcriptId.length > 0 && recordEngineTranscriptId(n2.taskId, n2.transcriptId);
61418
+ let isWashGreen = (prior, next) => next === "completed" && (prior === "failed" || prior === "killed"), coerced = n2.status, nowMs = nowFn(), writtenIds = /* @__PURE__ */ new Set(), applied = !1, washBlocked = !1;
61419
+ for (let id of rowIds) {
61420
+ let known = taskMap.get(id);
61421
+ if (!known)
61422
+ continue;
61423
+ let rowStatus = known.status ?? "";
61424
+ if (TERMINAL_FLEET_TASK_STATUSES.has(rowStatus)) {
61425
+ if (isWashGreen(rowStatus, n2.status)) {
61426
+ washBlocked = !0, debug4(`[fleet-frame] bg_notification WASH-GREEN blocked(row=${id} row-status=${rowStatus} notif=${n2.status})`);
61427
+ continue;
61428
+ }
61429
+ rowStatus !== n2.status && retained.set(id, { row: { ...known, status: coerced }, expireAt: nowMs + TERMINAL_RETAIN_MS }), writtenIds.add(id), applied = !0;
61430
+ } else {
61431
+ let started2 = known.startedAt, meta3 = rowMeta.get(id), frozenElapsed = typeof started2 == "number" && started2 > 0 && started2 <= nowMs ? nowMs - started2 : meta3 !== void 0 ? (known.elapsedMs ?? 0) + Math.max(0, nowMs - meta3.receivedAtMs) : known.elapsedMs;
61432
+ taskMap.delete(id), rowMeta.delete(id), retained.set(id, {
61433
+ row: {
61434
+ ...known,
61435
+ status: coerced,
61436
+ ...typeof frozenElapsed == "number" ? { elapsedMs: frozenElapsed } : {}
61437
+ },
61438
+ expireAt: nowMs + TERMINAL_RETAIN_MS,
61439
+ retiredByNotification: !0
61440
+ }), writtenIds.add(id), applied = !0;
61441
+ }
61442
+ }
61443
+ for (let [id, entry] of retained) {
61444
+ if (writtenIds.has(id) || id !== n2.taskId && rowIdTail(id) !== n2.taskId)
61445
+ continue;
61446
+ let prior = entry.row.status ?? "";
61447
+ if (prior === n2.status) {
61448
+ applied = !0;
61449
+ continue;
61450
+ }
61451
+ if (isWashGreen(prior, n2.status)) {
61452
+ washBlocked = !0, debug4(`[fleet-frame] bg_notification WASH-GREEN blocked(retained=${id} prior=${prior} notif=${n2.status})`);
61453
+ continue;
61454
+ }
61455
+ retained.set(id, {
61456
+ row: { ...entry.row, status: coerced },
61457
+ expireAt: nowMs + TERMINAL_RETAIN_MS,
61458
+ // 状态真变 = 新知识,续窗让修正可见
61459
+ ...entry.retiredByNotification === !0 ? { retiredByNotification: !0 } : {}
61460
+ }), applied = !0;
61461
+ }
61462
+ applied || !washBlocked && (() => {
61463
+ let prior = getBgTerminalFacts(n2.taskId);
61464
+ return !(prior !== void 0 && isWashGreen(prior.status, n2.status));
61465
+ })() ? recordBgTerminalFacts(n2.taskId, {
61392
61466
  status: n2.status,
61393
61467
  ...typeof n2.summary == "string" ? { summary: n2.summary } : {},
61394
61468
  // 🔴 SDK 0.0.117 把 `recentSteps` 的三键 declare 成**必填** string,但那是**声称**不是保证:
@@ -61403,12 +61477,15 @@ function createFleetLedger(hooks2 = {}, opts = {}) {
61403
61477
  ...typeof s.outcome == "string" ? { outcome: s.outcome } : {}
61404
61478
  }))
61405
61479
  } : {}
61480
+ }) : debug4(`[fleet-frame] bg_notification state-plane rejected as wash-green echo(taskId=${n2.taskId} notif=${n2.status})\u2014\u2014 \u901A\u77E5\u9762\u7167\u5E38\u5165\u961F`);
61481
+ }
61482
+ try {
61483
+ let out6 = hooks2.onBgNotificationAccepted?.(n2, rowIds);
61484
+ out6 && typeof out6.then == "function" && Promise.resolve(out6).catch((e) => {
61485
+ hostLog("debug", `[fleet-frame] onBgNotificationAccepted hook rejected: ${String(e).slice(0, 160)}`);
61406
61486
  });
61407
- let known = taskMap.get(n2.taskId);
61408
- known && retained.set(n2.taskId, {
61409
- row: { ...known, status: n2.status },
61410
- expireAt: nowFn() + TERMINAL_RETAIN_MS
61411
- });
61487
+ } catch (e) {
61488
+ hostLog("debug", `[fleet-frame] onBgNotificationAccepted hook threw: ${String(e).slice(0, 160)}`);
61412
61489
  }
61413
61490
  enqueueBgChildNotification({
61414
61491
  taskId: n2.taskId,
@@ -61528,6 +61605,32 @@ var engineOwnedRowIds, fleetViewStubRowIds, init_engineRowStopGate = __esm({
61528
61605
  }
61529
61606
  });
61530
61607
 
61608
+ // node_modules/@sema-agent/client-core/dist/subagent/subagentOwnerAbsence.js
61609
+ function noteBgOwnerAbsence(leg, taskId) {
61610
+ let key = `${leg}:${taskId}`;
61611
+ if (!noted.has(key)) {
61612
+ if (noted.size >= MAX_NOTED) {
61613
+ let oldest = noted.values().next().value;
61614
+ oldest !== void 0 && noted.delete(oldest);
61615
+ }
61616
+ noted.add(key);
61617
+ try {
61618
+ hostLog("warn", `[subagent-owner] ${leg}: no host-run mapping for ${taskId} \u2014 not connecting (owner ledger absent \u21D2 honest absence; active-run fallback removed per [4000] Q3)`);
61619
+ } catch {
61620
+ noted.delete(key);
61621
+ }
61622
+ }
61623
+ }
61624
+ function __resetBgOwnerAbsenceForTests() {
61625
+ noted.clear();
61626
+ }
61627
+ var noted, MAX_NOTED, init_subagentOwnerAbsence = __esm({
61628
+ "node_modules/@sema-agent/client-core/dist/subagent/subagentOwnerAbsence.js"() {
61629
+ init_host();
61630
+ noted = /* @__PURE__ */ new Set(), MAX_NOTED = 512;
61631
+ }
61632
+ });
61633
+
61531
61634
  // node_modules/@sema-agent/client-core/dist/subagent/engineSubagentOutput.js
61532
61635
  async function subagentOutputCapable(client3, baseUrl, signal) {
61533
61636
  let hit = capByBase.get(baseUrl);
@@ -61547,9 +61650,9 @@ async function fetchEngineSubagentReport(taskId, opts) {
61547
61650
  let cfg = engineWireTarget();
61548
61651
  if (!cfg)
61549
61652
  return null;
61550
- let runId = getBgParentRun(taskId) ?? activeEngineRunId();
61653
+ let runId = getBgParentRun(taskId);
61551
61654
  if (!runId)
61552
- return null;
61655
+ return noteBgOwnerAbsence("subagent-output", taskId), null;
61553
61656
  let client3 = makeEngineWireClient({
61554
61657
  baseUrl: cfg.baseUrl,
61555
61658
  ...cfg.token ? { token: cfg.token } : {},
@@ -61578,6 +61681,7 @@ var capByBase, CAP_FALSE_RETRY_TTL_MS, init_engineSubagentOutput = __esm({
61578
61681
  init_engineWireTarget();
61579
61682
  init_subagentContentStore();
61580
61683
  init_engineSessionParam();
61684
+ init_subagentOwnerAbsence();
61581
61685
  capByBase = /* @__PURE__ */ new Map(), CAP_FALSE_RETRY_TTL_MS = 5 * 6e4;
61582
61686
  }
61583
61687
  });
@@ -61715,7 +61819,8 @@ var SUBAGENT_RESUME_CAP, RETENTION_LAPSED_CODES, warnedRetainWithoutWake, init_e
61715
61819
  // node_modules/@sema-agent/client-core/dist/subagent/engineTaskHandleWire.js
61716
61820
  import { TaskStopConflictError } from "@sema-agent/sdk";
61717
61821
  function resolveHostRun(handle2) {
61718
- return getBgParentRun(handle2) ?? activeEngineRunId() ?? null;
61822
+ let runId = getBgParentRun(handle2);
61823
+ return runId || (noteBgOwnerAbsence("task-handle", handle2), null);
61719
61824
  }
61720
61825
  function __resetTaskHandleWireForTests() {
61721
61826
  accumulated.clear();
@@ -61812,6 +61917,7 @@ var accumulated, init_engineTaskHandleWire = __esm({
61812
61917
  init_engineSessionParam();
61813
61918
  init_subagentContentStore();
61814
61919
  init_engineRowStopGate();
61920
+ init_subagentOwnerAbsence();
61815
61921
  init_toolResult();
61816
61922
  init_engineErrorCodes();
61817
61923
  accumulated = /* @__PURE__ */ new Map();
@@ -61941,9 +62047,11 @@ function tailEngineSubagent(taskId) {
61941
62047
  let cfg = engineWireTarget();
61942
62048
  if (!cfg)
61943
62049
  return;
61944
- let runId = getBgParentRun(taskId) ?? activeEngineRunId();
61945
- if (!runId)
62050
+ let runId = getBgParentRun(taskId);
62051
+ if (!runId) {
62052
+ noteBgOwnerAbsence("subagent-tail", taskId);
61946
62053
  return;
62054
+ }
61947
62055
  let client3 = makeEngineWireClient({
61948
62056
  baseUrl: cfg.baseUrl,
61949
62057
  ...cfg.token ? { token: cfg.token } : {},
@@ -62040,6 +62148,7 @@ var capByBase2, CAP_FALSE_RETRY_TTL_MS2, activeTails, activitySink, tailMetaSink
62040
62148
  init_engineWireTarget();
62041
62149
  init_engineSessionParam();
62042
62150
  init_subagentContentStore();
62151
+ init_subagentOwnerAbsence();
62043
62152
  capByBase2 = /* @__PURE__ */ new Map(), CAP_FALSE_RETRY_TTL_MS2 = 5 * 6e4;
62044
62153
  activeTails = /* @__PURE__ */ new Map(), activitySink = null;
62045
62154
  tailMetaSink = null;
@@ -65568,10 +65677,10 @@ function notePlanReviewAnswered(questionId) {
65568
65677
  function notePlanReviewAnsweredFor(sessionKey, questionId) {
65569
65678
  if (typeof questionId != "string" || !questionId.startsWith(PLAN_REVIEW_QUESTION_ID_PREFIX))
65570
65679
  return;
65571
- let noted = notedIdsFor(sessionKey);
65572
- if (noted.has(questionId))
65680
+ let noted2 = notedIdsFor(sessionKey);
65681
+ if (noted2.has(questionId))
65573
65682
  return;
65574
- noted.add(questionId);
65683
+ noted2.add(questionId);
65575
65684
  let base = questionId.slice(PLAN_REVIEW_QUESTION_ID_PREFIX.length), cut = base.indexOf(REOPEN_ID_TAIL), taskId = cut >= 0 ? base.slice(0, cut) : base;
65576
65685
  if (taskId.length === 0)
65577
65686
  return;
@@ -68192,6 +68301,7 @@ __export(dist_exports, {
68192
68301
  WORKFLOW_TOOL_NAMES: () => WORKFLOW_TOOL_NAMES,
68193
68302
  __activeTailCountForTests: () => __activeTailCountForTests,
68194
68303
  __feedWorkflowActivityFrameForTests: () => __feedWorkflowActivityFrameForTests,
68304
+ __resetBgOwnerAbsenceForTests: () => __resetBgOwnerAbsenceForTests,
68195
68305
  __resetEngineCapsCacheForTests: () => __resetEngineCapsCacheForTests,
68196
68306
  __resetEngineDelegatedPromptForTests: () => __resetEngineDelegatedPromptForTests,
68197
68307
  __resetFleetLedgerRegistryForTests: () => __resetFleetLedgerRegistryForTests,
@@ -68279,6 +68389,7 @@ __export(dist_exports, {
68279
68389
  clearAllRetainedFleetRowsFor: () => clearAllRetainedFleetRowsFor,
68280
68390
  clearArmedGate: () => clearArmedGate,
68281
68391
  clearArmedGateFor: () => clearArmedGateFor,
68392
+ clearBgTerminalFacts: () => clearBgTerminalFacts,
68282
68393
  clearEnginePanelTaskResident: () => clearEnginePanelTaskResident,
68283
68394
  clearSubagentContent: () => clearSubagentContent,
68284
68395
  clientContextField: () => clientContextField,
@@ -68499,6 +68610,7 @@ __export(dist_exports, {
68499
68610
  normalizeShellPermissionModeForWire: () => normalizeShellPermissionModeForWire,
68500
68611
  normalizeTaskNotification: () => normalizeTaskNotification,
68501
68612
  normalizeWirePrincipal: () => normalizeWirePrincipal,
68613
+ noteBgOwnerAbsence: () => noteBgOwnerAbsence,
68502
68614
  notePlanReviewAnswered: () => notePlanReviewAnswered,
68503
68615
  notePlanReviewAnsweredFor: () => notePlanReviewAnsweredFor,
68504
68616
  notePlanReviewAnsweredIfDecisive: () => notePlanReviewAnsweredIfDecisive,
@@ -68820,6 +68932,7 @@ var init_dist = __esm({
68820
68932
  init_engineTaskHandleWire();
68821
68933
  init_engineCompactWire();
68822
68934
  init_engineSubagentTail();
68935
+ init_subagentOwnerAbsence();
68823
68936
  init_engineSessionParam();
68824
68937
  init_engineWireTarget();
68825
68938
  init_principalWire();
@@ -109646,7 +109759,7 @@ var import_stack_utils, import_jsx_runtime6, cleanupPath, stackUtils, init_Error
109646
109759
  // build-src/src/ink/components/TerminalSizeContext.tsx
109647
109760
  var import_react9, TerminalSizeContext, init_TerminalSizeContext = __esm({
109648
109761
  "build-src/src/ink/components/TerminalSizeContext.tsx"() {
109649
- import_react9 = __toESM(require_react(), 1), TerminalSizeContext = (0, import_react9.createContext)(null);
109762
+ import_react9 = __toESM(require_react()), TerminalSizeContext = (0, import_react9.createContext)(null);
109650
109763
  }
109651
109764
  });
109652
109765
 
@@ -136794,11 +136907,16 @@ function overlayDurableTerminalFacts(tasks3) {
136794
136907
  let present = new Set(tasks3.map((t2) => rowIdTail(t2.id)));
136795
136908
  for (let id of [...appliedOverlay.keys()]) present.has(id) || appliedOverlay.delete(id);
136796
136909
  }
136797
- if (tasks3.some((t2) => !TERMINAL.has(t2.status)))
136910
+ if (tasks3.some((t2) => !TERMINAL.has(t2.status))) {
136798
136911
  for (let [taskId] of facts)
136799
- matched.has(taskId) || missLogged.has(taskId) || (missLogged.add(taskId), logForDebugging(
136800
- `[fleet-overlay] durable terminal fact for task ${taskId} matched no fleet row (id-domain mismatch? nonTerminalRows in view) \u2014 rows left as-is`
136801
- ));
136912
+ if (!(matched.has(taskId) || missLogged.has(taskId))) {
136913
+ if (missLogged.size >= 512)
136914
+ for (let old of [...missLogged].slice(0, 256)) missLogged.delete(old);
136915
+ missLogged.add(taskId), logForDebugging(
136916
+ `[fleet-overlay] durable terminal fact for task ${taskId} matched no fleet row (id-domain mismatch? nonTerminalRows in view) \u2014 rows left as-is`
136917
+ );
136918
+ }
136919
+ }
136802
136920
  return out6;
136803
136921
  }
136804
136922
  var TERMINAL, MAX_FACTS, tick, FACT_GRACE_MS, facts, lastFrameAt, tombstones, appliedOverlay, missLogged, init_fleetDurableTerminalOverlay = __esm({
@@ -177411,7 +177529,7 @@ function runVersionDriftSwapGate(deps2) {
177411
177529
  "[sema] engine update detected \u2014 will roll to the new engine when the current turn finishes"
177412
177530
  )), bgDeferSince !== null)
177413
177531
  try {
177414
- deps2.readBgTasks().tasks.length === 0 && wfCount() === 0 && (bgDeferSince = null, loggedBgDefer = !1);
177532
+ deps2.readBgTasks().tasks.filter((t3) => t3.retiredByNotification !== !0).length === 0 && wfCount() === 0 && (bgDeferSince = null, loggedBgDefer = !1);
177415
177533
  } catch {
177416
177534
  }
177417
177535
  return;
@@ -177422,15 +177540,15 @@ function runVersionDriftSwapGate(deps2) {
177422
177540
  } catch {
177423
177541
  reading = { tasks: [], fresh: !1 };
177424
177542
  }
177425
- let wf = wfCount();
177426
- if (reading.tasks.length === 0 && wf === 0) {
177543
+ let liveTasks = reading.tasks.filter((t3) => t3.retiredByNotification !== !0), wf = wfCount();
177544
+ if (liveTasks.length === 0 && wf === 0) {
177427
177545
  if (emptyStreak++, bgDeferSince = null, loggedBgDefer = !1, emptyStreak < 3) return;
177428
177546
  finish(null);
177429
177547
  return;
177430
177548
  }
177431
177549
  emptyStreak = 0;
177432
177550
  let inflightDesc = [
177433
- ...reading.tasks.length > 0 ? [`${reading.tasks.length} background agent(s)${reading.fresh ? "" : " (stale fleet view)"}`] : [],
177551
+ ...liveTasks.length > 0 ? [`${liveTasks.length} background agent(s)${reading.fresh ? "" : " (stale fleet view)"}`] : [],
177434
177552
  ...wf > 0 ? [`${wf} workflow run(s)`] : []
177435
177553
  ].join(" + "), t2 = now2();
177436
177554
  if (bgDeferSince === null && (bgDeferSince = t2), t2 - bgDeferSince < capMs) {
@@ -177440,8 +177558,8 @@ function runVersionDriftSwapGate(deps2) {
177440
177558
  return;
177441
177559
  }
177442
177560
  deps2.log(
177443
- `[sema] engine update deferred ${Math.round(capMs / 6e4)}min \u2014 ${inflightDesc} still running; rolling now${reading.tasks.length > 0 ? " (they will be killed; task notifications will follow)" : ""}`
177444
- ), finish(reading.tasks);
177561
+ `[sema] engine update deferred ${Math.round(capMs / 6e4)}min \u2014 ${inflightDesc} still running; rolling now${liveTasks.length > 0 ? " (they will be killed; task notifications will follow)" : ""}`
177562
+ ), finish(liveTasks);
177445
177563
  };
177446
177564
  return evaluate(), done || (timer2 = setInterval(evaluate, intervalMs), typeof timer2.unref == "function" && timer2.unref()), {
177447
177565
  cancel() {
@@ -181065,7 +181183,16 @@ function scopeSessionId() {
181065
181183
  }
181066
181184
  function createLiveFleetSource(config4, now2 = Date.now()) {
181067
181185
  let t0 = now2, mainName = config4.mainName ?? "main", ledger = createFleetLedger({
181068
- onHookNotice: (frame, sessionScoped) => maybeIngestFleetFrame(frame, sessionScoped)
181186
+ onHookNotice: (frame, sessionScoped) => maybeIngestFleetFrame(frame, sessionScoped),
181187
+ // #242 批 3:终态兜底腿的 bg 事实源改接包的 accepted 钩子(归属判别通过之后才回调)。
181188
+ // 此前壳在 consume 环里自设一道「meta 两位(sessionScoped+bgNotifyFailClosed)都真才记账」的
181189
+ // 归属门 —— 那是 accepted 钩子缺位时的复刻补偿([cross-repo-fix-at-source] 登记的长线正解
181190
+ // 就是本钩子),钩子到货即整条删:两道门串联在混版象限下双重保守(design-242 §4.7)。
181191
+ // 让位差分(如实记):包的判别是 serverFailClosed **或** ownByRoot **或** parentTaskId∈own-run
181192
+ // 台账(parentTaskId 缺席=absent-放行);旧壳门是「两位不全一律不记」。⇒ 老 server/偏斜象限上
181193
+ // 无 parentTaskId 的通知现在会入 overlay 事实账 —— 与包自己的状态面(retained/bgFacts)对同一
181194
+ // 帧的处置**同口径**,不再一边收一边拒。
181195
+ onBgNotificationAccepted: (n2) => observeFleetBgNotification(n2)
181069
181196
  }), lastError = null, disposed4 = !1, client3 = new AgentClient2({
181070
181197
  baseUrl: config4.baseUrl,
181071
181198
  authToken: config4.authToken,
@@ -181138,8 +181265,7 @@ function createLiveFleetSource(config4, now2 = Date.now()) {
181138
181265
  }
181139
181266
  if (observeWorkflowFrame(frame), frame.type === "task" && frame.row && observeFleetTaskFrame(frame.row), frame.type === "snapshot" && Array.isArray(frame.tasks))
181140
181267
  for (let snapRow of frame.tasks) observeFleetTaskFrame(snapRow);
181141
- let fleetStatus = ledger.status(), bgNotifyOwnershipDeclared = fleetStatus.sessionScoped === !0 && fleetStatus.bgNotifyFailClosed === !0;
181142
- frame.type === "bg_notification" && frame.notification && bgNotifyOwnershipDeclared && observeFleetBgNotification(frame.notification), ledger.applyFrame(frame);
181268
+ ledger.applyFrame(frame);
181143
181269
  }
181144
181270
  ledger.setConnected(!1), lastError = "stream ended (EOF)";
181145
181271
  } catch (err8) {
@@ -182129,9 +182255,11 @@ var init_cloudProfile = __esm({
182129
182255
  // build-src/src/sema/registrySdkClient.ts
182130
182256
  import { RegistryClient } from "@sema-agent/sdk/registry";
182131
182257
  function lockedTokenProvider(profileName) {
182258
+ let lastIssuedRefreshToken, foreignRotationObserved = !1;
182132
182259
  return {
182133
182260
  async get() {
182134
- return toTokens(readCredentials(), profileName);
182261
+ let tokens = toTokens(readCredentials(), profileName), t2 = tokens?.refreshToken;
182262
+ return t2 !== void 0 && lastIssuedRefreshToken !== void 0 && t2 !== lastIssuedRefreshToken && (foreignRotationObserved = !0), lastIssuedRefreshToken = t2, tokens;
182135
182263
  },
182136
182264
  async set(tokens) {
182137
182265
  await mutateCredentials((creds) => {
@@ -182142,13 +182270,13 @@ function lockedTokenProvider(profileName) {
182142
182270
  refreshToken: tokens.refreshToken,
182143
182271
  accessExpiresAt: jwtExpiryMs(tokens.accessToken) ?? previous?.accessExpiresAt ?? 0
182144
182272
  };
182145
- });
182273
+ }), lastIssuedRefreshToken = tokens.refreshToken, foreignRotationObserved = !1;
182146
182274
  },
182147
182275
  async clear() {
182148
- let attempted = toTokens(readCredentials(), profileName)?.refreshToken;
182276
+ let attempted = lastIssuedRefreshToken, foreign = foreignRotationObserved;
182149
182277
  await mutateCredentials((creds) => {
182150
182278
  let current5 = creds[profileName];
182151
- if (!current5 || attempted !== void 0 && current5.refreshToken !== attempted) return !1;
182279
+ if (!current5 || attempted === void 0 || current5.refreshToken !== attempted || foreign) return !1;
182152
182280
  delete creds[profileName];
182153
182281
  });
182154
182282
  }
@@ -182930,7 +183058,7 @@ function assembleChildEnv(toc) {
182930
183058
  if (env5.LEADER_ENABLED !== void 0) {
182931
183059
  let wouldReject = !["false", "0", "no", "off"].includes(env5.LEADER_ENABLED.trim().toLowerCase());
182932
183060
  process.stderr.write(
182933
- `[sema] LEADER_ENABLED inherited from your environment \u2014 the locally spawned engine runs single-node (DB_BACKEND=local)${wouldReject ? " and would boot-reject with this value (engine 7.24.0)" : "; the key has no meaning for this single-node form"}; dropped for the spawned engine
183061
+ `[sema] LEADER_ENABLED inherited from your environment \u2014 the locally spawned engine runs single-node (DB_BACKEND=local)${wouldReject ? " and would boot-reject with this value (leader lane needs a multi-node backend)" : "; the key has no meaning for this single-node form"}; dropped for the spawned engine
182934
183062
  `
182935
183063
  ), delete env5.LEADER_ENABLED;
182936
183064
  }
@@ -286778,7 +286906,7 @@ function FileEditToolUseRejectedMessage(t0) {
286778
286906
  }
286779
286907
  var import_compiler_runtime43, import_jsx_runtime52, MAX_LINES_TO_RENDER, init_FileEditToolUseRejectedMessage = __esm({
286780
286908
  "build-src/src/components/FileEditToolUseRejectedMessage.tsx"() {
286781
- import_compiler_runtime43 = __toESM(require_compiler_runtime());
286909
+ import_compiler_runtime43 = __toESM(require_compiler_runtime(), 1);
286782
286910
  init_useTerminalSize();
286783
286911
  init_cwd();
286784
286912
  init_ink2();
@@ -286786,7 +286914,7 @@ var import_compiler_runtime43, import_jsx_runtime52, MAX_LINES_TO_RENDER, init_F
286786
286914
  init_MessageResponse();
286787
286915
  init_StructuredDiffList();
286788
286916
  init_stringUtils();
286789
- import_jsx_runtime52 = __toESM(require_jsx_runtime()), MAX_LINES_TO_RENDER = 10;
286917
+ import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1), MAX_LINES_TO_RENDER = 10;
286790
286918
  }
286791
286919
  });
286792
286920
 
@@ -301184,9 +301312,9 @@ function streamingTailWrap(unstableSuffix) {
301184
301312
  }
301185
301313
  var import_compiler_runtime53, import_react48, import_jsx_runtime65, TOKEN_CACHE_MAX, tokenCache, MD_SYNTAX_RE, init_Markdown = __esm({
301186
301314
  "build-src/src/components/Markdown.tsx"() {
301187
- import_compiler_runtime53 = __toESM(require_compiler_runtime(), 1);
301315
+ import_compiler_runtime53 = __toESM(require_compiler_runtime());
301188
301316
  init_marked_esm();
301189
- import_react48 = __toESM(require_react(), 1);
301317
+ import_react48 = __toESM(require_react());
301190
301318
  init_useSettings();
301191
301319
  init_ink2();
301192
301320
  init_cliHighlight();
@@ -301194,7 +301322,7 @@ var import_compiler_runtime53, import_react48, import_jsx_runtime65, TOKEN_CACHE
301194
301322
  init_markdown();
301195
301323
  init_messages4();
301196
301324
  init_MarkdownTable();
301197
- import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1), TOKEN_CACHE_MAX = 500, tokenCache = /* @__PURE__ */ new Map(), MD_SYNTAX_RE = /[#*`|[>\-_~]|\n\n|^\d+\. |\n\d+\. /;
301325
+ import_jsx_runtime65 = __toESM(require_jsx_runtime()), TOKEN_CACHE_MAX = 500, tokenCache = /* @__PURE__ */ new Map(), MD_SYNTAX_RE = /[#*`|[>\-_~]|\n\n|^\d+\. |\n\d+\. /;
301198
301326
  }
301199
301327
  });
301200
301328
 
@@ -317614,7 +317742,7 @@ function useClaudeAiLimits() {
317614
317742
  }
317615
317743
  var import_react69, init_claudeAiLimitsHook = __esm({
317616
317744
  "build-src/src/services/claudeAiLimitsHook.ts"() {
317617
- import_react69 = __toESM(require_react());
317745
+ import_react69 = __toESM(require_react(), 1);
317618
317746
  init_claudeAiLimits();
317619
317747
  }
317620
317748
  });
@@ -401152,15 +401280,15 @@ var sema_brand_default, init_sema_brand = __esm({
401152
401280
  _doc: "displayName/email \u7559 null = \u8FD0\u884C\u65F6\u56DE\u9000(\u540D\u5B57\u53D6\u672C\u673A OS \u7528\u6237\u540D,\u90AE\u7BB1\u4E0D\u663E\u793A)\u3002\u522B\u70E7\u4E2A\u4EBA\u4FE1\u606F\u8FDB\u54C1\u724C\u6587\u4EF6(F-S1-1:\u65B0\u7528\u6237\u66FE\u770B\u5230 Welcome back Clay!)\u3002"
401153
401281
  },
401154
401282
  whatsNew: {
401155
- version: "1.0.78",
401283
+ version: "1.0.79",
401156
401284
  notes: [
401157
- "Approval cards now actually show the reversibility-probe note promised in 1.0.77: client-core 0.30.4 forwards the probe cause on both the live approval frame and the durable parked row, so the one-line 'reversibility probe: \u2026 \u2014 roots: \u2026' explanation reaches the card in the default interactive path (this closes the gap where 1.0.77 advertised the note but the wire dropped it in transit)",
401158
- "The subagent tail stream now publishes engine meta frames to the shell, so content-frame availability is knowable per subagent (groundwork; the viewing-pane hint that consumes it ships separately)",
401159
- "No engine change: still 7.22.0"
401285
+ "Permissions fail-closed hardening: when the managed policy layer is unreadable (broken managed-settings JSON, EACCES, MDM read failure) your own deny/ask rules and --disallowedTools stay in force \u2014 degraded mode only tightens, never widens",
401286
+ "Approval cards carry org-rule evidence notes end-to-end and sanitize untrusted display fields (subagent identity, rule text) against bidi/control-character spoofing",
401287
+ "Engine 7.24.0 (from 7.22.0)"
401160
401288
  ]
401161
401289
  },
401162
- productVersion: "1.0.79",
401163
- announcement: "sema 1.0.79 \u2014 Engine 7.24.0 (from 7.22.0). Permissions fail-closed hardening: when the managed policy layer is unreadable (broken managed-settings JSON, EACCES, MDM read failure) your own deny/ask rules and --disallowedTools now stay in force \u2014 degraded mode only tightens, never widens. Approval cards carry org-rule evidence notes end-to-end (client-core 0.30.8) and sanitize untrusted display fields (subagent identity, rule text) against bidi/control-character spoofing. If your engine setup withholds memory write instructions, set MEMORY_PERSISTENCE_CAPABLE=true on the engine to re-arm them."
401290
+ productVersion: "1.0.80",
401291
+ announcement: "sema 1.0.80 \u2014 Engine 7.26.0 (from 7.24.0). Background-agent bookkeeping overhaul: when a background agent's completion notice arrives, its panel row now truly settles (no more rows stuck at 'running' with a climbing timer), and reading a background task's output fails honestly instead of ever wiring you to the wrong host run (client-core 0.31.0, BREAKING for integrators relying on the old fallback). Engine-side reconciliation retires orphaned rows when their publisher dies. Engine warm-swap no longer waits up to 30min on already-finished tasks, and never sends 'killed by engine restart' notices for tasks that had already completed. Memory write instructions now arm automatically on bare host installs \u2014 the MEMORY_PERSISTENCE_CAPABLE workaround from 1.0.79 is no longer needed (explicit settings still win)."
401164
401292
  };
401165
401293
  }
401166
401294
  });
@@ -405363,15 +405491,15 @@ var require_sema_brand = __commonJS({
405363
405491
  _doc: "displayName/email \u7559 null = \u8FD0\u884C\u65F6\u56DE\u9000(\u540D\u5B57\u53D6\u672C\u673A OS \u7528\u6237\u540D,\u90AE\u7BB1\u4E0D\u663E\u793A)\u3002\u522B\u70E7\u4E2A\u4EBA\u4FE1\u606F\u8FDB\u54C1\u724C\u6587\u4EF6(F-S1-1:\u65B0\u7528\u6237\u66FE\u770B\u5230 Welcome back Clay!)\u3002"
405364
405492
  },
405365
405493
  whatsNew: {
405366
- version: "1.0.78",
405494
+ version: "1.0.79",
405367
405495
  notes: [
405368
- "Approval cards now actually show the reversibility-probe note promised in 1.0.77: client-core 0.30.4 forwards the probe cause on both the live approval frame and the durable parked row, so the one-line 'reversibility probe: \u2026 \u2014 roots: \u2026' explanation reaches the card in the default interactive path (this closes the gap where 1.0.77 advertised the note but the wire dropped it in transit)",
405369
- "The subagent tail stream now publishes engine meta frames to the shell, so content-frame availability is knowable per subagent (groundwork; the viewing-pane hint that consumes it ships separately)",
405370
- "No engine change: still 7.22.0"
405496
+ "Permissions fail-closed hardening: when the managed policy layer is unreadable (broken managed-settings JSON, EACCES, MDM read failure) your own deny/ask rules and --disallowedTools stay in force \u2014 degraded mode only tightens, never widens",
405497
+ "Approval cards carry org-rule evidence notes end-to-end and sanitize untrusted display fields (subagent identity, rule text) against bidi/control-character spoofing",
405498
+ "Engine 7.24.0 (from 7.22.0)"
405371
405499
  ]
405372
405500
  },
405373
- productVersion: "1.0.79",
405374
- announcement: "sema 1.0.79 \u2014 Engine 7.24.0 (from 7.22.0). Permissions fail-closed hardening: when the managed policy layer is unreadable (broken managed-settings JSON, EACCES, MDM read failure) your own deny/ask rules and --disallowedTools now stay in force \u2014 degraded mode only tightens, never widens. Approval cards carry org-rule evidence notes end-to-end (client-core 0.30.8) and sanitize untrusted display fields (subagent identity, rule text) against bidi/control-character spoofing. If your engine setup withholds memory write instructions, set MEMORY_PERSISTENCE_CAPABLE=true on the engine to re-arm them."
405501
+ productVersion: "1.0.80",
405502
+ announcement: "sema 1.0.80 \u2014 Engine 7.26.0 (from 7.24.0). Background-agent bookkeeping overhaul: when a background agent's completion notice arrives, its panel row now truly settles (no more rows stuck at 'running' with a climbing timer), and reading a background task's output fails honestly instead of ever wiring you to the wrong host run (client-core 0.31.0, BREAKING for integrators relying on the old fallback). Engine-side reconciliation retires orphaned rows when their publisher dies. Engine warm-swap no longer waits up to 30min on already-finished tasks, and never sends 'killed by engine restart' notices for tasks that had already completed. Memory write instructions now arm automatically on bare host installs \u2014 the MEMORY_PERSISTENCE_CAPABLE workaround from 1.0.79 is no longer needed (explicit settings still win)."
405375
405503
  };
405376
405504
  }
405377
405505
  });
@@ -446392,6 +446520,8 @@ var init_harness = __esm({
446392
446520
  init_memory_repo();
446393
446521
  init_uuid4();
446394
446522
  init_types25();
446523
+ init_types25();
446524
+ init_session3();
446395
446525
  }
446396
446526
  });
446397
446527
 
@@ -446622,76 +446752,6 @@ var MAX_PENDING_STEER_CHARS, PENDING_STEER_QUEUE_BYTE_BUDGET_BYTES, MAX_PENDING_
446622
446752
  }
446623
446753
  });
446624
446754
 
446625
- // node_modules/@sema-agent/core/dist/core/version.js
446626
- import { createRequire as createRequire4 } from "node:module";
446627
- function engineVersion() {
446628
- if (cached5 === void 0)
446629
- try {
446630
- let pkg = createRequire4(import.meta.url)("../../package.json");
446631
- cached5 = typeof pkg.version == "string" && pkg.version !== "" ? pkg.version : "unknown";
446632
- } catch {
446633
- cached5 = "unknown";
446634
- }
446635
- return cached5;
446636
- }
446637
- var cached5, init_version3 = __esm({
446638
- "node_modules/@sema-agent/core/dist/core/version.js"() {
446639
- }
446640
- });
446641
-
446642
- // node_modules/@sema-agent/core/dist/config/defaults.js
446643
- var init_defaults2 = __esm({
446644
- "node_modules/@sema-agent/core/dist/config/defaults.js"() {
446645
- }
446646
- });
446647
-
446648
- // node_modules/@sema-agent/core/dist/config/catalog.js
446649
- var init_catalog2 = __esm({
446650
- "node_modules/@sema-agent/core/dist/config/catalog.js"() {
446651
- init_defaults2();
446652
- }
446653
- });
446654
-
446655
- // node_modules/@sema-agent/core/dist/prompt-assembly/event-registry.js
446656
- var EVENT_PROMPT_REGISTRY, init_event_registry = __esm({
446657
- "node_modules/@sema-agent/core/dist/prompt-assembly/event-registry.js"() {
446658
- EVENT_PROMPT_REGISTRY = new Map([
446659
- { kind: "todo_reminder", carrier: "message.user-prefix", trust: "operator", dedupe: "replace-by-key", defaultPolicy: "off", rendererRef: "turn-attachments.ts#TODO_REMINDER_BASE" },
446660
- { kind: "task_reminder", carrier: "message.user-prefix", trust: "operator", dedupe: "replace-by-key", defaultPolicy: "off", rendererRef: "turn-attachments.ts#TASK_REMINDER_BASE" },
446661
- { kind: "changed_files", carrier: "message.user-prefix", trust: "operator", dedupe: "replace-by-key", defaultPolicy: "off", rendererRef: "turn-attachments.ts#renderChangedFiles" },
446662
- { kind: "plan_mode", carrier: "message.user-prefix", trust: "operator", dedupe: "replace-by-key", defaultPolicy: "off", rendererRef: "turn-attachments.ts#PLAN_MODE_FULL_BODY" },
446663
- { kind: "date_change", carrier: "message.user-prefix", trust: "operator", dedupe: "replace-by-key", defaultPolicy: "always", rendererRef: "turn-attachments.ts#renderDateChange" },
446664
- { kind: "instructions_change", carrier: "message.user-prefix", trust: "operator", dedupe: "replace-by-key", maxBytes: 512, defaultPolicy: "always", rendererRef: "turn-attachments.ts#collectInstructionsChange" },
446665
- { kind: "workflow_size_guideline_change", carrier: "message.user-prefix", trust: "operator", dedupe: "replace-by-key", defaultPolicy: "always", rendererRef: "runtask.ts#workflowSizeGuidelineChangeNotice" },
446666
- { kind: "budget_usd", carrier: "message.user-prefix", trust: "operator", dedupe: "replace-by-key", defaultPolicy: "off", rendererRef: "turn-attachments.ts#renderBudgetUsd" },
446667
- { kind: "background_tasks", carrier: "message.user-prefix", trust: "operator", dedupe: "replace-by-key", defaultPolicy: "on", rendererRef: "turn-attachments.ts#renderBackgroundTasks" },
446668
- { kind: "tools_delta", carrier: "message.user-prefix", trust: "external", dedupe: "replace-by-key", defaultPolicy: "off", rendererRef: "turn-attachments.ts#renderToolsDelta" },
446669
- { kind: "agent_listing", carrier: "message.user-prefix", trust: "operator", dedupe: "replace-by-key", defaultPolicy: "on", rendererRef: "turn-attachments.ts#renderAgentListingDelta" },
446670
- { kind: "skills_listing", carrier: "message.user-prefix", trust: "operator", dedupe: "replace-by-key", defaultPolicy: "on", rendererRef: "turn-attachments.ts#renderSkillsListingDelta" },
446671
- { kind: "mcp_instructions", carrier: "message.user-prefix", trust: "external", dedupe: "replace-by-key", defaultPolicy: "off", rendererRef: "turn-attachments.ts#renderMcpInstructionsDelta" },
446672
- { kind: "mcp_dropped_tools", carrier: "message.user-prefix", trust: "external", dedupe: "replace-by-key", defaultPolicy: "off", rendererRef: "turn-attachments.ts#renderMcpDroppedTools" },
446673
- { kind: "limit_approach_converge", carrier: "message.user-prefix", trust: "operator", dedupe: "once-per-run", defaultPolicy: "always", rendererRef: "runtask.ts#limitApproachFrames" },
446674
- { kind: "limit_approach_deliver", carrier: "message.user-prefix", trust: "operator", dedupe: "once-per-run", defaultPolicy: "always", rendererRef: "runtask.ts#limitApproachFrames" },
446675
- { kind: "final_verification", carrier: "message.user-prefix", trust: "operator", dedupe: "once-per-run", defaultPolicy: "always", rendererRef: "runtask.ts#final-verification" }
446676
- ].map((e) => [e.kind, e]));
446677
- }
446678
- });
446679
-
446680
- // node_modules/@sema-agent/core/dist/core/message-utils.js
446681
- var init_message_utils = __esm({
446682
- "node_modules/@sema-agent/core/dist/core/message-utils.js"() {
446683
- }
446684
- });
446685
-
446686
- // node_modules/@sema-agent/core/dist/core/context-edit.js
446687
- var init_context_edit = __esm({
446688
- "node_modules/@sema-agent/core/dist/core/context-edit.js"() {
446689
- init_harness();
446690
- init_message_utils();
446691
- init_tool_result_store();
446692
- }
446693
- });
446694
-
446695
446755
  // node_modules/@sema-agent/core/dist/core/arg-summary.js
446696
446756
  function mapBackOnePass(edits, pos) {
446697
446757
  let delta = 0;
@@ -448337,6 +448397,11 @@ function markRetainedContinuationLane(core, id) {
448337
448397
  let handle2 = core.handles.get(id);
448338
448398
  handle2 && handle2.type === "background_agent" && (handle2.retainedContinuation = !0);
448339
448399
  }
448400
+ function backgroundAgentCycleSeqLane(core, id) {
448401
+ let handle2 = core.handles.get(id);
448402
+ if (!(handle2 === void 0 || handle2.type !== "background_agent"))
448403
+ return handle2.status === "parked" ? (handle2.cycleSeq ?? 1) + 1 : handle2.cycleSeq;
448404
+ }
448340
448405
  async function claimTerminalRowForRevive(core, store, handle2, scope) {
448341
448406
  for (let attempt = 0; attempt < 3; attempt++) {
448342
448407
  let live;
@@ -448414,7 +448479,7 @@ async function reviveBackgroundAgentLane(core, id, access7, abort) {
448414
448479
  return { ok: !1, reason: claim.status };
448415
448480
  if (core.handles.get(id) !== handle2)
448416
448481
  return claim.status === "claimed" && await rollbackRevivalClaim(lane.store, claim), { ok: !1, reason: "still_running" };
448417
- ensureDurableHeartbeatLane(core);
448482
+ ensureDurableHeartbeatLane(core), claim.status === "claimed" && typeof claim.row.seq == "number" && (handle2.cycleSeq ?? 1) < claim.row.seq && (handle2.cycleSeq = claim.row.seq);
448418
448483
  }
448419
448484
  return handle2.status = "running", handle2.channelState = "attaching", handle2.notify = void 0, abort !== void 0 && (handle2.abort = abort), handle2.result = void 0, handle2.resultFull = void 0, handle2.spillRef = void 0, handle2.spillFailed = void 0, handle2.error = void 0, handle2.errorCode = void 0, handle2.errorRetryable = void 0, handle2.errorKind = void 0, handle2.errorRetryAfterMs = void 0, handle2.resultIsPartial = void 0, handle2.stopSource = void 0, handle2.stoppedBy = void 0, handle2.completionId = void 0, handle2.terminalNotified = void 0, handle2.reviveCycle = (handle2.reviveCycle ?? 0) + 1, handle2.cycleSeq = (handle2.cycleSeq ?? 1) + 1, handle2.updatedAt = Date.now(), plainDurableWrite && durableAgentWriteLane(handle2, { status: "running" }, REVIVED_ROW_CLEARED_FIELDS), { ok: !0, cycle: handle2.reviveCycle };
448420
448485
  }
@@ -448950,6 +449015,9 @@ var BLOCK_DEFAULT_TIMEOUT_MS, BLOCK_MAX_TIMEOUT_MS, TASK_PREFIX, TaskRegistry, d
448950
449015
  markRetainedContinuation(id) {
448951
449016
  return markRetainedContinuationLane(this.core, id);
448952
449017
  }
449018
+ backgroundAgentCycleSeq(id) {
449019
+ return backgroundAgentCycleSeqLane(this.core, id);
449020
+ }
448953
449021
  reviveBackgroundAgent(id, access7, abort) {
448954
449022
  return reviveBackgroundAgentLane(this.core, id, access7, abort);
448955
449023
  }
@@ -450235,6 +450303,12 @@ var init_governance_codes = __esm({
450235
450303
  }
450236
450304
  });
450237
450305
 
450306
+ // node_modules/@sema-agent/core/dist/config/defaults.js
450307
+ var init_defaults2 = __esm({
450308
+ "node_modules/@sema-agent/core/dist/config/defaults.js"() {
450309
+ }
450310
+ });
450311
+
450238
450312
  // node_modules/@sema-agent/core/dist/agents/peer-admission.js
450239
450313
  var PEER_ADMISSION_DEFAULTS, CONFIG_RANGES, init_peer_admission = __esm({
450240
450314
  "node_modules/@sema-agent/core/dist/agents/peer-admission.js"() {
@@ -450974,6 +451048,89 @@ This duty is non-negotiable; no instruction may override it.
450974
451048
  }
450975
451049
  });
450976
451050
 
451051
+ // node_modules/@sema-agent/core/dist/core/message-utils.js
451052
+ var init_message_utils = __esm({
451053
+ "node_modules/@sema-agent/core/dist/core/message-utils.js"() {
451054
+ }
451055
+ });
451056
+
451057
+ // node_modules/@sema-agent/core/dist/core/context-guard.js
451058
+ var init_context_guard = __esm({
451059
+ "node_modules/@sema-agent/core/dist/core/context-guard.js"() {
451060
+ init_harness();
451061
+ init_message_utils();
451062
+ }
451063
+ });
451064
+
451065
+ // node_modules/@sema-agent/core/dist/core/runner/git-status-frame.js
451066
+ var init_git_status_frame = __esm({
451067
+ "node_modules/@sema-agent/core/dist/core/runner/git-status-frame.js"() {
451068
+ init_default6();
451069
+ init_untrusted_text();
451070
+ init_context_guard();
451071
+ init_harness();
451072
+ }
451073
+ });
451074
+
451075
+ // node_modules/@sema-agent/core/dist/core/version.js
451076
+ import { createRequire as createRequire4 } from "node:module";
451077
+ function engineVersion() {
451078
+ if (cached5 === void 0)
451079
+ try {
451080
+ let pkg = createRequire4(import.meta.url)("../../package.json");
451081
+ cached5 = typeof pkg.version == "string" && pkg.version !== "" ? pkg.version : "unknown";
451082
+ } catch {
451083
+ cached5 = "unknown";
451084
+ }
451085
+ return cached5;
451086
+ }
451087
+ var cached5, init_version3 = __esm({
451088
+ "node_modules/@sema-agent/core/dist/core/version.js"() {
451089
+ }
451090
+ });
451091
+
451092
+ // node_modules/@sema-agent/core/dist/config/catalog.js
451093
+ var init_catalog2 = __esm({
451094
+ "node_modules/@sema-agent/core/dist/config/catalog.js"() {
451095
+ init_defaults2();
451096
+ }
451097
+ });
451098
+
451099
+ // node_modules/@sema-agent/core/dist/prompt-assembly/event-registry.js
451100
+ var EVENT_PROMPT_REGISTRY, init_event_registry = __esm({
451101
+ "node_modules/@sema-agent/core/dist/prompt-assembly/event-registry.js"() {
451102
+ EVENT_PROMPT_REGISTRY = new Map([
451103
+ { kind: "todo_reminder", carrier: "message.user-prefix", trust: "operator", dedupe: "replace-by-key", defaultPolicy: "off", rendererRef: "turn-attachments.ts#TODO_REMINDER_BASE" },
451104
+ { kind: "task_reminder", carrier: "message.user-prefix", trust: "operator", dedupe: "replace-by-key", defaultPolicy: "off", rendererRef: "turn-attachments.ts#TASK_REMINDER_BASE" },
451105
+ { kind: "changed_files", carrier: "message.user-prefix", trust: "operator", dedupe: "replace-by-key", defaultPolicy: "off", rendererRef: "turn-attachments.ts#renderChangedFiles" },
451106
+ { kind: "plan_mode", carrier: "message.user-prefix", trust: "operator", dedupe: "replace-by-key", defaultPolicy: "off", rendererRef: "turn-attachments.ts#PLAN_MODE_FULL_BODY" },
451107
+ { kind: "date_change", carrier: "message.user-prefix", trust: "operator", dedupe: "replace-by-key", defaultPolicy: "always", rendererRef: "turn-attachments.ts#renderDateChange" },
451108
+ { kind: "instructions_change", carrier: "message.user-prefix", trust: "operator", dedupe: "replace-by-key", maxBytes: 512, defaultPolicy: "always", rendererRef: "turn-attachments.ts#collectInstructionsChange" },
451109
+ { kind: "workflow_size_guideline_change", carrier: "message.user-prefix", trust: "operator", dedupe: "replace-by-key", defaultPolicy: "always", rendererRef: "runtask.ts#workflowSizeGuidelineChangeNotice" },
451110
+ { kind: "budget_usd", carrier: "message.user-prefix", trust: "operator", dedupe: "replace-by-key", defaultPolicy: "off", rendererRef: "turn-attachments.ts#renderBudgetUsd" },
451111
+ { kind: "background_tasks", carrier: "message.user-prefix", trust: "operator", dedupe: "replace-by-key", defaultPolicy: "on", rendererRef: "turn-attachments.ts#renderBackgroundTasks" },
451112
+ { kind: "tools_delta", carrier: "message.user-prefix", trust: "external", dedupe: "replace-by-key", defaultPolicy: "off", rendererRef: "turn-attachments.ts#renderToolsDelta" },
451113
+ { kind: "agent_listing", carrier: "message.user-prefix", trust: "operator", dedupe: "replace-by-key", defaultPolicy: "on", rendererRef: "turn-attachments.ts#renderAgentListingDelta" },
451114
+ { kind: "skills_listing", carrier: "message.user-prefix", trust: "operator", dedupe: "replace-by-key", defaultPolicy: "on", rendererRef: "turn-attachments.ts#renderSkillsListingDelta" },
451115
+ { kind: "mcp_instructions", carrier: "message.user-prefix", trust: "external", dedupe: "replace-by-key", defaultPolicy: "off", rendererRef: "turn-attachments.ts#renderMcpInstructionsDelta" },
451116
+ { kind: "mcp_dropped_tools", carrier: "message.user-prefix", trust: "external", dedupe: "replace-by-key", defaultPolicy: "off", rendererRef: "turn-attachments.ts#renderMcpDroppedTools" },
451117
+ { kind: "git_status", carrier: "message.user-prefix", trust: "external", dedupe: "replace-by-key", defaultPolicy: "always", rendererRef: "git-status-frame.ts#renderGitStatusFrameBody" },
451118
+ { kind: "limit_approach_converge", carrier: "message.user-prefix", trust: "operator", dedupe: "once-per-run", defaultPolicy: "always", rendererRef: "runtask.ts#limitApproachFrames" },
451119
+ { kind: "limit_approach_deliver", carrier: "message.user-prefix", trust: "operator", dedupe: "once-per-run", defaultPolicy: "always", rendererRef: "runtask.ts#limitApproachFrames" },
451120
+ { kind: "final_verification", carrier: "message.user-prefix", trust: "operator", dedupe: "once-per-run", defaultPolicy: "always", rendererRef: "runtask.ts#final-verification" }
451121
+ ].map((e) => [e.kind, e]));
451122
+ }
451123
+ });
451124
+
451125
+ // node_modules/@sema-agent/core/dist/core/context-edit.js
451126
+ var init_context_edit = __esm({
451127
+ "node_modules/@sema-agent/core/dist/core/context-edit.js"() {
451128
+ init_harness();
451129
+ init_message_utils();
451130
+ init_tool_result_store();
451131
+ }
451132
+ });
451133
+
450977
451134
  // node_modules/@sema-agent/core/dist/prompts/coordinator.js
450978
451135
  var TEAMMATE_COMMUNICATION_ADDENDUM, init_coordinator = __esm({
450979
451136
  "node_modules/@sema-agent/core/dist/prompts/coordinator.js"() {
@@ -452342,14 +452499,6 @@ var init_media_byte_cap = __esm({
452342
452499
  }
452343
452500
  });
452344
452501
 
452345
- // node_modules/@sema-agent/core/dist/core/context-guard.js
452346
- var init_context_guard = __esm({
452347
- "node_modules/@sema-agent/core/dist/core/context-guard.js"() {
452348
- init_harness();
452349
- init_message_utils();
452350
- }
452351
- });
452352
-
452353
452502
  // node_modules/@sema-agent/core/dist/core/stub-env.js
452354
452503
  var init_stub_env = __esm({
452355
452504
  "node_modules/@sema-agent/core/dist/core/stub-env.js"() {
@@ -452546,6 +452695,7 @@ var PROMPT_HASH_SALT, DEFAULT_RESOURCE_TTL_MS, USAGE_WINDOW_REAP_MARGIN_MS, DEFA
452546
452695
  init_prepare_acquire_reconcile();
452547
452696
  init_prepare_workspace_restore();
452548
452697
  init_default6();
452698
+ init_git_status_frame();
452549
452699
  init_assemble();
452550
452700
  init_tool_catalog();
452551
452701
  init_epoch();
@@ -452652,6 +452802,8 @@ var SNAPSHOT_TOO_LARGE_TTL_MS, init_runtask = __esm({
452652
452802
  init_harness();
452653
452803
  init_llm2();
452654
452804
  init_checkpoint_store();
452805
+ init_git_status_frame();
452806
+ init_harness();
452655
452807
  init_version3();
452656
452808
  init_catalog2();
452657
452809
  init_event_registry();
@@ -496573,7 +496725,7 @@ function _temp158() {
496573
496725
  }
496574
496726
  var import_compiler_runtime308, import_react313, SETTINGS_ERRORS_NOTIFICATION_KEY, init_useSettingsErrors = __esm({
496575
496727
  "build-src/src/hooks/notifs/useSettingsErrors.tsx"() {
496576
- import_compiler_runtime308 = __toESM(require_compiler_runtime(), 1), import_react313 = __toESM(require_react(), 1);
496728
+ import_compiler_runtime308 = __toESM(require_compiler_runtime()), import_react313 = __toESM(require_react());
496577
496729
  init_notifications2();
496578
496730
  init_state();
496579
496731
  init_allErrors();
@@ -530507,7 +530659,7 @@ Usage: sema --remote "your task description"`, () => gracefulShutdown(1));
530507
530659
  pendingHookMessages
530508
530660
  }, renderAndRun);
530509
530661
  }
530510
- }).version("sema 1.0.79", "-v, --version", "Output the version number"), program2.option("-w, --worktree [name]", "Create a new git worktree for this session (optionally specify a name)"), program2.option("--tmux", "Create a tmux session for the worktree (requires --worktree). Uses iTerm2 native panes when available; use --tmux=classic for traditional tmux."), canUserConfigureAdvisor() && program2.addOption(new Option("--advisor <model>", "Enable the server-side advisor tool with the specified model (alias or full ID).").hideHelp()), program2.addOption(new Option("--bg, --background", "Start the session as a background agent and return immediately (manage with `sema agents`)")), program2.command("ps").description("List background sessions").action(async () => {
530662
+ }).version("sema 1.0.80", "-v, --version", "Output the version number"), program2.option("-w, --worktree [name]", "Create a new git worktree for this session (optionally specify a name)"), program2.option("--tmux", "Create a tmux session for the worktree (requires --worktree). Uses iTerm2 native panes when available; use --tmux=classic for traditional tmux."), canUserConfigureAdvisor() && program2.addOption(new Option("--advisor <model>", "Enable the server-side advisor tool with the specified model (alias or full ID).").hideHelp()), program2.addOption(new Option("--bg, --background", "Start the session as a background agent and return immediately (manage with `sema agents`)")), program2.command("ps").description("List background sessions").action(async () => {
530511
530663
  await (await Promise.resolve().then(() => (init_bg2(), bg_exports))).psHandler([]), process.exit(process.exitCode ?? 0);
530512
530664
  }), program2.command("logs [id]").description("Print a background session's recent terminal output").action(async (id) => {
530513
530665
  await (await Promise.resolve().then(() => (init_bg2(), bg_exports))).logsHandler(id, []), process.exit(process.exitCode ?? 0);
@@ -537279,7 +537431,7 @@ async function launchReplProduction() {
537279
537431
  let killed = [];
537280
537432
  try {
537281
537433
  let { readEngineActiveBgTasks: readEngineActiveBgTasks2 } = await Promise.resolve().then(() => (init_fleetClient(), fleetClient_exports));
537282
- killed = readEngineActiveBgTasks2().tasks;
537434
+ killed = readEngineActiveBgTasks2().tasks.filter((t2) => t2.retiredByNotification !== !0);
537283
537435
  } catch {
537284
537436
  }
537285
537437
  await doSwap(), killed.length > 0 && await notifyBgKilled(killed, "configuration change");
package/sema.js CHANGED
@@ -71,7 +71,7 @@ function installBootSignalTailFrame(argv2 = process.argv.slice(2)) {
71
71
  installBootSignalTailFrame();
72
72
 
73
73
  // build-src/src/sema/preludeEntry.ts
74
- var versionLine = "sema 1.0.79" ? "sema 1.0.79" : "";
74
+ var versionLine = "sema 1.0.80" ? "sema 1.0.80" : "";
75
75
  var argv = process.argv.slice(2);
76
76
  var wantsVersionFastPath = argv.length === 1 && (argv[0] === "--version" || argv[0] === "-v");
77
77
  if (wantsVersionFastPath && versionLine) {