@sema-agent/client-core 0.99.0 → 0.101.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +572 -0
- package/README.md +174 -114
- package/dist/adapt/arms.js +109 -50
- package/dist/adapt/panelTasks.d.ts +2 -1
- package/dist/adapt/panelTasks.js +32 -9
- package/dist/adapt/textStream.d.ts +1 -1
- package/dist/adapt/textStream.js +58 -32
- package/dist/adapt/toolCards.js +9 -8
- package/dist/adapt.js +7 -1
- package/dist/adapter/activeRunSelfHeal.d.ts +31 -2
- package/dist/adapter/activeRunSelfHeal.js +162 -13
- package/dist/adapter/downstream/eventToSdkMessage.d.ts +25 -6
- package/dist/adapter/downstream/eventToSdkMessage.js +157 -20
- package/dist/adapter/downstream/terminalToSdkResult.d.ts +60 -1
- package/dist/adapter/downstream/terminalToSdkResult.js +219 -39
- package/dist/adapter/downstream/wiringManifestView.d.ts +3 -1
- package/dist/adapter/downstream/wiringManifestView.js +1 -0
- package/dist/adapter/runStream.d.ts +4 -4
- package/dist/adapter/runStream.js +184 -42
- package/dist/adapter/types.d.ts +2 -0
- package/dist/agentsWireCaps.d.ts +9 -7
- package/dist/agentsWireCaps.js +101 -17
- package/dist/approvalDecidedByCapability.js +2 -2
- package/dist/approvalFrameFamilies.d.ts +33 -0
- package/dist/approvalFrameFamilies.js +120 -0
- package/dist/approvalsStreamLiveCapability.js +2 -2
- package/dist/attachmentsWireCaps.js +41 -13
- package/dist/callerCwdCapability.js +2 -2
- package/dist/centerWiringCapability.js +2 -2
- package/dist/clockReading.d.ts +2 -0
- package/dist/clockReading.js +4 -0
- package/dist/cloudConfigWireCaps.d.ts +28 -5
- package/dist/cloudConfigWireCaps.js +334 -103
- package/dist/compactionStatus.d.ts +34 -0
- package/dist/compactionStatus.js +196 -0
- package/dist/coreValuePorts.d.ts +12 -2
- package/dist/coreValuePorts.js +9 -0
- package/dist/decideFailureNote.js +8 -6
- package/dist/decideReceipt.js +2 -2
- package/dist/deviceExecutorManagementCapability.js +2 -2
- package/dist/deviceFlowPolling.js +1 -1
- package/dist/disableSkillsWire.d.ts +1 -1
- package/dist/disableSkillsWire.js +4 -3
- package/dist/displayUntrusted.d.ts +1 -0
- package/dist/displayUntrusted.js +215 -13
- package/dist/engineAgentPanelStore.d.ts +7 -4
- package/dist/engineCapReader.js +1 -1
- package/dist/engineConfigDrift.js +1 -1
- package/dist/engineErrorCodes.d.ts +23 -6
- package/dist/engineErrorCodes.js +36 -11
- package/dist/engineGenerationConvergence.d.ts +39 -0
- package/dist/engineGenerationConvergence.js +95 -0
- package/dist/engineGenerationPort.d.ts +61 -0
- package/dist/engineGenerationPort.js +144 -0
- package/dist/engineHealthFacts.d.ts +23 -0
- package/dist/engineHealthFacts.js +92 -0
- package/dist/engineIdentity.d.ts +4 -0
- package/dist/engineIdentity.js +11 -0
- package/dist/engineNoticeCodes.d.ts +2 -5
- package/dist/engineRowRef.js +4 -0
- package/dist/engineSessionMessages.js +2 -2
- package/dist/engineToolDirectory.d.ts +3 -0
- package/dist/engineToolDirectory.js +6 -4
- package/dist/engineWireFor.d.ts +99 -0
- package/dist/engineWireFor.js +248 -6
- package/dist/engineWireTarget.d.ts +1 -0
- package/dist/engineWireTarget.js +8 -0
- package/dist/env/uiLanguage.js +1 -1
- package/dist/errorSupplementRoles.d.ts +3 -0
- package/dist/errorSupplementRoles.js +37 -0
- package/dist/eventLeg.d.ts +1 -7
- package/dist/eventLeg.js +7 -8
- package/dist/executionLaneCapability.js +2 -2
- package/dist/fileHistoryCaptureCapability.d.ts +0 -3
- package/dist/fileHistoryCaptureCapability.js +3 -7
- package/dist/finalVerifyWire.d.ts +6 -3
- package/dist/finalVerifyWire.js +6 -23
- package/dist/flagInput.d.ts +4 -0
- package/dist/flagInput.js +24 -0
- package/dist/fleet/fleetLedger.js +5 -2
- package/dist/fleet/fleetProjection.d.ts +1 -0
- package/dist/fleet/fleetProjection.js +15 -2
- package/dist/gateVocabulary.js +3 -0
- package/dist/generated/engineFactTables.d.ts +7 -2
- package/dist/generated/engineFactTables.js +79 -0
- package/dist/generated/engineNoticeTables.js +15 -0
- package/dist/generated/settingsSchemaActiveTiers.d.ts +1 -0
- package/dist/generated/settingsSchemaActiveTiers.js +14 -0
- package/dist/generated/settingsSchemaCallerTextEcho.d.ts +1 -0
- package/dist/generated/settingsSchemaCallerTextEcho.js +8 -0
- package/dist/generated/settingsSchemaControlAndBidi.d.ts +1 -0
- package/dist/generated/settingsSchemaControlAndBidi.js +8 -0
- package/dist/generated/settingsSchemaDefaultModel.d.ts +11 -0
- package/dist/generated/settingsSchemaDefaultModel.js +25 -0
- package/dist/generated/settingsSchemaFns.d.ts +66 -0
- package/dist/generated/settingsSchemaFns.js +38 -0
- package/dist/generated/settingsSchemaMcpRequestEntry.d.ts +1 -0
- package/dist/generated/settingsSchemaMcpRequestEntry.js +156 -0
- package/dist/generated/settingsSchemaSafetyMergeSpec.d.ts +1 -0
- package/dist/generated/settingsSchemaSafetyMergeSpec.js +95 -0
- package/dist/generated/settingsSchemaSettingsSources.d.ts +1 -0
- package/dist/generated/settingsSchemaSettingsSources.js +58 -0
- package/dist/generated/settingsSchemaTables.d.ts +3 -0
- package/dist/generated/settingsSchemaTables.js +18 -0
- package/dist/generated/settingsSchemaTypes.d.ts +28 -0
- package/dist/generated/settingsSchemaUrlPattern.d.ts +1 -0
- package/dist/generated/settingsSchemaUrlPattern.js +183 -0
- package/dist/headlessPermissionModeWire.d.ts +18 -2
- package/dist/headlessPermissionModeWire.js +30 -19
- package/dist/hitl/allowRuleShadow.js +9 -7
- package/dist/hitl/approvalCardReading.d.ts +3 -0
- package/dist/hitl/approvalCardReading.js +17 -0
- package/dist/hitl/approvalCardReasons.js +2 -2
- package/dist/hitl/approvalCompleteParked.js +1 -1
- package/dist/hitl/approvalDelivery.d.ts +87 -0
- package/dist/hitl/approvalDelivery.js +193 -0
- package/dist/hitl/approvalHolds.d.ts +14 -0
- package/dist/hitl/approvalHolds.js +41 -0
- package/dist/hitl/approvalResolution.d.ts +11 -0
- package/dist/hitl/approvalResolution.js +50 -11
- package/dist/hitl/askClassPair.d.ts +8 -2
- package/dist/hitl/askClassPair.js +31 -4
- package/dist/hitl/askParkAutoReopenBlock.d.ts +30 -0
- package/dist/hitl/askParkAutoReopenBlock.js +117 -0
- package/dist/hitl/askParkRowRouting.js +4 -1
- package/dist/hitl/attributionLadder.d.ts +62 -0
- package/dist/hitl/attributionLadder.js +138 -0
- package/dist/hitl/automaticAnswerVerdict.d.ts +6 -1
- package/dist/hitl/automaticAnswerVerdict.js +46 -11
- package/dist/hitl/crashConverged.js +2 -2
- package/dist/hitl/decisionConflict.d.ts +6 -2
- package/dist/hitl/decisionConflict.js +24 -9
- package/dist/hitl/decisionLedger.d.ts +55 -0
- package/dist/hitl/decisionLedger.js +156 -0
- package/dist/hitl/decisionRefusal.d.ts +21 -10
- package/dist/hitl/decisionRefusal.js +100 -55
- package/dist/hitl/decisionSend.d.ts +116 -0
- package/dist/hitl/decisionSend.js +563 -0
- package/dist/hitl/frameRouter.d.ts +1 -0
- package/dist/hitl/frameRouter.js +9 -2
- package/dist/hitl/hitlBridge.d.ts +18 -6
- package/dist/hitl/hitlBridge.js +59 -43
- package/dist/hitl/livePendingAsk.js +4 -3
- package/dist/hitl/noAllowCause.js +1 -1
- package/dist/hitl/parkResolver.js +3 -2
- package/dist/hitl/persistedRulesWire.js +1 -0
- package/dist/hitl/planReviewWire.d.ts +4 -0
- package/dist/hitl/planReviewWire.js +104 -106
- package/dist/hitl/resumeRunningCard.d.ts +3 -2
- package/dist/hitl/resumeRunningCard.js +17 -11
- package/dist/hitl/sessionPolicyDeliverable.d.ts +5 -2
- package/dist/hitl/sessionPolicyDeliverable.js +65 -35
- package/dist/hitl/sessionPolicyWire.d.ts +13 -3
- package/dist/hitl/sessionPolicyWire.js +81 -16
- package/dist/hitl/standingRows.js +1 -1
- package/dist/hitl/toolApprovalWire.d.ts +9 -10
- package/dist/hitl/toolApprovalWire.js +103 -151
- package/dist/hookMatcherVerdict.d.ts +2 -0
- package/dist/hookMatcherVerdict.js +12 -0
- package/dist/hooksCompactTransition.d.ts +19 -0
- package/dist/hooksCompactTransition.js +41 -0
- package/dist/hooksWireCaps.d.ts +1 -1
- package/dist/hooksWireCaps.js +202 -203
- package/dist/host.d.ts +1 -14
- package/dist/host.js +0 -8
- package/dist/hostCallbackGuard.d.ts +1 -0
- package/dist/hostCallbackGuard.js +1 -1
- package/dist/hostSettingsSource.d.ts +172 -0
- package/dist/hostSettingsSource.js +675 -0
- package/dist/hostTurnSettings.d.ts +114 -19
- package/dist/hostTurnSettings.js +966 -68
- package/dist/httpHookPolicy.d.ts +37 -0
- package/dist/httpHookPolicy.js +176 -0
- package/dist/humanTurn.d.ts +4 -2
- package/dist/humanTurn.js +40 -10
- package/dist/humanTurnRead.js +4 -3
- package/dist/humanTurnSentences.d.ts +10 -0
- package/dist/humanTurnSentences.js +74 -0
- package/dist/i18n/messages.en.d.ts +313 -0
- package/dist/i18n/messages.en.js +326 -13
- package/dist/i18n/messages.zh.js +341 -13
- package/dist/i18n/translate.js +3 -3
- package/dist/index.d.ts +85 -15
- package/dist/index.js +53 -12
- package/dist/inheritEnvCapability.d.ts +4 -1
- package/dist/inheritEnvCapability.js +38 -17
- package/dist/inheritEnvWire.d.ts +2 -1
- package/dist/inheritEnvWire.js +11 -5
- package/dist/injectionLaneNotice.d.ts +5 -0
- package/dist/injectionLaneNotice.js +46 -0
- package/dist/interactiveToolsWire.d.ts +4 -2
- package/dist/interactiveToolsWire.js +5 -5
- package/dist/jsonFaithful.d.ts +20 -0
- package/dist/jsonFaithful.js +152 -0
- package/dist/limitsWire.d.ts +7 -2
- package/dist/limitsWire.js +19 -13
- package/dist/liveInitToolFace.d.ts +6 -1
- package/dist/liveInitToolFace.js +5 -3
- package/dist/liveModelCatalog.d.ts +22 -0
- package/dist/liveModelCatalog.js +132 -18
- package/dist/mcpPanel.js +3 -1
- package/dist/mcpProbeCapability.js +2 -2
- package/dist/mcpReconnect.js +2 -2
- package/dist/mcpStatusSupersetKeys.d.ts +24 -0
- package/dist/mcpStatusSupersetKeys.js +45 -0
- package/dist/mcpToolToggles.d.ts +6 -0
- package/dist/mcpToolToggles.js +47 -0
- package/dist/mcpWireCaps.d.ts +48 -4
- package/dist/mcpWireCaps.js +338 -99
- package/dist/mcpWireTransport.d.ts +4 -0
- package/dist/mcpWireTransport.js +18 -0
- package/dist/memoryComplianceCapability.js +2 -2
- package/dist/memoryOriginCapability.js +2 -2
- package/dist/model/catalogDefault.d.ts +24 -0
- package/dist/model/catalogDefault.js +4 -0
- package/dist/model/liveCatalogShape.js +5 -4
- package/dist/model/modelsPolicy.js +4 -3
- package/dist/model/onboardJudgement.d.ts +1 -0
- package/dist/model/onboardJudgement.js +1 -1
- package/dist/model/subagentModelWord.js +2 -2
- package/dist/modelCapabilityProbe.d.ts +2 -1
- package/dist/modelCapabilityProbe.js +16 -15
- package/dist/modelIdentityResolvability.d.ts +12 -1
- package/dist/modelIdentityResolvability.js +69 -28
- package/dist/modsKernelIdentity.d.ts +10 -0
- package/dist/modsKernelIdentity.js +103 -0
- package/dist/modsKernelTransit.d.ts +8 -0
- package/dist/modsKernelTransit.js +6 -0
- package/dist/notifications.d.ts +30 -12
- package/dist/notifications.js +241 -53
- package/dist/outputStyleSeatCapability.js +2 -2
- package/dist/ownKey.d.ts +37 -0
- package/dist/ownKey.js +238 -2
- package/dist/panelReduce.d.ts +5 -0
- package/dist/panelReduce.js +45 -13
- package/dist/panelStateHolder.d.ts +1 -0
- package/dist/panelStateHolder.js +10 -1
- package/dist/peerFrames.d.ts +1 -1
- package/dist/peerFrames.js +6 -2
- package/dist/peerLaneCapability.js +2 -2
- package/dist/permissionModesCapability.js +4 -4
- package/dist/permissionRuleIssue.d.ts +2 -1
- package/dist/permissionRuleIssue.js +24 -21
- package/dist/permissionRulesWriteCapability.js +2 -2
- package/dist/permissionsAllowGrantCapability.js +2 -2
- package/dist/permissionsDeclaration.d.ts +43 -4
- package/dist/permissionsDeclaration.js +102 -35
- package/dist/pluginHooksWire.d.ts +20 -4
- package/dist/pluginHooksWire.js +101 -60
- package/dist/prepareRefusal.d.ts +9 -0
- package/dist/prepareRefusal.js +90 -0
- package/dist/printInitToolFace.js +2 -2
- package/dist/printModelStatus.js +1 -1
- package/dist/projectMemory.d.ts +32 -0
- package/dist/projectMemory.js +70 -0
- package/dist/promptBlockedCopy.d.ts +2 -1
- package/dist/promptBlockedCopy.js +2 -1
- package/dist/promptDelivery.d.ts +23 -3
- package/dist/promptDelivery.js +169 -30
- package/dist/providerRejection.d.ts +19 -1
- package/dist/providerRejection.js +75 -4
- package/dist/queuedDelivery.d.ts +48 -0
- package/dist/queuedDelivery.js +233 -0
- package/dist/reattachWindow.d.ts +94 -0
- package/dist/reattachWindow.js +127 -0
- package/dist/request/printNotification.d.ts +1 -1
- package/dist/request/printNotification.js +5 -1
- package/dist/request/submissionIdentity.d.ts +37 -0
- package/dist/request/submissionIdentity.js +65 -0
- package/dist/request/taskRequest.d.ts +22 -14
- package/dist/request/taskRequest.js +312 -202
- package/dist/resultFrameKeys.d.ts +1 -0
- package/dist/resultFrameKeys.js +4 -1
- package/dist/resumeRefusalCopy.d.ts +3 -1
- package/dist/resumeRefusalCopy.js +22 -4
- package/dist/retryStatus.d.ts +26 -0
- package/dist/retryStatus.js +133 -28
- package/dist/rewindArchiveCapability.js +2 -2
- package/dist/rewindEngineAction.d.ts +2 -0
- package/dist/rewindEngineAction.js +23 -1
- package/dist/rowKind.d.ts +36 -0
- package/dist/rowKind.js +97 -0
- package/dist/ruleCompileVerdict.d.ts +18 -0
- package/dist/ruleCompileVerdict.js +67 -2
- package/dist/ruleReadings.d.ts +58 -0
- package/dist/ruleReadings.js +132 -0
- package/dist/ruleRefusalSentence.d.ts +8 -0
- package/dist/ruleRefusalSentence.js +64 -0
- package/dist/runCancelContext.d.ts +0 -1
- package/dist/runCancelContext.js +1 -2
- package/dist/runTerminal.d.ts +5 -0
- package/dist/runTerminal.js +52 -17
- package/dist/sandboxWire.d.ts +3 -2
- package/dist/sandboxWire.js +59 -27
- package/dist/scenarioRefusal.d.ts +2 -1
- package/dist/scenarioRefusal.js +6 -6
- package/dist/scenarioSkills.d.ts +20 -0
- package/dist/scenarioSkills.js +72 -0
- package/dist/scenarioWire.d.ts +5 -2
- package/dist/scenarioWire.js +9 -9
- package/dist/sealedKeyCapability.js +2 -2
- package/dist/seam.d.ts +26 -9
- package/dist/seam.js +44 -4
- package/dist/seatContract.d.ts +62 -9
- package/dist/seatContract.js +70 -25
- package/dist/selfOrchestrationDenial.js +1 -1
- package/dist/sessionPolicyCapability.js +2 -2
- package/dist/sessionRulesChildrenReadLive.d.ts +6 -0
- package/dist/sessionRulesChildrenReadLive.js +5 -0
- package/dist/sessionRulesNamespaceFormsCapability.d.ts +12 -0
- package/dist/sessionRulesNamespaceFormsCapability.js +29 -0
- package/dist/sessionSyncFileHistoryCapability.js +2 -2
- package/dist/settingsCredentialKeyPaths.d.ts +8 -0
- package/dist/settingsCredentialKeyPaths.js +274 -0
- package/dist/settingsHooksSalvage.d.ts +1 -0
- package/dist/settingsHooksSalvage.js +7 -1
- package/dist/settingsLayerAdmission.d.ts +4 -0
- package/dist/settingsLayerAdmission.js +16 -0
- package/dist/skillToolListsCapability.js +6 -5
- package/dist/skillsWireCaps.d.ts +14 -3
- package/dist/skillsWireCaps.js +48 -18
- package/dist/slashCommandGate.d.ts +24 -0
- package/dist/slashCommandGate.js +74 -0
- package/dist/slashCommandTable.d.ts +14 -0
- package/dist/slashCommandTable.js +99 -0
- package/dist/sqlEngineCapability.js +2 -2
- package/dist/steerPriorityCapability.js +2 -2
- package/dist/storePostureCapability.js +2 -2
- package/dist/subagent/agentStateDetail.js +1 -1
- package/dist/subagent/engineDelegatedPrompt.d.ts +9 -0
- package/dist/subagent/engineDelegatedPrompt.js +38 -7
- package/dist/subagent/engineRowStopGate.js +2 -2
- package/dist/subagent/engineSubagentResume.js +3 -3
- package/dist/subagent/engineTaskHandleWire.d.ts +1 -0
- package/dist/subagent/engineTaskHandleWire.js +10 -0
- package/dist/subagentContentStore.d.ts +1 -0
- package/dist/subagentContentStore.js +135 -27
- package/dist/submitFailure.d.ts +8 -0
- package/dist/submitFailure.js +17 -0
- package/dist/supportFloor.d.ts +1 -0
- package/dist/supportFloor.js +7 -0
- package/dist/terminationIntent.d.ts +55 -0
- package/dist/terminationIntent.js +352 -0
- package/dist/toolHistoryMismatch.d.ts +8 -0
- package/dist/toolHistoryMismatch.js +37 -6
- package/dist/toolResult.d.ts +13 -3
- package/dist/toolResult.js +158 -9
- package/dist/toolResultContent.d.ts +13 -0
- package/dist/toolResultContent.js +82 -7
- package/dist/toolRoster.d.ts +18 -0
- package/dist/toolRoster.js +64 -0
- package/dist/toolsFlagNames.d.ts +8 -0
- package/dist/toolsFlagNames.js +110 -0
- package/dist/turnFailurePresentation.js +41 -96
- package/dist/usageLimitAutoResume.d.ts +74 -0
- package/dist/usageLimitAutoResume.js +227 -0
- package/dist/userAttachmentEnvelope.js +1 -1
- package/dist/userAttachmentSeat.js +5 -5
- package/dist/userInvokedSkillsCapability.js +2 -2
- package/dist/webSearchBackendCapability.js +2 -2
- package/dist/wireErrorTriage.js +99 -50
- package/dist/wireFailureShape.d.ts +25 -1
- package/dist/wireFailureShape.js +92 -5
- package/dist/wireRefusalCopy.d.ts +75 -18
- package/dist/wireRefusalCopy.js +532 -148
- package/dist/wiringFleetDoctor.d.ts +3 -0
- package/dist/wiringFleetDoctor.js +21 -0
- package/dist/workflow.d.ts +2 -1
- package/dist/workflow.js +38 -1
- package/dist/workflowClient.d.ts +2 -7
- package/dist/workflowsJournalCapability.js +2 -2
- package/dist/writeProtectionCapability.js +2 -2
- package/docs/INTEGRATION-CLIENTS.md +1013 -190
- package/package.json +15 -4
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { usableClockMs } from './clockReading.js';
|
|
2
|
+
export const ENGINE_GENERATION_WINDOW_MARGIN_MS = 5_000;
|
|
3
|
+
export const ENGINE_STOPPED_CALL_PHASES = Object.freeze(['engine-stopped-awaiting-approval', 'engine-stopped-before-result']);
|
|
4
|
+
const EMPTY = Object.freeze({ retract: Object.freeze([]), phases: Object.freeze([]) });
|
|
5
|
+
const nonEmpty = (v) => typeof v === 'string' && v.length > 0;
|
|
6
|
+
export function approvalWindowLeftMs(keys, nowMs) {
|
|
7
|
+
try {
|
|
8
|
+
const now = usableClockMs(nowMs);
|
|
9
|
+
if (typeof keys !== 'object' || keys === null || now === null)
|
|
10
|
+
return undefined;
|
|
11
|
+
const { receivedAtMs, expiresInMs } = keys;
|
|
12
|
+
if (usableClockMs(receivedAtMs) === null || typeof expiresInMs !== 'number' || !Number.isFinite(expiresInMs))
|
|
13
|
+
return undefined;
|
|
14
|
+
if (now < receivedAtMs)
|
|
15
|
+
return undefined;
|
|
16
|
+
return receivedAtMs + expiresInMs - now;
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function forEachGuarded(items, visit) {
|
|
23
|
+
let skipped = 0;
|
|
24
|
+
for (const item of items) {
|
|
25
|
+
try {
|
|
26
|
+
visit(item);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
skipped += 1;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return skipped;
|
|
33
|
+
}
|
|
34
|
+
function windowDefinitelyOpen(card) {
|
|
35
|
+
if (card.closedByEngine === true)
|
|
36
|
+
return false;
|
|
37
|
+
const left = card.windowLeftMs;
|
|
38
|
+
return typeof left === 'number' && Number.isFinite(left) && left > ENGINE_GENERATION_WINDOW_MARGIN_MS;
|
|
39
|
+
}
|
|
40
|
+
export function convergeEndedEngineGeneration(facts) {
|
|
41
|
+
try {
|
|
42
|
+
if (typeof facts !== 'object' || facts === null)
|
|
43
|
+
return EMPTY;
|
|
44
|
+
const ended = facts.endedGeneration;
|
|
45
|
+
if (typeof ended !== 'number' || !Number.isFinite(ended))
|
|
46
|
+
return EMPTY;
|
|
47
|
+
const retract = [];
|
|
48
|
+
const phases = [];
|
|
49
|
+
const held = new Map();
|
|
50
|
+
const holds = facts.phases;
|
|
51
|
+
if (Array.isArray(holds)) {
|
|
52
|
+
forEachGuarded(holds, (p) => {
|
|
53
|
+
if (typeof p === 'object' && p !== null && nonEmpty(p.toolCallId) && typeof p.generation === 'number')
|
|
54
|
+
held.set(p.toolCallId, p.generation);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
const cards = facts.cards;
|
|
58
|
+
if (Array.isArray(cards)) {
|
|
59
|
+
forEachGuarded(cards, (card) => {
|
|
60
|
+
if (typeof card !== 'object' || card === null || !nonEmpty(card.callKey))
|
|
61
|
+
return;
|
|
62
|
+
if (card.parkRow !== false || !windowDefinitelyOpen(card))
|
|
63
|
+
return;
|
|
64
|
+
if (retract.includes(card.callKey))
|
|
65
|
+
return;
|
|
66
|
+
const id = card.toolCallId;
|
|
67
|
+
retract.push(card.callKey);
|
|
68
|
+
if (!nonEmpty(id))
|
|
69
|
+
return;
|
|
70
|
+
const heldGen = held.get(id);
|
|
71
|
+
if (heldGen !== undefined && heldGen !== ended)
|
|
72
|
+
return;
|
|
73
|
+
if (phases.some((p) => p.toolCallId === id))
|
|
74
|
+
return;
|
|
75
|
+
phases.push({ toolCallId: id, phase: 'engine-stopped-awaiting-approval', viaCallKey: card.callKey });
|
|
76
|
+
held.set(id, ended);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
const opened = facts.opened;
|
|
80
|
+
if (Array.isArray(opened)) {
|
|
81
|
+
forEachGuarded(opened, (call) => {
|
|
82
|
+
if (typeof call !== 'object' || call === null || !nonEmpty(call.toolCallId) || call.generation !== ended)
|
|
83
|
+
return;
|
|
84
|
+
if (held.has(call.toolCallId))
|
|
85
|
+
return;
|
|
86
|
+
phases.push({ toolCallId: call.toolCallId, phase: 'engine-stopped-before-result' });
|
|
87
|
+
held.set(call.toolCallId, ended);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
return Object.freeze({ retract: Object.freeze(retract), phases: Object.freeze(phases.map((p) => Object.freeze(p))) });
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
return EMPTY;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export declare const REATTACH_RUN_STATES: readonly ["done", "died", "parked", "running", "unreachable", "unauthorized", "engine-known-dead"];
|
|
2
|
+
export type ReattachRunState = (typeof REATTACH_RUN_STATES)[number];
|
|
3
|
+
export interface ReattachLivenessReading {
|
|
4
|
+
readonly state: ReattachRunState;
|
|
5
|
+
readonly notFound?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface ReattachOutageStopLineParts {
|
|
8
|
+
readonly taskId: string;
|
|
9
|
+
readonly action: string;
|
|
10
|
+
readonly nextMessage: string;
|
|
11
|
+
}
|
|
12
|
+
export type ReattachOutageStopLine = (parts: ReattachOutageStopLineParts) => string;
|
|
13
|
+
export interface EndedGenerationMaterials {
|
|
14
|
+
readonly restartPending: boolean;
|
|
15
|
+
readonly outageStopLine?: ReattachOutageStopLine;
|
|
16
|
+
}
|
|
17
|
+
export interface EngineGenerationPort {
|
|
18
|
+
current: () => number;
|
|
19
|
+
endedMaterials: () => Promise<EndedGenerationMaterials>;
|
|
20
|
+
replacementInFlight?: () => boolean;
|
|
21
|
+
awaitEngineInstalled?: (signal: AbortSignal, maxMs: number) => Promise<boolean>;
|
|
22
|
+
}
|
|
23
|
+
export type EngineGenerationReading = {
|
|
24
|
+
readonly known: true;
|
|
25
|
+
readonly generation: number;
|
|
26
|
+
} | {
|
|
27
|
+
readonly known: false;
|
|
28
|
+
};
|
|
29
|
+
export declare function engineGenerationReadingOf(read: (() => number | undefined) | undefined): EngineGenerationReading;
|
|
30
|
+
export declare function engineGenerationOfPort(port: EngineGenerationPort | undefined): EngineGenerationReading;
|
|
31
|
+
export interface EngineGenerationEndedFacts {
|
|
32
|
+
readonly run: EngineGenerationReading;
|
|
33
|
+
readonly current: EngineGenerationReading;
|
|
34
|
+
readonly freshCredentialAdopted?: boolean;
|
|
35
|
+
}
|
|
36
|
+
export declare function engineGenerationEnded(facts: EngineGenerationEndedFacts): boolean;
|
|
37
|
+
export interface ApprovalFrameGenerationFacts {
|
|
38
|
+
readonly streamOpenedIn: EngineGenerationReading;
|
|
39
|
+
readonly current: EngineGenerationReading;
|
|
40
|
+
readonly freshCredentialAdopted?: boolean;
|
|
41
|
+
}
|
|
42
|
+
export declare function approvalFrameGenerationVerdict(facts: ApprovalFrameGenerationFacts): 'admit' | 'drop';
|
|
43
|
+
export declare const REATTACH_AWAIT_NEXT_ENGINE_MS = 245000;
|
|
44
|
+
export declare function unreachableForSettle(liveness: ReattachLivenessReading): boolean;
|
|
45
|
+
export type EndedGenerationSettleStep = 'await-next-engine' | 'refresh-credentials' | 'credentials-rejected' | 'hand-over-terminal' | 'parked' | 'engine-stopped';
|
|
46
|
+
export interface EndedGenerationSettleFacts {
|
|
47
|
+
readonly liveness: ReattachLivenessReading;
|
|
48
|
+
readonly canAwaitNextEngine: boolean;
|
|
49
|
+
readonly awaitedNextEngine: boolean;
|
|
50
|
+
readonly refreshedCredentials: boolean | null;
|
|
51
|
+
readonly terminalReadable?: boolean;
|
|
52
|
+
}
|
|
53
|
+
export declare function endedGenerationSettleStep(facts: EndedGenerationSettleFacts): EndedGenerationSettleStep;
|
|
54
|
+
export declare const AWAIT_ENGINE_INSTALL_POLL_MS = 200;
|
|
55
|
+
export interface AwaitNextEngineDeps {
|
|
56
|
+
readonly installed: () => boolean;
|
|
57
|
+
readonly replacing: () => boolean;
|
|
58
|
+
readonly now?: () => number;
|
|
59
|
+
readonly pollMs?: number;
|
|
60
|
+
}
|
|
61
|
+
export declare function awaitNextEngineInstalled(signal: AbortSignal, maxMs: number, deps: AwaitNextEngineDeps): Promise<boolean>;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { usableClockMs } from './clockReading.js';
|
|
2
|
+
import { readSignalAborted, tryListenAbortOnce, tryUnlistenAbort } from './engineWireFor.js';
|
|
3
|
+
export const REATTACH_RUN_STATES = Object.freeze(['done', 'died', 'parked', 'running', 'unreachable', 'unauthorized', 'engine-known-dead']);
|
|
4
|
+
const UNKNOWN = Object.freeze({ known: false });
|
|
5
|
+
export function engineGenerationReadingOf(read) {
|
|
6
|
+
if (typeof read !== 'function')
|
|
7
|
+
return UNKNOWN;
|
|
8
|
+
try {
|
|
9
|
+
const g = read();
|
|
10
|
+
return typeof g === 'number' && Number.isFinite(g) ? Object.freeze({ known: true, generation: g }) : UNKNOWN;
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return UNKNOWN;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export function engineGenerationOfPort(port) {
|
|
17
|
+
if (typeof port !== 'object' || port === null)
|
|
18
|
+
return UNKNOWN;
|
|
19
|
+
return engineGenerationReadingOf(() => port.current());
|
|
20
|
+
}
|
|
21
|
+
export function engineGenerationEnded(facts) {
|
|
22
|
+
try {
|
|
23
|
+
const { run, current, freshCredentialAdopted } = facts;
|
|
24
|
+
const runGeneration = knownGenerationOf(run);
|
|
25
|
+
if (runGeneration === null)
|
|
26
|
+
return false;
|
|
27
|
+
if (freshCredentialAdopted === true)
|
|
28
|
+
return true;
|
|
29
|
+
const currentGeneration = knownGenerationOf(current);
|
|
30
|
+
if (currentGeneration === null)
|
|
31
|
+
return false;
|
|
32
|
+
return currentGeneration !== runGeneration;
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function knownGenerationOf(reading) {
|
|
39
|
+
if (typeof reading !== 'object' || reading === null)
|
|
40
|
+
return null;
|
|
41
|
+
const raw = reading;
|
|
42
|
+
const known = raw.known;
|
|
43
|
+
const generation = raw.generation;
|
|
44
|
+
return known === true && typeof generation === 'number' && Number.isFinite(generation) ? generation : null;
|
|
45
|
+
}
|
|
46
|
+
export function approvalFrameGenerationVerdict(facts) {
|
|
47
|
+
try {
|
|
48
|
+
return engineGenerationEnded({ run: facts.streamOpenedIn, current: facts.current, ...(facts.freshCredentialAdopted === true ? { freshCredentialAdopted: true } : {}) }) ? 'drop' : 'admit';
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return 'admit';
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export const REATTACH_AWAIT_NEXT_ENGINE_MS = 245_000;
|
|
55
|
+
export function unreachableForSettle(liveness) {
|
|
56
|
+
try {
|
|
57
|
+
return liveness.state === 'engine-known-dead' || (liveness.state === 'unreachable' && liveness.notFound !== true);
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export function endedGenerationSettleStep(facts) {
|
|
64
|
+
try {
|
|
65
|
+
const liveness = facts.liveness;
|
|
66
|
+
if (typeof liveness !== 'object' || liveness === null || !REATTACH_RUN_STATES.includes(liveness.state))
|
|
67
|
+
return 'engine-stopped';
|
|
68
|
+
if (facts.canAwaitNextEngine === true && facts.awaitedNextEngine !== true && unreachableForSettle(liveness))
|
|
69
|
+
return 'await-next-engine';
|
|
70
|
+
if (liveness.state === 'unauthorized')
|
|
71
|
+
return facts.refreshedCredentials === null ? 'refresh-credentials' : 'credentials-rejected';
|
|
72
|
+
if (liveness.state === 'done')
|
|
73
|
+
return facts.terminalReadable === false ? 'engine-stopped' : 'hand-over-terminal';
|
|
74
|
+
if (liveness.state === 'parked')
|
|
75
|
+
return 'parked';
|
|
76
|
+
return 'engine-stopped';
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return 'engine-stopped';
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export const AWAIT_ENGINE_INSTALL_POLL_MS = 200;
|
|
83
|
+
export function awaitNextEngineInstalled(signal, maxMs, deps) {
|
|
84
|
+
const clock = typeof deps.now === 'function' ? deps.now : () => performance.now();
|
|
85
|
+
const pollMs = typeof deps.pollMs === 'number' && Number.isFinite(deps.pollMs) && deps.pollMs > 0 ? deps.pollMs : AWAIT_ENGINE_INSTALL_POLL_MS;
|
|
86
|
+
const budgetMs = typeof maxMs === 'number' && Number.isFinite(maxMs) ? Math.max(0, maxMs) : 0;
|
|
87
|
+
const maxTicks = Math.ceil(budgetMs / pollMs) + 1;
|
|
88
|
+
const read = (f) => {
|
|
89
|
+
try {
|
|
90
|
+
return f() === true;
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
const now = () => {
|
|
97
|
+
try {
|
|
98
|
+
return usableClockMs(clock());
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
return new Promise((resolve) => {
|
|
105
|
+
if (readSignalAborted(signal) === true) {
|
|
106
|
+
resolve(false);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const start = now();
|
|
110
|
+
const deadline = start === null ? null : start + budgetMs;
|
|
111
|
+
let timer;
|
|
112
|
+
let done = false;
|
|
113
|
+
let ticks = 0;
|
|
114
|
+
const finish = (v) => {
|
|
115
|
+
if (done)
|
|
116
|
+
return;
|
|
117
|
+
done = true;
|
|
118
|
+
if (timer !== undefined)
|
|
119
|
+
clearTimeout(timer);
|
|
120
|
+
tryUnlistenAbort(signal, onAbort);
|
|
121
|
+
resolve(v);
|
|
122
|
+
};
|
|
123
|
+
const onAbort = () => finish(false);
|
|
124
|
+
tryListenAbortOnce(signal, onAbort);
|
|
125
|
+
const tick = () => {
|
|
126
|
+
if (done)
|
|
127
|
+
return;
|
|
128
|
+
ticks += 1;
|
|
129
|
+
if (read(deps.installed))
|
|
130
|
+
return finish(true);
|
|
131
|
+
if (done)
|
|
132
|
+
return;
|
|
133
|
+
if (!read(deps.replacing))
|
|
134
|
+
return finish(read(deps.installed));
|
|
135
|
+
if (done)
|
|
136
|
+
return;
|
|
137
|
+
const t = now();
|
|
138
|
+
if (deadline === null || t === null || t >= deadline || ticks >= maxTicks)
|
|
139
|
+
return finish(false);
|
|
140
|
+
timer = setTimeout(tick, pollMs);
|
|
141
|
+
};
|
|
142
|
+
tick();
|
|
143
|
+
});
|
|
144
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { HealthAuthKind } from '@sema-agent/sdk';
|
|
2
|
+
export interface EngineHealthCenterFacts {
|
|
3
|
+
readonly issuer?: string;
|
|
4
|
+
readonly webBaseUrl?: string;
|
|
5
|
+
readonly sessionsVisible: boolean | 'unknown';
|
|
6
|
+
}
|
|
7
|
+
export interface EngineHealthAuthFacts {
|
|
8
|
+
readonly required: boolean;
|
|
9
|
+
readonly kinds: readonly (HealthAuthKind | (string & {}))[];
|
|
10
|
+
readonly identityAttach: 'available' | 'unavailable';
|
|
11
|
+
}
|
|
12
|
+
export interface EngineHealthDrainingFacts {
|
|
13
|
+
readonly actionId: string;
|
|
14
|
+
readonly since: number;
|
|
15
|
+
readonly deadlineAt: number;
|
|
16
|
+
}
|
|
17
|
+
export interface EngineHealthFacts {
|
|
18
|
+
readonly center?: EngineHealthCenterFacts;
|
|
19
|
+
readonly auth?: EngineHealthAuthFacts;
|
|
20
|
+
readonly operator?: 'present' | 'absent';
|
|
21
|
+
readonly draining?: EngineHealthDrainingFacts;
|
|
22
|
+
}
|
|
23
|
+
export declare function readEngineHealthFacts(health: object | null | undefined): EngineHealthFacts;
|
|
@@ -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
|
@@ -96,6 +96,10 @@ export const TRANSCRIPT_ROW_SIDECAR_KEYS = Object.freeze([
|
|
|
96
96
|
'_sema_api_error_status',
|
|
97
97
|
'_sema_api_error_code',
|
|
98
98
|
'_sema_provider_condition',
|
|
99
|
+
'_sema_terminal_owner',
|
|
100
|
+
'_sema_row_kind',
|
|
101
|
+
'_sema_coded_detail',
|
|
102
|
+
'_sema_task_notification',
|
|
99
103
|
]);
|
|
100
104
|
export function parkHeldCallIdOf(carrier) {
|
|
101
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;
|
|
@@ -10,6 +10,9 @@ export type EngineToolDirectory = {
|
|
|
10
10
|
readonly state: 'not_landed';
|
|
11
11
|
} | {
|
|
12
12
|
readonly state: 'unreadable';
|
|
13
|
+
} | {
|
|
14
|
+
readonly state: 'request_only';
|
|
15
|
+
readonly requestMcpServerPrefixes: ReadonlySet<string>;
|
|
13
16
|
} | {
|
|
14
17
|
readonly state: 'directory';
|
|
15
18
|
readonly mcpServerPrefixes: ReadonlySet<string>;
|
|
@@ -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
|
}
|
|
@@ -35,18 +35,20 @@ export function engineToolDirectoryOf(source) {
|
|
|
35
35
|
const deployment = readHalf(ownDataField(source, 'deploymentMcpServers'));
|
|
36
36
|
if (request === 'unreadable' || deployment === 'unreadable')
|
|
37
37
|
return unreadable();
|
|
38
|
-
if (request === 'absent'
|
|
38
|
+
if (request === 'absent')
|
|
39
39
|
return notLanded();
|
|
40
40
|
const ns = namingPorts();
|
|
41
41
|
if (ns === undefined)
|
|
42
42
|
return unreadable();
|
|
43
43
|
const prefixes = [];
|
|
44
|
-
for (const name of [...request, ...deployment]) {
|
|
44
|
+
for (const name of deployment === 'absent' ? request : [...request, ...deployment]) {
|
|
45
45
|
const prefix = mintNamespacePrefix(ns, name);
|
|
46
46
|
if (typeof prefix !== 'string' || prefix.length === 0)
|
|
47
47
|
return unreadable();
|
|
48
48
|
prefixes.push(prefix);
|
|
49
49
|
}
|
|
50
|
+
if (deployment === 'absent')
|
|
51
|
+
return Object.freeze({ state: 'request_only', requestMcpServerPrefixes: frozenSet(prefixes) });
|
|
50
52
|
return Object.freeze({ state: 'directory', mcpServerPrefixes: frozenSet(prefixes) });
|
|
51
53
|
}
|
|
52
54
|
catch {
|
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 {};
|