@sema-agent/client-core 0.95.0 → 0.97.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 (233) hide show
  1. package/CHANGELOG.md +269 -0
  2. package/README.md +61 -31
  3. package/dist/adapt/arms.js +7 -1
  4. package/dist/adapt/toolCards.d.ts +1 -0
  5. package/dist/adapt/toolCards.js +16 -3
  6. package/dist/adapt/wireShapes.js +2 -16
  7. package/dist/adapter/activeRunSelfHeal.d.ts +4 -2
  8. package/dist/adapter/activeRunSelfHeal.js +32 -6
  9. package/dist/adapter/downstream/eventToSdkMessage.js +11 -3
  10. package/dist/adapter/downstream/terminalToSdkResult.js +14 -11
  11. package/dist/adapter/runStream.js +30 -47
  12. package/dist/agentSession/backgroundView.js +2 -15
  13. package/dist/agentSession/engineAgentRegistryRead.js +5 -4
  14. package/dist/agentSession/engineSessionBackgroundStop.js +22 -15
  15. package/dist/agentsWireCaps.d.ts +1 -1
  16. package/dist/agentsWireCaps.js +29 -12
  17. package/dist/approvalDecidedByCapability.d.ts +2 -0
  18. package/dist/approvalDecidedByCapability.js +0 -1
  19. package/dist/approvalsStreamLiveCapability.d.ts +2 -0
  20. package/dist/approvalsStreamLiveCapability.js +3 -2
  21. package/dist/attachmentSeatCapability.d.ts +2 -0
  22. package/dist/attachmentSeatCapability.js +0 -1
  23. package/dist/callerCwdCapability.d.ts +2 -4
  24. package/dist/callerCwdCapability.js +0 -7
  25. package/dist/centerWiringCapability.d.ts +2 -4
  26. package/dist/centerWiringCapability.js +4 -9
  27. package/dist/classifierVerdictWire.js +4 -16
  28. package/dist/clientSlice.js +1 -1
  29. package/dist/cloudConfigWireCaps.d.ts +4 -4
  30. package/dist/cloudConfigWireCaps.js +241 -85
  31. package/dist/coreValuePorts.d.ts +11 -7
  32. package/dist/coreValuePorts.js +5 -8
  33. package/dist/credentialProvenance.d.ts +28 -0
  34. package/dist/credentialProvenance.js +76 -0
  35. package/dist/decideFailureNote.js +3 -1
  36. package/dist/decideReceipt.js +7 -10
  37. package/dist/declared/supportFloorDeclared.js +3 -3
  38. package/dist/deviceExecutorManagementCapability.d.ts +2 -0
  39. package/dist/deviceExecutorManagementCapability.js +3 -2
  40. package/dist/displayUntrusted.d.ts +10 -3
  41. package/dist/displayUntrusted.js +371 -60
  42. package/dist/engineCapReader.d.ts +8 -2
  43. package/dist/engineCapReader.js +15 -7
  44. package/dist/engineCapsCache.d.ts +17 -3
  45. package/dist/engineCapsCache.js +268 -43
  46. package/dist/engineDirectory.d.ts +79 -0
  47. package/dist/engineDirectory.js +186 -0
  48. package/dist/engineErrorCodes.d.ts +17 -1
  49. package/dist/engineErrorCodes.js +46 -16
  50. package/dist/engineNoticeCodes.d.ts +17 -0
  51. package/dist/engineNoticeCodes.js +54 -1
  52. package/dist/executionLaneCapability.d.ts +2 -0
  53. package/dist/executionLaneCapability.js +3 -2
  54. package/dist/fileHistoryCaptureCapability.d.ts +16 -0
  55. package/dist/fileHistoryCaptureCapability.js +98 -2
  56. package/dist/fileHistoryLegNotice.js +4 -0
  57. package/dist/fleet/bgSubagentRow.d.ts +15 -0
  58. package/dist/fleet/bgSubagentRow.js +67 -0
  59. package/dist/fleet/fleetLedger.d.ts +1 -0
  60. package/dist/fleet/fleetLedger.js +164 -126
  61. package/dist/fleet/fleetProjection.d.ts +1 -0
  62. package/dist/fleet/fleetProjection.js +10 -3
  63. package/dist/fleetTaskDesc.js +4 -17
  64. package/dist/gateOutcome.d.ts +12 -1
  65. package/dist/gateOutcome.js +56 -1
  66. package/dist/gateVocabulary.d.ts +2 -2
  67. package/dist/gateVocabulary.js +4 -3
  68. package/dist/generated/engineAskFaceTables.js +1 -1
  69. package/dist/generated/engineFactTables.d.ts +5 -3
  70. package/dist/generated/engineFactTables.js +17 -4
  71. package/dist/generated/engineNoticeTables.js +12 -3
  72. package/dist/generated/sdkFactTables.d.ts +2 -0
  73. package/dist/generated/sdkFactTables.js +7 -0
  74. package/dist/generated/settingsSchemaFns.d.ts +3 -0
  75. package/dist/generated/settingsSchemaFns.js +53 -0
  76. package/dist/generated/toolNameTables.d.ts +1 -1
  77. package/dist/generated/toolNameTables.js +1 -42
  78. package/dist/hitl/approvalDecisionNoteAudit.js +2 -2
  79. package/dist/hitl/approvalEndingCause.d.ts +2 -0
  80. package/dist/hitl/approvalEndingCause.js +26 -21
  81. package/dist/hitl/approvalHolds.d.ts +16 -1
  82. package/dist/hitl/approvalHolds.js +52 -12
  83. package/dist/hitl/askGateWire.js +1 -0
  84. package/dist/hitl/askParkRowRouting.js +1 -1
  85. package/dist/hitl/automaticAnswerVerdict.d.ts +1 -1
  86. package/dist/hitl/automaticAnswerVerdict.js +13 -10
  87. package/dist/hitl/decisionConflict.js +4 -5
  88. package/dist/hitl/decisionRefusal.d.ts +8 -0
  89. package/dist/hitl/decisionRefusal.js +55 -14
  90. package/dist/hitl/frameRouter.d.ts +3 -1
  91. package/dist/hitl/frameRouter.js +58 -39
  92. package/dist/hitl/gateLedger.d.ts +0 -5
  93. package/dist/hitl/gateLedger.js +0 -21
  94. package/dist/hitl/hitlBridge.d.ts +6 -2
  95. package/dist/hitl/hitlBridge.js +46 -11
  96. package/dist/hitl/localAllowRule.d.ts +1 -0
  97. package/dist/hitl/localAllowRule.js +2 -2
  98. package/dist/hitl/noAllowCause.d.ts +2 -1
  99. package/dist/hitl/noAllowCause.js +3 -2
  100. package/dist/hitl/parkResolver.d.ts +1 -0
  101. package/dist/hitl/parkResolver.js +14 -56
  102. package/dist/hitl/parkRowBirthWait.d.ts +1 -0
  103. package/dist/hitl/parkRowBirthWait.js +2 -2
  104. package/dist/hitl/planReviewWire.d.ts +1 -0
  105. package/dist/hitl/planReviewWire.js +98 -20
  106. package/dist/hitl/replayedApproval.d.ts +3 -3
  107. package/dist/hitl/replayedApproval.js +21 -16
  108. package/dist/hitl/sessionPolicyDeliverable.d.ts +0 -1
  109. package/dist/hitl/sessionPolicyDeliverable.js +17 -17
  110. package/dist/hitl/sessionPolicyWire.d.ts +2 -0
  111. package/dist/hitl/sessionPolicyWire.js +15 -3
  112. package/dist/hitl/standingRows.d.ts +19 -0
  113. package/dist/hitl/standingRows.js +148 -0
  114. package/dist/hitl/suspendedReopen.js +2 -1
  115. package/dist/hitl/toolApprovalWire.d.ts +22 -10
  116. package/dist/hitl/toolApprovalWire.js +286 -47
  117. package/dist/hookMatcherVerdict.d.ts +1 -9
  118. package/dist/hookMatcherVerdict.js +21 -61
  119. package/dist/hooksWireCaps.js +2 -2
  120. package/dist/hostCallbackGuard.d.ts +1 -0
  121. package/dist/hostCallbackGuard.js +6 -0
  122. package/dist/index.d.ts +26 -12
  123. package/dist/index.js +20 -10
  124. package/dist/liveModelCatalog.d.ts +13 -0
  125. package/dist/liveModelCatalog.js +56 -0
  126. package/dist/mcpProbeCapability.d.ts +2 -4
  127. package/dist/mcpProbeCapability.js +3 -8
  128. package/dist/mcpWireCaps.d.ts +1 -0
  129. package/dist/mcpWireCaps.js +4 -1
  130. package/dist/memoryComplianceCapability.d.ts +2 -4
  131. package/dist/memoryComplianceCapability.js +3 -8
  132. package/dist/memoryOriginCapability.d.ts +2 -4
  133. package/dist/memoryOriginCapability.js +3 -8
  134. package/dist/memorySpecWire.js +2 -2
  135. package/dist/modelIdentityResolvability.d.ts +2 -2
  136. package/dist/modelIdentityResolvability.js +14 -5
  137. package/dist/noticePresentation.d.ts +68 -0
  138. package/dist/noticePresentation.js +247 -0
  139. package/dist/outputStyleSeatCapability.d.ts +2 -1
  140. package/dist/outputStyleSeatCapability.js +0 -4
  141. package/dist/ownKey.d.ts +2 -0
  142. package/dist/ownKey.js +18 -0
  143. package/dist/peerFrames.js +13 -9
  144. package/dist/peerLaneCapability.d.ts +2 -0
  145. package/dist/peerLaneCapability.js +3 -2
  146. package/dist/permissionModesCapability.d.ts +2 -4
  147. package/dist/permissionModesCapability.js +0 -7
  148. package/dist/permissionRuleIssue.js +0 -3
  149. package/dist/permissionRulesWriteCapability.d.ts +2 -0
  150. package/dist/permissionRulesWriteCapability.js +3 -2
  151. package/dist/permissionsAllowGrantCapability.d.ts +2 -0
  152. package/dist/permissionsAllowGrantCapability.js +4 -2
  153. package/dist/permissionsDeclaration.d.ts +2 -0
  154. package/dist/permissionsDeclaration.js +72 -59
  155. package/dist/printPermissionOutcome.d.ts +12 -0
  156. package/dist/printPermissionOutcome.js +50 -0
  157. package/dist/printToolResultFrame.d.ts +1 -0
  158. package/dist/printToolResultFrame.js +5 -9
  159. package/dist/promptBlockedCopy.d.ts +5 -0
  160. package/dist/promptBlockedCopy.js +35 -0
  161. package/dist/protocolSegment.d.ts +9 -6
  162. package/dist/protocolSegment.js +31 -21
  163. package/dist/providerRejection.d.ts +4 -0
  164. package/dist/providerRejection.js +75 -14
  165. package/dist/replayBody.d.ts +12 -0
  166. package/dist/replayBody.js +25 -0
  167. package/dist/request/taskRequest.d.ts +1 -4
  168. package/dist/request/taskRequest.js +74 -19
  169. package/dist/resumeRefusalCopy.js +9 -25
  170. package/dist/retryStatus.d.ts +9 -1
  171. package/dist/retryStatus.js +9 -2
  172. package/dist/rewindArchiveCapability.d.ts +3 -13
  173. package/dist/rewindArchiveCapability.js +12 -58
  174. package/dist/rewindArchiveReading.d.ts +17 -0
  175. package/dist/rewindArchiveReading.js +55 -0
  176. package/dist/ruleCompileVerdict.d.ts +9 -1
  177. package/dist/ruleCompileVerdict.js +29 -4
  178. package/dist/runTerminal.d.ts +48 -5
  179. package/dist/runTerminal.js +215 -12
  180. package/dist/sandboxWire.js +13 -0
  181. package/dist/sdkWireTransit.d.ts +2 -1
  182. package/dist/sdkWireTransit.js +1 -0
  183. package/dist/sealedKeyCapability.d.ts +2 -4
  184. package/dist/sealedKeyCapability.js +0 -7
  185. package/dist/seam.js +4 -2
  186. package/dist/seatContract.d.ts +76 -11
  187. package/dist/seatContract.js +222 -27
  188. package/dist/sessionPolicyCapability.d.ts +2 -0
  189. package/dist/sessionPolicyCapability.js +3 -2
  190. package/dist/sessionReadRedactionCapability.d.ts +2 -4
  191. package/dist/sessionReadRedactionCapability.js +0 -7
  192. package/dist/sessionSyncFileHistory.d.ts +4 -0
  193. package/dist/sessionSyncFileHistory.js +66 -0
  194. package/dist/sessionSyncFileHistoryCapability.d.ts +2 -1
  195. package/dist/sessionSyncFileHistoryCapability.js +3 -5
  196. package/dist/skillToolListsCapability.d.ts +2 -1
  197. package/dist/skillToolListsCapability.js +3 -5
  198. package/dist/sqlEngineCapability.d.ts +2 -0
  199. package/dist/sqlEngineCapability.js +4 -3
  200. package/dist/steerPriorityCapability.d.ts +2 -1
  201. package/dist/steerPriorityCapability.js +3 -5
  202. package/dist/storePostureCapability.d.ts +2 -4
  203. package/dist/storePostureCapability.js +4 -9
  204. package/dist/subagent/engineSubagentSteer.js +7 -5
  205. package/dist/subagentContentStore.js +4 -15
  206. package/dist/supportFloor.d.ts +1 -0
  207. package/dist/supportFloor.js +13 -9
  208. package/dist/systemReminderTag.d.ts +1 -0
  209. package/dist/systemReminderTag.js +8 -0
  210. package/dist/toolHistoryBadTurn.js +3 -2
  211. package/dist/toolHistoryMismatch.d.ts +0 -3
  212. package/dist/toolHistoryMismatch.js +3 -7
  213. package/dist/toolResult.d.ts +12 -1
  214. package/dist/toolResult.js +55 -1
  215. package/dist/toolResultContent.d.ts +2 -0
  216. package/dist/toolResultContent.js +63 -0
  217. package/dist/usageAnalytics.js +40 -16
  218. package/dist/userInvokedSkillsCapability.d.ts +2 -1
  219. package/dist/userInvokedSkillsCapability.js +3 -5
  220. package/dist/webSearchBackendCapability.d.ts +2 -0
  221. package/dist/webSearchBackendCapability.js +3 -2
  222. package/dist/wireErrorTriage.d.ts +2 -0
  223. package/dist/wireErrorTriage.js +91 -38
  224. package/dist/wireFailureShape.d.ts +20 -3
  225. package/dist/wireFailureShape.js +128 -72
  226. package/dist/workflowsJournalCapability.d.ts +2 -0
  227. package/dist/workflowsJournalCapability.js +3 -2
  228. package/dist/writeProtectionCapability.d.ts +2 -0
  229. package/dist/writeProtectionCapability.js +3 -2
  230. package/docs/INTEGRATION-CLIENTS.md +1784 -20
  231. package/package.json +5 -5
  232. package/dist/engineRefusedToolName.d.ts +0 -1
  233. package/dist/engineRefusedToolName.js +0 -8
