@sema-agent/client-core 0.110.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 (176) hide show
  1. package/CHANGELOG.md +169 -0
  2. package/README.md +50 -18
  3. package/dist/abortableSleep.d.ts +7 -0
  4. package/dist/abortableSleep.js +37 -0
  5. package/dist/adapt/arms.js +25 -4
  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 +10 -10
  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/displayUntrusted.d.ts +1 -0
  26. package/dist/displayUntrusted.js +6 -0
  27. package/dist/engineHealthFacts.d.ts +11 -0
  28. package/dist/engineHealthFacts.js +21 -0
  29. package/dist/engineHealthProbeVerdict.d.ts +23 -0
  30. package/dist/engineHealthProbeVerdict.js +115 -0
  31. package/dist/engineNoticeCodes.js +5 -7
  32. package/dist/engineRepoint.d.ts +12 -5
  33. package/dist/engineRepoint.js +44 -19
  34. package/dist/engineRowRef.d.ts +3 -0
  35. package/dist/engineRowRef.js +11 -1
  36. package/dist/engineSwapCrossing.d.ts +57 -0
  37. package/dist/engineSwapCrossing.js +297 -0
  38. package/dist/engineUnavailable.d.ts +44 -0
  39. package/dist/engineUnavailable.js +492 -0
  40. package/dist/eventLeg.js +3 -3
  41. package/dist/generated/sdkFactTables.d.ts +1 -1
  42. package/dist/generated/sdkFactTables.js +1 -0
  43. package/dist/generated/settingsSchemaTables.d.ts +4 -0
  44. package/dist/generated/settingsSchemaTables.js +1 -0
  45. package/dist/hitl/approvalDelivery.d.ts +1 -0
  46. package/dist/hitl/approvalDelivery.js +1 -1
  47. package/dist/hitl/approvalResolution.d.ts +1 -1
  48. package/dist/hitl/approvalResolution.js +2 -1
  49. package/dist/hitl/askGateWire.js +5 -6
  50. package/dist/hitl/decisionRefusal.d.ts +2 -0
  51. package/dist/hitl/decisionRefusal.js +7 -8
  52. package/dist/hitl/decisionRefusalCarrier.d.ts +3 -0
  53. package/dist/hitl/decisionRefusalCarrier.js +348 -0
  54. package/dist/hitl/decisionSend.d.ts +7 -0
  55. package/dist/hitl/decisionSend.js +34 -12
  56. package/dist/hitl/editedApprovalAcceptance.js +1 -1
  57. package/dist/hitl/elicitationRefusal.d.ts +4 -0
  58. package/dist/hitl/elicitationRefusal.js +23 -0
  59. package/dist/hitl/frameRouter.d.ts +2 -2
  60. package/dist/hitl/frameRouter.js +8 -15
  61. package/dist/hitl/gateIdentity.d.ts +5 -0
  62. package/dist/hitl/gateIdentity.js +23 -0
  63. package/dist/hitl/hitlBridge.d.ts +6 -0
  64. package/dist/hitl/hitlBridge.js +10 -4
  65. package/dist/hitl/hitlHostSurface.d.ts +2 -1
  66. package/dist/hitl/hitlHostSurface.js +7 -2
  67. package/dist/hitl/localAllowRedemption.d.ts +67 -0
  68. package/dist/hitl/localAllowRedemption.js +256 -0
  69. package/dist/hitl/parkResolver.js +7 -4
  70. package/dist/hitl/persistedRulesWire.d.ts +16 -0
  71. package/dist/hitl/persistedRulesWire.js +70 -0
  72. package/dist/hitl/planReviewWire.d.ts +3 -0
  73. package/dist/hitl/planReviewWire.js +23 -6
  74. package/dist/hitl/policyDenyCause.d.ts +1 -1
  75. package/dist/hitl/policyDenyCause.js +1 -1
  76. package/dist/hitl/resumeRunningCard.d.ts +1 -0
  77. package/dist/hitl/resumeRunningCard.js +1 -0
  78. package/dist/hitl/screenCardCarriers.d.ts +15 -0
  79. package/dist/hitl/screenCardCarriers.js +41 -0
  80. package/dist/hitl/screenDecisionCards.d.ts +98 -0
  81. package/dist/hitl/screenDecisionCards.js +362 -0
  82. package/dist/hitl/standingRows.d.ts +3 -1
  83. package/dist/hitl/standingRows.js +18 -0
  84. package/dist/hitl/toolApprovalWire.d.ts +30 -8
  85. package/dist/hitl/toolApprovalWire.js +264 -121
  86. package/dist/hooksWireCaps.js +3 -3
  87. package/dist/hostSettingNoticeArm.d.ts +3 -0
  88. package/dist/hostSettingNoticeArm.js +12 -0
  89. package/dist/hostTurnSettings.d.ts +3 -0
  90. package/dist/hostTurnSettings.js +38 -5
  91. package/dist/humanTurnRead.js +11 -1
  92. package/dist/i18n/messages.en.d.ts +129 -0
  93. package/dist/i18n/messages.en.js +135 -7
  94. package/dist/i18n/messages.zh.js +142 -6
  95. package/dist/i18n/translate.d.ts +3 -0
  96. package/dist/i18n/translate.js +78 -10
  97. package/dist/i18n/zh.d.ts +1 -0
  98. package/dist/i18n/zh.js +1 -0
  99. package/dist/index.d.ts +43 -17
  100. package/dist/index.js +30 -12
  101. package/dist/interactiveHalt.js +2 -1
  102. package/dist/interactiveInterrupt.js +20 -2
  103. package/dist/liveModelCatalog.js +2 -2
  104. package/dist/localEngineSeatReading.d.ts +2 -2
  105. package/dist/localEngineSeatReading.js +5 -3
  106. package/dist/localEngineSpawn.d.ts +0 -7
  107. package/dist/localEngineSpawn.js +0 -92
  108. package/dist/localEngineStep.d.ts +2 -2
  109. package/dist/localEngineStep.js +2 -0
  110. package/dist/mcpReconnect.js +3 -3
  111. package/dist/mcpWireCaps.js +1 -1
  112. package/dist/model/engineModelWords.d.ts +3 -0
  113. package/dist/model/engineModelWords.js +13 -0
  114. package/dist/model/subagentModelWord.d.ts +21 -2
  115. package/dist/model/subagentModelWord.js +100 -29
  116. package/dist/modelCapabilityProbe.js +3 -40
  117. package/dist/notifications.d.ts +19 -0
  118. package/dist/notifications.js +114 -12
  119. package/dist/ownKey.d.ts +6 -0
  120. package/dist/ownKey.js +31 -0
  121. package/dist/pendingUserRow.d.ts +4 -0
  122. package/dist/pendingUserRow.js +16 -0
  123. package/dist/permissionsDeclaration.d.ts +1 -0
  124. package/dist/permissionsDeclaration.js +11 -1
  125. package/dist/planReviewCardFacts.d.ts +3 -0
  126. package/dist/planReviewCardFacts.js +52 -2
  127. package/dist/pluginHooksWire.d.ts +9 -1
  128. package/dist/pluginHooksWire.js +40 -6
  129. package/dist/printToolResultFrame.js +4 -2
  130. package/dist/promptBlockedCopy.js +11 -6
  131. package/dist/promptSuggestionBatch.d.ts +7 -0
  132. package/dist/promptSuggestionBatch.js +9 -0
  133. package/dist/promptSuggestionsTail.d.ts +39 -0
  134. package/dist/promptSuggestionsTail.js +116 -0
  135. package/dist/request/taskRequest.js +10 -6
  136. package/dist/requestCoordinate.d.ts +1 -0
  137. package/dist/requestCoordinate.js +13 -0
  138. package/dist/rewindArchiveReading.js +4 -4
  139. package/dist/runCancelContext.d.ts +2 -1
  140. package/dist/runCancelContext.js +1 -0
  141. package/dist/runPermissionModeSwitch.js +2 -2
  142. package/dist/scenarioRefusal.js +11 -13
  143. package/dist/scenarioSkills.js +11 -6
  144. package/dist/seam.d.ts +16 -2
  145. package/dist/seam.js +10 -0
  146. package/dist/seatContract.d.ts +109 -9
  147. package/dist/seatContract.js +218 -15
  148. package/dist/sessionCostReading.d.ts +70 -0
  149. package/dist/sessionCostReading.js +150 -0
  150. package/dist/sessionHooksRoster.d.ts +4 -0
  151. package/dist/sessionHooksRoster.js +158 -0
  152. package/dist/sessionMemoryStatus.js +2 -2
  153. package/dist/sessionReadRedaction.d.ts +7 -0
  154. package/dist/sessionReadRedaction.js +26 -0
  155. package/dist/sessionSyncFileHistory.js +8 -9
  156. package/dist/settingsHooksSalvage.js +2 -1
  157. package/dist/sseIdleTriage.js +2 -1
  158. package/dist/storeDurabilityWord.d.ts +15 -0
  159. package/dist/storeDurabilityWord.js +18 -0
  160. package/dist/storePostureCapability.d.ts +7 -3
  161. package/dist/storePostureCapability.js +69 -39
  162. package/dist/subagent/engineSubagentResume.js +2 -2
  163. package/dist/subagent/engineSubagentTail.js +2 -1
  164. package/dist/subagentContentStore.d.ts +11 -0
  165. package/dist/subagentContentStore.js +28 -2
  166. package/dist/toolResult.d.ts +1 -0
  167. package/dist/toolResult.js +2 -0
  168. package/dist/userAttachmentEnvelope.d.ts +2 -1
  169. package/dist/userAttachmentEnvelope.js +10 -0
  170. package/dist/wireErrorTriage.js +2 -1
  171. package/dist/wireFailureShape.d.ts +4 -0
  172. package/dist/wireFailureShape.js +141 -19
  173. package/dist/wireRefusalCopy.d.ts +6 -5
  174. package/dist/wireRefusalCopy.js +49 -92
  175. package/docs/INTEGRATION-CLIENTS.md +2118 -17
  176. package/package.json +6 -2
