@sema-agent/client-core 0.97.0 → 0.98.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (281) hide show
  1. package/CHANGELOG.md +429 -0
  2. package/README.md +74 -36
  3. package/dist/adapt/arms.d.ts +1 -0
  4. package/dist/adapt/arms.js +128 -34
  5. package/dist/adapt/ids.d.ts +12 -1
  6. package/dist/adapt/ids.js +59 -8
  7. package/dist/adapt/instanceLedger.d.ts +50 -0
  8. package/dist/adapt/instanceLedger.js +147 -0
  9. package/dist/adapt/textStream.d.ts +1 -0
  10. package/dist/adapt/textStream.js +24 -7
  11. package/dist/adapt/toolCards.d.ts +27 -5
  12. package/dist/adapt/toolCards.js +39 -6
  13. package/dist/adapt/wireShapes.js +6 -2
  14. package/dist/adapt.d.ts +2 -0
  15. package/dist/adapt.js +8 -3
  16. package/dist/adapter/activeRunSelfHeal.d.ts +5 -0
  17. package/dist/adapter/activeRunSelfHeal.js +51 -28
  18. package/dist/adapter/downstream/eventToSdkMessage.d.ts +2 -5
  19. package/dist/adapter/downstream/eventToSdkMessage.js +27 -34
  20. package/dist/adapter/downstream/terminalToSdkResult.js +11 -4
  21. package/dist/adapter/downstream/turnUsageToModelUsage.d.ts +5 -2
  22. package/dist/adapter/downstream/turnUsageToModelUsage.js +2 -0
  23. package/dist/adapter/runStream.js +29 -13
  24. package/dist/adapter/types.d.ts +4 -4
  25. package/dist/agentSession/backgroundView.js +2 -1
  26. package/dist/agentSession/engineAgentRegistryRead.d.ts +2 -2
  27. package/dist/agentSession/engineAgentRegistryRead.js +12 -13
  28. package/dist/agentsWireCaps.d.ts +8 -6
  29. package/dist/agentsWireCaps.js +177 -162
  30. package/dist/approvalDecidedByCapability.d.ts +0 -4
  31. package/dist/approvalDecidedByCapability.js +0 -6
  32. package/dist/approvalsStreamLiveCapability.d.ts +0 -4
  33. package/dist/approvalsStreamLiveCapability.js +0 -6
  34. package/dist/assistantInbox.d.ts +34 -0
  35. package/dist/assistantInbox.js +118 -0
  36. package/dist/centerWiringCapability.js +9 -1
  37. package/dist/clientSlice.d.ts +0 -9
  38. package/dist/clientSlice.js +0 -3
  39. package/dist/cloudConfigWireCaps.d.ts +4 -2
  40. package/dist/cloudConfigWireCaps.js +81 -61
  41. package/dist/compensations.js +1 -1
  42. package/dist/connectorStatus.d.ts +21 -0
  43. package/dist/connectorStatus.js +112 -0
  44. package/dist/controlRouter.d.ts +14 -1
  45. package/dist/controlRouter.js +68 -17
  46. package/dist/coreValuePorts.d.ts +3 -3
  47. package/dist/decideReceipt.d.ts +2 -2
  48. package/dist/decideReceipt.js +5 -2
  49. package/dist/declared/supportFloorDeclared.js +3 -3
  50. package/dist/deviceExecutorManagementCapability.d.ts +0 -4
  51. package/dist/deviceExecutorManagementCapability.js +0 -6
  52. package/dist/deviceRebind.d.ts +49 -1
  53. package/dist/deviceRebind.js +221 -3
  54. package/dist/displayUntrusted.d.ts +1 -0
  55. package/dist/displayUntrusted.js +250 -76
  56. package/dist/engineAgentAbsence.d.ts +1 -1
  57. package/dist/engineAgentPanelStore.d.ts +5 -4
  58. package/dist/engineAgentPanelStore.js +3 -12
  59. package/dist/engineCapReader.d.ts +0 -4
  60. package/dist/engineCapReader.js +1 -5
  61. package/dist/engineCapsCache.d.ts +4 -0
  62. package/dist/engineCapsCache.js +17 -12
  63. package/dist/engineClosedSets.d.ts +1 -0
  64. package/dist/engineClosedSets.js +4 -1
  65. package/dist/engineErrorCodes.d.ts +9 -2
  66. package/dist/engineErrorCodes.js +9 -1
  67. package/dist/engineIdentity.d.ts +1 -0
  68. package/dist/engineIdentity.js +8 -0
  69. package/dist/engineRowRef.d.ts +28 -0
  70. package/dist/engineRowRef.js +111 -0
  71. package/dist/engineSessionMessages.d.ts +67 -0
  72. package/dist/engineSessionMessages.js +364 -0
  73. package/dist/engineToolDirectory.d.ts +18 -0
  74. package/dist/engineToolDirectory.js +85 -0
  75. package/dist/engineUrl.d.ts +18 -0
  76. package/dist/engineUrl.js +52 -0
  77. package/dist/env/uiLanguage.d.ts +9 -0
  78. package/dist/env/uiLanguage.js +35 -0
  79. package/dist/eventLeg.d.ts +92 -0
  80. package/dist/eventLeg.js +285 -0
  81. package/dist/executionLaneCapability.d.ts +0 -4
  82. package/dist/executionLaneCapability.js +3 -16
  83. package/dist/fileHistoryCaptureCapability.d.ts +0 -4
  84. package/dist/fileHistoryCaptureCapability.js +5 -7
  85. package/dist/fleet/fleetLedger.d.ts +0 -3
  86. package/dist/fleet/fleetLedger.js +21 -36
  87. package/dist/fleet/fleetProjection.d.ts +2 -2
  88. package/dist/fleet/fleetProjection.js +10 -8
  89. package/dist/frameBinding.d.ts +5 -0
  90. package/dist/frameBinding.js +23 -0
  91. package/dist/gateFailureCodes.d.ts +2 -0
  92. package/dist/gateFailureCodes.js +15 -0
  93. package/dist/gateOutcome.d.ts +3 -1
  94. package/dist/gateOutcome.js +25 -6
  95. package/dist/gateVocabulary.d.ts +5 -0
  96. package/dist/gateVocabulary.js +64 -2
  97. package/dist/generated/engineAskFaceTables.js +2 -2
  98. package/dist/generated/engineFactTables.d.ts +6 -3
  99. package/dist/generated/engineFactTables.js +22 -4
  100. package/dist/generated/engineNoticeTables.js +9 -0
  101. package/dist/generated/toolNameTables.d.ts +1 -0
  102. package/dist/generated/toolNameTables.js +1 -0
  103. package/dist/hitl/allowRuleShadow.d.ts +6 -1
  104. package/dist/hitl/allowRuleShadow.js +21 -17
  105. package/dist/hitl/approvalCardReading.d.ts +15 -0
  106. package/dist/hitl/approvalCardReading.js +154 -0
  107. package/dist/hitl/approvalCardReasons.d.ts +13 -0
  108. package/dist/hitl/approvalCardReasons.js +120 -0
  109. package/dist/hitl/approvalHolds.d.ts +47 -15
  110. package/dist/hitl/approvalHolds.js +134 -28
  111. package/dist/hitl/approvalResolution.d.ts +51 -26
  112. package/dist/hitl/approvalResolution.js +86 -122
  113. package/dist/hitl/approvalsFeed.js +6 -18
  114. package/dist/hitl/askClassPair.d.ts +2 -0
  115. package/dist/hitl/askClassPair.js +1 -0
  116. package/dist/hitl/askGateWire.d.ts +20 -2
  117. package/dist/hitl/askGateWire.js +49 -1
  118. package/dist/hitl/askParkRowRouting.d.ts +5 -0
  119. package/dist/hitl/askParkRowRouting.js +32 -1
  120. package/dist/hitl/askSettlementLine.d.ts +18 -0
  121. package/dist/hitl/askSettlementLine.js +79 -0
  122. package/dist/hitl/automaticAnswerVerdict.d.ts +1 -1
  123. package/dist/hitl/automaticAnswerVerdict.js +21 -5
  124. package/dist/hitl/crashConverged.d.ts +11 -20
  125. package/dist/hitl/crashConverged.js +56 -0
  126. package/dist/hitl/crashConvergedNotice.d.ts +3 -1
  127. package/dist/hitl/crashConvergedNotice.js +48 -11
  128. package/dist/hitl/decisionConflict.js +3 -10
  129. package/dist/hitl/decisionRefusal.d.ts +40 -1
  130. package/dist/hitl/decisionRefusal.js +199 -42
  131. package/dist/hitl/frameRouter.d.ts +5 -2
  132. package/dist/hitl/frameRouter.js +20 -16
  133. package/dist/hitl/gateLedger.d.ts +2 -0
  134. package/dist/hitl/gateLedger.js +50 -13
  135. package/dist/hitl/hitlBridge.d.ts +1 -2
  136. package/dist/hitl/hitlBridge.js +10 -7
  137. package/dist/hitl/livePendingAsk.d.ts +3 -3
  138. package/dist/hitl/livePendingAsk.js +7 -18
  139. package/dist/hitl/parkResolver.d.ts +2 -24
  140. package/dist/hitl/parkResolver.js +61 -97
  141. package/dist/hitl/persistedRulesWire.d.ts +24 -0
  142. package/dist/hitl/persistedRulesWire.js +122 -2
  143. package/dist/hitl/planReviewWire.d.ts +26 -13
  144. package/dist/hitl/planReviewWire.js +112 -78
  145. package/dist/hitl/refusedToolNameProse.d.ts +0 -1
  146. package/dist/hitl/refusedToolNameProse.js +0 -3
  147. package/dist/hitl/replayedApproval.d.ts +4 -3
  148. package/dist/hitl/replayedApproval.js +7 -4
  149. package/dist/hitl/sessionPolicyDeliverable.js +2 -4
  150. package/dist/hitl/sessionPolicyWire.d.ts +32 -20
  151. package/dist/hitl/sessionPolicyWire.js +162 -52
  152. package/dist/hitl/standingRows.d.ts +20 -2
  153. package/dist/hitl/standingRows.js +69 -8
  154. package/dist/hitl/toolApprovalWire.d.ts +87 -152
  155. package/dist/hitl/toolApprovalWire.js +591 -380
  156. package/dist/hookMatcherVerdict.d.ts +6 -1
  157. package/dist/hookMatcherVerdict.js +14 -7
  158. package/dist/hooksWireCaps.d.ts +2 -2
  159. package/dist/hooksWireCaps.js +59 -55
  160. package/dist/i18n/messages.en.d.ts +121 -0
  161. package/dist/i18n/messages.en.js +119 -0
  162. package/dist/i18n/messages.zh.d.ts +3 -0
  163. package/dist/i18n/messages.zh.js +120 -0
  164. package/dist/i18n/translate.d.ts +25 -0
  165. package/dist/i18n/translate.js +127 -0
  166. package/dist/index.d.ts +53 -18
  167. package/dist/index.js +38 -10
  168. package/dist/inheritEnvCapability.d.ts +31 -0
  169. package/dist/inheritEnvCapability.js +104 -0
  170. package/dist/liveModelCatalog.d.ts +1 -2
  171. package/dist/liveModelCatalog.js +2 -6
  172. package/dist/liveQuestionStore.d.ts +2 -21
  173. package/dist/mcpLiveness.d.ts +2 -1
  174. package/dist/mcpProbeWire.d.ts +6 -1
  175. package/dist/mcpProbeWire.js +1 -1
  176. package/dist/mcpWireCaps.d.ts +13 -2
  177. package/dist/mcpWireCaps.js +48 -0
  178. package/dist/memoryEntriesWire.d.ts +4 -9
  179. package/dist/model/modelSupplyRules.d.ts +0 -2
  180. package/dist/model/modelSupplyRules.js +3 -12
  181. package/dist/model/modelsPolicy.d.ts +0 -5
  182. package/dist/model/modelsPolicy.js +6 -36
  183. package/dist/model/subagentModelWord.d.ts +31 -0
  184. package/dist/model/subagentModelWord.js +261 -0
  185. package/dist/notifications.d.ts +6 -0
  186. package/dist/notifications.js +71 -23
  187. package/dist/outputStyleSeatCapability.d.ts +0 -3
  188. package/dist/outputStyleSeatCapability.js +0 -3
  189. package/dist/ownKey.d.ts +15 -0
  190. package/dist/ownKey.js +60 -3
  191. package/dist/panelReduce.d.ts +15 -9
  192. package/dist/panelReduce.js +680 -549
  193. package/dist/panelStateHolder.d.ts +3 -7
  194. package/dist/panelStateHolder.js +14 -130
  195. package/dist/peerLaneCapability.d.ts +0 -4
  196. package/dist/peerLaneCapability.js +0 -6
  197. package/dist/permissionRulesWriteCapability.d.ts +0 -4
  198. package/dist/permissionRulesWriteCapability.js +0 -6
  199. package/dist/permissionWireCaps.d.ts +2 -2
  200. package/dist/permissionWireCaps.js +2 -0
  201. package/dist/permissionsAllowGrantCapability.d.ts +0 -4
  202. package/dist/permissionsAllowGrantCapability.js +0 -6
  203. package/dist/permissionsDeclaration.d.ts +0 -11
  204. package/dist/permissionsDeclaration.js +60 -53
  205. package/dist/pluginHooksWire.d.ts +1 -1
  206. package/dist/pluginHooksWire.js +3 -6
  207. package/dist/preemptWire.d.ts +44 -0
  208. package/dist/preemptWire.js +83 -0
  209. package/dist/printToolResultFrame.js +15 -4
  210. package/dist/replayBody.d.ts +3 -0
  211. package/dist/replayBody.js +14 -0
  212. package/dist/request/taskRequest.d.ts +0 -1
  213. package/dist/request/taskRequest.js +0 -3
  214. package/dist/resumeRefusalCopy.d.ts +2 -1
  215. package/dist/resumeRefusalCopy.js +38 -2
  216. package/dist/retryStatus.d.ts +8 -0
  217. package/dist/retryStatus.js +106 -1
  218. package/dist/rewindArchiveCapability.d.ts +0 -4
  219. package/dist/rewindArchiveCapability.js +2 -10
  220. package/dist/rewindArchiveReading.d.ts +0 -1
  221. package/dist/rewindArchiveReading.js +0 -3
  222. package/dist/runCancelContext.d.ts +2 -1
  223. package/dist/runCancelContext.js +4 -2
  224. package/dist/runReattachPolicy.d.ts +31 -0
  225. package/dist/runReattachPolicy.js +46 -0
  226. package/dist/runTerminal.d.ts +3 -6
  227. package/dist/runTerminal.js +8 -9
  228. package/dist/sandboxWire.d.ts +3 -1
  229. package/dist/sandboxWire.js +76 -27
  230. package/dist/scenarioWire.js +1 -1
  231. package/dist/seam.d.ts +24 -2
  232. package/dist/seam.js +15 -3
  233. package/dist/seatContract.d.ts +53 -10
  234. package/dist/seatContract.js +132 -81
  235. package/dist/sessionPolicyCapability.d.ts +0 -4
  236. package/dist/sessionPolicyCapability.js +0 -6
  237. package/dist/sessionSyncFileHistoryCapability.d.ts +0 -3
  238. package/dist/sessionSyncFileHistoryCapability.js +0 -3
  239. package/dist/skillToolListsCapability.d.ts +0 -3
  240. package/dist/skillToolListsCapability.js +0 -3
  241. package/dist/sqlEngineCapability.d.ts +0 -4
  242. package/dist/sqlEngineCapability.js +0 -6
  243. package/dist/steerPriorityCapability.d.ts +0 -3
  244. package/dist/steerPriorityCapability.js +0 -3
  245. package/dist/streamDrainingLegs.d.ts +4 -0
  246. package/dist/streamDrainingLegs.js +6 -1
  247. package/dist/subagent/engineCompactWire.d.ts +0 -1
  248. package/dist/subagent/engineCompactWire.js +7 -5
  249. package/dist/subagent/engineTaskHandleWire.js +4 -7
  250. package/dist/subagentContentStore.js +1 -11
  251. package/dist/submitReopen.d.ts +24 -0
  252. package/dist/submitReopen.js +75 -0
  253. package/dist/terminalStatuses.d.ts +3 -0
  254. package/dist/terminalStatuses.js +10 -2
  255. package/dist/toolResult.d.ts +10 -1
  256. package/dist/toolResult.js +34 -6
  257. package/dist/toolRoster.d.ts +0 -2
  258. package/dist/toolRoster.js +0 -2
  259. package/dist/turnFailurePresentation.d.ts +28 -0
  260. package/dist/turnFailurePresentation.js +205 -0
  261. package/dist/userInvokedSkillsCapability.d.ts +0 -3
  262. package/dist/userInvokedSkillsCapability.js +0 -3
  263. package/dist/webSearchBackendCapability.d.ts +0 -4
  264. package/dist/webSearchBackendCapability.js +0 -6
  265. package/dist/wireErrorTriage.js +5 -24
  266. package/dist/wireFailureShape.d.ts +62 -5
  267. package/dist/wireFailureShape.js +105 -5
  268. package/dist/wireRefusalCopy.d.ts +12 -2
  269. package/dist/wireRefusalCopy.js +50 -52
  270. package/dist/workflowsJournalCapability.d.ts +0 -4
  271. package/dist/workflowsJournalCapability.js +0 -6
  272. package/dist/writeProtectionCapability.d.ts +0 -4
  273. package/dist/writeProtectionCapability.js +0 -6
  274. package/docs/INTEGRATION-CLIENTS.md +1305 -46
  275. package/package.json +5 -4
  276. package/dist/attachmentSeatCapability.d.ts +0 -12
  277. package/dist/attachmentSeatCapability.js +0 -23
  278. package/dist/hitl/approvalOutcomeNote.d.ts +0 -10
  279. package/dist/hitl/approvalOutcomeNote.js +0 -29
  280. package/dist/sessionReadRedactionCapability.d.ts +0 -13
  281. package/dist/sessionReadRedactionCapability.js +0 -35
