@sema-agent/client-core 0.109.0 → 0.111.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 (236) hide show
  1. package/CHANGELOG.md +342 -0
  2. package/README.md +88 -32
  3. package/dist/abortableSleep.d.ts +7 -0
  4. package/dist/abortableSleep.js +37 -0
  5. package/dist/adapt/arms.js +45 -11
  6. package/dist/adapt/toolCards.d.ts +3 -1
  7. package/dist/adapt/toolCards.js +4 -2
  8. package/dist/adapter/activeRunSelfHeal.d.ts +39 -0
  9. package/dist/adapter/activeRunSelfHeal.js +171 -3
  10. package/dist/adapter/downstream/eventToSdkMessage.js +20 -15
  11. package/dist/adapter/downstream/terminalToSdkResult.d.ts +2 -0
  12. package/dist/adapter/downstream/terminalToSdkResult.js +11 -0
  13. package/dist/adapter/runStream.d.ts +5 -0
  14. package/dist/adapter/runStream.js +15 -3
  15. package/dist/attachmentRoute.d.ts +20 -0
  16. package/dist/attachmentRoute.js +39 -0
  17. package/dist/attachmentsWireCaps.js +1 -1
  18. package/dist/builtinOutputStyles.d.ts +12 -0
  19. package/dist/builtinOutputStyles.js +147 -0
  20. package/dist/compactionStatus.d.ts +9 -0
  21. package/dist/compactionStatus.js +29 -5
  22. package/dist/controlRouter.js +2 -1
  23. package/dist/coreValuePorts.d.ts +39 -1
  24. package/dist/coreValuePorts.js +10 -0
  25. package/dist/declared/supportFloorDeclared.js +1 -1
  26. package/dist/displayUntrusted.d.ts +1 -0
  27. package/dist/displayUntrusted.js +138 -14
  28. package/dist/engineErrorCodes.d.ts +3 -0
  29. package/dist/engineErrorCodes.js +3 -0
  30. package/dist/engineHealthFacts.d.ts +20 -0
  31. package/dist/engineHealthFacts.js +42 -1
  32. package/dist/engineHealthProbeVerdict.d.ts +23 -0
  33. package/dist/engineHealthProbeVerdict.js +115 -0
  34. package/dist/engineInlineTaskStats.d.ts +4 -3
  35. package/dist/engineInlineTaskStats.js +18 -2
  36. package/dist/engineNoticeCodes.d.ts +10 -0
  37. package/dist/engineNoticeCodes.js +36 -6
  38. package/dist/engineRepoint.d.ts +147 -0
  39. package/dist/engineRepoint.js +310 -0
  40. package/dist/engineRowRef.d.ts +3 -0
  41. package/dist/engineRowRef.js +13 -1
  42. package/dist/engineSessionMessages.d.ts +2 -1
  43. package/dist/engineSessionMessages.js +5 -0
  44. package/dist/engineSwapCrossing.d.ts +57 -0
  45. package/dist/engineSwapCrossing.js +297 -0
  46. package/dist/engineUnavailable.d.ts +44 -0
  47. package/dist/engineUnavailable.js +492 -0
  48. package/dist/errorSupplementRoles.js +2 -1
  49. package/dist/eventLeg.js +3 -3
  50. package/dist/fleet/fleetProjection.js +3 -2
  51. package/dist/generated/engineFactTables.d.ts +2 -0
  52. package/dist/generated/engineFactTables.js +12 -0
  53. package/dist/generated/sdkFactTables.d.ts +2 -1
  54. package/dist/generated/sdkFactTables.js +5 -0
  55. package/dist/generated/settingsSchemaTables.d.ts +4 -0
  56. package/dist/generated/settingsSchemaTables.js +1 -0
  57. package/dist/hitl/approvalAskers.d.ts +6 -0
  58. package/dist/hitl/approvalAskers.js +30 -0
  59. package/dist/hitl/approvalCardReasons.js +6 -3
  60. package/dist/hitl/approvalDelivery.d.ts +1 -0
  61. package/dist/hitl/approvalDelivery.js +1 -1
  62. package/dist/hitl/approvalRequestFrameReading.d.ts +7 -0
  63. package/dist/hitl/approvalRequestFrameReading.js +11 -0
  64. package/dist/hitl/approvalResolution.d.ts +9 -2
  65. package/dist/hitl/approvalResolution.js +6 -1
  66. package/dist/hitl/askGateWire.js +5 -8
  67. package/dist/hitl/automaticAnswerVerdict.js +2 -2
  68. package/dist/hitl/decisionConflict.js +6 -3
  69. package/dist/hitl/decisionRefusal.d.ts +2 -0
  70. package/dist/hitl/decisionRefusal.js +8 -8
  71. package/dist/hitl/decisionRefusalCarrier.d.ts +3 -0
  72. package/dist/hitl/decisionRefusalCarrier.js +348 -0
  73. package/dist/hitl/decisionSend.d.ts +10 -0
  74. package/dist/hitl/decisionSend.js +57 -17
  75. package/dist/hitl/editedApprovalAcceptance.d.ts +25 -0
  76. package/dist/hitl/editedApprovalAcceptance.js +26 -0
  77. package/dist/hitl/elicitationRefusal.d.ts +4 -0
  78. package/dist/hitl/elicitationRefusal.js +23 -0
  79. package/dist/hitl/frameRouter.d.ts +2 -2
  80. package/dist/hitl/frameRouter.js +12 -33
  81. package/dist/hitl/gateIdentity.d.ts +5 -0
  82. package/dist/hitl/gateIdentity.js +23 -0
  83. package/dist/hitl/gateLedger.d.ts +0 -4
  84. package/dist/hitl/gateLedger.js +0 -19
  85. package/dist/hitl/hitlBridge.d.ts +7 -0
  86. package/dist/hitl/hitlBridge.js +14 -8
  87. package/dist/hitl/hitlHostSurface.d.ts +3 -1
  88. package/dist/hitl/hitlHostSurface.js +14 -4
  89. package/dist/hitl/hostWithdrawal.d.ts +15 -0
  90. package/dist/hitl/hostWithdrawal.js +38 -0
  91. package/dist/hitl/localAllowRedemption.d.ts +67 -0
  92. package/dist/hitl/localAllowRedemption.js +256 -0
  93. package/dist/hitl/parkResolver.js +32 -13
  94. package/dist/hitl/persistedRulesWire.d.ts +16 -0
  95. package/dist/hitl/persistedRulesWire.js +72 -2
  96. package/dist/hitl/planReviewWire.d.ts +3 -0
  97. package/dist/hitl/planReviewWire.js +37 -10
  98. package/dist/hitl/policyDenyCause.d.ts +1 -1
  99. package/dist/hitl/policyDenyCause.js +1 -1
  100. package/dist/hitl/resumeRunningCard.d.ts +1 -0
  101. package/dist/hitl/resumeRunningCard.js +1 -0
  102. package/dist/hitl/screenCardCarriers.d.ts +15 -0
  103. package/dist/hitl/screenCardCarriers.js +41 -0
  104. package/dist/hitl/screenDecisionCards.d.ts +98 -0
  105. package/dist/hitl/screenDecisionCards.js +362 -0
  106. package/dist/hitl/sessionPolicyWire.js +6 -4
  107. package/dist/hitl/standingRows.d.ts +4 -1
  108. package/dist/hitl/standingRows.js +33 -1
  109. package/dist/hitl/toolApprovalWire.d.ts +64 -15
  110. package/dist/hitl/toolApprovalWire.js +470 -125
  111. package/dist/hooksWireCaps.js +31 -1
  112. package/dist/hostSettingNoticeArm.d.ts +3 -0
  113. package/dist/hostSettingNoticeArm.js +12 -0
  114. package/dist/hostTurnSettings.d.ts +13 -4
  115. package/dist/hostTurnSettings.js +150 -10
  116. package/dist/humanTurnRead.js +11 -1
  117. package/dist/i18n/messages.en.d.ts +212 -0
  118. package/dist/i18n/messages.en.js +217 -5
  119. package/dist/i18n/messages.zh.js +235 -5
  120. package/dist/i18n/translate.d.ts +3 -0
  121. package/dist/i18n/translate.js +78 -10
  122. package/dist/i18n/zh.d.ts +1 -0
  123. package/dist/i18n/zh.js +1 -0
  124. package/dist/index.d.ts +56 -16
  125. package/dist/index.js +40 -12
  126. package/dist/inheritEnvCapability.js +2 -0
  127. package/dist/inputAuthor.d.ts +16 -0
  128. package/dist/inputAuthor.js +44 -0
  129. package/dist/interactiveHalt.js +2 -1
  130. package/dist/interactiveInterrupt.js +20 -2
  131. package/dist/interruptRefusalNote.d.ts +2 -0
  132. package/dist/interruptRefusalNote.js +17 -0
  133. package/dist/liveModelCatalog.d.ts +2 -0
  134. package/dist/liveModelCatalog.js +23 -9
  135. package/dist/liveQuestionStore.d.ts +4 -1
  136. package/dist/liveQuestionStore.js +12 -3
  137. package/dist/localEngineSeatReading.d.ts +2 -2
  138. package/dist/localEngineSeatReading.js +5 -3
  139. package/dist/localEngineSpawn.d.ts +0 -7
  140. package/dist/localEngineSpawn.js +0 -92
  141. package/dist/localEngineStep.d.ts +2 -2
  142. package/dist/localEngineStep.js +2 -0
  143. package/dist/mcpEngineLeg.d.ts +3 -0
  144. package/dist/mcpEngineLeg.js +38 -1
  145. package/dist/mcpPanel.js +2 -0
  146. package/dist/mcpReconnect.d.ts +9 -1
  147. package/dist/mcpReconnect.js +124 -19
  148. package/dist/mcpWireCaps.js +1 -1
  149. package/dist/model/engineModelWords.d.ts +3 -0
  150. package/dist/model/engineModelWords.js +13 -0
  151. package/dist/model/subagentModelWord.d.ts +21 -2
  152. package/dist/model/subagentModelWord.js +100 -29
  153. package/dist/modelCapabilityProbe.js +7 -43
  154. package/dist/modsFace.d.ts +8 -1
  155. package/dist/modsFace.js +27 -0
  156. package/dist/notifications.d.ts +36 -6
  157. package/dist/notifications.js +170 -20
  158. package/dist/ownKey.d.ts +6 -5
  159. package/dist/ownKey.js +31 -7
  160. package/dist/peerFrames.d.ts +40 -2
  161. package/dist/peerFrames.js +158 -3
  162. package/dist/pendingUserRow.d.ts +4 -0
  163. package/dist/pendingUserRow.js +16 -0
  164. package/dist/permissionsDeclaration.d.ts +1 -0
  165. package/dist/permissionsDeclaration.js +11 -1
  166. package/dist/planReviewCardFacts.d.ts +3 -0
  167. package/dist/planReviewCardFacts.js +52 -2
  168. package/dist/pluginHooksWire.d.ts +10 -1
  169. package/dist/pluginHooksWire.js +96 -7
  170. package/dist/printToolResultFrame.js +4 -2
  171. package/dist/promptBlockedCopy.js +11 -6
  172. package/dist/promptSuggestionBatch.d.ts +7 -0
  173. package/dist/promptSuggestionBatch.js +9 -0
  174. package/dist/promptSuggestionsTail.d.ts +39 -0
  175. package/dist/promptSuggestionsTail.js +116 -0
  176. package/dist/replayBody.js +10 -2
  177. package/dist/request/taskRequest.d.ts +5 -0
  178. package/dist/request/taskRequest.js +142 -21
  179. package/dist/requestCoordinate.d.ts +1 -0
  180. package/dist/requestCoordinate.js +13 -0
  181. package/dist/resumeRefusalCopy.d.ts +1 -3
  182. package/dist/resumeRefusalCopy.js +2 -1
  183. package/dist/retryStatus.d.ts +2 -2
  184. package/dist/retryStatus.js +2 -0
  185. package/dist/rewindArchiveReading.js +4 -4
  186. package/dist/runCancelContext.d.ts +2 -1
  187. package/dist/runCancelContext.js +1 -0
  188. package/dist/runPermissionModeSwitch.js +2 -2
  189. package/dist/scenarioRefusal.js +11 -13
  190. package/dist/scenarioSkills.js +11 -6
  191. package/dist/seam.d.ts +27 -2
  192. package/dist/seam.js +17 -1
  193. package/dist/seatContract.d.ts +189 -12
  194. package/dist/seatContract.js +401 -9
  195. package/dist/sessionBackground.js +2 -1
  196. package/dist/sessionBackgroundHandoff.js +2 -1
  197. package/dist/sessionCostReading.d.ts +70 -0
  198. package/dist/sessionCostReading.js +150 -0
  199. package/dist/sessionEngine.d.ts +2 -0
  200. package/dist/sessionEngine.js +111 -0
  201. package/dist/sessionHooksRoster.d.ts +4 -0
  202. package/dist/sessionHooksRoster.js +158 -0
  203. package/dist/sessionMemoryStatus.d.ts +2 -1
  204. package/dist/sessionMemoryStatus.js +2 -2
  205. package/dist/sessionReadRedaction.d.ts +7 -0
  206. package/dist/sessionReadRedaction.js +26 -0
  207. package/dist/sessionSyncFileHistory.d.ts +4 -0
  208. package/dist/sessionSyncFileHistory.js +27 -0
  209. package/dist/settingsHooksSalvage.js +2 -1
  210. package/dist/sseIdleTriage.d.ts +13 -1
  211. package/dist/sseIdleTriage.js +25 -6
  212. package/dist/storeDurabilityWord.d.ts +15 -0
  213. package/dist/storeDurabilityWord.js +18 -0
  214. package/dist/storePostureCapability.d.ts +7 -3
  215. package/dist/storePostureCapability.js +69 -39
  216. package/dist/subagent/engineSubagentResume.js +2 -2
  217. package/dist/subagent/engineSubagentTail.js +8 -1
  218. package/dist/subagentContentStore.d.ts +11 -0
  219. package/dist/subagentContentStore.js +28 -2
  220. package/dist/terminalStatuses.d.ts +1 -0
  221. package/dist/terminalStatuses.js +4 -1
  222. package/dist/toolResult.d.ts +1 -0
  223. package/dist/toolResult.js +2 -0
  224. package/dist/turnFailurePresentation.js +9 -2
  225. package/dist/typePins.d.ts +11 -0
  226. package/dist/usageAnalytics.d.ts +17 -0
  227. package/dist/usageAnalytics.js +44 -2
  228. package/dist/userAttachmentEnvelope.d.ts +2 -1
  229. package/dist/userAttachmentEnvelope.js +10 -0
  230. package/dist/wireErrorTriage.js +2 -1
  231. package/dist/wireFailureShape.d.ts +6 -5
  232. package/dist/wireFailureShape.js +150 -38
  233. package/dist/wireRefusalCopy.d.ts +16 -5
  234. package/dist/wireRefusalCopy.js +119 -86
  235. package/docs/INTEGRATION-CLIENTS.md +4228 -21
  236. package/package.json +7 -3