@@ -1,5 +1,5 @@
1
1
  import { engineWireTarget } from './engineWireTarget.js';
2
- import { createEngineCapReader } from './engineCapReader.js';
2
+ import { createEngineCapReader, unreadableReadingDetail } from './engineCapReader.js';
3
3
  import { ownDataField } from './ownKey.js';
4
4
  export function projectSessionPolicyCapability(caps) {
5
5
  try {
@@ -20,7 +20,6 @@ export function projectSessionPolicyCapability(caps) {
20
20
  const reader = createEngineCapReader({
21
21
  name: 'sessionPolicy',
22
22
  project: projectSessionPolicyCapability,
23
- makeUnobserved: () => ({ kind: 'unobserved' }),
24
23
  });
25
24
  export function noteEngineCapsForSessionPolicy(baseUrl, caps, opts) {
26
25
  reader.note(baseUrl, caps, opts);
@@ -37,6 +36,8 @@ export function sessionPolicyFaceAvailable(reading) {
37
36
  }
38
37
  export function sessionPolicyDoctorDetail(reading) {
39
38
  switch (reading.kind) {
39
+ case 'unreadable':
40
+ return unreadableReadingDetail('per-session rule face');
40
41
  case 'unobserved':
41
42
  return 'per-session rule face not observed — the engine reports it on /v1/capabilities (sessionPolicy); this process has no usable capabilities reading cached for it (none received, the last one was unreadable, or the last one was discarded when the engine connection was reset; this process cannot tell which)';
42
43
  case 'not_reported':
@@ -1,5 +1,7 @@
1
1
  export type SessionReadRedactionReading = {
2
2
  kind: 'unobserved';
3
+ } | {
4
+ kind: 'unreadable';
3
5
  } | {
4
6
  kind: 'not_reported';
5
7
  } | {
@@ -7,9 +9,5 @@ export type SessionReadRedactionReading = {
7
9
  value: true;
8
10
  };
9
11
  export declare function projectSessionReadRedactionCapability(caps: unknown): SessionReadRedactionReading | undefined;
10
- export declare function noteEngineCapsForSessionReadRedaction(baseUrl: string, caps: unknown, opts?: {
11
- generation?: number;
12
- }): void;
13
12
  export declare function observedSessionReadRedaction(baseUrl?: string | undefined): SessionReadRedactionReading;
14
13
  export declare function sessionReadRedactionAdmitted(reading: SessionReadRedactionReading | undefined): boolean;
15
- export declare function __resetSessionReadRedactionReadingsForTests(): void;
@@ -17,11 +17,7 @@ export function projectSessionReadRedactionCapability(caps) {
17
17
  const reader = createEngineCapReader({
18
18
  name: 'sessionReadRedaction',
19
19
  project: projectSessionReadRedactionCapability,
20
- makeUnobserved: () => ({ kind: 'unobserved' }),
21
20
  });
22
- export function noteEngineCapsForSessionReadRedaction(baseUrl, caps, opts) {
23
- reader.note(baseUrl, caps, opts);
24
- }
25
21
  export function observedSessionReadRedaction(baseUrl = engineWireTarget()?.baseUrl) {
26
22
  return reader.observed(baseUrl);
27
23
  }
@@ -37,6 +33,3 @@ export function sessionReadRedactionAdmitted(reading) {
37
33
  return false;
38
34
  }
39
35
  }
40
- export function __resetSessionReadRedactionReadingsForTests() {
41
- reader.__resetForTests();
42
- }
@@ -0,0 +1,4 @@
1
+ export declare const FILE_HISTORY_SKIPPED_NOTICE: string;
2
+ export declare function fileHistorySyncNotice(result: unknown): string | undefined;
3
+ export declare function fileHistorySyncNoticeIdentity(result: unknown): string | undefined;
4
+ export declare function isFileHistoryBlobMissing(err: unknown): boolean;
@@ -0,0 +1,66 @@
1
+ import { NOT_FOUND_BLOB } from './engineErrorCodes.js';
2
+ import { effectiveWireErrorCode } from './wireErrorTriage.js';
3
+ import { readThrownSlot } from './wireFailureShape.js';
4
+ export const FILE_HISTORY_SKIPPED_NOTICE = 'File history was not copied: only the conversation was synced, because one of the two engines does not confirm that it can ' +
5
+ 'transfer file history (the record /rewind uses to restore files). Syncing this session again will not add it until ' +
6
+ 'the conversation has new turns and both engines can transfer file history.';
7
+ function getOwn(o, key) {
8
+ return Object.hasOwn(o, key) ? o[key] : undefined;
9
+ }
10
+ function envelopeSaidEmpty(result) {
11
+ try {
12
+ const manifest = getOwn(result, 'manifest');
13
+ if (manifest === null || typeof manifest !== 'object')
14
+ return false;
15
+ const fh = getOwn(manifest, 'fileHistory');
16
+ if (fh === null || typeof fh !== 'object')
17
+ return false;
18
+ const tracked = getOwn(fh, 'tracked');
19
+ const boundaries = getOwn(fh, 'boundaries');
20
+ return Array.isArray(tracked) && tracked.length === 0 && Array.isArray(boundaries) && boundaries.length === 0;
21
+ }
22
+ catch {
23
+ return false;
24
+ }
25
+ }
26
+ export function fileHistorySyncNotice(result) {
27
+ if (result === null || typeof result !== 'object')
28
+ return undefined;
29
+ try {
30
+ if (getOwn(result, 'fileHistory') !== 'skipped')
31
+ return undefined;
32
+ return envelopeSaidEmpty(result) ? undefined : FILE_HISTORY_SKIPPED_NOTICE;
33
+ }
34
+ catch {
35
+ return undefined;
36
+ }
37
+ }
38
+ export function fileHistorySyncNoticeIdentity(result) {
39
+ if (fileHistorySyncNotice(result) === undefined)
40
+ return undefined;
41
+ try {
42
+ const manifest = getOwn(result, 'manifest');
43
+ if (manifest === null || typeof manifest !== 'object')
44
+ return undefined;
45
+ const sessionId = getOwn(manifest, 'sessionId');
46
+ const leafId = getOwn(manifest, 'leafId');
47
+ if (typeof sessionId !== 'string' || sessionId === '' || typeof leafId !== 'string' || leafId === '')
48
+ return undefined;
49
+ return JSON.stringify([sessionId, leafId]);
50
+ }
51
+ catch {
52
+ return undefined;
53
+ }
54
+ }
55
+ export function isFileHistoryBlobMissing(err) {
56
+ if (typeof err !== 'object' || err === null)
57
+ return false;
58
+ try {
59
+ if (readThrownSlot(err, 'status') !== 404)
60
+ return false;
61
+ return effectiveWireErrorCode(err) === NOT_FOUND_BLOB;
62
+ }
63
+ catch {
64
+ return false;
65
+ }
66
+ }
@@ -1,5 +1,7 @@
1
1
  export type SessionSyncFileHistoryReading = {
2
2
  kind: 'unobserved';
3
+ } | {
4
+ kind: 'unreadable';
3
5
  } | {
4
6
  kind: 'not_reported';
5
7
  } | {
@@ -14,4 +16,3 @@ export declare function noteEngineCapsForSessionSyncFileHistory(baseUrl: string,
14
16
  export declare function observedSessionSyncFileHistory(baseUrl?: string | undefined): SessionSyncFileHistoryReading;
15
17
  export declare function sessionSyncFileHistoryAvailable(reading: SessionSyncFileHistoryReading): 'yes' | 'no' | 'unknown';
16
18
  export declare function sessionSyncFileHistoryDoctorDetail(reading: SessionSyncFileHistoryReading): string;
17
- export declare function __resetSessionSyncFileHistoryReadingsForTests(): void;
@@ -1,5 +1,5 @@
1
1
  import { engineWireTarget } from './engineWireTarget.js';
2
- import { createEngineCapReader } from './engineCapReader.js';
2
+ import { createEngineCapReader, unreadableReadingDetail } from './engineCapReader.js';
3
3
  import { ownDataField } from './ownKey.js';
4
4
  export function projectSessionSyncFileHistoryCapability(caps) {
5
5
  try {
@@ -19,7 +19,6 @@ export function projectSessionSyncFileHistoryCapability(caps) {
19
19
  const reader = createEngineCapReader({
20
20
  name: 'sessionSyncFileHistory',
21
21
  project: projectSessionSyncFileHistoryCapability,
22
- makeUnobserved: () => ({ kind: 'unobserved' }),
23
22
  });
24
23
  export function noteEngineCapsForSessionSyncFileHistory(baseUrl, caps, opts) {
25
24
  reader.note(baseUrl, caps, opts);
@@ -36,6 +35,8 @@ export function sessionSyncFileHistoryAvailable(reading) {
36
35
  }
37
36
  export function sessionSyncFileHistoryDoctorDetail(reading) {
38
37
  switch (reading.kind) {
38
+ case 'unreadable':
39
+ return unreadableReadingDetail('session-sync file history');
39
40
  case 'unobserved':
40
41
  return 'session-sync file history not observed — the engine reports it on /v1/capabilities (sessionSyncFileHistory); this process has no usable capabilities reading cached for it (none received, the last one was unreadable, or the last one was discarded when the engine connection was reset; this process cannot tell which)';
41
42
  case 'not_reported':
@@ -46,6 +47,3 @@ export function sessionSyncFileHistoryDoctorDetail(reading) {
46
47
  return 'session-sync file history on — syncing a session can also move its edited-file history';
47
48
  }
48
49
  }
49
- export function __resetSessionSyncFileHistoryReadingsForTests() {
50
- reader.__resetForTests();
51
- }
@@ -1,5 +1,7 @@
1
1
  export type SkillToolListsReading = {
2
2
  kind: 'unobserved';
3
+ } | {
4
+ kind: 'unreadable';
3
5
  } | {
4
6
  kind: 'not_reported';
5
7
  } | {
@@ -14,4 +16,3 @@ export declare function noteEngineCapsForSkillToolLists(baseUrl: string, caps: u
14
16
  export declare function observedSkillToolLists(baseUrl?: string | undefined): SkillToolListsReading;
15
17
  export declare function skillToolListsAvailable(reading: SkillToolListsReading): 'yes' | 'no' | 'unknown';
16
18
  export declare function skillToolListsDoctorDetail(reading: SkillToolListsReading): string;
17
- export declare function __resetSkillToolListsReadingsForTests(): void;
@@ -1,5 +1,5 @@
1
1
  import { engineWireTarget } from './engineWireTarget.js';
2
- import { createEngineCapReader } from './engineCapReader.js';
2
+ import { createEngineCapReader, unreadableReadingDetail } from './engineCapReader.js';
3
3
  import { ownDataField } from './ownKey.js';
4
4
  export function projectSkillToolListsCapability(caps) {
5
5
  try {
@@ -19,7 +19,6 @@ export function projectSkillToolListsCapability(caps) {
19
19
  const reader = createEngineCapReader({
20
20
  name: 'skillToolLists',
21
21
  project: projectSkillToolListsCapability,
22
- makeUnobserved: () => ({ kind: 'unobserved' }),
23
22
  });
24
23
  export function noteEngineCapsForSkillToolLists(baseUrl, caps, opts) {
25
24
  reader.note(baseUrl, caps, opts);
@@ -36,6 +35,8 @@ export function skillToolListsAvailable(reading) {
36
35
  }
37
36
  export function skillToolListsDoctorDetail(reading) {
38
37
  switch (reading.kind) {
38
+ case 'unreadable':
39
+ return unreadableReadingDetail('skill tool lists');
39
40
  case 'unobserved':
40
41
  return 'skill tool lists not observed — the engine reports it on /v1/capabilities (skillToolLists); this process has no usable capabilities reading cached for it (none received, the last one was unreadable, or the last one was discarded when the engine connection was reset; this process cannot tell which)';
41
42
  case 'not_reported':
@@ -46,6 +47,3 @@ export function skillToolListsDoctorDetail(reading) {
46
47
  return 'skill tool lists on — a request skill’s allowed and disallowed tool lists are read as this run’s rules';
47
48
  }
48
49
  }
49
- export function __resetSkillToolListsReadingsForTests() {
50
- reader.__resetForTests();
51
- }
@@ -5,6 +5,8 @@ export interface SqlEngineCapabilityView {
5
5
  }
6
6
  export type SqlEngineReading = {
7
7
  kind: 'unobserved';
8
+ } | {
9
+ kind: 'unreadable';
8
10
  } | {
9
11
  kind: 'not_reported';
10
12
  } | {
@@ -1,6 +1,6 @@
1
1
  import { capForDisplay } from './fleetTaskDesc.js';
2
2
  import { engineWireTarget } from './engineWireTarget.js';
3
- import { storeSeatOf, createEngineCapReader } from './engineCapReader.js';
3
+ import { storeSeatOf, createEngineCapReader, unreadableReadingDetail } from './engineCapReader.js';
4
4
  import { ownDataField } from './ownKey.js';
5
5
  export function projectSqlEngineCapability(caps) {
6
6
  try {
@@ -16,7 +16,7 @@ export function projectSqlEngineCapability(caps) {
16
16
  return { kind: 'none' };
17
17
  return projectSqlEngineView(nested);
18
18
  }
19
- return { kind: 'not_reported' };
19
+ return seat.kind === 'absent' ? { kind: 'not_reported' } : undefined;
20
20
  }
21
21
  catch {
22
22
  return undefined;
@@ -39,7 +39,6 @@ function projectSqlEngineView(sql) {
39
39
  const reader = createEngineCapReader({
40
40
  name: 'sql',
41
41
  project: projectSqlEngineCapability,
42
- makeUnobserved: () => ({ kind: 'unobserved' }),
43
42
  });
44
43
  export function noteEngineCapsForSqlEngine(baseUrl, caps, opts) {
45
44
  reader.note(baseUrl, caps, opts);
@@ -53,6 +52,8 @@ function cleanSqlDetailScalar(v) {
53
52
  }
54
53
  export function sqlEngineDoctorDetail(reading) {
55
54
  switch (reading.kind) {
55
+ case 'unreadable':
56
+ return unreadableReadingDetail();
56
57
  case 'unobserved':
57
58
  return ('not observed — the engine reports it on /v1/capabilities; this process has no usable ' +
58
59
  'capabilities reading cached for it (none received, the last one was unreadable, or the last one was discarded when the engine connection was reset; this process cannot tell which)');
@@ -1,5 +1,7 @@
1
1
  export type SteerPriorityReading = {
2
2
  kind: 'unobserved';
3
+ } | {
4
+ kind: 'unreadable';
3
5
  } | {
4
6
  kind: 'not_reported';
5
7
  } | {
@@ -14,4 +16,3 @@ export declare function noteEngineCapsForSteerPriority(baseUrl: string, caps: un
14
16
  export declare function observedSteerPriority(baseUrl?: string | undefined): SteerPriorityReading;
15
17
  export declare function steerPriorityMode(reading: SteerPriorityReading): SteerPriorityMode;
16
18
  export declare function steerPriorityDoctorDetail(reading: SteerPriorityReading): string;
17
- export declare function __resetSteerPriorityReadingsForTests(): void;
@@ -1,6 +1,6 @@
1
1
  import { capForDisplay } from './fleetTaskDesc.js';
2
2
  import { engineWireTarget } from './engineWireTarget.js';
3
- import { createEngineCapReader } from './engineCapReader.js';
3
+ import { createEngineCapReader, unreadableReadingDetail } from './engineCapReader.js';
4
4
  import { ownDataField } from './ownKey.js';
5
5
  export function projectSteerPriorityCapability(caps) {
6
6
  try {
@@ -25,7 +25,6 @@ export function projectSteerPriorityCapability(caps) {
25
25
  const reader = createEngineCapReader({
26
26
  name: 'fleet.steerPriority',
27
27
  project: projectSteerPriorityCapability,
28
- makeUnobserved: () => ({ kind: 'unobserved' }),
29
28
  });
30
29
  export function noteEngineCapsForSteerPriority(baseUrl, caps, opts) {
31
30
  reader.note(baseUrl, caps, opts);
@@ -65,6 +64,8 @@ export function steerPriorityDoctorDetail(reading) {
65
64
  if (kind === 'not_reported') {
66
65
  return 'steer priority not reported by this engine — its capabilities reading carries no fleet.steerPriority (the fleet face is not reported, or the face carries no such field; this client cannot tell which), so a "now" or "later" steer is not sent (steers without a priority work as before)';
67
66
  }
67
+ if (kind === 'unreadable')
68
+ return unreadableReadingDetail('steer priority');
68
69
  if (kind !== 'present' || typeof word !== 'string' || word.length === 0)
69
70
  return unobserved;
70
71
  if (word === 'engine')
@@ -74,6 +75,3 @@ export function steerPriorityDoctorDetail(reading) {
74
75
  }
75
76
  return `steer priority reported as "${capForDisplay(word, WORD_DETAIL_MAX)}" — a value this client does not know yet, so whether it is applied is unknown and a "now" or "later" steer is not sent`;
76
77
  }
77
- export function __resetSteerPriorityReadingsForTests() {
78
- reader.__resetForTests();
79
- }
@@ -8,6 +8,8 @@ export interface StorePostureView {
8
8
  }
9
9
  export type StorePostureReading = {
10
10
  kind: 'unobserved';
11
+ } | {
12
+ kind: 'unreadable';
11
13
  } | {
12
14
  kind: 'not_reported';
13
15
  } | {
@@ -15,11 +17,7 @@ export type StorePostureReading = {
15
17
  view: StorePostureView;
16
18
  };
17
19
  export declare function projectStorePostureCapability(caps: unknown): StorePostureReading | undefined;
18
- export declare function noteEngineCapsForStorePosture(baseUrl: string, caps: unknown, opts?: {
19
- generation?: number;
20
- }): void;
21
20
  export declare function observedStorePosture(baseUrl?: string | undefined): StorePostureReading;
22
21
  export declare function storePersistence(reading: StorePostureReading): 'durable' | 'not_durable' | 'unknown';
23
22
  export declare function storePostureHeadWord(reading: StorePostureReading): string | undefined;
24
23
  export declare function storePostureDoctorDetail(reading: StorePostureReading): string;
25
- export declare function __resetStorePostureReadingsForTests(): void;
@@ -1,6 +1,6 @@
1
1
  import { capForDisplay } from './fleetTaskDesc.js';
2
2
  import { engineWireTarget } from './engineWireTarget.js';
3
- import { storeSeatOf, createEngineCapReader } from './engineCapReader.js';
3
+ import { storeSeatOf, createEngineCapReader, unreadableReadingDetail } from './engineCapReader.js';
4
4
  import { projectSqlEngineCapability } from './sqlEngineCapability.js';
5
5
  import { ownDataField } from './ownKey.js';
6
6
  const nonEmpty = (v) => typeof v === 'string' && v !== '';
@@ -44,11 +44,7 @@ function projectStorePostureOf(caps) {
44
44
  const reader = createEngineCapReader({
45
45
  name: 'store',
46
46
  project: projectStorePostureCapability,
47
- makeUnobserved: () => ({ kind: 'unobserved' }),
48
47
  });
49
- export function noteEngineCapsForStorePosture(baseUrl, caps, opts) {
50
- reader.note(baseUrl, caps, opts);
51
- }
52
48
  export function observedStorePosture(baseUrl = engineWireTarget()?.baseUrl) {
53
49
  return reader.observed(baseUrl);
54
50
  }
@@ -57,7 +53,7 @@ function presentView(reading) {
57
53
  return undefined;
58
54
  try {
59
55
  const kind = reading.kind;
60
- if (kind === 'not_reported' || kind === 'unobserved')
56
+ if (kind === 'not_reported' || kind === 'unobserved' || kind === 'unreadable')
61
57
  return { kind };
62
58
  if (kind !== 'present')
63
59
  return undefined;
@@ -92,6 +88,8 @@ const word = (v) => capForDisplay(v, WORD_DETAIL_MAX);
92
88
  export function storePostureDoctorDetail(reading) {
93
89
  const unobserved = 'store posture not observed — the engine reports it on /v1/capabilities; this process has no usable capabilities reading cached for it, so whether this deployment persists its state is unknown';
94
90
  const r = presentView(reading);
91
+ if (r?.kind === 'unreadable')
92
+ return unreadableReadingDetail('store posture');
95
93
  if (r?.kind === 'not_reported') {
96
94
  return 'store posture not reported by this engine; this does not say whether this deployment persists its state';
97
95
  }
@@ -127,6 +125,3 @@ export function storePostureDoctorDetail(reading) {
127
125
  }
128
126
  return `${assembled} — ${lost} (degraded for a reason this client does not know yet: "${word(reason)}")`;
129
127
  }
130
- export function __resetStorePostureReadingsForTests() {
131
- reader.__resetForTests();
132
- }
@@ -5,6 +5,7 @@ import { resolveOwnerContext, resolveOwnerRunId } from './engineSubagentResume.j
5
5
  import { noteBgOwnerAbsence } from './subagentOwnerAbsence.js';
6
6
  import { errCodes, steeringRefusedBeforeEngine } from '../controlRouter.js';
7
7
  import { ownNonEmptyStringOf } from '../steerReceipt.js';
8
+ import { wireFailureTextsOf } from '../wireFailureShape.js';
8
9
  function usableSteerClient(client) {
9
10
  return clientHasVerbs(client, [['runs', 'steerSubagent']]);
10
11
  }
@@ -53,14 +54,14 @@ export async function steerEngineSubagent(target, text, childTaskId, opts) {
53
54
  status = undefined;
54
55
  }
55
56
  if (status !== undefined) {
56
- const detail = e instanceof Error ? e.message : String(e);
57
- hostLog('debug', `engineSubagentSteer: ${status} ${detail.slice(0, 200)}`);
57
+ const texts = wireFailureTextsOf(e);
58
+ hostLog('debug', `engineSubagentSteer: ${status} ${texts.log.slice(0, 200)}`);
58
59
  const refused = typeof e === 'object' && e !== null ? steeringRefusedBeforeEngine(e) : undefined;
59
60
  if (refused !== undefined && refused.safety === 'ledger_unavailable') {
60
61
  return { ok: false, reason: 'not-delivered', safety: refused.safety, detail: refused.advice };
61
62
  }
62
63
  if (status === 409 || status === 404) {
63
- return { ok: false, reason: 'not-running', detail };
64
+ return { ok: false, reason: 'not-running', detail: texts.reason };
64
65
  }
65
66
  return { ok: false, reason: 'error', detail: `${status}` };
66
67
  }
@@ -69,7 +70,8 @@ export async function steerEngineSubagent(target, text, childTaskId, opts) {
69
70
  hostLog('debug', `engineSubagentSteer: may have been received, no answer — ${noAnswer}`);
70
71
  return { ok: false, reason: 'error', detail: noAnswer, unconfirmed: true };
71
72
  }
72
- hostLog('debug', `engineSubagentSteer: fetch failed ${String(e)}`);
73
- return { ok: false, reason: 'error', detail: String(e) };
73
+ const texts = wireFailureTextsOf(e);
74
+ hostLog('debug', `engineSubagentSteer: fetch failed ${texts.log}`);
75
+ return { ok: false, reason: 'error', detail: texts.reason };
74
76
  }
75
77
  }
@@ -1,22 +1,11 @@
1
1
  import { DEFAULT_SESSION_KEY } from './sessionSlot.js';
2
+ import { toolEndOutputText } from './toolResultContent.js';
2
3
  export function coerceOutput(v) {
3
4
  if (v === undefined || v === null)
4
5
  return undefined;
5
- if (typeof v === 'string')
6
- return v;
7
- if (Array.isArray(v)) {
8
- const parts = [];
9
- for (const block of v) {
10
- if (block && typeof block === 'object') {
11
- const b = block;
12
- if (b.type === 'text' && typeof b.text === 'string')
13
- parts.push(b.text);
14
- else if (b.type === 'image')
15
- parts.push('[image]');
16
- }
17
- }
18
- return parts.join('');
19
- }
6
+ const text = toolEndOutputText(v);
7
+ if (text !== undefined)
8
+ return text;
20
9
  try {
21
10
  return JSON.stringify(v);
22
11
  }
@@ -8,4 +8,5 @@ export declare const SUPPORT_FLOOR: Readonly<SupportFloor>;
8
8
  export declare function supportFloorOf(component: unknown): string | undefined;
9
9
  export type EngineVersionTier = 'engine' | 'legacy' | 'unknown';
10
10
  export declare function engineVersionTier(version: unknown, floor?: string): EngineVersionTier;
11
+ export declare function engineSupportFloorEffective(floor?: string): string;
11
12
  export declare function coreVersionTier(version: unknown, floor?: string): EngineVersionTier;
@@ -11,7 +11,8 @@ function releaseTriple(v) {
11
11
  const m = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/.exec(v);
12
12
  if (m === null)
13
13
  return undefined;
14
- return [Number(m[1]), Number(m[2]), Number(m[3])];
14
+ const t = [Number(m[1]), Number(m[2]), Number(m[3])];
15
+ return t.every(Number.isSafeInteger) ? t : undefined;
15
16
  }
16
17
  function compareTriple(a, b) {
17
18
  for (let i = 0; i < 3; i++) {
@@ -22,28 +23,31 @@ function compareTriple(a, b) {
22
23
  }
23
24
  return 0;
24
25
  }
25
- function versionTierAgainst(version, base, floor, caller) {
26
+ function judgeAgainst(version, base, floor, caller) {
26
27
  const baseTriple = releaseTriple(base);
27
28
  if (baseTriple === undefined) {
28
29
  throw new TypeError(`${caller}: 门槛只接受纯 x.y.z 版本串(整串、无前导零、无前后缀)—— 收到 typeof=${base === null ? 'null' : typeof base}。错误文本只报形状,不回显值。`);
29
30
  }
30
- let need = baseTriple;
31
+ let need = { triple: baseTriple, text: base };
31
32
  if (floor !== undefined) {
32
33
  const own = releaseTriple(floor);
33
34
  if (own === undefined) {
34
35
  throw new TypeError(`${caller}: floor 只接受纯 x.y.z 版本串(整串、无前导零、无前后缀)或缺席 —— 收到 typeof=${floor === null ? 'null' : typeof floor}。错误文本只报形状,不回显值。`);
35
36
  }
36
- if (compareTriple(own, need) > 0)
37
- need = own;
37
+ if (compareTriple(own, need.triple) > 0)
38
+ need = { triple: own, text: floor };
38
39
  }
39
40
  const got = releaseTriple(version);
40
41
  if (got === undefined)
41
- return 'unknown';
42
- return compareTriple(got, need) >= 0 ? 'engine' : 'legacy';
42
+ return { need: need.text, tier: 'unknown' };
43
+ return { need: need.text, tier: compareTriple(got, need.triple) >= 0 ? 'engine' : 'legacy' };
43
44
  }
44
45
  export function engineVersionTier(version, floor) {
45
- return versionTierAgainst(version, SUPPORT_FLOOR.server, floor, 'engineVersionTier');
46
+ return judgeAgainst(version, SUPPORT_FLOOR.server, floor, 'engineVersionTier').tier;
47
+ }
48
+ export function engineSupportFloorEffective(floor) {
49
+ return judgeAgainst(undefined, SUPPORT_FLOOR.server, floor, 'engineSupportFloorEffective').need;
46
50
  }
47
51
  export function coreVersionTier(version, floor) {
48
- return versionTierAgainst(version, SUPPORT_FLOOR.core, floor, 'coreVersionTier');
52
+ return judgeAgainst(version, SUPPORT_FLOOR.core, floor, 'coreVersionTier').tier;
49
53
  }
@@ -5,3 +5,4 @@ export interface SystemReminderOpenTagSpan {
5
5
  export declare function findSystemReminderOpenTag(text: string, from?: number): SystemReminderOpenTagSpan | null;
6
6
  export declare function unwrapSystemReminder(text: string): string;
7
7
  export declare function stripSystemReminderBlocks(text: string): string;
8
+ export declare function stripSystemReminderTagTokens(text: string): string;
@@ -39,3 +39,11 @@ export function stripSystemReminderBlocks(text) {
39
39
  }
40
40
  return pos === 0 ? text : out + text.slice(pos);
41
41
  }
42
+ const SYSTEM_REMINDER_TAG_TOKEN = /<[^A-Za-z0-9>]{0,12}system-reminder(?:[^>]{0,200}>)?/gi;
43
+ const SYSTEM_REMINDER_TAG_HEAD = /<[^A-Za-z0-9>]{0,12}system-reminder/i;
44
+ export function stripSystemReminderTagTokens(text) {
45
+ if (typeof text !== 'string')
46
+ return text;
47
+ const once = text.replace(SYSTEM_REMINDER_TAG_TOKEN, ' ');
48
+ return SYSTEM_REMINDER_TAG_HEAD.test(once) ? once.replace(/</g, '&lt;') : once;
49
+ }
@@ -1,10 +1,11 @@
1
- import { displayUntrusted } from './displayUntrusted.js';
1
+ import { displayUntrusted, markerSafeCut } from './displayUntrusted.js';
2
2
  const BAD_TURN_PREVIEW_MAX = 60;
3
3
  export function toolHistoryBadTurnSentence(promptText) {
4
4
  const text = typeof promptText === 'string' ? promptText : '';
5
5
  const washed = displayUntrusted(stripDisplayTagBlocks(text), { mark: 'dot' }).replace(/\s+/g, ' ').trim();
6
6
  const points = Array.from(washed);
7
- const preview = points.length > BAD_TURN_PREVIEW_MAX ? `${points.slice(0, BAD_TURN_PREVIEW_MAX).join('')}...` : washed;
7
+ const head = points.length > BAD_TURN_PREVIEW_MAX ? points.slice(0, BAD_TURN_PREVIEW_MAX).join('') : undefined;
8
+ const preview = head === undefined ? washed : `${washed.slice(0, markerSafeCut(washed, head.length))}...`;
8
9
  return preview.length > 0
9
10
  ? `The broken record is in the turn you started with "${preview}"; /rewind has that prompt preselected, so restore the conversation to before it.`
10
11
  : 'The broken record is in the turn /rewind has preselected; restore the conversation to before it.';
@@ -18,8 +18,6 @@ export declare const TOOL_HISTORY_MISMATCH_ANCHORS: readonly ToolHistoryMismatch
18
18
  export declare function classifyToolHistoryMismatch(err: ToolHistoryErrorCarrier | null | undefined): ToolHistoryMismatch | null;
19
19
  export declare const TOOL_HISTORY_REWIND_SENTENCE = "Run /rewind to recover the conversation.";
20
20
  export declare function toolHistoryRepeatSentence(n: number): string;
21
- type ConversationRewindVerdict = 'available' | 'unavailable' | 'unknown';
22
- export declare function _wireConversationRewindJudge(judge: (engineBaseUrl: string) => ConversationRewindVerdict): void;
23
21
  export declare function toolHistoryRewindOffered(declared: boolean | {
24
22
  readonly engineBaseUrl: string;
25
23
  } | undefined): boolean;
@@ -61,4 +59,3 @@ export type ToolHistoryRewindResolution<R> = {
61
59
  undecidable: ToolHistoryUndecidableReason;
62
60
  };
63
61
  export declare function resolveToolHistoryRewindTarget<R extends ToolHistoryRow>(rows: readonly (R | null | undefined)[] | null | undefined, mismatch: ToolHistoryMismatch | null | undefined): ToolHistoryRewindResolution<R>;
64
- export {};
@@ -1,3 +1,4 @@
1
+ import { rewindArchiveReadingAt, rewindConversationAvailability } from './rewindArchiveReading.js';
1
2
  export const TOOL_HISTORY_MISMATCH_KINDS = Object.freeze([
2
3
  'tool_use_without_result',
3
4
  'orphan_tool_result',
@@ -224,10 +225,6 @@ export const TOOL_HISTORY_REWIND_SENTENCE = 'Run /rewind to recover the conversa
224
225
  export function toolHistoryRepeatSentence(n) {
225
226
  return `The same error has now happened ${n} times in a row; /rewind is the only way to recover this conversation.`;
226
227
  }
227
- let conversationRewindJudge;
228
- export function _wireConversationRewindJudge(judge) {
229
- conversationRewindJudge = judge;
230
- }
231
228
  export function toolHistoryRewindOffered(declared) {
232
229
  const decl = declared;
233
230
  if (decl === true)
@@ -238,10 +235,9 @@ export function toolHistoryRewindOffered(declared) {
238
235
  if (Array.isArray(decl))
239
236
  return false;
240
237
  const base = decl.engineBaseUrl;
241
- const judge = conversationRewindJudge;
242
- if (typeof base !== 'string' || base.length === 0 || judge === undefined)
238
+ if (typeof base !== 'string' || base.length === 0)
243
239
  return true;
244
- return judge(base) !== 'unavailable';
240
+ return rewindConversationAvailability(rewindArchiveReadingAt(base)) !== 'unavailable';
245
241
  }
246
242
  catch {
247
243
  return true;
@@ -86,12 +86,23 @@ export declare function _resetBackgroundReceiptParseCountForTest(): void;
86
86
  export type FlattenWireOutput = (output: unknown) => string;
87
87
  export declare const TOOL_RESULT_DEGRADED_WIRE_NO_OUTPUT: "wire_carried_no_output";
88
88
  export interface ToolResultBody {
89
- content: unknown;
89
+ content: string | unknown[];
90
90
  isError: boolean;
91
91
  toolUseResult?: unknown;
92
92
  degraded?: typeof TOOL_RESULT_DEGRADED_WIRE_NO_OUTPUT;
93
93
  }
94
94
  export declare function degradedToolResultBody(isError: boolean): ToolResultBody;
95
+ export type ToolCardDegradedCause = 'not-executed' | 'error-without-detail' | 'no-result' | 'unrecognised';
96
+ export type ToolCardOutcomeReading = {
97
+ readonly kind: 'normal';
98
+ } | {
99
+ readonly kind: 'degraded';
100
+ readonly cause: ToolCardDegradedCause;
101
+ readonly text: string;
102
+ } | {
103
+ readonly kind: 'unreadable';
104
+ };
105
+ export declare function readToolCardOutcome(record: object | null | undefined): ToolCardOutcomeReading;
95
106
  export declare function wireOutputToBody(toolName: string, output: unknown, isError: boolean, truncated: boolean, flatten: FlattenWireOutput, structured?: unknown, leaderLedger?: boolean): ToolResultBody;
96
107
  export declare function structuredToToolUseResult(structured: unknown, modelText?: string, leaderLedger?: boolean): {
97
108
  toolUseResult: unknown;