@sema-agent/client-core 0.100.0 → 0.101.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 (335) hide show
  1. package/CHANGELOG.md +395 -0
  2. package/README.md +164 -117
  3. package/dist/adapt/arms.js +51 -16
  4. package/dist/adapt/textStream.js +7 -4
  5. package/dist/adapt/toolCards.js +9 -8
  6. package/dist/adapt.js +7 -1
  7. package/dist/adapter/activeRunSelfHeal.d.ts +24 -2
  8. package/dist/adapter/activeRunSelfHeal.js +108 -6
  9. package/dist/adapter/downstream/eventToSdkMessage.js +33 -12
  10. package/dist/adapter/downstream/terminalToSdkResult.d.ts +60 -1
  11. package/dist/adapter/downstream/terminalToSdkResult.js +209 -39
  12. package/dist/adapter/runStream.d.ts +4 -4
  13. package/dist/adapter/runStream.js +158 -43
  14. package/dist/agentsWireCaps.d.ts +2 -7
  15. package/dist/agentsWireCaps.js +1 -2
  16. package/dist/approvalDecidedByCapability.js +2 -2
  17. package/dist/approvalFrameFamilies.d.ts +33 -0
  18. package/dist/approvalFrameFamilies.js +120 -0
  19. package/dist/approvalsStreamLiveCapability.js +2 -2
  20. package/dist/attachmentsWireCaps.js +41 -13
  21. package/dist/callerCwdCapability.js +2 -2
  22. package/dist/centerWiringCapability.js +2 -2
  23. package/dist/clockReading.d.ts +2 -0
  24. package/dist/clockReading.js +4 -0
  25. package/dist/cloudConfigWireCaps.d.ts +19 -5
  26. package/dist/cloudConfigWireCaps.js +193 -56
  27. package/dist/coreValuePorts.d.ts +12 -2
  28. package/dist/coreValuePorts.js +9 -0
  29. package/dist/decideFailureNote.js +5 -3
  30. package/dist/decideReceipt.js +2 -2
  31. package/dist/deviceExecutorManagementCapability.js +2 -2
  32. package/dist/deviceFlowPolling.js +1 -1
  33. package/dist/disableSkillsWire.d.ts +1 -1
  34. package/dist/disableSkillsWire.js +4 -3
  35. package/dist/displayUntrusted.d.ts +1 -0
  36. package/dist/displayUntrusted.js +65 -8
  37. package/dist/engineCapReader.js +1 -1
  38. package/dist/engineConfigDrift.js +1 -1
  39. package/dist/engineErrorCodes.d.ts +14 -5
  40. package/dist/engineErrorCodes.js +27 -6
  41. package/dist/engineGenerationConvergence.d.ts +39 -0
  42. package/dist/engineGenerationConvergence.js +95 -0
  43. package/dist/engineGenerationPort.d.ts +61 -0
  44. package/dist/engineGenerationPort.js +144 -0
  45. package/dist/engineHealthFacts.d.ts +23 -0
  46. package/dist/engineHealthFacts.js +92 -0
  47. package/dist/engineIdentity.d.ts +4 -0
  48. package/dist/engineIdentity.js +11 -0
  49. package/dist/engineNoticeCodes.d.ts +2 -5
  50. package/dist/engineRowRef.js +3 -0
  51. package/dist/engineSessionMessages.js +2 -2
  52. package/dist/engineToolDirectory.js +2 -2
  53. package/dist/engineWireFor.d.ts +99 -0
  54. package/dist/engineWireFor.js +248 -6
  55. package/dist/engineWireTarget.d.ts +1 -0
  56. package/dist/engineWireTarget.js +8 -0
  57. package/dist/env/uiLanguage.js +1 -1
  58. package/dist/errorSupplementRoles.d.ts +3 -0
  59. package/dist/errorSupplementRoles.js +37 -0
  60. package/dist/executionLaneCapability.js +2 -2
  61. package/dist/fileHistoryCaptureCapability.js +3 -3
  62. package/dist/finalVerifyWire.d.ts +6 -3
  63. package/dist/finalVerifyWire.js +6 -23
  64. package/dist/flagInput.d.ts +4 -0
  65. package/dist/flagInput.js +24 -0
  66. package/dist/fleet/fleetLedger.js +5 -2
  67. package/dist/fleet/fleetProjection.d.ts +1 -0
  68. package/dist/fleet/fleetProjection.js +15 -2
  69. package/dist/gateVocabulary.js +3 -0
  70. package/dist/generated/engineFactTables.d.ts +7 -3
  71. package/dist/generated/engineFactTables.js +52 -0
  72. package/dist/generated/engineNoticeTables.js +12 -0
  73. package/dist/generated/settingsSchemaActiveTiers.d.ts +1 -0
  74. package/dist/generated/settingsSchemaActiveTiers.js +14 -0
  75. package/dist/generated/settingsSchemaCallerTextEcho.d.ts +1 -0
  76. package/dist/generated/settingsSchemaCallerTextEcho.js +8 -0
  77. package/dist/generated/settingsSchemaControlAndBidi.d.ts +1 -0
  78. package/dist/generated/settingsSchemaControlAndBidi.js +8 -0
  79. package/dist/generated/settingsSchemaDefaultModel.d.ts +11 -0
  80. package/dist/generated/settingsSchemaDefaultModel.js +25 -0
  81. package/dist/generated/settingsSchemaFns.d.ts +54 -0
  82. package/dist/generated/settingsSchemaFns.js +26 -1
  83. package/dist/generated/settingsSchemaMcpRequestEntry.d.ts +1 -1
  84. package/dist/generated/settingsSchemaMcpRequestEntry.js +1 -7
  85. package/dist/generated/settingsSchemaSafetyMergeSpec.d.ts +1 -0
  86. package/dist/generated/settingsSchemaSafetyMergeSpec.js +95 -0
  87. package/dist/generated/settingsSchemaSettingsSources.d.ts +1 -0
  88. package/dist/generated/settingsSchemaSettingsSources.js +58 -0
  89. package/dist/generated/settingsSchemaTables.d.ts +2 -0
  90. package/dist/generated/settingsSchemaTables.js +13 -0
  91. package/dist/generated/settingsSchemaUrlPattern.d.ts +1 -0
  92. package/dist/generated/settingsSchemaUrlPattern.js +183 -0
  93. package/dist/headlessPermissionModeWire.d.ts +18 -2
  94. package/dist/headlessPermissionModeWire.js +30 -19
  95. package/dist/hitl/allowRuleShadow.js +7 -5
  96. package/dist/hitl/approvalCardReading.d.ts +3 -0
  97. package/dist/hitl/approvalCardReading.js +17 -0
  98. package/dist/hitl/approvalCompleteParked.js +1 -1
  99. package/dist/hitl/approvalDelivery.d.ts +87 -0
  100. package/dist/hitl/approvalDelivery.js +193 -0
  101. package/dist/hitl/approvalResolution.d.ts +11 -0
  102. package/dist/hitl/approvalResolution.js +50 -11
  103. package/dist/hitl/askClassPair.d.ts +6 -0
  104. package/dist/hitl/askClassPair.js +30 -3
  105. package/dist/hitl/askParkAutoReopenBlock.d.ts +30 -0
  106. package/dist/hitl/askParkAutoReopenBlock.js +117 -0
  107. package/dist/hitl/askParkRowRouting.js +4 -1
  108. package/dist/hitl/attributionLadder.d.ts +42 -3
  109. package/dist/hitl/attributionLadder.js +79 -8
  110. package/dist/hitl/automaticAnswerVerdict.d.ts +6 -1
  111. package/dist/hitl/automaticAnswerVerdict.js +46 -11
  112. package/dist/hitl/crashConverged.js +2 -2
  113. package/dist/hitl/decisionConflict.d.ts +6 -2
  114. package/dist/hitl/decisionConflict.js +24 -9
  115. package/dist/hitl/decisionRefusal.d.ts +20 -10
  116. package/dist/hitl/decisionRefusal.js +99 -54
  117. package/dist/hitl/decisionSend.d.ts +3 -0
  118. package/dist/hitl/decisionSend.js +87 -103
  119. package/dist/hitl/frameRouter.d.ts +1 -0
  120. package/dist/hitl/frameRouter.js +9 -2
  121. package/dist/hitl/hitlBridge.d.ts +18 -6
  122. package/dist/hitl/hitlBridge.js +41 -37
  123. package/dist/hitl/livePendingAsk.js +4 -3
  124. package/dist/hitl/noAllowCause.js +1 -1
  125. package/dist/hitl/parkResolver.js +3 -2
  126. package/dist/hitl/persistedRulesWire.js +1 -0
  127. package/dist/hitl/planReviewWire.d.ts +4 -0
  128. package/dist/hitl/planReviewWire.js +59 -30
  129. package/dist/hitl/resumeRunningCard.d.ts +3 -2
  130. package/dist/hitl/resumeRunningCard.js +17 -11
  131. package/dist/hitl/sessionPolicyDeliverable.d.ts +5 -2
  132. package/dist/hitl/sessionPolicyDeliverable.js +62 -29
  133. package/dist/hitl/sessionPolicyWire.d.ts +13 -3
  134. package/dist/hitl/sessionPolicyWire.js +81 -16
  135. package/dist/hitl/standingRows.js +1 -1
  136. package/dist/hitl/toolApprovalWire.d.ts +9 -10
  137. package/dist/hitl/toolApprovalWire.js +72 -54
  138. package/dist/hookMatcherVerdict.d.ts +2 -0
  139. package/dist/hookMatcherVerdict.js +12 -0
  140. package/dist/hooksCompactTransition.d.ts +19 -0
  141. package/dist/hooksCompactTransition.js +41 -0
  142. package/dist/hooksWireCaps.d.ts +1 -1
  143. package/dist/hooksWireCaps.js +202 -203
  144. package/dist/host.d.ts +1 -14
  145. package/dist/host.js +0 -8
  146. package/dist/hostCallbackGuard.d.ts +1 -0
  147. package/dist/hostCallbackGuard.js +1 -1
  148. package/dist/hostSettingsSource.d.ts +172 -0
  149. package/dist/hostSettingsSource.js +675 -0
  150. package/dist/hostTurnSettings.d.ts +73 -17
  151. package/dist/hostTurnSettings.js +594 -97
  152. package/dist/httpHookPolicy.d.ts +37 -0
  153. package/dist/httpHookPolicy.js +176 -0
  154. package/dist/humanTurn.d.ts +2 -1
  155. package/dist/humanTurn.js +37 -7
  156. package/dist/humanTurnRead.js +4 -3
  157. package/dist/humanTurnSentences.d.ts +10 -0
  158. package/dist/humanTurnSentences.js +74 -0
  159. package/dist/i18n/messages.en.d.ts +184 -2
  160. package/dist/i18n/messages.en.js +187 -5
  161. package/dist/i18n/messages.zh.js +197 -5
  162. package/dist/i18n/translate.js +3 -3
  163. package/dist/index.d.ts +69 -15
  164. package/dist/index.js +45 -13
  165. package/dist/inheritEnvCapability.d.ts +3 -1
  166. package/dist/inheritEnvCapability.js +31 -17
  167. package/dist/inheritEnvWire.d.ts +2 -1
  168. package/dist/inheritEnvWire.js +11 -5
  169. package/dist/interactiveToolsWire.d.ts +4 -2
  170. package/dist/interactiveToolsWire.js +5 -5
  171. package/dist/jsonFaithful.d.ts +20 -0
  172. package/dist/jsonFaithful.js +152 -0
  173. package/dist/limitsWire.d.ts +7 -2
  174. package/dist/limitsWire.js +19 -13
  175. package/dist/liveInitToolFace.d.ts +6 -1
  176. package/dist/liveInitToolFace.js +5 -3
  177. package/dist/liveModelCatalog.d.ts +22 -0
  178. package/dist/liveModelCatalog.js +132 -18
  179. package/dist/mcpPanel.js +1 -1
  180. package/dist/mcpProbeCapability.js +2 -2
  181. package/dist/mcpStatusSupersetKeys.d.ts +24 -0
  182. package/dist/mcpStatusSupersetKeys.js +45 -0
  183. package/dist/mcpToolToggles.js +2 -1
  184. package/dist/mcpWireCaps.d.ts +39 -1
  185. package/dist/mcpWireCaps.js +254 -50
  186. package/dist/memoryComplianceCapability.js +2 -2
  187. package/dist/memoryOriginCapability.js +2 -2
  188. package/dist/model/catalogDefault.d.ts +24 -0
  189. package/dist/model/catalogDefault.js +4 -0
  190. package/dist/model/liveCatalogShape.js +5 -4
  191. package/dist/model/modelsPolicy.js +4 -3
  192. package/dist/model/onboardJudgement.d.ts +1 -0
  193. package/dist/model/onboardJudgement.js +1 -1
  194. package/dist/model/subagentModelWord.js +2 -2
  195. package/dist/modelCapabilityProbe.js +6 -6
  196. package/dist/modelIdentityResolvability.d.ts +10 -1
  197. package/dist/modelIdentityResolvability.js +62 -39
  198. package/dist/modsKernelIdentity.d.ts +10 -0
  199. package/dist/modsKernelIdentity.js +103 -0
  200. package/dist/modsKernelTransit.d.ts +8 -0
  201. package/dist/modsKernelTransit.js +6 -0
  202. package/dist/notifications.d.ts +30 -12
  203. package/dist/notifications.js +241 -53
  204. package/dist/outputStyleSeatCapability.js +2 -2
  205. package/dist/ownKey.d.ts +11 -0
  206. package/dist/ownKey.js +164 -3
  207. package/dist/panelReduce.js +1 -1
  208. package/dist/peerFrames.d.ts +1 -1
  209. package/dist/peerFrames.js +6 -2
  210. package/dist/peerLaneCapability.js +2 -2
  211. package/dist/permissionModesCapability.js +4 -4
  212. package/dist/permissionRuleIssue.js +2 -0
  213. package/dist/permissionRulesWriteCapability.js +2 -2
  214. package/dist/permissionsAllowGrantCapability.js +2 -2
  215. package/dist/permissionsDeclaration.d.ts +43 -4
  216. package/dist/permissionsDeclaration.js +102 -35
  217. package/dist/pluginHooksWire.d.ts +20 -4
  218. package/dist/pluginHooksWire.js +92 -53
  219. package/dist/prepareRefusal.d.ts +3 -2
  220. package/dist/prepareRefusal.js +27 -9
  221. package/dist/printInitToolFace.js +2 -2
  222. package/dist/printModelStatus.js +1 -1
  223. package/dist/projectMemory.d.ts +32 -0
  224. package/dist/projectMemory.js +70 -0
  225. package/dist/promptBlockedCopy.d.ts +2 -1
  226. package/dist/promptBlockedCopy.js +2 -1
  227. package/dist/promptDelivery.d.ts +23 -3
  228. package/dist/promptDelivery.js +169 -30
  229. package/dist/providerRejection.d.ts +19 -1
  230. package/dist/providerRejection.js +75 -4
  231. package/dist/queuedDelivery.d.ts +48 -0
  232. package/dist/queuedDelivery.js +233 -0
  233. package/dist/reattachWindow.d.ts +94 -0
  234. package/dist/reattachWindow.js +127 -0
  235. package/dist/request/printNotification.d.ts +1 -1
  236. package/dist/request/printNotification.js +5 -1
  237. package/dist/request/submissionIdentity.d.ts +37 -0
  238. package/dist/request/submissionIdentity.js +65 -0
  239. package/dist/request/taskRequest.d.ts +12 -4
  240. package/dist/request/taskRequest.js +221 -152
  241. package/dist/resultFrameKeys.d.ts +1 -0
  242. package/dist/resultFrameKeys.js +4 -1
  243. package/dist/retryStatus.d.ts +8 -0
  244. package/dist/retryStatus.js +57 -9
  245. package/dist/rewindArchiveCapability.js +2 -2
  246. package/dist/rewindEngineAction.d.ts +2 -0
  247. package/dist/rewindEngineAction.js +23 -1
  248. package/dist/rowKind.d.ts +36 -0
  249. package/dist/rowKind.js +97 -0
  250. package/dist/ruleCompileVerdict.d.ts +18 -0
  251. package/dist/ruleCompileVerdict.js +67 -2
  252. package/dist/ruleReadings.d.ts +58 -0
  253. package/dist/ruleReadings.js +132 -0
  254. package/dist/ruleRefusalSentence.d.ts +4 -0
  255. package/dist/ruleRefusalSentence.js +9 -3
  256. package/dist/runCancelContext.d.ts +0 -1
  257. package/dist/runCancelContext.js +1 -2
  258. package/dist/runTerminal.d.ts +5 -0
  259. package/dist/runTerminal.js +52 -17
  260. package/dist/sandboxWire.d.ts +1 -1
  261. package/dist/sandboxWire.js +4 -6
  262. package/dist/scenarioRefusal.js +1 -1
  263. package/dist/scenarioSkills.d.ts +20 -0
  264. package/dist/scenarioSkills.js +72 -0
  265. package/dist/scenarioWire.d.ts +5 -2
  266. package/dist/scenarioWire.js +9 -9
  267. package/dist/sealedKeyCapability.js +2 -2
  268. package/dist/seam.d.ts +2 -0
  269. package/dist/seam.js +2 -2
  270. package/dist/seatContract.d.ts +46 -1
  271. package/dist/seatContract.js +49 -19
  272. package/dist/selfOrchestrationDenial.js +1 -1
  273. package/dist/sessionPolicyCapability.js +2 -2
  274. package/dist/sessionRulesChildrenReadLive.d.ts +6 -0
  275. package/dist/sessionRulesChildrenReadLive.js +5 -0
  276. package/dist/sessionRulesNamespaceFormsCapability.d.ts +12 -0
  277. package/dist/sessionRulesNamespaceFormsCapability.js +29 -0
  278. package/dist/sessionSyncFileHistoryCapability.js +2 -2
  279. package/dist/settingsCredentialKeyPaths.js +60 -5
  280. package/dist/settingsHooksSalvage.d.ts +1 -0
  281. package/dist/settingsHooksSalvage.js +7 -1
  282. package/dist/settingsLayerAdmission.d.ts +4 -0
  283. package/dist/settingsLayerAdmission.js +16 -0
  284. package/dist/skillToolListsCapability.js +6 -5
  285. package/dist/skillsWireCaps.d.ts +14 -0
  286. package/dist/skillsWireCaps.js +47 -16
  287. package/dist/slashCommandGate.d.ts +24 -0
  288. package/dist/slashCommandGate.js +74 -0
  289. package/dist/slashCommandTable.d.ts +14 -0
  290. package/dist/slashCommandTable.js +99 -0
  291. package/dist/sqlEngineCapability.js +2 -2
  292. package/dist/steerPriorityCapability.js +2 -2
  293. package/dist/storePostureCapability.js +2 -2
  294. package/dist/subagent/agentStateDetail.js +1 -1
  295. package/dist/subagent/engineDelegatedPrompt.d.ts +9 -0
  296. package/dist/subagent/engineDelegatedPrompt.js +38 -7
  297. package/dist/subagent/engineRowStopGate.js +2 -2
  298. package/dist/subagent/engineSubagentResume.js +3 -3
  299. package/dist/subagent/engineTaskHandleWire.d.ts +1 -0
  300. package/dist/subagent/engineTaskHandleWire.js +10 -0
  301. package/dist/submitFailure.d.ts +8 -0
  302. package/dist/submitFailure.js +17 -0
  303. package/dist/supportFloor.d.ts +1 -0
  304. package/dist/supportFloor.js +7 -0
  305. package/dist/terminationIntent.d.ts +55 -0
  306. package/dist/terminationIntent.js +352 -0
  307. package/dist/toolHistoryMismatch.d.ts +8 -0
  308. package/dist/toolHistoryMismatch.js +37 -6
  309. package/dist/toolResult.d.ts +13 -3
  310. package/dist/toolResult.js +158 -9
  311. package/dist/toolResultContent.d.ts +13 -0
  312. package/dist/toolResultContent.js +82 -7
  313. package/dist/toolRoster.d.ts +18 -0
  314. package/dist/toolRoster.js +64 -0
  315. package/dist/turnFailurePresentation.js +27 -90
  316. package/dist/usageLimitAutoResume.d.ts +74 -0
  317. package/dist/usageLimitAutoResume.js +227 -0
  318. package/dist/userAttachmentEnvelope.js +1 -1
  319. package/dist/userAttachmentSeat.js +5 -5
  320. package/dist/userInvokedSkillsCapability.js +2 -2
  321. package/dist/webSearchBackendCapability.js +2 -2
  322. package/dist/wireErrorTriage.js +99 -50
  323. package/dist/wireFailureShape.d.ts +25 -1
  324. package/dist/wireFailureShape.js +92 -5
  325. package/dist/wireRefusalCopy.d.ts +24 -1
  326. package/dist/wireRefusalCopy.js +253 -32
  327. package/dist/wiringFleetDoctor.d.ts +3 -0
  328. package/dist/wiringFleetDoctor.js +21 -0
  329. package/dist/workflow.d.ts +2 -1
  330. package/dist/workflow.js +38 -1
  331. package/dist/workflowClient.d.ts +2 -7
  332. package/dist/workflowsJournalCapability.js +2 -2
  333. package/dist/writeProtectionCapability.js +2 -2
  334. package/docs/INTEGRATION-CLIENTS.md +607 -181
  335. package/package.json +14 -3
