@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/adapt/arms.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ccToolDenialKindForToolEnd, gateOutcomeOf } from '../gateOutcome.js';
|
|
2
|
+
import { terminalOwnerOf } from '../seam.js';
|
|
2
3
|
import { isSubFlowSegmentEnd, SEGMENT_END_IDENTITY_KEYS, snapshotSegmentIdentity, snapshotIsSubFlow } from '../adapter/types.js';
|
|
3
4
|
import { classifyPeerNotification, renderPeerFrameTranscriptText } from '../peerFrames.js';
|
|
4
|
-
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';
|
|
5
6
|
import { retryStatusFromArm } from '../retryStatus.js';
|
|
6
7
|
import { steeringInjectedToAttachments } from '../steering.js';
|
|
7
8
|
import { projectDiagnosticsFrame } from '../diagnostics.js';
|
|
@@ -11,39 +12,21 @@ import { readAsyncLaunchedAgentReceipt } from '../toolResult.js';
|
|
|
11
12
|
import { recordWorkflowAgentTaskId } from '../workflow.js';
|
|
12
13
|
import { isCoreTaskNotificationTerminal, isCoreTaskNotificationTerminalNotSuccess, isCoreTaskProgressTerminal, isCoreTaskProgressTerminalNotSuccess } from '../terminalStatuses.js';
|
|
13
14
|
import { readToolHistoryMismatchKey } from '../toolHistoryMismatch.js';
|
|
14
|
-
import { readProviderRejectionResendKey } from '../providerRejection.js';
|
|
15
|
-
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';
|
|
16
19
|
import { CORE_USER_ATTACHMENT_LABEL_MAX } from '../generated/engineFactTables.js';
|
|
17
20
|
import { ESCAPE_FACE, paintAndCap, washCredentials } from '../displayUntrusted.js';
|
|
18
21
|
import { resolveEnginePanelTaskId } from '../engineAgentPanelStore.js';
|
|
19
|
-
import {
|
|
22
|
+
import { cycleSeqValue } from '../cycleOrder.js';
|
|
23
|
+
import { fleetRowAgentType, recordFleetRowAgentType } from '../fleet/fleetRowAgentType.js';
|
|
20
24
|
import { chrome, mainLane, transcript, messageIdentityOf } from './ids.js';
|
|
21
25
|
import { engineRefOf } from '../engineRowRef.js';
|
|
22
26
|
import { isReplayMarked, RESULT_REPLAYED_TEXT } from '../replayBody.js';
|
|
23
27
|
import { wiringManifestViewOf } from '../adapter/downstream/wiringManifestView.js';
|
|
24
28
|
import { isUnsettledHeldToolEnd } from '../engineRowRef.js';
|
|
25
29
|
import { CANCEL_MESSAGE, decisionOf, flattenWireOutput, REJECT_MESSAGE, sanitizeToolUseBlock, shortTaskLabel, TASK_TOOL_NAMES, WORKFLOW_TOOL_NAMES, } from './wireShapes.js';
|
|
26
|
-
function hostOwnString(o, key) {
|
|
27
|
-
return readFrameStringKey(o, key);
|
|
28
|
-
}
|
|
29
|
-
function continuesParkDeclarationOf(ctx) {
|
|
30
|
-
const decl = guardedRead(() => ctx.continuesPark);
|
|
31
|
-
return typeof decl === 'object' && decl !== null ? decl : undefined;
|
|
32
|
-
}
|
|
33
|
-
function continuesParkWitness(ctx, row) {
|
|
34
|
-
const decl = continuesParkDeclarationOf(ctx);
|
|
35
|
-
if (decl === undefined)
|
|
36
|
-
return false;
|
|
37
|
-
if (hostOwnString(decl, 'toolCallId') !== row.toolCallId)
|
|
38
|
-
return false;
|
|
39
|
-
const cp = hostOwnString(decl, 'checkpointId');
|
|
40
|
-
if (cp !== undefined && row.checkpointId !== undefined && cp !== row.checkpointId)
|
|
41
|
-
return false;
|
|
42
|
-
const parkedTaskId = hostOwnString(decl, 'parkedTaskId');
|
|
43
|
-
if (parkedTaskId !== undefined && row.parkedRun !== undefined && parkedTaskId !== row.parkedRun)
|
|
44
|
-
return false;
|
|
45
|
-
return true;
|
|
46
|
-
}
|
|
47
30
|
function claimParkedCard(m, callId, toolName, deps) {
|
|
48
31
|
const { ctx, cards, inst, pass } = deps;
|
|
49
32
|
if (cards.has(callId))
|
|
@@ -57,12 +40,11 @@ function claimParkedCard(m, callId, toolName, deps) {
|
|
|
57
40
|
return undefined;
|
|
58
41
|
const frameRun = engineRefOf(m)?.taskId;
|
|
59
42
|
if (frameRun !== undefined) {
|
|
60
|
-
const
|
|
61
|
-
const allowed = [row.parkedRun, row.card.engineRef?.taskId, readFrameStringKey(decl, 'parkedTaskId'), readFrameStringKey(decl, 'continuationTaskId')].filter((x) => x !== undefined);
|
|
43
|
+
const allowed = [row.parkedRun, row.card.engineRef?.taskId].filter((x) => x !== undefined);
|
|
62
44
|
if (allowed.length > 0 && !allowed.includes(frameRun))
|
|
63
45
|
return undefined;
|
|
64
46
|
}
|
|
65
|
-
if (row.pass !== pass
|
|
47
|
+
if (row.pass !== pass)
|
|
66
48
|
return undefined;
|
|
67
49
|
inst.dropParkedToolRow(row.key);
|
|
68
50
|
return row.card;
|
|
@@ -70,15 +52,42 @@ function claimParkedCard(m, callId, toolName, deps) {
|
|
|
70
52
|
function laneOfCard(p) {
|
|
71
53
|
return p.parentToolCallId !== undefined && p.parentToolCallId !== '' ? { lane: 'subagent', parentToolCallId: p.parentToolCallId } : mainLane();
|
|
72
54
|
}
|
|
55
|
+
function isMintedSyntheticRow(m) {
|
|
56
|
+
return readFrameTrueMark(m, '_sema_api_error_message');
|
|
57
|
+
}
|
|
58
|
+
function terminalOwnerCarry(m) {
|
|
59
|
+
if (!isMintedSyntheticRow(m))
|
|
60
|
+
return {};
|
|
61
|
+
const owner = terminalOwnerOf(m);
|
|
62
|
+
return owner === undefined ? {} : { _sema_terminal_owner: owner };
|
|
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
|
+
}
|
|
73
82
|
function toolHistoryKeyCarry(m) {
|
|
74
|
-
if (m
|
|
83
|
+
if (!isMintedSyntheticRow(m))
|
|
75
84
|
return {};
|
|
76
85
|
const raw = m._sema_tool_history_mismatch;
|
|
77
86
|
const key = readToolHistoryMismatchKey(typeof raw === 'object' && raw !== null ? raw : undefined);
|
|
78
87
|
return key === undefined ? {} : { _sema_tool_history_mismatch: key };
|
|
79
88
|
}
|
|
80
89
|
function providerResendKeyCarry(m) {
|
|
81
|
-
if (m
|
|
90
|
+
if (!isMintedSyntheticRow(m))
|
|
82
91
|
return {};
|
|
83
92
|
const raw = m._sema_provider_rejection_resend;
|
|
84
93
|
const key = readProviderRejectionResendKey(typeof raw === 'object' && raw !== null ? raw : undefined);
|
|
@@ -189,10 +198,11 @@ const assistantArm = function* (m, deps) {
|
|
|
189
198
|
}
|
|
190
199
|
const textBlock = blocks.find(b => b?.type === 'text');
|
|
191
200
|
const thinkingBlock = blocks.find(b => b?.type === 'thinking');
|
|
192
|
-
if (
|
|
201
|
+
if (textBlock && typeof textBlock.text === 'string' && textBlock.text.length > 0)
|
|
193
202
|
text.anchorWindow(m);
|
|
194
203
|
if (textBlock && typeof textBlock.text === 'string' && textBlock.text.length > 0) {
|
|
195
|
-
const rowText = m
|
|
204
|
+
const rowText = isMintedSyntheticRow(m) ? washCredentials(textBlock.text) : textBlock.text;
|
|
205
|
+
const relayedKind = rowKindCarry(m);
|
|
196
206
|
text.appendAnswer(rowText);
|
|
197
207
|
text.beginAssistantMessage();
|
|
198
208
|
yield* text.takeThinking();
|
|
@@ -202,9 +212,12 @@ const assistantArm = function* (m, deps) {
|
|
|
202
212
|
uuid: idOf(m),
|
|
203
213
|
session_id: ctx.sessionId,
|
|
204
214
|
parent_tool_use_id: null,
|
|
205
|
-
...(m
|
|
215
|
+
...(isMintedSyntheticRow(m) ? { _sema_api_error_message: true } : {}),
|
|
206
216
|
...toolHistoryKeyCarry(m),
|
|
207
217
|
...providerResendKeyCarry(m),
|
|
218
|
+
...terminalOwnerCarry(m),
|
|
219
|
+
...relayedKind,
|
|
220
|
+
...codedDetailCarry(m, relayedKind._sema_row_kind),
|
|
208
221
|
}, ctx.now());
|
|
209
222
|
text.markEmittedText(rowText);
|
|
210
223
|
}
|
|
@@ -457,12 +470,41 @@ const compactionOutcomeArm = function* (m) {
|
|
|
457
470
|
const trigger = str(m.trigger);
|
|
458
471
|
const reason = str(m.reason);
|
|
459
472
|
const eventId = str(idSnap.eventId);
|
|
473
|
+
const pass = str(m.pass);
|
|
460
474
|
yield chrome({
|
|
461
475
|
kind: 'compaction_outcome',
|
|
462
476
|
laneProof,
|
|
463
477
|
outcome,
|
|
464
478
|
...(trigger !== undefined ? { trigger } : {}),
|
|
465
479
|
...(reason !== undefined ? { reason } : {}),
|
|
480
|
+
...(pass !== undefined ? { pass } : {}),
|
|
481
|
+
...(eventId !== undefined ? { eventId } : {}),
|
|
482
|
+
});
|
|
483
|
+
};
|
|
484
|
+
const compactionStartedArm = function* (m) {
|
|
485
|
+
const str = (v) => (typeof v === 'string' && v.length > 0 ? v : undefined);
|
|
486
|
+
const pass = str(m.pass);
|
|
487
|
+
const trigger = str(m.trigger);
|
|
488
|
+
if (pass === undefined || trigger === undefined)
|
|
489
|
+
return;
|
|
490
|
+
const idSnap = snapshotSegmentIdentity(m);
|
|
491
|
+
if (idSnap === null)
|
|
492
|
+
return;
|
|
493
|
+
let laneProof = mainLane();
|
|
494
|
+
if (snapshotIsSubFlow(idSnap)) {
|
|
495
|
+
const parent = str(idSnap.parentToolCallId);
|
|
496
|
+
if (parent === undefined)
|
|
497
|
+
return;
|
|
498
|
+
laneProof = { lane: 'subagent', parentToolCallId: parent };
|
|
499
|
+
}
|
|
500
|
+
const startedAt = typeof m.startedAt === 'number' && Number.isFinite(m.startedAt) ? m.startedAt : undefined;
|
|
501
|
+
const eventId = str(idSnap.eventId);
|
|
502
|
+
yield chrome({
|
|
503
|
+
kind: 'compaction_started',
|
|
504
|
+
laneProof,
|
|
505
|
+
pass,
|
|
506
|
+
trigger,
|
|
507
|
+
...(startedAt !== undefined ? { startedAt } : {}),
|
|
466
508
|
...(eventId !== undefined ? { eventId } : {}),
|
|
467
509
|
});
|
|
468
510
|
};
|
|
@@ -491,6 +533,8 @@ const taskStartedArm = function* (m) {
|
|
|
491
533
|
const agentType = str(m.agentType);
|
|
492
534
|
const startedAt = num(m.startedAt);
|
|
493
535
|
const eventId = str(idSnap.eventId);
|
|
536
|
+
if (agentType !== undefined && workflowRunId === undefined)
|
|
537
|
+
recordFleetRowAgentType(taskId, agentType);
|
|
494
538
|
yield chrome({
|
|
495
539
|
kind: 'subagent_started',
|
|
496
540
|
laneProof,
|
|
@@ -533,14 +577,8 @@ const promptAssembledArm = function* (m) {
|
|
|
533
577
|
const chars = size(o.chars);
|
|
534
578
|
return id === undefined || chars === undefined ? undefined : { id, chars };
|
|
535
579
|
});
|
|
536
|
-
const sections = promptManifestRows(m.sections, (o) =>
|
|
537
|
-
|
|
538
|
-
const chars = size(o.chars);
|
|
539
|
-
if (id === undefined || chars === undefined)
|
|
540
|
-
return undefined;
|
|
541
|
-
const slot = str(o.slot);
|
|
542
|
-
return { id, chars, ...(slot !== undefined ? { slot } : {}) };
|
|
543
|
-
});
|
|
580
|
+
const sections = promptManifestRows(m.sections, (o) => promptManifestSectionViewOf(o));
|
|
581
|
+
const promptIdentity = promptManifestIdentityOfFrame(m);
|
|
544
582
|
const tools = promptManifestRows(m.tools, (o) => {
|
|
545
583
|
const wireName = str(o.wireName);
|
|
546
584
|
return wireName === undefined ? undefined : { wireName };
|
|
@@ -567,6 +605,7 @@ const promptAssembledArm = function* (m) {
|
|
|
567
605
|
...(blocks !== undefined ? { blocks } : {}),
|
|
568
606
|
...(sections !== undefined ? { sections } : {}),
|
|
569
607
|
...(tools !== undefined ? { tools } : {}),
|
|
608
|
+
...(promptIdentity !== undefined ? { identity: promptIdentity } : {}),
|
|
570
609
|
...(eventId !== undefined ? { eventId } : {}),
|
|
571
610
|
});
|
|
572
611
|
};
|
|
@@ -576,6 +615,7 @@ const textSegmentEndArm = function* (m, { text }) {
|
|
|
576
615
|
const content = typeof m.content === 'string' ? m.content : '';
|
|
577
616
|
if (content.length === 0)
|
|
578
617
|
return;
|
|
618
|
+
text.anchorWindow(m);
|
|
579
619
|
const r = text.replaceAnswerSegment(content, m);
|
|
580
620
|
yield* text.drainLive();
|
|
581
621
|
yield chrome({
|
|
@@ -591,7 +631,7 @@ const textSegmentEndArm = function* (m, { text }) {
|
|
|
591
631
|
...(r.committedRows !== undefined ? { committedRows: r.committedRows } : {}),
|
|
592
632
|
...(typeof m.eventId === 'string' && m.eventId.length > 0 ? { eventId: m.eventId } : {}),
|
|
593
633
|
});
|
|
594
|
-
text.
|
|
634
|
+
yield* text.endSegment();
|
|
595
635
|
};
|
|
596
636
|
const thinkingSegmentEndArm = function* (m, { text }) {
|
|
597
637
|
if (isSubFlowSegmentEnd(m))
|
|
@@ -627,8 +667,9 @@ const toolEndResultArm = function* (m, deps) {
|
|
|
627
667
|
const { idOf, cards, panel, ctx, inst, pass } = deps;
|
|
628
668
|
const callId = typeof m.toolCallId === 'string' ? m.toolCallId : undefined;
|
|
629
669
|
recordEngineToolLabel(callId, m.label);
|
|
670
|
+
const structured = ownSnapshotWhenTyped(m.structured, 'task-output');
|
|
630
671
|
if (callId !== undefined) {
|
|
631
|
-
const launched = readAsyncLaunchedAgentReceipt(
|
|
672
|
+
const launched = readAsyncLaunchedAgentReceipt(structured);
|
|
632
673
|
if (launched !== null)
|
|
633
674
|
registerSubagentContentAlias(callId, launched.taskId);
|
|
634
675
|
}
|
|
@@ -653,7 +694,6 @@ const toolEndResultArm = function* (m, deps) {
|
|
|
653
694
|
}
|
|
654
695
|
if (p === undefined || callId === undefined)
|
|
655
696
|
return;
|
|
656
|
-
const structured = m.structured;
|
|
657
697
|
const closeEventIdRaw = m.eventId;
|
|
658
698
|
const closeParentRaw = m.parentToolCallId;
|
|
659
699
|
const closeEventId = typeof closeEventIdRaw === 'string' ? closeEventIdRaw : undefined;
|
|
@@ -769,10 +809,19 @@ const taskProgressArm = function* (m, { ctx, cards, panel, inst }) {
|
|
|
769
809
|
: undefined;
|
|
770
810
|
const identity = resolveEnginePanelTaskId(taskId);
|
|
771
811
|
if (!panel.isLive(taskId)) {
|
|
772
|
-
yield* panel.start(taskId, fleetRowAgentType(identity.taskId));
|
|
812
|
+
yield* panel.start(taskId, fleetRowAgentType(taskId) ?? fleetRowAgentType(identity.taskId));
|
|
773
813
|
}
|
|
774
814
|
panel.noteResidency(taskId, identity.taskId);
|
|
775
815
|
panel.markLive(taskId);
|
|
816
|
+
const cycleSeq = cycleSeqValue(m.seq);
|
|
817
|
+
panel.noteCycle(taskId, cycleSeq);
|
|
818
|
+
const finalUsage = {};
|
|
819
|
+
if (isCoreTaskProgressTerminal(m.status)) {
|
|
820
|
+
if (typeof usage.totalTokens === 'number' && Number.isFinite(usage.totalTokens))
|
|
821
|
+
finalUsage.totalTokens = true;
|
|
822
|
+
if (typeof usage.toolUses === 'number' && Number.isFinite(usage.toolUses))
|
|
823
|
+
finalUsage.toolUses = true;
|
|
824
|
+
}
|
|
776
825
|
yield chrome({
|
|
777
826
|
kind: 'panel_task',
|
|
778
827
|
laneProof: panel.laneOf(taskId),
|
|
@@ -788,11 +837,13 @@ const taskProgressArm = function* (m, { ctx, cards, panel, inst }) {
|
|
|
788
837
|
...(panel.isLiveBound(taskId) ? { cardBound: true } : {}),
|
|
789
838
|
toolUses: typeof usage.toolUses === 'number' ? usage.toolUses : 0,
|
|
790
839
|
totalTokens: typeof usage.totalTokens === 'number' ? usage.totalTokens : 0,
|
|
840
|
+
...(cycleSeq !== undefined ? { cycleSeq } : {}),
|
|
841
|
+
...(finalUsage.totalTokens === true || finalUsage.toolUses === true ? { final: finalUsage } : {}),
|
|
791
842
|
},
|
|
792
843
|
});
|
|
793
844
|
if (isCoreTaskProgressTerminal(m.status) && !panel.isLiveBound(taskId)) {
|
|
794
845
|
ctx.probe?.('tick', JSON.stringify({ t: ctx.now(), taskId, lane: 'foreground', settle: m.status }));
|
|
795
|
-
yield* panel.settleFromTerminalTick(taskId, isCoreTaskProgressTerminalNotSuccess(m.status));
|
|
846
|
+
yield* panel.settleFromTerminalTick(taskId, isCoreTaskProgressTerminalNotSuccess(m.status), cycleSeq);
|
|
796
847
|
}
|
|
797
848
|
};
|
|
798
849
|
const streamEventArm = function* (m, { text }) {
|
|
@@ -891,7 +942,7 @@ const resultArm = function* (m, { ctx, idOf, text, cards, panel, flags }) {
|
|
|
891
942
|
yield chrome({ kind: 'result_replayed', laneProof: mainLane(), text: RESULT_REPLAYED_TEXT });
|
|
892
943
|
};
|
|
893
944
|
const taskNotificationArm = function* (m, { ctx, idOf, panel, inst }) {
|
|
894
|
-
const n = (m
|
|
945
|
+
const n = ownSnapshotRecord(guardedRead(() => readOwnDataValue(m, 'notification'))) ?? {};
|
|
895
946
|
const fields = normalizeTaskNotification(n);
|
|
896
947
|
if (fields === null)
|
|
897
948
|
return;
|
|
@@ -938,6 +989,7 @@ const taskNotificationArm = function* (m, { ctx, idOf, panel, inst }) {
|
|
|
938
989
|
return;
|
|
939
990
|
if (peerFrame === null && n.task_type !== 'external')
|
|
940
991
|
markEngineWorkflowNotified(taskId);
|
|
992
|
+
const fact = peerFrame === null ? freezeTaskNotificationFields(fields) : undefined;
|
|
941
993
|
yield transcript({
|
|
942
994
|
type: 'user',
|
|
943
995
|
message: {
|
|
@@ -945,15 +997,19 @@ const taskNotificationArm = function* (m, { ctx, idOf, panel, inst }) {
|
|
|
945
997
|
content: [
|
|
946
998
|
{
|
|
947
999
|
type: 'text',
|
|
948
|
-
text: peerFrame !== null ? renderPeerFrameTranscriptText(peerFrame) : renderTaskNotificationXml(fields),
|
|
1000
|
+
text: peerFrame !== null ? renderPeerFrameTranscriptText(peerFrame) : renderTaskNotificationXml(fact ?? fields),
|
|
949
1001
|
},
|
|
950
1002
|
],
|
|
951
1003
|
},
|
|
952
1004
|
uuid: idOf(m),
|
|
953
1005
|
session_id: ctx.sessionId,
|
|
1006
|
+
...(fact !== undefined ? { _sema_task_notification: fact } : {}),
|
|
954
1007
|
}, ctx.now());
|
|
955
1008
|
};
|
|
956
|
-
const workflowCompleteArm = function* (
|
|
1009
|
+
const workflowCompleteArm = function* (frame) {
|
|
1010
|
+
const m = ownSnapshotRecord(frame);
|
|
1011
|
+
if (m === undefined)
|
|
1012
|
+
return;
|
|
957
1013
|
const runId = typeof m.runId === 'string' ? m.runId : undefined;
|
|
958
1014
|
if (runId === undefined)
|
|
959
1015
|
return;
|
|
@@ -963,13 +1019,15 @@ const workflowCompleteArm = function* (m) {
|
|
|
963
1019
|
const wfStatus = m.status === 'failed' ? 'failed' : 'completed';
|
|
964
1020
|
const wfSummary = typeof m.summary === 'string' ? m.summary : '';
|
|
965
1021
|
noteWorkflowCompletionCardEnqueued(runId);
|
|
1022
|
+
const notification = freezeTaskNotificationFields({ taskId: runId, taskType: 'workflow', status: wfStatus, summary: wfSummary });
|
|
966
1023
|
yield chrome({
|
|
967
1024
|
kind: 'workflow_notification_enqueue',
|
|
968
1025
|
laneProof: mainLane(),
|
|
969
1026
|
runId,
|
|
970
1027
|
status: wfStatus,
|
|
971
1028
|
summary: wfSummary,
|
|
972
|
-
message: renderTaskNotificationXml(
|
|
1029
|
+
message: renderTaskNotificationXml(notification),
|
|
1030
|
+
notification,
|
|
973
1031
|
});
|
|
974
1032
|
};
|
|
975
1033
|
const retryStatusArm = function* (m, { ctx, flags }) {
|
|
@@ -1028,6 +1086,7 @@ export const ARMS = new Map([
|
|
|
1028
1086
|
['tool_roster_delta', toolRosterDeltaArm],
|
|
1029
1087
|
['context_usage', contextUsageArm],
|
|
1030
1088
|
['compaction_outcome', compactionOutcomeArm],
|
|
1089
|
+
['compaction_started', compactionStartedArm],
|
|
1031
1090
|
['prompt_assembled', promptAssembledArm],
|
|
1032
1091
|
['wiring_manifest', wiringManifestArm],
|
|
1033
1092
|
['approval_request', approvalFrameArm('approval_request')],
|
|
@@ -7,10 +7,11 @@ export interface PanelTaskLedger {
|
|
|
7
7
|
isLiveBound(taskId: string): boolean;
|
|
8
8
|
isLive(taskId: string): boolean;
|
|
9
9
|
markLive(taskId: string): void;
|
|
10
|
+
noteCycle(taskId: string, cycleSeq: number | undefined): void;
|
|
10
11
|
noteResidency(taskId: string, residentKey?: string): void;
|
|
11
12
|
start(taskId: string, agentType?: string): Generator<AdapterOutput>;
|
|
12
13
|
settle(cardId: string | null, isError: boolean, report?: string): Generator<AdapterOutput>;
|
|
13
14
|
settleFromNotification(taskId: string, isError: boolean, sessionId?: string): Generator<AdapterOutput>;
|
|
14
|
-
settleFromTerminalTick(taskId: string, isError: boolean): Generator<AdapterOutput>;
|
|
15
|
+
settleFromTerminalTick(taskId: string, isError: boolean, cycleSeq?: number): Generator<AdapterOutput>;
|
|
15
16
|
}
|
|
16
17
|
export declare function createPanelTaskLedger(ctx: AdapterContext, cards: OpenCardView, inst: AdapterInstanceLedger): PanelTaskLedger;
|
package/dist/adapt/panelTasks.js
CHANGED
|
@@ -5,7 +5,15 @@ import { SUBAGENT_TOOL_NAMES } from './wireShapes.js';
|
|
|
5
5
|
export function createPanelTaskLedger(ctx, cards, inst) {
|
|
6
6
|
const taskCardBinding = new Map();
|
|
7
7
|
const livePanelTasks = new Set();
|
|
8
|
-
const endedPanelTasks = new
|
|
8
|
+
const endedPanelTasks = new Map();
|
|
9
|
+
const seenCycle = new Map();
|
|
10
|
+
const currentGenerationEnded = (taskId) => {
|
|
11
|
+
if (!endedPanelTasks.has(taskId))
|
|
12
|
+
return false;
|
|
13
|
+
const prior = endedPanelTasks.get(taskId);
|
|
14
|
+
const seen = seenCycle.get(taskId);
|
|
15
|
+
return !(prior !== undefined && seen !== undefined && prior < seen);
|
|
16
|
+
};
|
|
9
17
|
const liveBoundPanelTasks = new Set();
|
|
10
18
|
const clearResidencyBothKeys = (taskId) => clearEnginePanelTaskResidentByWire(taskId);
|
|
11
19
|
const subagentTypeById = new Map();
|
|
@@ -42,6 +50,13 @@ export function createPanelTaskLedger(ctx, cards, inst) {
|
|
|
42
50
|
markLive: (taskId) => {
|
|
43
51
|
livePanelTasks.add(taskId);
|
|
44
52
|
},
|
|
53
|
+
noteCycle: (taskId, cycleSeq) => {
|
|
54
|
+
if (cycleSeq === undefined)
|
|
55
|
+
return;
|
|
56
|
+
const seen = seenCycle.get(taskId);
|
|
57
|
+
if (seen === undefined || cycleSeq > seen)
|
|
58
|
+
seenCycle.set(taskId, cycleSeq);
|
|
59
|
+
},
|
|
45
60
|
noteResidency: (taskId, residentKey = taskId) => {
|
|
46
61
|
if (liveBoundPanelTasks.has(taskId))
|
|
47
62
|
clearEnginePanelTaskResident(residentKey);
|
|
@@ -69,9 +84,9 @@ export function createPanelTaskLedger(ctx, cards, inst) {
|
|
|
69
84
|
continue;
|
|
70
85
|
if (cardId === null && !liveBoundPanelTasks.has(taskId))
|
|
71
86
|
continue;
|
|
72
|
-
if (
|
|
87
|
+
if (currentGenerationEnded(taskId))
|
|
73
88
|
continue;
|
|
74
|
-
endedPanelTasks.
|
|
89
|
+
endedPanelTasks.set(taskId, undefined);
|
|
75
90
|
const mintLane = laneMinterFor(taskId);
|
|
76
91
|
const agentType = subagentTypeById.get(taskId);
|
|
77
92
|
yield chrome({
|
|
@@ -90,9 +105,9 @@ export function createPanelTaskLedger(ctx, cards, inst) {
|
|
|
90
105
|
},
|
|
91
106
|
*settleFromNotification(taskId, isError, sessionId) {
|
|
92
107
|
clearResidencyBothKeys(taskId);
|
|
93
|
-
if (
|
|
108
|
+
if (currentGenerationEnded(taskId))
|
|
94
109
|
return;
|
|
95
|
-
endedPanelTasks.
|
|
110
|
+
endedPanelTasks.set(taskId, undefined);
|
|
96
111
|
yield chrome({
|
|
97
112
|
kind: 'panel_task',
|
|
98
113
|
laneProof: mainLane(),
|
|
@@ -108,10 +123,18 @@ export function createPanelTaskLedger(ctx, cards, inst) {
|
|
|
108
123
|
});
|
|
109
124
|
}
|
|
110
125
|
},
|
|
111
|
-
*settleFromTerminalTick(taskId, isError) {
|
|
112
|
-
if (endedPanelTasks.has(taskId))
|
|
126
|
+
*settleFromTerminalTick(taskId, isError, cycleSeq) {
|
|
127
|
+
if (endedPanelTasks.has(taskId)) {
|
|
128
|
+
const prior = endedPanelTasks.get(taskId);
|
|
129
|
+
if (cycleSeq === undefined || prior === undefined || cycleSeq <= prior)
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const seen = seenCycle.get(taskId);
|
|
133
|
+
if (cycleSeq !== undefined && seen !== undefined && cycleSeq < seen) {
|
|
134
|
+
yield chrome({ kind: 'panel_task', laneProof: laneMinterFor(taskId)(), event: panelEndFact(taskId, isError, { cycleSeq }) });
|
|
113
135
|
return;
|
|
114
|
-
|
|
136
|
+
}
|
|
137
|
+
endedPanelTasks.set(taskId, cycleSeq);
|
|
115
138
|
clearResidencyBothKeys(taskId);
|
|
116
139
|
const mintLane = laneMinterFor(taskId);
|
|
117
140
|
const card = taskCardBinding.get(taskId);
|
|
@@ -138,7 +161,7 @@ export function createPanelTaskLedger(ctx, cards, inst) {
|
|
|
138
161
|
yield chrome({
|
|
139
162
|
kind: 'panel_task',
|
|
140
163
|
laneProof: mintLane(),
|
|
141
|
-
event: panelEndFact(taskId, isError),
|
|
164
|
+
event: panelEndFact(taskId, isError, cycleSeq !== undefined ? { cycleSeq } : undefined),
|
|
142
165
|
});
|
|
143
166
|
},
|
|
144
167
|
};
|
|
@@ -36,7 +36,7 @@ export interface TextStream {
|
|
|
36
36
|
replaceThinkingSegment(content: string, anchor?: Frame): ThinkingSegmentReplacement;
|
|
37
37
|
segmentId(): string;
|
|
38
38
|
anchorWindow(frame: Frame): void;
|
|
39
|
-
|
|
39
|
+
endSegment(): Generator<AdapterOutput>;
|
|
40
40
|
stampSegmentIdentity(out: AdapterOutput): AdapterOutput;
|
|
41
41
|
readonly answerLength: number;
|
|
42
42
|
}
|
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([
|
|
@@ -38,7 +39,6 @@ export function createTextStream(ctx, idOf) {
|
|
|
38
39
|
let segmentCommitted = '';
|
|
39
40
|
let previousSegmentCommitted = '';
|
|
40
41
|
let segmentWindowCloseArmed = false;
|
|
41
|
-
let segmentSealed = '';
|
|
42
42
|
const flushEveryMs = typeof ctx.coalesceIntervalMs === 'number' && ctx.coalesceIntervalMs >= 0
|
|
43
43
|
? ctx.coalesceIntervalMs
|
|
44
44
|
: FLUSH_INTERVAL_MS;
|
|
@@ -55,6 +55,25 @@ export function createTextStream(ctx, idOf) {
|
|
|
55
55
|
segmentIdCache = idOf(segmentWindowAnchor ?? {}, 'segment');
|
|
56
56
|
return segmentIdCache;
|
|
57
57
|
};
|
|
58
|
+
const openSegmentWindow = (frame) => {
|
|
59
|
+
if (segmentWindowAnchor !== null)
|
|
60
|
+
return;
|
|
61
|
+
segmentWindowAnchor = frame;
|
|
62
|
+
segmentIdCache = null;
|
|
63
|
+
};
|
|
64
|
+
const closeSegmentWindow = () => {
|
|
65
|
+
committedTextRows = [];
|
|
66
|
+
segmentWindowAnchor = null;
|
|
67
|
+
segmentIdCache = null;
|
|
68
|
+
};
|
|
69
|
+
const consumeArmedClose = () => {
|
|
70
|
+
if (!segmentWindowCloseArmed)
|
|
71
|
+
return;
|
|
72
|
+
segmentWindowCloseArmed = false;
|
|
73
|
+
previousSegmentCommitted = '';
|
|
74
|
+
segmentCommitted = '';
|
|
75
|
+
closeSegmentWindow();
|
|
76
|
+
};
|
|
58
77
|
function* takeThinking() {
|
|
59
78
|
if (thinking.length === 0)
|
|
60
79
|
return;
|
|
@@ -77,9 +96,11 @@ export function createTextStream(ctx, idOf) {
|
|
|
77
96
|
yield transcript(msg, ctx.now());
|
|
78
97
|
}
|
|
79
98
|
function* emitAnswerSegment() {
|
|
80
|
-
const body =
|
|
99
|
+
const body = answerSegment;
|
|
81
100
|
if (body.length === 0)
|
|
82
101
|
return;
|
|
102
|
+
if (segmentAnchor !== null)
|
|
103
|
+
openSegmentWindow(segmentAnchor);
|
|
83
104
|
const anchor = segmentAnchor ?? {};
|
|
84
105
|
const msg = {
|
|
85
106
|
type: 'assistant',
|
|
@@ -90,10 +111,8 @@ export function createTextStream(ctx, idOf) {
|
|
|
90
111
|
};
|
|
91
112
|
const committedTextBeforeRow = committedText;
|
|
92
113
|
committedText += body;
|
|
93
|
-
segmentCommitted +=
|
|
94
|
-
|
|
95
|
-
committedTextRows.push({ text: body, uuid: msg.uuid, sealedPrefix: segmentSealed, msgSerial: messageSerial, msgTextBefore: committedTextBeforeRow });
|
|
96
|
-
segmentSealed = '';
|
|
114
|
+
segmentCommitted += body;
|
|
115
|
+
committedTextRows.push({ text: body, uuid: msg.uuid, msgSerial: messageSerial, msgTextBefore: committedTextBeforeRow });
|
|
97
116
|
answerSegment = '';
|
|
98
117
|
segmentAnchor = null;
|
|
99
118
|
segmentLast = null;
|
|
@@ -108,7 +127,7 @@ export function createTextStream(ctx, idOf) {
|
|
|
108
127
|
segmentCommitted = '';
|
|
109
128
|
}
|
|
110
129
|
function* takeAnswerSegmentOnIdle() {
|
|
111
|
-
const body =
|
|
130
|
+
const body = answerSegment;
|
|
112
131
|
if (body.length === 0)
|
|
113
132
|
return;
|
|
114
133
|
if (idleFlushUsedInSegment)
|
|
@@ -149,28 +168,22 @@ export function createTextStream(ctx, idOf) {
|
|
|
149
168
|
}
|
|
150
169
|
return {
|
|
151
170
|
*feedText(delta, frame) {
|
|
152
|
-
if (segmentWindowCloseArmed)
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
segmentCommitted = '';
|
|
156
|
-
committedTextRows = [];
|
|
157
|
-
}
|
|
171
|
+
if (delta.length === 0 && segmentWindowCloseArmed && previousSegmentCommitted + segmentCommitted !== '')
|
|
172
|
+
return;
|
|
173
|
+
consumeArmedClose();
|
|
158
174
|
if (thinking.length > 0 || thinkingPending.length > 0) {
|
|
159
175
|
yield* drainLive();
|
|
160
176
|
yield* takeThinking();
|
|
161
177
|
}
|
|
162
|
-
if (answerSegment.length === 0
|
|
178
|
+
if (answerSegment.length === 0)
|
|
163
179
|
segmentAnchor = frame;
|
|
164
180
|
segmentLast = frame;
|
|
165
|
-
|
|
166
|
-
segmentWindowAnchor = frame;
|
|
181
|
+
openSegmentWindow(frame);
|
|
167
182
|
answer += delta;
|
|
168
183
|
answerSegment += delta;
|
|
169
184
|
textPending += delta;
|
|
170
185
|
},
|
|
171
186
|
*feedThinking(delta, frame) {
|
|
172
|
-
if (segmentWindowAnchor === null)
|
|
173
|
-
segmentWindowAnchor = frame;
|
|
174
187
|
if (thinkingSettled) {
|
|
175
188
|
if (thinking.length > 0) {
|
|
176
189
|
yield* drainLive();
|
|
@@ -212,7 +225,7 @@ export function createTextStream(ctx, idOf) {
|
|
|
212
225
|
const rows = uuidsUnique ? rowsAll : [];
|
|
213
226
|
const rowUuids = rows.map((r) => r.uuid);
|
|
214
227
|
const committedRowsOut = committedPrefixDiverged && rows.length > 0
|
|
215
|
-
? rows.map((r, i) => ({ uuid: r.uuid, text: i === 0 ?
|
|
228
|
+
? rows.map((r, i) => ({ uuid: r.uuid, text: i === 0 ? content : '' }))
|
|
216
229
|
: undefined;
|
|
217
230
|
const attribution = uuidsUnique
|
|
218
231
|
? {
|
|
@@ -241,11 +254,11 @@ export function createTextStream(ctx, idOf) {
|
|
|
241
254
|
committedText = txt;
|
|
242
255
|
currentTouched = true;
|
|
243
256
|
}
|
|
244
|
-
if (txt
|
|
257
|
+
if (carriesAnswerText(txt))
|
|
245
258
|
lastNonEmpty = txt;
|
|
246
259
|
}
|
|
247
260
|
if (!currentTouched && committedText.length > 0) { }
|
|
248
|
-
if (committedText
|
|
261
|
+
if (!carriesAnswerText(committedText) && lastNonEmpty.length > 0)
|
|
249
262
|
previousCommittedText = lastNonEmpty;
|
|
250
263
|
booksSynced = true;
|
|
251
264
|
}
|
|
@@ -287,11 +300,12 @@ export function createTextStream(ctx, idOf) {
|
|
|
287
300
|
}
|
|
288
301
|
}
|
|
289
302
|
else {
|
|
290
|
-
|
|
303
|
+
answerSegment = verdict.tail;
|
|
291
304
|
if (diverged && anchor !== undefined)
|
|
292
305
|
segmentLast = anchor;
|
|
293
306
|
}
|
|
294
|
-
|
|
307
|
+
if (committedPrefixDiverged)
|
|
308
|
+
answerSegment = '';
|
|
295
309
|
if (answer.endsWith(liveSegment)) {
|
|
296
310
|
answer = answer.slice(0, answer.length - liveSegment.length) + content;
|
|
297
311
|
}
|
|
@@ -305,7 +319,6 @@ export function createTextStream(ctx, idOf) {
|
|
|
305
319
|
return { diverged, committedPrefixLen, committedPrefixDiverged, ...attribution };
|
|
306
320
|
},
|
|
307
321
|
hasPendingContent: () => thinking.length > 0 ||
|
|
308
|
-
segmentSealed.length > 0 ||
|
|
309
322
|
answerSegment.length > 0 ||
|
|
310
323
|
thinkingPending.length > 0 ||
|
|
311
324
|
textPending.length > 0,
|
|
@@ -365,13 +378,21 @@ export function createTextStream(ctx, idOf) {
|
|
|
365
378
|
},
|
|
366
379
|
segmentId: segmentIdNow,
|
|
367
380
|
anchorWindow: (frame) => {
|
|
368
|
-
|
|
369
|
-
segmentWindowAnchor = frame;
|
|
381
|
+
openSegmentWindow(frame);
|
|
370
382
|
},
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
383
|
+
*endSegment() {
|
|
384
|
+
try {
|
|
385
|
+
yield* emitAnswerSegment();
|
|
386
|
+
}
|
|
387
|
+
finally {
|
|
388
|
+
segmentAnchor = null;
|
|
389
|
+
segmentLast = null;
|
|
390
|
+
segmentCommitted = '';
|
|
391
|
+
previousSegmentCommitted = '';
|
|
392
|
+
idleFlushUsedInSegment = false;
|
|
393
|
+
textBlockOpen = false;
|
|
394
|
+
closeSegmentWindow();
|
|
395
|
+
}
|
|
375
396
|
},
|
|
376
397
|
stampSegmentIdentity: (out) => {
|
|
377
398
|
if (out.plane !== 'transcript')
|
|
@@ -385,12 +406,17 @@ export function createTextStream(ctx, idOf) {
|
|
|
385
406
|
const last = blocks[blocks.length - 1];
|
|
386
407
|
if (last === undefined || last.type !== 'text' || typeof last.text !== 'string')
|
|
387
408
|
return out;
|
|
409
|
+
if (segmentWindowAnchor === null) {
|
|
410
|
+
const rowUuid = out.message.uuid;
|
|
411
|
+
openSegmentWindow(typeof rowUuid === 'string' ? { uuid: rowUuid } : {});
|
|
412
|
+
}
|
|
413
|
+
;
|
|
388
414
|
out.message[SEMA_SEGMENT_ID_KEY] = segmentIdNow();
|
|
389
415
|
return out;
|
|
390
416
|
},
|
|
391
417
|
beginAssistantMessage: () => {
|
|
392
418
|
messageSerial += 1;
|
|
393
|
-
if (committedText
|
|
419
|
+
if (carriesAnswerText(committedText))
|
|
394
420
|
previousCommittedText = committedText;
|
|
395
421
|
committedText = '';
|
|
396
422
|
previousSegmentCommitted += segmentCommitted;
|
|
@@ -403,7 +429,7 @@ export function createTextStream(ctx, idOf) {
|
|
|
403
429
|
return committedText;
|
|
404
430
|
},
|
|
405
431
|
get lastCommittedAnswerText() {
|
|
406
|
-
return committedText
|
|
432
|
+
return carriesAnswerText(committedText) ? committedText : previousCommittedText;
|
|
407
433
|
},
|
|
408
434
|
get emittedAssistantText() {
|
|
409
435
|
return emittedAssistantText;
|