@sema-agent/client-core 0.98.0 → 0.100.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 +376 -0
  2. package/README.md +61 -35
  3. package/dist/adapt/arms.js +120 -55
  4. package/dist/adapt/panelTasks.d.ts +3 -2
  5. package/dist/adapt/panelTasks.js +34 -11
  6. package/dist/adapt/textStream.d.ts +1 -1
  7. package/dist/adapt/textStream.js +51 -28
  8. package/dist/adapter/activeRunSelfHeal.d.ts +11 -3
  9. package/dist/adapter/activeRunSelfHeal.js +210 -294
  10. package/dist/adapter/downstream/eventToSdkMessage.d.ts +25 -6
  11. package/dist/adapter/downstream/eventToSdkMessage.js +176 -12
  12. package/dist/adapter/downstream/terminalToSdkResult.js +10 -0
  13. package/dist/adapter/downstream/wiringManifestView.d.ts +3 -1
  14. package/dist/adapter/downstream/wiringManifestView.js +1 -0
  15. package/dist/adapter/runStream.js +82 -40
  16. package/dist/adapter/types.d.ts +2 -0
  17. package/dist/adapter/types.js +2 -1
  18. package/dist/agentSession/engineSessionBackgroundStop.js +16 -8
  19. package/dist/agentsWireCaps.d.ts +7 -3
  20. package/dist/agentsWireCaps.js +133 -39
  21. package/dist/cloudConfigWireCaps.d.ts +10 -1
  22. package/dist/cloudConfigWireCaps.js +181 -65
  23. package/dist/compactionStatus.d.ts +34 -0
  24. package/dist/compactionStatus.js +196 -0
  25. package/dist/controlRouter.d.ts +4 -2
  26. package/dist/controlRouter.js +39 -51
  27. package/dist/coreValuePorts.d.ts +26 -1
  28. package/dist/coreValuePorts.js +10 -0
  29. package/dist/corruptSessionCopy.d.ts +2 -1
  30. package/dist/corruptSessionCopy.js +3 -3
  31. package/dist/decideFailureNote.js +3 -3
  32. package/dist/declared/supportFloorDeclared.js +1 -1
  33. package/dist/detachWire.js +3 -2
  34. package/dist/devicesFace.d.ts +34 -0
  35. package/dist/devicesFace.js +90 -0
  36. package/dist/displayUntrusted.d.ts +1 -0
  37. package/dist/displayUntrusted.js +153 -5
  38. package/dist/engineAgentPanelStore.d.ts +14 -4
  39. package/dist/engineAgentPanelStore.js +14 -0
  40. package/dist/engineCapReader.d.ts +2 -1
  41. package/dist/engineCapReader.js +7 -5
  42. package/dist/engineCapsCache.d.ts +8 -0
  43. package/dist/engineCapsCache.js +59 -6
  44. package/dist/engineCapsChange.d.ts +2 -0
  45. package/dist/engineCapsChange.js +9 -0
  46. package/dist/engineErrorCodes.d.ts +11 -2
  47. package/dist/engineErrorCodes.js +11 -12
  48. package/dist/engineRowRef.js +4 -0
  49. package/dist/engineSessionMessages.d.ts +1 -0
  50. package/dist/engineSessionMessages.js +7 -1
  51. package/dist/engineTargetSeat.d.ts +27 -0
  52. package/dist/engineTargetSeat.js +199 -0
  53. package/dist/engineToolDirectory.d.ts +3 -0
  54. package/dist/engineToolDirectory.js +4 -2
  55. package/dist/engineWireFor.js +3 -8
  56. package/dist/env/uiLanguage.d.ts +2 -1
  57. package/dist/env/uiLanguage.js +3 -2
  58. package/dist/eventLeg.d.ts +7 -5
  59. package/dist/eventLeg.js +68 -49
  60. package/dist/fileHistoryCaptureCapability.d.ts +2 -4
  61. package/dist/fileHistoryCaptureCapability.js +12 -22
  62. package/dist/fileHistoryLegNotice.d.ts +2 -1
  63. package/dist/fileHistoryLegNotice.js +3 -3
  64. package/dist/frameBinding.d.ts +3 -0
  65. package/dist/frameBinding.js +12 -0
  66. package/dist/gateOutcome.js +16 -2
  67. package/dist/gateVocabulary.d.ts +8 -7
  68. package/dist/gateVocabulary.js +71 -73
  69. package/dist/generated/engineFactTables.d.ts +18 -1
  70. package/dist/generated/engineFactTables.js +56 -0
  71. package/dist/generated/engineNoticeTables.js +12 -3
  72. package/dist/generated/settingsSchemaFns.d.ts +18 -0
  73. package/dist/generated/settingsSchemaFns.js +70 -0
  74. package/dist/generated/settingsSchemaHooksClassifier.d.ts +2 -0
  75. package/dist/generated/settingsSchemaHooksClassifier.js +254 -0
  76. package/dist/generated/settingsSchemaMcpRequestEntry.d.ts +1 -0
  77. package/dist/generated/settingsSchemaMcpRequestEntry.js +162 -0
  78. package/dist/generated/settingsSchemaTables.d.ts +2 -0
  79. package/dist/generated/settingsSchemaTables.js +9 -0
  80. package/dist/generated/settingsSchemaTypes.d.ts +133 -0
  81. package/dist/generated/settingsSchemaTypes.js +1 -0
  82. package/dist/hitl/allowRuleShadow.d.ts +2 -1
  83. package/dist/hitl/allowRuleShadow.js +18 -15
  84. package/dist/hitl/approvalCardReasons.d.ts +3 -2
  85. package/dist/hitl/approvalCardReasons.js +29 -30
  86. package/dist/hitl/approvalHolds.d.ts +17 -0
  87. package/dist/hitl/approvalHolds.js +114 -29
  88. package/dist/hitl/askClassPair.d.ts +2 -2
  89. package/dist/hitl/askClassPair.js +16 -0
  90. package/dist/hitl/askGateWire.js +2 -1
  91. package/dist/hitl/askSettlementLine.d.ts +14 -4
  92. package/dist/hitl/askSettlementLine.js +67 -47
  93. package/dist/hitl/attributionLadder.d.ts +23 -0
  94. package/dist/hitl/attributionLadder.js +67 -0
  95. package/dist/hitl/automaticAnswerVerdict.d.ts +2 -1
  96. package/dist/hitl/automaticAnswerVerdict.js +8 -8
  97. package/dist/hitl/crashConvergedNotice.d.ts +5 -4
  98. package/dist/hitl/crashConvergedNotice.js +28 -41
  99. package/dist/hitl/decisionLedger.d.ts +55 -0
  100. package/dist/hitl/decisionLedger.js +156 -0
  101. package/dist/hitl/decisionRefusal.d.ts +1 -0
  102. package/dist/hitl/decisionRefusal.js +1 -1
  103. package/dist/hitl/decisionSend.d.ts +113 -0
  104. package/dist/hitl/decisionSend.js +579 -0
  105. package/dist/hitl/frameRouter.js +7 -8
  106. package/dist/hitl/hitlBridge.d.ts +1 -0
  107. package/dist/hitl/hitlBridge.js +21 -9
  108. package/dist/hitl/persistedRulesWire.d.ts +6 -5
  109. package/dist/hitl/persistedRulesWire.js +55 -73
  110. package/dist/hitl/planReviewWire.d.ts +5 -0
  111. package/dist/hitl/planReviewWire.js +53 -76
  112. package/dist/hitl/sessionPolicyDeliverable.d.ts +2 -0
  113. package/dist/hitl/sessionPolicyDeliverable.js +49 -9
  114. package/dist/hitl/sessionPolicyWire.d.ts +2 -1
  115. package/dist/hitl/sessionPolicyWire.js +23 -24
  116. package/dist/hitl/suspendedReopen.d.ts +2 -1
  117. package/dist/hitl/suspendedReopen.js +7 -10
  118. package/dist/hitl/toolApprovalWire.d.ts +17 -5
  119. package/dist/hitl/toolApprovalWire.js +120 -147
  120. package/dist/hooksWireCaps.js +145 -56
  121. package/dist/host.d.ts +21 -0
  122. package/dist/hostTurnSettings.d.ts +110 -0
  123. package/dist/hostTurnSettings.js +692 -0
  124. package/dist/humanTurn.d.ts +15 -1
  125. package/dist/humanTurn.js +100 -12
  126. package/dist/humanTurnRead.d.ts +2 -0
  127. package/dist/humanTurnRead.js +22 -1
  128. package/dist/i18n/messages.en.d.ts +713 -0
  129. package/dist/i18n/messages.en.js +713 -0
  130. package/dist/i18n/messages.zh.js +854 -1
  131. package/dist/index.d.ts +45 -13
  132. package/dist/index.js +27 -9
  133. package/dist/inheritEnvCapability.d.ts +4 -2
  134. package/dist/inheritEnvCapability.js +12 -5
  135. package/dist/inheritEnvWire.d.ts +3 -2
  136. package/dist/inheritEnvWire.js +14 -16
  137. package/dist/injectionLaneNotice.d.ts +5 -0
  138. package/dist/injectionLaneNotice.js +46 -0
  139. package/dist/interactiveHalt.js +17 -6
  140. package/dist/liveModelCatalog.d.ts +2 -1
  141. package/dist/liveModelCatalog.js +14 -8
  142. package/dist/mcpPanel.d.ts +10 -1
  143. package/dist/mcpPanel.js +42 -13
  144. package/dist/mcpProbeCapability.d.ts +2 -1
  145. package/dist/mcpProbeCapability.js +7 -11
  146. package/dist/mcpProbeWire.d.ts +3 -1
  147. package/dist/mcpProbeWire.js +5 -0
  148. package/dist/mcpReconnect.js +2 -2
  149. package/dist/mcpToolToggles.d.ts +6 -0
  150. package/dist/mcpToolToggles.js +46 -0
  151. package/dist/mcpWireCaps.d.ts +43 -3
  152. package/dist/mcpWireCaps.js +194 -59
  153. package/dist/mcpWireTransport.d.ts +4 -0
  154. package/dist/mcpWireTransport.js +18 -0
  155. package/dist/memoryEntriesWire.js +5 -10
  156. package/dist/model/onboardJudgement.d.ts +93 -0
  157. package/dist/model/onboardJudgement.js +415 -0
  158. package/dist/model/tierVocabulary.d.ts +2 -0
  159. package/dist/model/tierVocabulary.js +17 -5
  160. package/dist/modelCapabilityProbe.d.ts +65 -0
  161. package/dist/modelCapabilityProbe.js +601 -0
  162. package/dist/modelIdentityResolvability.d.ts +5 -0
  163. package/dist/modelIdentityResolvability.js +49 -22
  164. package/dist/ownKey.d.ts +33 -0
  165. package/dist/ownKey.js +109 -0
  166. package/dist/panelReduce.d.ts +11 -1
  167. package/dist/panelReduce.js +95 -16
  168. package/dist/panelStateHolder.d.ts +1 -0
  169. package/dist/panelStateHolder.js +10 -1
  170. package/dist/permissionRuleIssue.d.ts +2 -1
  171. package/dist/permissionRuleIssue.js +23 -20
  172. package/dist/permissionRulesWriteCapability.d.ts +2 -1
  173. package/dist/permissionRulesWriteCapability.js +8 -6
  174. package/dist/pluginHooksWire.d.ts +46 -3
  175. package/dist/pluginHooksWire.js +220 -12
  176. package/dist/prepareRefusal.d.ts +8 -0
  177. package/dist/prepareRefusal.js +72 -0
  178. package/dist/printModelStatus.d.ts +63 -0
  179. package/dist/printModelStatus.js +155 -0
  180. package/dist/request/taskRequest.d.ts +16 -10
  181. package/dist/request/taskRequest.js +195 -58
  182. package/dist/resumeRefusalCopy.d.ts +14 -9
  183. package/dist/resumeRefusalCopy.js +89 -144
  184. package/dist/retryStatus.d.ts +55 -0
  185. package/dist/retryStatus.js +155 -19
  186. package/dist/ruleRefusalSentence.d.ts +4 -0
  187. package/dist/ruleRefusalSentence.js +58 -0
  188. package/dist/sandboxWire.d.ts +2 -1
  189. package/dist/sandboxWire.js +55 -21
  190. package/dist/scenarioRefusal.d.ts +10 -0
  191. package/dist/scenarioRefusal.js +111 -0
  192. package/dist/seam.d.ts +48 -9
  193. package/dist/seam.js +54 -5
  194. package/dist/seatContract.d.ts +272 -14
  195. package/dist/seatContract.js +711 -23
  196. package/dist/selfOrchestrationDenial.js +7 -19
  197. package/dist/sessionIdSegment.d.ts +6 -0
  198. package/dist/sessionIdSegment.js +24 -0
  199. package/dist/sessionMemoryStatus.js +6 -11
  200. package/dist/sessionPolicyCapability.d.ts +2 -1
  201. package/dist/sessionPolicyCapability.js +8 -6
  202. package/dist/settingsCredentialKeyPaths.d.ts +8 -0
  203. package/dist/settingsCredentialKeyPaths.js +219 -0
  204. package/dist/settingsHooksSalvage.d.ts +44 -0
  205. package/dist/settingsHooksSalvage.js +211 -0
  206. package/dist/skillToolListsCapability.d.ts +2 -1
  207. package/dist/skillToolListsCapability.js +8 -6
  208. package/dist/skillsWireCaps.d.ts +0 -3
  209. package/dist/skillsWireCaps.js +1 -2
  210. package/dist/sseIdleTriage.js +3 -2
  211. package/dist/subagent/engineSubagentResume.js +15 -9
  212. package/dist/subagentContentStore.d.ts +4 -0
  213. package/dist/subagentContentStore.js +157 -27
  214. package/dist/toolHistoryMismatch.js +3 -2
  215. package/dist/toolRoster.d.ts +3 -2
  216. package/dist/toolRoster.js +21 -20
  217. package/dist/toolsFlagNames.d.ts +8 -0
  218. package/dist/toolsFlagNames.js +110 -0
  219. package/dist/turnFailurePresentation.d.ts +12 -1
  220. package/dist/turnFailurePresentation.js +220 -15
  221. package/dist/usageAnalytics.js +6 -11
  222. package/dist/userAttachmentEnvelope.d.ts +1 -0
  223. package/dist/userAttachmentEnvelope.js +37 -7
  224. package/dist/userAttachmentSeat.d.ts +21 -0
  225. package/dist/userAttachmentSeat.js +75 -0
  226. package/dist/userInvokedSkillsCapability.d.ts +11 -1
  227. package/dist/userInvokedSkillsCapability.js +31 -7
  228. package/dist/wireErrorTriage.d.ts +7 -0
  229. package/dist/wireErrorTriage.js +23 -1
  230. package/dist/wireFailureShape.js +2 -1
  231. package/dist/wireRefusalCopy.d.ts +62 -16
  232. package/dist/wireRefusalCopy.js +307 -148
  233. package/dist/workflowsJournalCapability.d.ts +2 -1
  234. package/dist/workflowsJournalCapability.js +8 -6
  235. package/docs/INTEGRATION-CLIENTS.md +951 -42
  236. package/package.json +5 -5