@@ -3,6 +3,8 @@ import { isSdkRunParked } from './terminalStatuses.js';
3
3
  import { readOwnDataNonEmptyString, readOwnDataValue } from './ownKey.js';
4
4
  import { doneResultView } from './replayBody.js';
5
5
  export const PROMPT_BLOCK_CAUSES = CORE_PROMPT_BLOCK_CAUSES;
6
+ const _promptBlockTablePin = true;
7
+ void _promptBlockTablePin;
6
8
  const PROMPT_BLOCKED_BY_HOOK_DETAIL_KIND = 'prompt_blocked_by_hook';
7
9
  function str(v) {
8
10
  return typeof v === 'string' && v.length > 0 ? v : undefined;
@@ -267,8 +269,7 @@ export function readRunTerminal(result) {
267
269
  return null;
268
270
  const view = doneResultView(result);
269
271
  if (view.replay) {
270
- const inner = readRunTerminalArm(view.engine) ?? readRunTerminalArm({ status: view.row?.status, errorCode: view.row?.errorCode, errorMessage: view.row?.error });
271
- return inner === null ? null : { ...inner, replay: true };
272
+ return readRunTerminalArm(view.engine) ?? readRunTerminalArm({ status: view.row?.status, errorCode: view.row?.errorCode, errorMessage: view.row?.error });
272
273
  }
273
274
  return readRunTerminalArm(result);
274
275
  }
@@ -278,16 +279,14 @@ function readRunTerminalArm(result) {
278
279
  const r = result;
279
280
  if ('terminal' in r) {
280
281
  const t = r.terminal;
281
- if (typeof t !== 'object' || t === null || Array.isArray(t))
282
- return { kind: 'unknown', plane: 'cause' };
283
- const c = t;
284
- const kind = str(c.kind);
285
- if (kind === undefined)
286
- return { kind: 'unknown', plane: 'cause' };
282
+ const c = typeof t === 'object' && t !== null && !Array.isArray(t) ? t : undefined;
283
+ const kind = c === undefined ? undefined : str(c.kind);
287
284
  const parkWord = str(r.status);
288
285
  if (isSdkRunParked(parkWord)) {
289
- return { kind: 'paused', plane: 'cause', flatStatus: parkWord, ...(kind === 'paused' ? (pauseOf(c) ?? {}) : {}) };
286
+ return { kind: 'paused', plane: 'cause', flatStatus: parkWord, ...(c !== undefined && kind === 'paused' ? (pauseOf(c) ?? {}) : {}) };
290
287
  }
288
+ if (c === undefined || kind === undefined)
289
+ return { kind: 'unknown', plane: 'cause' };
291
290
  switch (kind) {
292
291
  case 'completed': {
293
292
  const detail = completedDetailOf(c);
@@ -23,4 +23,6 @@ export declare const SANDBOX_K8S_ONLY_400_ANCHOR = "only supported on the k8s sa
23
23
  export declare const SANDBOX_NO_IMAGE_INDEX_400_ANCHOR = "requires the image index";
24
24
  export declare const SANDBOX_NO_PUBLISHED_IMAGE_404_ANCHOR = "no published sandbox image for profile";
25
25
  export declare const SANDBOX_CASCADE_CONFLICT_400_ANCHOR = "not supported together with cascade/verify";
26
- export declare function sandboxDegradeHint(err: unknown): string | undefined;
26
+ export type SandboxHintHost = 'terminal' | 'web' | 'desktop';
27
+ export declare const SANDBOX_HINT_HOSTS: readonly SandboxHintHost[];
28
+ export declare function sandboxDegradeHint(err: unknown, host?: SandboxHintHost): string | undefined;
@@ -1,5 +1,6 @@
1
1
  import { lastFlagValue } from './argvFlagValue.js';
2
2
  import { CAPABILITY_IMAGE_INDEX_REQUIRED } from './engineErrorCodes.js';
3
+ import { THROWN_SLOT_UNREADABLE, readThrownSlot } from './wireFailureShape.js';
3
4
  const MAX_PROFILE_LEN = 128;
4
5
  const USAGE_HINT = "sema: --sandbox expects a profile name or 'auto'.\n" +
5
6
  ' --sandbox <profile> run on that sandbox image profile (k8s-lane workers; list: sema cloud images list)\n' +
@@ -46,36 +47,84 @@ export const SANDBOX_K8S_ONLY_400_ANCHOR = 'only supported on the k8s sandbox ba
46
47
  export const SANDBOX_NO_IMAGE_INDEX_400_ANCHOR = 'requires the image index';
47
48
  export const SANDBOX_NO_PUBLISHED_IMAGE_404_ANCHOR = 'no published sandbox image for profile';
48
49
  export const SANDBOX_CASCADE_CONFLICT_400_ANCHOR = 'not supported together with cascade/verify';
49
- const SANDBOX_IMAGE_INDEX_501_HINT = 'Cloud sandbox images are not available on this engine: its storage backend keeps no image index, so profiles cannot be listed or selected here.\n' +
50
- 'Use a worker backed by a SQL store (it has the image index), or re-run without --sandbox.';
51
- function imageIndexRequiredCode(err) {
50
+ export const SANDBOX_HINT_HOSTS = Object.freeze(['terminal', 'web', 'desktop']);
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.',
54
+ sep: '\n',
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.',
58
+ },
59
+ },
60
+ k8sLaneOnly400: {
61
+ subject: { terminal: '--sandbox <profile>', graphical: 'The selected sandbox image profile' },
62
+ fact: ' only applies on k8s-lane workers; this engine runs a host/e2b sandbox lane, so the request was honestly rejected.',
63
+ sep: '\n',
64
+ outlet: {
65
+ terminal: 'Re-run without --sandbox (worker default image), or point the shell at a k8s-lane worker (sema cloud engine connect <url>).',
66
+ graphical: 'Keep the default environment, or connect to a k8s-lane worker.',
67
+ },
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.',
71
+ sep: '\n',
72
+ 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.',
75
+ },
76
+ },
77
+ noPublishedImage404: {
78
+ fact: 'No published image matches that profile for your principal.',
79
+ sep: ' ',
80
+ outlet: {
81
+ terminal: 'List what you can use: sema cloud images list',
82
+ graphical: 'Choose one of the environments that are offered instead.',
83
+ },
84
+ },
85
+ cascadeConflict400: {
86
+ subject: { terminal: '--sandbox', graphical: 'The sandbox image profile' },
87
+ fact: ' cannot combine with cascade/verify submits in v1 (the per-task image would not bind to the sub-runs).',
88
+ sep: ' ',
89
+ outlet: { terminal: 'Drop one of the two.', graphical: 'Drop one of the two.' },
90
+ },
91
+ });
92
+ function sandboxHintOf(arm, host) {
93
+ const terminal = host === undefined || host === 'terminal';
94
+ const graphical = host === 'web' || host === 'desktop';
95
+ const subject = arm.subject === undefined ? '' : terminal ? arm.subject.terminal : arm.subject.graphical;
96
+ const factSegment = `${subject}${arm.fact}`;
97
+ if (terminal)
98
+ return `${factSegment}${arm.sep}${arm.outlet.terminal}`;
99
+ if (graphical)
100
+ return `${factSegment}${arm.sep}${arm.outlet.graphical}`;
101
+ return factSegment;
102
+ }
103
+ function sandboxSlot(err, key) {
104
+ const v = readThrownSlot(err, key, 'data');
105
+ return v === THROWN_SLOT_UNREADABLE ? undefined : v;
106
+ }
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;
52
113
  try {
53
- return typeof err === 'object' && err !== null && err.errorCode === CAPABILITY_IMAGE_INDEX_REQUIRED;
114
+ const msg = err.message;
115
+ if (typeof msg !== 'string')
116
+ 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))
122
+ return sandboxHintOf(SANDBOX_HINT_ARMS.noPublishedImage404, host);
123
+ if (status === 400 && msg.includes(SANDBOX_CASCADE_CONFLICT_400_ANCHOR))
124
+ return sandboxHintOf(SANDBOX_HINT_ARMS.cascadeConflict400, host);
125
+ return undefined;
54
126
  }
