@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,4 +1,6 @@
|
|
|
1
|
-
import { validatePermissionRules } from './coreValuePorts.js';
|
|
1
|
+
import { readRuleEntry, validatePermissionRules } from './coreValuePorts.js';
|
|
2
|
+
import { guardedRead, readOwnDataValue } from './ownKey.js';
|
|
3
|
+
import { engineVersionTier } from './supportFloor.js';
|
|
2
4
|
const RULE_COMPILE_ROOT = '/';
|
|
3
5
|
function issueText(issue, key) {
|
|
4
6
|
try {
|
|
@@ -20,9 +22,21 @@ function firstIssue(issues) {
|
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
export function ruleCompileVerdict(rule, behavior) {
|
|
25
|
+
return compileUnder(rule, behavior, { root: RULE_COMPILE_ROOT });
|
|
26
|
+
}
|
|
27
|
+
export function ruleCompileVerdictUnder(rule, behavior, pathBases) {
|
|
28
|
+
const given = {};
|
|
29
|
+
for (const base of ['cwd', 'root', 'home']) {
|
|
30
|
+
const v = guardedRead(() => readOwnDataValue(pathBases, base));
|
|
31
|
+
if (typeof v === 'string')
|
|
32
|
+
given[base] = v;
|
|
33
|
+
}
|
|
34
|
+
return compileUnder(rule, behavior, given);
|
|
35
|
+
}
|
|
36
|
+
function compileUnder(rule, behavior, pathBases) {
|
|
23
37
|
let issues;
|
|
24
38
|
try {
|
|
25
|
-
issues = validatePermissionRules([{ rule, behavior }], { pathBases
|
|
39
|
+
issues = validatePermissionRules([{ rule, behavior }], { pathBases });
|
|
26
40
|
if (!Array.isArray(issues))
|
|
27
41
|
return { kind: 'unknown' };
|
|
28
42
|
if (issues.length === 0)
|
|
@@ -36,3 +50,54 @@ export function ruleCompileVerdict(rule, behavior) {
|
|
|
36
50
|
const message = issueText(issue, 'message');
|
|
37
51
|
return { kind: 'refused', ...(code !== undefined ? { code } : {}), ...(message !== undefined ? { message } : {}) };
|
|
38
52
|
}
|
|
53
|
+
export function denyEntryReading(rule) {
|
|
54
|
+
try {
|
|
55
|
+
const reading = readRuleEntry(rule, 'deny');
|
|
56
|
+
if (typeof reading !== 'object' || reading === null)
|
|
57
|
+
return { kind: 'unknown' };
|
|
58
|
+
const kind = readOwnDataValue(reading, 'kind');
|
|
59
|
+
if (kind === 'row') {
|
|
60
|
+
const compiled = readOwnDataValue(reading, 'compiled');
|
|
61
|
+
return typeof compiled === 'object' && compiled !== null ? { kind: 'row' } : { kind: 'unknown' };
|
|
62
|
+
}
|
|
63
|
+
if (kind !== 'inert')
|
|
64
|
+
return { kind: 'unknown' };
|
|
65
|
+
const reason = readOwnDataValue(reading, 'reason');
|
|
66
|
+
if (reason === 'grammar' || reason === 'content_unsupported' || reason === 'wildcard_all' || reason === 'namespace_wildcard')
|
|
67
|
+
return { kind: 'inert', reason };
|
|
68
|
+
return { kind: 'unknown' };
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return { kind: 'unknown' };
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function readsAsDomainSpelling(rule) {
|
|
75
|
+
try {
|
|
76
|
+
const reading = readRuleEntry(rule, 'allow');
|
|
77
|
+
if (typeof reading !== 'object' || reading === null)
|
|
78
|
+
return false;
|
|
79
|
+
if (readOwnDataValue(reading, 'kind') !== 'row')
|
|
80
|
+
return false;
|
|
81
|
+
const compiled = readOwnDataValue(reading, 'compiled');
|
|
82
|
+
if (typeof compiled !== 'object' || compiled === null)
|
|
83
|
+
return false;
|
|
84
|
+
return readOwnDataValue(compiled, 'kind') === 'domain';
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
export const DOMAIN_TIGHTEN_HONORED_FROM = '7.135.0';
|
|
91
|
+
function targetLeavesDomainTightenInert(serverVersion) {
|
|
92
|
+
return engineVersionTier(serverVersion) === 'engine' && engineVersionTier(serverVersion, DOMAIN_TIGHTEN_HONORED_FROM) === 'legacy';
|
|
93
|
+
}
|
|
94
|
+
export function tightenEntryNeverMatches(rule, serverVersion) {
|
|
95
|
+
if (!targetLeavesDomainTightenInert(serverVersion))
|
|
96
|
+
return false;
|
|
97
|
+
const r = denyEntryReading(rule);
|
|
98
|
+
if (r.kind !== 'inert' || r.reason !== 'content_unsupported')
|
|
99
|
+
return false;
|
|
100
|
+
if (!readsAsDomainSpelling(rule))
|
|
101
|
+
return false;
|
|
102
|
+
return ruleCompileVerdict(rule, 'deny').kind === 'compiles';
|
|
103
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { UiLanguage } from './env/uiLanguage.js';
|
|
2
|
+
import { type PermissionsDeclarationInput, type PermissionsKeptReason, type WireRuleOrigin } from './permissionsDeclaration.js';
|
|
3
|
+
import type { PermissionsAllowGrantReading } from './permissionsAllowGrantCapability.js';
|
|
4
|
+
import { type RuleCompileVerdict } from './ruleCompileVerdict.js';
|
|
5
|
+
import type { ToolRosterView } from './toolRoster.js';
|
|
6
|
+
export interface RuleReadingBases {
|
|
7
|
+
readonly cwd?: string;
|
|
8
|
+
readonly root?: string;
|
|
9
|
+
readonly home?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface RuleReadingFacts {
|
|
12
|
+
readonly bases?: RuleReadingBases;
|
|
13
|
+
readonly roster?: ToolRosterView | null;
|
|
14
|
+
}
|
|
15
|
+
export interface RuleReadingEntryRow {
|
|
16
|
+
readonly kind: 'row';
|
|
17
|
+
readonly grammar: string;
|
|
18
|
+
}
|
|
19
|
+
export interface RuleReadingEntryInert {
|
|
20
|
+
readonly kind: 'inert';
|
|
21
|
+
readonly reason: string;
|
|
22
|
+
readonly verdict?: string;
|
|
23
|
+
readonly currentName?: string;
|
|
24
|
+
readonly currentNameShown?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface RuleReadingEntryUnread {
|
|
27
|
+
readonly kind: 'unread';
|
|
28
|
+
}
|
|
29
|
+
export type RuleReadingEntry = RuleReadingEntryRow | RuleReadingEntryInert | RuleReadingEntryUnread;
|
|
30
|
+
export type PermissionsRuleCompileReading = RuleCompileVerdict;
|
|
31
|
+
export interface PermissionsRuleWireSent {
|
|
32
|
+
readonly sent: true;
|
|
33
|
+
readonly as: string;
|
|
34
|
+
}
|
|
35
|
+
export interface PermissionsRuleWireKept {
|
|
36
|
+
readonly sent: false;
|
|
37
|
+
readonly reason: PermissionsKeptReason;
|
|
38
|
+
readonly code?: string;
|
|
39
|
+
readonly message?: string;
|
|
40
|
+
}
|
|
41
|
+
export type PermissionsRuleWire = PermissionsRuleWireSent | PermissionsRuleWireKept;
|
|
42
|
+
export interface PermissionsRuleReading {
|
|
43
|
+
readonly rule: string;
|
|
44
|
+
readonly list: 'deny' | 'cliDeny' | 'ask' | 'allow';
|
|
45
|
+
readonly bucket: 'deny' | 'ask' | 'allow';
|
|
46
|
+
readonly origin?: WireRuleOrigin;
|
|
47
|
+
readonly wire: PermissionsRuleWire;
|
|
48
|
+
readonly entry: RuleReadingEntry;
|
|
49
|
+
readonly compile?: PermissionsRuleCompileReading;
|
|
50
|
+
}
|
|
51
|
+
export type RuleReadingEntryMode = 'with_roster' | 'grammar_only' | 'unavailable';
|
|
52
|
+
export interface PermissionsRuleReadings {
|
|
53
|
+
readonly rules: readonly PermissionsRuleReading[];
|
|
54
|
+
readonly entryMode: RuleReadingEntryMode;
|
|
55
|
+
}
|
|
56
|
+
export declare function ruleReadingsOf(input: PermissionsDeclarationInput, caps: PermissionsAllowGrantReading, facts?: RuleReadingFacts | null): PermissionsRuleReadings;
|
|
57
|
+
export type RuleNearMissRow = Pick<PermissionsRuleReading, 'rule' | 'wire' | 'entry'>;
|
|
58
|
+
export declare function ruleNearMissSentence(rows: readonly RuleNearMissRow[], lang?: UiLanguage): string | undefined;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { displayUntrusted } from './displayUntrusted.js';
|
|
2
|
+
import { capForDisplay } from './fleetTaskDesc.js';
|
|
3
|
+
import { hasCoreValuePort, readRuleEntry } from './coreValuePorts.js';
|
|
4
|
+
import { msg, renderMessage } from './i18n/translate.js';
|
|
5
|
+
import { guardedRead, readOwnDataValue } from './ownKey.js';
|
|
6
|
+
import { assembledRuleRows } from './permissionsDeclaration.js';
|
|
7
|
+
import { ruleCompileVerdictUnder } from './ruleCompileVerdict.js';
|
|
8
|
+
import { rosterMountedNames } from './rosterMountedNames.js';
|
|
9
|
+
const unread = () => Object.freeze({ kind: 'unread' });
|
|
10
|
+
function text(v) {
|
|
11
|
+
return typeof v === 'string' && v !== '' ? v : undefined;
|
|
12
|
+
}
|
|
13
|
+
function entryOf(rule, direction, roster) {
|
|
14
|
+
try {
|
|
15
|
+
const reading = readRuleEntry(rule, direction, roster);
|
|
16
|
+
if (typeof reading !== 'object' || reading === null)
|
|
17
|
+
return unread();
|
|
18
|
+
const kind = readOwnDataValue(reading, 'kind');
|
|
19
|
+
if (kind === 'row') {
|
|
20
|
+
const compiled = readOwnDataValue(reading, 'compiled');
|
|
21
|
+
if (typeof compiled !== 'object' || compiled === null)
|
|
22
|
+
return unread();
|
|
23
|
+
const grammar = text(readOwnDataValue(compiled, 'kind'));
|
|
24
|
+
return grammar === undefined ? unread() : Object.freeze({ kind: 'row', grammar });
|
|
25
|
+
}
|
|
26
|
+
if (kind !== 'inert')
|
|
27
|
+
return unread();
|
|
28
|
+
const reason = text(readOwnDataValue(reading, 'reason'));
|
|
29
|
+
if (reason === undefined)
|
|
30
|
+
return unread();
|
|
31
|
+
const verdict = text(readOwnDataValue(reading, 'verdict'));
|
|
32
|
+
const currentName = text(readOwnDataValue(reading, 'currentName'));
|
|
33
|
+
return Object.freeze({
|
|
34
|
+
kind: 'inert',
|
|
35
|
+
reason,
|
|
36
|
+
...(verdict !== undefined ? { verdict } : {}),
|
|
37
|
+
...(currentName !== undefined ? { currentName, currentNameShown: displayUntrusted(currentName) } : {}),
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return unread();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function factsOf(facts) {
|
|
45
|
+
if (typeof facts !== 'object' || facts === null)
|
|
46
|
+
return { bases: undefined, roster: undefined };
|
|
47
|
+
const bases = guardedRead(() => readOwnDataValue(facts, 'bases'));
|
|
48
|
+
const roster = guardedRead(() => readOwnDataValue(facts, 'roster'));
|
|
49
|
+
return {
|
|
50
|
+
bases: typeof bases === 'object' && bases !== null ? bases : undefined,
|
|
51
|
+
roster: (roster ?? undefined),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export function ruleReadingsOf(input, caps, facts) {
|
|
55
|
+
const rows = assembledRuleRows(input, caps);
|
|
56
|
+
const { bases, roster: rosterView } = factsOf(facts);
|
|
57
|
+
const readerInstalled = hasCoreValuePort('readRuleEntry');
|
|
58
|
+
const mounted = readerInstalled ? rosterMountedNames(rosterView) : 'absent';
|
|
59
|
+
const roster = typeof mounted === 'object' ? mounted : undefined;
|
|
60
|
+
const rules = rows.map((r) => {
|
|
61
|
+
const wire = r.fate.sent
|
|
62
|
+
? Object.freeze({ sent: true, as: r.fate.wire })
|
|
63
|
+
: Object.freeze({
|
|
64
|
+
sent: false,
|
|
65
|
+
reason: r.fate.reason,
|
|
66
|
+
...(r.fate.code !== undefined ? { code: r.fate.code } : {}),
|
|
67
|
+
...(r.fate.message !== undefined ? { message: r.fate.message } : {}),
|
|
68
|
+
});
|
|
69
|
+
const entry = readerInstalled ? entryOf(r.rule, r.bucket === 'allow' ? 'allow' : 'deny', roster) : unread();
|
|
70
|
+
const compile = bases !== undefined && r.bucket !== 'allow' ? ruleCompileVerdictUnder(r.rule, r.bucket, bases) : undefined;
|
|
71
|
+
return Object.freeze({
|
|
72
|
+
rule: r.rule,
|
|
73
|
+
list: r.list,
|
|
74
|
+
bucket: r.bucket,
|
|
75
|
+
...(r.origin !== undefined ? { origin: r.origin } : {}),
|
|
76
|
+
wire,
|
|
77
|
+
entry,
|
|
78
|
+
...(compile !== undefined ? { compile } : {}),
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
const anyRead = rules.some((r) => r.entry.kind !== 'unread');
|
|
82
|
+
const entryMode = !readerInstalled || (rules.length > 0 && !anyRead) ? 'unavailable' : roster !== undefined ? 'with_roster' : 'grammar_only';
|
|
83
|
+
return Object.freeze({ rules: Object.freeze(rules), entryMode });
|
|
84
|
+
}
|
|
85
|
+
const NEAR_MISS_NAMED_MAX = 5;
|
|
86
|
+
const NEAR_MISS_RULE_MAX = 120;
|
|
87
|
+
const NEAR_MISS_NAME_MAX = 80;
|
|
88
|
+
export function ruleNearMissSentence(rows, lang) {
|
|
89
|
+
const seen = new Set();
|
|
90
|
+
const items = [];
|
|
91
|
+
try {
|
|
92
|
+
if (!Array.isArray(rows))
|
|
93
|
+
return undefined;
|
|
94
|
+
for (const row of rows) {
|
|
95
|
+
if (typeof row !== 'object' || row === null)
|
|
96
|
+
continue;
|
|
97
|
+
const rule = guardedRead(() => readOwnDataValue(row, 'rule'));
|
|
98
|
+
if (typeof rule !== 'string' || rule === '' || seen.has(rule))
|
|
99
|
+
continue;
|
|
100
|
+
const wire = guardedRead(() => readOwnDataValue(row, 'wire'));
|
|
101
|
+
if (typeof wire !== 'object' || wire === null || guardedRead(() => readOwnDataValue(wire, 'sent')) !== true)
|
|
102
|
+
continue;
|
|
103
|
+
const entry = guardedRead(() => readOwnDataValue(row, 'entry'));
|
|
104
|
+
if (typeof entry !== 'object' || entry === null)
|
|
105
|
+
continue;
|
|
106
|
+
if (guardedRead(() => readOwnDataValue(entry, 'kind')) !== 'inert' || guardedRead(() => readOwnDataValue(entry, 'reason')) !== 'near_miss')
|
|
107
|
+
continue;
|
|
108
|
+
const mounted = text(guardedRead(() => readOwnDataValue(entry, 'currentName')));
|
|
109
|
+
if (mounted === undefined)
|
|
110
|
+
continue;
|
|
111
|
+
seen.add(rule);
|
|
112
|
+
items.push({ rule, mounted });
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
return undefined;
|
|
117
|
+
}
|
|
118
|
+
if (items.length === 0)
|
|
119
|
+
return undefined;
|
|
120
|
+
const shown = items.slice(0, NEAR_MISS_NAMED_MAX);
|
|
121
|
+
const separator = renderMessage(msg('rules.refusal.itemSeparator'), lang);
|
|
122
|
+
const named = shown
|
|
123
|
+
.map((it) => renderMessage(msg('rules.refusal.item', {
|
|
124
|
+
rule: `"${capForDisplay(it.rule, NEAR_MISS_RULE_MAX)}"`,
|
|
125
|
+
reason: renderMessage(msg('rules.nearMiss.reason', { mounted: capForDisplay(displayUntrusted(it.mounted), NEAR_MISS_NAME_MAX) }), lang),
|
|
126
|
+
}), lang))
|
|
127
|
+
.join(separator);
|
|
128
|
+
const rest = items.length - shown.length;
|
|
129
|
+
const list = rest > 0 ? msg('rules.refusal.list.more', { shown: named, count: rest }) : named;
|
|
130
|
+
const listText = typeof list === 'string' ? list : renderMessage(list, lang);
|
|
131
|
+
return renderMessage(items.length === 1 ? msg('rules.nearMiss.sentence.one', { list: listText }) : msg('rules.nearMiss.sentence.other', { count: items.length, list: listText }), lang);
|
|
132
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { UiLanguage } from './env/uiLanguage.js';
|
|
2
|
+
import type { PermissionsKeptRule } from './permissionsDeclaration.js';
|
|
3
|
+
export type RuleRefusalRow = Pick<PermissionsKeptRule, 'rule' | 'reason' | 'code' | 'message'>;
|
|
4
|
+
export declare function ruleRefusalSentence(rows: readonly RuleRefusalRow[], lang?: UiLanguage): string | undefined;
|
|
5
|
+
export declare function ruleRefusalListText(items: readonly {
|
|
6
|
+
readonly rule?: string;
|
|
7
|
+
readonly reason: string;
|
|
8
|
+
}[], lang?: UiLanguage): string;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { capForDisplay } from './fleetTaskDesc.js';
|
|
2
|
+
import { msg, renderMessage } from './i18n/translate.js';
|
|
3
|
+
import { permissionRuleIssueDetail } from './permissionRuleIssue.js';
|
|
4
|
+
const RULE_REFUSAL_NAMED_MAX = 5;
|
|
5
|
+
const RULE_NAME_MAX = 120;
|
|
6
|
+
const CLASS_OF_REASON = Object.freeze({
|
|
7
|
+
retired_tool_name: 'toolName',
|
|
8
|
+
unprefixed_namespaced_name: 'toolName',
|
|
9
|
+
incomplete_protocol_name: 'toolName',
|
|
10
|
+
home_relative_path: 'homePath',
|
|
11
|
+
compile_refused: 'compile',
|
|
12
|
+
paren_in_tool_name: 'compile',
|
|
13
|
+
content_form_never_matches: 'neverMatches',
|
|
14
|
+
});
|
|
15
|
+
function reasonOf(row, lang) {
|
|
16
|
+
const cls = typeof row.reason === 'string' && Object.hasOwn(CLASS_OF_REASON, row.reason) ? CLASS_OF_REASON[row.reason] : undefined;
|
|
17
|
+
if (cls === 'toolName')
|
|
18
|
+
return renderMessage(msg('rules.refusal.reason.toolName'), lang);
|
|
19
|
+
if (cls === 'homePath')
|
|
20
|
+
return renderMessage(msg('rules.refusal.reason.homePath'), lang);
|
|
21
|
+
if (cls === 'neverMatches')
|
|
22
|
+
return renderMessage(msg('rules.refusal.reason.neverMatches'), lang);
|
|
23
|
+
if (cls === 'compile')
|
|
24
|
+
return permissionRuleIssueDetail(row.code, row.message, row.rule, lang);
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
function nameOf(rule) {
|
|
28
|
+
return `"${capForDisplay(rule, RULE_NAME_MAX)}"`;
|
|
29
|
+
}
|
|
30
|
+
export function ruleRefusalSentence(rows, lang) {
|
|
31
|
+
const seen = new Set();
|
|
32
|
+
const items = [];
|
|
33
|
+
try {
|
|
34
|
+
if (!Array.isArray(rows))
|
|
35
|
+
return undefined;
|
|
36
|
+
for (const row of rows) {
|
|
37
|
+
if (typeof row !== 'object' || row === null)
|
|
38
|
+
continue;
|
|
39
|
+
const rule = row.rule;
|
|
40
|
+
if (typeof rule !== 'string' || rule === '' || seen.has(rule))
|
|
41
|
+
continue;
|
|
42
|
+
const reason = reasonOf(row, lang);
|
|
43
|
+
if (reason === undefined)
|
|
44
|
+
continue;
|
|
45
|
+
seen.add(rule);
|
|
46
|
+
items.push({ rule, reason });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
if (items.length === 0)
|
|
53
|
+
return undefined;
|
|
54
|
+
const listText = ruleRefusalListText(items, lang);
|
|
55
|
+
return renderMessage(items.length === 1 ? msg('rules.refusal.sentence.one', { list: listText }) : msg('rules.refusal.sentence.other', { count: items.length, list: listText }), lang);
|
|
56
|
+
}
|
|
57
|
+
export function ruleRefusalListText(items, lang) {
|
|
58
|
+
const shown = items.slice(0, RULE_REFUSAL_NAMED_MAX);
|
|
59
|
+
const separator = renderMessage(msg('rules.refusal.itemSeparator'), lang);
|
|
60
|
+
const named = shown.map((it) => (it.rule === undefined ? it.reason : renderMessage(msg('rules.refusal.item', { rule: nameOf(it.rule), reason: it.reason }), lang))).join(separator);
|
|
61
|
+
const rest = items.length - shown.length;
|
|
62
|
+
const list = rest > 0 ? msg('rules.refusal.list.more', { shown: named, count: rest }) : named;
|
|
63
|
+
return typeof list === 'string' ? list : renderMessage(list, lang);
|
|
64
|
+
}
|
|
@@ -30,7 +30,6 @@ export type RunAbortCause = {
|
|
|
30
30
|
};
|
|
31
31
|
export declare const RUN_CANCELLED_CODE: "cancelled";
|
|
32
32
|
export declare function classifyRunAbortCause(record: unknown): RunAbortCause;
|
|
33
|
-
export declare const ABORT_CAUSES: readonly ["client_disconnected", "ask_park_grace_exhausted", "cancel_verb"];
|
|
34
33
|
export type { AbortCause };
|
|
35
34
|
export type AbortCauseReading = {
|
|
36
35
|
readonly kind: 'known';
|
package/dist/runCancelContext.js
CHANGED
|
@@ -57,7 +57,6 @@ export function classifyRunAbortCause(record) {
|
|
|
57
57
|
return { kind: 'run_still_live', status };
|
|
58
58
|
return { kind: 'unknown', ...(read !== null ? { terminal: read.kind } : {}) };
|
|
59
59
|
}
|
|
60
|
-
export const ABORT_CAUSES = SDK_ABORT_CAUSES;
|
|
61
60
|
const _abortCauseTablePin = true;
|
|
62
61
|
void _abortCauseTablePin;
|
|
63
62
|
function ownDataOf(o, key) {
|
|
@@ -85,7 +84,7 @@ function abortCauseIn(holder) {
|
|
|
85
84
|
const raw = ownDataOf(holder, 'abortCause');
|
|
86
85
|
if (typeof raw !== 'string' || raw.length === 0)
|
|
87
86
|
return undefined;
|
|
88
|
-
return
|
|
87
|
+
return SDK_ABORT_CAUSES.includes(raw) ? { kind: 'known', cause: raw } : { kind: 'unrecognized', word: raw };
|
|
89
88
|
}
|
|
90
89
|
export function readAbortCause(frame) {
|
|
91
90
|
try {
|
package/dist/runTerminal.d.ts
CHANGED
|
@@ -27,6 +27,9 @@ export type RunTerminalFailureDetail = RunTerminalProviderRejectedDetail | {
|
|
|
27
27
|
export type RunTerminalJsonValue = string | number | boolean | null | readonly RunTerminalJsonValue[] | {
|
|
28
28
|
readonly [key: string]: RunTerminalJsonValue;
|
|
29
29
|
};
|
|
30
|
+
export type RunTerminalCodedDetail = {
|
|
31
|
+
readonly [key: string]: RunTerminalJsonValue;
|
|
32
|
+
};
|
|
30
33
|
export interface RunTerminalOutputLimit {
|
|
31
34
|
capStop: boolean;
|
|
32
35
|
outputTokens?: number;
|
|
@@ -94,6 +97,8 @@ type RunTerminalReadArm = {
|
|
|
94
97
|
code?: string;
|
|
95
98
|
message?: string;
|
|
96
99
|
};
|
|
100
|
+
export declare function runTerminalCodedDetail(read: RunTerminalRead | null | undefined): RunTerminalCodedDetail | undefined;
|
|
101
|
+
export declare function terminalCodedDetailOf(carrier: {} | null | undefined): RunTerminalCodedDetail | undefined;
|
|
97
102
|
export declare function readRunTerminal(result: unknown): RunTerminalRead | null;
|
|
98
103
|
export declare const REVIEW_PARK_GATE_KINDS: readonly string[];
|
|
99
104
|
export declare function runTerminalGateKind(read: RunTerminalRead | null): string | undefined;
|
package/dist/runTerminal.js
CHANGED
|
@@ -2,6 +2,7 @@ import { CORE_PROMPT_BLOCK_CAUSES } from './generated/engineFactTables.js';
|
|
|
2
2
|
import { isSdkRunParked } from './terminalStatuses.js';
|
|
3
3
|
import { readOwnDataNonEmptyString, readOwnDataValue } from './ownKey.js';
|
|
4
4
|
import { doneResultView } from './replayBody.js';
|
|
5
|
+
import { washCredentials } from './displayUntrusted.js';
|
|
5
6
|
export const PROMPT_BLOCK_CAUSES = CORE_PROMPT_BLOCK_CAUSES;
|
|
6
7
|
const _promptBlockTablePin = true;
|
|
7
8
|
void _promptBlockTablePin;
|
|
@@ -39,7 +40,7 @@ void _modelOutputInvalidCausePin;
|
|
|
39
40
|
const CODED_DETAIL_MAX_DEPTH = 40;
|
|
40
41
|
function ownData(o, k) {
|
|
41
42
|
const d = Object.getOwnPropertyDescriptor(o, k);
|
|
42
|
-
return d !== undefined && 'value'
|
|
43
|
+
return d !== undefined && Object.hasOwn(d, 'value') ? d.value : undefined;
|
|
43
44
|
}
|
|
44
45
|
function isPlainRecord(v) {
|
|
45
46
|
if (typeof v !== 'object' || v === null || Array.isArray(v))
|
|
@@ -53,8 +54,10 @@ function jsonSnapshot(v, depth, ctx) {
|
|
|
53
54
|
ctx.budget -= 1;
|
|
54
55
|
if (ctx.budget < 0)
|
|
55
56
|
throw CODED_DETAIL_OVER_BUDGET;
|
|
56
|
-
if (v === null || typeof v === '
|
|
57
|
+
if (v === null || typeof v === 'boolean')
|
|
57
58
|
return v;
|
|
59
|
+
if (typeof v === 'string')
|
|
60
|
+
return ctx.leaf === undefined ? v : ctx.leaf(v);
|
|
58
61
|
if (typeof v === 'number')
|
|
59
62
|
return Number.isFinite(v) ? v : undefined;
|
|
60
63
|
if (depth >= CODED_DETAIL_MAX_DEPTH)
|
|
@@ -148,6 +151,51 @@ function requestRouteOf(d) {
|
|
|
148
151
|
return undefined;
|
|
149
152
|
}
|
|
150
153
|
}
|
|
154
|
+
function codedBodySnapshot(inner, washLeaves = false) {
|
|
155
|
+
if (!isPlainRecord(inner))
|
|
156
|
+
return undefined;
|
|
157
|
+
let snap;
|
|
158
|
+
try {
|
|
159
|
+
snap = jsonSnapshot(inner, 0, { budget: CODED_DETAIL_BUDGET, path: new Set(), ...(washLeaves ? { leaf: washCredentials } : {}) });
|
|
160
|
+
}
|
|
161
|
+
catch (e) {
|
|
162
|
+
if (e === CODED_DETAIL_OVER_BUDGET)
|
|
163
|
+
return undefined;
|
|
164
|
+
throw e;
|
|
165
|
+
}
|
|
166
|
+
if (snap === undefined || snap === null || typeof snap !== 'object' || Array.isArray(snap))
|
|
167
|
+
return undefined;
|
|
168
|
+
return snap;
|
|
169
|
+
}
|
|
170
|
+
export function runTerminalCodedDetail(read) {
|
|
171
|
+
try {
|
|
172
|
+
if (typeof read !== 'object' || read === null)
|
|
173
|
+
return undefined;
|
|
174
|
+
if (ownData(read, 'kind') !== 'failed')
|
|
175
|
+
return undefined;
|
|
176
|
+
const detail = ownData(read, 'detail');
|
|
177
|
+
if (typeof detail !== 'object' || detail === null)
|
|
178
|
+
return undefined;
|
|
179
|
+
if (ownData(detail, 'kind') !== CODED_DETAIL_KIND)
|
|
180
|
+
return undefined;
|
|
181
|
+
const body = codedBodySnapshot(ownData(detail, 'detail'), true);
|
|
182
|
+
return body !== undefined && Object.keys(body).length > 0 ? body : undefined;
|
|
183
|
+
}
|
|
184
|
+
catch {
|
|
185
|
+
return undefined;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
export function terminalCodedDetailOf(carrier) {
|
|
189
|
+
try {
|
|
190
|
+
if (typeof carrier !== 'object' || carrier === null || Array.isArray(carrier))
|
|
191
|
+
return undefined;
|
|
192
|
+
const body = codedBodySnapshot(ownData(carrier, '_sema_coded_detail'), true);
|
|
193
|
+
return body !== undefined && Object.keys(body).length > 0 ? body : undefined;
|
|
194
|
+
}
|
|
195
|
+
catch {
|
|
196
|
+
return undefined;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
151
199
|
function failureDetailOf(cause) {
|
|
152
200
|
try {
|
|
153
201
|
const own = ownValueOf;
|
|
@@ -185,21 +233,8 @@ function failureDetailOf(cause) {
|
|
|
185
233
|
};
|
|
186
234
|
}
|
|
187
235
|
if (kind === CODED_DETAIL_KIND) {
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
return undefined;
|
|
191
|
-
let snap;
|
|
192
|
-
try {
|
|
193
|
-
snap = jsonSnapshot(inner, 0, { budget: CODED_DETAIL_BUDGET, path: new Set() });
|
|
194
|
-
}
|
|
195
|
-
catch (e) {
|
|
196
|
-
if (e === CODED_DETAIL_OVER_BUDGET)
|
|
197
|
-
return undefined;
|
|
198
|
-
throw e;
|
|
199
|
-
}
|
|
200
|
-
if (snap === undefined || snap === null || typeof snap !== 'object' || Array.isArray(snap))
|
|
201
|
-
return undefined;
|
|
202
|
-
return { kind: CODED_DETAIL_KIND, detail: snap };
|
|
236
|
+
const snap = codedBodySnapshot(ownData(v, 'detail'));
|
|
237
|
+
return snap === undefined ? undefined : { kind: CODED_DETAIL_KIND, detail: snap };
|
|
203
238
|
}
|
|
204
239
|
if (kind === MODEL_OUTPUT_INVALID_DETAIL_KIND) {
|
|
205
240
|
const c = ownData(v, 'cause');
|
package/dist/sandboxWire.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { TaskRequestLike } from './request/taskRequest.js';
|
|
1
2
|
export type SandboxSelection = {
|
|
2
3
|
mode: 'default';
|
|
3
4
|
} | {
|
|
@@ -13,7 +14,7 @@ export type SandboxParseResult = {
|
|
|
13
14
|
ok: false;
|
|
14
15
|
error: string;
|
|
15
16
|
};
|
|
16
|
-
export declare function
|
|
17
|
+
export declare function sandboxFromFlag(value?: string): SandboxParseResult;
|
|
17
18
|
export declare function sandboxRequestFields(sel: SandboxSelection | undefined): {
|
|
18
19
|
sandboxImageProfile?: string;
|
|
19
20
|
};
|
|
@@ -25,4 +26,4 @@ export declare const SANDBOX_NO_PUBLISHED_IMAGE_404_ANCHOR = "no published sandb
|
|
|
25
26
|
export declare const SANDBOX_CASCADE_CONFLICT_400_ANCHOR = "not supported together with cascade/verify";
|
|
26
27
|
export type SandboxHintHost = 'terminal' | 'web' | 'desktop';
|
|
27
28
|
export declare const SANDBOX_HINT_HOSTS: readonly SandboxHintHost[];
|
|
28
|
-
export declare function sandboxDegradeHint(err: unknown, host?: SandboxHintHost): string | undefined;
|
|
29
|
+
export declare function sandboxDegradeHint(err: unknown, host?: SandboxHintHost, sentRequest?: TaskRequestLike): string | undefined;
|
package/dist/sandboxWire.js
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CAPABILITY_IMAGE_INDEX_REQUIRED } from './engineErrorCodes.js';
|
|
1
|
+
import { CAPABILITY_IMAGE_INDEX_REQUIRED, CAPABILITY_K8S_LANE_REQUIRED, isStatusDerivedCoarseCode, NOT_FOUND_IMAGE, REQUEST_FIELD_CONFLICT, REQUEST_PRECONDITION_UNMET } from './engineErrorCodes.js';
|
|
3
2
|
import { THROWN_SLOT_UNREADABLE, readThrownSlot } from './wireFailureShape.js';
|
|
4
3
|
const MAX_PROFILE_LEN = 128;
|
|
5
4
|
const USAGE_HINT = "sema: --sandbox expects a profile name or 'auto'.\n" +
|
|
6
5
|
' --sandbox <profile> run on that sandbox image profile (k8s-lane workers; list: sema cloud images list)\n' +
|
|
7
6
|
' --sandbox auto let the model pick via its SelectEnvironment tool (advisory — choice + reason shown in the reply)\n' +
|
|
8
7
|
' (no flag) the worker default image';
|
|
9
|
-
export function
|
|
10
|
-
|
|
11
|
-
if (!flag.present)
|
|
8
|
+
export function sandboxFromFlag(value) {
|
|
9
|
+
if (value === undefined)
|
|
12
10
|
return { ok: true, sel: { mode: 'default' } };
|
|
13
|
-
if (
|
|
11
|
+
if (typeof value !== 'string')
|
|
14
12
|
return { ok: false, error: USAGE_HINT };
|
|
15
|
-
const v =
|
|
13
|
+
const v = value.trim();
|
|
16
14
|
if (v.length === 0)
|
|
17
15
|
return { ok: false, error: USAGE_HINT };
|
|
18
16
|
if (/\s/.test(v)) {
|
|
@@ -49,15 +47,15 @@ export const SANDBOX_NO_PUBLISHED_IMAGE_404_ANCHOR = 'no published sandbox image
|
|
|
49
47
|
export const SANDBOX_CASCADE_CONFLICT_400_ANCHOR = 'not supported together with cascade/verify';
|
|
50
48
|
export const SANDBOX_HINT_HOSTS = Object.freeze(['terminal', 'web', 'desktop']);
|
|
51
49
|
const SANDBOX_HINT_ARMS = Object.freeze({
|
|
52
|
-
|
|
53
|
-
fact: 'Cloud sandbox images are not available on this engine: its
|
|
50
|
+
imageIndexRequired: {
|
|
51
|
+
fact: 'Cloud sandbox images are not available on this engine: it has no sandbox image index (its store keeps none, or no image catalog is attached from the sema-web-admin config center), so profiles cannot be listed or selected here.',
|
|
54
52
|
sep: '\n',
|
|
55
53
|
outlet: {
|
|
56
|
-
terminal: 'Use a worker
|
|
57
|
-
graphical: 'Use a worker
|
|
54
|
+
terminal: 'Use a worker that has the image index (a SQL-backed store with the image catalog attached), or re-run without --sandbox.',
|
|
55
|
+
graphical: 'Use a worker that has the image index (a SQL-backed store with the image catalog attached), or keep the default environment.',
|
|
58
56
|
},
|
|
59
57
|
},
|
|
60
|
-
|
|
58
|
+
k8sLaneOnly: {
|
|
61
59
|
subject: { terminal: '--sandbox <profile>', graphical: 'The selected sandbox image profile' },
|
|
62
60
|
fact: ' only applies on k8s-lane workers; this engine runs a host/e2b sandbox lane, so the request was honestly rejected.',
|
|
63
61
|
sep: '\n',
|
|
@@ -66,12 +64,13 @@ const SANDBOX_HINT_ARMS = Object.freeze({
|
|
|
66
64
|
graphical: 'Keep the default environment, or connect to a k8s-lane worker.',
|
|
67
65
|
},
|
|
68
66
|
},
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
sessionRequired: {
|
|
68
|
+
subject: { terminal: '--sandbox <profile>', graphical: 'The selected sandbox image profile' },
|
|
69
|
+
fact: ' is bound to a session, and this request resolved none, so the per-task image could not be registered.',
|
|
71
70
|
sep: '\n',
|
|
72
71
|
outlet: {
|
|
73
|
-
terminal: '
|
|
74
|
-
graphical: '
|
|
72
|
+
terminal: 'Run it inside a session, or re-run without --sandbox.',
|
|
73
|
+
graphical: 'Start the work inside a session, or keep the default environment.',
|
|
75
74
|
},
|
|
76
75
|
},
|
|
77
76
|
noPublishedImage404: {
|
|
@@ -104,21 +103,54 @@ function sandboxSlot(err, key) {
|
|
|
104
103
|
const v = readThrownSlot(err, key, 'data');
|
|
105
104
|
return v === THROWN_SLOT_UNREADABLE ? undefined : v;
|
|
106
105
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
106
|
+
function sentSandboxFacts(sentRequest) {
|
|
107
|
+
if (sentRequest === undefined || sentRequest === null || typeof sentRequest !== 'object')
|
|
108
|
+
return { profile: false, cascadeOrVerify: false, sessionOrDevice: false };
|
|
109
|
+
const profile = sandboxSlot(sentRequest, 'sandboxImageProfile');
|
|
110
|
+
const sent = (key) => {
|
|
111
|
+
const v = sandboxSlot(sentRequest, key);
|
|
112
|
+
return typeof v === 'string' && v.length > 0;
|
|
113
|
+
};
|
|
114
|
+
return {
|
|
115
|
+
profile: typeof profile === 'string' && profile.length > 0,
|
|
116
|
+
cascadeOrVerify: sandboxSlot(sentRequest, 'cascade') === true || sandboxSlot(sentRequest, 'verify') === true,
|
|
117
|
+
sessionOrDevice: sent('sessionId') || sent('deviceId'),
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
export function sandboxDegradeHint(err, host, sentRequest) {
|
|
113
121
|
try {
|
|
122
|
+
if (typeof err !== 'object' || err === null)
|
|
123
|
+
return undefined;
|
|
124
|
+
const status = sandboxSlot(err, 'status');
|
|
125
|
+
const codeRaw = sandboxSlot(err, 'errorCode');
|
|
126
|
+
const code = typeof codeRaw === 'string' && codeRaw.length > 0 ? codeRaw : undefined;
|
|
127
|
+
if (status === 501 && code === CAPABILITY_K8S_LANE_REQUIRED)
|
|
128
|
+
return sandboxHintOf(SANDBOX_HINT_ARMS.k8sLaneOnly, host);
|
|
129
|
+
if (status === 501 && code === CAPABILITY_IMAGE_INDEX_REQUIRED)
|
|
130
|
+
return sandboxHintOf(SANDBOX_HINT_ARMS.imageIndexRequired, host);
|
|
131
|
+
if (status === 404 && code === NOT_FOUND_IMAGE)
|
|
132
|
+
return sandboxHintOf(SANDBOX_HINT_ARMS.noPublishedImage404, host);
|
|
133
|
+
if (status === 400 && code === REQUEST_PRECONDITION_UNMET) {
|
|
134
|
+
const sent = sentSandboxFacts(sentRequest);
|
|
135
|
+
return sent.profile && !sent.cascadeOrVerify && !sent.sessionOrDevice ? sandboxHintOf(SANDBOX_HINT_ARMS.sessionRequired, host) : undefined;
|
|
136
|
+
}
|
|
137
|
+
if (typeof status !== 'number')
|
|
138
|
+
return undefined;
|
|
139
|
+
const noCode = code === undefined || isStatusDerivedCoarseCode(code);
|
|
140
|
+
const cascadeCoded = code === REQUEST_FIELD_CONFLICT && (sentRequest === undefined || (() => {
|
|
141
|
+
const sent = sentSandboxFacts(sentRequest);
|
|
142
|
+
return sent.profile && sent.cascadeOrVerify;
|
|
143
|
+
})());
|
|
144
|
+
if (!noCode && !cascadeCoded)
|
|
145
|
+
return undefined;
|
|
114
146
|
const msg = err.message;
|
|
115
147
|
if (typeof msg !== 'string')
|
|
116
148
|
return undefined;
|
|
117
|
-
if (status === 400 && msg.includes(SANDBOX_K8S_ONLY_400_ANCHOR))
|
|
118
|
-
return sandboxHintOf(SANDBOX_HINT_ARMS.
|
|
119
|
-
if (status === 400 && msg.includes(SANDBOX_NO_IMAGE_INDEX_400_ANCHOR))
|
|
120
|
-
return sandboxHintOf(SANDBOX_HINT_ARMS.
|
|
121
|
-
if (status === 404 && msg.includes(SANDBOX_NO_PUBLISHED_IMAGE_404_ANCHOR))
|
|
149
|
+
if (noCode && status === 400 && msg.includes(SANDBOX_K8S_ONLY_400_ANCHOR))
|
|
150
|
+
return sandboxHintOf(SANDBOX_HINT_ARMS.k8sLaneOnly, host);
|
|
151
|
+
if (noCode && status === 400 && msg.includes(SANDBOX_NO_IMAGE_INDEX_400_ANCHOR))
|
|
152
|
+
return sandboxHintOf(SANDBOX_HINT_ARMS.imageIndexRequired, host);
|
|
153
|
+
if (noCode && status === 404 && msg.includes(SANDBOX_NO_PUBLISHED_IMAGE_404_ANCHOR))
|
|
122
154
|
return sandboxHintOf(SANDBOX_HINT_ARMS.noPublishedImage404, host);
|
|
123
155
|
if (status === 400 && msg.includes(SANDBOX_CASCADE_CONFLICT_400_ANCHOR))
|
|
124
156
|
return sandboxHintOf(SANDBOX_HINT_ARMS.cascadeConflict400, host);
|