@sema-agent/client-core 0.110.0 → 0.112.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 (243) hide show
  1. package/CHANGELOG.md +244 -0
  2. package/README.md +59 -18
  3. package/dist/abortableSleep.d.ts +7 -0
  4. package/dist/abortableSleep.js +37 -0
  5. package/dist/adapt/arms.js +25 -4
  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 +10 -10
  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/agentSession/engineSessionBackgroundStop.js +2 -2
  16. package/dist/attachmentRoute.d.ts +20 -0
  17. package/dist/attachmentRoute.js +39 -0
  18. package/dist/attachmentsWireCaps.js +1 -1
  19. package/dist/builtinOutputStyles.d.ts +12 -0
  20. package/dist/builtinOutputStyles.js +147 -0
  21. package/dist/checkpointRowVerdict.d.ts +3 -0
  22. package/dist/checkpointRowVerdict.js +14 -1
  23. package/dist/compactionStatus.d.ts +9 -0
  24. package/dist/compactionStatus.js +29 -5
  25. package/dist/consoleCaPin.d.ts +136 -0
  26. package/dist/consoleCaPin.js +827 -0
  27. package/dist/controlRouter.js +2 -1
  28. package/dist/coreValuePorts.d.ts +39 -1
  29. package/dist/coreValuePorts.js +10 -0
  30. package/dist/decideReceipt.d.ts +2 -1
  31. package/dist/deviceRebind.js +3 -3
  32. package/dist/displayUntrusted.d.ts +1 -0
  33. package/dist/displayUntrusted.js +6 -0
  34. package/dist/effectiveFacts.d.ts +9 -0
  35. package/dist/effectiveFacts.js +33 -0
  36. package/dist/engineAddress.d.ts +1 -0
  37. package/dist/engineAddress.js +4 -1
  38. package/dist/engineCredentialRelease.d.ts +54 -0
  39. package/dist/engineCredentialRelease.js +146 -0
  40. package/dist/engineErrorCodes.d.ts +1 -0
  41. package/dist/engineErrorCodes.js +1 -0
  42. package/dist/engineHealthProbeVerdict.d.ts +24 -0
  43. package/dist/engineHealthProbeVerdict.js +123 -0
  44. package/dist/engineNoticeCodes.js +5 -7
  45. package/dist/engineRepoint.d.ts +12 -5
  46. package/dist/engineRepoint.js +44 -19
  47. package/dist/engineRowRef.d.ts +3 -0
  48. package/dist/engineRowRef.js +11 -1
  49. package/dist/engineSwapCrossing.d.ts +57 -0
  50. package/dist/engineSwapCrossing.js +297 -0
  51. package/dist/engineUnavailable.d.ts +45 -0
  52. package/dist/engineUnavailable.js +496 -0
  53. package/dist/engineUrl.js +4 -2
  54. package/dist/eventLeg.js +3 -3
  55. package/dist/gateFailureCodes.js +2 -2
  56. package/dist/generated/sdkFactTables.d.ts +2 -1
  57. package/dist/generated/sdkFactTables.js +14 -0
  58. package/dist/generated/settingsSchemaFns.d.ts +1 -0
  59. package/dist/generated/settingsSchemaFns.js +3 -0
  60. package/dist/generated/settingsSchemaHooksClassifier.js +38 -9
  61. package/dist/generated/settingsSchemaTables.d.ts +56 -0
  62. package/dist/generated/settingsSchemaTables.js +19 -0
  63. package/dist/generated/settingsSchemaTypes.d.ts +23 -13
  64. package/dist/generated/settingsSchemaUrlShape.d.ts +1 -0
  65. package/dist/generated/settingsSchemaUrlShape.js +17 -0
  66. package/dist/hitl/approvalDelivery.d.ts +1 -0
  67. package/dist/hitl/approvalDelivery.js +1 -1
  68. package/dist/hitl/approvalResolution.d.ts +1 -1
  69. package/dist/hitl/approvalResolution.js +2 -1
  70. package/dist/hitl/askGateWire.js +5 -6
  71. package/dist/hitl/decisionRefusal.d.ts +6 -0
  72. package/dist/hitl/decisionRefusal.js +19 -10
  73. package/dist/hitl/decisionRefusalCarrier.d.ts +3 -0
  74. package/dist/hitl/decisionRefusalCarrier.js +348 -0
  75. package/dist/hitl/decisionSend.d.ts +7 -0
  76. package/dist/hitl/decisionSend.js +34 -12
  77. package/dist/hitl/editedApprovalAcceptance.js +1 -1
  78. package/dist/hitl/elicitationRefusal.d.ts +4 -0
  79. package/dist/hitl/elicitationRefusal.js +23 -0
  80. package/dist/hitl/frameRouter.d.ts +2 -2
  81. package/dist/hitl/frameRouter.js +8 -15
  82. package/dist/hitl/gateIdentity.d.ts +5 -0
  83. package/dist/hitl/gateIdentity.js +23 -0
  84. package/dist/hitl/hitlBridge.d.ts +6 -0
  85. package/dist/hitl/hitlBridge.js +10 -4
  86. package/dist/hitl/hitlHostSurface.d.ts +2 -1
  87. package/dist/hitl/hitlHostSurface.js +7 -2
  88. package/dist/hitl/localAllowRedemption.d.ts +70 -0
  89. package/dist/hitl/localAllowRedemption.js +276 -0
  90. package/dist/hitl/parkOwnership.js +2 -1
  91. package/dist/hitl/parkResolver.js +14 -4
  92. package/dist/hitl/persistedRulesWire.d.ts +16 -0
  93. package/dist/hitl/persistedRulesWire.js +70 -0
  94. package/dist/hitl/planReviewWire.d.ts +3 -0
  95. package/dist/hitl/planReviewWire.js +23 -6
  96. package/dist/hitl/policyDenyCause.d.ts +1 -1
  97. package/dist/hitl/policyDenyCause.js +1 -1
  98. package/dist/hitl/resumeRunningCard.d.ts +1 -0
  99. package/dist/hitl/resumeRunningCard.js +1 -0
  100. package/dist/hitl/screenCardCarriers.d.ts +15 -0
  101. package/dist/hitl/screenCardCarriers.js +41 -0
  102. package/dist/hitl/screenDecisionCards.d.ts +98 -0
  103. package/dist/hitl/screenDecisionCards.js +363 -0
  104. package/dist/hitl/sessionPolicyWire.js +2 -2
  105. package/dist/hitl/standingRows.d.ts +6 -2
  106. package/dist/hitl/standingRows.js +27 -2
  107. package/dist/hitl/toolApprovalWire.d.ts +30 -8
  108. package/dist/hitl/toolApprovalWire.js +264 -121
  109. package/dist/hooksReaderGenerations.js +1 -1
  110. package/dist/hooksWireCaps.js +3 -3
  111. package/dist/hostSettingNoticeArm.d.ts +3 -0
  112. package/dist/hostSettingNoticeArm.js +12 -0
  113. package/dist/hostTurnSettings.d.ts +3 -0
  114. package/dist/hostTurnSettings.js +38 -5
  115. package/dist/humanTurnRead.js +11 -1
  116. package/dist/i18n/messages.en.d.ts +292 -0
  117. package/dist/i18n/messages.en.js +298 -7
  118. package/dist/i18n/messages.zh.js +316 -6
  119. package/dist/i18n/translate.d.ts +3 -0
  120. package/dist/i18n/translate.js +78 -10
  121. package/dist/i18n/zh.d.ts +1 -0
  122. package/dist/i18n/zh.js +1 -0
  123. package/dist/index.d.ts +71 -20
  124. package/dist/index.js +44 -13
  125. package/dist/interactiveHalt.js +2 -1
  126. package/dist/interactiveInterrupt.js +20 -2
  127. package/dist/liveModelCatalog.d.ts +4 -0
  128. package/dist/liveModelCatalog.js +12 -3
  129. package/dist/localConfig/documents.d.ts +61 -0
  130. package/dist/localConfig/documents.js +51 -0
  131. package/dist/localConfig/kernel.d.ts +149 -0
  132. package/dist/localConfig/kernel.js +597 -0
  133. package/dist/localConfig/mcp/edit.d.ts +161 -0
  134. package/dist/localConfig/mcp/edit.js +846 -0
  135. package/dist/localConfig/mcp/servers.d.ts +165 -0
  136. package/dist/localConfig/mcp/servers.js +776 -0
  137. package/dist/localConfig/mcp/views.d.ts +170 -0
  138. package/dist/localConfig/mcp/views.js +429 -0
  139. package/dist/localConfig/modelPool.d.ts +262 -0
  140. package/dist/localConfig/modelPool.js +1489 -0
  141. package/dist/localConfig/modelPoolWords.d.ts +13 -0
  142. package/dist/localConfig/modelPoolWords.js +20 -0
  143. package/dist/localConfig/receiptShape.d.ts +7 -0
  144. package/dist/localConfig/receiptShape.js +135 -0
  145. package/dist/localConfig/settingsWrite.d.ts +127 -0
  146. package/dist/localConfig/settingsWrite.js +237 -0
  147. package/dist/localConfig/skills.d.ts +124 -0
  148. package/dist/localConfig/skills.js +397 -0
  149. package/dist/localConfig/skillsWords.d.ts +10 -0
  150. package/dist/localConfig/skillsWords.js +5 -0
  151. package/dist/localEngineSeatReading.d.ts +2 -2
  152. package/dist/localEngineSeatReading.js +5 -3
  153. package/dist/localEngineSpawn.d.ts +0 -7
  154. package/dist/localEngineSpawn.js +0 -92
  155. package/dist/localEngineStep.d.ts +2 -2
  156. package/dist/localEngineStep.js +2 -0
  157. package/dist/mcpProbeWire.js +2 -1
  158. package/dist/mcpReconnect.js +3 -3
  159. package/dist/mcpWireCaps.js +1 -1
  160. package/dist/memoryVerbsWire.js +3 -2
  161. package/dist/model/engineModelWords.d.ts +3 -0
  162. package/dist/model/engineModelWords.js +13 -0
  163. package/dist/model/onboardJudgement.d.ts +14 -4
  164. package/dist/model/onboardJudgement.js +91 -139
  165. package/dist/model/subagentModelWord.d.ts +21 -2
  166. package/dist/model/subagentModelWord.js +100 -29
  167. package/dist/modelCapabilityProbe.js +3 -40
  168. package/dist/modelConfigGapNotice.d.ts +20 -0
  169. package/dist/modelConfigGapNotice.js +102 -0
  170. package/dist/modsKernelIdentity.js +2 -47
  171. package/dist/notifications.d.ts +19 -0
  172. package/dist/notifications.js +114 -12
  173. package/dist/ownKey.d.ts +7 -0
  174. package/dist/ownKey.js +71 -8
  175. package/dist/pendingUserRow.d.ts +4 -0
  176. package/dist/pendingUserRow.js +16 -0
  177. package/dist/permissionsDeclaration.d.ts +3 -1
  178. package/dist/permissionsDeclaration.js +33 -9
  179. package/dist/planReviewCardFacts.d.ts +3 -0
  180. package/dist/planReviewCardFacts.js +52 -2
  181. package/dist/pluginHooksWire.d.ts +9 -1
  182. package/dist/pluginHooksWire.js +40 -6
  183. package/dist/printToolResultFrame.js +4 -2
  184. package/dist/promptBlockedCopy.js +12 -7
  185. package/dist/promptSuggestionBatch.d.ts +7 -0
  186. package/dist/promptSuggestionBatch.js +9 -0
  187. package/dist/promptSuggestionsTail.d.ts +39 -0
  188. package/dist/promptSuggestionsTail.js +116 -0
  189. package/dist/request/taskRequest.js +10 -6
  190. package/dist/requestCoordinate.d.ts +1 -0
  191. package/dist/requestCoordinate.js +13 -0
  192. package/dist/resumeRefusalCopy.d.ts +3 -1
  193. package/dist/resumeRefusalCopy.js +12 -4
  194. package/dist/rewindArchiveReading.js +4 -4
  195. package/dist/runCancelContext.d.ts +2 -1
  196. package/dist/runCancelContext.js +1 -0
  197. package/dist/runLedgerSnapshot.js +3 -3
  198. package/dist/runPermissionModeSwitch.js +3 -4
  199. package/dist/scenarioRefusal.js +11 -13
  200. package/dist/scenarioSkills.js +11 -6
  201. package/dist/seam.d.ts +16 -2
  202. package/dist/seam.js +10 -0
  203. package/dist/seatContract.d.ts +259 -9
  204. package/dist/seatContract.js +444 -15
  205. package/dist/sessionCostReading.d.ts +70 -0
  206. package/dist/sessionCostReading.js +150 -0
  207. package/dist/sessionHooksRoster.d.ts +4 -0
  208. package/dist/sessionHooksRoster.js +158 -0
  209. package/dist/sessionIdSegment.d.ts +1 -0
  210. package/dist/sessionIdSegment.js +4 -1
  211. package/dist/sessionMemoryErase.js +2 -1
  212. package/dist/sessionMemoryStatus.js +2 -2
  213. package/dist/sessionReadRedaction.d.ts +7 -0
  214. package/dist/sessionReadRedaction.js +26 -0
  215. package/dist/sessionSyncFileHistory.js +8 -9
  216. package/dist/settingsHooksSalvage.js +2 -1
  217. package/dist/sha256Bytes.d.ts +1 -0
  218. package/dist/sha256Bytes.js +46 -0
  219. package/dist/skillOverrideChain.d.ts +83 -0
  220. package/dist/skillOverrideChain.js +378 -0
  221. package/dist/skillsWireCaps.d.ts +3 -0
  222. package/dist/skillsWireCaps.js +16 -1
  223. package/dist/sseIdleTriage.js +2 -1
  224. package/dist/storeDurabilityWord.d.ts +15 -0
  225. package/dist/storeDurabilityWord.js +18 -0
  226. package/dist/storePostureCapability.d.ts +7 -3
  227. package/dist/storePostureCapability.js +69 -39
  228. package/dist/subagent/engineSubagentResume.js +2 -2
  229. package/dist/subagent/engineSubagentTail.js +2 -1
  230. package/dist/subagentContentStore.d.ts +11 -0
  231. package/dist/subagentContentStore.js +28 -2
  232. package/dist/toolResult.d.ts +1 -0
  233. package/dist/toolResult.js +2 -0
  234. package/dist/turnFailurePresentation.js +4 -10
  235. package/dist/userAttachmentEnvelope.d.ts +2 -1
  236. package/dist/userAttachmentEnvelope.js +10 -0
  237. package/dist/wireErrorTriage.js +2 -1
  238. package/dist/wireFailureShape.d.ts +4 -0
  239. package/dist/wireFailureShape.js +141 -19
  240. package/dist/wireRefusalCopy.d.ts +6 -5
  241. package/dist/wireRefusalCopy.js +49 -92
  242. package/docs/INTEGRATION-CLIENTS.md +2718 -17
  243. package/package.json +7 -3
