@sema-agent/client-core 0.99.0 → 0.101.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 +572 -0
- package/README.md +174 -114
- package/dist/adapt/arms.js +109 -50
- package/dist/adapt/panelTasks.d.ts +2 -1
- package/dist/adapt/panelTasks.js +32 -9
- package/dist/adapt/textStream.d.ts +1 -1
- package/dist/adapt/textStream.js +58 -32
- package/dist/adapt/toolCards.js +9 -8
- package/dist/adapt.js +7 -1
- package/dist/adapter/activeRunSelfHeal.d.ts +31 -2
- package/dist/adapter/activeRunSelfHeal.js +162 -13
- package/dist/adapter/downstream/eventToSdkMessage.d.ts +25 -6
- package/dist/adapter/downstream/eventToSdkMessage.js +157 -20
- package/dist/adapter/downstream/terminalToSdkResult.d.ts +60 -1
- package/dist/adapter/downstream/terminalToSdkResult.js +219 -39
- package/dist/adapter/downstream/wiringManifestView.d.ts +3 -1
- package/dist/adapter/downstream/wiringManifestView.js +1 -0
- package/dist/adapter/runStream.d.ts +4 -4
- package/dist/adapter/runStream.js +184 -42
- package/dist/adapter/types.d.ts +2 -0
- package/dist/agentsWireCaps.d.ts +9 -7
- package/dist/agentsWireCaps.js +101 -17
- package/dist/approvalDecidedByCapability.js +2 -2
- package/dist/approvalFrameFamilies.d.ts +33 -0
- package/dist/approvalFrameFamilies.js +120 -0
- package/dist/approvalsStreamLiveCapability.js +2 -2
- package/dist/attachmentsWireCaps.js +41 -13
- package/dist/callerCwdCapability.js +2 -2
- package/dist/centerWiringCapability.js +2 -2
- package/dist/clockReading.d.ts +2 -0
- package/dist/clockReading.js +4 -0
- package/dist/cloudConfigWireCaps.d.ts +28 -5
- package/dist/cloudConfigWireCaps.js +334 -103
- package/dist/compactionStatus.d.ts +34 -0
- package/dist/compactionStatus.js +196 -0
- package/dist/coreValuePorts.d.ts +12 -2
- package/dist/coreValuePorts.js +9 -0
- package/dist/decideFailureNote.js +8 -6
- package/dist/decideReceipt.js +2 -2
- package/dist/deviceExecutorManagementCapability.js +2 -2
- package/dist/deviceFlowPolling.js +1 -1
- package/dist/disableSkillsWire.d.ts +1 -1
- package/dist/disableSkillsWire.js +4 -3
- package/dist/displayUntrusted.d.ts +1 -0
- package/dist/displayUntrusted.js +215 -13
- package/dist/engineAgentPanelStore.d.ts +7 -4
- package/dist/engineCapReader.js +1 -1
- package/dist/engineConfigDrift.js +1 -1
- package/dist/engineErrorCodes.d.ts +23 -6
- package/dist/engineErrorCodes.js +36 -11
- package/dist/engineGenerationConvergence.d.ts +39 -0
- package/dist/engineGenerationConvergence.js +95 -0
- package/dist/engineGenerationPort.d.ts +61 -0
- package/dist/engineGenerationPort.js +144 -0
- package/dist/engineHealthFacts.d.ts +23 -0
- package/dist/engineHealthFacts.js +92 -0
- package/dist/engineIdentity.d.ts +4 -0
- package/dist/engineIdentity.js +11 -0
- package/dist/engineNoticeCodes.d.ts +2 -5
- package/dist/engineRowRef.js +4 -0
- package/dist/engineSessionMessages.js +2 -2
- package/dist/engineToolDirectory.d.ts +3 -0
- package/dist/engineToolDirectory.js +6 -4
- package/dist/engineWireFor.d.ts +99 -0
- package/dist/engineWireFor.js +248 -6
- package/dist/engineWireTarget.d.ts +1 -0
- package/dist/engineWireTarget.js +8 -0
- package/dist/env/uiLanguage.js +1 -1
- package/dist/errorSupplementRoles.d.ts +3 -0
- package/dist/errorSupplementRoles.js +37 -0
- package/dist/eventLeg.d.ts +1 -7
- package/dist/eventLeg.js +7 -8
- package/dist/executionLaneCapability.js +2 -2
- package/dist/fileHistoryCaptureCapability.d.ts +0 -3
- package/dist/fileHistoryCaptureCapability.js +3 -7
- package/dist/finalVerifyWire.d.ts +6 -3
- package/dist/finalVerifyWire.js +6 -23
- package/dist/flagInput.d.ts +4 -0
- package/dist/flagInput.js +24 -0
- package/dist/fleet/fleetLedger.js +5 -2
- package/dist/fleet/fleetProjection.d.ts +1 -0
- package/dist/fleet/fleetProjection.js +15 -2
- package/dist/gateVocabulary.js +3 -0
- package/dist/generated/engineFactTables.d.ts +7 -2
- package/dist/generated/engineFactTables.js +79 -0
- package/dist/generated/engineNoticeTables.js +15 -0
- package/dist/generated/settingsSchemaActiveTiers.d.ts +1 -0
- package/dist/generated/settingsSchemaActiveTiers.js +14 -0
- package/dist/generated/settingsSchemaCallerTextEcho.d.ts +1 -0
- package/dist/generated/settingsSchemaCallerTextEcho.js +8 -0
- package/dist/generated/settingsSchemaControlAndBidi.d.ts +1 -0
- package/dist/generated/settingsSchemaControlAndBidi.js +8 -0
- package/dist/generated/settingsSchemaDefaultModel.d.ts +11 -0
- package/dist/generated/settingsSchemaDefaultModel.js +25 -0
- package/dist/generated/settingsSchemaFns.d.ts +66 -0
- package/dist/generated/settingsSchemaFns.js +38 -0
- package/dist/generated/settingsSchemaMcpRequestEntry.d.ts +1 -0
- package/dist/generated/settingsSchemaMcpRequestEntry.js +156 -0
- package/dist/generated/settingsSchemaSafetyMergeSpec.d.ts +1 -0
- package/dist/generated/settingsSchemaSafetyMergeSpec.js +95 -0
- package/dist/generated/settingsSchemaSettingsSources.d.ts +1 -0
- package/dist/generated/settingsSchemaSettingsSources.js +58 -0
- package/dist/generated/settingsSchemaTables.d.ts +3 -0
- package/dist/generated/settingsSchemaTables.js +18 -0
- package/dist/generated/settingsSchemaTypes.d.ts +28 -0
- package/dist/generated/settingsSchemaUrlPattern.d.ts +1 -0
- package/dist/generated/settingsSchemaUrlPattern.js +183 -0
- package/dist/headlessPermissionModeWire.d.ts +18 -2
- package/dist/headlessPermissionModeWire.js +30 -19
- package/dist/hitl/allowRuleShadow.js +9 -7
- package/dist/hitl/approvalCardReading.d.ts +3 -0
- package/dist/hitl/approvalCardReading.js +17 -0
- package/dist/hitl/approvalCardReasons.js +2 -2
- package/dist/hitl/approvalCompleteParked.js +1 -1
- package/dist/hitl/approvalDelivery.d.ts +87 -0
- package/dist/hitl/approvalDelivery.js +193 -0
- package/dist/hitl/approvalHolds.d.ts +14 -0
- package/dist/hitl/approvalHolds.js +41 -0
- package/dist/hitl/approvalResolution.d.ts +11 -0
- package/dist/hitl/approvalResolution.js +50 -11
- package/dist/hitl/askClassPair.d.ts +8 -2
- package/dist/hitl/askClassPair.js +31 -4
- package/dist/hitl/askParkAutoReopenBlock.d.ts +30 -0
- package/dist/hitl/askParkAutoReopenBlock.js +117 -0
- package/dist/hitl/askParkRowRouting.js +4 -1
- package/dist/hitl/attributionLadder.d.ts +62 -0
- package/dist/hitl/attributionLadder.js +138 -0
- package/dist/hitl/automaticAnswerVerdict.d.ts +6 -1
- package/dist/hitl/automaticAnswerVerdict.js +46 -11
- package/dist/hitl/crashConverged.js +2 -2
- package/dist/hitl/decisionConflict.d.ts +6 -2
- package/dist/hitl/decisionConflict.js +24 -9
- package/dist/hitl/decisionLedger.d.ts +55 -0
- package/dist/hitl/decisionLedger.js +156 -0
- package/dist/hitl/decisionRefusal.d.ts +21 -10
- package/dist/hitl/decisionRefusal.js +100 -55
- package/dist/hitl/decisionSend.d.ts +116 -0
- package/dist/hitl/decisionSend.js +563 -0
- package/dist/hitl/frameRouter.d.ts +1 -0
- package/dist/hitl/frameRouter.js +9 -2
- package/dist/hitl/hitlBridge.d.ts +18 -6
- package/dist/hitl/hitlBridge.js +59 -43
- package/dist/hitl/livePendingAsk.js +4 -3
- package/dist/hitl/noAllowCause.js +1 -1
- package/dist/hitl/parkResolver.js +3 -2
- package/dist/hitl/persistedRulesWire.js +1 -0
- package/dist/hitl/planReviewWire.d.ts +4 -0
- package/dist/hitl/planReviewWire.js +104 -106
- package/dist/hitl/resumeRunningCard.d.ts +3 -2
- package/dist/hitl/resumeRunningCard.js +17 -11
- package/dist/hitl/sessionPolicyDeliverable.d.ts +5 -2
- package/dist/hitl/sessionPolicyDeliverable.js +65 -35
- package/dist/hitl/sessionPolicyWire.d.ts +13 -3
- package/dist/hitl/sessionPolicyWire.js +81 -16
- package/dist/hitl/standingRows.js +1 -1
- package/dist/hitl/toolApprovalWire.d.ts +9 -10
- package/dist/hitl/toolApprovalWire.js +103 -151
- package/dist/hookMatcherVerdict.d.ts +2 -0
- package/dist/hookMatcherVerdict.js +12 -0
- package/dist/hooksCompactTransition.d.ts +19 -0
- package/dist/hooksCompactTransition.js +41 -0
- package/dist/hooksWireCaps.d.ts +1 -1
- package/dist/hooksWireCaps.js +202 -203
- package/dist/host.d.ts +1 -14
- package/dist/host.js +0 -8
- package/dist/hostCallbackGuard.d.ts +1 -0
- package/dist/hostCallbackGuard.js +1 -1
- package/dist/hostSettingsSource.d.ts +172 -0
- package/dist/hostSettingsSource.js +675 -0
- package/dist/hostTurnSettings.d.ts +114 -19
- package/dist/hostTurnSettings.js +966 -68
- package/dist/httpHookPolicy.d.ts +37 -0
- package/dist/httpHookPolicy.js +176 -0
- package/dist/humanTurn.d.ts +4 -2
- package/dist/humanTurn.js +40 -10
- package/dist/humanTurnRead.js +4 -3
- package/dist/humanTurnSentences.d.ts +10 -0
- package/dist/humanTurnSentences.js +74 -0
- package/dist/i18n/messages.en.d.ts +313 -0
- package/dist/i18n/messages.en.js +326 -13
- package/dist/i18n/messages.zh.js +341 -13
- package/dist/i18n/translate.js +3 -3
- package/dist/index.d.ts +85 -15
- package/dist/index.js +53 -12
- package/dist/inheritEnvCapability.d.ts +4 -1
- package/dist/inheritEnvCapability.js +38 -17
- package/dist/inheritEnvWire.d.ts +2 -1
- package/dist/inheritEnvWire.js +11 -5
- package/dist/injectionLaneNotice.d.ts +5 -0
- package/dist/injectionLaneNotice.js +46 -0
- package/dist/interactiveToolsWire.d.ts +4 -2
- package/dist/interactiveToolsWire.js +5 -5
- package/dist/jsonFaithful.d.ts +20 -0
- package/dist/jsonFaithful.js +152 -0
- package/dist/limitsWire.d.ts +7 -2
- package/dist/limitsWire.js +19 -13
- package/dist/liveInitToolFace.d.ts +6 -1
- package/dist/liveInitToolFace.js +5 -3
- package/dist/liveModelCatalog.d.ts +22 -0
- package/dist/liveModelCatalog.js +132 -18
- package/dist/mcpPanel.js +3 -1
- package/dist/mcpProbeCapability.js +2 -2
- package/dist/mcpReconnect.js +2 -2
- package/dist/mcpStatusSupersetKeys.d.ts +24 -0
- package/dist/mcpStatusSupersetKeys.js +45 -0
- package/dist/mcpToolToggles.d.ts +6 -0
- package/dist/mcpToolToggles.js +47 -0
- package/dist/mcpWireCaps.d.ts +48 -4
- package/dist/mcpWireCaps.js +338 -99
- package/dist/mcpWireTransport.d.ts +4 -0
- package/dist/mcpWireTransport.js +18 -0
- package/dist/memoryComplianceCapability.js +2 -2
- package/dist/memoryOriginCapability.js +2 -2
- package/dist/model/catalogDefault.d.ts +24 -0
- package/dist/model/catalogDefault.js +4 -0
- package/dist/model/liveCatalogShape.js +5 -4
- package/dist/model/modelsPolicy.js +4 -3
- package/dist/model/onboardJudgement.d.ts +1 -0
- package/dist/model/onboardJudgement.js +1 -1
- package/dist/model/subagentModelWord.js +2 -2
- package/dist/modelCapabilityProbe.d.ts +2 -1
- package/dist/modelCapabilityProbe.js +16 -15
- package/dist/modelIdentityResolvability.d.ts +12 -1
- package/dist/modelIdentityResolvability.js +69 -28
- package/dist/modsKernelIdentity.d.ts +10 -0
- package/dist/modsKernelIdentity.js +103 -0
- package/dist/modsKernelTransit.d.ts +8 -0
- package/dist/modsKernelTransit.js +6 -0
- package/dist/notifications.d.ts +30 -12
- package/dist/notifications.js +241 -53
- package/dist/outputStyleSeatCapability.js +2 -2
- package/dist/ownKey.d.ts +37 -0
- package/dist/ownKey.js +238 -2
- package/dist/panelReduce.d.ts +5 -0
- package/dist/panelReduce.js +45 -13
- package/dist/panelStateHolder.d.ts +1 -0
- package/dist/panelStateHolder.js +10 -1
- package/dist/peerFrames.d.ts +1 -1
- package/dist/peerFrames.js +6 -2
- package/dist/peerLaneCapability.js +2 -2
- package/dist/permissionModesCapability.js +4 -4
- package/dist/permissionRuleIssue.d.ts +2 -1
- package/dist/permissionRuleIssue.js +24 -21
- package/dist/permissionRulesWriteCapability.js +2 -2
- package/dist/permissionsAllowGrantCapability.js +2 -2
- package/dist/permissionsDeclaration.d.ts +43 -4
- package/dist/permissionsDeclaration.js +102 -35
- package/dist/pluginHooksWire.d.ts +20 -4
- package/dist/pluginHooksWire.js +101 -60
- package/dist/prepareRefusal.d.ts +9 -0
- package/dist/prepareRefusal.js +90 -0
- package/dist/printInitToolFace.js +2 -2
- package/dist/printModelStatus.js +1 -1
- package/dist/projectMemory.d.ts +32 -0
- package/dist/projectMemory.js +70 -0
- package/dist/promptBlockedCopy.d.ts +2 -1
- package/dist/promptBlockedCopy.js +2 -1
- package/dist/promptDelivery.d.ts +23 -3
- package/dist/promptDelivery.js +169 -30
- package/dist/providerRejection.d.ts +19 -1
- package/dist/providerRejection.js +75 -4
- package/dist/queuedDelivery.d.ts +48 -0
- package/dist/queuedDelivery.js +233 -0
- package/dist/reattachWindow.d.ts +94 -0
- package/dist/reattachWindow.js +127 -0
- package/dist/request/printNotification.d.ts +1 -1
- package/dist/request/printNotification.js +5 -1
- package/dist/request/submissionIdentity.d.ts +37 -0
- package/dist/request/submissionIdentity.js +65 -0
- package/dist/request/taskRequest.d.ts +22 -14
- package/dist/request/taskRequest.js +312 -202
- package/dist/resultFrameKeys.d.ts +1 -0
- package/dist/resultFrameKeys.js +4 -1
- package/dist/resumeRefusalCopy.d.ts +3 -1
- package/dist/resumeRefusalCopy.js +22 -4
- package/dist/retryStatus.d.ts +26 -0
- package/dist/retryStatus.js +133 -28
- package/dist/rewindArchiveCapability.js +2 -2
- package/dist/rewindEngineAction.d.ts +2 -0
- package/dist/rewindEngineAction.js +23 -1
- package/dist/rowKind.d.ts +36 -0
- package/dist/rowKind.js +97 -0
- package/dist/ruleCompileVerdict.d.ts +18 -0
- package/dist/ruleCompileVerdict.js +67 -2
- package/dist/ruleReadings.d.ts +58 -0
- package/dist/ruleReadings.js +132 -0
- package/dist/ruleRefusalSentence.d.ts +8 -0
- package/dist/ruleRefusalSentence.js +64 -0
- package/dist/runCancelContext.d.ts +0 -1
- package/dist/runCancelContext.js +1 -2
- package/dist/runTerminal.d.ts +5 -0
- package/dist/runTerminal.js +52 -17
- package/dist/sandboxWire.d.ts +3 -2
- package/dist/sandboxWire.js +59 -27
- package/dist/scenarioRefusal.d.ts +2 -1
- package/dist/scenarioRefusal.js +6 -6
- package/dist/scenarioSkills.d.ts +20 -0
- package/dist/scenarioSkills.js +72 -0
- package/dist/scenarioWire.d.ts +5 -2
- package/dist/scenarioWire.js +9 -9
- package/dist/sealedKeyCapability.js +2 -2
- package/dist/seam.d.ts +26 -9
- package/dist/seam.js +44 -4
- package/dist/seatContract.d.ts +62 -9
- package/dist/seatContract.js +70 -25
- package/dist/selfOrchestrationDenial.js +1 -1
- package/dist/sessionPolicyCapability.js +2 -2
- package/dist/sessionRulesChildrenReadLive.d.ts +6 -0
- package/dist/sessionRulesChildrenReadLive.js +5 -0
- package/dist/sessionRulesNamespaceFormsCapability.d.ts +12 -0
- package/dist/sessionRulesNamespaceFormsCapability.js +29 -0
- package/dist/sessionSyncFileHistoryCapability.js +2 -2
- package/dist/settingsCredentialKeyPaths.d.ts +8 -0
- package/dist/settingsCredentialKeyPaths.js +274 -0
- package/dist/settingsHooksSalvage.d.ts +1 -0
- package/dist/settingsHooksSalvage.js +7 -1
- package/dist/settingsLayerAdmission.d.ts +4 -0
- package/dist/settingsLayerAdmission.js +16 -0
- package/dist/skillToolListsCapability.js +6 -5
- package/dist/skillsWireCaps.d.ts +14 -3
- package/dist/skillsWireCaps.js +48 -18
- package/dist/slashCommandGate.d.ts +24 -0
- package/dist/slashCommandGate.js +74 -0
- package/dist/slashCommandTable.d.ts +14 -0
- package/dist/slashCommandTable.js +99 -0
- package/dist/sqlEngineCapability.js +2 -2
- package/dist/steerPriorityCapability.js +2 -2
- package/dist/storePostureCapability.js +2 -2
- package/dist/subagent/agentStateDetail.js +1 -1
- package/dist/subagent/engineDelegatedPrompt.d.ts +9 -0
- package/dist/subagent/engineDelegatedPrompt.js +38 -7
- package/dist/subagent/engineRowStopGate.js +2 -2
- package/dist/subagent/engineSubagentResume.js +3 -3
- package/dist/subagent/engineTaskHandleWire.d.ts +1 -0
- package/dist/subagent/engineTaskHandleWire.js +10 -0
- package/dist/subagentContentStore.d.ts +1 -0
- package/dist/subagentContentStore.js +135 -27
- package/dist/submitFailure.d.ts +8 -0
- package/dist/submitFailure.js +17 -0
- package/dist/supportFloor.d.ts +1 -0
- package/dist/supportFloor.js +7 -0
- package/dist/terminationIntent.d.ts +55 -0
- package/dist/terminationIntent.js +352 -0
- package/dist/toolHistoryMismatch.d.ts +8 -0
- package/dist/toolHistoryMismatch.js +37 -6
- package/dist/toolResult.d.ts +13 -3
- package/dist/toolResult.js +158 -9
- package/dist/toolResultContent.d.ts +13 -0
- package/dist/toolResultContent.js +82 -7
- package/dist/toolRoster.d.ts +18 -0
- package/dist/toolRoster.js +64 -0
- package/dist/toolsFlagNames.d.ts +8 -0
- package/dist/toolsFlagNames.js +110 -0
- package/dist/turnFailurePresentation.js +41 -96
- package/dist/usageLimitAutoResume.d.ts +74 -0
- package/dist/usageLimitAutoResume.js +227 -0
- package/dist/userAttachmentEnvelope.js +1 -1
- package/dist/userAttachmentSeat.js +5 -5
- package/dist/userInvokedSkillsCapability.js +2 -2
- package/dist/webSearchBackendCapability.js +2 -2
- package/dist/wireErrorTriage.js +99 -50
- package/dist/wireFailureShape.d.ts +25 -1
- package/dist/wireFailureShape.js +92 -5
- package/dist/wireRefusalCopy.d.ts +75 -18
- package/dist/wireRefusalCopy.js +532 -148
- package/dist/wiringFleetDoctor.d.ts +3 -0
- package/dist/wiringFleetDoctor.js +21 -0
- package/dist/workflow.d.ts +2 -1
- package/dist/workflow.js +38 -1
- package/dist/workflowClient.d.ts +2 -7
- package/dist/workflowsJournalCapability.js +2 -2
- package/dist/writeProtectionCapability.js +2 -2
- package/docs/INTEGRATION-CLIENTS.md +1013 -190
- package/package.json +15 -4
|
@@ -10,7 +10,7 @@ const isNumber = (v) => typeof v === 'number';
|
|
|
10
10
|
const nonEmptyString = (v) => typeof v === 'string' && v.length > 0;
|
|
11
11
|
const ownDataValue = (obj, key) => {
|
|
12
12
|
const d = Object.getOwnPropertyDescriptor(obj, key);
|
|
13
|
-
if (d === undefined || 'get'
|
|
13
|
+
if (d === undefined || Object.hasOwn(d, 'get') || Object.hasOwn(d, 'set'))
|
|
14
14
|
return undefined;
|
|
15
15
|
return d.value;
|
|
16
16
|
};
|
|
@@ -30,7 +30,7 @@ function readCrashConvergedRow(v) {
|
|
|
30
30
|
const d = descs[k];
|
|
31
31
|
if (d === undefined || d.enumerable !== true)
|
|
32
32
|
continue;
|
|
33
|
-
if ('get'
|
|
33
|
+
if (Object.hasOwn(d, 'get') || Object.hasOwn(d, 'set')) {
|
|
34
34
|
unstable = true;
|
|
35
35
|
continue;
|
|
36
36
|
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import type { UiLanguage } from '../env/uiLanguage.js';
|
|
2
|
+
import type { CapturedCode } from '../engineWireFor.js';
|
|
3
|
+
import { type ProtocolErrorNameReading } from '../wireFailureShape.js';
|
|
4
|
+
export type DecisionRefusalConflict = 'binding_mismatch' | 'row_integrity' | 'format_version' | 'answer_invalid' | 'grant_changed';
|
|
5
|
+
export declare function decisionConflictOf(err: unknown, captured?: CapturedCode, protocolNameRead?: ProtocolErrorNameReading): DecisionRefusalConflict | undefined;
|
|
3
6
|
export declare const DECISION_ANSWER_INVALID_CONTENT = "The engine rejected the answer itself because it does not fit the question that was asked \u00B7 Nothing was decided and the question is still waiting \u00B7 Correct the answer and send it again";
|
|
7
|
+
export declare function decisionGrantChangedContent(lang?: UiLanguage): string;
|
|
@@ -1,19 +1,31 @@
|
|
|
1
1
|
import { APPROVAL_BINDING_MISMATCH, CHECKPOINT_UNSUPPORTED_VERSION, RESUME_OUTCOME_INVALID } from '../engineErrorCodes.js';
|
|
2
|
+
import { msg, renderMessage } from '../i18n/translate.js';
|
|
2
3
|
import { ownDataField } from '../ownKey.js';
|
|
3
|
-
import { PROTOCOL_ERROR_NAME, protocolErrorNameOf, readRefusalField } from '../wireFailureShape.js';
|
|
4
|
+
import { isSlotCarrier, PROTOCOL_ERROR_NAME, protocolErrorNameOf, readRefusalField } from '../wireFailureShape.js';
|
|
4
5
|
const BINDING_SEAT_FIELDS = new Set(['boundCallId', 'boundInputHash']);
|
|
5
6
|
const ANSWER_FIELD = 'answer';
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
const GRANT_DIGEST_FIELD = 'boundGrantDigest';
|
|
8
|
+
function namedProtocolOf(r) {
|
|
9
|
+
return r.state === 'named' ? r.name : undefined;
|
|
10
|
+
}
|
|
11
|
+
export function decisionConflictOf(err, captured, protocolNameRead) {
|
|
12
|
+
if (!isSlotCarrier(err))
|
|
8
13
|
return undefined;
|
|
9
14
|
let code;
|
|
10
|
-
|
|
11
|
-
|
|
15
|
+
if (captured !== undefined) {
|
|
16
|
+
if (captured.state !== 'read')
|
|
17
|
+
return undefined;
|
|
18
|
+
code = captured.wire;
|
|
12
19
|
}
|
|
13
|
-
|
|
14
|
-
|
|
20
|
+
else {
|
|
21
|
+
try {
|
|
22
|
+
code = ownDataField(err, 'errorCode');
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
15
27
|
}
|
|
16
|
-
const protocolName = protocolErrorNameOf(err);
|
|
28
|
+
const protocolName = protocolNameRead !== undefined ? namedProtocolOf(protocolNameRead) : protocolErrorNameOf(err);
|
|
17
29
|
if (code === CHECKPOINT_UNSUPPORTED_VERSION)
|
|
18
30
|
return 'format_version';
|
|
19
31
|
const bindingFamily = code === APPROVAL_BINDING_MISMATCH || (code === undefined && protocolName === PROTOCOL_ERROR_NAME.ApprovalBindingMismatchError);
|
|
@@ -27,9 +39,12 @@ export function decisionConflictOf(err) {
|
|
|
27
39
|
field = undefined;
|
|
28
40
|
}
|
|
29
41
|
if (code === RESUME_OUTCOME_INVALID)
|
|
30
|
-
return field === ANSWER_FIELD ? 'answer_invalid' : undefined;
|
|
42
|
+
return field === ANSWER_FIELD ? 'answer_invalid' : field === GRANT_DIGEST_FIELD ? 'grant_changed' : undefined;
|
|
31
43
|
if (field === undefined)
|
|
32
44
|
return 'row_integrity';
|
|
33
45
|
return BINDING_SEAT_FIELDS.has(field) ? 'binding_mismatch' : undefined;
|
|
34
46
|
}
|
|
35
47
|
export const DECISION_ANSWER_INVALID_CONTENT = 'The engine rejected the answer itself because it does not fit the question that was asked · Nothing was decided and the question is still waiting · Correct the answer and send it again';
|
|
48
|
+
export function decisionGrantChangedContent(lang) {
|
|
49
|
+
return renderMessage(msg('approval.decision.grantChanged'), lang);
|
|
50
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export declare const DECISION_LEDGER_FAMILIES: readonly ["plan_review", "tool_approval", "elicitation"];
|
|
2
|
+
export type DecisionLedgerFamily = (typeof DECISION_LEDGER_FAMILIES)[number];
|
|
3
|
+
export type DecisionLedgerPhase = 'handed' | 'posting' | 'landed';
|
|
4
|
+
export type DecisionLedgerSettler = 'host' | 'package' | 'gate_left';
|
|
5
|
+
export interface DecisionLedgerOp {
|
|
6
|
+
readonly family: DecisionLedgerFamily;
|
|
7
|
+
keys: readonly string[];
|
|
8
|
+
readonly handedAt: number;
|
|
9
|
+
settledAt: number | null;
|
|
10
|
+
settler: DecisionLedgerSettler | null;
|
|
11
|
+
phase: DecisionLedgerPhase;
|
|
12
|
+
notApplied: boolean;
|
|
13
|
+
ownCallOpen: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface DecisionLedgerIdentityParts {
|
|
16
|
+
readonly taskId?: string | undefined;
|
|
17
|
+
readonly planTaskId?: string | undefined;
|
|
18
|
+
readonly approvalId?: string | undefined;
|
|
19
|
+
readonly callId?: string | undefined;
|
|
20
|
+
readonly askId?: string | undefined;
|
|
21
|
+
readonly elicitationId?: string | undefined;
|
|
22
|
+
}
|
|
23
|
+
export declare function decisionLedgerKeysOf(parts: DecisionLedgerIdentityParts): string[];
|
|
24
|
+
export declare function planDecisionKey(taskId: string): string;
|
|
25
|
+
export declare function nextDecisionLedgerTick(): number;
|
|
26
|
+
export declare function decisionOpsWithKey(family: DecisionLedgerFamily, key: string): DecisionLedgerOp[];
|
|
27
|
+
export declare function decisionOpsOfFamily(family: DecisionLedgerFamily): readonly DecisionLedgerOp[];
|
|
28
|
+
export declare function openDecisionOp(family: DecisionLedgerFamily, keys: readonly string[], phase: DecisionLedgerPhase, ownCallOpen: boolean): DecisionLedgerOp;
|
|
29
|
+
export declare function settleDecisionOp(op: DecisionLedgerOp, by: DecisionLedgerSettler): void;
|
|
30
|
+
export declare function closeDecisionOp(op: DecisionLedgerOp, by: DecisionLedgerSettler): void;
|
|
31
|
+
export declare function addDecisionOpKeys(op: DecisionLedgerOp, keys: readonly string[]): void;
|
|
32
|
+
export declare function dropDecisionOp(op: DecisionLedgerOp): void;
|
|
33
|
+
export declare function markLatestDecisionNotApplied(family: DecisionLedgerFamily, key: string): void;
|
|
34
|
+
export declare function settleDecisionOpsOnGateLeft(family: DecisionLedgerFamily, key: string): void;
|
|
35
|
+
export declare function latestDecisionHandedMark(family: DecisionLedgerFamily, key: string): number | null;
|
|
36
|
+
export declare function readMarkOf(v: number | undefined): number | undefined;
|
|
37
|
+
export declare function decisionKeyInFlight(key: string, mark: number | undefined): boolean;
|
|
38
|
+
export type DecisionIdentity = {
|
|
39
|
+
readonly gate: 'plan_review';
|
|
40
|
+
readonly taskId: string;
|
|
41
|
+
} | {
|
|
42
|
+
readonly gate: 'tool_approval';
|
|
43
|
+
readonly approvalId?: string;
|
|
44
|
+
readonly callId?: string;
|
|
45
|
+
readonly askId?: string;
|
|
46
|
+
} | {
|
|
47
|
+
readonly gate: 'elicitation';
|
|
48
|
+
readonly elicitationId: string;
|
|
49
|
+
} | {
|
|
50
|
+
readonly gate: 'run';
|
|
51
|
+
readonly taskId: string;
|
|
52
|
+
};
|
|
53
|
+
export declare function decisionInFlightOf(identity: DecisionIdentity, readMark?: number): boolean;
|
|
54
|
+
export declare function decisionReadMark(): number;
|
|
55
|
+
export declare function __resetDecisionLedgerForTests(family?: DecisionLedgerFamily): void;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { guardedRead, readOwnDataNonEmptyString } from '../ownKey.js';
|
|
2
|
+
export const DECISION_LEDGER_FAMILIES = Object.freeze(['plan_review', 'tool_approval', 'elicitation']);
|
|
3
|
+
const FAMILY_CAPACITY = Object.freeze({ plan_review: 32, tool_approval: 64, elicitation: 64 });
|
|
4
|
+
const KEY_PREFIX = Object.freeze({ run: 'run\u0000', plan: 'plan\u0000', approval: 'approval\u0000', call: 'call\u0000', ask: 'ask\u0000', elicitation: 'elicitation\u0000' });
|
|
5
|
+
const nonEmpty = (v) => typeof v === 'string' && v !== '';
|
|
6
|
+
export function decisionLedgerKeysOf(parts) {
|
|
7
|
+
const out = [];
|
|
8
|
+
const add = (prefix, v) => {
|
|
9
|
+
if (nonEmpty(v) && !out.includes(prefix + v))
|
|
10
|
+
out.push(prefix + v);
|
|
11
|
+
};
|
|
12
|
+
add(KEY_PREFIX.run, parts.taskId);
|
|
13
|
+
add(KEY_PREFIX.plan, parts.planTaskId);
|
|
14
|
+
add(KEY_PREFIX.approval, parts.approvalId);
|
|
15
|
+
add(KEY_PREFIX.call, parts.callId);
|
|
16
|
+
add(KEY_PREFIX.ask, parts.askId);
|
|
17
|
+
add(KEY_PREFIX.elicitation, parts.elicitationId);
|
|
18
|
+
return out;
|
|
19
|
+
}
|
|
20
|
+
export function planDecisionKey(taskId) {
|
|
21
|
+
return KEY_PREFIX.plan + taskId;
|
|
22
|
+
}
|
|
23
|
+
const ledger = Object.freeze({ plan_review: [], tool_approval: [], elicitation: [] });
|
|
24
|
+
let ledgerClock = 0;
|
|
25
|
+
export function nextDecisionLedgerTick() {
|
|
26
|
+
return ++ledgerClock;
|
|
27
|
+
}
|
|
28
|
+
export function decisionOpsWithKey(family, key) {
|
|
29
|
+
return ledger[family].filter((op) => op.keys.includes(key));
|
|
30
|
+
}
|
|
31
|
+
export function decisionOpsOfFamily(family) {
|
|
32
|
+
return ledger[family];
|
|
33
|
+
}
|
|
34
|
+
export function openDecisionOp(family, keys, phase, ownCallOpen) {
|
|
35
|
+
const op = {
|
|
36
|
+
family,
|
|
37
|
+
keys: Object.freeze([...keys]),
|
|
38
|
+
handedAt: ++ledgerClock,
|
|
39
|
+
settledAt: null,
|
|
40
|
+
settler: null,
|
|
41
|
+
phase,
|
|
42
|
+
notApplied: false,
|
|
43
|
+
ownCallOpen,
|
|
44
|
+
};
|
|
45
|
+
const rows = ledger[family];
|
|
46
|
+
rows.push(op);
|
|
47
|
+
while (rows.length > FAMILY_CAPACITY[family]) {
|
|
48
|
+
let victim = rows.findIndex((o) => o.settledAt !== null && !o.ownCallOpen);
|
|
49
|
+
if (victim < 0)
|
|
50
|
+
victim = rows.findIndex((o) => o !== op && o.phase === 'handed' && !o.ownCallOpen);
|
|
51
|
+
if (victim < 0)
|
|
52
|
+
break;
|
|
53
|
+
rows.splice(victim, 1);
|
|
54
|
+
}
|
|
55
|
+
return op;
|
|
56
|
+
}
|
|
57
|
+
export function settleDecisionOp(op, by) {
|
|
58
|
+
if (op.settledAt !== null)
|
|
59
|
+
return;
|
|
60
|
+
op.settledAt = ++ledgerClock;
|
|
61
|
+
op.settler = by;
|
|
62
|
+
}
|
|
63
|
+
export function closeDecisionOp(op, by) {
|
|
64
|
+
if (op.phase === 'posting')
|
|
65
|
+
op.phase = 'landed';
|
|
66
|
+
settleDecisionOp(op, by);
|
|
67
|
+
op.ownCallOpen = false;
|
|
68
|
+
}
|
|
69
|
+
export function addDecisionOpKeys(op, keys) {
|
|
70
|
+
const extra = keys.filter((k) => !op.keys.includes(k));
|
|
71
|
+
if (extra.length > 0)
|
|
72
|
+
op.keys = Object.freeze([...op.keys, ...extra]);
|
|
73
|
+
}
|
|
74
|
+
export function dropDecisionOp(op) {
|
|
75
|
+
const rows = ledger[op.family];
|
|
76
|
+
const i = rows.indexOf(op);
|
|
77
|
+
if (i >= 0)
|
|
78
|
+
rows.splice(i, 1);
|
|
79
|
+
}
|
|
80
|
+
export function markLatestDecisionNotApplied(family, key) {
|
|
81
|
+
const ops = decisionOpsWithKey(family, key);
|
|
82
|
+
if (ops.some((op) => op.settledAt === null))
|
|
83
|
+
return;
|
|
84
|
+
let latest;
|
|
85
|
+
for (const op of ops)
|
|
86
|
+
if (latest === undefined || op.handedAt > latest.handedAt)
|
|
87
|
+
latest = op;
|
|
88
|
+
if (latest !== undefined)
|
|
89
|
+
latest.notApplied = true;
|
|
90
|
+
}
|
|
91
|
+
export function settleDecisionOpsOnGateLeft(family, key) {
|
|
92
|
+
for (const op of decisionOpsWithKey(family, key))
|
|
93
|
+
settleDecisionOp(op, 'gate_left');
|
|
94
|
+
}
|
|
95
|
+
export function latestDecisionHandedMark(family, key) {
|
|
96
|
+
let mark = null;
|
|
97
|
+
for (const op of decisionOpsWithKey(family, key))
|
|
98
|
+
if (mark === null || op.handedAt > mark)
|
|
99
|
+
mark = op.handedAt;
|
|
100
|
+
return mark;
|
|
101
|
+
}
|
|
102
|
+
function anyInFlight(keys, mark) {
|
|
103
|
+
if (keys.length === 0)
|
|
104
|
+
return false;
|
|
105
|
+
for (const family of DECISION_LEDGER_FAMILIES) {
|
|
106
|
+
for (const op of ledger[family]) {
|
|
107
|
+
if (!op.keys.some((k) => keys.includes(k)))
|
|
108
|
+
continue;
|
|
109
|
+
if (op.settledAt === null)
|
|
110
|
+
return true;
|
|
111
|
+
if (mark !== undefined && op.settledAt > mark && !op.notApplied)
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
export function readMarkOf(v) {
|
|
118
|
+
return typeof v === 'number' && Number.isFinite(v) ? v : undefined;
|
|
119
|
+
}
|
|
120
|
+
export function decisionKeyInFlight(key, mark) {
|
|
121
|
+
return anyInFlight([key], mark);
|
|
122
|
+
}
|
|
123
|
+
function queryKeysOf(identity) {
|
|
124
|
+
if (typeof identity !== 'object' || identity === null)
|
|
125
|
+
return [];
|
|
126
|
+
const gate = guardedRead(() => readOwnDataNonEmptyString(identity, 'gate'));
|
|
127
|
+
const s = (key) => guardedRead(() => readOwnDataNonEmptyString(identity, key));
|
|
128
|
+
switch (gate) {
|
|
129
|
+
case 'plan_review':
|
|
130
|
+
return decisionLedgerKeysOf({ planTaskId: s('taskId') });
|
|
131
|
+
case 'run':
|
|
132
|
+
return decisionLedgerKeysOf({ taskId: s('taskId') });
|
|
133
|
+
case 'tool_approval':
|
|
134
|
+
return decisionLedgerKeysOf({ approvalId: s('approvalId'), callId: s('callId'), askId: s('askId') });
|
|
135
|
+
case 'elicitation':
|
|
136
|
+
return decisionLedgerKeysOf({ elicitationId: s('elicitationId') });
|
|
137
|
+
default:
|
|
138
|
+
return [];
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
export function decisionInFlightOf(identity, readMark) {
|
|
142
|
+
try {
|
|
143
|
+
return anyInFlight(queryKeysOf(identity), readMarkOf(readMark));
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
export function decisionReadMark() {
|
|
150
|
+
return ++ledgerClock;
|
|
151
|
+
}
|
|
152
|
+
export function __resetDecisionLedgerForTests(family) {
|
|
153
|
+
for (const f of DECISION_LEDGER_FAMILIES)
|
|
154
|
+
if (family === undefined || f === family)
|
|
155
|
+
ledger[f].length = 0;
|
|
156
|
+
}
|
|
@@ -1,23 +1,30 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type UiLanguage } from '../env/uiLanguage.js';
|
|
2
|
+
import { type GateCurrentPending, type RefusalCarrier } from './hitlBridge.js';
|
|
2
3
|
import { type DecisionRefusalConflict } from './decisionConflict.js';
|
|
3
|
-
import { type ProtocolErrorName } from '../wireFailureShape.js';
|
|
4
|
-
import {
|
|
4
|
+
import { type ProtocolErrorName, type ProtocolErrorNameReading } from '../wireFailureShape.js';
|
|
5
|
+
import type { DenyAttributionRefusalDetail } from '../wireRefusalCopy.js';
|
|
6
|
+
import { type DeliveredReading } from './attributionLadder.js';
|
|
7
|
+
import { type AnswerCapture, type UnansweredCapture } from '../engineWireFor.js';
|
|
8
|
+
export declare const ASK_DECIDED_CODE = "conflict.ask_decided";
|
|
5
9
|
export type DecisionRefusalStanding = 'settled-elsewhere' | 'ambiguous' | 'refused-pending';
|
|
6
10
|
export type { DecisionRefusalConflict } from './decisionConflict.js';
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
export { refusalCarrierOf, type RefusalCarrier } from './hitlBridge.js';
|
|
12
|
+
declare const DELIVERED_UNREADABLE: unique symbol;
|
|
13
|
+
type DeliveredAnswer = AnswerCapture | UnansweredCapture | typeof DELIVERED_UNREADABLE;
|
|
14
|
+
interface CarrierRead extends RefusalCarrier {
|
|
15
|
+
readonly protocolName: ProtocolErrorNameReading;
|
|
10
16
|
}
|
|
11
|
-
export declare function refusalCarrierOf(err: {} | null | undefined): RefusalCarrier;
|
|
12
17
|
export interface RefusalRouteContext {
|
|
13
18
|
readonly route?: 'approval_decide' | 'live_respond' | 'ask_decide' | 'plan_review' | 'compact';
|
|
19
|
+
readonly afterRetry?: true;
|
|
14
20
|
}
|
|
21
|
+
export declare function notPendingAfterRetry(status: number | undefined, retried: boolean): boolean;
|
|
15
22
|
export interface RefusalDelivery {
|
|
16
23
|
readonly delivery: 'refused' | 'ambiguous' | 'no_answer';
|
|
17
24
|
readonly status?: number;
|
|
18
25
|
readonly errorCode?: string;
|
|
19
26
|
}
|
|
20
|
-
export declare function refusalDeliveryOf(err: {} | null | undefined, context?: RefusalRouteContext): RefusalDelivery;
|
|
27
|
+
export declare function refusalDeliveryOf(err: {} | null | undefined, context?: RefusalRouteContext, answer?: DeliveredAnswer, read?: RefusalCarrier): RefusalDelivery;
|
|
21
28
|
export declare function decisionRefusalSaysAskGone(err: unknown): boolean;
|
|
22
29
|
export type DecisionRefusalAskReading = 'settled' | 'not_settled' | 'unreadable';
|
|
23
30
|
interface DecisionRefusalAskFacts {
|
|
@@ -25,7 +32,7 @@ interface DecisionRefusalAskFacts {
|
|
|
25
32
|
readonly gateMoved: boolean;
|
|
26
33
|
readonly wordingHint: boolean;
|
|
27
34
|
}
|
|
28
|
-
export declare function readDecisionRefusalAsk(failure: unknown): DecisionRefusalAskFacts;
|
|
35
|
+
export declare function readDecisionRefusalAsk(failure: unknown, answer?: DeliveredAnswer, read?: CarrierRead): DecisionRefusalAskFacts;
|
|
29
36
|
export declare function decisionRefusalAskReading(failure: unknown): DecisionRefusalAskReading;
|
|
30
37
|
export interface DecisionRefusalReading {
|
|
31
38
|
readonly status?: number;
|
|
@@ -46,8 +53,9 @@ export interface DecisionRefusalReading {
|
|
|
46
53
|
readonly standing?: DecisionRefusalStanding;
|
|
47
54
|
readonly transient?: true;
|
|
48
55
|
readonly conflict?: DecisionRefusalConflict;
|
|
56
|
+
readonly unrecoverable?: true;
|
|
49
57
|
}
|
|
50
|
-
export declare function mintDecisionRefusalReading(err: {} | null | undefined, context?: RefusalRouteContext, attributionCarried?: boolean): DecisionRefusalReading;
|
|
58
|
+
export declare function mintDecisionRefusalReading(err: {} | null | undefined, context?: RefusalRouteContext, attributionCarried?: boolean, delivered?: DeliveredReading, carried?: RefusalCarrier): DecisionRefusalReading;
|
|
51
59
|
export declare function readDecisionRefusalReading(err: {} | null | undefined, context?: RefusalRouteContext): DecisionRefusalReading;
|
|
52
60
|
export interface DecisionRefusalClassified {
|
|
53
61
|
readonly standing: DecisionRefusalStanding;
|
|
@@ -55,8 +63,10 @@ export interface DecisionRefusalClassified {
|
|
|
55
63
|
readonly errorCode?: string;
|
|
56
64
|
readonly transient?: true;
|
|
57
65
|
readonly conflict?: DecisionRefusalConflict;
|
|
66
|
+
readonly unrecoverable?: true;
|
|
58
67
|
}
|
|
59
68
|
export declare function classifyDecisionRefusal(err: unknown, context?: RefusalRouteContext): DecisionRefusalClassified | undefined;
|
|
69
|
+
export declare function classifyDeliveredDecisionRefusal(err: {} | null | undefined, delivered: DeliveredReading): DecisionRefusalClassified | undefined;
|
|
60
70
|
export type LiveAskPendingReading = 'pending' | 'not_pending' | 'unknown';
|
|
61
71
|
export declare function liveAskPendingReading(envelope: unknown, approvalId: string): LiveAskPendingReading;
|
|
62
72
|
export declare function decisionRefusalClosesOut(refusal: DecisionRefusalClassified | undefined, pending: LiveAskPendingReading): boolean;
|
|
@@ -68,3 +78,4 @@ export interface UndeliverableDecisionFacts {
|
|
|
68
78
|
readonly runId?: string;
|
|
69
79
|
}
|
|
70
80
|
export declare function undeliverableDecisionContent(facts: UndeliverableDecisionFacts): string;
|
|
81
|
+
export declare function decideRowUnrevivableNotice(lang?: UiLanguage | (string & {})): string;
|
|
@@ -1,25 +1,32 @@
|
|
|
1
|
-
import { ASK_GONE, ASK_GONE_PARKED, RESUME_PREFLIGHT_REJECTED, isDecideAlreadyResolvedCode, isDecideParkMovedCode, refusalRetriableReading, refusalSaysStillPending } from '../engineErrorCodes.js';
|
|
1
|
+
import { ASK_GONE, ASK_GONE_PARKED, RESUME_PREFLIGHT_REJECTED, isDecideAlreadyResolvedCode, isDecideParkMovedCode, isDecideRowUnrevivableCode, refusalRetriableReading, refusalSaysStillPending } from '../engineErrorCodes.js';
|
|
2
|
+
import { isUiLanguage } from '../env/uiLanguage.js';
|
|
3
|
+
import { msg, renderMessage } from '../i18n/translate.js';
|
|
2
4
|
import { notPendingCauseReading, refusalCauseWordOf } from './approvalEndingCause.js';
|
|
3
|
-
import { GATE_FAILURE_CODES, readDecideCurrentPending, readWireCodes } from './hitlBridge.js';
|
|
5
|
+
import { GATE_FAILURE_CODES, readDecideCurrentPending, readWireCodes, refusalCarrierOf } from './hitlBridge.js';
|
|
4
6
|
import { isAlreadyResolvedGateReason, isCodeClassifiedGateFailure } from './parkResolver.js';
|
|
5
7
|
import { decisionConflictOf } from './decisionConflict.js';
|
|
6
8
|
import { readLivePendingRows } from './livePendingAsk.js';
|
|
7
9
|
import { guardedRead, ownDataField, readOwnDataValue } from '../ownKey.js';
|
|
8
|
-
import { PROTOCOL_ERROR_NAME, isDisplayableWireCode, protocolErrorNameReading, readErrorRecord, readRefusalField } from '../wireFailureShape.js';
|
|
9
|
-
import {
|
|
10
|
-
|
|
10
|
+
import { PROTOCOL_ERROR_NAME, THROWN_SLOT_UNREADABLE, isDisplayableWireCode, isSlotCarrier, ownFoldedCodeBitsOf, protocolErrorNameReading, readErrorRecord, readRefusalField, readThrownSlot } from '../wireFailureShape.js';
|
|
11
|
+
import { attributionRefusalOf, carrierReadOf } from './attributionLadder.js';
|
|
12
|
+
import { CODE_UNREADABLE, ownReadingSlot } from '../engineWireFor.js';
|
|
13
|
+
export const ASK_DECIDED_CODE = 'conflict.ask_decided';
|
|
11
14
|
const TRANSIENT_STATUSES = new Set([408, 425, 429, 502, 503, 504]);
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
export { refusalCarrierOf } from './hitlBridge.js';
|
|
16
|
+
const DELIVERED_UNREADABLE = Symbol('delivered-answer-unreadable');
|
|
17
|
+
function deliveredAnswerOf(delivered, carrier) {
|
|
18
|
+
if (delivered === undefined)
|
|
19
|
+
return undefined;
|
|
20
|
+
const a = ownReadingSlot(delivered, 'answered') ?? ownReadingSlot(delivered, 'unanswered');
|
|
21
|
+
return a !== undefined && a.layer === carrier ? a : DELIVERED_UNREADABLE;
|
|
22
|
+
}
|
|
23
|
+
const PROTOCOL_NAME_ABSENT = Object.freeze({ state: 'absent' });
|
|
24
|
+
const PROTOCOL_NAME_UNREADABLE = Object.freeze({ state: 'unreadable' });
|
|
25
|
+
function capturedCodeOf(answer) {
|
|
26
|
+
return answer === undefined ? undefined : answer === DELIVERED_UNREADABLE ? CODE_UNREADABLE : answer.code;
|
|
27
|
+
}
|
|
28
|
+
export function notPendingAfterRetry(status, retried) {
|
|
29
|
+
return retried && (status === 404 || status === 410);
|
|
23
30
|
}
|
|
24
31
|
const ROUTE_WORDS = { approval_decide: true, live_respond: true, ask_decide: true, plan_review: true, compact: true };
|
|
25
32
|
const REFUSAL_ROUTES = Object.freeze(Object.keys(ROUTE_WORDS));
|
|
@@ -35,17 +42,19 @@ function routeOf(context) {
|
|
|
35
42
|
return typeof r === 'string' && REFUSAL_ROUTES.includes(r) ? r : undefined;
|
|
36
43
|
}
|
|
37
44
|
function carrierStatus(carrier) {
|
|
38
|
-
const raw =
|
|
45
|
+
const raw = isSlotCarrier(carrier) ? readThrownSlot(carrier, 'status', 'data') : undefined;
|
|
39
46
|
return typeof raw === 'number' && Number.isFinite(raw) ? raw : undefined;
|
|
40
47
|
}
|
|
41
|
-
function carrierCode(carrier) {
|
|
42
|
-
|
|
48
|
+
function carrierCode(carrier, captured) {
|
|
49
|
+
if (captured !== undefined)
|
|
50
|
+
return captured.state === 'read' ? captured.wire : undefined;
|
|
51
|
+
const raw = isSlotCarrier(carrier) ? readThrownSlot(carrier, 'errorCode', 'data') : undefined;
|
|
43
52
|
return typeof raw === 'string' && raw.length > 0 ? raw : undefined;
|
|
44
53
|
}
|
|
45
|
-
export function refusalDeliveryOf(err, context) {
|
|
46
|
-
const { carrier } = refusalCarrierOf(err);
|
|
47
|
-
const status = carrierStatus(carrier);
|
|
48
|
-
const errorCode = carrierCode(carrier);
|
|
54
|
+
export function refusalDeliveryOf(err, context, answer, read) {
|
|
55
|
+
const { carrier } = read ?? refusalCarrierOf(err);
|
|
56
|
+
const status = answer === undefined ? carrierStatus(carrier) : answer === DELIVERED_UNREADABLE ? undefined : answer.status;
|
|
57
|
+
const errorCode = carrierCode(carrier, capturedCodeOf(answer));
|
|
49
58
|
const facts = { ...(status !== undefined ? { status } : {}), ...(errorCode !== undefined ? { errorCode } : {}) };
|
|
50
59
|
if (status === undefined || !Number.isInteger(status) || status < 400 || status > 599)
|
|
51
60
|
return { delivery: 'no_answer', ...facts };
|
|
@@ -61,6 +70,9 @@ export function decisionRefusalSaysAskGone(err) {
|
|
|
61
70
|
return readDecisionRefusalAsk(err).reading === 'settled';
|
|
62
71
|
}
|
|
63
72
|
const facts = (reading, gateMoved = false, wordingHint = false) => ({ reading, gateMoved, wordingHint });
|
|
73
|
+
const codeUnreadable = () => {
|
|
74
|
+
throw new TypeError('status or errorCode was unreadable when this failure was first read');
|
|
75
|
+
};
|
|
64
76
|
function preflightSettledBitsPresent(carrier) {
|
|
65
77
|
const detail = guardedRead(() => readErrorRecord(carrier, 'detail'));
|
|
66
78
|
if (detail === undefined)
|
|
@@ -96,28 +108,31 @@ function askFactsOfResolution(r) {
|
|
|
96
108
|
return facts('unreadable');
|
|
97
109
|
}
|
|
98
110
|
}
|
|
99
|
-
export function readDecisionRefusalAsk(failure) {
|
|
100
|
-
if (
|
|
111
|
+
export function readDecisionRefusalAsk(failure, answer, read) {
|
|
112
|
+
if (!isSlotCarrier(failure))
|
|
101
113
|
return facts('not_settled');
|
|
102
|
-
if (isResolutionShaped(failure))
|
|
114
|
+
if (answer === undefined && isResolutionShaped(failure))
|
|
103
115
|
return askFactsOfResolution(failure);
|
|
104
|
-
const
|
|
116
|
+
const r = read ?? refusalCarrierOf(failure);
|
|
117
|
+
const local = ownReadingSlot(r, 'local');
|
|
118
|
+
const carrier = r.carrier;
|
|
105
119
|
if (local !== undefined)
|
|
106
120
|
return facts(local === 'no_pending' ? 'settled' : 'not_settled');
|
|
107
|
-
if (
|
|
121
|
+
if (!isSlotCarrier(carrier))
|
|
108
122
|
return facts('not_settled');
|
|
109
123
|
let localCode, name, protocolName, errorCode, status, retriable, text;
|
|
110
124
|
try {
|
|
111
125
|
const slot = (key) => ownDataField(carrier, key);
|
|
112
126
|
const closed = (v) => (typeof v === 'string' && GATE_FAILURE_CODES.includes(v) ? v : undefined);
|
|
113
|
-
localCode = closed(slot('code'));
|
|
127
|
+
localCode = closed(answer === undefined ? slot('code') : answer === DELIVERED_UNREADABLE || answer.localCode === THROWN_SLOT_UNREADABLE ? codeUnreadable() : answer.localCode);
|
|
114
128
|
name = slot('name');
|
|
115
|
-
const pn = protocolErrorNameReading(carrier);
|
|
129
|
+
const pn = read !== undefined ? read.protocolName : protocolErrorNameReading(carrier);
|
|
116
130
|
if (pn.state === 'unreadable')
|
|
117
131
|
throw new TypeError('protocol name unreadable');
|
|
118
132
|
protocolName = pn.state === 'named' ? pn.name : undefined;
|
|
119
|
-
|
|
120
|
-
|
|
133
|
+
const captured = capturedCodeOf(answer);
|
|
134
|
+
errorCode = captured === undefined ? slot('errorCode') : captured.state === 'read' ? captured.wire : codeUnreadable();
|
|
135
|
+
status = answer === undefined ? slot('status') : answer === DELIVERED_UNREADABLE ? codeUnreadable() : answer.status;
|
|
121
136
|
retriable = refusalRetriableReading(carrier);
|
|
122
137
|
text = String(carrier);
|
|
123
138
|
}
|
|
@@ -152,7 +167,7 @@ export function decisionRefusalAskReading(failure) {
|
|
|
152
167
|
}
|
|
153
168
|
const USELESS_REFUSAL_TEXTS = new Set(['[object Object]', 'null', 'undefined', '']);
|
|
154
169
|
function refusalTextOf(err) {
|
|
155
|
-
const message =
|
|
170
|
+
const message = isSlotCarrier(err) ? guardedRead(() => err.message) : undefined;
|
|
156
171
|
if (typeof message === 'string' && message.length > 0)
|
|
157
172
|
return message;
|
|
158
173
|
if (typeof err === 'string' && err.length > 0)
|
|
@@ -169,27 +184,49 @@ function refusalTextOf(err) {
|
|
|
169
184
|
function isolated(read) {
|
|
170
185
|
return guardedRead(read);
|
|
171
186
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
187
|
+
function wireCodesOfPinned(captured) {
|
|
188
|
+
if (captured.state !== 'read' || captured.wire === undefined)
|
|
189
|
+
return {};
|
|
190
|
+
return { errorCode: captured.wire, ...(captured.blockedBy !== undefined ? { blockedBy: captured.blockedBy } : {}) };
|
|
191
|
+
}
|
|
192
|
+
export function mintDecisionRefusalReading(err, context, attributionCarried, delivered, carried) {
|
|
193
|
+
const carrierRead = carried ?? carrierReadOf(err, delivered);
|
|
194
|
+
const { carrier } = carrierRead;
|
|
195
|
+
const obj = isSlotCarrier(carrier) ? carrier : undefined;
|
|
196
|
+
const answer = deliveredAnswerOf(delivered, carrier);
|
|
197
|
+
const captured = capturedCodeOf(answer);
|
|
198
|
+
const status = answer === undefined ? carrierStatus(carrier) : answer === DELIVERED_UNREADABLE ? undefined : answer.status;
|
|
199
|
+
const wire = captured !== undefined ? wireCodesOfPinned(captured) : obj !== undefined ? isolated(() => readWireCodes(obj)) : undefined;
|
|
200
|
+
const wireBits = ownFoldedCodeBitsOf(wire);
|
|
201
|
+
const errorCode = wireBits.errorCode ?? carrierCode(carrier, captured);
|
|
202
|
+
const blockedBy = wireBits.blockedBy;
|
|
178
203
|
const message = isolated(() => refusalTextOf(carrier));
|
|
179
204
|
const retriable = obj !== undefined && isolated(() => refusalSaysStillPending(obj)) === true;
|
|
180
|
-
const pn = obj !== undefined ? isolated(() => protocolErrorNameReading(obj)) :
|
|
181
|
-
const protocolName = pn
|
|
205
|
+
const pn = obj !== undefined ? (isolated(() => protocolErrorNameReading(obj)) ?? PROTOCOL_NAME_UNREADABLE) : PROTOCOL_NAME_ABSENT;
|
|
206
|
+
const protocolName = pn.state === 'named' ? pn.name : undefined;
|
|
182
207
|
const cause = obj !== undefined ? isolated(() => refusalCauseWordOf(obj)) : undefined;
|
|
183
208
|
const field = obj !== undefined ? isolated(() => readRefusalField(obj)) : undefined;
|
|
184
209
|
const currentPending = obj !== undefined ? isolated(() => readDecideCurrentPending(obj)) : undefined;
|
|
185
|
-
const attribution = attributionCarried
|
|
186
|
-
const ask = readDecisionRefusalAsk(err);
|
|
187
|
-
const delivery = refusalDeliveryOf(err, context);
|
|
188
|
-
const
|
|
210
|
+
const attribution = attributionCarried === undefined ? undefined : isolated(() => attributionRefusalOf(carrierRead, delivered ?? 'carrier', attributionCarried));
|
|
211
|
+
const ask = readDecisionRefusalAsk(err, answer, { ...carrierRead, protocolName: pn });
|
|
212
|
+
const delivery = refusalDeliveryOf(err, context, answer, carrierRead);
|
|
213
|
+
const unknownAfterRetry = guardedRead(() => (typeof context === 'object' && context !== null ? readOwnDataValue(context, 'afterRetry') : undefined)) === true && notPendingAfterRetry(status, true);
|
|
214
|
+
const standing = delivery.delivery === 'no_answer'
|
|
215
|
+
? undefined
|
|
216
|
+
: unknownAfterRetry
|
|
217
|
+
? 'ambiguous'
|
|
218
|
+
: ask.reading === 'settled'
|
|
219
|
+
? 'settled-elsewhere'
|
|
220
|
+
: delivery.delivery === 'refused'
|
|
221
|
+
? 'refused-pending'
|
|
222
|
+
: 'ambiguous';
|
|
189
223
|
const inRange = standing !== undefined && status !== undefined;
|
|
224
|
+
const conflict = inRange && status === 409 && obj !== undefined ? isolated(() => decisionConflictOf(obj, captured, pn)) : undefined;
|
|
225
|
+
const unrecoverable = inRange && status !== undefined && Number.isInteger(status) && status >= 400 && status <= 599 && isDecideRowUnrevivableCode(errorCode);
|
|
190
226
|
const transient = inRange &&
|
|
227
|
+
conflict !== 'grant_changed' &&
|
|
228
|
+
!unrecoverable &&
|
|
191
229
|
(TRANSIENT_STATUSES.has(status) || retriable || (status === 404 && obj !== undefined && isolated(() => notPendingCauseReading(obj)) === 'other_replica'));
|
|
192
|
-
const conflict = inRange && status === 409 && obj !== undefined ? isolated(() => decisionConflictOf(obj)) : undefined;
|
|
193
230
|
return Object.freeze({
|
|
194
231
|
...(status !== undefined ? { status } : {}),
|
|
195
232
|
...(errorCode !== undefined ? { errorCode } : {}),
|
|
@@ -197,7 +234,7 @@ export function mintDecisionRefusalReading(err, context, attributionCarried) {
|
|
|
197
234
|
...(retriable ? { retriable: true } : {}),
|
|
198
235
|
...(protocolName !== undefined ? { protocolName } : {}),
|
|
199
236
|
...(cause !== undefined || field !== undefined ? { extra: Object.freeze({ ...(cause !== undefined ? { cause } : {}), ...(field !== undefined ? { field } : {}) }) } : {}),
|
|
200
|
-
...(
|
|
237
|
+
...(blockedBy !== undefined ? { blockedBy } : {}),
|
|
201
238
|
...(currentPending !== undefined ? { currentPending } : {}),
|
|
202
239
|
...(attribution !== undefined && attribution !== null ? { denyAttributionRefusal: attribution } : {}),
|
|
203
240
|
ask: ask.reading,
|
|
@@ -206,6 +243,7 @@ export function mintDecisionRefusalReading(err, context, attributionCarried) {
|
|
|
206
243
|
...(standing !== undefined ? { standing } : {}),
|
|
207
244
|
...(transient ? { transient: true } : {}),
|
|
208
245
|
...(conflict !== undefined ? { conflict } : {}),
|
|
246
|
+
...(unrecoverable ? { unrecoverable: true } : {}),
|
|
209
247
|
});
|
|
210
248
|
}
|
|
211
249
|
export function readDecisionRefusalReading(err, context) {
|
|
@@ -223,12 +261,14 @@ function classifiedOf(reading) {
|
|
|
223
261
|
const errorCode = typeof code === 'string' && isDisplayableWireCode(code) ? code : undefined;
|
|
224
262
|
const transient = ownDataField(reading, 'transient') === true;
|
|
225
263
|
const conflict = ownDataField(reading, 'conflict');
|
|
264
|
+
const unrecoverable = ownDataField(reading, 'unrecoverable') === true;
|
|
226
265
|
return Object.freeze({
|
|
227
266
|
standing,
|
|
228
267
|
status,
|
|
229
268
|
...(errorCode !== undefined ? { errorCode } : {}),
|
|
230
269
|
...(transient ? { transient: true } : {}),
|
|
231
270
|
...(typeof conflict === 'string' ? { conflict: conflict } : {}),
|
|
271
|
+
...(unrecoverable ? { unrecoverable: true } : {}),
|
|
232
272
|
});
|
|
233
273
|
}
|
|
234
274
|
catch {
|
|
@@ -242,6 +282,9 @@ export function classifyDecisionRefusal(err, context) {
|
|
|
242
282
|
}
|
|
243
283
|
return classifiedOf(mintDecisionRefusalReading(err, context));
|
|
244
284
|
}
|
|
285
|
+
export function classifyDeliveredDecisionRefusal(err, delivered) {
|
|
286
|
+
return classifiedOf(mintDecisionRefusalReading(err, undefined, undefined, delivered));
|
|
287
|
+
}
|
|
245
288
|
export function liveAskPendingReading(envelope, approvalId) {
|
|
246
289
|
if (typeof approvalId !== 'string' || approvalId === '')
|
|
247
290
|
return 'unknown';
|
|
@@ -260,15 +303,14 @@ export function liveAskPendingReading(envelope, approvalId) {
|
|
|
260
303
|
export function decisionRefusalClosesOut(refusal, pending) {
|
|
261
304
|
if (pending !== 'pending' || typeof refusal !== 'object' || refusal === null)
|
|
262
305
|
return false;
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
return false;
|
|
267
|
-
return standing === 'ambiguous' || standing === 'refused-pending';
|
|
268
|
-
}
|
|
269
|
-
catch {
|
|
306
|
+
const standing = readThrownSlot(refusal, 'standing', 'data');
|
|
307
|
+
const transient = readThrownSlot(refusal, 'transient', 'data');
|
|
308
|
+
if (transient === true || transient === THROWN_SLOT_UNREADABLE)
|
|
270
309
|
return false;
|
|
271
|
-
|
|
310
|
+
const conflict = readThrownSlot(refusal, 'conflict', 'data');
|
|
311
|
+
if (conflict === 'grant_changed' || conflict === THROWN_SLOT_UNREADABLE)
|
|
312
|
+
return false;
|
|
313
|
+
return standing === 'ambiguous' || standing === 'refused-pending';
|
|
272
314
|
}
|
|
273
315
|
export function undeliverableDecisionContent(facts) {
|
|
274
316
|
const code = typeof facts.errorCode === 'string' && isDisplayableWireCode(facts.errorCode) ? ` ${facts.errorCode}` : '';
|
|
@@ -284,3 +326,6 @@ export function undeliverableDecisionContent(facts) {
|
|
|
284
326
|
return `${head}; this turn was stopped instead of being left waiting. Update the client, or switch to a permission mode that shows you the approval and try again.`;
|
|
285
327
|
}
|
|
286
328
|
}
|
|
329
|
+
export function decideRowUnrevivableNotice(lang) {
|
|
330
|
+
return renderMessage(msg('notice.decide.rowUnrevivable'), isUiLanguage(lang) ? lang : undefined);
|
|
331
|
+
}
|