@sema-agent/client-core 0.110.0 → 0.112.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 +244 -0
- package/README.md +59 -18
- package/dist/abortableSleep.d.ts +7 -0
- package/dist/abortableSleep.js +37 -0
- package/dist/adapt/arms.js +25 -4
- package/dist/adapt/toolCards.d.ts +3 -1
- package/dist/adapt/toolCards.js +4 -2
- package/dist/adapter/activeRunSelfHeal.d.ts +39 -0
- package/dist/adapter/activeRunSelfHeal.js +171 -3
- package/dist/adapter/downstream/eventToSdkMessage.js +10 -10
- package/dist/adapter/downstream/terminalToSdkResult.d.ts +2 -0
- package/dist/adapter/downstream/terminalToSdkResult.js +11 -0
- package/dist/adapter/runStream.d.ts +5 -0
- package/dist/adapter/runStream.js +15 -3
- package/dist/agentSession/engineSessionBackgroundStop.js +2 -2
- package/dist/attachmentRoute.d.ts +20 -0
- package/dist/attachmentRoute.js +39 -0
- package/dist/attachmentsWireCaps.js +1 -1
- package/dist/builtinOutputStyles.d.ts +12 -0
- package/dist/builtinOutputStyles.js +147 -0
- package/dist/checkpointRowVerdict.d.ts +3 -0
- package/dist/checkpointRowVerdict.js +14 -1
- package/dist/compactionStatus.d.ts +9 -0
- package/dist/compactionStatus.js +29 -5
- package/dist/consoleCaPin.d.ts +136 -0
- package/dist/consoleCaPin.js +827 -0
- package/dist/controlRouter.js +2 -1
- package/dist/coreValuePorts.d.ts +39 -1
- package/dist/coreValuePorts.js +10 -0
- package/dist/decideReceipt.d.ts +2 -1
- package/dist/deviceRebind.js +3 -3
- package/dist/displayUntrusted.d.ts +1 -0
- package/dist/displayUntrusted.js +6 -0
- package/dist/effectiveFacts.d.ts +9 -0
- package/dist/effectiveFacts.js +33 -0
- package/dist/engineAddress.d.ts +1 -0
- package/dist/engineAddress.js +4 -1
- package/dist/engineCredentialRelease.d.ts +54 -0
- package/dist/engineCredentialRelease.js +146 -0
- package/dist/engineErrorCodes.d.ts +1 -0
- package/dist/engineErrorCodes.js +1 -0
- package/dist/engineHealthProbeVerdict.d.ts +24 -0
- package/dist/engineHealthProbeVerdict.js +123 -0
- package/dist/engineNoticeCodes.js +5 -7
- package/dist/engineRepoint.d.ts +12 -5
- package/dist/engineRepoint.js +44 -19
- package/dist/engineRowRef.d.ts +3 -0
- package/dist/engineRowRef.js +11 -1
- package/dist/engineSwapCrossing.d.ts +57 -0
- package/dist/engineSwapCrossing.js +297 -0
- package/dist/engineUnavailable.d.ts +45 -0
- package/dist/engineUnavailable.js +496 -0
- package/dist/engineUrl.js +4 -2
- package/dist/eventLeg.js +3 -3
- package/dist/gateFailureCodes.js +2 -2
- package/dist/generated/sdkFactTables.d.ts +2 -1
- package/dist/generated/sdkFactTables.js +14 -0
- package/dist/generated/settingsSchemaFns.d.ts +1 -0
- package/dist/generated/settingsSchemaFns.js +3 -0
- package/dist/generated/settingsSchemaHooksClassifier.js +38 -9
- package/dist/generated/settingsSchemaTables.d.ts +56 -0
- package/dist/generated/settingsSchemaTables.js +19 -0
- package/dist/generated/settingsSchemaTypes.d.ts +23 -13
- package/dist/generated/settingsSchemaUrlShape.d.ts +1 -0
- package/dist/generated/settingsSchemaUrlShape.js +17 -0
- package/dist/hitl/approvalDelivery.d.ts +1 -0
- package/dist/hitl/approvalDelivery.js +1 -1
- package/dist/hitl/approvalResolution.d.ts +1 -1
- package/dist/hitl/approvalResolution.js +2 -1
- package/dist/hitl/askGateWire.js +5 -6
- package/dist/hitl/decisionRefusal.d.ts +6 -0
- package/dist/hitl/decisionRefusal.js +19 -10
- package/dist/hitl/decisionRefusalCarrier.d.ts +3 -0
- package/dist/hitl/decisionRefusalCarrier.js +348 -0
- package/dist/hitl/decisionSend.d.ts +7 -0
- package/dist/hitl/decisionSend.js +34 -12
- package/dist/hitl/editedApprovalAcceptance.js +1 -1
- package/dist/hitl/elicitationRefusal.d.ts +4 -0
- package/dist/hitl/elicitationRefusal.js +23 -0
- package/dist/hitl/frameRouter.d.ts +2 -2
- package/dist/hitl/frameRouter.js +8 -15
- package/dist/hitl/gateIdentity.d.ts +5 -0
- package/dist/hitl/gateIdentity.js +23 -0
- package/dist/hitl/hitlBridge.d.ts +6 -0
- package/dist/hitl/hitlBridge.js +10 -4
- package/dist/hitl/hitlHostSurface.d.ts +2 -1
- package/dist/hitl/hitlHostSurface.js +7 -2
- package/dist/hitl/localAllowRedemption.d.ts +70 -0
- package/dist/hitl/localAllowRedemption.js +276 -0
- package/dist/hitl/parkOwnership.js +2 -1
- package/dist/hitl/parkResolver.js +14 -4
- package/dist/hitl/persistedRulesWire.d.ts +16 -0
- package/dist/hitl/persistedRulesWire.js +70 -0
- package/dist/hitl/planReviewWire.d.ts +3 -0
- package/dist/hitl/planReviewWire.js +23 -6
- package/dist/hitl/policyDenyCause.d.ts +1 -1
- package/dist/hitl/policyDenyCause.js +1 -1
- package/dist/hitl/resumeRunningCard.d.ts +1 -0
- package/dist/hitl/resumeRunningCard.js +1 -0
- package/dist/hitl/screenCardCarriers.d.ts +15 -0
- package/dist/hitl/screenCardCarriers.js +41 -0
- package/dist/hitl/screenDecisionCards.d.ts +98 -0
- package/dist/hitl/screenDecisionCards.js +363 -0
- package/dist/hitl/sessionPolicyWire.js +2 -2
- package/dist/hitl/standingRows.d.ts +6 -2
- package/dist/hitl/standingRows.js +27 -2
- package/dist/hitl/toolApprovalWire.d.ts +30 -8
- package/dist/hitl/toolApprovalWire.js +264 -121
- package/dist/hooksReaderGenerations.js +1 -1
- package/dist/hooksWireCaps.js +3 -3
- package/dist/hostSettingNoticeArm.d.ts +3 -0
- package/dist/hostSettingNoticeArm.js +12 -0
- package/dist/hostTurnSettings.d.ts +3 -0
- package/dist/hostTurnSettings.js +38 -5
- package/dist/humanTurnRead.js +11 -1
- package/dist/i18n/messages.en.d.ts +292 -0
- package/dist/i18n/messages.en.js +298 -7
- package/dist/i18n/messages.zh.js +316 -6
- package/dist/i18n/translate.d.ts +3 -0
- package/dist/i18n/translate.js +78 -10
- package/dist/i18n/zh.d.ts +1 -0
- package/dist/i18n/zh.js +1 -0
- package/dist/index.d.ts +71 -20
- package/dist/index.js +44 -13
- package/dist/interactiveHalt.js +2 -1
- package/dist/interactiveInterrupt.js +20 -2
- package/dist/liveModelCatalog.d.ts +4 -0
- package/dist/liveModelCatalog.js +12 -3
- package/dist/localConfig/documents.d.ts +61 -0
- package/dist/localConfig/documents.js +51 -0
- package/dist/localConfig/kernel.d.ts +149 -0
- package/dist/localConfig/kernel.js +597 -0
- package/dist/localConfig/mcp/edit.d.ts +161 -0
- package/dist/localConfig/mcp/edit.js +846 -0
- package/dist/localConfig/mcp/servers.d.ts +165 -0
- package/dist/localConfig/mcp/servers.js +776 -0
- package/dist/localConfig/mcp/views.d.ts +170 -0
- package/dist/localConfig/mcp/views.js +429 -0
- package/dist/localConfig/modelPool.d.ts +262 -0
- package/dist/localConfig/modelPool.js +1489 -0
- package/dist/localConfig/modelPoolWords.d.ts +13 -0
- package/dist/localConfig/modelPoolWords.js +20 -0
- package/dist/localConfig/receiptShape.d.ts +7 -0
- package/dist/localConfig/receiptShape.js +135 -0
- package/dist/localConfig/settingsWrite.d.ts +127 -0
- package/dist/localConfig/settingsWrite.js +237 -0
- package/dist/localConfig/skills.d.ts +124 -0
- package/dist/localConfig/skills.js +397 -0
- package/dist/localConfig/skillsWords.d.ts +10 -0
- package/dist/localConfig/skillsWords.js +5 -0
- package/dist/localEngineSeatReading.d.ts +2 -2
- package/dist/localEngineSeatReading.js +5 -3
- package/dist/localEngineSpawn.d.ts +0 -7
- package/dist/localEngineSpawn.js +0 -92
- package/dist/localEngineStep.d.ts +2 -2
- package/dist/localEngineStep.js +2 -0
- package/dist/mcpProbeWire.js +2 -1
- package/dist/mcpReconnect.js +3 -3
- package/dist/mcpWireCaps.js +1 -1
- package/dist/memoryVerbsWire.js +3 -2
- package/dist/model/engineModelWords.d.ts +3 -0
- package/dist/model/engineModelWords.js +13 -0
- package/dist/model/onboardJudgement.d.ts +14 -4
- package/dist/model/onboardJudgement.js +91 -139
- package/dist/model/subagentModelWord.d.ts +21 -2
- package/dist/model/subagentModelWord.js +100 -29
- package/dist/modelCapabilityProbe.js +3 -40
- package/dist/modelConfigGapNotice.d.ts +20 -0
- package/dist/modelConfigGapNotice.js +102 -0
- package/dist/modsKernelIdentity.js +2 -47
- package/dist/notifications.d.ts +19 -0
- package/dist/notifications.js +114 -12
- package/dist/ownKey.d.ts +7 -0
- package/dist/ownKey.js +71 -8
- package/dist/pendingUserRow.d.ts +4 -0
- package/dist/pendingUserRow.js +16 -0
- package/dist/permissionsDeclaration.d.ts +3 -1
- package/dist/permissionsDeclaration.js +33 -9
- package/dist/planReviewCardFacts.d.ts +3 -0
- package/dist/planReviewCardFacts.js +52 -2
- package/dist/pluginHooksWire.d.ts +9 -1
- package/dist/pluginHooksWire.js +40 -6
- package/dist/printToolResultFrame.js +4 -2
- package/dist/promptBlockedCopy.js +12 -7
- package/dist/promptSuggestionBatch.d.ts +7 -0
- package/dist/promptSuggestionBatch.js +9 -0
- package/dist/promptSuggestionsTail.d.ts +39 -0
- package/dist/promptSuggestionsTail.js +116 -0
- package/dist/request/taskRequest.js +10 -6
- package/dist/requestCoordinate.d.ts +1 -0
- package/dist/requestCoordinate.js +13 -0
- package/dist/resumeRefusalCopy.d.ts +3 -1
- package/dist/resumeRefusalCopy.js +12 -4
- package/dist/rewindArchiveReading.js +4 -4
- package/dist/runCancelContext.d.ts +2 -1
- package/dist/runCancelContext.js +1 -0
- package/dist/runLedgerSnapshot.js +3 -3
- package/dist/runPermissionModeSwitch.js +3 -4
- package/dist/scenarioRefusal.js +11 -13
- package/dist/scenarioSkills.js +11 -6
- package/dist/seam.d.ts +16 -2
- package/dist/seam.js +10 -0
- package/dist/seatContract.d.ts +259 -9
- package/dist/seatContract.js +444 -15
- package/dist/sessionCostReading.d.ts +70 -0
- package/dist/sessionCostReading.js +150 -0
- package/dist/sessionHooksRoster.d.ts +4 -0
- package/dist/sessionHooksRoster.js +158 -0
- package/dist/sessionIdSegment.d.ts +1 -0
- package/dist/sessionIdSegment.js +4 -1
- package/dist/sessionMemoryErase.js +2 -1
- package/dist/sessionMemoryStatus.js +2 -2
- package/dist/sessionReadRedaction.d.ts +7 -0
- package/dist/sessionReadRedaction.js +26 -0
- package/dist/sessionSyncFileHistory.js +8 -9
- package/dist/settingsHooksSalvage.js +2 -1
- package/dist/sha256Bytes.d.ts +1 -0
- package/dist/sha256Bytes.js +46 -0
- package/dist/skillOverrideChain.d.ts +83 -0
- package/dist/skillOverrideChain.js +378 -0
- package/dist/skillsWireCaps.d.ts +3 -0
- package/dist/skillsWireCaps.js +16 -1
- package/dist/sseIdleTriage.js +2 -1
- package/dist/storeDurabilityWord.d.ts +15 -0
- package/dist/storeDurabilityWord.js +18 -0
- package/dist/storePostureCapability.d.ts +7 -3
- package/dist/storePostureCapability.js +69 -39
- package/dist/subagent/engineSubagentResume.js +2 -2
- package/dist/subagent/engineSubagentTail.js +2 -1
- package/dist/subagentContentStore.d.ts +11 -0
- package/dist/subagentContentStore.js +28 -2
- package/dist/toolResult.d.ts +1 -0
- package/dist/toolResult.js +2 -0
- package/dist/turnFailurePresentation.js +4 -10
- package/dist/userAttachmentEnvelope.d.ts +2 -1
- package/dist/userAttachmentEnvelope.js +10 -0
- package/dist/wireErrorTriage.js +2 -1
- package/dist/wireFailureShape.d.ts +4 -0
- package/dist/wireFailureShape.js +141 -19
- package/dist/wireRefusalCopy.d.ts +6 -5
- package/dist/wireRefusalCopy.js +49 -92
- package/docs/INTEGRATION-CLIENTS.md +2718 -17
- package/package.json +7 -3
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import { isSecretKeyName } from '../seatContract.js';
|
|
2
|
+
import { placeThrownExtraOnCopy, wireFailureCoreOf, wireFailureTextsOf } from '../wireFailureShape.js';
|
|
3
|
+
import { decideFailureNote } from '../decideFailureNote.js';
|
|
4
|
+
import { REFUSAL_ROUTES, classifyDecisionRefusal, decisionRefusalAskReading, decisionRefusalSaysAskGone, mintDecisionRefusalReading, readDecisionRefusalReading, } from './decisionRefusal.js';
|
|
5
|
+
import { decisionConflictOf } from './decisionConflict.js';
|
|
6
|
+
import { resumeReopenFromError } from './suspendedReopen.js';
|
|
7
|
+
import { askGoneFromError, decideParkMovedFromError, decideRefusalFromError, decideRequiresBindingFromError } from '../decideReceipt.js';
|
|
8
|
+
import { corruptStoredRowWhere, resumeRetryLaterFromError, scenarioDenyFromError } from '../wireErrorTriage.js';
|
|
9
|
+
import { checkpointUnsupportedVersionFromError, parkedResumeStartupFromError, refusedParkFromError, requireExistingSessionRefusalFromError, resumeContextUnavailableFromError, resumePolicyBlockFromError, resumeRefusalFromError, } from '../resumeRefusalCopy.js';
|
|
10
|
+
import { admissionWallRefusalFromError, autonomyLaneRefusalFromError, bodyShapeRefusalFromError, cancelConflictFromError, denyAttributionRefusalFromError, envCredentialRefusalFromError, fieldLimitRefusalFromError, fleetLeaseUnavailableFromError, hostPostureRefusalFromError, quotaExhaustedFromError, runConcurrencyCapFromError, sessionArchiveStampedFromError, sessionDeleteConflictFromError, sessionIdRetiredFromError, settingsHooksRefusalFromError, toolDeclarationRefusalFromError, unreadRequestMembersFromError, unsupportedRuleRefusalFromError, usageWindowExhaustedFromError, userAttachmentRefusalFromError, userInvokedSkillRefusalFromError, } from '../wireRefusalCopy.js';
|
|
11
|
+
import { scenarioRefusalFromError } from '../scenarioRefusal.js';
|
|
12
|
+
import { inheritEnvRefusalFromError } from '../inheritEnvWire.js';
|
|
13
|
+
const DECISION_WORDS = { approve: true, deny: true };
|
|
14
|
+
const DECISIONS = Object.freeze([undefined, ...Object.keys(DECISION_WORDS)]);
|
|
15
|
+
const CONTEXTS = Object.freeze([undefined, ...REFUSAL_ROUTES.map((route) => Object.freeze({ route }))]);
|
|
16
|
+
const READERS = Object.freeze({
|
|
17
|
+
classifyDecisionRefusal: (e) => CONTEXTS.map((c) => classifyDecisionRefusal(e, c)),
|
|
18
|
+
readDecisionRefusalReading: (e) => CONTEXTS.map((c) => readDecisionRefusalReading(e, c)),
|
|
19
|
+
mintDecisionRefusalReading: (e) => [mintDecisionRefusalReading(e, undefined, true), mintDecisionRefusalReading(e, undefined, false)],
|
|
20
|
+
decisionRefusalAskReading: (e) => decisionRefusalAskReading(e),
|
|
21
|
+
decisionRefusalSaysAskGone: (e) => decisionRefusalSaysAskGone(e),
|
|
22
|
+
decideFailureNote: (e) => DECISIONS.map((d) => decideFailureNote(e, d)),
|
|
23
|
+
decisionConflictOf: (e) => decisionConflictOf(e),
|
|
24
|
+
corruptStoredRowWhere: (e) => corruptStoredRowWhere(e),
|
|
25
|
+
wireFailureCoreOf: (e) => wireFailureCoreOf(e),
|
|
26
|
+
wireFailureTextsOf: (e) => wireFailureTextsOf(e).reason,
|
|
27
|
+
admissionWallRefusalFromError: (e) => admissionWallRefusalFromError(e),
|
|
28
|
+
askGoneFromError: (e) => askGoneFromError(e),
|
|
29
|
+
autonomyLaneRefusalFromError: (e) => autonomyLaneRefusalFromError(e),
|
|
30
|
+
bodyShapeRefusalFromError: (e) => bodyShapeRefusalFromError(e),
|
|
31
|
+
cancelConflictFromError: (e) => cancelConflictFromError(e),
|
|
32
|
+
checkpointUnsupportedVersionFromError: (e) => checkpointUnsupportedVersionFromError(e),
|
|
33
|
+
decideParkMovedFromError: (e) => decideParkMovedFromError(e),
|
|
34
|
+
decideRefusalFromError: (e) => decideRefusalFromError(e),
|
|
35
|
+
decideRequiresBindingFromError: (e) => decideRequiresBindingFromError(e),
|
|
36
|
+
denyAttributionRefusalFromError: (e) => [denyAttributionRefusalFromError(e, true), denyAttributionRefusalFromError(e, false)],
|
|
37
|
+
envCredentialRefusalFromError: (e) => envCredentialRefusalFromError(e),
|
|
38
|
+
fieldLimitRefusalFromError: (e) => fieldLimitRefusalFromError(e),
|
|
39
|
+
fleetLeaseUnavailableFromError: (e) => fleetLeaseUnavailableFromError(e),
|
|
40
|
+
hostPostureRefusalFromError: (e) => hostPostureRefusalFromError(e, undefined),
|
|
41
|
+
inheritEnvRefusalFromError: (e) => inheritEnvRefusalFromError(e, undefined),
|
|
42
|
+
parkedResumeStartupFromError: (e) => DECISIONS.map((d) => parkedResumeStartupFromError(e, d)),
|
|
43
|
+
quotaExhaustedFromError: (e) => quotaExhaustedFromError(e),
|
|
44
|
+
refusedParkFromError: (e) => refusedParkFromError(e),
|
|
45
|
+
requireExistingSessionRefusalFromError: (e) => requireExistingSessionRefusalFromError(e),
|
|
46
|
+
resumeContextUnavailableFromError: (e) => resumeContextUnavailableFromError(e),
|
|
47
|
+
resumePolicyBlockFromError: (e) => resumePolicyBlockFromError(e),
|
|
48
|
+
resumeRefusalFromError: (e) => resumeRefusalFromError(e),
|
|
49
|
+
resumeReopenFromError: (e) => resumeReopenFromError(e),
|
|
50
|
+
resumeRetryLaterFromError: (e) => resumeRetryLaterFromError(e),
|
|
51
|
+
runConcurrencyCapFromError: (e) => runConcurrencyCapFromError(e),
|
|
52
|
+
scenarioDenyFromError: (e) => scenarioDenyFromError(e),
|
|
53
|
+
scenarioRefusalFromError: (e) => scenarioRefusalFromError(e),
|
|
54
|
+
sessionArchiveStampedFromError: (e) => sessionArchiveStampedFromError(e),
|
|
55
|
+
sessionDeleteConflictFromError: (e) => sessionDeleteConflictFromError(e),
|
|
56
|
+
sessionIdRetiredFromError: (e) => sessionIdRetiredFromError(e),
|
|
57
|
+
settingsHooksRefusalFromError: (e) => settingsHooksRefusalFromError(e),
|
|
58
|
+
toolDeclarationRefusalFromError: (e) => toolDeclarationRefusalFromError(e),
|
|
59
|
+
unreadRequestMembersFromError: (e) => unreadRequestMembersFromError(e),
|
|
60
|
+
unsupportedRuleRefusalFromError: (e) => unsupportedRuleRefusalFromError(e),
|
|
61
|
+
usageWindowExhaustedFromError: (e) => usageWindowExhaustedFromError(e),
|
|
62
|
+
userAttachmentRefusalFromError: (e) => userAttachmentRefusalFromError(e),
|
|
63
|
+
userInvokedSkillRefusalFromError: (e) => userInvokedSkillRefusalFromError(e),
|
|
64
|
+
});
|
|
65
|
+
export function decisionRefusalCarrierReaderNames() {
|
|
66
|
+
return Object.freeze(Object.keys(READERS));
|
|
67
|
+
}
|
|
68
|
+
const COPY_DEPTH_MAX = 16;
|
|
69
|
+
const COPY_NODES_MAX = 4096;
|
|
70
|
+
const COPY_KEYS_MAX = 1024;
|
|
71
|
+
const SKIP = Symbol('carrier-skip');
|
|
72
|
+
function ownDataDescriptor(o, k) {
|
|
73
|
+
try {
|
|
74
|
+
const d = Reflect.getOwnPropertyDescriptor(o, k);
|
|
75
|
+
return d !== undefined && Object.hasOwn(d, 'value') ? { value: d.value } : undefined;
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function copyOf(v, depth, run) {
|
|
82
|
+
if (v === null || v === undefined || typeof v === 'string' || typeof v === 'boolean' || typeof v === 'number')
|
|
83
|
+
return v;
|
|
84
|
+
if (typeof v !== 'object' && typeof v !== 'function')
|
|
85
|
+
return SKIP;
|
|
86
|
+
const o = v;
|
|
87
|
+
if (depth > COPY_DEPTH_MAX || run.nodes >= COPY_NODES_MAX || run.path.has(o))
|
|
88
|
+
return SKIP;
|
|
89
|
+
run.nodes += 1;
|
|
90
|
+
run.path.add(o);
|
|
91
|
+
try {
|
|
92
|
+
let isArray;
|
|
93
|
+
try {
|
|
94
|
+
isArray = Array.isArray(o);
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
return SKIP;
|
|
98
|
+
}
|
|
99
|
+
if (isArray) {
|
|
100
|
+
const len = ownDataDescriptor(o, 'length')?.value;
|
|
101
|
+
if (typeof len !== 'number' || !Number.isInteger(len) || len < 0 || len > COPY_KEYS_MAX)
|
|
102
|
+
return SKIP;
|
|
103
|
+
const out = new Array(len);
|
|
104
|
+
for (let i = 0; i < len; i += 1) {
|
|
105
|
+
const d = ownDataDescriptor(o, String(i));
|
|
106
|
+
if (d === undefined)
|
|
107
|
+
continue;
|
|
108
|
+
const c = copyOf(d.value, depth + 1, run);
|
|
109
|
+
if (c !== SKIP)
|
|
110
|
+
out[i] = c;
|
|
111
|
+
}
|
|
112
|
+
return out;
|
|
113
|
+
}
|
|
114
|
+
let keys;
|
|
115
|
+
try {
|
|
116
|
+
keys = Reflect.ownKeys(o);
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
return SKIP;
|
|
120
|
+
}
|
|
121
|
+
const out = {};
|
|
122
|
+
let taken = 0;
|
|
123
|
+
for (let i = 0; i < keys.length; i += 1) {
|
|
124
|
+
const k = keys[i];
|
|
125
|
+
if (typeof k !== 'string')
|
|
126
|
+
continue;
|
|
127
|
+
if (taken >= COPY_KEYS_MAX)
|
|
128
|
+
break;
|
|
129
|
+
const d = ownDataDescriptor(o, k);
|
|
130
|
+
if (d === undefined)
|
|
131
|
+
continue;
|
|
132
|
+
const c = copyOf(d.value, depth + 1, run);
|
|
133
|
+
if (c === SKIP)
|
|
134
|
+
continue;
|
|
135
|
+
Object.defineProperty(out, k, { value: c, writable: true, enumerable: true, configurable: true });
|
|
136
|
+
taken += 1;
|
|
137
|
+
}
|
|
138
|
+
placeThrownExtraOnCopy(o, out, (bag) => {
|
|
139
|
+
const c = copyOf(bag, depth + 1, run);
|
|
140
|
+
return c === SKIP ? undefined : c;
|
|
141
|
+
});
|
|
142
|
+
return out;
|
|
143
|
+
}
|
|
144
|
+
finally {
|
|
145
|
+
run.path.delete(o);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
const newWatch = (node) => ({ node, touched: new Set(), kids: new Map(), enumerated: false, whole: false });
|
|
149
|
+
function viewOf(w, watches) {
|
|
150
|
+
if (w.view !== undefined)
|
|
151
|
+
return w.view;
|
|
152
|
+
const kid = (k, v) => {
|
|
153
|
+
if (typeof v !== 'object' || v === null)
|
|
154
|
+
return v;
|
|
155
|
+
let c = w.kids.get(k);
|
|
156
|
+
if (c === undefined || c.node !== v) {
|
|
157
|
+
c = newWatch(v);
|
|
158
|
+
w.kids.set(k, c);
|
|
159
|
+
}
|
|
160
|
+
return viewOf(c, watches);
|
|
161
|
+
};
|
|
162
|
+
const view = new Proxy(w.node, {
|
|
163
|
+
getOwnPropertyDescriptor(t, k) {
|
|
164
|
+
const d = Reflect.getOwnPropertyDescriptor(t, k);
|
|
165
|
+
if (typeof k !== 'string')
|
|
166
|
+
return d;
|
|
167
|
+
w.touched.add(k);
|
|
168
|
+
return d !== undefined && Object.hasOwn(d, 'value') ? { ...d, value: kid(k, d.value) } : d;
|
|
169
|
+
},
|
|
170
|
+
get(t, k, receiver) {
|
|
171
|
+
if (typeof k !== 'string')
|
|
172
|
+
return Reflect.get(t, k, receiver);
|
|
173
|
+
w.touched.add(k);
|
|
174
|
+
return Object.hasOwn(t, k) ? kid(k, t[k]) : Reflect.get(t, k, receiver);
|
|
175
|
+
},
|
|
176
|
+
has(t, k) {
|
|
177
|
+
if (typeof k === 'string')
|
|
178
|
+
w.touched.add(k);
|
|
179
|
+
return Reflect.has(t, k);
|
|
180
|
+
},
|
|
181
|
+
ownKeys(t) {
|
|
182
|
+
w.enumerated = true;
|
|
183
|
+
return Reflect.ownKeys(t);
|
|
184
|
+
},
|
|
185
|
+
});
|
|
186
|
+
w.view = view;
|
|
187
|
+
watches.set(view, w);
|
|
188
|
+
return view;
|
|
189
|
+
}
|
|
190
|
+
function ownKeysReading(o) {
|
|
191
|
+
try {
|
|
192
|
+
return { kind: 'listed', keys: Reflect.ownKeys(o) };
|
|
193
|
+
}
|
|
194
|
+
catch {
|
|
195
|
+
return { kind: 'unreadable' };
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function consumeOutput(out, watches, seen, depth) {
|
|
199
|
+
if ((typeof out !== 'object' && typeof out !== 'function') || out === null || depth > COPY_DEPTH_MAX || seen.has(out))
|
|
200
|
+
return;
|
|
201
|
+
const w = watches.get(out);
|
|
202
|
+
if (w !== undefined) {
|
|
203
|
+
w.whole = true;
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
seen.add(out);
|
|
207
|
+
const listed = ownKeysReading(out);
|
|
208
|
+
if (listed.kind === 'unreadable')
|
|
209
|
+
return;
|
|
210
|
+
for (let i = 0; i < listed.keys.length; i += 1) {
|
|
211
|
+
const k = listed.keys[i];
|
|
212
|
+
if (typeof k !== 'string')
|
|
213
|
+
continue;
|
|
214
|
+
const d = ownDataDescriptor(out, k);
|
|
215
|
+
if (d !== undefined)
|
|
216
|
+
consumeOutput(d.value, watches, seen, depth + 1);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
function wholeOf(v) {
|
|
220
|
+
if (typeof v !== 'object' || v === null)
|
|
221
|
+
return v;
|
|
222
|
+
if (Array.isArray(v)) {
|
|
223
|
+
const out = new Array(v.length);
|
|
224
|
+
for (let i = 0; i < v.length; i += 1)
|
|
225
|
+
if (Object.hasOwn(v, i))
|
|
226
|
+
out[i] = wholeOf(v[i]);
|
|
227
|
+
return out;
|
|
228
|
+
}
|
|
229
|
+
const out = {};
|
|
230
|
+
const names = Object.keys(v);
|
|
231
|
+
for (let i = 0; i < names.length; i += 1) {
|
|
232
|
+
const k = names[i];
|
|
233
|
+
if (isSecretKeyName(k))
|
|
234
|
+
continue;
|
|
235
|
+
Object.defineProperty(out, k, { value: wholeOf(v[k]), writable: true, enumerable: true, configurable: true });
|
|
236
|
+
}
|
|
237
|
+
return out;
|
|
238
|
+
}
|
|
239
|
+
function carried(w, k, v) {
|
|
240
|
+
if (typeof v !== 'object' || v === null)
|
|
241
|
+
return v;
|
|
242
|
+
if (w.whole)
|
|
243
|
+
return wholeOf(v);
|
|
244
|
+
const c = w.kids.get(k);
|
|
245
|
+
if (c !== undefined && c.node === v)
|
|
246
|
+
return pruned(c);
|
|
247
|
+
return Array.isArray(v) ? [] : {};
|
|
248
|
+
}
|
|
249
|
+
function pruned(w) {
|
|
250
|
+
if (w.whole)
|
|
251
|
+
return wholeOf(w.node);
|
|
252
|
+
const src = w.node;
|
|
253
|
+
if (Array.isArray(src)) {
|
|
254
|
+
const out = new Array(src.length);
|
|
255
|
+
for (let i = 0; i < src.length; i += 1) {
|
|
256
|
+
const k = String(i);
|
|
257
|
+
if (!Object.hasOwn(src, k))
|
|
258
|
+
continue;
|
|
259
|
+
if (w.touched.has(k))
|
|
260
|
+
out[i] = carried(w, k, src[k]);
|
|
261
|
+
else if (w.enumerated)
|
|
262
|
+
out[i] = null;
|
|
263
|
+
}
|
|
264
|
+
return out;
|
|
265
|
+
}
|
|
266
|
+
const out = {};
|
|
267
|
+
const names = Object.keys(src);
|
|
268
|
+
for (let i = 0; i < names.length; i += 1) {
|
|
269
|
+
const k = names[i];
|
|
270
|
+
if (isSecretKeyName(k))
|
|
271
|
+
continue;
|
|
272
|
+
const value = w.touched.has(k) ? carried(w, k, src[k]) : w.enumerated ? null : SKIP;
|
|
273
|
+
if (value !== SKIP)
|
|
274
|
+
Object.defineProperty(out, k, { value, writable: true, enumerable: true, configurable: true });
|
|
275
|
+
}
|
|
276
|
+
return out;
|
|
277
|
+
}
|
|
278
|
+
function deepFreeze(v) {
|
|
279
|
+
if (typeof v === 'object' && v !== null && !Object.isFrozen(v)) {
|
|
280
|
+
Object.freeze(v);
|
|
281
|
+
const names = Object.keys(v);
|
|
282
|
+
for (let i = 0; i < names.length; i += 1)
|
|
283
|
+
deepFreeze(v[names[i]]);
|
|
284
|
+
}
|
|
285
|
+
return v;
|
|
286
|
+
}
|
|
287
|
+
function sameReading(a, b, depth) {
|
|
288
|
+
if (Object.is(a, b))
|
|
289
|
+
return true;
|
|
290
|
+
if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null || depth > COPY_DEPTH_MAX * 2)
|
|
291
|
+
return false;
|
|
292
|
+
if (Array.isArray(a) !== Array.isArray(b))
|
|
293
|
+
return false;
|
|
294
|
+
const ka = Object.keys(a);
|
|
295
|
+
const kb = Object.keys(b);
|
|
296
|
+
if (ka.length !== kb.length)
|
|
297
|
+
return false;
|
|
298
|
+
for (let i = 0; i < ka.length; i += 1) {
|
|
299
|
+
const k = ka[i];
|
|
300
|
+
if (k !== kb[i] || !sameReading(a[k], b[k], depth + 1))
|
|
301
|
+
return false;
|
|
302
|
+
}
|
|
303
|
+
return true;
|
|
304
|
+
}
|
|
305
|
+
function readAll(e) {
|
|
306
|
+
return Object.values(READERS).map((read) => {
|
|
307
|
+
try {
|
|
308
|
+
return read(e);
|
|
309
|
+
}
|
|
310
|
+
catch {
|
|
311
|
+
return Symbol('reader-threw');
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
export function decisionRefusalCarrierOf(err) {
|
|
316
|
+
try {
|
|
317
|
+
if ((typeof err !== 'object' && typeof err !== 'function') || err === null)
|
|
318
|
+
return undefined;
|
|
319
|
+
const copy = copyOf(err, 0, { nodes: 0, path: new Set() });
|
|
320
|
+
if (typeof copy !== 'object' || copy === null || Array.isArray(copy))
|
|
321
|
+
return undefined;
|
|
322
|
+
const root = newWatch(copy);
|
|
323
|
+
const watches = new WeakMap();
|
|
324
|
+
const view = viewOf(root, watches);
|
|
325
|
+
const readers = Object.values(READERS);
|
|
326
|
+
for (let i = 0; i < readers.length; i += 1) {
|
|
327
|
+
const read = readers[i];
|
|
328
|
+
let out;
|
|
329
|
+
try {
|
|
330
|
+
out = read(view);
|
|
331
|
+
}
|
|
332
|
+
catch {
|
|
333
|
+
return undefined;
|
|
334
|
+
}
|
|
335
|
+
consumeOutput(out, watches, new Set(), 0);
|
|
336
|
+
}
|
|
337
|
+
const carrier = deepFreeze(pruned(root));
|
|
338
|
+
const original = readAll(err);
|
|
339
|
+
const fromCarrier = readAll(carrier);
|
|
340
|
+
for (let i = 0; i < original.length; i += 1)
|
|
341
|
+
if (!sameReading(original[i], fromCarrier[i], 0))
|
|
342
|
+
return undefined;
|
|
343
|
+
return carrier;
|
|
344
|
+
}
|
|
345
|
+
catch {
|
|
346
|
+
return undefined;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AgentClient, ElicitResponse } from '@sema-agent/sdk';
|
|
2
2
|
import type { UiLanguage } from '../env/uiLanguage.js';
|
|
3
3
|
import type { ToolPermissionSettledElsewhere } from './approvalResolution.js';
|
|
4
|
+
import { type ToolPermissionAck } from '../seatContract.js';
|
|
4
5
|
import { type AskGoneDetail } from '../decideReceipt.js';
|
|
5
6
|
import type { ApprovalDecidedByReading } from '../approvalDecidedByCapability.js';
|
|
6
7
|
import { type DecisionNoteAudit } from './approvalDecisionNoteAudit.js';
|
|
@@ -13,6 +14,10 @@ export declare const HITL_DECISION_NOT_APPLIED_CAUSES: readonly ["gone", "parked
|
|
|
13
14
|
export type HitlDecisionNotAppliedCause = (typeof HITL_DECISION_NOT_APPLIED_CAUSES)[number];
|
|
14
15
|
export declare const HITL_DECISION_UNCONFIRMED_CAUSES: readonly ["transport", "server_error", "local_error", "aborted", "gone_after_retry"];
|
|
15
16
|
export type HitlDecisionUnconfirmedCause = (typeof HITL_DECISION_UNCONFIRMED_CAUSES)[number];
|
|
17
|
+
export type ToolPermissionUnconfirmedCause = HitlDecisionUnconfirmedCause | 'registry_unreadable';
|
|
18
|
+
export interface ToolPermissionUnconfirmed {
|
|
19
|
+
readonly cause: ToolPermissionUnconfirmedCause;
|
|
20
|
+
}
|
|
16
21
|
export declare const HITL_DECISION_NOT_SENT_CAUSES: readonly ["aborted", "duplicate_in_flight", "invalid_request", "no_verb", "not_an_answer"];
|
|
17
22
|
export type HitlDecisionNotSentCause = (typeof HITL_DECISION_NOT_SENT_CAUSES)[number];
|
|
18
23
|
export interface HitlApprovalDecisionRequest {
|
|
@@ -118,5 +123,7 @@ export declare function __setHitlDecisionSendTimingForTests(t?: HitlDecisionSend
|
|
|
118
123
|
export declare function hitlAskIdempotencyKey(askId: string, verdict: 'approve' | 'deny'): string;
|
|
119
124
|
export declare function sendHitlDecision(request: HitlDecisionSendRequest, deps: HitlDecisionSendDeps): Promise<HitlDecisionSendOutcome>;
|
|
120
125
|
export declare function toolPermissionSettledLine(fact: ToolPermissionSettledElsewhere | null | undefined, lang?: UiLanguage): string | undefined;
|
|
126
|
+
export declare function toolPermissionUnconfirmedLine(ack: ToolPermissionAck | null | undefined, lang?: UiLanguage): string | undefined;
|
|
127
|
+
export declare function toolPermissionUnconfirmedOf(thrown: {} | null | undefined, signal?: AbortSignal): ToolPermissionUnconfirmed | undefined;
|
|
121
128
|
export declare function hitlDecisionOutcomeContent(outcome: HitlDecisionSendOutcome, lang?: UiLanguage): string | undefined;
|
|
122
129
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { settleWithinDeadline } from '../abortableSleep.js';
|
|
2
2
|
import { hostLog } from '../host.js';
|
|
3
3
|
import { invokeHostCallbackIsolated } from '../hostCallbackGuard.js';
|
|
4
|
+
import { readToolPermissionAckState } from '../seatContract.js';
|
|
4
5
|
import { msg, renderMessage } from '../i18n/translate.js';
|
|
5
6
|
import { askGoneFromError } from '../decideReceipt.js';
|
|
6
7
|
import { appendOwnElement, guardedRead, readOwnDataNonEmptyString, readOwnDataValue } from '../ownKey.js';
|
|
@@ -14,7 +15,7 @@ import { ASK_DECIDED_CODE, classifyDeliveredDecisionRefusal, decisionRefusalClos
|
|
|
14
15
|
import { sessionAllowEligible } from './sessionAllowRoute.js';
|
|
15
16
|
import { addDecisionOpKeys, closeDecisionOp, decisionLedgerKeysOf, decisionOpsWithKey, openDecisionOp } from './decisionLedger.js';
|
|
16
17
|
import { hostHoldIsActive, takeHostHoldLedgerOp, tryHoldApprovalNow } from './approvalHolds.js';
|
|
17
|
-
import { allowNoteReadingOf, answerPayloadFor, decisionAttributionKeyOf, readApprovalDenySettledBy, readToolApprovalRespondAck, readToolApprovalRespondParking,
|
|
18
|
+
import { allowNoteReadingOf, answerPayloadFor, decisionAttributionKeyOf, readApprovalDenySettledBy, readToolApprovalRespondAck, readToolApprovalRespondParking, replayVerdictFrom, settlementAckOf, } from './toolApprovalWire.js';
|
|
18
19
|
export const HITL_DECISION_FAMILIES = Object.freeze(['approval', 'ask', 'elicitation']);
|
|
19
20
|
export const HITL_DECISION_NOT_APPLIED_CAUSES = Object.freeze(['gone', 'parked', 'parking', 'lane_disabled', 'refused', 'idempotency_crossed']);
|
|
20
21
|
export const HITL_DECISION_UNCONFIRMED_CAUSES = Object.freeze(['transport', 'server_error', 'local_error', 'aborted', 'gone_after_retry']);
|
|
@@ -164,9 +165,9 @@ async function sendApprovalFamily(respond, approvalId, answer, ctx) {
|
|
|
164
165
|
return { ...base, kind: 'not_applied', cause: 'parking', ...(view !== undefined ? { parking: view, ...(hint !== undefined ? { retryAfterMs: hint } : {}) } : {}) };
|
|
165
166
|
}
|
|
166
167
|
const parsed = settlementAckOf(readToolApprovalRespondAck(raw));
|
|
167
|
-
const
|
|
168
|
-
if (
|
|
169
|
-
const first =
|
|
168
|
+
const replay = replayVerdictFrom(raw, parsed, approvalId);
|
|
169
|
+
if (replay.kind === 'replayed') {
|
|
170
|
+
const first = verdictOf(replay.firstDecision);
|
|
170
171
|
return {
|
|
171
172
|
...base,
|
|
172
173
|
kind: 'settled_elsewhere',
|
|
@@ -174,8 +175,8 @@ async function sendApprovalFamily(respond, approvalId, answer, ctx) {
|
|
|
174
175
|
...(first !== undefined && ours !== undefined && first !== ours ? { contrary: true } : {}),
|
|
175
176
|
};
|
|
176
177
|
}
|
|
177
|
-
if (
|
|
178
|
-
return { ...base, kind: '
|
|
178
|
+
if (replay.kind === 'unreadable')
|
|
179
|
+
return { ...base, kind: 'unconfirmed', cause: 'local_error' };
|
|
179
180
|
const ack = parsed !== undefined && parsed.approvalId === approvalId ? parsed : undefined;
|
|
180
181
|
return { ...base, kind: 'applied', ...(ack !== undefined ? { ack } : {}), ...(ctx.noteCapable ? { noteAudit: readDecisionNoteAudit(raw) } : {}) };
|
|
181
182
|
}
|
|
@@ -190,9 +191,6 @@ function bodyFacts(answer, payload, rememberUnsupported) {
|
|
|
190
191
|
function answerGateCannotTake(out) {
|
|
191
192
|
return out.kind === 'not_applied' && (out.cause === 'gone' || out.cause === 'parking' || out.cause === 'lane_disabled');
|
|
192
193
|
}
|
|
193
|
-
function ownTrue(raw, key) {
|
|
194
|
-
return typeof raw === 'object' && raw !== null && guardedRead(() => readOwnDataValue(raw, key)) === true;
|
|
195
|
-
}
|
|
196
194
|
async function sendAskFamily(respondForFallback, decideAsk, req, ctx) {
|
|
197
195
|
const payload = answerPayloadFor(req.answer, 'respond', { approvalDecisionNoteCapable: ctx.noteCapable });
|
|
198
196
|
if (payload === undefined)
|
|
@@ -363,8 +361,8 @@ function snapshotAnswer(raw) {
|
|
|
363
361
|
if (kind === 'allow') {
|
|
364
362
|
const allowSession = guardedRead(() => readOwnDataValue(raw, 'allowSession')) === true;
|
|
365
363
|
const edited = guardedRead(() => readOwnDataValue(raw, 'updatedInput'));
|
|
366
|
-
const
|
|
367
|
-
const note =
|
|
364
|
+
const noteReading = guardedRead(() => allowNoteReadingOf(raw));
|
|
365
|
+
const note = noteReading?.kind === 'text' ? noteReading.text : undefined;
|
|
368
366
|
if (edited === undefined)
|
|
369
367
|
return Object.freeze({ kind: 'allow', allowSession, ...(note !== undefined ? { note } : {}) });
|
|
370
368
|
let copy;
|
|
@@ -582,6 +580,30 @@ export function toolPermissionSettledLine(fact, lang) {
|
|
|
582
580
|
return undefined;
|
|
583
581
|
}
|
|
584
582
|
}
|
|
583
|
+
function unconfirmedDecisionContent(cause, lang) {
|
|
584
|
+
return cause === 'gone_after_retry' ? renderMessage(msg('approval.decision.unconfirmedAfterRetry'), lang) : renderMessage(msg('approval.decideAck.unconfirmed'), lang);
|
|
585
|
+
}
|
|
586
|
+
export function toolPermissionUnconfirmedLine(ack, lang) {
|
|
587
|
+
try {
|
|
588
|
+
const state = readToolPermissionAckState(ack);
|
|
589
|
+
return state !== undefined && state.kind === 'unconfirmed' ? unconfirmedDecisionContent(state.cause, lang) : undefined;
|
|
590
|
+
}
|
|
591
|
+
catch {
|
|
592
|
+
return undefined;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
export function toolPermissionUnconfirmedOf(thrown, signal) {
|
|
596
|
+
try {
|
|
597
|
+
const out = outcomeOfThrown(thrown, 'approval', undefined, signal, newSendTally(), false);
|
|
598
|
+
if (out.kind !== 'unconfirmed')
|
|
599
|
+
return undefined;
|
|
600
|
+
const cause = HITL_DECISION_UNCONFIRMED_CAUSES.find((w) => w === out.cause);
|
|
601
|
+
return cause === undefined ? undefined : Object.freeze({ cause });
|
|
602
|
+
}
|
|
603
|
+
catch {
|
|
604
|
+
return Object.freeze({ cause: 'local_error' });
|
|
605
|
+
}
|
|
606
|
+
}
|
|
585
607
|
export function hitlDecisionOutcomeContent(outcome, lang) {
|
|
586
608
|
try {
|
|
587
609
|
if (typeof outcome !== 'object' || outcome === null)
|
|
@@ -594,7 +616,7 @@ export function hitlDecisionOutcomeContent(outcome, lang) {
|
|
|
594
616
|
return first === 'deny' || first === 'approve' ? settledElsewhereContraryContent(first, lang) : undefined;
|
|
595
617
|
}
|
|
596
618
|
if (kind === 'unconfirmed' && readOwnDataValue(outcome, 'cause') === 'gone_after_retry')
|
|
597
|
-
return
|
|
619
|
+
return unconfirmedDecisionContent('gone_after_retry', lang);
|
|
598
620
|
return undefined;
|
|
599
621
|
}
|
|
600
622
|
catch {
|
|
@@ -22,5 +22,5 @@ export function editedApprovalAcceptanceOf(card) {
|
|
|
22
22
|
return read.value === true ? REFUSES : UNKNOWN_MALFORMED;
|
|
23
23
|
}
|
|
24
24
|
export function editedApprovalRefusedLine(lang) {
|
|
25
|
-
return renderMessage(msg('approval.editRefusal.line'), lang);
|
|
25
|
+
return renderMessage(msg('approval.editRefusal.line', { stem: msg('approval.editRefusal.stem') }), lang);
|
|
26
26
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { EventLegElicitationFrame } from '../eventLeg.js';
|
|
2
|
+
import type { UiLanguage } from '../env/uiLanguage.js';
|
|
3
|
+
import type { HitlDecisionSendOutcome } from './decisionSend.js';
|
|
4
|
+
export declare function elicitationRefusedLine(frame: EventLegElicitationFrame, outcome: HitlDecisionSendOutcome, lang?: UiLanguage): string | undefined;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { capForDisplay } from '../fleetTaskDesc.js';
|
|
2
|
+
import { msg, renderMessage } from '../i18n/translate.js';
|
|
3
|
+
import { guardedRead, readOwnDataNonEmptyString, readOwnDataValue } from '../ownKey.js';
|
|
4
|
+
const SERVER_NAME_SHOWN_MAX = 40;
|
|
5
|
+
export function elicitationRefusedLine(frame, outcome, lang) {
|
|
6
|
+
try {
|
|
7
|
+
if (typeof frame !== 'object' || frame === null || typeof outcome !== 'object' || outcome === null)
|
|
8
|
+
return undefined;
|
|
9
|
+
if (guardedRead(() => readOwnDataValue(frame, 'type')) !== 'elicitation')
|
|
10
|
+
return undefined;
|
|
11
|
+
if (guardedRead(() => readOwnDataValue(outcome, 'family')) !== 'elicitation')
|
|
12
|
+
return undefined;
|
|
13
|
+
if (guardedRead(() => readOwnDataValue(outcome, 'kind')) !== 'applied')
|
|
14
|
+
return undefined;
|
|
15
|
+
const name = guardedRead(() => readOwnDataNonEmptyString(frame, 'mcpServerName'));
|
|
16
|
+
return name === undefined
|
|
17
|
+
? renderMessage(msg('mcp.elicitation.refused.unnamed'), lang)
|
|
18
|
+
: renderMessage(msg('mcp.elicitation.refused.named', { server: capForDisplay(name, SERVER_NAME_SHOWN_MAX) }), lang);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -38,9 +38,8 @@ export interface AskGateWireDeps {
|
|
|
38
38
|
onToolApprovalOutcome?: (frame: ToolApprovalFrame, resolution: ApprovalResolution) => void | Promise<void>;
|
|
39
39
|
onDecideOperation?: DecideOperationObserver;
|
|
40
40
|
onReplayedApproval?: (frame: ToolApprovalFrame, disposition: ReplayedApprovalDisposition) => void | Promise<void>;
|
|
41
|
+
engineGeneration?: () => number;
|
|
41
42
|
}
|
|
42
|
-
export declare function setBridgeRunHandleFallback(deps: object, read: () => string | undefined): void;
|
|
43
|
-
export declare function bridgeRunHandleFallbackOf(deps: object): string | undefined;
|
|
44
43
|
type GateKind = 'ask' | 'fs';
|
|
45
44
|
export interface GatePark {
|
|
46
45
|
gate: GateKind;
|
|
@@ -73,6 +72,7 @@ export interface FrameRouterCtx {
|
|
|
73
72
|
deps: AskGateWireDeps;
|
|
74
73
|
taskId: TaskIdRef;
|
|
75
74
|
signal?: AbortSignal | undefined;
|
|
75
|
+
streamGeneration?: number | undefined;
|
|
76
76
|
}
|
|
77
77
|
export declare function isAskTool(toolName: string | undefined): boolean;
|
|
78
78
|
export declare function questionCardVerdict(carrier: object | null | undefined): boolean | undefined;
|
package/dist/hitl/frameRouter.js
CHANGED
|
@@ -89,6 +89,8 @@ function policyDenyHeadFor(cause) {
|
|
|
89
89
|
return renderMessage(msg('approval.policyDeny.denyRule', { tail }));
|
|
90
90
|
case 'engine_floor':
|
|
91
91
|
return renderMessage(msg('approval.policyDeny.engineFloor', { tail }));
|
|
92
|
+
case 'hook':
|
|
93
|
+
return renderMessage(msg('approval.policyDeny.hook'));
|
|
92
94
|
case 'no_approval_ui':
|
|
93
95
|
case undefined:
|
|
94
96
|
return HITL_POLICY_DENY_MESSAGE;
|
|
@@ -117,20 +119,6 @@ function denyStampedEnd(ev, attribution) {
|
|
|
117
119
|
export const HITL_INTERRUPT_MESSAGE_FOR_TOOL_USE = '[Request interrupted by user for tool use]';
|
|
118
120
|
const RUN_CANCELLED_ERROR_CODE = RUN_CANCELLED_CODE;
|
|
119
121
|
export const ENGINE_ABORT_TOOL_RESULT = 'Operation aborted';
|
|
120
|
-
const bridgeRunHandleFallbacks = new WeakMap();
|
|
121
|
-
export function setBridgeRunHandleFallback(deps, read) {
|
|
122
|
-
bridgeRunHandleFallbacks.set(deps, read);
|
|
123
|
-
}
|
|
124
|
-
export function bridgeRunHandleFallbackOf(deps) {
|
|
125
|
-
try {
|
|
126
|
-
const read = bridgeRunHandleFallbacks.get(deps);
|
|
127
|
-
const v = read?.();
|
|
128
|
-
return typeof v === 'string' && v !== '' ? v : undefined;
|
|
129
|
-
}
|
|
130
|
-
catch {
|
|
131
|
-
return undefined;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
122
|
function isAskToolLoose(name) {
|
|
135
123
|
return typeof name === 'string' && name.replace(/[\s_-]+/g, '').toLowerCase() === 'askuserquestion';
|
|
136
124
|
}
|
|
@@ -371,7 +359,12 @@ async function routeToolApprovalFrame(ev, ctx) {
|
|
|
371
359
|
const gatedCallId = fromSubagent ? undefined : frameCallId ?? led.lastPendingFsCall();
|
|
372
360
|
const argsCallId = frameCallId === undefined ? gatedCallId : typeof ev.toolName === 'string' && toolNameIsFsWrite(ev.toolName) ? frameCallId : undefined;
|
|
373
361
|
const runTaskId = ctx.taskId.current;
|
|
374
|
-
const
|
|
362
|
+
const streamGeneration = ctx.streamGeneration;
|
|
363
|
+
const runFacts = {
|
|
364
|
+
...(typeof runTaskId === 'string' && runTaskId !== '' ? { taskId: runTaskId } : {}),
|
|
365
|
+
...(streamGeneration !== undefined ? { sourceGeneration: streamGeneration } : {}),
|
|
366
|
+
};
|
|
367
|
+
const launched = surfaceToolApprovalFrameAndRespond(ev, deps.respondToolApproval, argsOfGatedStart(led, argsCallId), ctx.signal, deps.approvalLane, Object.keys(runFacts).length > 0 ? runFacts : undefined);
|
|
375
368
|
const hold = liveCardHoldOf(liveFrameCallKey(ev.approvalId));
|
|
376
369
|
const handled = launched.then((outcome) => settleLiveCardOutcome(ev, outcome, ctx, fromSubagent, gatedCallId), (e) => {
|
|
377
370
|
hostLog('debug', `liveHitlAskWire: tool_approval card for ${ev.approvalId} failed: ${String(e).slice(0, 160)}`);
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
export declare const PLAN_REVIEW_QUESTION_ID_PREFIX = "plan-review:";
|
|
2
2
|
export declare const REOPEN_ID_TAIL = "#reopen-";
|
|
3
|
+
export declare const SCREEN_CARD_ORIGINS: readonly ["live-approval", "park-approval", "park-question", "plan-review", "host-reopen-question", "host-choice", "local-permission"];
|
|
4
|
+
export type ScreenCardOrigin = (typeof SCREEN_CARD_ORIGINS)[number];
|
|
3
5
|
export declare function approvalCallKey(gatedCallId: string | undefined, taskId: string): string;
|
|
4
6
|
export declare function askGateQuestionId(callKey: string): string;
|
|
5
7
|
export declare function planReviewQuestionId(taskId: string): string;
|
|
6
8
|
export declare function freshPlanReviewQuestionId(taskId: string, suffix: string): string;
|
|
9
|
+
export declare function hostReopenQuestionId(rowTaskId: string, suffix: string): string;
|
|
10
|
+
export declare function hostRunChoiceQuestionId(taskId: string, suffix: string): string;
|
|
11
|
+
export declare function questionCardOriginOf(questionId: {} | null | undefined): Extract<ScreenCardOrigin, 'park-question' | 'plan-review' | 'host-reopen-question' | 'host-choice'> | undefined;
|
|
7
12
|
export declare function liveFrameCallKey(approvalId: string): string;
|
|
8
13
|
export declare function taskIdFromPlanReviewQuestionId(questionId: string): string | undefined;
|
|
9
14
|
export declare function armedKeyFromQuestionId(questionId: string): string;
|
|
@@ -2,6 +2,9 @@ const HITL_ASK_QUESTION_ID_PREFIX = 'hitl-ask:';
|
|
|
2
2
|
export const PLAN_REVIEW_QUESTION_ID_PREFIX = 'plan-review:';
|
|
3
3
|
const HITL_FRAME_CALL_KEY_PREFIX = 'hitl-frame:';
|
|
4
4
|
export const REOPEN_ID_TAIL = '#reopen-';
|
|
5
|
+
const HOST_REOPEN_QUESTION_ID_PREFIX = 'ask-park:';
|
|
6
|
+
const HOST_RUN_CHOICE_QUESTION_ID_PREFIX = 'active-run:';
|
|
7
|
+
export const SCREEN_CARD_ORIGINS = Object.freeze(['live-approval', 'park-approval', 'park-question', 'plan-review', 'host-reopen-question', 'host-choice', 'local-permission']);
|
|
5
8
|
export function approvalCallKey(gatedCallId, taskId) {
|
|
6
9
|
return gatedCallId ?? taskId;
|
|
7
10
|
}
|
|
@@ -14,6 +17,26 @@ export function planReviewQuestionId(taskId) {
|
|
|
14
17
|
export function freshPlanReviewQuestionId(taskId, suffix) {
|
|
15
18
|
return `${planReviewQuestionId(taskId)}${REOPEN_ID_TAIL}${suffix}`;
|
|
16
19
|
}
|
|
20
|
+
export function hostReopenQuestionId(rowTaskId, suffix) {
|
|
21
|
+
return `${HOST_REOPEN_QUESTION_ID_PREFIX}${rowTaskId}${REOPEN_ID_TAIL}${suffix}`;
|
|
22
|
+
}
|
|
23
|
+
export function hostRunChoiceQuestionId(taskId, suffix) {
|
|
24
|
+
return `${HOST_RUN_CHOICE_QUESTION_ID_PREFIX}${taskId}${REOPEN_ID_TAIL}${suffix}`;
|
|
25
|
+
}
|
|
26
|
+
export function questionCardOriginOf(questionId) {
|
|
27
|
+
if (typeof questionId !== 'string')
|
|
28
|
+
return undefined;
|
|
29
|
+
const has = (prefix) => questionId.startsWith(prefix) && questionId.length > prefix.length;
|
|
30
|
+
if (has(HITL_ASK_QUESTION_ID_PREFIX))
|
|
31
|
+
return 'park-question';
|
|
32
|
+
if (has(PLAN_REVIEW_QUESTION_ID_PREFIX))
|
|
33
|
+
return 'plan-review';
|
|
34
|
+
if (has(HOST_REOPEN_QUESTION_ID_PREFIX))
|
|
35
|
+
return 'host-reopen-question';
|
|
36
|
+
if (has(HOST_RUN_CHOICE_QUESTION_ID_PREFIX))
|
|
37
|
+
return 'host-choice';
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
17
40
|
export function liveFrameCallKey(approvalId) {
|
|
18
41
|
return `${HITL_FRAME_CALL_KEY_PREFIX}${approvalId}`;
|
|
19
42
|
}
|
|
@@ -138,6 +138,12 @@ export type FindPendingOutcome = {
|
|
|
138
138
|
readonly kind: 'ok';
|
|
139
139
|
}>;
|
|
140
140
|
};
|
|
141
|
+
export interface PendingRowCallIdentity {
|
|
142
|
+
readonly taskId?: string | null;
|
|
143
|
+
readonly toolCallId?: string | null;
|
|
144
|
+
readonly boundCallId?: string | null;
|
|
145
|
+
}
|
|
146
|
+
export declare function pendingRowAnswersCall(row: PendingRowCallIdentity, taskId: string, callId: string): boolean;
|
|
141
147
|
export declare function findPendingForTask(client: HitlClientLike, taskId: string, matches: (toolName: string | undefined) => boolean, opts?: {
|
|
142
148
|
signal?: AbortSignal;
|
|
143
149
|
}, callId?: string, identityAccepts?: (row: PendingCheckpoint) => boolean): Promise<FindPendingOutcome>;
|