@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
|
@@ -2,3 +2,4 @@ export declare function resultErrorCodeOf(frame: unknown): string | undefined;
|
|
|
2
2
|
export declare function resultSelectedModelOf(frame: unknown): string | undefined;
|
|
3
3
|
export declare function resultSalvagedResultOf(frame: unknown): string | undefined;
|
|
4
4
|
export declare function resultParkFailedReasonOf(frame: unknown): string | undefined;
|
|
5
|
+
export declare function resultErrorCodeInTextOf(frame: object | null | undefined): true | undefined;
|
package/dist/resultFrameKeys.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { readFrameStringKey } from './ownKey.js';
|
|
1
|
+
import { readFrameStringKey, readFrameTrueMark } from './ownKey.js';
|
|
2
2
|
export function resultErrorCodeOf(frame) {
|
|
3
3
|
return readFrameStringKey(frame, '_sema_error_code');
|
|
4
4
|
}
|
|
@@ -11,3 +11,6 @@ export function resultSalvagedResultOf(frame) {
|
|
|
11
11
|
export function resultParkFailedReasonOf(frame) {
|
|
12
12
|
return readFrameStringKey(frame, '_sema_park_failed_reason');
|
|
13
13
|
}
|
|
14
|
+
export function resultErrorCodeInTextOf(frame) {
|
|
15
|
+
return readFrameTrueMark(frame, '_sema_error_code_in_text') ? true : undefined;
|
|
16
|
+
}
|
|
@@ -48,7 +48,7 @@ export interface ParkedResumeStartupDetail {
|
|
|
48
48
|
denyStaysOpen: true;
|
|
49
49
|
}
|
|
50
50
|
declare const RESUME_CAUSE_CORE_AHEAD: readonly ["transcript_corrupt"];
|
|
51
|
-
type ResumeCauseCoreAhead = (typeof RESUME_CAUSE_CORE_AHEAD)[number]
|
|
51
|
+
type ResumeCauseCoreAhead = Exclude<(typeof RESUME_CAUSE_CORE_AHEAD)[number], ResumeStartupCause>;
|
|
52
52
|
export declare function parkedResumeStartupFromError(err: unknown, decision?: ParkedResumeStartupDecision): ParkedResumeStartupDetail | null;
|
|
53
53
|
export declare function parkedResumeStartupContent(detail: ParkedResumeStartupDetail, lang?: UiLanguage): string;
|
|
54
54
|
export interface CheckpointUnsupportedVersionDetail {
|
|
@@ -69,6 +69,8 @@ export interface RefusedParkFacts {
|
|
|
69
69
|
readonly code: RefusedParkCode;
|
|
70
70
|
readonly field?: string;
|
|
71
71
|
readonly stillPending?: boolean;
|
|
72
|
+
readonly blockedBy?: string;
|
|
73
|
+
readonly reason?: string;
|
|
72
74
|
}
|
|
73
75
|
export declare function refusedParkFromError(failure: unknown): RefusedParkFacts | null;
|
|
74
76
|
export interface RefusedParkContentInput {
|
|
@@ -238,6 +238,7 @@ export function checkpointUnsupportedVersionContent(detail, ctx, lang) {
|
|
|
238
238
|
return renderMessage(msg('resume.refusal.checkpoint.content', { outlet }), lang);
|
|
239
239
|
}
|
|
240
240
|
const REFUSED_PARK_FIELD_TOKEN = /^[A-Za-z][A-Za-z0-9_]{0,63}$/;
|
|
241
|
+
const REFUSED_PARK_CODE_TOKEN = /^(?=.{1,128}$)[A-Za-z][A-Za-z0-9_]*(?:\.[A-Za-z0-9_]+)*$/;
|
|
241
242
|
export function refusedParkFromError(failure) {
|
|
242
243
|
if (typeof failure !== 'object' || failure === null)
|
|
243
244
|
return null;
|
|
@@ -258,10 +259,22 @@ export function refusedParkFromError(failure) {
|
|
|
258
259
|
const stillPending = reading === true ? true : status === 409 && reading === false ? false : undefined;
|
|
259
260
|
const rawField = code === CHECKPOINT_CONFIG_REFUSED ? readErrorString(failure, 'field') : undefined;
|
|
260
261
|
const field = rawField !== undefined && REFUSED_PARK_FIELD_TOKEN.test(rawField) ? rawField : undefined;
|
|
262
|
+
let blockedBy;
|
|
263
|
+
try {
|
|
264
|
+
const b = readBlockedBy(failure);
|
|
265
|
+
blockedBy = b.kind === 'named' && REFUSED_PARK_CODE_TOKEN.test(b.code) ? b.code : undefined;
|
|
266
|
+
}
|
|
267
|
+
catch {
|
|
268
|
+
blockedBy = undefined;
|
|
269
|
+
}
|
|
270
|
+
const rawReason = readErrorString(failure, 'reason');
|
|
271
|
+
const reason = rawReason !== undefined && REFUSED_PARK_FIELD_TOKEN.test(rawReason) ? rawReason : undefined;
|
|
261
272
|
return Object.freeze({
|
|
262
273
|
code,
|
|
263
274
|
...(field !== undefined ? { field } : {}),
|
|
264
275
|
...(stillPending !== undefined ? { stillPending } : {}),
|
|
276
|
+
...(blockedBy !== undefined ? { blockedBy } : {}),
|
|
277
|
+
...(reason !== undefined ? { reason } : {}),
|
|
265
278
|
});
|
|
266
279
|
}
|
|
267
280
|
function refusedParkShownRunId(runId) {
|
|
@@ -272,6 +285,8 @@ function refusedParkWhy(code, field) {
|
|
|
272
285
|
case CHECKPOINT_WALLTIME_AXIS_RETIRED:
|
|
273
286
|
return msg('resume.refusal.park.whyWalltime');
|
|
274
287
|
case CHECKPOINT_CONFIG_REFUSED:
|
|
288
|
+
if (field === 'deps')
|
|
289
|
+
return msg('resume.refusal.park.whyDeps');
|
|
275
290
|
return msg(field === 'inheritedGate' ? 'resume.refusal.park.whyInheritedGate' : 'resume.refusal.park.whyConfigRefused');
|
|
276
291
|
default:
|
|
277
292
|
return msg('resume.refusal.park.whyUnsupported');
|
|
@@ -284,6 +299,7 @@ export function refusedParkContent(input, lang) {
|
|
|
284
299
|
let rawCode;
|
|
285
300
|
let field;
|
|
286
301
|
let stillPending;
|
|
302
|
+
let blockedBy;
|
|
287
303
|
try {
|
|
288
304
|
what = input.what;
|
|
289
305
|
lane = input.lane;
|
|
@@ -297,21 +313,23 @@ export function refusedParkContent(input, lang) {
|
|
|
297
313
|
rawCode = facts.code;
|
|
298
314
|
field = facts.field;
|
|
299
315
|
stillPending = facts.stillPending;
|
|
316
|
+
blockedBy = facts.blockedBy;
|
|
300
317
|
}
|
|
301
318
|
catch {
|
|
302
|
-
rawCode = field = stillPending = undefined;
|
|
319
|
+
rawCode = field = stillPending = blockedBy = undefined;
|
|
303
320
|
}
|
|
304
321
|
const code = rawCode === CHECKPOINT_WALLTIME_AXIS_RETIRED || rawCode === CHECKPOINT_CONFIG_REFUSED ? rawCode : CHECKPOINT_UNSUPPORTED_VERSION;
|
|
305
322
|
const shownWhat = typeof what === 'string' && what !== '' ? capForDisplay(what, 40) : msg('resume.refusal.park.whatDefault');
|
|
306
323
|
const why = refusedParkWhy(code, typeof field === 'string' ? field : undefined);
|
|
307
324
|
const shownRun = refusedParkShownRunId(runId);
|
|
308
325
|
const head = msg('resume.refusal.park.head', { what: shownWhat, why });
|
|
309
|
-
const configMayReturn = code === CHECKPOINT_CONFIG_REFUSED && field !== 'inheritedGate' ? msg('resume.refusal.park.configMayReturn') : '';
|
|
326
|
+
const configMayReturn = code === CHECKPOINT_CONFIG_REFUSED && field !== 'inheritedGate' ? msg(field === 'deps' ? 'resume.refusal.park.depsMayReturn' : 'resume.refusal.park.configMayReturn') : '';
|
|
310
327
|
if (lane === 'print') {
|
|
328
|
+
const blocked = typeof blockedBy === 'string' && REFUSED_PARK_CODE_TOKEN.test(blockedBy) ? msg('resume.refusal.park.blockedByTail', { blockedBy }) : '';
|
|
311
329
|
if (stillPending === false)
|
|
312
|
-
return renderMessage(msg('resume.refusal.park.printEnded', { head, code }), lang);
|
|
330
|
+
return renderMessage(msg('resume.refusal.park.printEnded', { head, code, blocked }), lang);
|
|
313
331
|
const cancel = `POST /v1/runs/${shownRun ?? '<run id>'}/cancel`;
|
|
314
|
-
return renderMessage(msg('resume.refusal.park.printHolds', { head, configMayReturn, code, cancel }), lang);
|
|
332
|
+
return renderMessage(msg('resume.refusal.park.printHolds', { head, configMayReturn, code, cancel, blocked }), lang);
|
|
315
333
|
}
|
|
316
334
|
if (stillPending === false)
|
|
317
335
|
return renderMessage(msg('resume.refusal.park.interactiveEnded', { head }), lang);
|
package/dist/retryStatus.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { UiLanguage } from './env/uiLanguage.js';
|
|
1
2
|
export type RetryStatus = {
|
|
2
3
|
kind: 'stalled';
|
|
3
4
|
deadline: number;
|
|
@@ -93,6 +94,24 @@ export interface RetryStatusNotice {
|
|
|
93
94
|
readonly recourse?: 'switch_model' | 'wait' | 'fix_request';
|
|
94
95
|
readonly phase: 'retrying' | 'reconnecting' | 'waiting_first_token' | 'gave_up' | 'cleared';
|
|
95
96
|
}
|
|
97
|
+
export interface RetryStatusParts {
|
|
98
|
+
readonly phase: RetryStatusNotice['phase'];
|
|
99
|
+
readonly model?: string;
|
|
100
|
+
readonly condition?: string;
|
|
101
|
+
readonly resendNote?: string;
|
|
102
|
+
readonly httpStatus?: number;
|
|
103
|
+
readonly source?: string;
|
|
104
|
+
readonly attempt?: number;
|
|
105
|
+
readonly maxAttempts?: number;
|
|
106
|
+
readonly elapsedMs?: number;
|
|
107
|
+
readonly timeoutMs?: number;
|
|
108
|
+
readonly retryAtMs?: number;
|
|
109
|
+
readonly detail?: string;
|
|
110
|
+
readonly recourse?: RetryStatusNotice['recourse'];
|
|
111
|
+
}
|
|
112
|
+
export declare function retryStatusParts(status: RetryStatus | null, ctx?: {
|
|
113
|
+
readonly modelName?: string;
|
|
114
|
+
}): RetryStatusParts;
|
|
96
115
|
export declare function retryStatusNotice(status: RetryStatus | null, ctx?: {
|
|
97
116
|
readonly modelName?: string;
|
|
98
117
|
}): RetryStatusNotice;
|
|
@@ -116,4 +135,11 @@ export interface ApiErrorNoticeCtx {
|
|
|
116
135
|
}
|
|
117
136
|
export declare function apiErrorFactsOfRow(row: ApiErrorRowLike | null | undefined): ApiErrorRowFacts;
|
|
118
137
|
export declare function apiErrorNotice(facts: ApiErrorRowFacts | null | undefined, ctx?: ApiErrorNoticeCtx): ApiErrorNotice | undefined;
|
|
138
|
+
export type ResultWayOutWord = NonNullable<ApiErrorNotice['recourse']>;
|
|
139
|
+
export interface ResultWayOut {
|
|
140
|
+
readonly word: ResultWayOutWord;
|
|
141
|
+
readonly keySource?: string;
|
|
142
|
+
}
|
|
143
|
+
export declare function resultWayOutOf(frame: object | null | undefined): ResultWayOut | undefined;
|
|
144
|
+
export declare function wayOutSentence(wayOut: ResultWayOut | null | undefined, lang?: UiLanguage): string | undefined;
|
|
119
145
|
export {};
|
package/dist/retryStatus.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { displayUntrusted } from './displayUntrusted.js';
|
|
2
2
|
import { guardedRead, readOwnDataFiniteNumber, readOwnDataNonEmptyString, readOwnDataValue } from './ownKey.js';
|
|
3
|
+
import { msg, renderMessage } from './i18n/translate.js';
|
|
4
|
+
import { conditionRecourseOf, isHttpStatus, isServiceSideStatus, terminalRecourseOf } from './providerRejection.js';
|
|
3
5
|
export const BRAIN_STATUS_PHASES = [
|
|
4
6
|
'rate_limited',
|
|
5
7
|
'retrying',
|
|
@@ -121,10 +123,10 @@ export function retryStatusFromArm(arm, nowMs) {
|
|
|
121
123
|
}
|
|
122
124
|
const WAIT_SWITCH_FRACTION = 0.5;
|
|
123
125
|
const CONDITION_READINGS = Object.freeze({
|
|
124
|
-
quota_exhausted: { clause: 'this account cannot be served by the model service until someone acts or its usage window resets'
|
|
125
|
-
throttled: { clause: 'the model service is rate limiting requests, which clears on its own'
|
|
126
|
-
overloaded: { clause: 'the model service is overloaded'
|
|
127
|
-
stop_other: { clause: 'the model service refused this request', resendNote: 'resending will not change it'
|
|
126
|
+
quota_exhausted: { clause: 'this account cannot be served by the model service until someone acts or its usage window resets' },
|
|
127
|
+
throttled: { clause: 'the model service is rate limiting requests, which clears on its own' },
|
|
128
|
+
overloaded: { clause: 'the model service is overloaded' },
|
|
129
|
+
stop_other: { clause: 'the model service refused this request', resendNote: 'resending will not change it' },
|
|
128
130
|
unknown: null,
|
|
129
131
|
});
|
|
130
132
|
function conditionReadingOf(word) {
|
|
@@ -151,7 +153,7 @@ function noticeCount(n) {
|
|
|
151
153
|
return n !== undefined && Number.isInteger(n) && n >= 1 ? n : undefined;
|
|
152
154
|
}
|
|
153
155
|
function noticeHttp(n) {
|
|
154
|
-
return
|
|
156
|
+
return isHttpStatus(n) ? n : undefined;
|
|
155
157
|
}
|
|
156
158
|
function spanText(ms) {
|
|
157
159
|
const total = Math.floor(ms / 1000);
|
|
@@ -172,11 +174,38 @@ function noticeAttemptTail(attempt, maxRetries) {
|
|
|
172
174
|
function sealNotice(line, phase, recourse) {
|
|
173
175
|
return Object.freeze(recourse === undefined ? { line, phase } : { line, recourse, phase });
|
|
174
176
|
}
|
|
175
|
-
|
|
177
|
+
const SOURCE_PHRASES = Object.freeze({
|
|
178
|
+
unified_header: 'notice.retry.source.unifiedHeader',
|
|
179
|
+
provider_code: 'notice.retry.source.providerCode',
|
|
180
|
+
status: 'notice.retry.source.status',
|
|
181
|
+
});
|
|
182
|
+
function sourcePhraseOf(word) {
|
|
183
|
+
if (word === undefined || !Object.hasOwn(SOURCE_PHRASES, word))
|
|
184
|
+
return undefined;
|
|
185
|
+
return renderMessage(msg(SOURCE_PHRASES[word]));
|
|
186
|
+
}
|
|
187
|
+
function sealParts(p) {
|
|
188
|
+
return Object.freeze({
|
|
189
|
+
phase: p.phase,
|
|
190
|
+
...(p.model !== undefined ? { model: p.model } : {}),
|
|
191
|
+
...(p.condition !== undefined ? { condition: p.condition } : {}),
|
|
192
|
+
...(p.resendNote !== undefined ? { resendNote: p.resendNote } : {}),
|
|
193
|
+
...(p.httpStatus !== undefined ? { httpStatus: p.httpStatus } : {}),
|
|
194
|
+
...(p.source !== undefined ? { source: p.source } : {}),
|
|
195
|
+
...(p.attempt !== undefined ? { attempt: p.attempt } : {}),
|
|
196
|
+
...(p.maxAttempts !== undefined ? { maxAttempts: p.maxAttempts } : {}),
|
|
197
|
+
...(p.elapsedMs !== undefined ? { elapsedMs: p.elapsedMs } : {}),
|
|
198
|
+
...(p.timeoutMs !== undefined ? { timeoutMs: p.timeoutMs } : {}),
|
|
199
|
+
...(p.retryAtMs !== undefined ? { retryAtMs: p.retryAtMs } : {}),
|
|
200
|
+
...(p.detail !== undefined ? { detail: p.detail } : {}),
|
|
201
|
+
...(p.recourse !== undefined ? { recourse: p.recourse } : {}),
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
export function retryStatusParts(status, ctx) {
|
|
176
205
|
const modelName = washedText(noticeText(ctx, 'modelName'))?.trim();
|
|
177
|
-
const
|
|
206
|
+
const model = modelName === undefined || modelName === '' ? undefined : modelName;
|
|
178
207
|
if (status === null)
|
|
179
|
-
return
|
|
208
|
+
return sealParts({ phase: 'cleared' });
|
|
180
209
|
const armWord = noticeText(status, 'kind');
|
|
181
210
|
const kind = armWord === 'stalled' || armWord === 'waiting' ? armWord : 'error';
|
|
182
211
|
if (kind === 'waiting') {
|
|
@@ -184,41 +213,71 @@ export function retryStatusNotice(status, ctx) {
|
|
|
184
213
|
const timeoutRaw = noticeNumber(status, 'timeoutMs');
|
|
185
214
|
const elapsed = elapsedRaw !== undefined && elapsedRaw >= 0 && elapsedRaw <= Number.MAX_SAFE_INTEGER ? elapsedRaw : undefined;
|
|
186
215
|
const ceiling = timeoutRaw !== undefined && timeoutRaw > 0 && timeoutRaw <= Number.MAX_SAFE_INTEGER ? timeoutRaw : undefined;
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
const text = `${prefix}Waiting for the model's first token${progress.length === 0 ? '' : ` — ${progress.join(', ')}`}${offerSwitch ? '; keep waiting or switch model' : ''}`;
|
|
190
|
-
return sealNotice(text, 'waiting_first_token', offerSwitch ? 'switch_model' : 'wait');
|
|
216
|
+
const offerSwitch = model !== undefined && elapsed !== undefined && ceiling !== undefined && elapsed >= ceiling * WAIT_SWITCH_FRACTION;
|
|
217
|
+
return sealParts({ phase: 'waiting_first_token', model, elapsedMs: elapsed, timeoutMs: ceiling, recourse: offerSwitch ? 'switch_model' : 'wait' });
|
|
191
218
|
}
|
|
192
219
|
const terminal = kind === 'error' && noticeValue(status, 'terminal') === true;
|
|
193
|
-
const
|
|
220
|
+
const conditionWord = noticeText(status, 'providerCondition');
|
|
221
|
+
const reading = conditionReadingOf(conditionWord);
|
|
194
222
|
const http = noticeHttp(noticeNumber(status, 'errorStatus'));
|
|
195
223
|
const attempt = noticeCount(noticeNumber(status, 'attempt'));
|
|
196
224
|
const maxRetries = noticeCount(noticeNumber(status, 'maxRetries'));
|
|
197
225
|
const engineWords = kind === 'stalled' ? noticeText(status, 'detail') : noticeText(noticeValue(status, 'error'), 'formatted');
|
|
198
|
-
const httpPart = http === undefined ? '' : ` (HTTP ${http})`;
|
|
199
|
-
let first;
|
|
200
|
-
if (terminal) {
|
|
201
|
-
const after = attempt === undefined ? '' : ` after ${attempt} attempt${attempt === 1 ? '' : 's'}`;
|
|
202
|
-
const why = reading === undefined ? '' : `: ${reading.clause}${reading.resendNote === undefined ? '' : `, and ${reading.resendNote}`}`;
|
|
203
|
-
first = `Stopped${after}${why}${httpPart}`;
|
|
204
|
-
}
|
|
205
|
-
else {
|
|
206
|
-
const head = reading !== undefined ? `${reading.clause.charAt(0).toUpperCase()}${reading.clause.slice(1)}` : http !== undefined || kind === 'error' ? 'Request failed' : 'Waiting for the API response';
|
|
207
|
-
first = `${head}${httpPart} — ${kind === 'stalled' ? 'will retry' : 'retrying'}${noticeAttemptTail(attempt, maxRetries)}`;
|
|
208
|
-
}
|
|
209
226
|
const note = washedText(engineWords);
|
|
210
|
-
const
|
|
227
|
+
const source = reading === undefined ? undefined : sourcePhraseOf(noticeText(status, 'providerConditionSource'));
|
|
228
|
+
const condition = reading === undefined ? undefined : `${reading.clause.charAt(0).toUpperCase()}${reading.clause.slice(1)}`;
|
|
229
|
+
const serviceSide = http !== undefined && isServiceSideStatus(http);
|
|
211
230
|
const knownArm = armWord === 'stalled' || armWord === 'error';
|
|
212
231
|
const recourse = !knownArm
|
|
213
232
|
? undefined
|
|
214
233
|
: reading !== undefined
|
|
215
|
-
?
|
|
234
|
+
? conditionRecourseOf(conditionWord)
|
|
216
235
|
: serviceSide
|
|
217
236
|
? 'switch_model'
|
|
218
237
|
: !terminal
|
|
219
238
|
? 'wait'
|
|
220
239
|
: undefined;
|
|
221
|
-
|
|
240
|
+
const deadlineRaw = knownArm && !terminal && noticeNumber(status, 'retryAtMs') !== undefined ? noticeNumber(status, 'deadline') : undefined;
|
|
241
|
+
const retryAtMs = deadlineRaw !== undefined && deadlineRaw > 0 ? deadlineRaw : undefined;
|
|
242
|
+
return sealParts({
|
|
243
|
+
phase: kind === 'stalled' ? 'reconnecting' : terminal ? 'gave_up' : 'retrying',
|
|
244
|
+
model,
|
|
245
|
+
condition,
|
|
246
|
+
resendNote: terminal ? reading?.resendNote : undefined,
|
|
247
|
+
httpStatus: http,
|
|
248
|
+
source,
|
|
249
|
+
attempt,
|
|
250
|
+
maxAttempts: maxRetries,
|
|
251
|
+
retryAtMs,
|
|
252
|
+
detail: note,
|
|
253
|
+
recourse,
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
function retryLineOfParts(parts) {
|
|
257
|
+
if (parts.phase === 'cleared')
|
|
258
|
+
return '';
|
|
259
|
+
const prefix = parts.model === undefined ? '' : `${parts.model}: `;
|
|
260
|
+
if (parts.phase === 'waiting_first_token') {
|
|
261
|
+
const progress = [...(parts.elapsedMs === undefined ? [] : [`${spanText(parts.elapsedMs)} so far`]), ...(parts.timeoutMs === undefined ? [] : [`limit ${spanText(parts.timeoutMs)}`])];
|
|
262
|
+
const offerSwitch = parts.recourse === 'switch_model';
|
|
263
|
+
return `${prefix}Waiting for the model's first token${progress.length === 0 ? '' : ` — ${progress.join(', ')}`}${offerSwitch ? '; keep waiting or switch model' : ''}`;
|
|
264
|
+
}
|
|
265
|
+
const httpPart = parts.httpStatus === undefined ? '' : ` (HTTP ${parts.httpStatus})`;
|
|
266
|
+
let first;
|
|
267
|
+
if (parts.phase === 'gave_up') {
|
|
268
|
+
const after = parts.attempt === undefined ? '' : ` after ${parts.attempt} attempt${parts.attempt === 1 ? '' : 's'}`;
|
|
269
|
+
const why = parts.condition === undefined ? '' : `: ${parts.condition.charAt(0).toLowerCase()}${parts.condition.slice(1)}${parts.resendNote === undefined ? '' : `, and ${parts.resendNote}`}`;
|
|
270
|
+
first = `Stopped${after}${why}${httpPart}`;
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
const head = parts.condition !== undefined ? parts.condition : parts.httpStatus !== undefined || parts.phase === 'retrying' ? 'Request failed' : 'Waiting for the API response';
|
|
274
|
+
first = `${head}${httpPart} — ${parts.phase === 'reconnecting' ? 'will retry' : 'retrying'}${noticeAttemptTail(parts.attempt, parts.maxAttempts)}`;
|
|
275
|
+
}
|
|
276
|
+
return `${prefix}${first}${parts.detail === undefined ? '' : ` · ${parts.detail}`}`;
|
|
277
|
+
}
|
|
278
|
+
export function retryStatusNotice(status, ctx) {
|
|
279
|
+
const parts = retryStatusParts(status, ctx);
|
|
280
|
+
return sealNotice(retryLineOfParts(parts), parts.phase, parts.recourse);
|
|
222
281
|
}
|
|
223
282
|
const API_ERROR_PROVIDER_TEXT_MAX = 200;
|
|
224
283
|
function isRecordObject(v) {
|
|
@@ -255,6 +314,52 @@ export function apiErrorNotice(facts, ctx) {
|
|
|
255
314
|
};
|
|
256
315
|
const modelName = noticeText(ctx, 'modelName');
|
|
257
316
|
const notice = retryStatusNotice(terminal, modelName !== undefined ? { modelName } : undefined);
|
|
258
|
-
const recourse = status
|
|
317
|
+
const recourse = terminalRecourseOf(status, providerCondition);
|
|
259
318
|
return Object.freeze(recourse === undefined ? { line: notice.line } : { line: notice.line, recourse });
|
|
260
319
|
}
|
|
320
|
+
const RESULT_WAY_OUT_WORDS = Object.freeze(['check_credentials', 'switch_model', 'wait', 'fix_request']);
|
|
321
|
+
const _wayOutWordPins = [true, true];
|
|
322
|
+
void _wayOutWordPins;
|
|
323
|
+
const KEY_SOURCE_DISPLAY_MAX = 60;
|
|
324
|
+
const WAY_OUT_SENTENCE_KEYS = Object.freeze({
|
|
325
|
+
check_credentials: 'notice.wayOut.checkCredentials',
|
|
326
|
+
switch_model: 'notice.wayOut.switchModel',
|
|
327
|
+
wait: 'notice.wayOut.wait',
|
|
328
|
+
fix_request: 'notice.wayOut.fixRequest',
|
|
329
|
+
});
|
|
330
|
+
function isResultWayOutWord(v) {
|
|
331
|
+
return typeof v === 'string' && RESULT_WAY_OUT_WORDS.includes(v);
|
|
332
|
+
}
|
|
333
|
+
export function resultWayOutOf(frame) {
|
|
334
|
+
try {
|
|
335
|
+
const raw = guardedRead(() => readOwnDataValue(frame, '_sema_wayOut'));
|
|
336
|
+
if (typeof raw !== 'object' || raw === null || Array.isArray(raw))
|
|
337
|
+
return undefined;
|
|
338
|
+
const word = guardedRead(() => readOwnDataNonEmptyString(raw, 'word'));
|
|
339
|
+
if (!isResultWayOutWord(word))
|
|
340
|
+
return undefined;
|
|
341
|
+
const keySource = guardedRead(() => readOwnDataNonEmptyString(raw, 'keySource'));
|
|
342
|
+
return Object.freeze(keySource === undefined ? { word } : { word, keySource });
|
|
343
|
+
}
|
|
344
|
+
catch {
|
|
345
|
+
return undefined;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
export function wayOutSentence(wayOut, lang) {
|
|
349
|
+
try {
|
|
350
|
+
if (typeof wayOut !== 'object' || wayOut === null)
|
|
351
|
+
return undefined;
|
|
352
|
+
const word = readOwnDataNonEmptyString(wayOut, 'word');
|
|
353
|
+
if (!isResultWayOutWord(word))
|
|
354
|
+
return undefined;
|
|
355
|
+
if (word === 'check_credentials') {
|
|
356
|
+
const keySource = readOwnDataNonEmptyString(wayOut, 'keySource');
|
|
357
|
+
if (keySource !== undefined)
|
|
358
|
+
return renderMessage(msg('notice.wayOut.checkCredentialsFrom', { source: displayUntrusted(keySource, { max: KEY_SOURCE_DISPLAY_MAX }) }), lang);
|
|
359
|
+
}
|
|
360
|
+
return renderMessage(msg(WAY_OUT_SENTENCE_KEYS[word]), lang);
|
|
361
|
+
}
|
|
362
|
+
catch {
|
|
363
|
+
return undefined;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { engineWireTargetBaseUrl } from './engineWireTarget.js';
|
|
2
2
|
import { rewindArchiveReadingAt, rewindConversationAvailability, } from './rewindArchiveReading.js';
|
|
3
3
|
import { unreadableReadingDetail } from './engineCapReader.js';
|
|
4
4
|
export { projectRewindArchiveCapability, rewindConversationAvailability } from './rewindArchiveReading.js';
|
|
5
|
-
export function observedRewindArchive(baseUrl =
|
|
5
|
+
export function observedRewindArchive(baseUrl = engineWireTargetBaseUrl()) {
|
|
6
6
|
return rewindArchiveReadingAt(baseUrl);
|
|
7
7
|
}
|
|
8
8
|
export function rewindCodeArchiveAvailability(reading, mode) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { UiLanguage } from './env/uiLanguage.js';
|
|
1
2
|
import { type RewindArchiveReading } from './rewindArchiveCapability.js';
|
|
2
3
|
import { type RewindMode, type SeamRewindSpec } from './rewindWireCaps.js';
|
|
3
4
|
export type RewindRestoreOption = RewindMode | 'summarize' | 'summarize_up_to' | 'nevermind';
|
|
@@ -19,3 +20,4 @@ export type RewindEngineAction = {
|
|
|
19
20
|
};
|
|
20
21
|
export declare function decideRewindEngineAction(option: RewindRestoreOption, resolved: RewindTargetResolution, reading?: RewindArchiveReading): RewindEngineAction;
|
|
21
22
|
export declare function previewEngineRewind(option: RewindRestoreOption, resolved: RewindTargetResolution, reading?: RewindArchiveReading): RewindEngineAction['kind'];
|
|
23
|
+
export declare function rewindConversationOnlyNotice(option: RewindRestoreOption, action: RewindEngineAction | null | undefined, lang?: UiLanguage, reading?: RewindArchiveReading): string | undefined;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { msg, renderMessage } from './i18n/translate.js';
|
|
2
|
+
import { engineRewindRefusedNow, observedRewindArchive } from './rewindArchiveCapability.js';
|
|
2
3
|
import { REWIND_MODES, rewindSpecForMode } from './rewindWireCaps.js';
|
|
3
4
|
import { readOwnDataNonEmptyString, readOwnDataValue } from './ownKey.js';
|
|
4
5
|
function modeOfOption(option) {
|
|
@@ -34,3 +35,24 @@ export function decideRewindEngineAction(option, resolved, reading = observedRew
|
|
|
34
35
|
export function previewEngineRewind(option, resolved, reading = observedRewindArchive()) {
|
|
35
36
|
return decideRewindEngineAction(option, resolved, reading).kind;
|
|
36
37
|
}
|
|
38
|
+
const UNOBSERVED_READING = { kind: 'unobserved' };
|
|
39
|
+
export function rewindConversationOnlyNotice(option, action, lang, reading = observedRewindArchive()) {
|
|
40
|
+
try {
|
|
41
|
+
const mode = modeOfOption(option);
|
|
42
|
+
if (mode === undefined || rewindSpecForMode(mode, 'x', UNOBSERVED_READING).restoreFiles !== true)
|
|
43
|
+
return undefined;
|
|
44
|
+
if (typeof action !== 'object' || action === null || readOwnDataValue(action, 'kind') !== 'arm')
|
|
45
|
+
return undefined;
|
|
46
|
+
const spec = readOwnDataValue(action, 'spec');
|
|
47
|
+
if (typeof spec !== 'object' || spec === null)
|
|
48
|
+
return undefined;
|
|
49
|
+
if (readOwnDataValue(spec, 'restoreFiles') === true)
|
|
50
|
+
return undefined;
|
|
51
|
+
const codeOnlyMode = REWIND_MODES.find((m) => !carriesResumeAt(m));
|
|
52
|
+
const codeRouteDeadEnd = codeOnlyMode !== undefined && engineRewindRefusedNow(codeOnlyMode, reading);
|
|
53
|
+
return renderMessage(msg(codeRouteDeadEnd ? 'session.rewind.conversationOnly.noCodeRoute' : 'session.rewind.conversationOnly.withCodeRoute'), lang);
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export declare const RUN_STOPPED_MESSAGE_PREFIX = "Run stopped";
|
|
2
|
+
export declare const RUN_BLOCKED_MESSAGE_PREFIX = "Run blocked";
|
|
3
|
+
export declare const PROMPT_BLOCKED_BY_HOOK_ROW_LEAD = "UserPromptSubmit operation blocked by hook";
|
|
4
|
+
export declare const MODEL_OUTPUT_ERROR_PREFIX = "Model output error";
|
|
5
|
+
export declare const OUTCOME_UNKNOWN_ROW_PREFIX = "Outcome unknown";
|
|
6
|
+
export declare const SESSION_BUSY_ROW_LEAD = "This session is locked by an earlier run";
|
|
7
|
+
export declare const SEMA_ROW_KIND_KEY = "_sema_row_kind";
|
|
8
|
+
export declare const SEMA_ROW_KINDS: readonly [Readonly<{
|
|
9
|
+
kind: "api_error";
|
|
10
|
+
owner: "client-core";
|
|
11
|
+
}>, Readonly<{
|
|
12
|
+
kind: "governance_stop";
|
|
13
|
+
owner: "client-core";
|
|
14
|
+
}>, Readonly<{
|
|
15
|
+
kind: "model_output_error";
|
|
16
|
+
owner: "client-core";
|
|
17
|
+
}>, Readonly<{
|
|
18
|
+
kind: "outcome_unknown";
|
|
19
|
+
owner: "client-core";
|
|
20
|
+
}>, Readonly<{
|
|
21
|
+
kind: "session_busy";
|
|
22
|
+
owner: "client-core";
|
|
23
|
+
}>, Readonly<{
|
|
24
|
+
kind: "engine_link";
|
|
25
|
+
owner: "client-core";
|
|
26
|
+
}>];
|
|
27
|
+
export type SemaRowKind = (typeof SEMA_ROW_KINDS)[number]['kind'];
|
|
28
|
+
export declare function rowKindOf(m: object | null | undefined): SemaRowKind | undefined;
|
|
29
|
+
export declare function rowKindOf<H extends string>(m: object | null | undefined, opts: {
|
|
30
|
+
readonly hostKinds: readonly H[];
|
|
31
|
+
}): SemaRowKind | H | undefined;
|
|
32
|
+
export declare function isSyntheticRow(m: object | null | undefined): boolean;
|
|
33
|
+
export declare function legacyRowKindOfText(text: string): SemaRowKind | undefined;
|
|
34
|
+
export declare function inferLegacyRowKind(m: object | null | undefined, opts?: {
|
|
35
|
+
readonly requireFlag?: boolean;
|
|
36
|
+
}): SemaRowKind | undefined;
|
package/dist/rowKind.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { guardedRead, readOwnDataValue } from './ownKey.js';
|
|
2
|
+
export const RUN_STOPPED_MESSAGE_PREFIX = 'Run stopped';
|
|
3
|
+
export const RUN_BLOCKED_MESSAGE_PREFIX = 'Run blocked';
|
|
4
|
+
export const PROMPT_BLOCKED_BY_HOOK_ROW_LEAD = 'UserPromptSubmit operation blocked by hook';
|
|
5
|
+
export const MODEL_OUTPUT_ERROR_PREFIX = 'Model output error';
|
|
6
|
+
export const OUTCOME_UNKNOWN_ROW_PREFIX = 'Outcome unknown';
|
|
7
|
+
export const SESSION_BUSY_ROW_LEAD = 'This session is locked by an earlier run';
|
|
8
|
+
const API_ERROR_ROW_PREFIX = 'API Error';
|
|
9
|
+
const LOGIN_API_ERROR_ROW_PREFIX = `Please run /login · ${API_ERROR_ROW_PREFIX}`;
|
|
10
|
+
export const SEMA_ROW_KIND_KEY = '_sema_row_kind';
|
|
11
|
+
export const SEMA_ROW_KINDS = Object.freeze([
|
|
12
|
+
Object.freeze({ kind: 'api_error', owner: 'client-core' }),
|
|
13
|
+
Object.freeze({ kind: 'governance_stop', owner: 'client-core' }),
|
|
14
|
+
Object.freeze({ kind: 'model_output_error', owner: 'client-core' }),
|
|
15
|
+
Object.freeze({ kind: 'outcome_unknown', owner: 'client-core' }),
|
|
16
|
+
Object.freeze({ kind: 'session_busy', owner: 'client-core' }),
|
|
17
|
+
Object.freeze({ kind: 'engine_link', owner: 'client-core' }),
|
|
18
|
+
]);
|
|
19
|
+
const KIND_WORDS = new Set(SEMA_ROW_KINDS.map((e) => e.kind));
|
|
20
|
+
const ownData = (o, key) => guardedRead(() => readOwnDataValue(o, key));
|
|
21
|
+
export function rowKindOf(m, opts) {
|
|
22
|
+
const v = ownData(m, SEMA_ROW_KIND_KEY);
|
|
23
|
+
if (typeof v !== 'string' || v.length === 0)
|
|
24
|
+
return undefined;
|
|
25
|
+
if (KIND_WORDS.has(v))
|
|
26
|
+
return v;
|
|
27
|
+
const hostKinds = opts === undefined ? undefined : ownData(opts, 'hostKinds');
|
|
28
|
+
if (Array.isArray(hostKinds)) {
|
|
29
|
+
try {
|
|
30
|
+
if (hostKinds.includes(v))
|
|
31
|
+
return v;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
function hasSyntheticFlag(m) {
|
|
40
|
+
return ownData(m, '_sema_api_error_message') === true || ownData(m, 'isApiErrorMessage') === true;
|
|
41
|
+
}
|
|
42
|
+
export function isSyntheticRow(m) {
|
|
43
|
+
const v = ownData(m, SEMA_ROW_KIND_KEY);
|
|
44
|
+
if (typeof v === 'string' && v.length > 0)
|
|
45
|
+
return true;
|
|
46
|
+
return hasSyntheticFlag(m);
|
|
47
|
+
}
|
|
48
|
+
export function legacyRowKindOfText(text) {
|
|
49
|
+
const t = text.trimStart();
|
|
50
|
+
if (t.startsWith(API_ERROR_ROW_PREFIX) || t.startsWith(LOGIN_API_ERROR_ROW_PREFIX))
|
|
51
|
+
return 'api_error';
|
|
52
|
+
if (t.startsWith(`${RUN_STOPPED_MESSAGE_PREFIX}:`) || t.startsWith(RUN_BLOCKED_MESSAGE_PREFIX) || t.startsWith(PROMPT_BLOCKED_BY_HOOK_ROW_LEAD))
|
|
53
|
+
return 'governance_stop';
|
|
54
|
+
if (t.startsWith(`${MODEL_OUTPUT_ERROR_PREFIX}:`))
|
|
55
|
+
return 'model_output_error';
|
|
56
|
+
if (t.startsWith(`${OUTCOME_UNKNOWN_ROW_PREFIX}:`))
|
|
57
|
+
return 'outcome_unknown';
|
|
58
|
+
if (t.startsWith(SESSION_BUSY_ROW_LEAD))
|
|
59
|
+
return 'session_busy';
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
function singleTextOf(m) {
|
|
63
|
+
if (ownData(m, 'type') !== 'assistant')
|
|
64
|
+
return undefined;
|
|
65
|
+
const envelope = ownData(m, 'message');
|
|
66
|
+
if (typeof envelope !== 'object' || envelope === null)
|
|
67
|
+
return undefined;
|
|
68
|
+
const content = ownData(envelope, 'content');
|
|
69
|
+
if (typeof content === 'string')
|
|
70
|
+
return content;
|
|
71
|
+
if (!Array.isArray(content))
|
|
72
|
+
return undefined;
|
|
73
|
+
try {
|
|
74
|
+
if (content.length !== 1)
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
const block = ownData(content, '0');
|
|
81
|
+
if (ownData(block, 'type') !== 'text')
|
|
82
|
+
return undefined;
|
|
83
|
+
const text = ownData(block, 'text');
|
|
84
|
+
return typeof text === 'string' ? text : undefined;
|
|
85
|
+
}
|
|
86
|
+
export function inferLegacyRowKind(m, opts) {
|
|
87
|
+
const present = rowKindOf(m);
|
|
88
|
+
if (present !== undefined)
|
|
89
|
+
return present;
|
|
90
|
+
if (ownData(m, SEMA_ROW_KIND_KEY) !== undefined)
|
|
91
|
+
return undefined;
|
|
92
|
+
const requireFlag = opts === undefined ? true : ownData(opts, 'requireFlag') !== false;
|
|
93
|
+
if (requireFlag && !hasSyntheticFlag(m))
|
|
94
|
+
return undefined;
|
|
95
|
+
const text = singleTextOf(m);
|
|
96
|
+
return text === undefined ? undefined : legacyRowKindOfText(text);
|
|
97
|
+
}
|
|
@@ -8,3 +8,21 @@ export type RuleCompileVerdict = {
|
|
|
8
8
|
readonly kind: 'unknown';
|
|
9
9
|
};
|
|
10
10
|
export declare function ruleCompileVerdict(rule: string, behavior: 'deny' | 'ask'): RuleCompileVerdict;
|
|
11
|
+
export interface RuleCompilePathBases {
|
|
12
|
+
readonly cwd?: string;
|
|
13
|
+
readonly root?: string;
|
|
14
|
+
readonly home?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function ruleCompileVerdictUnder(rule: string, behavior: 'deny' | 'ask', pathBases: RuleCompilePathBases): RuleCompileVerdict;
|
|
17
|
+
export type DenyEntryInertReason = 'grammar' | 'content_unsupported' | 'wildcard_all' | 'namespace_wildcard';
|
|
18
|
+
export type DenyEntryReading = {
|
|
19
|
+
readonly kind: 'row';
|
|
20
|
+
} | {
|
|
21
|
+
readonly kind: 'inert';
|
|
22
|
+
readonly reason: DenyEntryInertReason;
|
|
23
|
+
} | {
|
|
24
|
+
readonly kind: 'unknown';
|
|
25
|
+
};
|
|
26
|
+
export declare function denyEntryReading(rule: string): DenyEntryReading;
|
|
27
|
+
export declare const DOMAIN_TIGHTEN_HONORED_FROM = "7.135.0";
|
|
28
|
+
export declare function tightenEntryNeverMatches(rule: string, serverVersion: string | undefined): boolean;
|