@sema-agent/client-core 0.109.0 → 0.111.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 +342 -0
  2. package/README.md +88 -32
  3. package/dist/abortableSleep.d.ts +7 -0
  4. package/dist/abortableSleep.js +37 -0
  5. package/dist/adapt/arms.js +45 -11
  6. package/dist/adapt/toolCards.d.ts +3 -1
  7. package/dist/adapt/toolCards.js +4 -2
  8. package/dist/adapter/activeRunSelfHeal.d.ts +39 -0
  9. package/dist/adapter/activeRunSelfHeal.js +171 -3
  10. package/dist/adapter/downstream/eventToSdkMessage.js +20 -15
  11. package/dist/adapter/downstream/terminalToSdkResult.d.ts +2 -0
  12. package/dist/adapter/downstream/terminalToSdkResult.js +11 -0
  13. package/dist/adapter/runStream.d.ts +5 -0
  14. package/dist/adapter/runStream.js +15 -3
  15. package/dist/attachmentRoute.d.ts +20 -0
  16. package/dist/attachmentRoute.js +39 -0
  17. package/dist/attachmentsWireCaps.js +1 -1
  18. package/dist/builtinOutputStyles.d.ts +12 -0
  19. package/dist/builtinOutputStyles.js +147 -0
  20. package/dist/compactionStatus.d.ts +9 -0
  21. package/dist/compactionStatus.js +29 -5
  22. package/dist/controlRouter.js +2 -1
  23. package/dist/coreValuePorts.d.ts +39 -1
  24. package/dist/coreValuePorts.js +10 -0
  25. package/dist/declared/supportFloorDeclared.js +1 -1
  26. package/dist/displayUntrusted.d.ts +1 -0
  27. package/dist/displayUntrusted.js +138 -14
  28. package/dist/engineErrorCodes.d.ts +3 -0
  29. package/dist/engineErrorCodes.js +3 -0
  30. package/dist/engineHealthFacts.d.ts +20 -0
  31. package/dist/engineHealthFacts.js +42 -1
  32. package/dist/engineHealthProbeVerdict.d.ts +23 -0
  33. package/dist/engineHealthProbeVerdict.js +115 -0
  34. package/dist/engineInlineTaskStats.d.ts +4 -3
  35. package/dist/engineInlineTaskStats.js +18 -2
  36. package/dist/engineNoticeCodes.d.ts +10 -0
  37. package/dist/engineNoticeCodes.js +36 -6
  38. package/dist/engineRepoint.d.ts +147 -0
  39. package/dist/engineRepoint.js +310 -0
  40. package/dist/engineRowRef.d.ts +3 -0
  41. package/dist/engineRowRef.js +13 -1
  42. package/dist/engineSessionMessages.d.ts +2 -1
  43. package/dist/engineSessionMessages.js +5 -0
  44. package/dist/engineSwapCrossing.d.ts +57 -0
  45. package/dist/engineSwapCrossing.js +297 -0
  46. package/dist/engineUnavailable.d.ts +44 -0
  47. package/dist/engineUnavailable.js +492 -0
  48. package/dist/errorSupplementRoles.js +2 -1
  49. package/dist/eventLeg.js +3 -3
  50. package/dist/fleet/fleetProjection.js +3 -2
  51. package/dist/generated/engineFactTables.d.ts +2 -0
  52. package/dist/generated/engineFactTables.js +12 -0
  53. package/dist/generated/sdkFactTables.d.ts +2 -1
  54. package/dist/generated/sdkFactTables.js +5 -0
  55. package/dist/generated/settingsSchemaTables.d.ts +4 -0
  56. package/dist/generated/settingsSchemaTables.js +1 -0
  57. package/dist/hitl/approvalAskers.d.ts +6 -0
  58. package/dist/hitl/approvalAskers.js +30 -0
  59. package/dist/hitl/approvalCardReasons.js +6 -3
  60. package/dist/hitl/approvalDelivery.d.ts +1 -0
  61. package/dist/hitl/approvalDelivery.js +1 -1
  62. package/dist/hitl/approvalRequestFrameReading.d.ts +7 -0
  63. package/dist/hitl/approvalRequestFrameReading.js +11 -0
  64. package/dist/hitl/approvalResolution.d.ts +9 -2
  65. package/dist/hitl/approvalResolution.js +6 -1
  66. package/dist/hitl/askGateWire.js +5 -8
  67. package/dist/hitl/automaticAnswerVerdict.js +2 -2
  68. package/dist/hitl/decisionConflict.js +6 -3
  69. package/dist/hitl/decisionRefusal.d.ts +2 -0
  70. package/dist/hitl/decisionRefusal.js +8 -8
  71. package/dist/hitl/decisionRefusalCarrier.d.ts +3 -0
  72. package/dist/hitl/decisionRefusalCarrier.js +348 -0
  73. package/dist/hitl/decisionSend.d.ts +10 -0
  74. package/dist/hitl/decisionSend.js +57 -17
  75. package/dist/hitl/editedApprovalAcceptance.d.ts +25 -0
  76. package/dist/hitl/editedApprovalAcceptance.js +26 -0
  77. package/dist/hitl/elicitationRefusal.d.ts +4 -0
  78. package/dist/hitl/elicitationRefusal.js +23 -0
  79. package/dist/hitl/frameRouter.d.ts +2 -2
  80. package/dist/hitl/frameRouter.js +12 -33
  81. package/dist/hitl/gateIdentity.d.ts +5 -0
  82. package/dist/hitl/gateIdentity.js +23 -0
  83. package/dist/hitl/gateLedger.d.ts +0 -4
  84. package/dist/hitl/gateLedger.js +0 -19
  85. package/dist/hitl/hitlBridge.d.ts +7 -0
  86. package/dist/hitl/hitlBridge.js +14 -8
  87. package/dist/hitl/hitlHostSurface.d.ts +3 -1
  88. package/dist/hitl/hitlHostSurface.js +14 -4
  89. package/dist/hitl/hostWithdrawal.d.ts +15 -0
  90. package/dist/hitl/hostWithdrawal.js +38 -0
  91. package/dist/hitl/localAllowRedemption.d.ts +67 -0
  92. package/dist/hitl/localAllowRedemption.js +256 -0
  93. package/dist/hitl/parkResolver.js +32 -13
  94. package/dist/hitl/persistedRulesWire.d.ts +16 -0
  95. package/dist/hitl/persistedRulesWire.js +72 -2
  96. package/dist/hitl/planReviewWire.d.ts +3 -0
  97. package/dist/hitl/planReviewWire.js +37 -10
  98. package/dist/hitl/policyDenyCause.d.ts +1 -1
  99. package/dist/hitl/policyDenyCause.js +1 -1
  100. package/dist/hitl/resumeRunningCard.d.ts +1 -0
  101. package/dist/hitl/resumeRunningCard.js +1 -0
  102. package/dist/hitl/screenCardCarriers.d.ts +15 -0
  103. package/dist/hitl/screenCardCarriers.js +41 -0
  104. package/dist/hitl/screenDecisionCards.d.ts +98 -0
  105. package/dist/hitl/screenDecisionCards.js +362 -0
  106. package/dist/hitl/sessionPolicyWire.js +6 -4
  107. package/dist/hitl/standingRows.d.ts +4 -1
  108. package/dist/hitl/standingRows.js +33 -1
  109. package/dist/hitl/toolApprovalWire.d.ts +64 -15
  110. package/dist/hitl/toolApprovalWire.js +470 -125
  111. package/dist/hooksWireCaps.js +31 -1
  112. package/dist/hostSettingNoticeArm.d.ts +3 -0
  113. package/dist/hostSettingNoticeArm.js +12 -0
  114. package/dist/hostTurnSettings.d.ts +13 -4
  115. package/dist/hostTurnSettings.js +150 -10
  116. package/dist/humanTurnRead.js +11 -1
  117. package/dist/i18n/messages.en.d.ts +212 -0
  118. package/dist/i18n/messages.en.js +217 -5
  119. package/dist/i18n/messages.zh.js +235 -5
  120. package/dist/i18n/translate.d.ts +3 -0
  121. package/dist/i18n/translate.js +78 -10
  122. package/dist/i18n/zh.d.ts +1 -0
  123. package/dist/i18n/zh.js +1 -0
  124. package/dist/index.d.ts +56 -16
  125. package/dist/index.js +40 -12
  126. package/dist/inheritEnvCapability.js +2 -0
  127. package/dist/inputAuthor.d.ts +16 -0
  128. package/dist/inputAuthor.js +44 -0
  129. package/dist/interactiveHalt.js +2 -1
  130. package/dist/interactiveInterrupt.js +20 -2
  131. package/dist/interruptRefusalNote.d.ts +2 -0
  132. package/dist/interruptRefusalNote.js +17 -0
  133. package/dist/liveModelCatalog.d.ts +2 -0
  134. package/dist/liveModelCatalog.js +23 -9
  135. package/dist/liveQuestionStore.d.ts +4 -1
  136. package/dist/liveQuestionStore.js +12 -3
  137. package/dist/localEngineSeatReading.d.ts +2 -2
  138. package/dist/localEngineSeatReading.js +5 -3
  139. package/dist/localEngineSpawn.d.ts +0 -7
  140. package/dist/localEngineSpawn.js +0 -92
  141. package/dist/localEngineStep.d.ts +2 -2
  142. package/dist/localEngineStep.js +2 -0
  143. package/dist/mcpEngineLeg.d.ts +3 -0
  144. package/dist/mcpEngineLeg.js +38 -1
  145. package/dist/mcpPanel.js +2 -0
  146. package/dist/mcpReconnect.d.ts +9 -1
  147. package/dist/mcpReconnect.js +124 -19
  148. package/dist/mcpWireCaps.js +1 -1
  149. package/dist/model/engineModelWords.d.ts +3 -0
  150. package/dist/model/engineModelWords.js +13 -0
  151. package/dist/model/subagentModelWord.d.ts +21 -2
  152. package/dist/model/subagentModelWord.js +100 -29
  153. package/dist/modelCapabilityProbe.js +7 -43
  154. package/dist/modsFace.d.ts +8 -1
  155. package/dist/modsFace.js +27 -0
  156. package/dist/notifications.d.ts +36 -6
  157. package/dist/notifications.js +170 -20
  158. package/dist/ownKey.d.ts +6 -5
  159. package/dist/ownKey.js +31 -7
  160. package/dist/peerFrames.d.ts +40 -2
  161. package/dist/peerFrames.js +158 -3
  162. package/dist/pendingUserRow.d.ts +4 -0
  163. package/dist/pendingUserRow.js +16 -0
  164. package/dist/permissionsDeclaration.d.ts +1 -0
  165. package/dist/permissionsDeclaration.js +11 -1
  166. package/dist/planReviewCardFacts.d.ts +3 -0
  167. package/dist/planReviewCardFacts.js +52 -2
  168. package/dist/pluginHooksWire.d.ts +10 -1
  169. package/dist/pluginHooksWire.js +96 -7
  170. package/dist/printToolResultFrame.js +4 -2
  171. package/dist/promptBlockedCopy.js +11 -6
  172. package/dist/promptSuggestionBatch.d.ts +7 -0
  173. package/dist/promptSuggestionBatch.js +9 -0
  174. package/dist/promptSuggestionsTail.d.ts +39 -0
  175. package/dist/promptSuggestionsTail.js +116 -0
  176. package/dist/replayBody.js +10 -2
  177. package/dist/request/taskRequest.d.ts +5 -0
  178. package/dist/request/taskRequest.js +142 -21
  179. package/dist/requestCoordinate.d.ts +1 -0
  180. package/dist/requestCoordinate.js +13 -0
  181. package/dist/resumeRefusalCopy.d.ts +1 -3
  182. package/dist/resumeRefusalCopy.js +2 -1
  183. package/dist/retryStatus.d.ts +2 -2
  184. package/dist/retryStatus.js +2 -0
  185. package/dist/rewindArchiveReading.js +4 -4
  186. package/dist/runCancelContext.d.ts +2 -1
  187. package/dist/runCancelContext.js +1 -0
  188. package/dist/runPermissionModeSwitch.js +2 -2
  189. package/dist/scenarioRefusal.js +11 -13
  190. package/dist/scenarioSkills.js +11 -6
  191. package/dist/seam.d.ts +27 -2
  192. package/dist/seam.js +17 -1
  193. package/dist/seatContract.d.ts +189 -12
  194. package/dist/seatContract.js +401 -9
  195. package/dist/sessionBackground.js +2 -1
  196. package/dist/sessionBackgroundHandoff.js +2 -1
  197. package/dist/sessionCostReading.d.ts +70 -0
  198. package/dist/sessionCostReading.js +150 -0
  199. package/dist/sessionEngine.d.ts +2 -0
  200. package/dist/sessionEngine.js +111 -0
  201. package/dist/sessionHooksRoster.d.ts +4 -0
  202. package/dist/sessionHooksRoster.js +158 -0
  203. package/dist/sessionMemoryStatus.d.ts +2 -1
  204. package/dist/sessionMemoryStatus.js +2 -2
  205. package/dist/sessionReadRedaction.d.ts +7 -0
  206. package/dist/sessionReadRedaction.js +26 -0
  207. package/dist/sessionSyncFileHistory.d.ts +4 -0
  208. package/dist/sessionSyncFileHistory.js +27 -0
  209. package/dist/settingsHooksSalvage.js +2 -1
  210. package/dist/sseIdleTriage.d.ts +13 -1
  211. package/dist/sseIdleTriage.js +25 -6
  212. package/dist/storeDurabilityWord.d.ts +15 -0
  213. package/dist/storeDurabilityWord.js +18 -0
  214. package/dist/storePostureCapability.d.ts +7 -3
  215. package/dist/storePostureCapability.js +69 -39
  216. package/dist/subagent/engineSubagentResume.js +2 -2
  217. package/dist/subagent/engineSubagentTail.js +8 -1
  218. package/dist/subagentContentStore.d.ts +11 -0
  219. package/dist/subagentContentStore.js +28 -2
  220. package/dist/terminalStatuses.d.ts +1 -0
  221. package/dist/terminalStatuses.js +4 -1
  222. package/dist/toolResult.d.ts +1 -0
  223. package/dist/toolResult.js +2 -0
  224. package/dist/turnFailurePresentation.js +9 -2
  225. package/dist/typePins.d.ts +11 -0
  226. package/dist/usageAnalytics.d.ts +17 -0
  227. package/dist/usageAnalytics.js +44 -2
  228. package/dist/userAttachmentEnvelope.d.ts +2 -1
  229. package/dist/userAttachmentEnvelope.js +10 -0
  230. package/dist/wireErrorTriage.js +2 -1
  231. package/dist/wireFailureShape.d.ts +6 -5
  232. package/dist/wireFailureShape.js +150 -38
  233. package/dist/wireRefusalCopy.d.ts +16 -5
  234. package/dist/wireRefusalCopy.js +119 -86
  235. package/docs/INTEGRATION-CLIENTS.md +4228 -21
  236. package/package.json +7 -3
