@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,5 +1,5 @@
|
|
|
1
1
|
import { type EngineAgentPanelAbsence, type EngineAgentPanelCycleIdentity, type EngineAgentPanelEvent } from './engineAgentPanelStore.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { CcTaskTerminalStatus } from './terminalStatuses.js';
|
|
3
3
|
export declare const ENGINE_AGENT_ABSENT_ROW_TEXT = "engine no longer reports this agent \u00B7 it may still be running";
|
|
4
4
|
export declare const ENGINE_AGENT_ABSENCE_TTL_MS: number;
|
|
5
5
|
export type EngineAgentAbsenceMark = Readonly<Pick<EngineAgentPanelAbsence, 'lastSeenAtMs' | 'absentForMs'>>;
|
|
@@ -48,7 +48,7 @@ export interface EngineAgentAbsenceReapOptions {
|
|
|
48
48
|
}
|
|
49
49
|
export declare function reapEngineAgentAbsentRows(rows: Readonly<Record<string, EngineAgentAbsenceReapRow | null | undefined>>, opts: EngineAgentAbsenceReapOptions): EngineAgentAbsenceReap;
|
|
50
50
|
export declare function engineAgentAbsenceDroppedLine(label: string, ttlMs?: number, removeReason?: string | null): string;
|
|
51
|
-
export declare function engineAgentTerminalAfterDropLine(label: string, status:
|
|
51
|
+
export declare function engineAgentTerminalAfterDropLine(label: string, status: CcTaskTerminalStatus, hasReport: boolean): string;
|
|
52
52
|
export interface EngineAgentRegistryRowView {
|
|
53
53
|
readonly id: string;
|
|
54
54
|
readonly type: string;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { isNewEngineAgentPanelCycle, isStaleEngineAgentPanelEnd, MAX_HELD_WIRE_TICK_BEATS, type EnginePanelTaskIdentity, type PanelDelta } from './panelReduce.js';
|
|
2
|
+
import type { EngineAgentPanelCycleIdentity } from './cycleOrder.js';
|
|
3
|
+
export { isNewEngineAgentPanelCycle, isStaleEngineAgentPanelEnd, MAX_HELD_WIRE_TICK_BEATS };
|
|
4
|
+
export type { EngineAgentPanelCycleIdentity, EnginePanelTaskIdentity };
|
|
1
5
|
export type EngineAgentPanelEvent = {
|
|
2
6
|
kind: 'tick';
|
|
3
7
|
taskId: string;
|
|
@@ -45,33 +49,19 @@ export declare const PANEL_TOOLUSES_LANE_POLICY: Readonly<Record<'tick' | 'fleet
|
|
|
45
49
|
export declare function markEnginePanelTaskResident(taskId: string): void;
|
|
46
50
|
export declare function clearEnginePanelTaskResident(taskId: string): void;
|
|
47
51
|
export declare function isEnginePanelTaskResident(taskId: string): boolean;
|
|
48
|
-
type Listener = (ev: EngineAgentPanelEvent) => void;
|
|
49
|
-
export declare function isNewEngineAgentPanelCycle(prev: EngineAgentPanelCycleIdentity | null | undefined, next: EngineAgentPanelCycleIdentity | null | undefined): boolean;
|
|
50
|
-
export interface EngineAgentPanelCycleIdentity {
|
|
51
|
-
readonly cycleSeq?: number;
|
|
52
|
-
readonly startedAt?: number;
|
|
53
|
-
}
|
|
54
|
-
export declare function isStaleEngineAgentPanelEnd(end: EngineAgentPanelCycleIdentity | null | undefined, current: EngineAgentPanelCycleIdentity | null | undefined): boolean;
|
|
55
|
-
export declare const MAX_HELD_WIRE_TICK_BEATS = 16;
|
|
56
|
-
export interface EnginePanelTaskIdentity {
|
|
57
|
-
readonly taskId: string;
|
|
58
|
-
readonly origin: 'fleet-row' | 'wire';
|
|
59
|
-
readonly cycleSeq?: number;
|
|
60
|
-
readonly startedAt?: number;
|
|
61
|
-
}
|
|
62
52
|
export declare function resolveEnginePanelTaskId(wireTaskId: string, parentToolCallId?: string): EnginePanelTaskIdentity;
|
|
63
53
|
export declare function clearEnginePanelTaskResidentByWire(wireTaskId: string, cycle?: EngineAgentPanelCycleIdentity): void;
|
|
64
54
|
export declare function __resetEngineAgentPanelIdentityForTests(): void;
|
|
55
|
+
export declare function __resetEnginePanelStateForTests(): void;
|
|
65
56
|
export declare function publishEngineAgentPanelEvent(ev: EngineAgentPanelEvent): void;
|
|
66
|
-
export declare function subscribeEngineAgentPanel(fn:
|
|
57
|
+
export declare function subscribeEngineAgentPanel(fn: (ev: EngineAgentPanelEvent) => void): () => void;
|
|
58
|
+
export declare function subscribeEnginePanelRows(fn: (delta: PanelDelta) => void): () => void;
|
|
67
59
|
export interface EngineAgentPanelAbsence {
|
|
68
60
|
taskId: string;
|
|
69
61
|
lastSeenAtMs: number;
|
|
70
62
|
absentForMs: number;
|
|
71
63
|
wireTaskId?: string;
|
|
72
64
|
}
|
|
73
|
-
type AbsenceListener = (ev: EngineAgentPanelAbsence) => void;
|
|
74
65
|
export declare function publishEngineAgentPanelAbsence(ev: EngineAgentPanelAbsence): void;
|
|
75
|
-
export declare function subscribeEngineAgentPanelAbsence(fn:
|
|
66
|
+
export declare function subscribeEngineAgentPanelAbsence(fn: (ev: EngineAgentPanelAbsence) => void): () => void;
|
|
76
67
|
export declare function __resetEngineAgentPanelAbsenceForTests(): void;
|
|
77
|
-
export {};
|
|
@@ -1,566 +1,48 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isNewEngineAgentPanelCycle, isStaleEngineAgentPanelEnd, panelIsResident, panelResolveTaskId, MAX_HELD_WIRE_TICK_BEATS, } from './panelReduce.js';
|
|
2
|
+
import { clearEnginePanelIdentity, panelStateNow, resetAbsenceChannel, stepEnginePanel, subscribeAbsence, subscribeLegacyEvents, subscribeRows, resetEnginePanelHolder, } from './panelStateHolder.js';
|
|
3
|
+
export { isNewEngineAgentPanelCycle, isStaleEngineAgentPanelEnd, MAX_HELD_WIRE_TICK_BEATS };
|
|
2
4
|
const _panelToolUsesLanePins = [true, true];
|
|
3
5
|
void _panelToolUsesLanePins;
|
|
4
6
|
export const PANEL_TOOLUSES_LANE_POLICY = {
|
|
5
7
|
tick: 'required-engine-always-emits',
|
|
6
8
|
'fleet-row': 'optional-tolerate-absent',
|
|
7
9
|
};
|
|
8
|
-
const residentTaskIds = new Set();
|
|
9
10
|
export function markEnginePanelTaskResident(taskId) {
|
|
10
|
-
|
|
11
|
+
stepEnginePanel({ kind: 'resident', taskId, resident: true });
|
|
11
12
|
}
|
|
12
13
|
export function clearEnginePanelTaskResident(taskId) {
|
|
13
|
-
|
|
14
|
+
stepEnginePanel({ kind: 'resident', taskId, resident: false });
|
|
14
15
|
}
|
|
15
16
|
export function isEnginePanelTaskResident(taskId) {
|
|
16
|
-
return
|
|
17
|
-
}
|
|
18
|
-
const MAX_BUFFER = 200;
|
|
19
|
-
let listener = null;
|
|
20
|
-
const buffer = [];
|
|
21
|
-
function launchAnchorChanged(prev, next) {
|
|
22
|
-
if (prev.kind !== 'fleet-row' || next.kind !== 'fleet-row')
|
|
23
|
-
return false;
|
|
24
|
-
return isNewEngineAgentPanelCycle(prev, next);
|
|
25
|
-
}
|
|
26
|
-
export function isNewEngineAgentPanelCycle(prev, next) {
|
|
27
|
-
const pc = cycleSeqOf(prev);
|
|
28
|
-
const nc = cycleSeqOf(next);
|
|
29
|
-
if (pc !== undefined && nc !== undefined)
|
|
30
|
-
return pc !== nc;
|
|
31
|
-
const ps = startedAtOf(prev);
|
|
32
|
-
const ns = startedAtOf(next);
|
|
33
|
-
return ps !== undefined && ns !== undefined && ps !== ns;
|
|
34
|
-
}
|
|
35
|
-
function cycleSeqOf(v) {
|
|
36
|
-
const n = v?.cycleSeq;
|
|
37
|
-
return typeof n === 'number' && Number.isInteger(n) && n >= 1 ? n : undefined;
|
|
38
|
-
}
|
|
39
|
-
function startedAtOf(v) {
|
|
40
|
-
const n = v?.startedAt;
|
|
41
|
-
return typeof n === 'number' && Number.isFinite(n) && n > 0 ? n : undefined;
|
|
42
|
-
}
|
|
43
|
-
export function isStaleEngineAgentPanelEnd(end, current) {
|
|
44
|
-
const ec = cycleSeqOf(end);
|
|
45
|
-
const cc = cycleSeqOf(current);
|
|
46
|
-
if (ec !== undefined && cc !== undefined)
|
|
47
|
-
return ec < cc;
|
|
48
|
-
const es = startedAtOf(end);
|
|
49
|
-
const cs = startedAtOf(current);
|
|
50
|
-
if (es !== undefined && cs !== undefined)
|
|
51
|
-
return es < cs;
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
const MAX_IDENTITY_KEYS = 2048;
|
|
55
|
-
const MAX_HELD_WIRE_TICKS = 64;
|
|
56
|
-
export const MAX_HELD_WIRE_TICK_BEATS = 16;
|
|
57
|
-
const fleetIdByTranscriptId = new Map();
|
|
58
|
-
const fleetIdByParentToolCallId = new Map();
|
|
59
|
-
const heldWireTicks = new Map();
|
|
60
|
-
const latestCycleByFleetId = new Map();
|
|
61
|
-
const MAX_OWNERSHIP_KEYS = 8192;
|
|
62
|
-
const publishedWireIds = new Map();
|
|
63
|
-
const publishedWireByParent = new Map();
|
|
64
|
-
const wireIdByFleetId = new Map();
|
|
65
|
-
function bounded(map, key, value) {
|
|
66
|
-
map.delete(key);
|
|
67
|
-
map.set(key, value);
|
|
68
|
-
if (map.size > MAX_IDENTITY_KEYS) {
|
|
69
|
-
const oldest = map.keys().next().value;
|
|
70
|
-
if (oldest !== undefined)
|
|
71
|
-
map.delete(oldest);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
function boundedOwnership(map, key, value) {
|
|
75
|
-
map.delete(key);
|
|
76
|
-
map.set(key, value);
|
|
77
|
-
if (map.size <= MAX_OWNERSHIP_KEYS)
|
|
78
|
-
return;
|
|
79
|
-
for (const [k, v] of map) {
|
|
80
|
-
if (v.retired) {
|
|
81
|
-
map.delete(k);
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
const oldest = map.keys().next().value;
|
|
86
|
-
if (oldest !== undefined)
|
|
87
|
-
map.delete(oldest);
|
|
88
|
-
}
|
|
89
|
-
function notePublishedWire(ev) {
|
|
90
|
-
boundedOwnership(publishedWireIds, ev.taskId, { retired: publishedWireIds.get(ev.taskId)?.retired ?? false });
|
|
91
|
-
if (ev.parentToolCallId !== undefined && ev.parentToolCallId.length > 0)
|
|
92
|
-
bounded(publishedWireByParent, ev.parentToolCallId, ev.taskId);
|
|
93
|
-
}
|
|
94
|
-
function retireWire(wireId) {
|
|
95
|
-
const w = publishedWireIds.get(wireId);
|
|
96
|
-
if (w !== undefined)
|
|
97
|
-
w.retired = true;
|
|
98
|
-
for (const o of wireIdByFleetId.values())
|
|
99
|
-
if (o.wireId === wireId)
|
|
100
|
-
o.retired = true;
|
|
101
|
-
}
|
|
102
|
-
function publishedWireFor(ev) {
|
|
103
|
-
if (ev.transcriptId !== undefined && publishedWireIds.has(ev.transcriptId))
|
|
104
|
-
return ev.transcriptId;
|
|
105
|
-
if (ev.parentToolCallId !== undefined) {
|
|
106
|
-
const u = publishedWireByParent.get(ev.parentToolCallId);
|
|
107
|
-
if (u !== undefined && publishedWireIds.get(u)?.retired === false)
|
|
108
|
-
return u;
|
|
109
|
-
}
|
|
110
|
-
return undefined;
|
|
111
|
-
}
|
|
112
|
-
function wireOwnerOf(fleetId, current, transcriptId) {
|
|
113
|
-
const o = wireIdByFleetId.get(fleetId);
|
|
114
|
-
if (o === undefined)
|
|
115
|
-
return undefined;
|
|
116
|
-
const newTranscript = transcriptId !== undefined && transcriptId !== (o.transcriptId ?? o.wireId);
|
|
117
|
-
if (newTranscript || (current !== undefined && isStaleEngineAgentPanelEnd(o, current))) {
|
|
118
|
-
wireIdByFleetId.delete(fleetId);
|
|
119
|
-
retireWire(o.wireId);
|
|
120
|
-
return undefined;
|
|
121
|
-
}
|
|
122
|
-
return o.wireId;
|
|
123
|
-
}
|
|
124
|
-
function remember(map, key, alias) {
|
|
125
|
-
map.delete(key);
|
|
126
|
-
map.set(key, alias);
|
|
127
|
-
if (map.size > MAX_IDENTITY_KEYS) {
|
|
128
|
-
const oldest = map.keys().next().value;
|
|
129
|
-
if (oldest !== undefined)
|
|
130
|
-
map.delete(oldest);
|
|
131
|
-
}
|
|
17
|
+
return panelIsResident(panelStateNow(), taskId);
|
|
132
18
|
}
|
|
133
19
|
export function resolveEnginePanelTaskId(wireTaskId, parentToolCallId) {
|
|
134
|
-
|
|
135
|
-
if (byTranscript !== undefined) {
|
|
136
|
-
remember(fleetIdByTranscriptId, wireTaskId, byTranscript);
|
|
137
|
-
return identityOf(byTranscript);
|
|
138
|
-
}
|
|
139
|
-
const byParent = parentToolCallId !== undefined ? fleetIdByParentToolCallId.get(parentToolCallId) : undefined;
|
|
140
|
-
if (byParent !== undefined) {
|
|
141
|
-
remember(fleetIdByParentToolCallId, parentToolCallId, byParent);
|
|
142
|
-
return identityOf(byParent);
|
|
143
|
-
}
|
|
144
|
-
return { taskId: wireTaskId, origin: 'wire' };
|
|
145
|
-
}
|
|
146
|
-
function identityOf(alias) {
|
|
147
|
-
return {
|
|
148
|
-
taskId: alias.fleetId,
|
|
149
|
-
origin: 'fleet-row',
|
|
150
|
-
...(alias.cycleSeq !== undefined ? { cycleSeq: alias.cycleSeq } : {}),
|
|
151
|
-
...(alias.startedAt !== undefined ? { startedAt: alias.startedAt } : {}),
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
function rememberResolvedWire(wireTaskId, id) {
|
|
155
|
-
if (fleetIdByTranscriptId.has(wireTaskId))
|
|
156
|
-
return;
|
|
157
|
-
remember(fleetIdByTranscriptId, wireTaskId, {
|
|
158
|
-
fleetId: id.taskId,
|
|
159
|
-
...(id.cycleSeq !== undefined ? { cycleSeq: id.cycleSeq } : {}),
|
|
160
|
-
...(id.startedAt !== undefined ? { startedAt: id.startedAt } : {}),
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
function ageHeld(except) {
|
|
164
|
-
for (const [wireId, held] of [...heldWireTicks]) {
|
|
165
|
-
if (wireId === except)
|
|
166
|
-
continue;
|
|
167
|
-
held.beats += 1;
|
|
168
|
-
if (held.beats >= MAX_HELD_WIRE_TICK_BEATS) {
|
|
169
|
-
heldWireTicks.delete(wireId);
|
|
170
|
-
deliverEngineAgentPanelEvent(asIsTick(held.ev));
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
function migrateResidency(wireTaskId, fleetId) {
|
|
175
|
-
if (wireTaskId !== fleetId && residentTaskIds.has(wireTaskId)) {
|
|
176
|
-
residentTaskIds.delete(wireTaskId);
|
|
177
|
-
residentTaskIds.add(fleetId);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
function normalizedTick(ev, fleetId) {
|
|
181
|
-
const { cardBound: _cardBound, ...rest } = ev;
|
|
182
|
-
void _cardBound;
|
|
183
|
-
migrateResidency(ev.taskId, fleetId);
|
|
184
|
-
return { ...rest, taskId: fleetId, wireTaskId: ev.taskId, taskIdOrigin: 'fleet-row' };
|
|
185
|
-
}
|
|
186
|
-
function asIsTick(ev) {
|
|
187
|
-
const { cardBound: _cardBound, ...rest } = ev;
|
|
188
|
-
void _cardBound;
|
|
189
|
-
notePublishedWire(ev);
|
|
190
|
-
return { ...rest, taskIdOrigin: 'wire' };
|
|
191
|
-
}
|
|
192
|
-
function staleWireTick(id) {
|
|
193
|
-
return isStaleEngineAgentPanelEnd(id, latestCycleByFleetId.get(id.taskId));
|
|
194
|
-
}
|
|
195
|
-
function flushHeld(wireTaskId) {
|
|
196
|
-
const held = heldWireTicks.get(wireTaskId);
|
|
197
|
-
if (held === undefined)
|
|
198
|
-
return;
|
|
199
|
-
heldWireTicks.delete(wireTaskId);
|
|
200
|
-
if (publishedWireIds.has(held.ev.taskId)) {
|
|
201
|
-
deliverEngineAgentPanelEvent(asIsTick(held.ev));
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
const id = resolveEnginePanelTaskId(held.ev.taskId, held.ev.parentToolCallId);
|
|
205
|
-
if (id.origin === 'fleet-row') {
|
|
206
|
-
if (staleWireTick(id))
|
|
207
|
-
return;
|
|
208
|
-
rememberResolvedWire(held.ev.taskId, id);
|
|
209
|
-
deliverEngineAgentPanelEvent(normalizedTick(held.ev, id.taskId));
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
deliverEngineAgentPanelEvent(asIsTick(held.ev));
|
|
20
|
+
return panelResolveTaskId(panelStateNow(), wireTaskId, parentToolCallId);
|
|
213
21
|
}
|
|
214
22
|
export function clearEnginePanelTaskResidentByWire(wireTaskId, cycle) {
|
|
215
|
-
|
|
216
|
-
const owner = wireIdByFleetId.get(wireTaskId);
|
|
217
|
-
if (owner !== undefined && !(cycle !== undefined && isStaleEngineAgentPanelEnd(cycle, owner)))
|
|
218
|
-
residentTaskIds.delete(owner.wireId);
|
|
219
|
-
const id = resolveEnginePanelTaskId(wireTaskId);
|
|
220
|
-
if (id.taskId === wireTaskId)
|
|
221
|
-
return;
|
|
222
|
-
if (isStaleEngineAgentPanelEnd(id, latestCycleByFleetId.get(id.taskId)))
|
|
223
|
-
return;
|
|
224
|
-
residentTaskIds.delete(id.taskId);
|
|
23
|
+
stepEnginePanel({ kind: 'resident-clear-wire', taskId: wireTaskId, ...(cycle !== undefined ? { cycle } : {}) });
|
|
225
24
|
}
|
|
226
25
|
export function __resetEngineAgentPanelIdentityForTests() {
|
|
227
|
-
|
|
228
|
-
fleetIdByParentToolCallId.clear();
|
|
229
|
-
heldWireTicks.clear();
|
|
230
|
-
latestCycleByFleetId.clear();
|
|
231
|
-
publishedWireIds.clear();
|
|
232
|
-
publishedWireByParent.clear();
|
|
233
|
-
wireIdByFleetId.clear();
|
|
234
|
-
}
|
|
235
|
-
function heldRowConsumerKey(tail, held) {
|
|
236
|
-
const owner = wireIdByFleetId.get(tail);
|
|
237
|
-
if (owner !== undefined)
|
|
238
|
-
return owner.wireId;
|
|
239
|
-
return publishedWireFor(held) ?? tail;
|
|
26
|
+
clearEnginePanelIdentity();
|
|
240
27
|
}
|
|
241
|
-
function
|
|
242
|
-
|
|
243
|
-
if (held === undefined || held.kind !== 'fleet-row')
|
|
244
|
-
return 'none';
|
|
245
|
-
const heldCycle = { ...(held.cycleSeq !== undefined ? { cycleSeq: held.cycleSeq } : {}), ...(held.startedAt !== undefined ? { startedAt: held.startedAt } : {}) };
|
|
246
|
-
if (isStaleEngineAgentPanelEnd(endCycle, heldCycle))
|
|
247
|
-
return 'keep';
|
|
248
|
-
if (isStaleEngineAgentPanelEnd(heldCycle, endCycle))
|
|
249
|
-
return 'drop';
|
|
250
|
-
return 'release';
|
|
251
|
-
}
|
|
252
|
-
function heldRowReleasesOntoSameKey(tail, end) {
|
|
253
|
-
const held = peekHeldNewbornTerminalRow(tail);
|
|
254
|
-
if (held === undefined || held.kind !== 'fleet-row')
|
|
255
|
-
return false;
|
|
256
|
-
const rowKey = heldRowConsumerKey(tail, held);
|
|
257
|
-
if (rowKey === end.taskId)
|
|
258
|
-
return true;
|
|
259
|
-
return rowKey === tail && held.transcriptId === end.taskId && !publishedWireIds.has(end.taskId);
|
|
260
|
-
}
|
|
261
|
-
function releaseHeldNewbornTerminal(taskId, endCycle) {
|
|
262
|
-
const verdict = heldNewbornTerminalVerdict(taskId, endCycle);
|
|
263
|
-
if (verdict === 'drop') {
|
|
264
|
-
dropHeldNewbornTerminalRow(taskId);
|
|
265
|
-
return;
|
|
266
|
-
}
|
|
267
|
-
if (verdict !== 'release')
|
|
268
|
-
return;
|
|
269
|
-
const held = takeHeldNewbornTerminalRow(taskId);
|
|
270
|
-
if (held !== undefined)
|
|
271
|
-
publishEngineAgentPanelEvent(held);
|
|
272
|
-
}
|
|
273
|
-
function settleRowHistory(taskId, cycle) {
|
|
274
|
-
retirePanelRowRunning(taskId);
|
|
275
|
-
notePanelRowEnded(taskId, cycle, isStaleEngineAgentPanelEnd(cycle, panelRowEndedIdentity(taskId)));
|
|
276
|
-
}
|
|
277
|
-
function endOlderThanKnown(end, taskId, rowCycle) {
|
|
278
|
-
return isStaleEngineAgentPanelEnd(end, rowCycle) || isStaleEngineAgentPanelEnd(end, panelRowEndedIdentity(taskId));
|
|
28
|
+
export function __resetEnginePanelStateForTests() {
|
|
29
|
+
resetEnginePanelHolder();
|
|
279
30
|
}
|
|
280
31
|
export function publishEngineAgentPanelEvent(ev) {
|
|
281
|
-
|
|
282
|
-
ageHeld(ev.kind === 'sweep' ? undefined : ev.taskId);
|
|
283
|
-
switch (ev.kind) {
|
|
284
|
-
case 'fleet-row': {
|
|
285
|
-
const rowCycle = { ...(ev.cycleSeq !== undefined ? { cycleSeq: ev.cycleSeq } : {}), ...(ev.startedAt !== undefined ? { startedAt: ev.startedAt } : {}) };
|
|
286
|
-
const published = wireOwnerOf(ev.taskId, rowCycle, ev.transcriptId) ?? publishedWireFor(ev);
|
|
287
|
-
if (published !== undefined && published !== ev.taskId) {
|
|
288
|
-
const prev = wireIdByFleetId.get(ev.taskId);
|
|
289
|
-
boundedOwnership(wireIdByFleetId, ev.taskId, { wireId: published, retired: prev?.wireId === published ? prev.retired : false, ...(ev.transcriptId !== undefined ? { transcriptId: ev.transcriptId } : prev?.transcriptId !== undefined ? { transcriptId: prev.transcriptId } : {}), ...rowCycle });
|
|
290
|
-
deliverEngineAgentPanelEvent({ ...ev, taskId: published, wireTaskId: ev.taskId, taskIdOrigin: 'wire' });
|
|
291
|
-
ageHeld(undefined);
|
|
292
|
-
return;
|
|
293
|
-
}
|
|
294
|
-
const alias = {
|
|
295
|
-
fleetId: ev.taskId,
|
|
296
|
-
...(ev.cycleSeq !== undefined ? { cycleSeq: ev.cycleSeq } : {}),
|
|
297
|
-
...(ev.startedAt !== undefined ? { startedAt: ev.startedAt } : {}),
|
|
298
|
-
};
|
|
299
|
-
if (alias.cycleSeq !== undefined || alias.startedAt !== undefined) {
|
|
300
|
-
latestCycleByFleetId.delete(ev.taskId);
|
|
301
|
-
latestCycleByFleetId.set(ev.taskId, { ...(alias.cycleSeq !== undefined ? { cycleSeq: alias.cycleSeq } : {}), ...(alias.startedAt !== undefined ? { startedAt: alias.startedAt } : {}) });
|
|
302
|
-
if (latestCycleByFleetId.size > MAX_IDENTITY_KEYS) {
|
|
303
|
-
const oldest = latestCycleByFleetId.keys().next().value;
|
|
304
|
-
if (oldest !== undefined)
|
|
305
|
-
latestCycleByFleetId.delete(oldest);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
if (ev.transcriptId !== undefined && ev.transcriptId.length > 0)
|
|
309
|
-
remember(fleetIdByTranscriptId, ev.transcriptId, alias);
|
|
310
|
-
if (ev.parentToolCallId !== undefined && ev.parentToolCallId.length > 0)
|
|
311
|
-
remember(fleetIdByParentToolCallId, ev.parentToolCallId, alias);
|
|
312
|
-
deliverEngineAgentPanelEvent(ev);
|
|
313
|
-
for (const [wireId, held] of [...heldWireTicks]) {
|
|
314
|
-
if (wireId === ev.transcriptId || (held.ev.parentToolCallId !== undefined && held.ev.parentToolCallId === ev.parentToolCallId))
|
|
315
|
-
flushHeld(wireId);
|
|
316
|
-
}
|
|
317
|
-
ageHeld(undefined);
|
|
318
|
-
return;
|
|
319
|
-
}
|
|
320
|
-
case 'tick': {
|
|
321
|
-
if (publishedWireIds.has(ev.taskId)) {
|
|
322
|
-
heldWireTicks.delete(ev.taskId);
|
|
323
|
-
deliverEngineAgentPanelEvent(asIsTick(ev));
|
|
324
|
-
return;
|
|
325
|
-
}
|
|
326
|
-
const id = resolveEnginePanelTaskId(ev.taskId, ev.parentToolCallId);
|
|
327
|
-
if (id.origin === 'fleet-row') {
|
|
328
|
-
heldWireTicks.delete(ev.taskId);
|
|
329
|
-
if (staleWireTick(id))
|
|
330
|
-
return;
|
|
331
|
-
rememberResolvedWire(ev.taskId, id);
|
|
332
|
-
deliverEngineAgentPanelEvent(normalizedTick(ev, id.taskId));
|
|
333
|
-
return;
|
|
334
|
-
}
|
|
335
|
-
if (ev.cardBound === true) {
|
|
336
|
-
deliverEngineAgentPanelEvent(asIsTick(ev));
|
|
337
|
-
return;
|
|
338
|
-
}
|
|
339
|
-
if (heldWireTicks.has(ev.taskId)) {
|
|
340
|
-
heldWireTicks.delete(ev.taskId);
|
|
341
|
-
deliverEngineAgentPanelEvent(asIsTick(ev));
|
|
342
|
-
return;
|
|
343
|
-
}
|
|
344
|
-
if (heldWireTicks.size >= MAX_HELD_WIRE_TICKS) {
|
|
345
|
-
const oldest = heldWireTicks.keys().next().value;
|
|
346
|
-
if (oldest !== undefined)
|
|
347
|
-
flushHeld(oldest);
|
|
348
|
-
}
|
|
349
|
-
heldWireTicks.set(ev.taskId, { ev, beats: 0 });
|
|
350
|
-
return;
|
|
351
|
-
}
|
|
352
|
-
case 'end': {
|
|
353
|
-
releaseHeldNewbornTerminal(ev.taskId, ev);
|
|
354
|
-
{
|
|
355
|
-
const pre = resolveEnginePanelTaskId(ev.taskId);
|
|
356
|
-
if (pre.origin === 'fleet-row' && pre.taskId !== ev.taskId) {
|
|
357
|
-
releaseHeldNewbornTerminal(pre.taskId, {
|
|
358
|
-
...(ev.cycleSeq !== undefined ? { cycleSeq: ev.cycleSeq } : pre.cycleSeq !== undefined ? { cycleSeq: pre.cycleSeq } : {}),
|
|
359
|
-
...(ev.startedAt !== undefined ? { startedAt: ev.startedAt } : pre.startedAt !== undefined ? { startedAt: pre.startedAt } : {}),
|
|
360
|
-
});
|
|
361
|
-
}
|
|
362
|
-
for (const [fleetId, o] of wireIdByFleetId)
|
|
363
|
-
if (o.wireId === ev.taskId && !o.retired)
|
|
364
|
-
releaseHeldNewbornTerminal(fleetId, ev);
|
|
365
|
-
const heldMatches = [];
|
|
366
|
-
for (const ref of heldNewbornTerminalRefs()) {
|
|
367
|
-
if (ref.taskId === ev.taskId)
|
|
368
|
-
continue;
|
|
369
|
-
const byTranscript = ref.transcriptId !== undefined && ref.transcriptId === ev.taskId;
|
|
370
|
-
const byParent = ref.parentToolCallId !== undefined &&
|
|
371
|
-
publishedWireByParent.get(ref.parentToolCallId) === ev.taskId &&
|
|
372
|
-
publishedWireIds.get(ev.taskId)?.retired === false;
|
|
373
|
-
if (byTranscript || byParent)
|
|
374
|
-
heldMatches.push(ref.taskId);
|
|
375
|
-
}
|
|
376
|
-
const releasable = [];
|
|
377
|
-
for (const tail of heldMatches) {
|
|
378
|
-
const verdict = heldNewbornTerminalVerdict(tail, ev);
|
|
379
|
-
if (verdict === 'drop')
|
|
380
|
-
dropHeldNewbornTerminalRow(tail);
|
|
381
|
-
else if (verdict === 'release' && heldRowReleasesOntoSameKey(tail, ev))
|
|
382
|
-
releasable.push(tail);
|
|
383
|
-
}
|
|
384
|
-
if (releasable.length === 1)
|
|
385
|
-
releaseHeldNewbornTerminal(releasable[0], ev);
|
|
386
|
-
}
|
|
387
|
-
const wireOwner = wireOwnerOf(ev.taskId, ev);
|
|
388
|
-
if (wireOwner !== undefined) {
|
|
389
|
-
const ownerRec = wireIdByFleetId.get(ev.taskId);
|
|
390
|
-
const staleA = endOlderThanKnown(ev, ev.taskId, ownerRec) || isStaleEngineAgentPanelEnd(ev, panelRowEndedIdentity(wireOwner));
|
|
391
|
-
deliverEngineAgentPanelEvent({ ...ev, taskId: wireOwner, wireTaskId: ev.taskId, taskIdOrigin: 'wire' });
|
|
392
|
-
if (!staleA) {
|
|
393
|
-
retireWire(wireOwner);
|
|
394
|
-
settleRowHistory(ev.taskId, ev);
|
|
395
|
-
settleRowHistory(wireOwner, ev);
|
|
396
|
-
}
|
|
397
|
-
return;
|
|
398
|
-
}
|
|
399
|
-
if (publishedWireIds.has(ev.taskId)) {
|
|
400
|
-
flushHeld(ev.taskId);
|
|
401
|
-
const ownedFleetIds = [];
|
|
402
|
-
for (const [fleetId, o] of wireIdByFleetId) {
|
|
403
|
-
if (o.wireId === ev.taskId && !endOlderThanKnown(ev, fleetId, o))
|
|
404
|
-
ownedFleetIds.push(fleetId);
|
|
405
|
-
}
|
|
406
|
-
const alias = fleetIdByTranscriptId.get(ev.taskId);
|
|
407
|
-
if (alias !== undefined && !endOlderThanKnown(ev, alias.fleetId, alias) && !ownedFleetIds.includes(alias.fleetId))
|
|
408
|
-
ownedFleetIds.push(alias.fleetId);
|
|
409
|
-
deliverEngineAgentPanelEvent(ev);
|
|
410
|
-
retireWire(ev.taskId);
|
|
411
|
-
if (!isStaleEngineAgentPanelEnd(ev, panelRowEndedIdentity(ev.taskId)))
|
|
412
|
-
settleRowHistory(ev.taskId, ev);
|
|
413
|
-
for (const fleetId of ownedFleetIds)
|
|
414
|
-
settleRowHistory(fleetId, ev);
|
|
415
|
-
return;
|
|
416
|
-
}
|
|
417
|
-
const id = resolveEnginePanelTaskId(ev.taskId);
|
|
418
|
-
if (id.origin === 'fleet-row' && id.taskId !== ev.taskId) {
|
|
419
|
-
flushHeld(ev.taskId);
|
|
420
|
-
migrateResidency(ev.taskId, id.taskId);
|
|
421
|
-
const effectiveEnd = {
|
|
422
|
-
...(ev.cycleSeq !== undefined ? { cycleSeq: ev.cycleSeq } : id.cycleSeq !== undefined ? { cycleSeq: id.cycleSeq } : {}),
|
|
423
|
-
...(ev.startedAt !== undefined ? { startedAt: ev.startedAt } : id.startedAt !== undefined ? { startedAt: id.startedAt } : {}),
|
|
424
|
-
};
|
|
425
|
-
const staleC = endOlderThanKnown(effectiveEnd, id.taskId, latestCycleByFleetId.get(id.taskId));
|
|
426
|
-
deliverEngineAgentPanelEvent({
|
|
427
|
-
...ev,
|
|
428
|
-
taskId: id.taskId,
|
|
429
|
-
wireTaskId: ev.taskId,
|
|
430
|
-
taskIdOrigin: 'fleet-row',
|
|
431
|
-
...(ev.cycleSeq === undefined && id.cycleSeq !== undefined ? { cycleSeq: id.cycleSeq } : {}),
|
|
432
|
-
...(ev.startedAt === undefined && id.startedAt !== undefined ? { startedAt: id.startedAt } : {}),
|
|
433
|
-
});
|
|
434
|
-
if (!staleC)
|
|
435
|
-
settleRowHistory(id.taskId, effectiveEnd);
|
|
436
|
-
return;
|
|
437
|
-
}
|
|
438
|
-
flushHeld(ev.taskId);
|
|
439
|
-
const staleD = endOlderThanKnown(ev, ev.taskId, latestCycleByFleetId.get(ev.taskId));
|
|
440
|
-
deliverEngineAgentPanelEvent(ev);
|
|
441
|
-
retireWire(ev.taskId);
|
|
442
|
-
if (!staleD)
|
|
443
|
-
settleRowHistory(ev.taskId, ev);
|
|
444
|
-
return;
|
|
445
|
-
}
|
|
446
|
-
default:
|
|
447
|
-
deliverEngineAgentPanelEvent(ev);
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
function deliverEngineAgentPanelEvent(ev) {
|
|
451
|
-
if (ev.kind !== 'sweep')
|
|
452
|
-
absenceBuffer.delete(ev.taskId);
|
|
453
|
-
if (listener) {
|
|
454
|
-
try {
|
|
455
|
-
listener(ev);
|
|
456
|
-
}
|
|
457
|
-
catch {
|
|
458
|
-
}
|
|
459
|
-
return;
|
|
460
|
-
}
|
|
461
|
-
if (ev.kind === 'sweep' && buffer.length > 0 && buffer[buffer.length - 1]?.kind === 'sweep')
|
|
462
|
-
return;
|
|
463
|
-
const progress = ev.kind === 'tick' || ev.kind === 'fleet-row';
|
|
464
|
-
if (progress) {
|
|
465
|
-
const kind = ev.kind;
|
|
466
|
-
const taskId = ev.taskId;
|
|
467
|
-
let i = -1;
|
|
468
|
-
for (let at = buffer.length - 1; at >= 0; at--) {
|
|
469
|
-
const b = buffer[at];
|
|
470
|
-
if (b === undefined)
|
|
471
|
-
continue;
|
|
472
|
-
if (b.kind === 'sweep')
|
|
473
|
-
break;
|
|
474
|
-
if (b.kind === 'end') {
|
|
475
|
-
if (b.taskId === taskId)
|
|
476
|
-
break;
|
|
477
|
-
continue;
|
|
478
|
-
}
|
|
479
|
-
if (b.taskId !== taskId)
|
|
480
|
-
continue;
|
|
481
|
-
if (b.kind === kind && !launchAnchorChanged(b, ev))
|
|
482
|
-
i = at;
|
|
483
|
-
break;
|
|
484
|
-
}
|
|
485
|
-
if (i >= 0) {
|
|
486
|
-
const merged = { ...buffer[i], ...ev };
|
|
487
|
-
buffer.splice(i, 1);
|
|
488
|
-
buffer.push(merged);
|
|
489
|
-
return;
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
if (buffer.length < MAX_BUFFER) {
|
|
493
|
-
buffer.push(ev);
|
|
494
|
-
return;
|
|
495
|
-
}
|
|
496
|
-
const evictAt = buffer.findIndex(b => b.kind === 'tick' || b.kind === 'fleet-row');
|
|
497
|
-
if (evictAt >= 0) {
|
|
498
|
-
buffer.splice(evictAt, 1);
|
|
499
|
-
buffer.push(ev);
|
|
500
|
-
return;
|
|
501
|
-
}
|
|
502
|
-
buffer.shift();
|
|
503
|
-
buffer.push(ev);
|
|
32
|
+
stepEnginePanel(ev);
|
|
504
33
|
}
|
|
505
34
|
export function subscribeEngineAgentPanel(fn) {
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
try {
|
|
511
|
-
fn(ev);
|
|
512
|
-
}
|
|
513
|
-
catch {
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
return () => {
|
|
518
|
-
if (listener === fn)
|
|
519
|
-
listener = null;
|
|
520
|
-
};
|
|
35
|
+
return subscribeLegacyEvents(fn);
|
|
36
|
+
}
|
|
37
|
+
export function subscribeEnginePanelRows(fn) {
|
|
38
|
+
return subscribeRows(fn);
|
|
521
39
|
}
|
|
522
|
-
const MAX_ABSENCE_BUFFER = 200;
|
|
523
|
-
let absenceListener = null;
|
|
524
|
-
const absenceBuffer = new Map();
|
|
525
40
|
export function publishEngineAgentPanelAbsence(ev) {
|
|
526
|
-
|
|
527
|
-
if (owner !== undefined)
|
|
528
|
-
ev = { ...ev, taskId: owner, wireTaskId: ev.taskId };
|
|
529
|
-
if (absenceListener) {
|
|
530
|
-
try {
|
|
531
|
-
absenceListener(ev);
|
|
532
|
-
}
|
|
533
|
-
catch {
|
|
534
|
-
}
|
|
535
|
-
return;
|
|
536
|
-
}
|
|
537
|
-
absenceBuffer.delete(ev.taskId);
|
|
538
|
-
absenceBuffer.set(ev.taskId, ev);
|
|
539
|
-
if (absenceBuffer.size > MAX_ABSENCE_BUFFER) {
|
|
540
|
-
const oldest = absenceBuffer.keys().next().value;
|
|
541
|
-
if (oldest !== undefined)
|
|
542
|
-
absenceBuffer.delete(oldest);
|
|
543
|
-
}
|
|
41
|
+
stepEnginePanel({ kind: 'absence', absence: ev });
|
|
544
42
|
}
|
|
545
43
|
export function subscribeEngineAgentPanelAbsence(fn) {
|
|
546
|
-
|
|
547
|
-
if (absenceBuffer.size > 0) {
|
|
548
|
-
const pending = [...absenceBuffer.values()];
|
|
549
|
-
absenceBuffer.clear();
|
|
550
|
-
for (const ev of pending) {
|
|
551
|
-
try {
|
|
552
|
-
fn(ev);
|
|
553
|
-
}
|
|
554
|
-
catch {
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
return () => {
|
|
559
|
-
if (absenceListener === fn)
|
|
560
|
-
absenceListener = null;
|
|
561
|
-
};
|
|
44
|
+
return subscribeAbsence(fn);
|
|
562
45
|
}
|
|
563
46
|
export function __resetEngineAgentPanelAbsenceForTests() {
|
|
564
|
-
|
|
565
|
-
absenceBuffer.clear();
|
|
47
|
+
resetAbsenceChannel();
|
|
566
48
|
}
|
|
@@ -8,16 +8,16 @@ interface EngineCapReader<R> {
|
|
|
8
8
|
generation?: number;
|
|
9
9
|
}): void;
|
|
10
10
|
observed(baseUrl: string | undefined): R;
|
|
11
|
-
forget(baseUrl: string | undefined): void;
|
|
12
11
|
__resetForTests(): void;
|
|
13
12
|
}
|
|
14
13
|
export declare function createEngineCapReader<R>(spec: EngineCapReaderSpec<R>): EngineCapReader<R>;
|
|
15
|
-
export type
|
|
16
|
-
|
|
14
|
+
export type StoreSeat = {
|
|
15
|
+
kind: 'object';
|
|
17
16
|
store: object;
|
|
18
17
|
} | {
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
kind: 'absent';
|
|
19
|
+
} | {
|
|
20
|
+
kind: 'malformed';
|
|
21
21
|
};
|
|
22
|
-
export declare function
|
|
22
|
+
export declare function storeSeatOf(caps: object): StoreSeat;
|
|
23
23
|
export {};
|