@@ -1,5 +1,6 @@
1
1
  import { displayUntrusted } from './displayUntrusted.js';
2
2
  import { guardedRead, readOwnDataFiniteNumber, readOwnDataNonEmptyString, readOwnDataValue } from './ownKey.js';
3
+ import { msg, renderMessage } from './i18n/translate.js';
3
4
  export const BRAIN_STATUS_PHASES = [
4
5
  'rate_limited',
5
6
  'retrying',
@@ -78,6 +79,47 @@ export function mapBrainStatusToRetry(p, nowMs) {
78
79
  return { kind: 'error', deadline, ...extra, error: { formatted: '' } };
79
80
  }
80
81
  }
82
+ export function retryStatusFromArm(arm, nowMs) {
83
+ const object = guardedRead(() => typeof arm === 'object' && arm !== null && !Array.isArray(arm));
84
+ if (object !== true || arm === null || arm === undefined)
85
+ return undefined;
86
+ const bit = (key) => guardedRead(() => readOwnDataValue(arm, key));
87
+ if (typeof bit('parentToolCallId') === 'string')
88
+ return undefined;
89
+ const num = (key) => {
90
+ const v = bit(key);
91
+ return typeof v === 'number' && Number.isFinite(v) ? v : undefined;
92
+ };
93
+ const str = (key) => {
94
+ const v = bit(key);
95
+ return typeof v === 'string' ? v : undefined;
96
+ };
97
+ const word = (key) => {
98
+ const v = str(key);
99
+ return v !== undefined && v.length > 0 ? v : undefined;
100
+ };
101
+ const [detail, retryInSec, retryInMs, attempt, maxRetries, errClass, retryAtMs, errorStatus, elapsedMs, timeoutMs, providerCondition, providerConditionSource] = [
102
+ str('detail'), num('retryInSec'), num('retryInMs'), num('attempt'), num('maxRetries'), str('errClass'), num('retryAtMs'), num('errorStatus'), num('elapsedMs'), num('timeoutMs'), word('providerCondition'), word('providerConditionSource'),
103
+ ];
104
+ const phase = str('phase');
105
+ if (phase === undefined)
106
+ return undefined;
107
+ return mapBrainStatusToRetry({
108
+ phase,
109
+ ...(detail !== undefined ? { detail } : {}),
110
+ ...(retryInSec !== undefined ? { retryInSec } : {}),
111
+ ...(retryInMs !== undefined ? { retryInMs } : {}),
112
+ ...(attempt !== undefined ? { attempt } : {}),
113
+ ...(maxRetries !== undefined ? { maxRetries } : {}),
114
+ ...(errClass !== undefined ? { errClass } : {}),
115
+ ...(retryAtMs !== undefined ? { retryAtMs } : {}),
116
+ ...(errorStatus !== undefined ? { errorStatus } : {}),
117
+ ...(elapsedMs !== undefined ? { elapsedMs } : {}),
118
+ ...(timeoutMs !== undefined ? { timeoutMs } : {}),
119
+ ...(providerCondition !== undefined ? { providerCondition } : {}),
120
+ ...(providerConditionSource !== undefined ? { providerConditionSource } : {}),
121
+ }, nowMs);
122
+ }
81
123
  const WAIT_SWITCH_FRACTION = 0.5;