@@ -5,16 +5,16 @@ import { ccToolDenialKindForToolEnd, gateOutcomeOf, toolInputRewriteOf } from '.
5
5
  import { projectToolRoster, projectToolRosterDelta } from '../../toolRoster.js';
6
6
  import { projectHandsSection } from '../../handsSeam.js';
7
7
  import { readMcpAuthorization, readMcpLiveness } from '../../mcpLiveness.js';
8
- import { contextUsageReadingOf, humanInputAttachmentsOf, humanInputAuthorKeys, guardedRead, markMcpSectionDroppedNamedRows, ownSnapshotTyped, promptManifestIdentityOfFrame, promptManifestSectionViewOf, readFrameStringKey, readFrameTrueMark, readOwnDataFiniteNumber, readOwnDataNonEmptyString, workflowCompletionExtrasOf } from '../../ownKey.js';
8
+ import { contextUsageReadingOf, humanInputAttachmentsOf, guardedRead, markMcpSectionDroppedNamedRows, ownSnapshotTyped, promptManifestIdentityOfFrame, promptManifestSectionViewOf, readFrameStringKey, readFrameTrueMark, readOwnDataFiniteNumber, readOwnDataNonEmptyString, resupplyTruncatedOf, workflowCompletionExtrasOf } from '../../ownKey.js';
9
+ import { humanInputAuthorKeys, runOriginKeys } from '../../inputAuthor.js';
9
10
  import { SEGMENT_END_IDENTITY_KEYS, eventSeq, stripToolUseSideChannels } from '../types.js';