@@ -150,6 +150,22 @@ export function planReviewCardViewOf(frame, lang) {
150
150
  return Object.freeze({ options: OPTIONS_BY_SHAPE.withheld, note: renderMessage(planReviewUnreadableNoteRef(), lang) });
151
151
  }
152
152
  }
153
+ export function planReviewEvidenceMovedOf(shown, latest) {
154
+ try {
155
+ const a = planReviewCardFactsFrom(shown);
156
+ const b = planReviewCardFactsFrom(latest);
157
+ if (a === undefined || b === undefined || a.taskId !== b.taskId)
158
+ return 'unknown';
159
+ if (a.checkpointId !== undefined && b.checkpointId !== undefined && a.checkpointId !== b.checkpointId)
160
+ return 'moved';
161
+ if (a.evidenceRevision === undefined || b.evidenceRevision === undefined)
162
+ return 'unknown';
163
+ return a.evidenceRevision === b.evidenceRevision ? 'same' : 'moved';
164
+ }
165
+ catch {
166
+ return 'unknown';
167
+ }
168
+ }
153
169
  export function notePlanReviewAnsweredIfDecisive(questionId, answer) {
154
170
  notePlanReviewAnsweredIfDecisiveFor(DEFAULT_SESSION_KEY, questionId, answer);
155
171
  }
