@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,29 +1,65 @@
|
|
|
1
|
-
import { hasLedgerPositionKey } from './gateLedger.js';
|
|
1
|
+
import { APPROVAL_SETTLED_HOWS, hasLedgerPositionKey } from './gateLedger.js';
|
|
2
2
|
import { readLivePendingRows } from './livePendingAsk.js';
|
|
3
3
|
import { projectCrashConverged } from './crashConverged.js';
|
|
4
|
+
import { quoteUntrustedForSentence } from '../displayUntrusted.js';
|
|
5
|
+
import { readOwnDataValue } from '../ownKey.js';
|
|
4
6
|
const live = (basis) => Object.freeze({ kind: 'live', basis });
|
|
5
7
|
const unknown = (why) => Object.freeze({ kind: 'unknown', why });
|
|
6
|
-
const decided = (
|
|
8
|
+
const decided = (row) => Object.freeze(row === undefined
|
|
9
|
+
? { kind: 'decided' }
|
|
10
|
+
: { kind: 'decided', cause: row.cause, ...(row.needsHumanReason !== undefined ? { needsHumanReason: row.needsHumanReason } : {}) });
|
|
11
|
+
const decidedSettled = (how) => Object.freeze({ kind: 'decided', settled: how });
|
|
7
12
|
function approvalIdOf(frame) {
|
|
8
13
|
const v = frame.approvalId;
|
|
9
14
|
return typeof v === 'string' && v !== '' ? v : undefined;
|
|
10
15
|
}
|
|
11
|
-
function
|
|
16
|
+
function crashConvergedFactsOf(body, approvalId) {
|
|
12
17
|
const projection = projectCrashConverged(body);
|
|
13
18
|
if (projection === undefined)
|
|
14
19
|
return undefined;
|
|
15
20
|
for (const row of [...projection.resumeSafe, ...projection.needsHuman]) {
|
|
16
21
|
if (row.approvalId === approvalId)
|
|
17
|
-
return row.cause;
|
|
22
|
+
return { cause: row.cause, ...(row.needsHumanReason !== undefined ? { needsHumanReason: row.needsHumanReason } : {}) };
|
|
18
23
|
}
|
|
19
24
|
return undefined;
|
|
20
25
|
}
|
|
26
|
+
export function settledApprovalDisposition(frame, settled) {
|
|
27
|
+
try {
|
|
28
|
+
if (typeof settled !== 'object' || settled === null || typeof settled.get !== 'function')
|
|
29
|
+
return undefined;
|
|
30
|
+
const id = approvalIdOf(frame);
|
|
31
|
+
if (id === undefined)
|
|
32
|
+
return undefined;
|
|
33
|
+
const how = settled.get(id);
|
|
34
|
+
return typeof how === 'string' && APPROVAL_SETTLED_HOWS.includes(how) ? decidedSettled(how) : undefined;
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
21
40
|
export function replayedApprovalDisposition(frame, basis) {
|
|
22
41
|
let approvalId;
|
|
42
|
+
let positioned;
|
|
23
43
|
try {
|
|
24
44
|
if (typeof frame !== 'object' || frame === null)
|
|
25
45
|
return unknown('unreadable_frame');
|
|
26
|
-
|
|
46
|
+
positioned = hasLedgerPositionKey(frame);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return unknown('unreadable_frame');
|
|
50
|
+
}
|
|
51
|
+
let settledBasis;
|
|
52
|
+
try {
|
|
53
|
+
settledBasis = typeof basis === 'object' && basis !== null ? basis.settled : undefined;
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
settledBasis = undefined;
|
|
57
|
+
}
|
|
58
|
+
const early = settledApprovalDisposition(frame, settledBasis);
|
|
59
|
+
if (early !== undefined)
|
|
60
|
+
return early;
|
|
61
|
+
try {
|
|
62
|
+
if (!positioned)
|
|
27
63
|
return live('live_leg');
|
|
28
64
|
approvalId = approvalIdOf(frame);
|
|
29
65
|
}
|
|
@@ -70,15 +106,15 @@ export function replayedApprovalDisposition(frame, basis) {
|
|
|
70
106
|
}
|
|
71
107
|
if (reading.kind === 'present' && reading.rows.some((r) => r.approvalId === approvalId))
|
|
72
108
|
return live('pending_list');
|
|
73
|
-
let
|
|
109
|
+
let facts;
|
|
74
110
|
try {
|
|
75
|
-
|
|
111
|
+
facts = crashConvergedFactsOf(body, approvalId);
|
|
76
112
|
}
|
|
77
113
|
catch {
|
|
78
|
-
|
|
114
|
+
facts = undefined;
|
|
79
115
|
}
|
|
80
|
-
if (
|
|
81
|
-
return decided(
|
|
116
|
+
if (facts !== undefined)
|
|
117
|
+
return decided(facts);
|
|
82
118
|
if (reading.kind === 'not_reported')
|
|
83
119
|
return unknown('list_not_reported');
|
|
84
120
|
if (reading.kind === 'malformed')
|
|
@@ -87,3 +123,96 @@ export function replayedApprovalDisposition(frame, basis) {
|
|
|
87
123
|
return unknown('list_incomplete');
|
|
88
124
|
return decided();
|
|
89
125
|
}
|
|
126
|
+
const TOOL_NAME_MAX = 80;
|
|
127
|
+
const THIS_REQUEST = 'this approval request';
|
|
128
|
+
const sentenceInitial = (s) => s.charAt(0).toUpperCase() + s.slice(1);
|
|
129
|
+
const TOOL_STATE_NOT_SHOWN = 'Whether the tool had started is not shown here.';
|
|
130
|
+
const STOPPED_BY_CAUSE = Object.freeze({
|
|
131
|
+
crashed_before_park: 'the engine stopped unexpectedly',
|
|
132
|
+
shutdown_before_park: 'the engine was shut down in an orderly way',
|
|
133
|
+
});
|
|
134
|
+
const STATE_BY_REASON = Object.freeze({
|
|
135
|
+
pending_unsafe: 'waiting',
|
|
136
|
+
approved_then_interrupted: 'approved',
|
|
137
|
+
contradictory: 'unclear',
|
|
138
|
+
unstable_row: 'unclear',
|
|
139
|
+
});
|
|
140
|
+
const CRASH_CONVERGED_SENTENCE = Object.freeze({
|
|
141
|
+
waiting: (what, stopped) => `${sentenceInitial(what)} was still waiting when ${stopped}, so the engine denied it automatically; no decision was sent for it from here. ${TOOL_STATE_NOT_SHOWN}`,
|
|
142
|
+
approved: (what, stopped) => `${sentenceInitial(what)} had already been approved and may have been running when ${stopped}, so a side effect may have partly landed; the engine then marked it denied, and no decision was sent for it from here.`,
|
|
143
|
+
unclear: (what, stopped) => `${sentenceInitial(what)} was denied automatically when ${stopped}, but its record does not show reliably whether it had been approved or whether the tool had started; no decision was sent for it from here.`,
|
|
144
|
+
});
|
|
145
|
+
function crashConvergedStateOf(disposition) {
|
|
146
|
+
let reason;
|
|
147
|
+
try {
|
|
148
|
+
if (typeof disposition !== 'object' || disposition === null || !('needsHumanReason' in disposition))
|
|
149
|
+
return 'waiting';
|
|
150
|
+
reason = disposition.needsHumanReason;
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
return 'unclear';
|
|
154
|
+
}
|
|
155
|
+
if (reason === undefined)
|
|
156
|
+
return 'waiting';
|
|
157
|
+
return typeof reason === 'string' && Object.hasOwn(STATE_BY_REASON, reason) ? STATE_BY_REASON[reason] : 'unclear';
|
|
158
|
+
}
|
|
159
|
+
const SETTLED_PHRASE = Object.freeze({
|
|
160
|
+
answered: 'answered',
|
|
161
|
+
interrupted: 'dismissed',
|
|
162
|
+
closed_by_engine: 'closed by the engine',
|
|
163
|
+
});
|
|
164
|
+
const settledRepeat = (what, how) => `${sentenceInitial(what)} was ${SETTLED_PHRASE[how]} earlier, so this repeated copy of it was not raised as a new question and no decision was sent for it.`;
|
|
165
|
+
const decidedPlain = (what) => `${sentenceInitial(what)} is no longer listed by the engine as waiting for a decision, so no decision was sent for it.`;
|
|
166
|
+
export function replayedApprovalClosesCardFrame(disposition) {
|
|
167
|
+
try {
|
|
168
|
+
if (typeof disposition !== 'object' || disposition === null)
|
|
169
|
+
return false;
|
|
170
|
+
if (readOwnDataValue(disposition, 'kind') !== 'decided')
|
|
171
|
+
return false;
|
|
172
|
+
const cause = readOwnDataValue(disposition, 'cause');
|
|
173
|
+
return typeof cause === 'string' && Object.hasOwn(STOPPED_BY_CAUSE, cause);
|
|
174
|
+
}
|
|
175
|
+
catch {
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
const unconfirmed = (what) => `Whether ${what} is still waiting for a decision could not be confirmed, so no decision was sent for it.`;
|
|
180
|
+
function guardedGet(o, key) {
|
|
181
|
+
try {
|
|
182
|
+
if (typeof o !== 'object' || o === null)
|
|
183
|
+
return undefined;
|
|
184
|
+
return o[key];
|
|
185
|
+
}
|
|
186
|
+
catch {
|
|
187
|
+
return undefined;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
function subjectOf(opts) {
|
|
191
|
+
const raw = guardedGet(opts, 'toolName');
|
|
192
|
+
if (typeof raw !== 'string')
|
|
193
|
+
return THIS_REQUEST;
|
|
194
|
+
let quoted;
|
|
195
|
+
try {
|
|
196
|
+
quoted = quoteUntrustedForSentence(raw, TOOL_NAME_MAX);
|
|
197
|
+
}
|
|
198
|
+
catch {
|
|
199
|
+
return THIS_REQUEST;
|
|
200
|
+
}
|
|
201
|
+
return quoted === undefined ? THIS_REQUEST : `the approval request for ${quoted}`;
|
|
202
|
+
}
|
|
203
|
+
export function replayedApprovalSentence(disposition, opts) {
|
|
204
|
+
const kind = guardedGet(disposition, 'kind');
|
|
205
|
+
if (kind === 'unknown')
|
|
206
|
+
return unconfirmed(subjectOf(opts));
|
|
207
|
+
if (kind !== 'decided')
|
|
208
|
+
return undefined;
|
|
209
|
+
const what = subjectOf(opts);
|
|
210
|
+
const cause = guardedGet(disposition, 'cause');
|
|
211
|
+
if (typeof cause === 'string' && Object.hasOwn(STOPPED_BY_CAUSE, cause)) {
|
|
212
|
+
return CRASH_CONVERGED_SENTENCE[crashConvergedStateOf(disposition)](what, STOPPED_BY_CAUSE[cause]);
|
|
213
|
+
}
|
|
214
|
+
const settled = guardedGet(disposition, 'settled');
|
|
215
|
+
if (typeof settled === 'string' && Object.hasOwn(SETTLED_PHRASE, settled))
|
|
216
|
+
return settledRepeat(what, settled);
|
|
217
|
+
return decidedPlain(what);
|
|
218
|
+
}
|
|
@@ -17,6 +17,7 @@ export interface ResumeRunningCardOption {
|
|
|
17
17
|
}
|
|
18
18
|
export declare function resumeRunningLivenessRow(msSinceLastActivity: number | null | undefined): string | null;
|
|
19
19
|
export declare function resumeRunningQuestionText(i: ResumeRunningCardInput): string;
|
|
20
|
+
export declare function runningAttachOffered(canAttach: boolean | undefined): boolean;
|
|
20
21
|
export declare function resumeRunningOptions(i: ResumeRunningCardInput): ResumeRunningCardOption[];
|
|
21
22
|
export declare function resumeChoiceFromLabels(selected: readonly string[] | null | undefined): ResumeRunningChoice;
|
|
22
23
|
export declare const RESUME_RUNNING_NO_UI_EXIT_CODE = 75;
|
|
@@ -26,4 +27,5 @@ export declare function resumeRunningNoUiGuidance(i: {
|
|
|
26
27
|
sessionId?: string | null;
|
|
27
28
|
}): string;
|
|
28
29
|
export declare function resumeAttachReplayDisclosure(taskId: string): string;
|
|
30
|
+
export declare function resumeRunningCancelConfirmedRow(taskId: string): string;
|
|
29
31
|
export declare function resumeRunningCancelUnconfirmedRow(taskId: string): string;
|
|
@@ -14,6 +14,9 @@ export function resumeRunningQuestionText(i) {
|
|
|
14
14
|
const liveness = resumeRunningLivenessRow(i.msSinceLastActivity);
|
|
15
15
|
return liveness === null ? head : `${head}\n${liveness}`;
|
|
16
16
|
}
|
|
17
|
+
export function runningAttachOffered(canAttach) {
|
|
18
|
+
return canAttach === true;
|
|
19
|
+
}
|
|
17
20
|
export function resumeRunningOptions(i) {
|
|
18
21
|
const options = [
|
|
19
22
|
{
|
|
@@ -21,7 +24,7 @@ export function resumeRunningOptions(i) {
|
|
|
21
24
|
description: 'Leaves the run alone. It keeps executing on the engine, but this screen will not show it and it will not be listed here — your next message runs into it again, and sema asks you then.',
|
|
22
25
|
},
|
|
23
26
|
];
|
|
24
|
-
if (i.canAttach) {
|
|
27
|
+
if (runningAttachOffered(i.canAttach)) {
|
|
25
28
|
options.push({
|
|
26
29
|
label: RESUME_CHOICE_ATTACH_LABEL,
|
|
27
30
|
description: 'Follows that run from here: sema replays it from the engine ledger and keeps streaming it into this conversation. ' +
|
|
@@ -65,8 +68,16 @@ export function resumeAttachReplayDisclosure(taskId) {
|
|
|
65
68
|
`The replayed turns are not billed into this session's cost again either — the engine's own record ` +
|
|
66
69
|
`(GET /v1/runs/${taskId}) is the authority on what that run really spent.`);
|
|
67
70
|
}
|
|
71
|
+
function cancelRow(taskId, confirmed) {
|
|
72
|
+
return confirmed
|
|
73
|
+
? `The engine accepted the cancel for run ${taskId} on your request. A cancel finishes on the engine's side, so that run may need a moment to stop.`
|
|
74
|
+
: `sema: the cancel for run ${taskId} did not come back confirmed, so that run may still be executing. ` +
|
|
75
|
+
`This screen does not list it — read its real state on the engine (GET /v1/runs/${taskId}) before ` +
|
|
76
|
+
`assuming this session is free.`;
|
|
77
|
+
}
|
|
78
|
+
export function resumeRunningCancelConfirmedRow(taskId) {
|
|
79
|
+
return cancelRow(taskId, true);
|
|
80
|
+
}
|
|
68
81
|
export function resumeRunningCancelUnconfirmedRow(taskId) {
|
|
69
|
-
return (
|
|
70
|
-
`This screen does not list it — read its real state on the engine (GET /v1/runs/${taskId}) before ` +
|
|
71
|
-
`assuming this session is free.`);
|
|
82
|
+
return cancelRow(taskId, false);
|
|
72
83
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CONFIG_LEGACY_TOOL_NAME, RULES_LEGACY_TOOL_NAME } from '../engineErrorCodes.js';
|
|
2
2
|
import { rosterMountedNames } from '../rosterMountedNames.js';
|
|
3
3
|
import { ruleCompileVerdict } from '../ruleCompileVerdict.js';
|
|
4
|
-
import {
|
|
4
|
+
import { ruleToolNameVerdictOf } from '../protocolSegment.js';
|
|
5
5
|
import { PREFIXES_IN_PROSE, REFUSED_NAME_CLASSES, REFUSED_NAME_FIX, RULES_LEGACY_TOOL_NAME_WRITE_NOTE } from './refusedToolNameProse.js';
|
|
6
6
|
import { CORE_PROTOCOL_PREFIXES, CORE_RETIRED_TOOL_CURRENT_NAMES } from '../generated/toolNameTables.js';
|
|
7
7
|
import { isEngineRefusedToolName } from '../engineRefusedToolName.js';
|
|
@@ -96,18 +96,20 @@ export function sessionPolicyDeliverable(behavior, rules, opts) {
|
|
|
96
96
|
}
|
|
97
97
|
let why = withheldWhyOf(r);
|
|
98
98
|
if (why === undefined) {
|
|
99
|
-
const grammar = ruleCompileVerdict(r, 'deny');
|
|
99
|
+
const grammar = ruleCompileVerdict(r, 'deny').kind;
|
|
100
100
|
if (grammar === 'unknown')
|
|
101
101
|
return unreadable();
|
|
102
102
|
if (grammar === 'refused')
|
|
103
103
|
why = 'not_a_tool_name';
|
|
104
104
|
}
|
|
105
105
|
if (why === undefined && COVERING_NAMESPACE_PREFIXES.some((p) => r.startsWith(p))) {
|
|
106
|
-
const
|
|
107
|
-
if (
|
|
108
|
-
why = 'not_a_tool_name';
|
|
109
|
-
else if (segment.kind === 'unknown')
|
|
106
|
+
const verdict = ruleToolNameVerdictOf(r);
|
|
107
|
+
if (verdict.kind === 'unknown')
|
|
110
108
|
return unreadable();
|
|
109
|
+
if (verdict.kind === 'unmintable_segment')
|
|
110
|
+
why = 'not_a_tool_name';
|
|
111
|
+
else if (verdict.kind === 'retired' || verdict.kind === 'unprefixed_namespace')
|
|
112
|
+
why = 'legacy_tool_name';
|
|
111
113
|
}
|
|
112
114
|
if (why === undefined && mounted !== undefined && !mounted.has(r))
|
|
113
115
|
why = 'not_in_roster';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type StandingRowWhy = 'given' | 'card_unreadable' | 'remember_refused' | 'remember_unreadable' | 'route_cannot_carry' | 'classes_unreadable' | 'not_deployment_list_question' | 'evidence_unreadable' | 'offers_unreadable' | 'engine_lane_closed' | 'args_unavailable' | 'grant_binding' | 'tool_name_unreadable' | 'rule_cannot_clear' | 'host_fact_missing' | 'face_not_generic' | 'rule_not_sent';
|
|
2
|
+
export type StandingPersistentRow = 'engine_offer' | 'local_whole_tool' | 'none';
|
|
3
|
+
export interface StandingRowsWhy {
|
|
4
|
+
readonly session: StandingRowWhy;
|
|
5
|
+
readonly persistent: StandingRowWhy;
|
|
6
|
+
readonly deploymentList: StandingRowWhy;
|
|
7
|
+
}
|
|
8
|
+
export interface StandingRows {
|
|
9
|
+
readonly sessionRow: boolean;
|
|
10
|
+
readonly persistentRow: StandingPersistentRow;
|
|
11
|
+
readonly deploymentListSessionRow: boolean;
|
|
12
|
+
readonly why: StandingRowsWhy;
|
|
13
|
+
}
|
|
14
|
+
export interface StandingRowsHostFacts {
|
|
15
|
+
readonly cardFace?: string;
|
|
16
|
+
readonly wholeToolRuleSent?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare function standingRowsOf(card: object | null | undefined, host?: StandingRowsHostFacts | null): StandingRows;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { readAskClassPairState } from './askClassPair.js';
|
|
2
|
+
import { automaticAnswerVerdict } from './automaticAnswerVerdict.js';
|
|
3
|
+
import { readRuleOffers } from './toolApprovalWire.js';
|
|
4
|
+
const DEPLOYMENT_LIST_ASK_CLASSES = Object.freeze(['ask_rule']);
|
|
5
|
+
const UNREADABLE = Symbol('unreadable');
|
|
6
|
+
function ownData(v, key) {
|
|
7
|
+
try {
|
|
8
|
+
const d = Object.getOwnPropertyDescriptor(v, key);
|
|
9
|
+
return d !== undefined && 'value' in d ? d.value : undefined;
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function hasKey(v, key) {
|
|
16
|
+
try {
|
|
17
|
+
return { inCard: key in v };
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return UNREADABLE;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function present(v, key) {
|
|
24
|
+
try {
|
|
25
|
+
const inCard = key in v;
|
|
26
|
+
return { inCard, value: inCard ? v[key] : undefined };
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return UNREADABLE;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function freezeRows(sessionRow, persistentRow, deploymentListSessionRow, why) {
|
|
33
|
+
return Object.freeze({ sessionRow, persistentRow, deploymentListSessionRow, why: Object.freeze({ ...why }) });
|
|
34
|
+
}
|
|
35
|
+
function allClosed(why) {
|
|
36
|
+
return freezeRows(false, 'none', false, { session: why, persistent: why, deploymentList: why });
|
|
37
|
+
}
|
|
38
|
+
function persistentRowOf(card, host, evidenceUnreadable) {
|
|
39
|
+
if (evidenceUnreadable)
|
|
40
|
+
return { row: 'none', why: 'evidence_unreadable' };
|
|
41
|
+
for (const key of ['ruleOffers', 'ruleOffersReadOnly']) {
|
|
42
|
+
const p = hasKey(card, key);
|
|
43
|
+
if (p === UNREADABLE)
|
|
44
|
+
return UNREADABLE;
|
|
45
|
+
if (!p.inCard)
|
|
46
|
+
continue;
|
|
47
|
+
const offers = readRuleOffers(ownData(card, key));
|
|
48
|
+
if (offers === undefined || offers.length === 0)
|
|
49
|
+
return { row: 'none', why: 'offers_unreadable' };
|
|
50
|
+
return { row: 'engine_offer', why: 'given' };
|
|
51
|
+
}
|
|
52
|
+
const absence = present(card, 'ruleOffersAbsence');
|
|
53
|
+
if (absence === UNREADABLE)
|
|
54
|
+
return UNREADABLE;
|
|
55
|
+
if (absence.inCard)
|
|
56
|
+
return { row: 'none', why: 'engine_lane_closed' };
|
|
57
|
+
const blind = present(card, 'argsUnavailable');
|
|
58
|
+
if (blind === UNREADABLE)
|
|
59
|
+
return UNREADABLE;
|
|
60
|
+
if (blind.inCard)
|
|
61
|
+
return { row: 'none', why: 'args_unavailable' };
|
|
62
|
+
if (ownData(card, 'grantBinding') !== 'none')
|
|
63
|
+
return { row: 'none', why: 'grant_binding' };
|
|
64
|
+
const tool = ownData(card, 'toolName');
|
|
65
|
+
if (typeof tool !== 'string' || tool.length === 0)
|
|
66
|
+
return { row: 'none', why: 'tool_name_unreadable' };
|
|
67
|
+
if (automaticAnswerVerdict(card, 'standing_rule').kind !== 'may_answer')
|
|
68
|
+
return { row: 'none', why: 'rule_cannot_clear' };
|
|
69
|
+
if (typeof host !== 'object' || host === null)
|
|
70
|
+
return { row: 'none', why: 'host_fact_missing' };
|
|
71
|
+
const face = ownData(host, 'cardFace');
|
|
72
|
+
if (typeof face !== 'string')
|
|
73
|
+
return { row: 'none', why: 'host_fact_missing' };
|
|
74
|
+
if (face !== 'generic')
|
|
75
|
+
return { row: 'none', why: 'face_not_generic' };
|
|
76
|
+
const sent = ownData(host, 'wholeToolRuleSent');
|
|
77
|
+
if (typeof sent !== 'boolean')
|
|
78
|
+
return { row: 'none', why: 'host_fact_missing' };
|
|
79
|
+
if (!sent)
|
|
80
|
+
return { row: 'none', why: 'rule_not_sent' };
|
|
81
|
+
return { row: 'local_whole_tool', why: 'given' };
|
|
82
|
+
}
|
|
83
|
+
export function standingRowsOf(card, host) {
|
|
84
|
+
if (typeof card !== 'object' || card === null)
|
|
85
|
+
return allClosed('card_unreadable');
|
|
86
|
+
try {
|
|
87
|
+
const refused = present(card, 'rememberRefused');
|
|
88
|
+
if (refused === UNREADABLE)
|
|
89
|
+
return allClosed('card_unreadable');
|
|
90
|
+
if (refused.inCard)
|
|
91
|
+
return allClosed(refused.value === true ? 'remember_refused' : 'remember_unreadable');
|
|
92
|
+
const evidence = present(card, 'unreadableEvidence');
|
|
93
|
+
if (evidence === UNREADABLE)
|
|
94
|
+
return allClosed('card_unreadable');
|
|
95
|
+
let evidenceUnreadable = false;
|
|
96
|
+
if (evidence.inCard) {
|
|
97
|
+
const list = ownData(card, 'unreadableEvidence');
|
|
98
|
+
if (!Array.isArray(list) || !list.every((k) => typeof k === 'string'))
|
|
99
|
+
return allClosed('card_unreadable');
|
|
100
|
+
if (list.includes('rememberRefused'))
|
|
101
|
+
return allClosed('remember_unreadable');
|
|
102
|
+
evidenceUnreadable = list.length > 0;
|
|
103
|
+
}
|
|
104
|
+
const sessionRow = ownData(card, 'allowSessionCarried') === true;
|
|
105
|
+
const sessionWhy = sessionRow ? 'given' : 'route_cannot_carry';
|
|
106
|
+
let deploymentList;
|
|
107
|
+
if (!sessionRow) {
|
|
108
|
+
deploymentList = 'route_cannot_carry';
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
const pair = readAskClassPairState(card);
|
|
112
|
+
deploymentList =
|
|
113
|
+
pair.state !== 'pair'
|
|
114
|
+
? 'classes_unreadable'
|
|
115
|
+
: pair.classes.every((c) => DEPLOYMENT_LIST_ASK_CLASSES.includes(c))
|
|
116
|
+
? 'given'
|
|
117
|
+
: 'not_deployment_list_question';
|
|
118
|
+
}
|
|
119
|
+
const persistent = persistentRowOf(card, host, evidenceUnreadable);
|
|
120
|
+
if (persistent === UNREADABLE)
|
|
121
|
+
return allClosed('card_unreadable');
|
|
122
|
+
return freezeRows(sessionRow, persistent.row, deploymentList === 'given', { session: sessionWhy, persistent: persistent.why, deploymentList });
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
return allClosed('card_unreadable');
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -6,7 +6,7 @@ import { type DenyAttributionRefusalDetail } from '../wireRefusalCopy.js';
|
|
|
6
6
|
import { type ApprovalDecidedByReading } from '../approvalDecidedByCapability.js';
|
|
7
7
|
import { type DecideReceiptView } from '../decideReceipt.js';
|
|
8
8
|
import { RULE_OFFER_MATCHES, RULE_OFFER_BATCH_MEMBER_KINDS, RULE_OFFER_UNCOVERED_REASONS, RULE_OFFERS_ABSENCE_REASONS } from '@sema-agent/sdk';
|
|
9
|
-
import type { ApprovalDecidedBy, ToolApprovalRespondAck, PersistedRuleAnchor as SdkPersistedRuleAnchor, RuleOfferMatch as SdkRuleOfferMatch, RuleOfferBatchMember as SdkRuleOfferBatchMember, RuleOfferUncoveredDetail as SdkRuleOfferUncoveredDetail, RuleOfferUncoveredReason as SdkRuleOfferUncoveredReason, AskOrigin as SdkAskOrigin, RuleOffersAbsence as SdkRuleOffersAbsence, DenialLimitKind as SdkDenialLimitKind, DenialLimitFallback as SdkDenialLimitFallback } from '@sema-agent/sdk';
|
|
9
|
+
import type { ApprovalDecidedBy, ApprovalSettleCause, ToolApprovalRespondAck, PersistedRuleAnchor as SdkPersistedRuleAnchor, RuleOfferMatch as SdkRuleOfferMatch, RuleOfferBatchMember as SdkRuleOfferBatchMember, RuleOfferUncoveredDetail as SdkRuleOfferUncoveredDetail, RuleOfferUncoveredReason as SdkRuleOfferUncoveredReason, AskOrigin as SdkAskOrigin, RuleOffersAbsence as SdkRuleOffersAbsence, DenialLimitKind as SdkDenialLimitKind, DenialLimitFallback as SdkDenialLimitFallback } from '@sema-agent/sdk';
|
|
10
10
|
export declare function isFsApprovalGate(gate: {
|
|
11
11
|
kind?: unknown;
|
|
12
12
|
toolName?: unknown;
|
|
@@ -40,8 +40,9 @@ export type FsApprovalOutcome = {
|
|
|
40
40
|
stage: HitlFailureStage;
|
|
41
41
|
gatedCallId?: string | undefined;
|
|
42
42
|
reason: string;
|
|
43
|
-
code?: 'no_pending' | undefined;
|
|
43
|
+
code?: 'no_pending' | 'wrong_gate' | undefined;
|
|
44
44
|
errorCode?: string | undefined;
|
|
45
|
+
blockedBy?: string | undefined;
|
|
45
46
|
retriable?: true;
|
|
46
47
|
safetyCode?: HitlSafetyCode | undefined;
|
|
47
48
|
retryExhausted?: true;
|
|
@@ -68,7 +69,6 @@ export type DenialLimitKind = SdkDenialLimitKind;
|
|
|
68
69
|
export type DenialLimitFallback = SdkDenialLimitFallback;
|
|
69
70
|
export { RULE_OFFERS_ABSENCE_REASONS };
|
|
70
71
|
export declare const ASK_ORIGIN_WORDS: readonly string[];
|
|
71
|
-
export declare const APPROVAL_MANDATE_WORDS: readonly ["operator_always", "tool_marks", "probe_mandate", "probe_unanswered", "write_protection", "write_protection_unresolved"];
|
|
72
72
|
export type WireRuleOffer = {
|
|
73
73
|
kind: 'single';
|
|
74
74
|
rule: string;
|
|
@@ -137,11 +137,11 @@ export interface ApprovalCardRequest {
|
|
|
137
137
|
ruleOffersReadOnly?: RuleOffer[];
|
|
138
138
|
inputHasBidi?: true;
|
|
139
139
|
hasBidiControls?: true;
|
|
140
|
-
persistedRuleShadowed?: string;
|
|
141
140
|
allowRuleShadow?: ApprovalAllowRuleShadow;
|
|
142
141
|
probeCause?: unknown;
|
|
143
142
|
probeReason?: string;
|
|
144
143
|
rememberRefused?: true;
|
|
144
|
+
allowSessionCarried?: true;
|
|
145
145
|
ruleEvidence?: unknown;
|
|
146
146
|
requiresRealApproval?: true;
|
|
147
147
|
irreversibleParkGate?: true;
|
|
@@ -158,6 +158,8 @@ export interface ApprovalCardRequest {
|
|
|
158
158
|
askClass?: string;
|
|
159
159
|
classes?: readonly string[];
|
|
160
160
|
boundGrants?: BoundSkillGrantsWire;
|
|
161
|
+
grantBinding?: ApprovalGrantBinding;
|
|
162
|
+
unreadableEvidence?: readonly string[];
|
|
161
163
|
classifierNoRuling?: string;
|
|
162
164
|
priorCardsForCall?: readonly ApprovalPriorCard[];
|
|
163
165
|
}
|
|
@@ -177,6 +179,9 @@ export declare function hasApprovalCardPortFor(sessionKey: string): boolean;
|
|
|
177
179
|
export declare function approvalCardPortFor(sessionKey: string): ApprovalCardPort | null;
|
|
178
180
|
export declare function _resetApprovalCardPortForTest(): void;
|
|
179
181
|
export declare function surfaceApprovalCard(req: ApprovalCardRequest): Promise<ApprovalCardDecision>;
|
|
182
|
+
declare const REMEMBER_REFUSAL_CODES: readonly ["remember_not_in_proof", "remember_requires_binding", "capability.store_required", "decide.workflow_remember_unsupported", "decide.parked_remember_unsupported"];
|
|
183
|
+
export type RememberRefusalCode = (typeof REMEMBER_REFUSAL_CODES)[number];
|
|
184
|
+
export declare function rememberRefusalOf(error: unknown): RememberRefusalCode | undefined;
|
|
180
185
|
export declare function surfaceFsApprovalAndDecide(deps: FsApprovalWireDeps, taskId: string, argsByCall: Map<string, unknown>, signal?: AbortSignal, parkGatedCallId?: string): Promise<FsApprovalOutcome>;
|
|
181
186
|
export interface BoundSkillGrantsWire {
|
|
182
187
|
readonly skill: string | null;
|
|
@@ -192,6 +197,7 @@ export interface ToolApprovalFrame {
|
|
|
192
197
|
args?: unknown;
|
|
193
198
|
argsOmitted?: boolean;
|
|
194
199
|
outcome?: 'allowed' | 'denied' | 'expired';
|
|
200
|
+
cause?: ApprovalSettleCause;
|
|
195
201
|
sourceTaskId?: string;
|
|
196
202
|
fromSubagent?: true;
|
|
197
203
|
sourceAgentName?: string;
|
|
@@ -232,7 +238,7 @@ export interface ToolApprovalDelegation {
|
|
|
232
238
|
depth: number;
|
|
233
239
|
agentName?: string;
|
|
234
240
|
}
|
|
235
|
-
export declare const TOOL_APPROVAL_FRAME_KEYS_MIRROR: readonly ["type", "approvalId", "toolCallId", "toolName", "sourceTaskId", "fromSubagent", "sourceAgentName", "message", "args", "argsOmitted", "governanceForced", "ruleOffers", "ruleOffersAbsence", "denialLimitFallback", "readRootCandidate", "mandated", "mandate", "origin", "askClass", "classes", "inputHasBidi", "parked", "persistedRuleShadowed", "allowRuleShadowed", "probeCause", "probeReason", "rememberRefused", "boundGrantDigest", "boundGrants", "classifierNoRuling", "ruleEvidence", "requiresRealApproval", "expiresInMs", "expiresAtMs", "serverNowMs", "delegation", "outcome"];
|
|
241
|
+
export declare const TOOL_APPROVAL_FRAME_KEYS_MIRROR: readonly ["type", "approvalId", "toolCallId", "toolName", "sourceTaskId", "fromSubagent", "sourceAgentName", "message", "args", "argsOmitted", "governanceForced", "ruleOffers", "ruleOffersAbsence", "denialLimitFallback", "readRootCandidate", "mandated", "mandate", "origin", "askClass", "classes", "inputHasBidi", "parked", "persistedRuleShadowed", "allowRuleShadowed", "probeCause", "probeReason", "rememberRefused", "boundGrantDigest", "boundGrants", "classifierNoRuling", "ruleEvidence", "requiresRealApproval", "expiresInMs", "expiresAtMs", "serverNowMs", "delegation", "outcome", "cause"];
|
|
236
242
|
export interface ApprovalMandatedFacts {
|
|
237
243
|
readonly mandated?: true;
|
|
238
244
|
readonly ruleOffersAbsence?: string;
|
|
@@ -242,7 +248,7 @@ export declare function approvalIsMandated(v: ApprovalMandatedFacts | undefined
|
|
|
242
248
|
export declare function readApprovalMandate(v: {
|
|
243
249
|
readonly mandate?: string;
|
|
244
250
|
} | undefined | null): ApprovalMandateWord | undefined;
|
|
245
|
-
export declare function toolPermissionRequestAskBits(card: object | null | undefined): Pick<ToolPermissionRequest, 'mandated' | 'mandate' | 'origin' | 'ruleOffersAbsence' | 'askClass' | 'classes'>;
|
|
251
|
+
export declare function toolPermissionRequestAskBits(card: object | null | undefined): Pick<ToolPermissionRequest, 'mandated' | 'mandate' | 'origin' | 'ruleOffersAbsence' | 'askClass' | 'classes' | 'rememberRefused'>;
|
|
246
252
|
export declare function isFromSubagent(frame: ToolApprovalFrame): boolean;
|
|
247
253
|
export type ToolApprovalRespondDecision = 'allow' | 'allow_session' | 'deny';
|
|
248
254
|
export interface RespondToolApprovalOpts {
|
|
@@ -296,6 +302,12 @@ interface ToolApprovalRespondRefusalFields {
|
|
|
296
302
|
status?: number;
|
|
297
303
|
errorCode?: string;
|
|
298
304
|
message?: string;
|
|
305
|
+
retriable?: true;
|
|
306
|
+
extra?: {
|
|
307
|
+
readonly cause?: string;
|
|
308
|
+
readonly field?: string;
|
|
309
|
+
};
|
|
310
|
+
unreadable?: true;
|
|
299
311
|
}
|
|
300
312
|
export type ToolApprovalRespondRefusal = (ToolApprovalRespondRefusalFields & {
|
|
301
313
|
status: number;
|
|
@@ -307,7 +319,9 @@ export type ToolApprovalRespondRefusal = (ToolApprovalRespondRefusalFields & {
|
|
|
307
319
|
export declare function readToolApprovalRespondRefusal(err: unknown): ToolApprovalRespondRefusal | undefined;
|
|
308
320
|
export declare function isToolApprovalFrame(ev: unknown): ev is ToolApprovalFrame;
|
|
309
321
|
export declare function askProbeReasonDetail(card: Pick<ApprovalCardRequest, 'probeReason' | 'probeCause'> | null | undefined): string | undefined;
|
|
322
|
+
export declare function readApprovalRememberRefused(v: unknown): boolean;
|
|
310
323
|
export declare function readApprovalBoundGrants(v: unknown): BoundSkillGrantsWire | undefined;
|
|
324
|
+
export type ApprovalGrantBinding = 'bound' | 'none' | 'unreadable';
|
|
311
325
|
export declare function readApprovalClassifierNoRuling(v: unknown): string | undefined;
|
|
312
326
|
export declare function classifierNoRulingDetail(word: string | undefined): string;
|
|
313
327
|
export declare function approvalBoundGrantsDetail(grants: BoundSkillGrantsWire | null | undefined): string | undefined;
|
|
@@ -315,6 +329,8 @@ export declare function approvalPriorCardsDetail(card: Pick<ApprovalCardRequest,
|
|
|
315
329
|
export declare function readDenialLimitFallback(v: unknown): DenialLimitFallback | undefined;
|
|
316
330
|
export declare function readRuleOffers(v: unknown): RuleOffer[] | undefined;
|
|
317
331
|
export declare function readRuleOfferSupply(offers: unknown): RuleOffer[] | undefined;
|
|
332
|
+
export type ApprovalCardV1Facts = Pick<ApprovalCardRequest, 'toolName' | 'args'> & Pick<ApprovalCardRequest, 'toolCallId' | 'workerBadge' | 'wireNote' | 'argsUnavailable' | 'governanceForced' | 'delegation' | 'ruleOffersReadOnly' | 'inputHasBidi' | 'allowRuleShadow' | 'probeCause' | 'rememberRefused' | 'ruleEvidence' | 'requiresRealApproval' | 'ruleOffersAbsence' | 'denialLimitFallback' | 'askClass' | 'classes' | 'grantBinding' | 'unreadableEvidence'>;
|
|
333
|
+
export declare function approvalCardFactsOfV1(card: object | null | undefined): Readonly<ApprovalCardV1Facts> | undefined;
|
|
318
334
|
export interface ToolApprovalFrameLaneOpts {
|
|
319
335
|
approvalDecisionNoteCapable?: boolean;
|
|
320
336
|
respondFreeFormRulesCapable?: boolean;
|
|
@@ -323,4 +339,20 @@ export interface ToolApprovalFrameLaneOpts {
|
|
|
323
339
|
windowIsCurrent?: boolean;
|
|
324
340
|
argsUnavailable?: true;
|
|
325
341
|
}
|
|
326
|
-
export declare function surfaceToolApprovalFrameAndRespond(frame: ToolApprovalFrame, respond: RespondToolApprovalFn, streamArgs: unknown | undefined, signal?: AbortSignal, lane?: ToolApprovalFrameLaneOpts
|
|
342
|
+
export declare function surfaceToolApprovalFrameAndRespond(frame: ToolApprovalFrame, respond: RespondToolApprovalFn, streamArgs: unknown | undefined, signal?: AbortSignal, lane?: ToolApprovalFrameLaneOpts, run?: {
|
|
343
|
+
readonly taskId?: string;
|
|
344
|
+
readonly sessionId?: string;
|
|
345
|
+
}): Promise<ToolApprovalFrameOutcome>;
|
|
346
|
+
export interface ApprovalHolderIdentity {
|
|
347
|
+
readonly approvalId?: string;
|
|
348
|
+
readonly taskId?: string;
|
|
349
|
+
readonly toolCallId?: string;
|
|
350
|
+
readonly sessionId?: string;
|
|
351
|
+
}
|
|
352
|
+
export type ApprovalHolderJoin = {
|
|
353
|
+
readonly kind: 'joined';
|
|
354
|
+
readonly outcome: ToolApprovalFrameOutcome;
|
|
355
|
+
} | {
|
|
356
|
+
readonly kind: 'free';
|
|
357
|
+
};
|
|
358
|
+
export declare function joinApprovalHolder(identity: ApprovalHolderIdentity, signal?: AbortSignal): Promise<ApprovalHolderJoin>;
|