@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
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { guardedRead, readOwnDataNonEmptyString, readOwnDataValue } from './ownKey.js';
|
|
2
|
+
const KIND_WORDS = ['managed'];
|
|
3
|
+
const POSTURE_WORDS = ['single', 'multi'];
|
|
4
|
+
const RULE_WORDS = ['only-one', 'none', 'ambiguous'];
|
|
5
|
+
const UNREADABLE = Object.freeze({ kind: 'unreadable' });
|
|
6
|
+
function isCenterRelativePath(path) {
|
|
7
|
+
if (path.length === 0 || path.charCodeAt(0) !== 0x2f)
|
|
8
|
+
return false;
|
|
9
|
+
const second = path.charCodeAt(1);
|
|
10
|
+
if (second === 0x2f || second === 0x5c)
|
|
11
|
+
return false;
|
|
12
|
+
if (/[\s\u0000-\u001f\u007f-\u009f\\?#]/u.test(path))
|
|
13
|
+
return false;
|
|
14
|
+
return path.split('/').every((segment) => {
|
|
15
|
+
const decoded = segment.replace(/%2e/gi, '.');
|
|
16
|
+
return decoded !== '.' && decoded !== '..';
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function isObj(v) {
|
|
20
|
+
return typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
21
|
+
}
|
|
22
|
+
function stringOf(holder, key) {
|
|
23
|
+
return guardedRead(() => readOwnDataNonEmptyString(holder, key));
|
|
24
|
+
}
|
|
25
|
+
function boolOf(holder, key) {
|
|
26
|
+
return guardedRead(() => {
|
|
27
|
+
const v = readOwnDataValue(holder, key);
|
|
28
|
+
return typeof v === 'boolean' ? v : undefined;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function wordOf(holder, key, listed) {
|
|
32
|
+
const word = stringOf(holder, key);
|
|
33
|
+
if (word === undefined)
|
|
34
|
+
return UNREADABLE;
|
|
35
|
+
const hit = listed.find((w) => w === word);
|
|
36
|
+
return hit !== undefined ? { kind: 'listed', word: hit } : { kind: 'unlisted', word };
|
|
37
|
+
}
|
|
38
|
+
function rowOf(raw) {
|
|
39
|
+
try {
|
|
40
|
+
if (!isObj(raw))
|
|
41
|
+
return undefined;
|
|
42
|
+
const name = stringOf(raw, 'name');
|
|
43
|
+
if (name === undefined)
|
|
44
|
+
return undefined;
|
|
45
|
+
const connect = guardedRead(() => readOwnDataValue(raw, 'connect'));
|
|
46
|
+
if (!isObj(connect))
|
|
47
|
+
return undefined;
|
|
48
|
+
const viaCenter = stringOf(connect, 'viaCenter');
|
|
49
|
+
if (viaCenter === undefined || !isCenterRelativePath(viaCenter))
|
|
50
|
+
return undefined;
|
|
51
|
+
return {
|
|
52
|
+
name,
|
|
53
|
+
kind: wordOf(raw, 'kind', KIND_WORDS),
|
|
54
|
+
scope: stringOf(raw, 'scope'),
|
|
55
|
+
online: boolOf(raw, 'online'),
|
|
56
|
+
posture: wordOf(raw, 'posture', POSTURE_WORDS),
|
|
57
|
+
viaCenter,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function rowSetOf(raw) {
|
|
65
|
+
try {
|
|
66
|
+
if (!Array.isArray(raw))
|
|
67
|
+
return undefined;
|
|
68
|
+
const length = readOwnDataValue(raw, 'length');
|
|
69
|
+
if (typeof length !== 'number' || !Number.isSafeInteger(length) || length < 0)
|
|
70
|
+
return undefined;
|
|
71
|
+
const rows = [];
|
|
72
|
+
const unreadableNames = [];
|
|
73
|
+
let unreadableRows = 0;
|
|
74
|
+
for (let i = 0; i < length; i += 1) {
|
|
75
|
+
const element = guardedRead(() => readOwnDataValue(raw, String(i)));
|
|
76
|
+
const row = rowOf(element);
|
|
77
|
+
if (row !== undefined) {
|
|
78
|
+
rows.push(row);
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
unreadableRows += 1;
|
|
82
|
+
const name = guardedRead(() => (isObj(element) ? stringOf(element, 'name') : undefined));
|
|
83
|
+
if (name !== undefined)
|
|
84
|
+
unreadableNames.push(name);
|
|
85
|
+
}
|
|
86
|
+
return { rows, unreadableRows, unreadableNames };
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
export function projectEngineDirectory(body) {
|
|
93
|
+
try {
|
|
94
|
+
if (!isObj(body))
|
|
95
|
+
return undefined;
|
|
96
|
+
return rowSetOf(readOwnDataValue(body, 'engines'));
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
export function projectMeEngine(body) {
|
|
103
|
+
try {
|
|
104
|
+
if (!isObj(body))
|
|
105
|
+
return undefined;
|
|
106
|
+
const rule = wordOf(body, 'rule', RULE_WORDS);
|
|
107
|
+
const rawTarget = guardedRead(() => readOwnDataValue(body, 'target'));
|
|
108
|
+
let target = UNREADABLE;
|
|
109
|
+
if (rawTarget === null) {
|
|
110
|
+
target = { kind: 'null' };
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
const row = rowOf(rawTarget);
|
|
114
|
+
if (row !== undefined)
|
|
115
|
+
target = { kind: 'row', row };
|
|
116
|
+
}
|
|
117
|
+
const candidates = guardedRead(() => rowSetOf(readOwnDataValue(body, 'candidates')));
|
|
118
|
+
if (rule.kind === 'unreadable' && target.kind === 'unreadable' && candidates === undefined)
|
|
119
|
+
return undefined;
|
|
120
|
+
return { rule, target, candidates };
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
return undefined;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
export function decideMeEngine(reading) {
|
|
127
|
+
try {
|
|
128
|
+
if (reading === undefined)
|
|
129
|
+
return { kind: 'unresolved', reason: 'body', rule: UNREADABLE, candidates: undefined };
|
|
130
|
+
const { rule, target, candidates } = reading;
|
|
131
|
+
const unresolved = (reason) => ({ kind: 'unresolved', reason, rule, candidates });
|
|
132
|
+
if (rule.kind === 'unreadable')
|
|
133
|
+
return unresolved('rule');
|
|
134
|
+
if (target.kind === 'unreadable')
|
|
135
|
+
return unresolved('target');
|
|
136
|
+
if (target.kind === 'row') {
|
|
137
|
+
if (rule.kind === 'listed' && (rule.word === 'none' || rule.word === 'ambiguous'))
|
|
138
|
+
return unresolved('conflict');
|
|
139
|
+
if (candidates === undefined)
|
|
140
|
+
return unresolved('candidates');
|
|
141
|
+
const picked = target.row;
|
|
142
|
+
if (!candidates.rows.some((row) => row.name === picked.name && row.viaCenter === picked.viaCenter))
|
|
143
|
+
return unresolved('conflict');
|
|
144
|
+
if (rule.kind === 'listed' && (candidates.rows.length !== 1 || candidates.unreadableRows !== 0))
|
|
145
|
+
return unresolved('conflict');
|
|
146
|
+
return { kind: 'connect', engine: picked, rule };
|
|
147
|
+
}
|
|
148
|
+
if (rule.kind === 'unlisted')
|
|
149
|
+
return unresolved('rule-unlisted');
|
|
150
|
+
if (rule.word === 'only-one')
|
|
151
|
+
return unresolved('conflict');
|
|
152
|
+
if (candidates === undefined)
|
|
153
|
+
return unresolved('candidates');
|
|
154
|
+
if (rule.word === 'none') {
|
|
155
|
+
if (candidates.rows.length === 0 && candidates.unreadableRows === 0)
|
|
156
|
+
return { kind: 'no-engine' };
|
|
157
|
+
return unresolved('conflict');
|
|
158
|
+
}
|
|
159
|
+
if (candidates.rows.length === 0)
|
|
160
|
+
return unresolved('candidates');
|
|
161
|
+
return candidates.rows.length + candidates.unreadableRows >= 2 ? { kind: 'choose', candidates } : unresolved('conflict');
|
|
162
|
+
}
|
|
163
|
+
catch {
|
|
164
|
+
return { kind: 'unresolved', reason: 'body', rule: UNREADABLE, candidates: undefined };
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
export function engineOverrideOf(set, requested) {
|
|
168
|
+
try {
|
|
169
|
+
if (typeof requested !== 'string' || requested === '')
|
|
170
|
+
return { kind: 'invalid' };
|
|
171
|
+
if (set === undefined)
|
|
172
|
+
return { kind: 'unreadable' };
|
|
173
|
+
const hits = set.rows.filter((row) => row.name === requested);
|
|
174
|
+
const hidden = set.unreadableNames.filter((name) => name === requested).length;
|
|
175
|
+
if (hits.length + hidden > 1)
|
|
176
|
+
return { kind: 'duplicate', name: requested };
|
|
177
|
+
if (hits.length === 1)
|
|
178
|
+
return { kind: 'select', engine: hits[0] };
|
|
179
|
+
if (hidden === 1)
|
|
180
|
+
return { kind: 'row-unreadable', name: requested };
|
|
181
|
+
return { kind: 'not-listed', candidates: set };
|
|
182
|
+
}
|
|
183
|
+
catch {
|
|
184
|
+
return { kind: 'unreadable' };
|
|
185
|
+
}
|
|
186
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export interface EngineEnvView {
|
|
2
|
+
raw(key: string): string | undefined;
|
|
3
|
+
get(key: string): string | undefined;
|
|
4
|
+
}
|
|
5
|
+
export interface EngineEnvGroupDecl {
|
|
6
|
+
readonly id: string;
|
|
7
|
+
readonly safety: boolean;
|
|
8
|
+
readonly keys: readonly string[];
|
|
9
|
+
readonly dropKeys: readonly string[];
|
|
10
|
+
refuses(view: EngineEnvView): boolean;
|
|
11
|
+
readonly skippable?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface EngineEnvSourcingInput {
|
|
14
|
+
readonly env: Readonly<Record<string, string | undefined>>;
|
|
15
|
+
readonly caseInsensitive: boolean;
|
|
16
|
+
readonly sources: ReadonlyArray<{
|
|
17
|
+
readonly source: string;
|
|
18
|
+
readonly keys: readonly string[];
|
|
19
|
+
}>;
|
|
20
|
+
ignored(key: string, source: string): boolean;
|
|
21
|
+
readonly aliases?: ReadonlyArray<readonly [from: string, to: string]>;
|
|
22
|
+
readonly groups: readonly EngineEnvGroupDecl[];
|
|
23
|
+
}
|
|
24
|
+
export interface EngineEnvTouchedKey {
|
|
25
|
+
readonly key: string;
|
|
26
|
+
readonly written: string;
|
|
27
|
+
readonly source: string;
|
|
28
|
+
}
|
|
29
|
+
export interface EngineEnvGroupReading {
|
|
30
|
+
readonly id: string;
|
|
31
|
+
readonly touched: readonly EngineEnvTouchedKey[];
|
|
32
|
+
readonly refuses: boolean;
|
|
33
|
+
readonly action: 'none' | 'skip' | 'refuse-explained';
|
|
34
|
+
readonly own: readonly string[];
|
|
35
|
+
}
|
|
36
|
+
export type EngineEnvKeyReason = {
|
|
37
|
+
readonly key: string;
|
|
38
|
+
readonly reason: 'repo-half-ignored';
|
|
39
|
+
readonly written: string;
|
|
40
|
+
readonly source: string;
|
|
41
|
+
readonly groups: readonly string[];
|
|
42
|
+
} | {
|
|
43
|
+
readonly key: string;
|
|
44
|
+
readonly reason: 'dropped-with-group';
|
|
45
|
+
readonly groups: readonly string[];
|
|
46
|
+
};
|
|
47
|
+
export interface EngineEnvSourcingVerdict {
|
|
48
|
+
readonly drop: readonly string[];
|
|
49
|
+
readonly groups: readonly EngineEnvGroupReading[];
|
|
50
|
+
readonly keys: readonly EngineEnvKeyReason[];
|
|
51
|
+
}
|
|
52
|
+
export declare function engineEnvView(env: Readonly<Record<string, string | undefined>>, caseInsensitive: boolean): EngineEnvView;
|
|
53
|
+
export declare function resolveEngineEnvSourcing(input: EngineEnvSourcingInput): EngineEnvSourcingVerdict;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export function engineEnvView(env, caseInsensitive) {
|
|
2
|
+
const raw = (key) => {
|
|
3
|
+
const direct = env[key];
|
|
4
|
+
if (direct !== undefined || !caseInsensitive)
|
|
5
|
+
return direct;
|
|
6
|
+
const upper = key.toUpperCase();
|
|
7
|
+
for (const [k, v] of Object.entries(env))
|
|
8
|
+
if (k.toUpperCase() === upper)
|
|
9
|
+
return v;
|
|
10
|
+
return undefined;
|
|
11
|
+
};
|
|
12
|
+
return { raw, get: (key) => { const v = raw(key); return v === undefined || v === '' ? undefined : v; } };
|
|
13
|
+
}
|
|
14
|
+
function safely(f) {
|
|
15
|
+
try {
|
|
16
|
+
return f() === true;
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function resolveEngineEnvSourcing(input) {
|
|
23
|
+
const view = engineEnvView(input.env, input.caseInsensitive === true);
|
|
24
|
+
const alias = new Map((input.aliases ?? []).map(([from, to]) => [from.toUpperCase(), to.toUpperCase()]));
|
|
25
|
+
const repo = new Map();
|
|
26
|
+
for (const { source, keys } of input.sources) {
|
|
27
|
+
for (const k of keys) {
|
|
28
|
+
if (!safely(() => input.ignored(k, source)))
|
|
29
|
+
continue;
|
|
30
|
+
const upper = k.toUpperCase();
|
|
31
|
+
repo.set(upper, { source, written: k });
|
|
32
|
+
const target = alias.get(upper);
|
|
33
|
+
if (target !== undefined && !repo.has(target))
|
|
34
|
+
repo.set(target, { source, written: k });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const drop = [];
|
|
38
|
+
const groups = [];
|
|
39
|
+
const halfRows = new Map();
|
|
40
|
+
const dropRows = new Map();
|
|
41
|
+
for (const g of input.groups) {
|
|
42
|
+
const touched = [];
|
|
43
|
+
for (const k of g.keys) {
|
|
44
|
+
const hit = repo.get(k);
|
|
45
|
+
if (hit !== undefined && view.get(k) === undefined)
|
|
46
|
+
touched.push({ key: k, written: hit.written, source: hit.source });
|
|
47
|
+
}
|
|
48
|
+
const refuses = touched.length > 0 && safely(() => g.refuses(view));
|
|
49
|
+
let action = 'none';
|
|
50
|
+
let own = [];
|
|
51
|
+
if (refuses) {
|
|
52
|
+
own = g.dropKeys.filter((k) => view.raw(k) !== undefined);
|
|
53
|
+
if (g.safety || g.skippable === false)
|
|
54
|
+
action = 'refuse-explained';
|
|
55
|
+
else {
|
|
56
|
+
action = 'skip';
|
|
57
|
+
drop.push(...g.dropKeys);
|
|
58
|
+
for (const k of g.dropKeys) {
|
|
59
|
+
const row = dropRows.get(k);
|
|
60
|
+
if (row === undefined)
|
|
61
|
+
dropRows.set(k, { key: k, groups: [g.id] });
|
|
62
|
+
else if (!row.groups.includes(g.id))
|
|
63
|
+
row.groups.push(g.id);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
for (const t of touched) {
|
|
67
|
+
const row = halfRows.get(t.key);
|
|
68
|
+
if (row === undefined)
|
|
69
|
+
halfRows.set(t.key, { ...t, groups: [g.id] });
|
|
70
|
+
else if (!row.groups.includes(g.id))
|
|
71
|
+
row.groups.push(g.id);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
groups.push({ id: g.id, touched, refuses, action, own });
|
|
75
|
+
}
|
|
76
|
+
const keys = [
|
|
77
|
+
...[...halfRows.values()].map((r) => ({ key: r.key, reason: 'repo-half-ignored', written: r.written, source: r.source, groups: r.groups })),
|
|
78
|
+
...[...dropRows.values()].map((r) => ({ key: r.key, reason: 'dropped-with-group', groups: r.groups })),
|
|
79
|
+
];
|
|
80
|
+
return { drop, groups, keys };
|
|
81
|
+
}
|
|
@@ -18,7 +18,6 @@ export declare const CONFIG_IMAGE_INVALID = "config.image_invalid";
|
|
|
18
18
|
export declare function imageInvalidFailureNoteOf(code: string | undefined): string | undefined;
|
|
19
19
|
export declare const CONFIG_AGENT_UNKNOWN_TOOL = "config.agent.unknown_tool";
|
|
20
20
|
export declare const CONFIG_OUTPUT_STYLE_INVALID = "config.output_style_invalid";
|
|
21
|
-
export declare const CONFIG_REFUSAL_CODES: ReadonlySet<string>;
|
|
22
21
|
export declare const RULES_LEGACY_TOOL_NAME = "rules.legacy_tool_name";
|
|
23
22
|
export declare function isRulesRefusalCode(code: string | undefined): boolean;
|
|
24
23
|
export declare const DELEGATION_CONCURRENCY_CAP = "delegation.concurrency_cap";
|
|
@@ -33,8 +32,18 @@ export declare const TOOL_END_INTERRUPTED_NEVER_STARTED = "interrupted_never_sta
|
|
|
33
32
|
export declare const TOOL_END_INTERRUPTED_OUTCOME_UNKNOWN = "interrupted_outcome_unknown";
|
|
34
33
|
export declare function isInterruptedToolEndCode(code: string | undefined): boolean;
|
|
35
34
|
export declare const CAPABILITY_SELF_ORCHESTRATION_REQUIRED = "capability.self_orchestration_required";
|
|
35
|
+
export declare const CAPABILITY_IMAGE_INDEX_REQUIRED = "capability.image_index_required";
|
|
36
36
|
export declare const GATE_PARKED_ERROR_CODE = "gate.parked";
|
|
37
37
|
export declare const ACTIVE_RUN_BUSY_ERROR_CODE = "conflict.session_active_run";
|
|
38
|
+
export interface BusyClassification {
|
|
39
|
+
readonly busy: boolean;
|
|
40
|
+
readonly handle: string | null;
|
|
41
|
+
}
|
|
42
|
+
export declare function classifyActiveRunBusy(input: {
|
|
43
|
+
errorCode: string | undefined;
|
|
44
|
+
activeTaskId: unknown;
|
|
45
|
+
}): BusyClassification;
|
|
46
|
+
export declare function activeRunBusyCarrierOf(ev: unknown): Record<string, unknown> | null;
|
|
38
47
|
export declare const CORRUPT_SESSION_ERROR_CODE = "corrupt_session";
|
|
39
48
|
export declare function isCorruptSessionCode(code: string | null | undefined): boolean;
|
|
40
49
|
export declare const STOP_PARK_ARBITER_UNREACHABLE = "stop.park_arbiter_unreachable";
|
|
@@ -56,7 +65,12 @@ export declare const RESUME_SESSION_NOT_FOUND = "resume.session_not_found";
|
|
|
56
65
|
export declare const REQUEST_FIELD_CONFLICT = "request.field_conflict";
|
|
57
66
|
export declare const REQUEST_AUTONOMY_LANE_REFUSED = "request.autonomy_lane_refused";
|
|
58
67
|
export declare const CHECKPOINT_UNSUPPORTED_VERSION = "checkpoint.unsupported_version";
|
|
68
|
+
export declare const CHECKPOINT_WALLTIME_AXIS_RETIRED = "checkpoint.walltime_axis_retired";
|
|
69
|
+
export declare const CHECKPOINT_CONFIG_REFUSED = "checkpoint.config_refused";
|
|
70
|
+
export declare const CHECKPOINT_REFUSED_PARK_CODES: readonly string[];
|
|
71
|
+
export declare function isRefusedParkCode(code: string | null | undefined): code is typeof CHECKPOINT_UNSUPPORTED_VERSION | typeof CHECKPOINT_WALLTIME_AXIS_RETIRED | typeof CHECKPOINT_CONFIG_REFUSED;
|
|
59
72
|
export declare function refusalSaysStillPending(err: object): boolean;
|
|
73
|
+
export declare function refusalRetriableReading(err: object): boolean | undefined;
|
|
60
74
|
export type StatusDerivedCoarseCode = (typeof STATUS_DERIVED_COARSE_CODES)[number];
|
|
61
75
|
export declare const RESUME_PLACEMENT_MISMATCH = "resume.placement_mismatch";
|
|
62
76
|
export declare const RESUME_CONTEXT_UNAVAILABLE = "conflict.resume_context_unavailable";
|
|
@@ -76,13 +90,23 @@ export declare const DECIDE_GATE_MOVED = "decide.gate_moved";
|
|
|
76
90
|
export declare const DECIDE_CLAIM_LOST = "decide.claim_lost";
|
|
77
91
|
export declare const DECIDE_PARK_MOVED_CODES: readonly string[];
|
|
78
92
|
export declare function isDecideParkMovedCode(code: string | null | undefined): boolean;
|
|
93
|
+
export declare const APPROVAL_STALE = "approval_stale";
|
|
94
|
+
export declare const APPROVAL_BINDING_MISMATCH = "approval_binding_mismatch";
|
|
95
|
+
export declare const RESUME_OUTCOME_INVALID = "resume_outcome_invalid";
|
|
96
|
+
export declare const CHECKPOINT_ALREADY_RESOLVED = "checkpoint.already_resolved";
|
|
97
|
+
export declare const NOT_FOUND_APPROVAL = "not_found.approval";
|
|
98
|
+
export declare const NOT_FOUND_CHECKPOINT = "not_found.checkpoint";
|
|
99
|
+
export declare const NOT_FOUND_BLOB = "not_found.blob";
|
|
100
|
+
export declare const DECIDE_ALREADY_RESOLVED_CODES: readonly string[];
|
|
101
|
+
export declare function isDecideAlreadyResolvedCode(code: string | null | undefined): boolean;
|
|
79
102
|
export declare const ASK_GONE = "gone.ask";
|
|
103
|
+
export declare const ASK_GONE_PARKED = "gone.ask_parked";
|
|
80
104
|
export declare const ASK_GONE_DENIED_WORD: "routing_failure_fail_closed";
|
|
81
|
-
export declare const RUN_STALLED = "run.stalled";
|
|
82
|
-
export declare const RUN_ORPHANED = "run.orphaned";
|
|
83
|
-
export declare const APPROVAL_EXPIRED = "approval.expired";
|
|
84
105
|
export declare const RUN_DEATH_VERDICT_CODES: readonly ["run.stalled", "run.orphaned", "approval.expired"];
|
|
85
106
|
export type RunDeathVerdictCode = (typeof RUN_DEATH_VERDICT_CODES)[number];
|
|
107
|
+
export declare const RUN_STALLED: "run.stalled";
|
|
108
|
+
export declare const RUN_ORPHANED: "run.orphaned";
|
|
109
|
+
export declare const APPROVAL_EXPIRED: "approval.expired";
|
|
86
110
|
export declare function runDeathVerdictNoteOf(code: string | undefined): string | undefined;
|
|
87
111
|
export declare const CAPABILITY_OPERATOR_PRINCIPALS_REQUIRED = "capability.operator_principals_required";
|
|
88
112
|
export declare const COMPACT_NOT_RUNNING = "compact.not_running";
|
package/dist/engineErrorCodes.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { frozenSet } from './frozenSet.js';
|
|
2
|
-
import {
|
|
3
|
-
import { SDK_DENY_REASON_ROUTING_FAILURE, SDK_STATUS_DERIVED_COARSE_CODES } from './generated/sdkFactTables.js';
|
|
2
|
+
import { SDK_DENY_REASON_ROUTING_FAILURE, SDK_RUN_DEATH_VERDICT_CODES, SDK_STATUS_DERIVED_COARSE_CODES } from './generated/sdkFactTables.js';
|
|
4
3
|
export const LIMITS_MAX_TOKENS_EXCEEDED = 'limits.max_tokens_exceeded';
|
|
5
4
|
export const LIMITS_MAX_COST_EXCEEDED = 'limits.max_cost_exceeded';
|
|
6
5
|
export const LIMITS_MAX_TURNS_EXCEEDED = 'limits.max_turns_exceeded';
|
|
@@ -28,20 +27,6 @@ export function imageInvalidFailureNoteOf(code) {
|
|
|
28
27
|
}
|
|
29
28
|
export const CONFIG_AGENT_UNKNOWN_TOOL = 'config.agent.unknown_tool';
|
|
30
29
|
export const CONFIG_OUTPUT_STYLE_INVALID = 'config.output_style_invalid';
|
|
31
|
-
export const CONFIG_REFUSAL_CODES = frozenSet([
|
|
32
|
-
CONFIG_LIMIT_INVALID,
|
|
33
|
-
CONFIG_STRATEGY_FIND_LIMIT_INVALID,
|
|
34
|
-
CONFIG_STRATEGY_MAX_SIZE_INVALID,
|
|
35
|
-
CONFIG_LIMIT_UNKNOWN_KEY,
|
|
36
|
-
CONFIG_DELEGATION_ENTRY_CAPS,
|
|
37
|
-
CONFIG_MEMORY_PROJECT_KEY_SPELLING,
|
|
38
|
-
CONFIG_MEMORY_WRITE_SCOPE_MISMATCH,
|
|
39
|
-
CONFIG_LEGACY_TOOL_NAME,
|
|
40
|
-
CONFIG_IMAGE_INVALID,
|
|
41
|
-
CONFIG_AGENT_UNKNOWN_TOOL,
|
|
42
|
-
CONFIG_OUTPUT_STYLE_INVALID,
|
|
43
|
-
...CORE_TOOL_DECLARATION_CODES,
|
|
44
|
-
]);
|
|
45
30
|
export const RULES_LEGACY_TOOL_NAME = 'rules.legacy_tool_name';
|
|
46
31
|
const RULES_ERROR_CODE_PREFIX = 'rules.';
|
|
47
32
|
export function isRulesRefusalCode(code) {
|
|
@@ -77,8 +62,35 @@ export function isInterruptedToolEndCode(code) {
|
|
|
77
62
|
return typeof code === 'string' && TOOL_END_INTERRUPTED_CODES.has(code);
|
|
78
63
|
}
|
|
79
64
|
export const CAPABILITY_SELF_ORCHESTRATION_REQUIRED = 'capability.self_orchestration_required';
|
|
65
|
+
export const CAPABILITY_IMAGE_INDEX_REQUIRED = 'capability.image_index_required';
|
|
80
66
|
export const GATE_PARKED_ERROR_CODE = 'gate.parked';
|
|
81
67
|
export const ACTIVE_RUN_BUSY_ERROR_CODE = 'conflict.session_active_run';
|
|
68
|
+
export function classifyActiveRunBusy(input) {
|
|
69
|
+
const handle = typeof input.activeTaskId === 'string' && input.activeTaskId.length > 0 ? input.activeTaskId : null;
|
|
70
|
+
if (input.errorCode === ACTIVE_RUN_BUSY_ERROR_CODE)
|
|
71
|
+
return { busy: true, handle };
|
|
72
|
+
if (typeof input.activeTaskId === 'string')
|
|
73
|
+
return { busy: true, handle };
|
|
74
|
+
return { busy: false, handle };
|
|
75
|
+
}
|
|
76
|
+
export function activeRunBusyCarrierOf(ev) {
|
|
77
|
+
if (typeof ev !== 'object' || ev === null || !('type' in ev))
|
|
78
|
+
return null;
|
|
79
|
+
const type = ev.type;
|
|
80
|
+
if (type === 'failed')
|
|
81
|
+
return ev;
|
|
82
|
+
if (type !== 'done')
|
|
83
|
+
return null;
|
|
84
|
+
const result = ev.result;
|
|
85
|
+
if (typeof result !== 'object' || result === null)
|
|
86
|
+
return null;
|
|
87
|
+
const status = result.status;
|
|
88
|
+
if (status === 'failed')
|
|
89
|
+
return result;
|
|
90
|
+
if (status === undefined && !Array.isArray(result) && Object.hasOwn(result, 'terminal'))
|
|
91
|
+
return result;
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
82
94
|
export const CORRUPT_SESSION_ERROR_CODE = 'corrupt_session';
|
|
83
95
|
export function isCorruptSessionCode(code) {
|
|
84
96
|
return code === CORRUPT_SESSION_ERROR_CODE;
|
|
@@ -112,12 +124,25 @@ export const RESUME_SESSION_NOT_FOUND = 'resume.session_not_found';
|
|
|
112
124
|
export const REQUEST_FIELD_CONFLICT = 'request.field_conflict';
|
|
113
125
|
export const REQUEST_AUTONOMY_LANE_REFUSED = 'request.autonomy_lane_refused';
|
|
114
126
|
export const CHECKPOINT_UNSUPPORTED_VERSION = 'checkpoint.unsupported_version';
|
|
127
|
+
export const CHECKPOINT_WALLTIME_AXIS_RETIRED = 'checkpoint.walltime_axis_retired';
|
|
128
|
+
export const CHECKPOINT_CONFIG_REFUSED = 'checkpoint.config_refused';
|
|
129
|
+
export const CHECKPOINT_REFUSED_PARK_CODES = Object.freeze([
|
|
130
|
+
CHECKPOINT_UNSUPPORTED_VERSION,
|
|
131
|
+
CHECKPOINT_WALLTIME_AXIS_RETIRED,
|
|
132
|
+
CHECKPOINT_CONFIG_REFUSED,
|
|
133
|
+
]);
|
|
134
|
+
export function isRefusedParkCode(code) {
|
|
135
|
+
return typeof code === 'string' && CHECKPOINT_REFUSED_PARK_CODES.includes(code);
|
|
136
|
+
}
|
|
115
137
|
export function refusalSaysStillPending(err) {
|
|
138
|
+
return refusalRetriableReading(err) === true;
|
|
139
|
+
}
|
|
140
|
+
export function refusalRetriableReading(err) {
|
|
116
141
|
try {
|
|
117
142
|
return Object.hasOwn(err, 'retriable') && err.retriable === true;
|
|
118
143
|
}
|
|
119
144
|
catch {
|
|
120
|
-
return
|
|
145
|
+
return undefined;
|
|
121
146
|
}
|
|
122
147
|
}
|
|
123
148
|
export const RESUME_PLACEMENT_MISMATCH = 'resume.placement_mismatch';
|
|
@@ -156,25 +181,43 @@ export const DECIDE_PARK_MOVED_CODES = Object.freeze([
|
|
|
156
181
|
export function isDecideParkMovedCode(code) {
|
|
157
182
|
return typeof code === 'string' && DECIDE_PARK_MOVED_CODES.includes(code);
|
|
158
183
|
}
|
|
184
|
+
export const APPROVAL_STALE = 'approval_stale';
|
|
185
|
+
export const APPROVAL_BINDING_MISMATCH = 'approval_binding_mismatch';
|
|
186
|
+
export const RESUME_OUTCOME_INVALID = 'resume_outcome_invalid';
|
|
187
|
+
export const CHECKPOINT_ALREADY_RESOLVED = 'checkpoint.already_resolved';
|
|
188
|
+
export const NOT_FOUND_APPROVAL = 'not_found.approval';
|
|
189
|
+
export const NOT_FOUND_CHECKPOINT = 'not_found.checkpoint';
|
|
190
|
+
export const NOT_FOUND_BLOB = 'not_found.blob';
|
|
191
|
+
export const DECIDE_ALREADY_RESOLVED_CODES = Object.freeze([
|
|
192
|
+
APPROVAL_STALE,
|
|
193
|
+
CHECKPOINT_ALREADY_RESOLVED,
|
|
194
|
+
NOT_FOUND_APPROVAL,
|
|
195
|
+
NOT_FOUND_CHECKPOINT,
|
|
196
|
+
]);
|
|
197
|
+
export function isDecideAlreadyResolvedCode(code) {
|
|
198
|
+
return typeof code === 'string' && DECIDE_ALREADY_RESOLVED_CODES.includes(code);
|
|
199
|
+
}
|
|
159
200
|
export const ASK_GONE = 'gone.ask';
|
|
201
|
+
export const ASK_GONE_PARKED = 'gone.ask_parked';
|
|
160
202
|
export const ASK_GONE_DENIED_WORD = SDK_DENY_REASON_ROUTING_FAILURE;
|
|
203
|
+
export const RUN_DEATH_VERDICT_CODES = SDK_RUN_DEATH_VERDICT_CODES;
|
|
204
|
+
const _runDeathVerdictCodePin = true;
|
|
205
|
+
void _runDeathVerdictCodePin;
|
|
161
206
|
export const RUN_STALLED = 'run.stalled';
|
|
162
207
|
export const RUN_ORPHANED = 'run.orphaned';
|
|
163
208
|
export const APPROVAL_EXPIRED = 'approval.expired';
|
|
164
|
-
export const RUN_DEATH_VERDICT_CODES = Object.freeze([RUN_STALLED, RUN_ORPHANED, APPROVAL_EXPIRED]);
|
|
165
209
|
const RUN_HOLDER_LOST_OUTLET = 'The request itself was not at fault, but this run cannot be picked up again; submit the work again as a new task.';
|
|
166
210
|
const RUN_ORPHANED_NOTE = 'This run ended because the engine process that was running it went away (it was restarted) before the run finished. ' + RUN_HOLDER_LOST_OUTLET;
|
|
167
211
|
const RUN_STALLED_NOTE = 'This run ended because the engine process that was running it stopped reporting in before the run finished. ' + RUN_HOLDER_LOST_OUTLET;
|
|
168
212
|
const RUN_APPROVAL_EXPIRED_NOTE = 'This run ended because it was waiting on an approval for too long and the engine retired it. ' +
|
|
169
213
|
'The request itself was not at fault, but this run cannot be picked up again; submit the work again as a new task, and it will ask for the approval again.';
|
|
214
|
+
const RUN_DEATH_VERDICT_NOTES = Object.freeze({
|
|
215
|
+
[RUN_STALLED]: RUN_STALLED_NOTE,
|
|
216
|
+
[RUN_ORPHANED]: RUN_ORPHANED_NOTE,
|
|
217
|
+
[APPROVAL_EXPIRED]: RUN_APPROVAL_EXPIRED_NOTE,
|
|
218
|
+
});
|
|
170
219
|
export function runDeathVerdictNoteOf(code) {
|
|
171
|
-
|
|
172
|
-
return RUN_ORPHANED_NOTE;
|
|
173
|
-
if (code === RUN_STALLED)
|
|
174
|
-
return RUN_STALLED_NOTE;
|
|
175
|
-
if (code === APPROVAL_EXPIRED)
|
|
176
|
-
return RUN_APPROVAL_EXPIRED_NOTE;
|
|
177
|
-
return undefined;
|
|
220
|
+
return typeof code === 'string' && Object.hasOwn(RUN_DEATH_VERDICT_NOTES, code) ? RUN_DEATH_VERDICT_NOTES[code] : undefined;
|
|
178
221
|
}
|
|
179
222
|
export const CAPABILITY_OPERATOR_PRINCIPALS_REQUIRED = 'capability.operator_principals_required';
|
|
180
223
|
export const COMPACT_NOT_RUNNING = 'compact.not_running';
|
package/dist/engineIdentity.js
CHANGED
|
@@ -171,6 +171,7 @@ export type ToolTurnIncompleteCause = (typeof CORE_TOOL_TURN_INCOMPLETE_CAUSES)[
|
|
|
171
171
|
export interface ToolTurnIncompleteFactsView {
|
|
172
172
|
cause: string;
|
|
173
173
|
count: number;
|
|
174
|
+
outcome?: string;
|
|
174
175
|
toolCallIds?: readonly string[];
|
|
175
176
|
sessionId: string;
|
|
176
177
|
runId: string;
|
|
@@ -201,6 +202,20 @@ export declare function readTurnInterrupted(notice: unknown): TurnInterruptedFac
|
|
|
201
202
|
export declare function turnInterruptedNotice(facts: Pick<TurnInterruptedFactsView, 'lane'>): string | undefined;
|
|
202
203
|
export type SteerCutVerdict = 'this_input' | 'other_input' | 'user_halt' | 'unattributed' | 'not_a_cut';
|
|
203
204
|
export declare function steerCutVerdict(notice: unknown, messageId: string | undefined): SteerCutVerdict;
|
|
205
|
+
export interface FinishReasonUnknownFactsView {
|
|
206
|
+
finishReason: string;
|
|
207
|
+
sessionId: string;
|
|
208
|
+
runId: string;
|
|
209
|
+
}
|
|
210
|
+
export declare function readFinishReasonUnknown(notice: unknown): FinishReasonUnknownFactsView | undefined;
|
|
211
|
+
export interface StreamEndIgnoredFactsView {
|
|
212
|
+
statement: string;
|
|
213
|
+
word: string;
|
|
214
|
+
frames: number;
|
|
215
|
+
sessionId: string;
|
|
216
|
+
runId: string;
|
|
217
|
+
}
|
|
218
|
+
export declare function readStreamEndIgnored(notice: unknown): StreamEndIgnoredFactsView | undefined;
|
|
204
219
|
export declare const ENGINE_NOTICE_FACT_READERS: Readonly<{
|
|
205
220
|
readonly 'mcp.injection_dropped': typeof readMcpInjectionDrop;
|
|
206
221
|
readonly 'delegation.ask_unresolvable': typeof readAskUnresolvable;
|
|
@@ -223,6 +238,8 @@ export declare const ENGINE_NOTICE_FACT_READERS: Readonly<{
|
|
|
223
238
|
readonly 'task.user_steer_undrained': typeof readUserInputUndrained;
|
|
224
239
|
readonly 'task.user_followup_undrained': typeof readUserInputUndrained;
|
|
225
240
|
readonly 'task.turn_interrupted': typeof readTurnInterrupted;
|
|
241
|
+
readonly 'route.finish_reason_unknown': typeof readFinishReasonUnknown;
|
|
242
|
+
readonly 'route.stream_end_ignored': typeof readStreamEndIgnored;
|
|
226
243
|
}>;
|
|
227
244
|
type FactReaderTable = typeof ENGINE_NOTICE_FACT_READERS;
|
|
228
245
|
export type EngineNoticeFactsCode = keyof FactReaderTable;
|