@sema-agent/client-core 0.89.0 → 0.91.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 (104) hide show
  1. package/CHANGELOG.md +297 -0
  2. package/README.md +35 -24
  3. package/dist/adapt/arms.js +9 -0
  4. package/dist/adapter/downstream/eventToSdkMessage.js +4 -2
  5. package/dist/adapter/downstream/wiringManifestView.d.ts +6 -0
  6. package/dist/adapter/downstream/wiringManifestView.js +16 -0
  7. package/dist/adapter/runStream.d.ts +2 -0
  8. package/dist/adapter/runStream.js +180 -38
  9. package/dist/askSurvivesStandingAnswer.d.ts +10 -0
  10. package/dist/askSurvivesStandingAnswer.js +40 -0
  11. package/dist/attachmentSeatCapability.d.ts +11 -0
  12. package/dist/attachmentSeatCapability.js +27 -0
  13. package/dist/attachmentsWireCaps.d.ts +22 -2
  14. package/dist/attachmentsWireCaps.js +95 -22
  15. package/dist/compensations.js +10 -14
  16. package/dist/controlRouter.d.ts +9 -2
  17. package/dist/controlRouter.js +66 -28
  18. package/dist/coreValuePorts.d.ts +1 -0
  19. package/dist/decideFailureNote.js +4 -2
  20. package/dist/disableSkillsWire.d.ts +1 -0
  21. package/dist/disableSkillsWire.js +8 -1
  22. package/dist/displayUntrusted.js +153 -4
  23. package/dist/engineCapReader.js +12 -1
  24. package/dist/engineCapsCache.d.ts +3 -1
  25. package/dist/engineCapsCache.js +56 -6
  26. package/dist/engineClosedSets.d.ts +2 -0
  27. package/dist/engineClosedSets.js +3 -0
  28. package/dist/engineErrorCodes.d.ts +3 -0
  29. package/dist/engineErrorCodes.js +10 -0
  30. package/dist/engineNoticeCodes.d.ts +2 -9
  31. package/dist/engineNoticeCodes.js +19 -27
  32. package/dist/fileHistoryLegNotice.d.ts +20 -0
  33. package/dist/fileHistoryLegNotice.js +122 -0
  34. package/dist/gateOutcome.d.ts +1 -1
  35. package/dist/gateOutcome.js +1 -0
  36. package/dist/generated/engineFactTables.d.ts +13 -0
  37. package/dist/generated/engineFactTables.js +50 -0
  38. package/dist/generated/engineNoticeTables.js +0 -3
  39. package/dist/hitl/askGateWire.d.ts +1 -1
  40. package/dist/hitl/askGateWire.js +1 -1
  41. package/dist/hitl/crashConverged.d.ts +7 -0
  42. package/dist/hitl/crashConverged.js +57 -0
  43. package/dist/hitl/crashConvergedNotice.d.ts +4 -0
  44. package/dist/hitl/crashConvergedNotice.js +57 -0
  45. package/dist/hitl/hitlBridge.d.ts +7 -4
  46. package/dist/hitl/parkResolver.d.ts +7 -2
  47. package/dist/hitl/parkResolver.js +19 -7
  48. package/dist/hitl/planReviewWire.d.ts +1 -1
  49. package/dist/hitl/planReviewWire.js +18 -4
  50. package/dist/hitl/sessionPolicyWire.d.ts +5 -0
  51. package/dist/hitl/sessionPolicyWire.js +63 -0
  52. package/dist/hitl/suspendedReopen.js +2 -2
  53. package/dist/hitl/toolApprovalWire.d.ts +4 -1
  54. package/dist/hitl/toolApprovalWire.js +20 -0
  55. package/dist/hookMatcherVerdict.d.ts +29 -0
  56. package/dist/hookMatcherVerdict.js +265 -0
  57. package/dist/hookToolAliases.d.ts +3 -0
  58. package/dist/hookToolAliases.js +10 -0
  59. package/dist/humanTurn.d.ts +91 -0
  60. package/dist/humanTurn.js +253 -0
  61. package/dist/humanTurnRead.d.ts +105 -0
  62. package/dist/humanTurnRead.js +331 -0
  63. package/dist/index.d.ts +30 -5
  64. package/dist/index.js +19 -4
  65. package/dist/inheritEnvWire.js +1 -1
  66. package/dist/liveModelCatalog.d.ts +2 -0
  67. package/dist/liveModelCatalog.js +51 -3
  68. package/dist/permissionRuleIssue.d.ts +1 -1
  69. package/dist/permissionRuleIssue.js +22 -3
  70. package/dist/permissionsAllowGrantCapability.d.ts +18 -0
  71. package/dist/permissionsAllowGrantCapability.js +84 -0
  72. package/dist/permissionsDeclaration.d.ts +48 -0
  73. package/dist/permissionsDeclaration.js +307 -0
  74. package/dist/promptDelivery.d.ts +16 -5
  75. package/dist/promptDelivery.js +172 -32
  76. package/dist/providerRejection.d.ts +3 -1
  77. package/dist/providerRejection.js +27 -1
  78. package/dist/readDenyTiers.d.ts +10 -0
  79. package/dist/readDenyTiers.js +29 -0
  80. package/dist/request/taskRequest.js +27 -1
  81. package/dist/resumeRefusalCopy.d.ts +11 -0
  82. package/dist/resumeRefusalCopy.js +61 -4
  83. package/dist/rewindArchiveCapability.js +4 -4
  84. package/dist/rewindWireCaps.d.ts +2 -1
  85. package/dist/rewindWireCaps.js +19 -2
  86. package/dist/sdkRegistryTransit.d.ts +1 -0
  87. package/dist/sdkRegistryTransit.js +1 -0
  88. package/dist/seam.d.ts +2 -0
  89. package/dist/supportFloor.d.ts +10 -0
  90. package/dist/supportFloor.js +42 -0
  91. package/dist/taskRequestWords.d.ts +7 -0
  92. package/dist/taskRequestWords.js +24 -0
  93. package/dist/toolHistoryBadTurn.d.ts +1 -0
  94. package/dist/toolHistoryBadTurn.js +89 -0
  95. package/dist/toolHistoryMismatch.d.ts +2 -1
  96. package/dist/toolHistoryMismatch.js +19 -6
  97. package/dist/userAttachmentEnvelope.d.ts +61 -0
  98. package/dist/userAttachmentEnvelope.js +204 -0
  99. package/dist/wireFailureShape.d.ts +1 -0
  100. package/dist/wireFailureShape.js +4 -0
  101. package/dist/wireRefusalCopy.d.ts +6 -0
  102. package/dist/wireRefusalCopy.js +26 -3
  103. package/docs/INTEGRATION-CLIENTS.md +1369 -18
  104. package/package.json +3 -3
