@sema-agent/client-core 0.94.0 → 0.96.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 +521 -0
- package/README.md +104 -57
- package/dist/adapt/arms.js +12 -7
- package/dist/adapt/panelTasks.js +4 -10
- package/dist/adapt/toolCards.d.ts +1 -0
- package/dist/adapt/toolCards.js +18 -5
- package/dist/adapt/wireShapes.js +5 -24
- package/dist/adapter/activeRunSelfHeal.d.ts +12 -3
- package/dist/adapter/activeRunSelfHeal.js +50 -16
- package/dist/adapter/downstream/eventToSdkMessage.js +33 -18
- package/dist/adapter/downstream/terminalToSdkResult.js +19 -12
- package/dist/adapter/runStream.js +30 -46
- package/dist/adapter/types.d.ts +7 -0
- package/dist/adapter/types.js +15 -0
- package/dist/agentSession/backgroundView.js +5 -1
- package/dist/agentSession/engineAgentRegistryRead.js +7 -5
- package/dist/agentSession/engineSessionBackgroundStop.js +25 -17
- package/dist/agentsWireCaps.d.ts +2 -0
- package/dist/agentsWireCaps.js +13 -2
- package/dist/approvalDecidedByCapability.d.ts +0 -1
- package/dist/approvalDecidedByCapability.js +2 -7
- package/dist/approvalsStreamLiveCapability.d.ts +0 -1
- package/dist/approvalsStreamLiveCapability.js +2 -6
- package/dist/atMostOnce.d.ts +8 -0
- package/dist/atMostOnce.js +36 -0
- package/dist/attachmentSeatCapability.d.ts +0 -1
- package/dist/attachmentSeatCapability.js +0 -3
- package/dist/attachmentsWireCaps.js +11 -6
- package/dist/bashExitReading.d.ts +10 -0
- package/dist/bashExitReading.js +12 -0
- package/dist/callerCwdCapability.d.ts +0 -5
- package/dist/callerCwdCapability.js +2 -13
- package/dist/centerWiringCapability.d.ts +1 -7
- package/dist/centerWiringCapability.js +18 -27
- package/dist/classifierStatus.js +4 -4
- package/dist/classifierVerdictWire.js +4 -16
- package/dist/clientSlice.js +1 -1
- package/dist/cloudConfigWireCaps.d.ts +3 -3
- package/dist/cloudConfigWireCaps.js +85 -43
- package/dist/compensations.js +1 -1
- package/dist/coreValuePorts.d.ts +11 -7
- package/dist/coreValuePorts.js +5 -8
- package/dist/credentialProvenance.d.ts +28 -0
- package/dist/credentialProvenance.js +76 -0
- package/dist/cycleOrder.d.ts +15 -0
- package/dist/cycleOrder.js +45 -0
- package/dist/decideFailureNote.js +7 -2
- package/dist/decideReceipt.d.ts +2 -1
- package/dist/decideReceipt.js +39 -14
- package/dist/declared/supportFloorDeclared.d.ts +1 -0
- package/dist/declared/supportFloorDeclared.js +5 -0
- package/dist/deviceExecutorManagementCapability.d.ts +0 -1
- package/dist/deviceExecutorManagementCapability.js +7 -16
- package/dist/deviceRebind.d.ts +88 -0
- package/dist/deviceRebind.js +242 -0
- package/dist/displayUntrusted.d.ts +8 -3
- package/dist/displayUntrusted.js +661 -63
- package/dist/engineAgentAbsence.d.ts +2 -2
- package/dist/engineAgentPanelStore.d.ts +8 -18
- package/dist/engineAgentPanelStore.js +19 -537
- package/dist/engineCapReader.d.ts +6 -6
- package/dist/engineCapReader.js +30 -43
- package/dist/engineCapsCache.d.ts +13 -2
- package/dist/engineCapsCache.js +276 -44
- package/dist/engineCredentialRequirement.d.ts +9 -0
- package/dist/engineCredentialRequirement.js +23 -0
- package/dist/engineDirectory.d.ts +79 -0
- package/dist/engineDirectory.js +186 -0
- package/dist/engineEnvSourcing.d.ts +53 -0
- package/dist/engineEnvSourcing.js +81 -0
- package/dist/engineErrorCodes.d.ts +28 -4
- package/dist/engineErrorCodes.js +68 -25
- package/dist/engineIdentity.js +2 -0
- package/dist/engineNoticeCodes.d.ts +17 -0
- package/dist/engineNoticeCodes.js +57 -3
- package/dist/engineWireSdk.js +2 -2
- package/dist/engineWordRenames.d.ts +8 -0
- package/dist/engineWordRenames.js +13 -0
- package/dist/executionLaneCapability.d.ts +2 -3
- package/dist/executionLaneCapability.js +18 -23
- package/dist/fileHistoryCaptureCapability.d.ts +14 -1
- package/dist/fileHistoryCaptureCapability.js +72 -6
- package/dist/fileHistoryLegNotice.d.ts +3 -2
- package/dist/fileHistoryLegNotice.js +51 -2
- package/dist/fleet/bgSubagentRow.d.ts +15 -0
- package/dist/fleet/bgSubagentRow.js +67 -0
- package/dist/fleet/fleetLedger.d.ts +3 -0
- package/dist/fleet/fleetLedger.js +153 -122
- package/dist/fleet/fleetProjection.d.ts +1 -3
- package/dist/fleet/fleetProjection.js +19 -19
- package/dist/fleetAgentPanelProjection.d.ts +4 -17
- package/dist/fleetAgentPanelProjection.js +7 -197
- package/dist/fleetAgentRowLike.d.ts +16 -0
- package/dist/fleetAgentRowLike.js +1 -0
- package/dist/fleetTaskDesc.js +4 -17
- package/dist/gateOutcome.d.ts +12 -1
- package/dist/gateOutcome.js +87 -18
- package/dist/gateVocabulary.d.ts +7 -2
- package/dist/gateVocabulary.js +5 -1
- package/dist/generated/engineAskFaceTables.js +1 -1
- package/dist/generated/engineFactTables.d.ts +5 -3
- package/dist/generated/engineFactTables.js +17 -4
- package/dist/generated/engineNoticeTables.js +12 -3
- package/dist/generated/sdkFactTables.d.ts +2 -0
- package/dist/generated/sdkFactTables.js +17 -0
- package/dist/generated/settingsSchemaFns.d.ts +13 -0
- package/dist/generated/settingsSchemaFns.js +75 -0
- package/dist/generated/toolNameTables.d.ts +1 -0
- package/dist/generated/toolNameTables.js +1 -0
- package/dist/headlessPermissionModeWire.d.ts +1 -1
- package/dist/headlessPermissionModeWire.js +1 -1
- package/dist/headlessReconnectWire.js +49 -20
- package/dist/hitl/allowRuleShadow.d.ts +1 -1
- package/dist/hitl/allowRuleShadow.js +49 -8
- package/dist/hitl/approvalCompleteParked.d.ts +1 -0
- package/dist/hitl/approvalCompleteParked.js +14 -0
- package/dist/hitl/approvalEndingCause.d.ts +7 -0
- package/dist/hitl/approvalEndingCause.js +71 -0
- package/dist/hitl/approvalHolds.d.ts +12 -2
- package/dist/hitl/approvalHolds.js +53 -2
- package/dist/hitl/approvalsFeed.js +23 -11
- package/dist/hitl/askGateWire.d.ts +2 -1
- package/dist/hitl/askGateWire.js +26 -1
- package/dist/hitl/askParkRowRouting.js +1 -1
- package/dist/hitl/automaticAnswerVerdict.d.ts +1 -1
- package/dist/hitl/automaticAnswerVerdict.js +15 -10
- package/dist/hitl/crashConverged.js +2 -0
- package/dist/hitl/decisionConflict.d.ts +3 -0
- package/dist/hitl/decisionConflict.js +41 -0
- package/dist/hitl/decisionRefusal.d.ts +12 -0
- package/dist/hitl/decisionRefusal.js +63 -4
- package/dist/hitl/frameRouter.d.ts +0 -1
- package/dist/hitl/frameRouter.js +32 -57
- package/dist/hitl/gateLedger.d.ts +5 -0
- package/dist/hitl/gateLedger.js +21 -0
- package/dist/hitl/hitlBridge.d.ts +17 -2
- package/dist/hitl/hitlBridge.js +91 -55
- package/dist/hitl/hitlHostSurface.js +3 -11
- package/dist/hitl/livePendingAsk.d.ts +16 -6
- package/dist/hitl/livePendingAsk.js +36 -4
- package/dist/hitl/localAllowRule.d.ts +1 -0
- package/dist/hitl/localAllowRule.js +2 -2
- package/dist/hitl/noAllowCause.d.ts +2 -1
- package/dist/hitl/noAllowCause.js +3 -2
- package/dist/hitl/parkExpiryJudgements.d.ts +19 -0
- package/dist/hitl/parkExpiryJudgements.js +46 -0
- package/dist/hitl/parkResolver.d.ts +4 -7
- package/dist/hitl/parkResolver.js +12 -34
- package/dist/hitl/parkRowBirthWait.d.ts +1 -0
- package/dist/hitl/parkRowBirthWait.js +2 -2
- package/dist/hitl/persistedRulesWire.js +5 -1
- package/dist/hitl/planReviewWire.d.ts +3 -2
- package/dist/hitl/planReviewWire.js +154 -50
- package/dist/hitl/replayedApproval.d.ts +9 -0
- package/dist/hitl/replayedApproval.js +139 -10
- package/dist/hitl/resumeRunningCard.d.ts +2 -0
- package/dist/hitl/resumeRunningCard.js +15 -4
- package/dist/hitl/sessionPolicyDeliverable.js +8 -6
- package/dist/hitl/standingRows.d.ts +18 -0
- package/dist/hitl/standingRows.js +127 -0
- package/dist/hitl/toolApprovalWire.d.ts +39 -7
- package/dist/hitl/toolApprovalWire.js +351 -61
- package/dist/hookMatcherVerdict.d.ts +1 -9
- package/dist/hookMatcherVerdict.js +21 -61
- package/dist/hooksWireCaps.js +40 -8
- package/dist/host.d.ts +5 -0
- package/dist/host.js +3 -1
- package/dist/hostCallbackGuard.d.ts +2 -0
- package/dist/hostCallbackGuard.js +31 -0
- package/dist/index.d.ts +48 -17
- package/dist/index.js +36 -15
- package/dist/interactiveInterrupt.d.ts +8 -0
- package/dist/interactiveInterrupt.js +54 -0
- package/dist/limitsWire.d.ts +5 -0
- package/dist/limitsWire.js +49 -3
- package/dist/liveModelCatalog.d.ts +95 -0
- package/dist/liveModelCatalog.js +297 -32
- package/dist/mcpEngineLeg.d.ts +25 -0
- package/dist/mcpEngineLeg.js +71 -15
- package/dist/mcpPanel.js +2 -1
- package/dist/mcpProbeCapability.d.ts +0 -5
- package/dist/mcpProbeCapability.js +2 -12
- package/dist/mcpReconnect.d.ts +1 -3
- package/dist/mcpReconnect.js +10 -5
- package/dist/memoryComplianceCapability.d.ts +0 -5
- package/dist/memoryComplianceCapability.js +2 -12
- package/dist/memoryOriginCapability.d.ts +0 -5
- package/dist/memoryOriginCapability.js +2 -12
- package/dist/memorySpecWire.js +2 -2
- package/dist/memoryVerbsWire.d.ts +1 -1
- package/dist/memoryVerbsWire.js +4 -0
- package/dist/model/liveCatalogShape.d.ts +14 -0
- package/dist/model/liveCatalogShape.js +71 -0
- package/dist/model/modelSupplyRules.d.ts +1 -0
- package/dist/model/modelSupplyRules.js +30 -9
- package/dist/model/modelsPolicy.d.ts +21 -0
- package/dist/model/modelsPolicy.js +90 -0
- package/dist/modelIdentityResolvability.d.ts +2 -2
- package/dist/modelIdentityResolvability.js +14 -12
- package/dist/modelSwitchFallback.d.ts +69 -0
- package/dist/modelSwitchFallback.js +206 -0
- package/dist/noticePresentation.d.ts +68 -0
- package/dist/noticePresentation.js +247 -0
- package/dist/notifications.js +12 -11
- package/dist/outputStyleSeatCapability.d.ts +0 -2
- package/dist/outputStyleSeatCapability.js +2 -10
- package/dist/ownKey.d.ts +8 -0
- package/dist/ownKey.js +66 -0
- package/dist/panelReduce.d.ts +114 -0
- package/dist/panelReduce.js +1135 -0
- package/dist/panelStateHolder.d.ts +17 -0
- package/dist/panelStateHolder.js +201 -0
- package/dist/peerFrames.js +13 -9
- package/dist/peerLaneCapability.d.ts +0 -1
- package/dist/peerLaneCapability.js +2 -6
- package/dist/permissionModesCapability.d.ts +0 -5
- package/dist/permissionModesCapability.js +5 -16
- package/dist/permissionRuleIssue.js +0 -3
- package/dist/permissionRulesWriteCapability.d.ts +0 -1
- package/dist/permissionRulesWriteCapability.js +2 -6
- package/dist/permissionsAllowGrantCapability.d.ts +0 -1
- package/dist/permissionsAllowGrantCapability.js +3 -9
- package/dist/permissionsDeclaration.d.ts +8 -0
- package/dist/permissionsDeclaration.js +101 -41
- package/dist/printPermissionOutcome.d.ts +12 -0
- package/dist/printPermissionOutcome.js +50 -0
- package/dist/printToolResultFrame.d.ts +1 -0
- package/dist/printToolResultFrame.js +5 -17
- package/dist/promptBlockedCopy.d.ts +5 -0
- package/dist/promptBlockedCopy.js +35 -0
- package/dist/promptDelivery.js +0 -8
- package/dist/protocolSegment.d.ts +9 -6
- package/dist/protocolSegment.js +31 -21
- package/dist/providerRejection.d.ts +4 -0
- package/dist/providerRejection.js +75 -14
- package/dist/replayBody.d.ts +12 -0
- package/dist/replayBody.js +25 -0
- package/dist/resumeRefusalCopy.d.ts +18 -1
- package/dist/resumeRefusalCopy.js +127 -32
- package/dist/retryStatus.d.ts +9 -1
- package/dist/retryStatus.js +9 -2
- package/dist/rewindArchiveCapability.d.ts +5 -14
- package/dist/rewindArchiveCapability.js +18 -61
- package/dist/rewindArchiveReading.d.ts +15 -0
- package/dist/rewindArchiveReading.js +56 -0
- package/dist/rewindEngineAction.d.ts +21 -0
- package/dist/rewindEngineAction.js +36 -0
- package/dist/rewindWireCaps.d.ts +2 -1
- package/dist/rewindWireCaps.js +1 -0
- package/dist/ruleCompileVerdict.d.ts +9 -1
- package/dist/ruleCompileVerdict.js +29 -4
- package/dist/runTerminal.d.ts +15 -12
- package/dist/runTerminal.js +60 -35
- package/dist/sandboxWire.js +13 -0
- package/dist/sdkRegistryTransit.d.ts +2 -1
- package/dist/sdkRegistryTransit.js +1 -0
- package/dist/sealedKeyCapability.d.ts +0 -5
- package/dist/sealedKeyCapability.js +3 -15
- package/dist/seam.js +4 -2
- package/dist/seatContract.d.ts +125 -34
- package/dist/seatContract.js +583 -179
- package/dist/sessionIdSegment.d.ts +1 -0
- package/dist/sessionIdSegment.js +11 -0
- package/dist/sessionMemoryErase.d.ts +1 -1
- package/dist/sessionMemoryErase.js +6 -1
- package/dist/sessionMemoryStatus.js +3 -2
- package/dist/sessionPolicyCapability.d.ts +0 -1
- package/dist/sessionPolicyCapability.js +2 -6
- package/dist/sessionReadRedactionCapability.d.ts +0 -5
- package/dist/sessionReadRedactionCapability.js +2 -13
- package/dist/sessionSyncFileHistory.d.ts +4 -0
- package/dist/sessionSyncFileHistory.js +66 -0
- package/dist/sessionSyncFileHistoryCapability.d.ts +0 -2
- package/dist/sessionSyncFileHistoryCapability.js +2 -9
- package/dist/skillToolListsCapability.d.ts +0 -2
- package/dist/skillToolListsCapability.js +2 -9
- package/dist/skillsWireCaps.d.ts +4 -0
- package/dist/skillsWireCaps.js +66 -1
- package/dist/sqlEngineCapability.d.ts +0 -1
- package/dist/sqlEngineCapability.js +9 -14
- package/dist/steerPriorityCapability.d.ts +0 -2
- package/dist/steerPriorityCapability.js +3 -12
- package/dist/storePostureCapability.d.ts +1 -5
- package/dist/storePostureCapability.js +16 -22
- package/dist/streamDrainingLegs.d.ts +6 -0
- package/dist/streamDrainingLegs.js +23 -0
- package/dist/subagent/engineCompactWire.js +13 -38
- package/dist/subagent/engineDelegatedPrompt.js +10 -6
- package/dist/subagent/engineSubagentOutput.d.ts +0 -1
- package/dist/subagent/engineSubagentOutput.js +5 -20
- package/dist/subagent/engineSubagentSteer.js +7 -5
- package/dist/subagent/engineSubagentTail.d.ts +0 -1
- package/dist/subagent/engineSubagentTail.js +7 -32
- package/dist/subagentContentStore.js +7 -18
- package/dist/supportFloor.d.ts +1 -0
- package/dist/supportFloor.js +15 -14
- package/dist/systemReminderTag.d.ts +1 -0
- package/dist/systemReminderTag.js +8 -0
- package/dist/terminalStatuses.d.ts +30 -0
- package/dist/terminalStatuses.js +67 -0
- package/dist/toolHistoryMismatch.d.ts +0 -3
- package/dist/toolHistoryMismatch.js +3 -7
- package/dist/toolResult.d.ts +6 -1
- package/dist/toolResult.js +90 -37
- package/dist/toolResultContent.d.ts +2 -0
- package/dist/toolResultContent.js +63 -0
- package/dist/types/engineState.d.ts +2 -1
- package/dist/usageAnalytics.d.ts +146 -0
- package/dist/usageAnalytics.js +335 -0
- package/dist/userInvokedSkillsCapability.d.ts +0 -2
- package/dist/userInvokedSkillsCapability.js +2 -9
- package/dist/webSearchBackendCapability.d.ts +0 -1
- package/dist/webSearchBackendCapability.js +3 -7
- package/dist/webSearchWireCaps.js +3 -11
- package/dist/wireErrorTriage.d.ts +2 -0
- package/dist/wireErrorTriage.js +34 -5
- package/dist/wireFailureShape.d.ts +23 -2
- package/dist/wireFailureShape.js +88 -43
- package/dist/wireRefusalCopy.js +2 -18
- package/dist/workflowClient.js +7 -11
- package/dist/workflowsJournalCapability.d.ts +0 -1
- package/dist/workflowsJournalCapability.js +2 -6
- package/dist/writeProtectionCapability.d.ts +0 -1
- package/dist/writeProtectionCapability.js +5 -10
- package/docs/INTEGRATION-CLIENTS.md +2279 -27
- package/package.json +5 -5
- package/dist/engineCapsGenerationGuard.d.ts +0 -4
- package/dist/engineCapsGenerationGuard.js +0 -19
- package/dist/panelRunningHistory.d.ts +0 -22
- package/dist/panelRunningHistory.js +0 -82
- package/dist/registryConflict.d.ts +0 -3
- package/dist/registryConflict.js +0 -44
|
@@ -1,24 +1,27 @@
|
|
|
1
|
-
import { APPROVAL_CARD_PORT_KEY_MISMATCH_REASON, DEFAULT_DENY_REASON, DecideTransportRetryExhaustedError, HitlBridge, NO_APPROVAL_CARD_PORT_REASON,
|
|
1
|
+
import { APPROVAL_CARD_PORT_KEY_MISMATCH_REASON, DEFAULT_DENY_REASON, DecideTransportRetryExhaustedError, HitlBridge, NO_APPROVAL_CARD_PORT_REASON, denyReasonForWire, findPendingForTask, hitlSafetyCodeOf, readDecideCurrentPending, readWireCodes, readWireErrorCodeReading, } from './hitlBridge.js';
|
|
2
2
|
import { askParkRowArm } from './askParkRowRouting.js';
|
|
3
3
|
import { hostLog } from '../host.js';
|
|
4
|
-
import { readOwnDataNonEmptyString, readOwnDataValue, readOwnNonEmptyString } from '../ownKey.js';
|
|
4
|
+
import { readAskOrigin, readOwnDataNonEmptyString, readOwnDataValue, readOwnNonEmptyString } from '../ownKey.js';
|
|
5
5
|
import { readAskClassPair } from './askClassPair.js';
|
|
6
|
-
import {
|
|
6
|
+
import { readAllowRuleShadowFromWire } from './allowRuleShadow.js';
|
|
7
7
|
import { createSessionSlot, DEFAULT_SESSION_KEY } from '../sessionSlot.js';
|
|
8
8
|
import { readEngineActiveBgTasks } from '../fleet/fleetLedger.js';
|
|
9
|
+
import { CORE_SKILL_TOOL_NAME } from '../generated/toolNameTables.js';
|
|
9
10
|
import { INTERRUPT_DENY_REASON, observeCancelByDeny, surfaceApprovalParking, surfaceRememberNotApplied, surfaceEditNotForwarded, surfaceEditRefusedOnBlindAsk, surfaceRuleArmNotSent, surfaceRuleArmRejected } from './hitlHostSurface.js';
|
|
10
11
|
import { approvalCallKey, liveFrameCallKey } from './gateIdentity.js';
|
|
11
12
|
import { displayUntrusted } from '../displayUntrusted.js';
|
|
12
|
-
import { approvalDecisionHolds, holdLiveCard, joinLiveCard, liveCardHoldOf } from './approvalHolds.js';
|
|
13
|
+
import { approvalDecisionHolds, awaitLiveCardHolder, holdLiveCard, joinLiveCard, liveCardHoldFor, liveCardHoldOf } from './approvalHolds.js';
|
|
13
14
|
import { approvalResolutionOf } from './approvalResolution.js';
|
|
14
15
|
import { isApprovalMandateWord } from '../gateVocabulary.js';
|
|
15
16
|
import { denyAttributionRefusalFromError } from '../wireRefusalCopy.js';
|
|
16
17
|
import { approvalDecidedByAdmitted } from '../approvalDecidedByCapability.js';
|
|
17
18
|
import { decideFailureNote } from '../decideFailureNote.js';
|
|
18
|
-
import { wireFailureTextsOf } from '../wireFailureShape.js';
|
|
19
|
-
import {
|
|
19
|
+
import { readRefusalField, thrownIsInstanceOf, wireFailureTextsOf } from '../wireFailureShape.js';
|
|
20
|
+
import { refusalCauseWordOf } from './approvalEndingCause.js';
|
|
21
|
+
import { readDecisionRefusalAsk } from './decisionRefusal.js';
|
|
22
|
+
import { DECIDE_WORKFLOW_REMEMBER_UNSUPPORTED, refusalSaysStillPending } from '../engineErrorCodes.js';
|
|
20
23
|
import { readDecideReceipt } from '../decideReceipt.js';
|
|
21
|
-
import { RULE_OFFER_MATCHES, RULE_OFFER_BATCH_MEMBER_KINDS, RULE_OFFER_UNCOVERED_REASONS, RULE_OFFERS_ABSENCE_REASONS, ASK_ORIGINS,
|
|
24
|
+
import { RULE_OFFER_MATCHES, RULE_OFFER_BATCH_MEMBER_KINDS, RULE_OFFER_UNCOVERED_REASONS, RULE_OFFERS_ABSENCE_REASONS, ASK_ORIGINS, } from '@sema-agent/sdk';
|
|
22
25
|
export function isFsApprovalGate(gate) {
|
|
23
26
|
if (!gate)
|
|
24
27
|
return false;
|
|
@@ -61,7 +64,6 @@ export function structurallyEqual(a, b) {
|
|
|
61
64
|
export { RULE_OFFER_MATCHES, RULE_OFFER_BATCH_MEMBER_KINDS, RULE_OFFER_UNCOVERED_REASONS };
|
|
62
65
|
export { RULE_OFFERS_ABSENCE_REASONS };
|
|
63
66
|
export const ASK_ORIGIN_WORDS = ASK_ORIGINS;
|
|
64
|
-
export const APPROVAL_MANDATE_WORDS = PERSISTED_RULE_MANDATES;
|
|
65
67
|
export const APPROVAL_DENY_SETTLED_BY_WORDS = Object.freeze(['human', 'policy']);
|
|
66
68
|
export function readApprovalDenySettledBy(decision) {
|
|
67
69
|
if (decision === null || typeof decision !== 'object')
|
|
@@ -132,17 +134,26 @@ function cardPortMissReason() {
|
|
|
132
134
|
return APPROVAL_CARD_PORT_KEY_MISMATCH_REASON;
|
|
133
135
|
return NO_APPROVAL_CARD_PORT_REASON;
|
|
134
136
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
137
|
+
const REMEMBER_REFUSAL_CODES = Object.freeze([
|
|
138
|
+
'remember_not_in_proof',
|
|
139
|
+
'remember_requires_binding',
|
|
140
|
+
'capability.store_required',
|
|
141
|
+
DECIDE_WORKFLOW_REMEMBER_UNSUPPORTED,
|
|
142
|
+
'decide.parked_remember_unsupported',
|
|
143
|
+
]);
|
|
144
|
+
export function rememberRefusalOf(error) {
|
|
145
|
+
return rememberRefusalIn(readWireErrorCodeReading(error));
|
|
146
|
+
}
|
|
147
|
+
function rememberRefusalIn(reading) {
|
|
148
|
+
return reading.state === 'code' ? REMEMBER_REFUSAL_CODES.find((c) => c === reading.code) : undefined;
|
|
149
|
+
}
|
|
150
|
+
function rememberFallbackKind(e) {
|
|
151
|
+
const reading = readWireErrorCodeReading(e);
|
|
152
|
+
if (rememberRefusalIn(reading) !== undefined)
|
|
153
|
+
return 'refused';
|
|
154
|
+
if (reading.state !== 'absent')
|
|
155
|
+
return undefined;
|
|
156
|
+
return readToolApprovalRespondRefusal(e)?.status === 400 ? 'legacy' : undefined;
|
|
146
157
|
}
|
|
147
158
|
function logAfterDecided(msg) {
|
|
148
159
|
try {
|
|
@@ -157,6 +168,14 @@ const ARGS_OMITTED_PATH_RECOVERED_NOTE = 'tool arguments exceeded the wire cap a
|
|
|
157
168
|
const ARGS_OMITTED_NOTHING_RECOVERED_NOTE = 'tool arguments exceeded the wire cap and were omitted, and nothing could be recovered from the approval question — ' +
|
|
158
169
|
'you are deciding without seeing what this call will do; deny it if you are not sure. ' +
|
|
159
170
|
'Edits are not accepted on this card: there is no original input to edit';
|
|
171
|
+
function argsFallbackOf(message, argsOmitted) {
|
|
172
|
+
const p = pathFromGateMessage(typeof message === 'string' ? message : undefined);
|
|
173
|
+
return {
|
|
174
|
+
args: p !== undefined ? { file_path: p } : {},
|
|
175
|
+
pathRecovered: p !== undefined,
|
|
176
|
+
...(argsOmitted === true ? { omittedNote: p !== undefined ? ARGS_OMITTED_PATH_RECOVERED_NOTE : ARGS_OMITTED_NOTHING_RECOVERED_NOTE } : {}),
|
|
177
|
+
};
|
|
178
|
+
}
|
|
160
179
|
const PARK_ROW_ARGS_ABSENT_NOTE = "this request's tool arguments are not available on this surface — neither the event stream nor the pending approval record " +
|
|
161
180
|
'carries them, so you are deciding without seeing them; deny it if you are not sure what it will do. ' +
|
|
162
181
|
'Edits are not accepted on this card: there is no original input to edit';
|
|
@@ -281,6 +300,13 @@ export async function surfaceFsApprovalAndDecide(deps, taskId, argsByCall, signa
|
|
|
281
300
|
return { kind: 'failed', stage: 'fetch', reason: found.reason, ...(found.code !== undefined ? { code: found.code } : {}) };
|
|
282
301
|
if (held !== undefined)
|
|
283
302
|
return joinDurableDecision(held, deps, signal);
|
|
303
|
+
const liveHolder = liveCardHoldFor(parkRowHolderIdentity(found.pending, found.gatedCallId));
|
|
304
|
+
if (liveHolder !== undefined) {
|
|
305
|
+
const joined = await awaitLiveCardHolder(liveHolder, signal);
|
|
306
|
+
if (joined !== undefined)
|
|
307
|
+
return fsOutcomeOfJoinedLiveCard(joined, found.gatedCallId);
|
|
308
|
+
return surfaceFsApprovalAndDecide(deps, taskId, argsByCall, signal, parkGatedCallId);
|
|
309
|
+
}
|
|
284
310
|
const callKey = approvalCallKey(found.gatedCallId, taskId);
|
|
285
311
|
const fetched = found;
|
|
286
312
|
return holdDurableDecision(durableHoldKey(fetched.pending, callKey), signal, async (hold) => {
|
|
@@ -290,6 +316,33 @@ export async function surfaceFsApprovalAndDecide(deps, taskId, argsByCall, signa
|
|
|
290
316
|
return out;
|
|
291
317
|
});
|
|
292
318
|
}
|
|
319
|
+
function parkRowHolderIdentity(row, gatedCallId) {
|
|
320
|
+
return {
|
|
321
|
+
...(typeof row.taskId === 'string' && row.taskId !== '' ? { taskId: row.taskId } : {}),
|
|
322
|
+
...(gatedCallId !== undefined && gatedCallId !== '' ? { toolCallId: gatedCallId } : {}),
|
|
323
|
+
...(typeof row.sessionId === 'string' && row.sessionId !== '' ? { sessionId: row.sessionId } : {}),
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
function fsOutcomeOfJoinedLiveCard(o, gatedCallId) {
|
|
327
|
+
if (o.aborted === true)
|
|
328
|
+
return { kind: 'aborted', gatedCallId, joinedInFlight: true };
|
|
329
|
+
if (o.decision === 'unresolved')
|
|
330
|
+
return { kind: 'retracted', gatedCallId, joinedInFlight: true };
|
|
331
|
+
return {
|
|
332
|
+
kind: 'decided',
|
|
333
|
+
gatedCallId,
|
|
334
|
+
...(o.decision === 'deny'
|
|
335
|
+
? {
|
|
336
|
+
denied: true,
|
|
337
|
+
...(o.denySettledBy !== undefined ? { denySettledBy: o.denySettledBy } : {}),
|
|
338
|
+
...(o.denyReason !== undefined ? { denyReason: o.denyReason } : {}),
|
|
339
|
+
}
|
|
340
|
+
: {}),
|
|
341
|
+
...(o.denyAttributionDropped === true ? { denyAttributionDropped: true } : {}),
|
|
342
|
+
...(o.denyAttributionRenamed === true ? { denyAttributionRenamed: true } : {}),
|
|
343
|
+
joinedInFlight: true,
|
|
344
|
+
};
|
|
345
|
+
}
|
|
293
346
|
async function presentFsApprovalAndDecide(deps, taskId, argsByCall, signal, found, decidedByReading, callKey, hold, ledgerSlot) {
|
|
294
347
|
const { pending, gatedCallId } = found;
|
|
295
348
|
const toolName = typeof pending.toolName === 'string' ? pending.toolName : '';
|
|
@@ -314,7 +367,7 @@ async function presentFsApprovalAndDecide(deps, taskId, argsByCall, signal, foun
|
|
|
314
367
|
const durableRuleOffersAbsence = pending.ruleOffersAbsence;
|
|
315
368
|
hold.presented = true;
|
|
316
369
|
deps.onPresented?.();
|
|
317
|
-
const card = await surfaceCallTrackedCard(gatedCallId, undefined, ledgerSlot, {
|
|
370
|
+
const card = await surfaceCallTrackedCard(gatedCallId, undefined, ledgerSlot, withUnreadableEvidence(pending, 'row', {
|
|
318
371
|
toolName,
|
|
319
372
|
args,
|
|
320
373
|
callKey,
|
|
@@ -329,23 +382,24 @@ async function presentFsApprovalAndDecide(deps, taskId, argsByCall, signal, foun
|
|
|
329
382
|
...(pending.requiresRealApproval === true ? { requiresRealApproval: true } : {}),
|
|
330
383
|
...(hasOwnStrictTrue(pending, 'mandated') ? { mandated: true } : {}),
|
|
331
384
|
...((w) => (w !== undefined ? { mandate: w } : {}))(readApprovalMandate(pending)),
|
|
332
|
-
...((o) => (o !== undefined ? { origin: o } : {}))(
|
|
385
|
+
...((o) => (o !== undefined ? { origin: o } : {}))(readAskOrigin(pending)),
|
|
333
386
|
...(readAskClassPair(pending) ?? {}),
|
|
334
387
|
...(pending.gateKind === 'irreversible_ask' ? { irreversibleParkGate: true } : {}),
|
|
335
388
|
...(pending.hasBidiControls === true ? { hasBidiControls: true } : {}),
|
|
336
389
|
...(ruleOffersReadOnly !== undefined ? { ruleOffersReadOnly } : {}),
|
|
337
390
|
...(isWireRecordCarrier(durableProbeCause) ? { probeCause: durableProbeCause } : {}),
|
|
338
391
|
...(durableProbeReason !== undefined ? { probeReason: durableProbeReason } : {}),
|
|
339
|
-
...(
|
|
392
|
+
...(readApprovalRememberRefused(pending) ? { rememberRefused: true } : {}),
|
|
340
393
|
...(durableShadow !== undefined ? { allowRuleShadow: durableShadow } : {}),
|
|
341
|
-
...((t) => (t !== undefined ? { persistedRuleShadowed: t } : {}))(legacyShadowedRuleTextOf(durableShadow)),
|
|
342
394
|
...(typeof durableRuleOffersAbsence === 'string' && durableRuleOffersAbsence !== ''
|
|
343
395
|
? { ruleOffersAbsence: durableRuleOffersAbsence }
|
|
344
396
|
: {}),
|
|
345
397
|
...(typeof pending.toolCallId === 'string' && pending.toolCallId !== ''
|
|
346
398
|
? { toolCallId: pending.toolCallId }
|
|
347
399
|
: {}),
|
|
348
|
-
|
|
400
|
+
allowSessionCarried: true,
|
|
401
|
+
grantBinding: readApprovalGrantBinding(pending),
|
|
402
|
+
}));
|
|
349
403
|
if (rowArgsGap !== undefined && card.kind === 'allow' && card.updatedInput !== undefined) {
|
|
350
404
|
hostLog('error', `liveToolApprovalWire: approval card for ${gatedCallId ?? `task ${taskId}`} returned an edited approval, but the tool input is ${rowArgsGap === 'truncated' ? 'a size marker on the pending row' : 'missing from both the stream and the pending row'} — nothing sent (the park stays pending)`);
|
|
351
405
|
surfaceEditRefusedOnBlindAsk();
|
|
@@ -379,12 +433,11 @@ async function presentFsApprovalAndDecide(deps, taskId, argsByCall, signal, foun
|
|
|
379
433
|
sessionDecided = true;
|
|
380
434
|
}
|
|
381
435
|
catch (e) {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
if (readDecideCurrentPending(e) !== undefined)
|
|
436
|
+
const fallbackKind = rememberFallbackKind(e);
|
|
437
|
+
if (fallbackKind === undefined)
|
|
385
438
|
throw e;
|
|
386
|
-
rememberRefused =
|
|
387
|
-
logAfterDecided(`liveToolApprovalWire: decide(approve+remember)
|
|
439
|
+
rememberRefused = fallbackKind === 'refused';
|
|
440
|
+
logAfterDecided(`liveToolApprovalWire: decide(approve+remember) refused the remember part (${String(e)}) — falling back to plain approve`);
|
|
388
441
|
}
|
|
389
442
|
if (sessionDecided) {
|
|
390
443
|
if (sessionReceipt?.rememberApplied === false)
|
|
@@ -400,9 +453,9 @@ async function presentFsApprovalAndDecide(deps, taskId, argsByCall, signal, foun
|
|
|
400
453
|
}
|
|
401
454
|
catch (e) {
|
|
402
455
|
const currentPending = readDecideCurrentPending(e);
|
|
403
|
-
const
|
|
456
|
+
const wireCodes = readWireCodes(e);
|
|
404
457
|
const wireRetriable = typeof e === 'object' && e !== null && refusalSaysStillPending(e);
|
|
405
|
-
const safetyCode = e
|
|
458
|
+
const safetyCode = hitlSafetyCodeOf(e);
|
|
406
459
|
const failureTexts = wireFailureTextsOf(e);
|
|
407
460
|
hostLog('debug', `liveToolApprovalWire: decide(approve) failed: ${failureTexts.log}`);
|
|
408
461
|
return {
|
|
@@ -410,9 +463,9 @@ async function presentFsApprovalAndDecide(deps, taskId, argsByCall, signal, foun
|
|
|
410
463
|
stage: 'decide',
|
|
411
464
|
gatedCallId,
|
|
412
465
|
reason: `decide(approve) failed: ${failureTexts.reason}${decideFailureNote(e, 'approve')}`,
|
|
413
|
-
...(e
|
|
466
|
+
...(thrownIsInstanceOf(e, DecideTransportRetryExhaustedError) ? { retryExhausted: true } : {}),
|
|
414
467
|
...(currentPending !== undefined ? { currentPending } : {}),
|
|
415
|
-
...
|
|
468
|
+
...wireCodes,
|
|
416
469
|
...(wireRetriable ? { retriable: true } : {}),
|
|
417
470
|
...(safetyCode !== undefined ? { safetyCode } : {}),
|
|
418
471
|
};
|
|
@@ -486,9 +539,9 @@ async function presentFsApprovalAndDecide(deps, taskId, argsByCall, signal, foun
|
|
|
486
539
|
}
|
|
487
540
|
catch (e) {
|
|
488
541
|
const currentPending = readDecideCurrentPending(e);
|
|
489
|
-
const
|
|
542
|
+
const wireCodes = readWireCodes(e);
|
|
490
543
|
const wireRetriable = typeof e === 'object' && e !== null && refusalSaysStillPending(e);
|
|
491
|
-
const safetyCode = e
|
|
544
|
+
const safetyCode = hitlSafetyCodeOf(e);
|
|
492
545
|
const attributionRefusal = denyAttributionRefusalFromError(e, lastSendCarriedAttribution);
|
|
493
546
|
const failureTexts = wireFailureTextsOf(e);
|
|
494
547
|
hostLog('debug', `liveToolApprovalWire: decide(deny) failed: ${failureTexts.log}`);
|
|
@@ -497,9 +550,9 @@ async function presentFsApprovalAndDecide(deps, taskId, argsByCall, signal, foun
|
|
|
497
550
|
stage: 'decide',
|
|
498
551
|
gatedCallId,
|
|
499
552
|
reason: `decide(deny) failed: ${failureTexts.reason}${decideFailureNote(e, 'deny')}`,
|
|
500
|
-
...(e
|
|
553
|
+
...(thrownIsInstanceOf(e, DecideTransportRetryExhaustedError) ? { retryExhausted: true } : {}),
|
|
501
554
|
...(currentPending !== undefined ? { currentPending } : {}),
|
|
502
|
-
...
|
|
555
|
+
...wireCodes,
|
|
503
556
|
...(wireRetriable ? { retriable: true } : {}),
|
|
504
557
|
...(safetyCode !== undefined ? { safetyCode } : {}),
|
|
505
558
|
...(attributionRefusal !== null ? { denyAttributionRefusal: attributionRefusal } : {}),
|
|
@@ -562,6 +615,7 @@ export const TOOL_APPROVAL_FRAME_KEYS_MIRROR = [
|
|
|
562
615
|
'serverNowMs',
|
|
563
616
|
'delegation',
|
|
564
617
|
'outcome',
|
|
618
|
+
'cause',
|
|
565
619
|
];
|
|
566
620
|
const _mirrorPin = [true, true];
|
|
567
621
|
void _mirrorPin;
|
|
@@ -588,7 +642,7 @@ export function toolPermissionRequestAskBits(card) {
|
|
|
588
642
|
return {};
|
|
589
643
|
const mandated = hasOwnStrictTrue(card, 'mandated');
|
|
590
644
|
const mandate = readApprovalMandate(card);
|
|
591
|
-
const origin =
|
|
645
|
+
const origin = readAskOrigin(card);
|
|
592
646
|
const ruleOffersAbsence = readOwnNonEmptyString(card, 'ruleOffersAbsence');
|
|
593
647
|
const askClassPair = readAskClassPair(card);
|
|
594
648
|
return {
|
|
@@ -597,6 +651,7 @@ export function toolPermissionRequestAskBits(card) {
|
|
|
597
651
|
...(origin !== undefined ? { origin } : {}),
|
|
598
652
|
...(ruleOffersAbsence !== undefined ? { ruleOffersAbsence } : {}),
|
|
599
653
|
...(askClassPair ?? {}),
|
|
654
|
+
...(readApprovalRememberRefused(card) ? { rememberRefused: true } : {}),
|
|
600
655
|
};
|
|
601
656
|
}
|
|
602
657
|
function hasOwnStrictTrue(v, key) {
|
|
@@ -795,10 +850,20 @@ export function readToolApprovalRespondRefusal(err) {
|
|
|
795
850
|
const message = refusalTextOf(err, pick('message'));
|
|
796
851
|
if (status === undefined && errorCode === undefined && message === undefined)
|
|
797
852
|
return undefined;
|
|
853
|
+
const machine = typeof err === 'object' && err !== null ? err : undefined;
|
|
854
|
+
const retriable = machine !== undefined && refusalSaysStillPending(machine);
|
|
855
|
+
const cause = machine !== undefined ? refusalCauseWordOf(machine) : undefined;
|
|
856
|
+
const field = machine !== undefined ? readRefusalField(machine) : undefined;
|
|
857
|
+
const unreadable = machine !== undefined && readDecisionRefusalAsk(machine).reading === 'unreadable';
|
|
798
858
|
const rest = {
|
|
799
859
|
...(status !== undefined ? { status } : {}),
|
|
800
860
|
...(errorCode !== undefined ? { errorCode } : {}),
|
|
801
861
|
...(message !== undefined ? { message } : {}),
|
|
862
|
+
...(retriable ? { retriable: true } : {}),
|
|
863
|
+
...(cause !== undefined || field !== undefined
|
|
864
|
+
? { extra: { ...(cause !== undefined ? { cause } : {}), ...(field !== undefined ? { field } : {}) } }
|
|
865
|
+
: {}),
|
|
866
|
+
...(unreadable ? { unreadable: true } : {}),
|
|
802
867
|
};
|
|
803
868
|
if (status !== undefined)
|
|
804
869
|
return { ...rest, status };
|
|
@@ -864,17 +929,28 @@ function usableProbeReason(raw) {
|
|
|
864
929
|
}
|
|
865
930
|
const PROBE_CAUSE_CODE_WORD = /^[a-z][a-z0-9_]{0,31}(?:\.[a-z][a-z0-9_]{0,31}){1,3}$/;
|
|
866
931
|
export function askProbeReasonDetail(card) {
|
|
867
|
-
const
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
932
|
+
const prose = usableProbeReason(ownDataValue(card, 'probeReason'));
|
|
933
|
+
const shown = prose === undefined ? '' : displayUntrusted(prose);
|
|
934
|
+
const sentence = probeCauseSentence(ownDataValue(card, 'probeCause'), shown !== '');
|
|
935
|
+
if (sentence === undefined)
|
|
936
|
+
return shown === '' ? undefined : shown;
|
|
937
|
+
return shown === '' ? sentence : `${sentence} ${shown}`;
|
|
938
|
+
}
|
|
939
|
+
function probeCauseSentence(cause, withProse) {
|
|
940
|
+
try {
|
|
941
|
+
if (!isWireRecordCarrier(cause))
|
|
942
|
+
return undefined;
|
|
943
|
+
const code = ownDataValue(cause, 'code');
|
|
944
|
+
const head = withProse
|
|
945
|
+
? 'An automatic check could not clear this call, so it is asking you'
|
|
946
|
+
: 'An automatic check could not clear this call, so it is asking you; the engine did not say the specific reason';
|
|
947
|
+
return typeof code === 'string' && PROBE_CAUSE_CODE_WORD.test(code) ? `${head} (check code: ${code}).` : `${head}.`;
|
|
948
|
+
}
|
|
949
|
+
catch {
|
|
872
950
|
return undefined;
|
|
873
|
-
|
|
874
|
-
const head = 'An automatic check could not clear this call, so it is asking you; the engine did not say the specific reason';
|
|
875
|
-
return typeof code === 'string' && PROBE_CAUSE_CODE_WORD.test(code) ? `${head} (check code: ${code}).` : `${head}.`;
|
|
951
|
+
}
|
|
876
952
|
}
|
|
877
|
-
function
|
|
953
|
+
export function readApprovalRememberRefused(v) {
|
|
878
954
|
try {
|
|
879
955
|
return typeof v === 'object' && v !== null && Object.hasOwn(v, 'rememberRefused') && v.rememberRefused === true;
|
|
880
956
|
}
|
|
@@ -926,6 +1002,76 @@ export function readApprovalBoundGrants(v) {
|
|
|
926
1002
|
return undefined;
|
|
927
1003
|
return Object.freeze({ skill, allowedTools, disallowedTools });
|
|
928
1004
|
}
|
|
1005
|
+
function readApprovalGrantBinding(carrier) {
|
|
1006
|
+
if (typeof carrier !== 'object' || carrier === null)
|
|
1007
|
+
return 'unreadable';
|
|
1008
|
+
try {
|
|
1009
|
+
if (Object.hasOwn(carrier, 'boundGrantDigest')) {
|
|
1010
|
+
const digest = ownDataValue(carrier, 'boundGrantDigest');
|
|
1011
|
+
return typeof digest === 'string' && digest.length > 0 ? 'bound' : 'unreadable';
|
|
1012
|
+
}
|
|
1013
|
+
const tool = ownDataValue(carrier, 'toolName');
|
|
1014
|
+
if (typeof tool !== 'string' || tool.length === 0)
|
|
1015
|
+
return 'unreadable';
|
|
1016
|
+
return tool === CORE_SKILL_TOOL_NAME ? 'unreadable' : 'none';
|
|
1017
|
+
}
|
|
1018
|
+
catch {
|
|
1019
|
+
return 'unreadable';
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
const UNREADABLE_EVIDENCE_KEYS = Object.freeze({
|
|
1023
|
+
frame: Object.freeze([
|
|
1024
|
+
['rememberRefused', 'rememberRefused'], ['governanceForced', 'governanceForced'], ['requiresRealApproval', 'requiresRealApproval'],
|
|
1025
|
+
['mandated', 'mandated'], ['mandate', 'mandate'], ['origin', 'origin'], ['ruleOffersAbsence', 'ruleOffersAbsence'], ['ruleOffers', 'ruleOffers'],
|
|
1026
|
+
['allowRuleShadowed', 'allowRuleShadow'], ['persistedRuleShadowed', 'allowRuleShadow'], ['askClass', 'askClass'], ['classes', 'classes'],
|
|
1027
|
+
]),
|
|
1028
|
+
row: Object.freeze([
|
|
1029
|
+
['rememberRefused', 'rememberRefused'], ['governanceForced', 'governanceForced'], ['requiresRealApproval', 'requiresRealApproval'],
|
|
1030
|
+
['mandated', 'mandated'], ['mandate', 'mandate'], ['origin', 'origin'], ['ruleOffersAbsence', 'ruleOffersAbsence'], ['ruleOffers', 'ruleOffersReadOnly'],
|
|
1031
|
+
['askClass', 'askClass'], ['classes', 'classes'],
|
|
1032
|
+
]),
|
|
1033
|
+
v1: Object.freeze([
|
|
1034
|
+
['rememberRefused', 'rememberRefused'], ['governanceForced', 'governanceForced'], ['ruleOffersAbsence', 'ruleOffersAbsence'], ['ruleOffers', 'ruleOffersReadOnly'],
|
|
1035
|
+
['allowRuleShadowed', 'allowRuleShadow'], ['persistedRuleShadowed', 'allowRuleShadow'], ['askClass', 'askClass'], ['classes', 'classes'],
|
|
1036
|
+
]),
|
|
1037
|
+
});
|
|
1038
|
+
function carrierHas(carrier, key) {
|
|
1039
|
+
if (typeof carrier !== 'object' || carrier === null)
|
|
1040
|
+
return false;
|
|
1041
|
+
try {
|
|
1042
|
+
return key in carrier;
|
|
1043
|
+
}
|
|
1044
|
+
catch {
|
|
1045
|
+
return true;
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
function v1RiskUnreadable(card) {
|
|
1049
|
+
if (!carrierHas(card, 'risk'))
|
|
1050
|
+
return false;
|
|
1051
|
+
try {
|
|
1052
|
+
const risk = card.risk;
|
|
1053
|
+
return typeof risk !== 'object' || risk === null || typeof risk.requiresRealApproval !== 'boolean';
|
|
1054
|
+
}
|
|
1055
|
+
catch {
|
|
1056
|
+
return true;
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
function withUnreadableEvidence(carrier, leg, req) {
|
|
1060
|
+
const keys = new Set();
|
|
1061
|
+
for (const [from, to] of UNREADABLE_EVIDENCE_KEYS[leg]) {
|
|
1062
|
+
if (carrierHas(carrier, from) && !Object.hasOwn(req, to))
|
|
1063
|
+
keys.add(from);
|
|
1064
|
+
}
|
|
1065
|
+
if (leg === 'row') {
|
|
1066
|
+
const rd = ownDataValue(carrier, 'riskDescriptor');
|
|
1067
|
+
for (const k of ['allowRuleShadowed', 'shadowedRule'])
|
|
1068
|
+
if (carrierHas(rd, k) && !Object.hasOwn(req, 'allowRuleShadow'))
|
|
1069
|
+
keys.add(`riskDescriptor.${k}`);
|
|
1070
|
+
}
|
|
1071
|
+
if (leg === 'v1' && v1RiskUnreadable(carrier))
|
|
1072
|
+
keys.add('risk');
|
|
1073
|
+
return keys.size === 0 ? req : { ...req, unreadableEvidence: Object.freeze([...keys].sort()) };
|
|
1074
|
+
}
|
|
929
1075
|
const CAUSE_WORD = /^[a-z][a-z0-9_]{0,63}$/;
|
|
930
1076
|
export function readApprovalClassifierNoRuling(v) {
|
|
931
1077
|
const w = ownDataValue(v, 'classifierNoRuling');
|
|
@@ -1207,20 +1353,163 @@ function subagentBadgeFor(frame) {
|
|
|
1207
1353
|
name = `${name.slice(0, 31)}…`;
|
|
1208
1354
|
return { name, color: 'cyan' };
|
|
1209
1355
|
}
|
|
1356
|
+
function v1Bit(stamp) {
|
|
1357
|
+
try {
|
|
1358
|
+
stamp();
|
|
1359
|
+
}
|
|
1360
|
+
catch {
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
export function approvalCardFactsOfV1(card) {
|
|
1364
|
+
if (typeof card !== 'object' || card === null)
|
|
1365
|
+
return undefined;
|
|
1366
|
+
const c = card;
|
|
1367
|
+
const asFrame = card;
|
|
1368
|
+
const fromSubagent = (() => {
|
|
1369
|
+
try {
|
|
1370
|
+
return isFromSubagent(asFrame);
|
|
1371
|
+
}
|
|
1372
|
+
catch {
|
|
1373
|
+
return false;
|
|
1374
|
+
}
|
|
1375
|
+
})();
|
|
1376
|
+
const argsPart = (() => {
|
|
1377
|
+
try {
|
|
1378
|
+
const raw = c.args !== undefined && c.args !== null ? c.args : undefined;
|
|
1379
|
+
if (typeof raw === 'object' && raw !== null)
|
|
1380
|
+
return { args: raw };
|
|
1381
|
+
const fallback = argsFallbackOf(c.message, c.argsOmitted);
|
|
1382
|
+
return { args: fallback.args, argsUnavailable: true, ...(fallback.omittedNote !== undefined ? { wireNote: fallback.omittedNote } : {}) };
|
|
1383
|
+
}
|
|
1384
|
+
catch {
|
|
1385
|
+
return { args: {}, argsUnavailable: true };
|
|
1386
|
+
}
|
|
1387
|
+
})();
|
|
1388
|
+
const out = { toolName: '', ...argsPart };
|
|
1389
|
+
v1Bit(() => {
|
|
1390
|
+
if (typeof c.toolName === 'string')
|
|
1391
|
+
out.toolName = c.toolName;
|
|
1392
|
+
});
|
|
1393
|
+
v1Bit(() => {
|
|
1394
|
+
if (typeof c.toolCallId === 'string' && c.toolCallId !== '')
|
|
1395
|
+
out.toolCallId = c.toolCallId;
|
|
1396
|
+
});
|
|
1397
|
+
v1Bit(() => {
|
|
1398
|
+
if (fromSubagent)
|
|
1399
|
+
out.workerBadge = subagentBadgeFor(asFrame);
|
|
1400
|
+
});
|
|
1401
|
+
v1Bit(() => {
|
|
1402
|
+
if (c.governanceForced === true)
|
|
1403
|
+
out.governanceForced = true;
|
|
1404
|
+
});
|
|
1405
|
+
v1Bit(() => {
|
|
1406
|
+
const d = c.delegation;
|
|
1407
|
+
if (fromSubagent && isToolApprovalDelegation(d))
|
|
1408
|
+
out.delegation = d;
|
|
1409
|
+
});
|
|
1410
|
+
v1Bit(() => {
|
|
1411
|
+
const offers = readRuleOffers(c.ruleOffers);
|
|
1412
|
+
if (offers !== undefined)
|
|
1413
|
+
out.ruleOffersReadOnly = offers;
|
|
1414
|
+
});
|
|
1415
|
+
v1Bit(() => {
|
|
1416
|
+
const shadow = readAllowRuleShadowFromWire(card, 'frame');
|
|
1417
|
+
if (shadow !== undefined)
|
|
1418
|
+
out.allowRuleShadow = shadow;
|
|
1419
|
+
});
|
|
1420
|
+
v1Bit(() => {
|
|
1421
|
+
const pc = c.probeCause;
|
|
1422
|
+
if (isWireRecordCarrier(pc))
|
|
1423
|
+
out.probeCause = pc;
|
|
1424
|
+
});
|
|
1425
|
+
v1Bit(() => {
|
|
1426
|
+
if (readApprovalRememberRefused(card))
|
|
1427
|
+
out.rememberRefused = true;
|
|
1428
|
+
});
|
|
1429
|
+
v1Bit(() => {
|
|
1430
|
+
const re = c.ruleEvidence;
|
|
1431
|
+
if (isWireRecordCarrier(re))
|
|
1432
|
+
out.ruleEvidence = re;
|
|
1433
|
+
});
|
|
1434
|
+
v1Bit(() => {
|
|
1435
|
+
const risk = c.risk;
|
|
1436
|
+
if (typeof risk === 'object' && risk !== null && risk.requiresRealApproval === true)
|
|
1437
|
+
out.requiresRealApproval = true;
|
|
1438
|
+
});
|
|
1439
|
+
v1Bit(() => {
|
|
1440
|
+
if (c.inputHasBidi === true)
|
|
1441
|
+
out.inputHasBidi = true;
|
|
1442
|
+
});
|
|
1443
|
+
v1Bit(() => {
|
|
1444
|
+
const w = c.ruleOffersAbsence;
|
|
1445
|
+
if (typeof w === 'string' && w !== '')
|
|
1446
|
+
out.ruleOffersAbsence = w;
|
|
1447
|
+
});
|
|
1448
|
+
v1Bit(() => {
|
|
1449
|
+
const dlf = readDenialLimitFallback(c.denialLimitFallback);
|
|
1450
|
+
if (dlf !== undefined)
|
|
1451
|
+
out.denialLimitFallback = dlf;
|
|
1452
|
+
});
|
|
1453
|
+
v1Bit(() => {
|
|
1454
|
+
const pair = readAskClassPair(card);
|
|
1455
|
+
if (pair !== undefined) {
|
|
1456
|
+
out.askClass = pair.askClass;
|
|
1457
|
+
out.classes = pair.classes;
|
|
1458
|
+
}
|
|
1459
|
+
});
|
|
1460
|
+
out.grantBinding = readApprovalGrantBinding(card);
|
|
1461
|
+
return Object.freeze(withUnreadableEvidence(card, 'v1', out));
|
|
1462
|
+
}
|
|
1210
1463
|
const MAX_RESPOND_NOTE_CHARS = 2048;
|
|
1211
|
-
export async function surfaceToolApprovalFrameAndRespond(frame, respond, streamArgs, signal, lane) {
|
|
1464
|
+
export async function surfaceToolApprovalFrameAndRespond(frame, respond, streamArgs, signal, lane, run) {
|
|
1212
1465
|
const approvalId = frame.approvalId;
|
|
1213
|
-
const
|
|
1214
|
-
const held = liveCardHoldOf(key);
|
|
1466
|
+
const held = liveCardHoldOf(liveFrameCallKey(approvalId));
|
|
1215
1467
|
if (held !== undefined)
|
|
1216
1468
|
return joinLiveCard(held, signal);
|
|
1217
|
-
return holdLiveCard(
|
|
1469
|
+
return holdLiveCard(liveCardIdentityOf(approvalId, frame, run), signal, async (hold) => {
|
|
1218
1470
|
const slot = {};
|
|
1219
1471
|
const out = await presentToolApprovalFrameAndRespond(frame, approvalId, respond, streamArgs, signal, lane, hold, slot);
|
|
1220
1472
|
noteCallOutcome(slot, out);
|
|
1221
1473
|
return out;
|
|
1222
1474
|
});
|
|
1223
1475
|
}
|
|
1476
|
+
function liveCardIdentityOf(approvalId, frame, run) {
|
|
1477
|
+
const toolCallId = typeof frame.toolCallId === 'string' && frame.toolCallId !== '' ? frame.toolCallId : undefined;
|
|
1478
|
+
const fromSubagent = isFromSubagent(frame);
|
|
1479
|
+
const ownRun = fromSubagent ? frame.sourceTaskId : run?.taskId;
|
|
1480
|
+
const taskId = typeof ownRun === 'string' && ownRun !== '' ? ownRun : undefined;
|
|
1481
|
+
const sessionId = !fromSubagent && typeof run?.sessionId === 'string' && run.sessionId !== '' ? run.sessionId : undefined;
|
|
1482
|
+
return {
|
|
1483
|
+
approvalId,
|
|
1484
|
+
...(toolCallId !== undefined ? { toolCallId } : {}),
|
|
1485
|
+
...(taskId !== undefined ? { taskId } : {}),
|
|
1486
|
+
...(sessionId !== undefined ? { sessionId } : {}),
|
|
1487
|
+
};
|
|
1488
|
+
}
|
|
1489
|
+
function readApprovalHolderIdentity(v) {
|
|
1490
|
+
if (typeof v !== 'object' || v === null)
|
|
1491
|
+
return {};
|
|
1492
|
+
const out = {};
|
|
1493
|
+
try {
|
|
1494
|
+
for (const k of ['approvalId', 'taskId', 'toolCallId', 'sessionId']) {
|
|
1495
|
+
const d = Object.getOwnPropertyDescriptor(v, k);
|
|
1496
|
+
const x = d !== undefined && Object.hasOwn(d, 'value') ? d.value : undefined;
|
|
1497
|
+
if (typeof x === 'string' && x !== '')
|
|
1498
|
+
out[k] = x;
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
catch {
|
|
1502
|
+
return {};
|
|
1503
|
+
}
|
|
1504
|
+
return out;
|
|
1505
|
+
}
|
|
1506
|
+
export async function joinApprovalHolder(identity, signal) {
|
|
1507
|
+
const hold = liveCardHoldFor(readApprovalHolderIdentity(identity));
|
|
1508
|
+
if (hold === undefined)
|
|
1509
|
+
return { kind: 'free' };
|
|
1510
|
+
const joined = await awaitLiveCardHolder(hold, signal);
|
|
1511
|
+
return joined !== undefined ? { kind: 'joined', outcome: joined } : { kind: 'free' };
|
|
1512
|
+
}
|
|
1224
1513
|
async function presentToolApprovalFrameAndRespond(frame, approvalId, respond, streamArgs, signal, lane, hold, ledgerSlot) {
|
|
1225
1514
|
const frameToolCallId = typeof frame.toolCallId === 'string' && frame.toolCallId !== '' ? frame.toolCallId : undefined;
|
|
1226
1515
|
const decidedByReading = decidedByReadingSnapshotOf(lane);
|
|
@@ -1234,11 +1523,11 @@ async function presentToolApprovalFrameAndRespond(frame, approvalId, respond, st
|
|
|
1234
1523
|
let argsFallback = false;
|
|
1235
1524
|
if (typeof args !== 'object' || args === null) {
|
|
1236
1525
|
argsFallback = true;
|
|
1237
|
-
const
|
|
1238
|
-
args =
|
|
1239
|
-
if (
|
|
1240
|
-
wireNote =
|
|
1241
|
-
hostLog('debug', `liveToolApprovalWire: frame ${approvalId} args omitted (>16KiB wire cap) — card falls back to ${
|
|
1526
|
+
const fallback = argsFallbackOf(frame.message, frame.argsOmitted);
|
|
1527
|
+
args = fallback.args;
|
|
1528
|
+
if (fallback.omittedNote !== undefined) {
|
|
1529
|
+
wireNote = fallback.omittedNote;
|
|
1530
|
+
hostLog('debug', `liveToolApprovalWire: frame ${approvalId} args omitted (>16KiB wire cap) — card falls back to ${fallback.pathRecovered ? 'the message-derived path' : 'an empty input (no path could be derived from the message)'}`);
|
|
1242
1531
|
}
|
|
1243
1532
|
if (lane?.argsUnavailable === true) {
|
|
1244
1533
|
wireNote =
|
|
@@ -1251,7 +1540,7 @@ async function presentToolApprovalFrameAndRespond(frame, approvalId, respond, st
|
|
|
1251
1540
|
const ruleOffers = readRuleOffers(frame.ruleOffers);
|
|
1252
1541
|
const denialLimitFallback = readDenialLimitFallback(frame.denialLimitFallback);
|
|
1253
1542
|
const frameShadow = readAllowRuleShadowFromWire(frame, 'frame');
|
|
1254
|
-
const card = await surfaceCallTrackedCard(frameToolCallId, approvalId, ledgerSlot, {
|
|
1543
|
+
const card = await surfaceCallTrackedCard(frameToolCallId, approvalId, ledgerSlot, withUnreadableEvidence(frame, 'frame', {
|
|
1255
1544
|
toolName,
|
|
1256
1545
|
args: args,
|
|
1257
1546
|
callKey: liveFrameCallKey(approvalId),
|
|
@@ -1278,10 +1567,9 @@ async function presentToolApprovalFrameAndRespond(frame, approvalId, respond, st
|
|
|
1278
1567
|
: {}),
|
|
1279
1568
|
...(ruleOffers !== undefined ? { ruleOffers } : {}),
|
|
1280
1569
|
...((sh) => (sh !== undefined ? { allowRuleShadow: sh } : {}))(frameShadow),
|
|
1281
|
-
...((t) => (t !== undefined ? { persistedRuleShadowed: t } : {}))(legacyShadowedRuleTextOf(frameShadow)),
|
|
1282
1570
|
...(isWireRecordCarrier(frame.probeCause) ? { probeCause: frame.probeCause } : {}),
|
|
1283
1571
|
...((r) => (r !== undefined ? { probeReason: r } : {}))(readProbeReason(frame)),
|
|
1284
|
-
...(
|
|
1572
|
+
...(readApprovalRememberRefused(frame) ? { rememberRefused: true } : {}),
|
|
1285
1573
|
...(isWireRecordCarrier(frame.ruleEvidence) ? { ruleEvidence: frame.ruleEvidence } : {}),
|
|
1286
1574
|
...(frame.requiresRealApproval === true ? { requiresRealApproval: true } : {}),
|
|
1287
1575
|
...(hasOwnStrictTrue(frame, 'mandated') ? { mandated: true } : {}),
|
|
@@ -1292,11 +1580,13 @@ async function presentToolApprovalFrameAndRespond(frame, approvalId, respond, st
|
|
|
1292
1580
|
? { ruleOffersAbsence: frame.ruleOffersAbsence }
|
|
1293
1581
|
: {}),
|
|
1294
1582
|
...(denialLimitFallback !== undefined ? { denialLimitFallback } : {}),
|
|
1295
|
-
...((o) => (o !== undefined ? { origin: o } : {}))(
|
|
1583
|
+
...((o) => (o !== undefined ? { origin: o } : {}))(readAskOrigin(frame)),
|
|
1296
1584
|
...(readAskClassPair(frame) ?? {}),
|
|
1297
1585
|
...((g) => (g !== undefined ? { boundGrants: g } : {}))(readApprovalBoundGrants(frame)),
|
|
1298
1586
|
...((w) => (w !== undefined ? { classifierNoRuling: w } : {}))(readApprovalClassifierNoRuling(frame)),
|
|
1299
|
-
|
|
1587
|
+
allowSessionCarried: true,
|
|
1588
|
+
grantBinding: readApprovalGrantBinding(frame),
|
|
1589
|
+
}));
|
|
1300
1590
|
if (hold.superseded !== undefined) {
|
|
1301
1591
|
hostLog('debug', `liveToolApprovalWire: ${approvalId} was settled by the engine while its card was up${hold.superseded.parked ? ' (parked)' : ''} — card withdrawn; ` +
|
|
1302
1592
|
`the card came back ${card.kind}; nothing sent`);
|
|
@@ -3,15 +3,7 @@ export type HookMatcherVerdict = {
|
|
|
3
3
|
readonly kind: 'matchesAll';
|
|
4
4
|
} | {
|
|
5
5
|
readonly kind: 'accepted';
|
|
6
|
-
readonly reading: 'names';
|
|
7
|
-
readonly names: readonly string[];
|
|
8
|
-
readonly aliases: readonly {
|
|
9
|
-
readonly alias: string;
|
|
10
|
-
readonly canonical: string;
|
|
11
|
-
}[];
|
|
12
|
-
} | {
|
|
13
|
-
readonly kind: 'accepted';
|
|
14
|
-
readonly reading: 'pattern';
|
|
6
|
+
readonly reading: 'names' | 'pattern';
|
|
15
7
|
readonly aliases: readonly {
|
|
16
8
|
readonly alias: string;
|
|
17
9
|
readonly canonical: string;
|