@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
@@ -2,7 +2,7 @@ import type { AgentEvent, CheckpointGate, TaskResult } from '@sema-agent/sdk';
2
2
  import { type WiringManifestView } from './wiringManifestView.js';
3
3
  import { type SDKMessage, type EmitContext, type ModelUsage } from '../types.js';
4
4
  import { type McpLivenessView } from '../../mcpLiveness.js';
5
- import { type ContextUsageSectionRow } from '../../ownKey.js';
5
+ import { type ContextUsageSectionRow, type PromptIdentityLayersRow, type PromptManifestIdentityRow, type PromptManifestSectionRow } from '../../ownKey.js';
6
6
  export declare const INTERNAL_SDK_ARM_TYPES: ReadonlySet<string>;
7
7
  export type EventProjectionNoneReason = 'usage_only' | 'terminal_delegated' | 'hitl_out_of_slice' | 'not_in_slice' | 'empty_payload';
8
8
  export type EventProjectionDropReason = 'malformed' | 'unknown_arm' | 'unsupported_arm';
@@ -67,12 +67,31 @@ export interface WiringManifestLspSeamView {
67
67
  mounted: boolean;
68
68
  lane?: string;
69
69
  }
70
- export type ContextUsageSectionView = ContextUsageSectionRow;
71
- export interface PromptManifestSectionView {
72
- id: string;
73
- chars: number;
74
- slot?: string;
70
+ export interface WiringManifestModSkipView {
71
+ readonly registration: string;
72
+ readonly cause: string;
73
+ readonly reason: string;
75
74
  }
75
+ export interface WiringManifestModMountedView {
76
+ readonly name: string;
77
+ readonly seat: string;
78
+ readonly tier: string;
79
+ readonly events: readonly string[];
80
+ readonly observe?: readonly string[];
81
+ readonly skipped?: readonly WiringManifestModSkipView[];
82
+ }
83
+ export interface WiringManifestModRefusedView {
84
+ readonly name: string;
85
+ readonly seat: string;
86
+ readonly tier: string;
87
+ readonly refusedBy: string;
88
+ readonly reason: string;
89
+ }
90
+ export type WiringManifestModView = WiringManifestModMountedView | WiringManifestModRefusedView;
91
+ export type ContextUsageSectionView = ContextUsageSectionRow;
92
+ export type PromptManifestSectionView = PromptManifestSectionRow;
93
+ export type PromptManifestIdentityView = PromptManifestIdentityRow;
94
+ export type PromptIdentityLayersView = PromptIdentityLayersRow;
76
95
  export interface PromptManifestBlockView {
77
96
  id: string;
78
97
  chars: number;
@@ -5,8 +5,8 @@ import { ccToolDenialKindForToolEnd, gateOutcomeOf } from '../../gateOutcome.js'
5
5
  import { projectToolRoster, projectToolRosterDelta } from '../../toolRoster.js';
6
6
  import { projectHandsSection } from '../../handsSeam.js';
7
7
  import { readMcpLiveness } from '../../mcpLiveness.js';
8
- import { contextUsageReadingOf, markMcpSectionDroppedNamedRows, readFrameTrueMark } from '../../ownKey.js';
9
- import { SEGMENT_END_IDENTITY_KEYS, stripToolUseSideChannels } from '../types.js';
8
+ import { contextUsageReadingOf, humanInputAttachmentsOf, markMcpSectionDroppedNamedRows, promptManifestIdentityOfFrame, promptManifestSectionViewOf, readFrameTrueMark } from '../../ownKey.js';
9
+ import { SEGMENT_END_IDENTITY_KEYS, eventSeq, stripToolUseSideChannels } from '../types.js';
10
10
  import { frozenSet } from '../../frozenSet.js';
11
11
  import { isCoreWorkflowRunTerminal } from '../../terminalStatuses.js';
12
12
  import { envelopeUuidOf, mintEngineRowRef, readBoundRun, wireEventIdOf } from '../../engineRowRef.js';
@@ -21,12 +21,14 @@ export const INTERNAL_SDK_ARM_TYPES = frozenSet([
21
21
  'tool_roster_delta',
22
22
  'context_usage',
23
23
  'compaction_outcome',
24
+ 'compaction_started',
24
25
  'prompt_assembled',
25
26
  'workflow_complete',
26
27
  'tool_end_result',
27
28
  'terminal_fact',
28
29
  'retry_status',
29
30
  'task_progress',
31
+ 'task_started',
30
32
  'task_notification',
31
33
  'diagnostics',
32
34
  'steering_injected',
@@ -68,6 +70,9 @@ function streamEventArm(ctx, event) {
68
70
  const projected = (message) => ({ kind: 'message', message });
69
71
  const nothing = (why) => ({ kind: 'none', why });
70
72
  const dropped = (why, type) => ({ kind: 'dropped', why, type });
73
+ function isCompactionStartedFrame(ev) {
74
+ return ev.type === 'compaction_started';
75
+ }
71
76
  function assertNeverArm(_ev) {
72
77
  }
73
78
  export function eventToSdkMessage(ev, ctx) {
@@ -84,9 +89,11 @@ function withEngineIdentity(p, ev, ctx) {
84
89
  return projected(Object.assign({}, env, { uuid: envelopeUuidOf(eventId, env.type), _sema_engine_ref: ref }));
85
90
  }
86
91
  function projectEvent(ev, ctx) {
92
+ if (isCompactionStartedFrame(ev))
93
+ return compactionStartedProjection(ev, ctx);
87
94
  switch (ev.type) {
88
95
  case 'task_started':
89
- return dropped('unsupported_arm', 'task_started');
96
+ return taskStartedProjection(ev, ctx);
90
97
  case 'text_end':
91
98
  return textEndProjection(ev, ctx);
92
99
  case 'reasoning_end':
@@ -163,6 +170,10 @@ function projectEvent(ev, ctx) {
163
170
  }
164
171
  case 'compacted': {
165
172
  const raw = ev;
173
+ const pass = typeof raw.pass === 'string' && raw.pass.length > 0 ? raw.pass : undefined;
174
+ const tokenOf = (v) => (typeof v === 'number' && Number.isFinite(v) && v >= 0 ? v : undefined);
175
+ const tokensBefore = tokenOf(raw.triggerTokensBefore);
176
+ const tokensAfter = tokenOf(raw.tokensAfter);
166
177
  const freedTokens = typeof raw.freedTokens === 'number' && Number.isFinite(raw.freedTokens) && raw.freedTokens >= 0 ? raw.freedTokens : undefined;
167
178
  const attachedFiles = raw.attachedFiles;
168
179
  const seg = raw.preserved_segment;
@@ -183,6 +194,10 @@ function projectEvent(ev, ctx) {
183
194
  ? { _sema_clamped_ratio: clampedRatio }
184
195
  : {}),
185
196
  ...(freedTokens !== undefined ? { _sema_freed_tokens: freedTokens } : {}),
197
+ ...(pass !== undefined ? { _sema_pass: pass } : {}),
198
+ ...(tokensBefore !== undefined || tokensAfter !== undefined
199
+ ? { _sema_compaction_tokens: { ...(tokensBefore !== undefined ? { before: tokensBefore } : {}), ...(tokensAfter !== undefined ? { after: tokensAfter } : {}) } }
200
+ : {}),
186
201
  },
187
202
  ...(Array.isArray(attachedFiles) && attachedFiles.length > 0 ? { _sema_attached_files: attachedFiles } : {}),
188
203
  })));
@@ -264,6 +279,7 @@ function projectEvent(ev, ctx) {
264
279
  const workflowAgentLabel = ev.workflowAgentLabel;
265
280
  const model = ev.model;
266
281
  const status = ev.status;
282
+ const seq = typeof ev.seq === 'number' && Number.isFinite(ev.seq) ? ev.seq : undefined;
267
283
  return projected(stamp(ctx, armBody({
268
284
  type: 'task_progress',
269
285
  taskId: ev.taskId,
@@ -283,6 +299,7 @@ function projectEvent(ev, ctx) {
283
299
  ...(ev.parentToolCallId !== undefined
284
300
  ? { parentToolCallId: ev.parentToolCallId }
285
301
  : {}),
302
+ ...(seq !== undefined ? { seq } : {}),
286
303
  })));
287
304
  }
288
305
  case 'wiring_manifest': {
@@ -581,7 +598,8 @@ function wiringManifestSupersetBody(ev) {
581
598
  const fileHistory = projectFileHistorySection(ev);
582
599
  const instructions = readInstructionsSegment(ev, 'instructions');
583
600
  const fleet = readFleetSegment(ev, 'fleet');
584
- if (modelGate === undefined && autoMode === undefined && mcp === undefined && tools === undefined && hooks === undefined && lsp === undefined && writeProtection === undefined && autoConsolidation === undefined && readDeny === undefined && hands === undefined && fileHistory === undefined && instructions === undefined && fleet === undefined)
601
+ const mods = projectModsSection(ev);
602
+ if (modelGate === undefined && autoMode === undefined && mcp === undefined && tools === undefined && hooks === undefined && lsp === undefined && writeProtection === undefined && autoConsolidation === undefined && readDeny === undefined && hands === undefined && fileHistory === undefined && instructions === undefined && fleet === undefined && mods === undefined)
585
603
  return undefined;
586
604
  return {
587
605
  ...(modelGate !== undefined ? { _sema_modelGate: modelGate } : {}),
@@ -597,6 +615,7 @@ function wiringManifestSupersetBody(ev) {
597
615
  ...(fileHistory !== undefined ? { _sema_fileHistory: fileHistory } : {}),
598
616
  ...(instructions !== undefined ? { _sema_instructions: instructions } : {}),
599
617
  ...(fleet !== undefined ? { _sema_fleet: fleet } : {}),
618
+ ...(mods !== undefined ? { _sema_mods: mods } : {}),
600
619
  };
601
620
  }
602
621
  function projectFileHistorySection(holder) {
@@ -635,6 +654,83 @@ function projectReadDenySection(raw) {
635
654
  return undefined;
636
655
  return { builtinTiers: [...tiers] };
637
656
  }
657
+ const _modViewPins = [true, true, true, true, true, true];
658
+ void _modViewPins;
659
+ function projectModsSection(holder) {
660
+ try {
661
+ if (!Object.hasOwn(holder, 'mods'))
662
+ return undefined;
663
+ const raw = holder.mods;
664
+ if (!Array.isArray(raw))
665
+ return undefined;
666
+ const rows = [];
667
+ for (const r of raw) {
668
+ const row = modRowOf(r);
669
+ if (row !== undefined)
670
+ rows.push(row);
671
+ }
672
+ if (raw.length > 0 && rows.length === 0)
673
+ return undefined;
674
+ return rows;
675
+ }
676
+ catch {
677
+ return undefined;
678
+ }
679
+ }
680
+ function modRowOf(r) {
681
+ try {
682
+ if (typeof r !== 'object' || r === null || Array.isArray(r))
683
+ return undefined;
684
+ const str = (v) => (typeof v === 'string' && v.length > 0 ? v : undefined);
685
+ const strList = (v) => (Array.isArray(v) && v.every((x) => typeof x === 'string') ? [...v] : undefined);
686
+ const o = r;
687
+ const name = str(o.name);
688
+ const seat = str(o.seat);
689
+ const tier = str(o.tier);
690
+ if (name === undefined || seat === undefined || tier === undefined)
691
+ return undefined;
692
+ const eventsRaw = o.events;
693
+ const observeRaw = o.observe;
694
+ const skippedRaw = o.skipped;
695
+ const refusedByRaw = o.refusedBy;
696
+ const reasonRaw = o.reason;
697
+ const hasMountedKey = eventsRaw !== undefined || observeRaw !== undefined || skippedRaw !== undefined;
698
+ const hasRefusedKey = refusedByRaw !== undefined || reasonRaw !== undefined;
699
+ if (hasMountedKey && hasRefusedKey)
700
+ return undefined;
701
+ if (hasRefusedKey) {
702
+ const refusedBy = str(refusedByRaw);
703
+ const reason = str(reasonRaw);
704
+ return refusedBy === undefined || reason === undefined ? undefined : { name, seat, tier, refusedBy, reason };
705
+ }
706
+ const events = strList(eventsRaw);
707
+ if (events === undefined)
708
+ return undefined;
709
+ const observe = observeRaw === undefined ? undefined : strList(observeRaw);
710
+ const skipped = Array.isArray(skippedRaw)
711
+ ? skippedRaw.flatMap((x) => {
712
+ if (typeof x !== 'object' || x === null || Array.isArray(x))
713
+ return [];
714
+ const k = x;
715
+ const registration = str(k.registration);
716
+ const cause = str(k.cause);
717
+ const why = str(k.reason);
718
+ return registration === undefined || cause === undefined || why === undefined ? [] : [{ registration, cause, reason: why }];
719
+ })
720
+ : undefined;
721
+ return {
722
+ name,
723
+ seat,
724
+ tier,
725
+ events,
726
+ ...(observe !== undefined ? { observe } : {}),
727
+ ...(skipped !== undefined && skipped.length > 0 ? { skipped } : {}),
728
+ };
729
+ }
730
+ catch {
731
+ return undefined;
732
+ }
733
+ }
638
734
  function projectHooksSection(raw) {
639
735
  if (!Array.isArray(raw))
640
736
  return undefined;
@@ -671,6 +767,48 @@ function contextUsageProjection(ev, ctx) {
671
767
  ...identity,
672
768
  }))));
673
769
  }
770
+ function taskStartedProjection(frame, ctx) {
771
+ const ev = frame;
772
+ const { identity, bad } = identityOrMalformed(ev, 'task_started');
773
+ if (bad !== null)
774
+ return bad;
775
+ const str = (v) => (typeof v === 'string' && v.length > 0 ? v : undefined);
776
+ const num = (v) => (typeof v === 'number' && Number.isFinite(v) ? v : undefined);
777
+ const taskId = str(ev.taskId);
778
+ if (taskId === undefined)
779
+ return dropped('malformed', 'task_started');
780
+ const sessionId = str(ev.sessionId);
781
+ const model = str(ev.model);
782
+ const taskType = str(ev.taskType);
783
+ const seq = num(ev.seq);
784
+ const workflowRunId = str(ev.workflowRunId);
785
+ const workflowAgentLabel = str(ev.workflowAgentLabel);
786
+ const parentTaskId = str(ev.parentTaskId);
787
+ const parentSessionId = str(ev.parentSessionId);
788
+ const rootSessionId = str(ev.rootSessionId);
789
+ const name = str(ev.name);
790
+ const spawnName = str(ev.spawnName);
791
+ const agentType = str(ev.agentType);
792
+ const startedAt = num(ev.startedAt);
793
+ return projected(internalArmExit(stamp(ctx, armBody({
794
+ type: 'task_started',
795
+ taskId,
796
+ ...(sessionId !== undefined ? { sessionId } : {}),
797
+ ...(model !== undefined ? { model } : {}),
798
+ ...(taskType !== undefined ? { taskType } : {}),
799
+ ...(seq !== undefined ? { seq } : {}),
800
+ ...(workflowRunId !== undefined ? { workflowRunId } : {}),
801
+ ...(workflowAgentLabel !== undefined ? { workflowAgentLabel } : {}),
802
+ ...(parentTaskId !== undefined ? { parentTaskId } : {}),
803
+ ...(parentSessionId !== undefined ? { parentSessionId } : {}),
804
+ ...(rootSessionId !== undefined ? { rootSessionId } : {}),
805
+ ...(name !== undefined ? { name } : {}),
806
+ ...(spawnName !== undefined ? { spawnName } : {}),
807
+ ...(agentType !== undefined ? { agentType } : {}),
808
+ ...(startedAt !== undefined ? { startedAt } : {}),
809
+ ...identity,
810
+ }))));
811
+ }
674
812
  function compactionOutcomeProjection(frame, ctx) {
675
813
  const ev = frame;
676
814
  const { identity, bad } = identityOrMalformed(ev, 'compaction_outcome');
@@ -682,14 +820,37 @@ function compactionOutcomeProjection(frame, ctx) {
682
820
  return dropped('malformed', 'compaction_outcome');
683
821
  const trigger = str(ev.trigger);
684
822
  const reason = str(ev.reason);
823
+ const pass = str(ev.pass);
685
824
  return projected(internalArmExit(stamp(ctx, armBody({
686
825
  type: 'compaction_outcome',
687
826
  outcome,
688
827
  ...(trigger !== undefined ? { trigger } : {}),
689
828
  ...(reason !== undefined ? { reason } : {}),
829
+ ...(pass !== undefined ? { pass } : {}),
830
+ ...identity,
831
+ }))));
832
+ }
833
+ function compactionStartedProjection(frame, ctx) {
834
+ const ev = frame;
835
+ const { identity, bad } = identityOrMalformed(ev, 'compaction_started');
836
+ if (bad !== null)
837
+ return bad;
838
+ const str = (v) => (typeof v === 'string' && v.length > 0 ? v : undefined);
839
+ const pass = str(ev.pass);
840
+ const trigger = str(ev.trigger);
841
+ if (pass === undefined || trigger === undefined)
842
+ return dropped('malformed', 'compaction_started');
843
+ const startedAt = typeof ev.startedAt === 'number' && Number.isFinite(ev.startedAt) ? ev.startedAt : undefined;
844
+ return projected(internalArmExit(stamp(ctx, armBody({
845
+ type: 'compaction_started',
846
+ trigger,
847
+ pass,
848
+ ...(startedAt !== undefined ? { startedAt } : {}),
690
849
  ...identity,
691
850
  }))));
692
851
  }
852
+ const _promptManifestPins = [true, true, true, true, true];
853
+ void _promptManifestPins;
693
854
  function promptAssembledProjection(frame, ctx) {
694
855
  const ev = frame;
695
856
  const { identity, bad } = identityOrMalformed(ev, 'prompt_assembled');
@@ -705,16 +866,13 @@ function promptAssembledProjection(frame, ctx) {
705
866
  for (const r of ev.sections) {
706
867
  if (typeof r !== 'object' || r === null || Array.isArray(r))
707
868
  continue;
708
- const o = r;
709
- const id = str(o.id);
710
- const chars = size(o.chars);
711
- if (id === undefined || chars === undefined)
712
- continue;
713
- const slot = str(o.slot);
714
- rows.push({ id, chars, ...(slot !== undefined ? { slot } : {}) });
869
+ const row = promptManifestSectionViewOf(r);
870
+ if (row !== undefined)
871
+ rows.push(row);
715
872
  }
716
873
  return rows.length > 0 ? rows : undefined;
717
874
  })();
875
+ const promptIdentity = promptManifestIdentityOfFrame(ev);
718
876
  const blocks = (() => {
719
877
  if (!Array.isArray(ev.blocks))
720
878
  return undefined;
@@ -754,6 +912,7 @@ function promptAssembledProjection(frame, ctx) {
754
912
  ...(blocks !== undefined ? { blocks } : {}),
755
913
  ...(sections !== undefined ? { sections } : {}),
756
914
  ...(tools !== undefined ? { tools } : {}),
915
+ ...(promptIdentity !== undefined ? { identity: promptIdentity } : {}),
757
916
  ...identity,
758
917
  }))));
759
918
  }
@@ -767,6 +926,7 @@ function engineNoticeProjection(ev, ctx) {
767
926
  const detail = typeof rawDetail === 'object' && rawDetail !== null && !Array.isArray(rawDetail)
768
927
  ? rawDetail
769
928
  : {};
929
+ const seq = eventSeq(ev);
770
930
  return projected(stamp(ctx, armBody({
771
931
  type: 'engine_notice',
772
932
  code,
@@ -775,7 +935,7 @@ function engineNoticeProjection(ev, ctx) {
775
935
  ...(sessionId !== undefined ? { sessionId } : {}),
776
936
  ...(ts !== undefined ? { ts } : {}),
777
937
  ...(typeof ev.eventId === 'string' && ev.eventId.length > 0 ? { eventId: ev.eventId } : {}),
778
- ...(typeof ev.id === 'string' && ev.id.length > 0 ? { eventSeq: ev.id } : {}),
938
+ ...(seq !== undefined ? { eventSeq: seq } : {}),
779
939
  })));
780
940
  }
781
941
  function approvalFrameBody(ev) {
@@ -813,8 +973,12 @@ function humanInputProjection(ev, ctx) {
813
973
  ...(str(ev.entryId) !== undefined ? { entryId: str(ev.entryId) } : {}),
814
974
  ...(str(ev.eventId) !== undefined ? { eventId: str(ev.eventId) } : {}),
815
975
  ...(str(ev.parentToolCallId) !== undefined ? { parentToolCallId: str(ev.parentToolCallId) } : {}),
976
+ ...attachmentsKey(humanInputAttachmentsOf(ev)),
816
977
  })));
817
978
  }