@@ -133,6 +133,35 @@ export function readCcImportRedeemCounts(body) {
133
133
  return null;
134
134
  }
135
135
  }
136
+ const isCount = (r) => r.presence === 'present' && typeof r.value === 'number' && Number.isSafeInteger(r.value) && r.value >= 0;
137
+ const NO_REFUSED_ROWS = Object.freeze([]);
138
+ const NO_REFUSED = Object.freeze({ count: 0, rows: NO_REFUSED_ROWS });
139
+ export function refusedRowOf(counts) {
140
+ try {
141
+ if (typeof counts !== 'object' || counts === null)
142
+ return null;
143
+ if (!isCount(slotReadOf(counts, 'persisted')) || !isCount(slotReadOf(counts, 'deduped')))
144
+ return null;
145
+ const slot = slotReadOf(counts, 'refused');
146
+ if (slot.presence === 'absent')
147
+ return NO_REFUSED;
148
+ if (slot.presence !== 'present')
149
+ return null;
150
+ const rows = ownArrayItems(slot.value);
151
+ if (rows === undefined)
152
+ return null;
153
+ const kept = [];
154
+ for (const row of rows) {
155
+ if (typeof row !== 'object' || row === null)
156
+ return null;
157
+ kept.push(row);
158
+ }
159
+ return kept.length === 0 ? NO_REFUSED : Object.freeze({ count: kept.length, rows: Object.freeze(kept) });
160
+ }
161
+ catch {
162
+ return null;
163
+ }
164
+ }
136
165
  export function classifyRulesFailure(e, context) {
137
166
  const { status, errorCode, message, retryAfterSec, committed } = wireFailureShapeOf(e);
138
167
  if (errorCode === 'capability.rule_store_required') {
@@ -635,6 +664,47 @@ export function classifySkippedReason(reason) {
635
664
  return { text };
636
665
  return { code: head, text };
637
666
  }
667
+ const CC_IMPORT_SKIPPED_READ_BUDGET = 20_000;
668
+ const CC_IMPORT_SKIPPED_SHOWN_MAX = 2000;
669
+ function ccImportSkippedReading(shape, groups, unreadable) {
670
+ return Object.freeze({ shape, groups: Object.freeze([...groups]), unreadable });
671
+ }
672
+ export function ccImportSkippedRowsOf(skipped) {
673
+ if (skipped === undefined)
674
+ return ccImportSkippedReading('absent', [], 0);
675
+ const grouped = new Map();
676
+ let unreadable = 0;
677
+ try {
678
+ if (!Array.isArray(skipped))
679
+ return ccImportSkippedReading('malformed', [], 0);
680
+ const length = readOwnDataValue(skipped, 'length');
681
+ if (typeof length !== 'number' || !Number.isSafeInteger(length) || length < 0 || length > CC_IMPORT_SKIPPED_READ_BUDGET)
682
+ return ccImportSkippedReading('malformed', [], 0);
683
+ for (let i = 0; i < length; i++) {
684
+ const row = guardedRead(() => readOwnDataValue(skipped, String(i)));
685
+ const rule = typeof row === 'object' && row !== null ? guardedRead(() => readOwnDataValue(row, 'rule')) : undefined;
686
+ const reason = typeof row === 'object' && row !== null ? guardedRead(() => readOwnDataValue(row, 'reason')) : undefined;
687
+ if (typeof rule !== 'string' || typeof reason !== 'string') {
688
+ unreadable += 1;
689
+ continue;
690
+ }
691
+ const entries = grouped.get(reason);
692
+ if (entries === undefined)
693
+ grouped.set(reason, [displayUntrusted(rule, { max: CC_IMPORT_SKIPPED_SHOWN_MAX })]);
694
+ else
695
+ entries.push(displayUntrusted(rule, { max: CC_IMPORT_SKIPPED_SHOWN_MAX }));
696
+ }
697
+ }
698
+ catch {
699
+ return ccImportSkippedReading('malformed', [], 0);
700
+ }
701
+ const groups = [];
702
+ for (const [raw, entries] of grouped) {
703
+ const code = classifySkippedReason(raw).code;
704
+ groups.push(Object.freeze({ entries: Object.freeze(entries), reason: displayUntrusted(raw, { max: CC_IMPORT_SKIPPED_SHOWN_MAX }), ...(code !== undefined ? { code } : {}) }));
705
+ }
706
+ return ccImportSkippedReading('read', groups, unreadable);
707
+ }
638
708
  export function readRulePersistOutcome(ack) {
639
709
  const parsed = readToolApprovalRespondAck(ack);
640
710
  if (parsed === undefined || isToolApprovalRespondReplayed(parsed) || isToolApprovalRespondParkedRedeemed(parsed))
@@ -41,6 +41,8 @@ export interface PlanReviewCardView {
41
41
  readonly note?: string;
42
42
  }
43
43
  export declare function planReviewCardViewOf(frame: object | null | undefined, lang?: UiLanguage): PlanReviewCardView | undefined;
44
+ export type PlanReviewEvidenceMove = 'same' | 'moved' | 'unknown';
45
+ export declare function planReviewEvidenceMovedOf(shown: object | null | undefined, latest: object | null | undefined): PlanReviewEvidenceMove;
44
46
  export declare function notePlanReviewAnsweredIfDecisive(questionId: unknown, answer: QuestionAnswer | null | undefined): void;
45
47
  export { isPlanReviewPark };
46
48
  export declare function _resetArmedPlanReviewsForTest(): void;
@@ -79,6 +81,7 @@ export interface PlanReviewOutcomeMeta {
79
81
  decision: 'approve' | 'reject' | 'ask_again';
80
82
  effect: PlanReviewDecisionEffect;
81
83
  cause?: 'stored_form_unsupported';
84
+ questionId?: string;
82
85
  }
83
86
  export declare function planReviewOutcomeTail(taskId: string, decision: 'approve' | 'reject', effect: PlanReviewDecisionEffect, cause?: 'stored_form_unsupported'): string;
84
87
  export type PlanReviewWireClient = {
@@ -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
  }
@@ -524,7 +540,7 @@ export function armPlanReviewApproval(result, sessionKey, opts) {
524
540
  const cardDelivery = cardReason !== undefined ? { ...delivery, reason: cardReason } : delivery;
525
541
  notePlanReviewAnswered(questionId);
526
542
  hostLog('debug', `planReviewWire: arm responder delivering ${decided} for task ${taskId} (path=arm)`);
527
- void decidePlanReviewFor(taskId, decided, modeAfter, cardDelivery, facts);
543
+ void decidePlanReviewFor(taskId, decided, modeAfter, cardDelivery, facts, questionId);
528
544
  return { ok: true };
529
545
  };
530
546
  unregister = registerLocalQuestionResponder(questionId, responder, onWithdraw);
@@ -725,7 +741,7 @@ function askAgainReasonOf(card, opts) {
725
741
  return renderMessage(msg('approval.planReview.askAgain.unknown'), DATA_FACE_LANGUAGE);
726
742
  }
727
743
  }
728
- async function decidePlanReviewFor(taskId, decision, permissionModeAfter, opts, card) {
744
+ async function decidePlanReviewFor(taskId, decision, permissionModeAfter, opts, card, cardId) {
729
745
  if (typeof taskId === 'string' && planReviewOpsOf(taskId).some((op) => op.phase === 'posting')) {
730
746
  hostLog('error', `planReviewWire: decidePlanReview(${decision}) for task ${taskId} REFUSED — a decision for this task is already in flight (duplicate delivery latched)`);
731
747
  return;
@@ -758,7 +774,7 @@ async function decidePlanReviewFor(taskId, decision, permissionModeAfter, opts,
758
774
  try {
759
775
  const wireDecision = decision === 'ask_again' ? 'reject' : decision;
760
776
  const wireOpts = decision === 'ask_again' ? { ...opts, reason: askAgainReasonOf(card, opts) } : opts;
761
- await decidePlanReviewInner(taskId, wireDecision, permissionModeAfter, dispatchNo, releaseLatch, settle, wireOpts, card, decision);
777
+ await decidePlanReviewInner(taskId, wireDecision, permissionModeAfter, dispatchNo, releaseLatch, settle, wireOpts, card, decision, cardId);
762
778
  }
763
779
  finally {
764
780
  releaseLatch();
@@ -779,7 +795,7 @@ function planReviewClientsFor(resolved) {
779
795
  repull: () => resolved.make({ timeoutMs: 15_000 }),
780
796
  };
781
797
  }
782
- 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) {
783
799
  let outcome;
784
800
  let decisionReason;
785
801
  const gateBefore = card?.checkpointId;
@@ -1019,7 +1035,7 @@ async function decidePlanReviewInner(taskId, decision, permissionModeAfter, disp
1019
1035
  const onOutcome = opts?.onOutcome;
1020
1036
  settle(effect === 'not_sent' || effect === 'still_parked');
1021
1037
  try {
1022
- 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 } : {}) });
1023
1039
  if (!delivered) {
1024
1040
  if (onOutcome !== undefined) {
1025
1041
  hostLog('debug', `planReviewWire: outcome queue port not installed for task ${taskId} — outcome handed to the host's onOutcome callback only`);
@@ -1039,6 +1055,7 @@ async function decidePlanReviewInner(taskId, decision, permissionModeAfter, disp
1039
1055
  decision: semanticDecision,
1040
1056
  effect,
1041
1057
  ...(effect === 'still_parked' && stillParkedCause !== undefined ? { cause: stillParkedCause } : {}),
1058
+ ...(cardId !== undefined ? { questionId: cardId } : {}),
1042
1059
  detail: outcome,
1043
1060
  tail,
1044
1061
  prompt,
@@ -1160,7 +1177,7 @@ function mintPlanReviewReopenCard(taskId, opts, sessionKey, receiptMs, taken) {
1160
1177
  ((tid, decision, reason, card) => {
1161
1178
  hostLog('debug', `planReviewWire: reopen responder delivering ${decision} for task ${tid} (path=reopen-default)`);
1162
1179
  const withReason = reason === undefined ? delivery : { ...delivery, reason };
1163
- void decidePlanReviewFor(tid, decision, undefined, withReason, card);
1180
+ void decidePlanReviewFor(tid, decision, undefined, withReason, card, questionId);
1164
1181
  });
1165
1182
  const activeKey = `${sessionKey}\u0000${canonicalId}`;
1166
1183
  let unregister = () => { };
@@ -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[];