@sema-agent/client-core 0.94.0 → 0.96.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 +521 -0
- package/README.md +104 -57
- package/dist/adapt/arms.js +12 -7
- package/dist/adapt/panelTasks.js +4 -10
- package/dist/adapt/toolCards.d.ts +1 -0
- package/dist/adapt/toolCards.js +18 -5
- package/dist/adapt/wireShapes.js +5 -24
- package/dist/adapter/activeRunSelfHeal.d.ts +12 -3
- package/dist/adapter/activeRunSelfHeal.js +50 -16
- package/dist/adapter/downstream/eventToSdkMessage.js +33 -18
- package/dist/adapter/downstream/terminalToSdkResult.js +19 -12
- package/dist/adapter/runStream.js +30 -46
- package/dist/adapter/types.d.ts +7 -0
- package/dist/adapter/types.js +15 -0
- package/dist/agentSession/backgroundView.js +5 -1
- package/dist/agentSession/engineAgentRegistryRead.js +7 -5
- package/dist/agentSession/engineSessionBackgroundStop.js +25 -17
- package/dist/agentsWireCaps.d.ts +2 -0
- package/dist/agentsWireCaps.js +13 -2
- package/dist/approvalDecidedByCapability.d.ts +0 -1
- package/dist/approvalDecidedByCapability.js +2 -7
- package/dist/approvalsStreamLiveCapability.d.ts +0 -1
- package/dist/approvalsStreamLiveCapability.js +2 -6
- package/dist/atMostOnce.d.ts +8 -0
- package/dist/atMostOnce.js +36 -0
- package/dist/attachmentSeatCapability.d.ts +0 -1
- package/dist/attachmentSeatCapability.js +0 -3
- package/dist/attachmentsWireCaps.js +11 -6
- package/dist/bashExitReading.d.ts +10 -0
- package/dist/bashExitReading.js +12 -0
- package/dist/callerCwdCapability.d.ts +0 -5
- package/dist/callerCwdCapability.js +2 -13
- package/dist/centerWiringCapability.d.ts +1 -7
- package/dist/centerWiringCapability.js +18 -27
- package/dist/classifierStatus.js +4 -4
- package/dist/classifierVerdictWire.js +4 -16
- package/dist/clientSlice.js +1 -1
- package/dist/cloudConfigWireCaps.d.ts +3 -3
- package/dist/cloudConfigWireCaps.js +85 -43
- package/dist/compensations.js +1 -1
- package/dist/coreValuePorts.d.ts +11 -7
- package/dist/coreValuePorts.js +5 -8
- package/dist/credentialProvenance.d.ts +28 -0
- package/dist/credentialProvenance.js +76 -0
- package/dist/cycleOrder.d.ts +15 -0
- package/dist/cycleOrder.js +45 -0
- package/dist/decideFailureNote.js +7 -2
- package/dist/decideReceipt.d.ts +2 -1
- package/dist/decideReceipt.js +39 -14
- package/dist/declared/supportFloorDeclared.d.ts +1 -0
- package/dist/declared/supportFloorDeclared.js +5 -0
- package/dist/deviceExecutorManagementCapability.d.ts +0 -1
- package/dist/deviceExecutorManagementCapability.js +7 -16
- package/dist/deviceRebind.d.ts +88 -0
- package/dist/deviceRebind.js +242 -0
- package/dist/displayUntrusted.d.ts +8 -3
- package/dist/displayUntrusted.js +661 -63
- package/dist/engineAgentAbsence.d.ts +2 -2
- package/dist/engineAgentPanelStore.d.ts +8 -18
- package/dist/engineAgentPanelStore.js +19 -537
- package/dist/engineCapReader.d.ts +6 -6
- package/dist/engineCapReader.js +30 -43
- package/dist/engineCapsCache.d.ts +13 -2
- package/dist/engineCapsCache.js +276 -44
- package/dist/engineCredentialRequirement.d.ts +9 -0
- package/dist/engineCredentialRequirement.js +23 -0
- package/dist/engineDirectory.d.ts +79 -0
- package/dist/engineDirectory.js +186 -0
- package/dist/engineEnvSourcing.d.ts +53 -0
- package/dist/engineEnvSourcing.js +81 -0
- package/dist/engineErrorCodes.d.ts +28 -4
- package/dist/engineErrorCodes.js +68 -25
- package/dist/engineIdentity.js +2 -0
- package/dist/engineNoticeCodes.d.ts +17 -0
- package/dist/engineNoticeCodes.js +57 -3
- package/dist/engineWireSdk.js +2 -2
- package/dist/engineWordRenames.d.ts +8 -0
- package/dist/engineWordRenames.js +13 -0
- package/dist/executionLaneCapability.d.ts +2 -3
- package/dist/executionLaneCapability.js +18 -23
- package/dist/fileHistoryCaptureCapability.d.ts +14 -1
- package/dist/fileHistoryCaptureCapability.js +72 -6
- package/dist/fileHistoryLegNotice.d.ts +3 -2
- package/dist/fileHistoryLegNotice.js +51 -2
- package/dist/fleet/bgSubagentRow.d.ts +15 -0
- package/dist/fleet/bgSubagentRow.js +67 -0
- package/dist/fleet/fleetLedger.d.ts +3 -0
- package/dist/fleet/fleetLedger.js +153 -122
- package/dist/fleet/fleetProjection.d.ts +1 -3
- package/dist/fleet/fleetProjection.js +19 -19
- package/dist/fleetAgentPanelProjection.d.ts +4 -17
- package/dist/fleetAgentPanelProjection.js +7 -197
- package/dist/fleetAgentRowLike.d.ts +16 -0
- package/dist/fleetAgentRowLike.js +1 -0
- package/dist/fleetTaskDesc.js +4 -17
- package/dist/gateOutcome.d.ts +12 -1
- package/dist/gateOutcome.js +87 -18
- package/dist/gateVocabulary.d.ts +7 -2
- package/dist/gateVocabulary.js +5 -1
- package/dist/generated/engineAskFaceTables.js +1 -1
- package/dist/generated/engineFactTables.d.ts +5 -3
- package/dist/generated/engineFactTables.js +17 -4
- package/dist/generated/engineNoticeTables.js +12 -3
- package/dist/generated/sdkFactTables.d.ts +2 -0
- package/dist/generated/sdkFactTables.js +17 -0
- package/dist/generated/settingsSchemaFns.d.ts +13 -0
- package/dist/generated/settingsSchemaFns.js +75 -0
- package/dist/generated/toolNameTables.d.ts +1 -0
- package/dist/generated/toolNameTables.js +1 -0
- package/dist/headlessPermissionModeWire.d.ts +1 -1
- package/dist/headlessPermissionModeWire.js +1 -1
- package/dist/headlessReconnectWire.js +49 -20
- package/dist/hitl/allowRuleShadow.d.ts +1 -1
- package/dist/hitl/allowRuleShadow.js +49 -8
- package/dist/hitl/approvalCompleteParked.d.ts +1 -0
- package/dist/hitl/approvalCompleteParked.js +14 -0
- package/dist/hitl/approvalEndingCause.d.ts +7 -0
- package/dist/hitl/approvalEndingCause.js +71 -0
- package/dist/hitl/approvalHolds.d.ts +12 -2
- package/dist/hitl/approvalHolds.js +53 -2
- package/dist/hitl/approvalsFeed.js +23 -11
- package/dist/hitl/askGateWire.d.ts +2 -1
- package/dist/hitl/askGateWire.js +26 -1
- package/dist/hitl/askParkRowRouting.js +1 -1
- package/dist/hitl/automaticAnswerVerdict.d.ts +1 -1
- package/dist/hitl/automaticAnswerVerdict.js +15 -10
- package/dist/hitl/crashConverged.js +2 -0
- package/dist/hitl/decisionConflict.d.ts +3 -0
- package/dist/hitl/decisionConflict.js +41 -0
- package/dist/hitl/decisionRefusal.d.ts +12 -0
- package/dist/hitl/decisionRefusal.js +63 -4
- package/dist/hitl/frameRouter.d.ts +0 -1
- package/dist/hitl/frameRouter.js +32 -57
- package/dist/hitl/gateLedger.d.ts +5 -0
- package/dist/hitl/gateLedger.js +21 -0
- package/dist/hitl/hitlBridge.d.ts +17 -2
- package/dist/hitl/hitlBridge.js +91 -55
- package/dist/hitl/hitlHostSurface.js +3 -11
- package/dist/hitl/livePendingAsk.d.ts +16 -6
- package/dist/hitl/livePendingAsk.js +36 -4
- package/dist/hitl/localAllowRule.d.ts +1 -0
- package/dist/hitl/localAllowRule.js +2 -2
- package/dist/hitl/noAllowCause.d.ts +2 -1
- package/dist/hitl/noAllowCause.js +3 -2
- package/dist/hitl/parkExpiryJudgements.d.ts +19 -0
- package/dist/hitl/parkExpiryJudgements.js +46 -0
- package/dist/hitl/parkResolver.d.ts +4 -7
- package/dist/hitl/parkResolver.js +12 -34
- package/dist/hitl/parkRowBirthWait.d.ts +1 -0
- package/dist/hitl/parkRowBirthWait.js +2 -2
- package/dist/hitl/persistedRulesWire.js +5 -1
- package/dist/hitl/planReviewWire.d.ts +3 -2
- package/dist/hitl/planReviewWire.js +154 -50
- package/dist/hitl/replayedApproval.d.ts +9 -0
- package/dist/hitl/replayedApproval.js +139 -10
- package/dist/hitl/resumeRunningCard.d.ts +2 -0
- package/dist/hitl/resumeRunningCard.js +15 -4
- package/dist/hitl/sessionPolicyDeliverable.js +8 -6
- package/dist/hitl/standingRows.d.ts +18 -0
- package/dist/hitl/standingRows.js +127 -0
- package/dist/hitl/toolApprovalWire.d.ts +39 -7
- package/dist/hitl/toolApprovalWire.js +351 -61
- package/dist/hookMatcherVerdict.d.ts +1 -9
- package/dist/hookMatcherVerdict.js +21 -61
- package/dist/hooksWireCaps.js +40 -8
- package/dist/host.d.ts +5 -0
- package/dist/host.js +3 -1
- package/dist/hostCallbackGuard.d.ts +2 -0
- package/dist/hostCallbackGuard.js +31 -0
- package/dist/index.d.ts +48 -17
- package/dist/index.js +36 -15
- package/dist/interactiveInterrupt.d.ts +8 -0
- package/dist/interactiveInterrupt.js +54 -0
- package/dist/limitsWire.d.ts +5 -0
- package/dist/limitsWire.js +49 -3
- package/dist/liveModelCatalog.d.ts +95 -0
- package/dist/liveModelCatalog.js +297 -32
- package/dist/mcpEngineLeg.d.ts +25 -0
- package/dist/mcpEngineLeg.js +71 -15
- package/dist/mcpPanel.js +2 -1
- package/dist/mcpProbeCapability.d.ts +0 -5
- package/dist/mcpProbeCapability.js +2 -12
- package/dist/mcpReconnect.d.ts +1 -3
- package/dist/mcpReconnect.js +10 -5
- package/dist/memoryComplianceCapability.d.ts +0 -5
- package/dist/memoryComplianceCapability.js +2 -12
- package/dist/memoryOriginCapability.d.ts +0 -5
- package/dist/memoryOriginCapability.js +2 -12
- package/dist/memorySpecWire.js +2 -2
- package/dist/memoryVerbsWire.d.ts +1 -1
- package/dist/memoryVerbsWire.js +4 -0
- package/dist/model/liveCatalogShape.d.ts +14 -0
- package/dist/model/liveCatalogShape.js +71 -0
- package/dist/model/modelSupplyRules.d.ts +1 -0
- package/dist/model/modelSupplyRules.js +30 -9
- package/dist/model/modelsPolicy.d.ts +21 -0
- package/dist/model/modelsPolicy.js +90 -0
- package/dist/modelIdentityResolvability.d.ts +2 -2
- package/dist/modelIdentityResolvability.js +14 -12
- package/dist/modelSwitchFallback.d.ts +69 -0
- package/dist/modelSwitchFallback.js +206 -0
- package/dist/noticePresentation.d.ts +68 -0
- package/dist/noticePresentation.js +247 -0
- package/dist/notifications.js +12 -11
- package/dist/outputStyleSeatCapability.d.ts +0 -2
- package/dist/outputStyleSeatCapability.js +2 -10
- package/dist/ownKey.d.ts +8 -0
- package/dist/ownKey.js +66 -0
- package/dist/panelReduce.d.ts +114 -0
- package/dist/panelReduce.js +1135 -0
- package/dist/panelStateHolder.d.ts +17 -0
- package/dist/panelStateHolder.js +201 -0
- package/dist/peerFrames.js +13 -9
- package/dist/peerLaneCapability.d.ts +0 -1
- package/dist/peerLaneCapability.js +2 -6
- package/dist/permissionModesCapability.d.ts +0 -5
- package/dist/permissionModesCapability.js +5 -16
- package/dist/permissionRuleIssue.js +0 -3
- package/dist/permissionRulesWriteCapability.d.ts +0 -1
- package/dist/permissionRulesWriteCapability.js +2 -6
- package/dist/permissionsAllowGrantCapability.d.ts +0 -1
- package/dist/permissionsAllowGrantCapability.js +3 -9
- package/dist/permissionsDeclaration.d.ts +8 -0
- package/dist/permissionsDeclaration.js +101 -41
- package/dist/printPermissionOutcome.d.ts +12 -0
- package/dist/printPermissionOutcome.js +50 -0
- package/dist/printToolResultFrame.d.ts +1 -0
- package/dist/printToolResultFrame.js +5 -17
- package/dist/promptBlockedCopy.d.ts +5 -0
- package/dist/promptBlockedCopy.js +35 -0
- package/dist/promptDelivery.js +0 -8
- package/dist/protocolSegment.d.ts +9 -6
- package/dist/protocolSegment.js +31 -21
- package/dist/providerRejection.d.ts +4 -0
- package/dist/providerRejection.js +75 -14
- package/dist/replayBody.d.ts +12 -0
- package/dist/replayBody.js +25 -0
- package/dist/resumeRefusalCopy.d.ts +18 -1
- package/dist/resumeRefusalCopy.js +127 -32
- package/dist/retryStatus.d.ts +9 -1
- package/dist/retryStatus.js +9 -2
- package/dist/rewindArchiveCapability.d.ts +5 -14
- package/dist/rewindArchiveCapability.js +18 -61
- package/dist/rewindArchiveReading.d.ts +15 -0
- package/dist/rewindArchiveReading.js +56 -0
- package/dist/rewindEngineAction.d.ts +21 -0
- package/dist/rewindEngineAction.js +36 -0
- package/dist/rewindWireCaps.d.ts +2 -1
- package/dist/rewindWireCaps.js +1 -0
- package/dist/ruleCompileVerdict.d.ts +9 -1
- package/dist/ruleCompileVerdict.js +29 -4
- package/dist/runTerminal.d.ts +15 -12
- package/dist/runTerminal.js +60 -35
- package/dist/sandboxWire.js +13 -0
- package/dist/sdkRegistryTransit.d.ts +2 -1
- package/dist/sdkRegistryTransit.js +1 -0
- package/dist/sealedKeyCapability.d.ts +0 -5
- package/dist/sealedKeyCapability.js +3 -15
- package/dist/seam.js +4 -2
- package/dist/seatContract.d.ts +125 -34
- package/dist/seatContract.js +583 -179
- package/dist/sessionIdSegment.d.ts +1 -0
- package/dist/sessionIdSegment.js +11 -0
- package/dist/sessionMemoryErase.d.ts +1 -1
- package/dist/sessionMemoryErase.js +6 -1
- package/dist/sessionMemoryStatus.js +3 -2
- package/dist/sessionPolicyCapability.d.ts +0 -1
- package/dist/sessionPolicyCapability.js +2 -6
- package/dist/sessionReadRedactionCapability.d.ts +0 -5
- package/dist/sessionReadRedactionCapability.js +2 -13
- package/dist/sessionSyncFileHistory.d.ts +4 -0
- package/dist/sessionSyncFileHistory.js +66 -0
- package/dist/sessionSyncFileHistoryCapability.d.ts +0 -2
- package/dist/sessionSyncFileHistoryCapability.js +2 -9
- package/dist/skillToolListsCapability.d.ts +0 -2
- package/dist/skillToolListsCapability.js +2 -9
- package/dist/skillsWireCaps.d.ts +4 -0
- package/dist/skillsWireCaps.js +66 -1
- package/dist/sqlEngineCapability.d.ts +0 -1
- package/dist/sqlEngineCapability.js +9 -14
- package/dist/steerPriorityCapability.d.ts +0 -2
- package/dist/steerPriorityCapability.js +3 -12
- package/dist/storePostureCapability.d.ts +1 -5
- package/dist/storePostureCapability.js +16 -22
- package/dist/streamDrainingLegs.d.ts +6 -0
- package/dist/streamDrainingLegs.js +23 -0
- package/dist/subagent/engineCompactWire.js +13 -38
- package/dist/subagent/engineDelegatedPrompt.js +10 -6
- package/dist/subagent/engineSubagentOutput.d.ts +0 -1
- package/dist/subagent/engineSubagentOutput.js +5 -20
- package/dist/subagent/engineSubagentSteer.js +7 -5
- package/dist/subagent/engineSubagentTail.d.ts +0 -1
- package/dist/subagent/engineSubagentTail.js +7 -32
- package/dist/subagentContentStore.js +7 -18
- package/dist/supportFloor.d.ts +1 -0
- package/dist/supportFloor.js +15 -14
- package/dist/systemReminderTag.d.ts +1 -0
- package/dist/systemReminderTag.js +8 -0
- package/dist/terminalStatuses.d.ts +30 -0
- package/dist/terminalStatuses.js +67 -0
- package/dist/toolHistoryMismatch.d.ts +0 -3
- package/dist/toolHistoryMismatch.js +3 -7
- package/dist/toolResult.d.ts +6 -1
- package/dist/toolResult.js +90 -37
- package/dist/toolResultContent.d.ts +2 -0
- package/dist/toolResultContent.js +63 -0
- package/dist/types/engineState.d.ts +2 -1
- package/dist/usageAnalytics.d.ts +146 -0
- package/dist/usageAnalytics.js +335 -0
- package/dist/userInvokedSkillsCapability.d.ts +0 -2
- package/dist/userInvokedSkillsCapability.js +2 -9
- package/dist/webSearchBackendCapability.d.ts +0 -1
- package/dist/webSearchBackendCapability.js +3 -7
- package/dist/webSearchWireCaps.js +3 -11
- package/dist/wireErrorTriage.d.ts +2 -0
- package/dist/wireErrorTriage.js +34 -5
- package/dist/wireFailureShape.d.ts +23 -2
- package/dist/wireFailureShape.js +88 -43
- package/dist/wireRefusalCopy.js +2 -18
- package/dist/workflowClient.js +7 -11
- package/dist/workflowsJournalCapability.d.ts +0 -1
- package/dist/workflowsJournalCapability.js +2 -6
- package/dist/writeProtectionCapability.d.ts +0 -1
- package/dist/writeProtectionCapability.js +5 -10
- package/docs/INTEGRATION-CLIENTS.md +2279 -27
- package/package.json +5 -5
- package/dist/engineCapsGenerationGuard.d.ts +0 -4
- package/dist/engineCapsGenerationGuard.js +0 -19
- package/dist/panelRunningHistory.d.ts +0 -22
- package/dist/panelRunningHistory.js +0 -82
- package/dist/registryConflict.d.ts +0 -3
- package/dist/registryConflict.js +0 -44
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { hostLog } from '../host.js';
|
|
2
|
+
import { invokeHostCallbackIsolated } from '../hostCallbackGuard.js';
|
|
2
3
|
import { engineWireDebugEnabled } from '../engineWireTarget.js';
|
|
3
4
|
import { engineSessionParam, engineSessionParamFor } from '../engineSessionParam.js';
|
|
4
5
|
import { enqueueBgChildNotification, isOwnWorkflowRun } from '../notifications.js';
|
|
@@ -7,9 +8,15 @@ import { rowIdTail } from '../workflow.js';
|
|
|
7
8
|
import { recordEngineTranscriptId } from '../subagent/engineDelegatedPrompt.js';
|
|
8
9
|
import { recordFleetRowAgentType } from './fleetRowAgentType.js';
|
|
9
10
|
import { DEFAULT_SESSION_KEY } from '../sessionSlot.js';
|
|
10
|
-
import {
|
|
11
|
+
import { isSdkFleetTaskTerminal, isSdkFleetTaskTerminalNotSuccess } from '../terminalStatuses.js';
|
|
12
|
+
import { projectTasks, projectWorkflows, wireCycleSeq, wireParentId, } from './fleetProjection.js';
|
|
11
13
|
import { isInStreamDrainingEnd } from '../wireErrorTriage.js';
|
|
14
|
+
import { cycleSeqOrder, cycleSeqValue } from '../cycleOrder.js';
|
|
12
15
|
export const TERMINAL_RETAIN_MS = 60_000;
|
|
16
|
+
function hasRowId(row) {
|
|
17
|
+
const id = row?.id;
|
|
18
|
+
return typeof id === 'string' && id.length > 0;
|
|
19
|
+
}
|
|
13
20
|
const liveBgViews = new Map();
|
|
14
21
|
function viewsFor(sessionKey) {
|
|
15
22
|
return liveBgViews.get(sessionKey) ?? new Set();
|
|
@@ -59,6 +66,16 @@ export function clearAllRetainedFleetRowsFor(sessionKey) {
|
|
|
59
66
|
}
|
|
60
67
|
}
|
|
61
68
|
}
|
|
69
|
+
export function forgetSettledTerminalRow(id) {
|
|
70
|
+
return forgetSettledTerminalRowFor(DEFAULT_SESSION_KEY, id);
|
|
71
|
+
}
|
|
72
|
+
export function forgetSettledTerminalRowFor(sessionKey, id) {
|
|
73
|
+
let forgotten = false;
|
|
74
|
+
for (const view of viewsFor(sessionKey))
|
|
75
|
+
if (view.forgetSettledTerminal(id))
|
|
76
|
+
forgotten = true;
|
|
77
|
+
return forgotten;
|
|
78
|
+
}
|
|
62
79
|
export function __resetFleetLedgerRegistryForTests() {
|
|
63
80
|
liveBgViews.clear();
|
|
64
81
|
}
|
|
@@ -88,7 +105,7 @@ export function createFleetLedger(hooks = {}, opts = {}) {
|
|
|
88
105
|
if (gen === undefined || tail.length === 0)
|
|
89
106
|
return;
|
|
90
107
|
const prior = cycleWatermark.get(tail);
|
|
91
|
-
if (prior !== undefined && prior
|
|
108
|
+
if (prior !== undefined && cycleSeqOrder(prior, gen) !== 'before')
|
|
92
109
|
return;
|
|
93
110
|
cycleWatermark.delete(tail);
|
|
94
111
|
if (cycleWatermark.size >= CYCLE_WATERMARK_MAX) {
|
|
@@ -98,6 +115,25 @@ export function createFleetLedger(hooks = {}, opts = {}) {
|
|
|
98
115
|
}
|
|
99
116
|
cycleWatermark.set(tail, gen);
|
|
100
117
|
}
|
|
118
|
+
const settledTerminal = new Map();
|
|
119
|
+
const SETTLED_TERMINAL_MAX = 512;
|
|
120
|
+
function noteSettledTerminal(tail, row) {
|
|
121
|
+
if (tail.length === 0 || typeof row.status !== 'string')
|
|
122
|
+
return;
|
|
123
|
+
const gen = wireCycleSeq(row);
|
|
124
|
+
const recordedGen = settledTerminal.get(tail)?.cycleSeq;
|
|
125
|
+
if (cycleSeqOrder(gen, recordedGen) === 'before')
|
|
126
|
+
return;
|
|
127
|
+
if (cycleSeqOrder(gen, cycleWatermark.get(tail)) === 'before')
|
|
128
|
+
return;
|
|
129
|
+
settledTerminal.delete(tail);
|
|
130
|
+
if (settledTerminal.size >= SETTLED_TERMINAL_MAX) {
|
|
131
|
+
const oldest = settledTerminal.keys().next().value;
|
|
132
|
+
if (oldest !== undefined)
|
|
133
|
+
settledTerminal.delete(oldest);
|
|
134
|
+
}
|
|
135
|
+
settledTerminal.set(tail, { status: row.status, cycleSeq: gen });
|
|
136
|
+
}
|
|
101
137
|
let droppedMalformed = 0;
|
|
102
138
|
let droppedUnknownFrame = 0;
|
|
103
139
|
let droppedForeignBgNotification = 0;
|
|
@@ -127,14 +163,48 @@ export function createFleetLedger(hooks = {}, opts = {}) {
|
|
|
127
163
|
...(typeof r.name === 'string' && r.name.length > 0 ? { name: r.name } : {}),
|
|
128
164
|
status: r.status ?? 'unknown',
|
|
129
165
|
...(parentId !== undefined ? { parentId } : {}),
|
|
166
|
+
...(typeof r.sourceLane === 'string' && r.sourceLane.length > 0 ? { sourceLane: r.sourceLane } : {}),
|
|
130
167
|
...(retired ? { retiredByNotification: true } : {}),
|
|
131
168
|
};
|
|
132
169
|
};
|
|
170
|
+
function settleTerminalRow(row, receivedAtMs) {
|
|
171
|
+
taskMap.delete(row.id);
|
|
172
|
+
rowMeta.delete(row.id);
|
|
173
|
+
retained.set(row.id, { row, expireAt: receivedAtMs + TERMINAL_RETAIN_MS });
|
|
174
|
+
const tail = rowIdTail(row.id);
|
|
175
|
+
for (const id of [...retained.keys()]) {
|
|
176
|
+
if (id !== row.id && rowIdTail(id) === tail)
|
|
177
|
+
retained.delete(id);
|
|
178
|
+
}
|
|
179
|
+
noteSettledTerminal(tail, row);
|
|
180
|
+
}
|
|
181
|
+
function admitRow(row, receivedAtMs) {
|
|
182
|
+
if (isSdkFleetTaskTerminal(row.status)) {
|
|
183
|
+
settleTerminalRow(row, receivedAtMs);
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
taskMap.set(row.id, row);
|
|
187
|
+
rowMeta.set(row.id, { receivedAtMs });
|
|
188
|
+
const tail = rowIdTail(row.id);
|
|
189
|
+
for (const id of [...retained.keys()]) {
|
|
190
|
+
if (rowIdTail(id) === tail)
|
|
191
|
+
retained.delete(id);
|
|
192
|
+
}
|
|
193
|
+
settledTerminal.delete(tail);
|
|
194
|
+
clearBgTerminalFacts(tail);
|
|
195
|
+
}
|
|
196
|
+
function forgetSettledTerminalRowOf(id) {
|
|
197
|
+
if (taskMap.has(id))
|
|
198
|
+
return false;
|
|
199
|
+
const pooled = retained.get(id);
|
|
200
|
+
if (pooled === undefined || pooled.retiredByNotification === true)
|
|
201
|
+
return false;
|
|
202
|
+
retained.delete(id);
|
|
203
|
+
return true;
|
|
204
|
+
}
|
|
133
205
|
const bgView = {
|
|
134
206
|
read: () => {
|
|
135
|
-
const rows = [...taskMap.values()]
|
|
136
|
-
.filter(r => !TERMINAL_FLEET_TASK_STATUSES.has(r.status ?? ''))
|
|
137
|
-
.map(r => toBgTask(r, false));
|
|
207
|
+
const rows = [...taskMap.values()].map(r => toBgTask(r, false));
|
|
138
208
|
const nowMs = nowFn();
|
|
139
209
|
for (const [id, r] of retained) {
|
|
140
210
|
if (r.retiredByNotification !== true)
|
|
@@ -151,6 +221,7 @@ export function createFleetLedger(hooks = {}, opts = {}) {
|
|
|
151
221
|
clearRetained: () => {
|
|
152
222
|
retained.clear();
|
|
153
223
|
},
|
|
224
|
+
forgetSettledTerminal: id => forgetSettledTerminalRowOf(id),
|
|
154
225
|
};
|
|
155
226
|
{
|
|
156
227
|
let views = liveBgViews.get(sessionKey);
|
|
@@ -176,33 +247,35 @@ export function createFleetLedger(hooks = {}, opts = {}) {
|
|
|
176
247
|
wfMap.clear();
|
|
177
248
|
rowMeta.clear();
|
|
178
249
|
const receivedAtMs = nowFn();
|
|
250
|
+
const rows = [];
|
|
179
251
|
for (const row of frame.tasks) {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
for (const id of [...retained.keys()]) {
|
|
185
|
-
if (rowIdTail(id) === tail)
|
|
186
|
-
retained.delete(id);
|
|
187
|
-
}
|
|
188
|
-
clearBgTerminalFacts(tail);
|
|
252
|
+
if (!hasRowId(row)) {
|
|
253
|
+
droppedMalformed++;
|
|
254
|
+
debug('[fleet-frame] MALFORMED snapshot task row dropped(row 或 row.id 缺席 / 非串)');
|
|
255
|
+
continue;
|
|
189
256
|
}
|
|
257
|
+
rows.push(row);
|
|
190
258
|
}
|
|
259
|
+
for (const row of rows)
|
|
260
|
+
if (isSdkFleetTaskTerminal(row.status))
|
|
261
|
+
admitRow(row, receivedAtMs);
|
|
262
|
+
for (const row of rows)
|
|
263
|
+
if (!isSdkFleetTaskTerminal(row.status))
|
|
264
|
+
admitRow(row, receivedAtMs);
|
|
191
265
|
for (const row of frame.workflows)
|
|
192
266
|
wfMap.set(row.id, row);
|
|
193
267
|
break;
|
|
194
268
|
}
|
|
195
269
|
case 'task': {
|
|
196
270
|
const row = frame.row;
|
|
197
|
-
if (!row
|
|
271
|
+
if (!hasRowId(row)) {
|
|
198
272
|
droppedMalformed++;
|
|
199
|
-
debug('[fleet-frame] MALFORMED task frame dropped(row 或 row.id 缺席)');
|
|
273
|
+
debug('[fleet-frame] MALFORMED task frame dropped(row 或 row.id 缺席 / 非串)');
|
|
200
274
|
break;
|
|
201
275
|
}
|
|
202
276
|
const receivedAtMs = nowFn();
|
|
203
|
-
|
|
277
|
+
admitRow(row, receivedAtMs);
|
|
204
278
|
raiseCycleWatermark(rowIdTail(row.id), wireCycleSeq(row));
|
|
205
|
-
rowMeta.set(row.id, { receivedAtMs });
|
|
206
279
|
debug(`[fleet-row] id=${row.id} parent=${row.parentId ?? '-'} agentType=${row.agentType ?? '-'}` +
|
|
207
280
|
` agentName=${row.agentName ?? '-'} name=${row.name ?? '-'} status=${row.status ?? '-'}` +
|
|
208
281
|
` tokens=${row.tokens ?? '-'} parentToolCallId=${row.parentToolCallId ?? '-'}`);
|
|
@@ -224,54 +297,37 @@ export function createFleetLedger(hooks = {}, opts = {}) {
|
|
|
224
297
|
recordEngineTranscriptId(rowIdTail(row.id), row.transcriptId);
|
|
225
298
|
}
|
|
226
299
|
recordFleetRowAgentType(rowIdTail(row.id), row.agentType);
|
|
227
|
-
if (TERMINAL_FLEET_TASK_STATUSES.has(row.status ?? '')) {
|
|
228
|
-
retained.set(row.id, { row, expireAt: receivedAtMs + TERMINAL_RETAIN_MS });
|
|
229
|
-
const tailT = rowIdTail(row.id);
|
|
230
|
-
for (const id of [...retained.keys()]) {
|
|
231
|
-
if (id !== row.id && rowIdTail(id) === tailT)
|
|
232
|
-
retained.delete(id);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
else {
|
|
236
|
-
retained.delete(row.id);
|
|
237
|
-
const tail = rowIdTail(row.id);
|
|
238
|
-
for (const id of [...retained.keys()]) {
|
|
239
|
-
if (id !== row.id && rowIdTail(id) === tail)
|
|
240
|
-
retained.delete(id);
|
|
241
|
-
}
|
|
242
|
-
clearBgTerminalFacts(tail);
|
|
243
|
-
}
|
|
244
300
|
break;
|
|
245
301
|
}
|
|
246
302
|
case 'task_remove': {
|
|
247
303
|
const fr = frame;
|
|
248
|
-
const removedGen =
|
|
249
|
-
const
|
|
304
|
+
const removedGen = cycleSeqValue(fr.cycleSeq);
|
|
305
|
+
const pooledHeld = retained.get(frame.id);
|
|
306
|
+
const held = taskMap.get(frame.id) ?? (pooledHeld !== undefined && pooledHeld.retiredByNotification !== true ? pooledHeld.row : undefined);
|
|
250
307
|
const heldGen = held !== undefined ? wireCycleSeq(held) : undefined;
|
|
251
|
-
const stale = removedGen
|
|
308
|
+
const stale = cycleSeqOrder(removedGen, heldGen) === 'before';
|
|
309
|
+
const reason = typeof fr.removeReason === 'string' && fr.removeReason.length > 0 ? fr.removeReason : undefined;
|
|
252
310
|
if (!stale) {
|
|
253
311
|
taskMap.delete(frame.id);
|
|
254
312
|
rowMeta.delete(frame.id);
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
...(removedGen !== undefined ? { cycleSeq: removedGen } : {}),
|
|
263
|
-
...(stale ? { stale: true } : {}),
|
|
264
|
-
...(held === undefined ? { unknownRow: true } : {}),
|
|
265
|
-
});
|
|
266
|
-
if (out && typeof out.then === 'function') {
|
|
267
|
-
void Promise.resolve(out).catch((e) => {
|
|
268
|
-
hostLog('debug', `[fleet-frame] onTaskRemoved hook rejected: ${String(e).slice(0, 160)}`);
|
|
269
|
-
});
|
|
313
|
+
if (reason === undefined) {
|
|
314
|
+
const pooled = retained.get(frame.id);
|
|
315
|
+
if (pooled !== undefined &&
|
|
316
|
+
pooled.row.status === 'killed' &&
|
|
317
|
+
cycleSeqOrder(removedGen, wireCycleSeq(pooled.row)) !== 'before' &&
|
|
318
|
+
forgetSettledTerminalRowOf(frame.id)) {
|
|
319
|
+
debug(`[fleet-frame] settled-level task_remove evicted the stopped row(id=${frame.id})`);
|
|
270
320
|
}
|
|
271
321
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
322
|
+
}
|
|
323
|
+
if (hooks.onTaskRemoved !== undefined) {
|
|
324
|
+
invokeHostCallbackIsolated('[fleet-frame] onTaskRemoved hook', () => hooks.onTaskRemoved?.({
|
|
325
|
+
id: frame.id,
|
|
326
|
+
...(reason !== undefined ? { removeReason: reason } : {}),
|
|
327
|
+
...(removedGen !== undefined ? { cycleSeq: removedGen } : {}),
|
|
328
|
+
...(stale ? { stale: true } : {}),
|
|
329
|
+
...(held === undefined ? { unknownRow: true } : {}),
|
|
330
|
+
}));
|
|
275
331
|
}
|
|
276
332
|
break;
|
|
277
333
|
}
|
|
@@ -345,29 +401,30 @@ export function createFleetLedger(hooks = {}, opts = {}) {
|
|
|
345
401
|
? 'own_parent'
|
|
346
402
|
: 'absent_parent');
|
|
347
403
|
debug(`[fleet-frame] bg_notification taskId=${n.taskId} status=${n.status} seq=${n.seq ?? '-'} accept=${evidence}`);
|
|
404
|
+
const notifTail = rowIdTail(n.taskId);
|
|
348
405
|
const rowIds = [];
|
|
349
406
|
for (const id of taskMap.keys()) {
|
|
350
|
-
if (
|
|
407
|
+
if (rowIdTail(id) === notifTail)
|
|
351
408
|
rowIds.push(id);
|
|
352
409
|
}
|
|
353
|
-
if (
|
|
410
|
+
if (isSdkFleetTaskTerminal(n.status)) {
|
|
354
411
|
if (typeof n.parentTaskId === 'string' && n.parentTaskId) {
|
|
355
412
|
recordBgParentRun(n.taskId, n.parentTaskId, ing?.session, ing?.sessionKey);
|
|
356
413
|
}
|
|
357
414
|
if (typeof n.transcriptId === 'string' && n.transcriptId.length > 0) {
|
|
358
415
|
recordEngineTranscriptId(n.taskId, n.transcriptId);
|
|
359
416
|
}
|
|
360
|
-
const isWashGreen = (prior, next) => next === 'completed' && (prior
|
|
417
|
+
const isWashGreen = (prior, next) => next === 'completed' && isSdkFleetTaskTerminalNotSuccess(prior);
|
|
361
418
|
const coerced = n.status;
|
|
362
419
|
const nowMs = nowFn();
|
|
363
420
|
const writtenIds = new Set();
|
|
364
421
|
let applied = false;
|
|
365
422
|
let washBlocked = false;
|
|
366
423
|
let staleBlocked = false;
|
|
367
|
-
const notifSeq =
|
|
424
|
+
const notifSeq = cycleSeqValue(n.seq);
|
|
368
425
|
{
|
|
369
426
|
const mark = cycleWatermark.get(n.taskId);
|
|
370
|
-
if (notifSeq
|
|
427
|
+
if (cycleSeqOrder(notifSeq, mark) === 'before') {
|
|
371
428
|
staleBlocked = true;
|
|
372
429
|
debug(`[fleet-frame] bg_notification stale-cycle ignored(watermark=${mark} notif-seq=${notifSeq})`);
|
|
373
430
|
}
|
|
@@ -377,56 +434,39 @@ export function createFleetLedger(hooks = {}, opts = {}) {
|
|
|
377
434
|
if (!known)
|
|
378
435
|
continue;
|
|
379
436
|
const heldGen = wireCycleSeq(known);
|
|
380
|
-
if (notifSeq
|
|
437
|
+
if (cycleSeqOrder(notifSeq, heldGen) === 'before') {
|
|
381
438
|
staleBlocked = true;
|
|
382
439
|
debug(`[fleet-frame] bg_notification stale-cycle ignored(row=${id} row-cycle=${heldGen} notif-seq=${notifSeq})`);
|
|
383
440
|
continue;
|
|
384
441
|
}
|
|
385
|
-
const
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
: meta !== undefined && isElapsedBase(known.elapsedMs)
|
|
406
|
-
? known.elapsedMs + Math.max(0, nowMs - meta.receivedAtMs)
|
|
407
|
-
: known.elapsedMs;
|
|
408
|
-
taskMap.delete(id);
|
|
409
|
-
rowMeta.delete(id);
|
|
410
|
-
retained.set(id, {
|
|
411
|
-
row: {
|
|
412
|
-
...known,
|
|
413
|
-
status: coerced,
|
|
414
|
-
...(typeof frozenElapsed === 'number' ? { elapsedMs: frozenElapsed } : {}),
|
|
415
|
-
},
|
|
416
|
-
expireAt: nowMs + TERMINAL_RETAIN_MS,
|
|
417
|
-
retiredByNotification: true,
|
|
418
|
-
});
|
|
419
|
-
writtenIds.add(id);
|
|
420
|
-
applied = true;
|
|
421
|
-
}
|
|
442
|
+
const started = known.startedAt;
|
|
443
|
+
const meta = rowMeta.get(id);
|
|
444
|
+
const frozenElapsed = typeof started === 'number' && started > 0 && started <= nowMs
|
|
445
|
+
? nowMs - started
|
|
446
|
+
: meta !== undefined && isElapsedBase(known.elapsedMs)
|
|
447
|
+
? known.elapsedMs + Math.max(0, nowMs - meta.receivedAtMs)
|
|
448
|
+
: known.elapsedMs;
|
|
449
|
+
taskMap.delete(id);
|
|
450
|
+
rowMeta.delete(id);
|
|
451
|
+
retained.set(id, {
|
|
452
|
+
row: {
|
|
453
|
+
...known,
|
|
454
|
+
status: coerced,
|
|
455
|
+
...(typeof frozenElapsed === 'number' ? { elapsedMs: frozenElapsed } : {}),
|
|
456
|
+
},
|
|
457
|
+
expireAt: nowMs + TERMINAL_RETAIN_MS,
|
|
458
|
+
retiredByNotification: true,
|
|
459
|
+
});
|
|
460
|
+
writtenIds.add(id);
|
|
461
|
+
applied = true;
|
|
422
462
|
}
|
|
423
463
|
for (const [id, entry] of retained) {
|
|
424
464
|
if (writtenIds.has(id))
|
|
425
465
|
continue;
|
|
426
|
-
if (
|
|
466
|
+
if (rowIdTail(id) !== notifTail)
|
|
427
467
|
continue;
|
|
428
468
|
const retainedGen = wireCycleSeq(entry.row);
|
|
429
|
-
if (notifSeq
|
|
469
|
+
if (cycleSeqOrder(notifSeq, retainedGen) === 'before') {
|
|
430
470
|
staleBlocked = true;
|
|
431
471
|
debug(`[fleet-frame] bg_notification stale-cycle ignored(retained=${id} row-cycle=${retainedGen} notif-seq=${notifSeq})`);
|
|
432
472
|
continue;
|
|
@@ -452,16 +492,18 @@ export function createFleetLedger(hooks = {}, opts = {}) {
|
|
|
452
492
|
(applied ||
|
|
453
493
|
(!washBlocked &&
|
|
454
494
|
(() => {
|
|
455
|
-
const prior
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
if (
|
|
495
|
+
for (const prior of [getBgTerminalFacts(n.taskId), settledTerminal.get(notifTail)]) {
|
|
496
|
+
if (prior === undefined)
|
|
497
|
+
continue;
|
|
498
|
+
const order = cycleSeqOrder(notifSeq, prior.cycleSeq);
|
|
499
|
+
if (order === 'before')
|
|
500
|
+
return false;
|
|
501
|
+
if (order === 'after')
|
|
502
|
+
continue;
|
|
503
|
+
if (isWashGreen(prior.status, n.status))
|
|
460
504
|
return false;
|
|
461
|
-
if (notifSeq > prior.cycleSeq)
|
|
462
|
-
return true;
|
|
463
505
|
}
|
|
464
|
-
return
|
|
506
|
+
return true;
|
|
465
507
|
})()));
|
|
466
508
|
if (factsAccepted)
|
|
467
509
|
raiseCycleWatermark(n.taskId, notifSeq);
|
|
@@ -487,17 +529,7 @@ export function createFleetLedger(hooks = {}, opts = {}) {
|
|
|
487
529
|
debug(`[fleet-frame] bg_notification state-plane rejected as wash-green echo(taskId=${n.taskId} notif=${n.status})—— 通知面照常入队`);
|
|
488
530
|
}
|
|
489
531
|
}
|
|
490
|
-
|
|
491
|
-
const out = hooks.onBgNotificationAccepted?.(n, rowIds, evidence);
|
|
492
|
-
if (out && typeof out.then === 'function') {
|
|
493
|
-
void Promise.resolve(out).catch((e) => {
|
|
494
|
-
hostLog('debug', `[fleet-frame] onBgNotificationAccepted hook rejected: ${String(e).slice(0, 160)}`);
|
|
495
|
-
});
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
catch (e) {
|
|
499
|
-
hostLog('debug', `[fleet-frame] onBgNotificationAccepted hook threw: ${String(e).slice(0, 160)}`);
|
|
500
|
-
}
|
|
532
|
+
invokeHostCallbackIsolated('[fleet-frame] onBgNotificationAccepted hook', () => hooks.onBgNotificationAccepted?.(n, rowIds, evidence));
|
|
501
533
|
enqueueBgChildNotification({
|
|
502
534
|
taskId: n.taskId,
|
|
503
535
|
status: n.status,
|
|
@@ -508,8 +540,6 @@ export function createFleetLedger(hooks = {}, opts = {}) {
|
|
|
508
540
|
function project(nowMs, opts) {
|
|
509
541
|
const viewingTaskId = opts.viewingTaskId;
|
|
510
542
|
const liveRows = [...taskMap.values()].map(r => {
|
|
511
|
-
if (TERMINAL_FLEET_TASK_STATUSES.has(r.status ?? ''))
|
|
512
|
-
return r;
|
|
513
543
|
const started = r.startedAt;
|
|
514
544
|
if (typeof started === 'number' && started > 0 && started <= nowMs) {
|
|
515
545
|
return { ...r, elapsedMs: nowMs - started };
|
|
@@ -603,6 +633,7 @@ export function createFleetLedger(hooks = {}, opts = {}) {
|
|
|
603
633
|
wfMap.clear();
|
|
604
634
|
rowMeta.clear();
|
|
605
635
|
retained.clear();
|
|
636
|
+
settledTerminal.clear();
|
|
606
637
|
contentAnchorSet = false;
|
|
607
638
|
contentAnchor = undefined;
|
|
608
639
|
debug(`[fleet-frame] 会话锚变更(${from ?? '-'} → ${to ?? '-'})⇒ 清上一会话的行/留存` +
|
|
@@ -10,7 +10,6 @@ export interface FleetTaskView {
|
|
|
10
10
|
elapsedMs?: number;
|
|
11
11
|
tokens?: number;
|
|
12
12
|
tokenDir: 'down' | 'up';
|
|
13
|
-
queuedCount?: number;
|
|
14
13
|
awaitingPlanApproval: boolean;
|
|
15
14
|
descendantCount: number;
|
|
16
15
|
viewed: boolean;
|
|
@@ -31,6 +30,7 @@ export interface FleetTaskView {
|
|
|
31
30
|
}>;
|
|
32
31
|
cycleSeq?: number;
|
|
33
32
|
retiredBy?: string;
|
|
33
|
+
workspaceSnapshot?: 'failed';
|
|
34
34
|
}
|
|
35
35
|
export interface FleetRowUsage {
|
|
36
36
|
totalTokens?: number;
|
|
@@ -51,9 +51,7 @@ export interface FleetWorkflowView {
|
|
|
51
51
|
tokens?: number;
|
|
52
52
|
failedCount?: number;
|
|
53
53
|
startedCount?: number;
|
|
54
|
-
errorCode?: string;
|
|
55
54
|
}
|
|
56
|
-
export declare const TERMINAL_FLEET_TASK_STATUSES: ReadonlySet<string>;
|
|
57
55
|
export declare function coerceTaskStatus(s: string): FleetTaskStatus;
|
|
58
56
|
export declare function coerceWorkflowStatus(s: string | undefined): FleetTaskStatus;
|
|
59
57
|
export declare const CONTROL_TOOL_VERBS: ReadonlySet<string>;
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { collapseLabel, escapeDisplayControlChars, taskDescFromName } from '../fleetTaskDesc.js';
|
|
2
2
|
import { rowIdTail } from '../workflow.js';
|
|
3
|
+
import { cycleSeqValue } from '../cycleOrder.js';
|
|
3
4
|
import { frozenSet } from '../frozenSet.js';
|
|
4
5
|
import { CORE_RESERVED_AGENT_NAMES } from '../generated/engineFactTables.js';
|
|
5
|
-
export const TERMINAL_FLEET_TASK_STATUSES = frozenSet([
|
|
6
|
-
'completed',
|
|
7
|
-
'failed',
|
|
8
|
-
'killed',
|
|
9
|
-
]);
|
|
10
6
|
export function coerceTaskStatus(s) {
|
|
11
7
|
switch (s) {
|
|
12
8
|
case 'queued':
|
|
@@ -130,13 +126,15 @@ function wireStoppedBy(r) {
|
|
|
130
126
|
return typeof v === 'string' && v.length > 0 ? v : undefined;
|
|
131
127
|
}
|
|
132
128
|
export function wireCycleSeq(r) {
|
|
133
|
-
|
|
134
|
-
return typeof v === 'number' && Number.isInteger(v) && v > 0 ? v : undefined;
|
|
129
|
+
return cycleSeqValue(r.cycleSeq);
|
|
135
130
|
}
|
|
136
131
|
function wireRetiredBy(r) {
|
|
137
132
|
const v = r.retiredBy;
|
|
138
133
|
return typeof v === 'string' && v.length > 0 ? v : undefined;
|
|
139
134
|
}
|
|
135
|
+
function wireWorkspaceSnapshot(r) {
|
|
136
|
+
return r.workspaceSnapshot === 'failed' ? 'failed' : undefined;
|
|
137
|
+
}
|
|
140
138
|
export function wireResumable(r) {
|
|
141
139
|
return typeof r.resumable === 'boolean' ? r.resumable : undefined;
|
|
142
140
|
}
|
|
@@ -172,6 +170,7 @@ export function projectTasks(allRows, opts) {
|
|
|
172
170
|
const editedFiles = wireEditedFiles(r);
|
|
173
171
|
const cycleSeq = wireCycleSeq(r);
|
|
174
172
|
const retiredBy = wireRetiredBy(r);
|
|
173
|
+
const workspaceSnapshot = wireWorkspaceSnapshot(r);
|
|
175
174
|
const task = {
|
|
176
175
|
id: r.id,
|
|
177
176
|
name: deriveAgentLabel(r.agentType, r.agentName, r.name, r.id),
|
|
@@ -182,7 +181,6 @@ export function projectTasks(allRows, opts) {
|
|
|
182
181
|
...wireNumberKey('elapsedMs', wireDuration(r.elapsedMs)),
|
|
183
182
|
...wireNumberKey('tokens', wireCount(r.tokens)),
|
|
184
183
|
tokenDir: 'down',
|
|
185
|
-
...wireNumberKey('queuedCount', wireCount(r.queuedCount)),
|
|
186
184
|
awaitingPlanApproval: r.awaitingPlanApproval ?? false,
|
|
187
185
|
descendantCount: childCount.get(r.id) ?? 0,
|
|
188
186
|
viewed: viewingTaskId !== undefined && rowIdTail(r.id) === viewingTaskId,
|
|
@@ -197,6 +195,7 @@ export function projectTasks(allRows, opts) {
|
|
|
197
195
|
...(editedFiles !== undefined ? { editedFiles } : {}),
|
|
198
196
|
...(cycleSeq !== undefined ? { cycleSeq } : {}),
|
|
199
197
|
...(retiredBy !== undefined ? { retiredBy } : {}),
|
|
198
|
+
...(workspaceSnapshot !== undefined ? { workspaceSnapshot } : {}),
|
|
200
199
|
};
|
|
201
200
|
return task;
|
|
202
201
|
});
|
|
@@ -213,7 +212,6 @@ function wireNumberKey(key, v) {
|
|
|
213
212
|
export function projectWorkflows(rows) {
|
|
214
213
|
return rows.map(r => {
|
|
215
214
|
const startedCount = wireStartedCount(r);
|
|
216
|
-
const errorCode = wireErrorCode(r);
|
|
217
215
|
return {
|
|
218
216
|
id: r.id,
|
|
219
217
|
name: collapseLabel(r.name ?? '') || 'Dynamic workflow',
|
|
@@ -225,14 +223,9 @@ export function projectWorkflows(rows) {
|
|
|
225
223
|
...wireNumberKey('tokens', wireCount(r.tokens)),
|
|
226
224
|
...wireNumberKey('failedCount', wireCount(r.failedCount)),
|
|
227
225
|
...(startedCount !== undefined ? { startedCount } : {}),
|
|
228
|
-
...(errorCode !== undefined ? { errorCode } : {}),
|
|
229
226
|
};
|
|
230
227
|
});
|
|
231
228
|
}
|
|
232
|
-
function wireErrorCode(r) {
|
|
233
|
-
const v = r.errorCode;
|
|
234
|
-
return typeof v === 'string' && v.length > 0 ? v : undefined;
|
|
235
|
-
}
|
|
236
229
|
const FLEET_TASK_VIEW_KEY_TUPLE = [
|
|
237
230
|
'id',
|
|
238
231
|
'name',
|
|
@@ -243,7 +236,6 @@ const FLEET_TASK_VIEW_KEY_TUPLE = [
|
|
|
243
236
|
'elapsedMs',
|
|
244
237
|
'tokens',
|
|
245
238
|
'tokenDir',
|
|
246
|
-
'queuedCount',
|
|
247
239
|
'awaitingPlanApproval',
|
|
248
240
|
'descendantCount',
|
|
249
241
|
'viewed',
|
|
@@ -258,6 +250,7 @@ const FLEET_TASK_VIEW_KEY_TUPLE = [
|
|
|
258
250
|
'editedFiles',
|
|
259
251
|
'cycleSeq',
|
|
260
252
|
'retiredBy',
|
|
253
|
+
'workspaceSnapshot',
|
|
261
254
|
];
|
|
262
255
|
export const FLEET_TASK_VIEW_KEYS = FLEET_TASK_VIEW_KEY_TUPLE;
|
|
263
256
|
const FLEET_WORKFLOW_VIEW_KEY_TUPLE = [
|
|
@@ -271,7 +264,6 @@ const FLEET_WORKFLOW_VIEW_KEY_TUPLE = [
|
|
|
271
264
|
'tokens',
|
|
272
265
|
'failedCount',
|
|
273
266
|
'startedCount',
|
|
274
|
-
'errorCode',
|
|
275
267
|
];
|
|
276
268
|
export const FLEET_WORKFLOW_VIEW_KEYS = FLEET_WORKFLOW_VIEW_KEY_TUPLE;
|
|
277
269
|
const FLEET_TASK_ROW_WIRE_KEY_TUPLE = [
|
|
@@ -300,6 +292,7 @@ const FLEET_TASK_ROW_WIRE_KEY_TUPLE = [
|
|
|
300
292
|
'editedFiles',
|
|
301
293
|
'cycleSeq',
|
|
302
294
|
'retiredBy',
|
|
295
|
+
'workspaceSnapshot',
|
|
303
296
|
];
|
|
304
297
|
export const FLEET_TASK_ROW_WIRE_KEYS = FLEET_TASK_ROW_WIRE_KEY_TUPLE;
|
|
305
298
|
const FLEET_WORKFLOW_ROW_WIRE_KEY_TUPLE = [
|
|
@@ -319,9 +312,9 @@ export const FLEET_TASK_ROW_KEYS_NOT_PROJECTED = {
|
|
|
319
312
|
sourceLane: {
|
|
320
313
|
kind: 'by-design',
|
|
321
314
|
owner: 'client-core 规范重构轮',
|
|
322
|
-
reason: 'SDK 3.0.0 新键([2070]① 让位半场:前台 delegation 复合 id 行带 "run-leg" 标)
|
|
323
|
-
'#95
|
|
324
|
-
'
|
|
315
|
+
reason: 'SDK 3.0.0 新键([2070]① 让位半场:前台 delegation 复合 id 行带 "run-leg" 标)。**渲染视图**(FleetTaskView)不投 —— 渲染面没有按车道分支的需求,' +
|
|
316
|
+
'#95 纪律:没人读的键不盲投。🆕 0.96.0 CC-643 起它有了消费者,但住在另一张读面:在飞 bg 读面行(EngineActiveBgTask)投了它,' +
|
|
317
|
+
'「这一行是不是后台子代」的单一判定口 isBackgroundSubagentRow 读它(见 fleet/bgSubagentRow.ts);视图不投的理由不变,不是第二份真源。',
|
|
325
318
|
},
|
|
326
319
|
agentType: {
|
|
327
320
|
kind: 'by-design',
|
|
@@ -337,6 +330,13 @@ export const FLEET_TASK_ROW_KEYS_NOT_PROJECTED = {
|
|
|
337
330
|
owner: 'client-core 规范重构轮',
|
|
338
331
|
reason: '同 agentType:两位在本层合成一个身份 label,分开带出去等于把 187 的 tjl 规则推给每个消费端各写一遍。',
|
|
339
332
|
},
|
|
333
|
+
queuedCount: {
|
|
334
|
+
kind: 'by-design',
|
|
335
|
+
owner: 'client-core 0.95.0 CC-388',
|
|
336
|
+
reason: '幻影键:sdk 行型仍声明它,但任何 server 版本都不发(生产侧已整只删除,零生产者,契约里也从没列过)。' +
|
|
337
|
+
'投影一个永远缺席的可选位 = 假线索(读者以为「队列深度已经报了」),所以视图上不留位。' +
|
|
338
|
+
'sdk 在下一个 major 删掉这条声明的同批,本条与 `FLEET_TASK_ROW_WIRE_KEYS` 的 `queuedCount` 一起删;真要队列深度 = 带生产者的新键,不是复活这一个。',
|
|
339
|
+
},
|
|
340
340
|
workflowRunId: {
|
|
341
341
|
kind: 'by-design',
|
|
342
342
|
owner: 'client-core 规范重构轮',
|
|
@@ -1,20 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
status?: string;
|
|
6
|
-
tokens?: number;
|
|
7
|
-
toolUses?: number;
|
|
8
|
-
transcriptId?: string;
|
|
9
|
-
currentTool?: {
|
|
10
|
-
toolName: string;
|
|
11
|
-
target?: string;
|
|
12
|
-
};
|
|
13
|
-
startedAt?: number;
|
|
14
|
-
cycleSeq?: number;
|
|
15
|
-
parentToolCallId?: string;
|
|
16
|
-
}
|
|
17
|
-
export declare const ABSENT_SETTLE_MS = 30000;
|
|
1
|
+
import { ABSENT_SETTLE_MS } from './panelReduce.js';
|
|
2
|
+
import type { FleetAgentRowLike } from './fleetAgentRowLike.js';
|
|
3
|
+
export type { FleetAgentRowLike };
|
|
4
|
+
export { ABSENT_SETTLE_MS };
|
|
18
5
|
export declare function resetFleetAgentPanelProjection(): void;
|
|
19
6
|
export declare function resetFleetAgentPanelProjectionFor(sessionKey: string): void;
|
|
20
7
|
export declare function fleetAgentProjectionSize(): number;
|