@sema-agent/client-core 0.100.0 → 0.101.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +395 -0
- package/README.md +164 -117
- package/dist/adapt/arms.js +51 -16
- package/dist/adapt/textStream.js +7 -4
- package/dist/adapt/toolCards.js +9 -8
- package/dist/adapt.js +7 -1
- package/dist/adapter/activeRunSelfHeal.d.ts +24 -2
- package/dist/adapter/activeRunSelfHeal.js +108 -6
- package/dist/adapter/downstream/eventToSdkMessage.js +33 -12
- package/dist/adapter/downstream/terminalToSdkResult.d.ts +60 -1
- package/dist/adapter/downstream/terminalToSdkResult.js +209 -39
- package/dist/adapter/runStream.d.ts +4 -4
- package/dist/adapter/runStream.js +158 -43
- package/dist/agentsWireCaps.d.ts +2 -7
- package/dist/agentsWireCaps.js +1 -2
- package/dist/approvalDecidedByCapability.js +2 -2
- package/dist/approvalFrameFamilies.d.ts +33 -0
- package/dist/approvalFrameFamilies.js +120 -0
- package/dist/approvalsStreamLiveCapability.js +2 -2
- package/dist/attachmentsWireCaps.js +41 -13
- package/dist/callerCwdCapability.js +2 -2
- package/dist/centerWiringCapability.js +2 -2
- package/dist/clockReading.d.ts +2 -0
- package/dist/clockReading.js +4 -0
- package/dist/cloudConfigWireCaps.d.ts +19 -5
- package/dist/cloudConfigWireCaps.js +193 -56
- package/dist/coreValuePorts.d.ts +12 -2
- package/dist/coreValuePorts.js +9 -0
- package/dist/decideFailureNote.js +5 -3
- package/dist/decideReceipt.js +2 -2
- package/dist/deviceExecutorManagementCapability.js +2 -2
- package/dist/deviceFlowPolling.js +1 -1
- package/dist/disableSkillsWire.d.ts +1 -1
- package/dist/disableSkillsWire.js +4 -3
- package/dist/displayUntrusted.d.ts +1 -0
- package/dist/displayUntrusted.js +65 -8
- package/dist/engineCapReader.js +1 -1
- package/dist/engineConfigDrift.js +1 -1
- package/dist/engineErrorCodes.d.ts +14 -5
- package/dist/engineErrorCodes.js +27 -6
- package/dist/engineGenerationConvergence.d.ts +39 -0
- package/dist/engineGenerationConvergence.js +95 -0
- package/dist/engineGenerationPort.d.ts +61 -0
- package/dist/engineGenerationPort.js +144 -0
- package/dist/engineHealthFacts.d.ts +23 -0
- package/dist/engineHealthFacts.js +92 -0
- package/dist/engineIdentity.d.ts +4 -0
- package/dist/engineIdentity.js +11 -0
- package/dist/engineNoticeCodes.d.ts +2 -5
- package/dist/engineRowRef.js +3 -0
- package/dist/engineSessionMessages.js +2 -2
- package/dist/engineToolDirectory.js +2 -2
- package/dist/engineWireFor.d.ts +99 -0
- package/dist/engineWireFor.js +248 -6
- package/dist/engineWireTarget.d.ts +1 -0
- package/dist/engineWireTarget.js +8 -0
- package/dist/env/uiLanguage.js +1 -1
- package/dist/errorSupplementRoles.d.ts +3 -0
- package/dist/errorSupplementRoles.js +37 -0
- package/dist/executionLaneCapability.js +2 -2
- package/dist/fileHistoryCaptureCapability.js +3 -3
- package/dist/finalVerifyWire.d.ts +6 -3
- package/dist/finalVerifyWire.js +6 -23
- package/dist/flagInput.d.ts +4 -0
- package/dist/flagInput.js +24 -0
- package/dist/fleet/fleetLedger.js +5 -2
- package/dist/fleet/fleetProjection.d.ts +1 -0
- package/dist/fleet/fleetProjection.js +15 -2
- package/dist/gateVocabulary.js +3 -0
- package/dist/generated/engineFactTables.d.ts +7 -3
- package/dist/generated/engineFactTables.js +52 -0
- package/dist/generated/engineNoticeTables.js +12 -0
- package/dist/generated/settingsSchemaActiveTiers.d.ts +1 -0
- package/dist/generated/settingsSchemaActiveTiers.js +14 -0
- package/dist/generated/settingsSchemaCallerTextEcho.d.ts +1 -0
- package/dist/generated/settingsSchemaCallerTextEcho.js +8 -0
- package/dist/generated/settingsSchemaControlAndBidi.d.ts +1 -0
- package/dist/generated/settingsSchemaControlAndBidi.js +8 -0
- package/dist/generated/settingsSchemaDefaultModel.d.ts +11 -0
- package/dist/generated/settingsSchemaDefaultModel.js +25 -0
- package/dist/generated/settingsSchemaFns.d.ts +54 -0
- package/dist/generated/settingsSchemaFns.js +26 -1
- package/dist/generated/settingsSchemaMcpRequestEntry.d.ts +1 -1
- package/dist/generated/settingsSchemaMcpRequestEntry.js +1 -7
- package/dist/generated/settingsSchemaSafetyMergeSpec.d.ts +1 -0
- package/dist/generated/settingsSchemaSafetyMergeSpec.js +95 -0
- package/dist/generated/settingsSchemaSettingsSources.d.ts +1 -0
- package/dist/generated/settingsSchemaSettingsSources.js +58 -0
- package/dist/generated/settingsSchemaTables.d.ts +2 -0
- package/dist/generated/settingsSchemaTables.js +13 -0
- package/dist/generated/settingsSchemaUrlPattern.d.ts +1 -0
- package/dist/generated/settingsSchemaUrlPattern.js +183 -0
- package/dist/headlessPermissionModeWire.d.ts +18 -2
- package/dist/headlessPermissionModeWire.js +30 -19
- package/dist/hitl/allowRuleShadow.js +7 -5
- package/dist/hitl/approvalCardReading.d.ts +3 -0
- package/dist/hitl/approvalCardReading.js +17 -0
- package/dist/hitl/approvalCompleteParked.js +1 -1
- package/dist/hitl/approvalDelivery.d.ts +87 -0
- package/dist/hitl/approvalDelivery.js +193 -0
- package/dist/hitl/approvalResolution.d.ts +11 -0
- package/dist/hitl/approvalResolution.js +50 -11
- package/dist/hitl/askClassPair.d.ts +6 -0
- package/dist/hitl/askClassPair.js +30 -3
- package/dist/hitl/askParkAutoReopenBlock.d.ts +30 -0
- package/dist/hitl/askParkAutoReopenBlock.js +117 -0
- package/dist/hitl/askParkRowRouting.js +4 -1
- package/dist/hitl/attributionLadder.d.ts +42 -3
- package/dist/hitl/attributionLadder.js +79 -8
- package/dist/hitl/automaticAnswerVerdict.d.ts +6 -1
- package/dist/hitl/automaticAnswerVerdict.js +46 -11
- package/dist/hitl/crashConverged.js +2 -2
- package/dist/hitl/decisionConflict.d.ts +6 -2
- package/dist/hitl/decisionConflict.js +24 -9
- package/dist/hitl/decisionRefusal.d.ts +20 -10
- package/dist/hitl/decisionRefusal.js +99 -54
- package/dist/hitl/decisionSend.d.ts +3 -0
- package/dist/hitl/decisionSend.js +87 -103
- package/dist/hitl/frameRouter.d.ts +1 -0
- package/dist/hitl/frameRouter.js +9 -2
- package/dist/hitl/hitlBridge.d.ts +18 -6
- package/dist/hitl/hitlBridge.js +41 -37
- package/dist/hitl/livePendingAsk.js +4 -3
- package/dist/hitl/noAllowCause.js +1 -1
- package/dist/hitl/parkResolver.js +3 -2
- package/dist/hitl/persistedRulesWire.js +1 -0
- package/dist/hitl/planReviewWire.d.ts +4 -0
- package/dist/hitl/planReviewWire.js +59 -30
- package/dist/hitl/resumeRunningCard.d.ts +3 -2
- package/dist/hitl/resumeRunningCard.js +17 -11
- package/dist/hitl/sessionPolicyDeliverable.d.ts +5 -2
- package/dist/hitl/sessionPolicyDeliverable.js +62 -29
- package/dist/hitl/sessionPolicyWire.d.ts +13 -3
- package/dist/hitl/sessionPolicyWire.js +81 -16
- package/dist/hitl/standingRows.js +1 -1
- package/dist/hitl/toolApprovalWire.d.ts +9 -10
- package/dist/hitl/toolApprovalWire.js +72 -54
- package/dist/hookMatcherVerdict.d.ts +2 -0
- package/dist/hookMatcherVerdict.js +12 -0
- package/dist/hooksCompactTransition.d.ts +19 -0
- package/dist/hooksCompactTransition.js +41 -0
- package/dist/hooksWireCaps.d.ts +1 -1
- package/dist/hooksWireCaps.js +202 -203
- package/dist/host.d.ts +1 -14
- package/dist/host.js +0 -8
- package/dist/hostCallbackGuard.d.ts +1 -0
- package/dist/hostCallbackGuard.js +1 -1
- package/dist/hostSettingsSource.d.ts +172 -0
- package/dist/hostSettingsSource.js +675 -0
- package/dist/hostTurnSettings.d.ts +73 -17
- package/dist/hostTurnSettings.js +594 -97
- package/dist/httpHookPolicy.d.ts +37 -0
- package/dist/httpHookPolicy.js +176 -0
- package/dist/humanTurn.d.ts +2 -1
- package/dist/humanTurn.js +37 -7
- package/dist/humanTurnRead.js +4 -3
- package/dist/humanTurnSentences.d.ts +10 -0
- package/dist/humanTurnSentences.js +74 -0
- package/dist/i18n/messages.en.d.ts +184 -2
- package/dist/i18n/messages.en.js +187 -5
- package/dist/i18n/messages.zh.js +197 -5
- package/dist/i18n/translate.js +3 -3
- package/dist/index.d.ts +69 -15
- package/dist/index.js +45 -13
- package/dist/inheritEnvCapability.d.ts +3 -1
- package/dist/inheritEnvCapability.js +31 -17
- package/dist/inheritEnvWire.d.ts +2 -1
- package/dist/inheritEnvWire.js +11 -5
- package/dist/interactiveToolsWire.d.ts +4 -2
- package/dist/interactiveToolsWire.js +5 -5
- package/dist/jsonFaithful.d.ts +20 -0
- package/dist/jsonFaithful.js +152 -0
- package/dist/limitsWire.d.ts +7 -2
- package/dist/limitsWire.js +19 -13
- package/dist/liveInitToolFace.d.ts +6 -1
- package/dist/liveInitToolFace.js +5 -3
- package/dist/liveModelCatalog.d.ts +22 -0
- package/dist/liveModelCatalog.js +132 -18
- package/dist/mcpPanel.js +1 -1
- package/dist/mcpProbeCapability.js +2 -2
- package/dist/mcpStatusSupersetKeys.d.ts +24 -0
- package/dist/mcpStatusSupersetKeys.js +45 -0
- package/dist/mcpToolToggles.js +2 -1
- package/dist/mcpWireCaps.d.ts +39 -1
- package/dist/mcpWireCaps.js +254 -50
- package/dist/memoryComplianceCapability.js +2 -2
- package/dist/memoryOriginCapability.js +2 -2
- package/dist/model/catalogDefault.d.ts +24 -0
- package/dist/model/catalogDefault.js +4 -0
- package/dist/model/liveCatalogShape.js +5 -4
- package/dist/model/modelsPolicy.js +4 -3
- package/dist/model/onboardJudgement.d.ts +1 -0
- package/dist/model/onboardJudgement.js +1 -1
- package/dist/model/subagentModelWord.js +2 -2
- package/dist/modelCapabilityProbe.js +6 -6
- package/dist/modelIdentityResolvability.d.ts +10 -1
- package/dist/modelIdentityResolvability.js +62 -39
- package/dist/modsKernelIdentity.d.ts +10 -0
- package/dist/modsKernelIdentity.js +103 -0
- package/dist/modsKernelTransit.d.ts +8 -0
- package/dist/modsKernelTransit.js +6 -0
- package/dist/notifications.d.ts +30 -12
- package/dist/notifications.js +241 -53
- package/dist/outputStyleSeatCapability.js +2 -2
- package/dist/ownKey.d.ts +11 -0
- package/dist/ownKey.js +164 -3
- package/dist/panelReduce.js +1 -1
- package/dist/peerFrames.d.ts +1 -1
- package/dist/peerFrames.js +6 -2
- package/dist/peerLaneCapability.js +2 -2
- package/dist/permissionModesCapability.js +4 -4
- package/dist/permissionRuleIssue.js +2 -0
- package/dist/permissionRulesWriteCapability.js +2 -2
- package/dist/permissionsAllowGrantCapability.js +2 -2
- package/dist/permissionsDeclaration.d.ts +43 -4
- package/dist/permissionsDeclaration.js +102 -35
- package/dist/pluginHooksWire.d.ts +20 -4
- package/dist/pluginHooksWire.js +92 -53
- package/dist/prepareRefusal.d.ts +3 -2
- package/dist/prepareRefusal.js +27 -9
- package/dist/printInitToolFace.js +2 -2
- package/dist/printModelStatus.js +1 -1
- package/dist/projectMemory.d.ts +32 -0
- package/dist/projectMemory.js +70 -0
- package/dist/promptBlockedCopy.d.ts +2 -1
- package/dist/promptBlockedCopy.js +2 -1
- package/dist/promptDelivery.d.ts +23 -3
- package/dist/promptDelivery.js +169 -30
- package/dist/providerRejection.d.ts +19 -1
- package/dist/providerRejection.js +75 -4
- package/dist/queuedDelivery.d.ts +48 -0
- package/dist/queuedDelivery.js +233 -0
- package/dist/reattachWindow.d.ts +94 -0
- package/dist/reattachWindow.js +127 -0
- package/dist/request/printNotification.d.ts +1 -1
- package/dist/request/printNotification.js +5 -1
- package/dist/request/submissionIdentity.d.ts +37 -0
- package/dist/request/submissionIdentity.js +65 -0
- package/dist/request/taskRequest.d.ts +12 -4
- package/dist/request/taskRequest.js +221 -152
- package/dist/resultFrameKeys.d.ts +1 -0
- package/dist/resultFrameKeys.js +4 -1
- package/dist/retryStatus.d.ts +8 -0
- package/dist/retryStatus.js +57 -9
- package/dist/rewindArchiveCapability.js +2 -2
- package/dist/rewindEngineAction.d.ts +2 -0
- package/dist/rewindEngineAction.js +23 -1
- package/dist/rowKind.d.ts +36 -0
- package/dist/rowKind.js +97 -0
- package/dist/ruleCompileVerdict.d.ts +18 -0
- package/dist/ruleCompileVerdict.js +67 -2
- package/dist/ruleReadings.d.ts +58 -0
- package/dist/ruleReadings.js +132 -0
- package/dist/ruleRefusalSentence.d.ts +4 -0
- package/dist/ruleRefusalSentence.js +9 -3
- package/dist/runCancelContext.d.ts +0 -1
- package/dist/runCancelContext.js +1 -2
- package/dist/runTerminal.d.ts +5 -0
- package/dist/runTerminal.js +52 -17
- package/dist/sandboxWire.d.ts +1 -1
- package/dist/sandboxWire.js +4 -6
- package/dist/scenarioRefusal.js +1 -1
- package/dist/scenarioSkills.d.ts +20 -0
- package/dist/scenarioSkills.js +72 -0
- package/dist/scenarioWire.d.ts +5 -2
- package/dist/scenarioWire.js +9 -9
- package/dist/sealedKeyCapability.js +2 -2
- package/dist/seam.d.ts +2 -0
- package/dist/seam.js +2 -2
- package/dist/seatContract.d.ts +46 -1
- package/dist/seatContract.js +49 -19
- package/dist/selfOrchestrationDenial.js +1 -1
- package/dist/sessionPolicyCapability.js +2 -2
- package/dist/sessionRulesChildrenReadLive.d.ts +6 -0
- package/dist/sessionRulesChildrenReadLive.js +5 -0
- package/dist/sessionRulesNamespaceFormsCapability.d.ts +12 -0
- package/dist/sessionRulesNamespaceFormsCapability.js +29 -0
- package/dist/sessionSyncFileHistoryCapability.js +2 -2
- package/dist/settingsCredentialKeyPaths.js +60 -5
- package/dist/settingsHooksSalvage.d.ts +1 -0
- package/dist/settingsHooksSalvage.js +7 -1
- package/dist/settingsLayerAdmission.d.ts +4 -0
- package/dist/settingsLayerAdmission.js +16 -0
- package/dist/skillToolListsCapability.js +6 -5
- package/dist/skillsWireCaps.d.ts +14 -0
- package/dist/skillsWireCaps.js +47 -16
- package/dist/slashCommandGate.d.ts +24 -0
- package/dist/slashCommandGate.js +74 -0
- package/dist/slashCommandTable.d.ts +14 -0
- package/dist/slashCommandTable.js +99 -0
- package/dist/sqlEngineCapability.js +2 -2
- package/dist/steerPriorityCapability.js +2 -2
- package/dist/storePostureCapability.js +2 -2
- package/dist/subagent/agentStateDetail.js +1 -1
- package/dist/subagent/engineDelegatedPrompt.d.ts +9 -0
- package/dist/subagent/engineDelegatedPrompt.js +38 -7
- package/dist/subagent/engineRowStopGate.js +2 -2
- package/dist/subagent/engineSubagentResume.js +3 -3
- package/dist/subagent/engineTaskHandleWire.d.ts +1 -0
- package/dist/subagent/engineTaskHandleWire.js +10 -0
- package/dist/submitFailure.d.ts +8 -0
- package/dist/submitFailure.js +17 -0
- package/dist/supportFloor.d.ts +1 -0
- package/dist/supportFloor.js +7 -0
- package/dist/terminationIntent.d.ts +55 -0
- package/dist/terminationIntent.js +352 -0
- package/dist/toolHistoryMismatch.d.ts +8 -0
- package/dist/toolHistoryMismatch.js +37 -6
- package/dist/toolResult.d.ts +13 -3
- package/dist/toolResult.js +158 -9
- package/dist/toolResultContent.d.ts +13 -0
- package/dist/toolResultContent.js +82 -7
- package/dist/toolRoster.d.ts +18 -0
- package/dist/toolRoster.js +64 -0
- package/dist/turnFailurePresentation.js +27 -90
- package/dist/usageLimitAutoResume.d.ts +74 -0
- package/dist/usageLimitAutoResume.js +227 -0
- package/dist/userAttachmentEnvelope.js +1 -1
- package/dist/userAttachmentSeat.js +5 -5
- package/dist/userInvokedSkillsCapability.js +2 -2
- package/dist/webSearchBackendCapability.js +2 -2
- package/dist/wireErrorTriage.js +99 -50
- package/dist/wireFailureShape.d.ts +25 -1
- package/dist/wireFailureShape.js +92 -5
- package/dist/wireRefusalCopy.d.ts +24 -1
- package/dist/wireRefusalCopy.js +253 -32
- package/dist/wiringFleetDoctor.d.ts +3 -0
- package/dist/wiringFleetDoctor.js +21 -0
- package/dist/workflow.d.ts +2 -1
- package/dist/workflow.js +38 -1
- package/dist/workflowClient.d.ts +2 -7
- package/dist/workflowsJournalCapability.js +2 -2
- package/dist/writeProtectionCapability.js +2 -2
- package/docs/INTEGRATION-CLIENTS.md +607 -181
- package/package.json +14 -3
package/dist/adapt/arms.js
CHANGED
|
@@ -2,7 +2,7 @@ import { ccToolDenialKindForToolEnd, gateOutcomeOf } from '../gateOutcome.js';
|
|
|
2
2
|
import { terminalOwnerOf } from '../seam.js';
|
|
3
3
|
import { isSubFlowSegmentEnd, SEGMENT_END_IDENTITY_KEYS, snapshotSegmentIdentity, snapshotIsSubFlow } from '../adapter/types.js';
|
|
4
4
|
import { classifyPeerNotification, renderPeerFrameTranscriptText } from '../peerFrames.js';
|
|
5
|
-
import { dropQueuedNotificationsForRun, isEngineWorkflowNotified, isWorkflowCompletionCardEnqueued, markEngineWorkflowNotified, noteOwnWorkflowRun, normalizeTaskNotification, noteWorkflowCompletionCardEnqueued, renderTaskNotificationXml, taskNotificationDedupKey } from '../notifications.js';
|
|
5
|
+
import { dropQueuedNotificationsForRun, freezeTaskNotificationFields, isEngineWorkflowNotified, isWorkflowCompletionCardEnqueued, markEngineWorkflowNotified, noteOwnWorkflowRun, normalizeTaskNotification, noteWorkflowCompletionCardEnqueued, renderTaskNotificationXml, taskNotificationDedupKey } from '../notifications.js';
|
|
6
6
|
import { retryStatusFromArm } from '../retryStatus.js';
|
|
7
7
|
import { steeringInjectedToAttachments } from '../steering.js';
|
|
8
8
|
import { projectDiagnosticsFrame } from '../diagnostics.js';
|
|
@@ -12,13 +12,15 @@ import { readAsyncLaunchedAgentReceipt } from '../toolResult.js';
|
|
|
12
12
|
import { recordWorkflowAgentTaskId } from '../workflow.js';
|
|
13
13
|
import { isCoreTaskNotificationTerminal, isCoreTaskNotificationTerminalNotSuccess, isCoreTaskProgressTerminal, isCoreTaskProgressTerminalNotSuccess } from '../terminalStatuses.js';
|
|
14
14
|
import { readToolHistoryMismatchKey } from '../toolHistoryMismatch.js';
|
|
15
|
-
import { readProviderRejectionResendKey } from '../providerRejection.js';
|
|
16
|
-
import {
|
|
15
|
+
import { isMintedRowCcError, readProviderRejectionResendKey } from '../providerRejection.js';
|
|
16
|
+
import { rowKindOf } from '../rowKind.js';
|
|
17
|
+
import { terminalCodedDetailOf } from '../runTerminal.js';
|
|
18
|
+
import { contextUsageReadingOf, guardedRead, humanInputAttachmentsOf, ownSnapshotRecord, ownSnapshotWhenTyped, readOwnDataValue, promptManifestIdentityOfFrame, promptManifestSectionViewOf, readFrameStringKey, readFrameTrueMark } from '../ownKey.js';
|
|
17
19
|
import { CORE_USER_ATTACHMENT_LABEL_MAX } from '../generated/engineFactTables.js';
|
|
18
20
|
import { ESCAPE_FACE, paintAndCap, washCredentials } from '../displayUntrusted.js';
|
|
19
21
|
import { resolveEnginePanelTaskId } from '../engineAgentPanelStore.js';
|
|
20
22
|
import { cycleSeqValue } from '../cycleOrder.js';
|
|
21
|
-
import { fleetRowAgentType } from '../fleet/fleetRowAgentType.js';
|
|
23
|
+
import { fleetRowAgentType, recordFleetRowAgentType } from '../fleet/fleetRowAgentType.js';
|
|
22
24
|
import { chrome, mainLane, transcript, messageIdentityOf } from './ids.js';
|
|
23
25
|
import { engineRefOf } from '../engineRowRef.js';
|
|
24
26
|
import { isReplayMarked, RESULT_REPLAYED_TEXT } from '../replayBody.js';
|
|
@@ -50,21 +52,42 @@ function claimParkedCard(m, callId, toolName, deps) {
|
|
|
50
52
|
function laneOfCard(p) {
|
|
51
53
|
return p.parentToolCallId !== undefined && p.parentToolCallId !== '' ? { lane: 'subagent', parentToolCallId: p.parentToolCallId } : mainLane();
|
|
52
54
|
}
|
|
55
|
+
function isMintedSyntheticRow(m) {
|
|
56
|
+
return readFrameTrueMark(m, '_sema_api_error_message');
|
|
57
|
+
}
|
|
53
58
|
function terminalOwnerCarry(m) {
|
|
54
|
-
if (m
|
|
59
|
+
if (!isMintedSyntheticRow(m))
|
|
55
60
|
return {};
|
|
56
61
|
const owner = terminalOwnerOf(m);
|
|
57
62
|
return owner === undefined ? {} : { _sema_terminal_owner: owner };
|
|
58
63
|
}
|
|
64
|
+
function rowKindCarry(m) {
|
|
65
|
+
if (!isMintedSyntheticRow(m))
|
|
66
|
+
return {};
|
|
67
|
+
const kind = rowKindOf(m);
|
|
68
|
+
const code = readFrameStringKey(m, '_sema_api_error_code');
|
|
69
|
+
const err = guardedRead(() => readOwnDataValue(m, 'error'));
|
|
70
|
+
return {
|
|
71
|
+
...(kind !== undefined ? { _sema_row_kind: kind } : {}),
|
|
72
|
+
...(code !== undefined ? { _sema_api_error_code: code } : {}),
|
|
73
|
+
...(isMintedRowCcError(err) ? { error: err } : {}),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function codedDetailCarry(m, relayedRowKind) {
|
|
77
|
+
if (!isMintedSyntheticRow(m) || relayedRowKind !== 'api_error')
|
|
78
|
+
return {};
|
|
79
|
+
const body = terminalCodedDetailOf(m);
|
|
80
|
+
return body === undefined ? {} : { _sema_coded_detail: body };
|
|
81
|
+
}
|
|
59
82
|
function toolHistoryKeyCarry(m) {
|
|
60
|
-
if (m
|
|
83
|
+
if (!isMintedSyntheticRow(m))
|
|
61
84
|
return {};
|
|
62
85
|
const raw = m._sema_tool_history_mismatch;
|
|
63
86
|
const key = readToolHistoryMismatchKey(typeof raw === 'object' && raw !== null ? raw : undefined);
|
|
64
87
|
return key === undefined ? {} : { _sema_tool_history_mismatch: key };
|
|
65
88
|
}
|
|
66
89
|
function providerResendKeyCarry(m) {
|
|
67
|
-
if (m
|
|
90
|
+
if (!isMintedSyntheticRow(m))
|
|
68
91
|
return {};
|
|
69
92
|
const raw = m._sema_provider_rejection_resend;
|
|
70
93
|
const key = readProviderRejectionResendKey(typeof raw === 'object' && raw !== null ? raw : undefined);
|
|
@@ -178,7 +201,8 @@ const assistantArm = function* (m, deps) {
|
|
|
178
201
|
if (textBlock && typeof textBlock.text === 'string' && textBlock.text.length > 0)
|
|
179
202
|
text.anchorWindow(m);
|
|
180
203
|
if (textBlock && typeof textBlock.text === 'string' && textBlock.text.length > 0) {
|
|
181
|
-
const rowText = m
|
|
204
|
+
const rowText = isMintedSyntheticRow(m) ? washCredentials(textBlock.text) : textBlock.text;
|
|
205
|
+
const relayedKind = rowKindCarry(m);
|
|
182
206
|
text.appendAnswer(rowText);
|
|
183
207
|
text.beginAssistantMessage();
|
|
184
208
|
yield* text.takeThinking();
|
|
@@ -188,10 +212,12 @@ const assistantArm = function* (m, deps) {
|
|
|
188
212
|
uuid: idOf(m),
|
|
189
213
|
session_id: ctx.sessionId,
|
|
190
214
|
parent_tool_use_id: null,
|
|
191
|
-
...(m
|
|
215
|
+
...(isMintedSyntheticRow(m) ? { _sema_api_error_message: true } : {}),
|
|
192
216
|
...toolHistoryKeyCarry(m),
|
|
193
217
|
...providerResendKeyCarry(m),
|
|
194
218
|
...terminalOwnerCarry(m),
|
|
219
|
+
...relayedKind,
|
|
220
|
+
...codedDetailCarry(m, relayedKind._sema_row_kind),
|
|
195
221
|
}, ctx.now());
|
|
196
222
|
text.markEmittedText(rowText);
|
|
197
223
|
}
|
|
@@ -507,6 +533,8 @@ const taskStartedArm = function* (m) {
|
|
|
507
533
|
const agentType = str(m.agentType);
|
|
508
534
|
const startedAt = num(m.startedAt);
|
|
509
535
|
const eventId = str(idSnap.eventId);
|
|
536
|
+
if (agentType !== undefined && workflowRunId === undefined)
|
|
537
|
+
recordFleetRowAgentType(taskId, agentType);
|
|
510
538
|
yield chrome({
|
|
511
539
|
kind: 'subagent_started',
|
|
512
540
|
laneProof,
|
|
@@ -639,8 +667,9 @@ const toolEndResultArm = function* (m, deps) {
|
|
|
639
667
|
const { idOf, cards, panel, ctx, inst, pass } = deps;
|
|
640
668
|
const callId = typeof m.toolCallId === 'string' ? m.toolCallId : undefined;
|
|
641
669
|
recordEngineToolLabel(callId, m.label);
|
|
670
|
+
const structured = ownSnapshotWhenTyped(m.structured, 'task-output');
|
|
642
671
|
if (callId !== undefined) {
|
|
643
|
-
const launched = readAsyncLaunchedAgentReceipt(
|
|
672
|
+
const launched = readAsyncLaunchedAgentReceipt(structured);
|
|
644
673
|
if (launched !== null)
|
|
645
674
|
registerSubagentContentAlias(callId, launched.taskId);
|
|
646
675
|
}
|
|
@@ -665,7 +694,6 @@ const toolEndResultArm = function* (m, deps) {
|
|
|
665
694
|
}
|
|
666
695
|
if (p === undefined || callId === undefined)
|
|
667
696
|
return;
|
|
668
|
-
const structured = m.structured;
|
|
669
697
|
const closeEventIdRaw = m.eventId;
|
|
670
698
|
const closeParentRaw = m.parentToolCallId;
|
|
671
699
|
const closeEventId = typeof closeEventIdRaw === 'string' ? closeEventIdRaw : undefined;
|
|
@@ -781,7 +809,7 @@ const taskProgressArm = function* (m, { ctx, cards, panel, inst }) {
|
|
|
781
809
|
: undefined;
|
|
782
810
|
const identity = resolveEnginePanelTaskId(taskId);
|
|
783
811
|
if (!panel.isLive(taskId)) {
|
|
784
|
-
yield* panel.start(taskId, fleetRowAgentType(identity.taskId));
|
|
812
|
+
yield* panel.start(taskId, fleetRowAgentType(taskId) ?? fleetRowAgentType(identity.taskId));
|
|
785
813
|
}
|
|
786
814
|
panel.noteResidency(taskId, identity.taskId);
|
|
787
815
|
panel.markLive(taskId);
|
|
@@ -914,7 +942,7 @@ const resultArm = function* (m, { ctx, idOf, text, cards, panel, flags }) {
|
|
|
914
942
|
yield chrome({ kind: 'result_replayed', laneProof: mainLane(), text: RESULT_REPLAYED_TEXT });
|
|
915
943
|
};
|
|
916
944
|
const taskNotificationArm = function* (m, { ctx, idOf, panel, inst }) {
|
|
917
|
-
const n = (m
|
|
945
|
+
const n = ownSnapshotRecord(guardedRead(() => readOwnDataValue(m, 'notification'))) ?? {};
|
|
918
946
|
const fields = normalizeTaskNotification(n);
|
|
919
947
|
if (fields === null)
|
|
920
948
|
return;
|
|
@@ -961,6 +989,7 @@ const taskNotificationArm = function* (m, { ctx, idOf, panel, inst }) {
|
|
|
961
989
|
return;
|
|
962
990
|
if (peerFrame === null && n.task_type !== 'external')
|
|
963
991
|
markEngineWorkflowNotified(taskId);
|
|
992
|
+
const fact = peerFrame === null ? freezeTaskNotificationFields(fields) : undefined;
|
|
964
993
|
yield transcript({
|
|
965
994
|
type: 'user',
|
|
966
995
|
message: {
|
|
@@ -968,15 +997,19 @@ const taskNotificationArm = function* (m, { ctx, idOf, panel, inst }) {
|
|
|
968
997
|
content: [
|
|
969
998
|
{
|
|
970
999
|
type: 'text',
|
|
971
|
-
text: peerFrame !== null ? renderPeerFrameTranscriptText(peerFrame) : renderTaskNotificationXml(fields),
|
|
1000
|
+
text: peerFrame !== null ? renderPeerFrameTranscriptText(peerFrame) : renderTaskNotificationXml(fact ?? fields),
|
|
972
1001
|
},
|
|
973
1002
|
],
|
|
974
1003
|
},
|
|
975
1004
|
uuid: idOf(m),
|
|
976
1005
|
session_id: ctx.sessionId,
|
|
1006
|
+
...(fact !== undefined ? { _sema_task_notification: fact } : {}),
|
|
977
1007
|
}, ctx.now());
|
|
978
1008
|
};
|
|
979
|
-
const workflowCompleteArm = function* (
|
|
1009
|
+
const workflowCompleteArm = function* (frame) {
|
|
1010
|
+
const m = ownSnapshotRecord(frame);
|
|
1011
|
+
if (m === undefined)
|
|
1012
|
+
return;
|
|
980
1013
|
const runId = typeof m.runId === 'string' ? m.runId : undefined;
|
|
981
1014
|
if (runId === undefined)
|
|
982
1015
|
return;
|
|
@@ -986,13 +1019,15 @@ const workflowCompleteArm = function* (m) {
|
|
|
986
1019
|
const wfStatus = m.status === 'failed' ? 'failed' : 'completed';
|
|
987
1020
|
const wfSummary = typeof m.summary === 'string' ? m.summary : '';
|
|
988
1021
|
noteWorkflowCompletionCardEnqueued(runId);
|
|
1022
|
+
const notification = freezeTaskNotificationFields({ taskId: runId, taskType: 'workflow', status: wfStatus, summary: wfSummary });
|
|
989
1023
|
yield chrome({
|
|
990
1024
|
kind: 'workflow_notification_enqueue',
|
|
991
1025
|
laneProof: mainLane(),
|
|
992
1026
|
runId,
|
|
993
1027
|
status: wfStatus,
|
|
994
1028
|
summary: wfSummary,
|
|
995
|
-
message: renderTaskNotificationXml(
|
|
1029
|
+
message: renderTaskNotificationXml(notification),
|
|
1030
|
+
notification,
|
|
996
1031
|
});
|
|
997
1032
|
};
|
|
998
1033
|
const retryStatusArm = function* (m, { ctx, flags }) {
|
package/dist/adapt/textStream.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { chrome, mainLane, segmentRowId, transcript, messageIdentityOf } from './ids.js';
|
|
2
2
|
import { estimateCjkTokens, FLUSH_INTERVAL_MS } from './wireShapes.js';
|
|
3
3
|
import { resolveTextSegmentAuthority } from './textSegmentAuthority.js';
|
|
4
|
+
import { carriesAnswerText } from '../ownKey.js';
|
|
4
5
|
export const SEMA_SEGMENT_ID_KEY = '_sema_segment_id';
|
|
5
6
|
const SENTENCE_END_CHARS = new Set(['。', '!', '?', '…', '.', '!', '?']);
|
|
6
7
|
const SENTENCE_CLOSING_CHARS = new Set([
|
|
@@ -167,6 +168,8 @@ export function createTextStream(ctx, idOf) {
|
|
|
167
168
|
}
|
|
168
169
|
return {
|
|
169
170
|
*feedText(delta, frame) {
|
|
171
|
+
if (delta.length === 0 && segmentWindowCloseArmed && previousSegmentCommitted + segmentCommitted !== '')
|
|
172
|
+
return;
|
|
170
173
|
consumeArmedClose();
|
|
171
174
|
if (thinking.length > 0 || thinkingPending.length > 0) {
|
|
172
175
|
yield* drainLive();
|
|
@@ -251,11 +254,11 @@ export function createTextStream(ctx, idOf) {
|
|
|
251
254
|
committedText = txt;
|
|
252
255
|
currentTouched = true;
|
|
253
256
|
}
|
|
254
|
-
if (txt
|
|
257
|
+
if (carriesAnswerText(txt))
|
|
255
258
|
lastNonEmpty = txt;
|
|
256
259
|
}
|
|
257
260
|
if (!currentTouched && committedText.length > 0) { }
|
|
258
|
-
if (committedText
|
|
261
|
+
if (!carriesAnswerText(committedText) && lastNonEmpty.length > 0)
|
|
259
262
|
previousCommittedText = lastNonEmpty;
|
|
260
263
|
booksSynced = true;
|
|
261
264
|
}
|
|
@@ -413,7 +416,7 @@ export function createTextStream(ctx, idOf) {
|
|
|
413
416
|
},
|
|
414
417
|
beginAssistantMessage: () => {
|
|
415
418
|
messageSerial += 1;
|
|
416
|
-
if (committedText
|
|
419
|
+
if (carriesAnswerText(committedText))
|
|
417
420
|
previousCommittedText = committedText;
|
|
418
421
|
committedText = '';
|
|
419
422
|
previousSegmentCommitted += segmentCommitted;
|
|
@@ -426,7 +429,7 @@ export function createTextStream(ctx, idOf) {
|
|
|
426
429
|
return committedText;
|
|
427
430
|
},
|
|
428
431
|
get lastCommittedAnswerText() {
|
|
429
|
-
return committedText
|
|
432
|
+
return carriesAnswerText(committedText) ? committedText : previousCommittedText;
|
|
430
433
|
},
|
|
431
434
|
get emittedAssistantText() {
|
|
432
435
|
return emittedAssistantText;
|
package/dist/adapt/toolCards.js
CHANGED
|
@@ -5,7 +5,7 @@ import { flattenWireOutput } from './wireShapes.js';
|
|
|
5
5
|
import { toolResultBlocksOf } from '../toolResultContent.js';
|
|
6
6
|
import { bashExitOf, bashExitReadingFailed } from '../bashExitReading.js';
|
|
7
7
|
import { isCcToolDenialKind } from '../gateVocabulary.js';
|
|
8
|
-
import { guardedRead, readFrameStringKey, readFrameTrueMark } from '../ownKey.js';
|
|
8
|
+
import { guardedRead, ownSnapshotWhenTyped, readFrameStringKey, readFrameTrueMark } from '../ownKey.js';
|
|
9
9
|
import { gateOutcomeOf, isApprovalWindowExpiredGate, isDenialLimitAutoDeniedGate } from '../gateOutcome.js';
|
|
10
10
|
import { TOOL_END_INTERRUPTED_NEVER_STARTED } from '../engineErrorCodes.js';
|
|
11
11
|
function toolUseResultParts(v) {
|
|
@@ -14,18 +14,19 @@ function toolUseResultParts(v) {
|
|
|
14
14
|
export function toolResultOutcomeOf(toolName, end, rawInput, owner, ledgerTier, killCauseOf) {
|
|
15
15
|
const isError = end?.isError ?? false;
|
|
16
16
|
const leaderLedger = owner === 'leader';
|
|
17
|
+
const structured = ownSnapshotWhenTyped(end?.structured, 'task-output');
|
|
17
18
|
const body = end && end.output !== undefined
|
|
18
|
-
? wireOutputToBody(toolName, end.output, isError, end.truncated === true, flattenWireOutput,
|
|
19
|
+
? wireOutputToBody(toolName, end.output, isError, end.truncated === true, flattenWireOutput, structured, leaderLedger, killCauseOf)
|
|
19
20
|
: degradedToolResultBody(isError);
|
|
20
|
-
let rich =
|
|
21
|
-
? structuredToToolUseResult(
|
|
21
|
+
let rich = structured !== undefined
|
|
22
|
+
? structuredToToolUseResult(structured, end?.output !== undefined ? flattenWireOutput(end.output) : undefined, leaderLedger)
|
|
22
23
|
: null;
|
|
23
24
|
if (rich === null && ledgerTier !== undefined)
|
|
24
25
|
rich = ledgerTier(isError);
|
|
25
26
|
if (rich === null && !isError && toolName === 'ReportFindings') {
|
|
26
|
-
rich = reportFindingsToolUseResult(
|
|
27
|
+
rich = reportFindingsToolUseResult(structured, rawInput);
|
|
27
28
|
}
|
|
28
|
-
const failed = body.isError || rich?.isError === true || bashExitReadingFailed(bashExitOf(
|
|
29
|
+
const failed = body.isError || rich?.isError === true || bashExitReadingFailed(bashExitOf(structured, () => null));
|
|
29
30
|
const settled = failed && !body.isError ? { ...body, isError: true } : body;
|
|
30
31
|
return { body: withContentBlocks(settled, end), rich };
|
|
31
32
|
}
|
|
@@ -73,8 +74,8 @@ export function createToolCardLedger(ctx, idOf) {
|
|
|
73
74
|
const parentToolCallId = end?.parentToolCallId ?? p.parentToolCallId;
|
|
74
75
|
if ((p.name === 'Bash' || p.name === 'Monitor') && !isError) {
|
|
75
76
|
const outputText = end?.output !== undefined ? flattenWireOutput(end.output) : undefined;
|
|
76
|
-
const reg = detectEngineBgShellDetach(p.name, p.rawInput, end?.structured, outputText) ??
|
|
77
|
-
detectEngineBgShellReceipt(p.name, p.rawInput, outputText, end?.structured);
|
|
77
|
+
const reg = detectEngineBgShellDetach(p.name, p.rawInput, end?.structured, outputText, p.id) ??
|
|
78
|
+
detectEngineBgShellReceipt(p.name, p.rawInput, outputText, end?.structured, p.id);
|
|
78
79
|
if (reg !== null) {
|
|
79
80
|
yield chrome({ kind: 'bgshell_register', laneProof: parentToolCallId === undefined ? mainLane() : { lane: 'subagent', parentToolCallId }, taskId: reg.taskId, registration: reg });
|
|
80
81
|
}
|
package/dist/adapt.js
CHANGED
|
@@ -8,6 +8,7 @@ import { createPanelTaskLedger } from './adapt/panelTasks.js';
|
|
|
8
8
|
import { createAdapterInstanceLedger } from './adapt/instanceLedger.js';
|
|
9
9
|
import { createTurnFlags } from './adapt/turnFlags.js';
|
|
10
10
|
import { ARMS } from './adapt/arms.js';
|
|
11
|
+
import { guardedRead, ownSnapshotTyped, readOwnDataNonEmptyString } from './ownKey.js';
|
|
11
12
|
export const ADAPTER_COVERAGE = {
|
|
12
13
|
frames: [
|
|
13
14
|
'assistant',
|
|
@@ -221,9 +222,14 @@ class WireToCcAdapterImpl {
|
|
|
221
222
|
const rawFrame = step.value;
|
|
222
223
|
if (ctx.signal?.aborted)
|
|
223
224
|
break;
|
|
224
|
-
|
|
225
|
+
let m = rawFrame;
|
|
225
226
|
if (m === null || typeof m !== 'object')
|
|
226
227
|
continue;
|
|
228
|
+
{
|
|
229
|
+
const noticeWord = guardedRead(() => readOwnDataNonEmptyString(m, 'type'));
|
|
230
|
+
if (noticeWord === 'task_notification' || noticeWord === 'workflow_complete')
|
|
231
|
+
m = ownSnapshotTyped(m) ?? {};
|
|
232
|
+
}
|
|
227
233
|
yield* flags.onFrameBeforeDispatch(m);
|
|
228
234
|
if (m.type !== 'stream_event')
|
|
229
235
|
yield* text.drainLive();
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { UiLanguage } from '../env/uiLanguage.js';
|
|
2
2
|
import type { ActiveRunBusySignal } from './runStream.js';
|
|
3
|
+
import type { RejectedSubmissionOrigin } from '../request/submissionIdentity.js';
|
|
3
4
|
import type { PlanReviewReopenTrigger } from '../hitl/planReviewWire.js';
|
|
5
|
+
import { type AskParkAutoReopenBlock } from '../hitl/askParkAutoReopenBlock.js';
|
|
4
6
|
import { atMostOnceFailureClass } from '../atMostOnce.js';
|
|
5
7
|
export declare const PLAN_REVIEW_GATE_KIND = "plan_review";
|
|
6
8
|
export type DurableDecideLeg = 'approval' | 'plan_review' | 'other_gate' | 'unreadable' | 'absent';
|
|
@@ -41,6 +43,7 @@ export type ReopenCardVerdict = {
|
|
|
41
43
|
_sema_noPresentationSurface?: true;
|
|
42
44
|
_sema_errorCode?: string;
|
|
43
45
|
_sema_reopenRefusal?: PlanReviewReopenRefusal;
|
|
46
|
+
_sema_policyBlocked?: AskParkAutoReopenBlock;
|
|
44
47
|
} | {
|
|
45
48
|
reopened: true;
|
|
46
49
|
firstSight: boolean;
|
|
@@ -60,6 +63,11 @@ export interface StaleParkChoiceRequest {
|
|
|
60
63
|
status: string;
|
|
61
64
|
canCancel: boolean;
|
|
62
65
|
}
|
|
66
|
+
export interface InterruptedSettleWindow {
|
|
67
|
+
budgetMs?: number;
|
|
68
|
+
intervalMs?: number;
|
|
69
|
+
now?: () => number;
|
|
70
|
+
}
|
|
63
71
|
export interface ActiveRunSelfHealDeps {
|
|
64
72
|
hasPendingDecision?: () => boolean;
|
|
65
73
|
listOwnedPendingApprovals?: (opts?: {
|
|
@@ -68,7 +76,9 @@ export interface ActiveRunSelfHealDeps {
|
|
|
68
76
|
reopenPlanReview?: (taskId: string, opts?: {
|
|
69
77
|
trigger?: PlanReviewReopenTrigger;
|
|
70
78
|
}) => ReopenCardVerdict | Promise<ReopenCardVerdict>;
|
|
71
|
-
reopenAskPark?: (taskId: string
|
|
79
|
+
reopenAskPark?: (taskId: string, opts?: {
|
|
80
|
+
trigger?: PlanReviewReopenTrigger;
|
|
81
|
+
}) => Promise<ReopenCardVerdict>;
|
|
72
82
|
offerRunningChoice?: (req: RunningChoiceRequest) => Promise<'steer' | 'cancel' | 'wait' | 'attach'>;
|
|
73
83
|
canAttachRunning?: boolean;
|
|
74
84
|
offerStaleParkChoice?: (req: StaleParkChoiceRequest) => Promise<'cancel' | 'wait'>;
|
|
@@ -77,6 +87,8 @@ export interface ActiveRunSelfHealDeps {
|
|
|
77
87
|
cancelReleaseWaitMs?: number;
|
|
78
88
|
submissionOrigin?: RejectedSubmissionOrigin;
|
|
79
89
|
sessionId?: string;
|
|
90
|
+
wasRecentlyTerminatedByUs?: (taskId: string) => boolean;
|
|
91
|
+
interruptedSettle?: InterruptedSettleWindow;
|
|
80
92
|
}
|
|
81
93
|
export type SelfHealOutcome = {
|
|
82
94
|
kind: 'ask-reopened';
|
|
@@ -98,6 +110,7 @@ export type SelfHealOutcome = {
|
|
|
98
110
|
dismissedByUser?: true;
|
|
99
111
|
noPresentationSurface?: true;
|
|
100
112
|
errorCode?: string;
|
|
113
|
+
reopenRefusal?: PlanReviewReopenRefusal;
|
|
101
114
|
} | {
|
|
102
115
|
kind: 'not-parked';
|
|
103
116
|
taskId: string;
|
|
@@ -111,6 +124,14 @@ export type SelfHealOutcome = {
|
|
|
111
124
|
kind: 'running-settled';
|
|
112
125
|
taskId: string;
|
|
113
126
|
status: string;
|
|
127
|
+
} | {
|
|
128
|
+
kind: 'interrupted-settled';
|
|
129
|
+
taskId: string;
|
|
130
|
+
status: string;
|
|
131
|
+
} | {
|
|
132
|
+
kind: 'interrupted-still-finishing';
|
|
133
|
+
taskId: string;
|
|
134
|
+
waitedMs: number;
|
|
114
135
|
} | {
|
|
115
136
|
kind: 'state-unknown';
|
|
116
137
|
taskId: string | null;
|
|
@@ -123,6 +144,7 @@ export type SelfHealOutcome = {
|
|
|
123
144
|
pendingRowGone?: true;
|
|
124
145
|
noPresentationSurface?: true;
|
|
125
146
|
errorCode?: string;
|
|
147
|
+
policyBlocked?: AskParkAutoReopenBlock;
|
|
126
148
|
} | {
|
|
127
149
|
kind: 'ask-decided-without-card';
|
|
128
150
|
taskId: string;
|
|
@@ -191,7 +213,7 @@ export type SelfHealOutcome = {
|
|
|
191
213
|
status: string;
|
|
192
214
|
alreadyOffered?: true;
|
|
193
215
|
};
|
|
194
|
-
export type RejectedSubmissionOrigin
|
|
216
|
+
export type { RejectedSubmissionOrigin };
|
|
195
217
|
export type SelfHealSubmissionDisposition = 'held-for-decision' | 'resending' | 'handed-off' | 'not-delivered';
|
|
196
218
|
export declare function selfHealSubmissionDisposition(outcome: SelfHealOutcome): SelfHealSubmissionDisposition;
|
|
197
219
|
export type SteerFollowIntent = {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { abortableSleep } from '../abortableSleep.js';
|
|
2
2
|
import { EN_MESSAGES } from '../i18n/messages.en.js';
|
|
3
3
|
import { msg, renderMessage } from '../i18n/translate.js';
|
|
4
|
+
import { ASK_PARK_AUTO_REOPEN_BLOCKS, askParkAutoReopenBlockedContent } from '../hitl/askParkAutoReopenBlock.js';
|
|
4
5
|
import { corruptStoredRowContent, corruptStoredRowWhere, effectiveWireErrorCode } from '../wireErrorTriage.js';
|
|
5
6
|
import { readThrownStatusSlot } from '../wireFailureShape.js';
|
|
6
7
|
import { steerBodyOf, UNOBSERVED_STEER_PRIORITY } from '../controlRouter.js';
|
|
@@ -8,6 +9,7 @@ import { atMostOnceFailureClass } from '../atMostOnce.js';
|
|
|
8
9
|
import { readSteerReceipt } from '../steerReceipt.js';
|
|
9
10
|
import { resumeAttachReplayDisclosure, runningAttachOffered } from '../hitl/resumeRunningCard.js';
|
|
10
11
|
import { isSdkRunParked, isSdkRunTerminal, SDK_RUN_LIVE_STATUSES } from '../terminalStatuses.js';
|
|
12
|
+
import { awaitInterruptedRunSettle, interruptedRunSettleRow } from '../terminationIntent.js';
|
|
11
13
|
import { SDK_APPROVAL_DECIDE_GATE_KINDS, SDK_PLAN_REVIEW_GATE_KINDS } from '../generated/sdkFactTables.js';
|
|
12
14
|
export const PLAN_REVIEW_GATE_KIND = 'plan_review';
|
|
13
15
|
const APPROVAL_LEG_GATE_KINDS = SDK_APPROVAL_DECIDE_GATE_KINDS;
|
|
@@ -60,6 +62,10 @@ export function selfHealSubmissionDisposition(outcome) {
|
|
|
60
62
|
return 'not-delivered';
|
|
61
63
|
case 'running-steered':
|
|
62
64
|
return 'handed-off';
|
|
65
|
+
case 'interrupted-settled':
|
|
66
|
+
return 'resending';
|
|
67
|
+
case 'interrupted-still-finishing':
|
|
68
|
+
return 'not-delivered';
|
|
63
69
|
case 'running-attach':
|
|
64
70
|
return 'not-delivered';
|
|
65
71
|
default:
|
|
@@ -136,6 +142,8 @@ const REOPEN_VERDICT_KEYS = [
|
|
|
136
142
|
'dismissedByUser',
|
|
137
143
|
'_sema_noPresentationSurface',
|
|
138
144
|
'_sema_errorCode',
|
|
145
|
+
'_sema_reopenRefusal',
|
|
146
|
+
'_sema_policyBlocked',
|
|
139
147
|
];
|
|
140
148
|
function snapshotReopenVerdict(raw) {
|
|
141
149
|
if (raw === null || raw === undefined)
|
|
@@ -238,6 +246,28 @@ function reopenErrorCodeOf(verdict) {
|
|
|
238
246
|
return undefined;
|
|
239
247
|
}
|
|
240
248
|
}
|
|
249
|
+
function reopenPolicyBlockedOf(verdict) {
|
|
250
|
+
try {
|
|
251
|
+
if (verdict.reopened !== false)
|
|
252
|
+
return undefined;
|
|
253
|
+
const v = verdict._sema_policyBlocked;
|
|
254
|
+
return typeof v === 'string' && ASK_PARK_AUTO_REOPEN_BLOCKS.includes(v) ? v : undefined;
|
|
255
|
+
}
|
|
256
|
+
catch {
|
|
257
|
+
return undefined;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
function reopenRefusalOf(verdict) {
|
|
261
|
+
try {
|
|
262
|
+
if (verdict.reopened !== false)
|
|
263
|
+
return undefined;
|
|
264
|
+
const v = verdict._sema_reopenRefusal;
|
|
265
|
+
return typeof v === 'string' && PLAN_REVIEW_REOPEN_REFUSALS.includes(v) ? v : undefined;
|
|
266
|
+
}
|
|
267
|
+
catch {
|
|
268
|
+
return undefined;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
241
271
|
function failureWireCode(e) {
|
|
242
272
|
try {
|
|
243
273
|
return effectiveWireErrorCode(e);
|
|
@@ -415,7 +445,58 @@ async function readOwnedPendingCount(read, deps) {
|
|
|
415
445
|
recheckCtl.abort(new Error('owned-pending recheck settled'));
|
|
416
446
|
}
|
|
417
447
|
}
|
|
448
|
+
async function interruptedShortCircuit(signal, runs, deps) {
|
|
449
|
+
try {
|
|
450
|
+
return await interruptedShortCircuitUnguarded(signal, runs, deps);
|
|
451
|
+
}
|
|
452
|
+
catch {
|
|
453
|
+
return null;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
async function interruptedShortCircuitUnguarded(signal, runs, deps) {
|
|
457
|
+
const taskId = signal.activeTaskId;
|
|
458
|
+
if (typeof taskId !== 'string' || taskId === '')
|
|
459
|
+
return null;
|
|
460
|
+
const callerAborted = () => deps?.signal?.aborted === true;
|
|
461
|
+
if (callerAborted())
|
|
462
|
+
return null;
|
|
463
|
+
const port = deps?.wasRecentlyTerminatedByUs;
|
|
464
|
+
if (deps === undefined || typeof port !== 'function')
|
|
465
|
+
return null;
|
|
466
|
+
let ours = false;
|
|
467
|
+
try {
|
|
468
|
+
ours = port.call(deps, taskId) === true;
|
|
469
|
+
}
|
|
470
|
+
catch {
|
|
471
|
+
ours = false;
|
|
472
|
+
}
|
|
473
|
+
if (!ours)
|
|
474
|
+
return null;
|
|
475
|
+
const verbs = runs;
|
|
476
|
+
if (verbs === undefined || typeof verbs.get !== 'function')
|
|
477
|
+
return null;
|
|
478
|
+
const callerSignal = deps.signal;
|
|
479
|
+
const settleDeps = {
|
|
480
|
+
getRun: async (id, o) => {
|
|
481
|
+
const row = await verbs.get(id, { ...sessionOpts(deps), ...(o?.signal !== undefined ? { signal: o.signal } : {}) });
|
|
482
|
+
return row === null ? null : { status: readStatusGuarded(row) };
|
|
483
|
+
},
|
|
484
|
+
...(callerSignal !== undefined ? { signal: callerSignal } : {}),
|
|
485
|
+
...(deps.interruptedSettle ?? {}),
|
|
486
|
+
};
|
|
487
|
+
const verdict = await awaitInterruptedRunSettle(taskId, settleDeps);
|
|
488
|
+
if (callerAborted())
|
|
489
|
+
return null;
|
|
490
|
+
if (verdict.kind === 'settled')
|
|
491
|
+
return { kind: 'interrupted-settled', taskId, status: verdict.status };
|
|
492
|
+
if (verdict.kind === 'still-running')
|
|
493
|
+
return { kind: 'interrupted-still-finishing', taskId, waitedMs: verdict.waitedMs };
|
|
494
|
+
return null;
|
|
495
|
+
}
|
|
418
496
|
export async function attemptActiveRunSelfHeal(signal, runs, deps) {
|
|
497
|
+
const interrupted = await interruptedShortCircuit(signal, runs, deps);
|
|
498
|
+
if (interrupted !== null)
|
|
499
|
+
return interrupted;
|
|
419
500
|
let pending = false;
|
|
420
501
|
try {
|
|
421
502
|
pending = deps?.hasPendingDecision?.() === true;
|
|
@@ -491,7 +572,8 @@ async function planVerdict(taskId, deps) {
|
|
|
491
572
|
}
|
|
492
573
|
async function askVerdict(taskId, deps) {
|
|
493
574
|
try {
|
|
494
|
-
|
|
575
|
+
const trigger = planReviewReopenTriggerFor(deps?.submissionOrigin);
|
|
576
|
+
return snapshotReopenVerdict(await (trigger === undefined ? deps?.reopenAskPark?.(taskId) : deps?.reopenAskPark?.(taskId, { trigger })));
|
|
495
577
|
}
|
|
496
578
|
catch (e) {
|
|
497
579
|
if (deps?.signal?.aborted === true)
|
|
@@ -507,6 +589,7 @@ async function planReviewArm(taskId, signal, deps) {
|
|
|
507
589
|
const dismissed = reopenRefusedForUserDismissal(verdict);
|
|
508
590
|
const noView = reopenRefusedForNoPresentationSurface(verdict);
|
|
509
591
|
const errorCode = inFlight || dismissed || noView ? undefined : reopenErrorCodeOf(verdict);
|
|
592
|
+
const reopenRefusal = inFlight || dismissed || noView ? undefined : reopenRefusalOf(verdict);
|
|
510
593
|
return {
|
|
511
594
|
kind: 'plan-review-reopen-failed',
|
|
512
595
|
taskId,
|
|
@@ -516,6 +599,7 @@ async function planReviewArm(taskId, signal, deps) {
|
|
|
516
599
|
...(dismissed ? { dismissedByUser: true } : {}),
|
|
517
600
|
...(noView ? { noPresentationSurface: true } : {}),
|
|
518
601
|
...(errorCode !== undefined ? { errorCode } : {}),
|
|
602
|
+
...(reopenRefusal !== undefined ? { reopenRefusal } : {}),
|
|
519
603
|
};
|
|
520
604
|
}
|
|
521
605
|
async function askParkArm(taskId, signal, runs, deps) {
|
|
@@ -551,7 +635,8 @@ async function askParkArm(taskId, signal, runs, deps) {
|
|
|
551
635
|
return staleParkArm(taskId, signal, runs, deps);
|
|
552
636
|
}
|
|
553
637
|
const noView = reopenRefusedForNoPresentationSurface(verdict);
|
|
554
|
-
const
|
|
638
|
+
const policyBlocked = inFlight || noView ? undefined : reopenPolicyBlockedOf(verdict);
|
|
639
|
+
const errorCode = inFlight || noView || reopenRefusedForUserDismissal(verdict) || policyBlocked !== undefined ? undefined : reopenErrorCodeOf(verdict);
|
|
555
640
|
return {
|
|
556
641
|
kind: 'ask-reopen-failed',
|
|
557
642
|
taskId,
|
|
@@ -560,6 +645,7 @@ async function askParkArm(taskId, signal, runs, deps) {
|
|
|
560
645
|
...(verdict.pendingRowGone === true ? { pendingRowGone: true } : {}),
|
|
561
646
|
...(noView ? { noPresentationSurface: true } : {}),
|
|
562
647
|
...(errorCode !== undefined ? { errorCode } : {}),
|
|
648
|
+
...(policyBlocked !== undefined ? { policyBlocked } : {}),
|
|
563
649
|
};
|
|
564
650
|
}
|
|
565
651
|
async function probeRunStatusOnce(taskId, durable, durableGet, deps) {
|
|
@@ -855,7 +941,7 @@ const say = (lang, key, params) => renderMessage(msg(key, params), lang);
|
|
|
855
941
|
function gateKindPhrase(kind, lang) {
|
|
856
942
|
return kind ? say(lang, 'session.selfHeal.gate.kind', { kind }) : say(lang, 'session.selfHeal.gate.generic');
|
|
857
943
|
}
|
|
858
|
-
function endRunClause(copy, taskId, lang) {
|
|
944
|
+
function endRunClause(copy, taskId, lang, face = 'headless') {
|
|
859
945
|
let host;
|
|
860
946
|
try {
|
|
861
947
|
host = copy?.endRun;
|
|
@@ -866,6 +952,9 @@ function endRunClause(copy, taskId, lang) {
|
|
|
866
952
|
const phrase = typeof host === 'string' ? host.trim().replace(/[\s.;。;!!??]+$/u, '') : '';
|
|
867
953
|
if (/[\p{L}\p{N}]/u.test(phrase))
|
|
868
954
|
return phrase;
|
|
955
|
+
if (face === 'interactive') {
|
|
956
|
+
return taskId ? say(lang, 'session.selfHeal.endRun.engineInteractive', { taskId }) : say(lang, 'session.selfHeal.endRun.engineInteractive.noId');
|
|
957
|
+
}
|
|
869
958
|
return say(lang, 'session.selfHeal.endRun.engine', { cancelPath: `POST /v1/runs/${taskId ? taskId : '<id>'}/cancel` });
|
|
870
959
|
}
|
|
871
960
|
function wakeSessionClause(copy, lang) {
|
|
@@ -937,6 +1026,9 @@ function injectedSubmissionRow(outcome, following = false, lang) {
|
|
|
937
1026
|
if ((outcome.kind === 'ask-reopen-failed' || outcome.kind === 'plan-review-reopen-failed') && outcome.decisionInFlight === true) {
|
|
938
1027
|
return say(lang, 'session.selfHeal.injected.decisionInFlight', { lead, id });
|
|
939
1028
|
}
|
|
1029
|
+
if (outcome.kind === 'ask-reopen-failed' && outcome.policyBlocked !== undefined) {
|
|
1030
|
+
return askParkAutoReopenBlockedContent(outcome.policyBlocked, outcome.taskId, 'interactive', lang);
|
|
1031
|
+
}
|
|
940
1032
|
if (outcome.kind === 'plan-review-reopen-failed' && outcome.dismissedByUser === true) {
|
|
941
1033
|
return say(lang, 'session.selfHeal.injected.dismissedPlan', { lead, id, closed: msg('session.selfHeal.userClosedCardNotPutBack') });
|
|
942
1034
|
}
|
|
@@ -961,6 +1053,8 @@ function injectedSubmissionRow(outcome, following = false, lang) {
|
|
|
961
1053
|
? say(lang, 'session.selfHeal.injected.unknownDeliveryFollowing', { unknown })
|
|
962
1054
|
: say(lang, 'session.selfHeal.injected.unknownDeliveryWatch', { unknown });
|
|
963
1055
|
}
|
|
1056
|
+
if (outcome.kind === 'interrupted-still-finishing')
|
|
1057
|
+
return say(lang, 'session.selfHeal.injected.interruptedFinishing', { lead, id });
|
|
964
1058
|
switch (selfHealSubmissionDisposition(outcome)) {
|
|
965
1059
|
case 'held-for-decision':
|
|
966
1060
|
return say(lang, 'session.selfHeal.injected.heldForDecision', { lead, id });
|
|
@@ -1021,6 +1115,8 @@ function activeRunSelfHealBaseRow(outcome, wayOut, following = false, keepSessio
|
|
|
1021
1115
|
case 'ask-reopen-failed': {
|
|
1022
1116
|
if (outcome.decisionInFlight === true)
|
|
1023
1117
|
return decisionInFlightRow('ask', outcome.taskId, lang);
|
|
1118
|
+
if (outcome.policyBlocked !== undefined)
|
|
1119
|
+
return askParkAutoReopenBlockedContent(outcome.policyBlocked, outcome.taskId, 'interactive', lang);
|
|
1024
1120
|
const viaEngine = engineDecide && outcome.decidePath ? msg('session.selfHeal.viaEngine', { decidePath: outcome.decidePath }) : '';
|
|
1025
1121
|
const noView = outcome.noPresentationSurface === true ? msg('session.selfHeal.noCardView.afterColon') : '';
|
|
1026
1122
|
return keepSessionWayOut !== null
|
|
@@ -1125,15 +1221,21 @@ function activeRunSelfHealBaseRow(outcome, wayOut, following = false, keepSessio
|
|
|
1125
1221
|
return say(lang, 'session.selfHeal.row.cancelFailed.rejected', { taskId: outcome.taskId, detail: outcome.detail, wayOut });
|
|
1126
1222
|
case 'stale-park-wait':
|
|
1127
1223
|
return outcome.alreadyOffered === true
|
|
1128
|
-
? say(lang, 'session.selfHeal.row.stale.wait.offered', { taskId: outcome.taskId, status: outcome.status, wayOut, endRun: endRunClause(copy, outcome.taskId, lang) })
|
|
1129
|
-
: say(lang, 'session.selfHeal.row.stale.wait.first', { taskId: outcome.taskId, status: outcome.status, wayOut, endRun: endRunClause(copy, outcome.taskId, lang) });
|
|
1224
|
+
? say(lang, 'session.selfHeal.row.stale.wait.offered', { taskId: outcome.taskId, status: outcome.status, wayOut, endRun: endRunClause(copy, outcome.taskId, lang, 'interactive') })
|
|
1225
|
+
: say(lang, 'session.selfHeal.row.stale.wait.first', { taskId: outcome.taskId, status: outcome.status, wayOut, endRun: endRunClause(copy, outcome.taskId, lang, 'interactive') });
|
|
1130
1226
|
case 'running-not-found':
|
|
1131
1227
|
return say(lang, 'session.selfHeal.row.runNotFound', { taskId: outcome.taskId, wayOut });
|
|
1228
|
+
case 'interrupted-settled':
|
|
1229
|
+
return interruptedRunSettleRow(outcome.taskId, { kind: 'settled', status: outcome.status }, lang) ?? '';
|
|
1230
|
+
case 'interrupted-still-finishing': {
|
|
1231
|
+
const waited = `${String(Math.max(1, Math.round(outcome.waitedMs / 1000)))}s`;
|
|
1232
|
+
return say(lang, 'session.selfHeal.row.interrupted.stillFinishing', { taskId: outcome.taskId, waited });
|
|
1233
|
+
}
|
|
1132
1234
|
case 'running-settled':
|
|
1133
1235
|
return say(lang, 'session.selfHeal.row.runSettled', { taskId: outcome.taskId, status: outcome.status, wayOut });
|
|
1134
1236
|
case 'not-parked':
|
|
1135
1237
|
if (outcome.alreadyOffered === true) {
|
|
1136
|
-
return say(lang, 'session.selfHeal.row.notParked.offered', { taskId: outcome.taskId, status: outcome.status, wayOut, endRun: endRunClause(copy, outcome.taskId, lang) });
|
|
1238
|
+
return say(lang, 'session.selfHeal.row.notParked.offered', { taskId: outcome.taskId, status: outcome.status, wayOut, endRun: endRunClause(copy, outcome.taskId, lang, 'interactive') });
|
|
1137
1239
|
}
|
|
1138
1240
|
const parkedOn = outcome.pendingGateKind !== undefined
|
|
1139
1241
|
? gateKindPhrase(outcome.pendingGateKind, lang)
|