11
+ import { promptSuggestionBatchOf } from '../../promptSuggestionBatch.js';
10
12
  import { frozenSet } from '../../frozenSet.js';
11
13
  import { isCoreWorkflowRunTerminal } from '../../terminalStatuses.js';
12
14
  import { envelopeUuidOf, mintEngineRowRef, readBoundRun, wireEventIdOf } from '../../engineRowRef.js';
13
15
  function armBody(body) {
14
16
  return body;
15
17
  }
16
- const SUGGESTION_BATCH_CAP = 8;
17
- const SUGGESTION_CHARS_CAP = 200;
18
18
  export const INTERNAL_SDK_ARM_TYPES = frozenSet([
19
19
  'tool_disclosure',
20
20
  'tool_progress',
@@ -72,9 +72,6 @@ function streamEventArm(ctx, event) {
72
72
  const projected = (message) => ({ kind: 'message', message });
73
73
  const nothing = (why) => ({ kind: 'none', why });
74
74
  const dropped = (why, type) => ({ kind: 'dropped', why, type });
75
- function isCompactionStartedFrame(ev) {
76
- return ev.type === 'compaction_started';
77
- }
78
75
  const BEYOND_FLOOR_ARMS = Object.freeze(['cross_boundary_taint', 'approval_complete', 'session_titled']);
79
76
  function isBeyondFloorArm(ev) {
80
77
  const word = ev.type;
@@ -111,8 +108,6 @@ function withEngineIdentity(p, ev, ctx, identityFrame = ev) {
111
108
  return projected(Object.assign({}, env, { uuid: envelopeUuidOf(eventId, env.type), _sema_engine_ref: ref }));
112
109
  }
113
110
  function projectEvent(ev, ctx) {
114
- if (isCompactionStartedFrame(ev))
115
- return compactionStartedProjection(ev, ctx);
116
111
  if (isBeyondFloorArm(ev)) {
117
112
  const word = ev.type;
118
113
  if (word === 'cross_boundary_taint')
@@ -127,6 +122,8 @@ function projectEvent(ev, ctx) {
127
122
  switch (ev.type) {
128
123
  case 'task_started':
129
124
  return taskStartedProjection(ev, ctx);
125
+ case 'compaction_started':
126
+ return compactionStartedProjection(ev, ctx);
130
127
  case 'text_end':
131
128
  return textEndProjection(ev, ctx);
132
129
  case 'reasoning_end':
@@ -176,6 +173,10 @@ function projectEvent(ev, ctx) {
176
173
  status: wf.status,
177
174
  summary: typeof wf.summary === 'string' ? wf.summary : '',
178
175
  ...workflowCompletionExtrasOf(wf),
176
+ ...(() => {
177
+ const t = resupplyTruncatedOf(wf);
178
+ return t === undefined ? {} : { payloadTruncated: { bytes: t.bytes, droppedKeys: [...t.droppedKeys] } };
179
+ })(),
179
180
  })));
180
181
  }
181
182
  case 'text':
@@ -405,16 +406,13 @@ function projectEvent(ev, ctx) {
405
406
  })));
406
407
  }
407
408
  case 'suggestions': {
408
- const filtered = (Array.isArray(ev.suggestions) ? ev.suggestions : []).filter((s) => typeof s === 'string' && s.trim().length > 0);
409
- const list = filtered
410
- .slice(0, SUGGESTION_BATCH_CAP)
411
- .map((s) => (s.length > SUGGESTION_CHARS_CAP ? `${s.slice(0, SUGGESTION_CHARS_CAP)}…` : s));
412
- if (list.length === 0)
409
+ const batch = promptSuggestionBatchOf(ev.suggestions);
410
+ if (batch === undefined)
413
411
  return nothing('empty_payload');
414
412
  return projected(stamp(ctx, armBody({
415
413
  type: 'prompt_suggestions',
416
- suggestions: list,
417
- ...(filtered.length > list.length ? { truncatedCount: filtered.length - list.length } : {}),
414
+ suggestions: [...batch.list],
415
+ ...(batch.truncatedCount !== undefined ? { truncatedCount: batch.truncatedCount } : {}),
418
416
  })));
419
417
  }
420
418
  case 'turn_end':
@@ -955,6 +953,7 @@ function humanInputProjection(ev, ctx) {
955
953
  ...(str(ev.parentToolCallId) !== undefined ? { parentToolCallId: str(ev.parentToolCallId) } : {}),
956
954
  ...attachmentsKey(humanInputAttachmentsOf(ev)),
957
955
  ...humanInputAuthorKeys(ev),
956
+ ...runOriginKeys(ev),
958
957
  })));
959
958
  }
