@sema-agent/client-core 0.100.0 → 0.102.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.
- package/CHANGELOG.md +452 -0
- package/README.md +172 -120
- package/dist/adapt/arms.js +51 -16
- package/dist/adapt/textStream.js +7 -4
- package/dist/adapt/toolCards.d.ts +2 -1
- package/dist/adapt/toolCards.js +28 -13
- package/dist/adapt.d.ts +1 -1
- package/dist/adapt.js +8 -2
- package/dist/adapter/activeRunSelfHeal.d.ts +24 -2
- package/dist/adapter/activeRunSelfHeal.js +108 -6
- package/dist/adapter/downstream/eventToSdkMessage.js +38 -79
- package/dist/adapter/downstream/terminalToSdkResult.d.ts +60 -1
- package/dist/adapter/downstream/terminalToSdkResult.js +209 -39
- package/dist/adapter/downstream/wiringManifestView.d.ts +1 -0
- package/dist/adapter/downstream/wiringManifestView.js +138 -0
- package/dist/adapter/runStream.d.ts +4 -4
- package/dist/adapter/runStream.js +158 -43
- package/dist/agentsWireCaps.d.ts +2 -7
- package/dist/agentsWireCaps.js +1 -2
- package/dist/approvalDecidedByCapability.js +2 -2
- package/dist/approvalFrameFamilies.d.ts +33 -0
- package/dist/approvalFrameFamilies.js +120 -0
- package/dist/approvalsStreamLiveCapability.js +2 -2
- package/dist/attachmentsWireCaps.js +41 -13
- package/dist/callerCwdCapability.js +2 -2
- package/dist/centerWiringCapability.js +2 -2
- package/dist/clockReading.d.ts +2 -0
- package/dist/clockReading.js +4 -0
- package/dist/cloudConfigWireCaps.d.ts +19 -5
- package/dist/cloudConfigWireCaps.js +193 -56
- package/dist/compensations.js +1 -1
- package/dist/coreValuePorts.d.ts +12 -2
- package/dist/coreValuePorts.js +9 -0
- package/dist/decideFailureNote.js +5 -3
- package/dist/decideReceipt.js +2 -2
- package/dist/deviceExecutorManagementCapability.js +2 -2
- package/dist/deviceFlowPolling.js +1 -1
- package/dist/disableSkillsWire.d.ts +1 -1
- package/dist/disableSkillsWire.js +4 -3
- package/dist/displayUntrusted.d.ts +9 -4
- package/dist/displayUntrusted.js +834 -104
- package/dist/engineCapReader.js +1 -1
- package/dist/engineConfigDrift.js +1 -1
- package/dist/engineErrorCodes.d.ts +14 -5
- package/dist/engineErrorCodes.js +27 -6
- package/dist/engineGenerationConvergence.d.ts +39 -0
- package/dist/engineGenerationConvergence.js +95 -0
- package/dist/engineGenerationPort.d.ts +61 -0
- package/dist/engineGenerationPort.js +144 -0
- package/dist/engineHealthFacts.d.ts +23 -0
- package/dist/engineHealthFacts.js +92 -0
- package/dist/engineIdentity.d.ts +4 -0
- package/dist/engineIdentity.js +11 -0
- package/dist/engineNoticeCodes.d.ts +2 -5
- package/dist/engineRowRef.js +4 -0
- package/dist/engineSessionMessages.js +2 -2
- package/dist/engineToolDirectory.js +2 -2
- package/dist/engineWireFor.d.ts +99 -0
- package/dist/engineWireFor.js +248 -6
- package/dist/engineWireTarget.d.ts +1 -0
- package/dist/engineWireTarget.js +8 -0
- package/dist/env/uiLanguage.js +1 -1
- package/dist/errorSupplementRoles.d.ts +3 -0
- package/dist/errorSupplementRoles.js +37 -0
- package/dist/executionLaneCapability.js +2 -2
- package/dist/fileHistoryCaptureCapability.js +3 -3
- package/dist/finalVerifyWire.d.ts +6 -3
- package/dist/finalVerifyWire.js +6 -23
- package/dist/flagInput.d.ts +4 -0
- package/dist/flagInput.js +24 -0
- package/dist/fleet/fleetLedger.js +5 -2
- package/dist/fleet/fleetProjection.d.ts +1 -0
- package/dist/fleet/fleetProjection.js +16 -3
- package/dist/gateVocabulary.js +3 -0
- package/dist/generated/engineFactTables.d.ts +7 -3
- package/dist/generated/engineFactTables.js +52 -0
- package/dist/generated/engineNoticeTables.js +12 -0
- package/dist/generated/settingsSchemaActiveTiers.d.ts +1 -0
- package/dist/generated/settingsSchemaActiveTiers.js +14 -0
- package/dist/generated/settingsSchemaCallerTextEcho.d.ts +1 -0
- package/dist/generated/settingsSchemaCallerTextEcho.js +8 -0
- package/dist/generated/settingsSchemaControlAndBidi.d.ts +1 -0
- package/dist/generated/settingsSchemaControlAndBidi.js +8 -0
- package/dist/generated/settingsSchemaDefaultModel.d.ts +11 -0
- package/dist/generated/settingsSchemaDefaultModel.js +25 -0
- package/dist/generated/settingsSchemaFns.d.ts +54 -0
- package/dist/generated/settingsSchemaFns.js +26 -1
- package/dist/generated/settingsSchemaMcpRequestEntry.d.ts +1 -1
- package/dist/generated/settingsSchemaMcpRequestEntry.js +1 -7
- package/dist/generated/settingsSchemaSafetyMergeSpec.d.ts +1 -0
- package/dist/generated/settingsSchemaSafetyMergeSpec.js +95 -0
- package/dist/generated/settingsSchemaSettingsSources.d.ts +1 -0
- package/dist/generated/settingsSchemaSettingsSources.js +58 -0
- package/dist/generated/settingsSchemaTables.d.ts +2 -0
- package/dist/generated/settingsSchemaTables.js +13 -0
- package/dist/generated/settingsSchemaUrlPattern.d.ts +1 -0
- package/dist/generated/settingsSchemaUrlPattern.js +183 -0
- package/dist/headlessPermissionModeWire.d.ts +18 -2
- package/dist/headlessPermissionModeWire.js +30 -19
- package/dist/hitl/allowRuleShadow.js +7 -5
- package/dist/hitl/approvalCardReading.d.ts +3 -0
- package/dist/hitl/approvalCardReading.js +17 -0
- package/dist/hitl/approvalCompleteParked.js +1 -1
- package/dist/hitl/approvalDelivery.d.ts +87 -0
- package/dist/hitl/approvalDelivery.js +193 -0
- package/dist/hitl/approvalResolution.d.ts +11 -0
- package/dist/hitl/approvalResolution.js +50 -11
- package/dist/hitl/askClassPair.d.ts +6 -0
- package/dist/hitl/askClassPair.js +30 -3
- package/dist/hitl/askParkAutoReopenBlock.d.ts +30 -0
- package/dist/hitl/askParkAutoReopenBlock.js +117 -0
- package/dist/hitl/askParkRowRouting.js +4 -1
- package/dist/hitl/attributionLadder.d.ts +42 -3
- package/dist/hitl/attributionLadder.js +79 -8
- package/dist/hitl/automaticAnswerVerdict.d.ts +6 -1
- package/dist/hitl/automaticAnswerVerdict.js +46 -11
- package/dist/hitl/crashConverged.js +2 -2
- package/dist/hitl/decisionConflict.d.ts +6 -2
- package/dist/hitl/decisionConflict.js +24 -9
- package/dist/hitl/decisionRefusal.d.ts +20 -10
- package/dist/hitl/decisionRefusal.js +99 -54
- package/dist/hitl/decisionSend.d.ts +3 -0
- package/dist/hitl/decisionSend.js +87 -103
- package/dist/hitl/frameRouter.d.ts +1 -0
- package/dist/hitl/frameRouter.js +9 -2
- package/dist/hitl/hitlBridge.d.ts +18 -6
- package/dist/hitl/hitlBridge.js +41 -37
- package/dist/hitl/livePendingAsk.js +4 -3
- package/dist/hitl/noAllowCause.js +1 -1
- package/dist/hitl/parkResolver.js +3 -2
- package/dist/hitl/persistedRulesWire.js +1 -0
- package/dist/hitl/planReviewWire.d.ts +4 -0
- package/dist/hitl/planReviewWire.js +59 -30
- package/dist/hitl/resumeRunningCard.d.ts +3 -2
- package/dist/hitl/resumeRunningCard.js +17 -11
- package/dist/hitl/sessionPolicyDeliverable.d.ts +5 -2
- package/dist/hitl/sessionPolicyDeliverable.js +62 -29
- package/dist/hitl/sessionPolicyWire.d.ts +13 -3
- package/dist/hitl/sessionPolicyWire.js +81 -16
- package/dist/hitl/standingRows.js +1 -1
- package/dist/hitl/toolApprovalWire.d.ts +9 -10
- package/dist/hitl/toolApprovalWire.js +72 -54
- package/dist/hookMatcherVerdict.d.ts +2 -0
- package/dist/hookMatcherVerdict.js +12 -0
- package/dist/hooksCompactTransition.d.ts +19 -0
- package/dist/hooksCompactTransition.js +41 -0
- package/dist/hooksWireCaps.d.ts +1 -1
- package/dist/hooksWireCaps.js +202 -203
- package/dist/host.d.ts +1 -14
- package/dist/host.js +0 -8
- package/dist/hostCallbackGuard.d.ts +1 -0
- package/dist/hostCallbackGuard.js +1 -1
- package/dist/hostSettingsSource.d.ts +172 -0
- package/dist/hostSettingsSource.js +675 -0
- package/dist/hostTurnSettings.d.ts +73 -17
- package/dist/hostTurnSettings.js +594 -97
- package/dist/httpHookPolicy.d.ts +37 -0
- package/dist/httpHookPolicy.js +176 -0
- package/dist/humanTurn.d.ts +2 -1
- package/dist/humanTurn.js +37 -7
- package/dist/humanTurnRead.js +4 -3
- package/dist/humanTurnSentences.d.ts +10 -0
- package/dist/humanTurnSentences.js +74 -0
- package/dist/i18n/messages.en.d.ts +222 -2
- package/dist/i18n/messages.en.js +225 -5
- package/dist/i18n/messages.zh.js +237 -5
- package/dist/i18n/translate.js +3 -3
- package/dist/index.d.ts +77 -15
- package/dist/index.js +50 -13
- package/dist/inheritEnvCapability.d.ts +3 -1
- package/dist/inheritEnvCapability.js +31 -17
- package/dist/inheritEnvWire.d.ts +2 -1
- package/dist/inheritEnvWire.js +11 -5
- package/dist/interactiveHalt.d.ts +3 -1
- package/dist/interactiveHalt.js +2 -0
- package/dist/interactiveInterrupt.d.ts +2 -0
- package/dist/interactiveInterrupt.js +15 -0
- package/dist/interactiveToolsWire.d.ts +4 -2
- package/dist/interactiveToolsWire.js +5 -5
- package/dist/jsonFaithful.d.ts +20 -0
- package/dist/jsonFaithful.js +152 -0
- package/dist/limitsWire.d.ts +7 -2
- package/dist/limitsWire.js +19 -13
- package/dist/liveInitToolFace.d.ts +6 -1
- package/dist/liveInitToolFace.js +5 -3
- package/dist/liveModelCatalog.d.ts +22 -0
- package/dist/liveModelCatalog.js +132 -18
- package/dist/mcpPanel.js +1 -1
- package/dist/mcpProbeCapability.js +2 -2
- package/dist/mcpStatusSupersetKeys.d.ts +24 -0
- package/dist/mcpStatusSupersetKeys.js +45 -0
- package/dist/mcpToolToggles.js +2 -1
- package/dist/mcpWireCaps.d.ts +39 -1
- package/dist/mcpWireCaps.js +254 -50
- package/dist/memoryComplianceCapability.js +2 -2
- package/dist/memoryOriginCapability.js +2 -2
- package/dist/model/catalogDefault.d.ts +24 -0
- package/dist/model/catalogDefault.js +4 -0
- package/dist/model/liveCatalogShape.js +5 -4
- package/dist/model/modelsPolicy.js +4 -3
- package/dist/model/onboardJudgement.d.ts +1 -0
- package/dist/model/onboardJudgement.js +1 -1
- package/dist/model/subagentModelWord.js +2 -2
- package/dist/modelCapabilityProbe.js +6 -6
- package/dist/modelIdentityResolvability.d.ts +10 -1
- package/dist/modelIdentityResolvability.js +62 -39
- package/dist/modsFace.d.ts +8 -0
- package/dist/modsFace.js +59 -0
- package/dist/modsKernelIdentity.d.ts +10 -0
- package/dist/modsKernelIdentity.js +103 -0
- package/dist/modsKernelTransit.d.ts +8 -0
- package/dist/modsKernelTransit.js +6 -0
- package/dist/notifications.d.ts +30 -12
- package/dist/notifications.js +241 -53
- package/dist/outputStyleSeatCapability.js +2 -2
- package/dist/ownKey.d.ts +12 -0
- package/dist/ownKey.js +179 -3
- package/dist/panelReduce.js +1 -1
- package/dist/peerFrames.d.ts +1 -1
- package/dist/peerFrames.js +6 -2
- package/dist/peerLaneCapability.js +2 -2
- package/dist/permissionModesCapability.js +4 -4
- package/dist/permissionRuleIssue.js +2 -0
- package/dist/permissionRulesWriteCapability.js +2 -2
- package/dist/permissionsAllowGrantCapability.js +2 -2
- package/dist/permissionsDeclaration.d.ts +43 -4
- package/dist/permissionsDeclaration.js +102 -35
- package/dist/pluginHooksWire.d.ts +20 -4
- package/dist/pluginHooksWire.js +92 -53
- package/dist/prepareRefusal.d.ts +3 -2
- package/dist/prepareRefusal.js +27 -9
- package/dist/printInitToolFace.js +2 -2
- package/dist/printModelStatus.js +1 -1
- package/dist/printToolResultFrame.js +1 -1
- package/dist/projectMemory.d.ts +32 -0
- package/dist/projectMemory.js +70 -0
- package/dist/promptBlockedCopy.d.ts +2 -1
- package/dist/promptBlockedCopy.js +2 -1
- package/dist/promptDelivery.d.ts +23 -3
- package/dist/promptDelivery.js +169 -30
- package/dist/providerRejection.d.ts +19 -1
- package/dist/providerRejection.js +75 -4
- package/dist/queuedDelivery.d.ts +48 -0
- package/dist/queuedDelivery.js +233 -0
- package/dist/reattachWindow.d.ts +94 -0
- package/dist/reattachWindow.js +127 -0
- package/dist/request/printNotification.d.ts +1 -1
- package/dist/request/printNotification.js +6 -2
- package/dist/request/submissionIdentity.d.ts +37 -0
- package/dist/request/submissionIdentity.js +65 -0
- package/dist/request/taskRequest.d.ts +33 -4
- package/dist/request/taskRequest.js +341 -156
- package/dist/resultFrameKeys.d.ts +1 -0
- package/dist/resultFrameKeys.js +4 -1
- package/dist/retryStatus.d.ts +8 -0
- package/dist/retryStatus.js +57 -9
- package/dist/rewindArchiveCapability.js +2 -2
- package/dist/rewindEngineAction.d.ts +2 -0
- package/dist/rewindEngineAction.js +23 -1
- package/dist/rowKind.d.ts +36 -0
- package/dist/rowKind.js +97 -0
- package/dist/ruleCompileVerdict.d.ts +18 -0
- package/dist/ruleCompileVerdict.js +67 -2
- package/dist/ruleReadings.d.ts +58 -0
- package/dist/ruleReadings.js +132 -0
- package/dist/ruleRefusalSentence.d.ts +4 -0
- package/dist/ruleRefusalSentence.js +9 -3
- package/dist/runCancelContext.d.ts +0 -1
- package/dist/runCancelContext.js +1 -2
- package/dist/runTerminal.d.ts +5 -0
- package/dist/runTerminal.js +52 -17
- package/dist/sandboxWire.d.ts +1 -1
- package/dist/sandboxWire.js +4 -6
- package/dist/scenarioRefusal.js +1 -1
- package/dist/scenarioSkills.d.ts +20 -0
- package/dist/scenarioSkills.js +72 -0
- package/dist/scenarioWire.d.ts +5 -2
- package/dist/scenarioWire.js +9 -9
- package/dist/sealedKeyCapability.js +2 -2
- package/dist/seam.d.ts +2 -0
- package/dist/seam.js +3 -3
- package/dist/seatContract.d.ts +68 -7
- package/dist/seatContract.js +84 -25
- package/dist/selfOrchestrationDenial.js +1 -1
- package/dist/sessionBackground.d.ts +165 -0
- package/dist/sessionBackground.js +781 -0
- package/dist/sessionBackgroundHandoff.d.ts +54 -0
- package/dist/sessionBackgroundHandoff.js +321 -0
- package/dist/sessionMap.js +4 -1
- package/dist/sessionPolicyCapability.js +2 -2
- package/dist/sessionRulesChildrenReadLive.d.ts +6 -0
- package/dist/sessionRulesChildrenReadLive.js +5 -0
- package/dist/sessionRulesNamespaceFormsCapability.d.ts +12 -0
- package/dist/sessionRulesNamespaceFormsCapability.js +29 -0
- package/dist/sessionSyncFileHistoryCapability.js +2 -2
- package/dist/settingsCredentialKeyPaths.js +55 -15
- package/dist/settingsHooksSalvage.d.ts +1 -0
- package/dist/settingsHooksSalvage.js +7 -1
- package/dist/settingsLayerAdmission.d.ts +4 -0
- package/dist/settingsLayerAdmission.js +16 -0
- package/dist/skillToolListsCapability.js +6 -5
- package/dist/skillsWireCaps.d.ts +14 -0
- package/dist/skillsWireCaps.js +47 -16
- package/dist/slashCommandGate.d.ts +24 -0
- package/dist/slashCommandGate.js +74 -0
- package/dist/slashCommandTable.d.ts +14 -0
- package/dist/slashCommandTable.js +99 -0
- package/dist/sqlEngineCapability.js +2 -2
- package/dist/steerPriorityCapability.js +2 -2
- package/dist/storePostureCapability.js +2 -2
- package/dist/subagent/agentStateDetail.js +1 -1
- package/dist/subagent/engineDelegatedPrompt.d.ts +9 -0
- package/dist/subagent/engineDelegatedPrompt.js +38 -7
- package/dist/subagent/engineRowStopGate.js +2 -2
- package/dist/subagent/engineSubagentResume.js +3 -3
- package/dist/subagent/engineTaskHandleWire.d.ts +1 -0
- package/dist/subagent/engineTaskHandleWire.js +10 -0
- package/dist/submitFailure.d.ts +8 -0
- package/dist/submitFailure.js +17 -0
- package/dist/supportFloor.d.ts +1 -0
- package/dist/supportFloor.js +7 -0
- package/dist/terminationIntent.d.ts +55 -0
- package/dist/terminationIntent.js +352 -0
- package/dist/thinkingLatch.d.ts +69 -0
- package/dist/thinkingLatch.js +255 -0
- package/dist/thinkingLatchWords.d.ts +7 -0
- package/dist/thinkingLatchWords.js +4 -0
- package/dist/toolHistoryMismatch.d.ts +8 -0
- package/dist/toolHistoryMismatch.js +37 -6
- package/dist/toolResult.d.ts +13 -3
- package/dist/toolResult.js +159 -32
- package/dist/toolResultContent.d.ts +13 -0
- package/dist/toolResultContent.js +82 -7
- package/dist/toolRoster.d.ts +18 -0
- package/dist/toolRoster.js +64 -0
- package/dist/turnFailurePresentation.js +27 -90
- package/dist/usageLimitAutoResume.d.ts +74 -0
- package/dist/usageLimitAutoResume.js +227 -0
- package/dist/userAttachmentEnvelope.js +1 -1
- package/dist/userAttachmentSeat.js +5 -5
- package/dist/userInvokedSkillsCapability.js +2 -2
- package/dist/webSearchBackendCapability.js +2 -2
- package/dist/wireErrorTriage.js +99 -50
- package/dist/wireFailureShape.d.ts +25 -1
- package/dist/wireFailureShape.js +92 -5
- package/dist/wireRefusalCopy.d.ts +24 -1
- package/dist/wireRefusalCopy.js +253 -32
- package/dist/wiringFleetDoctor.d.ts +3 -0
- package/dist/wiringFleetDoctor.js +21 -0
- package/dist/workflow.d.ts +2 -1
- package/dist/workflow.js +38 -1
- package/dist/workflowClient.d.ts +2 -7
- package/dist/workflowsJournalCapability.js +2 -2
- package/dist/writeProtectionCapability.js +2 -2
- package/docs/INTEGRATION-CLIENTS.md +907 -182
- package/package.json +14 -3
- package/dist/argvFlagValue.d.ts +0 -8
- package/dist/argvFlagValue.js +0 -37
package/dist/peerFrames.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export type CrossSessionNoticeFrame = {
|
|
|
28
28
|
text: string;
|
|
29
29
|
};
|
|
30
30
|
export type PeerFrameProjection = AgentMessageFrame | CrossSessionMessageFrame | CrossSessionNoticeFrame;
|
|
31
|
-
export declare function classifyPeerNotification(
|
|
31
|
+
export declare function classifyPeerNotification(raw: Record<string, unknown>): PeerFrameProjection | null;
|
|
32
32
|
export declare function renderPeerFrameTranscriptText(p: PeerFrameProjection): string;
|
|
33
33
|
export declare function parsePeerFrameText(text: string): AgentMessageFrame | CrossSessionMessageFrame | null;
|
|
34
34
|
export declare function peerFrameDisplayName(p: AgentMessageFrame | CrossSessionMessageFrame): string;
|
package/dist/peerFrames.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { applyDisplayFace, PEER_NAME_FACE } from './displayUntrusted.js';
|
|
2
|
+
import { ownSnapshotRecord } from './ownKey.js';
|
|
2
3
|
import { CORE_ENGINE_AUTHORITY_ENVELOPE_TAGS, CORE_PERMISSION_MODE_CLASSES } from './generated/engineFactTables.js';
|
|
3
4
|
const WIRE_KEY_FROM = 'from';
|
|
4
5
|
const WIRE_KEY_BODY = 'body';
|
|
@@ -32,7 +33,7 @@ function dataProp(o, key) {
|
|
|
32
33
|
catch {
|
|
33
34
|
return undefined;
|
|
34
35
|
}
|
|
35
|
-
if (d === undefined || !('value'
|
|
36
|
+
if (d === undefined || !Object.hasOwn(d, 'value'))
|
|
36
37
|
return undefined;
|
|
37
38
|
return d.value;
|
|
38
39
|
}
|
|
@@ -59,7 +60,10 @@ function provenanceAgrees(n, lane, carrierFromRaw) {
|
|
|
59
60
|
const seq = finiteNumber(dataProp(n, WIRE_KEY_SEQ));
|
|
60
61
|
return seq !== undefined && finiteNumber(dataProp(prov, WIRE_KEY_SEQ)) === seq;
|
|
61
62
|
}
|
|
62
|
-
export function classifyPeerNotification(
|
|
63
|
+
export function classifyPeerNotification(raw) {
|
|
64
|
+
const n = ownSnapshotRecord(raw);
|
|
65
|
+
if (n === undefined)
|
|
66
|
+
return null;
|
|
63
67
|
const seq = finiteNumber(dataProp(n, WIRE_KEY_SEQ));
|
|
64
68
|
const agentMessage = dataProp(n, WIRE_KEY_AGENT_MESSAGE);
|
|
65
69
|
if (agentMessage !== undefined) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { engineWireTargetBaseUrl } from './engineWireTarget.js';
|
|
2
2
|
import { createEngineCapReader, unreadableReadingDetail } from './engineCapReader.js';
|
|
3
3
|
import { ownDataField } from './ownKey.js';
|
|
4
4
|
export function projectPeerLaneCapability(caps) {
|
|
@@ -22,7 +22,7 @@ const reader = createEngineCapReader({
|
|
|
22
22
|
name: 'peerLane',
|
|
23
23
|
project: projectPeerLaneCapability,
|
|
24
24
|
});
|
|
25
|
-
export function observedPeerLane(baseUrl =
|
|
25
|
+
export function observedPeerLane(baseUrl = engineWireTargetBaseUrl()) {
|
|
26
26
|
return reader.observed(baseUrl);
|
|
27
27
|
}
|
|
28
28
|
export function peerLaneAvailable(reading) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { engineWireTargetBaseUrl } from './engineWireTarget.js';
|
|
2
2
|
import { createEngineCapReader } from './engineCapReader.js';
|
|
3
|
-
import { ownDataField, readOwnDataValue } from './ownKey.js';
|
|
3
|
+
import { appendOwnElement, ownDataField, readOwnDataValue } from './ownKey.js';
|
|
4
4
|
function readModesStrict(v) {
|
|
5
5
|
try {
|
|
6
6
|
if (!Array.isArray(v))
|
|
@@ -13,7 +13,7 @@ function readModesStrict(v) {
|
|
|
13
13
|
const item = ownDataField(v, String(i));
|
|
14
14
|
if (typeof item !== 'string' || item.length === 0)
|
|
15
15
|
return undefined;
|
|
16
|
-
modes
|
|
16
|
+
appendOwnElement(modes, item);
|
|
17
17
|
}
|
|
18
18
|
return modes;
|
|
19
19
|
}
|
|
@@ -39,7 +39,7 @@ const reader = createEngineCapReader({
|
|
|
39
39
|
name: 'permissionModes',
|
|
40
40
|
project: projectPermissionModesCapability,
|
|
41
41
|
});
|
|
42
|
-
export function observedPermissionModes(baseUrl =
|
|
42
|
+
export function observedPermissionModes(baseUrl = engineWireTargetBaseUrl()) {
|
|
43
43
|
return reader.observed(baseUrl);
|
|
44
44
|
}
|
|
45
45
|
export function permissionModeAdmitted(reading, mode) {
|
|
@@ -14,6 +14,7 @@ export const PERMISSION_RULE_ISSUE_CODES = Object.freeze([
|
|
|
14
14
|
'unsupported.param_unknown',
|
|
15
15
|
'unsupported.param_non_scalar',
|
|
16
16
|
'unsupported.tool_unknown',
|
|
17
|
+
'invalid.name_ambiguous',
|
|
17
18
|
'unsupported.path_base',
|
|
18
19
|
'unsupported.mcp_paren',
|
|
19
20
|
'unsupported.covering_paren',
|
|
@@ -30,6 +31,7 @@ const ISSUE_SENTENCES = Object.freeze({
|
|
|
30
31
|
'invalid.behavior': 'rules.issue.behavior',
|
|
31
32
|
'invalid.command_rule': 'rules.issue.commandRule',
|
|
32
33
|
'invalid.entry_type': 'rules.issue.entryType',
|
|
34
|
+
'invalid.name_ambiguous': 'rules.issue.nameAmbiguous',
|
|
33
35
|
'unsupported.allow': 'rules.issue.allowRule',
|
|
34
36
|
'unsupported.param_unknown': 'rules.issue.paramUnknown',
|
|
35
37
|
'unsupported.param_non_scalar': 'rules.issue.paramNonScalar',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { engineWireTargetBaseUrl } from './engineWireTarget.js';
|
|
2
2
|
import { createEngineCapReader, unreadableReadingDetail } from './engineCapReader.js';
|
|
3
3
|
import { msg, renderMessage } from './i18n/translate.js';
|
|
4
4
|
import { ownDataField } from './ownKey.js';
|
|
@@ -23,7 +23,7 @@ const reader = createEngineCapReader({
|
|
|
23
23
|
name: 'permissionRulesWrite',
|
|
24
24
|
project: projectPermissionRulesWriteCapability,
|
|
25
25
|
});
|
|
26
|
-
export function observedPermissionRulesWrite(baseUrl =
|
|
26
|
+
export function observedPermissionRulesWrite(baseUrl = engineWireTargetBaseUrl()) {
|
|
27
27
|
return reader.observed(baseUrl);
|
|
28
28
|
}
|
|
29
29
|
export function permissionRulesWriteAvailable(reading) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { engineWireTargetBaseUrl } from './engineWireTarget.js';
|
|
2
2
|
import { createEngineCapReader, unreadableReadingDetail } from './engineCapReader.js';
|
|
3
3
|
import { ownDataField } from './ownKey.js';
|
|
4
4
|
import { hasCoreValuePort } from './coreValuePorts.js';
|
|
@@ -36,7 +36,7 @@ const reader = createEngineCapReader({
|
|
|
36
36
|
name: ALLOW_GRANT_CAP_PATH.join('.'),
|
|
37
37
|
project: projectPermissionsAllowGrantCapability,
|
|
38
38
|
});
|
|
39
|
-
export function observedPermissionsAllowGrant(baseUrl =
|
|
39
|
+
export function observedPermissionsAllowGrant(baseUrl = engineWireTargetBaseUrl()) {
|
|
40
40
|
return reader.observed(baseUrl);
|
|
41
41
|
}
|
|
42
42
|
export function permissionsAllowGrantAvailable(reading) {
|
|
@@ -1,7 +1,21 @@
|
|
|
1
|
+
import { type CoreValuePortName } from './coreValuePorts.js';
|
|
1
2
|
import { type PermissionsAllowGrantReading } from './permissionsAllowGrantCapability.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
declare const SETTINGS_SOURCE_TIERS: Readonly<{
|
|
4
|
+
readonly policySettings: "managed";
|
|
5
|
+
readonly flagSettings: "global";
|
|
6
|
+
readonly userSettings: "global";
|
|
7
|
+
readonly localSettings: "project";
|
|
8
|
+
readonly projectSettings: "project";
|
|
9
|
+
}>;
|
|
10
|
+
declare const OFF_LADDER_ROWS: readonly [{
|
|
11
|
+
readonly origin: "cliArg";
|
|
12
|
+
readonly after: "policySettings";
|
|
13
|
+
}, {
|
|
14
|
+
readonly origin: "session";
|
|
15
|
+
readonly after: "flagSettings";
|
|
16
|
+
}];
|
|
17
|
+
export type WireRuleOrigin = keyof typeof SETTINGS_SOURCE_TIERS | (typeof OFF_LADDER_ROWS)[number]['origin'];
|
|
18
|
+
export declare const WIRE_RULE_TRUST_ORDER: readonly WireRuleOrigin[];
|
|
5
19
|
export interface WireRuleOrigins {
|
|
6
20
|
readonly deny?: ReadonlyMap<string, WireRuleOrigin>;
|
|
7
21
|
readonly ask?: ReadonlyMap<string, WireRuleOrigin>;
|
|
@@ -15,6 +29,7 @@ export interface PermissionsDeclarationInput {
|
|
|
15
29
|
readonly cliDeny?: readonly string[];
|
|
16
30
|
readonly settingsRead: 'clean' | 'partial' | 'unreadable';
|
|
17
31
|
readonly clientOwnedServers?: readonly string[];
|
|
32
|
+
readonly serverVersion?: string;
|
|
18
33
|
}
|
|
19
34
|
export interface PermissionsDeclarationBuckets {
|
|
20
35
|
deny?: string[];
|
|
@@ -24,7 +39,7 @@ export interface PermissionsDeclarationBuckets {
|
|
|
24
39
|
export interface PermissionsDeclaration {
|
|
25
40
|
permissions?: PermissionsDeclarationBuckets;
|
|
26
41
|
}
|
|
27
|
-
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", "unminted_protocol_segment", "home_relative_path", "compile_refused", "content_form_not_grantable", "judge_failed", "duplicate", "voids_allow_list"];
|
|
42
|
+
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", "unminted_protocol_segment", "home_relative_path", "compile_refused", "content_form_not_grantable", "content_form_never_matches", "judge_failed", "duplicate", "voids_allow_list"];
|
|
28
43
|
export type PermissionsKeptReason = (typeof PERMISSIONS_KEPT_REASONS)[number];
|
|
29
44
|
export interface PermissionsKeptRule {
|
|
30
45
|
rule: string;
|
|
@@ -49,8 +64,32 @@ export interface PermissionsClientOwnedStatement {
|
|
|
49
64
|
sent: boolean;
|
|
50
65
|
reason?: PermissionsKeptReason;
|
|
51
66
|
}
|
|
67
|
+
export interface RulePortsProjection {
|
|
68
|
+
readonly kind: 'rule-ports-projection';
|
|
69
|
+
}
|
|
70
|
+
export declare function newRulePortsProjection(): RulePortsProjection;
|
|
71
|
+
export declare function rulePortsMissingOf(thrown: {} | null | undefined, projection: RulePortsProjection): readonly CoreValuePortName[] | undefined;
|
|
72
|
+
type RuleFate = {
|
|
73
|
+
readonly sent: true;
|
|
74
|
+
readonly wire: string;
|
|
75
|
+
} | {
|
|
76
|
+
readonly sent: false;
|
|
77
|
+
readonly reason: PermissionsKeptReason;
|
|
78
|
+
readonly code?: string;
|
|
79
|
+
readonly message?: string;
|
|
80
|
+
};
|
|
81
|
+
export type AssembledRuleFate = RuleFate;
|
|
82
|
+
export interface AssembledRuleRow {
|
|
83
|
+
readonly rule: string;
|
|
84
|
+
readonly list: 'deny' | 'cliDeny' | 'ask' | 'allow';
|
|
85
|
+
readonly bucket: 'deny' | 'ask' | 'allow';
|
|
86
|
+
readonly origin?: WireRuleOrigin;
|
|
87
|
+
readonly fate: AssembledRuleFate;
|
|
88
|
+
}
|
|
52
89
|
export declare function permissionsDeclaration(input: PermissionsDeclarationInput, caps: PermissionsAllowGrantReading): PermissionsDeclaration;
|
|
90
|
+
export declare function projectPermissionsDeclaration(input: PermissionsDeclarationInput, caps: PermissionsAllowGrantReading, projection: RulePortsProjection): PermissionsDeclaration;
|
|
53
91
|
export declare function permissionsDeclarationReport(input: PermissionsDeclarationInput, caps: PermissionsAllowGrantReading): PermissionsDeclarationReport;
|
|
92
|
+
export declare function assembledRuleRows(input: PermissionsDeclarationInput, caps: PermissionsAllowGrantReading): readonly AssembledRuleRow[];
|
|
54
93
|
export interface PermissionsAllowKeptFacts {
|
|
55
94
|
readonly problemCount?: number;
|
|
56
95
|
readonly managedPolicyPending?: true;
|
|
@@ -1,18 +1,40 @@
|
|
|
1
1
|
import { compileAllowList, hasCoreValuePort, protocolOf, ruleToolGrammarOf } from './coreValuePorts.js';
|
|
2
2
|
import { clientOwnedServerPrefix, ruleToolNameVerdictOf } from './protocolSegment.js';
|
|
3
|
-
import { ruleCompileVerdict } from './ruleCompileVerdict.js';
|
|
3
|
+
import { ruleCompileVerdict, tightenEntryNeverMatches } from './ruleCompileVerdict.js';
|
|
4
4
|
import { allowRulesGate, allowWireForm } from './permissionsAllowGrantCapability.js';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
'
|
|
10
|
-
'
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
import { SETTINGS_IS_AT_LEAST } from './generated/settingsSchemaFns.js';
|
|
6
|
+
import { THROWN_SLOT_UNREADABLE, asAssemblyRefusal, assemblyRefusalOf, isSlotCarrier, readThrownSlot, withAssemblyRefusal } from './wireFailureShape.js';
|
|
7
|
+
import { appendOwnElement } from './ownKey.js';
|
|
8
|
+
const SETTINGS_SOURCE_TIERS = Object.freeze({
|
|
9
|
+
policySettings: 'managed',
|
|
10
|
+
flagSettings: 'global',
|
|
11
|
+
userSettings: 'global',
|
|
12
|
+
localSettings: 'project',
|
|
13
|
+
projectSettings: 'project',
|
|
14
|
+
});
|
|
15
|
+
const SAME_TIER_ORDER = ['flagSettings', 'userSettings', 'localSettings', 'projectSettings'];
|
|
16
|
+
const OFF_LADDER_ROWS = Object.freeze([
|
|
17
|
+
{ origin: 'cliArg', after: 'policySettings' },
|
|
18
|
+
{ origin: 'session', after: 'flagSettings' },
|
|
14
19
|
]);
|
|
15
|
-
|
|
20
|
+
function deriveWireRuleTrustOrder() {
|
|
21
|
+
const sources = Object.keys(SETTINGS_SOURCE_TIERS).sort((a, b) => {
|
|
22
|
+
const ta = SETTINGS_SOURCE_TIERS[a];
|
|
23
|
+
const tb = SETTINGS_SOURCE_TIERS[b];
|
|
24
|
+
const aAtLeastB = SETTINGS_IS_AT_LEAST(ta, tb);
|
|
25
|
+
const bAtLeastA = SETTINGS_IS_AT_LEAST(tb, ta);
|
|
26
|
+
if (aAtLeastB && !bAtLeastA)
|
|
27
|
+
return -1;
|
|
28
|
+
if (bAtLeastA && !aAtLeastB)
|
|
29
|
+
return 1;
|
|
30
|
+
return SAME_TIER_ORDER.indexOf(a) - SAME_TIER_ORDER.indexOf(b);
|
|
31
|
+
});
|
|
32
|
+
const out = [...sources];
|
|
33
|
+
for (const row of OFF_LADDER_ROWS)
|
|
34
|
+
out.splice(out.indexOf(row.after) + 1, 0, row.origin);
|
|
35
|
+
return out;
|
|
36
|
+
}
|
|
37
|
+
export const WIRE_RULE_TRUST_ORDER = Object.freeze(deriveWireRuleTrustOrder());
|
|
16
38
|
export const PERMISSIONS_KEPT_REASONS = Object.freeze([
|
|
17
39
|
'allow_capability_off',
|
|
18
40
|
'settings_read_not_clean',
|
|
@@ -25,6 +47,7 @@ export const PERMISSIONS_KEPT_REASONS = Object.freeze([
|
|
|
25
47
|
'home_relative_path',
|
|
26
48
|
'compile_refused',
|
|
27
49
|
'content_form_not_grantable',
|
|
50
|
+
'content_form_never_matches',
|
|
28
51
|
'judge_failed',
|
|
29
52
|
'duplicate',
|
|
30
53
|
'voids_allow_list',
|
|
@@ -62,11 +85,26 @@ function parseRule(rule) {
|
|
|
62
85
|
}
|
|
63
86
|
function requireRulePorts() {
|
|
64
87
|
const required = ['MCP_NAMESPACE', 'judgeRuleToolName', 'protocolOf', 'ruleToolGrammarOf', 'validatePermissionRules'];
|
|
65
|
-
const missing = required.filter((p) => !hasCoreValuePort(p));
|
|
88
|
+
const missing = Object.freeze(required.filter((p) => !hasCoreValuePort(p)));
|
|
66
89
|
if (missing.length === 0)
|
|
67
90
|
return;
|
|
68
|
-
|
|
91
|
+
const refused = withAssemblyRefusal(new Error(`permissionsDeclaration: 规则判据端口缺席(${missing.join(' / ')})—— 先用 installCoreValuePorts 装上 core 的同名实现。` +
|
|
69
92
|
'缺席不等于全部合格:不判就发会让整份请求被引擎拒收,不判就删会静默丢掉 deny 规则,所以这里拒绝装配。'), 'ports_missing');
|
|
93
|
+
RULE_PORTS_MISSING.set(refused, Object.freeze({ ports: missing, projection: activeRulePortsProjection }));
|
|
94
|
+
throw refused;
|
|
95
|
+
}
|
|
96
|
+
export function newRulePortsProjection() {
|
|
97
|
+
return Object.freeze({ kind: 'rule-ports-projection' });
|
|
98
|
+
}
|
|
99
|
+
const RULE_PORTS_MISSING = new WeakMap();
|
|
100
|
+
let activeRulePortsProjection;
|
|
101
|
+
export function rulePortsMissingOf(thrown, projection) {
|
|
102
|
+
if (!isSlotCarrier(thrown))
|
|
103
|
+
return undefined;
|
|
104
|
+
const r = RULE_PORTS_MISSING.get(thrown);
|
|
105
|
+
if (r === undefined || r.projection !== projection)
|
|
106
|
+
return undefined;
|
|
107
|
+
return assemblyRefusalOf(thrown)?.cause === 'ports_missing' ? r.ports : undefined;
|
|
70
108
|
}
|
|
71
109
|
function nameCheck(name) {
|
|
72
110
|
if (name.includes('('))
|
|
@@ -87,12 +125,14 @@ function nameCheck(name) {
|
|
|
87
125
|
return { unminted: true };
|
|
88
126
|
return { ok: true };
|
|
89
127
|
}
|
|
90
|
-
function wholeServerRuleName(name) {
|
|
128
|
+
function wholeServerRuleName(name, keepWildcardPeer) {
|
|
91
129
|
const read = name.trim();
|
|
92
130
|
const ns = protocolOf(read);
|
|
93
131
|
if (ns === undefined || !read.startsWith(ns.prefix))
|
|
94
132
|
return name;
|
|
95
133
|
const peer = read.slice(ns.prefix.length);
|
|
134
|
+
if (keepWildcardPeer && peer === '*')
|
|
135
|
+
return name;
|
|
96
136
|
return peer !== '' && !peer.includes('__') && !peer.endsWith('_') ? `${read}__*` : name;
|
|
97
137
|
}
|
|
98
138
|
const compileVerdict = ruleCompileVerdict;
|
|
@@ -114,7 +154,7 @@ function tighteningWholeName(name, check) {
|
|
|
114
154
|
const next = nameCheck(successor);
|
|
115
155
|
return 'retired' in next || 'issue' in next ? name : successor;
|
|
116
156
|
}
|
|
117
|
-
function judgeList(rules, behavior, allowForm = 'grant') {
|
|
157
|
+
function judgeList(rules, behavior, allowForm = 'grant', serverVersion) {
|
|
118
158
|
let portsChecked = false;
|
|
119
159
|
return rules.map((rule) => {
|
|
120
160
|
if (rule === '')
|
|
@@ -125,7 +165,7 @@ function judgeList(rules, behavior, allowForm = 'grant') {
|
|
|
125
165
|
}
|
|
126
166
|
const parsed = parseRule(rule);
|
|
127
167
|
if (parsed.ruleContent === undefined) {
|
|
128
|
-
const name = wholeServerRuleName(parsed.toolName);
|
|
168
|
+
const name = wholeServerRuleName(parsed.toolName, behavior !== 'allow');
|
|
129
169
|
const check = nameCheck(name);
|
|
130
170
|
if (behavior !== 'allow')
|
|
131
171
|
return { sent: true, wire: tighteningWholeName(name, check) };
|
|
@@ -144,7 +184,7 @@ function judgeList(rules, behavior, allowForm = 'grant') {
|
|
|
144
184
|
}
|
|
145
185
|
const check = nameCheck(parsed.toolName);
|
|
146
186
|
if (behavior !== 'allow')
|
|
147
|
-
return { sent: true, wire: rule };
|
|
187
|
+
return tightenEntryNeverMatches(rule, serverVersion) ? kept('content_form_never_matches') : { sent: true, wire: rule };
|
|
148
188
|
if ('retired' in check)
|
|
149
189
|
return kept('retired_tool_name');
|
|
150
190
|
if ('issue' in check)
|
|
@@ -204,18 +244,18 @@ function allowListVoiders(sent) {
|
|
|
204
244
|
return 'unknown';
|
|
205
245
|
}
|
|
206
246
|
}
|
|
207
|
-
function judgeBucket(raw, behavior, originOf, cli, settingsGate, allowForm = 'grant', dropWire, owned = []) {
|
|
247
|
+
function judgeBucket(raw, behavior, originOf, cli, settingsGate, allowForm = 'grant', dropWire, owned = [], serverVersion) {
|
|
208
248
|
const firstSlot = new Map();
|
|
209
249
|
for (const s of raw)
|
|
210
250
|
if (!firstSlot.has(s.rule))
|
|
211
251
|
firstSlot.set(s.rule, s);
|
|
212
|
-
const groups =
|
|
213
|
-
const rankOf = (origin) =>
|
|
252
|
+
const groups = WIRE_RULE_TRUST_ORDER.map(() => []);
|
|
253
|
+
const rankOf = (origin) => WIRE_RULE_TRUST_ORDER.indexOf(origin);
|
|
214
254
|
if (originOf !== undefined) {
|
|
215
255
|
for (const [r, origin] of originOf) {
|
|
216
256
|
const rank = rankOf(origin);
|
|
217
257
|
if (rank >= 0 && typeof r === 'string' && firstSlot.has(r))
|
|
218
|
-
groups[rank]
|
|
258
|
+
appendOwnElement(groups[rank], r);
|
|
219
259
|
}
|
|
220
260
|
}
|
|
221
261
|
const unknownOrigin = [...firstSlot.keys()].filter((r) => originOf === undefined || rankOf(originOf.get(r)) < 0);
|
|
@@ -232,15 +272,15 @@ function judgeBucket(raw, behavior, originOf, cli, settingsGate, allowForm = 'gr
|
|
|
232
272
|
if (winnerOf.has(fate.wire))
|
|
233
273
|
return kept('duplicate');
|
|
234
274
|
winnerOf.set(fate.wire, slot);
|
|
235
|
-
sent
|
|
275
|
+
appendOwnElement(sent, fate.wire);
|
|
236
276
|
return fate;
|
|
237
277
|
};
|
|
238
278
|
const appendGroup = (group, origin) => {
|
|
239
279
|
const held = settingsGate !== undefined && !outsideSettingsFiles(origin);
|
|
240
|
-
const fates = held ? group.map(() => kept(settingsGate)) : judgeList(group, behavior, allowForm);
|
|
280
|
+
const fates = held ? group.map(() => kept(settingsGate)) : judgeList(group, behavior, allowForm, serverVersion);
|
|
241
281
|
group.forEach((r, k) => fateOfRule.set(r, place(firstSlot.get(r), fates[k])));
|
|
242
282
|
};
|
|
243
|
-
|
|
283
|
+
WIRE_RULE_TRUST_ORDER.forEach((origin, rank) => {
|
|
244
284
|
if (origin === 'cliArg' && cli !== undefined)
|
|
245
285
|
cli.slots.forEach((s, k) => (cliFates[k] = place(s, cliFates[k])));
|
|
246
286
|
appendGroup(groups[rank], origin);
|
|
@@ -287,7 +327,7 @@ function ruleList(v, key) {
|
|
|
287
327
|
}
|
|
288
328
|
const r = v[i];
|
|
289
329
|
if (typeof r === 'string')
|
|
290
|
-
out
|
|
330
|
+
appendOwnElement(out, r);
|
|
291
331
|
}
|
|
292
332
|
return out;
|
|
293
333
|
}
|
|
@@ -308,7 +348,17 @@ function originMap(v, key) {
|
|
|
308
348
|
return snap;
|
|
309
349
|
}
|
|
310
350
|
const slotsOf = (list, name) => (list ?? []).map((rule, at) => ({ rule, list: name, at }));
|
|
311
|
-
function assemble(input, caps) {
|
|
351
|
+
function assemble(input, caps, projection) {
|
|
352
|
+
const outer = activeRulePortsProjection;
|
|
353
|
+
activeRulePortsProjection = projection;
|
|
354
|
+
try {
|
|
355
|
+
return assembleNow(input, caps);
|
|
356
|
+
}
|
|
357
|
+
finally {
|
|
358
|
+
activeRulePortsProjection = outer;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
function assembleNow(input, caps) {
|
|
312
362
|
let read;
|
|
313
363
|
try {
|
|
314
364
|
read = readAssemblyInput(input, caps);
|
|
@@ -344,17 +394,19 @@ function readAssemblyInput(input, caps) {
|
|
|
344
394
|
origins = { ...(od ? { deny: od } : {}), ...(oa ? { ask: oa } : {}), ...(ol ? { allow: ol } : {}) };
|
|
345
395
|
}
|
|
346
396
|
const gate = allowRulesGate(caps, ownField(input, 'settingsRead', ''));
|
|
347
|
-
|
|
397
|
+
const versionRaw = ownField(input, 'serverVersion', '');
|
|
398
|
+
const serverVersion = typeof versionRaw === 'string' ? versionRaw : undefined;
|
|
399
|
+
return { deny, ask, allow, cliDeny, ownedServers, origins, gate, serverVersion };
|
|
348
400
|
}
|
|
349
401
|
function judgeAssembly(read, caps) {
|
|
350
|
-
const { deny, ask, allow, cliDeny, ownedServers, origins, gate } = read;
|
|
402
|
+
const { deny, ask, allow, cliDeny, ownedServers, origins, gate, serverVersion } = read;
|
|
351
403
|
const cliSlots = slotsOf(cliDeny, 'cliDeny');
|
|
352
|
-
const cli = cliDeny === undefined ? undefined : { slots: cliSlots, fates: judgeList(cliDeny, 'deny') };
|
|
404
|
+
const cli = cliDeny === undefined ? undefined : { slots: cliSlots, fates: judgeList(cliDeny, 'deny', 'grant', serverVersion) };
|
|
353
405
|
const denySlots = slotsOf(deny, 'deny');
|
|
354
406
|
const askSlots = slotsOf(ask, 'ask');
|
|
355
407
|
const allowSlots = slotsOf(allow, 'allow');
|
|
356
|
-
const denyJ = judgeBucket(denySlots, 'deny', origins.deny, cli);
|
|
357
|
-
const askJ = judgeBucket(askSlots, 'ask', origins.ask, undefined);
|
|
408
|
+
const denyJ = judgeBucket(denySlots, 'deny', origins.deny, cli, undefined, 'grant', undefined, [], serverVersion);
|
|
409
|
+
const askJ = judgeBucket(askSlots, 'ask', origins.ask, undefined, undefined, 'grant', undefined, [], serverVersion);
|
|
358
410
|
const allowForm = allowWireForm(caps) === 'layer' ? 'layer' : 'grant';
|
|
359
411
|
const settingsGate = gate === 'settings_read_not_clean' ? 'settings_read_not_clean' : undefined;
|
|
360
412
|
let allowJ = gate === 'capability_off'
|
|
@@ -376,6 +428,11 @@ function judgeAssembly(read, caps) {
|
|
|
376
428
|
buckets.allow = [...allowJ.sent];
|
|
377
429
|
const keptRows = [];
|
|
378
430
|
const rewritten = [];
|
|
431
|
+
const ruleRows = [];
|
|
432
|
+
const knownOrigin = (table, rule) => {
|
|
433
|
+
const o = table?.get(rule);
|
|
434
|
+
return typeof o === 'string' && WIRE_RULE_TRUST_ORDER.includes(o) ? o : undefined;
|
|
435
|
+
};
|
|
379
436
|
const rows = [
|
|
380
437
|
['deny', [...denySlots, ...cliSlots], denyJ],
|
|
381
438
|
['ask', askSlots, askJ],
|
|
@@ -389,8 +446,10 @@ function judgeAssembly(read, caps) {
|
|
|
389
446
|
for (const [bucket, slots, j] of rows) {
|
|
390
447
|
slots.forEach((s, k) => {
|
|
391
448
|
const f = j.fates[k];
|
|
449
|
+
const origin = s.list === 'cliDeny' ? 'cliArg' : knownOrigin(origins[bucket], s.rule);
|
|
450
|
+
appendOwnElement(ruleRows, { rule: s.rule, list: s.list, bucket, ...(origin !== undefined ? { origin } : {}), fate: f });
|
|
392
451
|
if (!f.sent) {
|
|
393
|
-
keptRows
|
|
452
|
+
appendOwnElement(keptRows, {
|
|
394
453
|
rule: s.rule,
|
|
395
454
|
bucket,
|
|
396
455
|
reason: f.reason,
|
|
@@ -404,19 +463,27 @@ function judgeAssembly(read, caps) {
|
|
|
404
463
|
if (winner.at < 0)
|
|
405
464
|
continue;
|
|
406
465
|
if (winner.rule !== wire)
|
|
407
|
-
rewritten
|
|
466
|
+
appendOwnElement(rewritten, { from: winner.rule, to: wire, bucket });
|
|
408
467
|
}
|
|
409
468
|
}
|
|
410
|
-
return { buckets, report: { kept: keptRows, rewritten, ...(clientOwned.length > 0 ? { clientOwned } : {}) } };
|
|
469
|
+
return { buckets, report: { kept: keptRows, rewritten, ...(clientOwned.length > 0 ? { clientOwned } : {}) }, rows: ruleRows };
|
|
411
470
|
}
|
|
412
471
|
export function permissionsDeclaration(input, caps) {
|
|
413
|
-
|
|
472
|
+
return declarationOf(assemble(input, caps));
|
|
473
|
+
}
|
|
474
|
+
export function projectPermissionsDeclaration(input, caps, projection) {
|
|
475
|
+
return declarationOf(assemble(input, caps, projection));
|
|
476
|
+
}
|
|
477
|
+
function declarationOf({ buckets }) {
|
|
414
478
|
return Object.keys(buckets).length > 0 ? { permissions: buckets } : {};
|
|
415
479
|
}
|
|
416
480
|
export function permissionsDeclarationReport(input, caps) {
|
|
417
481
|
const { buckets, report } = assemble(input, caps);
|
|
418
482
|
return { ...(Object.keys(buckets).length > 0 ? { permissions: buckets } : {}), ...report };
|
|
419
483
|
}
|
|
484
|
+
export function assembledRuleRows(input, caps) {
|
|
485
|
+
return assemble(input, caps).rows;
|
|
486
|
+
}
|
|
420
487
|
const ALLOW_KEPT_ROWS_READ_MAX = 4096;
|
|
421
488
|
function allowHeldBySettingsReadCount(report) {
|
|
422
489
|
if (typeof report !== 'object' || report === null)
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
import type { HostSettingsSource } from './hostSettingsSource.js';
|
|
1
2
|
import type { WireHooksConfig } from './finalVerifyWire.js';
|
|
2
3
|
import type { PluginHookSource, SessionHookOrigin, SessionHookSource } from './host.js';
|
|
4
|
+
import type { HttpPolicyDropRow } from './httpHookPolicy.js';
|
|
5
|
+
import type { SubmissionIdentity } from './request/submissionIdentity.js';
|
|
3
6
|
import { type HooksSalvageDrop, type HooksSalvageMask, type HooksSalvageRejection } from './settingsHooksSalvage.js';
|
|
4
7
|
export declare const ENGINE_FIRED_HOOK_EVENTS: readonly ["PreToolUse", "PostToolUse", "PostToolUseFailure", "PostToolBatch", "PreCompact", "PostCompact", "Stop", "StopFailure", "UserPromptSubmit"];
|
|
5
8
|
export type EngineFiredHookEvent = (typeof ENGINE_FIRED_HOOK_EVENTS)[number];
|
|
6
9
|
export declare const PLUGIN_HOOK_DISPOSITIONS: readonly ["engine", "shell", "not_run"];
|
|
7
10
|
export type PluginHookDisposition = (typeof PLUGIN_HOOK_DISPOSITIONS)[number];
|
|
8
|
-
export declare const PLUGIN_HOOK_REASONS: readonly ["projected", "shell_event", "no_executor", "engine_not_local", "engine_locality_unknown", "engine_capability_absent", "engine_capability_unknown", "not_command", "sensitive_options", "engine_limit", "shell_form_user_config", "user_config_unset", "malformed_entry", "engine_hooks_off", "engine_hooks_unknown", "engine_type_skipped", "engine_llm_limit", "engine_unconfirmed", "engine_elsewhere", "hooks_module", "scope_unsupported", "source_incomplete"];
|
|
11
|
+
export declare const PLUGIN_HOOK_REASONS: readonly ["projected", "shell_event", "no_executor", "engine_not_local", "engine_locality_unknown", "engine_capability_absent", "engine_capability_unknown", "not_command", "sensitive_options", "engine_limit", "shell_form_user_config", "user_config_unset", "malformed_entry", "engine_hooks_off", "engine_hooks_unknown", "engine_type_skipped", "engine_llm_limit", "engine_unconfirmed", "engine_elsewhere", "hooks_module", "scope_unsupported", "source_incomplete", "compaction_local_fallback"];
|
|
9
12
|
export type PluginHookReason = (typeof PLUGIN_HOOK_REASONS)[number];
|
|
10
13
|
export declare const PLUGIN_HOOK_EXCLUSION_REASONS: readonly ["workspace_untrusted", "governance_unreadable", "policy_disable_all", "startup_mode", "managed_plugins_only", "prompt_not_user_authored"];
|
|
11
14
|
export type PluginHookExclusionReason = (typeof PLUGIN_HOOK_EXCLUSION_REASONS)[number];
|
|
@@ -56,6 +59,11 @@ export interface SettingsHooksSalvageRow {
|
|
|
56
59
|
readonly rejections: readonly HooksSalvageRejection[];
|
|
57
60
|
readonly notice: string;
|
|
58
61
|
}
|
|
62
|
+
export interface SettingsLayerWithheldRow {
|
|
63
|
+
readonly source: HookSettingsSource;
|
|
64
|
+
readonly cause: 'trust_withheld';
|
|
65
|
+
readonly notice: string;
|
|
66
|
+
}
|
|
59
67
|
export interface PluginHookModuleVerdict {
|
|
60
68
|
readonly pluginId: string;
|
|
61
69
|
readonly pluginName: string;
|
|
@@ -86,19 +94,25 @@ export interface HooksWirePlan {
|
|
|
86
94
|
readonly settingsVerdicts: readonly SettingsHookVerdict[];
|
|
87
95
|
readonly settingsExcluded: readonly SettingsHookExclusion[];
|
|
88
96
|
readonly settingsSalvage: readonly SettingsHooksSalvageRow[];
|
|
97
|
+
readonly httpPolicyDrops: readonly HttpPolicyDropRow[];
|
|
89
98
|
readonly moduleVerdicts: readonly PluginHookModuleVerdict[];
|
|
90
99
|
readonly sessionVerdicts: readonly SessionHookVerdict[];
|
|
91
100
|
readonly sessionReader: PluginHookReaderState;
|
|
92
101
|
readonly closedBy: Extract<PluginHookExclusionReason, 'workspace_untrusted' | 'governance_unreadable' | 'policy_disable_all'> | null;
|
|
102
|
+
readonly settingsSources: readonly HookSettingsSource[];
|
|
103
|
+
readonly settingsWithheld: readonly SettingsLayerWithheldRow[];
|
|
93
104
|
readonly wire: WireHooksConfig | undefined;
|
|
94
105
|
}
|
|
95
106
|
export interface HooksWirePlanOptions {
|
|
107
|
+
readonly settings: HostSettingsSource;
|
|
96
108
|
readonly baseUrl?: string;
|
|
97
109
|
readonly engineOwnedByThisShell?: boolean;
|
|
98
110
|
readonly shellHookEvents?: readonly string[];
|
|
99
111
|
readonly shellHookTypesByEvent?: Readonly<Record<string, readonly string[]>>;
|
|
112
|
+
readonly identity?: SubmissionIdentity;
|
|
100
113
|
readonly promptAuthoredByUser?: boolean;
|
|
101
114
|
readonly suppressedLocally?: readonly string[];
|
|
115
|
+
readonly compactionOnShell?: boolean;
|
|
102
116
|
}
|
|
103
117
|
export declare function hooksWirePlanShapeOf(v: unknown): 'plan' | 'not' | 'threw';
|
|
104
118
|
export declare const ENGINE_HOOK_LIMITS: {
|
|
@@ -161,7 +175,7 @@ export interface SettingsHookFilterResult {
|
|
|
161
175
|
readonly excluded: SettingsHookExclusion[];
|
|
162
176
|
}
|
|
163
177
|
export type SettingsHookJudge = (event: string, group: WireHookGroup, entry: WireHookEntry) => HookExecutor;
|
|
164
|
-
export declare function createSettingsHookJudge(engine: HooksWireEngineFacts, shellRuns: ShellRunsHook, promptAuthoredByUser: boolean): SettingsHookJudge;
|
|
178
|
+
export declare function createSettingsHookJudge(engine: HooksWireEngineFacts, shellRuns: ShellRunsHook, promptAuthoredByUser: boolean, compactionOnShell?: boolean): SettingsHookJudge;
|
|
165
179
|
export interface SourcedSettingsHookGroup {
|
|
166
180
|
readonly source: HookSettingsSource;
|
|
167
181
|
readonly group: WireHookGroup;
|
|
@@ -172,10 +186,12 @@ export interface SettingsHookDedupResult {
|
|
|
172
186
|
readonly removed: number;
|
|
173
187
|
}
|
|
174
188
|
export declare function pluginHookVerdictOf(plan: HooksWirePlan, pluginId: string, event: string, groupIndex: number, hookIndex: number): PluginHookVerdict | undefined;
|
|
175
|
-
export
|
|
189
|
+
export interface SettingsHooksLocalGroup<T> {
|
|
176
190
|
readonly matcher?: string;
|
|
177
191
|
readonly hooks: readonly T[];
|
|
178
|
-
|
|
192
|
+
readonly source?: HookSettingsSource;
|
|
193
|
+
}
|
|
194
|
+
export declare function settingsHooksKeptLocally<T>(plan: HooksWirePlan, event: string, group: SettingsHooksLocalGroup<T>, opts?: {
|
|
179
195
|
readonly engineCompaction?: 'performed' | 'not_performed';
|
|
180
196
|
}): readonly T[];
|
|
181
197
|
export declare function pluginHookReasonText(reason: PluginHookReason): string;
|