@sema-agent/client-core 0.108.0 → 0.109.0

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.
Files changed (103) hide show
  1. package/CHANGELOG.md +121 -0
  2. package/README.md +37 -24
  3. package/dist/adapt/arms.js +23 -8
  4. package/dist/adapt/textStream.d.ts +2 -0
  5. package/dist/adapt/textStream.js +37 -16
  6. package/dist/adapter/activeRunSelfHeal.js +1 -1
  7. package/dist/adapter/downstream/eventToSdkMessage.js +2 -1
  8. package/dist/agentSession/engineAgentRegistryRead.js +2 -0
  9. package/dist/bashExitReading.d.ts +12 -0
  10. package/dist/bashExitReading.js +44 -0
  11. package/dist/checkpointRowVerdict.d.ts +1 -1
  12. package/dist/checkpointRowVerdict.js +4 -2
  13. package/dist/compensations.js +1 -1
  14. package/dist/engineAgentAbsence.d.ts +2 -0
  15. package/dist/engineAgentAbsence.js +28 -0
  16. package/dist/engineErrorCodes.d.ts +4 -0
  17. package/dist/engineErrorCodes.js +4 -0
  18. package/dist/engineHealthFacts.d.ts +17 -0
  19. package/dist/engineHealthFacts.js +42 -3
  20. package/dist/engineNoticeCodes.d.ts +128 -0
  21. package/dist/engineNoticeCodes.js +630 -55
  22. package/dist/errorSupplementRoles.js +4 -1
  23. package/dist/fleetTaskDesc.js +3 -3
  24. package/dist/generated/engineFactTables.d.ts +1 -0
  25. package/dist/generated/engineFactTables.js +6 -0
  26. package/dist/generated/engineNoticeTables.js +3 -0
  27. package/dist/hitl/approvalCardReasons.js +22 -4
  28. package/dist/hitl/approvalRequestFrameReading.d.ts +14 -0
  29. package/dist/hitl/approvalRequestFrameReading.js +79 -0
  30. package/dist/hitl/approvalsFeed.js +1 -1
  31. package/dist/hitl/askParkRowRouting.js +5 -2
  32. package/dist/hitl/automaticAnswerVerdict.d.ts +5 -2
  33. package/dist/hitl/automaticAnswerVerdict.js +16 -2
  34. package/dist/hitl/decisionConflict.d.ts +2 -1
  35. package/dist/hitl/decisionConflict.js +4 -1
  36. package/dist/hitl/frameRouter.js +9 -1
  37. package/dist/hitl/hitlBridge.d.ts +4 -0
  38. package/dist/hitl/hitlBridge.js +9 -5
  39. package/dist/hitl/livePendingAsk.js +17 -16
  40. package/dist/hitl/localAllowRule.js +2 -1
  41. package/dist/hitl/noAllowCause.d.ts +1 -1
  42. package/dist/hitl/noAllowCause.js +4 -2
  43. package/dist/hitl/parkExpiryJudgements.js +26 -1
  44. package/dist/hitl/parkOwnership.d.ts +2 -0
  45. package/dist/hitl/parkOwnership.js +48 -8
  46. package/dist/hitl/parkResolver.js +7 -7
  47. package/dist/hitl/parkedUnresumable.d.ts +13 -0
  48. package/dist/hitl/parkedUnresumable.js +80 -0
  49. package/dist/hitl/permissionRuleScope.d.ts +4 -0
  50. package/dist/hitl/permissionRuleScope.js +31 -0
  51. package/dist/hitl/persistedRulesWire.d.ts +2 -0
  52. package/dist/hitl/persistedRulesWire.js +11 -10
  53. package/dist/hitl/sessionAllowRoute.js +5 -4
  54. package/dist/hitl/standingRows.d.ts +1 -5
  55. package/dist/hitl/standingRows.js +15 -14
  56. package/dist/hitl/toolApprovalWire.d.ts +8 -2
  57. package/dist/hitl/toolApprovalWire.js +35 -14
  58. package/dist/hooksWireCaps.js +4 -3
  59. package/dist/hostSettingsSource.js +2 -0
  60. package/dist/i18n/messages.en.d.ts +168 -0
  61. package/dist/i18n/messages.en.js +169 -1
  62. package/dist/i18n/messages.zh.js +169 -1
  63. package/dist/index.d.ts +29 -7
  64. package/dist/index.js +16 -4
  65. package/dist/localEngineJudge.d.ts +75 -0
  66. package/dist/localEngineJudge.js +242 -0
  67. package/dist/localEngineOccupancy.d.ts +88 -0
  68. package/dist/localEngineOccupancy.js +269 -0
  69. package/dist/localEngineSeatReading.d.ts +29 -0
  70. package/dist/localEngineSeatReading.js +294 -0
  71. package/dist/localEngineSpawn.d.ts +113 -0
  72. package/dist/localEngineSpawn.js +486 -0
  73. package/dist/localEngineStep.d.ts +286 -0
  74. package/dist/localEngineStep.js +1086 -0
  75. package/dist/localEngineStopLadder.d.ts +29 -0
  76. package/dist/localEngineStopLadder.js +139 -0
  77. package/dist/localEngineSwapCard.d.ts +43 -0
  78. package/dist/localEngineSwapCard.js +205 -0
  79. package/dist/localEngineTiming.d.ts +8 -0
  80. package/dist/localEngineTiming.js +8 -0
  81. package/dist/mcpReconnect.js +12 -5
  82. package/dist/mcpWireCaps.js +2 -2
  83. package/dist/memoryEntriesWire.d.ts +1 -1
  84. package/dist/memoryEntriesWire.js +5 -0
  85. package/dist/noticePresentation.d.ts +2 -0
  86. package/dist/noticePresentation.js +79 -1
  87. package/dist/ownKey.d.ts +10 -0
  88. package/dist/ownKey.js +15 -1
  89. package/dist/ruleReadings.js +1 -1
  90. package/dist/seam.d.ts +13 -2
  91. package/dist/seam.js +8 -1
  92. package/dist/seatContract.d.ts +42 -4
  93. package/dist/seatContract.js +180 -3
  94. package/dist/sessionBackground.js +2 -0
  95. package/dist/subagentContentStore.d.ts +12 -0
  96. package/dist/subagentContentStore.js +72 -11
  97. package/dist/toolResult.js +18 -5
  98. package/dist/wireFailureShape.d.ts +20 -0
  99. package/dist/wireFailureShape.js +37 -6
  100. package/dist/wireRefusalCopy.d.ts +21 -1
  101. package/dist/wireRefusalCopy.js +91 -2
  102. package/docs/INTEGRATION-CLIENTS.md +1152 -10
  103. package/package.json +3 -3