82
124
  const CONDITION_READINGS = Object.freeze({
83
125
  quota_exhausted: { clause: 'this account cannot be served by the model service until someone acts or its usage window resets', recourse: 'switch_model' },
@@ -131,11 +173,38 @@ function noticeAttemptTail(attempt, maxRetries) {
131
173
  function sealNotice(line, phase, recourse) {
132
174
  return Object.freeze(recourse === undefined ? { line, phase } : { line, recourse, phase });
133
175
  }
134
- export function retryStatusNotice(status, ctx) {
176
+ const SOURCE_PHRASES = Object.freeze({
177
+ unified_header: 'notice.retry.source.unifiedHeader',
178
+ provider_code: 'notice.retry.source.providerCode',
179
+ status: 'notice.retry.source.status',
180
+ });
181
+ function sourcePhraseOf(word) {
182
+ if (word === undefined || !Object.hasOwn(SOURCE_PHRASES, word))
183
+ return undefined;
184
+ return renderMessage(msg(SOURCE_PHRASES[word]));
185
+ }
186
+ function sealParts(p) {
187
+ return Object.freeze({
188
+ phase: p.phase,
189
+ ...(p.model !== undefined ? { model: p.model } : {}),
190
+ ...(p.condition !== undefined ? { condition: p.condition } : {}),
191
+ ...(p.resendNote !== undefined ? { resendNote: p.resendNote } : {}),
192
+ ...(p.httpStatus !== undefined ? { httpStatus: p.httpStatus } : {}),
193
+ ...(p.source !== undefined ? { source: p.source } : {}),
194
+ ...(p.attempt !== undefined ? { attempt: p.attempt } : {}),
195
+ ...(p.maxAttempts !== undefined ? { maxAttempts: p.maxAttempts } : {}),
196
+ ...(p.elapsedMs !== undefined ? { elapsedMs: p.elapsedMs } : {}),
197
+ ...(p.timeoutMs !== undefined ? { timeoutMs: p.timeoutMs } : {}),
198
+ ...(p.retryAtMs !== undefined ? { retryAtMs: p.retryAtMs } : {}),
199
+ ...(p.detail !== undefined ? { detail: p.detail } : {}),
200
+ ...(p.recourse !== undefined ? { recourse: p.recourse } : {}),
201
+ });
202
+ }
203
+ export function retryStatusParts(status, ctx) {
135
204
  const modelName = washedText(noticeText(ctx, 'modelName'))?.trim();
136
- const prefix = modelName === undefined || modelName === '' ? '' : `${modelName}: `;
205
+ const model = modelName === undefined || modelName === '' ? undefined : modelName;
137
206
  if (status === null)
138
- return sealNotice('', 'cleared', undefined);
207
+ return sealParts({ phase: 'cleared' });
139
208
  const armWord = noticeText(status, 'kind');
140
209
  const kind = armWord === 'stalled' || armWord === 'waiting' ? armWord : 'error';
141
210
  if (kind === 'waiting') {
@@ -143,10 +212,8 @@ export function retryStatusNotice(status, ctx) {
143
212
  const timeoutRaw = noticeNumber(status, 'timeoutMs');
144
213
  const elapsed = elapsedRaw !== undefined && elapsedRaw >= 0 && elapsedRaw <= Number.MAX_SAFE_INTEGER ? elapsedRaw : undefined;
145
214
  const ceiling = timeoutRaw !== undefined && timeoutRaw > 0 && timeoutRaw <= Number.MAX_SAFE_INTEGER ? timeoutRaw : undefined;
146
- const progress = [...(elapsed === undefined ? [] : [`${spanText(elapsed)} so far`]), ...(ceiling === undefined ? [] : [`limit ${spanText(ceiling)}`])];
147
- const offerSwitch = prefix !== '' && elapsed !== undefined && ceiling !== undefined && elapsed >= ceiling * WAIT_SWITCH_FRACTION;
148
- const text = `${prefix}Waiting for the model's first token${progress.length === 0 ? '' : ` — ${progress.join(', ')}`}${offerSwitch ? '; keep waiting or switch model' : ''}`;
149
- return sealNotice(text, 'waiting_first_token', offerSwitch ? 'switch_model' : 'wait');
215
+ const offerSwitch = model !== undefined && elapsed !== undefined && ceiling !== undefined && elapsed >= ceiling * WAIT_SWITCH_FRACTION;
216
+ return sealParts({ phase: 'waiting_first_token', model, elapsedMs: elapsed, timeoutMs: ceiling, recourse: offerSwitch ? 'switch_model' : 'wait' });
150
217
  }
151
218
  const terminal = kind === 'error' && noticeValue(status, 'terminal') === true;
152
219
  const reading = conditionReadingOf(noticeText(status, 'providerCondition'));
@@ -154,18 +221,9 @@ export function retryStatusNotice(status, ctx) {
154
221
  const attempt = noticeCount(noticeNumber(status, 'attempt'));
155
222
  const maxRetries = noticeCount(noticeNumber(status, 'maxRetries'));
156
223
  const engineWords = kind === 'stalled' ? noticeText(status, 'detail') : noticeText(noticeValue(status, 'error'), 'formatted');
157
- const httpPart = http === undefined ? '' : ` (HTTP ${http})`;
158
- let first;
159
- if (terminal) {
160
- const after = attempt === undefined ? '' : ` after ${attempt} attempt${attempt === 1 ? '' : 's'}`;
161
- const why = reading === undefined ? '' : `: ${reading.clause}${reading.resendNote === undefined ? '' : `, and ${reading.resendNote}`}`;
162
- first = `Stopped${after}${why}${httpPart}`;
163
- }
164
- else {
165
- const head = reading !== undefined ? `${reading.clause.charAt(0).toUpperCase()}${reading.clause.slice(1)}` : http !== undefined || kind === 'error' ? 'Request failed' : 'Waiting for the API response';
166
- first = `${head}${httpPart} — ${kind === 'stalled' ? 'will retry' : 'retrying'}${noticeAttemptTail(attempt, maxRetries)}`;
167
- }
168
224
  const note = washedText(engineWords);
225
+ const source = reading === undefined ? undefined : sourcePhraseOf(noticeText(status, 'providerConditionSource'));
226
+ const condition = reading === undefined ? undefined : `${reading.clause.charAt(0).toUpperCase()}${reading.clause.slice(1)}`;
169
227
  const serviceSide = http !== undefined && (http === 429 || (http >= 500 && http <= 599));
170
228
  const knownArm = armWord === 'stalled' || armWord === 'error';
171
229
  const recourse = !knownArm
@@ -177,5 +235,83 @@ export function retryStatusNotice(status, ctx) {
177
235
  : !terminal
178
236
  ? 'wait'
179
237
  : undefined;
180
- return sealNotice(`${prefix}${first}${note === undefined ? '' : ` · ${note}`}`, kind === 'stalled' ? 'reconnecting' : terminal ? 'gave_up' : 'retrying', recourse);
238
+ const deadlineRaw = knownArm && !terminal && noticeNumber(status, 'retryAtMs') !== undefined ? noticeNumber(status, 'deadline') : undefined;
239
+ const retryAtMs = deadlineRaw !== undefined && deadlineRaw > 0 ? deadlineRaw : undefined;
240
+ return sealParts({
241
+ phase: kind === 'stalled' ? 'reconnecting' : terminal ? 'gave_up' : 'retrying',
242
+ model,
243
+ condition,
244
+ resendNote: terminal ? reading?.resendNote : undefined,
245
+ httpStatus: http,
246
+ source,
247
+ attempt,
248
+ maxAttempts: maxRetries,
249
+ retryAtMs,
250
+ detail: note,
251
+ recourse,
252
+ });
253
+ }
254
+ function retryLineOfParts(parts) {
255
+ if (parts.phase === 'cleared')
256
+ return '';
257
+ const prefix = parts.model === undefined ? '' : `${parts.model}: `;
258
+ if (parts.phase === 'waiting_first_token') {
259
+ const progress = [...(parts.elapsedMs === undefined ? [] : [`${spanText(parts.elapsedMs)} so far`]), ...(parts.timeoutMs === undefined ? [] : [`limit ${spanText(parts.timeoutMs)}`])];
260
+ const offerSwitch = parts.recourse === 'switch_model';
261
+ return `${prefix}Waiting for the model's first token${progress.length === 0 ? '' : ` — ${progress.join(', ')}`}${offerSwitch ? '; keep waiting or switch model' : ''}`;
262
+ }
263
+ const httpPart = parts.httpStatus === undefined ? '' : ` (HTTP ${parts.httpStatus})`;
264
+ let first;
265
+ if (parts.phase === 'gave_up') {
266
+ const after = parts.attempt === undefined ? '' : ` after ${parts.attempt} attempt${parts.attempt === 1 ? '' : 's'}`;
267
+ const why = parts.condition === undefined ? '' : `: ${parts.condition.charAt(0).toLowerCase()}${parts.condition.slice(1)}${parts.resendNote === undefined ? '' : `, and ${parts.resendNote}`}`;
268
+ first = `Stopped${after}${why}${httpPart}`;
269
+ }
270
+ else {
271
+ const head = parts.condition !== undefined ? parts.condition : parts.httpStatus !== undefined || parts.phase === 'retrying' ? 'Request failed' : 'Waiting for the API response';
272
+ first = `${head}${httpPart} — ${parts.phase === 'reconnecting' ? 'will retry' : 'retrying'}${noticeAttemptTail(parts.attempt, parts.maxAttempts)}`;
273
+ }
274
+ return `${prefix}${first}${parts.detail === undefined ? '' : ` · ${parts.detail}`}`;
275
+ }
276
+ export function retryStatusNotice(status, ctx) {
277
+ const parts = retryStatusParts(status, ctx);
278
+ return sealNotice(retryLineOfParts(parts), parts.phase, parts.recourse);
279
+ }
280
+ const API_ERROR_PROVIDER_TEXT_MAX = 200;
281
+ function isRecordObject(v) {
282
+ return guardedRead(() => typeof v === 'object' && v !== null && !Array.isArray(v)) === true;
283
+ }
284
+ export function apiErrorFactsOfRow(row) {
285
+ if (!isRecordObject(row))
286
+ return Object.freeze({});
287
+ const status = noticeHttp(noticeNumber(row, '_sema_api_error_status'));
288
+ const providerCondition = noticeText(row, '_sema_provider_condition');
289
+ const errorCode = noticeText(row, '_sema_api_error_code');
290
+ return Object.freeze({
291
+ ...(status !== undefined ? { status } : {}),
292
+ ...(providerCondition !== undefined ? { providerCondition } : {}),
293
+ ...(errorCode !== undefined ? { errorCode } : {}),
294
+ });
295
+ }
296
+ export function apiErrorNotice(facts, ctx) {
297
+ if (!isRecordObject(facts))
298
+ return undefined;
299
+ const status = noticeHttp(noticeNumber(facts, 'status'));
300
+ const providerCondition = noticeText(facts, 'providerCondition');
301
+ if (status === undefined && conditionReadingOf(providerCondition) === undefined)
302
+ return undefined;
303
+ const rawText = noticeText(ctx, 'providerText');
304
+ const shownText = rawText === undefined ? undefined : washedText(displayUntrusted(rawText, { max: API_ERROR_PROVIDER_TEXT_MAX }));
305
+ const terminal = {
306
+ kind: 'error',
307
+ deadline: 0,
308
+ terminal: true,
309
+ ...(status !== undefined ? { errorStatus: status } : {}),
310
+ ...(providerCondition !== undefined ? { providerCondition } : {}),
311
+ error: { formatted: shownText ?? '' },
312
+ };
313
+ const modelName = noticeText(ctx, 'modelName');
314
+ const notice = retryStatusNotice(terminal, modelName !== undefined ? { modelName } : undefined);
315
+ const recourse = status === 401 || status === 403 ? 'check_credentials' : notice.recourse;
316
+ return Object.freeze(recourse === undefined ? { line: notice.line } : { line: notice.line, recourse });
181
317
  }
@@ -0,0 +1,4 @@
1
+ import type { UiLanguage } from './env/uiLanguage.js';
2
+ import type { PermissionsKeptRule } from './permissionsDeclaration.js';
3
+ export type RuleRefusalRow = Pick<PermissionsKeptRule, 'rule' | 'reason' | 'code' | 'message'>;
4
+ export declare function ruleRefusalSentence(rows: readonly RuleRefusalRow[], lang?: UiLanguage): string | undefined;
@@ -0,0 +1,58 @@
1
+ import { capForDisplay } from './fleetTaskDesc.js';
2
+ import { msg, renderMessage } from './i18n/translate.js';
3
+ import { permissionRuleIssueDetail } from './permissionRuleIssue.js';
4
+ const RULE_REFUSAL_NAMED_MAX = 5;
5
+ const RULE_NAME_MAX = 120;
6
+ const CLASS_OF_REASON = Object.freeze({
7
+ retired_tool_name: 'toolName',
8
+ unprefixed_namespaced_name: 'toolName',
9
+ incomplete_protocol_name: 'toolName',
10
+ home_relative_path: 'homePath',
11
+ compile_refused: 'compile',
12
+ paren_in_tool_name: 'compile',
13
+ });
14
+ function reasonOf(row, lang) {
15
+ const cls = typeof row.reason === 'string' && Object.hasOwn(CLASS_OF_REASON, row.reason) ? CLASS_OF_REASON[row.reason] : undefined;
16
+ if (cls === 'toolName')
17
+ return renderMessage(msg('rules.refusal.reason.toolName'), lang);
18
+ if (cls === 'homePath')
19
+ return renderMessage(msg('rules.refusal.reason.homePath'), lang);
20
+ if (cls === 'compile')
21
+ return permissionRuleIssueDetail(row.code, row.message, row.rule, lang);
22
+ return undefined;
23
+ }
24
+ function nameOf(rule) {
25
+ return `"${capForDisplay(rule, RULE_NAME_MAX)}"`;
26
+ }
27
+ export function ruleRefusalSentence(rows, lang) {
28
+ const seen = new Set();
29
+ const items = [];
30
+ try {
31
+ if (!Array.isArray(rows))
32
+ return undefined;
33
+ for (const row of rows) {
34
+ if (typeof row !== 'object' || row === null)
35
+ continue;
36
+ const rule = row.rule;
37
+ if (typeof rule !== 'string' || rule === '' || seen.has(rule))
38
+ continue;
39
+ const reason = reasonOf(row, lang);
40
+ if (reason === undefined)
41
+ continue;
42
+ seen.add(rule);
43
+ items.push({ rule, reason });
44
+ }
45
+ }
46
+ catch {
47
+ return undefined;
48
+ }
49
+ if (items.length === 0)
50
+ return undefined;
51
+ const shown = items.slice(0, RULE_REFUSAL_NAMED_MAX);
52
+ const separator = renderMessage(msg('rules.refusal.itemSeparator'), lang);
53
+ const named = shown.map((it) => renderMessage(msg('rules.refusal.item', { rule: nameOf(it.rule), reason: it.reason }), lang)).join(separator);
54
+ const rest = items.length - shown.length;
55
+ const list = rest > 0 ? msg('rules.refusal.list.more', { shown: named, count: rest }) : named;
56
+ const listText = typeof list === 'string' ? list : renderMessage(list, lang);
57
+ return renderMessage(items.length === 1 ? msg('rules.refusal.sentence.one', { list: listText }) : msg('rules.refusal.sentence.other', { count: items.length, list: listText }), lang);
58
+ }
@@ -1,3 +1,4 @@
1
+ import type { TaskRequestLike } from './request/taskRequest.js';
1
2
  export type SandboxSelection = {
2
3
  mode: 'default';
3
4
  } | {
@@ -25,4 +26,4 @@ export declare const SANDBOX_NO_PUBLISHED_IMAGE_404_ANCHOR = "no published sandb
25
26
  export declare const SANDBOX_CASCADE_CONFLICT_400_ANCHOR = "not supported together with cascade/verify";
26
27
  export type SandboxHintHost = 'terminal' | 'web' | 'desktop';
27
28
  export declare const SANDBOX_HINT_HOSTS: readonly SandboxHintHost[];
28
- export declare function sandboxDegradeHint(err: unknown, host?: SandboxHintHost): string | undefined;
29
+ export declare function sandboxDegradeHint(err: unknown, host?: SandboxHintHost, sentRequest?: TaskRequestLike): string | undefined;
@@ -1,5 +1,5 @@
1
1
  import { lastFlagValue } from './argvFlagValue.js';
2
- import { CAPABILITY_IMAGE_INDEX_REQUIRED } from './engineErrorCodes.js';
2
+ import { CAPABILITY_IMAGE_INDEX_REQUIRED, CAPABILITY_K8S_LANE_REQUIRED, isStatusDerivedCoarseCode, NOT_FOUND_IMAGE, REQUEST_FIELD_CONFLICT, REQUEST_PRECONDITION_UNMET } from './engineErrorCodes.js';
3
3
  import { THROWN_SLOT_UNREADABLE, readThrownSlot } from './wireFailureShape.js';
4
4
  const MAX_PROFILE_LEN = 128;
5
5
  const USAGE_HINT = "sema: --sandbox expects a profile name or 'auto'.\n" +
@@ -49,15 +49,15 @@ export const SANDBOX_NO_PUBLISHED_IMAGE_404_ANCHOR = 'no published sandbox image
49
49
  export const SANDBOX_CASCADE_CONFLICT_400_ANCHOR = 'not supported together with cascade/verify';
50
50
  export const SANDBOX_HINT_HOSTS = Object.freeze(['terminal', 'web', 'desktop']);
51
51
  const SANDBOX_HINT_ARMS = Object.freeze({
52
- imageIndexRequired501: {
53
- fact: 'Cloud sandbox images are not available on this engine: its storage backend keeps no image index, so profiles cannot be listed or selected here.',
52
+ imageIndexRequired: {
53
+ fact: 'Cloud sandbox images are not available on this engine: it has no sandbox image index (its store keeps none, or no image catalog is attached from the sema-web-admin config center), so profiles cannot be listed or selected here.',
54
54
  sep: '\n',
55
55
  outlet: {
56
- terminal: 'Use a worker backed by a SQL store (it has the image index), or re-run without --sandbox.',
57
- graphical: 'Use a worker backed by a SQL store (it has the image index), or keep the default environment.',
56
+ terminal: 'Use a worker that has the image index (a SQL-backed store with the image catalog attached), or re-run without --sandbox.',
57
+ graphical: 'Use a worker that has the image index (a SQL-backed store with the image catalog attached), or keep the default environment.',
58
58
  },
59
59
  },
60
- k8sLaneOnly400: {
60
+ k8sLaneOnly: {
61
61
  subject: { terminal: '--sandbox <profile>', graphical: 'The selected sandbox image profile' },
62
62
  fact: ' only applies on k8s-lane workers; this engine runs a host/e2b sandbox lane, so the request was honestly rejected.',
63
63
  sep: '\n',
@@ -66,12 +66,13 @@ const SANDBOX_HINT_ARMS = Object.freeze({
66
66
  graphical: 'Keep the default environment, or connect to a k8s-lane worker.',
67
67
  },
68
68
  },
69
- noImageIndex400: {
70
- fact: 'This worker has no sandbox image index configured (the sema-web-admin config center is not attached), so per-task profiles cannot resolve.',
69
+ sessionRequired: {
70
+ subject: { terminal: '--sandbox <profile>', graphical: 'The selected sandbox image profile' },
71
+ fact: ' is bound to a session, and this request resolved none, so the per-task image could not be registered.',
71
72
  sep: '\n',
72
73
  outlet: {
73
- terminal: 'Re-run without --sandbox, or use a worker with the image index enabled.',
74
- graphical: 'Keep the default environment, or use a worker with the image index enabled.',
74
+ terminal: 'Run it inside a session, or re-run without --sandbox.',
75
+ graphical: 'Start the work inside a session, or keep the default environment.',
75
76
  },
76
77
  },
77
78
  noPublishedImage404: {
@@ -104,21 +105,54 @@ function sandboxSlot(err, key) {
104
105
  const v = readThrownSlot(err, key, 'data');
105
106
  return v === THROWN_SLOT_UNREADABLE ? undefined : v;
106
107
  }
107
- export function sandboxDegradeHint(err, host) {
108
- const status = sandboxSlot(err, 'status');
109
- if (status === 501 && sandboxSlot(err, 'errorCode') === CAPABILITY_IMAGE_INDEX_REQUIRED)
110
- return sandboxHintOf(SANDBOX_HINT_ARMS.imageIndexRequired501, host);
111
- if (typeof err !== 'object' || err === null || typeof status !== 'number')
112
- return undefined;
108
+ function sentSandboxFacts(sentRequest) {
109
+ if (sentRequest === undefined || sentRequest === null || typeof sentRequest !== 'object')
110
+ return { profile: false, cascadeOrVerify: false, sessionOrDevice: false };
111
+ const profile = sandboxSlot(sentRequest, 'sandboxImageProfile');
112
+ const sent = (key) => {
113
+ const v = sandboxSlot(sentRequest, key);
114
+ return typeof v === 'string' && v.length > 0;
115
+ };
116
+ return {
117
+ profile: typeof profile === 'string' && profile.length > 0,
118
+ cascadeOrVerify: sandboxSlot(sentRequest, 'cascade') === true || sandboxSlot(sentRequest, 'verify') === true,
119
+ sessionOrDevice: sent('sessionId') || sent('deviceId'),
120
+ };
121
+ }
122
+ export function sandboxDegradeHint(err, host, sentRequest) {
113
123
  try {
124
+ if (typeof err !== 'object' || err === null)
125
+ return undefined;
126
+ const status = sandboxSlot(err, 'status');
127
+ const codeRaw = sandboxSlot(err, 'errorCode');
128
+ const code = typeof codeRaw === 'string' && codeRaw.length > 0 ? codeRaw : undefined;
129
+ if (status === 501 && code === CAPABILITY_K8S_LANE_REQUIRED)
130
+ return sandboxHintOf(SANDBOX_HINT_ARMS.k8sLaneOnly, host);
131
+ if (status === 501 && code === CAPABILITY_IMAGE_INDEX_REQUIRED)
132
+ return sandboxHintOf(SANDBOX_HINT_ARMS.imageIndexRequired, host);
133
+ if (status === 404 && code === NOT_FOUND_IMAGE)
134
+ return sandboxHintOf(SANDBOX_HINT_ARMS.noPublishedImage404, host);
135
+ if (status === 400 && code === REQUEST_PRECONDITION_UNMET) {
136
+ const sent = sentSandboxFacts(sentRequest);
137
+ return sent.profile && !sent.cascadeOrVerify && !sent.sessionOrDevice ? sandboxHintOf(SANDBOX_HINT_ARMS.sessionRequired, host) : undefined;
138
+ }
139
+ if (typeof status !== 'number')
140
+ return undefined;
141
+ const noCode = code === undefined || isStatusDerivedCoarseCode(code);
142
+ const cascadeCoded = code === REQUEST_FIELD_CONFLICT && (sentRequest === undefined || (() => {
143
+ const sent = sentSandboxFacts(sentRequest);
144
+ return sent.profile && sent.cascadeOrVerify;
145
+ })());
146
+ if (!noCode && !cascadeCoded)
147
+ return undefined;
114
148
  const msg = err.message;
115
149
  if (typeof msg !== 'string')
116
150
  return undefined;
117
- if (status === 400 && msg.includes(SANDBOX_K8S_ONLY_400_ANCHOR))
118
- return sandboxHintOf(SANDBOX_HINT_ARMS.k8sLaneOnly400, host);
119
- if (status === 400 && msg.includes(SANDBOX_NO_IMAGE_INDEX_400_ANCHOR))
120
- return sandboxHintOf(SANDBOX_HINT_ARMS.noImageIndex400, host);
121
- if (status === 404 && msg.includes(SANDBOX_NO_PUBLISHED_IMAGE_404_ANCHOR))
151
+ if (noCode && status === 400 && msg.includes(SANDBOX_K8S_ONLY_400_ANCHOR))
152
+ return sandboxHintOf(SANDBOX_HINT_ARMS.k8sLaneOnly, host);
153
+ if (noCode && status === 400 && msg.includes(SANDBOX_NO_IMAGE_INDEX_400_ANCHOR))
154
+ return sandboxHintOf(SANDBOX_HINT_ARMS.imageIndexRequired, host);
155
+ if (noCode && status === 404 && msg.includes(SANDBOX_NO_PUBLISHED_IMAGE_404_ANCHOR))
122
156
  return sandboxHintOf(SANDBOX_HINT_ARMS.noPublishedImage404, host);
123
157
  if (status === 400 && msg.includes(SANDBOX_CASCADE_CONFLICT_400_ANCHOR))
124
158
  return sandboxHintOf(SANDBOX_HINT_ARMS.cascadeConflict400, host);
@@ -0,0 +1,10 @@
1
+ import type { UiLanguage } from './env/uiLanguage.js';
2
+ export interface ScenarioRefusalReading {
3
+ readonly errorCode?: string;
4
+ readonly error?: string;
5
+ readonly scenario?: string;
6
+ readonly source?: 'ruling' | 'deployment';
7
+ }
8
+ export declare function scenarioRefusalOf(body: object): ScenarioRefusalReading | undefined | null;
9
+ export declare function scenarioRefusalFromError(err: {} | null | undefined): ScenarioRefusalReading | null;
10
+ export declare function scenarioRefusalContent(reading: ScenarioRefusalReading, lang?: UiLanguage): string;
@@ -0,0 +1,111 @@
1
+ import { capForDisplay } from './fleetTaskDesc.js';
2
+ import { readOwnDataValue } from './ownKey.js';
3
+ import { SCENARIO_ASSIGNMENT_UNKNOWN_ERROR_CODE } from './engineErrorCodes.js';
4
+ import { readErrorRecord, readErrorString } from './wireFailureShape.js';
5
+ import { effectiveWireErrorCode } from './wireErrorTriage.js';
6
+ import { msg, renderMessage } from './i18n/translate.js';
7
+ const SCENARIO_REFUSAL_ERROR_MAX = 200;
8
+ function detailBits(detail) {
9
+ if (detail === undefined)
10
+ return {};
11
+ let scenario;
12
+ let source;
13
+ try {
14
+ scenario = readOwnDataValue(detail, 'scenario');
15
+ }
16
+ catch {
17
+ scenario = undefined;
18
+ }
19
+ try {
20
+ source = readOwnDataValue(detail, 'source');
21
+ }
22
+ catch {
23
+ source = undefined;
24
+ }
25
+ return {
26
+ ...(typeof scenario === 'string' && scenario.length > 0 ? { scenario } : {}),
27
+ ...(source === 'ruling' || source === 'deployment' ? { source } : {}),
28
+ };
29
+ }
30
+ const isPlainRecord = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);
31
+ export function scenarioRefusalOf(body) {
32
+ let raw;
33
+ try {
34
+ const d = Object.getOwnPropertyDescriptor(body, 'scenarioRefusal');
35
+ if (d === undefined)
36
+ return undefined;
37
+ raw = 'value' in d ? d.value : undefined;
38
+ }
39
+ catch {
40
+ return null;
41
+ }
42
+ try {
43
+ if (!isPlainRecord(raw))
44
+ return Object.freeze({});
45
+ const own = (key) => {
46
+ try {
47
+ return readOwnDataValue(raw, key);
48
+ }
49
+ catch {
50
+ return undefined;
51
+ }
52
+ };
53
+ const errorCode = own('errorCode');
54
+ const error = own('error');
55
+ const detail = own('detail');
56
+ let bits = {};
57
+ try {
58
+ bits = detailBits(isPlainRecord(detail) ? detail : undefined);
59
+ }
60
+ catch {
61
+ bits = {};
62
+ }
63
+ return Object.freeze({
64
+ ...(typeof errorCode === 'string' && errorCode.length > 0 ? { errorCode } : {}),
65
+ ...(typeof error === 'string' && error.length > 0 ? { error: capForDisplay(error, SCENARIO_REFUSAL_ERROR_MAX) } : {}),
66
+ ...bits,
67
+ });
68
+ }
69
+ catch {
70
+ return Object.freeze({});
71
+ }
72
+ }
73
+ export function scenarioRefusalFromError(err) {
74
+ try {
75
+ if (err === null || typeof err !== 'object')
76
+ return null;
77
+ if (effectiveWireErrorCode(err) !== SCENARIO_ASSIGNMENT_UNKNOWN_ERROR_CODE)
78
+ return null;
79
+ const error = readErrorString(err, 'message');
80
+ return Object.freeze({
81
+ errorCode: SCENARIO_ASSIGNMENT_UNKNOWN_ERROR_CODE,
82
+ ...(error !== undefined && error.length > 0 ? { error: capForDisplay(error, SCENARIO_REFUSAL_ERROR_MAX) } : {}),
83
+ ...detailBits(readErrorRecord(err, 'detail')),
84
+ });
85
+ }
86
+ catch {
87
+ return null;
88
+ }
89
+ }
90
+ export function scenarioRefusalContent(reading, lang) {
91
+ let code;
92
+ let scenario;
93
+ let source;
94
+ try {
95
+ code = isPlainRecord(reading) ? readOwnDataValue(reading, 'errorCode') : undefined;
96
+ scenario = isPlainRecord(reading) ? readOwnDataValue(reading, 'scenario') : undefined;
97
+ source = isPlainRecord(reading) ? readOwnDataValue(reading, 'source') : undefined;
98
+ }
99
+ catch {
100
+ code = undefined;
101
+ scenario = undefined;
102
+ source = undefined;
103
+ }
104
+ if (code === SCENARIO_ASSIGNMENT_UNKNOWN_ERROR_CODE) {
105
+ const name = typeof scenario === 'string' && scenario.length > 0 ? ` ("${capForDisplay(scenario, 80)}")` : '';
106
+ const from = source === 'ruling' ? msg('config.scenarioRefusal.source.ruling') : source === 'deployment' ? msg('config.scenarioRefusal.source.deployment') : '';
107
+ return renderMessage(msg('config.scenarioRefusal.dangling', { name, from }), lang);
108
+ }
109
+ const tail = typeof code === 'string' && code.length > 0 ? ` (${capForDisplay(code, 80)})` : '';
110
+ return renderMessage(msg('config.scenarioRefusal.generic', { tail }), lang);
111
+ }
package/dist/seam.d.ts CHANGED
@@ -1,11 +1,12 @@
1
1
  import type { ModelUsage, SDKMessage } from '@sema-agent/agent-types';
2
2
  import type { EngineTurnUsage } from './adapter/downstream/turnUsageToModelUsage.js';
3
3
  import type { RunCostReconcile } from './adapter/downstream/terminalToSdkResult.js';
4
- import type { WiringManifestAutoMode, WiringManifestModelGate, WiringManifestMcpEntryView, WiringManifestHookEntryView, WiringManifestLspSeamView, WiringManifestWriteProtectionView, WiringManifestAutoConsolidationView, WiringManifestReadDenyView, ContextUsageSectionView, PromptManifestSectionView, PromptManifestBlockView, PromptManifestToolView } from './adapter/downstream/eventToSdkMessage.js';
4
+ import type { WiringManifestAutoMode, WiringManifestModelGate, WiringManifestMcpEntryView, WiringManifestHookEntryView, WiringManifestLspSeamView, WiringManifestWriteProtectionView, WiringManifestAutoConsolidationView, WiringManifestReadDenyView, WiringManifestModView, ContextUsageSectionView, PromptManifestSectionView, PromptManifestBlockView, PromptManifestToolView, PromptManifestIdentityView } from './adapter/downstream/eventToSdkMessage.js';
5
5
  import type { ToolRosterView, ToolRosterDeltaView, WiringManifestHandsView } from './toolRoster.js';
6
6
  import type { WiringManifestFleetView } from './adapter/downstream/wiringManifestView.js';
7
7
  import type { SuspendedReopenReading } from './hitl/suspendedReopen.js';
8
8
  import type { ToolKillCause } from './toolResult.js';
9
+ import type { HumanInputAttachmentView } from './ownKey.js';
9
10
  export interface AbortSignalLike {
10
11
  readonly aborted: boolean;
11
12
  }
@@ -33,13 +34,6 @@ export interface AdapterContext {
33
34
  readonly toolName: string;
34
35
  }): ToolKillCause | undefined;
35
36
  coalesceIntervalMs?: number;
36
- continuesPark?: ContinuesParkDeclaration;
37
- }
38
- export interface ContinuesParkDeclaration {
39
- readonly toolCallId: string;
40
- readonly checkpointId?: string;
41
- readonly parkedTaskId?: string;
42
- readonly continuationTaskId?: string;
43
37
  }
44
38
  export type ChromeEvent = {
45
39
  kind: 'retry_status';
@@ -143,6 +137,7 @@ export type ChromeEvent = {
143
137
  laneProof: LaneProof;
144
138
  usage: ModelUsage;
145
139
  engineUsage?: EngineTurnUsage;
140
+ engineUsageUnknownKeys?: number;
146
141
  usageMissing?: true;
147
142
  stopReason?: string;
148
143
  responseModel?: string;
@@ -154,6 +149,7 @@ export type ChromeEvent = {
154
149
  parentToolCallId: string;
155
150
  usage?: ModelUsage;
156
151
  engineUsage?: EngineTurnUsage;
152
+ engineUsageUnknownKeys?: number;
157
153
  usageMissing?: true;
158
154
  stopReason?: string;
159
155
  responseModel?: string;
@@ -164,7 +160,7 @@ export type ChromeEvent = {
164
160
  } | ({
165
161
  kind: 'run_cost_reconciled';
166
162
  laneProof: LaneProof;
167
- } & RunCostReconcile) | HumanInputChromeEvent | MessageCommittedChromeEvent | EngineNoticeChromeEvent | TextSegmentEndChromeEvent | ThinkingSegmentEndChromeEvent | ToolDisclosureChromeEvent | ToolProgressChromeEvent | ToolRosterDeltaChromeEvent | ContextUsageChromeEvent | CompactionOutcomeChromeEvent | PromptAssembledChromeEvent | MemorySavedChromeEvent | WiringManifestChromeEvent | ResultTextDivergedChromeEvent | ResultReplayedChromeEvent | ToolParkedChromeEvent | ApprovalRequestChromeEvent | ApprovalRevokeChromeEvent | {
163
+ } & RunCostReconcile) | HumanInputChromeEvent | MessageCommittedChromeEvent | EngineNoticeChromeEvent | TextSegmentEndChromeEvent | ThinkingSegmentEndChromeEvent | ToolDisclosureChromeEvent | ToolProgressChromeEvent | ToolRosterDeltaChromeEvent | ContextUsageChromeEvent | CompactionOutcomeChromeEvent | CompactionStartedChromeEvent | SubagentStartedChromeEvent | PromptAssembledChromeEvent | MemorySavedChromeEvent | WiringManifestChromeEvent | ResultTextDivergedChromeEvent | ResultReplayedChromeEvent | ToolParkedChromeEvent | ApprovalRequestChromeEvent | ApprovalRevokeChromeEvent | {
168
164
  kind: 'suspended_reopened';
169
165
  laneProof: LaneProof;
170
166
  reopen: Extract<SuspendedReopenReading, {
@@ -192,6 +188,7 @@ export interface WiringManifestChromeEvent {
192
188
  readonly selected: readonly string[];
193
189
  };
194
190
  fleet?: WiringManifestFleetView;
191
+ mods?: readonly WiringManifestModView[];
195
192
  eventId?: string;
196
193
  }
197
194
  export interface TextSegmentCommittedRow {
@@ -232,6 +229,34 @@ export interface CompactionOutcomeChromeEvent {
232
229
  outcome: string;
233
230
  trigger?: string;
234
231
  reason?: string;
232
+ pass?: string;
233
+ eventId?: string;
234
+ }
235
+ export interface CompactionStartedChromeEvent {
236
+ kind: 'compaction_started';
237
+ laneProof: LaneProof;
238
+ pass: string;
239
+ trigger: string;
240
+ startedAt?: number;
241
+ eventId?: string;
242
+ }
243
+ export interface SubagentStartedChromeEvent {
244
+ kind: 'subagent_started';
245
+ laneProof: LaneProof;
246
+ taskId: string;
247
+ sessionId?: string;
248
+ model?: string;
249
+ taskType?: string;
250
+ seq?: number;
251
+ workflowRunId?: string;
252
+ workflowAgentLabel?: string;
253
+ parentTaskId?: string;
254
+ parentSessionId?: string;
255
+ rootSessionId?: string;
256
+ name?: string;
257
+ spawnName?: string;
258
+ agentType?: string;
259
+ startedAt?: number;
235
260
  eventId?: string;
236
261
  }
237
262
  export interface MemorySavedChromeEvent {
@@ -247,6 +272,7 @@ export interface PromptAssembledChromeEvent {
247
272
  blocks?: readonly PromptManifestBlockView[];
248
273
  sections?: readonly PromptManifestSectionView[];
249
274
  tools?: readonly PromptManifestToolView[];
275
+ identity?: PromptManifestIdentityView;
250
276
  eventId?: string;
251
277
  }
252
278
  export interface ToolDisclosureChromeEvent {
@@ -337,7 +363,9 @@ export interface HumanInputChromeEvent {
337
363
  actor?: HumanInputActor;
338
364
  entryId?: string;
339
365
  eventId?: string;
366
+ attachments?: HumanInputAttachmentView[];
340
367
  }
368
+ export type { HumanInputAttachmentView } from './ownKey.js';
341
369
  export interface MessageCommittedChromeEvent {
342
370
  kind: 'message_committed';
343
371
  laneProof: LaneProof;
@@ -377,3 +405,14 @@ export declare function deriveTranscriptId(frame: {
377
405
  id?: unknown;
378
406
  toolCallId?: unknown;
379
407
  }, ctx: Pick<AdapterContext, 'uuid'>, suffix?: string): string;
408
+ export declare const SEMA_TERMINAL_OWNER_KEY = "_sema_terminal_owner";
409
+ export type TerminalOwner = {
410
+ readonly kind: 'request-not-sent';
411
+ readonly requestId?: string;
412
+ readonly heldBy?: string;
413
+ } | {
414
+ readonly kind: 'followed-run';
415
+ readonly taskId: string;
416
+ readonly runId?: string;
417
+ };
418
+ export declare function terminalOwnerOf(row: {} | null | undefined): TerminalOwner | undefined;