@sema-agent/client-core 0.100.0 → 0.102.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 (358) hide show
  1. package/CHANGELOG.md +452 -0
  2. package/README.md +172 -120
  3. package/dist/adapt/arms.js +51 -16
  4. package/dist/adapt/textStream.js +7 -4
  5. package/dist/adapt/toolCards.d.ts +2 -1
  6. package/dist/adapt/toolCards.js +28 -13
  7. package/dist/adapt.d.ts +1 -1
  8. package/dist/adapt.js +8 -2
  9. package/dist/adapter/activeRunSelfHeal.d.ts +24 -2
  10. package/dist/adapter/activeRunSelfHeal.js +108 -6
  11. package/dist/adapter/downstream/eventToSdkMessage.js +38 -79
  12. package/dist/adapter/downstream/terminalToSdkResult.d.ts +60 -1
  13. package/dist/adapter/downstream/terminalToSdkResult.js +209 -39
  14. package/dist/adapter/downstream/wiringManifestView.d.ts +1 -0
  15. package/dist/adapter/downstream/wiringManifestView.js +138 -0
  16. package/dist/adapter/runStream.d.ts +4 -4
  17. package/dist/adapter/runStream.js +158 -43
  18. package/dist/agentsWireCaps.d.ts +2 -7
  19. package/dist/agentsWireCaps.js +1 -2
  20. package/dist/approvalDecidedByCapability.js +2 -2
  21. package/dist/approvalFrameFamilies.d.ts +33 -0
  22. package/dist/approvalFrameFamilies.js +120 -0
  23. package/dist/approvalsStreamLiveCapability.js +2 -2
  24. package/dist/attachmentsWireCaps.js +41 -13
  25. package/dist/callerCwdCapability.js +2 -2
  26. package/dist/centerWiringCapability.js +2 -2
  27. package/dist/clockReading.d.ts +2 -0
  28. package/dist/clockReading.js +4 -0
  29. package/dist/cloudConfigWireCaps.d.ts +19 -5
  30. package/dist/cloudConfigWireCaps.js +193 -56
  31. package/dist/compensations.js +1 -1
  32. package/dist/coreValuePorts.d.ts +12 -2
  33. package/dist/coreValuePorts.js +9 -0
  34. package/dist/decideFailureNote.js +5 -3
  35. package/dist/decideReceipt.js +2 -2
  36. package/dist/deviceExecutorManagementCapability.js +2 -2
  37. package/dist/deviceFlowPolling.js +1 -1
  38. package/dist/disableSkillsWire.d.ts +1 -1
  39. package/dist/disableSkillsWire.js +4 -3
  40. package/dist/displayUntrusted.d.ts +9 -4
  41. package/dist/displayUntrusted.js +834 -104
  42. package/dist/engineCapReader.js +1 -1
  43. package/dist/engineConfigDrift.js +1 -1
  44. package/dist/engineErrorCodes.d.ts +14 -5
  45. package/dist/engineErrorCodes.js +27 -6
  46. package/dist/engineGenerationConvergence.d.ts +39 -0
  47. package/dist/engineGenerationConvergence.js +95 -0
  48. package/dist/engineGenerationPort.d.ts +61 -0
  49. package/dist/engineGenerationPort.js +144 -0
  50. package/dist/engineHealthFacts.d.ts +23 -0
  51. package/dist/engineHealthFacts.js +92 -0
  52. package/dist/engineIdentity.d.ts +4 -0
  53. package/dist/engineIdentity.js +11 -0
  54. package/dist/engineNoticeCodes.d.ts +2 -5
  55. package/dist/engineRowRef.js +4 -0
  56. package/dist/engineSessionMessages.js +2 -2
  57. package/dist/engineToolDirectory.js +2 -2
  58. package/dist/engineWireFor.d.ts +99 -0
  59. package/dist/engineWireFor.js +248 -6
  60. package/dist/engineWireTarget.d.ts +1 -0
  61. package/dist/engineWireTarget.js +8 -0
  62. package/dist/env/uiLanguage.js +1 -1
  63. package/dist/errorSupplementRoles.d.ts +3 -0
  64. package/dist/errorSupplementRoles.js +37 -0
  65. package/dist/executionLaneCapability.js +2 -2
  66. package/dist/fileHistoryCaptureCapability.js +3 -3
  67. package/dist/finalVerifyWire.d.ts +6 -3
  68. package/dist/finalVerifyWire.js +6 -23
  69. package/dist/flagInput.d.ts +4 -0
  70. package/dist/flagInput.js +24 -0
  71. package/dist/fleet/fleetLedger.js +5 -2
  72. package/dist/fleet/fleetProjection.d.ts +1 -0
  73. package/dist/fleet/fleetProjection.js +16 -3
  74. package/dist/gateVocabulary.js +3 -0
  75. package/dist/generated/engineFactTables.d.ts +7 -3
  76. package/dist/generated/engineFactTables.js +52 -0
  77. package/dist/generated/engineNoticeTables.js +12 -0
  78. package/dist/generated/settingsSchemaActiveTiers.d.ts +1 -0
  79. package/dist/generated/settingsSchemaActiveTiers.js +14 -0
  80. package/dist/generated/settingsSchemaCallerTextEcho.d.ts +1 -0
  81. package/dist/generated/settingsSchemaCallerTextEcho.js +8 -0
  82. package/dist/generated/settingsSchemaControlAndBidi.d.ts +1 -0
  83. package/dist/generated/settingsSchemaControlAndBidi.js +8 -0
  84. package/dist/generated/settingsSchemaDefaultModel.d.ts +11 -0
  85. package/dist/generated/settingsSchemaDefaultModel.js +25 -0
  86. package/dist/generated/settingsSchemaFns.d.ts +54 -0
  87. package/dist/generated/settingsSchemaFns.js +26 -1
  88. package/dist/generated/settingsSchemaMcpRequestEntry.d.ts +1 -1
  89. package/dist/generated/settingsSchemaMcpRequestEntry.js +1 -7
  90. package/dist/generated/settingsSchemaSafetyMergeSpec.d.ts +1 -0
  91. package/dist/generated/settingsSchemaSafetyMergeSpec.js +95 -0
  92. package/dist/generated/settingsSchemaSettingsSources.d.ts +1 -0
  93. package/dist/generated/settingsSchemaSettingsSources.js +58 -0
  94. package/dist/generated/settingsSchemaTables.d.ts +2 -0
  95. package/dist/generated/settingsSchemaTables.js +13 -0
  96. package/dist/generated/settingsSchemaUrlPattern.d.ts +1 -0
  97. package/dist/generated/settingsSchemaUrlPattern.js +183 -0
  98. package/dist/headlessPermissionModeWire.d.ts +18 -2
  99. package/dist/headlessPermissionModeWire.js +30 -19
  100. package/dist/hitl/allowRuleShadow.js +7 -5
  101. package/dist/hitl/approvalCardReading.d.ts +3 -0
  102. package/dist/hitl/approvalCardReading.js +17 -0
  103. package/dist/hitl/approvalCompleteParked.js +1 -1
  104. package/dist/hitl/approvalDelivery.d.ts +87 -0
  105. package/dist/hitl/approvalDelivery.js +193 -0
  106. package/dist/hitl/approvalResolution.d.ts +11 -0
  107. package/dist/hitl/approvalResolution.js +50 -11
  108. package/dist/hitl/askClassPair.d.ts +6 -0
  109. package/dist/hitl/askClassPair.js +30 -3
  110. package/dist/hitl/askParkAutoReopenBlock.d.ts +30 -0
  111. package/dist/hitl/askParkAutoReopenBlock.js +117 -0
  112. package/dist/hitl/askParkRowRouting.js +4 -1
  113. package/dist/hitl/attributionLadder.d.ts +42 -3
  114. package/dist/hitl/attributionLadder.js +79 -8
  115. package/dist/hitl/automaticAnswerVerdict.d.ts +6 -1
  116. package/dist/hitl/automaticAnswerVerdict.js +46 -11
  117. package/dist/hitl/crashConverged.js +2 -2
  118. package/dist/hitl/decisionConflict.d.ts +6 -2
  119. package/dist/hitl/decisionConflict.js +24 -9
  120. package/dist/hitl/decisionRefusal.d.ts +20 -10
  121. package/dist/hitl/decisionRefusal.js +99 -54
  122. package/dist/hitl/decisionSend.d.ts +3 -0
  123. package/dist/hitl/decisionSend.js +87 -103
  124. package/dist/hitl/frameRouter.d.ts +1 -0
  125. package/dist/hitl/frameRouter.js +9 -2
  126. package/dist/hitl/hitlBridge.d.ts +18 -6
  127. package/dist/hitl/hitlBridge.js +41 -37
  128. package/dist/hitl/livePendingAsk.js +4 -3
  129. package/dist/hitl/noAllowCause.js +1 -1
  130. package/dist/hitl/parkResolver.js +3 -2
  131. package/dist/hitl/persistedRulesWire.js +1 -0
  132. package/dist/hitl/planReviewWire.d.ts +4 -0
  133. package/dist/hitl/planReviewWire.js +59 -30
  134. package/dist/hitl/resumeRunningCard.d.ts +3 -2
  135. package/dist/hitl/resumeRunningCard.js +17 -11
  136. package/dist/hitl/sessionPolicyDeliverable.d.ts +5 -2
  137. package/dist/hitl/sessionPolicyDeliverable.js +62 -29
  138. package/dist/hitl/sessionPolicyWire.d.ts +13 -3
  139. package/dist/hitl/sessionPolicyWire.js +81 -16
  140. package/dist/hitl/standingRows.js +1 -1
  141. package/dist/hitl/toolApprovalWire.d.ts +9 -10
  142. package/dist/hitl/toolApprovalWire.js +72 -54
  143. package/dist/hookMatcherVerdict.d.ts +2 -0
  144. package/dist/hookMatcherVerdict.js +12 -0
  145. package/dist/hooksCompactTransition.d.ts +19 -0
  146. package/dist/hooksCompactTransition.js +41 -0
  147. package/dist/hooksWireCaps.d.ts +1 -1
  148. package/dist/hooksWireCaps.js +202 -203
  149. package/dist/host.d.ts +1 -14
  150. package/dist/host.js +0 -8
  151. package/dist/hostCallbackGuard.d.ts +1 -0
  152. package/dist/hostCallbackGuard.js +1 -1
  153. package/dist/hostSettingsSource.d.ts +172 -0
  154. package/dist/hostSettingsSource.js +675 -0
  155. package/dist/hostTurnSettings.d.ts +73 -17
  156. package/dist/hostTurnSettings.js +594 -97
  157. package/dist/httpHookPolicy.d.ts +37 -0
  158. package/dist/httpHookPolicy.js +176 -0
  159. package/dist/humanTurn.d.ts +2 -1
  160. package/dist/humanTurn.js +37 -7
  161. package/dist/humanTurnRead.js +4 -3
  162. package/dist/humanTurnSentences.d.ts +10 -0
  163. package/dist/humanTurnSentences.js +74 -0
  164. package/dist/i18n/messages.en.d.ts +222 -2
  165. package/dist/i18n/messages.en.js +225 -5
  166. package/dist/i18n/messages.zh.js +237 -5
  167. package/dist/i18n/translate.js +3 -3
  168. package/dist/index.d.ts +77 -15
  169. package/dist/index.js +50 -13
  170. package/dist/inheritEnvCapability.d.ts +3 -1
  171. package/dist/inheritEnvCapability.js +31 -17
  172. package/dist/inheritEnvWire.d.ts +2 -1
  173. package/dist/inheritEnvWire.js +11 -5
  174. package/dist/interactiveHalt.d.ts +3 -1
  175. package/dist/interactiveHalt.js +2 -0
  176. package/dist/interactiveInterrupt.d.ts +2 -0
  177. package/dist/interactiveInterrupt.js +15 -0
  178. package/dist/interactiveToolsWire.d.ts +4 -2
  179. package/dist/interactiveToolsWire.js +5 -5
  180. package/dist/jsonFaithful.d.ts +20 -0
  181. package/dist/jsonFaithful.js +152 -0
  182. package/dist/limitsWire.d.ts +7 -2
  183. package/dist/limitsWire.js +19 -13
  184. package/dist/liveInitToolFace.d.ts +6 -1
  185. package/dist/liveInitToolFace.js +5 -3
  186. package/dist/liveModelCatalog.d.ts +22 -0
  187. package/dist/liveModelCatalog.js +132 -18
  188. package/dist/mcpPanel.js +1 -1
  189. package/dist/mcpProbeCapability.js +2 -2
  190. package/dist/mcpStatusSupersetKeys.d.ts +24 -0
  191. package/dist/mcpStatusSupersetKeys.js +45 -0
  192. package/dist/mcpToolToggles.js +2 -1
  193. package/dist/mcpWireCaps.d.ts +39 -1
  194. package/dist/mcpWireCaps.js +254 -50
  195. package/dist/memoryComplianceCapability.js +2 -2
  196. package/dist/memoryOriginCapability.js +2 -2
  197. package/dist/model/catalogDefault.d.ts +24 -0
  198. package/dist/model/catalogDefault.js +4 -0
  199. package/dist/model/liveCatalogShape.js +5 -4
  200. package/dist/model/modelsPolicy.js +4 -3
  201. package/dist/model/onboardJudgement.d.ts +1 -0
  202. package/dist/model/onboardJudgement.js +1 -1
  203. package/dist/model/subagentModelWord.js +2 -2
  204. package/dist/modelCapabilityProbe.js +6 -6
  205. package/dist/modelIdentityResolvability.d.ts +10 -1
  206. package/dist/modelIdentityResolvability.js +62 -39
  207. package/dist/modsFace.d.ts +8 -0
  208. package/dist/modsFace.js +59 -0
  209. package/dist/modsKernelIdentity.d.ts +10 -0
  210. package/dist/modsKernelIdentity.js +103 -0
  211. package/dist/modsKernelTransit.d.ts +8 -0
  212. package/dist/modsKernelTransit.js +6 -0
  213. package/dist/notifications.d.ts +30 -12
  214. package/dist/notifications.js +241 -53
  215. package/dist/outputStyleSeatCapability.js +2 -2
  216. package/dist/ownKey.d.ts +12 -0
  217. package/dist/ownKey.js +179 -3
  218. package/dist/panelReduce.js +1 -1
  219. package/dist/peerFrames.d.ts +1 -1
  220. package/dist/peerFrames.js +6 -2
  221. package/dist/peerLaneCapability.js +2 -2
  222. package/dist/permissionModesCapability.js +4 -4
  223. package/dist/permissionRuleIssue.js +2 -0
  224. package/dist/permissionRulesWriteCapability.js +2 -2
  225. package/dist/permissionsAllowGrantCapability.js +2 -2
  226. package/dist/permissionsDeclaration.d.ts +43 -4
  227. package/dist/permissionsDeclaration.js +102 -35
  228. package/dist/pluginHooksWire.d.ts +20 -4
  229. package/dist/pluginHooksWire.js +92 -53
  230. package/dist/prepareRefusal.d.ts +3 -2
  231. package/dist/prepareRefusal.js +27 -9
  232. package/dist/printInitToolFace.js +2 -2
  233. package/dist/printModelStatus.js +1 -1
  234. package/dist/printToolResultFrame.js +1 -1
  235. package/dist/projectMemory.d.ts +32 -0
  236. package/dist/projectMemory.js +70 -0
  237. package/dist/promptBlockedCopy.d.ts +2 -1
  238. package/dist/promptBlockedCopy.js +2 -1
  239. package/dist/promptDelivery.d.ts +23 -3
  240. package/dist/promptDelivery.js +169 -30
  241. package/dist/providerRejection.d.ts +19 -1
  242. package/dist/providerRejection.js +75 -4
  243. package/dist/queuedDelivery.d.ts +48 -0
  244. package/dist/queuedDelivery.js +233 -0
  245. package/dist/reattachWindow.d.ts +94 -0
  246. package/dist/reattachWindow.js +127 -0
  247. package/dist/request/printNotification.d.ts +1 -1
  248. package/dist/request/printNotification.js +6 -2
  249. package/dist/request/submissionIdentity.d.ts +37 -0
  250. package/dist/request/submissionIdentity.js +65 -0
  251. package/dist/request/taskRequest.d.ts +33 -4
  252. package/dist/request/taskRequest.js +341 -156
  253. package/dist/resultFrameKeys.d.ts +1 -0
  254. package/dist/resultFrameKeys.js +4 -1
  255. package/dist/retryStatus.d.ts +8 -0
  256. package/dist/retryStatus.js +57 -9
  257. package/dist/rewindArchiveCapability.js +2 -2
  258. package/dist/rewindEngineAction.d.ts +2 -0
  259. package/dist/rewindEngineAction.js +23 -1
  260. package/dist/rowKind.d.ts +36 -0
  261. package/dist/rowKind.js +97 -0
  262. package/dist/ruleCompileVerdict.d.ts +18 -0
  263. package/dist/ruleCompileVerdict.js +67 -2
  264. package/dist/ruleReadings.d.ts +58 -0
  265. package/dist/ruleReadings.js +132 -0
  266. package/dist/ruleRefusalSentence.d.ts +4 -0
  267. package/dist/ruleRefusalSentence.js +9 -3
  268. package/dist/runCancelContext.d.ts +0 -1
  269. package/dist/runCancelContext.js +1 -2
  270. package/dist/runTerminal.d.ts +5 -0
  271. package/dist/runTerminal.js +52 -17
  272. package/dist/sandboxWire.d.ts +1 -1
  273. package/dist/sandboxWire.js +4 -6
  274. package/dist/scenarioRefusal.js +1 -1
  275. package/dist/scenarioSkills.d.ts +20 -0
  276. package/dist/scenarioSkills.js +72 -0
  277. package/dist/scenarioWire.d.ts +5 -2
  278. package/dist/scenarioWire.js +9 -9
  279. package/dist/sealedKeyCapability.js +2 -2
  280. package/dist/seam.d.ts +2 -0
  281. package/dist/seam.js +3 -3
  282. package/dist/seatContract.d.ts +68 -7
  283. package/dist/seatContract.js +84 -25
  284. package/dist/selfOrchestrationDenial.js +1 -1
  285. package/dist/sessionBackground.d.ts +165 -0
  286. package/dist/sessionBackground.js +781 -0
  287. package/dist/sessionBackgroundHandoff.d.ts +54 -0
  288. package/dist/sessionBackgroundHandoff.js +321 -0
  289. package/dist/sessionMap.js +4 -1
  290. package/dist/sessionPolicyCapability.js +2 -2
  291. package/dist/sessionRulesChildrenReadLive.d.ts +6 -0
  292. package/dist/sessionRulesChildrenReadLive.js +5 -0
  293. package/dist/sessionRulesNamespaceFormsCapability.d.ts +12 -0
  294. package/dist/sessionRulesNamespaceFormsCapability.js +29 -0
  295. package/dist/sessionSyncFileHistoryCapability.js +2 -2
  296. package/dist/settingsCredentialKeyPaths.js +55 -15
  297. package/dist/settingsHooksSalvage.d.ts +1 -0
  298. package/dist/settingsHooksSalvage.js +7 -1
  299. package/dist/settingsLayerAdmission.d.ts +4 -0
  300. package/dist/settingsLayerAdmission.js +16 -0
  301. package/dist/skillToolListsCapability.js +6 -5
  302. package/dist/skillsWireCaps.d.ts +14 -0
  303. package/dist/skillsWireCaps.js +47 -16
  304. package/dist/slashCommandGate.d.ts +24 -0
  305. package/dist/slashCommandGate.js +74 -0
  306. package/dist/slashCommandTable.d.ts +14 -0
  307. package/dist/slashCommandTable.js +99 -0
  308. package/dist/sqlEngineCapability.js +2 -2
  309. package/dist/steerPriorityCapability.js +2 -2
  310. package/dist/storePostureCapability.js +2 -2
  311. package/dist/subagent/agentStateDetail.js +1 -1
  312. package/dist/subagent/engineDelegatedPrompt.d.ts +9 -0
  313. package/dist/subagent/engineDelegatedPrompt.js +38 -7
  314. package/dist/subagent/engineRowStopGate.js +2 -2
  315. package/dist/subagent/engineSubagentResume.js +3 -3
  316. package/dist/subagent/engineTaskHandleWire.d.ts +1 -0
  317. package/dist/subagent/engineTaskHandleWire.js +10 -0
  318. package/dist/submitFailure.d.ts +8 -0
  319. package/dist/submitFailure.js +17 -0
  320. package/dist/supportFloor.d.ts +1 -0
  321. package/dist/supportFloor.js +7 -0
  322. package/dist/terminationIntent.d.ts +55 -0
  323. package/dist/terminationIntent.js +352 -0
  324. package/dist/thinkingLatch.d.ts +69 -0
  325. package/dist/thinkingLatch.js +255 -0
  326. package/dist/thinkingLatchWords.d.ts +7 -0
  327. package/dist/thinkingLatchWords.js +4 -0
  328. package/dist/toolHistoryMismatch.d.ts +8 -0
  329. package/dist/toolHistoryMismatch.js +37 -6
  330. package/dist/toolResult.d.ts +13 -3
  331. package/dist/toolResult.js +159 -32
  332. package/dist/toolResultContent.d.ts +13 -0
  333. package/dist/toolResultContent.js +82 -7
  334. package/dist/toolRoster.d.ts +18 -0
  335. package/dist/toolRoster.js +64 -0
  336. package/dist/turnFailurePresentation.js +27 -90
  337. package/dist/usageLimitAutoResume.d.ts +74 -0
  338. package/dist/usageLimitAutoResume.js +227 -0
  339. package/dist/userAttachmentEnvelope.js +1 -1
  340. package/dist/userAttachmentSeat.js +5 -5
  341. package/dist/userInvokedSkillsCapability.js +2 -2
  342. package/dist/webSearchBackendCapability.js +2 -2
  343. package/dist/wireErrorTriage.js +99 -50
  344. package/dist/wireFailureShape.d.ts +25 -1
  345. package/dist/wireFailureShape.js +92 -5
  346. package/dist/wireRefusalCopy.d.ts +24 -1
  347. package/dist/wireRefusalCopy.js +253 -32
  348. package/dist/wiringFleetDoctor.d.ts +3 -0
  349. package/dist/wiringFleetDoctor.js +21 -0
  350. package/dist/workflow.d.ts +2 -1
  351. package/dist/workflow.js +38 -1
  352. package/dist/workflowClient.d.ts +2 -7
  353. package/dist/workflowsJournalCapability.js +2 -2
  354. package/dist/writeProtectionCapability.js +2 -2
  355. package/docs/INTEGRATION-CLIENTS.md +907 -182
  356. package/package.json +14 -3
  357. package/dist/argvFlagValue.d.ts +0 -8
  358. package/dist/argvFlagValue.js +0 -37