@@ -7,7 +7,7 @@ import { retryStatusFromArm } from '../retryStatus.js';
7
7
  import { steeringInjectedToAttachments } from '../steering.js';
8
8
  import { projectDiagnosticsFrame } from '../diagnostics.js';
9
9
  import { recordEngineToolLabel } from '../engineToolLabelStore.js';
10
- import { registerSubagentAlias, registerSubagentContentAlias } from '../subagentContentStore.js';
10
+ import { applySubagentAlias } from '../subagentContentStore.js';
11
11
  import { readAsyncLaunchedAgentReceipt } from '../toolResult.js';
12
12
  import { recordWorkflowAgentTaskId } from '../workflow.js';
13
13
  import { isCoreTaskNotificationTerminal, isCoreTaskNotificationTerminalNotSuccess, isCoreTaskProgressTerminal, isCoreTaskProgressTerminalNotSuccess } from '../terminalStatuses.js';
@@ -15,7 +15,7 @@ import { readToolHistoryMismatchKey } from '../toolHistoryMismatch.js';
15
15
  import { isMintedRowCcError, readProviderRejectionResendKey } from '../providerRejection.js';
16
16
  import { rowKindOf } from '../rowKind.js';
17
17
  import { terminalCodedDetailOf } from '../runTerminal.js';
18
- import { contextUsageReadingOf, guardedRead, humanInputAttachmentsOf, ownSnapshotRecord, ownSnapshotWhenTyped, readOwnDataNonEmptyString, readOwnDataValue, promptManifestIdentityOfFrame, promptManifestSectionViewOf, readFrameStringKey, readFrameTrueMark, workflowCompletionExtrasOf } from '../ownKey.js';
18
+ import { contextUsageReadingOf, guardedRead, humanInputAttachmentsOf, humanInputAuthorKeys, ownSnapshotRecord, ownSnapshotWhenTyped, readOwnDataNonEmptyString, readOwnDataValue, promptManifestIdentityOfFrame, promptManifestSectionViewOf, readFrameStringKey, readFrameTrueMark, workflowCompletionExtrasOf } from '../ownKey.js';
19
19
  import { CORE_USER_ATTACHMENT_LABEL_MAX } from '../generated/engineFactTables.js';
20
20
  import { ESCAPE_FACE, paintAndCap, washCredentials } from '../displayUntrusted.js';
21
21
  import { resolveEnginePanelTaskId } from '../engineAgentPanelStore.js';
@@ -236,7 +236,9 @@ const userArm = function* (m, { ctx, idOf }) {
236
236
  return;
237
237
  yield transcript({ ...m, uuid: idOf(m), session_id: ctx.sessionId }, ctx.now());
238
238
  };