package/dist/index.d.ts CHANGED
@@ -31,6 +31,8 @@ export * from './executionLaneCapability.js';
31
31
  export * from './approvalsStreamLiveCapability.js';
32
32
  export * from './peerLaneCapability.js';
33
33
  export * from './permissionRulesWriteCapability.js';
34
+ export { __resetPermissionsAllowGrantReadingsForTests, forgetPermissionsAllowGrantReading, noteEngineCapsForPermissionsAllowGrant, observedPermissionsAllowGrant, permissionsAllowGrantAvailable, permissionsAllowGrantDoctorDetail, projectPermissionsAllowGrantCapability, } from './permissionsAllowGrantCapability.js';
35
+ export type { PermissionsAllowGrantReading } from './permissionsAllowGrantCapability.js';
34
36
  export * from './sessionPolicyCapability.js';
35
37
  export * from './memoryComplianceCapability.js';
36
38
  export * from './memoryOriginCapability.js';
@@ -67,7 +69,7 @@ export type { DisplayUntrustedOptions, DisplayMark, DisplayMarkSpan, DisplayUntr
67
69
  export type * from './types/engineState.js';
68
70
  export * from './hostEnv.js';
69
71
  export * from './unrefTimer.js';
70
- export { ControlRouter, ControlSafetyError, errCodes, type ControlClientLike, type ControlRouterOptions, type ControlSafetyCode, type ErrCodes, type QueuedCommand, type QueuePriority, type RunsResourceLike, } from './controlRouter.js';
72
+ export { ControlRouter, ControlSafetyError, errCodes, steerRefusalAdviceOf, steeringRefusedBeforeEngine, type ControlClientLike, type ControlRouterOptions, type ControlSafetyCode, type ErrCodes, type QueuedCommand, type QueuePriority, type RunsResourceLike, type SteerRefusalAdvice, type SteeringRefusedBeforeEngine, } from './controlRouter.js';
71
73
  export * from './sseIdleTriage.js';
72
74
  export * from './engineWireSdk.js';
73
75
  export * from './classifierVerdictWire.js';
@@ -90,6 +92,8 @@ export * from './oneShotWireCaps.js';
90
92
  export * from './rewindWireCaps.js';
91
93
  export * from './rewindArchiveCapability.js';
92
94
  export * from './fileHistoryCaptureCapability.js';
95
+ export { FILE_HISTORY_LEG_VERDICTS, fileHistoryLegNoticeVerdict, fileHistoryLegNoticeSentence, fileHistoryDeclarationOfBody, createFileHistoryDeclarationLedger, } from './fileHistoryLegNotice.js';
96
+ export type { FileHistoryDeclarationFact, FileHistoryLegNoticeVerdict, FileHistoryLegNoticeInput, FileHistoryDeclarationLedger } from './fileHistoryLegNotice.js';
93
97
  export * from './sealedKeyCapability.js';
94
98
  export * from './storePostureCapability.js';
95
99
  export * from './centerWiringCapability.js';
@@ -107,15 +111,18 @@ export * from './effortWire.js';
107
111
  export * from './adapter/types.js';
108
112
  export * from './adapter/downstream/turnUsageToModelUsage.js';
109
113
  export * from './adapter/downstream/eventToSdkMessage.js';
110
- export type { WiringManifestView, WiringManifestSections } from './adapter/downstream/wiringManifestView.js';
114
+ export type { WiringManifestView, WiringManifestSections, WiringManifestFleetView } from './adapter/downstream/wiringManifestView.js';
111
115
  export * from './adapter/downstream/terminalToSdkResult.js';
112
116
  export * from './adapter/runStream.js';
113
117
  export * from './adapter/activeRunSelfHeal.js';
114
118
  export * from './request/taskRequest.js';
115
- export { disableSkillsDeclaration } from './disableSkillsWire.js';
119
+ export { disableSkillsDeclaration, disableSkillsDeclarationSettled } from './disableSkillsWire.js';
116
120
  export type { DisableSkillsDeclaration } from './disableSkillsWire.js';
121
+ export { PERMISSIONS_KEPT_REASONS, permissionsDeclaration, permissionsDeclarationReport } from './permissionsDeclaration.js';
122
+ export type { PermissionsDeclaration, PermissionsDeclarationBuckets, PermissionsDeclarationInput, PermissionsDeclarationReport, PermissionsKeptReason, PermissionsKeptRule, PermissionsRewrittenRule, PermissionsUncheckedRule, WireRuleOrigin, WireRuleOrigins, } from './permissionsDeclaration.js';
117
123
  export * from './clientSlice.js';
118
124
  export * from './host.js';
125
+ export { abortableSleep } from './abortableSleep.js';
119
126
  export { DEFAULT_SESSION_KEY } from './sessionSlot.js';
120
127
  export * from './scratchpadWireCaps.js';
121
128
  export * from './toolResult.js';
@@ -148,14 +155,24 @@ export * from './principalWire.js';
148
155
  export * from './wireErrorTriage.js';
149
156
  export * from './corruptSession.js';
150
157
  export * from './corruptSessionCopy.js';
151
- export { classifyToolHistoryMismatch, resolveToolHistoryRewindTarget } from './toolHistoryMismatch.js';
158
+ export { classifyToolHistoryMismatch, readToolHistoryMismatchKey, resolveToolHistoryRewindTarget } from './toolHistoryMismatch.js';
159
+ export type { ToolHistoryMismatchRowKey } from './toolHistoryMismatch.js';
160
+ export { toolHistoryBadTurnSentence } from './toolHistoryBadTurn.js';
152
161
  export { classifyRegistryConflict, isScopeGoneError } from './registryConflict.js';
153
162
  export type { RegistryConflictClass } from './registryConflict.js';
154
163
  export { createPromptDeliveryLedger, promptKnownUndelivered, withoutUndeliveredPrompts } from './promptDelivery.js';
155
164
  export type { PromptDeliveryLedger, PromptDeliveryRecord } from './promptDelivery.js';
165
+ export { mintUserAttachmentEnvelope } from './userAttachmentEnvelope.js';
166
+ export type { UserAttachmentDescriptor, UserAttachmentNotebookCell } from './userAttachmentEnvelope.js';
167
+ export { encodeHumanTurn, deliveredUuidsOf } from './humanTurn.js';
168
+ export type { HumanTurnInput, HumanTurnItem, HumanTurnAttachment, HumanTurnRider, HumanTurnMissing, HumanTurnCaps, HumanTurnEncoding, HumanTurnShare, HumanTurnSharePart, HumanTurnDegraded, HumanTurnDelivered, } from './humanTurn.js';
169
+ export { noteEngineCapsForAttachmentSeat, observedAttachmentSeat, forgetAttachmentSeatReading, __resetAttachmentSeatReadingsForTests, } from './attachmentSeatCapability.js';
170
+ export type { AttachmentSeatReading } from './attachmentSeatCapability.js';
156
171
  export * from './resumeRefusalCopy.js';
157
172
  export * from './wireRefusalCopy.js';
158
173
  export * from './inheritEnvWire.js';
174
+ export { SUPPORT_FLOOR, supportFloorOf, engineVersionTier } from './supportFloor.js';
175
+ export type { SupportFloor, SupportFloorComponent, EngineVersionTier } from './supportFloor.js';
159
176
  export * from './decideReceipt.js';
160
177
  export * from './sessionMap.js';
161
178
  export * from './detachWire.js';
@@ -163,6 +180,12 @@ export * from './workflowMonitor.js';
163
180
  export * from './workflowClient.js';
164
181
  export * from './hooksWireCaps.js';
165
182
  export { ENGINE_FIRED_HOOK_EVENTS, PLUGIN_HOOK_DISPOSITIONS, PLUGIN_HOOK_REASONS, PLUGIN_HOOK_EXCLUSION_REASONS, SETTINGS_HOOK_DROP_REASONS, isEngineFiredHookEvent, pluginHookVerdictOf, pluginHookReasonText, settingsHookDropText, pluginHookExecutorLabel, hooksNotRunNotice, settingsHooksKeptLocally, type EngineFiredHookEvent, type PluginHookDisposition, type PluginHookReason, type PluginHookExclusionReason, type SettingsHookDropReason, type HookSettingsSource, type PluginHookKey, type PluginHookVerdict, type PluginHookExclusion, type SettingsHookDrop, type SettingsHookVerdict, type SettingsHookExclusion, type HooksWireEngineFacts, type PluginHookReaderState, type HooksWirePlan, type HooksWirePlanOptions, } from './pluginHooksWire.js';
183
+ export { hookToolAliasesOf, canonicalHookToolName } from './hookToolAliases.js';
184
+ export { hookMatcherVerdict } from './hookMatcherVerdict.js';
185
+ export type { HookMatcherVerdict, HookMatcherUnjudgedReason } from './hookMatcherVerdict.js';
186
+ export { ASK_EVIDENCE_ABSENCE_VALUES, SYSTEM_INJECTION_PRIORITIES } from './engineClosedSets.js';
187
+ export { READ_DENY_BUILTIN_TIERS, READ_DENY_DEFAULT_TIERS, parseReadDenyBuiltinTiers, type ReadDenyBuiltinTiersParse } from './readDenyTiers.js';
188
+ export { MODE_ARBITRATION, askSurvivesStandingAnswer, type StandingAnswerVerdict } from './askSurvivesStandingAnswer.js';
166
189
  export * from './liveInitToolFace.js';
167
190
  export * from './printInitToolFace.js';
168
191
  export * from './model/providerPresets.js';
@@ -193,7 +216,9 @@ export * from './hitl/sessionPolicyDeliverable.js';
193
216
  export * from './hitl/approvalsFeed.js';
194
217
  export * from './hitl/livePendingAsk.js';
195
218
  export * from './hitl/askSurvivesPosture.js';
196
- export * from './hitl/crashConverged.js';
219
+ export { projectCrashConverged } from './hitl/crashConverged.js';
220
+ export type { ApprovalsListEnvelope, CrashConvergedOrphanState, CrashConvergedProjection, CrashConvergedRow } from './hitl/crashConverged.js';
221
+ export * from './hitl/crashConvergedNotice.js';
197
222
  export * from './interactiveHalt.js';
198
223
  export * from './compensations.js';
199
224
  export * from './request/printNotification.js';
package/dist/index.js CHANGED
@@ -26,6 +26,7 @@ export * from './executionLaneCapability.js';
26
26
  export * from './approvalsStreamLiveCapability.js';
27
27
  export * from './peerLaneCapability.js';
28
28
  export * from './permissionRulesWriteCapability.js';
29
+ export { __resetPermissionsAllowGrantReadingsForTests, forgetPermissionsAllowGrantReading, noteEngineCapsForPermissionsAllowGrant, observedPermissionsAllowGrant, permissionsAllowGrantAvailable, permissionsAllowGrantDoctorDetail, projectPermissionsAllowGrantCapability, } from './permissionsAllowGrantCapability.js';
29
30
  export * from './sessionPolicyCapability.js';
30
31
  export * from './memoryComplianceCapability.js';
31
32
  export * from './memoryOriginCapability.js';
@@ -60,7 +61,7 @@ export * from './fleetTaskDesc.js';
60
61
  export { displayUntrusted, displayUntrustedMarks } from './displayUntrusted.js';
61
62
  export * from './hostEnv.js';
62
63
  export * from './unrefTimer.js';
63
- export { ControlRouter, ControlSafetyError, errCodes, } from './controlRouter.js';
64
+ export { ControlRouter, ControlSafetyError, errCodes, steerRefusalAdviceOf, steeringRefusedBeforeEngine, } from './controlRouter.js';
64
65
  export * from './sseIdleTriage.js';
65
66
  export * from './engineWireSdk.js';
66
67
  export * from './classifierVerdictWire.js';
@@ -82,6 +83,7 @@ export * from './oneShotWireCaps.js';
82
83
  export * from './rewindWireCaps.js';
83
84
  export * from './rewindArchiveCapability.js';
84
85
  export * from './fileHistoryCaptureCapability.js';
86
+ export { FILE_HISTORY_LEG_VERDICTS, fileHistoryLegNoticeVerdict, fileHistoryLegNoticeSentence, fileHistoryDeclarationOfBody, createFileHistoryDeclarationLedger, } from './fileHistoryLegNotice.js';
85
87
  export * from './sealedKeyCapability.js';
86
88
  export * from './storePostureCapability.js';
87
89
  export * from './centerWiringCapability.js';
@@ -103,9 +105,11 @@ export * from './adapter/downstream/terminalToSdkResult.js';
103
105
  export * from './adapter/runStream.js';
104
106
  export * from './adapter/activeRunSelfHeal.js';
105
107
  export * from './request/taskRequest.js';
106
- export { disableSkillsDeclaration } from './disableSkillsWire.js';
108
+ export { disableSkillsDeclaration, disableSkillsDeclarationSettled } from './disableSkillsWire.js';
109
+ export { PERMISSIONS_KEPT_REASONS, permissionsDeclaration, permissionsDeclarationReport } from './permissionsDeclaration.js';
107
110
  export * from './clientSlice.js';
108
111
  export * from './host.js';
112
+ export { abortableSleep } from './abortableSleep.js';
109
113
  export { DEFAULT_SESSION_KEY } from './sessionSlot.js';
110
114
  export * from './scratchpadWireCaps.js';
111
115
  export * from './toolResult.js';
@@ -135,12 +139,17 @@ export * from './principalWire.js';
135
139
  export * from './wireErrorTriage.js';
136
140
  export * from './corruptSession.js';
137
141
  export * from './corruptSessionCopy.js';
138
- export { classifyToolHistoryMismatch, resolveToolHistoryRewindTarget } from './toolHistoryMismatch.js';
142
+ export { classifyToolHistoryMismatch, readToolHistoryMismatchKey, resolveToolHistoryRewindTarget } from './toolHistoryMismatch.js';
143
+ export { toolHistoryBadTurnSentence } from './toolHistoryBadTurn.js';
139
144
  export { classifyRegistryConflict, isScopeGoneError } from './registryConflict.js';
140
145
  export { createPromptDeliveryLedger, promptKnownUndelivered, withoutUndeliveredPrompts } from './promptDelivery.js';
146
+ export { mintUserAttachmentEnvelope } from './userAttachmentEnvelope.js';
147
+ export { encodeHumanTurn, deliveredUuidsOf } from './humanTurn.js';
148
+ export { noteEngineCapsForAttachmentSeat, observedAttachmentSeat, forgetAttachmentSeatReading, __resetAttachmentSeatReadingsForTests, } from './attachmentSeatCapability.js';
141
149
  export * from './resumeRefusalCopy.js';
142
150
  export * from './wireRefusalCopy.js';
143
151
  export * from './inheritEnvWire.js';
152
+ export { SUPPORT_FLOOR, supportFloorOf, engineVersionTier } from './supportFloor.js';
144
153
  export * from './decideReceipt.js';
145
154
  export * from './sessionMap.js';
146
155
  export * from './detachWire.js';
@@ -148,6 +157,11 @@ export * from './workflowMonitor.js';
148
157
  export * from './workflowClient.js';
149
158
  export * from './hooksWireCaps.js';
150
159
  export { ENGINE_FIRED_HOOK_EVENTS, PLUGIN_HOOK_DISPOSITIONS, PLUGIN_HOOK_REASONS, PLUGIN_HOOK_EXCLUSION_REASONS, SETTINGS_HOOK_DROP_REASONS, isEngineFiredHookEvent, pluginHookVerdictOf, pluginHookReasonText, settingsHookDropText, pluginHookExecutorLabel, hooksNotRunNotice, settingsHooksKeptLocally, } from './pluginHooksWire.js';
160
+ export { hookToolAliasesOf, canonicalHookToolName } from './hookToolAliases.js';
161
+ export { hookMatcherVerdict } from './hookMatcherVerdict.js';
162
+ export { ASK_EVIDENCE_ABSENCE_VALUES, SYSTEM_INJECTION_PRIORITIES } from './engineClosedSets.js';
163
+ export { READ_DENY_BUILTIN_TIERS, READ_DENY_DEFAULT_TIERS, parseReadDenyBuiltinTiers } from './readDenyTiers.js';
164
+ export { MODE_ARBITRATION, askSurvivesStandingAnswer } from './askSurvivesStandingAnswer.js';
151
165
  export * from './liveInitToolFace.js';
152
166
  export * from './printInitToolFace.js';
153
167
  export * from './model/providerPresets.js';
@@ -176,7 +190,8 @@ export * from './hitl/sessionPolicyDeliverable.js';
176
190
  export * from './hitl/approvalsFeed.js';
177
191
  export * from './hitl/livePendingAsk.js';
178
192
  export * from './hitl/askSurvivesPosture.js';
179
- export * from './hitl/crashConverged.js';
193
+ export { projectCrashConverged } from './hitl/crashConverged.js';
194
+ export * from './hitl/crashConvergedNotice.js';
180
195
  export * from './interactiveHalt.js';
181
196
  export * from './compensations.js';
182
197
  export * from './request/printNotification.js';
@@ -77,7 +77,7 @@ export function inheritEnvRefusalFromError(err, sentRequest) {
77
77
  return null;
78
78
  }
79
79
  }
