@sema-agent/client-core 0.97.0 → 0.98.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 (281) hide show
  1. package/CHANGELOG.md +429 -0
  2. package/README.md +74 -36
  3. package/dist/adapt/arms.d.ts +1 -0
  4. package/dist/adapt/arms.js +128 -34
  5. package/dist/adapt/ids.d.ts +12 -1
  6. package/dist/adapt/ids.js +59 -8
  7. package/dist/adapt/instanceLedger.d.ts +50 -0
  8. package/dist/adapt/instanceLedger.js +147 -0
  9. package/dist/adapt/textStream.d.ts +1 -0
  10. package/dist/adapt/textStream.js +24 -7
  11. package/dist/adapt/toolCards.d.ts +27 -5
  12. package/dist/adapt/toolCards.js +39 -6
  13. package/dist/adapt/wireShapes.js +6 -2
  14. package/dist/adapt.d.ts +2 -0
  15. package/dist/adapt.js +8 -3
  16. package/dist/adapter/activeRunSelfHeal.d.ts +5 -0
  17. package/dist/adapter/activeRunSelfHeal.js +51 -28
  18. package/dist/adapter/downstream/eventToSdkMessage.d.ts +2 -5
  19. package/dist/adapter/downstream/eventToSdkMessage.js +27 -34
  20. package/dist/adapter/downstream/terminalToSdkResult.js +11 -4
  21. package/dist/adapter/downstream/turnUsageToModelUsage.d.ts +5 -2
  22. package/dist/adapter/downstream/turnUsageToModelUsage.js +2 -0
  23. package/dist/adapter/runStream.js +29 -13
  24. package/dist/adapter/types.d.ts +4 -4
  25. package/dist/agentSession/backgroundView.js +2 -1
  26. package/dist/agentSession/engineAgentRegistryRead.d.ts +2 -2
  27. package/dist/agentSession/engineAgentRegistryRead.js +12 -13
  28. package/dist/agentsWireCaps.d.ts +8 -6
  29. package/dist/agentsWireCaps.js +177 -162
  30. package/dist/approvalDecidedByCapability.d.ts +0 -4
  31. package/dist/approvalDecidedByCapability.js +0 -6
  32. package/dist/approvalsStreamLiveCapability.d.ts +0 -4
  33. package/dist/approvalsStreamLiveCapability.js +0 -6
  34. package/dist/assistantInbox.d.ts +34 -0
  35. package/dist/assistantInbox.js +118 -0
  36. package/dist/centerWiringCapability.js +9 -1
  37. package/dist/clientSlice.d.ts +0 -9
  38. package/dist/clientSlice.js +0 -3
  39. package/dist/cloudConfigWireCaps.d.ts +4 -2
  40. package/dist/cloudConfigWireCaps.js +81 -61
  41. package/dist/compensations.js +1 -1
  42. package/dist/connectorStatus.d.ts +21 -0
  43. package/dist/connectorStatus.js +112 -0
  44. package/dist/controlRouter.d.ts +14 -1
  45. package/dist/controlRouter.js +68 -17
  46. package/dist/coreValuePorts.d.ts +3 -3
  47. package/dist/decideReceipt.d.ts +2 -2
  48. package/dist/decideReceipt.js +5 -2
  49. package/dist/declared/supportFloorDeclared.js +3 -3
  50. package/dist/deviceExecutorManagementCapability.d.ts +0 -4
  51. package/dist/deviceExecutorManagementCapability.js +0 -6
  52. package/dist/deviceRebind.d.ts +49 -1
  53. package/dist/deviceRebind.js +221 -3
  54. package/dist/displayUntrusted.d.ts +1 -0
  55. package/dist/displayUntrusted.js +250 -76
  56. package/dist/engineAgentAbsence.d.ts +1 -1
  57. package/dist/engineAgentPanelStore.d.ts +5 -4
  58. package/dist/engineAgentPanelStore.js +3 -12
  59. package/dist/engineCapReader.d.ts +0 -4
  60. package/dist/engineCapReader.js +1 -5
  61. package/dist/engineCapsCache.d.ts +4 -0
  62. package/dist/engineCapsCache.js +17 -12
  63. package/dist/engineClosedSets.d.ts +1 -0
  64. package/dist/engineClosedSets.js +4 -1
  65. package/dist/engineErrorCodes.d.ts +9 -2
  66. package/dist/engineErrorCodes.js +9 -1
  67. package/dist/engineIdentity.d.ts +1 -0
  68. package/dist/engineIdentity.js +8 -0
  69. package/dist/engineRowRef.d.ts +28 -0
  70. package/dist/engineRowRef.js +111 -0
  71. package/dist/engineSessionMessages.d.ts +67 -0
  72. package/dist/engineSessionMessages.js +364 -0
  73. package/dist/engineToolDirectory.d.ts +18 -0
  74. package/dist/engineToolDirectory.js +85 -0
  75. package/dist/engineUrl.d.ts +18 -0
  76. package/dist/engineUrl.js +52 -0
  77. package/dist/env/uiLanguage.d.ts +9 -0
  78. package/dist/env/uiLanguage.js +35 -0
  79. package/dist/eventLeg.d.ts +92 -0
  80. package/dist/eventLeg.js +285 -0
  81. package/dist/executionLaneCapability.d.ts +0 -4
  82. package/dist/executionLaneCapability.js +3 -16
  83. package/dist/fileHistoryCaptureCapability.d.ts +0 -4
  84. package/dist/fileHistoryCaptureCapability.js +5 -7
  85. package/dist/fleet/fleetLedger.d.ts +0 -3
  86. package/dist/fleet/fleetLedger.js +21 -36
  87. package/dist/fleet/fleetProjection.d.ts +2 -2
  88. package/dist/fleet/fleetProjection.js +10 -8
  89. package/dist/frameBinding.d.ts +5 -0
  90. package/dist/frameBinding.js +23 -0
  91. package/dist/gateFailureCodes.d.ts +2 -0
  92. package/dist/gateFailureCodes.js +15 -0
  93. package/dist/gateOutcome.d.ts +3 -1
  94. package/dist/gateOutcome.js +25 -6
  95. package/dist/gateVocabulary.d.ts +5 -0
  96. package/dist/gateVocabulary.js +64 -2
  97. package/dist/generated/engineAskFaceTables.js +2 -2
  98. package/dist/generated/engineFactTables.d.ts +6 -3
  99. package/dist/generated/engineFactTables.js +22 -4
  100. package/dist/generated/engineNoticeTables.js +9 -0
  101. package/dist/generated/toolNameTables.d.ts +1 -0
  102. package/dist/generated/toolNameTables.js +1 -0
  103. package/dist/hitl/allowRuleShadow.d.ts +6 -1
  104. package/dist/hitl/allowRuleShadow.js +21 -17
  105. package/dist/hitl/approvalCardReading.d.ts +15 -0
  106. package/dist/hitl/approvalCardReading.js +154 -0
  107. package/dist/hitl/approvalCardReasons.d.ts +13 -0
  108. package/dist/hitl/approvalCardReasons.js +120 -0
  109. package/dist/hitl/approvalHolds.d.ts +47 -15
  110. package/dist/hitl/approvalHolds.js +134 -28
  111. package/dist/hitl/approvalResolution.d.ts +51 -26
  112. package/dist/hitl/approvalResolution.js +86 -122
  113. package/dist/hitl/approvalsFeed.js +6 -18
  114. package/dist/hitl/askClassPair.d.ts +2 -0
  115. package/dist/hitl/askClassPair.js +1 -0
  116. package/dist/hitl/askGateWire.d.ts +20 -2
  117. package/dist/hitl/askGateWire.js +49 -1
  118. package/dist/hitl/askParkRowRouting.d.ts +5 -0
  119. package/dist/hitl/askParkRowRouting.js +32 -1
  120. package/dist/hitl/askSettlementLine.d.ts +18 -0
  121. package/dist/hitl/askSettlementLine.js +79 -0
  122. package/dist/hitl/automaticAnswerVerdict.d.ts +1 -1
  123. package/dist/hitl/automaticAnswerVerdict.js +21 -5
  124. package/dist/hitl/crashConverged.d.ts +11 -20
  125. package/dist/hitl/crashConverged.js +56 -0
  126. package/dist/hitl/crashConvergedNotice.d.ts +3 -1
  127. package/dist/hitl/crashConvergedNotice.js +48 -11
  128. package/dist/hitl/decisionConflict.js +3 -10
  129. package/dist/hitl/decisionRefusal.d.ts +40 -1
  130. package/dist/hitl/decisionRefusal.js +199 -42
  131. package/dist/hitl/frameRouter.d.ts +5 -2
  132. package/dist/hitl/frameRouter.js +20 -16
  133. package/dist/hitl/gateLedger.d.ts +2 -0
  134. package/dist/hitl/gateLedger.js +50 -13
  135. package/dist/hitl/hitlBridge.d.ts +1 -2
  136. package/dist/hitl/hitlBridge.js +10 -7
  137. package/dist/hitl/livePendingAsk.d.ts +3 -3
  138. package/dist/hitl/livePendingAsk.js +7 -18
  139. package/dist/hitl/parkResolver.d.ts +2 -24
  140. package/dist/hitl/parkResolver.js +61 -97
  141. package/dist/hitl/persistedRulesWire.d.ts +24 -0
  142. package/dist/hitl/persistedRulesWire.js +122 -2
  143. package/dist/hitl/planReviewWire.d.ts +26 -13
  144. package/dist/hitl/planReviewWire.js +112 -78
  145. package/dist/hitl/refusedToolNameProse.d.ts +0 -1
  146. package/dist/hitl/refusedToolNameProse.js +0 -3
  147. package/dist/hitl/replayedApproval.d.ts +4 -3
  148. package/dist/hitl/replayedApproval.js +7 -4
  149. package/dist/hitl/sessionPolicyDeliverable.js +2 -4
  150. package/dist/hitl/sessionPolicyWire.d.ts +32 -20
  151. package/dist/hitl/sessionPolicyWire.js +162 -52
  152. package/dist/hitl/standingRows.d.ts +20 -2
  153. package/dist/hitl/standingRows.js +69 -8
  154. package/dist/hitl/toolApprovalWire.d.ts +87 -152
  155. package/dist/hitl/toolApprovalWire.js +591 -380
  156. package/dist/hookMatcherVerdict.d.ts +6 -1
  157. package/dist/hookMatcherVerdict.js +14 -7
  158. package/dist/hooksWireCaps.d.ts +2 -2
  159. package/dist/hooksWireCaps.js +59 -55
  160. package/dist/i18n/messages.en.d.ts +121 -0
  161. package/dist/i18n/messages.en.js +119 -0
  162. package/dist/i18n/messages.zh.d.ts +3 -0
  163. package/dist/i18n/messages.zh.js +120 -0
  164. package/dist/i18n/translate.d.ts +25 -0
  165. package/dist/i18n/translate.js +127 -0
  166. package/dist/index.d.ts +53 -18
  167. package/dist/index.js +38 -10
  168. package/dist/inheritEnvCapability.d.ts +31 -0
  169. package/dist/inheritEnvCapability.js +104 -0
  170. package/dist/liveModelCatalog.d.ts +1 -2
  171. package/dist/liveModelCatalog.js +2 -6
  172. package/dist/liveQuestionStore.d.ts +2 -21
  173. package/dist/mcpLiveness.d.ts +2 -1
  174. package/dist/mcpProbeWire.d.ts +6 -1
  175. package/dist/mcpProbeWire.js +1 -1
  176. package/dist/mcpWireCaps.d.ts +13 -2
  177. package/dist/mcpWireCaps.js +48 -0
  178. package/dist/memoryEntriesWire.d.ts +4 -9
  179. package/dist/model/modelSupplyRules.d.ts +0 -2
  180. package/dist/model/modelSupplyRules.js +3 -12
  181. package/dist/model/modelsPolicy.d.ts +0 -5
  182. package/dist/model/modelsPolicy.js +6 -36
  183. package/dist/model/subagentModelWord.d.ts +31 -0
  184. package/dist/model/subagentModelWord.js +261 -0
  185. package/dist/notifications.d.ts +6 -0
  186. package/dist/notifications.js +71 -23
  187. package/dist/outputStyleSeatCapability.d.ts +0 -3
  188. package/dist/outputStyleSeatCapability.js +0 -3
  189. package/dist/ownKey.d.ts +15 -0
  190. package/dist/ownKey.js +60 -3
  191. package/dist/panelReduce.d.ts +15 -9
  192. package/dist/panelReduce.js +680 -549
  193. package/dist/panelStateHolder.d.ts +3 -7
  194. package/dist/panelStateHolder.js +14 -130
  195. package/dist/peerLaneCapability.d.ts +0 -4
  196. package/dist/peerLaneCapability.js +0 -6
  197. package/dist/permissionRulesWriteCapability.d.ts +0 -4
  198. package/dist/permissionRulesWriteCapability.js +0 -6
  199. package/dist/permissionWireCaps.d.ts +2 -2
  200. package/dist/permissionWireCaps.js +2 -0
  201. package/dist/permissionsAllowGrantCapability.d.ts +0 -4
  202. package/dist/permissionsAllowGrantCapability.js +0 -6
  203. package/dist/permissionsDeclaration.d.ts +0 -11
  204. package/dist/permissionsDeclaration.js +60 -53
  205. package/dist/pluginHooksWire.d.ts +1 -1
  206. package/dist/pluginHooksWire.js +3 -6
  207. package/dist/preemptWire.d.ts +44 -0
  208. package/dist/preemptWire.js +83 -0
  209. package/dist/printToolResultFrame.js +15 -4
  210. package/dist/replayBody.d.ts +3 -0
  211. package/dist/replayBody.js +14 -0
  212. package/dist/request/taskRequest.d.ts +0 -1
  213. package/dist/request/taskRequest.js +0 -3
  214. package/dist/resumeRefusalCopy.d.ts +2 -1
  215. package/dist/resumeRefusalCopy.js +38 -2
  216. package/dist/retryStatus.d.ts +8 -0
  217. package/dist/retryStatus.js +106 -1
  218. package/dist/rewindArchiveCapability.d.ts +0 -4
  219. package/dist/rewindArchiveCapability.js +2 -10
  220. package/dist/rewindArchiveReading.d.ts +0 -1
  221. package/dist/rewindArchiveReading.js +0 -3
  222. package/dist/runCancelContext.d.ts +2 -1
  223. package/dist/runCancelContext.js +4 -2
  224. package/dist/runReattachPolicy.d.ts +31 -0
  225. package/dist/runReattachPolicy.js +46 -0
  226. package/dist/runTerminal.d.ts +3 -6
  227. package/dist/runTerminal.js +8 -9
  228. package/dist/sandboxWire.d.ts +3 -1
  229. package/dist/sandboxWire.js +76 -27
  230. package/dist/scenarioWire.js +1 -1
  231. package/dist/seam.d.ts +24 -2
  232. package/dist/seam.js +15 -3
  233. package/dist/seatContract.d.ts +53 -10
  234. package/dist/seatContract.js +132 -81
  235. package/dist/sessionPolicyCapability.d.ts +0 -4
  236. package/dist/sessionPolicyCapability.js +0 -6
  237. package/dist/sessionSyncFileHistoryCapability.d.ts +0 -3
  238. package/dist/sessionSyncFileHistoryCapability.js +0 -3
  239. package/dist/skillToolListsCapability.d.ts +0 -3
  240. package/dist/skillToolListsCapability.js +0 -3
  241. package/dist/sqlEngineCapability.d.ts +0 -4
  242. package/dist/sqlEngineCapability.js +0 -6
  243. package/dist/steerPriorityCapability.d.ts +0 -3
  244. package/dist/steerPriorityCapability.js +0 -3
  245. package/dist/streamDrainingLegs.d.ts +4 -0
  246. package/dist/streamDrainingLegs.js +6 -1
  247. package/dist/subagent/engineCompactWire.d.ts +0 -1
  248. package/dist/subagent/engineCompactWire.js +7 -5
  249. package/dist/subagent/engineTaskHandleWire.js +4 -7
  250. package/dist/subagentContentStore.js +1 -11
  251. package/dist/submitReopen.d.ts +24 -0
  252. package/dist/submitReopen.js +75 -0
  253. package/dist/terminalStatuses.d.ts +3 -0
  254. package/dist/terminalStatuses.js +10 -2
  255. package/dist/toolResult.d.ts +10 -1
  256. package/dist/toolResult.js +34 -6
  257. package/dist/toolRoster.d.ts +0 -2
  258. package/dist/toolRoster.js +0 -2
  259. package/dist/turnFailurePresentation.d.ts +28 -0
  260. package/dist/turnFailurePresentation.js +205 -0
  261. package/dist/userInvokedSkillsCapability.d.ts +0 -3
  262. package/dist/userInvokedSkillsCapability.js +0 -3
  263. package/dist/webSearchBackendCapability.d.ts +0 -4
  264. package/dist/webSearchBackendCapability.js +0 -6
  265. package/dist/wireErrorTriage.js +5 -24
  266. package/dist/wireFailureShape.d.ts +62 -5
  267. package/dist/wireFailureShape.js +105 -5
  268. package/dist/wireRefusalCopy.d.ts +12 -2
  269. package/dist/wireRefusalCopy.js +50 -52
  270. package/dist/workflowsJournalCapability.d.ts +0 -4
  271. package/dist/workflowsJournalCapability.js +0 -6
  272. package/dist/writeProtectionCapability.d.ts +0 -4
  273. package/dist/writeProtectionCapability.js +0 -6
  274. package/docs/INTEGRATION-CLIENTS.md +1305 -46
  275. package/package.json +5 -4
  276. package/dist/attachmentSeatCapability.d.ts +0 -12
  277. package/dist/attachmentSeatCapability.js +0 -23
  278. package/dist/hitl/approvalOutcomeNote.d.ts +0 -10
  279. package/dist/hitl/approvalOutcomeNote.js +0 -29
  280. package/dist/sessionReadRedactionCapability.d.ts +0 -13
  281. package/dist/sessionReadRedactionCapability.js +0 -35
