@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
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
|
+
}
|
package/dist/eventLeg.d.ts
CHANGED
|
@@ -65,11 +65,6 @@ export interface EventLegIdleTriagePorts {
|
|
|
65
65
|
readonly baseUrl: string;
|
|
66
66
|
}
|
|
67
67
|
export type EventLegTap = (frame: AgentEvent) => void;
|
|
68
|
-
export type EventLegStreamDecorator = (stream: AsyncGenerator<AgentEvent>, ctx: EventLegStreamContext) => AsyncGenerator<AgentEvent>;
|
|
69
|
-
export interface EventLegStreamContext {
|
|
70
|
-
readonly leg: EventLegKind;
|
|
71
|
-
readonly runId: string | undefined;
|
|
72
|
-
}
|
|
73
68
|
export interface ApprovalFrameContext {
|
|
74
69
|
readonly leg: EventLegKind;
|
|
75
70
|
readonly windowIsCurrent: boolean;
|
|
@@ -85,9 +80,8 @@ export interface EventLegPorts {
|
|
|
85
80
|
readonly idleTriage?: EventLegIdleTriagePorts;
|
|
86
81
|
readonly signal?: AbortSignal;
|
|
87
82
|
readonly taps?: readonly EventLegTap[];
|
|
88
|
-
readonly perStream?: readonly EventLegStreamDecorator[];
|
|
89
83
|
}
|
|
90
|
-
export type EventLegPortName = 'run.headerRunId' | 'run.onBound' | 'run.onRefused' | 'run.onTerminal' | 'run.isCurrent' | 'hitl.question' | 'hitl.elicitation' | 'hitl.toolApproval' | 'askBridge.respondToolApproval' | 'taps'
|
|
84
|
+
export type EventLegPortName = 'run.headerRunId' | 'run.onBound' | 'run.onRefused' | 'run.onTerminal' | 'run.isCurrent' | 'hitl.question' | 'hitl.elicitation' | 'hitl.toolApproval' | 'askBridge.respondToolApproval' | 'taps';
|
|
91
85
|
export interface EventLegReport {
|
|
92
86
|
readonly missingPorts: readonly EventLegPortName[];
|
|
93
87
|
readonly portFaults: Readonly<Partial<Record<EventLegPortName, number>>>;
|
package/dist/eventLeg.js
CHANGED
|
@@ -22,6 +22,12 @@ const FRAME_STAGE_DOMAINS = makeFrameStageDomains({
|
|
|
22
22
|
stampOwner: Object.freeze(['task_progress']),
|
|
23
23
|
hitlFrames: Object.freeze(['question', 'question_complete', 'elicitation', 'elicitation_complete', 'tool_approval', 'tool_approval_complete', 'approval_request', 'approval_revoke']),
|
|
24
24
|
});
|
|
25
|
+
const HITL_FRAMES_PROJECTED = Object.freeze(['human_input']);
|
|
26
|
+
const _hitlFrameTypesPin = [true, true];
|
|
27
|
+
const _hitlProjectedDisjointPin = true;
|
|
28
|
+
void _hitlFrameTypesPin;
|
|
29
|
+
void _hitlProjectedDisjointPin;
|
|
30
|
+
void HITL_FRAMES_PROJECTED;
|
|
25
31
|
const HITL_PORT_OF = Object.freeze({
|
|
26
32
|
question: 'question',
|
|
27
33
|
question_complete: 'question',
|
|
@@ -130,7 +136,6 @@ export function composeEventLeg(source, leg, ports) {
|
|
|
130
136
|
};
|
|
131
137
|
const sessionKey = typeof ports.owner?.sessionKey === 'string' && ports.owner.sessionKey !== '' ? ports.owner.sessionKey : undefined;
|
|
132
138
|
const taps = (ports.taps ?? []).filter((t) => typeof t === 'function');
|
|
133
|
-
const decorators = (ports.perStream ?? []).filter((d) => typeof d === 'function');
|
|
134
139
|
const info = Object.freeze({ leg: kind });
|
|
135
140
|
const runSessions = new Map();
|
|
136
141
|
let lastBound;
|
|
@@ -218,13 +223,7 @@ export function composeEventLeg(source, leg, ports) {
|
|
|
218
223
|
ended.abort();
|
|
219
224
|
}
|
|
220
225
|
}
|
|
221
|
-
const streamOf = (raw, streamKind, streamRunId) =>
|
|
222
|
-
let s = generatorOf(raw);
|
|
223
|
-
const ctx = Object.freeze({ leg: streamKind, runId: streamRunId });
|
|
224
|
-
for (const d of decorators)
|
|
225
|
-
s = d(s, ctx);
|
|
226
|
-
return frameLevel(s, streamKind, streamRunId);
|
|
227
|
-
};
|
|
226
|
+
const streamOf = (raw, streamKind, streamRunId) => frameLevel(generatorOf(raw), streamKind, streamRunId);
|
|
228
227
|
let inner = streamOf(source, kind, legRunId);
|
|
229
228
|
if (hostBridge !== undefined) {
|
|
230
229
|
let windowOpen = row.windowIsCurrent;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { capForDisplay } from './fleetTaskDesc.js';
|
|
2
|
-
import {
|
|
2
|
+
import { engineWireTargetBaseUrl } from './engineWireTarget.js';
|
|
3
3
|
import { createEngineCapReader, unreadableReadingDetail } from './engineCapReader.js';
|
|
4
4
|
import { ownDataField } from './ownKey.js';
|
|
5
5
|
export function projectExecutionLaneCapability(caps) {
|
|
@@ -49,7 +49,7 @@ const reader = createEngineCapReader({
|
|
|
49
49
|
name: 'executionLane',
|
|
50
50
|
project: projectExecutionLaneCapability,
|
|
51
51
|
});
|
|
52
|
-
export function observedExecutionLane(baseUrl =
|
|
52
|
+
export function observedExecutionLane(baseUrl = engineWireTargetBaseUrl()) {
|
|
53
53
|
return reader.observed(baseUrl);
|
|
54
54
|
}
|
|
55
55
|
export function toolsRunHereFromExecutionLane(reading) {
|
|
@@ -13,9 +13,6 @@ export type FileHistoryCaptureMode = 'off' | 'on-optional' | 'unknown';
|
|
|
13
13
|
export declare function projectFileHistoryCaptureCapability(caps: unknown): FileHistoryCaptureReading | undefined;
|
|
14
14
|
export declare function observedFileHistoryCapture(baseUrl?: string | undefined): FileHistoryCaptureReading;
|
|
15
15
|
export declare function fileHistoryCaptureMode(reading: FileHistoryCaptureReading): FileHistoryCaptureMode;
|
|
16
|
-
export declare function fileHistoryDeclarationField(reading: FileHistoryCaptureReading, captureOff: boolean): {
|
|
17
|
-
fileHistory: 'disabled';
|
|
18
|
-
} | Record<string, never>;
|
|
19
16
|
export declare const FILE_HISTORY_TIGHTEN_VERDICTS: readonly ["not_requested", "declare", "already_off", "unjudged"];
|
|
20
17
|
export type FileHistoryTightenVerdict = (typeof FILE_HISTORY_TIGHTEN_VERDICTS)[number];
|
|
21
18
|
export declare function fileHistoryTightenVerdict(reading: FileHistoryCaptureReading, captureOffByUser: boolean): FileHistoryTightenVerdict;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { msg, renderMessage } from './i18n/translate.js';
|
|
2
2
|
import { capForDisplay } from './fleetTaskDesc.js';
|
|
3
|
-
import {
|
|
3
|
+
import { engineWireTargetBaseUrl } from './engineWireTarget.js';
|
|
4
4
|
import { createEngineCapReader, unreadableReadingDetail } from './engineCapReader.js';
|
|
5
5
|
import { refreshEngineCapsOnce } from './engineCapsCache.js';
|
|
6
6
|
import { ownDataField } from './ownKey.js';
|
|
7
|
-
import { FILE_HISTORY_DISABLED } from './request/taskRequest.js';
|
|
8
7
|
export function projectFileHistoryCaptureCapability(caps) {
|
|
9
8
|
try {
|
|
10
9
|
if (caps === null || typeof caps !== 'object' || Array.isArray(caps))
|
|
@@ -24,7 +23,7 @@ const reader = createEngineCapReader({
|
|
|
24
23
|
name: 'fileHistoryCapture',
|
|
25
24
|
project: projectFileHistoryCaptureCapability,
|
|
26
25
|
});
|
|
27
|
-
export function observedFileHistoryCapture(baseUrl =
|
|
26
|
+
export function observedFileHistoryCapture(baseUrl = engineWireTargetBaseUrl()) {
|
|
28
27
|
return reader.observed(baseUrl);
|
|
29
28
|
}
|
|
30
29
|
export function fileHistoryCaptureMode(reading) {
|
|
@@ -47,9 +46,6 @@ export function fileHistoryCaptureMode(reading) {
|
|
|
47
46
|
return 'on-optional';
|
|
48
47
|
return 'unknown';
|
|
49
48
|
}
|
|
50
|
-
export function fileHistoryDeclarationField(reading, captureOff) {
|
|
51
|
-
return captureOff === true && fileHistoryCaptureMode(reading) === 'on-optional' ? { fileHistory: FILE_HISTORY_DISABLED } : {};
|
|
52
|
-
}
|
|
53
49
|
export const FILE_HISTORY_TIGHTEN_VERDICTS = Object.freeze(['not_requested', 'declare', 'already_off', 'unjudged']);
|
|
54
50
|
export function fileHistoryTightenVerdict(reading, captureOffByUser) {
|
|
55
51
|
if (captureOffByUser !== true)
|
|
@@ -122,7 +118,7 @@ export async function judgeFileHistoryTighten(captureOffByUser, opts) {
|
|
|
122
118
|
withinMs = 0;
|
|
123
119
|
}
|
|
124
120
|
}
|
|
125
|
-
const baseUrl = explicitBase ??
|
|
121
|
+
const baseUrl = explicitBase ?? engineWireTargetBaseUrl();
|
|
126
122
|
const first = observedFileHistoryCapture(baseUrl);
|
|
127
123
|
const v1 = fileHistoryTightenVerdict(first, captureOffByUser);
|
|
128
124
|
if (v1 !== 'unjudged')
|
|
@@ -2,11 +2,14 @@ import type { SemaSettings } from '@sema-agent/sdk';
|
|
|
2
2
|
import { type EnvLike } from './hostEnv.js';
|
|
3
3
|
export type WireHooksConfig = NonNullable<SemaSettings['hooks']>;
|
|
4
4
|
export declare const HEADLESS_FINAL_VERIFY_ENV = "SEMA_HEADLESS_FINAL_VERIFY";
|
|
5
|
-
export
|
|
5
|
+
export interface HeadlessFinalVerifyFlags {
|
|
6
|
+
readonly noFinalVerify?: boolean;
|
|
7
|
+
readonly finalVerify?: boolean;
|
|
8
|
+
}
|
|
6
9
|
export declare function headlessFinalVerifyDisabledByEnv(env?: EnvLike): boolean;
|
|
7
10
|
export declare function hasUserStopHook(wireHooks: WireHooksConfig | undefined): boolean;
|
|
8
|
-
export declare function resolveHeadlessFinalVerify(
|
|
9
|
-
export declare function resolveHeadlessFinalVerifyDetail(
|
|
11
|
+
export declare function resolveHeadlessFinalVerify(flags: HeadlessFinalVerifyFlags | undefined, env?: EnvLike, wireHooks?: WireHooksConfig): boolean;
|
|
12
|
+
export declare function resolveHeadlessFinalVerifyDetail(flags: HeadlessFinalVerifyFlags | undefined, env?: EnvLike, wireHooks?: WireHooksConfig): {
|
|
10
13
|
on: boolean;
|
|
11
14
|
offReason?: 'flag' | 'env' | 'stop-hook';
|
|
12
15
|
};
|
package/dist/finalVerifyWire.js
CHANGED
|
@@ -1,24 +1,7 @@
|
|
|
1
1
|
import { hostEnv } from './hostEnv.js';
|
|
2
2
|
import { envFlagOff, envFlagOn } from './envFlag.js';
|
|
3
|
+
import { flagTrue } from './flagInput.js';
|
|
3
4
|
export const HEADLESS_FINAL_VERIFY_ENV = 'SEMA_HEADLESS_FINAL_VERIFY';
|
|
4
|
-
export function parseNoFinalVerifyArgv(argv) {
|
|
5
|
-
for (const a of argv) {
|
|
6
|
-
if (a === '--')
|
|
7
|
-
break;
|
|
8
|
-
if (a === '--no-final-verify')
|
|
9
|
-
return true;
|
|
10
|
-
}
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
function parseFinalVerifyArgv(argv) {
|
|
14
|
-
for (const a of argv) {
|
|
15
|
-
if (a === '--')
|
|
16
|
-
break;
|
|
17
|
-
if (a === '--final-verify')
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
5
|
export function headlessFinalVerifyDisabledByEnv(env = hostEnv()) {
|
|
23
6
|
return envFlagOff(env[HEADLESS_FINAL_VERIFY_ENV]);
|
|
24
7
|
}
|
|
@@ -26,15 +9,15 @@ export function hasUserStopHook(wireHooks) {
|
|
|
26
9
|
const groups = wireHooks?.['Stop'];
|
|
27
10
|
return Array.isArray(groups) && groups.length > 0;
|
|
28
11
|
}
|
|
29
|
-
export function resolveHeadlessFinalVerify(
|
|
30
|
-
return resolveHeadlessFinalVerifyDetail(
|
|
12
|
+
export function resolveHeadlessFinalVerify(flags, env = hostEnv(), wireHooks) {
|
|
13
|
+
return resolveHeadlessFinalVerifyDetail(flags, env, wireHooks).on;
|
|
31
14
|
}
|
|
32
|
-
export function resolveHeadlessFinalVerifyDetail(
|
|
33
|
-
if (
|
|
15
|
+
export function resolveHeadlessFinalVerifyDetail(flags, env = hostEnv(), wireHooks) {
|
|
16
|
+
if (flagTrue(flags, 'noFinalVerify'))
|
|
34
17
|
return { on: false, offReason: 'flag' };
|
|
35
18
|
if (headlessFinalVerifyDisabledByEnv(env))
|
|
36
19
|
return { on: false, offReason: 'env' };
|
|
37
|
-
const explicitOn =
|
|
20
|
+
const explicitOn = flagTrue(flags, 'finalVerify') || envFlagOn(env[HEADLESS_FINAL_VERIFY_ENV]);
|
|
38
21
|
if (explicitOn) {
|
|
39
22
|
if (hasUserStopHook(wireHooks))
|
|
40
23
|
return { on: false, offReason: 'stop-hook' };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function flagObject(flags: object | null | undefined, key: string): object | undefined;
|
|
2
|
+
export declare function flagIsWronglyTyped(flags: object | null | undefined, key: string): boolean;
|
|
3
|
+
export declare function flagString(flags: object | null | undefined, key: string): string | undefined;
|
|
4
|
+
export declare function flagTrue(flags: object | null | undefined, key: string): boolean;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { guardedRead, readOwnDataValue } from './ownKey.js';
|
|
2
|
+
function flagSlot(flags, key) {
|
|
3
|
+
return guardedRead(() => readOwnDataValue(flags, key));
|
|
4
|
+
}
|
|
5
|
+
export function flagObject(flags, key) {
|
|
6
|
+
const v = flagSlot(flags, key);
|
|
7
|
+
try {
|
|
8
|
+
return typeof v === 'object' && v !== null && !Array.isArray(v) ? v : undefined;
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export function flagIsWronglyTyped(flags, key) {
|
|
15
|
+
const v = flagSlot(flags, key);
|
|
16
|
+
return v !== undefined && typeof v !== 'string';
|
|
17
|
+
}
|
|
18
|
+
export function flagString(flags, key) {
|
|
19
|
+
const v = flagSlot(flags, key);
|
|
20
|
+
return typeof v === 'string' ? v : undefined;
|
|
21
|
+
}
|
|
22
|
+
export function flagTrue(flags, key) {
|
|
23
|
+
return flagSlot(flags, key) === true;
|
|
24
|
+
}
|
|
@@ -12,6 +12,7 @@ import { isSdkFleetTaskTerminal, isSdkFleetTaskTerminalNotSuccess } from '../ter
|
|
|
12
12
|
import { projectTasks, projectWorkflows, wireCycleSeq, wireParentId, } from './fleetProjection.js';
|
|
13
13
|
import { isInStreamDrainingEnd } from '../wireErrorTriage.js';
|
|
14
14
|
import { cycleSeqOrder, cycleSeqValue } from '../cycleOrder.js';
|
|
15
|
+
import { guardedRead, ownSnapshotRecord, readOwnDataValue } from '../ownKey.js';
|
|
15
16
|
export const TERMINAL_RETAIN_MS = 60_000;
|
|
16
17
|
function hasRowId(row) {
|
|
17
18
|
const id = row?.id;
|
|
@@ -382,7 +383,7 @@ export function createFleetLedger(hooks = {}, opts = {}) {
|
|
|
382
383
|
hooks.onHookNotice?.(frame, sessionScopedMeta === true);
|
|
383
384
|
break;
|
|
384
385
|
case 'bg_notification':
|
|
385
|
-
applyBgNotification(frame
|
|
386
|
+
applyBgNotification(guardedRead(() => readOwnDataValue(frame, 'notification')), ing);
|
|
386
387
|
break;
|
|
387
388
|
default:
|
|
388
389
|
if (isInStreamDrainingEnd(frame)) {
|
|
@@ -394,7 +395,8 @@ export function createFleetLedger(hooks = {}, opts = {}) {
|
|
|
394
395
|
break;
|
|
395
396
|
}
|
|
396
397
|
}
|
|
397
|
-
function applyBgNotification(
|
|
398
|
+
function applyBgNotification(raw, ing) {
|
|
399
|
+
const n = ownSnapshotRecord(raw);
|
|
398
400
|
if (typeof n?.taskId !== 'string' || typeof n?.status !== 'string') {
|
|
399
401
|
droppedMalformed++;
|
|
400
402
|
debug('[fleet-frame] MALFORMED bg_notification dropped(taskId 或 status 缺席/非串)');
|
|
@@ -554,6 +556,7 @@ export function createFleetLedger(hooks = {}, opts = {}) {
|
|
|
554
556
|
status: n.status,
|
|
555
557
|
...(typeof n.seq === 'number' ? { seq: n.seq } : {}),
|
|
556
558
|
...(typeof n.summary === 'string' ? { summary: n.summary } : {}),
|
|
559
|
+
...(typeof n.completionId === 'string' && n.completionId.length > 0 ? { completionId: n.completionId } : {}),
|
|
557
560
|
});
|
|
558
561
|
}
|
|
559
562
|
function project(nowMs, opts) {
|
|
@@ -54,6 +54,7 @@ export interface FleetWorkflowView {
|
|
|
54
54
|
}
|
|
55
55
|
export declare function coerceTaskStatus(s: string): FleetTaskStatus;
|
|
56
56
|
export declare function coerceWorkflowStatus(s: string | undefined): FleetTaskStatus;
|
|
57
|
+
export declare function workflowRunDisplayStatusOf(run: object | null | undefined): FleetTaskStatus;
|
|
57
58
|
export declare const CONTROL_TOOL_VERBS: ReadonlySet<string>;
|
|
58
59
|
export declare function projectDescription(description: string | undefined): string;
|
|
59
60
|
export declare function wireParentId(r: Pick<FleetTaskRow, 'parentId'>): string | undefined;
|