239
- const systemArm = function* (m, { ctx, idOf }) {
239
+ const systemArm = function* (m, { ctx, idOf, text }) {
240
+ if (readFrameStringKey(m, 'subtype') === 'compact_boundary')
241
+ text.noteModelSegmentBoundary();
240
242
  yield transcript(m, ctx.now());
241
243
  const attachedFiles = m._sema_attached_files;
242
244
  if (Array.isArray(attachedFiles)) {
@@ -325,13 +327,20 @@ const humanInputArm = function* (m) {
325
327
  ...(str(m.entryId) !== undefined ? { entryId: str(m.entryId) } : {}),
326
328
  ...(str(m.eventId) !== undefined ? { eventId: str(m.eventId) } : {}),
327
329
  ...humanInputAttachmentsForChrome(m),
330
+ ...humanInputAuthorKeys(m),
328
331
  });
329
332
  };
330
333
  function humanInputAttachmentsForChrome(m) {
331
334
  const rows = humanInputAttachmentsOf(m);
332
335
  if (rows === undefined)
333
336
  return {};
334
- return { attachments: rows.map((r) => (r.label !== undefined ? { ...r, label: paintAndCap(r.label, ESCAPE_FACE, CORE_USER_ATTACHMENT_LABEL_MAX) } : r)) };
337
+ return {
338
+ attachments: rows.map((r) => ({
339
+ ...r,
340
+ ...(r.label !== undefined ? { label: paintAndCap(r.label, ESCAPE_FACE, CORE_USER_ATTACHMENT_LABEL_MAX) } : {}),
341
+ ...(r.declinedBy !== undefined ? { declinedBy: { kind: r.declinedBy.kind, name: paintAndCap(r.declinedBy.name, ESCAPE_FACE, CORE_USER_ATTACHMENT_LABEL_MAX) } } : {}),
342
+ })),
343
+ };
335
344
  }
336
345
  const messageCommittedArm = function* (m) {
337
346
  if (typeof m.parentToolCallId === 'string')
@@ -623,6 +632,7 @@ const textSegmentEndArm = function* (m, { text }) {
623
632
  if (content.length === 0)
624
633
  return;
625
634
  text.anchorWindow(m);
635
+ yield* text.admitEndOnlyBlock(content, m);
626
636
  const r = text.replaceAnswerSegment(content, m);
627
637
  yield* text.drainLive();
628
638
  yield chrome({
@@ -677,8 +687,9 @@ const toolEndResultArm = function* (m, deps) {
677
687
  const structured = ownSnapshotWhenTyped(m.structured, 'task-output');
678
688
  if (callId !== undefined) {
679
689
  const launched = readAsyncLaunchedAgentReceipt(structured);
680
- if (launched !== null)
681
- registerSubagentContentAlias(callId, launched.taskId);
690
+ if (launched !== null && applySubagentAlias(callId, launched.taskId, 'content') !== 'rejected') {
691
+ yield chrome({ kind: 'subagent_alias', laneProof: { lane: 'subagent', parentToolCallId: callId }, parentToolCallId: callId, taskId: launched.taskId, scope: 'content' });
692
+ }
682
693
  }
683
694
  if (callId !== undefined && isUnsettledHeldToolEnd(m)) {
684
695
  const held = cards.detach(callId);
@@ -769,8 +780,12 @@ const taskProgressArm = function* (m, { ctx, cards, panel, inst }) {
769
780
  }));
770
781
  return;
771
782
  }
772
- if (explicitParent !== undefined)
773
- registerSubagentAlias(explicitParent, taskId);
783
+ if (explicitParent !== undefined) {
784
+ const aliasSeq = cycleSeqValue(m.seq);
785
+ if (applySubagentAlias(explicitParent, taskId, 'full', aliasSeq) !== 'rejected') {
786
+ yield chrome({ kind: 'subagent_alias', laneProof: { lane: 'subagent', parentToolCallId: explicitParent }, parentToolCallId: explicitParent, taskId, scope: 'full', ...(aliasSeq !== undefined ? { seq: aliasSeq } : {}) });
787
+ }
788
+ }
774
789
  const cardId = panel.bind(taskId, explicitParent);
775
790
  const usage = (m.usage ?? {});
776
791
  ctx.probe?.('tick', JSON.stringify({
@@ -18,6 +18,8 @@ interface ThinkingSegmentReplacement {
18
18
  }
19
19
  export interface TextStream {
20
20
  feedText(delta: string, frame: Frame): Generator<AdapterOutput>;
21
+ admitEndOnlyBlock(content: string, frame: Frame): Generator<AdapterOutput>;
22
+ noteModelSegmentBoundary(): void;
21
23
  feedThinking(delta: string, frame: Frame): Generator<AdapterOutput>;
22
24
  drainLive(): Generator<AdapterOutput>;
23
25
  takeThinking(): Generator<AdapterOutput>;
@@ -39,6 +39,10 @@ export function createTextStream(ctx, idOf) {
39
39
  let segmentCommitted = '';
40
40
  let previousSegmentCommitted = '';
41
41
  let segmentWindowCloseArmed = false;
42
+ let wholeBlockDelivered = false;
43
+ const closeWholeBlockMark = () => {
44
+ wholeBlockDelivered = false;
45
+ };
42
46
  const flushEveryMs = typeof ctx.coalesceIntervalMs === 'number' && ctx.coalesceIntervalMs >= 0
43
47
  ? ctx.coalesceIntervalMs
44
48
  : FLUSH_INTERVAL_MS;
@@ -122,6 +126,7 @@ export function createTextStream(ctx, idOf) {
122
126
  }
123
127
  function* takeAnswerSegment() {
124
128
  idleFlushUsedInSegment = false;
129
+ closeWholeBlockMark();
125
130
  yield* emitAnswerSegment();
126
131
  previousSegmentCommitted += segmentCommitted;
127
132
  segmentCommitted = '';
@@ -166,23 +171,37 @@ export function createTextStream(ctx, idOf) {
166
171
  textPending = '';
167
172
  }
168
173
  }
174
+ function* feedText(delta, frame) {
175
+ if (delta.length === 0 && segmentWindowCloseArmed && previousSegmentCommitted + segmentCommitted !== '')
176
+ return;
177
+ consumeArmedClose();
178
+ if (thinking.length > 0 || thinkingPending.length > 0) {
179
+ yield* drainLive();
180
+ yield* takeThinking();
181
+ }
182
+ if (answerSegment.length === 0)
183
+ segmentAnchor = frame;
184
+ segmentLast = frame;
185
+ openSegmentWindow(frame);
186
+ answer += delta;
187
+ answerSegment += delta;
188
+ textPending += delta;
189
+ }
190
+ function* admitEndOnlyBlock(content, frame) {
191
+ if (content.length === 0 || wholeBlockDelivered)
192
+ return;
193
+ const verdict = resolveTextSegmentAuthority(content, {
194
+ committedPrefix: previousSegmentCommitted + segmentCommitted,
195
+ openSegment: answerSegment,
196
+ });
197
+ if (verdict.form !== 'untouched')
198
+ return;
199
+ yield* feedText(content, frame);
200
+ }
169
201
  return {
170
- *feedText(delta, frame) {
171
- if (delta.length === 0 && segmentWindowCloseArmed && previousSegmentCommitted + segmentCommitted !== '')
172
- return;
173
- consumeArmedClose();
174
- if (thinking.length > 0 || thinkingPending.length > 0) {
175
- yield* drainLive();
176
- yield* takeThinking();
177
- }
178
- if (answerSegment.length === 0)
179
- segmentAnchor = frame;
180
- segmentLast = frame;
181
- openSegmentWindow(frame);
182
- answer += delta;
183
- answerSegment += delta;
184
- textPending += delta;
185
- },
202
+ feedText,
203
+ admitEndOnlyBlock,
204
+ noteModelSegmentBoundary: closeWholeBlockMark,
186
205
  *feedThinking(delta, frame) {
187
206
  if (thinkingSettled) {
188
207
  if (thinking.length > 0) {
@@ -335,6 +354,8 @@ export function createTextStream(ctx, idOf) {
335
354
  emittedAssistantText = true;
336
355
  if (typeof committed === 'string')
337
356
  committedText += committed;
357
+ if (typeof committed === 'string' && committed.length > 0)
358
+ wholeBlockDelivered = true;
338
359
  },
339
360
  replaceThinkingSegment: (content, anchor) => {
340
361
  const rows = committedThinking;
@@ -1231,7 +1231,7 @@ function activeRunSelfHealBaseRow(outcome, wayOut, following = false, keepSessio
1231
1231
  if (outcome.rowVerdict !== undefined) {
1232
1232
  return say(lang, 'session.selfHeal.row.askReopenFailed.rowUnresumable', {
1233
1233
  taskId: outcome.taskId,
1234
- sentence: checkpointRowBarSentence(outcome.rowVerdict),
1234
+ sentence: checkpointRowBarSentence(outcome.rowVerdict, lang),
1235
1235
  unbound: rowBarWayOutContent(outcome.rowVerdict, outcome.rowDeadline ?? 'unknown', lang),
1236
1236
  });
1237
1237
  }
@@ -5,7 +5,7 @@ import { ccToolDenialKindForToolEnd, gateOutcomeOf, toolInputRewriteOf } from '.
5
5
  import { projectToolRoster, projectToolRosterDelta } from '../../toolRoster.js';
6
6
  import { projectHandsSection } from '../../handsSeam.js';
7
7
  import { readMcpAuthorization, readMcpLiveness } from '../../mcpLiveness.js';
8
- import { contextUsageReadingOf, humanInputAttachmentsOf, guardedRead, markMcpSectionDroppedNamedRows, ownSnapshotTyped, promptManifestIdentityOfFrame, promptManifestSectionViewOf, readFrameStringKey, readFrameTrueMark, readOwnDataFiniteNumber, readOwnDataNonEmptyString, workflowCompletionExtrasOf } from '../../ownKey.js';
8
+ import { contextUsageReadingOf, humanInputAttachmentsOf, humanInputAuthorKeys, guardedRead, markMcpSectionDroppedNamedRows, ownSnapshotTyped, promptManifestIdentityOfFrame, promptManifestSectionViewOf, readFrameStringKey, readFrameTrueMark, readOwnDataFiniteNumber, readOwnDataNonEmptyString, workflowCompletionExtrasOf } from '../../ownKey.js';
9
9
  import { SEGMENT_END_IDENTITY_KEYS, eventSeq, stripToolUseSideChannels } from '../types.js';
10
10
  import { frozenSet } from '../../frozenSet.js';
11
11
  import { isCoreWorkflowRunTerminal } from '../../terminalStatuses.js';
@@ -954,6 +954,7 @@ function humanInputProjection(ev, ctx) {
954
954
  ...(str(ev.eventId) !== undefined ? { eventId: str(ev.eventId) } : {}),
955
955
  ...(str(ev.parentToolCallId) !== undefined ? { parentToolCallId: str(ev.parentToolCallId) } : {}),
956
956
  ...attachmentsKey(humanInputAttachmentsOf(ev)),
957
+ ...humanInputAuthorKeys(ev),
957
958
  })));
958
959
  }
959
960
  function attachmentsKey(rows) {
@@ -77,6 +77,7 @@ function readRow(v) {
77
77
  const description = Object.hasOwn(o, 'description') ? o.description : undefined;
78
78
  const createdAt = Object.hasOwn(o, 'createdAt') ? o.createdAt : undefined;
79
79
  const childSessionId = type === 'background_agent' ? guardedRead(() => readOwnDataValue(o, 'sessionId')) : undefined;
80
+ const retained = guardedRead(() => readOwnDataValue(o, 'retained')) === true;
80
81
  return {
81
82
  id,
82
83
  type,
@@ -84,6 +85,7 @@ function readRow(v) {
84
85
  ...(typeof description === 'string' && description.length > 0 ? { description } : {}),
85
86
  ...(typeof createdAt === 'number' && Number.isFinite(createdAt) ? { createdAt } : {}),
86
87
  ...(typeof childSessionId === 'string' && childSessionId.length > 0 ? { sessionId: childSessionId } : {}),
88
+ ...(retained ? { retained: true } : {}),
87
89
  };
88
90
  }
89
91
  export async function readEngineAgentRegistry(client, sessionId, capsBaseUrl, opts) {
@@ -8,3 +8,15 @@ export interface BashExitReading {
8
8
  }
9
9
  export declare function bashExitOf(structured: unknown, parseFrame: () => BashFrameExit | null): BashExitReading;
10
10
  export declare function bashExitReadingFailed(r: BashExitReading): boolean;
11
+ export type BashCurtailmentKind = 'timedOut' | 'livenessNoOutput' | 'aborted' | 'callbackError';
12
+ export interface BashCurtailment {
13
+ readonly kind: BashCurtailmentKind;
14
+ readonly timeoutSec?: number;
15
+ readonly noOutputSec?: number;
16
+ }
17
+ export declare function bashCurtailmentOf(structured: unknown): BashCurtailment | undefined;
18
+ export declare function bashCurtailmentSentence(c: BashCurtailment): string;
19
+ export declare function bashCurtailedResultPart(stderr: string, c: BashCurtailment | undefined): {
20
+ stderr: string;
21
+ _sema_curtailed?: BashCurtailment;
22
+ };
@@ -1,3 +1,4 @@
1
+ import { guardedRead, readOwnDataValue } from './ownKey.js';
1
2
  export function bashExitOf(structured, parseFrame) {
2
3
  const s = typeof structured === 'object' && structured !== null ? structured : undefined;
3
4
  const interp = typeof s?.returnCodeInterpretation === 'string' && s.returnCodeInterpretation.length > 0 ? s.returnCodeInterpretation : undefined;
@@ -10,3 +11,46 @@ export function bashExitOf(structured, parseFrame) {
10
11
  export function bashExitReadingFailed(r) {
11
12
  return r.exitCode !== null && r.exitCode !== 0 && r.benignNote === undefined;
12
13
  }
14
+ export function bashCurtailmentOf(structured) {
15
+ if (typeof structured !== 'object' || structured === null)
16
+ return undefined;
17
+ const own = (key) => guardedRead(() => readOwnDataValue(structured, key));
18
+ if (own('type') !== 'bash')
19
+ return undefined;
20
+ const secOf = (key) => {
21
+ const v = own(key);
22
+ return typeof v === 'number' && Number.isSafeInteger(v) && v >= 0 ? (v === 0 ? 0 : v) : undefined;
23
+ };
24
+ if (own('timedOut') === true) {
25
+ const timeoutSec = secOf('timeoutSec');
26
+ return timeoutSec === undefined ? { kind: 'timedOut' } : { kind: 'timedOut', timeoutSec };
27
+ }
28
+ if (own('livenessNoOutput') === true) {
29
+ const noOutputSec = secOf('noOutputSec');
30
+ return noOutputSec === undefined ? { kind: 'livenessNoOutput' } : { kind: 'livenessNoOutput', noOutputSec };
31
+ }
32
+ if (own('aborted') === true)
33
+ return { kind: 'aborted' };
34
+ if (own('callbackError') === true)
35
+ return { kind: 'callbackError' };
36
+ return undefined;
37
+ }
38
+ export function bashCurtailmentSentence(c) {
39
+ switch (c.kind) {
40
+ case 'timedOut':
41
+ return c.timeoutSec === undefined ? 'Command timed out' : `Command timed out after ${c.timeoutSec}s`;
42
+ case 'livenessNoOutput':
43
+ return c.noOutputSec === undefined ? 'Command killed: no output' : `Command killed: no output for ${c.noOutputSec}s`;
44
+ case 'aborted':
45
+ return 'Command was interrupted';
46
+ case 'callbackError':
47
+ return 'Command ended: output stream failed';
48
+ }
49
+ }
50
+ export function bashCurtailedResultPart(stderr, c) {
51
+ if (c === undefined)
52
+ return { stderr };
53
+ const sentence = bashCurtailmentSentence(c);
54
+ const alreadyLeads = stderr.startsWith(sentence) && stderr.charAt(sentence.length).trim() === '';
55
+ return { stderr: stderr.length === 0 ? sentence : alreadyLeads ? stderr : `${sentence} ${stderr}`, _sema_curtailed: { ...c } };
56
+ }
@@ -27,7 +27,7 @@ export type CheckpointRowBar = Exclude<CheckpointRowVerdictReading, {
27
27
  }>;
28
28
  export declare function checkpointRowBarOf(row: object | null | undefined): CheckpointRowBar | undefined;
29
29
  export declare const CHECKPOINT_ROW_BAR_SENTENCE: string;
30
- export declare function checkpointRowBarSentence(bar: CheckpointRowBar): string;
30
+ export declare function checkpointRowBarSentence(bar: CheckpointRowBar, lang?: UiLanguage | (string & {})): string;
31
31
  export type CheckpointDeadlineState = 'armed' | 'none' | 'unknown';
32
32
  export declare function checkpointDeadlineStateOf(row: object | null | undefined): CheckpointDeadlineState;
33
33
  export declare function unboundWayOutContent(state: CheckpointDeadlineState, lang?: UiLanguage | (string & {})): string;
@@ -94,8 +94,10 @@ export function checkpointRowBarOf(row) {
94
94
  return v === undefined || v.kind === 'ok' ? undefined : v;
95
95
  }
96
96
  export const CHECKPOINT_ROW_BAR_SENTENCE = renderMessage(msg('approval.rowUnresumable.fallback'));
97
- export function checkpointRowBarSentence(bar) {
98
- return bar.kind !== 'unreadable' && typeof bar.sentence === 'string' && bar.sentence !== '' ? bar.sentence : CHECKPOINT_ROW_BAR_SENTENCE;
97
+ export function checkpointRowBarSentence(bar, lang) {
98
+ return bar.kind !== 'unreadable' && typeof bar.sentence === 'string' && bar.sentence !== ''
99
+ ? bar.sentence
100
+ : renderMessage(msg('approval.rowUnresumable.fallback'), isUiLanguage(lang) ? lang : undefined);
99
101
  }
100
102
  export function checkpointDeadlineStateOf(row) {
101
103
  try {
@@ -118,7 +118,7 @@ export const MIGRATED_COMPENSATIONS = [
118
118
  id: 'T49',
119
119
  what: 'subagent alias 只能在 tick 上学 —— content 帧只带 parentToolCallId、没有 taskId',
120
120
  disposition: 'in-library',
121
- libraryHalf: 'adapt.ts task_progress 臂 registerSubagentAlias(explicitParent, taskId)',
121
+ libraryHalf: 'adapt.ts task_progress 臂 applySubagentAlias(explicitParent, taskId, \'full\')(与 registerSubagentAlias 同一实现)',
122
122
  chromeArm: null,
123
123
  hostHalf: null,
124
124
  retireOn: 'RL-40',
@@ -56,6 +56,7 @@ export interface EngineAgentRegistryRowView {
56
56
  readonly description?: string;
57
57
  readonly createdAt?: number;
58
58
  readonly sessionId?: string;
59
+ readonly retained?: true;
59
60
  }
60
61
  export type EngineAgentRegistryUnavailableWhy = 'no_list_face' | 'capability_unknown' | 'route_absent' | 'ownership_required' | 'read_failed';
61
62
  export type EngineAgentRegistryListing = {
@@ -75,6 +76,7 @@ export interface EngineAgentRegistryReadingOptions {
75
76
  readonly sessionId?: string;
76
77
  }
77
78
  export declare function engineAgentRegistryReadingOf(listing: EngineAgentRegistryListing | null | undefined, registryKey: string | null | undefined, opts?: EngineAgentRegistryReadingOptions | null): EngineAgentRegistryReading;
79
+ export declare function localEngineSessionShellsOf(listings: readonly (EngineAgentRegistryListing | null | undefined)[]): number | 'unknown';
78
80
  export interface EngineAgentRegistryMissingRow {
79
81
  readonly id: string;
80
82
  readonly status: string;
@@ -214,6 +214,34 @@ function readingFromRecord(rec, registryKey, opts) {
214
214
  const single = ownOpt(opts, 'singleReplica');
215
215
  return single.given && single.value === true && REGISTRY_AGENT_HANDLE_RE.test(registryKey) ? 'not_listed' : 'unknown';
216
216
  }
217
+ const SESSION_SHELL_TYPES = new Set(Object.keys({ background_bash: true, monitor: true }));
218
+ export function localEngineSessionShellsOf(listings) {
219
+ try {
220
+ if (!Array.isArray(listings))
221
+ return 'unknown';
222
+ let count = 0;
223
+ for (let i = 0; i < listings.length; i++) {
224
+ if (!Object.hasOwn(listings, i))
225
+ return 'unknown';
226
+ const rec = registryListingProvenanceOf(listings[i]);
227
+ if (rec === undefined || rec.superseded || rec.rawRowCount >= REGISTRY_LIST_LIMIT)
228
+ return 'unknown';
229
+ for (const r of rec.rows) {
230
+ if (!SESSION_SHELL_TYPES.has(r.type) || r.retained === true)
231
+ continue;
232
+ const reading = registryStatusReading(r.status);
233
+ if (reading === 'unknown')
234
+ return 'unknown';
235
+ if (reading === 'running')
236
+ count++;
237
+ }
238
+ }
239
+ return count;
240
+ }
241
+ catch {
242
+ return 'unknown';
243
+ }
244
+ }
217
245
  function keySetOf(v) {
218
246
  if (v instanceof Set)
219
247
  return (k) => v.has(k);
@@ -49,6 +49,10 @@ export declare const ATTACHMENT_BUNDLE_SEED_FIXED = "attachment.bundle_seed_fixe
49
49
  export declare const ATTACHMENT_BOUND_ELSEWHERE = "attachment.bound_elsewhere";
50
50
  export declare const CONFLICT_SESSION_MEMORY_UNOBSERVED = "conflict.session_memory_unobserved";
51
51
  export declare const CONFLICT_SESSION_ARCHIVE_STAMPED = "conflict.session_archive_stamped";
52
+ export declare const REQUEST_ENV_CREDENTIAL_REFUSED = "request.env_credential_refused";
53
+ export declare const CONFLICT_SESSION_ID_RETIRED = "conflict.session_id_retired";
54
+ export declare const LIMIT_RATE_EXCEEDED = "limit.rate_exceeded";
55
+ export declare const RATE_EXCEEDED_RUN_CONCURRENCY_CAP = "run_concurrency_cap";
52
56
  export declare const GATE_PARKED_ERROR_CODE = "gate.parked";
53
57
  export declare const ACTIVE_RUN_BUSY_ERROR_CODE = "conflict.session_active_run";
54
58
  export declare const CONFLICT_IDEMPOTENCY_PAYLOAD_MISMATCH = "conflict.idempotency_payload_mismatch";
@@ -73,6 +73,10 @@ export const ATTACHMENT_BUNDLE_SEED_FIXED = 'attachment.bundle_seed_fixed';
73
73
  export const ATTACHMENT_BOUND_ELSEWHERE = 'attachment.bound_elsewhere';
74
74
  export const CONFLICT_SESSION_MEMORY_UNOBSERVED = 'conflict.session_memory_unobserved';
75
75
  export const CONFLICT_SESSION_ARCHIVE_STAMPED = 'conflict.session_archive_stamped';
76
+ export const REQUEST_ENV_CREDENTIAL_REFUSED = 'request.env_credential_refused';
77
+ export const CONFLICT_SESSION_ID_RETIRED = 'conflict.session_id_retired';
78
+ export const LIMIT_RATE_EXCEEDED = 'limit.rate_exceeded';
79
+ export const RATE_EXCEEDED_RUN_CONCURRENCY_CAP = 'run_concurrency_cap';
76
80
  export const GATE_PARKED_ERROR_CODE = 'gate.parked';
77
81
  export const ACTIVE_RUN_BUSY_ERROR_CODE = 'conflict.session_active_run';
78
82
  export const CONFLICT_IDEMPOTENCY_PAYLOAD_MISMATCH = 'conflict.idempotency_payload_mismatch';
@@ -8,6 +8,7 @@ export interface EngineHealthAuthFacts {
8
8
  readonly required: boolean;
9
9
  readonly kinds: readonly (HealthAuthKind | (string & {}))[];
10
10
  readonly identityAttach: 'available' | 'unavailable';
11
+ readonly serviceTokenActsForDeployment?: boolean;
11
12
  }
12
13
  export interface EngineHealthDrainingFacts {
13
14
  readonly actionId: string;
@@ -17,6 +18,19 @@ export interface EngineHealthDrainingFacts {
17
18
  export interface EngineHealthLeaseFacts {
18
19
  readonly lingerMs: number;
19
20
  readonly tickMs: number;
21
+ readonly firstAttach?: EngineHealthFirstAttachFacts;
22
+ }
23
+ export interface EngineHealthFirstAttachFacts {
24
+ readonly windowMs: number;
25
+ readonly since: number;
26
+ readonly attachedAt: number | null;
27
+ }
28
+ export interface EngineHealthInflightFacts {
29
+ readonly total: number;
30
+ readonly http?: number;
31
+ readonly leader?: number;
32
+ readonly sessionResident?: number;
33
+ readonly backgroundAgents?: number;
20
34
  }
21
35
  export interface EngineHealthFacts {
22
36
  readonly center?: EngineHealthCenterFacts;
@@ -24,5 +38,8 @@ export interface EngineHealthFacts {
24
38
  readonly operator?: 'present' | 'absent';
25
39
  readonly draining?: EngineHealthDrainingFacts;
26
40
  readonly engineLease?: EngineHealthLeaseFacts;
41
+ readonly inflight?: EngineHealthInflightFacts;
42
+ readonly version?: string;
43
+ readonly dataRoot?: string;
27
44
  }
28
45
  export declare function readEngineHealthFacts(health: object | null | undefined): EngineHealthFacts;
@@ -1,5 +1,5 @@
1
1
  import { readOwnDataValue } from './ownKey.js';
2
- const _healthFactsMatchSdk = [true, true, true, true, true, true];
2
+ const _healthFactsMatchSdk = [true, true, true, true, true, true, true, true, true, true];
3
3
  void _healthFactsMatchSdk;
4
4
  const ENGINE_SIGNAL_KEY = 'engineSignal';
5
5
  function isObject(v) {
@@ -51,7 +51,10 @@ function authOf(raw) {
51
51
  return undefined;
52
52
  kinds.push(word);
53
53
  }
54
- return Object.freeze({ required, kinds: Object.freeze(kinds), identityAttach });
54
+ const actsRaw = readOwnDataValue(raw, 'serviceTokenActsForDeployment');
55
+ if (actsRaw !== undefined && typeof actsRaw !== 'boolean')
56
+ return undefined;
57
+ return Object.freeze({ required, kinds: Object.freeze(kinds), identityAttach, ...(typeof actsRaw === 'boolean' ? { serviceTokenActsForDeployment: actsRaw } : {}) });
55
58
  }
56
59
  function drainingOf(health) {
57
60
  const signal = readOwnDataValue(health, ENGINE_SIGNAL_KEY);
@@ -67,6 +70,17 @@ function drainingOf(health) {
67
70
  return undefined;
68
71
  return Object.freeze({ actionId, since, deadlineAt });
69
72
  }
73
+ function firstAttachOf(raw) {
74
+ if (!isObject(raw))
75
+ return undefined;
76
+ const windowMs = epochMs(readOwnDataValue(raw, 'windowMs'));
77
+ const since = epochMs(readOwnDataValue(raw, 'since'));
78
+ const attachedRaw = readOwnDataValue(raw, 'attachedAt');
79
+ const attachedAt = attachedRaw === null ? null : epochMs(attachedRaw);
80
+ if (windowMs === undefined || since === undefined || attachedAt === undefined)
81
+ return undefined;
82
+ return Object.freeze({ windowMs, since, attachedAt });
83
+ }
70
84
  function leaseOf(raw) {
71
85
  if (!isObject(raw))
72
86
  return undefined;
@@ -74,7 +88,26 @@ function leaseOf(raw) {
74
88
  const tickMs = epochMs(readOwnDataValue(raw, 'tickMs'));
75
89
  if (lingerMs === undefined || tickMs === undefined)
76
90
  return undefined;
77
- return Object.freeze({ lingerMs, tickMs });
91
+ const firstRaw = readOwnDataValue(raw, 'firstAttach');
92
+ const firstAttach = firstRaw === undefined ? undefined : firstAttachOf(firstRaw);
93
+ if (firstRaw !== undefined && firstAttach === undefined)
94
+ return undefined;
95
+ return Object.freeze({ lingerMs, tickMs, ...(firstAttach !== undefined ? { firstAttach } : {}) });
96
+ }
97
+ function inflightOf(health) {
98
+ const total = epochMs(readOwnDataValue(health, 'inflight'));
99
+ if (total === undefined)
100
+ return undefined;
101
+ const raw = guarded(() => readOwnDataValue(health, 'inflightBreakdown'));
102
+ const parts = {};
103
+ if (isObject(raw)) {
104
+ for (const key of ['http', 'leader', 'sessionResident', 'backgroundAgents']) {
105
+ const v = guarded(() => epochMs(readOwnDataValue(raw, key)));
106
+ if (v !== undefined)
107
+ parts[key] = v;
108
+ }
109
+ }
110
+ return Object.freeze({ total, ...parts });
78
111
  }
79
112
  function guarded(read) {
80
113
  try {
@@ -93,11 +126,17 @@ export function readEngineHealthFacts(health) {
93
126
  const operator = operatorRaw === 'present' || operatorRaw === 'absent' ? operatorRaw : undefined;
94
127
  const draining = guarded(() => drainingOf(health));
95
128
  const engineLease = guarded(() => leaseOf(readOwnDataValue(health, 'engineLease')));
129
+ const inflight = guarded(() => inflightOf(health));
130
+ const version = guarded(() => nonEmptyString(readOwnDataValue(health, 'version')));
131
+ const dataRoot = guarded(() => nonEmptyString(readOwnDataValue(health, 'dataRoot')));
96
132
  return Object.freeze({
97
133
  ...(center !== undefined ? { center } : {}),
98
134
  ...(auth !== undefined ? { auth } : {}),
99
135
  ...(operator !== undefined ? { operator } : {}),
100
136
  ...(draining !== undefined ? { draining } : {}),
101
137
  ...(engineLease !== undefined ? { engineLease } : {}),
138
+ ...(inflight !== undefined ? { inflight } : {}),
139
+ ...(version !== undefined ? { version } : {}),
140
+ ...(dataRoot !== undefined ? { dataRoot } : {}),
102
141
  });
103
142
  }