@@ -197,7 +197,7 @@ function snapshotCapsBody(body) {
197
197
  length = ld.value;
198
198
  }
199
199
  const proto = isArray ? null : Object.getPrototypeOf(src);
200
- out = isArray ? new Array(length) : proto === Object.prototype || proto === null ? {} : Object.create(FOREIGN_PROTOTYPE);
200
+ out = isArray ? new Array(length) : isPlainRecordPrototype(proto) ? {} : Object.create(FOREIGN_PROTOTYPE);
201
201
  }
202
202
  catch {
203
203
  return UNREADABLE_NODE;
@@ -257,9 +257,6 @@ function slotInLanding(landing, key) {
257
257
  return capSlotIn(landing.caps, key);
258
258
  }
259
259
  }
260
- function capStateIn(caps, key) {
261
- return stateOfSlot(capSlotIn(caps, key));
262
- }
263
260
  function stateOfSlot(slot) {
264
261
  switch (slot.kind) {
265
262
  case 'unobserved':
@@ -293,24 +290,30 @@ async function untilSettledOrAborted(p, signal) {
293
290
  }
294
291
  }
295
292
  export async function engineCapStateVia(baseUrl, key, probe, opts) {
293
+ return stateOfSlot(await capSlotVia(baseUrl, key, probe, opts));
294
+ }
295
+ export async function engineCapValueVia(baseUrl, key, probe, opts) {
296
+ return valueStateOfSlot(await capSlotVia(baseUrl, key, probe, opts));
297
+ }
298
+ async function capSlotVia(baseUrl, key, probe, opts) {
296
299
  const signal = opts?.signal;
297
300
  if (!baseUrl) {
298
301
  try {
299
302
  if (signal?.aborted)
300
- return 'unprobed';
303
+ return SLOT_UNOBSERVED;
301
304
  const body = await probe(signal);
302
- return isPlainCapsBody(body) ? capStateIn(body, key) : 'unprobed';
305
+ return isPlainCapsBody(body) ? capSlotIn(body, key) : SLOT_UNOBSERVED;
303
306
  }
304
307
  catch {
305
- return 'unprobed';
308
+ return SLOT_UNOBSERVED;
306
309
  }
307
310
  }
308
- const now = engineCapState(baseUrl, key);
309
- if (now !== 'unprobed')
311
+ const now = slotInLanding(engineCapsLandingOf(baseUrl), key);
312
+ if (now.kind !== 'unobserved')
310
313
  return now;
311
314
  kickEngineCapsProbe(baseUrl, () => probe());
312
315
  await untilSettledOrAborted(engineCapsSettled(baseUrl, opts?.withinMs !== undefined ? { withinMs: opts.withinMs } : undefined), signal);
313
- return engineCapState(baseUrl, key);
316
+ return slotInLanding(engineCapsLandingOf(baseUrl), key);
314
317
  }
315
318
  export function engineCapTrue(baseUrl, key) {
316
319
  return engineCapState(baseUrl, key) === 'true';
@@ -424,8 +427,7 @@ function isPlainCapsBody(caps) {
424
427
  return false;
425
428
  if (Array.isArray(caps))
426
429
  return false;
427
- const proto = Object.getPrototypeOf(caps);
428
- if (proto !== null && Object.getPrototypeOf(proto) !== null)
430
+ if (!isPlainRecordPrototype(Object.getPrototypeOf(caps)))
429
431
  return false;
430
432
  for (const key of Reflect.ownKeys(caps))
431
433
  Object.getOwnPropertyDescriptor(caps, key);
@@ -435,6 +437,9 @@ function isPlainCapsBody(caps) {
435
437
  return false;
436
438
  }
437
439
  }
440
+ function isPlainRecordPrototype(proto) {
441
+ return proto === null || (typeof proto === 'object' && Object.getPrototypeOf(proto) === null);
442
+ }
438
443
  async function awaitRefreshWithin(entry, budget) {
439
444
  if (budget === undefined) {
440
445
  await entry.promise;
@@ -1,2 +1,3 @@
1
1
  export declare const ASK_EVIDENCE_ABSENCE_VALUES: readonly ["not_wired", "not_adjudicated", "unavailable", "no_match", "not_reported"];
2
2
  export declare const SYSTEM_INJECTION_PRIORITIES: readonly ["now", "next", "later"];
3
+ export declare const BUILTIN_SUBAGENT_TYPES: readonly ["Explore", "Plan", "fork", "general-purpose"];
@@ -1,3 +1,6 @@
1
- import { CORE_ASK_EVIDENCE_ABSENCE_VALUES, CORE_SYSTEM_INJECTION_PRIORITIES } from './generated/engineFactTables.js';
1
+ import { CORE_ASK_EVIDENCE_ABSENCE_VALUES, CORE_BUILTIN_SUBAGENT_TYPES, CORE_SYSTEM_INJECTION_PRIORITIES } from './generated/engineFactTables.js';
2
2
  export const ASK_EVIDENCE_ABSENCE_VALUES = CORE_ASK_EVIDENCE_ABSENCE_VALUES;
3
3
  export const SYSTEM_INJECTION_PRIORITIES = CORE_SYSTEM_INJECTION_PRIORITIES;
4
+ export const BUILTIN_SUBAGENT_TYPES = CORE_BUILTIN_SUBAGENT_TYPES;
5
+ const _builtinSubagentTypePins = [true];
6
+ void _builtinSubagentTypePins;
@@ -1,3 +1,4 @@
1
+ import type { RunDeathVerdictCode } from '@sema-agent/sdk';
1
2
  export declare const LIMITS_MAX_TOKENS_EXCEEDED = "limits.max_tokens_exceeded";
2
3
  export declare const LIMITS_MAX_COST_EXCEEDED = "limits.max_cost_exceeded";
3
4
  export declare const LIMITS_MAX_TURNS_EXCEEDED = "limits.max_turns_exceeded";
@@ -18,7 +19,8 @@ export declare const CONFIG_IMAGE_INVALID = "config.image_invalid";
18
19
  export declare function imageInvalidFailureNoteOf(code: string | undefined): string | undefined;
19
20
  export declare const CONFIG_AGENT_UNKNOWN_TOOL = "config.agent.unknown_tool";
20
21
  export declare const CONFIG_OUTPUT_STYLE_INVALID = "config.output_style_invalid";
21
- export declare const RULES_LEGACY_TOOL_NAME = "rules.legacy_tool_name";
22
+ export declare const RULES_INERT_ENTRY = "rules.inert_entry";
23
+ export declare const RULES_INVALID_SHAPE = "rules.invalid_shape";
22
24
  export declare function isRulesRefusalCode(code: string | undefined): boolean;
23
25
  export declare const DELEGATION_CONCURRENCY_CAP = "delegation.concurrency_cap";
24
26
  export declare const DELEGATION_SESSION_CAP = "delegation.session_cap";
@@ -48,6 +50,8 @@ export declare function classifyActiveRunBusy(input: {
48
50
  }): BusyClassification;
49
51
  export declare function activeRunBusyCarrierOf(ev: unknown): Record<string, unknown> | null;
50
52
  export declare const CORRUPT_SESSION_ERROR_CODE = "corrupt_session";
53
+ export declare const CORRUPT_ROW_ERROR_CODE = "corrupt";
54
+ export declare const MEMORY_CONTROL_PLANE_CORRUPT = "internal.memory_control_plane_corrupt";
51
55
  export declare function isCorruptSessionCode(code: string | null | undefined): boolean;
52
56
  export declare const STOP_PARK_ARBITER_UNREACHABLE = "stop.park_arbiter_unreachable";
53
57
  export declare const STOP_PARK_RESUME_WON = "stop.park_resume_won";
@@ -91,10 +95,13 @@ export declare const DECIDE_WORKFLOW_LANE_CODES: readonly string[];
91
95
  export declare const DECIDE_NOT_PARKED = "decide.not_parked";
92
96
  export declare const DECIDE_GATE_MOVED = "decide.gate_moved";
93
97
  export declare const DECIDE_CLAIM_LOST = "decide.claim_lost";
98
+ export declare const CONFLICT_NOT_RESUMABLE = "conflict.not_resumable";
99
+ export declare const GATE_NOT_TOOL_APPROVAL = "gate_not_tool_approval";
94
100
  export declare const DECIDE_PARK_MOVED_CODES: readonly string[];
95
101
  export declare function isDecideParkMovedCode(code: string | null | undefined): boolean;
96
102
  export declare const APPROVAL_STALE = "approval_stale";
97
103
  export declare const APPROVAL_BINDING_MISMATCH = "approval_binding_mismatch";
104
+ export declare const CHECKPOINT_INVALID_OUTCOME = "checkpoint.invalid_outcome";
98
105
  export declare const RESUME_OUTCOME_INVALID = "resume_outcome_invalid";
99
106
  export declare const CHECKPOINT_ALREADY_RESOLVED = "checkpoint.already_resolved";
100
107
  export declare const NOT_FOUND_APPROVAL = "not_found.approval";
@@ -106,7 +113,7 @@ export declare const ASK_GONE = "gone.ask";
106
113
  export declare const ASK_GONE_PARKED = "gone.ask_parked";
107
114
  export declare const ASK_GONE_DENIED_WORD: "routing_failure_fail_closed";
108
115
  export declare const RUN_DEATH_VERDICT_CODES: readonly ["run.stalled", "run.orphaned", "approval.expired"];
109
- export type RunDeathVerdictCode = (typeof RUN_DEATH_VERDICT_CODES)[number];
116
+ export type { RunDeathVerdictCode };
110
117
  export declare const RUN_STALLED: "run.stalled";
111
118
  export declare const RUN_ORPHANED: "run.orphaned";
112
119
  export declare const APPROVAL_EXPIRED: "approval.expired";
@@ -28,7 +28,8 @@ export function imageInvalidFailureNoteOf(code) {
28
28
  }
29
29
  export const CONFIG_AGENT_UNKNOWN_TOOL = 'config.agent.unknown_tool';
30
30
  export const CONFIG_OUTPUT_STYLE_INVALID = 'config.output_style_invalid';
31
- export const RULES_LEGACY_TOOL_NAME = 'rules.legacy_tool_name';
31
+ export const RULES_INERT_ENTRY = 'rules.inert_entry';
32
+ export const RULES_INVALID_SHAPE = 'rules.invalid_shape';
32
33
  const RULES_ERROR_CODE_PREFIX = 'rules.';
33
34
  export function isRulesRefusalCode(code) {
34
35
  return typeof code === 'string' && code.startsWith(RULES_ERROR_CODE_PREFIX);
@@ -100,6 +101,8 @@ export function activeRunBusyCarrierOf(ev) {
100
101
  return null;
101
102
  }
102
103
  export const CORRUPT_SESSION_ERROR_CODE = 'corrupt_session';
104
+ export const CORRUPT_ROW_ERROR_CODE = 'corrupt';
105
+ export const MEMORY_CONTROL_PLANE_CORRUPT = 'internal.memory_control_plane_corrupt';
103
106
  export function isCorruptSessionCode(code) {
104
107
  return code === CORRUPT_SESSION_ERROR_CODE;
105
108
  }
@@ -181,16 +184,21 @@ export const DECIDE_WORKFLOW_LANE_CODES = Object.freeze([
181
184
  export const DECIDE_NOT_PARKED = 'decide.not_parked';
182
185
  export const DECIDE_GATE_MOVED = 'decide.gate_moved';
183
186
  export const DECIDE_CLAIM_LOST = 'decide.claim_lost';
187
+ export const CONFLICT_NOT_RESUMABLE = 'conflict.not_resumable';
188
+ export const GATE_NOT_TOOL_APPROVAL = 'gate_not_tool_approval';
184
189
  export const DECIDE_PARK_MOVED_CODES = Object.freeze([
185
190
  DECIDE_NOT_PARKED,
186
191
  DECIDE_GATE_MOVED,
187
192
  DECIDE_CLAIM_LOST,
193
+ CONFLICT_NOT_RESUMABLE,
194
+ GATE_NOT_TOOL_APPROVAL,
188
195
  ]);
189
196
  export function isDecideParkMovedCode(code) {
190
197
  return typeof code === 'string' && DECIDE_PARK_MOVED_CODES.includes(code);
191
198
  }
192
199
  export const APPROVAL_STALE = 'approval_stale';
193
200
  export const APPROVAL_BINDING_MISMATCH = 'approval_binding_mismatch';
201
+ export const CHECKPOINT_INVALID_OUTCOME = 'checkpoint.invalid_outcome';
194
202
  export const RESUME_OUTCOME_INVALID = 'resume_outcome_invalid';
195
203
  export const CHECKPOINT_ALREADY_RESOLVED = 'checkpoint.already_resolved';
196
204
  export const NOT_FOUND_APPROVAL = 'not_found.approval';
@@ -9,3 +9,4 @@ export type EngineIdentityVerdict = 'changed' | 'same' | 'unknown';
9
9
  export declare function engineIdentityVerdict(a: unknown, b: unknown): EngineIdentityVerdict;
10
10
  export declare function engineIdentityChangedBy(a: unknown, b: unknown): keyof EngineIdentityView | undefined;
11
11
  export declare function engineIdentityChanged(a: unknown, b: unknown): boolean;
12
+ export declare function toolKillCauseAcrossEngineIdentity(before: object | null | undefined, after: object | null | undefined): 'engine_restarted' | undefined;
@@ -55,3 +55,11 @@ export function engineIdentityChangedBy(a, b) {
55
55
  export function engineIdentityChanged(a, b) {
56
56
  return engineIdentityVerdict(a, b) === 'changed';
57
57
  }
58
+ export function toolKillCauseAcrossEngineIdentity(before, after) {
59
+ try {
60
+ return engineIdentityVerdict(before, after) === 'changed' ? 'engine_restarted' : undefined;
61
+ }
62
+ catch {
63
+ return undefined;
64
+ }
65
+ }
@@ -0,0 +1,28 @@
1
+ import type { AgentEvent } from '@sema-agent/sdk';
2
+ export interface EngineRowRef {
3
+ readonly eventId?: string;
4
+ readonly taskId?: string;
5
+ readonly sessionId?: string;
6
+ }
7
+ export type SameEngineRefVerdict = 'same' | 'different' | 'unknown';
8
+ export interface EngineBoundRun {
9
+ readonly taskId?: string;
10
+ readonly sessionId?: string;
11
+ }
12
+ export declare function engineRefOf(row: object | null | undefined): EngineRowRef | undefined;
13
+ export declare function sameEngineRef(a: object | null | undefined, b: object | null | undefined): SameEngineRefVerdict;
14
+ export declare function wireEventIdOf(ev: object): string | undefined;
15
+ export declare function envelopeUuidOf(eventId: string, envelopeType: string): string;
16
+ export type TerminalUuidLabel = 'result' | 'terminal-row' | 'outcome-unknown';
17
+ export declare function terminalUuidOf(runId: string, label: TerminalUuidLabel): string;
18
+ export declare function readBoundRun(call: () => EngineBoundRun | undefined): EngineBoundRun | undefined;
19
+ export declare function mintEngineRowRef(eventId: string, bound: EngineBoundRun | undefined): EngineRowRef;
20
+ export declare function terminalRunIdOf(ev: Extract<AgentEvent, {
21
+ type: 'done';
22
+ } | {
23
+ type: 'failed';
24
+ }>): string | undefined;
25
+ export declare const TRANSCRIPT_ROW_SIDECAR_KEYS: readonly string[];
26
+ export declare function parkHeldCallIdOf(carrier: {} | null | undefined): string | undefined;
27
+ export declare function parkedToolEndRoleOf(frame: {} | null | undefined): 'held' | 'collateral' | undefined;
28
+ export declare function isUnsettledHeldToolEnd(frame: {} | null | undefined): boolean;
@@ -0,0 +1,111 @@
1
+ import { guardedRead, readFrameStringKey, readOwnDataNonEmptyString, readOwnDataValue } from './ownKey.js';
2
+ import { GATE_PARKED_ERROR_CODE } from './engineErrorCodes.js';
3
+ import { isCcToolDenialKind } from './gateVocabulary.js';
4
+ import { doneResultView } from './replayBody.js';
5
+ import { TRANSCRIPT_ID_NAMESPACE, uuidV5 } from './uuidV5.js';
6
+ const ENGINE_REF_KEY = '_sema_engine_ref';
7
+ function refFromCarrier(carrier) {
8
+ const out = {};
9
+ for (const k of ['eventId', 'taskId', 'sessionId']) {
10
+ const v = guardedRead(() => readOwnDataNonEmptyString(carrier, k));
11
+ if (v !== undefined)
12
+ out[k] = v;
13
+ }
14
+ return out.eventId !== undefined || out.taskId !== undefined || out.sessionId !== undefined ? out : undefined;
15
+ }
16
+ export function engineRefOf(row) {
17
+ if (typeof row !== 'object' || row === null)
18
+ return undefined;
19
+ const carrier = guardedRead(() => readOwnDataValue(row, ENGINE_REF_KEY));
20
+ if (typeof carrier !== 'object' || carrier === null)
21
+ return undefined;
22
+ if (guardedRead(() => (Array.isArray(carrier) ? undefined : true)) !== true)
23
+ return undefined;
24
+ return refFromCarrier(carrier);
25
+ }
26
+ export function sameEngineRef(a, b) {
27
+ const ra = engineRefOf(a);
28
+ const rb = engineRefOf(b);
29
+ if (ra?.eventId !== undefined && rb?.eventId !== undefined)
30
+ return ra.eventId === rb.eventId ? 'same' : 'different';
31
+ if (ra?.taskId !== undefined && rb?.taskId !== undefined && ra.taskId !== rb.taskId)
32
+ return 'different';
33
+ if (ra?.sessionId !== undefined && rb?.sessionId !== undefined && ra.sessionId !== rb.sessionId)
34
+ return 'different';
35
+ return 'unknown';
36
+ }
37
+ export function wireEventIdOf(ev) {
38
+ return guardedRead(() => readOwnDataNonEmptyString(ev, 'eventId'));
39
+ }
40
+ export function envelopeUuidOf(eventId, envelopeType) {
41
+ return uuidV5(TRANSCRIPT_ID_NAMESPACE, `ev_${eventId}#${envelopeType}`);
42
+ }
43
+ export function terminalUuidOf(runId, label) {
44
+ return uuidV5(TRANSCRIPT_ID_NAMESPACE, `run_${runId}#${label}`);
45
+ }
46
+ export function readBoundRun(call) {
47
+ let raw;
48
+ try {
49
+ raw = call();
50
+ }
51
+ catch {
52
+ return undefined;
53
+ }
54
+ if (typeof raw !== 'object' || raw === null)
55
+ return undefined;
56
+ const then = guardedRead(() => raw.then);
57
+ if (typeof then === 'function') {
58
+ void Promise.resolve(raw).then(undefined, () => undefined);
59
+ return undefined;
60
+ }
61
+ const taskId = guardedRead(() => readOwnDataNonEmptyString(raw, 'taskId'));
62
+ const sessionId = guardedRead(() => readOwnDataNonEmptyString(raw, 'sessionId'));
63
+ if (taskId === undefined && sessionId === undefined)
64
+ return undefined;
65
+ return { ...(taskId !== undefined ? { taskId } : {}), ...(sessionId !== undefined ? { sessionId } : {}) };
66
+ }
67
+ export function mintEngineRowRef(eventId, bound) {
68
+ return {
69
+ eventId,
70
+ ...(bound?.taskId !== undefined ? { taskId: bound.taskId } : {}),
71
+ ...(bound?.sessionId !== undefined ? { sessionId: bound.sessionId } : {}),
72
+ };
73
+ }
74
+ export function terminalRunIdOf(ev) {
75
+ if (ev.type !== 'done')
76
+ return undefined;
77
+ const v = (doneResultView(ev.result).engine ?? ev.result)?.runId;
78
+ return typeof v === 'string' && v.length > 0 ? v : undefined;
79
+ }
80
+ export const TRANSCRIPT_ROW_SIDECAR_KEYS = Object.freeze([
81
+ '_sema_segment_id',
82
+ '_sema_engine_ref',
83
+ '_sema_replay',
84
+ '_sema_api_error_message',
85
+ '_sema_tool_history_mismatch',
86
+ '_sema_provider_rejection_resend',
87
+ '_sema_tool_recovered',
88
+ '_sema_degraded',
89
+ '_sema_denial_kind',
90
+ '_sema_gate',
91
+ '_sema_not_executed',
92
+ '_sema_collateral_abort',
93
+ '_sema_interrupted_never_started',
94
+ '_sema_approval_window_expired',
95
+ '_sema_denial_limit_window_expired',
96
+ ]);
97
+ export function parkHeldCallIdOf(carrier) {
98
+ return readFrameStringKey(carrier, 'toolCallId');
99
+ }
100
+ export function parkedToolEndRoleOf(frame) {
101
+ if (readFrameStringKey(frame, 'errorCode') !== GATE_PARKED_ERROR_CODE)
102
+ return undefined;
103
+ const gated = readFrameStringKey(frame, 'gatedCallId');
104
+ const call = readFrameStringKey(frame, 'toolCallId');
105
+ if (gated === undefined || call === undefined)
106
+ return undefined;
107
+ return gated === call ? 'held' : 'collateral';
108
+ }
109
+ export function isUnsettledHeldToolEnd(frame) {
110
+ return parkedToolEndRoleOf(frame) === 'held' && !isCcToolDenialKind(readFrameStringKey(frame, '_sema_denial_kind'));
111
+ }
@@ -0,0 +1,67 @@
1
+ export type EngineHistoryJson = string | number | boolean | null | readonly EngineHistoryJson[] | {
2
+ readonly [key: string]: EngineHistoryJson;
3
+ };
4
+ export interface EngineHistoryTextBlock {
5
+ readonly type: 'text';
6
+ readonly text: string;
7
+ }
8
+ export interface EngineHistoryThinkingBlock {
9
+ readonly type: 'thinking';
10
+ readonly thinking: string;
11
+ readonly signature?: string;
12
+ }
13
+ export interface EngineHistoryToolUseBlock {
14
+ readonly type: 'tool_use';
15
+ readonly id: string;
16
+ readonly name: string;
17
+ readonly input: {
18
+ readonly [key: string]: EngineHistoryJson;
19
+ };
20
+ }
21
+ export interface EngineHistoryBase64Source {
22
+ readonly type: 'base64';
23
+ readonly media_type: string;
24
+ readonly data: string;
25
+ }
26
+ export interface EngineHistoryMediaBlock {
27
+ readonly type: 'image' | 'document';
28
+ readonly source: EngineHistoryBase64Source;
29
+ }
30
+ export interface EngineHistoryToolResultBlock {
31
+ readonly type: 'tool_result';
32
+ readonly tool_use_id: string;
33
+ readonly content: readonly EngineHistoryBlock[];
34
+ readonly is_error: boolean;
35
+ }
36
+ export interface EngineHistoryOpaqueBlock {
37
+ readonly type: string;
38
+ readonly [key: string]: EngineHistoryJson;
39
+ }
40
+ export type EngineHistoryBlock = EngineHistoryTextBlock | EngineHistoryThinkingBlock | EngineHistoryToolUseBlock | EngineHistoryMediaBlock | EngineHistoryToolResultBlock | EngineHistoryOpaqueBlock;
41
+ export interface EngineHistoryMessageBody {
42
+ readonly role: 'user' | 'assistant';
43
+ readonly content: string | readonly EngineHistoryBlock[];
44
+ readonly model?: string;
45
+ }
46
+ export interface EngineHistoryMessage {
47
+ readonly type: 'user' | 'assistant';
48
+ readonly uuid: string;
49
+ readonly session_id: string;
50
+ readonly timestamp?: string;
51
+ readonly message: EngineHistoryMessageBody;
52
+ readonly parent_tool_use_id: null;
53
+ }
54
+ export interface EngineHistorySkipped {
55
+ readonly unreadable: number;
56
+ readonly unknownRole: number;
57
+ readonly noVisibleContent: number;
58
+ readonly droppedBlocks: number;
59
+ }
60
+ export interface EngineHistoryProjection {
61
+ readonly messages: readonly EngineHistoryMessage[];
62
+ readonly skipped: EngineHistorySkipped;
63
+ }
64
+ export interface EngineHistoryProjectionOpts {
65
+ readonly sessionId: string;
66
+ }
67
+ export declare function projectEngineSessionMessages<Row>(rows: readonly Row[], opts: EngineHistoryProjectionOpts): EngineHistoryProjection;