55
127
  catch {
56
- return false;
57
- }
58
- }
59
- export function sandboxDegradeHint(err) {
60
- const e = err;
61
- if (e?.status === 501 && imageIndexRequiredCode(err))
62
- return SANDBOX_IMAGE_INDEX_501_HINT;
63
- if (typeof e?.status !== 'number' || typeof e?.message !== 'string')
64
128
  return undefined;
65
- const msg = e.message;
66
- if (e.status === 400 && msg.includes(SANDBOX_K8S_ONLY_400_ANCHOR)) {
67
- return ('--sandbox <profile> only applies on k8s-lane workers; this engine runs a host/e2b sandbox lane, so the request was honestly rejected.\n' +
68
- 'Re-run without --sandbox (worker default image), or point the shell at a k8s-lane worker (sema cloud engine connect <url>).');
69
- }
70
- if (e.status === 400 && msg.includes(SANDBOX_NO_IMAGE_INDEX_400_ANCHOR)) {
71
- return ('This worker has no sandbox image index configured (the sema-web-admin config center is not attached), so per-task profiles cannot resolve.\n' +
72
- 'Re-run without --sandbox, or use a worker with the image index enabled.');
73
- }
74
- if (e.status === 404 && msg.includes(SANDBOX_NO_PUBLISHED_IMAGE_404_ANCHOR)) {
75
- return 'No published image matches that profile for your principal. List what you can use: sema cloud images list';
76
- }
77
- if (e.status === 400 && msg.includes(SANDBOX_CASCADE_CONFLICT_400_ANCHOR)) {
78
- return '--sandbox cannot combine with cascade/verify submits in v1 (the per-task image would not bind to the sub-runs). Drop one of the two.';
79
129
  }
80
- return undefined;
81
130
  }