960
959
  function attachmentsKey(rows) {
@@ -974,3 +973,9 @@ export function turnEndUsage(ev) {
974
973
  export function gateKind(gate) {
975
974
  return gate?.kind ?? 'human';
976
975
  }
976
+ const _pinCompaction = [true, true, true, true, true, true, true, true, true, true, true];
977
+ void _pinCompaction;
978
+ const _pinMods = [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true];
979
+ void _pinMods;
980
+ const _pinPrompt = [true, true, true, true, true, true, true, true, true, true];
981
+ void _pinPrompt;
@@ -5,6 +5,7 @@ import type { SDKPermissionDenial, SDKResultError, SDKResultSuccess, TerminalRea
5
5
  import { type RunTerminalCodedDetail, type RunTerminalRead } from '../../runTerminal.js';
6
6
  import { type SemaModelUsage } from './turnUsageToModelUsage.js';
7
7
  import { type ResultLimitWord } from '../../engineErrorCodes.js';
8
+ import type { RunCostSettlement } from '../../sessionCostReading.js';
8
9
  import { type ResultWayOutFacts } from '../../providerRejection.js';
9
10
  export interface SemaFlatUsage {
10
11
  readonly inputTokens: number;
@@ -89,6 +90,7 @@ export interface RunCostFacts {
89
90
  export declare function readRunCostFacts(stats: TaskStats | undefined, observed?: {
90
91
  readonly usageMissingObserved?: boolean;
91
92
  }): RunCostFacts | undefined;
93
+ export declare function runCostSettlementOf(stats: TaskStats | undefined): Exclude<RunCostSettlement, 'awaiting'>;
92
94
  export interface ObservedTerminalParts extends PermissionDenialParts {
93
95
  readonly _sema_usage_lower_bound?: true;
94
96
  }
@@ -261,6 +261,17 @@ export function readRunCostFacts(stats, observed) {
261
261
  reconcile,
262
262
  };
263
263
  }
264
+ export function runCostSettlementOf(stats) {
265
+ try {
266
+ const facts = readRunCostFacts(stats);
267
+ if (facts === undefined)
268
+ return 'lost';
269
+ return facts.reconcile.ownMicroUsd !== undefined ? 'priced' : 'unpriced';
270
+ }
271
+ catch {
272
+ return 'lost';
273
+ }
274
+ }
264
275
  function structuredOutputParts(r) {
265
276
  const so = r.structuredOutput;
266
277
  return so !== undefined ? { structured_output: so } : {};
@@ -5,6 +5,7 @@ import type { ObservedTerminalParts } from './downstream/terminalToSdkResult.js'
5
5
  import { type ToolHistoryErrorCarrier } from '../toolHistoryMismatch.js';
6
6
  import { MODEL_OUTPUT_ERROR_PREFIX, OUTCOME_UNKNOWN_ROW_PREFIX, RUN_BLOCKED_MESSAGE_PREFIX, RUN_STOPPED_MESSAGE_PREFIX } from '../rowKind.js';
7
7
  export { MODEL_OUTPUT_ERROR_PREFIX, OUTCOME_UNKNOWN_ROW_PREFIX, RUN_BLOCKED_MESSAGE_PREFIX, RUN_STOPPED_MESSAGE_PREFIX };
8
+ import { type PlanReviewCardFacts } from '../planReviewCardFacts.js';
8
9
  export interface ActiveRunPendingGate {
9
10
  readonly kind: string | null;
10
11
  readonly decidePath: string | null;
@@ -37,5 +38,9 @@ export interface RunStreamHandle {
37
38
  latestUsageMissing?: true;
38
39
  observedTerminalParts?: () => ObservedTerminalParts;
39
40
  }
41
+ export interface PlanReviewFrameClaim {
42
+ feed(frame: {} | null | undefined): PlanReviewCardFacts | undefined;
43
+ }
44
+ export declare function openPlanReviewFrameClaim(): PlanReviewFrameClaim;
40
45
  export declare function isRunStreamActive(): boolean;
41
46
  export declare function runStream(events: AsyncIterable<AgentEvent>, ctx: EmitContext, handle?: RunStreamHandle): AsyncGenerator<SDKMessage>;
@@ -20,7 +20,7 @@ import { MODEL_OUTPUT_ERROR_PREFIX, OUTCOME_UNKNOWN_ROW_PREFIX, RUN_BLOCKED_MESS
20
20
  export { MODEL_OUTPUT_ERROR_PREFIX, OUTCOME_UNKNOWN_ROW_PREFIX, RUN_BLOCKED_MESSAGE_PREFIX, RUN_STOPPED_MESSAGE_PREFIX };
21
21
  import { ccToolDenialKindForToolEnd, gateDeniedBy, gateOutcomeOf } from '../gateOutcome.js';
22
22
  import { resumeReopenContent, resumeReopenFromError, suspendedReopenOf } from '../hitl/suspendedReopen.js';
23
- import { openPlanBodyClaimLeg, planReviewParkFacts, stepPlanBodyClaim } from '../planReviewCardFacts.js';
23
+ import { openPlanBodyClaimLeg, planReviewClaimStep } from '../planReviewCardFacts.js';
24
24
  import { isCcToolDenialKind, isCcToolDenialKindADenial, isGateDeniedByWord } from '../gateVocabulary.js';
25
25
  const ENGINE_TURN_USAGE_KEYS = Object.freeze(['inputTokens', 'totalInputTokens', 'outputTokens', 'cacheReadTokens', 'cacheWriteTokens', 'costMicroUsd']);
26
26
  const _engineTurnUsageKeysPin = true;
@@ -454,6 +454,18 @@ function wireFrameIsSubFlow(ev) {
454
454
  });
455
455
  return snap === undefined || snapshotIsSubFlow(snap);
456
456
  }
457
+ export function openPlanReviewFrameClaim() {
458
+ const leg = openPlanBodyClaimLeg();
459
+ return Object.freeze({
460
+ feed(frame) {
461
+ if (typeof frame !== 'object' || frame === null)
462
+ return undefined;
463
+ const subFlow = wireFrameIsSubFlow(frame);
464
+ const seq = guardedRead(() => eventSeq(frame));
465
+ return planReviewClaimStep(leg, frame, subFlow, seq);
466
+ },
467
+ });
468
+ }
457
469
  function withStringFailureFields(ev) {
458
470
  if (ev.type !== 'failed')
459
471
  return ev;
@@ -592,7 +604,7 @@ async function* runStreamInner(events, ctx, handle = {}) {
592
604
  }
593
605
  seen.add(seq);
594
606
  }
595
- stepPlanBodyClaim(planLeg, ev, wireSubFlow);
607
+ const planReviewAtTerminal = planReviewClaimStep(planLeg, ev, wireSubFlow, seq);
596
608
  if (ev.type === 'tool_start') {
597
609
  const callId = ev.toolCallId;
598
610
  if (typeof callId === 'string' && callId.length > 0 && !toolInputAmbiguous.has(callId)) {
@@ -855,7 +867,7 @@ async function* runStreamInner(events, ctx, handle = {}) {
855
867
  accepted: ev.type === 'done' && (doneTerminal?.kind === 'completed' || doneTerminal?.kind === 'paused'),
856
868
  }).acceptedSinceMismatch;
857
869
  }
858
- const planReview = ev.type === 'done' ? planReviewParkFacts(planLeg, engineResultOf(ev.result)) : undefined;
870
+ const planReview = planReviewAtTerminal;
859
871
  if (ev.type === 'done' && isReviewPark(doneTerminal) && ctx.emitChrome) {
860
872
  try {
861
873
  await ctx.emitChrome({ kind: 'plan_review_park', laneProof: mainLane(), result: ev.result, ...(planReview !== undefined ? { planReview } : {}) });
@@ -0,0 +1,20 @@
1
+ import type { UiLanguage } from './env/uiLanguage.js';
2
+ export declare const TOOLS_LOCATIONS: readonly ["this-machine", "elsewhere", "unconfirmed"];
3
+ export type ToolsLocation = (typeof TOOLS_LOCATIONS)[number];
4
+ export declare const ATTACHMENT_ROUTE_LEGS: readonly ["at_mention", "edited_file", "paste", "ide_selection"];
5
+ export type AttachmentRouteLeg = (typeof ATTACHMENT_ROUTE_LEGS)[number];
6
+ export interface AttachmentRouteFacts {
7
+ readonly leg: AttachmentRouteLeg;
8
+ readonly toolsLocation: ToolsLocation;
9
+ }
10
+ export type AttachmentWithheldReason = 'tools-elsewhere' | 'tools-location-unconfirmed';
11
+ export type AttachmentRoute = {
12
+ readonly route: 'attach_content';
13
+ readonly localCopy: boolean;
14
+ } | {
15
+ readonly route: 'withhold';
16
+ readonly reason: AttachmentWithheldReason;
17
+ };
18
+ export declare function attachmentRouteOf(facts: AttachmentRouteFacts): AttachmentRoute;
19
+ export declare function attachmentWithheldReasonText(reason: AttachmentWithheldReason, lang?: UiLanguage): string;
20
+ export declare function attachmentLocalCopyNote(): string;
@@ -0,0 +1,39 @@
1
+ import { msg, renderMessage } from './i18n/translate.js';
2
+ import { readOwnDataNonEmptyString } from './ownKey.js';
3
+ export const TOOLS_LOCATIONS = Object.freeze(['this-machine', 'elsewhere', 'unconfirmed']);
4
+ export const ATTACHMENT_ROUTE_LEGS = Object.freeze(['at_mention', 'edited_file', 'paste', 'ide_selection']);
5
+ const _withheldReasonsPinned = true;
6
+ void _withheldReasonsPinned;
7
+ const ATTACH = Object.freeze({ route: 'attach_content', localCopy: false });
8
+ const ATTACH_LOCAL_COPY = Object.freeze({ route: 'attach_content', localCopy: true });
9
+ const WITHHOLD_ELSEWHERE = Object.freeze({ route: 'withhold', reason: 'tools-elsewhere' });
10
+ const WITHHOLD_UNCONFIRMED = Object.freeze({ route: 'withhold', reason: 'tools-location-unconfirmed' });
11
+ const SNAPSHOT_LEGS = new Set(['paste', 'ide_selection']);
12
+ function closedWord(facts, key, words) {
13
+ try {
14
+ if (typeof facts !== 'object' || facts === null)
15
+ return undefined;
16
+ const raw = readOwnDataNonEmptyString(facts, key);
17
+ return raw !== undefined && words.includes(raw) ? raw : undefined;
18
+ }
19
+ catch {
20
+ return undefined;
21
+ }
22
+ }
23
+ export function attachmentRouteOf(facts) {
24
+ const where = closedWord(facts, 'toolsLocation', TOOLS_LOCATIONS);
25
+ if (where === 'this-machine')
26
+ return ATTACH;
27
+ const leg = closedWord(facts, 'leg', ATTACHMENT_ROUTE_LEGS);
28
+ if (leg !== undefined && SNAPSHOT_LEGS.has(leg))
29
+ return ATTACH_LOCAL_COPY;
30
+ return where === 'elsewhere' ? WITHHOLD_ELSEWHERE : WITHHOLD_UNCONFIRMED;
31
+ }
32
+ export function attachmentWithheldReasonText(reason, lang) {
33
+ return reason === 'tools-elsewhere'
34
+ ? renderMessage(msg('attachments.withheld.toolsElsewhere.row'), lang)
35
+ : renderMessage(msg('attachments.withheld.toolsLocationUnconfirmed.row'), lang);
36
+ }
37
+ export function attachmentLocalCopyNote() {
38
+ return renderMessage(msg('attachments.localCopy.model'));
39
+ }
@@ -25,7 +25,7 @@ const OPT_IN_KEYS = [
25
25
  'mcpInstructions',
26
26
  ];
27
27
  const DEFAULT_ON_ONLY_KEYS = ['agentListing', 'skillsListing'];
28
- const PRODUCT_DEFAULT_KEYS = ['backgroundTasks', 'toolsDelta', 'todoReminder'];
28
+ const PRODUCT_DEFAULT_KEYS = ['backgroundTasks', 'toolsDelta', 'todoReminder', 'mcpInstructions'];
29
29
  function productDefaultAttachments() {
30
30
  const out = {};
31
31
  for (const k of PRODUCT_DEFAULT_KEYS)
@@ -0,0 +1,12 @@
1
+ export type BuiltinOutputStyleName = 'default' | 'Proactive' | 'Concise' | 'Explanatory' | 'Learning';
2
+ export interface BuiltinOutputStyle {
3
+ readonly name: string;
4
+ readonly source: 'built-in';
5
+ readonly description: string;
6
+ readonly keepCodingInstructions: true;
7
+ readonly prompt: string;
8
+ readonly turnReminder?: string;
9
+ readonly waitingTurnReminder?: string;
10
+ }
11
+ export declare const BUILTIN_OUTPUT_STYLES: Readonly<Record<BuiltinOutputStyleName, BuiltinOutputStyle | null>>;
12
+ export declare function builtinOutputStyleOf(name: string): BuiltinOutputStyle | null | undefined;
@@ -0,0 +1,147 @@
1
+ const INSIGHTS_SECTION = `
2
+ ## Insights
3
+ In order to encourage learning, before and after writing code, always provide brief educational explanations about implementation choices using (with backticks):
4
+ "\`★ Insight ─────────────────────────────────────\`
5
+ [2-3 key educational points]
6
+ \`─────────────────────────────────────────────────\`"
7
+
8
+ These insights should be included in the conversation, not in the codebase. You should generally focus on interesting insights that are specific to the codebase or the code you just wrote, rather than general programming concepts.`;
9
+ const PROACTIVE_SECTION = `The user chose continuous, autonomous execution. You should:
10
+
11
+ 1. **Execute immediately** — Start implementing right away. Make reasonable assumptions and proceed on low-risk work.
12
+ 2. **Minimize interruptions** — Prefer making reasonable assumptions over asking questions for routine decisions.
13
+ 3. **Prefer action over planning** — Do not enter plan mode unless the user explicitly asks. When in doubt, start coding.
14
+ 4. **Expect course corrections** — The user may provide suggestions or course corrections at any point; treat those as normal input.
15
+ 5. **Do not take overly destructive actions** — This is not a license to destroy. Anything that deletes data or modifies shared or production systems still needs explicit user confirmation. If you reach such a decision point, ask and wait, or course correct to a safer method instead.
16
+ 6. **Avoid data exfiltration** — Post even routine messages to chat platforms or work tickets only if the user has directed you to. You must not share secrets (e.g. credentials, internal documentation) unless the user has explicitly authorized both that specific secret and its destination.`;
17
+ const CONCISE_SECTION = `The user chose brevity over narration. You should:
18
+
19
+ 1. **Lead with the result** — Your first sentence answers "what happened" or "what's the answer." No preamble ("Let me...", "Now I'll...") and no closing recap of what you already said.
20
+ 2. **Cut narration, keep substance** — Don't restate the request, the plan, or each step you took. Report outcomes, decisions, and anything the user must act on.
21
+ 3. **Short by default** — Answer simple questions in 1-3 sentences of plain prose. Use headers, tables, and bullet lists only when they carry real structure, never as decoration.
22
+ 4. **State things plainly** — Skip hedging boilerplate. Mention a caveat only when it changes what the user should do next.
23
+ 5. **Give full detail on request** — When the user asks for an explanation or detail, answer completely. Conciseness never means withholding requested information.
24
+ 6. **Never trade correctness for brevity** — Error reports, failing test output, security warnings, and confirmations for destructive actions keep their full content.
25
+
26
+ Where these rules conflict with more general communication or formatting guidance elsewhere in your instructions, these rules win.`;
27
+ export const BUILTIN_OUTPUT_STYLES = Object.freeze({
28
+ default: null,
29
+ Proactive: Object.freeze({
30
+ name: 'Proactive',
31
+ source: 'built-in',
32
+ description: "Sema executes immediately, minimizes interruptions, and prefers action over planning",
33
+ keepCodingInstructions: true,
34
+ prompt: `You are an interactive CLI tool that helps users with software engineering tasks. You should work proactively and autonomously, executing immediately and minimizing interruptions.
35
+
36
+ # Proactive Style Active
37
+ ${PROACTIVE_SECTION}`,
38
+ turnReminder: "Execute autonomously, minimize interruptions, prefer action over planning.",
39
+ waitingTurnReminder: "Execute autonomously and minimize interruptions. If the only work left is waiting for a background task or monitor you started, end your turn now: you will be notified when it finishes or fires. Do not poll, sleep, or re-read its output while you wait.",
40
+ }),
41
+ Concise: Object.freeze({
42
+ name: 'Concise',
43
+ source: 'built-in',
44
+ description: "Sema responds tersely, leading with results and skipping preamble and narration",
45
+ keepCodingInstructions: true,
46
+ prompt: `You are an interactive CLI tool that helps users with software engineering tasks. Keep your responses short and direct while doing the work just as thoroughly.
47
+
48
+ # Concise Style Active
49
+ ${CONCISE_SECTION}`,
50
+ turnReminder: "Be concise: lead with the result, skip preamble and narration, keep only what the user needs.",
51
+ }),
52
+ Explanatory: Object.freeze({
53
+ name: 'Explanatory',
54
+ source: 'built-in',
55
+ description: "Sema explains its implementation choices and codebase patterns",
56
+ keepCodingInstructions: true,
57
+ prompt: `You are an interactive CLI tool that helps users with software engineering tasks. In addition to software engineering tasks, you should provide educational insights about the codebase along the way.
58
+
59
+ You should be clear and educational, providing helpful explanations while remaining focused on the task. Balance educational content with task completion. When providing insights, you may exceed typical length constraints, but remain focused and relevant.
60
+
61
+ # Explanatory Style Active
62
+ ${INSIGHTS_SECTION}`,
63
+ }),
64
+ Learning: Object.freeze({
65
+ name: 'Learning',
66
+ source: 'built-in',
67
+ description: "Sema pauses and asks you to write small pieces of code for hands-on practice",
68
+ keepCodingInstructions: true,
69
+ prompt: `You are an interactive CLI tool that helps users with software engineering tasks. In addition to software engineering tasks, you should help users learn more about the codebase through hands-on practice and educational insights.
70
+
71
+ You should be collaborative and encouraging. Balance task completion with learning by requesting user input for meaningful design decisions while handling routine implementation yourself.
72
+
73
+ # Learning Style Active
74
+ ## Requesting Human Contributions
75
+ In order to encourage learning, ask the human to contribute 2-10 line code pieces when generating 20+ lines involving:
76
+ - Design decisions (error handling, data structures)
77
+ - Business logic with multiple valid approaches
78
+ - Key algorithms or interface definitions
79
+
80
+ **TodoList Integration**: If using a TodoList for the overall task, include a specific todo item like "Request human input on [specific decision]" when planning to request human input. This ensures proper task tracking. Note: TodoList is not required for all tasks.
81
+
82
+ Example TodoList flow:
83
+ ✓ "Set up component structure with placeholder for logic"
84
+ ✓ "Request human collaboration on decision logic implementation"
85
+ ✓ "Integrate contribution and complete feature"
86
+
87
+ ### Request Format
88
+ \`\`\`
89
+ ● **Learn by Doing**
90
+ **Context:** [what's built and why this decision matters]
91
+ **Your Task:** [specific function/section in file, mention file and TODO(human) but do not include line numbers]
92
+ **Guidance:** [trade-offs and constraints to consider]
93
+ \`\`\`
94
+
95
+ ### Key Guidelines
96
+ - Frame contributions as valuable design decisions, not busy work
97
+ - You must first add a TODO(human) section into the codebase with your editing tools before making the Learn by Doing request
98
+ - Make sure there is one and only one TODO(human) section in the code
99
+ - Don't take any action or output anything after the Learn by Doing request. Wait for human implementation before proceeding.
100
+
101
+ ### Example Requests
102
+
103
+ **Whole Function Example:**
104
+ \`\`\`
105
+ ● **Learn by Doing**
106
+
107
+ **Context:** I've set up the hint feature UI with a button that triggers the hint system. The infrastructure is ready: when clicked, it calls selectHintCell() to determine which cell to hint, then highlights that cell with a yellow background and shows possible values. The hint system needs to decide which empty cell would be most helpful to reveal to the user.
108
+
109
+ **Your Task:** In sudoku.js, implement the selectHintCell(board) function. Look for TODO(human). This function should analyze the board and return {row, col} for the best cell to hint, or null if the puzzle is complete.
110
+
111
+ **Guidance:** Consider multiple strategies: prioritize cells with only one possible value (naked singles), or cells that appear in rows/columns/boxes with many filled cells. You could also consider a balanced approach that helps without making it too easy. The board parameter is a 9x9 array where 0 represents empty cells.
112
+ \`\`\`
113
+
114
+ **Partial Function Example:**
115
+ \`\`\`
116
+ ● **Learn by Doing**
117
+
118
+ **Context:** I've built a file upload component that validates files before accepting them. The main validation logic is complete, but it needs specific handling for different file type categories in the switch statement.
119
+
120
+ **Your Task:** In upload.js, inside the validateFile() function's switch statement, implement the 'case "document":' branch. Look for TODO(human). This should validate document files (pdf, doc, docx).
121
+
122
+ **Guidance:** Consider checking file size limits (maybe 10MB for documents?), validating the file extension matches the MIME type, and returning {valid: boolean, error?: string}. The file object has properties: name, size, type.
123
+ \`\`\`
124
+
125
+ **Debugging Example:**
126
+ \`\`\`
127
+ ● **Learn by Doing**
128
+
129
+ **Context:** The user reported that number inputs aren't working correctly in the calculator. I've identified the handleInput() function as the likely source, but need to understand what values are being processed.
130
+
131
+ **Your Task:** In calculator.js, inside the handleInput() function, add 2-3 console.log statements after the TODO(human) comment to help debug why number inputs fail.
132
+
133
+ **Guidance:** Consider logging: the raw input value, the parsed result, and any validation state. This will help us understand where the conversion breaks.
134
+ \`\`\`
135
+
136
+ ### After Contributions
137
+ Share one insight connecting their code to broader patterns or system effects. Avoid praise or repetition.
138
+
139
+ ## Insights
140
+ ${INSIGHTS_SECTION}`,
141
+ }),
142
+ });
143
+ export function builtinOutputStyleOf(name) {
144
+ if (typeof name !== 'string' || !Object.hasOwn(BUILTIN_OUTPUT_STYLES, name))
145
+ return undefined;
146
+ return BUILTIN_OUTPUT_STYLES[name];
147
+ }
@@ -1,6 +1,8 @@
1
+ import type { UiLanguage } from './env/uiLanguage.js';
1
2
  export interface CompactionStatusReading {
2
3
  readonly compacting: boolean;
3
4
  readonly since?: number;
5
+ readonly openTriggers?: readonly string[];
4
6
  }
5
7
  export type CompactionStatusChange = {
6
8
  readonly kind: 'opened';
@@ -32,3 +34,10 @@ export interface PrintCompactionStatusCtx {
32
34
  }
33
35
  export declare function createCompactionStatusTracker(): CompactionStatusTracker;
34
36
  export declare function compactionStatusFrameOf(change: CompactionStatusChange | null | undefined, ctx: PrintCompactionStatusCtx): PrintCompactionStatusFrame | null;
37
+ export type CompactionStopVerdict = {
38
+ readonly kind: 'compaction_canceled';
39
+ } | {
40
+ readonly kind: 'interrupted';
41
+ };
42
+ export declare function compactionStopVerdict(reading: CompactionStatusReading | null | undefined): CompactionStopVerdict;
43
+ export declare function compactionCanceledSentence(lang?: UiLanguage): string;
@@ -1,4 +1,5 @@
1
- import { readOwnDataValue } from './ownKey.js';
1
+ import { msg, renderMessage } from './i18n/translate.js';
2
+ import { appendOwnElement, readOwnDataValue } from './ownKey.js';
2
3
  import { snapshotIsSubFlow, snapshotSegmentIdentity } from './adapter/types.js';
3
4
  const _printStatusFramePins = [true, true];
4
5
  void _printStatusFramePins;
@@ -20,9 +21,10 @@ function armLane(m) {
20
21
  function openOf(pass, lane, startedAt, trigger) {
21
22
  if (lane === 'unreadable')
22
23
  return null;
23
- if (nonEmpty(trigger) === undefined)
24
+ const t = nonEmpty(trigger);
25
+ if (t === undefined)
24
26
  return null;
25
- return { kind: 'open', pass, main: lane === 'main', ...(typeof startedAt === 'number' && Number.isFinite(startedAt) ? { startedAt } : {}) };
27
+ return { kind: 'open', pass, main: lane === 'main', trigger: t, ...(typeof startedAt === 'number' && Number.isFinite(startedAt) ? { startedAt } : {}) };
26
28
  }
27
29
  function parse(input) {
28
30
  const plane = own(input, 'plane');
@@ -101,7 +103,11 @@ export function createCompactionStatusTracker() {
101
103
  if (mainOpen() === 0)
102
104
  return { compacting: false };
103
105
  const s = since();
104
- return { compacting: true, ...(s !== undefined ? { since: s } : {}) };
106
+ const triggers = [];
107
+ for (const e of open.values())
108
+ if (e.main)
109
+ appendOwnElement(triggers, e.trigger);
110
+ return { compacting: true, ...(s !== undefined ? { since: s } : {}), openTriggers: Object.freeze(triggers) };
105
111
  };
106
112
  return {
107
113
  take(input) {
@@ -115,7 +121,7 @@ export function createCompactionStatusTracker() {
115
121
  if (open.has(p.pass) || closed.has(p.pass))
116
122
  return null;
117
123
  const before = mainOpen();
118
- open.set(p.pass, { main: p.main === true, ...(p.startedAt !== undefined ? { startedAt: p.startedAt } : {}) });
124
+ open.set(p.pass, { main: p.main === true, trigger: p.trigger ?? '', ...(p.startedAt !== undefined ? { startedAt: p.startedAt } : {}) });
119
125
  if (before === 0 && p.main === true) {
120
126
  const s = since();
121
127
  return { kind: 'opened', pass: p.pass, ...(s !== undefined ? { since: s } : {}) };
@@ -194,3 +200,21 @@ export function compactionStatusFrameOf(change, ctx) {
194
200
  return null;
195
201
  }
196
202
  }
203
+ const STOP_CANCELED = Object.freeze({ kind: 'compaction_canceled' });
204
+ const STOP_INTERRUPTED = Object.freeze({ kind: 'interrupted' });
205
+ export function compactionStopVerdict(reading) {
206
+ try {
207
+ if (own(reading, 'compacting') !== true)
208
+ return STOP_INTERRUPTED;
209
+ const triggers = own(reading, 'openTriggers');
210
+ if (!Array.isArray(triggers) || own(triggers, 'length') !== 1)
211
+ return STOP_INTERRUPTED;
212
+ return own(triggers, '0') === 'manual' ? STOP_CANCELED : STOP_INTERRUPTED;
213
+ }
214
+ catch {
215
+ return STOP_INTERRUPTED;
216
+ }
217
+ }
218
+ export function compactionCanceledSentence(lang) {
219
+ return renderMessage(msg('session.compaction.canceled'), lang);
220
+ }
@@ -1,4 +1,5 @@
1
1
  import { cancelConflictContent, cancelConflictFromError } from './wireRefusalCopy.js';
2
+ import { STEERING_NOT_RUNNING } from './engineErrorCodes.js';
2
3
  import { PROTOCOL_ERROR_NAME, THROWN_SLOT_UNREADABLE, protocolErrorNameOf, readThrownSlot, readThrownStatusSlot } from './wireFailureShape.js';
3
4
  import { steerPriorityMode } from './steerPriorityCapability.js';
4
5
  import { preemptReadingOfAck, preemptReadingOfError } from './preemptWire.js';
@@ -166,7 +167,7 @@ export function errCodes(e) {
166
167
  return { code, name, status };
167
168
  }
168
169
  const STEERING_CODE_TO_SAFETY = new Map([
169
- ['steering.not_running', 'not_running'],
170
+ [STEERING_NOT_RUNNING, 'not_running'],
170
171
  ['steering.invalid_content', 'invalid_content'],
171
172
  ['steering.queue_full', 'queue_full'],
172
173
  ['steering.duplicate_input_id', 'duplicate_input_id'],
@@ -154,6 +154,40 @@ export interface CoreValuePorts {
154
154
  runParkedOf(run: WorkflowRunParkedInputView): boolean;
155
155
  parkedAgentsOf(agents: ReadonlyArray<WorkflowAgentStatusView>): WorkflowAgentStatusView[];
156
156
  modelFaceResolvable(face: object, options?: ModelFaceOptionsView): ModelFaceVerdictView;
157
+ accountRowOfResult(result: {
158
+ readonly stats: AccountRowStatsView;
159
+ }): AccountRowView;
160
+ foldAccount(rows: Iterable<AccountRowView>): SessionAccountView;
161
+ }
162
+ export interface AccountRowView {
163
+ origin: 'run' | 'side_query';
164
+ tokens: number;
165
+ costMicroUsd?: number;
166
+ usageMissing?: true;
167
+ }
168
+ export interface AccountTotalView {
169
+ rows: number;
170
+ tokens: number;
171
+ costMicroUsd?: number;
172
+ usageMissing?: true;
173
+ }
174
+ export interface SessionAccountView extends AccountTotalView {
175
+ byOrigin: {
176
+ readonly run: AccountTotalView;
177
+ readonly side_query: AccountTotalView;
178
+ };
179
+ }
180
+ export interface AccountRowStatsView {
181
+ readonly tokens: number;
182
+ readonly costMicroUsd?: number;
183
+ readonly usageMissing?: true;
184
+ readonly nested?: AccountRowNestedStatsView;
185
+ }
186
+ export interface AccountRowNestedStatsView {
187
+ readonly tokens: number;
188
+ readonly turns: number;
189
+ readonly tasks: number;
190
+ readonly costMicroUsd?: number;
157
191
  }
158
192
  export interface WorkflowAgentStatusView {
159
193
  readonly status: string;
@@ -176,7 +210,7 @@ export type ModelFaceVerdictView = {
176
210
  readonly role: string;
177
211
  readonly code: string;
178
212
  };
179
- export declare const CORE_VALUE_PORT_NAMES: readonly ["resolveAutonomousLoopPrompt", "loosenReasons", "combinePolicies", "createAllowDenyPolicy", "MCP_NAMESPACE", "protocolOf", "ruleToolGrammarOf", "validatePermissionRules", "mintNamespacePrefix", "compileAllowList", "routeKeyOf", "joinRequestUrl", "resolveRouteCredential", "adjudicateModelRoute", "routePairingStatus", "judgeRuleToolName", "readRuleEntry", "readMcpToolAxes", "ANTHROPIC_DEFAULT_BASE_URL", "readToolFaces", "ruleNameCovers", "IMPORTED_SETTINGS_LAYERS", "runParkedOf", "parkedAgentsOf", "modelFaceResolvable"];
213
+ export declare const CORE_VALUE_PORT_NAMES: readonly ["resolveAutonomousLoopPrompt", "loosenReasons", "combinePolicies", "createAllowDenyPolicy", "MCP_NAMESPACE", "protocolOf", "ruleToolGrammarOf", "validatePermissionRules", "mintNamespacePrefix", "compileAllowList", "routeKeyOf", "joinRequestUrl", "resolveRouteCredential", "adjudicateModelRoute", "routePairingStatus", "judgeRuleToolName", "readRuleEntry", "readMcpToolAxes", "ANTHROPIC_DEFAULT_BASE_URL", "readToolFaces", "ruleNameCovers", "IMPORTED_SETTINGS_LAYERS", "runParkedOf", "parkedAgentsOf", "modelFaceResolvable", "accountRowOfResult", "foldAccount"];
180
214
  export type CoreValuePortName = (typeof CORE_VALUE_PORT_NAMES)[number];
181
215
  export declare function installCoreValuePorts(ports: Partial<CoreValuePorts> | null): () => void;
182
216
  export declare function hasCoreValuePorts(): boolean;
@@ -211,3 +245,7 @@ export declare function importedSettingsLayers(): CoreValuePorts['IMPORTED_SETTI
211
245
  export declare function runParkedOf(run: WorkflowRunParkedInputView): boolean | undefined;
212
246
  export declare function parkedAgentsOf(agents: ReadonlyArray<WorkflowAgentStatusView>): WorkflowAgentStatusView[] | undefined;
213
247
  export declare function modelFaceResolvable(face: object, options?: ModelFaceOptionsView): ModelFaceVerdictView | undefined;
248
+ export declare function accountRowOfResult(result: {
249
+ readonly stats: AccountRowStatsView;
250
+ }): AccountRowView | undefined;
251
+ export declare function foldAccount(rows: Iterable<AccountRowView>): SessionAccountView | undefined;
@@ -24,6 +24,8 @@ export const CORE_VALUE_PORT_NAMES = Object.freeze([
24
24
  'runParkedOf',
25
25
  'parkedAgentsOf',
26
26
  'modelFaceResolvable',
27
+ 'accountRowOfResult',
28
+ 'foldAccount',
27
29
  ]);
28
30
  let installed = null;
29
31
  export function installCoreValuePorts(ports) {
@@ -142,3 +144,11 @@ export function modelFaceResolvable(face, options) {
142
144
  const fn = port('modelFaceResolvable');
143
145
  return fn === undefined ? undefined : fn(face, options);
144
146
  }
147
+ export function accountRowOfResult(result) {
148
+ const fn = port('accountRowOfResult');
149
+ return fn === undefined ? undefined : fn(result);
150
+ }
151
+ export function foldAccount(rows) {
152
+ const fn = port('foldAccount');
153
+ return fn === undefined ? undefined : fn(rows);
154
+ }
@@ -1,5 +1,5 @@
1
1
  export const DECLARED_SUPPORT_FLOOR = Object.freeze({
2
2
  server: "7.139.0",
3
3
  core: "7.60.0",
4
- sdk: "23.1.0",
4
+ sdk: "25.0.0",
5
5
  });
@@ -51,6 +51,7 @@ export declare function capDisplay(text: string, max: number | undefined, mark:
51
51
  export declare function paintAndCap(text: string, face: DisplayFace, max?: number): string;
52
52
  export declare function credentialWashPasses(text: string, opts?: DisplayUntrustedOptions | null): Readonly<WashStats>;
53
53
  export declare function displayUntrusted(text: string, opts?: DisplayUntrustedOptions): string;
54
+ export declare function displayUntrustedCapped(text: string, max: number, opts?: DisplayUntrustedOptions): string;
54
55
  export declare function cleanUntrustedScalar(v: string | number | bigint | boolean | null | undefined): string;
55
56
  export declare function queryCarriesCredential(query: string): boolean;
56
57
  export declare function displayConfiguredUrl(url: string, opts?: DisplayUntrustedOptions): string;