@@ -0,0 +1,255 @@
1
+ import { readOwnDataValue } from './ownKey.js';
2
+ import { msg, renderMessage } from './i18n/translate.js';
3
+ import { quoteUntrustedForSentence } from './displayUntrusted.js';
4
+ import { seatCapabilityUnavailableDetail } from './seatContract.js';
5
+ import { THINKING_LATCH_EVENTS, } from './thinkingLatchWords.js';
6
+ const UNSET_WHYS = Object.freeze(['no_port', 'never_set', 'unreadable', 'malformed']);
7
+ const THINKING_LATCH_TRANSITIONS = Object.freeze({
8
+ on: Object.freeze({ on: 'on', off: 'off', toggle: 'off', clear: 'unset' }),
9
+ off: Object.freeze({ on: 'on', off: 'off', toggle: 'on', clear: 'unset' }),
10
+ unset: Object.freeze({ on: 'on', off: 'off', toggle: 'off', clear: 'unset' }),
11
+ });
12
+ const storedOf = (state) => (state === 'on' ? true : state === 'off' ? false : undefined);
13
+ const setReading = (state) => Object.freeze({ state });
14
+ const unsetReading = (why) => Object.freeze({ state: 'unset', why });
15
+ function normalizedReading(v) {
16
+ try {
17
+ if (typeof v !== 'object' || v === null)
18
+ return unsetReading('malformed');
19
+ const state = readOwnDataValue(v, 'state');
20
+ if (state === 'on' || state === 'off')
21
+ return setReading(state);
22
+ if (state !== 'unset')
23
+ return unsetReading('malformed');
24
+ const why = readOwnDataValue(v, 'why');
25
+ return typeof why === 'string' && UNSET_WHYS.includes(why) ? unsetReading(why) : unsetReading('malformed');
26
+ }
27
+ catch {
28
+ return unsetReading('malformed');
29
+ }
30
+ }
31
+ export function readThinkingLatch(port) {
32
+ if (port === undefined || port === null)
33
+ return unsetReading('no_port');
34
+ let stored;
35
+ try {
36
+ const read = port.read;
37
+ if (typeof read !== 'function')
38
+ return unsetReading('unreadable');
39
+ stored = Reflect.apply(read, port, []);
40
+ }
41
+ catch {
42
+ return unsetReading('unreadable');
43
+ }
44
+ if (stored === true)
45
+ return setReading('on');
46
+ if (stored === false)
47
+ return setReading('off');
48
+ if (stored === undefined)
49
+ return unsetReading('never_set');
50
+ return unsetReading('malformed');
51
+ }
52
+ export function writeThinkingLatch(port, event) {
53
+ if (port === undefined || port === null)
54
+ return Object.freeze({ kind: 'not_saved', why: 'no_port', previous: unsetReading('no_port') });
55
+ const previous = readThinkingLatch(port);
56
+ const ev = event;
57
+ if (typeof ev !== 'string' || !THINKING_LATCH_EVENTS.includes(ev)) {
58
+ return Object.freeze({ kind: 'not_saved', why: 'bad_event', previous });
59
+ }
60
+ const target = THINKING_LATCH_TRANSITIONS[previous.state][ev];
61
+ const clean = previous.why === undefined || previous.why === 'never_set';
62
+ if (clean && target === previous.state)
63
+ return Object.freeze({ kind: 'unchanged', state: target });
64
+ let wrote = false;
65
+ try {
66
+ const write = port.write;
67
+ if (typeof write === 'function') {
68
+ Reflect.apply(write, port, [storedOf(target)]);
69
+ wrote = true;
70
+ }
71
+ }
72
+ catch {
73
+ wrote = false;
74
+ }
75
+ if (!wrote)
76
+ return Object.freeze({ kind: 'not_saved', why: 'write_failed', attempted: target, now: readThinkingLatch(port) });
77
+ return Object.freeze({ kind: 'saved', previous, state: target });
78
+ }
79
+ const ownSlotOf = (v, key) => {
80
+ try {
81
+ const d = Object.getOwnPropertyDescriptor(v, key);
82
+ if (d === undefined)
83
+ return { kind: 'absent' };
84
+ return Object.hasOwn(d, 'value') ? { kind: 'data', value: d.value } : { kind: 'unreadable' };
85
+ }
86
+ catch {
87
+ return { kind: 'unreadable' };
88
+ }
89
+ };
90
+ function capabilityReadingOf(capability) {
91
+ if (typeof capability !== 'object' || capability === null)
92
+ return Object.freeze({ kind: 'malformed' });
93
+ const kind = ownSlotOf(capability, 'kind');
94
+ if (kind.kind !== 'data')
95
+ return Object.freeze({ kind: 'malformed' });
96
+ if (kind.value === 'not_reported')
97
+ return Object.freeze({ kind: 'not_reported' });
98
+ if (kind.value === 'reported') {
99
+ const available = ownSlotOf(capability, 'available');
100
+ return available.kind === 'data' && typeof available.value === 'boolean'
101
+ ? Object.freeze({ kind: 'reported', available: available.value })
102
+ : Object.freeze({ kind: 'malformed' });
103
+ }
104
+ return Object.freeze({ kind: 'malformed' });
105
+ }
106
+ const seatCarries = (capability) => {
107
+ try {
108
+ return seatCapabilityUnavailableDetail('thinkingLatch', capabilityReadingOf(capability)) === undefined;
109
+ }
110
+ catch {
111
+ return false;
112
+ }
113
+ };
114
+ const carrierBlocks = (carrier) => {
115
+ if (carrier.kind === 'absent')
116
+ return false;
117
+ if (carrier.kind === 'unreadable')
118
+ return true;
119
+ const c = carrier.value;
120
+ if (c === undefined)
121
+ return false;
122
+ if (typeof c !== 'object' || c === null)
123
+ return true;
124
+ const kind = ownSlotOf(c, 'kind');
125
+ if (kind.kind !== 'data')
126
+ return true;
127
+ if (kind.value === 'engine')
128
+ return false;
129
+ if (kind.value === 'seat') {
130
+ const capability = ownSlotOf(c, 'capability');
131
+ return capability.kind !== 'data' || !seatCarries(capability.value);
132
+ }
133
+ return true;
134
+ };
135
+ export function thinkingLatchView(reading, ctx) {
136
+ const r = normalizedReading(reading);
137
+ let carrier = { kind: 'absent' };
138
+ let modelSaysNoThinking = false;
139
+ if (ctx !== undefined && ctx !== null) {
140
+ if (typeof ctx !== 'object')
141
+ carrier = { kind: 'unreadable' };
142
+ else {
143
+ carrier = ownSlotOf(ctx, 'carrier');
144
+ const model = ownSlotOf(ctx, 'model');
145
+ if (model.kind === 'data' && typeof model.value === 'object' && model.value !== null) {
146
+ const mk = ownSlotOf(model.value, 'kind');
147
+ modelSaysNoThinking = mk.kind === 'data' && mk.value === 'not_applicable';
148
+ }
149
+ }
150
+ }
151
+ const conflict = carrierBlocks(carrier) ? 'seat_cannot_carry' : r.state === 'on' && modelSaysNoThinking ? 'model_cannot_think' : undefined;
152
+ return Object.freeze({ state: r.state, ...(r.why !== undefined ? { why: r.why } : {}), ...(conflict !== undefined ? { conflict } : {}) });
153
+ }
154
+ const MODEL_NAME_MAX = 120;
155
+ const stateSentence = (state, lang) => state === 'on'
156
+ ? renderMessage(msg('session.thinking.state.on'), lang)
157
+ : state === 'off'
158
+ ? renderMessage(msg('session.thinking.state.off'), lang)
159
+ : state === 'unset'
160
+ ? renderMessage(msg('session.thinking.state.unset'), lang)
161
+ : undefined;
162
+ export function thinkingLatchSentence(subject, lang) {
163
+ try {
164
+ if (typeof subject !== 'object' || subject === null)
165
+ return undefined;
166
+ const kind = readOwnDataValue(subject, 'kind');
167
+ if (kind === 'state')
168
+ return stateSentence(readOwnDataValue(subject, 'state'), lang);
169
+ if (kind === 'turn') {
170
+ const p = readOwnDataValue(subject, 'projection');
171
+ if (typeof p !== 'object' || p === null)
172
+ return undefined;
173
+ return readOwnDataValue(p, 'verdict') === 'off' && readOwnDataValue(p, 'ultracodeStamped') === true
174
+ ? renderMessage(msg('session.thinking.offWithUltracodeOnBody'), lang)
175
+ : undefined;
176
+ }
177
+ if (kind === 'view') {
178
+ const view = readOwnDataValue(subject, 'view');
179
+ if (typeof view !== 'object' || view === null)
180
+ return undefined;
181
+ const conflict = readOwnDataValue(view, 'conflict');
182
+ if (conflict === 'seat_cannot_carry') {
183
+ const carrier = readOwnDataValue(subject, 'carrier');
184
+ const capability = typeof carrier === 'object' && carrier !== null && readOwnDataValue(carrier, 'kind') === 'seat'
185
+ ? readOwnDataValue(carrier, 'capability')
186
+ : undefined;
187
+ return seatCapabilityUnavailableDetail('thinkingLatch', capabilityReadingOf(capability));
188
+ }
189
+ if (conflict === 'model_cannot_think') {
190
+ const model = readOwnDataValue(subject, 'model');
191
+ const shown = typeof model === 'string' && model.length > 0 ? quoteUntrustedForSentence(model, MODEL_NAME_MAX) : undefined;
192
+ return shown === undefined ? undefined : renderMessage(msg('session.thinking.modelCannotThink', { model: shown }), lang);
193
+ }
194
+ if (conflict !== undefined)
195
+ return undefined;
196
+ const r = normalizedReading(view);
197
+ if (r.why === 'unreadable' || r.why === 'malformed')
198
+ return renderMessage(msg('session.thinking.storeUnreadable'), lang);
199
+ return stateSentence(r.state, lang);
200
+ }
201
+ if (kind === 'write') {
202
+ const outcome = readOwnDataValue(subject, 'outcome');
203
+ if (typeof outcome !== 'object' || outcome === null)
204
+ return undefined;
205
+ return readOwnDataValue(outcome, 'kind') === 'not_saved' ? renderMessage(msg('session.thinking.notSaved'), lang) : undefined;
206
+ }
207
+ if (kind === 'seat_ack') {
208
+ const ack = readOwnDataValue(subject, 'ack');
209
+ if (typeof ack !== 'object' || ack === null)
210
+ return undefined;
211
+ return readOwnDataValue(ack, 'ok') === false ? renderMessage(msg('session.thinking.notSaved'), lang) : undefined;
212
+ }
213
+ return undefined;
214
+ }
215
+ catch {
216
+ return undefined;
217
+ }
218
+ }
219
+ export function thinkingLatchRowWordOf(reading) {
220
+ const r = normalizedReading(reading);
221
+ if (r.state === 'on' || r.state === 'off')
222
+ return r.state;
223
+ if (r.why === 'unreadable')
224
+ return 'unreadable';
225
+ if (r.why === 'malformed')
226
+ return 'malformed';
227
+ return undefined;
228
+ }
229
+ export function readSeatThinkingLatch(record, capability) {
230
+ if (!seatCarries(capability))
231
+ return unsetReading('no_port');
232
+ const row = record;
233
+ if (row === undefined || row === null)
234
+ return unsetReading('no_port');
235
+ try {
236
+ if (typeof row !== 'object')
237
+ return unsetReading('malformed');
238
+ const d = Object.getOwnPropertyDescriptor(row, 'thinkingLatch');
239
+ if (d === undefined)
240
+ return unsetReading('never_set');
241
+ if (!Object.hasOwn(d, 'value'))
242
+ return unsetReading('malformed');
243
+ const w = d.value;
244
+ if (w === undefined)
245
+ return unsetReading('never_set');
246
+ if (w === 'on' || w === 'off')
247
+ return setReading(w);
248
+ if (w === 'unreadable')
249
+ return unsetReading('unreadable');
250
+ return unsetReading('malformed');
251
+ }
252
+ catch {
253
+ return unsetReading('unreadable');
254
+ }
255
+ }
@@ -0,0 +1,7 @@
1
+ export declare const THINKING_LATCH_STATES: readonly ["on", "off", "unset"];
2
+ export type ThinkingLatchState = (typeof THINKING_LATCH_STATES)[number];
3
+ export declare const THINKING_LATCH_SET_STATES: readonly ["on", "off"];
4
+ export declare const THINKING_LATCH_EVENTS: readonly ["on", "off", "toggle", "clear"];
5
+ export type ThinkingLatchEvent = (typeof THINKING_LATCH_EVENTS)[number];
6
+ export declare const THINKING_LATCH_ROW_WORDS: readonly ["on", "off", "unreadable", "malformed"];
7
+ export type ThinkingLatchRowWord = (typeof THINKING_LATCH_ROW_WORDS)[number];
@@ -0,0 +1,4 @@
1
+ export const THINKING_LATCH_STATES = Object.freeze(['on', 'off', 'unset']);
2
+ export const THINKING_LATCH_SET_STATES = Object.freeze(['on', 'off']);
3
+ export const THINKING_LATCH_EVENTS = Object.freeze(['on', 'off', 'toggle', 'clear']);
4
+ export const THINKING_LATCH_ROW_WORDS = Object.freeze(['on', 'off', 'unreadable', 'malformed']);
@@ -29,6 +29,8 @@ export interface ToolHistoryMismatchRowKey {
29
29
  }