@@ -498,11 +514,15 @@ export function armPlanReviewApproval(result, sessionKey, opts) {
498
514
  armedPlanReviews.set(taskId, instance);
499
515
  armedTaskId = taskId;
500
516
  let unregister = () => { };
517
+ const onWithdraw = () => {
518
+ hostLog('debug', `planReviewWire: card-withdrawn-by-host task=${taskId} card=${questionId}`);
519
+ retireArmedPlanReview(taskId, instance);
520
+ };
501
521
  const responder = async (_id, answer) => {
502
522
  const choice = planReviewAnswerChoiceOf(questionId, answer);
503
523
  if (choice === 'inadmissible') {
504
524
  if (armedPlanReviews.get(taskId) === instance && !hasLocalQuestionResponder(questionId))
505
- unregister = registerLocalQuestionResponder(questionId, responder);
525
+ unregister = registerLocalQuestionResponder(questionId, responder, onWithdraw);
506
526
  hostLog('debug', `planReviewWire: answer-inadmissible card=${questionId}`);
507
527
  return { ok: false, inadmissible: true };
508
528
  }
@@ -520,10 +540,10 @@ export function armPlanReviewApproval(result, sessionKey, opts) {
520
540
  const cardDelivery = cardReason !== undefined ? { ...delivery, reason: cardReason } : delivery;
521
541
  notePlanReviewAnswered(questionId);
522
542
  hostLog('debug', `planReviewWire: arm responder delivering ${decided} for task ${taskId} (path=arm)`);
523
- void decidePlanReviewFor(taskId, decided, modeAfter, cardDelivery, facts);
543
+ void decidePlanReviewFor(taskId, decided, modeAfter, cardDelivery, facts, questionId);
524
544
  return { ok: true };
525
545
  };
526
- unregister = registerLocalQuestionResponder(questionId, responder);
546
+ unregister = registerLocalQuestionResponder(questionId, responder, onWithdraw);
527
547
  publishArmedPlanReviewCard(instance);
528
548
  hostLog('debug', `planReviewWire: approval card armed for parked plan (task ${taskId})`);
529
549
  }
@@ -721,7 +741,7 @@ function askAgainReasonOf(card, opts) {
721
741
  return renderMessage(msg('approval.planReview.askAgain.unknown'), DATA_FACE_LANGUAGE);
722
742
  }
723
743
  }