@@ -1,4 +1,6 @@
1
1
  import { displayUntrusted } from './displayUntrusted.js';
2
+ import { appendOwnElement } from './ownKey.js';
3
+ import { msg, renderMessage } from './i18n/translate.js';
2
4
  import { SETTINGS_ENGINE_OWNED_HOOK_EVENTS } from './generated/settingsSchemaTables.js';
3
5
  import { HOOK_SETTINGS_SOURCE_TEXT, hooksSalvageMaskOf, salvageSettingsHooksEntries, } from './settingsHooksSalvage.js';
4
6
  export const ENGINE_FIRED_HOOK_EVENTS = SETTINGS_ENGINE_OWNED_HOOK_EVENTS;
@@ -26,6 +28,7 @@ export const PLUGIN_HOOK_REASONS = [
26
28
  'hooks_module',
27
29
  'scope_unsupported',
28
30
  'source_incomplete',
31
+ 'compaction_local_fallback',
29
32
  ];
30
33
  export const PLUGIN_HOOK_EXCLUSION_REASONS = [
31
34
  'workspace_untrusted',
@@ -54,6 +57,9 @@ export function hooksWirePlanShapeOf(v) {
54
57
  Array.isArray(o.settingsVerdicts) &&
55
58
  Array.isArray(o.settingsExcluded) &&
56
59
  arrayOrAbsent('settingsSalvage') &&
60
+ arrayOrAbsent('httpPolicyDrops') &&
61
+ arrayOrAbsent('settingsSources') &&
62
+ arrayOrAbsent('settingsWithheld') &&
57
63
  arrayOrAbsent('moduleVerdicts') &&
58
64
  arrayOrAbsent('sessionVerdicts') &&
59
65
  (!Object.hasOwn(o, 'sessionReader') || o.sessionReader === 'present' || o.sessionReader === 'absent' || o.sessionReader === 'failed') &&
@@ -69,8 +75,8 @@ export function hooksWirePlanShapeOf(v) {
69
75
  return 'threw';
70
76
  }
71
77
  }
72
- const PLAN_KEYS = ['engine', 'pluginReader', 'verdicts', 'excluded', 'settingsDropped', 'settingsVerdicts', 'settingsExcluded', 'settingsSalvage', 'moduleVerdicts', 'sessionVerdicts', 'sessionReader', 'closedBy', 'wire'];
73
- const LATER_PLAN_KEYS = new Set(['settingsSalvage', 'moduleVerdicts', 'sessionVerdicts', 'sessionReader', 'closedBy']);
78
+ const PLAN_KEYS = ['engine', 'pluginReader', 'verdicts', 'excluded', 'settingsDropped', 'settingsVerdicts', 'settingsExcluded', 'settingsSalvage', 'httpPolicyDrops', 'moduleVerdicts', 'sessionVerdicts', 'sessionReader', 'closedBy', 'settingsSources', 'settingsWithheld', 'wire'];
79
+ const LATER_PLAN_KEYS = new Set(['settingsSalvage', 'httpPolicyDrops', 'moduleVerdicts', 'sessionVerdicts', 'sessionReader', 'closedBy', 'settingsSources', 'settingsWithheld']);
74
80
  const _planKeysPin = [true, true];
75
81
  void _planKeysPin;
76
82
  export const ENGINE_HOOK_LIMITS = { maxGroupsPerEvent: 16, maxEntriesPerEvent: 32, maxCommandChars: 8192, maxLlmEntriesPerEvent: 4 };
@@ -93,6 +99,9 @@ function hookExecutorOf(x) {
93
99
  ? { reason: 'engine_llm_limit', certain: false }
94
100
  : undefined;
95
101
  const compaction = COMPACTION_EVENTS.has(x.event);
102
+ if (compaction && x.compactionOnShell === true && x.shellRuns && (why === undefined || (!why.certain && why.reason !== 'engine_llm_limit'))) {
103
+ return judged('shell', 'compaction_local_fallback');
104
+ }
96
105
  if (why === undefined) {
97
106
  if (!x.shellRuns || x.engine.ownedByThisShell === true)
98
107
  return judged('engine', 'projected');
@@ -225,7 +234,7 @@ export function decidePluginHooks(input) {
225
234
  return;
226
235
  }
227
236
  if (p.hooksModule === true && input.exclusion === undefined && !(input.managedOnly && p.managed !== true)) {
228
- modules.push({ pluginId: typeof p.id === 'string' ? p.id : '', pluginName: typeof p.name === 'string' ? p.name : '', disposition: 'not_run', reason: 'hooks_module' });
237
+ appendOwnElement(modules, { pluginId: typeof p.id === 'string' ? p.id : '', pluginName: typeof p.name === 'string' ? p.name : '', disposition: 'not_run', reason: 'hooks_module' });
229
238
  }
230
239
  if (!isRecord(p.hooks)) {
231
240
  unreadable++;
@@ -252,37 +261,37 @@ export function decidePluginHooks(input) {
252
261
  group.hooks.forEach((entry, hookIndex) => {
253
262
  const key = { pluginId, pluginName, event, groupIndex, hookIndex };
254
263
  if (input.exclusion !== undefined) {
255
- excluded.push({ ...key, reason: input.exclusion });
264
+ appendOwnElement(excluded, { ...key, reason: input.exclusion });
256
265
  return;
257
266
  }
258
267
  if (input.managedOnly && p.managed !== true) {
259
- excluded.push({ ...key, reason: 'managed_plugins_only' });
268
+ appendOwnElement(excluded, { ...key, reason: 'managed_plugins_only' });
260
269
  return;
261
270
  }
262
271
  const entryType = isRecord(entry) && typeof entry.type === 'string' ? entry.type : undefined;
263
272
  if (!sourceOk) {
264
- verdicts.push({ ...key, disposition: 'not_run', reason: 'source_incomplete' });
273
+ appendOwnElement(verdicts, { ...key, disposition: 'not_run', reason: 'source_incomplete' });
265
274
  return;
266
275
  }
267
276
  if (!pieceMask.eventDropped(event) && pieceMask.entryDropped(event, groupIndex, hookIndex)) {
268
- verdicts.push({ ...key, disposition: 'not_run', reason: 'malformed_entry' });
277
+ appendOwnElement(verdicts, { ...key, disposition: 'not_run', reason: 'malformed_entry' });
269
278
  return;
270
279
  }
271
280
  const shape = classifyEntry(entry, src.options);
272
281
  if (shape.kind === 'malformed') {
273
- verdicts.push({ ...key, disposition: 'not_run', reason: 'malformed_entry' });
282
+ appendOwnElement(verdicts, { ...key, disposition: 'not_run', reason: 'malformed_entry' });
274
283
  return;
275
284
  }
276
285
  if (shape.kind === 'shell_form' && shape.refusesUserConfig) {
277
- verdicts.push({ ...key, disposition: 'not_run', reason: 'shell_form_user_config' });
286
+ appendOwnElement(verdicts, { ...key, disposition: 'not_run', reason: 'shell_form_user_config' });
278
287
  return;
279
288
  }
280
289
  if (shape.kind === 'exec_form' && shape.unsetUserConfig) {
281
- verdicts.push({ ...key, disposition: 'not_run', reason: 'user_config_unset' });
290
+ appendOwnElement(verdicts, { ...key, disposition: 'not_run', reason: 'user_config_unset' });
282
291
  return;
283
292
  }
284
293
  if (!ENGINE_EVENTS.has(event)) {
285
- verdicts.push({
294
+ appendOwnElement(verdicts, {
286
295
  ...key,
287
296
  ...(input.shellRuns(event, entryType)
288
297
  ? { disposition: 'shell', reason: 'shell_event' }
@@ -301,11 +310,11 @@ export function decidePluginHooks(input) {
301
310
  ...(shape.kind === 'other' ? { pluginBlock: 'not_command' } : declaresSensitive(src.options) ? { pluginBlock: 'sensitive_options' } : {}),
302
311
  });
303
312
  if (ex.kind === 'excluded') {
304
- excluded.push({ ...key, reason: ex.reason });
313
+ appendOwnElement(excluded, { ...key, reason: ex.reason });
305
314
  return;
306
315
  }
307
316
  if (ex.disposition !== 'engine') {
308
- verdicts.push({ ...key, disposition: ex.disposition, reason: ex.reason });
317
+ appendOwnElement(verdicts, { ...key, disposition: ex.disposition, reason: ex.reason });
309
318
  return;
310
319
  }
311
320
  const plugin = { name: src.name, root: src.root, dataDir: src.dataDir };
@@ -318,9 +327,9 @@ export function decidePluginHooks(input) {
318
327
  wireEntry.args = shape.args.map((a) => substituteUserConfig(a, src.options));
319
328
  }
320
329
  const verdict = { ...key, disposition: 'engine', reason: 'projected' };
321
- verdicts.push(verdict);
330
+ appendOwnElement(verdicts, verdict);
322
331
  const list = candidates.get(event) ?? [];
323
- list.push({ verdict, pluginIndex, group, wireEntry });
332
+ appendOwnElement(list, { verdict, pluginIndex, group, wireEntry });
324
333
  candidates.set(event, list);
325
334
  });
326
335
  });
@@ -341,7 +350,7 @@ export function decidePluginHooks(input) {
341
350
  for (const c of fits) {
342
351
  const k = `${c.pluginIndex}\u0000${c.verdict.groupIndex}`;
343
352
  if (!groupKeys.includes(k))
344
- groupKeys.push(k);
353
+ appendOwnElement(groupKeys, k);
345
354
  }
346
355
  const occ = input.occupied.get(event) ?? { groups: 0, entries: 0 };
347
356
  if (occ.groups + groupKeys.length > ENGINE_HOOK_LIMITS.maxGroupsPerEvent ||
@@ -356,7 +365,7 @@ export function decidePluginHooks(input) {
356
365
  const first = members[0];
357
366
  if (first === undefined)
358
367
  continue;
359
- groupsOut.push({ ...first.group, hooks: members.map((c) => c.wireEntry) });
368
+ appendOwnElement(groupsOut, { ...first.group, hooks: members.map((c) => c.wireEntry) });
360
369
  }
361
370
  projected.set(event, groupsOut);
362
371
  }
@@ -416,18 +425,18 @@ export function decideSessionHooks(input) {
416
425
  const key = { origin, name, event, groupIndex, hookIndex };
417
426
  const type = isRecord(entry) && typeof entry.type === 'string' ? entry.type : undefined;
418
427
  if (rejectedWhole || (!mask.eventDropped(event) && mask.entryDropped(event, groupIndex, hookIndex)) || type === undefined) {
419
- out.push({ ...key, disposition: 'not_run', reason: 'malformed_entry' });
428
+ appendOwnElement(out, { ...key, disposition: 'not_run', reason: 'malformed_entry' });
420
429
  return;
421
430
  }
422
431
  const shellRuns = input.shellRuns(event, type);
423
432
  if (!ENGINE_EVENTS.has(event)) {
424
- out.push({ ...key, ...(shellRuns ? { disposition: 'shell', reason: 'shell_event' } : { disposition: 'not_run', reason: 'no_executor' }) });
433
+ appendOwnElement(out, { ...key, ...(shellRuns ? { disposition: 'shell', reason: 'shell_event' } : { disposition: 'not_run', reason: 'no_executor' }) });
425
434
  return;
426
435
  }
427
436
  const ex = hookExecutorOf({ source: 'session', event, powershell: false, llmPosition: 0, engine: input.engine, shellRuns, promptAuthoredByUser: input.promptAuthoredByUser });
428
437
  if (ex.kind === 'excluded')
429
438
  return;
430
- out.push({ ...key, disposition: ex.disposition, reason: ex.reason });
439
+ appendOwnElement(out, { ...key, disposition: ex.disposition, reason: ex.reason });
431
440
  });
432
441
  });
433
442
  }
@@ -456,7 +465,7 @@ export function filterSettingsHookGroups(source, event, groups, execFormCapable,
456
465
  if (mask !== undefined && mask.groupDropped(event, groupIndex))
457
466
  return;
458
467
  if (!isRecord(group) || !Array.isArray(group.hooks)) {
459
- out.push(group);
468
+ appendOwnElement(out, group);
460
469
  return;
461
470
  }
462
471
  const kept = [];
@@ -474,18 +483,18 @@ export function filterSettingsHookGroups(source, event, groups, execFormCapable,
474
483
  ? 'exec_form_unsupported'
475
484
  : undefined;
476
485
  if (reason !== undefined) {
477
- drops.push({ source, event, groupIndex, hookIndex, reason, notRun: engineEvent && !shellRunsType(isRecord(entry) && typeof entry.type === 'string' ? entry.type : undefined) });
486
+ appendOwnElement(drops, { source, event, groupIndex, hookIndex, reason, notRun: engineEvent && !shellRunsType(isRecord(entry) && typeof entry.type === 'string' ? entry.type : undefined) });
478
487
  changed = true;
479
488
  return;
480
489
  }
481
490
  if (engineEvent && isRecord(entry) && judgeableSettingsEntry(entry)) {
482
491
  const ex = judge(event, group, entry);
483
492
  if (ex.kind === 'excluded') {
484
- excluded.push({ source, event, groupIndex, hookIndex, reason: ex.reason });
493
+ appendOwnElement(excluded, { source, event, groupIndex, hookIndex, reason: ex.reason });
485
494
  changed = true;
486
495
  return;
487
496
  }
488
- verdicts.push({ source, event, groupIndex, hookIndex, disposition: ex.disposition, reason: ex.reason });
497
+ appendOwnElement(verdicts, { source, event, groupIndex, hookIndex, disposition: ex.disposition, reason: ex.reason });
489
498
  if (ex.disposition === 'shell') {
490
499
  changed = true;
491
500
  return;
@@ -494,17 +503,17 @@ export function filterSettingsHookGroups(source, event, groups, execFormCapable,
494
503
  if (isRecord(entry) && Object.hasOwn(entry, 'plugin')) {
495
504
  const copy = { ...entry };
496
505
  delete copy.plugin;
497
- kept.push(copy);
506
+ appendOwnElement(kept, copy);
498
507
  stripped++;
499
508
  changed = true;
500
509
  return;
501
510
  }
502
- kept.push(entry);
511
+ appendOwnElement(kept, entry);
503
512
  });
504
513
  if (!changed)
505
- out.push(group);
514
+ appendOwnElement(out, group);
506
515
  else if (kept.length > 0)
507
- out.push({ ...group, hooks: kept });
516
+ appendOwnElement(out, { ...group, hooks: kept });
508
517
  });
509
518
  return { groups: out, drops, stripped, verdicts, excluded };
510
519
  }
@@ -515,7 +524,7 @@ function judgeableSettingsEntry(entry) {
515
524
  const field = type === 'command' ? entry.command : type === 'http' ? entry.url : entry.prompt;
516
525
  return nonEmptyString(field) && !field.includes('\u0000');
517
526
  }
518
- export function createSettingsHookJudge(engine, shellRuns, promptAuthoredByUser) {
527
+ export function createSettingsHookJudge(engine, shellRuns, promptAuthoredByUser, compactionOnShell) {
519
528
  const llm = new Map();
520
529
  const seen = new Map();
521
530
  return (event, group, entry) => {
@@ -544,6 +553,7 @@ export function createSettingsHookJudge(engine, shellRuns, promptAuthoredByUser)
544
553
  engine,
545
554
  shellRuns: shellRuns(event, typeof type === 'string' ? type : undefined),
546
555
  promptAuthoredByUser,
556
+ ...(compactionOnShell === true ? { compactionOnShell: true } : {}),
547
557
  });
548
558
  if (isLlm && ex.kind === 'judged' && ex.disposition !== 'shell')
549
559
  llm.set(event, (llm.get(event) ?? 0) + 1);
@@ -610,7 +620,7 @@ export function dedupeSettingsHookGroups(groups) {
610
620
  const winner = new Map();
611
621
  for (const { source, group } of groups) {
612
622
  if (!isRecord(group) || !Array.isArray(group.hooks)) {
613
- keysOf.push([]);
623
+ appendOwnElement(keysOf, []);
614
624
  continue;
615
625
  }
616
626
  let groupKey;
@@ -627,21 +637,21 @@ export function dedupeSettingsHookGroups(groups) {
627
637
  for (const entry of group.hooks) {
628
638
  const entryKey = groupKey === undefined ? undefined : settingsHookEntryKey(entry);
629
639
  const key = entryKey === undefined ? undefined : `${groupKey}\u0000${entryKey}`;
630
- keys.push(key);
640
+ appendOwnElement(keys, key);
631
641
  if (key === undefined)
632
642
  continue;
633
643
  const prev = winner.get(key);
634
644
  if (prev === undefined || rank >= prev.rank)
635
645
  winner.set(key, { entry, rank });
636
646
  }
637
- keysOf.push(keys);
647
+ appendOwnElement(keysOf, keys);
638
648
  }
639
649
  const placed = new Set();
640
650
  const out = [];
641
651
  let removed = 0;
642
652
  groups.forEach(({ group }, gi) => {
643
653
  if (!isRecord(group) || !Array.isArray(group.hooks)) {
644
- out.push(group);
654
+ appendOwnElement(out, group);
645
655
  return;
646
656
  }
647
657
  const keys = keysOf[gi] ?? [];
@@ -650,7 +660,7 @@ export function dedupeSettingsHookGroups(groups) {
650
660
  group.hooks.forEach((entry, hi) => {
651
661
  const key = keys[hi];
652
662
  if (key === undefined) {
653
- kept.push(entry);
663
+ appendOwnElement(kept, entry);
654
664
  return;
655
665
  }
656
666
  if (placed.has(key)) {
@@ -662,12 +672,12 @@ export function dedupeSettingsHookGroups(groups) {
662
672
  const win = winner.get(key)?.entry ?? entry;
663
673
  if (win !== entry)
664
674
  changed = true;
665
- kept.push(win);
675
+ appendOwnElement(kept, win);
666
676
  });
667
677
  if (!changed)
668
- out.push(group);
678
+ appendOwnElement(out, group);
669
679
  else if (kept.length > 0)
670
- out.push({ ...group, hooks: kept });
680
+ appendOwnElement(out, { ...group, hooks: kept });
671
681
  });
672
682
  return { groups: out, removed };
673
683
  }
@@ -686,6 +696,20 @@ export function settingsHooksKeptLocally(plan, event, group, opts) {
686
696
  raw = undefined;
687
697
  }
688
698
  const hooks = raw;
699
+ if (Array.isArray(hooks) && hooks.length > 0) {
700
+ let layerSkipped;
701
+ try {
702
+ const src = isRecord(group) ? group.source : undefined;
703
+ const planRec0 = plan;
704
+ const allowed = typeof src === 'string' && isRecord(planRec0) ? ownField(planRec0, 'settingsSources') : undefined;
705
+ layerSkipped = Array.isArray(allowed) && !allowed.includes(src);
706
+ }
707
+ catch {
708
+ layerSkipped = false;
709
+ }
710
+ if (layerSkipped)
711
+ return [];
712
+ }
689
713
  if (!Array.isArray(hooks) || hooks.length === 0 || !ENGINE_EVENTS.has(event))
690
714
  return hooks;
691
715
  try {
@@ -729,7 +753,7 @@ export function settingsHooksKeptLocally(plan, event, group, opts) {
729
753
  if (skip)
730
754
  kept ??= hooks.slice(0, i);
731
755
  else if (kept !== null)
732
- kept.push(h);
756
+ appendOwnElement(kept, h);
733
757
  });
734
758
  return kept ?? hooks;
735
759
  }
@@ -807,6 +831,7 @@ const REASON_TEXT = {
807
831
  hooks_module: 'hooks registered in code by a plugin module run neither in the engine nor in this client',
808
832
  scope_unsupported: 'hooks registered for a skill, an agent or by the host application are not sent to the engine, and this client does not run this event',
809
833
  source_incomplete: 'the plugin was reported without its id, name, root folder or data folder',
834
+ compaction_local_fallback: renderMessage(msg('config.hooks.plan.reason.compactionLocalFallback')),
810
835
  };
811
836
  const DROP_TEXT = {
812
837
  exec_form_unsupported: 'exec-form hooks (with "args") are sent to the engine only once it reports support for them',
@@ -844,17 +869,17 @@ function escapeNoticeQuotes(s) {
844
869
  j++;
845
870
  const want = s.charCodeAt(j) === 0x22 ? (j - i) * 2 : j - i;
846
871
  const take = Math.min(want, budget + 1 - len);
847
- out.push('\\'.repeat(take));
872
+ appendOwnElement(out, '\\'.repeat(take));
848
873
  len += take;
849
874
  i = j;
850
875
  continue;
851
876
  }
852
877
  if (c === 0x22) {
853
- out.push('\\"');
878
+ appendOwnElement(out, '\\"');
854
879
  len += 2;
855
880
  }
856
881
  else {
857
- out.push(s.charAt(i));
882
+ appendOwnElement(out, s.charAt(i));
858
883
  len++;
859
884
  }
860
885
  i++;
@@ -882,13 +907,13 @@ export function hooksNotRunNotice(plan) {
882
907
  const k = `${v.pluginId}\u0000${v.reason}`;
883
908
  const row = byPlugin.get(k) ?? { name: v.pluginName, reason: v.reason, events: [], count: 0 };
884
909
  if (!row.events.includes(v.event))
885
- row.events.push(v.event);
910
+ appendOwnElement(row.events, v.event);
886
911
  row.count++;
887
912
  byPlugin.set(k, row);
888
913
  }
889
914
  for (const row of byPlugin.values()) {
890
915
  const events = row.events.map((e) => noticeLabel(e)).join(', ');
891
- lines.push(`Plugin "${noticeLabel(row.name) || '(unnamed)'}": ${events} ${row.count === 1 ? 'hook' : 'hooks'} will not run — ${pluginHookReasonText(row.reason)}.`);
916
+ appendOwnElement(lines, `Plugin "${noticeLabel(row.name) || '(unnamed)'}": ${events} ${row.count === 1 ? 'hook' : 'hooks'} will not run — ${pluginHookReasonText(row.reason)}.`);
892
917
  }
893
918
  const bySource = new Map();
894
919
  for (const d of plan.settingsDropped) {
@@ -897,13 +922,13 @@ export function hooksNotRunNotice(plan) {
897
922
  const k = `${d.source}\u0000${d.reason}`;
898
923
  const row = bySource.get(k) ?? { source: d.source, reason: d.reason, events: [], count: 0 };
899
924
  if (!row.events.includes(d.event))
900
- row.events.push(d.event);
925
+ appendOwnElement(row.events, d.event);
901
926
  row.count++;
902
927
  bySource.set(k, row);
903
928
  }
904
929
  for (const row of bySource.values()) {
905
930
  const events = row.events.map((e) => noticeLabel(e)).join(', ');
906
- lines.push(`${SOURCE_TEXT[row.source]}: ${events} ${row.count === 1 ? 'hook' : 'hooks'} will not run — ${settingsHookDropText(row.reason)}.`);
931
+ appendOwnElement(lines, `${SOURCE_TEXT[row.source]}: ${events} ${row.count === 1 ? 'hook' : 'hooks'} will not run — ${settingsHookDropText(row.reason)}.`);
907
932
  }
908
933
  const settingsVerdicts = plan.settingsVerdicts;
909
934
  const byVerdict = new Map();
@@ -914,13 +939,13 @@ export function hooksNotRunNotice(plan) {
914
939
  const k = `${v.source}\u0000${v.reason}`;
915
940
  const row = byVerdict.get(k) ?? { source: v.source, reason: v.reason, events: [], count: 0 };
916
941
  if (!row.events.includes(v.event))
917
- row.events.push(v.event);
942
+ appendOwnElement(row.events, v.event);
918
943
  row.count++;
919
944
  byVerdict.set(k, row);
920
945
  }
921
946
  for (const row of byVerdict.values()) {
922
947
  const events = row.events.map((e) => noticeLabel(e)).join(', ');
923
- lines.push(`${SOURCE_TEXT[row.source]}: ${events} ${row.count === 1 ? 'hook' : 'hooks'} will not run — ${pluginHookReasonText(row.reason)}.`);
948
+ appendOwnElement(lines, `${SOURCE_TEXT[row.source]}: ${events} ${row.count === 1 ? 'hook' : 'hooks'} will not run — ${pluginHookReasonText(row.reason)}.`);
924
949
  }
925
950
  const moduleRows = plan.moduleVerdicts;
926
951
  for (const raw of Array.isArray(moduleRows) ? moduleRows : []) {
@@ -930,7 +955,7 @@ export function hooksNotRunNotice(plan) {
930
955
  const name = ownField(raw, 'pluginName');
931
956
  if (typeof reason !== 'string' || !REASON_SET.has(reason))
932
957
  continue;
933
- lines.push(`Plugin "${noticeLabel(typeof name === 'string' ? name : '') || '(unnamed)'}": hooks module will not run — ${pluginHookReasonText(reason)}.`);
958
+ appendOwnElement(lines, `Plugin "${noticeLabel(typeof name === 'string' ? name : '') || '(unnamed)'}": hooks module will not run — ${pluginHookReasonText(reason)}.`);
934
959
  }
935
960
  const sessionRows = plan.sessionVerdicts;
936
961
  const bySession = new Map();
@@ -947,20 +972,32 @@ export function hooksNotRunNotice(plan) {
947
972
  const k = `${origin}\u0000${nm}\u0000${reason}`;
948
973
  const row = bySession.get(k) ?? { origin: origin, name: nm, reason: reason, events: [], count: 0 };
949
974
  if (!row.events.includes(event))
950
- row.events.push(event);
975
+ appendOwnElement(row.events, event);
951
976
  row.count++;
952
977
  bySession.set(k, row);
953
978
  }
954
979
  for (const row of bySession.values()) {
955
980
  const events = row.events.map((e) => noticeLabel(e)).join(', ');
956
981
  const who = row.origin === 'sdk_host' ? 'Host application hooks' : `${row.origin === 'skill' ? 'Skill' : 'Agent'} "${noticeLabel(row.name) || '(unnamed)'}"`;
957
- lines.push(`${who}: ${events} ${row.count === 1 ? 'hook' : 'hooks'} will not run — ${pluginHookReasonText(row.reason)}.`);
982
+ appendOwnElement(lines, `${who}: ${events} ${row.count === 1 ? 'hook' : 'hooks'} will not run — ${pluginHookReasonText(row.reason)}.`);
958
983
  }
959
984
  const salvageRows = plan.settingsSalvage;
960
985
  for (const row of Array.isArray(salvageRows) ? salvageRows : []) {
961
986
  const notice = isRecord(row) ? ownField(row, 'notice') : undefined;
962
987
  if (typeof notice === 'string' && notice.length > 0)
963
- lines.push(notice);
988
+ appendOwnElement(lines, notice);
989
+ }
990
+ const httpRows = plan.httpPolicyDrops;
991
+ for (const row of Array.isArray(httpRows) ? httpRows : []) {
992
+ const notice = isRecord(row) ? ownField(row, 'notice') : undefined;
993
+ if (typeof notice === 'string' && notice.length > 0)
994
+ appendOwnElement(lines, notice);
995
+ }
996
+ const withheldRows = plan.settingsWithheld;
997
+ for (const row of Array.isArray(withheldRows) ? withheldRows : []) {
998
+ const notice = isRecord(row) ? ownField(row, 'notice') : undefined;
999
+ if (typeof notice === 'string' && notice.length > 0)
1000
+ appendOwnElement(lines, notice);
964
1001
  }
965
1002
  return lines;
966
1003
  }
@@ -976,12 +1013,14 @@ export function userPromptSubmitExecutorOf(plan) {
976
1013
  const settingsRows = ownField(p, 'settingsVerdicts');
977
1014
  if (!Array.isArray(settingsRows))
978
1015
  return 'unknown';
979
- rows.push(...settingsRows);
1016
+ for (const v of settingsRows)
1017
+ appendOwnElement(rows, v);
980
1018
  const sessionRows = ownField(p, 'sessionVerdicts');
981
1019
  if (sessionRows !== undefined) {
982
1020
  if (!Array.isArray(sessionRows))
983
1021
  return 'unknown';
984
- rows.push(...sessionRows);
1022
+ for (const v of sessionRows)
1023
+ appendOwnElement(rows, v);
985
1024
  }
986
1025
  const ups = rows.filter((r) => isRecord(r) && ownField(r, 'event') === 'UserPromptSubmit').map((r) => ownField(r, 'disposition'));
987
1026
  if (ups.length === 0)
@@ -1,7 +1,8 @@
1
- import { CONFIG_AGENT_UNKNOWN_TOOL, CONFIG_IMAGE_INVALID, CONFIG_LEGACY_TOOL_NAME, CONFIG_TOOL_FACE_CONTROL, PROMPT_ASSEMBLED_ROLE_REFUSED, USER_ATTACHMENT_INVALID_ERROR_CODE, USER_INVOKED_SKILL_UNKNOWN_ERROR_CODE } from './engineErrorCodes.js';
2
- export type PrepareRefusalCode = typeof CONFIG_LEGACY_TOOL_NAME | typeof CONFIG_IMAGE_INVALID | typeof CONFIG_AGENT_UNKNOWN_TOOL | typeof PROMPT_ASSEMBLED_ROLE_REFUSED | typeof USER_ATTACHMENT_INVALID_ERROR_CODE | typeof USER_INVOKED_SKILL_UNKNOWN_ERROR_CODE | typeof CONFIG_TOOL_FACE_CONTROL;
1
+ import { CONFIG_AGENT_UNKNOWN_TOOL, CONFIG_IMAGE_INVALID, CONFIG_LEGACY_TOOL_NAME, CONFIG_MCP_SERVER_NAME_COLLISION, CONFIG_TOOL_FACE_CONTROL, PROMPT_ASSEMBLED_ROLE_REFUSED, USER_ATTACHMENT_INVALID_ERROR_CODE, USER_INVOKED_SKILL_UNKNOWN_ERROR_CODE } from './engineErrorCodes.js';
2
+ export type PrepareRefusalCode = typeof CONFIG_LEGACY_TOOL_NAME | typeof CONFIG_IMAGE_INVALID | typeof CONFIG_AGENT_UNKNOWN_TOOL | typeof PROMPT_ASSEMBLED_ROLE_REFUSED | typeof USER_ATTACHMENT_INVALID_ERROR_CODE | typeof USER_INVOKED_SKILL_UNKNOWN_ERROR_CODE | typeof CONFIG_TOOL_FACE_CONTROL | typeof CONFIG_MCP_SERVER_NAME_COLLISION;
3
3
  export interface PrepareRefusalNoteFacts {
4
4
  readonly index?: number;
5
+ readonly draftKept?: boolean;
5
6
  }
6
7
  export declare function prepareRefusalNoteOf(code: string | undefined, facts?: PrepareRefusalNoteFacts): string | undefined;
7
8
  export declare function prepareRefusalCodeOf(failure: {} | null | undefined): PrepareRefusalCode | undefined;
@@ -1,8 +1,11 @@
1
- import { CONFIG_AGENT_UNKNOWN_TOOL, CONFIG_IMAGE_INVALID, CONFIG_LEGACY_TOOL_NAME, CONFIG_TOOL_FACE_CONTROL, PROMPT_ASSEMBLED_ROLE_REFUSED, USER_ATTACHMENT_INVALID_ERROR_CODE, USER_INVOKED_SKILL_UNKNOWN_ERROR_CODE, } from './engineErrorCodes.js';
1
+ import { CONFIG_AGENT_UNKNOWN_TOOL, CONFIG_IMAGE_INVALID, CONFIG_LEGACY_TOOL_NAME, CONFIG_MCP_SERVER_NAME_COLLISION, CONFIG_TOOL_FACE_CONTROL, PROMPT_ASSEMBLED_ROLE_REFUSED, USER_ATTACHMENT_INVALID_ERROR_CODE, USER_INVOKED_SKILL_UNKNOWN_ERROR_CODE, } from './engineErrorCodes.js';
2
2
  import { REFUSED_NAME_CLASSES } from './hitl/refusedToolNameProse.js';
3
+ import { msg, renderMessage } from './i18n/translate.js';
3
4
  import { readOwnDataValue } from './ownKey.js';
4
5
  import { effectiveWireErrorCode } from './wireErrorTriage.js';
5
6
  const nonNegInt = (v) => (typeof v === 'number' && Number.isSafeInteger(v) && v >= 0 ? v : undefined);
7
+ const draftKeptSegment = (facts) => Object.hasOwn(facts, 'draftKept') && facts.draftKept === true ? ` · ${renderMessage(msg('notice.prepareRefusal.draftKept'))}` : '';
8
+ const indexOf = (facts) => nonNegInt(Object.hasOwn(facts, 'index') ? facts.index : undefined);
6
9
  const PREPARE_REFUSAL_NOTES = Object.freeze({
7
10
  [CONFIG_LEGACY_TOOL_NAME]: () => `The engine refused this run at setup: a tool rule applied to it names a tool the engine refuses — ${REFUSED_NAME_CLASSES} (the engine's own error text names the entry). ` +
8
11
  'Every later run fails the same way until that entry is removed from wherever it is set: this session’s rule record, the settings sent with the run, a parent session’s rule record, or the deployment’s own tool rules.',
@@ -13,17 +16,18 @@ const PREPARE_REFUSAL_NOTES = Object.freeze({
13
16
  [PROMPT_ASSEMBLED_ROLE_REFUSED]: () => 'The engine refused this run at setup: the role text sent with it contains the engine’s own prompt sections word for word — the engine’s own error text names the field · ' +
14
17
  'Send only your own role text (the engine assembles the rest), then send it again',
15
18
  [USER_ATTACHMENT_INVALID_ERROR_CODE]: (facts) => {
16
- const index = nonNegInt(facts.index);
19
+ const index = indexOf(facts);
17
20
  return index !== undefined
18
- ? `The engine refused attachment ${index + 1} of this message: it is in a form the engine does not accept, or larger than it takes · Your draft is kept · Remove or replace that attachment, then send it again`
19
- : 'The engine refused the files attached to this message: together with the message they are more than it can take in one request on this model, or one of them is in a form it does not accept · ' +
20
- 'Your draft is kept · Remove some attachments or attach smaller parts, then send it again';
21
+ ? `The engine refused attachment ${index + 1} of this message: it is in a form the engine does not accept, or larger than it takes${draftKeptSegment(facts)} · Remove or replace that attachment, then send it again`
22
+ : 'The engine refused the files attached to this message: together with the message they are more than it can take in one request on this model, or one of them is in a form it does not accept' +
23
+ `${draftKeptSegment(facts)} · Remove some attachments or attach smaller parts, then send it again`;
21
24
  },
22
- [USER_INVOKED_SKILL_UNKNOWN_ERROR_CODE]: () => 'The engine refused this run at setup: a skill named for it is not one this run has loaded, or skills are turned off for this run · ' +
23
- 'Your draft is kept · Check the skill name, or load that skill, then send it again',
25
+ [USER_INVOKED_SKILL_UNKNOWN_ERROR_CODE]: (facts) => 'The engine refused this run at setup: a skill named for it is not one this run has loaded, or skills are turned off for this run' +
26
+ `${draftKeptSegment(facts)} · Check the skill name, or load that skill, then send it again`,
24
27
  [CONFIG_TOOL_FACE_CONTROL]: () => 'The engine refused this run at setup: its tool set could not be put together as asked — usually a tool list on the request or one it inherits (allowed or excluded tools) names something no tool answers to, ' +
25
28
  'uses a form those lists do not accept, or excludes a tool this run depends on; it can also be the deployment’s own tool mounts — the engine’s own error text says what it refused and where · ' +
26
29
  'Sending the same request again is refused the same way; fix what it names (or ask whoever operates the engine, if it names the deployment’s tools), then send it',
30
+ [CONFIG_MCP_SERVER_NAME_COLLISION]: () => renderMessage(msg('notice.prepareRefusal.mcpServerNameCollision')),
27
31
  });
28
32
  function isPrepareRefusalCode(code) {
29
33
  return typeof code === 'string' && Object.hasOwn(PREPARE_REFUSAL_NOTES, code);
@@ -32,15 +36,29 @@ export function prepareRefusalNoteOf(code, facts) {
32
36
  try {
33
37
  if (!isPrepareRefusalCode(code))
34
38
  return undefined;
39
+ let bag;
40
+ try {
41
+ bag = typeof facts === 'object' && facts !== null && !Array.isArray(facts) ? facts : undefined;
42
+ }
43
+ catch {
44
+ bag = undefined;
45
+ }
35
46
  let index;
36
47
  try {
37
- index = facts === undefined || facts === null ? undefined : facts.index;
48
+ index = readOwnDataValue(bag, 'index');
38
49
  }
39
50
  catch {
40
51
  index = undefined;
41
52
  }
53
+ let draftKept;
54
+ try {
55
+ draftKept = readOwnDataValue(bag, 'draftKept');
56
+ }
57
+ catch {
58
+ draftKept = undefined;
59
+ }
42
60
  const i = nonNegInt(index);
43
- return PREPARE_REFUSAL_NOTES[code](i !== undefined ? { index: i } : {});
61
+ return PREPARE_REFUSAL_NOTES[code]({ ...(i !== undefined ? { index: i } : {}), ...(draftKept === true ? { draftKept: true } : {}) });
44
62
  }
45
63
  catch {
46
64
  return undefined;
@@ -87,7 +87,7 @@ function snapshotStampKeys(rec) {
87
87
  return undefined;
88
88
  const d = Reflect.getOwnPropertyDescriptor(o, key);
89
89
  if (d !== undefined) {
90
- if ('get' in d || 'set' in d)
90
+ if (Object.hasOwn(d, 'get') || Object.hasOwn(d, 'set'))
91
91
  return undefined;
92
92
  if (depth === 0)
93
93
  own = d;
@@ -112,7 +112,7 @@ function restoreStampKeys(rec, saved) {
112
112
  if (s.own !== undefined) {
113
113
  if (now === undefined)
114
114
  ok = Reflect.defineProperty(rec, s.key, s.own);
115
- else if (!('value' in now) || !Object.is(now.value, s.own.value))
115
+ else if (!Object.hasOwn(now, 'value') || !Object.is(now.value, s.own.value))
116
116
  ok = Reflect.set(rec, s.key, s.own.value);
117
117
  }
118
118
  else if (now !== undefined) {
@@ -77,7 +77,7 @@ function isMainLaneArm(msg) {
77
77
  const tri = (o, key) => {
78
78
  try {
79
79
  const d = Object.getOwnPropertyDescriptor(o, key);
80
- if (d !== undefined && !('value' in d))
80
+ if (d !== undefined && !Object.hasOwn(d, 'value'))
81
81
  return { ok: false };
82
82
  return { ok: true, v: readOwnDataValue(o, key) };
83
83
  }
@@ -0,0 +1,32 @@
1
+ import type { UiLanguage } from './env/uiLanguage.js';
2
+ export declare const PROJECT_MEMORY_DISABLED: "disabled";
3
+ export declare const PROJECT_MEMORY_WORDS: readonly ["on", "disabled", "absent"];
4
+ export type ProjectMemoryWord = (typeof PROJECT_MEMORY_WORDS)[number];
5
+ export interface ProjectMemoryManifestSeat {
6
+ readonly projectMemory?: string;
7
+ }
8
+ export declare function projectMemoryOf(manifest: ProjectMemoryManifestSeat | null | undefined): ProjectMemoryWord | undefined;
9
+ export type ProjectMemoryCapabilityReading = {
10
+ readonly kind: 'confirmed';
11
+ } | {
12
+ readonly kind: 'absent';
13
+ } | {
14
+ readonly kind: 'declined';
15
+ } | {
16
+ readonly kind: 'unreadable';
17
+ } | {
18
+ readonly kind: 'unobserved';
19
+ };
20
+ export declare function observedProjectMemoryCapability(baseUrl?: string | undefined): ProjectMemoryCapabilityReading;
21
+ export type ProjectMemoryWithheldCause = 'capability_absent' | 'capability_declined' | 'capability_unreadable';
22
+ export interface ProjectMemoryWithheld {
23
+ readonly cause: ProjectMemoryWithheldCause;
24
+ }
25
+ export interface ProjectMemoryDeclaration {
26
+ readonly field: {
27
+ readonly projectMemory?: 'disabled';
28
+ };
29
+ readonly withheld?: ProjectMemoryWithheld;
30
+ }
31
+ export declare function projectMemoryDeclaration(intent: 'disabled' | undefined, reading: ProjectMemoryCapabilityReading): ProjectMemoryDeclaration;
32
+ export declare function projectMemoryWithheldNotice(withheld: ProjectMemoryWithheld, lang?: UiLanguage): string;