30
30
  export declare function toolHistoryMismatchRowKey(m: ToolHistoryMismatch, consecutive: number | undefined, rewindOffered: boolean): ToolHistoryMismatchRowKey;
31
31
  export declare function readToolHistoryMismatchKey(v: object | null | undefined): ToolHistoryMismatchRowKey | undefined;
32
+ export declare const SEMA_TOOL_HISTORY_ACCEPTED_KEY = "_sema_tool_history_accepted";
33
+ export declare function readToolHistoryAcceptedKey(frame: object | null | undefined): true | undefined;
32
34
  export declare const TOOL_HISTORY_LEDGER_CAP = 64;
33
35
  export declare function openToolHistoryGeneration(): number;
34
36
  export interface ToolHistoryTerminalNote {
@@ -38,8 +40,14 @@ export interface ToolHistoryTerminalNote {
38
40
  runId: string | undefined;
39
41
  replay: boolean;
40
42
  mismatch: ToolHistoryMismatch | null;
43
+ accepted?: boolean;
44
+ }
45
+ export interface ToolHistoryTerminalFacts {
46
+ readonly consecutive: number | undefined;
47
+ readonly acceptedSinceMismatch: true | undefined;
41
48
  }
42
49
  export declare function noteToolHistoryTerminal(note: ToolHistoryTerminalNote): number | undefined;
50
+ export declare function noteToolHistoryTerminalFacts(note: ToolHistoryTerminalNote): ToolHistoryTerminalFacts;
43
51
  export declare function _resetToolHistoryLedgerForTest(): void;
44
52
  export interface ToolHistoryRow {
45
53
  readonly toolUseIds?: readonly string[];
@@ -286,6 +286,18 @@ function ownDataMember(o, k) {
286
286
  return undefined;
287
287
  }
288
288
  }
289
+ export const SEMA_TOOL_HISTORY_ACCEPTED_KEY = '_sema_tool_history_accepted';
290
+ export function readToolHistoryAcceptedKey(frame) {
291
+ try {
292
+ if (typeof frame !== 'object' || frame === null)
293
+ return undefined;
294
+ const d = Object.getOwnPropertyDescriptor(frame, SEMA_TOOL_HISTORY_ACCEPTED_KEY);
295
+ return d !== undefined && Object.hasOwn(d, 'value') && d.value === true ? true : undefined;
296
+ }
297
+ catch {
298
+ return undefined;
299
+ }
300
+ }
289
301
  export const TOOL_HISTORY_LEDGER_CAP = 64;
290
302
  const PRIOR_RUN_IDS_CAP = 16;
291
303
  const ECHOED_SESSION_IDS_CAP = TOOL_HISTORY_LEDGER_CAP * 4;
@@ -308,16 +320,30 @@ export function openToolHistoryGeneration() {
308
320
  return toolHistoryGenerationSeq;
309
321
  }
310
322
  const fingerprintOf = (m) => `${m.kind}\u0000${m.toolUseId ?? ''}`;
323
+ function acceptanceStep(prev, note, attributed) {
324
+ if (note.replay)
325
+ return { awaiting: prev, accepted: undefined };
326
+ if (note.mismatch !== null)
327
+ return { awaiting: true, accepted: undefined };
328
+ if (note.accepted === true)
329
+ return attributed ? { awaiting: false, accepted: prev ? true : undefined } : { awaiting: prev, accepted: undefined };
330
+ return { awaiting: prev, accepted: undefined };
331
+ }
311
332
  export function noteToolHistoryTerminal(note) {
333
+ return noteToolHistoryTerminalFacts(note).consecutive;
334
+ }
335
+ export function noteToolHistoryTerminalFacts(note) {
336
+ const none = { consecutive: undefined, acceptedSinceMismatch: undefined };
312
337
  const { sessionId, generation, runId, replay, mismatch } = note;
313
338
  if (typeof sessionId !== 'string' || sessionId.length === 0) {
314
339
  unattributedTerminalSeq += 1;
315
- return undefined;
340
+ return none;
316
341
  }
317
342
  if (note.sessionEchoed === true)
318
343
  rememberEchoedSession(sessionId);
319
344
  else if (!echoedSessionIds.has(sessionId))
320
345
  unattributedTerminalSeq += 1;
346
+ const attributed = note.sessionEchoed === true || echoedSessionIds.has(sessionId);
321
347
  const row = toolHistoryLedger.get(sessionId);
322
348
  const fingerprint = mismatch === null ? null : fingerprintOf(mismatch);
323
349
  const run = !replay && typeof runId === 'string' && runId.length > 0 ? runId : undefined;
@@ -330,25 +356,29 @@ export function noteToolHistoryTerminal(note) {
330
356
  unattributedMark: unattributedTerminalSeq,
331
357
  lastRunId: undefined,
332
358
  recentRunIds: run !== undefined ? [...row.recentRunIds, run].slice(-PRIOR_RUN_IDS_CAP) : row.recentRunIds,
359
+ awaitingAcceptance: row.awaitingAcceptance,
333
360
  });
334
361
  }