80
- const REFUSAL_NOT_ACCEPTED = 'The engine refused this request as invalid without naming the field · ' +
80
+ const REFUSAL_NOT_ACCEPTED = 'The engine refused this request as invalid, under a refusal code that many different request fields share · ' +
81
81
  "This request asked for the shell to inherit this machine's whole environment, which the engine accepts only when tools run directly on its own machine and the request belongs to a session; if that is what it refused, send it again without that setting (or with the default)";
82
82
  export function inheritEnvRefusalContent(_detail) {
83
83
  return REFUSAL_NOT_ACCEPTED;
@@ -16,6 +16,8 @@ export declare function setLiveModelCatalogRefresher(fn: (() => Promise<LiveMode
16
16
  export declare function refreshLiveModelCatalog(): Promise<boolean>;
17
17
  export declare function getLiveModelCatalog(): LiveModelCatalog | null;
18
18
  export declare function normalizeLiveModelRef(ref: string): string;
19
+ export type ImageVision = 'yes' | 'no' | 'unknown';
20
+ export declare function imageVisionOf(model: string | undefined, catalog?: LiveModelCatalog | null): ImageVision;
19
21
  export declare function liveDefaultModelName(): string | null;
20
22
  export interface RoutePairingVerdict {
21
23
  verdict: 'ok' | 'broken' | 'unknown';
@@ -26,10 +26,58 @@ export function getLiveModelCatalog() {
26
26
  export function normalizeLiveModelRef(ref) {
27
27
  if (!catalog || !ref)
28
28
  return ref;
29
- if (catalog.models.some(m => m.name === ref))
29
+ const row = liveModelRowOf(catalog, ref);
30
+ if (row === undefined)
30
31
  return ref;
31
- const row = catalog.models.find(m => typeof m.id === 'string' && m.id === ref);
32
- return row?.name || ref;
32
+ const name = ownDataOf(row, 'name');
33
+ return typeof name === 'string' && name ? name : ref;
34
+ }
35
+ function ownDataOf(o, key) {
36
+ try {
37
+ const d = Object.getOwnPropertyDescriptor(o, key);
38
+ return d !== undefined && 'value' in d ? d.value : undefined;
39
+ }
40
+ catch {
41
+ return undefined;
42
+ }
43
+ }
44
+ function liveModelRowOf(cat, ref) {
45
+ const models = ownDataOf(cat, 'models');
46
+ if (!Array.isArray(models))
47
+ return undefined;
48
+ const n = ownDataOf(models, 'length');
49
+ if (typeof n !== 'number' || !Number.isSafeInteger(n) || n < 0)
50
+ return undefined;
51
+ const rows = [];
52
+ for (let i = 0; i < n; i += 1) {
53
+ const row = ownDataOf(models, String(i));
54
+ if (row !== null && typeof row === 'object')
55
+ rows.push(row);
56
+ }
57
+ return rows.find((row) => ownDataOf(row, 'name') === ref) ?? rows.find((row) => ownDataOf(row, 'id') === ref);
58
+ }
59
+ export function imageVisionOf(model, catalog = getLiveModelCatalog()) {
60
+ try {
61
+ if (model !== undefined && typeof model !== 'string')
62
+ return 'unknown';
63
+ if (catalog === null || typeof catalog !== 'object' || Array.isArray(catalog))
64
+ return 'unknown';
65
+ let target = model !== undefined && model.length > 0 ? model : undefined;
66
+ if (target === undefined) {
67
+ const def = ownDataOf(catalog, 'default');
68
+ target = typeof def === 'string' && def.length > 0 ? def : undefined;
69
+ }
70
+ if (target === undefined)
71
+ return 'unknown';
72
+ const row = liveModelRowOf(catalog, target);
73
+ if (row === undefined)
74
+ return 'unknown';
75
+ const vision = ownDataOf(row, 'vision');
76
+ return vision === true ? 'yes' : vision === false ? 'no' : 'unknown';
77
+ }
78
+ catch {
79
+ return 'unknown';
80
+ }
33
81
  }
34
82
  export function liveDefaultModelName() {
35
83
  if (!catalog?.default)
@@ -1,3 +1,3 @@
1
1
  export declare const PERMISSION_RULE_ISSUE_CODES: readonly string[];
2
2
  export declare const RETIRED_PERMISSION_RULE_ISSUE_CODES: readonly string[];
3
- export declare function permissionRuleIssueDetail(code: unknown, message: unknown): string;
3
+ export declare function permissionRuleIssueDetail(code: unknown, message: unknown, rule?: string): string;
@@ -21,7 +21,7 @@ const ISSUE_MESSAGE_MAX = 200;
21
21
  const ISSUE_SENTENCES = Object.freeze({
22
22
  'invalid.empty_tool': 'this rule is invalid: it names no tool',
23
23
  'invalid.paren': 'this rule is invalid: its parentheses do not parse (escape a literal one as \\( or \\))',
24
- 'invalid.param_split': 'this rule is invalid: the part before the colon is not a parameter name',
24
+ 'invalid.param_split': 'this rule is invalid: its parentheses do not hold a parameter rule written name:pattern',
25
25
  'invalid.allow_param_rule': 'this rule is invalid: an allow rule cannot carry a parameter pattern — only bare tool rules auto-allow',
26
26
  'invalid.primary_field': "this rule is invalid: it patterns the tool's primary field, which matches the whole trimmed string rather than a prefix",
27
27
  'invalid.cap_exceeded': 'this rule set is invalid: it is over one of the deployment caps (rule count, rule length, pattern length, or star count)',
@@ -35,8 +35,27 @@ const ISSUE_SENTENCES = Object.freeze({
35
35
  'unsupported.mcp_paren': 'a parenthesised parameter rule is not supported on an MCP tool name',
36
36
  'unsupported.covering_paren': 'a parenthesised parameter rule is not supported on a covering protocol name — the parameter grammar is keyed by an exact tool name, so no mounted tool could ever bear it',
37
37
  });
38
- export function permissionRuleIssueDetail(code, message) {
39
- const known = typeof code === 'string' && Object.hasOwn(ISSUE_SENTENCES, code) ? ISSUE_SENTENCES[code] : undefined;
38
+ const PARAM_SPLIT_WITH_COLON = 'this rule is invalid: a parameter rule is written name:pattern, and the name before the colon or the pattern after it is empty';
39
+ const PARAM_SPLIT_NO_COLON = 'this rule is invalid: there is no colon inside the parentheses, so this is not a parameter rule (a parameter rule is written name:pattern)';
40
+ function colonInsideParens(rule) {
41
+ if (typeof rule !== 'string')
42
+ return undefined;
43
+ for (let i = 0; i < rule.length; i += 1) {
44
+ const ch = rule[i];
45
+ if (ch === '\\') {
46
+ i += 1;
47
+ continue;
48
+ }
49
+ if (ch === '(')
50
+ return rule.indexOf(':', i + 1) !== -1;
51
+ }
52
+ return undefined;
53
+ }
54
+ export function permissionRuleIssueDetail(code, message, rule) {
55
+ const colon = code === 'invalid.param_split' ? colonInsideParens(rule) : undefined;
56
+ const known = colon !== undefined
57
+ ? colon ? PARAM_SPLIT_WITH_COLON : PARAM_SPLIT_NO_COLON
58
+ : typeof code === 'string' && Object.hasOwn(ISSUE_SENTENCES, code) ? ISSUE_SENTENCES[code] : undefined;
40
59
  const text = typeof message === 'string' && message.length > 0
41
60
  ? capForDisplay(message, ISSUE_MESSAGE_MAX)
42
61
  : '';
@@ -0,0 +1,18 @@
1
+ export type PermissionsAllowGrantReading = {
2
+ kind: 'unobserved';
3
+ } | {
4
+ kind: 'not_reported';
5
+ } | {
6
+ kind: 'present';
7
+ grants: boolean;
8
+ };
9
+ export declare function projectPermissionsAllowGrantCapability(caps: unknown): PermissionsAllowGrantReading | undefined;
10
+ export declare function noteEngineCapsForPermissionsAllowGrant(baseUrl: string, caps: unknown, opts?: {
11
+ generation?: number;
12
+ }): void;
13
+ export declare function observedPermissionsAllowGrant(baseUrl?: string | undefined): PermissionsAllowGrantReading;
14
+ export declare function permissionsAllowGrantAvailable(reading: PermissionsAllowGrantReading): boolean;
15
+ export declare function allowRulesGate(reading: PermissionsAllowGrantReading, settingsRead: 'clean' | 'partial' | 'unreadable' | undefined): 'open' | 'capability_off' | 'settings_read_not_clean';
16
+ export declare function permissionsAllowGrantDoctorDetail(reading: PermissionsAllowGrantReading, settingsRead?: 'clean' | 'partial' | 'unreadable'): string;
17
+ export declare function forgetPermissionsAllowGrantReading(baseUrl: string | undefined): void;
18
+ export declare function __resetPermissionsAllowGrantReadingsForTests(): void;
@@ -0,0 +1,84 @@
1
+ import { engineWireTarget } from './engineWireTarget.js';
2
+ import { createEngineCapReader } from './engineCapReader.js';
3
+ const ALLOW_GRANT_CAP_PATH = ['settings', 'permissions', 'allowGrant'];
4
+ export function projectPermissionsAllowGrantCapability(caps) {
5
+ if (caps === null || typeof caps !== 'object' || Array.isArray(caps))
6
+ return undefined;
7
+ let node = caps;
8
+ for (let i = 0; i < ALLOW_GRANT_CAP_PATH.length; i++) {
9
+ const seg = ALLOW_GRANT_CAP_PATH[i];
10
+ if (!Object.hasOwn(node, seg))
11
+ return { kind: 'not_reported' };
12
+ const v = node[seg];
13
+ if (v === undefined)
14
+ return { kind: 'not_reported' };
15
+ if (i === ALLOW_GRANT_CAP_PATH.length - 1) {
16
+ return typeof v === 'boolean' ? { kind: 'present', grants: v } : undefined;
17
+ }
18
+ if (v === null || typeof v !== 'object' || Array.isArray(v))
19
+ return undefined;
20
+ node = v;
21
+ }
22
+ return undefined;
23
+ }
24
+ const reader = createEngineCapReader({
25
+ name: ALLOW_GRANT_CAP_PATH.join('.'),
26
+ project: projectPermissionsAllowGrantCapability,
27
+ makeUnobserved: () => ({ kind: 'unobserved' }),
28
+ });
29
+ export function noteEngineCapsForPermissionsAllowGrant(baseUrl, caps, opts) {
30
+ reader.note(baseUrl, caps, opts);
31
+ }
32
+ export function observedPermissionsAllowGrant(baseUrl = engineWireTarget()?.baseUrl) {
33
+ return reader.observed(baseUrl);
34
+ }
35
+ export function permissionsAllowGrantAvailable(reading) {
36
+ try {
37
+ if (reading === null || typeof reading !== 'object' || Array.isArray(reading))
38
+ return false;
39
+ if (!Object.hasOwn(reading, 'kind') || !Object.hasOwn(reading, 'grants'))
40
+ return false;
41
+ return reading.kind === 'present' && reading.grants === true;
42
+ }
43
+ catch {
44
+ return false;
45
+ }
46
+ }
47
+ export function allowRulesGate(reading, settingsRead) {
48
+ if (!permissionsAllowGrantAvailable(reading))
49
+ return 'capability_off';
50
+ return settingsRead === 'clean' ? 'open' : 'settings_read_not_clean';
51
+ }
52
+ function ownReadingField(reading, key) {
53
+ try {
54
+ if (reading === null || typeof reading !== 'object' || Array.isArray(reading))
55
+ return undefined;
56
+ return Object.hasOwn(reading, key) ? reading[key] : undefined;
57
+ }
58
+ catch {
59
+ return undefined;
60
+ }
61
+ }
62
+ export function permissionsAllowGrantDoctorDetail(reading, settingsRead) {
63
+ const gate = allowRulesGate(reading, settingsRead);
64
+ if (gate === 'open') {
65
+ return 'allow rules sent to the engine — it reads them as rules, not as an exclusive list: a matching call counts as answered for, and the engine still raises its own prompts where it requires them';
66
+ }
67
+ if (gate === 'settings_read_not_clean') {
68
+ return 'allow rules from settings files kept on this side — this engine reads allow rules as rules, but the settings read that produced them was not reported clean (a settings file was unreadable or had a problem, or no read health was given), so they are not sent; command-line and session allow rules are still sent, and matching approvals are still answered here';
69
+ }
70
+ const kind = ownReadingField(reading, 'kind');
71
+ if (kind === 'present' && ownReadingField(reading, 'grants') === false) {
72
+ return 'allow rules kept on this side — this engine says it does not read allow rules as rules of that kind, so they are not sent and matching approvals are still answered here';
73
+ }
74
+ if (kind === 'not_reported') {
75
+ return 'allow rules kept on this side — this engine does not say how it reads allow rules; sending them to an engine that reads them as an exclusive list would block every tool not on it, so they are not sent and matching approvals are still answered here';
76
+ }
77
+ return 'allow rules kept on this side — no usable capabilities reading is cached for this engine (none received, or the last one was unreadable), so allow rules are not sent and matching approvals are still answered here';
78
+ }
79
+ export function forgetPermissionsAllowGrantReading(baseUrl) {
80
+ reader.forget(baseUrl);
81
+ }
82
+ export function __resetPermissionsAllowGrantReadingsForTests() {
83
+ reader.__resetForTests();
84
+ }
@@ -0,0 +1,48 @@
1
+ import { type PermissionsAllowGrantReading } from './permissionsAllowGrantCapability.js';
2
+ declare const RULE_TRUST_ORDER: readonly ["policySettings", "cliArg", "flagSettings", "session", "userSettings", "localSettings", "projectSettings"];
3
+ export type WireRuleOrigin = (typeof RULE_TRUST_ORDER)[number];
4
+ export interface WireRuleOrigins {
5
+ readonly deny?: ReadonlyMap<string, WireRuleOrigin>;
6
+ readonly ask?: ReadonlyMap<string, WireRuleOrigin>;
7
+ readonly allow?: ReadonlyMap<string, WireRuleOrigin>;
8
+ }
9
+ export interface PermissionsDeclarationInput {
10
+ readonly deny: readonly string[];
11
+ readonly ask: readonly string[];
12
+ readonly allow: readonly string[];
13
+ readonly origins?: WireRuleOrigins;
14
+ readonly cliDeny?: readonly string[];
15
+ readonly settingsRead: 'clean' | 'partial' | 'unreadable';
16
+ }
17
+ export interface PermissionsDeclarationBuckets {
18
+ deny?: string[];
19
+ ask?: string[];
20
+ allow?: string[];
21
+ }
22
+ export interface PermissionsDeclaration {
23
+ permissions?: PermissionsDeclarationBuckets;
24
+ }
25
+ export declare const PERMISSIONS_KEPT_REASONS: readonly ["allow_capability_off", "settings_read_not_clean", "empty_rule", "paren_in_tool_name", "retired_tool_name", "unprefixed_namespaced_name", "incomplete_protocol_name", "home_relative_path", "compile_refused", "content_form_not_grantable", "judge_failed", "duplicate"];
26
+ export type PermissionsKeptReason = (typeof PERMISSIONS_KEPT_REASONS)[number];
27
+ export interface PermissionsKeptRule {
28
+ rule: string;
29
+ bucket: 'deny' | 'ask' | 'allow';
30
+ reason: PermissionsKeptReason;
31
+ }
32
+ export interface PermissionsRewrittenRule {
33
+ from: string;
34
+ to: string;
35
+ bucket: 'deny' | 'ask' | 'allow';
36
+ }
37
+ export interface PermissionsUncheckedRule {
38
+ rule: string;
39
+ bucket: 'deny' | 'ask';
40
+ }
41
+ export interface PermissionsDeclarationReport extends PermissionsDeclaration {
42
+ kept: PermissionsKeptRule[];
43
+ rewritten: PermissionsRewrittenRule[];
44
+ unchecked: PermissionsUncheckedRule[];
45
+ }
46
+ export declare function permissionsDeclaration(input: PermissionsDeclarationInput, caps: PermissionsAllowGrantReading): PermissionsDeclaration;
47
+ export declare function permissionsDeclarationReport(input: PermissionsDeclarationInput, caps: PermissionsAllowGrantReading): PermissionsDeclarationReport;
48
+ export {};