979
+ function attachmentsKey(rows) {
980
+ return rows !== undefined ? { attachments: rows } : {};
981
+ }
818
982
  export function turnEndUsage(ev) {
819
983
  const rawValue = ev.usage;
820
984
  if (typeof rawValue !== 'object' || rawValue === null || Array.isArray(rawValue))
@@ -523,8 +523,17 @@ function errorResult(ctx, parts) {
523
523
  ...(parts.outcomeUnknown === true ? { _sema_outcome: 'unknown' } : {}),
524
524
  ...(parts.parkFailedReason !== undefined ? { _sema_park_failed_reason: washCredentials(parts.parkFailedReason) } : {}),
525
525
  ...(parts.abortCause !== undefined ? { _sema_abort_cause: parts.abortCause } : {}),
526
+ ...(parts.route !== undefined ? { _sema_route: routeOnFrame(parts.route) } : {}),
526
527
  });
527
528
  }
529
+ function routeOnFrame(route) {
530
+ return {
531
+ credentialSource: route.credentialSource,
532
+ ...(route.carrier !== undefined ? { carrier: route.carrier } : {}),
533
+ ...(route.carrierBag !== undefined ? { carrierBag: route.carrierBag } : {}),
534
+ root: route.root,
535
+ };
536
+ }
528
537
  export function doneToSdkResult(ev, ctx, observed) {
529
538
  const msg = doneToSdkResultBody(ev, ctx, observed);
530
539
  return isReplayedTerminal(ev) ? Object.assign({}, msg, { _sema_replay: true }) : msg;
@@ -563,6 +572,7 @@ function doneToSdkResultBody(ev, ctx, observed) {
563
572
  return errorResult(ctx, {
564
573
  ...errorBase,
565
574
  subtype: failedSubtype,
575
+ ...(terminal.detail?.kind === 'provider_rejected' && terminal.detail.route !== undefined ? { route: terminal.detail.route } : {}),
566
576
  errors: [
567
577
  withTerminalNote(isRewindFamilyCode(failedCode) && failedMessage
568
578
  ? `${failedMessage} (${failedCode})`
@@ -1,4 +1,4 @@
1
- import type { WiringManifestModelGate, WiringManifestAutoMode, WiringManifestMcpEntryView, WiringManifestHookEntryView, WiringManifestLspSeamView, WiringManifestWriteProtectionView, WiringManifestAutoConsolidationView, WiringManifestReadDenyView } from './eventToSdkMessage.js';
1
+ import type { WiringManifestModelGate, WiringManifestAutoMode, WiringManifestMcpEntryView, WiringManifestHookEntryView, WiringManifestLspSeamView, WiringManifestWriteProtectionView, WiringManifestAutoConsolidationView, WiringManifestReadDenyView, WiringManifestModView } from './eventToSdkMessage.js';
2
2
  import type { ToolRosterView, WiringManifestHandsView } from '../../toolRoster.js';
3
3
  export type WiringManifestSections = {
4
4
  _sema_modelGate?: WiringManifestModelGate;
@@ -16,6 +16,7 @@ export type WiringManifestSections = {
16
16
  readonly selected: readonly string[];
17
17
  };
18
18
  _sema_fleet?: WiringManifestFleetView;
19
+ _sema_mods?: WiringManifestModView[];
19
20
  eventId?: string;
20
21
  };
21
22
  export interface WiringManifestFleetView {
@@ -37,6 +38,7 @@ export interface WiringManifestView {
37
38
  readonly selected: readonly string[];
38
39
  };
39
40
  fleet?: WiringManifestFleetView;
41
+ mods?: readonly WiringManifestModView[];
40
42
  eventId?: string;
41
43
  }
42
44
  export declare function readInstructionsSegment(holder: object, key: 'instructions' | '_sema_instructions'): {
@@ -59,6 +59,7 @@ export function wiringManifestViewOf(s) {
59
59
  ...(typeof s._sema_fileHistory === 'string' && s._sema_fileHistory.length > 0 ? { fileHistory: s._sema_fileHistory } : {}),
60
60
  ...(instructions !== undefined ? { instructions } : {}),
61
61
  ...(fleet !== undefined ? { fleet } : {}),
62
+ ...(Array.isArray(s._sema_mods) ? { mods: s._sema_mods } : {}),
62
63
  };
63
64
  if (Object.keys(view).length === 0)
64
65
  return undefined;