@sema-agent/client-core 0.94.0 → 0.96.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 +521 -0
- package/README.md +104 -57
- package/dist/adapt/arms.js +12 -7
- package/dist/adapt/panelTasks.js +4 -10
- package/dist/adapt/toolCards.d.ts +1 -0
- package/dist/adapt/toolCards.js +18 -5
- package/dist/adapt/wireShapes.js +5 -24
- package/dist/adapter/activeRunSelfHeal.d.ts +12 -3
- package/dist/adapter/activeRunSelfHeal.js +50 -16
- package/dist/adapter/downstream/eventToSdkMessage.js +33 -18
- package/dist/adapter/downstream/terminalToSdkResult.js +19 -12
- package/dist/adapter/runStream.js +30 -46
- package/dist/adapter/types.d.ts +7 -0
- package/dist/adapter/types.js +15 -0
- package/dist/agentSession/backgroundView.js +5 -1
- package/dist/agentSession/engineAgentRegistryRead.js +7 -5
- package/dist/agentSession/engineSessionBackgroundStop.js +25 -17
- package/dist/agentsWireCaps.d.ts +2 -0
- package/dist/agentsWireCaps.js +13 -2
- package/dist/approvalDecidedByCapability.d.ts +0 -1
- package/dist/approvalDecidedByCapability.js +2 -7
- package/dist/approvalsStreamLiveCapability.d.ts +0 -1
- package/dist/approvalsStreamLiveCapability.js +2 -6
- package/dist/atMostOnce.d.ts +8 -0
- package/dist/atMostOnce.js +36 -0
- package/dist/attachmentSeatCapability.d.ts +0 -1
- package/dist/attachmentSeatCapability.js +0 -3
- package/dist/attachmentsWireCaps.js +11 -6
- package/dist/bashExitReading.d.ts +10 -0
- package/dist/bashExitReading.js +12 -0
- package/dist/callerCwdCapability.d.ts +0 -5
- package/dist/callerCwdCapability.js +2 -13
- package/dist/centerWiringCapability.d.ts +1 -7
- package/dist/centerWiringCapability.js +18 -27
- package/dist/classifierStatus.js +4 -4
- package/dist/classifierVerdictWire.js +4 -16
- package/dist/clientSlice.js +1 -1
- package/dist/cloudConfigWireCaps.d.ts +3 -3
- package/dist/cloudConfigWireCaps.js +85 -43
- package/dist/compensations.js +1 -1
- package/dist/coreValuePorts.d.ts +11 -7
- package/dist/coreValuePorts.js +5 -8
- package/dist/credentialProvenance.d.ts +28 -0
- package/dist/credentialProvenance.js +76 -0
- package/dist/cycleOrder.d.ts +15 -0
- package/dist/cycleOrder.js +45 -0
- package/dist/decideFailureNote.js +7 -2
- package/dist/decideReceipt.d.ts +2 -1
- package/dist/decideReceipt.js +39 -14
- package/dist/declared/supportFloorDeclared.d.ts +1 -0
- package/dist/declared/supportFloorDeclared.js +5 -0
- package/dist/deviceExecutorManagementCapability.d.ts +0 -1
- package/dist/deviceExecutorManagementCapability.js +7 -16
- package/dist/deviceRebind.d.ts +88 -0
- package/dist/deviceRebind.js +242 -0
- package/dist/displayUntrusted.d.ts +8 -3
- package/dist/displayUntrusted.js +661 -63
- package/dist/engineAgentAbsence.d.ts +2 -2
- package/dist/engineAgentPanelStore.d.ts +8 -18
- package/dist/engineAgentPanelStore.js +19 -537
- package/dist/engineCapReader.d.ts +6 -6
- package/dist/engineCapReader.js +30 -43
- package/dist/engineCapsCache.d.ts +13 -2
- package/dist/engineCapsCache.js +276 -44
- package/dist/engineCredentialRequirement.d.ts +9 -0
- package/dist/engineCredentialRequirement.js +23 -0
- package/dist/engineDirectory.d.ts +79 -0
- package/dist/engineDirectory.js +186 -0
- package/dist/engineEnvSourcing.d.ts +53 -0
- package/dist/engineEnvSourcing.js +81 -0
- package/dist/engineErrorCodes.d.ts +28 -4
- package/dist/engineErrorCodes.js +68 -25
- package/dist/engineIdentity.js +2 -0
- package/dist/engineNoticeCodes.d.ts +17 -0
- package/dist/engineNoticeCodes.js +57 -3
- package/dist/engineWireSdk.js +2 -2
- package/dist/engineWordRenames.d.ts +8 -0
- package/dist/engineWordRenames.js +13 -0
- package/dist/executionLaneCapability.d.ts +2 -3
- package/dist/executionLaneCapability.js +18 -23
- package/dist/fileHistoryCaptureCapability.d.ts +14 -1
- package/dist/fileHistoryCaptureCapability.js +72 -6
- package/dist/fileHistoryLegNotice.d.ts +3 -2
- package/dist/fileHistoryLegNotice.js +51 -2
- package/dist/fleet/bgSubagentRow.d.ts +15 -0
- package/dist/fleet/bgSubagentRow.js +67 -0
- package/dist/fleet/fleetLedger.d.ts +3 -0
- package/dist/fleet/fleetLedger.js +153 -122
- package/dist/fleet/fleetProjection.d.ts +1 -3
- package/dist/fleet/fleetProjection.js +19 -19
- package/dist/fleetAgentPanelProjection.d.ts +4 -17
- package/dist/fleetAgentPanelProjection.js +7 -197
- package/dist/fleetAgentRowLike.d.ts +16 -0
- package/dist/fleetAgentRowLike.js +1 -0
- package/dist/fleetTaskDesc.js +4 -17
- package/dist/gateOutcome.d.ts +12 -1
- package/dist/gateOutcome.js +87 -18
- package/dist/gateVocabulary.d.ts +7 -2
- package/dist/gateVocabulary.js +5 -1
- package/dist/generated/engineAskFaceTables.js +1 -1
- package/dist/generated/engineFactTables.d.ts +5 -3
- package/dist/generated/engineFactTables.js +17 -4
- package/dist/generated/engineNoticeTables.js +12 -3
- package/dist/generated/sdkFactTables.d.ts +2 -0
- package/dist/generated/sdkFactTables.js +17 -0
- package/dist/generated/settingsSchemaFns.d.ts +13 -0
- package/dist/generated/settingsSchemaFns.js +75 -0
- package/dist/generated/toolNameTables.d.ts +1 -0
- package/dist/generated/toolNameTables.js +1 -0
- package/dist/headlessPermissionModeWire.d.ts +1 -1
- package/dist/headlessPermissionModeWire.js +1 -1
- package/dist/headlessReconnectWire.js +49 -20
- package/dist/hitl/allowRuleShadow.d.ts +1 -1
- package/dist/hitl/allowRuleShadow.js +49 -8
- package/dist/hitl/approvalCompleteParked.d.ts +1 -0
- package/dist/hitl/approvalCompleteParked.js +14 -0
- package/dist/hitl/approvalEndingCause.d.ts +7 -0
- package/dist/hitl/approvalEndingCause.js +71 -0
- package/dist/hitl/approvalHolds.d.ts +12 -2
- package/dist/hitl/approvalHolds.js +53 -2
- package/dist/hitl/approvalsFeed.js +23 -11
- package/dist/hitl/askGateWire.d.ts +2 -1
- package/dist/hitl/askGateWire.js +26 -1
- package/dist/hitl/askParkRowRouting.js +1 -1
- package/dist/hitl/automaticAnswerVerdict.d.ts +1 -1
- package/dist/hitl/automaticAnswerVerdict.js +15 -10
- package/dist/hitl/crashConverged.js +2 -0
- package/dist/hitl/decisionConflict.d.ts +3 -0
- package/dist/hitl/decisionConflict.js +41 -0
- package/dist/hitl/decisionRefusal.d.ts +12 -0
- package/dist/hitl/decisionRefusal.js +63 -4
- package/dist/hitl/frameRouter.d.ts +0 -1
- package/dist/hitl/frameRouter.js +32 -57
- package/dist/hitl/gateLedger.d.ts +5 -0
- package/dist/hitl/gateLedger.js +21 -0
- package/dist/hitl/hitlBridge.d.ts +17 -2
- package/dist/hitl/hitlBridge.js +91 -55
- package/dist/hitl/hitlHostSurface.js +3 -11
- package/dist/hitl/livePendingAsk.d.ts +16 -6
- package/dist/hitl/livePendingAsk.js +36 -4
- package/dist/hitl/localAllowRule.d.ts +1 -0
- package/dist/hitl/localAllowRule.js +2 -2
- package/dist/hitl/noAllowCause.d.ts +2 -1
- package/dist/hitl/noAllowCause.js +3 -2
- package/dist/hitl/parkExpiryJudgements.d.ts +19 -0
- package/dist/hitl/parkExpiryJudgements.js +46 -0
- package/dist/hitl/parkResolver.d.ts +4 -7
- package/dist/hitl/parkResolver.js +12 -34
- package/dist/hitl/parkRowBirthWait.d.ts +1 -0
- package/dist/hitl/parkRowBirthWait.js +2 -2
- package/dist/hitl/persistedRulesWire.js +5 -1
- package/dist/hitl/planReviewWire.d.ts +3 -2
- package/dist/hitl/planReviewWire.js +154 -50
- package/dist/hitl/replayedApproval.d.ts +9 -0
- package/dist/hitl/replayedApproval.js +139 -10
- package/dist/hitl/resumeRunningCard.d.ts +2 -0
- package/dist/hitl/resumeRunningCard.js +15 -4
- package/dist/hitl/sessionPolicyDeliverable.js +8 -6
- package/dist/hitl/standingRows.d.ts +18 -0
- package/dist/hitl/standingRows.js +127 -0
- package/dist/hitl/toolApprovalWire.d.ts +39 -7
- package/dist/hitl/toolApprovalWire.js +351 -61
- package/dist/hookMatcherVerdict.d.ts +1 -9
- package/dist/hookMatcherVerdict.js +21 -61
- package/dist/hooksWireCaps.js +40 -8
- package/dist/host.d.ts +5 -0
- package/dist/host.js +3 -1
- package/dist/hostCallbackGuard.d.ts +2 -0
- package/dist/hostCallbackGuard.js +31 -0
- package/dist/index.d.ts +48 -17
- package/dist/index.js +36 -15
- package/dist/interactiveInterrupt.d.ts +8 -0
- package/dist/interactiveInterrupt.js +54 -0
- package/dist/limitsWire.d.ts +5 -0
- package/dist/limitsWire.js +49 -3
- package/dist/liveModelCatalog.d.ts +95 -0
- package/dist/liveModelCatalog.js +297 -32
- package/dist/mcpEngineLeg.d.ts +25 -0
- package/dist/mcpEngineLeg.js +71 -15
- package/dist/mcpPanel.js +2 -1
- package/dist/mcpProbeCapability.d.ts +0 -5
- package/dist/mcpProbeCapability.js +2 -12
- package/dist/mcpReconnect.d.ts +1 -3
- package/dist/mcpReconnect.js +10 -5
- package/dist/memoryComplianceCapability.d.ts +0 -5
- package/dist/memoryComplianceCapability.js +2 -12
- package/dist/memoryOriginCapability.d.ts +0 -5
- package/dist/memoryOriginCapability.js +2 -12
- package/dist/memorySpecWire.js +2 -2
- package/dist/memoryVerbsWire.d.ts +1 -1
- package/dist/memoryVerbsWire.js +4 -0
- package/dist/model/liveCatalogShape.d.ts +14 -0
- package/dist/model/liveCatalogShape.js +71 -0
- package/dist/model/modelSupplyRules.d.ts +1 -0
- package/dist/model/modelSupplyRules.js +30 -9
- package/dist/model/modelsPolicy.d.ts +21 -0
- package/dist/model/modelsPolicy.js +90 -0
- package/dist/modelIdentityResolvability.d.ts +2 -2
- package/dist/modelIdentityResolvability.js +14 -12
- package/dist/modelSwitchFallback.d.ts +69 -0
- package/dist/modelSwitchFallback.js +206 -0
- package/dist/noticePresentation.d.ts +68 -0
- package/dist/noticePresentation.js +247 -0
- package/dist/notifications.js +12 -11
- package/dist/outputStyleSeatCapability.d.ts +0 -2
- package/dist/outputStyleSeatCapability.js +2 -10
- package/dist/ownKey.d.ts +8 -0
- package/dist/ownKey.js +66 -0
- package/dist/panelReduce.d.ts +114 -0
- package/dist/panelReduce.js +1135 -0
- package/dist/panelStateHolder.d.ts +17 -0
- package/dist/panelStateHolder.js +201 -0
- package/dist/peerFrames.js +13 -9
- package/dist/peerLaneCapability.d.ts +0 -1
- package/dist/peerLaneCapability.js +2 -6
- package/dist/permissionModesCapability.d.ts +0 -5
- package/dist/permissionModesCapability.js +5 -16
- package/dist/permissionRuleIssue.js +0 -3
- package/dist/permissionRulesWriteCapability.d.ts +0 -1
- package/dist/permissionRulesWriteCapability.js +2 -6
- package/dist/permissionsAllowGrantCapability.d.ts +0 -1
- package/dist/permissionsAllowGrantCapability.js +3 -9
- package/dist/permissionsDeclaration.d.ts +8 -0
- package/dist/permissionsDeclaration.js +101 -41
- package/dist/printPermissionOutcome.d.ts +12 -0
- package/dist/printPermissionOutcome.js +50 -0
- package/dist/printToolResultFrame.d.ts +1 -0
- package/dist/printToolResultFrame.js +5 -17
- package/dist/promptBlockedCopy.d.ts +5 -0
- package/dist/promptBlockedCopy.js +35 -0
- package/dist/promptDelivery.js +0 -8
- package/dist/protocolSegment.d.ts +9 -6
- package/dist/protocolSegment.js +31 -21
- package/dist/providerRejection.d.ts +4 -0
- package/dist/providerRejection.js +75 -14
- package/dist/replayBody.d.ts +12 -0
- package/dist/replayBody.js +25 -0
- package/dist/resumeRefusalCopy.d.ts +18 -1
- package/dist/resumeRefusalCopy.js +127 -32
- package/dist/retryStatus.d.ts +9 -1
- package/dist/retryStatus.js +9 -2
- package/dist/rewindArchiveCapability.d.ts +5 -14
- package/dist/rewindArchiveCapability.js +18 -61
- package/dist/rewindArchiveReading.d.ts +15 -0
- package/dist/rewindArchiveReading.js +56 -0
- package/dist/rewindEngineAction.d.ts +21 -0
- package/dist/rewindEngineAction.js +36 -0
- package/dist/rewindWireCaps.d.ts +2 -1
- package/dist/rewindWireCaps.js +1 -0
- package/dist/ruleCompileVerdict.d.ts +9 -1
- package/dist/ruleCompileVerdict.js +29 -4
- package/dist/runTerminal.d.ts +15 -12
- package/dist/runTerminal.js +60 -35
- package/dist/sandboxWire.js +13 -0
- package/dist/sdkRegistryTransit.d.ts +2 -1
- package/dist/sdkRegistryTransit.js +1 -0
- package/dist/sealedKeyCapability.d.ts +0 -5
- package/dist/sealedKeyCapability.js +3 -15
- package/dist/seam.js +4 -2
- package/dist/seatContract.d.ts +125 -34
- package/dist/seatContract.js +583 -179
- package/dist/sessionIdSegment.d.ts +1 -0
- package/dist/sessionIdSegment.js +11 -0
- package/dist/sessionMemoryErase.d.ts +1 -1
- package/dist/sessionMemoryErase.js +6 -1
- package/dist/sessionMemoryStatus.js +3 -2
- package/dist/sessionPolicyCapability.d.ts +0 -1
- package/dist/sessionPolicyCapability.js +2 -6
- package/dist/sessionReadRedactionCapability.d.ts +0 -5
- package/dist/sessionReadRedactionCapability.js +2 -13
- package/dist/sessionSyncFileHistory.d.ts +4 -0
- package/dist/sessionSyncFileHistory.js +66 -0
- package/dist/sessionSyncFileHistoryCapability.d.ts +0 -2
- package/dist/sessionSyncFileHistoryCapability.js +2 -9
- package/dist/skillToolListsCapability.d.ts +0 -2
- package/dist/skillToolListsCapability.js +2 -9
- package/dist/skillsWireCaps.d.ts +4 -0
- package/dist/skillsWireCaps.js +66 -1
- package/dist/sqlEngineCapability.d.ts +0 -1
- package/dist/sqlEngineCapability.js +9 -14
- package/dist/steerPriorityCapability.d.ts +0 -2
- package/dist/steerPriorityCapability.js +3 -12
- package/dist/storePostureCapability.d.ts +1 -5
- package/dist/storePostureCapability.js +16 -22
- package/dist/streamDrainingLegs.d.ts +6 -0
- package/dist/streamDrainingLegs.js +23 -0
- package/dist/subagent/engineCompactWire.js +13 -38
- package/dist/subagent/engineDelegatedPrompt.js +10 -6
- package/dist/subagent/engineSubagentOutput.d.ts +0 -1
- package/dist/subagent/engineSubagentOutput.js +5 -20
- package/dist/subagent/engineSubagentSteer.js +7 -5
- package/dist/subagent/engineSubagentTail.d.ts +0 -1
- package/dist/subagent/engineSubagentTail.js +7 -32
- package/dist/subagentContentStore.js +7 -18
- package/dist/supportFloor.d.ts +1 -0
- package/dist/supportFloor.js +15 -14
- package/dist/systemReminderTag.d.ts +1 -0
- package/dist/systemReminderTag.js +8 -0
- package/dist/terminalStatuses.d.ts +30 -0
- package/dist/terminalStatuses.js +67 -0
- package/dist/toolHistoryMismatch.d.ts +0 -3
- package/dist/toolHistoryMismatch.js +3 -7
- package/dist/toolResult.d.ts +6 -1
- package/dist/toolResult.js +90 -37
- package/dist/toolResultContent.d.ts +2 -0
- package/dist/toolResultContent.js +63 -0
- package/dist/types/engineState.d.ts +2 -1
- package/dist/usageAnalytics.d.ts +146 -0
- package/dist/usageAnalytics.js +335 -0
- package/dist/userInvokedSkillsCapability.d.ts +0 -2
- package/dist/userInvokedSkillsCapability.js +2 -9
- package/dist/webSearchBackendCapability.d.ts +0 -1
- package/dist/webSearchBackendCapability.js +3 -7
- package/dist/webSearchWireCaps.js +3 -11
- package/dist/wireErrorTriage.d.ts +2 -0
- package/dist/wireErrorTriage.js +34 -5
- package/dist/wireFailureShape.d.ts +23 -2
- package/dist/wireFailureShape.js +88 -43
- package/dist/wireRefusalCopy.js +2 -18
- package/dist/workflowClient.js +7 -11
- package/dist/workflowsJournalCapability.d.ts +0 -1
- package/dist/workflowsJournalCapability.js +2 -6
- package/dist/writeProtectionCapability.d.ts +0 -1
- package/dist/writeProtectionCapability.js +5 -10
- package/docs/INTEGRATION-CLIENTS.md +2279 -27
- package/package.json +5 -5
- package/dist/engineCapsGenerationGuard.d.ts +0 -4
- package/dist/engineCapsGenerationGuard.js +0 -19
- package/dist/panelRunningHistory.d.ts +0 -22
- package/dist/panelRunningHistory.js +0 -82
- package/dist/registryConflict.d.ts +0 -3
- package/dist/registryConflict.js +0 -44
package/dist/engineCapReader.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { engineCapsLandingOf } from './engineCapsCache.js';
|
|
2
|
+
import { ownDataField } from './ownKey.js';
|
|
3
3
|
function freezeReading(reading, seen = new Set()) {
|
|
4
4
|
if (reading === null || typeof reading !== 'object' || seen.has(reading))
|
|
5
5
|
return reading;
|
|
@@ -11,67 +11,54 @@ function freezeReading(reading, seen = new Set()) {
|
|
|
11
11
|
}
|
|
12
12
|
return reading;
|
|
13
13
|
}
|
|
14
|
+
const PROJECTING = Symbol('projecting');
|
|
14
15
|
export function createEngineCapReader(spec) {
|
|
15
|
-
|
|
16
|
+
let memo = new WeakMap();
|
|
16
17
|
return {
|
|
17
|
-
note(
|
|
18
|
+
note(_baseUrl, _caps, _opts) { },
|
|
19
|
+
observed(baseUrl) {
|
|
18
20
|
if (typeof baseUrl !== 'string' || baseUrl === '')
|
|
19
|
-
return;
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
22
|
-
return;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
return spec.makeUnobserved();
|
|
22
|
+
const landing = engineCapsLandingOf(baseUrl);
|
|
23
|
+
if (landing === undefined)
|
|
24
|
+
return spec.makeUnobserved();
|
|
25
|
+
const hit = memo.get(landing);
|
|
26
|
+
if (hit === PROJECTING)
|
|
27
|
+
return spec.makeUnobserved();
|
|
28
|
+
if (hit !== undefined)
|
|
29
|
+
return hit.reading === undefined ? spec.makeUnobserved() : hit.reading;
|
|
30
|
+
const mine = memo;
|
|
31
|
+
mine.set(landing, PROJECTING);
|
|
26
32
|
let reading;
|
|
27
33
|
try {
|
|
28
|
-
reading = spec.project(caps);
|
|
34
|
+
reading = spec.project(landing.caps);
|
|
29
35
|
}
|
|
30
36
|
catch {
|
|
31
37
|
reading = undefined;
|
|
32
38
|
}
|
|
33
|
-
if (
|
|
34
|
-
|
|
35
|
-
if (reading === undefined) {
|
|
36
|
-
cellByBase.delete(baseUrl);
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
cellByBase.set(baseUrl, { reading: freezeReading(reading), mark });
|
|
40
|
-
},
|
|
41
|
-
observed(baseUrl) {
|
|
42
|
-
if (typeof baseUrl !== 'string' || baseUrl === '')
|
|
43
|
-
return spec.makeUnobserved();
|
|
44
|
-
const cell = cellByBase.get(baseUrl);
|
|
45
|
-
if (cell === undefined)
|
|
46
|
-
return spec.makeUnobserved();
|
|
47
|
-
if (cell.mark !== capsGenerationMarkOf(baseUrl)) {
|
|
48
|
-
cellByBase.delete(baseUrl);
|
|
39
|
+
if (engineCapsLandingOf(baseUrl) !== landing) {
|
|
40
|
+
mine.delete(landing);
|
|
49
41
|
return spec.makeUnobserved();
|
|
50
42
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (typeof baseUrl !== 'string' || baseUrl === '')
|
|
55
|
-
return;
|
|
56
|
-
cellByBase.delete(baseUrl);
|
|
43
|
+
const done = { reading: reading === undefined ? undefined : freezeReading(reading) };
|
|
44
|
+
mine.set(landing, done);
|
|
45
|
+
return done.reading === undefined ? spec.makeUnobserved() : done.reading;
|
|
57
46
|
},
|
|
58
47
|
__resetForTests() {
|
|
59
|
-
|
|
48
|
+
memo = new WeakMap();
|
|
60
49
|
},
|
|
61
50
|
};
|
|
62
51
|
}
|
|
63
|
-
export function
|
|
52
|
+
export function storeSeatOf(caps) {
|
|
64
53
|
try {
|
|
65
|
-
|
|
66
|
-
return { generation: 'old', store: 'absent' };
|
|
67
|
-
const store = caps.store;
|
|
54
|
+
const store = ownDataField(caps, 'store');
|
|
68
55
|
if (store === undefined)
|
|
69
|
-
return {
|
|
56
|
+
return { kind: 'absent' };
|
|
70
57
|
if (typeof store !== 'object' || store === null || Array.isArray(store))
|
|
71
|
-
return {
|
|
72
|
-
return {
|
|
58
|
+
return { kind: 'malformed' };
|
|
59
|
+
return { kind: 'object', store };
|
|
73
60
|
}
|
|
74
61
|
catch {
|
|
75
|
-
return {
|
|
62
|
+
return { kind: 'malformed' };
|
|
76
63
|
}
|
|
77
64
|
}
|
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
export declare function engineCapsGeneration(baseUrl: string): number;
|
|
2
|
-
export declare function
|
|
3
|
-
|
|
2
|
+
export declare function engineCapsLandingOf(baseUrl: string): {
|
|
3
|
+
readonly caps: object;
|
|
4
|
+
} | undefined;
|
|
4
5
|
export declare function kickEngineCapsProbe(baseUrl: string, probe: () => Promise<unknown>): void;
|
|
5
6
|
export declare function engineCapsSettled(baseUrl: string | undefined, opts?: {
|
|
6
7
|
withinMs?: number;
|
|
7
8
|
}): Promise<'settled' | 'timed_out'>;
|
|
8
9
|
export type EngineCapState = 'true' | 'false' | 'unprobed' | 'absent' | 'non_boolean';
|
|
9
10
|
export declare function engineCapState(baseUrl: string | undefined, key: string): EngineCapState;
|
|
11
|
+
export declare function engineCapStateVia(baseUrl: string | undefined, key: string, probe: (signal?: AbortSignal) => Promise<unknown>, opts?: {
|
|
12
|
+
withinMs?: number;
|
|
13
|
+
signal?: AbortSignal;
|
|
14
|
+
}): Promise<EngineCapState>;
|
|
10
15
|
export declare function engineCapTrue(baseUrl: string | undefined, key: string): boolean;
|
|
11
16
|
export declare function engineCapNestedTrue(baseUrl: string | undefined, parentKey: string, key: string): boolean;
|
|
17
|
+
export declare function engineCapNestedValue(baseUrl: string | undefined, parentKey: string, key: string): EngineCapValueState;
|
|
12
18
|
export type EngineCapValueState = {
|
|
13
19
|
kind: 'unobserved';
|
|
14
20
|
} | {
|
|
15
21
|
kind: 'not_reported';
|
|
22
|
+
} | {
|
|
23
|
+
kind: 'unreadable';
|
|
16
24
|
} | {
|
|
17
25
|
kind: 'null';
|
|
18
26
|
} | {
|
|
@@ -22,4 +30,7 @@ export type EngineCapValueState = {
|
|
|
22
30
|
export declare function engineCapValue(baseUrl: string | undefined, key: string): EngineCapValueState;
|
|
23
31
|
export declare function engineCapString(baseUrl: string | undefined, key: string): string | undefined;
|
|
24
32
|
export declare function invalidateEngineCaps(baseUrl: string | undefined, probe?: () => Promise<unknown>): void;
|
|
33
|
+
export declare function refreshEngineCapsOnce(baseUrl: string | undefined, opts?: {
|
|
34
|
+
withinMs?: number;
|
|
35
|
+
}): Promise<'settled' | 'timed_out' | 'no_probe'>;
|
|
25
36
|
export declare function __resetEngineCapsCacheForTests(): void;
|
package/dist/engineCapsCache.js
CHANGED
|
@@ -1,27 +1,24 @@
|
|
|
1
|
+
import { settleWithinDeadline } from './abortableSleep.js';
|
|
2
|
+
import { ownDataField } from './ownKey.js';
|
|
1
3
|
const capsByBase = new Map();
|
|
2
4
|
const inFlight = new Set();
|
|
3
5
|
const settleByBase = new Map();
|
|
4
6
|
const genByBase = new Map();
|
|
7
|
+
const probeByBase = new Map();
|
|
8
|
+
const refreshByBase = new Map();
|
|
5
9
|
function capsGeneration(baseUrl) {
|
|
6
|
-
return genByBase.get(baseUrl)
|
|
10
|
+
return genByBase.get(baseUrl) ?? 0;
|
|
7
11
|
}
|
|
8
12
|
export function engineCapsGeneration(baseUrl) {
|
|
9
13
|
return capsGeneration(baseUrl);
|
|
10
14
|
}
|
|
11
|
-
export function
|
|
12
|
-
return
|
|
13
|
-
}
|
|
14
|
-
export function retainCapsGenerationMark(baseUrl) {
|
|
15
|
-
let mark = genByBase.get(baseUrl);
|
|
16
|
-
if (mark === undefined) {
|
|
17
|
-
mark = Object.freeze({ n: 0 });
|
|
18
|
-
genByBase.set(baseUrl, mark);
|
|
19
|
-
}
|
|
20
|
-
return mark;
|
|
15
|
+
export function engineCapsLandingOf(baseUrl) {
|
|
16
|
+
return capsByBase.get(baseUrl);
|
|
21
17
|
}
|
|
22
18
|
export function kickEngineCapsProbe(baseUrl, probe) {
|
|
23
19
|
if (!baseUrl || capsByBase.has(baseUrl) || inFlight.has(baseUrl))
|
|
24
20
|
return;
|
|
21
|
+
probeByBase.set(baseUrl, probe);
|
|
25
22
|
const gen = capsGeneration(baseUrl);
|
|
26
23
|
inFlight.add(baseUrl);
|
|
27
24
|
let wake = () => { };
|
|
@@ -38,9 +35,8 @@ export function kickEngineCapsProbe(baseUrl, probe) {
|
|
|
38
35
|
const caps = await probe();
|
|
39
36
|
if (gen !== capsGeneration(baseUrl))
|
|
40
37
|
return;
|
|
41
|
-
if (caps && typeof caps === 'object')
|
|
42
|
-
|
|
43
|
-
}
|
|
38
|
+
if (caps && typeof caps === 'object')
|
|
39
|
+
landCapsSnapshot(baseUrl, gen, caps);
|
|
44
40
|
}
|
|
45
41
|
catch {
|
|
46
42
|
}
|
|
@@ -124,59 +120,227 @@ export async function engineCapsSettled(baseUrl, opts) {
|
|
|
124
120
|
export function engineCapState(baseUrl, key) {
|
|
125
121
|
if (!baseUrl)
|
|
126
122
|
return 'unprobed';
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
123
|
+
return capStateIn(capsByBase.get(baseUrl)?.caps, key);
|
|
124
|
+
}
|
|
125
|
+
const SNAPSHOT_MAX_DEPTH = 64;
|
|
126
|
+
const SNAPSHOT_MAX_NODES = 100_000;
|
|
127
|
+
const SNAPSHOT_PROBE_KEY = '\u0000capabilities-snapshot-probe\u0000';
|
|
128
|
+
const FOREIGN_PROTOTYPE = Object.freeze(Object.create(null));
|
|
129
|
+
function unreadableError() {
|
|
130
|
+
return new TypeError('capabilities body position is not readable (accessor or throwing proxy)');
|
|
131
|
+
}
|
|
132
|
+
const UNREADABLE_NODE = new Proxy(Object.freeze({}), {
|
|
133
|
+
getOwnPropertyDescriptor: () => {
|
|
134
|
+
throw unreadableError();
|
|
135
|
+
},
|
|
136
|
+
ownKeys: () => {
|
|
137
|
+
throw unreadableError();
|
|
138
|
+
},
|
|
139
|
+
has: () => {
|
|
140
|
+
throw unreadableError();
|
|
141
|
+
},
|
|
142
|
+
get: () => {
|
|
143
|
+
throw unreadableError();
|
|
144
|
+
},
|
|
145
|
+
getPrototypeOf: () => {
|
|
146
|
+
throw unreadableError();
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
function throwingAccessor() {
|
|
150
|
+
return {
|
|
151
|
+
get: () => {
|
|
152
|
+
throw unreadableError();
|
|
153
|
+
},
|
|
154
|
+
enumerable: true,
|
|
155
|
+
configurable: false,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
function landCapsSnapshot(baseUrl, gen, caps) {
|
|
159
|
+
const snapshot = snapshotCapsBody(caps);
|
|
160
|
+
if (gen !== capsGeneration(baseUrl))
|
|
161
|
+
return;
|
|
162
|
+
capsByBase.set(baseUrl, Object.freeze({ caps: snapshot }));
|
|
163
|
+
}
|
|
164
|
+
function snapshotCapsBody(body) {
|
|
165
|
+
if (body === null || typeof body !== 'object')
|
|
166
|
+
return body;
|
|
167
|
+
const seen = new WeakMap();
|
|
168
|
+
let nodes = 0;
|
|
169
|
+
const copy = (src, depth) => {
|
|
170
|
+
const known = seen.get(src);
|
|
171
|
+
if (known !== undefined)
|
|
172
|
+
return known;
|
|
173
|
+
if (depth > SNAPSHOT_MAX_DEPTH || ++nodes > SNAPSHOT_MAX_NODES)
|
|
174
|
+
return UNREADABLE_NODE;
|
|
175
|
+
let keys;
|
|
176
|
+
let out;
|
|
177
|
+
let isArray;
|
|
178
|
+
try {
|
|
179
|
+
isArray = Array.isArray(src);
|
|
180
|
+
keys = Object.getOwnPropertyNames(src);
|
|
181
|
+
Object.getOwnPropertyDescriptor(src, SNAPSHOT_PROBE_KEY);
|
|
182
|
+
let length = 0;
|
|
183
|
+
if (isArray) {
|
|
184
|
+
const ld = Object.getOwnPropertyDescriptor(src, 'length');
|
|
185
|
+
if (ld === undefined || !Object.hasOwn(ld, 'value') || typeof ld.value !== 'number')
|
|
186
|
+
return UNREADABLE_NODE;
|
|
187
|
+
length = ld.value;
|
|
188
|
+
}
|
|
189
|
+
const proto = isArray ? null : Object.getPrototypeOf(src);
|
|
190
|
+
out = isArray ? new Array(length) : proto === Object.prototype || proto === null ? {} : Object.create(FOREIGN_PROTOTYPE);
|
|
191
|
+
}
|
|
192
|
+
catch {
|
|
193
|
+
return UNREADABLE_NODE;
|
|
194
|
+
}
|
|
195
|
+
seen.set(src, out);
|
|
196
|
+
for (const k of keys) {
|
|
197
|
+
if (isArray && k === 'length')
|
|
198
|
+
continue;
|
|
199
|
+
let d;
|
|
200
|
+
try {
|
|
201
|
+
d = Object.getOwnPropertyDescriptor(src, k);
|
|
202
|
+
}
|
|
203
|
+
catch {
|
|
204
|
+
Object.defineProperty(out, k, throwingAccessor());
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
if (d === undefined)
|
|
208
|
+
continue;
|
|
209
|
+
if (!Object.hasOwn(d, 'value')) {
|
|
210
|
+
Object.defineProperty(out, k, throwingAccessor());
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
const v = d.value;
|
|
214
|
+
Object.defineProperty(out, k, {
|
|
215
|
+
value: v !== null && typeof v === 'object' ? copy(v, depth + 1) : v,
|
|
216
|
+
enumerable: d.enumerable === true,
|
|
217
|
+
writable: false,
|
|
218
|
+
configurable: false,
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
Object.freeze(out);
|
|
222
|
+
return out;
|
|
223
|
+
};
|
|
224
|
+
return copy(body, 0);
|
|
225
|
+
}
|
|
226
|
+
const SLOT_UNOBSERVED = Object.freeze({ kind: 'unobserved' });
|
|
227
|
+
const SLOT_ABSENT = Object.freeze({ kind: 'absent' });
|
|
228
|
+
const SLOT_UNREADABLE = Object.freeze({ kind: 'unreadable' });
|
|
229
|
+
function capSlotIn(caps, key) {
|
|
230
|
+
if (caps === undefined || caps === null || typeof caps !== 'object')
|
|
231
|
+
return SLOT_UNOBSERVED;
|
|
232
|
+
try {
|
|
233
|
+
const v = ownDataField(caps, key);
|
|
234
|
+
return v === undefined ? SLOT_ABSENT : { kind: 'present', value: v };
|
|
235
|
+
}
|
|
236
|
+
catch {
|
|
237
|
+
return SLOT_UNREADABLE;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
function capStateIn(caps, key) {
|
|
241
|
+
const slot = capSlotIn(caps, key);
|
|
242
|
+
switch (slot.kind) {
|
|
243
|
+
case 'unobserved':
|
|
244
|
+
return 'unprobed';
|
|
245
|
+
case 'absent':
|
|
246
|
+
return 'absent';
|
|
247
|
+
case 'unreadable':
|
|
248
|
+
return 'non_boolean';
|
|
249
|
+
case 'present':
|
|
250
|
+
return slot.value === true ? 'true' : slot.value === false ? 'false' : 'non_boolean';
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
async function untilSettledOrAborted(p, signal) {
|
|
254
|
+
if (signal === undefined) {
|
|
255
|
+
await p.catch(() => undefined);
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
if (signal.aborted)
|
|
259
|
+
return;
|
|
260
|
+
let onAbort;
|
|
261
|
+
const aborted = new Promise((resolve) => {
|
|
262
|
+
onAbort = () => resolve();
|
|
263
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
264
|
+
});
|
|
265
|
+
try {
|
|
266
|
+
await Promise.race([p.then(() => undefined, () => undefined), aborted]);
|
|
267
|
+
}
|
|
268
|
+
finally {
|
|
269
|
+
if (onAbort !== undefined)
|
|
270
|
+
signal.removeEventListener('abort', onAbort);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
export async function engineCapStateVia(baseUrl, key, probe, opts) {
|
|
274
|
+
const signal = opts?.signal;
|
|
275
|
+
if (!baseUrl) {
|
|
276
|
+
try {
|
|
277
|
+
if (signal?.aborted)
|
|
278
|
+
return 'unprobed';
|
|
279
|
+
return capStateIn(await probe(signal), key);
|
|
280
|
+
}
|
|
281
|
+
catch {
|
|
282
|
+
return 'unprobed';
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
const now = engineCapState(baseUrl, key);
|
|
286
|
+
if (now !== 'unprobed')
|
|
287
|
+
return now;
|
|
288
|
+
kickEngineCapsProbe(baseUrl, () => probe());
|
|
289
|
+
await untilSettledOrAborted(engineCapsSettled(baseUrl, opts?.withinMs !== undefined ? { withinMs: opts.withinMs } : undefined), signal);
|
|
290
|
+
return engineCapState(baseUrl, key);
|
|
138
291
|
}
|
|
139
292
|
export function engineCapTrue(baseUrl, key) {
|
|
140
293
|
return engineCapState(baseUrl, key) === 'true';
|
|
141
294
|
}
|
|
142
295
|
export function engineCapNestedTrue(baseUrl, parentKey, key) {
|
|
296
|
+
const state = engineCapNestedValue(baseUrl, parentKey, key);
|
|
297
|
+
return state.kind === 'value' && state.value === true;
|
|
298
|
+
}
|
|
299
|
+
export function engineCapNestedValue(baseUrl, parentKey, key) {
|
|
143
300
|
if (!baseUrl)
|
|
144
|
-
return
|
|
145
|
-
const parent = capsByBase.get(baseUrl)?.
|
|
146
|
-
if (parent
|
|
147
|
-
return
|
|
148
|
-
|
|
301
|
+
return { kind: 'unobserved' };
|
|
302
|
+
const parent = capSlotIn(capsByBase.get(baseUrl)?.caps, parentKey);
|
|
303
|
+
if (parent.kind !== 'present')
|
|
304
|
+
return valueStateOfSlot(parent);
|
|
305
|
+
const group = parent.value;
|
|
306
|
+
if (group === null || typeof group !== 'object')
|
|
307
|
+
return { kind: 'not_reported' };
|
|
308
|
+
return valueStateOfSlot(capSlotIn(group, key));
|
|
149
309
|
}
|
|
150
310
|
export function engineCapValue(baseUrl, key) {
|
|
151
311
|
if (!baseUrl)
|
|
152
312
|
return { kind: 'unobserved' };
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
313
|
+
return valueStateOfSlot(capSlotIn(capsByBase.get(baseUrl)?.caps, key));
|
|
314
|
+
}
|
|
315
|
+
function valueStateOfSlot(slot) {
|
|
316
|
+
switch (slot.kind) {
|
|
317
|
+
case 'unobserved':
|
|
318
|
+
return { kind: 'unobserved' };
|
|
319
|
+
case 'absent':
|
|
320
|
+
return { kind: 'not_reported' };
|
|
321
|
+
case 'unreadable':
|
|
322
|
+
return { kind: 'unreadable' };
|
|
323
|
+
case 'present':
|
|
324
|
+
return slot.value === null ? { kind: 'null' } : { kind: 'value', value: slot.value };
|
|
325
|
+
}
|
|
164
326
|
}
|
|
165
327
|
export function engineCapString(baseUrl, key) {
|
|
166
328
|
if (!baseUrl)
|
|
167
329
|
return undefined;
|
|
168
|
-
const
|
|
169
|
-
return typeof
|
|
330
|
+
const slot = capSlotIn(capsByBase.get(baseUrl)?.caps, key);
|
|
331
|
+
return slot.kind === 'present' && typeof slot.value === 'string' && slot.value.length > 0 ? slot.value : undefined;
|
|
170
332
|
}
|
|
171
333
|
export function invalidateEngineCaps(baseUrl, probe) {
|
|
172
334
|
if (!baseUrl)
|
|
173
335
|
return;
|
|
336
|
+
if (probe === undefined)
|
|
337
|
+
probeByBase.delete(baseUrl);
|
|
174
338
|
const hadState = capsByBase.has(baseUrl) ||
|
|
175
339
|
inFlight.has(baseUrl) ||
|
|
176
340
|
settleByBase.has(baseUrl) ||
|
|
177
341
|
genByBase.has(baseUrl);
|
|
178
342
|
if (hadState) {
|
|
179
|
-
genByBase.set(baseUrl,
|
|
343
|
+
genByBase.set(baseUrl, capsGeneration(baseUrl) + 1);
|
|
180
344
|
capsByBase.delete(baseUrl);
|
|
181
345
|
inFlight.delete(baseUrl);
|
|
182
346
|
settleByBase.get(baseUrl)?.wake();
|
|
@@ -184,9 +348,77 @@ export function invalidateEngineCaps(baseUrl, probe) {
|
|
|
184
348
|
if (probe !== undefined)
|
|
185
349
|
kickEngineCapsProbe(baseUrl, probe);
|
|
186
350
|
}
|
|
351
|
+
export async function refreshEngineCapsOnce(baseUrl, opts) {
|
|
352
|
+
try {
|
|
353
|
+
if (typeof baseUrl !== 'string' || baseUrl === '')
|
|
354
|
+
return 'no_probe';
|
|
355
|
+
const budget = waitBudgetOf(opts);
|
|
356
|
+
const probe = probeByBase.get(baseUrl);
|
|
357
|
+
if (probe === undefined)
|
|
358
|
+
return 'no_probe';
|
|
359
|
+
const flying = refreshByBase.get(baseUrl);
|
|
360
|
+
if (flying !== undefined && flying.gen === capsGeneration(baseUrl))
|
|
361
|
+
return await awaitRefreshWithin(flying, budget);
|
|
362
|
+
if (!capsByBase.has(baseUrl)) {
|
|
363
|
+
kickEngineCapsProbe(baseUrl, probe);
|
|
364
|
+
return await engineCapsSettled(baseUrl, budget === undefined ? undefined : { withinMs: budget });
|
|
365
|
+
}
|
|
366
|
+
const gen = capsGeneration(baseUrl);
|
|
367
|
+
let finish = () => { };
|
|
368
|
+
const entry = { gen, promise: new Promise((resolve) => { finish = resolve; }) };
|
|
369
|
+
refreshByBase.set(baseUrl, entry);
|
|
370
|
+
void (async () => {
|
|
371
|
+
try {
|
|
372
|
+
const caps = await probe();
|
|
373
|
+
if (gen !== capsGeneration(baseUrl) || !capsByBase.has(baseUrl) || !isPlainCapsBody(caps))
|
|
374
|
+
return false;
|
|
375
|
+
landCapsSnapshot(baseUrl, gen, caps);
|
|
376
|
+
return gen === capsGeneration(baseUrl);
|
|
377
|
+
}
|
|
378
|
+
catch {
|
|
379
|
+
return false;
|
|
380
|
+
}
|
|
381
|
+
finally {
|
|
382
|
+
if (refreshByBase.get(baseUrl) === entry)
|
|
383
|
+
refreshByBase.delete(baseUrl);
|
|
384
|
+
}
|
|
385
|
+
})().then(finish);
|
|
386
|
+
return await awaitRefreshWithin(entry, budget);
|
|
387
|
+
}
|
|
388
|
+
catch {
|
|
389
|
+
return 'timed_out';
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
function isPlainCapsBody(caps) {
|
|
393
|
+
try {
|
|
394
|
+
if (typeof caps !== 'object' || caps === null)
|
|
395
|
+
return false;
|
|
396
|
+
const proto = Object.getPrototypeOf(caps);
|
|
397
|
+
if (proto !== null && Object.getPrototypeOf(proto) !== null)
|
|
398
|
+
return false;
|
|
399
|
+
for (const key of Reflect.ownKeys(caps))
|
|
400
|
+
Object.getOwnPropertyDescriptor(caps, key);
|
|
401
|
+
return true;
|
|
402
|
+
}
|
|
403
|
+
catch {
|
|
404
|
+
return false;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
async function awaitRefreshWithin(entry, budget) {
|
|
408
|
+
if (budget === undefined) {
|
|
409
|
+
await entry.promise;
|
|
410
|
+
return 'settled';
|
|
411
|
+
}
|
|
412
|
+
if (budget === 0)
|
|
413
|
+
return 'timed_out';
|
|
414
|
+
const out = await settleWithinDeadline(budget, () => entry.promise);
|
|
415
|
+
return out.kind === 'deadline' ? 'timed_out' : 'settled';
|
|
416
|
+
}
|
|
187
417
|
export function __resetEngineCapsCacheForTests() {
|
|
188
418
|
capsByBase.clear();
|
|
189
419
|
inFlight.clear();
|
|
190
420
|
settleByBase.clear();
|
|
191
421
|
genByBase.clear();
|
|
422
|
+
probeByBase.clear();
|
|
423
|
+
refreshByBase.clear();
|
|
192
424
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type EngineProbeAnswer = {
|
|
2
|
+
readonly ok: true;
|
|
3
|
+
} | {
|
|
4
|
+
readonly status: number;
|
|
5
|
+
} | {
|
|
6
|
+
readonly transport: true;
|
|
7
|
+
};
|
|
8
|
+
export type EngineCredentialNeed = 'open' | 'requires' | 'undetermined';
|
|
9
|
+
export declare function engineCredentialRequirementOf(answer: EngineProbeAnswer): EngineCredentialNeed;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function engineCredentialRequirementOf(answer) {
|
|
2
|
+
try {
|
|
3
|
+
const a = answer;
|
|
4
|
+
if (typeof a !== 'object' || a === null || Array.isArray(a))
|
|
5
|
+
return 'undetermined';
|
|
6
|
+
const ok = Object.getOwnPropertyDescriptor(a, 'ok');
|
|
7
|
+
const status = Object.getOwnPropertyDescriptor(a, 'status');
|
|
8
|
+
const transport = Object.getOwnPropertyDescriptor(a, 'transport');
|
|
9
|
+
const arms = (ok !== undefined ? 1 : 0) + (status !== undefined ? 1 : 0) + (transport !== undefined ? 1 : 0);
|
|
10
|
+
if (arms !== 1)
|
|
11
|
+
return 'undetermined';
|
|
12
|
+
if (ok !== undefined)
|
|
13
|
+
return Object.hasOwn(ok, 'value') && ok.value === true ? 'open' : 'undetermined';
|
|
14
|
+
if (status !== undefined) {
|
|
15
|
+
const value = Object.hasOwn(status, 'value') ? status.value : undefined;
|
|
16
|
+
return value === 401 || value === 403 ? 'requires' : 'undetermined';
|
|
17
|
+
}
|
|
18
|
+
return 'undetermined';
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return 'undetermined';
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
declare const KIND_WORDS: readonly ["managed"];
|
|
2
|
+
declare const POSTURE_WORDS: readonly ["single", "multi"];
|
|
3
|
+
declare const RULE_WORDS: readonly ["only-one", "none", "ambiguous"];
|
|
4
|
+
export type EngineKindWord = (typeof KIND_WORDS)[number];
|
|
5
|
+
export type EnginePostureWord = (typeof POSTURE_WORDS)[number];
|
|
6
|
+
export type MeEngineRuleWord = (typeof RULE_WORDS)[number];
|
|
7
|
+
export type OpenWordReading<K extends string> = {
|
|
8
|
+
readonly kind: 'listed';
|
|
9
|
+
readonly word: K;
|
|
10
|
+
} | {
|
|
11
|
+
readonly kind: 'unlisted';
|
|
12
|
+
readonly word: string;
|
|
13
|
+
} | {
|
|
14
|
+
readonly kind: 'unreadable';
|
|
15
|
+
};
|
|
16
|
+
export interface EngineRowReading {
|
|
17
|
+
readonly name: string;
|
|
18
|
+
readonly kind: OpenWordReading<EngineKindWord>;
|
|
19
|
+
readonly scope: string | undefined;
|
|
20
|
+
readonly online: boolean | undefined;
|
|
21
|
+
readonly posture: OpenWordReading<EnginePostureWord>;
|
|
22
|
+
readonly viaCenter: string;
|
|
23
|
+
}
|
|
24
|
+
export interface EngineRowSet {
|
|
25
|
+
readonly rows: readonly EngineRowReading[];
|
|
26
|
+
readonly unreadableRows: number;
|
|
27
|
+
readonly unreadableNames: readonly string[];
|
|
28
|
+
}
|
|
29
|
+
export type MeEngineTargetReading = {
|
|
30
|
+
readonly kind: 'row';
|
|
31
|
+
readonly row: EngineRowReading;
|
|
32
|
+
} | {
|
|
33
|
+
readonly kind: 'null';
|
|
34
|
+
} | {
|
|
35
|
+
readonly kind: 'unreadable';
|
|
36
|
+
};
|
|
37
|
+
export interface MeEngineReading {
|
|
38
|
+
readonly rule: OpenWordReading<MeEngineRuleWord>;
|
|
39
|
+
readonly target: MeEngineTargetReading;
|
|
40
|
+
readonly candidates: EngineRowSet | undefined;
|
|
41
|
+
}
|
|
42
|
+
export type MeEngineUnresolvedReason = 'body' | 'rule' | 'rule-unlisted' | 'target' | 'candidates' | 'conflict';
|
|
43
|
+
export type MeEngineDecision = {
|
|
44
|
+
readonly kind: 'connect';
|
|
45
|
+
readonly engine: EngineRowReading;
|
|
46
|
+
readonly rule: OpenWordReading<MeEngineRuleWord>;
|
|
47
|
+
} | {
|
|
48
|
+
readonly kind: 'no-engine';
|
|
49
|
+
} | {
|
|
50
|
+
readonly kind: 'choose';
|
|
51
|
+
readonly candidates: EngineRowSet;
|
|
52
|
+
} | {
|
|
53
|
+
readonly kind: 'unresolved';
|
|
54
|
+
readonly reason: MeEngineUnresolvedReason;
|
|
55
|
+
readonly rule: OpenWordReading<MeEngineRuleWord>;
|
|
56
|
+
readonly candidates: EngineRowSet | undefined;
|
|
57
|
+
};
|
|
58
|
+
export type EngineOverrideDecision = {
|
|
59
|
+
readonly kind: 'select';
|
|
60
|
+
readonly engine: EngineRowReading;
|
|
61
|
+
} | {
|
|
62
|
+
readonly kind: 'not-listed';
|
|
63
|
+
readonly candidates: EngineRowSet;
|
|
64
|
+
} | {
|
|
65
|
+
readonly kind: 'duplicate';
|
|
66
|
+
readonly name: string;
|
|
67
|
+
} | {
|
|
68
|
+
readonly kind: 'row-unreadable';
|
|
69
|
+
readonly name: string;
|
|
70
|
+
} | {
|
|
71
|
+
readonly kind: 'unreadable';
|
|
72
|
+
} | {
|
|
73
|
+
readonly kind: 'invalid';
|
|
74
|
+
};
|
|
75
|
+
export declare function projectEngineDirectory(body: unknown): EngineRowSet | undefined;
|
|
76
|
+
export declare function projectMeEngine(body: unknown): MeEngineReading | undefined;
|
|
77
|
+
export declare function decideMeEngine(reading: MeEngineReading | undefined): MeEngineDecision;
|
|
78
|
+
export declare function engineOverrideOf(set: EngineRowSet | undefined, requested: unknown): EngineOverrideDecision;
|
|
79
|
+
export {};
|