@sema-agent/client-core 0.94.0 → 0.95.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 (255) hide show
  1. package/CHANGELOG.md +341 -0
  2. package/README.md +70 -47
  3. package/dist/adapt/arms.js +5 -6
  4. package/dist/adapt/panelTasks.js +4 -10
  5. package/dist/adapt/toolCards.js +2 -2
  6. package/dist/adapt/wireShapes.js +3 -8
  7. package/dist/adapter/activeRunSelfHeal.d.ts +8 -3
  8. package/dist/adapter/activeRunSelfHeal.js +20 -12
  9. package/dist/adapter/downstream/eventToSdkMessage.js +24 -17
  10. package/dist/adapter/downstream/terminalToSdkResult.js +11 -3
  11. package/dist/adapter/runStream.js +2 -1
  12. package/dist/adapter/types.d.ts +7 -0
  13. package/dist/adapter/types.js +15 -0
  14. package/dist/agentSession/backgroundView.js +5 -1
  15. package/dist/agentSession/engineAgentRegistryRead.js +2 -1
  16. package/dist/agentSession/engineSessionBackgroundStop.js +3 -2
  17. package/dist/agentsWireCaps.d.ts +2 -0
  18. package/dist/approvalDecidedByCapability.d.ts +0 -1
  19. package/dist/approvalDecidedByCapability.js +2 -7
  20. package/dist/approvalsStreamLiveCapability.d.ts +0 -1
  21. package/dist/approvalsStreamLiveCapability.js +2 -6
  22. package/dist/atMostOnce.d.ts +8 -0
  23. package/dist/atMostOnce.js +36 -0
  24. package/dist/attachmentSeatCapability.d.ts +0 -1
  25. package/dist/attachmentSeatCapability.js +0 -3
  26. package/dist/attachmentsWireCaps.js +11 -6
  27. package/dist/bashExitReading.d.ts +10 -0
  28. package/dist/bashExitReading.js +12 -0
  29. package/dist/callerCwdCapability.d.ts +0 -1
  30. package/dist/callerCwdCapability.js +2 -7
  31. package/dist/centerWiringCapability.d.ts +1 -3
  32. package/dist/centerWiringCapability.js +18 -21
  33. package/dist/classifierStatus.js +4 -4
  34. package/dist/cloudConfigWireCaps.js +43 -21
  35. package/dist/compensations.js +1 -1
  36. package/dist/cycleOrder.d.ts +15 -0
  37. package/dist/cycleOrder.js +45 -0
  38. package/dist/decideFailureNote.js +4 -1
  39. package/dist/decideReceipt.d.ts +2 -1
  40. package/dist/decideReceipt.js +41 -13
  41. package/dist/declared/supportFloorDeclared.d.ts +1 -0
  42. package/dist/declared/supportFloorDeclared.js +5 -0
  43. package/dist/deviceExecutorManagementCapability.d.ts +0 -1
  44. package/dist/deviceExecutorManagementCapability.js +7 -16
  45. package/dist/deviceRebind.d.ts +88 -0
  46. package/dist/deviceRebind.js +242 -0
  47. package/dist/displayUntrusted.d.ts +1 -0
  48. package/dist/displayUntrusted.js +313 -11
  49. package/dist/engineAgentAbsence.d.ts +2 -2
  50. package/dist/engineAgentPanelStore.d.ts +8 -18
  51. package/dist/engineAgentPanelStore.js +19 -537
  52. package/dist/engineCapReader.d.ts +6 -6
  53. package/dist/engineCapReader.js +30 -43
  54. package/dist/engineCapsCache.d.ts +7 -2
  55. package/dist/engineCapsCache.js +64 -26
  56. package/dist/engineCredentialRequirement.d.ts +9 -0
  57. package/dist/engineCredentialRequirement.js +23 -0
  58. package/dist/engineEnvSourcing.d.ts +53 -0
  59. package/dist/engineEnvSourcing.js +81 -0
  60. package/dist/engineErrorCodes.d.ts +14 -3
  61. package/dist/engineErrorCodes.js +31 -10
  62. package/dist/engineIdentity.js +2 -0
  63. package/dist/engineWireSdk.js +2 -2
  64. package/dist/executionLaneCapability.d.ts +2 -3
  65. package/dist/executionLaneCapability.js +18 -23
  66. package/dist/fileHistoryCaptureCapability.d.ts +0 -1
  67. package/dist/fileHistoryCaptureCapability.js +2 -6
  68. package/dist/fileHistoryLegNotice.d.ts +3 -2
  69. package/dist/fileHistoryLegNotice.js +51 -2
  70. package/dist/fleet/fleetLedger.d.ts +2 -0
  71. package/dist/fleet/fleetLedger.js +69 -52
  72. package/dist/fleet/fleetProjection.d.ts +0 -3
  73. package/dist/fleet/fleetProjection.js +9 -16
  74. package/dist/fleetAgentPanelProjection.d.ts +4 -17
  75. package/dist/fleetAgentPanelProjection.js +7 -197
  76. package/dist/fleetAgentRowLike.d.ts +16 -0
  77. package/dist/fleetAgentRowLike.js +1 -0
  78. package/dist/gateOutcome.js +30 -18
  79. package/dist/generated/sdkFactTables.d.ts +2 -0
  80. package/dist/generated/sdkFactTables.js +17 -0
  81. package/dist/generated/settingsSchemaFns.d.ts +10 -0
  82. package/dist/generated/settingsSchemaFns.js +22 -0
  83. package/dist/headlessPermissionModeWire.d.ts +1 -1
  84. package/dist/headlessPermissionModeWire.js +1 -1
  85. package/dist/headlessReconnectWire.js +49 -20
  86. package/dist/hitl/allowRuleShadow.d.ts +1 -1
  87. package/dist/hitl/allowRuleShadow.js +49 -8
  88. package/dist/hitl/approvalCompleteParked.d.ts +1 -0
  89. package/dist/hitl/approvalCompleteParked.js +14 -0
  90. package/dist/hitl/approvalEndingCause.d.ts +5 -0
  91. package/dist/hitl/approvalEndingCause.js +61 -0
  92. package/dist/hitl/approvalHolds.d.ts +12 -2
  93. package/dist/hitl/approvalHolds.js +53 -2
  94. package/dist/hitl/approvalsFeed.js +23 -11
  95. package/dist/hitl/askGateWire.d.ts +2 -1
  96. package/dist/hitl/askGateWire.js +26 -1
  97. package/dist/hitl/automaticAnswerVerdict.js +2 -2
  98. package/dist/hitl/crashConverged.js +2 -0
  99. package/dist/hitl/decisionConflict.d.ts +3 -0
  100. package/dist/hitl/decisionConflict.js +43 -0
  101. package/dist/hitl/decisionRefusal.d.ts +4 -0
  102. package/dist/hitl/decisionRefusal.js +26 -1
  103. package/dist/hitl/frameRouter.js +26 -43
  104. package/dist/hitl/gateLedger.d.ts +5 -0
  105. package/dist/hitl/gateLedger.js +21 -0
  106. package/dist/hitl/hitlBridge.d.ts +12 -1
  107. package/dist/hitl/hitlBridge.js +68 -53
  108. package/dist/hitl/hitlHostSurface.js +3 -11
  109. package/dist/hitl/livePendingAsk.d.ts +16 -6
  110. package/dist/hitl/livePendingAsk.js +36 -4
  111. package/dist/hitl/parkExpiryJudgements.d.ts +19 -0
  112. package/dist/hitl/parkExpiryJudgements.js +46 -0
  113. package/dist/hitl/parkResolver.d.ts +3 -7
  114. package/dist/hitl/parkResolver.js +50 -26
  115. package/dist/hitl/persistedRulesWire.js +5 -1
  116. package/dist/hitl/planReviewWire.d.ts +2 -2
  117. package/dist/hitl/planReviewWire.js +56 -30
  118. package/dist/hitl/replayedApproval.d.ts +8 -0
  119. package/dist/hitl/replayedApproval.js +125 -10
  120. package/dist/hitl/resumeRunningCard.d.ts +2 -0
  121. package/dist/hitl/resumeRunningCard.js +15 -4
  122. package/dist/hitl/toolApprovalWire.d.ts +24 -4
  123. package/dist/hitl/toolApprovalWire.js +115 -38
  124. package/dist/hooksWireCaps.js +38 -6
  125. package/dist/host.d.ts +5 -0
  126. package/dist/host.js +3 -1
  127. package/dist/hostCallbackGuard.d.ts +1 -0
  128. package/dist/hostCallbackGuard.js +25 -0
  129. package/dist/index.d.ts +30 -11
  130. package/dist/index.js +20 -8
  131. package/dist/interactiveInterrupt.d.ts +8 -0
  132. package/dist/interactiveInterrupt.js +54 -0
  133. package/dist/limitsWire.d.ts +5 -0
  134. package/dist/limitsWire.js +49 -3
  135. package/dist/liveModelCatalog.d.ts +95 -0
  136. package/dist/liveModelCatalog.js +297 -32
  137. package/dist/mcpEngineLeg.d.ts +25 -0
  138. package/dist/mcpEngineLeg.js +71 -15
  139. package/dist/mcpPanel.js +2 -1
  140. package/dist/mcpProbeCapability.d.ts +0 -1
  141. package/dist/mcpProbeCapability.js +2 -6
  142. package/dist/mcpReconnect.d.ts +1 -3
  143. package/dist/mcpReconnect.js +10 -5
  144. package/dist/memoryComplianceCapability.d.ts +0 -1
  145. package/dist/memoryComplianceCapability.js +2 -6
  146. package/dist/memoryOriginCapability.d.ts +0 -1
  147. package/dist/memoryOriginCapability.js +2 -6
  148. package/dist/memoryVerbsWire.d.ts +1 -1
  149. package/dist/memoryVerbsWire.js +4 -0
  150. package/dist/model/liveCatalogShape.d.ts +14 -0
  151. package/dist/model/liveCatalogShape.js +71 -0
  152. package/dist/model/modelSupplyRules.d.ts +1 -0
  153. package/dist/model/modelSupplyRules.js +30 -9
  154. package/dist/model/modelsPolicy.d.ts +21 -0
  155. package/dist/model/modelsPolicy.js +90 -0
  156. package/dist/modelIdentityResolvability.d.ts +1 -1
  157. package/dist/modelIdentityResolvability.js +5 -12
  158. package/dist/modelSwitchFallback.d.ts +69 -0
  159. package/dist/modelSwitchFallback.js +206 -0
  160. package/dist/notifications.js +12 -11
  161. package/dist/outputStyleSeatCapability.d.ts +0 -1
  162. package/dist/outputStyleSeatCapability.js +2 -7
  163. package/dist/ownKey.d.ts +6 -0
  164. package/dist/ownKey.js +48 -0
  165. package/dist/panelReduce.d.ts +114 -0
  166. package/dist/panelReduce.js +1135 -0
  167. package/dist/panelStateHolder.d.ts +17 -0
  168. package/dist/panelStateHolder.js +201 -0
  169. package/dist/peerLaneCapability.d.ts +0 -1
  170. package/dist/peerLaneCapability.js +2 -6
  171. package/dist/permissionModesCapability.d.ts +0 -1
  172. package/dist/permissionModesCapability.js +5 -10
  173. package/dist/permissionRulesWriteCapability.d.ts +0 -1
  174. package/dist/permissionRulesWriteCapability.js +2 -6
  175. package/dist/permissionsAllowGrantCapability.d.ts +0 -1
  176. package/dist/permissionsAllowGrantCapability.js +3 -9
  177. package/dist/permissionsDeclaration.d.ts +6 -0
  178. package/dist/permissionsDeclaration.js +45 -0
  179. package/dist/printToolResultFrame.js +2 -10
  180. package/dist/promptDelivery.js +0 -8
  181. package/dist/resumeRefusalCopy.d.ts +18 -1
  182. package/dist/resumeRefusalCopy.js +126 -15
  183. package/dist/rewindArchiveCapability.d.ts +2 -1
  184. package/dist/rewindArchiveCapability.js +15 -7
  185. package/dist/rewindEngineAction.d.ts +21 -0
  186. package/dist/rewindEngineAction.js +36 -0
  187. package/dist/rewindWireCaps.d.ts +2 -1
  188. package/dist/rewindWireCaps.js +1 -0
  189. package/dist/runTerminal.d.ts +0 -11
  190. package/dist/runTerminal.js +4 -27
  191. package/dist/sdkRegistryTransit.d.ts +2 -1
  192. package/dist/sdkRegistryTransit.js +1 -0
  193. package/dist/sealedKeyCapability.d.ts +0 -1
  194. package/dist/sealedKeyCapability.js +3 -9
  195. package/dist/seatContract.d.ts +54 -25
  196. package/dist/seatContract.js +394 -171
  197. package/dist/sessionIdSegment.d.ts +1 -0
  198. package/dist/sessionIdSegment.js +11 -0
  199. package/dist/sessionMemoryErase.d.ts +1 -1
  200. package/dist/sessionMemoryErase.js +6 -1
  201. package/dist/sessionMemoryStatus.js +3 -2
  202. package/dist/sessionPolicyCapability.d.ts +0 -1
  203. package/dist/sessionPolicyCapability.js +2 -6
  204. package/dist/sessionReadRedactionCapability.d.ts +0 -1
  205. package/dist/sessionReadRedactionCapability.js +2 -7
  206. package/dist/sessionSyncFileHistoryCapability.d.ts +0 -1
  207. package/dist/sessionSyncFileHistoryCapability.js +2 -6
  208. package/dist/skillToolListsCapability.d.ts +0 -1
  209. package/dist/skillToolListsCapability.js +2 -6
  210. package/dist/skillsWireCaps.d.ts +4 -0
  211. package/dist/skillsWireCaps.js +66 -1
  212. package/dist/sqlEngineCapability.d.ts +0 -1
  213. package/dist/sqlEngineCapability.js +9 -14
  214. package/dist/steerPriorityCapability.d.ts +0 -1
  215. package/dist/steerPriorityCapability.js +3 -9
  216. package/dist/storePostureCapability.d.ts +1 -1
  217. package/dist/storePostureCapability.js +16 -16
  218. package/dist/streamDrainingLegs.d.ts +6 -0
  219. package/dist/streamDrainingLegs.js +23 -0
  220. package/dist/subagent/engineCompactWire.js +13 -38
  221. package/dist/subagent/engineDelegatedPrompt.js +10 -6
  222. package/dist/subagent/engineSubagentOutput.d.ts +0 -1
  223. package/dist/subagent/engineSubagentOutput.js +5 -20
  224. package/dist/subagent/engineSubagentTail.d.ts +0 -1
  225. package/dist/subagent/engineSubagentTail.js +7 -32
  226. package/dist/subagentContentStore.js +3 -3
  227. package/dist/supportFloor.js +2 -5
  228. package/dist/terminalStatuses.d.ts +30 -0
  229. package/dist/terminalStatuses.js +67 -0
  230. package/dist/toolResult.d.ts +5 -0
  231. package/dist/toolResult.js +88 -36
  232. package/dist/types/engineState.d.ts +2 -1
  233. package/dist/usageAnalytics.d.ts +146 -0
  234. package/dist/usageAnalytics.js +311 -0
  235. package/dist/userInvokedSkillsCapability.d.ts +0 -1
  236. package/dist/userInvokedSkillsCapability.js +2 -6
  237. package/dist/webSearchBackendCapability.d.ts +0 -1
  238. package/dist/webSearchBackendCapability.js +3 -7
  239. package/dist/webSearchWireCaps.js +3 -11
  240. package/dist/wireFailureShape.d.ts +4 -0
  241. package/dist/wireFailureShape.js +42 -2
  242. package/dist/wireRefusalCopy.js +2 -18
  243. package/dist/workflowClient.js +7 -11
  244. package/dist/workflowsJournalCapability.d.ts +0 -1
  245. package/dist/workflowsJournalCapability.js +2 -6
  246. package/dist/writeProtectionCapability.d.ts +0 -1
  247. package/dist/writeProtectionCapability.js +5 -10
  248. package/docs/INTEGRATION-CLIENTS.md +1033 -26
  249. package/package.json +5 -5
  250. package/dist/engineCapsGenerationGuard.d.ts +0 -4
  251. package/dist/engineCapsGenerationGuard.js +0 -19
  252. package/dist/panelRunningHistory.d.ts +0 -22
  253. package/dist/panelRunningHistory.js +0 -82
  254. package/dist/registryConflict.d.ts +0 -3
  255. package/dist/registryConflict.js +0 -44
