@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
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { msg, renderMessage } from './i18n/translate.js';
|
|
2
|
-
import { classifyTurnWireError,
|
|
2
|
+
import { classifyTurnWireError, isPreStreamDrainingReject } from './wireErrorTriage.js';
|
|
3
3
|
import { isSseIdleError } from './sseIdleTriage.js';
|
|
4
4
|
import { isCodeClassifiedGateFailure } from './gateFailureCodes.js';
|
|
5
5
|
import { CORRUPT_ROW_ERROR_CODE, CORRUPT_SESSION_ERROR_CODE, MEMORY_CONTROL_PLANE_CORRUPT, SCENARIO_ASSIGNMENT_UNKNOWN_ERROR_CODE } from './engineErrorCodes.js';
|
|
6
|
-
import { bodyShapeRefusalFromError, bodyShapeRefusalTouchesSettings, fleetLeaseUnavailableContent, fleetLeaseUnavailableFromError, hostPostureRefusalContent, hostPostureRefusalFromError,
|
|
6
|
+
import { admissionWallRefusalContent, admissionWallRefusalFromError, bodyShapeRefusalFromError, bodyShapeRefusalTouchesSettings, fleetLeaseUnavailableContent, fleetLeaseUnavailableFromError, hostPostureRefusalContent, hostPostureRefusalFromError, fieldLimitRefusalContent, fieldLimitRefusalFromError, toolDeclarationRefusalContent, toolDeclarationRefusalFromError, usageWindowExhaustedContent, usageWindowExhaustedFromError, quotaExhaustedContent, quotaExhaustedFromError, userAttachmentRefusalFromError, } from './wireRefusalCopy.js';
|
|
7
7
|
import { THROWN_SLOT_UNREADABLE, readErrorNumber, readThrownSlot, wireFailureTextsOf } from './wireFailureShape.js';
|
|
8
|
-
import { provablyNotSent } from './engineWireFor.js';
|
|
8
|
+
import { effectiveCodeOf, ownReadingSlot, provablyNotSent, triageReadingOf } from './engineWireFor.js';
|
|
9
9
|
import { corruptStoredRowContent, scenarioDenyFromError, scenarioNotAllowedContent } from './wireErrorTriage.js';
|
|
10
10
|
import { checkpointUnsupportedVersionContent, checkpointUnsupportedVersionFromError, requireExistingSessionRefusalContent, requireExistingSessionRefusalFromError, resumeContextUnavailableContent, resumeContextUnavailableFromError, resumePolicyBlockContent, resumePolicyBlockFromError, resumeRefusalContent, resumeRefusalFromError, } from './resumeRefusalCopy.js';
|
|
11
11
|
import { resumeReopenContent, resumeReopenFromError } from './hitl/suspendedReopen.js';
|
|
12
|
+
import { prepareRefusalCodeOf, prepareRefusalNoteOf } from './prepareRefusal.js';
|
|
12
13
|
import { isCorruptSessionError } from './corruptSession.js';
|
|
13
14
|
import { corruptSessionContent } from './corruptSessionCopy.js';
|
|
14
15
|
import { inheritEnvRefusalContent, inheritEnvRefusalFromError } from './inheritEnvWire.js';
|
|
@@ -32,6 +33,7 @@ const TURN_FAILURE_HEADLINE_KEYS = Object.freeze({
|
|
|
32
33
|
timeout: 'notice.failure.headline.timeout',
|
|
33
34
|
parked: 'notice.failure.headline.parked',
|
|
34
35
|
internal: 'notice.failure.headline.internal',
|
|
36
|
+
cause_unreadable: 'notice.failure.headline.causeUnreadable',
|
|
35
37
|
});
|
|
36
38
|
function waitSecOf(err) {
|
|
37
39
|
const ms = readThrownSlot(err, 'retryAfterMs', 'data');
|
|
@@ -60,12 +62,12 @@ function isIdleWatchdog(err) {
|
|
|
60
62
|
}
|
|
61
63
|
const DETERMINISTIC_SERVER_CODES = new Set([CORRUPT_SESSION_ERROR_CODE, CORRUPT_ROW_ERROR_CODE, SCENARIO_ASSIGNMENT_UNKNOWN_ERROR_CODE, MEMORY_CONTROL_PLANE_CORRUPT]);
|
|
62
64
|
const BROWSER_FETCH_FAILURE = /\bfailed to fetch\b|\bnetworkerror\b|\bnetwork error\b|\bload failed\b/i;
|
|
63
|
-
function httpShapeOf(
|
|
65
|
+
function httpShapeOf(verdict, code) {
|
|
64
66
|
const status = verdict.status;
|
|
65
|
-
const code = effectiveWireErrorCode(err) ?? verdict.errorCode;
|
|
66
67
|
if (verdict.sessionUnreadable === true || verdict.storedRowWhere !== undefined)
|
|
67
68
|
return { category: 'server_error', offer: false };
|
|
68
|
-
|
|
69
|
+
const facts = { status: verdict.status, ...(verdict.errorCode !== undefined ? { errorCode: verdict.errorCode } : {}) };
|
|
70
|
+
if (toolDeclarationRefusalFromError(facts) !== null)
|
|
69
71
|
return { category: 'invalid_request', offer: false };
|
|
70
72
|
if (code !== undefined && DETERMINISTIC_SERVER_CODES.has(code))
|
|
71
73
|
return { category: 'server_error', offer: false };
|
|
@@ -73,7 +75,7 @@ function httpShapeOf(err, verdict) {
|
|
|
73
75
|
return { category: 'rate_limited', offer: false };
|
|
74
76
|
if (code === 'budget.precall' || code === 'budget.exceeded')
|
|
75
77
|
return { category: 'billing', offer: false };
|
|
76
|
-
if (code === 'draining' || verdict.leaseUnavailable === true || isPreStreamDrainingReject(
|
|
78
|
+
if (code === 'draining' || verdict.leaseUnavailable === true || isPreStreamDrainingReject(facts))
|
|
77
79
|
return { category: 'server_error', offer: true };
|
|
78
80
|
if (status === 501 || (code !== undefined && code.startsWith('capability.')))
|
|
79
81
|
return { category: 'capability_unavailable', offer: false };
|
|
@@ -91,6 +93,13 @@ function httpShapeOf(err, verdict) {
|
|
|
91
93
|
return { category: 'invalid_request', offer: false };
|
|
92
94
|
return { category: 'internal', offer: false };
|
|
93
95
|
}
|
|
96
|
+
function answeringSubjectOf(err, verdict) {
|
|
97
|
+
if (verdict.kind !== 'http')
|
|
98
|
+
return { subject: err, code: undefined };
|
|
99
|
+
const answered = triageReadingOf(verdict);
|
|
100
|
+
const a = ownReadingSlot(answered, 'answer');
|
|
101
|
+
return a !== undefined && a !== THROWN_SLOT_UNREADABLE ? { subject: a.layer, code: effectiveCodeOf(a.code) ?? verdict.errorCode } : { subject: err, code: verdict.errorCode };
|
|
102
|
+
}
|
|
94
103
|
function connectionLostBeforeSend(err, evidence) {
|
|
95
104
|
if (readThrownSlot(evidence, 'bound', 'data') === true || readThrownSlot(evidence, 'reopened', 'data') === true)
|
|
96
105
|
return false;
|
|
@@ -98,12 +107,13 @@ function connectionLostBeforeSend(err, evidence) {
|
|
|
98
107
|
}
|
|
99
108
|
export function turnFailurePresentation(err, evidence, notesCtx, lang) {
|
|
100
109
|
const verdict = classifyTurnWireError(err);
|
|
110
|
+
const { subject, code: httpCode } = answeringSubjectOf(err, verdict);
|
|
101
111
|
let shape;
|
|
102
112
|
let headlineKey;
|
|
103
113
|
let detail;
|
|
104
114
|
let name;
|
|
105
115
|
if (verdict.kind === 'http') {
|
|
106
|
-
shape = httpShapeOf(
|
|
116
|
+
shape = httpShapeOf(verdict, httpCode);
|
|
107
117
|
detail = verdict.message;
|
|
108
118
|
if (shape.category === 'internal')
|
|
109
119
|
headlineKey = TURN_FAILURE_HEADLINE_KEYS.internal;
|
|
@@ -131,17 +141,19 @@ export function turnFailurePresentation(err, evidence, notesCtx, lang) {
|
|
|
131
141
|
detail = verdict.detail;
|
|
132
142
|
}
|
|
133
143
|
else {
|
|
134
|
-
|
|
135
|
-
|
|
144
|
+
const triaged = triageReadingOf(verdict);
|
|
145
|
+
const causeUnreadable = ownReadingSlot(triaged, 'answer') === THROWN_SLOT_UNREADABLE || ownReadingSlot(triaged, 'chainEnd') === 'unreadable';
|
|
146
|
+
shape = { category: 'internal', offer: causeUnreadable };
|
|
147
|
+
headlineKey = causeUnreadable ? TURN_FAILURE_HEADLINE_KEYS.cause_unreadable : TURN_FAILURE_HEADLINE_KEYS.internal;
|
|
136
148
|
detail = verdict.detail;
|
|
137
149
|
name = verdict.name;
|
|
138
150
|
}
|
|
139
151
|
const status = verdict.kind === 'http' ? verdict.status : undefined;
|
|
140
|
-
const errorCode = verdict.kind === 'http' ?
|
|
141
|
-
const wireRetriable = readThrownSlot(
|
|
152
|
+
const errorCode = verdict.kind === 'http' ? httpCode : undefined;
|
|
153
|
+
const wireRetriable = readThrownSlot(subject, 'retriable', 'data') === true && !isCodeClassifiedGateFailure(errorCode, true);
|
|
142
154
|
const retry = wireRetriable && shape.category !== 'parked' ? { offer: true, basis: 'wire' } : { offer: shape.offer, basis: 'category' };
|
|
143
|
-
const waitSec = waitSecOf(
|
|
144
|
-
const chain = turnFailureNotesOf(
|
|
155
|
+
const waitSec = waitSecOf(subject);
|
|
156
|
+
const chain = turnFailureNotesOf(subject, verdict, notesCtx, waitSec, lang);
|
|
145
157
|
const headline = headlineKey !== undefined ? renderMessage(msg(headlineKey), lang) : undefined;
|
|
146
158
|
return Object.freeze({
|
|
147
159
|
category: shape.category,
|
|
@@ -157,80 +169,6 @@ export function turnFailurePresentation(err, evidence, notesCtx, lang) {
|
|
|
157
169
|
...(chain.waitNote !== undefined ? { waitNote: chain.waitNote } : {}),
|
|
158
170
|
});
|
|
159
171
|
}
|
|
160
|
-
function quotaDetailOf(err) {
|
|
161
|
-
if (readThrownSlot(err, 'status', 'data') !== 429 || readThrownSlot(err, 'errorCode', 'data') !== 'quota_exhausted')
|
|
162
|
-
return null;
|
|
163
|
-
const detail = readThrownSlot(err, 'detail', 'data');
|
|
164
|
-
const slot = (key) => (typeof detail === 'object' && detail !== null ? readThrownSlot(detail, key, 'data') : undefined);
|
|
165
|
-
const windowType = slot('windowType');
|
|
166
|
-
const remaining = slot('remaining');
|
|
167
|
-
const resetAt = slot('resetAt');
|
|
168
|
-
const isEstimate = slot('isEstimate');
|
|
169
|
-
const pool = slot('pool');
|
|
170
|
-
return {
|
|
171
|
-
...(windowType === 'fiveHour' || windowType === 'weekly' || windowType === 'budget' ? { windowType } : {}),
|
|
172
|
-
...(typeof remaining === 'number' && Number.isFinite(remaining) ? { remaining } : {}),
|
|
173
|
-
...(typeof resetAt === 'string' || resetAt === null ? { resetAt } : {}),
|
|
174
|
-
...(typeof isEstimate === 'boolean' ? { isEstimate } : {}),
|
|
175
|
-
...(typeof pool === 'string' && pool.length > 0 ? { pool } : {}),
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
const MONTH_KEYS = [
|
|
179
|
-
'notice.failure.month.jan',
|
|
180
|
-
'notice.failure.month.feb',
|
|
181
|
-
'notice.failure.month.mar',
|
|
182
|
-
'notice.failure.month.apr',
|
|
183
|
-
'notice.failure.month.may',
|
|
184
|
-
'notice.failure.month.jun',
|
|
185
|
-
'notice.failure.month.jul',
|
|
186
|
-
'notice.failure.month.aug',
|
|
187
|
-
'notice.failure.month.sep',
|
|
188
|
-
'notice.failure.month.oct',
|
|
189
|
-
'notice.failure.month.nov',
|
|
190
|
-
'notice.failure.month.dec',
|
|
191
|
-
];
|
|
192
|
-
function quotaResetInstant(resetAtIso, nowMs, lang) {
|
|
193
|
-
const t = Date.parse(resetAtIso);
|
|
194
|
-
if (!Number.isFinite(t))
|
|
195
|
-
return undefined;
|
|
196
|
-
const d = new Date(t);
|
|
197
|
-
const now = new Date(nowMs);
|
|
198
|
-
const hm = `${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}`;
|
|
199
|
-
const sameDay = d.getFullYear() === now.getFullYear() && d.getMonth() === now.getMonth() && d.getDate() === now.getDate();
|
|
200
|
-
if (sameDay)
|
|
201
|
-
return hm;
|
|
202
|
-
const monthKey = MONTH_KEYS[d.getMonth()];
|
|
203
|
-
return renderMessage(msg('notice.failure.quota.instantOtherDay', { month: monthKey === undefined ? '' : msg(monthKey), day: d.getDate(), time: hm }), lang);
|
|
204
|
-
}
|
|
205
|
-
function quotaExhaustedLine(detail, nowMs, lang) {
|
|
206
|
-
const part = (key, params) => renderMessage(msg(key, params), lang);
|
|
207
|
-
const parts = [];
|
|
208
|
-
if (detail.windowType === 'fiveHour')
|
|
209
|
-
parts.push(part('notice.failure.quota.fiveHour'));
|
|
210
|
-
else if (detail.windowType === 'weekly')
|
|
211
|
-
parts.push(part('notice.failure.quota.weekly'));
|
|
212
|
-
else if (detail.windowType === 'budget') {
|
|
213
|
-
if (detail.pool === 'personal')
|
|
214
|
-
parts.push(part('notice.failure.quota.budgetPersonal'));
|
|
215
|
-
else if (detail.pool)
|
|
216
|
-
parts.push(part('notice.failure.quota.budgetPool', { pool: detail.pool }));
|
|
217
|
-
else
|
|
218
|
-
parts.push(part('notice.failure.quota.budget'));
|
|
219
|
-
}
|
|
220
|
-
else
|
|
221
|
-
parts.push(part('notice.failure.quota.usage'));
|
|
222
|
-
if (typeof detail.remaining === 'number' && Number.isFinite(detail.remaining)) {
|
|
223
|
-
parts.push(detail.windowType === 'budget'
|
|
224
|
-
? part('notice.failure.quota.remainingBudget', { amount: `$${(detail.remaining / 1_000_000).toFixed(2)}` })
|
|
225
|
-
: part('notice.failure.quota.remainingTokens', { count: detail.remaining.toLocaleString('en-US') }));
|
|
226
|
-
}
|
|
227
|
-
const resetText = typeof detail.resetAt === 'string' ? quotaResetInstant(detail.resetAt, nowMs, lang) : undefined;
|
|
228
|
-
if (resetText)
|
|
229
|
-
parts.push(detail.isEstimate === false ? part('notice.failure.quota.resetAt', { time: resetText }) : part('notice.failure.quota.resetAround', { time: resetText }));
|
|
230
|
-
parts.push(part('notice.failure.quota.refresh'));
|
|
231
|
-
parts.push(part('notice.failure.quota.noBypass'));
|
|
232
|
-
return parts.join(part('notice.failure.quota.join'));
|
|
233
|
-
}
|
|
234
172
|
function protectiveSettingsAtRisk(sent, lang) {
|
|
235
173
|
const out = [];
|
|
236
174
|
const permsRaw = sent.permissions;
|
|
@@ -281,9 +219,9 @@ function turnFailureNotesOf(err, verdict, ctx, waitSec, lang) {
|
|
|
281
219
|
try {
|
|
282
220
|
const sentRequest = ctx === undefined ? undefined : ctx.sentRequest;
|
|
283
221
|
const nowMs = ctx !== undefined && typeof ctx.nowMs === 'number' && Number.isFinite(ctx.nowMs) ? ctx.nowMs : Date.now();
|
|
284
|
-
const quota =
|
|
222
|
+
const quota = quotaExhaustedFromError(err);
|
|
285
223
|
if (quota)
|
|
286
|
-
lines.push(
|
|
224
|
+
lines.push(quotaExhaustedContent(quota, nowMs, lang));
|
|
287
225
|
const scenarioDeny = quota ? null : scenarioDenyFromError(err);
|
|
288
226
|
if (scenarioDeny)
|
|
289
227
|
lines.push(scenarioNotAllowedContent(scenarioDeny, ctx?.requestedScenario));
|
|
@@ -309,25 +247,32 @@ function turnFailureNotesOf(err, verdict, ctx, waitSec, lang) {
|
|
|
309
247
|
lines.push(corruptSessionContent(lang));
|
|
310
248
|
const usageWindow = quota || scenarioDeny || resumeRefusal || resumeReopen || resumeGone ? null : usageWindowExhaustedFromError(err);
|
|
311
249
|
if (usageWindow)
|
|
312
|
-
lines.push(usageWindowExhaustedContent(usageWindow));
|
|
250
|
+
lines.push(usageWindowExhaustedContent(usageWindow, lang));
|
|
313
251
|
const hostPosture = quota || scenarioDeny || resumeRefusal || resumeReopen || resumeGone || storedRowWhere !== undefined ? null : hostPostureRefusalFromError(err, sentRequest);
|
|
314
252
|
if (hostPosture)
|
|
315
|
-
lines.push(hostPostureRefusalContent(hostPosture));
|
|
253
|
+
lines.push(hostPostureRefusalContent(hostPosture, lang));
|
|
316
254
|
const inheritEnv = hostPosture ? null : inheritEnvRefusalFromError(err, sentRequest);
|
|
317
255
|
if (inheritEnv)
|
|
318
256
|
lines.push(inheritEnvRefusalContent(inheritEnv, lang));
|
|
319
|
-
const bucket = inheritEnv ? null :
|
|
257
|
+
const bucket = inheritEnv ? null : fieldLimitRefusalFromError(err);
|
|
320
258
|
const toolDecl = toolDeclarationRefusalFromError(err);
|
|
321
259
|
if (toolDecl)
|
|
322
|
-
lines.push(toolDeclarationRefusalContent(toolDecl));
|
|
260
|
+
lines.push(toolDeclarationRefusalContent(toolDecl, lang));
|
|
261
|
+
const prepareCode = toolDecl ? undefined : prepareRefusalCodeOf(err);
|
|
262
|
+
const prepareNote = prepareCode === undefined ? undefined : prepareRefusalNoteOf(prepareCode, userAttachmentRefusalFromError(err) ?? undefined);
|
|
263
|
+
if (prepareNote !== undefined)
|
|
264
|
+
lines.push(prepareNote);
|
|
265
|
+
const wall = admissionWallRefusalFromError(err);
|
|
266
|
+
if (wall)
|
|
267
|
+
lines.push(admissionWallRefusalContent(wall));
|
|
323
268
|
const lease = fleetLeaseUnavailableFromError(err);
|
|
324
269
|
if (lease)
|
|
325
|
-
lines.push(fleetLeaseUnavailableContent(lease));
|
|
270
|
+
lines.push(fleetLeaseUnavailableContent(lease, lang));
|
|
326
271
|
const policyBlock = quota || scenarioDeny || resumeRefusal || resumeReopen || resumeGone || usageWindow || hostPosture ? null : resumePolicyBlockFromError(err);
|
|
327
272
|
if (policyBlock)
|
|
328
273
|
lines.push(resumePolicyBlockContent(policyBlock, lang));
|
|
329
274
|
if (bucket)
|
|
330
|
-
lines.push(
|
|
275
|
+
lines.push(fieldLimitRefusalContent(bucket, lang));
|
|
331
276
|
const settingsRefusal = settingsBodyShapeNote(err, sentRequest, lang);
|
|
332
277
|
if (settingsRefusal !== undefined)
|
|
333
278
|
lines.push(settingsRefusal);
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { UiLanguage } from './env/uiLanguage.js';
|
|
2
|
+
import { type QuotaExhaustedView } from './wireRefusalCopy.js';
|
|
3
|
+
export declare const AUTO_RESUME_HORIZON_MS: number;
|
|
4
|
+
export declare const AUTO_RESUME_REPEAT_BREAKER_HITS = 2;
|
|
5
|
+
export declare const AUTO_RESUME_IMMINENT_MS = 60000;
|
|
6
|
+
export type AutoResumePhase = 'idle' | 'offered' | 'armed' | 'fired' | 'stale' | 'disabled' | 'horizon';
|
|
7
|
+
export type AutoResumeReason = 'context-changed' | 'not-replayable' | 'user-escaped' | 'user-chose-wait' | 'user-cancelled-auto' | 'repeated-usage-limit-hits' | 'no-reset-instant' | 'reset-horizon-exceeded' | 'prompt-superseded' | 'reset-without-auto-resume';
|
|
8
|
+
export interface AutoResumeState {
|
|
9
|
+
readonly phase: AutoResumePhase;
|
|
10
|
+
readonly prompt: string | null;
|
|
11
|
+
readonly resumeAtMs: number | null;
|
|
12
|
+
readonly windowType: 'fiveHour' | 'weekly' | 'budget' | null;
|
|
13
|
+
readonly consecutiveHits: number;
|
|
14
|
+
readonly reason: AutoResumeReason | null;
|
|
15
|
+
readonly contextId: string | null;
|
|
16
|
+
}
|
|
17
|
+
export type RateLimitOption = 'cancel' | 'auto-resume' | 'cancel-auto-resume';
|
|
18
|
+
export type AutoResumeEvent = {
|
|
19
|
+
readonly type: 'usage-limit-hit';
|
|
20
|
+
readonly detail: QuotaExhaustedView;
|
|
21
|
+
readonly prompt: string;
|
|
22
|
+
readonly contextId?: string;
|
|
23
|
+
readonly replayable?: boolean;
|
|
24
|
+
} | {
|
|
25
|
+
readonly type: 'menu-choice';
|
|
26
|
+
readonly option: RateLimitOption;
|
|
27
|
+
readonly contextId?: string;
|
|
28
|
+
} | {
|
|
29
|
+
readonly type: 'escape';
|
|
30
|
+
} | {
|
|
31
|
+
readonly type: 'tick';
|
|
32
|
+
readonly contextId?: string;
|
|
33
|
+
} | {
|
|
34
|
+
readonly type: 'user-submitted';
|
|
35
|
+
} | {
|
|
36
|
+
readonly type: 'context-changed';
|
|
37
|
+
} | {
|
|
38
|
+
readonly type: 'turn-completed';
|
|
39
|
+
};
|
|
40
|
+
export declare const AUTO_RESUME_COPY_WORDS: readonly ["fired", "reset", "breaker", "superseded", "not-replayable", "context-changed", "escaped"];
|
|
41
|
+
export type AutoResumeCopyWord = (typeof AUTO_RESUME_COPY_WORDS)[number];
|
|
42
|
+
export type AutoResumeAction = {
|
|
43
|
+
readonly type: 'schedule';
|
|
44
|
+
readonly atMs: number;
|
|
45
|
+
} | {
|
|
46
|
+
readonly type: 'clear-schedule';
|
|
47
|
+
} | {
|
|
48
|
+
readonly type: 'resubmit';
|
|
49
|
+
readonly prompt: string;
|
|
50
|
+
} | {
|
|
51
|
+
readonly type: 'revoke-resubmit';
|
|
52
|
+
} | {
|
|
53
|
+
readonly type: 'notify';
|
|
54
|
+
readonly kind: 'fired' | 'stale' | 'disabled';
|
|
55
|
+
readonly copy: AutoResumeCopyWord;
|
|
56
|
+
readonly message: string;
|
|
57
|
+
};
|
|
58
|
+
export interface AutoResumeStep {
|
|
59
|
+
readonly state: AutoResumeState;
|
|
60
|
+
readonly actions: readonly AutoResumeAction[];
|
|
61
|
+
}
|
|
62
|
+
export declare function autoResumeCopy(word: AutoResumeCopyWord, lang?: UiLanguage): string;
|
|
63
|
+
export declare function autoResumeAtMs(resetAt: string | null | undefined): number | null;
|
|
64
|
+
export declare function initialAutoResumeState(): AutoResumeState;
|
|
65
|
+
export declare function autoResumeTransition(state: AutoResumeState, event: AutoResumeEvent, nowMs: number): AutoResumeStep;
|
|
66
|
+
export declare function autoResumeArmedRow(state: AutoResumeState, nowMs: number, lang?: UiLanguage): string | undefined;
|
|
67
|
+
export declare function autoResumeNoticeRow(state: AutoResumeState, lang?: UiLanguage): string | undefined;
|
|
68
|
+
export interface RateLimitOptionRow {
|
|
69
|
+
readonly value: RateLimitOption;
|
|
70
|
+
readonly label: string;
|
|
71
|
+
readonly disabled: boolean;
|
|
72
|
+
readonly disabledReason?: string;
|
|
73
|
+
}
|
|
74
|
+
export declare function rateLimitOptionRows(state: AutoResumeState, lang?: UiLanguage): readonly RateLimitOptionRow[];
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { msg, renderMessage } from './i18n/translate.js';
|
|
2
|
+
import { usableClockMs } from './clockReading.js';
|
|
3
|
+
import { quotaResetInstantText } from './wireRefusalCopy.js';
|
|
4
|
+
export const AUTO_RESUME_HORIZON_MS = 24 * 60 * 60 * 1000;
|
|
5
|
+
export const AUTO_RESUME_REPEAT_BREAKER_HITS = 2;
|
|
6
|
+
export const AUTO_RESUME_IMMINENT_MS = 60_000;
|
|
7
|
+
export const AUTO_RESUME_COPY_WORDS = Object.freeze(['fired', 'reset', 'breaker', 'superseded', 'not-replayable', 'context-changed', 'escaped']);
|
|
8
|
+
const COPY_KEYS = {
|
|
9
|
+
fired: 'notice.usageLimit.autoResume.fired',
|
|
10
|
+
reset: 'notice.usageLimit.autoResume.reset',
|
|
11
|
+
breaker: 'notice.usageLimit.autoResume.breaker',
|
|
12
|
+
superseded: 'notice.usageLimit.autoResume.superseded',
|
|
13
|
+
'not-replayable': 'notice.usageLimit.autoResume.notReplayable',
|
|
14
|
+
'context-changed': 'notice.usageLimit.autoResume.contextChanged',
|
|
15
|
+
escaped: 'notice.usageLimit.autoResume.escaped',
|
|
16
|
+
};
|
|
17
|
+
export function autoResumeCopy(word, lang) {
|
|
18
|
+
return Object.hasOwn(COPY_KEYS, word) ? renderMessage(msg(COPY_KEYS[word]), lang) : '';
|
|
19
|
+
}
|
|
20
|
+
const notifyAction = (kind, copy) => ({ type: 'notify', kind, copy, message: autoResumeCopy(copy) });
|
|
21
|
+
export function autoResumeAtMs(resetAt) {
|
|
22
|
+
if (typeof resetAt !== 'string')
|
|
23
|
+
return null;
|
|
24
|
+
const t = Date.parse(resetAt);
|
|
25
|
+
return Number.isFinite(t) ? t : null;
|
|
26
|
+
}
|
|
27
|
+
export function initialAutoResumeState() {
|
|
28
|
+
return Object.freeze({ phase: 'idle', prompt: null, resumeAtMs: null, windowType: null, consecutiveHits: 0, reason: null, contextId: null });
|
|
29
|
+
}
|
|
30
|
+
function noticeSchedule(resumeAtMs, nowMs) {
|
|
31
|
+
if (resumeAtMs === null || usableClockMs(nowMs) === null || resumeAtMs - nowMs > AUTO_RESUME_HORIZON_MS)
|
|
32
|
+
return [{ type: 'clear-schedule' }];
|
|
33
|
+
return [{ type: 'schedule', atMs: resumeAtMs }];
|
|
34
|
+
}
|
|
35
|
+
function freezeActions(actions) {
|
|
36
|
+
return Object.freeze(actions.map((a) => Object.freeze({ ...a })));
|
|
37
|
+
}
|
|
38
|
+
function settle(state, patch, actions = []) {
|
|
39
|
+
return Object.freeze({ state: Object.freeze({ ...state, ...patch }), actions: freezeActions(actions) });
|
|
40
|
+
}
|
|
41
|
+
const withActions = (state, actions) => Object.freeze({ state, actions: freezeActions(actions) });
|
|
42
|
+
const NO_ACTIONS = Object.freeze([]);
|
|
43
|
+
const NO_CHANGE = (state) => Object.freeze({ state, actions: NO_ACTIONS });
|
|
44
|
+
const ctxOf = (v) => (typeof v === 'string' ? v : undefined);
|
|
45
|
+
function snapshotDetail(d) {
|
|
46
|
+
if (typeof d !== 'object' || d === null)
|
|
47
|
+
return {};
|
|
48
|
+
const raw = d;
|
|
49
|
+
const resetAt = raw.resetAt;
|
|
50
|
+
const windowType = raw.windowType;
|
|
51
|
+
return {
|
|
52
|
+
...(typeof resetAt === 'string' ? { resetAt } : {}),
|
|
53
|
+
...(windowType === 'fiveHour' || windowType === 'weekly' || windowType === 'budget' ? { windowType } : {}),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export function autoResumeTransition(state, event, nowMs) {
|
|
57
|
+
try {
|
|
58
|
+
if (typeof event !== 'object' || event === null)
|
|
59
|
+
return NO_CHANGE(state);
|
|
60
|
+
const raw = event;
|
|
61
|
+
const facts = { type: raw.type, detail: raw.detail, prompt: raw.prompt, contextId: raw.contextId, replayable: raw.replayable, option: raw.option };
|
|
62
|
+
return transition(state, facts, nowMs);
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return NO_CHANGE(state);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function transition(state, event, nowMs) {
|
|
69
|
+
const clockOk = usableClockMs(nowMs) !== null;
|
|
70
|
+
switch (event.type) {
|
|
71
|
+
case 'usage-limit-hit': {
|
|
72
|
+
if (!clockOk)
|
|
73
|
+
return NO_CHANGE(state);
|
|
74
|
+
const detail = snapshotDetail(event.detail);
|
|
75
|
+
const hits = state.consecutiveHits + 1;
|
|
76
|
+
const resumeAtMs = autoResumeAtMs(detail.resetAt);
|
|
77
|
+
const windowType = detail.windowType ?? null;
|
|
78
|
+
const contextId = ctxOf(event.contextId) ?? null;
|
|
79
|
+
const base = { consecutiveHits: hits, resumeAtMs, windowType, contextId };
|
|
80
|
+
const prompt = typeof event.prompt === 'string' ? event.prompt : null;
|
|
81
|
+
const isOurs = state.prompt !== null && prompt === state.prompt;
|
|
82
|
+
if (state.phase === 'armed')
|
|
83
|
+
return settle(state, { consecutiveHits: hits }, []);
|
|
84
|
+
if (state.phase === 'fired' && !isOurs)
|
|
85
|
+
return settle(state, { consecutiveHits: hits }, []);
|
|
86
|
+
if (state.phase === 'fired' && hits >= AUTO_RESUME_REPEAT_BREAKER_HITS) {
|
|
87
|
+
return settle(state, { ...base, phase: 'disabled', reason: 'repeated-usage-limit-hits', prompt: null }, [{ type: 'clear-schedule' }, notifyAction('disabled', 'breaker')]);
|
|
88
|
+
}
|
|
89
|
+
if (event.replayable === false || prompt === null) {
|
|
90
|
+
return settle(state, { ...base, phase: 'disabled', reason: 'not-replayable', prompt: null }, noticeSchedule(resumeAtMs, nowMs));
|
|
91
|
+
}
|
|
92
|
+
if (resumeAtMs === null) {
|
|
93
|
+
return settle(state, { ...base, phase: 'disabled', reason: 'no-reset-instant', prompt: null }, [{ type: 'clear-schedule' }]);
|
|
94
|
+
}
|
|
95
|
+
if (resumeAtMs - nowMs > AUTO_RESUME_HORIZON_MS) {
|
|
96
|
+
return settle(state, { ...base, phase: 'horizon', reason: 'reset-horizon-exceeded', prompt }, [{ type: 'clear-schedule' }]);
|
|
97
|
+
}
|
|
98
|
+
return settle(state, { ...base, phase: 'offered', reason: null, prompt }, noticeSchedule(resumeAtMs, nowMs));
|
|
99
|
+
}
|
|
100
|
+
case 'menu-choice': {
|
|
101
|
+
const revokeIfFired = state.phase === 'fired' ? [{ type: 'revoke-resubmit' }] : [];
|
|
102
|
+
if (event.option === 'cancel') {
|
|
103
|
+
return settle(state, { phase: 'disabled', reason: 'user-chose-wait', prompt: null }, [...revokeIfFired, ...noticeSchedule(state.resumeAtMs, nowMs)]);
|
|
104
|
+
}
|
|
105
|
+
if (event.option === 'cancel-auto-resume') {
|
|
106
|
+
if (state.phase !== 'armed' && state.phase !== 'fired')
|
|
107
|
+
return NO_CHANGE(state);
|
|
108
|
+
return settle(state, { phase: 'disabled', reason: 'user-cancelled-auto', prompt: null }, [{ type: 'clear-schedule' }, ...revokeIfFired]);
|
|
109
|
+
}
|
|
110
|
+
if (event.option !== 'auto-resume')
|
|
111
|
+
return NO_CHANGE(state);
|
|
112
|
+
if (state.phase === 'armed')
|
|
113
|
+
return NO_CHANGE(state);
|
|
114
|
+
if (state.phase !== 'offered' && state.phase !== 'horizon')
|
|
115
|
+
return NO_CHANGE(state);
|
|
116
|
+
if (state.resumeAtMs === null || state.prompt === null)
|
|
117
|
+
return NO_CHANGE(state);
|
|
118
|
+
if (!clockOk)
|
|
119
|
+
return NO_CHANGE(state);
|
|
120
|
+
const authorizedIn = ctxOf(event.contextId);
|
|
121
|
+
return settle(state, { phase: 'armed', reason: null, ...(authorizedIn !== undefined ? { contextId: authorizedIn } : {}) }, [{ type: 'schedule', atMs: state.resumeAtMs }]);
|
|
122
|
+
}
|
|
123
|
+
case 'escape': {
|
|
124
|
+
if (state.phase === 'fired')
|
|
125
|
+
return settle(state, { phase: 'disabled', reason: 'user-escaped', prompt: null }, [{ type: 'clear-schedule' }, { type: 'revoke-resubmit' }]);
|
|
126
|
+
if (state.phase !== 'armed')
|
|
127
|
+
return NO_CHANGE(state);
|
|
128
|
+
return settle(state, { phase: 'disabled', reason: 'user-escaped', prompt: null }, [{ type: 'clear-schedule' }]);
|
|
129
|
+
}
|
|
130
|
+
case 'tick': {
|
|
131
|
+
if (state.resumeAtMs === null)
|
|
132
|
+
return NO_CHANGE(state);
|
|
133
|
+
if (!clockOk)
|
|
134
|
+
return NO_CHANGE(state);
|
|
135
|
+
if (nowMs < state.resumeAtMs) {
|
|
136
|
+
if (state.phase === 'armed' || state.phase === 'offered' || state.phase === 'horizon' || state.phase === 'disabled') {
|
|
137
|
+
return withActions(state, [{ type: 'schedule', atMs: state.resumeAtMs }]);
|
|
138
|
+
}
|
|
139
|
+
return NO_CHANGE(state);
|
|
140
|
+
}
|
|
141
|
+
if (state.contextId !== null && ctxOf(event.contextId) !== state.contextId) {
|
|
142
|
+
return settle(state, { phase: 'stale', reason: 'context-changed', prompt: null }, state.phase === 'armed' ? [{ type: 'clear-schedule' }, notifyAction('stale', 'context-changed')] : [{ type: 'clear-schedule' }]);
|
|
143
|
+
}
|
|
144
|
+
if (state.phase === 'armed') {
|
|
145
|
+
if (state.prompt === null) {
|
|
146
|
+
return settle(state, { phase: 'stale', reason: 'reset-without-auto-resume' }, [{ type: 'clear-schedule' }, notifyAction('stale', 'reset')]);
|
|
147
|
+
}
|
|
148
|
+
return settle(state, { phase: 'fired', reason: null }, [{ type: 'clear-schedule' }, { type: 'resubmit', prompt: state.prompt }, notifyAction('fired', 'fired')]);
|
|
149
|
+
}
|
|
150
|
+
if (state.phase === 'offered' || state.phase === 'horizon' || state.phase === 'disabled') {
|
|
151
|
+
return settle(state, { phase: 'stale', reason: 'reset-without-auto-resume', prompt: null }, [{ type: 'clear-schedule' }, notifyAction('stale', 'reset')]);
|
|
152
|
+
}
|
|
153
|
+
return NO_CHANGE(state);
|
|
154
|
+
}
|
|
155
|
+
case 'user-submitted': {
|
|
156
|
+
if (state.phase !== 'armed' && state.phase !== 'fired')
|
|
157
|
+
return NO_CHANGE(state);
|
|
158
|
+
return settle(state, { phase: 'stale', reason: 'prompt-superseded', prompt: null }, state.phase === 'fired' ? [{ type: 'clear-schedule' }, { type: 'revoke-resubmit' }] : [{ type: 'clear-schedule' }]);
|
|
159
|
+
}
|
|
160
|
+
case 'context-changed': {
|
|
161
|
+
if (state.phase !== 'armed' && state.phase !== 'fired' && state.phase !== 'offered' && state.phase !== 'horizon')
|
|
162
|
+
return NO_CHANGE(state);
|
|
163
|
+
return settle(state, { phase: 'stale', reason: 'context-changed', prompt: null }, [
|
|
164
|
+
{ type: 'clear-schedule' },
|
|
165
|
+
...(state.phase === 'fired' ? [{ type: 'revoke-resubmit' }] : []),
|
|
166
|
+
notifyAction('stale', 'context-changed'),
|
|
167
|
+
]);
|
|
168
|
+
}
|
|
169
|
+
case 'turn-completed': {
|
|
170
|
+
if (state.phase === 'fired')
|
|
171
|
+
return settle(state, { ...initialAutoResumeState() });
|
|
172
|
+
if (state.phase === 'stale' || state.phase === 'disabled' || state.phase === 'horizon')
|
|
173
|
+
return settle(state, { ...initialAutoResumeState() });
|
|
174
|
+
return settle(state, { consecutiveHits: 0 });
|
|
175
|
+
}
|
|
176
|
+
default:
|
|
177
|
+
return NO_CHANGE(state);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
export function autoResumeArmedRow(state, nowMs, lang) {
|
|
181
|
+
if (state.phase !== 'armed' || state.resumeAtMs === null)
|
|
182
|
+
return undefined;
|
|
183
|
+
const remaining = state.resumeAtMs - nowMs;
|
|
184
|
+
const at = remaining > AUTO_RESUME_IMMINENT_MS ? quotaResetInstantText(new Date(state.resumeAtMs).toISOString(), nowMs, lang) : undefined;
|
|
185
|
+
return at !== undefined ? renderMessage(msg('notice.usageLimit.autoResume.armed.at', { time: at }), lang) : renderMessage(msg('notice.usageLimit.autoResume.armed.shortly'), lang);
|
|
186
|
+
}
|
|
187
|
+
export function autoResumeNoticeRow(state, lang) {
|
|
188
|
+
if (state.phase === 'stale') {
|
|
189
|
+
if (state.reason === 'prompt-superseded')
|
|
190
|
+
return autoResumeCopy('superseded', lang);
|
|
191
|
+
if (state.reason === 'context-changed')
|
|
192
|
+
return autoResumeCopy('context-changed', lang);
|
|
193
|
+
return autoResumeCopy('reset', lang);
|
|
194
|
+
}
|
|
195
|
+
if (state.phase === 'disabled' && state.reason === 'repeated-usage-limit-hits')
|
|
196
|
+
return autoResumeCopy('breaker', lang);
|
|
197
|
+
if (state.phase === 'disabled' && state.reason === 'not-replayable')
|
|
198
|
+
return autoResumeCopy('not-replayable', lang);
|
|
199
|
+
if (state.phase === 'disabled' && state.reason === 'user-escaped')
|
|
200
|
+
return autoResumeCopy('escaped', lang);
|
|
201
|
+
if (state.phase === 'horizon')
|
|
202
|
+
return renderMessage(msg('notice.usageLimit.autoResume.horizon'), lang);
|
|
203
|
+
return undefined;
|
|
204
|
+
}
|
|
205
|
+
export function rateLimitOptionRows(state, lang) {
|
|
206
|
+
const t = (key) => renderMessage(msg(key), lang);
|
|
207
|
+
const rows = [{ value: 'cancel', label: t('notice.usageLimit.autoResume.option.cancel'), disabled: false }];
|
|
208
|
+
if (state.phase === 'armed' || state.phase === 'fired') {
|
|
209
|
+
rows.push({ value: 'cancel-auto-resume', label: t('notice.usageLimit.autoResume.option.cancelAuto'), disabled: false });
|
|
210
|
+
return rows;
|
|
211
|
+
}
|
|
212
|
+
const armable = state.phase === 'offered' || state.phase === 'horizon';
|
|
213
|
+
let disabledReason;
|
|
214
|
+
if (state.reason === 'repeated-usage-limit-hits')
|
|
215
|
+
disabledReason = t('notice.usageLimit.autoResume.disabled.breaker');
|
|
216
|
+
else if (state.reason === 'not-replayable')
|
|
217
|
+
disabledReason = t('notice.usageLimit.autoResume.disabled.notReplayable');
|
|
218
|
+
else if (state.reason === 'context-changed')
|
|
219
|
+
disabledReason = t('notice.usageLimit.autoResume.disabled.contextChanged');
|
|
220
|
+
else if (state.resumeAtMs === null)
|
|
221
|
+
disabledReason = t('notice.usageLimit.autoResume.disabled.noResetInstant');
|
|
222
|
+
else if (!armable)
|
|
223
|
+
disabledReason = t('notice.usageLimit.autoResume.disabled.nothingWaiting');
|
|
224
|
+
const label = state.phase === 'horizon' ? t('notice.usageLimit.autoResume.option.autoHorizon') : t('notice.usageLimit.autoResume.option.auto');
|
|
225
|
+
rows.push({ value: 'auto-resume', label, disabled: disabledReason !== undefined, ...(disabledReason !== undefined ? { disabledReason } : {}) });
|
|
226
|
+
return rows;
|
|
227
|
+
}
|
|
@@ -165,7 +165,7 @@ const NOT_INCLUDED_REASON = Object.freeze({
|
|
|
165
165
|
'too-large': "it is larger than the client's size limit for attaching files",
|
|
166
166
|
unreadable: 'the client could not read it',
|
|
167
167
|
'read-denied': "the user's permission rules do not allow reading it",
|
|
168
|
-
'approval-required':
|
|
168
|
+
'approval-required': 'a read-approval rule applies to it, so the client did not attach it without asking',
|
|
169
169
|
'server-not-connected': 'the MCP server it comes from is not connected',
|
|
170
170
|
'resource-not-listed': 'the MCP server does not list that resource',
|
|
171
171
|
'read-failed': 'reading it from the MCP server failed',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { engineWireTargetBaseUrl } from './engineWireTarget.js';
|
|
2
2
|
import { createEngineCapReader } from './engineCapReader.js';
|
|
3
|
-
import { ownDataField, readOwnDataValue } from './ownKey.js';
|
|
3
|
+
import { appendOwnElement, ownDataField, readOwnDataValue } from './ownKey.js';
|
|
4
4
|
const _seatPin = [true, true];
|
|
5
5
|
void _seatPin;
|
|
6
6
|
function stringList(v) {
|
|
@@ -12,9 +12,9 @@ function stringList(v) {
|
|
|
12
12
|
const out = [];
|
|
13
13
|
for (let i = 0; i < n; i += 1) {
|
|
14
14
|
const d = Object.getOwnPropertyDescriptor(v, i);
|
|
15
|
-
if (d === undefined || !('value'
|
|
15
|
+
if (d === undefined || !Object.hasOwn(d, 'value') || typeof d.value !== 'string')
|
|
16
16
|
return undefined;
|
|
17
|
-
out
|
|
17
|
+
appendOwnElement(out, d.value);
|
|
18
18
|
}
|
|
19
19
|
return out;
|
|
20
20
|
}
|
|
@@ -46,7 +46,7 @@ export function projectUserAttachmentSeatCapability(caps) {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
const reader = createEngineCapReader({ name: 'userAttachments', project: projectUserAttachmentSeatCapability });
|
|
49
|
-
export function observedUserAttachmentSeat(baseUrl =
|
|
49
|
+
export function observedUserAttachmentSeat(baseUrl = engineWireTargetBaseUrl()) {
|
|
50
50
|
return reader.observed(baseUrl);
|
|
51
51
|
}
|
|
52
52
|
export function userAttachmentSeatAdmits(reading) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { engineWireTargetBaseUrl } from './engineWireTarget.js';
|
|
2
2
|
import { createEngineCapReader, unreadableReadingDetail } from './engineCapReader.js';
|
|
3
3
|
import { msg, renderMessage } from './i18n/translate.js';
|
|
4
4
|
import { ownDataField, readOwnDataValue } from './ownKey.js';
|
|
@@ -21,7 +21,7 @@ const reader = createEngineCapReader({
|
|
|
21
21
|
name: 'userInvokedSkills',
|
|
22
22
|
project: projectUserInvokedSkillsCapability,
|
|
23
23
|
});
|
|
24
|
-
export function observedUserInvokedSkills(baseUrl =
|
|
24
|
+
export function observedUserInvokedSkills(baseUrl = engineWireTargetBaseUrl()) {
|
|
25
25
|
return reader.observed(baseUrl);
|
|
26
26
|
}
|
|
27
27
|
export function userInvokedSkillsAvailable(reading) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { capForDisplay } from './fleetTaskDesc.js';
|
|
2
|
-
import {
|
|
2
|
+
import { engineWireTargetBaseUrl } from './engineWireTarget.js';
|
|
3
3
|
import { createEngineCapReader, unreadableReadingDetail } from './engineCapReader.js';
|
|
4
4
|
import { ownDataField } from './ownKey.js';
|
|
5
5
|
export const WEB_SEARCH_BACKEND_NONE = 'none';
|
|
@@ -29,7 +29,7 @@ const reader = createEngineCapReader({
|
|
|
29
29
|
name: 'webSearch.backend',
|
|
30
30
|
project: projectWebSearchBackendCapability,
|
|
31
31
|
});
|
|
32
|
-
export function observedWebSearchBackend(baseUrl =
|
|
32
|
+
export function observedWebSearchBackend(baseUrl = engineWireTargetBaseUrl()) {
|
|
33
33
|
return reader.observed(baseUrl);
|
|
34
34
|
}
|
|
35
35
|
const WS_DETAIL_MAX = 40;
|