@@ -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,6 @@
1
1
  import { type GateOutcomeView } from './gateOutcome.js';
2
2
  import { type ResumeReopenDetail } from './hitl/suspendedReopen.js';
3
+ import { ASK_GONE } from './engineErrorCodes.js';
3
4
  import { type CrashConvergedRowReading } from './hitl/crashConverged.js';
4
5
  import type { AskRowEndingCause } from '@sema-agent/sdk';
5
6
  import { SDK_DECIDE_BINDING_KEYS } from './generated/sdkFactTables.js';
@@ -41,7 +42,7 @@ export interface DecideRequiresBindingDetail {
41
42
  export declare function decideRequiresBindingFromError(e: {} | null | undefined): DecideRequiresBindingDetail | null;
42
43
  export declare function decideRequiresBindingContent(_detail?: DecideRequiresBindingDetail, lang?: UiLanguage | (string & {})): string;
43
44
  export interface AskGoneDetail {
44
- code: 'gone.ask';
45
+ code: typeof ASK_GONE;
45
46
  state?: 'VOID' | 'DENIED';
46
47
  endingCause?: AskRowEndingCause;
47
48
  holderGone?: CrashConvergedRowReading['cause'];
@@ -1,5 +1,6 @@
1
1
  import { atMostOnceVerdictOf } from './atMostOnce.js';
2
2
  import { readOwnDataValue } from './ownKey.js';
3
+ import { LIMIT_RATE_EXCEEDED } from './engineErrorCodes.js';
3
4
  import { isDisplayableWireCode, readErrorString, readErrorStrictStringList, readThrownSlot, wireFailureShapeOf } from './wireFailureShape.js';
4
5
  import { EXECUTION_PLACEMENT_DEVICE_LANE, EXECUTION_PLACEMENT_ROLES } from './executionPlacementWords.js';
5
6
  const LANE_ABSENT = 'capability.device_lane_required';
@@ -308,7 +309,6 @@ export function rebindProvesRequestNotApplied(outcome) {
308
309
  return false;
309
310
  }
310
311
  }
311
- const RATE_LIMITED = 'limit.rate_exceeded';
312
312
  const ENROLLMENT_INVALID = 'device.enrollment_invalid';
313
313
  function rateLimitedOf(e) {
314
314
  const sec = wireFailureShapeOf(e).retryAfterSec;
@@ -329,7 +329,7 @@ function issueFailureOf(e) {
329
329
  const common = commonOf(v.status, v.code);
330
330
  if (common !== null)
331
331
  return common.kind === 'not-found' ? refusedOf(404, NOT_FOUND, e) : common;
332
- if (v.status === 429 && v.code === RATE_LIMITED)
332
+ if (v.status === 429 && v.code === LIMIT_RATE_EXCEEDED)
333
333
  return rateLimitedOf(e);
334
334
  return v.status !== undefined ? refusedOf(v.status, v.code, e) : transportOf(v);
335
335
  }
@@ -359,7 +359,7 @@ function enrollFailureOf(e, token) {
359
359
  return common.kind === 'not-found' ? refusedOf(404, NOT_FOUND, e, token) : common;
360
360
  if (v.status === 403 && v.code === ENROLLMENT_INVALID)
361
361
  return { kind: 'enrollment-invalid' };
362
- if (v.status === 429 && v.code === RATE_LIMITED)
362
+ if (v.status === 429 && v.code === LIMIT_RATE_EXCEEDED)
363
363
  return rateLimitedOf(e);
364
364
  if (v.status === 503 && v.code === SERVICE_TOKEN_REQUIRED)
365
365
  return refusedOf(v.status, v.code, e, token);
@@ -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;
@@ -5236,6 +5236,12 @@ export function displayUntrusted(text, opts = {}) {
5236
5236
  const out = renderUntrusted(text, opts, null);
5237
5237
  return typeof out === 'string' ? out : out.tracked.text;
5238
5238
  }
5239
+ export function displayUntrustedCapped(text, max, opts = {}) {
5240
+ const whole = displayUntrusted(text, opts);
5241
+ if (typeof max !== 'number' || !Number.isFinite(max) || whole.length <= max)
5242
+ return whole;
5243
+ return `${displayUntrusted(text, { ...opts, max })}…`;
5244
+ }
5239
5245
  export function cleanUntrustedScalar(v) {
5240
5246
  return displayUntrusted(String(v ?? ''), { credentialUrls: false, credentialWords: false, foldLines: false });
5241
5247
  }
@@ -30,3 +30,12 @@ export interface EffectiveMemoryScopesView {
30
30
  }
31
31
  export declare function readEffectiveReasoning(v: unknown): EffectiveReasoningView | undefined;
32
32
  export declare function readEffectiveMemoryScopes(v: unknown): EffectiveMemoryScopesView | undefined;
33
+ export type ReadDenyFloorReading = {
34
+ readonly kind: 'unkept';
35
+ readonly message: string;
36
+ } | {
37
+ readonly kind: 'not_reported';
38
+ } | {
39
+ readonly kind: 'unreadable';
40
+ };
41
+ export declare function readDenyFloorOf(result: {} | null | undefined): ReadDenyFloorReading;
@@ -1,3 +1,4 @@
1
+ import { READ_DENY_FLOOR_UNKEPT } from './engineErrorCodes.js';
1
2
  const nonEmpty = (v) => typeof v === 'string' && v.length > 0;
2
3
  const nonBlank = (v) => typeof v === 'string' && v.trim().length > 0;
3
4
  const UNREADABLE = Symbol('unreadable');
@@ -104,3 +105,35 @@ export function readEffectiveMemoryScopes(v) {
104
105
  return undefined;
105
106
  return { state: 'none', reason, scopes: [], writeScope: null };
106
107
  }
108
+ const DENY_FLOOR_NOT_REPORTED = Object.freeze({ kind: 'not_reported' });
109
+ const DENY_FLOOR_UNREADABLE = Object.freeze({ kind: 'unreadable' });
110
+ function ownSlotOf(o, key) {
111
+ const d = Object.getOwnPropertyDescriptor(o, key);
112
+ if (d === undefined)
113
+ return { absent: true };
114
+ if (!Object.hasOwn(d, 'value'))
115
+ throw new TypeError('accessor');
116
+ return { absent: false, value: d.value };
117
+ }
118
+ export function readDenyFloorOf(result) {
119
+ try {
120
+ if (typeof result !== 'object' || result === null)
121
+ return DENY_FLOOR_NOT_REPORTED;
122
+ const slot = ownSlotOf(result, 'readDenyFloor');
123
+ if (slot.absent || slot.value === undefined)
124
+ return DENY_FLOOR_NOT_REPORTED;
125
+ const v = slot.value;
126
+ if (typeof v !== 'object' || v === null || Array.isArray(v))
127
+ return DENY_FLOOR_UNREADABLE;
128
+ const code = ownSlotOf(v, 'code');
129
+ const message = ownSlotOf(v, 'message');
130
+ if (code.absent || code.value !== READ_DENY_FLOOR_UNKEPT)
131
+ return DENY_FLOOR_UNREADABLE;
132
+ if (message.absent || typeof message.value !== 'string' || message.value.length === 0)
133
+ return DENY_FLOOR_UNREADABLE;
134
+ return Object.freeze({ kind: 'unkept', message: message.value });
135
+ }
136
+ catch {
137
+ return DENY_FLOOR_UNREADABLE;
138
+ }
139
+ }
@@ -1,3 +1,4 @@
1
+ export declare function hasUnsafeAddressCharacter(s: string): boolean;
1
2
  export declare function tupleOriginUrlOf(raw: string): URL | undefined;
2
3
  export declare function carriesNoCredentialSlots(u: URL): boolean;
3
4
  export declare function isCenterRelativePath(path: string): boolean;
@@ -1,3 +1,6 @@
1
+ export function hasUnsafeAddressCharacter(s) {
2
+ return /[\s\u0000-\u001f\u007f-\u009f\\]/u.test(s);
3
+ }
1
4
  export function tupleOriginUrlOf(raw) {
2
5
  try {
3
6
  const u = new URL(raw);
@@ -16,7 +19,7 @@ export function isCenterRelativePath(path) {
16
19
  const second = path.charCodeAt(1);
17
20
  if (second === 0x2f || second === 0x5c)
18
21
  return false;
19
- if (/[\s\u0000-\u001f\u007f-\u009f\\?#]/u.test(path))
22
+ if (hasUnsafeAddressCharacter(path) || path.includes('?') || path.includes('#'))
20
23
  return false;
21
24
  return path.split('/').every((segment) => {
22
25
  const decoded = segment.replace(/%2e/gi, '.');
@@ -0,0 +1,54 @@
1
+ import type { AgentClient } from '@sema-agent/sdk';
2
+ import { type EngineIdentityView } from './engineIdentity.js';
3
+ import type { LocalEngineVerdict } from './localEngineJudge.js';
4
+ type OwnershipMismatchWhich = Extract<LocalEngineVerdict, {
5
+ kind: 'stranger';
6
+ }>['mismatch'];
7
+ export type LocalEngineIdentityVerdict = {
8
+ readonly kind: 'match';
9
+ readonly identity: EngineIdentityView;
10
+ readonly provenAt?: number;
11
+ } | {
12
+ readonly kind: 'mismatch';
13
+ readonly which: OwnershipMismatchWhich;
14
+ } | {
15
+ readonly kind: 'unreadable';
16
+ };
17
+ export type EngineCredentialTransport = {
18
+ readonly reuse: 'none';
19
+ readonly fetch: typeof fetch;
20
+ } | {
21
+ readonly reuse: 'generation';
22
+ readonly fetch: typeof fetch;
23
+ readonly boundTo: EngineIdentityView;
24
+ readonly openedAt: number;
25
+ };
26
+ export interface EngineCredentialReleaseInput {
27
+ readonly ownership: LocalEngineIdentityVerdict;
28
+ readonly transport?: EngineCredentialTransport;
29
+ }
30
+ export type EngineCredentialWithholdReason = 'ownership_unreadable' | 'ownership_mismatch' | 'transport_undeclared' | 'transport_predates_proof' | 'transport_generation_unreadable';
31
+ export declare const ENGINE_CREDENTIAL_WITHHOLD_REASONS: readonly EngineCredentialWithholdReason[];
32
+ export type EngineCredentialReleaseVerdict = {
33
+ readonly kind: 'present';
34
+ readonly identity: 'proven';
35
+ } | {
36
+ readonly kind: 'withhold';
37
+ readonly identity: 'unproven';
38
+ readonly reason: EngineCredentialWithholdReason;
39
+ readonly retireTransport: boolean;
40
+ };
41
+ export interface LocalEngineWireClientConfig extends EngineCredentialReleaseInput {
42
+ readonly baseUrl: string;
43
+ readonly token?: string;
44
+ readonly principal?: string;
45
+ readonly timeoutMs?: number;
46
+ readonly maxRetries?: number;
47
+ }
48
+ export interface LocalEngineWireClient {
49
+ readonly client: AgentClient | null;
50
+ readonly release: EngineCredentialReleaseVerdict;
51
+ }
52
+ export declare function engineCredentialReleaseVerdictOf(input: EngineCredentialReleaseInput): EngineCredentialReleaseVerdict;
53
+ export declare function makeLocalEngineWireClient(cfg: LocalEngineWireClientConfig): LocalEngineWireClient;
54
+ export {};
@@ -0,0 +1,146 @@
1
+ import { engineIdentityOf, engineIdentityVerdict } from './engineIdentity.js';
2
+ import { makeEngineWireClient } from './engineWireSdk.js';
3
+ import { readOwnDataValue } from './ownKey.js';
4
+ export const ENGINE_CREDENTIAL_WITHHOLD_REASONS = Object.freeze([
5
+ 'ownership_unreadable',
6
+ 'ownership_mismatch',
7
+ 'transport_undeclared',
8
+ 'transport_predates_proof',
9
+ 'transport_generation_unreadable',
10
+ ]);
11
+ const MISMATCH_WHICH = Object.freeze(['pid', 'generation', 'data-root']);
12
+ const _whichIsJudgeVocabulary = [true, true];
13
+ void _whichIsJudgeVocabulary;
14
+ function isRecord(v) {
15
+ if (typeof v !== 'object' || v === null)
16
+ return false;
17
+ try {
18
+ return !Array.isArray(v);
19
+ }
20
+ catch {
21
+ return false;
22
+ }
23
+ }
24
+ function own(v, key) {
25
+ if (!isRecord(v))
26
+ return undefined;
27
+ try {
28
+ return readOwnDataValue(v, key);
29
+ }
30
+ catch {
31
+ return undefined;
32
+ }
33
+ }
34
+ function identityOwn(v) {
35
+ return engineIdentityOf({ pid: own(v, 'pid'), instanceId: own(v, 'instanceId'), startedAt: own(v, 'startedAt') });
36
+ }
37
+ function isMoment(v) {
38
+ return typeof v === 'number' && Number.isFinite(v) && v >= 0;
39
+ }
40
+ function globalFetch() {
41
+ try {
42
+ return globalThis.fetch;
43
+ }
44
+ catch {
45
+ return undefined;
46
+ }
47
+ }
48
+ function declaredFetch(t) {
49
+ const f = own(t, 'fetch');
50
+ return typeof f === 'function' && f !== globalFetch() ? f : undefined;
51
+ }
52
+ function reuseOf(t) {
53
+ if (declaredFetch(t) === undefined)
54
+ return undefined;
55
+ const r = own(t, 'reuse');
56
+ return r === 'none' || r === 'generation' ? r : undefined;
57
+ }
58
+ function withhold(reason, retireTransport) {
59
+ return Object.freeze({ kind: 'withhold', identity: 'unproven', reason, retireTransport });
60
+ }
61
+ function present() {
62
+ return Object.freeze({ kind: 'present', identity: 'proven' });
63
+ }
64
+ function judge(input) {
65
+ const ownership = own(input, 'ownership');
66
+ const transport = own(input, 'transport');
67
+ const reuse = reuseOf(transport);
68
+ const kind = own(ownership, 'kind');
69
+ if (kind === 'mismatch') {
70
+ const which = own(ownership, 'which');
71
+ return MISMATCH_WHICH.includes(which) ? withhold('ownership_mismatch', reuse === 'generation') : withhold('ownership_unreadable', false);
72
+ }
73
+ const identity = own(ownership, 'identity');
74
+ if (kind !== 'match' || !isRecord(identity))
75
+ return withhold('ownership_unreadable', false);
76
+ if (reuse === undefined)
77
+ return withhold('transport_undeclared', false);
78
+ if (reuse === 'none')
79
+ return present();
80
+ const boundTo = own(transport, 'boundTo');
81
+ const same = isRecord(boundTo) ? engineIdentityVerdict(identityOwn(boundTo), identityOwn(identity)) : 'unknown';
82
+ if (same === 'changed')
83
+ return withhold('transport_predates_proof', true);
84
+ const provenAt = own(ownership, 'provenAt');
85
+ const openedAt = own(transport, 'openedAt');
86
+ if (same !== 'same' || !isMoment(provenAt) || !isMoment(openedAt))
87
+ return withhold('transport_generation_unreadable', true);
88
+ return openedAt >= provenAt ? present() : withhold('transport_predates_proof', true);
89
+ }
90
+ export function engineCredentialReleaseVerdictOf(input) {
91
+ try {
92
+ return judge(input);
93
+ }
94
+ catch {
95
+ return withhold('ownership_unreadable', false);
96
+ }
97
+ }
98
+ function anchorsOf(v) {
99
+ if (!isRecord(v))
100
+ return undefined;
101
+ return Object.freeze({ pid: own(v, 'pid'), instanceId: own(v, 'instanceId'), startedAt: own(v, 'startedAt') });
102
+ }
103
+ function sampleRelease(cfg) {
104
+ try {
105
+ const o = own(cfg, 'ownership');
106
+ const t = own(cfg, 'transport');
107
+ const fetchImpl = declaredFetch(t);
108
+ const ownership = isRecord(o)
109
+ ? Object.freeze({ kind: own(o, 'kind'), which: own(o, 'which'), identity: anchorsOf(own(o, 'identity')), provenAt: own(o, 'provenAt') })
110
+ : undefined;
111
+ const transport = isRecord(t)
112
+ ? Object.freeze({ reuse: own(t, 'reuse'), fetch: fetchImpl, boundTo: anchorsOf(own(t, 'boundTo')), openedAt: own(t, 'openedAt') })
113
+ : undefined;
114
+ return Object.freeze({ input: Object.freeze({ ownership, transport }), fetchImpl });
115
+ }
116
+ catch {
117
+ return Object.freeze({ input: Object.freeze({ ownership: undefined, transport: undefined }), fetchImpl: undefined });
118
+ }
119
+ }
120
+ export function makeLocalEngineWireClient(cfg) {
121
+ const sample = sampleRelease(cfg);
122
+ const release = engineCredentialReleaseVerdictOf(sample.input);
123
+ let client = null;
124
+ try {
125
+ const baseUrl = own(cfg, 'baseUrl');
126
+ if (typeof baseUrl === 'string') {
127
+ const token = own(cfg, 'token');
128
+ const principal = own(cfg, 'principal');
129
+ const timeoutMs = own(cfg, 'timeoutMs');
130
+ const maxRetries = own(cfg, 'maxRetries');
131
+ const fetchImpl = sample.fetchImpl;
132
+ client = makeEngineWireClient({
133
+ baseUrl,
134
+ ...(release.kind === 'present' && fetchImpl !== undefined && typeof token === 'string' && token !== '' ? { token } : {}),
135
+ ...(typeof principal === 'string' ? { principal } : {}),
136
+ ...(typeof timeoutMs === 'number' ? { timeoutMs } : {}),
137
+ ...(typeof maxRetries === 'number' ? { maxRetries } : {}),
138
+ ...(fetchImpl !== undefined ? { fetchImpl } : {}),
139
+ });
140
+ }
141
+ }
142
+ catch {
143
+ client = null;
144
+ }
145
+ return Object.freeze({ client, release });
146
+ }
@@ -165,6 +165,7 @@ export declare function isWorkflowParkRefusalCode(code: unknown): boolean;
165
165
  export declare const DRAINING_ERROR_CODE = "draining";
166
166
  export declare const SCENARIO_NOT_ALLOWED_ERROR_CODE = "scenario_not_allowed";
167
167
  export declare const SCENARIO_ASSIGNMENT_UNKNOWN_ERROR_CODE = "state.scenario_assignment_unknown";
168
+ export declare const READ_DENY_FLOOR_UNKEPT = "config.read_deny_floor_unkept";
168
169
  export declare const USER_ATTACHMENT_INVALID_ERROR_CODE = "config.user_attachment_invalid";
169
170
  export declare const USER_INVOKED_SKILL_UNKNOWN_ERROR_CODE = "config.user_invoked_skill_unknown";
170
171
  export declare const STREAM_MAX_DURATION = "STREAM_MAX_DURATION";
@@ -306,6 +306,7 @@ export function isWorkflowParkRefusalCode(code) {
306
306
  export const DRAINING_ERROR_CODE = 'draining';
307
307
  export const SCENARIO_NOT_ALLOWED_ERROR_CODE = 'scenario_not_allowed';
308
308
  export const SCENARIO_ASSIGNMENT_UNKNOWN_ERROR_CODE = 'state.scenario_assignment_unknown';
309
+ export const READ_DENY_FLOOR_UNKEPT = 'config.read_deny_floor_unkept';
309
310
  export const USER_ATTACHMENT_INVALID_ERROR_CODE = 'config.user_attachment_invalid';
310
311
  export const USER_INVOKED_SKILL_UNKNOWN_ERROR_CODE = 'config.user_invoked_skill_unknown';
311
312
  export const STREAM_MAX_DURATION = 'STREAM_MAX_DURATION';
@@ -0,0 +1,24 @@
1
+ import type { UiLanguage } from './env/uiLanguage.js';
2
+ import type { ProbeHealthResult } from '@sema-agent/sdk';
3
+ export type HealthProbeUnansweredReason = 'timeout' | 'network';
4
+ export type HealthProbeNotOkReason = 'http' | 'not_ok';
5
+ export interface HealthProbeAnsweredNotOk {
6
+ readonly kind: 'answered_not_ok';
7
+ readonly reason: HealthProbeNotOkReason;
8
+ readonly http: number;
9
+ readonly status?: string;
10
+ }
11
+ export type HealthProbeVerdict = {
12
+ readonly kind: 'unanswered';
13
+ readonly reason: HealthProbeUnansweredReason;
14
+ } | {
15
+ readonly kind: 'answered_ok';
16
+ } | HealthProbeAnsweredNotOk;
17
+ export interface TimedHealthAnswer {
18
+ readonly answer: HealthProbeAnsweredNotOk;
19
+ readonly atMs: number;
20
+ }
21
+ export declare function classifyHealthProbe(reading: ProbeHealthResult): HealthProbeVerdict | undefined;
22
+ export declare function healthProbeVerdictOf(v: {} | null | undefined): HealthProbeVerdict | undefined;
23
+ export declare function healthAnswerClause(verdict: HealthProbeVerdict, lang?: UiLanguage): string | undefined;
24
+ export declare function latestSegmentHealthAnswer(segmentStartMs: number | undefined, ...seen: ReadonlyArray<TimedHealthAnswer | undefined>): HealthProbeAnsweredNotOk | undefined;
@@ -0,0 +1,123 @@
1
+ import { displayUntrusted } from './displayUntrusted.js';
2
+ import { msg, renderMessage } from './i18n/translate.js';
3
+ import { slotReadOf } from './wireFailureShape.js';
4
+ const UNANSWERED_REASONS = new Set(['timeout', 'network']);
5
+ const NOT_OK_REASONS = new Set(['http', 'not_ok']);
6
+ const REPORTED_STATUS_SHOWN_MAX = 64;
7
+ function ownValue(o, key) {
8
+ const r = slotReadOf(o, key);
9
+ return r.presence === 'present' ? r.value : undefined;
10
+ }
11
+ function isHttpCode(v) {
12
+ return typeof v === 'number' && Number.isInteger(v) && v >= 100 && v <= 599;
13
+ }
14
+ function shownStatusOf(v) {
15
+ if (typeof v !== 'string')
16
+ return undefined;
17
+ const shown = displayUntrusted(v, { max: REPORTED_STATUS_SHOWN_MAX });
18
+ return shown.trim() === '' ? undefined : shown;
19
+ }
20
+ function answeredNotOk(reason, http, status) {
21
+ return Object.freeze({ kind: 'answered_not_ok', reason, http, ...(status !== undefined ? { status } : {}) });
22
+ }
23
+ export function classifyHealthProbe(reading) {
24
+ try {
25
+ if (typeof reading !== 'object' || reading === null)
26
+ return undefined;
27
+ const alive = ownValue(reading, 'alive');
28
+ if (alive === true)
29
+ return Object.freeze({ kind: 'answered_ok' });
30
+ if (alive !== false)
31
+ return undefined;
32
+ const reason = ownValue(reading, 'reason');
33
+ if (typeof reason !== 'string')
34
+ return undefined;
35
+ if (UNANSWERED_REASONS.has(reason))
36
+ return Object.freeze({ kind: 'unanswered', reason: reason });
37
+ if (!NOT_OK_REASONS.has(reason))
38
+ return undefined;
39
+ const http = ownValue(reading, 'status');
40
+ if (!isHttpCode(http))
41
+ return undefined;
42
+ return answeredNotOk(reason, http, reason === 'not_ok' ? shownStatusOf(ownValue(reading, 'reportedStatus')) : undefined);
43
+ }
44
+ catch {
45
+ return undefined;
46
+ }
47
+ }
48
+ function answeredNotOkOf(v) {
49
+ if (typeof v !== 'object' || v === null)
50
+ return undefined;
51
+ if (ownValue(v, 'kind') !== 'answered_not_ok')
52
+ return undefined;
53
+ const reason = ownValue(v, 'reason');
54
+ const http = ownValue(v, 'http');
55
+ if (typeof reason !== 'string' || !NOT_OK_REASONS.has(reason) || !isHttpCode(http))
56
+ return undefined;
57
+ return answeredNotOk(reason, http, shownStatusOf(ownValue(v, 'status')));
58
+ }
59
+ export function healthProbeVerdictOf(v) {
60
+ try {
61
+ if (typeof v !== 'object' || v === null)
62
+ return undefined;
63
+ const kind = ownValue(v, 'kind');
64
+ if (kind === 'answered_ok')
65
+ return Object.freeze({ kind: 'answered_ok' });
66
+ if (kind === 'unanswered') {
67
+ const reason = ownValue(v, 'reason');
68
+ return typeof reason === 'string' && UNANSWERED_REASONS.has(reason) ? Object.freeze({ kind: 'unanswered', reason: reason }) : undefined;
69
+ }
70
+ return answeredNotOkOf(v);
71
+ }
72
+ catch {
73
+ return undefined;
74
+ }
75
+ }
76
+ export function healthAnswerClause(verdict, lang) {
77
+ try {
78
+ const v = healthProbeVerdictOf(verdict);
79
+ if (v === undefined)
80
+ return undefined;
81
+ if (v.kind === 'answered_ok')
82
+ return renderMessage(msg('localEngine.health.answer.ok'), lang);
83
+ if (v.kind === 'unanswered')
84
+ return renderMessage(msg(v.reason === 'timeout' ? 'localEngine.health.answer.unansweredTimeout' : 'localEngine.health.answer.unansweredNetwork'), lang);
85
+ return renderMessage(msg(v.reason === 'not_ok' ? 'localEngine.health.answer.notOkStatus' : 'localEngine.health.answer.notOkHttp', { http: v.http }), lang);
86
+ }
87
+ catch {
88
+ return undefined;
89
+ }
90
+ }
91
+ function timedNotOkOf(s, start, bestAtMs) {
92
+ try {
93
+ if (typeof s !== 'object' || s === null)
94
+ return { kind: 'not_better' };
95
+ const atMs = ownValue(s, 'atMs');
96
+ if (typeof atMs !== 'number' || !Number.isFinite(atMs))
97
+ return { kind: 'not_better' };
98
+ if (start !== undefined && atMs < start)
99
+ return { kind: 'not_better' };
100
+ if (bestAtMs !== undefined && atMs <= bestAtMs)
101
+ return { kind: 'not_better' };
102
+ const answer = answeredNotOkOf(ownValue(s, 'answer'));
103
+ return answer === undefined ? { kind: 'not_better' } : { kind: 'better', entry: { atMs, answer } };
104
+ }
105
+ catch {
106
+ return { kind: 'unreadable' };
107
+ }
108
+ }
109
+ export function latestSegmentHealthAnswer(segmentStartMs, ...seen) {
110
+ try {
111
+ const start = typeof segmentStartMs === 'number' && Number.isFinite(segmentStartMs) ? segmentStartMs : undefined;
112
+ let best;
113
+ for (const s of seen) {
114
+ const r = timedNotOkOf(s, start, best?.atMs);
115
+ if (r.kind === 'better')
116
+ best = r.entry;
117
+ }
118
+ return best?.answer;
119
+ }
120
+ catch {
121
+ return undefined;
122
+ }
123
+ }
@@ -1,8 +1,8 @@
1
1
  import { AUTO_MODE_UNAVAILABLE_CAUSES } from './autoModeUnavailable.js';
2
- import { displayUntrusted } from './displayUntrusted.js';
2
+ import { displayUntrusted, displayUntrustedCapped } from './displayUntrusted.js';
3
3
  import { CORE_ENGINE_NOTICE_CODES, CORE_MCP_INJECTION_DROP_REASONS, CORE_NOTICE_AUDIENCE, CORE_USER_INPUT_UNDRAINED_FAMILIES, } from './generated/engineNoticeTables.js';
4
4
  import { CORE_APPROVAL_REMEDY_KINDS, CORE_ASK_UNRESOLVABLE_CAUSES, CORE_DISCARDED_DELIVERY_PATHS, CORE_DURABLE_MANDATE_SOURCES, CORE_PERMISSION_MODE_FOLD_REASONS, } from './generated/engineFactTables.js';
5
- import { msg, renderMessage } from './i18n/translate.js';
5
+ import { msg, renderLanguageOf, renderMessage } from './i18n/translate.js';
6
6
  import { ownDataField, readOwnDataValue } from './ownKey.js';
7
7
  import { inValueOf, slotReadOf } from './wireFailureShape.js';
8
8
  export const ENGINE_NOTICE_CODES = CORE_ENGINE_NOTICE_CODES;
@@ -196,7 +196,6 @@ function readAskUnresolvableOf(notice) {
196
196
  };
197
197
  }
198
198
  export const DURABLE_MANDATE_SOURCES = CORE_DURABLE_MANDATE_SOURCES;
199
- const DURABLE_MANDATE_SOURCE_SET = new Set(DURABLE_MANDATE_SOURCES);
200
199
  export function readDurableGateUnavailable(notice) {
201
200
  if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
202
201
  return undefined;
@@ -213,7 +212,7 @@ export function readDurableGateUnavailable(notice) {
213
212
  const causeIn = o.cause;
214
213
  const sessionId = typeof sessionIdIn === 'string' && sessionIdIn.length > 0 ? sessionIdIn : undefined;
215
214
  const runId = typeof runIdIn === 'string' && runIdIn.length > 0 ? runIdIn : undefined;
216
- const source = typeof sourceIn === 'string' && DURABLE_MANDATE_SOURCE_SET.has(sourceIn) ? sourceIn : undefined;
215
+ const source = typeof sourceIn === 'string' && sourceIn.length > 0 ? sourceIn : undefined;
217
216
  const cause = typeof causeIn === 'string' && causeIn.length > 0 ? causeIn : undefined;
218
217
  if (sessionId === undefined || runId === undefined || source === undefined || cause === undefined) {
219
218
  return undefined;
@@ -1417,15 +1416,14 @@ function shownName(v) {
1417
1416
  function shownText(v, max) {
1418
1417
  if (v === undefined)
1419
1418
  return undefined;
1420
- const whole = displayUntrusted(v);
1421
- const s = whole.length <= max ? whole : `${displayUntrusted(v, { max: max - 1 })}…`;
1419
+ const s = displayUntrustedCapped(v, max);
1422
1420
  return s.length > 0 ? s : undefined;
1423
1421
  }
1424
1422
  function wordLookup(table, word) {
1425
1423
  return Object.hasOwn(table, word) ? table[word] : undefined;
1426
1424
  }
1427
1425
  function joinSentences(parts, lang) {
1428
- return parts.filter((p) => p !== undefined && p.length > 0).join(lang === 'zh' ? '' : ' ');
1426
+ return parts.filter((p) => p !== undefined && p.length > 0).join(renderLanguageOf(lang) === 'zh' ? '' : ' ');
1429
1427
  }
1430
1428
  export function memorySessionPollutedSentence(facts, lang) {
1431
1429
  try {