@@ -4,7 +4,7 @@ export const SCENARIO_NAME_RE = /^[a-z][a-z0-9-]{1,31}$/;
4
4
  export const HEADLESS_SCENARIO_ENV = 'SEMA_HEADLESS_SCENARIO';
5
5
  const USAGE_HINT = "sema: --scenario expects a scenario name (lowercase letters/digits/hyphens, starting with a letter, ≤32 chars).\n" +
6
6
  ' --scenario <name> route this run through the named engine scenario (deployment-defined tool\n' +
7
- ' roster + system prompt; unknown names fall back to the default scenario)\n' +
7
+ ' roster + system prompt; unknown names are refused by the engine (scenario_unknown))\n' +
8
8
  ' (no flag) the default scenario — today\'s behaviour';
9
9
  export function parseScenarioArgv(argv) {
10
10
  const flag = lastFlagValue(argv, '--scenario');
package/dist/seam.d.ts CHANGED
@@ -5,6 +5,7 @@ import type { WiringManifestAutoMode, WiringManifestModelGate, WiringManifestMcp
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
+ import type { ToolKillCause } from './toolResult.js';
8
9
  export interface AbortSignalLike {
9
10
  readonly aborted: boolean;
10
11
  }
@@ -27,7 +28,18 @@ export interface AdapterContext {
27
28
  signal?: AbortSignalLike;
28
29
  setTimer?(ms: number, fn: () => void): TimerHandle;
29
30
  clearTimer?(handle: TimerHandle): void;
31
+ toolKillCause?(call: {
32
+ readonly toolCallId: string;
33
+ readonly toolName: string;
34
+ }): ToolKillCause | undefined;
30
35
  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;
31
43
  }
32
44
  export type ChromeEvent = {
33
45
  kind: 'retry_status';
@@ -152,7 +164,7 @@ export type ChromeEvent = {
152
164
  } | ({
153
165
  kind: 'run_cost_reconciled';
154
166
  laneProof: LaneProof;
155
- } & RunCostReconcile) | HumanInputChromeEvent | MessageCommittedChromeEvent | EngineNoticeChromeEvent | TextSegmentEndChromeEvent | ThinkingSegmentEndChromeEvent | ToolDisclosureChromeEvent | ToolProgressChromeEvent | ToolRosterDeltaChromeEvent | ContextUsageChromeEvent | CompactionOutcomeChromeEvent | PromptAssembledChromeEvent | MemorySavedChromeEvent | WiringManifestChromeEvent | ResultTextDivergedChromeEvent | ApprovalRequestChromeEvent | ApprovalRevokeChromeEvent | {
167
+ } & RunCostReconcile) | HumanInputChromeEvent | MessageCommittedChromeEvent | EngineNoticeChromeEvent | TextSegmentEndChromeEvent | ThinkingSegmentEndChromeEvent | ToolDisclosureChromeEvent | ToolProgressChromeEvent | ToolRosterDeltaChromeEvent | ContextUsageChromeEvent | CompactionOutcomeChromeEvent | PromptAssembledChromeEvent | MemorySavedChromeEvent | WiringManifestChromeEvent | ResultTextDivergedChromeEvent | ResultReplayedChromeEvent | ToolParkedChromeEvent | ApprovalRequestChromeEvent | ApprovalRevokeChromeEvent | {
156
168
  kind: 'suspended_reopened';
157
169
  laneProof: LaneProof;
158
170
  reopen: Extract<SuspendedReopenReading, {
@@ -286,6 +298,17 @@ export interface ResultTextDivergedChromeEvent {
286
298
  committedLength: number;
287
299
  resultLength: number;
288
300
  }
301
+ export interface ResultReplayedChromeEvent {
302
+ kind: 'result_replayed';
303
+ laneProof: LaneProof;
304
+ text: string;
305
+ }
306
+ export interface ToolParkedChromeEvent {
307
+ kind: 'tool_parked';
308
+ laneProof: LaneProof;
309
+ toolUseId: string;
310
+ rowUuid?: string;
311
+ }
289
312
  export interface EngineNoticeChromeEvent {
290
313
  kind: 'engine_notice';
291
314
  laneProof: LaneProof;
@@ -352,6 +375,5 @@ export interface WireToCcAdapter {
352
375
  }
353
376
  export declare function deriveTranscriptId(frame: {
354
377
  id?: unknown;
355
- seq?: unknown;
356
378
  toolCallId?: unknown;
357
379
  }, ctx: Pick<AdapterContext, 'uuid'>, suffix?: string): string;
package/dist/seam.js CHANGED
@@ -113,6 +113,19 @@ const CHROME_ARM_TABLE = {
113
113
  'mcp 的空数组是「一台都没申报」这句正面事实、**不是**缺席(判在场写 mcp !== undefined,' +
114
114
  '别写 mcp?.length),errorCode 按开集分支必带 default;durable 重放按 run/leg 幂等',
115
115
  },
116
+ result_replayed: {
117
+ required: true,
118
+ duty: '0.98.0:提交幂等的重放(同一把幂等键命中更早的一次提交,这次没有新跑)。每个重放终局恰一条,在终局臂全部产出之后;渲一行 `text`,不进模型面。' +
119
+ '🔴 零转录行的重放终局(空正文成功 / 停驻)里本臂是这一轮唯一的可渲染产出 —— 不接 = 整轮无提示;' +
120
+ '句子只说「这次没有新跑」,结局由已有的行与结果帧说,别在本臂上拼结局,也别从行上的 `_sema_replay` 现拼句子;' +
121
+ '没收到本臂 ≠ 这次真跑;续读 / 接管重投的终局永不发本臂;冷恢复后看不到是诚实缺席(要留就把渲成的那一行随转录落盘)。',
122
+ },
123
+ tool_parked: {
124
+ required: true,
125
+ duty: '0.98.0:被停驻扣住的那只调用此刻是「停驻、没结算」—— 摘卡那一拍恰一枚(同一拍零终态行)。把 `rowUuid` 那一行(调用 occurrence 的开始行)置「在等审批」;' +
126
+ '按开始行 uuid 认行,不按 toolUseId(调用 id 只在同一条助手消息内唯一)。它的终态由执行腿的结果铸(续跑带见证时接回原行),或永远缺席(停驻被取消 / 过期)。' +
127
+ '连坐旁观者 / 普通错误 / 停驻卡上 Esc(包已自发中断拒绝,行照铸 Interrupted)零枚。',
128
+ },
116
129
  result_text_diverged: {
117
130
  required: false,
118
131
  duty: '可选:终帧正文与已上屏正文**互相都不是对方前缀**时的诚实披露。🔴 处置是把这一拍的转录行**改口**' +
@@ -155,14 +168,13 @@ const CHROME_ARM_TABLE = {
155
168
  '⑦序:该段尾部的活体增量(`stream_delta`)一律先于本事件到达,本事件之后不再有同段增量(下一条增量属于下一段)。',
156
169
  },
157
170
  };
171
+ const _chromeArmRequiredFloorPins = [true, true];
172
+ void _chromeArmRequiredFloorPins;
158
173
  export const CHROME_ARMS = Object.entries(CHROME_ARM_TABLE).map(([kind, d]) => ({ kind, required: d.required, duty: d.duty }));
159
174
  export function deriveTranscriptId(frame, ctx, suffix) {
160
175
  if (typeof frame.id === 'string' && frame.id.length > 0) {
161
176
  return uuidV5(TRANSCRIPT_ID_NAMESPACE, suffix !== undefined ? `wid_${frame.id}#${suffix}` : `wid_${frame.id}`);
162
177
  }
163
- if (typeof frame.seq === 'number') {
164
- return uuidV5(TRANSCRIPT_ID_NAMESPACE, suffix !== undefined ? `wseq#${suffix}_${frame.seq}` : `wseq_${frame.seq}`);
165
- }
166
178
  if (typeof frame.toolCallId === 'string' && frame.toolCallId.length > 0) {
167
179
  return uuidV5(TRANSCRIPT_ID_NAMESPACE, suffix !== undefined ? `wtc#${suffix}_${frame.toolCallId}` : `wtc_${frame.toolCallId}`);
168
180
  }
@@ -1,6 +1,7 @@
1
1
  import type { ReasoningEffort } from "./effortWire.js";
2
2
  import type { PermissionMode } from "./permissionWireCaps.js";
3
3
  import type { ChromeArmKind, LaneProof } from "./seam.js";
4
+ import type { SeatTurnFailure } from "./turnFailurePresentation.js";
4
5
  import type { QuestionAnswer } from "./liveQuestionStore.js";
5
6
  import type { ToolApprovalDelegation } from "./hitl/toolApprovalWire.js";
6
7
  import type { ApprovalMandateWord } from "./gateVocabulary.js";
@@ -73,7 +74,7 @@ export interface ToolPermissionRequest {
73
74
  declare const SEAT_EVENT_TYPE_TUPLE: readonly ["start", "close", "session_updated", "message", "stream_event", "chrome_event", "error", "tool_permission_resolved"];
74
75
  export type SeatEventType = (typeof SEAT_EVENT_TYPE_TUPLE)[number];
75
76
  export declare const SEAT_EVENT_TYPES: readonly SeatEventType[];
76
- declare const CHROME_EVENT_KIND_TUPLE: readonly ["panel_task", "notification_terminal", "prompt_suggestions", "subagent_lifecycle", "text_segment_end", "thinking_segment_end"];
77
+ declare const CHROME_EVENT_KIND_TUPLE: readonly ["panel_task", "notification_terminal", "prompt_suggestions", "subagent_lifecycle", "text_segment_end", "thinking_segment_end", "retry_status", "context_usage", "last_turn_usage", "bgshell_register", "bgshell_settle", "memory_saved", "result_replayed", "tool_parked"];
77
78
  export type ChromeEventKind = Extract<ChromeArmKind, (typeof CHROME_EVENT_KIND_TUPLE)[number]>;
78
79
  export declare const CHROME_EVENT_KINDS: readonly ChromeEventKind[];
79
80
  export interface SeatChromeEnvelopeBase {
@@ -88,23 +89,58 @@ export interface LocalSessionEvent {
88
89
  type: SeatEventType;
89
90
  sessionId: string;
90
91
  message?: unknown;
91
- messages?: unknown[];
92
92
  error?: string;
93
93
  errorCategory?: string;
94
+ _sema_turnFailure?: SeatTurnFailure;
94
95
  code?: number;
95
96
  request?: ToolPermissionRequest;
96
- data?: string;
97
97
  sources?: string[];
98
- permissionMode?: PermissionModeIntent;
99
98
  session?: LocalSessionRecord;
100
99
  userMessageUuid?: string;
101
- hasPreClearSession?: boolean;
102
100
  requestId?: string;
103
101
  outcome?: string;
104
102
  parked?: true;
105
103
  chrome?: SeatChromeEnvelope;
106
104
  }
107
105
  export declare const HITL_RESOLUTION_OUTCOMES: readonly string[];
106
+ export declare const SEAT_STREAM_DELTA_TYPE_OF_CHANNEL: Readonly<{
107
+ readonly text: "text_delta";
108
+ readonly thinking: "thinking_delta";
109
+ }>;
110
+ export type SeatStreamChannel = keyof typeof SEAT_STREAM_DELTA_TYPE_OF_CHANNEL;
111
+ export type SeatStreamDeltaType = (typeof SEAT_STREAM_DELTA_TYPE_OF_CHANNEL)[SeatStreamChannel];
112
+ export interface SeatStreamDelta {
113
+ type: SeatStreamDeltaType;
114
+ delta: string;
115
+ }
116
+ export interface SeatStreamEventMessage {
117
+ type: "stream_event";
118
+ uuid: string;
119
+ session_id: string;
120
+ event: SeatStreamDelta;
121
+ parent_tool_use_id: null;
122
+ }
123
+ export interface SeatStreamDeltaSource {
124
+ readonly channel: SeatStreamChannel;
125
+ readonly text: string;
126
+ }
127
+ export interface SeatStreamDeltaIds {
128
+ readonly uuid: string;
129
+ readonly sessionId: string;
130
+ }
131
+ export type SeatStreamReading = {
132
+ readonly kind: "delta";
133
+ readonly channel: SeatStreamChannel;
134
+ readonly delta: string;
135
+ } | {
136
+ readonly kind: "unknown_event";
137
+ } | {
138
+ readonly kind: "malformed";
139
+ } | {
140
+ readonly kind: "not_stream_event";
141
+ };
142
+ export declare function seatStreamDeltaMessage(event: SeatStreamDeltaSource, ids: SeatStreamDeltaIds): SeatStreamEventMessage | undefined;
143
+ export declare function readSeatStreamDelta(message: object): SeatStreamReading;
108
144
  export declare const SEAT_CAPABILITY_NAMES: readonly ["pickFolder", "rewind", "recents", "patchSession"];
109
145
  export type SeatCapabilityName = (typeof SEAT_CAPABILITY_NAMES)[number];
110
146
  export interface SeatCapabilitiesState {
@@ -328,11 +364,15 @@ export interface ApplyModelConfigRequest {
328
364
  defaultModel: SeatCatalogEntry;
329
365
  cheapModel?: SeatCatalogEntry;
330
366
  }
367
+ export declare const APPLY_MODEL_CONFIG_REASONS: readonly ["shadowed_by_models_json", "cheap_provider_unsupported", "invalid_request", "write_failed", "unavailable"];
368
+ export type ApplyModelConfigReason = (typeof APPLY_MODEL_CONFIG_REASONS)[number];
331
369
  export interface ApplyModelConfigResult {
332
370
  ok: boolean;
333
- reason?: string;
371
+ reason?: ApplyModelConfigReason;
372
+ detail?: string;
334
373
  requiresRestart: boolean;
335
374
  }
375
+ export declare function applyModelConfigReasonDetail(reason: string | undefined): string;
336
376
  export declare function checkSendMessageRequest(v: unknown): SeatValidation;
337
377
  export declare function isSendMessageRequest(v: unknown): v is SendMessageRequest;
338
378
  export declare const checkSessionRowPatchRequest: (v: unknown) => SeatValidation;
@@ -342,7 +382,7 @@ export declare const LOCAL_SESSIONS_SPEC: EipcServiceSpec;
342
382
  export declare const SEAT_METHOD_NAMES: readonly ["start", "sendMessage", "interrupt", "stop", "respondToToolPermission", "cancelQueuedMessage", "reorderQueuedMessage", "promoteQueuedMessage", "setFocusedSession", "setModel", "getTranscript", "searchSessions", "uploadAttachment", "listModels", "applyModelConfig", "pickFolder", "listRecentFolders", "noteRecentFolder", "patchSession", "onEvent", "onToolPermissionRequest"];
343
383
  export declare const SEAT_STORE_PROPS: readonly ["sessionsStateStore", "focusedSessionStateStore", "settingsStateStore", "seatCapabilitiesStateStore"];
344
384
  export declare const SEAT_EVENT_METHOD_NAMES: readonly ["onEvent", "onToolPermissionRequest"];
345
- export declare const LOCAL_SESSION_EVENT_KEYS: readonly ["type", "sessionId", "message", "messages", "error", "errorCategory", "code", "request", "data", "sources", "permissionMode", "session", "userMessageUuid", "hasPreClearSession", "requestId", "outcome", "parked", "chrome"];
385
+ export declare const LOCAL_SESSION_EVENT_KEYS: readonly ["type", "sessionId", "message", "error", "errorCategory", "code", "request", "sources", "session", "userMessageUuid", "requestId", "outcome", "parked", "chrome", "_sema_turnFailure"];
346
386
  export declare const TOOL_PERMISSION_REQUEST_KEYS: readonly ["requestId", "sessionId", "toolName", "toolCallId", "input", "message", "toctouBinding", "createdAtMs", "governanceForced", "delegation", "mandated", "mandate", "origin", "ruleOffersAbsence", "askClass", "classes", "sessionRow"];
347
387
  export declare const LOCAL_SESSION_RECORD_KEYS: readonly ["sessionId", "engineSessionId", "model", "title", "cwd", "isRunning", "createdAt", "lastActivityAt", "queuedMessages", "parked", "pinned"];
348
388
  export declare const SEND_MESSAGE_REQUEST_KEYS: readonly ["sessionId", "text", "model", "userMessageUuid", "permissionMode", "attachmentIds", "reasoningEffort", "retainBackgroundProcesses", "forwardSubagentEvents", "retainSubagentSessions", "settings", "scenario", "rewind"];
@@ -436,10 +476,13 @@ export declare const SEAT_VALIDATOR_KEY_COVERAGE: {
436
476
  readonly LocalSessionEvent: {
437
477
  readonly guard: "isLocalSessionEvent";
438
478
  readonly check: (v: unknown) => SeatValidation;
439
- readonly validated: readonly ["type", "sessionId", "messages", "error", "errorCategory", "code", "request", "data", "sources", "permissionMode", "session", "userMessageUuid", "hasPreClearSession", "requestId", "outcome", "parked", "chrome"];
479
+ readonly validated: readonly ["type", "sessionId", "error", "errorCategory", "code", "request", "sources", "session", "userMessageUuid", "requestId", "outcome", "parked", "chrome"];
440
480
  readonly unchecked: readonly [{
441
481
  readonly key: "message";
442
482
  readonly why: "transcript 面直通位(CC fQe 逐字姿态:SDKMessage 体不做 schema 校验)—— 校它 = 引擎加一种消息体的那天整条转录被门吃掉。";
483
+ }, {
484
+ readonly key: "_sema_turnFailure";
485
+ readonly why: "turn 失败的呈现判决(CC-378 TK-9),核形在包读口 readSeatTurnFailure(坏形 / 表外类别词 ⇒ undefined、渲染端只渲 error 文本);出站门为它拒掉整条 error 事件 = 宿主 settle 照走、渲染端把失败轮渲成完成,所以门只登键不拒。";
443
486
  }];
444
487
  };
445
488
  readonly AttachmentUploadReceipt: {
@@ -450,7 +493,7 @@ export declare const SEAT_VALIDATOR_KEY_COVERAGE: {
450
493
  };
451
494
  readonly LiveModelCatalog: {
452
495
  readonly check: (v: unknown) => SeatValidation;
453
- readonly validated: readonly ["models", "default", "defaultModel"];
496
+ readonly validated: readonly ["models", "defaultModel"];
454
497
  readonly unchecked: readonly [{
455
498
  readonly key: "droppedEntries";
456
499
  readonly why: "诊断面(哪些目录条目没被引擎收下),三态读法归 droppedModelEntriesOf(含坏形 malformed);出站门为它拒掉整份目录 = 选单为一行诊断整个消失。";
@@ -473,7 +516,7 @@ export declare const SEAT_VALIDATOR_KEY_COVERAGE: {
473
516
  };
474
517
  readonly ApplyModelConfigResult: {
475
518
  readonly check: (v: unknown) => SeatValidation;
476
- readonly validated: readonly ["ok", "requiresRestart", "reason"];
519
+ readonly validated: readonly ["ok", "requiresRestart", "reason", "detail"];
477
520
  readonly unchecked: readonly [];
478
521
  };
479
522
  readonly SendMessageAck: {