335
- return undefined;
362
+ return none;
336
363
  }
337
364
  if (row !== undefined)
338
365
  row.writtenGeneration = generation;
339
366
  const interrupted = row !== undefined && row.unattributedMark < unattributedTerminalSeq;
340
367
  if (run !== undefined && row !== undefined && (row.segmentRunIds.has(run) || row.recentRunIds.includes(run))) {
341
- return !interrupted && row.lastRunId === run && fingerprint !== null && row.fingerprint === fingerprint ? row.segmentRunIds.size : undefined;
368
+ const repeated = !interrupted && row.lastRunId === run && fingerprint !== null && row.fingerprint === fingerprint ? row.segmentRunIds.size : undefined;
369
+ return { consecutive: repeated, acceptedSinceMismatch: undefined };
342
370
  }
371
+ const acceptance = acceptanceStep(row?.awaitingAcceptance ?? false, note, attributed);
343
372
  if (row !== undefined && row.fingerprint === fingerprint && !(interrupted && fingerprint !== null && run !== undefined)) {
373
+ row.awaitingAcceptance = acceptance.awaiting;
344
374
  if (run === undefined)
345
- return undefined;
375
+ return { consecutive: undefined, acceptedSinceMismatch: acceptance.accepted };
346
376
  if (fingerprint !== null)
347
377
  row.segmentRunIds.add(run);
348
378
  row.lastRunId = run;
349
379
  row.recentRunIds = [...row.recentRunIds, run].slice(-PRIOR_RUN_IDS_CAP);
350
380
  touchLedgerRow(sessionId, row);
351
- return fingerprint === null ? undefined : row.segmentRunIds.size;
381
+ return { consecutive: fingerprint === null ? undefined : row.segmentRunIds.size, acceptedSinceMismatch: acceptance.accepted };
352
382
  }