724
- async function decidePlanReviewFor(taskId, decision, permissionModeAfter, opts, card) {
744
+ async function decidePlanReviewFor(taskId, decision, permissionModeAfter, opts, card, cardId) {
725
745
  if (typeof taskId === 'string' && planReviewOpsOf(taskId).some((op) => op.phase === 'posting')) {
726
746
  hostLog('error', `planReviewWire: decidePlanReview(${decision}) for task ${taskId} REFUSED — a decision for this task is already in flight (duplicate delivery latched)`);
727
747
  return;
@@ -754,7 +774,7 @@ async function decidePlanReviewFor(taskId, decision, permissionModeAfter, opts,
754
774
  try {
755
775
  const wireDecision = decision === 'ask_again' ? 'reject' : decision;
756
776
  const wireOpts = decision === 'ask_again' ? { ...opts, reason: askAgainReasonOf(card, opts) } : opts;
757
- await decidePlanReviewInner(taskId, wireDecision, permissionModeAfter, dispatchNo, releaseLatch, settle, wireOpts, card, decision);
777
+ await decidePlanReviewInner(taskId, wireDecision, permissionModeAfter, dispatchNo, releaseLatch, settle, wireOpts, card, decision, cardId);
758
778
  }
759
779
  finally {
760
780
  releaseLatch();
@@ -775,7 +795,7 @@ function planReviewClientsFor(resolved) {
775
795
  repull: () => resolved.make({ timeoutMs: 15_000 }),
776
796
  };
777
797
  }
778
- async function decidePlanReviewInner(taskId, decision, permissionModeAfter, dispatchNo, releaseLatch, settle, opts, card, semanticDecision) {
798
+ async function decidePlanReviewInner(taskId, decision, permissionModeAfter, dispatchNo, releaseLatch, settle, opts, card, semanticDecision, cardId) {
779
799
  let outcome;
780
800
  let decisionReason;
781
801
  const gateBefore = card?.checkpointId;
@@ -1015,7 +1035,7 @@ async function decidePlanReviewInner(taskId, decision, permissionModeAfter, disp
1015
1035
  const onOutcome = opts?.onOutcome;
1016
1036
  settle(effect === 'not_sent' || effect === 'still_parked');
1017
1037
  try {
1018
- const delivered = enqueuePlanReviewOutcome(prompt, { taskId, dispatchNo, decision: semanticDecision, effect, ...(effect === 'still_parked' && stillParkedCause !== undefined ? { cause: stillParkedCause } : {}) });
1038
+ const delivered = enqueuePlanReviewOutcome(prompt, { taskId, dispatchNo, decision: semanticDecision, effect, ...(effect === 'still_parked' && stillParkedCause !== undefined ? { cause: stillParkedCause } : {}), ...(cardId !== undefined ? { questionId: cardId } : {}) });
1019
1039
  if (!delivered) {
1020
1040
  if (onOutcome !== undefined) {
1021
1041
  hostLog('debug', `planReviewWire: outcome queue port not installed for task ${taskId} — outcome handed to the host's onOutcome callback only`);
@@ -1035,6 +1055,7 @@ async function decidePlanReviewInner(taskId, decision, permissionModeAfter, disp
1035
1055
  decision: semanticDecision,
1036
1056
  effect,
1037
1057
  ...(effect === 'still_parked' && stillParkedCause !== undefined ? { cause: stillParkedCause } : {}),
1058
+ ...(cardId !== undefined ? { questionId: cardId } : {}),
1038
1059
  detail: outcome,
1039
1060
  tail,
1040
1061
  prompt,
@@ -1156,15 +1177,21 @@ function mintPlanReviewReopenCard(taskId, opts, sessionKey, receiptMs, taken) {
1156
1177
  ((tid, decision, reason, card) => {
1157
1178
  hostLog('debug', `planReviewWire: reopen responder delivering ${decision} for task ${tid} (path=reopen-default)`);
1158
1179
  const withReason = reason === undefined ? delivery : { ...delivery, reason };
1159
- void decidePlanReviewFor(tid, decision, undefined, withReason, card);
1180
+ void decidePlanReviewFor(tid, decision, undefined, withReason, card, questionId);
1160
1181
  });
1161
1182
  const activeKey = `${sessionKey}\u0000${canonicalId}`;
1162
1183
  let unregister = () => { };
1184
+ const onWithdraw = () => {
1185
+ hostLog('debug', `planReviewWire: card-withdrawn-by-host task=${taskId} card=${questionId}`);
1186
+ if (activeReopenResponders.get(activeKey)?.questionId === questionId)
1187
+ activeReopenResponders.delete(activeKey);
1188
+ publishQuestionFrameFor(sessionKey, { type: 'question_complete', questionId });
1189
+ };
1163
1190
  const responder = async (_id, answer) => {
1164
1191
  const choice = planReviewAnswerChoiceOf(questionId, answer);
1165
1192
  if (choice === 'inadmissible') {
1166
1193
  if (activeReopenResponders.get(activeKey)?.questionId === questionId && !hasLocalQuestionResponder(questionId)) {
1167
- unregister = registerLocalQuestionResponder(questionId, responder);
1194
+ unregister = registerLocalQuestionResponder(questionId, responder, onWithdraw);
1168
1195
  }
1169
1196
  hostLog('debug', `planReviewWire: answer-inadmissible card=${questionId}`);
1170
1197
  return { ok: false, inadmissible: true };
@@ -1190,7 +1217,7 @@ function mintPlanReviewReopenCard(taskId, opts, sessionKey, receiptMs, taken) {
1190
1217
  return { ok: true };
1191
1218
  };
1192
1219
  const shape = cardShapeOf(facts, false);
1193
- unregister = registerLocalQuestionResponder(questionId, responder);
1220
+ unregister = registerLocalQuestionResponder(questionId, responder, onWithdraw);
1194
1221
  activeReopenResponders.set(activeKey, { questionId, unregister: () => unregister(), shape });
1195
1222
  const receipt = waitForGateArmedFor(sessionKey, [questionId], receiptMs);
1196
1223
  publishQuestionFrameFor(sessionKey, planReviewQuestionFrame(questionId, REOPEN_QUESTION, shape, facts));
@@ -1,3 +1,3 @@
1
- export declare const POLICY_DENY_CAUSES: readonly ["no_approval_ui", "dont_ask", "deny_rule", "engine_floor"];
1
+ export declare const POLICY_DENY_CAUSES: readonly ["no_approval_ui", "dont_ask", "deny_rule", "engine_floor", "hook"];
2
2
  export type PolicyDenyCause = (typeof POLICY_DENY_CAUSES)[number];
3
3
  export declare function readPolicyDenyCause(decision: object | null | undefined): PolicyDenyCause | undefined;
@@ -1,4 +1,4 @@
1
- export const POLICY_DENY_CAUSES = Object.freeze(['no_approval_ui', 'dont_ask', 'deny_rule', 'engine_floor']);
1
+ export const POLICY_DENY_CAUSES = Object.freeze(['no_approval_ui', 'dont_ask', 'deny_rule', 'engine_floor', 'hook']);
2
2
  export function readPolicyDenyCause(decision) {
3
3
  if (decision === null || typeof decision !== 'object')
4
4
  return undefined;
@@ -21,6 +21,7 @@ export declare function runningAttachOffered(canAttach: boolean | undefined): bo
21
21
  export declare function resumeRunningOptions(i: ResumeRunningCardInput): ResumeRunningCardOption[];
22
22
  export declare function resumeChoiceFromLabels(selected: readonly string[] | null | undefined): ResumeRunningChoice;
23
23
  export declare const RESUME_RUNNING_NO_UI_EXIT_CODE = 75;
24
+ export declare const ENGINE_UNAVAILABLE_EXIT_CODE = 69;
24
25
  export declare const RESUME_RUNNING_GUIDANCE_TAG = "sema: resume-running:";
25
26
  export declare function resumeRunningNoUiGuidance(i: {
26
27
  taskId: string;
@@ -50,6 +50,7 @@ export function resumeChoiceFromLabels(selected) {
50
50
  return 'background';
51
51
  }
52
52
  export const RESUME_RUNNING_NO_UI_EXIT_CODE = 75;
53
+ export const ENGINE_UNAVAILABLE_EXIT_CODE = 69;
53
54
  export const RESUME_RUNNING_GUIDANCE_TAG = 'sema: resume-running:';
54
55
  export function resumeRunningNoUiGuidance(i) {
55
56
  const sid = typeof i.sessionId === 'string' && i.sessionId.length > 0 ? i.sessionId : null;
@@ -0,0 +1,15 @@
1
+ export declare const PARK_GATE_KEY = "_sema_parkGate";
2
+ export declare function sourceGenerationNow(deps: {
3
+ readonly engineGeneration?: () => number;
4
+ } | null | undefined): number | undefined;
5
+ export declare function parkQuestionFrameBits(taskId: string, gatedCallId: string | undefined, sourceGeneration: number | undefined): {
6
+ readonly _sema_parkGate?: {
7
+ readonly taskId: string;
8
+ readonly gatedCallId: string;
9
+ };
10
+ readonly _sema_sourceGeneration?: number;
11
+ };
12
+ export declare function sourceGenerationBit(sourceGeneration: number | undefined): {
13
+ readonly sourceGeneration?: number;
14
+ };
15
+ export declare function questionFrameSourceGenerationOf(frame: object | null | undefined): number | undefined;
@@ -0,0 +1,41 @@
1
+ import { slotReadOf } from '../wireFailureShape.js';
2
+ import { engineGenerationReadingOf } from '../engineGenerationPort.js';
3
+ export const PARK_GATE_KEY = '_sema_parkGate';
4
+ const SOURCE_GENERATION_KEY = '_sema_sourceGeneration';
5
+ const nonEmpty = (v) => typeof v === 'string' && v.length > 0;
6
+ const finite = (v) => typeof v === 'number' && Number.isFinite(v);
7
+ export function sourceGenerationNow(deps) {
8
+ try {
9
+ if (typeof deps !== 'object' || deps === null)
10
+ return undefined;
11
+ const read = deps.engineGeneration;
12
+ if (typeof read !== 'function')
13
+ return undefined;
14
+ const r = engineGenerationReadingOf(() => read.call(deps));
15
+ return r.known ? r.generation : undefined;
16
+ }
17
+ catch {
18
+ return undefined;
19
+ }
20
+ }
21
+ export function parkQuestionFrameBits(taskId, gatedCallId, sourceGeneration) {
22
+ return {
23
+ ...(nonEmpty(taskId) && nonEmpty(gatedCallId) ? { _sema_parkGate: Object.freeze({ taskId, gatedCallId }) } : {}),
24
+ ...(finite(sourceGeneration) ? { _sema_sourceGeneration: sourceGeneration } : {}),
25
+ };
26
+ }
27
+ export function sourceGenerationBit(sourceGeneration) {
28
+ return finite(sourceGeneration) ? { sourceGeneration } : {};
29
+ }
30
+ export function questionFrameSourceGenerationOf(frame) {
31
+ try {
32
+ if (typeof frame !== 'object' || frame === null)
33
+ return undefined;
34
+ const r = slotReadOf(frame, SOURCE_GENERATION_KEY);
35
+ const v = r.presence === 'present' ? r.value : undefined;
36
+ return finite(v) ? v : undefined;
37
+ }
38
+ catch {
39
+ return undefined;
40
+ }
41
+ }
@@ -0,0 +1,98 @@
1
+ import { type ScreenCardOrigin } from './gateIdentity.js';
2
+ import { type EndedGenerationOpenedCall, type EndedGenerationPhaseChange, type EndedGenerationPhaseHold } from '../engineGenerationConvergence.js';
3
+ import type { HostWithdrawal } from './hostWithdrawal.js';
4
+ export type ScreenCardGate = {
5
+ readonly kind: 'tool';
6
+ readonly taskId: string;
7
+ readonly gatedCallId: string;
8
+ } | {
9
+ readonly kind: 'plan';
10
+ readonly taskId: string;
11
+ readonly checkpointId?: string;
12
+ };
13
+ export interface ScreenCardWindow {
14
+ readonly leftMs?: number;
15
+ readonly closedByEngine?: boolean;
16
+ }
17
+ export interface ScreenDecisionCard {
18
+ readonly instance: string;
19
+ readonly origin?: ScreenCardOrigin;
20
+ readonly gate?: ScreenCardGate;
21
+ readonly sourceGeneration?: number;
22
+ readonly toolCallId?: string;
23
+ readonly window?: ScreenCardWindow;
24
+ }
25
+ export declare const SCREEN_CARD_KEEP_REASONS: readonly ["not-ready", "generation-moved", "not-withdrawable", "no-gate", "not-early", "no-row", "not-owned", "verdict-ok", "verdict-absent"];
26
+ export type ScreenCardKeepReason = (typeof SCREEN_CARD_KEEP_REASONS)[number];
27
+ export interface EngineGenerationEndedCardFacts {
28
+ readonly phase: 'ended';
29
+ readonly endedGeneration: number;
30
+ readonly cards: readonly ScreenDecisionCard[];
31
+ readonly opened: readonly EndedGenerationOpenedCall[];
32
+ readonly phases?: readonly EndedGenerationPhaseHold[];
33
+ }
34
+ export interface EngineGenerationReadyCardFacts<R extends object> {
35
+ readonly phase: 'ready';
36
+ readonly generation: number;
37
+ readonly ready: boolean;
38
+ readonly readGeneration: number;
39
+ readonly cards: readonly ScreenDecisionCard[];
40
+ readonly rows: readonly R[];
41
+ readonly isOwned: (row: R) => boolean;
42
+ readonly withdrawable: readonly ScreenCardOrigin[];
43
+ }
44
+ export interface EngineGenerationEndedCardPlan {
45
+ readonly phase: 'ended';
46
+ readonly retract: readonly string[];
47
+ readonly phases: readonly EndedGenerationPhaseChange[];
48
+ }
49
+ export interface ScreenCardWithdrawal<R extends object> {
50
+ readonly instance: string;
51
+ readonly origin: ScreenCardOrigin;
52
+ readonly row: R;
53
+ readonly withdrawal: HostWithdrawal;
54
+ }
55
+ export interface ScreenCardKeep {
56
+ readonly instance: string;
57
+ readonly why: ScreenCardKeepReason;
58
+ }
59
+ export interface EngineGenerationReadyCardPlan<R extends object> {
60
+ readonly phase: 'ready';
61
+ readonly withdraw: readonly ScreenCardWithdrawal<R>[];
62
+ readonly keep: readonly ScreenCardKeep[];
63
+ }
64
+ export interface EngineGenerationCardRecheckDueFacts {
65
+ readonly generation: number;
66
+ readonly ready: boolean;
67
+ readonly cards: readonly ScreenDecisionCard[];
68
+ readonly withdrawable: readonly ScreenCardOrigin[];
69
+ }
70
+ export declare function questionFrameGateOf(frame: object | null | undefined): ScreenCardGate | undefined;
71
+ export declare function approvalCardGateOf(card: object | null | undefined): ScreenCardGate | undefined;
72
+ export declare function approvalCardOriginOf(card: object | null | undefined): 'live-approval' | 'park-approval';
73
+ export declare function screenCardsHoldEngineDecision(cards: readonly {
74
+ readonly origin?: ScreenCardOrigin;
75
+ }[] | null | undefined): boolean;
76
+ export declare function engineGenerationCardPlan(facts: EngineGenerationEndedCardFacts): EngineGenerationEndedCardPlan;
77
+ export declare function engineGenerationCardPlan<R extends object>(facts: EngineGenerationReadyCardFacts<R>): EngineGenerationReadyCardPlan<R>;
78
+ export declare function engineGenerationCardRecheckDue(facts: EngineGenerationCardRecheckDueFacts): boolean;
79
+ export interface ScreenCardGoldenRow {
80
+ readonly taskId?: string;
81
+ readonly toolCallId?: string;
82
+ readonly boundCallId?: string;
83
+ readonly checkpointId?: string;
84
+ readonly rowVerdict?: ScreenCardGoldenRowVerdict;
85
+ readonly owned: boolean;
86
+ }
87
+ export interface ScreenCardGoldenRowVerdict {
88
+ readonly kind: string;
89
+ readonly code?: string;
90
+ readonly reason?: string;
91
+ readonly sentence?: string;
92
+ }
93
+ export interface EngineGenerationCardPlanGoldenCase {
94
+ readonly name: string;
95
+ readonly facts: EngineGenerationEndedCardFacts | Omit<EngineGenerationReadyCardFacts<ScreenCardGoldenRow>, 'isOwned'>;
96
+ readonly plan: EngineGenerationEndedCardPlan | EngineGenerationReadyCardPlan<ScreenCardGoldenRow>;
97
+ }
98
+ export declare const ENGINE_GENERATION_CARD_PLAN_GOLDEN: readonly EngineGenerationCardPlanGoldenCase[];