@@ -1,7 +1,9 @@
1
1
  import { hostEnv } from './hostEnv.js';
2
2
  import { unrefTimer } from './unrefTimer.js';
3
3
  import { clearEnginePanelTaskResidentByWire, publishEngineAgentPanelEvent, } from './engineAgentPanelStore.js';
4
- import { isTaskNotificationTerminalStatus, isTerminalNotSuccess, isTerminalStatus } from './runTerminal.js';
4
+ import { panelEndFact } from './panelReduce.js';
5
+ import { isCoreTaskNotificationTerminal, isCoreTaskNotificationTerminalNotSuccess } from './terminalStatuses.js';
6
+ import { cycleSeqValue } from './cycleOrder.js';
5
7
  function escapeXml(v) {
6
8
  return v.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
7
9
  }
@@ -130,7 +132,7 @@ export function parseTranscriptNotificationSeeds(messages) {
130
132
  continue;
131
133
  const external = /\btype="external"/.test(attrs);
132
134
  renderedKeys.push(`${external ? 'external:' : ''}${taskId}:${status}`);
133
- if (!external && (isTerminalStatus(status) || isTaskNotificationTerminalStatus(status))) {
135
+ if (!external && isCoreTaskNotificationTerminal(status)) {
134
136
  notifiedKeys.push(taskId);
135
137
  }
136
138
  seeded++;
@@ -316,6 +318,10 @@ const BG_FIRST_SEQ = 1;
316
318
  function normalizeBgSeq(seq) {
317
319
  return typeof seq === 'number' && Number.isFinite(seq) && seq >= BG_FIRST_SEQ ? Math.floor(seq) : BG_FIRST_SEQ;
318
320
  }
321
+ function notificationCycleOf(n) {
322
+ const cycleSeq = cycleSeqValue(n.seq);
323
+ return cycleSeq !== undefined ? { cycleSeq } : undefined;
324
+ }
319
325
  function bgOutstandingKey(taskId, seq) {
320
326
  return `${taskId}:${seq}`;
321
327
  }
@@ -570,20 +576,15 @@ export function enqueueBgChildNotification(n) {
570
576
  return;
571
577
  }
572
578
  bgNotifiedKeys.add(key);
573
- const terminal = isTaskNotificationTerminalStatus(n.status);
579
+ const terminal = isCoreTaskNotificationTerminal(n.status);
574
580
  if (terminal) {
575
581
  markRunNotified(n.taskId, cycle);
576
582
  cardEnqueuedRunIds.add(n.taskId);
577
583
  }
578
584
  if (terminal) {
579
585
  try {
580
- clearEnginePanelTaskResidentByWire(n.taskId, typeof n.seq === 'number' && Number.isInteger(n.seq) && n.seq >= BG_FIRST_SEQ ? { cycleSeq: n.seq } : undefined);
581
- publishEngineAgentPanelEvent({
582
- kind: 'end',
583
- taskId: n.taskId,
584
- isError: isTerminalNotSuccess(n.status),
585
- ...(typeof n.seq === 'number' && Number.isInteger(n.seq) && n.seq >= BG_FIRST_SEQ ? { cycleSeq: n.seq } : {}),
586
- });
586
+ clearEnginePanelTaskResidentByWire(n.taskId, notificationCycleOf(n));
587
+ publishEngineAgentPanelEvent(panelEndFact(n.taskId, isCoreTaskNotificationTerminalNotSuccess(n.status), notificationCycleOf(n)));
587
588
  }
588
589
  catch {
589
590
  }
@@ -667,7 +668,7 @@ export function taskNotificationDeliverySupplement(objective) {
667
668
  return `${SUPPLEMENT_LINE_PREFIX}completed — only this notification delivery failed. Check /tasks for the result.`;
668
669
  }
669
670
  const statusNote = status && status.length > 0 ? ` (status: ${status})` : '';
670
- if (isTaskNotificationTerminalStatus(status)) {
671
+ if (isCoreTaskNotificationTerminal(status)) {
671
672
  return `${SUPPLEMENT_LINE_PREFIX}already finished${statusNote} — only this notification delivery failed. Check /tasks for the result.`;
672
673
  }
673
674
  return `${SUPPLEMENT_LINE_PREFIX}is in a state this client cannot confirm${statusNote} — this notification delivery failed and the task's outcome is unknown here. Check /tasks for its current state.`;
@@ -12,5 +12,4 @@ export declare function noteEngineCapsForOutputStyleSeat(baseUrl: string, caps:
12
12
  }): void;
13
13
  export declare function observedOutputStyleSeat(baseUrl?: string | undefined): OutputStyleSeatReading;
14
14
  export declare function outputStyleSeatAdmitted(reading: OutputStyleSeatReading | undefined): boolean;
15
- export declare function forgetOutputStyleSeatReading(baseUrl: string | undefined): void;
16
15
  export declare function __resetOutputStyleSeatReadingsForTests(): void;
@@ -1,13 +1,11 @@
1
1
  import { engineWireTarget } from './engineWireTarget.js';
2
2
  import { createEngineCapReader } from './engineCapReader.js';
3
- import { readOwnDataValue } from './ownKey.js';
3
+ import { ownDataField, readOwnDataValue } from './ownKey.js';
4
4
  export function projectOutputStyleSeatCapability(caps) {
5
5
  try {
6
6
  if (caps === null || typeof caps !== 'object' || Array.isArray(caps))
7
7
  return undefined;
8
- if (!Object.hasOwn(caps, 'outputStyle'))
9
- return { kind: 'not_reported' };
10
- const v = caps.outputStyle;
8
+ const v = ownDataField(caps, 'outputStyle');
11
9
  if (v === undefined)
12
10
  return { kind: 'not_reported' };
13
11
  return v === true ? { kind: 'present', value: true } : undefined;
@@ -39,9 +37,6 @@ export function outputStyleSeatAdmitted(reading) {
39
37
  return false;
40
38
  }
41
39
  }
42
- export function forgetOutputStyleSeatReading(baseUrl) {
43
- reader.forget(baseUrl);
44
- }
45
40
  export function __resetOutputStyleSeatReadingsForTests() {
46
41
  reader.__resetForTests();
47
42
  }
package/dist/ownKey.d.ts CHANGED
@@ -1,5 +1,11 @@
1
1
  export declare function putOwnKey<T>(table: Record<string, T>, key: string, value: T): void;
2
2
  export declare function readOwnNonEmptyString(v: object | null | undefined, key: string): string | undefined;
3
+ export declare function readAskOrigin(carrier: object | null | undefined): string | undefined;
3
4
  export declare function readOwnDataNonEmptyString(v: object | null | undefined, key: string): string | undefined;
4
5
  export declare function readOwnDataValue<T>(v: object | null | undefined, key: string): T | undefined;
6
+ export declare function ownDataField(v: object, key: string): unknown;
7
+ export declare function ownSendableField(v: object, key: string): unknown;
8
+ export declare function ownDataRefusalKeyOf(e: unknown): string | undefined;
5
9
  export declare function readFrameStringKey(frame: unknown, key: string): string | undefined;
10
+ export declare function markMcpSectionDroppedNamedRows(rows: object, dropped: ReadonlyMap<string, number>): void;
11
+ export declare function mcpSectionDroppedNamedRowsOf(rows: object | null | undefined, name: string): number;
package/dist/ownKey.js CHANGED
@@ -7,6 +7,9 @@ export function readOwnNonEmptyString(v, key) {
7
7
  const raw = v[key];
8
8
  return typeof raw === 'string' && raw !== '' ? raw : undefined;
9
9
  }
10
+ export function readAskOrigin(carrier) {
11
+ return readOwnNonEmptyString(carrier, 'origin');
12
+ }
10
13
  export function readOwnDataNonEmptyString(v, key) {
11
14
  if (typeof v !== 'object' || v === null)
12
15
  return undefined;
@@ -22,6 +25,27 @@ export function readOwnDataValue(v, key) {
22
25
  const d = Object.getOwnPropertyDescriptor(v, key);
23
26
  return d !== undefined && Object.hasOwn(d, 'value') ? d.value : undefined;
24
27
  }
28
+ export function ownDataField(v, key) {
29
+ return ownField(v, key, false);
30
+ }
31
+ export function ownSendableField(v, key) {
32
+ return ownField(v, key, true);
33
+ }
34
+ export function ownDataRefusalKeyOf(e) {
35
+ return typeof e === 'object' && e !== null ? REFUSAL_KEYS.get(e) : undefined;
36
+ }
37
+ const REFUSAL_KEYS = new WeakMap();
38
+ function ownField(v, key, sendable) {
39
+ const d = Object.getOwnPropertyDescriptor(v, key);
40
+ if (d === undefined)
41
+ return undefined;
42
+ if (!Object.hasOwn(d, 'value') || (sendable && d.enumerable !== true)) {
43
+ const e = new TypeError(`own property "${key}" is not a plain${sendable ? ' enumerable' : ''} data property (accessors are not executed)`);
44
+ REFUSAL_KEYS.set(e, key);
45
+ throw e;
46
+ }
47
+ return d.value;
48
+ }
25
49
  export function readFrameStringKey(frame, key) {
26
50
  try {
27
51
  if (frame === null || typeof frame !== 'object' || Array.isArray(frame))
@@ -32,3 +56,27 @@ export function readFrameStringKey(frame, key) {
32
56
  return undefined;
33
57
  }
34
58
  }
59
+ const DROPPED_NAMED_ROWS = Symbol.for('@sema-agent/client-core/mcpSectionDroppedNamedRows');
60
+ export function markMcpSectionDroppedNamedRows(rows, dropped) {
61
+ if (dropped.size === 0)
62
+ return;
63
+ try {
64
+ Object.defineProperty(rows, DROPPED_NAMED_ROWS, { value: Object.freeze(new Map(dropped)), enumerable: false, writable: false, configurable: false });
65
+ }
66
+ catch {
67
+ }
68
+ }
69
+ export function mcpSectionDroppedNamedRowsOf(rows, name) {
70
+ try {
71
+ if (rows === null || typeof rows !== 'object')
72
+ return 0;
73
+ const d = Object.getOwnPropertyDescriptor(rows, DROPPED_NAMED_ROWS);
74
+ if (d === undefined || !Object.hasOwn(d, 'value') || !(d.value instanceof Map))
75
+ return 0;
76
+ const n = d.value.get(name);
77
+ return typeof n === 'number' && Number.isInteger(n) && n > 0 ? n : 0;
78
+ }
79
+ catch {
80
+ return 0;
81
+ }
82
+ }
@@ -0,0 +1,114 @@
1
+ import type { EngineAgentPanelAbsence, EngineAgentPanelEvent } from './engineAgentPanelStore.js';
2
+ import type { FleetAgentRowLike } from './fleetAgentRowLike.js';
3
+ import { type EngineAgentPanelCycleIdentity } from './cycleOrder.js';
4
+ export declare function isStaleEngineAgentPanelEnd(end: EngineAgentPanelCycleIdentity | null | undefined, current: EngineAgentPanelCycleIdentity | null | undefined): boolean;
5
+ export declare function isNewEngineAgentPanelCycle(prev: EngineAgentPanelCycleIdentity | null | undefined, next: EngineAgentPanelCycleIdentity | null | undefined): boolean;
6
+ type EndArm = Extract<EngineAgentPanelEvent, {
7
+ kind: 'end';
8
+ }>;
9
+ export declare const ABSENT_SETTLE_MS = 30000;
10
+ export declare const MAX_HELD_WIRE_TICK_BEATS = 16;
11
+ export type PanelFrame = EngineAgentPanelEvent | {
12
+ kind: 'fleet-rows';
13
+ sessionKey: string;
14
+ rows: readonly FleetAgentRowLike[];
15
+ nowMs: number;
16
+ } | {
17
+ kind: 'fleet-rows-reset';
18
+ sessionKey?: string;
19
+ } | {
20
+ kind: 'absence';
21
+ absence: EngineAgentPanelAbsence;
22
+ } | {
23
+ kind: 'resident';
24
+ taskId: string;
25
+ resident: boolean;
26
+ } | {
27
+ kind: 'resident-clear-wire';
28
+ taskId: string;
29
+ cycle?: EngineAgentPanelCycleIdentity;
30
+ } | {
31
+ kind: 'anchor';
32
+ taskId: string;
33
+ transcriptId: string;
34
+ };
35
+ export interface PanelRowFields {
36
+ name?: string;
37
+ description?: string;
38
+ prompt?: string;
39
+ currentAction?: string;
40
+ spawnName?: string;
41
+ currentTool?: {
42
+ toolName: string;
43
+ target?: string;
44
+ };
45
+ transcriptId?: string;
46
+ parentToolCallId?: string;
47
+ startedAt?: number;
48
+ cycleSeq?: number;
49
+ wireTaskId?: string;
50
+ taskIdOrigin?: 'fleet-row' | 'wire';
51
+ absence?: {
52
+ lastSeenAtMs: number;
53
+ absentForMs: number;
54
+ } | null;
55
+ }
56
+ export type PanelDelta = {
57
+ op: 'upsert';
58
+ canonicalId: string;
59
+ created?: true;
60
+ revived?: true;
61
+ fields: PanelRowFields;
62
+ } | {
63
+ op: 'usage_delta';
64
+ canonicalId: string;
65
+ totalTokens?: number;
66
+ toolUses?: number;
67
+ } | {
68
+ op: 'terminal';
69
+ canonicalId: string;
70
+ isError: boolean;
71
+ report?: string;
72
+ cause: 'end' | 'sweep';
73
+ } | {
74
+ op: 'remove';
75
+ canonicalId: string;
76
+ };
77
+ export declare const PANEL_DELTA_OPS: readonly ["upsert", "usage_delta", "terminal", "remove"];
78
+ export interface PanelReduceState {
79
+ readonly __panelReduceState: true;
80
+ }
81
+ export declare const PANEL_REDUCE_STATE_KEYS: readonly ["__panelReduceState", "records", "alias", "pending", "sessions", "overflowed", "counts"];
82
+ export declare function createPanelReduceState(): PanelReduceState;
83
+ export interface PanelStep {
84
+ readonly state: PanelReduceState;
85
+ readonly deltas: PanelDelta[];
86
+ readonly facts: Array<{
87
+ readonly ch: 'event';
88
+ readonly ev: EngineAgentPanelEvent;
89
+ } | {
90
+ readonly ch: 'absence';
91
+ readonly absence: EngineAgentPanelAbsence;
92
+ }>;
93
+ }
94
+ export declare function panelEndFact(taskId: string, isError: boolean, extra?: Pick<EndArm, 'report' | 'cycleSeq' | 'startedAt'>): EndArm;
95
+ export interface EnginePanelTaskIdentity {
96
+ readonly taskId: string;
97
+ readonly origin: 'fleet-row' | 'wire';
98
+ readonly cycleSeq?: number;
99
+ readonly startedAt?: number;
100
+ }
101
+ export declare function stepPanelFrame(state: PanelReduceState, frame: PanelFrame): PanelStep;
102
+ export declare function reducePanelFrame(state: PanelReduceState, frame: PanelFrame): {
103
+ state: PanelReduceState;
104
+ deltas: PanelDelta[];
105
+ };
106
+ export declare function panelRowSnapshot(state: PanelReduceState): PanelDelta[];
107
+ export declare function panelResolveTaskId(state: PanelReduceState, wireTaskId: string, parentToolCallId?: string): EnginePanelTaskIdentity;
108
+ export declare function panelIsResident(state: PanelReduceState, taskId: string): boolean;
109
+ export declare function panelAnchorOf(state: PanelReduceState, taskId: string): string | undefined;
110
+ export declare function panelPresenceSize(state: PanelReduceState, sessionKey: string): number;
111
+ export declare function panelClearIdentity(state: PanelReduceState): PanelReduceState;
112
+ export declare function panelClearAnchors(state: PanelReduceState): PanelReduceState;
113
+ export declare function panelClearRows(state: PanelReduceState): PanelReduceState;
114
+ export {};