353
383
  touchLedgerRow(sessionId, {
354
384
  fingerprint,
@@ -357,8 +387,9 @@ export function noteToolHistoryTerminal(note) {
357
387
  unattributedMark: unattributedTerminalSeq,
358
388
  lastRunId: run,
359
389
  recentRunIds: run !== undefined ? [...(row?.recentRunIds ?? []), run].slice(-PRIOR_RUN_IDS_CAP) : [...(row?.recentRunIds ?? [])],
390
+ awaitingAcceptance: acceptance.awaiting,
360
391
  });
361
- return fingerprint !== null && run !== undefined ? 1 : undefined;
392
+ return { consecutive: fingerprint !== null && run !== undefined ? 1 : undefined, acceptedSinceMismatch: acceptance.accepted };
362
393
  }
363
394
  function touchLedgerRow(sessionId, row) {
364
395
  toolHistoryLedger.delete(sessionId);
@@ -112,21 +112,31 @@ export interface ToolResultRowFlags {
112
112
  }
113
113
  export declare function toolResultRowFlagsOf(row: object | null | undefined): ToolResultRowFlags;
114
114
  export type ToolKillCause = NonNullable<ReturnType<typeof toolKillCauseAcrossEngineIdentity>> | 'memory_pressure';
115
- export declare function wireOutputToBody(toolName: string, output: unknown, isError: boolean, truncated: boolean, flatten: FlattenWireOutput, structured?: unknown, leaderLedger?: boolean, killCauseOf?: () => ToolKillCause | undefined): ToolResultBody;
115
+ export declare function wireOutputToBody(toolName: string, output: unknown, isError: boolean, truncated: boolean, flatten: FlattenWireOutput, structuredIn?: unknown, leaderLedger?: boolean, killCauseOf?: () => ToolKillCause | undefined): ToolResultBody;
116
116
  export declare function structuredToToolUseResult(structured: unknown, modelText?: string, leaderLedger?: boolean): {
117
117
  toolUseResult: unknown;
118
118
  isError?: boolean;
119
119
  } | null;
120
+ export interface WebSearchSource {
121
+ readonly title: string;
122
+ readonly url: string;
123
+ }
124
+ export type WebSearchSources = readonly WebSearchSource[] & {
125
+ readonly droppedCount: number;
126
+ };
127
+ export declare function webSearchSourcesOf(toolEnd: {} | null | undefined): WebSearchSources | undefined;
120
128
  export interface EngineBgShellRegistration {
121
129
  kind: 'register';
122
130
  taskId: string;
131
+ toolUseId?: string;
123
132
  command: string;
124
133
  description?: string;
125
134
  receipt: string;
135
+ outputFile?: string;
126
136
  source: 'bash' | 'monitor';
127
137
  }
128
- export declare function detectEngineBgShellReceipt(toolName: string, rawInput: unknown, outputText: string | undefined, structured?: unknown): EngineBgShellRegistration | null;
129
- export declare function detectEngineBgShellDetach(toolName: string, rawInput: unknown, structured: unknown, outputText: string | undefined): EngineBgShellRegistration | null;
138
+ export declare function detectEngineBgShellReceipt(toolName: string, rawInput: unknown, outputText: string | undefined, structured?: unknown, toolUseId?: string): EngineBgShellRegistration | null;
139
+ export declare function detectEngineBgShellDetach(toolName: string, rawInput: unknown, structured: unknown, outputText: string | undefined, toolUseId?: string): EngineBgShellRegistration | null;
130
140
  export declare function todoWriteToolUseResult(rawInput: unknown, oldTodos: unknown[], isError: boolean): {
131
141
  toolUseResult: unknown;
132
142
  isError: boolean;