@sema-agent/client-core 0.100.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 +395 -0
- package/README.md +164 -117
- package/dist/adapt/arms.js +51 -16
- package/dist/adapt/textStream.js +7 -4
- package/dist/adapt/toolCards.js +9 -8
- package/dist/adapt.js +7 -1
- package/dist/adapter/activeRunSelfHeal.d.ts +24 -2
- package/dist/adapter/activeRunSelfHeal.js +108 -6
- package/dist/adapter/downstream/eventToSdkMessage.js +33 -12
- package/dist/adapter/downstream/terminalToSdkResult.d.ts +60 -1
- package/dist/adapter/downstream/terminalToSdkResult.js +209 -39
- package/dist/adapter/runStream.d.ts +4 -4
- package/dist/adapter/runStream.js +158 -43
- package/dist/agentsWireCaps.d.ts +2 -7
- package/dist/agentsWireCaps.js +1 -2
- 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 +19 -5
- package/dist/cloudConfigWireCaps.js +193 -56
- package/dist/coreValuePorts.d.ts +12 -2
- package/dist/coreValuePorts.js +9 -0
- package/dist/decideFailureNote.js +5 -3
- 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 +65 -8
- package/dist/engineCapReader.js +1 -1
- package/dist/engineConfigDrift.js +1 -1
- package/dist/engineErrorCodes.d.ts +14 -5
- package/dist/engineErrorCodes.js +27 -6
- 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 +3 -0
- package/dist/engineSessionMessages.js +2 -2
- package/dist/engineToolDirectory.js +2 -2
- 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/executionLaneCapability.js +2 -2
- package/dist/fileHistoryCaptureCapability.js +3 -3
- 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 -3
- package/dist/generated/engineFactTables.js +52 -0
- package/dist/generated/engineNoticeTables.js +12 -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 +54 -0
- package/dist/generated/settingsSchemaFns.js +26 -1
- package/dist/generated/settingsSchemaMcpRequestEntry.d.ts +1 -1
- package/dist/generated/settingsSchemaMcpRequestEntry.js +1 -7
- 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 +2 -0
- package/dist/generated/settingsSchemaTables.js +13 -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 +7 -5
- package/dist/hitl/approvalCardReading.d.ts +3 -0
- package/dist/hitl/approvalCardReading.js +17 -0
- 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/approvalResolution.d.ts +11 -0
- package/dist/hitl/approvalResolution.js +50 -11
- package/dist/hitl/askClassPair.d.ts +6 -0
- package/dist/hitl/askClassPair.js +30 -3
- 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 +42 -3
- package/dist/hitl/attributionLadder.js +79 -8
- 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/decisionRefusal.d.ts +20 -10
- package/dist/hitl/decisionRefusal.js +99 -54
- package/dist/hitl/decisionSend.d.ts +3 -0
- package/dist/hitl/decisionSend.js +87 -103
- 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 +41 -37
- 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 +59 -30
- 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 +62 -29
- 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 +72 -54
- 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 +73 -17
- package/dist/hostTurnSettings.js +594 -97
- package/dist/httpHookPolicy.d.ts +37 -0
- package/dist/httpHookPolicy.js +176 -0
- package/dist/humanTurn.d.ts +2 -1
- package/dist/humanTurn.js +37 -7
- 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 +184 -2
- package/dist/i18n/messages.en.js +187 -5
- package/dist/i18n/messages.zh.js +197 -5
- package/dist/i18n/translate.js +3 -3
- package/dist/index.d.ts +69 -15
- package/dist/index.js +45 -13
- package/dist/inheritEnvCapability.d.ts +3 -1
- package/dist/inheritEnvCapability.js +31 -17
- package/dist/inheritEnvWire.d.ts +2 -1
- package/dist/inheritEnvWire.js +11 -5
- 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 +1 -1
- package/dist/mcpProbeCapability.js +2 -2
- package/dist/mcpStatusSupersetKeys.d.ts +24 -0
- package/dist/mcpStatusSupersetKeys.js +45 -0
- package/dist/mcpToolToggles.js +2 -1
- package/dist/mcpWireCaps.d.ts +39 -1
- package/dist/mcpWireCaps.js +254 -50
- 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.js +6 -6
- package/dist/modelIdentityResolvability.d.ts +10 -1
- package/dist/modelIdentityResolvability.js +62 -39
- 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 +11 -0
- package/dist/ownKey.js +164 -3
- package/dist/panelReduce.js +1 -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.js +2 -0
- 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 +92 -53
- package/dist/prepareRefusal.d.ts +3 -2
- package/dist/prepareRefusal.js +27 -9
- 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 +12 -4
- package/dist/request/taskRequest.js +221 -152
- package/dist/resultFrameKeys.d.ts +1 -0
- package/dist/resultFrameKeys.js +4 -1
- package/dist/retryStatus.d.ts +8 -0
- package/dist/retryStatus.js +57 -9
- 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 +4 -0
- package/dist/ruleRefusalSentence.js +9 -3
- 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 +1 -1
- package/dist/sandboxWire.js +4 -6
- package/dist/scenarioRefusal.js +1 -1
- 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 +2 -0
- package/dist/seam.js +2 -2
- package/dist/seatContract.d.ts +46 -1
- package/dist/seatContract.js +49 -19
- 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.js +60 -5
- 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 -0
- package/dist/skillsWireCaps.js +47 -16
- 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/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/turnFailurePresentation.js +27 -90
- 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 +24 -1
- package/dist/wireRefusalCopy.js +253 -32
- 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 +607 -181
- package/package.json +14 -3
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { readOwnDataValue } from './ownKey.js';
|
|
2
|
+
const _healthFactsMatchSdk = [true, true, true, true, true, true];
|
|
3
|
+
void _healthFactsMatchSdk;
|
|
4
|
+
const ENGINE_SIGNAL_KEY = 'engineSignal';
|
|
5
|
+
function isObject(v) {
|
|
6
|
+
try {
|
|
7
|
+
return typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function nonEmptyString(v) {
|
|
14
|
+
return typeof v === 'string' && v.length > 0 ? v : undefined;
|
|
15
|
+
}
|
|
16
|
+
function epochMs(v) {
|
|
17
|
+
return typeof v === 'number' && Number.isSafeInteger(v) && v >= 0 ? v : undefined;
|
|
18
|
+
}
|
|
19
|
+
function centerOf(raw) {
|
|
20
|
+
if (!isObject(raw))
|
|
21
|
+
return undefined;
|
|
22
|
+
const sessionsVisible = readOwnDataValue(raw, 'sessionsVisible');
|
|
23
|
+
if (sessionsVisible !== true && sessionsVisible !== false && sessionsVisible !== 'unknown')
|
|
24
|
+
return undefined;
|
|
25
|
+
const issuerRaw = readOwnDataValue(raw, 'issuer');
|
|
26
|
+
const urlRaw = readOwnDataValue(raw, 'webBaseUrl');
|
|
27
|
+
const issuer = nonEmptyString(issuerRaw);
|
|
28
|
+
const webBaseUrl = nonEmptyString(urlRaw);
|
|
29
|
+
if (issuerRaw !== undefined && issuer === undefined)
|
|
30
|
+
return undefined;
|
|
31
|
+
if (urlRaw !== undefined && webBaseUrl === undefined)
|
|
32
|
+
return undefined;
|
|
33
|
+
return Object.freeze({ ...(issuer !== undefined ? { issuer } : {}), ...(webBaseUrl !== undefined ? { webBaseUrl } : {}), sessionsVisible });
|
|
34
|
+
}
|
|
35
|
+
function authOf(raw) {
|
|
36
|
+
if (!isObject(raw))
|
|
37
|
+
return undefined;
|
|
38
|
+
const required = readOwnDataValue(raw, 'required');
|
|
39
|
+
const identityAttach = readOwnDataValue(raw, 'identityAttach');
|
|
40
|
+
const kindsRaw = readOwnDataValue(raw, 'kinds');
|
|
41
|
+
if (typeof required !== 'boolean')
|
|
42
|
+
return undefined;
|
|
43
|
+
if (identityAttach !== 'available' && identityAttach !== 'unavailable')
|
|
44
|
+
return undefined;
|
|
45
|
+
if (!Array.isArray(kindsRaw))
|
|
46
|
+
return undefined;
|
|
47
|
+
const kinds = [];
|
|
48
|
+
for (let i = 0; i < kindsRaw.length; i++) {
|
|
49
|
+
const word = nonEmptyString(readOwnDataValue(kindsRaw, String(i)));
|
|
50
|
+
if (word === undefined)
|
|
51
|
+
return undefined;
|
|
52
|
+
kinds.push(word);
|
|
53
|
+
}
|
|
54
|
+
return Object.freeze({ required, kinds: Object.freeze(kinds), identityAttach });
|
|
55
|
+
}
|
|
56
|
+
function drainingOf(health) {
|
|
57
|
+
const signal = readOwnDataValue(health, ENGINE_SIGNAL_KEY);
|
|
58
|
+
if (!isObject(signal))
|
|
59
|
+
return undefined;
|
|
60
|
+
const raw = readOwnDataValue(signal, 'draining');
|
|
61
|
+
if (!isObject(raw))
|
|
62
|
+
return undefined;
|
|
63
|
+
const actionId = nonEmptyString(readOwnDataValue(raw, 'actionId'));
|
|
64
|
+
const since = epochMs(readOwnDataValue(raw, 'since'));
|
|
65
|
+
const deadlineAt = epochMs(readOwnDataValue(raw, 'deadlineAt'));
|
|
66
|
+
if (actionId === undefined || since === undefined || deadlineAt === undefined)
|
|
67
|
+
return undefined;
|
|
68
|
+
return Object.freeze({ actionId, since, deadlineAt });
|
|
69
|
+
}
|
|
70
|
+
function guarded(read) {
|
|
71
|
+
try {
|
|
72
|
+
return read();
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
export function readEngineHealthFacts(health) {
|
|
79
|
+
if (!isObject(health))
|
|
80
|
+
return Object.freeze({});
|
|
81
|
+
const center = guarded(() => centerOf(readOwnDataValue(health, 'center')));
|
|
82
|
+
const auth = guarded(() => authOf(readOwnDataValue(health, 'auth')));
|
|
83
|
+
const operatorRaw = guarded(() => readOwnDataValue(health, 'operator'));
|
|
84
|
+
const operator = operatorRaw === 'present' || operatorRaw === 'absent' ? operatorRaw : undefined;
|
|
85
|
+
const draining = guarded(() => drainingOf(health));
|
|
86
|
+
return Object.freeze({
|
|
87
|
+
...(center !== undefined ? { center } : {}),
|
|
88
|
+
...(auth !== undefined ? { auth } : {}),
|
|
89
|
+
...(operator !== undefined ? { operator } : {}),
|
|
90
|
+
...(draining !== undefined ? { draining } : {}),
|
|
91
|
+
});
|
|
92
|
+
}
|
package/dist/engineIdentity.d.ts
CHANGED
|
@@ -10,3 +10,7 @@ export declare function engineIdentityVerdict(a: unknown, b: unknown): EngineIde
|
|
|
10
10
|
export declare function engineIdentityChangedBy(a: unknown, b: unknown): keyof EngineIdentityView | undefined;
|
|
11
11
|
export declare function engineIdentityChanged(a: unknown, b: unknown): boolean;
|
|
12
12
|
export declare function toolKillCauseAcrossEngineIdentity(before: object | null | undefined, after: object | null | undefined): 'engine_restarted' | undefined;
|
|
13
|
+
export declare function toolKillCauseFromGenerationEnd(input: {
|
|
14
|
+
readonly cause?: string | undefined;
|
|
15
|
+
readonly stopSignalDelivered?: boolean | undefined;
|
|
16
|
+
} | null | undefined): 'engine_restarted' | undefined;
|
package/dist/engineIdentity.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { readOwnDataValue } from './ownKey.js';
|
|
1
2
|
const _startedAtIsOneQuantity = [true, true, true, true];
|
|
2
3
|
void _startedAtIsOneQuantity;
|
|
3
4
|
export const ENGINE_IDENTITY_ANCHORS = Object.freeze([
|
|
@@ -63,3 +64,13 @@ export function toolKillCauseAcrossEngineIdentity(before, after) {
|
|
|
63
64
|
return undefined;
|
|
64
65
|
}
|
|
65
66
|
}
|
|
67
|
+
export function toolKillCauseFromGenerationEnd(input) {
|
|
68
|
+
try {
|
|
69
|
+
if (typeof input !== 'object' || input === null)
|
|
70
|
+
return undefined;
|
|
71
|
+
return readOwnDataValue(input, 'cause') === 'respawned' && readOwnDataValue(input, 'stopSignalDelivered') === true ? 'engine_restarted' : undefined;
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { FinishReasonUnknownDetail } from '@sema-agent/sdk';
|
|
1
2
|
import { CORE_TOOL_TURN_INCOMPLETE_CAUSES, CORE_USER_INPUT_UNDRAINED_CAUSES, CORE_USER_INPUT_UNDRAINED_FAMILIES } from './generated/engineNoticeTables.js';
|
|
2
3
|
export type NoticeAudience = 'user' | 'operator';
|
|
3
4
|
export declare const ENGINE_NOTICE_CODES: readonly string[];
|
|
@@ -202,11 +203,7 @@ export declare function readTurnInterrupted(notice: unknown): TurnInterruptedFac
|
|
|
202
203
|
export declare function turnInterruptedNotice(facts: Pick<TurnInterruptedFactsView, 'lane'>): string | undefined;
|
|
203
204
|
export type SteerCutVerdict = 'this_input' | 'other_input' | 'user_halt' | 'unattributed' | 'not_a_cut';
|
|
204
205
|
export declare function steerCutVerdict(notice: unknown, messageId: string | undefined): SteerCutVerdict;
|
|
205
|
-
export
|
|
206
|
-
finishReason: string;
|
|
207
|
-
sessionId: string;
|
|
208
|
-
runId: string;
|
|
209
|
-
}
|
|
206
|
+
export type FinishReasonUnknownFactsView = FinishReasonUnknownDetail;
|
|
210
207
|
export declare function readFinishReasonUnknown(notice: unknown): FinishReasonUnknownFactsView | undefined;
|
|
211
208
|
export interface StreamEndIgnoredFactsView {
|
|
212
209
|
statement: string;
|
package/dist/engineRowRef.js
CHANGED
|
@@ -97,6 +97,9 @@ export const TRANSCRIPT_ROW_SIDECAR_KEYS = Object.freeze([
|
|
|
97
97
|
'_sema_api_error_code',
|
|
98
98
|
'_sema_provider_condition',
|
|
99
99
|
'_sema_terminal_owner',
|
|
100
|
+
'_sema_row_kind',
|
|
101
|
+
'_sema_coded_detail',
|
|
102
|
+
'_sema_task_notification',
|
|
100
103
|
]);
|
|
101
104
|
export function parkHeldCallIdOf(carrier) {
|
|
102
105
|
return readFrameStringKey(carrier, 'toolCallId');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isGateParkedToolEnd } from './gateOutcome.js';
|
|
2
|
-
import { ownDataField, ownSendableField } from './ownKey.js';
|
|
2
|
+
import { appendOwnElement, ownDataField, ownSendableField } from './ownKey.js';
|
|
3
3
|
const isObjectLike = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
4
4
|
function optionalOwn(o, key) {
|
|
5
5
|
try {
|
|
@@ -17,7 +17,7 @@ function itemsOf(a) {
|
|
|
17
17
|
return undefined;
|
|
18
18
|
const out = [];
|
|
19
19
|
for (let i = 0; i < n; i += 1)
|
|
20
|
-
out
|
|
20
|
+
appendOwnElement(out, ownDataField(a, String(i)));
|
|
21
21
|
return out;
|
|
22
22
|
}
|
|
23
23
|
const JSON_MAX_DEPTH = 64;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { frozenSet } from './frozenSet.js';
|
|
2
|
-
import { ownDataField } from './ownKey.js';
|
|
2
|
+
import { appendOwnElement, ownDataField } from './ownKey.js';
|
|
3
3
|
import { hasCoreValuePort, mcpNamespace, mintNamespacePrefix } from './coreValuePorts.js';
|
|
4
4
|
const notLanded = () => Object.freeze({ state: 'not_landed' });
|
|
5
5
|
const unreadable = () => Object.freeze({ state: 'unreadable' });
|
|
@@ -21,7 +21,7 @@ function readHalf(half) {
|
|
|
21
21
|
const name = ownDataField(row, 'name');
|
|
22
22
|
if (typeof name !== 'string' || name.length === 0)
|
|
23
23
|
return 'unreadable';
|
|
24
|
-
names
|
|
24
|
+
appendOwnElement(names, name);
|
|
25
25
|
}
|
|
26
26
|
return names;
|
|
27
27
|
}
|
package/dist/engineWireFor.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AgentClient } from '@sema-agent/sdk';
|
|
2
2
|
import { type EngineWireClientConfig, type EngineWireInjection } from './engineWireSdk.js';
|
|
3
3
|
import { type EngineWireTarget } from './engineWireTarget.js';
|
|
4
|
+
import { THROWN_SLOT_UNREADABLE, type SlotPresence } from './wireFailureShape.js';
|
|
4
5
|
export declare const INJECTED_WIRE_SETTLE_MS = 60000;
|
|
5
6
|
export type EngineWireTargetClientOptions = Pick<EngineWireClientConfig, 'timeoutMs' | 'maxRetries'>;
|
|
6
7
|
export interface EngineWireInjected<C> {
|
|
@@ -22,6 +23,12 @@ export interface EngineWireNoTarget {
|
|
|
22
23
|
export type EngineWireResolution<C> = EngineWireInjected<C> | EngineWireFromTarget | EngineWireInjectedUnusable | EngineWireNoTarget;
|
|
23
24
|
export declare function engineWireFor<C extends object>(wire: EngineWireInjection<C> | undefined, sessionKey: string, usable: (client: object) => client is C): EngineWireResolution<C>;
|
|
24
25
|
export declare function clientHasVerbs(client: object, verbs: ReadonlyArray<ReadonlyArray<string>>): boolean;
|
|
26
|
+
export declare function readSignalAborted(signal: AbortSignal): boolean | null;
|
|
27
|
+
export declare function readSignalReason(signal: AbortSignal): {
|
|
28
|
+
readonly reason: {} | null | undefined;
|
|
29
|
+
} | null;
|
|
30
|
+
export declare function tryListenAbortOnce(signal: AbortSignal, listener: () => void): boolean;
|
|
31
|
+
export declare function tryUnlistenAbort(signal: AbortSignal, listener: () => void): boolean;
|
|
25
32
|
export interface LinkedAbortSignal {
|
|
26
33
|
signal: AbortSignal;
|
|
27
34
|
dispose: () => void;
|
|
@@ -36,6 +43,97 @@ export declare class EngineWireCancelledError extends Error {
|
|
|
36
43
|
constructor();
|
|
37
44
|
}
|
|
38
45
|
export declare function connectionLostDetail(): string;
|
|
46
|
+
export type CauseSlotValue = {} | null | undefined;
|
|
47
|
+
type CauseChainEnd = 'complete' | 'depth_cap' | 'unreadable';
|
|
48
|
+
export declare function walkCauseChain(e: CauseSlotValue, visit: (layer: object, depth: number) => 'stop' | undefined, readCause?: (layer: object) => CauseSlotValue | typeof THROWN_SLOT_UNREADABLE, callableReach?: boolean): {
|
|
49
|
+
stopped: true;
|
|
50
|
+
} | {
|
|
51
|
+
stopped: false;
|
|
52
|
+
end: CauseChainEnd;
|
|
53
|
+
};
|
|
54
|
+
export declare const causeSlotProtected: (layer: object) => CauseSlotValue | typeof THROWN_SLOT_UNREADABLE;
|
|
55
|
+
export declare function causeSlotReadOf(layer: object): CauseSlotRead;
|
|
56
|
+
export interface CauseSlotRead {
|
|
57
|
+
readonly value: CauseSlotValue | typeof THROWN_SLOT_UNREADABLE;
|
|
58
|
+
readonly presence: SlotPresence;
|
|
59
|
+
}
|
|
60
|
+
export declare const TRANSIENT_TRANSPORT_CODES: readonly string[];
|
|
61
|
+
export type TransportChainReading = 'transient' | 'answered' | 'blocked' | 'none';
|
|
62
|
+
export interface ChainAnswer {
|
|
63
|
+
readonly layer: object;
|
|
64
|
+
readonly status: number;
|
|
65
|
+
}
|
|
66
|
+
export interface TransportChainVerdict {
|
|
67
|
+
readonly reading: TransportChainReading;
|
|
68
|
+
readonly answer?: ChainAnswer;
|
|
69
|
+
readonly chainEnd?: 'unreadable';
|
|
70
|
+
}
|
|
71
|
+
export declare function transportChainReading(e: CauseSlotValue, facets: 'retry' | 'code', stopOn?: (layer: object) => boolean, topStatusAlreadyRead?: boolean): TransportChainReading;
|
|
72
|
+
export declare function transportChainVerdict(e: CauseSlotValue, facets: 'retry' | 'code', stopOn?: (layer: object) => boolean, topStatusAlreadyRead?: boolean, noteTopCause?: (read: CauseSlotRead) => void, noteTopLocalCode?: (value: {} | null | undefined) => void): TransportChainVerdict;
|
|
73
|
+
export interface AnswerReading {
|
|
74
|
+
readonly answer: ChainAnswer | typeof THROWN_SLOT_UNREADABLE | undefined;
|
|
75
|
+
readonly chain: TransportChainVerdict;
|
|
76
|
+
readonly topCause?: CauseSlotRead;
|
|
77
|
+
readonly topLocalCode?: {
|
|
78
|
+
readonly value: CapturedLocalCode;
|
|
79
|
+
};
|
|
80
|
+
readonly topStatusSlot?: SlotPresence;
|
|
81
|
+
}
|
|
82
|
+
export declare function answerReadingOf(e: CauseSlotValue): AnswerReading;
|
|
83
|
+
export declare function answeringLayerOf(e: CauseSlotValue): ChainAnswer | typeof THROWN_SLOT_UNREADABLE | undefined;
|
|
84
|
+
export type CapturedCode = {
|
|
85
|
+
readonly state: 'read';
|
|
86
|
+
readonly wire?: string;
|
|
87
|
+
readonly blockedBy?: string;
|
|
88
|
+
} | {
|
|
89
|
+
readonly state: 'unreadable';
|
|
90
|
+
};
|
|
91
|
+
export type CapturedLocalCode = string | undefined | typeof THROWN_SLOT_UNREADABLE;
|
|
92
|
+
declare class AnswerCaptureRecord implements ChainAnswer {
|
|
93
|
+
protected readonly answerCaptureBrand: true;
|
|
94
|
+
readonly layer: object;
|
|
95
|
+
readonly status: number;
|
|
96
|
+
readonly code: CapturedCode;
|
|
97
|
+
readonly localCode: CapturedLocalCode;
|
|
98
|
+
constructor(layer: object, status: number, code: CapturedCode, localCode: CapturedLocalCode);
|
|
99
|
+
}
|
|
100
|
+
export type AnswerCapture = AnswerCaptureRecord;
|
|
101
|
+
export declare const CODE_UNREADABLE: CapturedCode;
|
|
102
|
+
export declare function captureAnswer(answer: ChainAnswer, codeSlot: {} | null | undefined): AnswerCapture;
|
|
103
|
+
declare class UnansweredCaptureRecord {
|
|
104
|
+
protected readonly unansweredCaptureBrand: true;
|
|
105
|
+
readonly layer: object;
|
|
106
|
+
readonly status: undefined;
|
|
107
|
+
readonly code: CapturedCode;
|
|
108
|
+
readonly localCode: CapturedLocalCode;
|
|
109
|
+
readonly statusSlot: SlotPresence;
|
|
110
|
+
constructor(layer: object, code: CapturedCode, localCode: CapturedLocalCode, statusSlot: SlotPresence);
|
|
111
|
+
}
|
|
112
|
+
export type UnansweredCapture = UnansweredCaptureRecord;
|
|
113
|
+
export declare function captureUnanswered(layer: object, codeSlot: {} | null | undefined, localCodeRead: {
|
|
114
|
+
readonly value: CapturedLocalCode;
|
|
115
|
+
} | undefined, statusSlot?: SlotPresence): UnansweredCapture;
|
|
116
|
+
export declare function effectiveCodeOf(code: CapturedCode): string | undefined;
|
|
117
|
+
export interface TriageReading {
|
|
118
|
+
readonly answer: AnswerCapture | typeof THROWN_SLOT_UNREADABLE | undefined;
|
|
119
|
+
readonly unanswered?: UnansweredCapture;
|
|
120
|
+
readonly topLocalCode?: TopLocalCodeReading;
|
|
121
|
+
readonly topCause?: TopCauseReading;
|
|
122
|
+
readonly transport: boolean;
|
|
123
|
+
readonly chainEnd?: 'unreadable';
|
|
124
|
+
}
|
|
125
|
+
export interface TopLocalCodeReading {
|
|
126
|
+
readonly layer: object;
|
|
127
|
+
readonly localCode: CapturedLocalCode;
|
|
128
|
+
}
|
|
129
|
+
export interface TopCauseReading {
|
|
130
|
+
readonly layer: object;
|
|
131
|
+
readonly read: CauseSlotRead;
|
|
132
|
+
}
|
|
133
|
+
export declare function ownReadingSlot<T extends object, K extends keyof T & string>(record: T | undefined, key: K): T[K] | undefined;
|
|
134
|
+
export declare function noteTriageReading(verdict: object, reading: TriageReading): void;
|
|
135
|
+
export declare function triageReadingOf(verdict: object): TriageReading | undefined;
|
|
136
|
+
export declare function attemptTimeoutOnChain(e: CauseSlotValue): boolean;
|
|
39
137
|
export type EngineWireNoAnswerKind = 'deadline' | 'time-limit' | 'connection-lost' | 'cancelled';
|
|
40
138
|
export declare function noAnswerKindOf(e: object | null | undefined): EngineWireNoAnswerKind | null;
|
|
41
139
|
export declare function noAnswerDetailFrom(e: object | null | undefined): string | null;
|
|
@@ -64,3 +162,4 @@ export interface TransportFailureScene {
|
|
|
64
162
|
}
|
|
65
163
|
export declare function transportFailureScene(error: unknown): TransportFailureScene;
|
|
66
164
|
export declare function settleInjected<T>(ms: number, signal: AbortSignal | null | undefined, run: (signal: AbortSignal) => Promise<T>): Promise<T>;
|
|
165
|
+
export {};
|
package/dist/engineWireFor.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { settleWithinDeadline } from './abortableSleep.js';
|
|
2
2
|
import { makeEngineWireClient } from './engineWireSdk.js';
|
|
3
3
|
import { engineWireTargetFor } from './engineWireTarget.js';
|
|
4
|
-
import { readThrownSlot } from './wireFailureShape.js';
|
|
4
|
+
import { foldedWireCodeReading, readThrownSlot, readThrownStatusSlot, slotReadOf, THROWN_SLOT_UNREADABLE } from './wireFailureShape.js';
|
|
5
|
+
import { guardedRead, readOwnDataValue } from './ownKey.js';
|
|
5
6
|
export const INJECTED_WIRE_SETTLE_MS = 60_000;
|
|
6
7
|
export function engineWireFor(wire, sessionKey, usable) {
|
|
7
8
|
if (wire !== undefined) {
|
|
@@ -73,6 +74,40 @@ function quietlyRemoveAbortListener(signal, listener) {
|
|
|
73
74
|
catch {
|
|
74
75
|
}
|
|
75
76
|
}
|
|
77
|
+
export function readSignalAborted(signal) {
|
|
78
|
+
try {
|
|
79
|
+
return signal.aborted === true;
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
export function readSignalReason(signal) {
|
|
86
|
+
try {
|
|
87
|
+
return { reason: signal.reason };
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
export function tryListenAbortOnce(signal, listener) {
|
|
94
|
+
try {
|
|
95
|
+
signal.addEventListener('abort', listener, { once: true });
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
export function tryUnlistenAbort(signal, listener) {
|
|
103
|
+
try {
|
|
104
|
+
signal.removeEventListener('abort', listener);
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
76
111
|
export function linkedAbortSignal(caller, deadline) {
|
|
77
112
|
const from = callerSignalOf(caller);
|
|
78
113
|
if (from === undefined)
|
|
@@ -208,15 +243,38 @@ function allAttemptsFailedBeforeSend(errors) {
|
|
|
208
243
|
return errors.every((x) => x !== null && typeof x === 'object' && isPreSendCode(x.code, x.syscall));
|
|
209
244
|
}
|
|
210
245
|
const CAUSE_CHAIN_MAX_LAYERS = 4;
|
|
211
|
-
function walkCauseChain(e, visit) {
|
|
246
|
+
export function walkCauseChain(e, visit, readCause, callableReach = false) {
|
|
247
|
+
const seen = readCause === undefined ? undefined : new Set();
|
|
212
248
|
let cur = e;
|
|
213
|
-
|
|
249
|
+
let depth = 0;
|
|
250
|
+
for (; depth < CAUSE_CHAIN_MAX_LAYERS && isChainLayer(cur, depth, callableReach); depth++) {
|
|
251
|
+
if (seen !== undefined) {
|
|
252
|
+
if (seen.has(cur))
|
|
253
|
+
return { stopped: false, end: 'complete' };
|
|
254
|
+
seen.add(cur);
|
|
255
|
+
}
|
|
214
256
|
if (visit(cur, depth) === 'stop')
|
|
215
257
|
return { stopped: true };
|
|
216
|
-
cur = cur.cause;
|
|
258
|
+
cur = readCause === undefined ? cur.cause : readCause(cur);
|
|
259
|
+
if (cur === THROWN_SLOT_UNREADABLE)
|
|
260
|
+
return { stopped: false, end: 'unreadable' };
|
|
217
261
|
}
|
|
218
|
-
return { stopped: false, end: cur
|
|
219
|
-
}
|
|
262
|
+
return { stopped: false, end: isChainLayer(cur, depth, callableReach) && seen?.has(cur) !== true ? 'depth_cap' : 'complete' };
|
|
263
|
+
}
|
|
264
|
+
const CALLABLE_LAYER_REACH = 1;
|
|
265
|
+
function isChainLayer(v, depth, callableReach) {
|
|
266
|
+
return (typeof v === 'object' && v !== null) || (callableReach && typeof v === 'function' && depth <= CALLABLE_LAYER_REACH);
|
|
267
|
+
}
|
|
268
|
+
export const causeSlotProtected = (layer) => causeSlotReadOf(layer).value;
|
|
269
|
+
export function causeSlotReadOf(layer) {
|
|
270
|
+
const read = slotReadOf(layer, 'cause');
|
|
271
|
+
if (read.presence === 'unreadable')
|
|
272
|
+
return CAUSE_SLOT_UNREADABLE;
|
|
273
|
+
if (read.presence === 'present')
|
|
274
|
+
return Object.freeze({ value: read.value, presence: 'present' });
|
|
275
|
+
return readThrownSlot(layer, 'cause') === undefined ? Object.freeze({ value: undefined, presence: 'absent' }) : CAUSE_SLOT_UNREADABLE;
|
|
276
|
+
}
|
|
277
|
+
const CAUSE_SLOT_UNREADABLE = Object.freeze({ value: THROWN_SLOT_UNREADABLE, presence: 'unreadable' });
|
|
220
278
|
function readLayerEvidence(layer) {
|
|
221
279
|
const o = layer;
|
|
222
280
|
const code = o.code;
|
|
@@ -230,6 +288,190 @@ function readLayerEvidence(layer) {
|
|
|
230
288
|
function failedBeforeSend(e) {
|
|
231
289
|
return walkCauseChain(e, (layer) => (readLayerEvidence(layer).proof !== null ? 'stop' : undefined)).stopped;
|
|
232
290
|
}
|
|
291
|
+
export const TRANSIENT_TRANSPORT_CODES = Object.freeze([
|
|
292
|
+
'ECONNREFUSED', 'ECONNRESET', 'ETIMEDOUT', 'EPIPE', 'EAI_AGAIN',
|
|
293
|
+
'ENETUNREACH', 'EHOSTUNREACH', 'ECONNABORTED',
|
|
294
|
+
'UND_ERR_CONNECT_TIMEOUT', 'UND_ERR_HEADERS_TIMEOUT', 'UND_ERR_BODY_TIMEOUT', 'UND_ERR_SOCKET',
|
|
295
|
+
]);
|
|
296
|
+
function readLayerTransience(layer, facets, statusAlreadyRead = false, noteCode) {
|
|
297
|
+
if (!statusAlreadyRead) {
|
|
298
|
+
const status = readAnsweredStatus(layer);
|
|
299
|
+
if (typeof status === 'number')
|
|
300
|
+
return { t: 'answered', status };
|
|
301
|
+
if (status === THROWN_SLOT_UNREADABLE)
|
|
302
|
+
return { t: 'answered', status: undefined };
|
|
303
|
+
}
|
|
304
|
+
const callable = typeof layer === 'function';
|
|
305
|
+
if (facets === 'retry' && !callable) {
|
|
306
|
+
const name = readThrownSlot(layer, 'name');
|
|
307
|
+
if (name === 'TimeoutError' || name === 'AbortError')
|
|
308
|
+
return TRANSIENT_LAYER;
|
|
309
|
+
}
|
|
310
|
+
const code = readThrownSlot(layer, 'code', 'data');
|
|
311
|
+
noteCode?.(code);
|
|
312
|
+
if (callable)
|
|
313
|
+
return NONE_LAYER;
|
|
314
|
+
if (typeof code === 'string' && TRANSIENT_TRANSPORT_CODES.includes(code))
|
|
315
|
+
return TRANSIENT_LAYER;
|
|
316
|
+
if (facets === 'retry') {
|
|
317
|
+
const message = readThrownSlot(layer, 'message');
|
|
318
|
+
if (typeof message === 'string' && message.toLowerCase().includes('fetch failed'))
|
|
319
|
+
return TRANSIENT_LAYER;
|
|
320
|
+
}
|
|
321
|
+
return NONE_LAYER;
|
|
322
|
+
}
|
|
323
|
+
const TRANSIENT_LAYER = Object.freeze({ t: 'transient' });
|
|
324
|
+
const NONE_LAYER = Object.freeze({ t: 'none' });
|
|
325
|
+
export function transportChainReading(e, facets, stopOn, topStatusAlreadyRead = false) {
|
|
326
|
+
return transportChainVerdict(e, facets, stopOn, topStatusAlreadyRead).reading;
|
|
327
|
+
}
|
|
328
|
+
export function transportChainVerdict(e, facets, stopOn, topStatusAlreadyRead = false, noteTopCause, noteTopLocalCode) {
|
|
329
|
+
let reading = 'none';
|
|
330
|
+
let answer;
|
|
331
|
+
let layerIndex = 0;
|
|
332
|
+
let topCauseNoted = false;
|
|
333
|
+
const readCause = noteTopCause === undefined
|
|
334
|
+
? causeSlotProtected
|
|
335
|
+
: (layer) => {
|
|
336
|
+
if (topCauseNoted || layer !== e)
|
|
337
|
+
return causeSlotProtected(layer);
|
|
338
|
+
topCauseNoted = true;
|
|
339
|
+
const read = causeSlotReadOf(layer);
|
|
340
|
+
noteTopCause(read);
|
|
341
|
+
return read.value;
|
|
342
|
+
};
|
|
343
|
+
const callableReach = facets === 'code';
|
|
344
|
+
const walked = walkCauseChain(e, (layer) => {
|
|
345
|
+
const isTop = layerIndex === 0;
|
|
346
|
+
const skipStatus = topStatusAlreadyRead && isTop;
|
|
347
|
+
layerIndex += 1;
|
|
348
|
+
if (stopOn !== undefined) {
|
|
349
|
+
let blocked;
|
|
350
|
+
try {
|
|
351
|
+
blocked = stopOn(layer);
|
|
352
|
+
}
|
|
353
|
+
catch {
|
|
354
|
+
blocked = true;
|
|
355
|
+
}
|
|
356
|
+
if (blocked) {
|
|
357
|
+
reading = 'blocked';
|
|
358
|
+
return 'stop';
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
const t = readLayerTransience(layer, facets, skipStatus, isTop ? noteTopLocalCode : undefined);
|
|
362
|
+
if (t.t === 'none')
|
|
363
|
+
return undefined;
|
|
364
|
+
reading = t.t;
|
|
365
|
+
if (t.t === 'answered' && t.status !== undefined)
|
|
366
|
+
answer = Object.freeze({ layer, status: t.status });
|
|
367
|
+
return 'stop';
|
|
368
|
+
}, readCause, callableReach);
|
|
369
|
+
const unreadableEnd = !walked.stopped && walked.end === 'unreadable';
|
|
370
|
+
return { reading, ...(answer !== undefined ? { answer } : {}), ...(unreadableEnd ? { chainEnd: 'unreadable' } : {}) };
|
|
371
|
+
}
|
|
372
|
+
function isHttpStatus(n) {
|
|
373
|
+
return Number.isInteger(n) && n >= 100 && n <= 599;
|
|
374
|
+
}
|
|
375
|
+
function readAnsweredStatus(o, notePresence) {
|
|
376
|
+
const s = readThrownStatusSlot(o, notePresence);
|
|
377
|
+
return typeof s === 'number' && !isHttpStatus(s) ? undefined : s;
|
|
378
|
+
}
|
|
379
|
+
const NO_CHAIN_VERDICT = Object.freeze({ reading: 'none' });
|
|
380
|
+
const NO_ANSWER = Object.freeze({ answer: undefined, chain: NO_CHAIN_VERDICT });
|
|
381
|
+
export function answerReadingOf(e) {
|
|
382
|
+
if (e === null || e === undefined || (typeof e !== 'object' && typeof e !== 'function'))
|
|
383
|
+
return NO_ANSWER;
|
|
384
|
+
let topStatusSlot = 'unreadable';
|
|
385
|
+
const status = readAnsweredStatus(e, (presence) => {
|
|
386
|
+
topStatusSlot = presence;
|
|
387
|
+
});
|
|
388
|
+
if (status === THROWN_SLOT_UNREADABLE)
|
|
389
|
+
return Object.freeze({ answer: THROWN_SLOT_UNREADABLE, chain: NO_CHAIN_VERDICT });
|
|
390
|
+
if (typeof status === 'number')
|
|
391
|
+
return Object.freeze({ answer: Object.freeze({ layer: e, status }), chain: NO_CHAIN_VERDICT });
|
|
392
|
+
let topCause;
|
|
393
|
+
let topLocalCode;
|
|
394
|
+
const chain = transportChainVerdict(e, 'code', undefined, true, (read) => {
|
|
395
|
+
topCause = read;
|
|
396
|
+
}, (value) => {
|
|
397
|
+
topLocalCode = Object.freeze({ value: localCodeOfSlot(value) });
|
|
398
|
+
});
|
|
399
|
+
const tc = {
|
|
400
|
+
...(topCause !== undefined ? { topCause } : {}),
|
|
401
|
+
...(topLocalCode !== undefined ? { topLocalCode } : {}),
|
|
402
|
+
topStatusSlot,
|
|
403
|
+
};
|
|
404
|
+
const chainAnswer = ownReadingSlot(chain, 'answer');
|
|
405
|
+
if (chain.reading === 'answered' && chainAnswer === undefined)
|
|
406
|
+
return Object.freeze({ answer: THROWN_SLOT_UNREADABLE, chain, ...tc });
|
|
407
|
+
return Object.freeze({ answer: chainAnswer, chain, ...tc });
|
|
408
|
+
}
|
|
409
|
+
export function answeringLayerOf(e) {
|
|
410
|
+
return answerReadingOf(e).answer;
|
|
411
|
+
}
|
|
412
|
+
function localCodeOfSlot(raw) {
|
|
413
|
+
return raw === THROWN_SLOT_UNREADABLE ? raw : typeof raw === 'string' ? raw : undefined;
|
|
414
|
+
}
|
|
415
|
+
class AnswerCaptureRecord {
|
|
416
|
+
layer;
|
|
417
|
+
status;
|
|
418
|
+
code;
|
|
419
|
+
localCode;
|
|
420
|
+
constructor(layer, status, code, localCode) {
|
|
421
|
+
this.layer = layer;
|
|
422
|
+
this.status = status;
|
|
423
|
+
this.code = code;
|
|
424
|
+
this.localCode = localCode;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
export const CODE_UNREADABLE = Object.freeze(Object.assign(Object.create(null), { state: 'unreadable' }));
|
|
428
|
+
function capturedCodeOfSlot(layer, codeSlot) {
|
|
429
|
+
if (codeSlot === THROWN_SLOT_UNREADABLE)
|
|
430
|
+
return CODE_UNREADABLE;
|
|
431
|
+
const wire = typeof codeSlot === 'string' && codeSlot.length > 0 ? codeSlot : undefined;
|
|
432
|
+
const folded = foldedWireCodeReading(layer, wire);
|
|
433
|
+
return Object.freeze(Object.assign(Object.create(null), { state: 'read', ...(wire !== undefined ? { wire } : {}), ...(folded.folded && folded.code !== undefined ? { blockedBy: folded.code } : {}) }));
|
|
434
|
+
}
|
|
435
|
+
export function captureAnswer(answer, codeSlot) {
|
|
436
|
+
const captured = new AnswerCaptureRecord(answer.layer, answer.status, capturedCodeOfSlot(answer.layer, codeSlot), localCodeOfSlot(readThrownSlot(answer.layer, 'code', 'data')));
|
|
437
|
+
Object.freeze(captured);
|
|
438
|
+
return captured;
|
|
439
|
+
}
|
|
440
|
+
class UnansweredCaptureRecord {
|
|
441
|
+
layer;
|
|
442
|
+
status;
|
|
443
|
+
code;
|
|
444
|
+
localCode;
|
|
445
|
+
statusSlot;
|
|
446
|
+
constructor(layer, code, localCode, statusSlot) {
|
|
447
|
+
this.layer = layer;
|
|
448
|
+
this.status = undefined;
|
|
449
|
+
this.code = code;
|
|
450
|
+
this.localCode = localCode;
|
|
451
|
+
this.statusSlot = statusSlot;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
export function captureUnanswered(layer, codeSlot, localCodeRead, statusSlot) {
|
|
455
|
+
const captured = new UnansweredCaptureRecord(layer, capturedCodeOfSlot(layer, codeSlot), localCodeRead !== undefined ? localCodeRead.value : THROWN_SLOT_UNREADABLE, statusSlot ?? 'unreadable');
|
|
456
|
+
Object.freeze(captured);
|
|
457
|
+
return captured;
|
|
458
|
+
}
|
|
459
|
+
export function effectiveCodeOf(code) {
|
|
460
|
+
return code.state === 'read' ? (code.blockedBy ?? code.wire) : undefined;
|
|
461
|
+
}
|
|
462
|
+
const TRIAGE_READINGS = new WeakMap();
|
|
463
|
+
export function ownReadingSlot(record, key) {
|
|
464
|
+
return record === undefined ? undefined : guardedRead(() => readOwnDataValue(record, key));
|
|
465
|
+
}
|
|
466
|
+
export function noteTriageReading(verdict, reading) {
|
|
467
|
+
TRIAGE_READINGS.set(verdict, Object.freeze({ ...reading }));
|
|
468
|
+
}
|
|
469
|
+
export function triageReadingOf(verdict) {
|
|
470
|
+
return TRIAGE_READINGS.get(verdict);
|
|
471
|
+
}
|
|
472
|
+
export function attemptTimeoutOnChain(e) {
|
|
473
|
+
return walkCauseChain(e, (layer) => (readThrownSlot(layer, 'name') === 'TimeoutError' ? 'stop' : undefined), causeSlotProtected).stopped;
|
|
474
|
+
}
|
|
233
475
|
export function noAnswerKindOf(e) {
|
|
234
476
|
return noAnswerKindWith(e, () => failedBeforeSend(e));
|
|
235
477
|
}
|
|
@@ -7,4 +7,5 @@ export declare function installEngineWireTarget(t: EngineWireTarget | null): ()
|
|
|
7
7
|
export declare function installEngineWireTargetFor(sessionKey: string, t: EngineWireTarget | null): () => void;
|
|
8
8
|
export declare function engineWireTarget(): EngineWireTarget | null;
|
|
9
9
|
export declare function engineWireTargetFor(sessionKey: string): EngineWireTarget | null;
|
|
10
|
+
export declare function engineWireTargetBaseUrl(sessionKey?: string): string | undefined;
|
|
10
11
|
export declare function engineWireDebugEnabled(): boolean;
|
package/dist/engineWireTarget.js
CHANGED
|
@@ -35,6 +35,14 @@ export function engineWireTargetFor(sessionKey) {
|
|
|
35
35
|
...(envPrincipal !== undefined ? { principal: envPrincipal } : {}),
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
|
+
export function engineWireTargetBaseUrl(sessionKey = DEFAULT_SESSION_KEY) {
|
|
39
|
+
try {
|
|
40
|
+
return engineWireTargetFor(sessionKey)?.baseUrl;
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
38
46
|
export function engineWireDebugEnabled() {
|
|
39
47
|
return Boolean(hostEnv().SEMA_DEBUG);
|
|
40
48
|
}
|
package/dist/env/uiLanguage.js
CHANGED
|
@@ -17,7 +17,7 @@ function ownDataOf(v, key) {
|
|
|
17
17
|
return undefined;
|
|
18
18
|
try {
|
|
19
19
|
const d = Object.getOwnPropertyDescriptor(v, key);
|
|
20
|
-
return d !== undefined && 'value'
|
|
20
|
+
return d !== undefined && Object.hasOwn(d, 'value') ? d.value : undefined;
|
|
21
21
|
}
|
|
22
22
|
catch {
|
|
23
23
|
return undefined;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { corruptSessionContent } from './corruptSessionCopy.js';
|
|
2
|
+
import { corruptStoredRowContent } from './wireErrorTriage.js';
|
|
3
|
+
import { resumeRefusalContent, resumeContextUnavailableContent, requireExistingSessionRefusalContent, checkpointUnsupportedVersionContent, } from './resumeRefusalCopy.js';
|
|
4
|
+
import { resumeReopenContent } from './hitl/suspendedReopen.js';
|
|
5
|
+
import { idempotencyPayloadMismatchContent } from './engineErrorCodes.js';
|
|
6
|
+
import { inheritEnvRefusalContent } from './inheritEnvWire.js';
|
|
7
|
+
import { usageWindowExhaustedContent, fleetLeaseUnavailableContent, settingsPermissionBucketRefusalContent, fieldLimitRefusalContent, autonomyLaneRefusalContent, userAttachmentRefusalContent, userInvokedSkillRefusalContent, unsupportedRuleRefusalContent, admissionWallRefusalContent, hostPostureRefusalContent, toolDeclarationRefusalContent, } from './wireRefusalCopy.js';
|
|
8
|
+
const ROLE_BY_READER = new Map([
|
|
9
|
+
[corruptSessionContent, 'replacement'],
|
|
10
|
+
[corruptStoredRowContent, 'replacement'],
|
|
11
|
+
[resumeRefusalContent, 'replacement'],
|
|
12
|
+
[resumeContextUnavailableContent, 'replacement'],
|
|
13
|
+
[requireExistingSessionRefusalContent, 'replacement'],
|
|
14
|
+
[checkpointUnsupportedVersionContent, 'replacement'],
|
|
15
|
+
[resumeReopenContent, 'replacement'],
|
|
16
|
+
[usageWindowExhaustedContent, 'replacement'],
|
|
17
|
+
[fleetLeaseUnavailableContent, 'replacement'],
|
|
18
|
+
[settingsPermissionBucketRefusalContent, 'replacement'],
|
|
19
|
+
[fieldLimitRefusalContent, 'replacement'],
|
|
20
|
+
[autonomyLaneRefusalContent, 'replacement'],
|
|
21
|
+
[idempotencyPayloadMismatchContent, 'replacement'],
|
|
22
|
+
[userAttachmentRefusalContent, 'replacement'],
|
|
23
|
+
[userInvokedSkillRefusalContent, 'replacement'],
|
|
24
|
+
[unsupportedRuleRefusalContent, 'replacement'],
|
|
25
|
+
[admissionWallRefusalContent, 'supplement'],
|
|
26
|
+
[hostPostureRefusalContent, 'supplement'],
|
|
27
|
+
[toolDeclarationRefusalContent, 'supplement'],
|
|
28
|
+
[inheritEnvRefusalContent, 'supplement'],
|
|
29
|
+
]);
|
|
30
|
+
export function errorSupplementRoleOf(reader) {
|
|
31
|
+
try {
|
|
32
|
+
return ROLE_BY_READER.get(reader) ?? 'supplement';
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return 'supplement';
|
|
36
|
+
}
|
|
37
|
+
}
|