maka-agent 0.2.0-dev.22.20260905 → 0.2.0-dev.24.20260907
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/dist/acp/maka-acp-agent.js +2 -1
- package/dist/acp/session-configuration.js +143 -0
- package/dist/acp/session-registry.js +90 -4
- package/dist/cli-core.js +2 -0
- package/dist/pi-transcript.js +5 -12
- package/dist/pi-tui-runner.js +74 -4
- package/dist/runtime-host-cli-context.js +167 -78
- package/dist/runtime-host-cli-installation.js +8 -2
- package/dist/runtime-host-cli.js +31 -1
- package/dist/runtime-host-handoff-surface.js +81 -0
- package/dist/runtime-host-installed-update-bootstrap.js +13 -0
- package/dist/runtime-host-installed-update-coordinator.js +33 -0
- package/dist/runtime-host-lifecycle-transaction.js +9 -1
- package/dist/runtime-host-local-handoff.js +37 -4
- package/dist/runtime-host-local-managed-activation.js +84 -0
- package/dist/runtime-host-local-source-retirement.js +18 -2
- package/dist/runtime-host-managed-lifecycle-manager.js +1 -0
- package/dist/runtime-host-operator-retirement.js +50 -0
- package/dist/runtime-host-service-manager.js +3 -0
- package/dist/runtime-host-session-driver.js +4 -25
- package/dist/runtime-host-session-update.js +62 -0
- package/dist/runtime-host-tui-command.js +38 -73
- package/dist/runtime-host-tui-context.js +1 -0
- package/dist/runtime-host-tui-owner.js +226 -0
- package/dist/tui-copy-catalog.js +140 -3
- package/dist/tui-host-owner-copy.js +24 -0
- package/native/runtime-host-peer/prebuilds/darwin-arm64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-peer/prebuilds/linux-arm64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-peer/prebuilds/linux-x64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-peer/prebuilds/win32-x64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
- package/node_modules/@maka/core/dist/bot-events.js +18 -63
- package/node_modules/@maka/core/dist/canonical-runtime-event.js +3 -1
- package/node_modules/@maka/core/dist/model-call-attempt.js +0 -82
- package/node_modules/@maka/core/dist/model-call-usage-projection.js +0 -186
- package/node_modules/@maka/core/dist/model-failure.js +40 -0
- package/node_modules/@maka/core/dist/model-metadata.generated.js +4 -4
- package/node_modules/@maka/core/dist/model-metadata.js +3 -3
- package/node_modules/@maka/core/dist/model-web-search.js +5 -4
- package/node_modules/@maka/core/dist/provider-registry.js +45 -4
- package/node_modules/@maka/core/dist/record-schema.js +22 -2
- package/node_modules/@maka/core/dist/redaction.js +41 -58
- package/node_modules/@maka/core/dist/runtime-boundary.js +31 -11
- package/node_modules/@maka/core/dist/runtime-event.js +37 -6
- package/node_modules/@maka/core/dist/runtime-handoff.js +98 -0
- package/node_modules/@maka/core/dist/runtime-invocation.js +1 -1
- package/node_modules/@maka/core/dist/runtime-logical-execution.js +112 -0
- package/node_modules/@maka/core/dist/session-trace.js +5 -1
- package/node_modules/@maka/core/dist/session.js +54 -52
- package/node_modules/@maka/core/dist/slash-command-catalog.js +2 -0
- package/node_modules/@maka/core/dist/tool-result-archive-evidence.js +20 -0
- package/node_modules/@maka/core/dist/usage-ledger-merge.js +7 -9
- package/node_modules/@maka/core/dist/usage-record-schema.js +26 -35
- package/node_modules/@maka/core/dist/workhub-creation-intent.js +34 -20
- package/node_modules/@maka/core/package.json +4 -0
- package/node_modules/@maka/eval/harbor/egress-proxy/entrypoint.sh +2 -1
- package/node_modules/@maka/mcp/dist/index.js +131 -1
- package/node_modules/@maka/runtime/dist/agent-run.js +272 -105
- package/node_modules/@maka/runtime/dist/ai-sdk-backend.js +13 -5
- package/node_modules/@maka/runtime/dist/ai-sdk-compaction.js +109 -34
- package/node_modules/@maka/runtime/dist/ai-sdk-turn.js +155 -134
- package/node_modules/@maka/runtime/dist/bots/base-adapter.js +17 -0
- package/node_modules/@maka/runtime/dist/bots/bot-test.js +38 -22
- package/node_modules/@maka/runtime/dist/bots/dingtalk-bridge.js +7 -5
- package/node_modules/@maka/runtime/dist/bots/discord-bridge.js +4 -4
- package/node_modules/@maka/runtime/dist/bots/feishu-bridge.js +4 -5
- package/node_modules/@maka/runtime/dist/bots/qq-bridge.js +6 -4
- package/node_modules/@maka/runtime/dist/bots/slack-bridge.js +3 -4
- package/node_modules/@maka/runtime/dist/bots/telegram-bridge.js +4 -5
- package/node_modules/@maka/runtime/dist/bots/wechat-bridge.js +17 -19
- package/node_modules/@maka/runtime/dist/bots/wecom-bridge.js +5 -6
- package/node_modules/@maka/runtime/dist/bots/ws-bridge-base.js +2 -3
- package/node_modules/@maka/runtime/dist/context-budget.js +14 -9
- package/node_modules/@maka/runtime/dist/conversation-copy.js +5 -4
- package/node_modules/@maka/runtime/dist/goal-continuation.js +36 -4
- package/node_modules/@maka/runtime/dist/history-compact-checkpoint.js +18 -9
- package/node_modules/@maka/runtime/dist/history-compact-summarizer.js +30 -22
- package/node_modules/@maka/runtime/dist/history-compaction.js +29 -4
- package/node_modules/@maka/runtime/dist/ledger-tool-result-archive-reader.js +106 -0
- package/node_modules/@maka/runtime/dist/message-authority.js +9 -0
- package/node_modules/@maka/runtime/dist/model-adapter.js +19 -98
- package/node_modules/@maka/runtime/dist/model-factory.js +19 -81
- package/node_modules/@maka/runtime/dist/model-fetcher.js +7 -0
- package/node_modules/@maka/runtime/dist/model-runtime.js +85 -111
- package/node_modules/@maka/runtime/dist/native-web-search-tool.js +2 -1
- package/node_modules/@maka/runtime/dist/openai-codex-history-compactor.js +2 -2
- package/node_modules/@maka/runtime/dist/opencode-session-header.js +4 -2
- package/node_modules/@maka/runtime/dist/provider-error-classification.js +84 -123
- package/node_modules/@maka/runtime/dist/provider-request-telemetry.js +68 -108
- package/node_modules/@maka/runtime/dist/run-handoff-gate.js +97 -0
- package/node_modules/@maka/runtime/dist/runtime-event-backfill.js +82 -54
- package/node_modules/@maka/runtime/dist/runtime-event-read-model.js +117 -159
- package/node_modules/@maka/runtime/dist/runtime-kernel.js +150 -112
- package/node_modules/@maka/runtime/dist/runtime-ledger-repair.js +160 -79
- package/node_modules/@maka/runtime/dist/runtime-read-model.js +30 -89
- package/node_modules/@maka/runtime/dist/runtime-resume.js +80 -4
- package/node_modules/@maka/runtime/dist/session-event-runtime-mapper.js +5 -0
- package/node_modules/@maka/runtime/dist/session-manager.js +171 -288
- package/node_modules/@maka/runtime/dist/session-projection-helpers.js +0 -27
- package/node_modules/@maka/runtime/dist/session-trace-projection.js +3 -30
- package/node_modules/@maka/runtime/dist/subscription-model-fetch.js +3 -4
- package/node_modules/@maka/runtime/dist/test-connection.js +16 -16
- package/node_modules/@maka/runtime/dist/tool-result-archive-encoding.js +38 -0
- package/node_modules/@maka/runtime/dist/tool-runtime.js +3 -61
- package/node_modules/@maka/runtime/package.json +1 -0
- package/node_modules/@maka/runtime-host/dist/adapter/session-projector.js +35 -0
- package/node_modules/@maka/runtime-host/dist/candidate-entry.js +4 -1
- package/node_modules/@maka/runtime-host/dist/client/connect-or-spawn.js +9 -1
- package/node_modules/@maka/runtime-host/dist/client/connection.js +3 -0
- package/node_modules/@maka/runtime-host/dist/client/host-handoff-copy.js +156 -0
- package/node_modules/@maka/runtime-host/dist/client/host-handoff.js +273 -0
- package/node_modules/@maka/runtime-host/dist/client/host-retirement.js +26 -5
- package/node_modules/@maka/runtime-host/dist/client/index.js +3 -1
- package/node_modules/@maka/runtime-host/dist/client/launcher.js +3 -0
- package/node_modules/@maka/runtime-host/dist/client/peer-client.js +13 -0
- package/node_modules/@maka/runtime-host/dist/client/registered-host-termination.js +0 -59
- package/node_modules/@maka/runtime-host/dist/client/remote-compatibility-error.js +2 -0
- package/node_modules/@maka/runtime-host/dist/client/session-subscription.js +27 -5
- package/node_modules/@maka/runtime-host/dist/operator/index.js +2 -1
- package/node_modules/@maka/runtime-host/dist/operator/retirement-cancellation.js +20 -0
- package/node_modules/@maka/runtime-host/dist/peer-mesh/node.js +28 -16
- package/node_modules/@maka/runtime-host/dist/protocol/external-session.js +4 -0
- package/node_modules/@maka/runtime-host/dist/protocol/host-status.js +29 -12
- package/node_modules/@maka/runtime-host/dist/protocol/index.js +37 -1
- package/node_modules/@maka/runtime-host/dist/protocol/operations.js +2 -0
- package/node_modules/@maka/runtime-host/dist/protocol/session-collaboration.js +28 -1
- package/node_modules/@maka/runtime-host/dist/protocol/session-continuity.js +40 -20
- package/node_modules/@maka/runtime-host/dist/protocol/session-transcript.js +0 -5
- package/node_modules/@maka/runtime-host/dist/protocol/session-turns.js +29 -58
- package/node_modules/@maka/runtime-host/dist/protocol/turn.js +11 -1
- package/node_modules/@maka/runtime-host/dist/protocol/workhub-coordination.js +33 -0
- package/node_modules/@maka/runtime-host/dist/server/access-authority.js +26 -1
- package/node_modules/@maka/runtime-host/dist/server/access-credential-store.js +6 -1
- package/node_modules/@maka/runtime-host/dist/server/canonical-turn-snapshot.js +19 -4
- package/node_modules/@maka/runtime-host/dist/server/canonical-usage-reader.js +24 -11
- package/node_modules/@maka/runtime-host/dist/server/connection-session.js +7 -6
- package/node_modules/@maka/runtime-host/dist/server/daily-review-coordinator.js +7 -4
- package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +168 -28
- package/node_modules/@maka/runtime-host/dist/server/execution-model-authority.js +5 -5
- package/node_modules/@maka/runtime-host/dist/server/execution-model-composition.js +3 -2
- package/node_modules/@maka/runtime-host/dist/server/external-session-coordinator.js +6 -3
- package/node_modules/@maka/runtime-host/dist/server/goal-coordinator.js +40 -1
- package/node_modules/@maka/runtime-host/dist/server/host-kernel.js +108 -23
- package/node_modules/@maka/runtime-host/dist/server/host-residency-registry.js +13 -7
- package/node_modules/@maka/runtime-host/dist/server/hosted-execution-admission-registry.js +3 -1
- package/node_modules/@maka/runtime-host/dist/server/hosted-execution-recovery.js +124 -62
- package/node_modules/@maka/runtime-host/dist/server/message-coordinator.js +85 -8
- package/node_modules/@maka/runtime-host/dist/server/root-admission-owner.js +7 -0
- package/node_modules/@maka/runtime-host/dist/server/root-turn-coordinator.js +344 -71
- package/node_modules/@maka/runtime-host/dist/server/scheduled-task-coordinator.js +37 -2
- package/node_modules/@maka/runtime-host/dist/server/serial-outbound-writer.js +45 -3
- package/node_modules/@maka/runtime-host/dist/server/session-catalog-coordinator.js +201 -12
- package/node_modules/@maka/runtime-host/dist/server/session-continuity-coordinator.js +87 -25
- package/node_modules/@maka/runtime-host/dist/server/session-revision-coordinator.js +8 -55
- package/node_modules/@maka/runtime-host/dist/server/session-sidecar-purge.js +1 -16
- package/node_modules/@maka/runtime-host/dist/server/session-transcript-pager.js +0 -1
- package/node_modules/@maka/runtime-host/dist/server/session-transcript-reader.js +460 -70
- package/node_modules/@maka/runtime-host/dist/server/shared-session-transcript.js +1 -1
- package/node_modules/@maka/runtime-host/dist/server/storage-maintenance.js +109 -0
- package/node_modules/@maka/runtime-host/dist/server/usage-pricing-coordinator.js +4 -11
- package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-action-gate.js +44 -15
- package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-coordinator.js +6 -2
- package/node_modules/@maka/storage/dist/agent-run-store.js +44 -0
- package/node_modules/@maka/storage/dist/artifact-store.js +21 -10
- package/node_modules/@maka/storage/dist/artifact-stores.js +1 -1
- package/node_modules/@maka/storage/dist/claude-code-session-adapter.js +0 -4
- package/node_modules/@maka/storage/dist/codex-session-adapter.js +0 -2
- package/node_modules/@maka/storage/dist/context-offload-snapshot.js +325 -0
- package/node_modules/@maka/storage/dist/conversation-operational-state.js +4 -0
- package/node_modules/@maka/storage/dist/execution-stores.js +11 -7
- package/node_modules/@maka/storage/dist/file-session-repository.js +1012 -0
- package/node_modules/@maka/storage/dist/model-call-ledger.js +199 -32
- package/node_modules/@maka/storage/dist/model-call-usage-sql.js +136 -0
- package/node_modules/@maka/storage/dist/opencode-session-adapter.js +0 -4
- package/node_modules/@maka/storage/dist/operational-state-backup.js +9 -5
- package/node_modules/@maka/storage/dist/operational-state-store-public.js +1 -1
- package/node_modules/@maka/storage/dist/operational-state-store.js +5 -3
- package/node_modules/@maka/storage/dist/runtime-event-persistence.js +1 -0
- package/node_modules/@maka/storage/dist/runtime-transcript-query.js +308 -0
- package/node_modules/@maka/storage/dist/session-bundle-policy.js +24 -4
- package/node_modules/@maka/storage/dist/session-message-projection.js +15 -0
- package/node_modules/@maka/storage/dist/session-repository.js +767 -0
- package/node_modules/@maka/storage/dist/session-store.js +25 -99
- package/node_modules/@maka/storage/dist/sqlite-artifact-metadata.js +10 -3
- package/node_modules/@maka/storage/dist/sqlite-context-offload-store.js +24 -8
- package/node_modules/@maka/storage/dist/sqlite-core-execution-schema.js +17 -1
- package/node_modules/@maka/storage/dist/sqlite-runtime-schema.js +44 -1
- package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +129 -25
- package/node_modules/@maka/storage/dist/sqlite-session-metadata-store.js +109 -892
- package/node_modules/@maka/storage/dist/sqlite-usage-schema.js +200 -20
- package/node_modules/@maka/storage/dist/tool-result-archive-evidence.js +111 -0
- package/node_modules/@maka/storage/dist/usage-stores.js +6 -2
- package/node_modules/@maka/storage/package.json +2 -0
- package/package.json +1 -1
|
@@ -22,6 +22,7 @@ import { messageContentDigest, normalizeMessageContent } from '@maka/core/events
|
|
|
22
22
|
import { NO_REAL_CONNECTION_CODE } from '@maka/core/connection-error-copy';
|
|
23
23
|
import { generalizedErrorMessage } from '@maka/core/redaction';
|
|
24
24
|
import { emptyPlanSessionState } from '@maka/core/plan';
|
|
25
|
+
import { readLogicalRuntimeExecutionForRun } from '@maka/core/runtime-logical-execution';
|
|
25
26
|
import { runtimeInvocationOutcome, } from '@maka/core/runtime-invocation';
|
|
26
27
|
import { isDeepResearchSession, WORKHUB_COORDINATION_SESSION_ID, WORKHUB_COORDINATION_REPLACEMENT_SCHEMA_VERSION, } from '@maka/core/session';
|
|
27
28
|
import { AgentGraphCoordinator } from '@maka/runtime/stream-graph-coordinator';
|
|
@@ -77,7 +78,7 @@ import { HostGoalCoordinator } from './goal-coordinator.js';
|
|
|
77
78
|
import { HostGoalExecutionCoordinator } from './goal-execution-coordinator.js';
|
|
78
79
|
import { HostHostedExecutionCoordinator } from './hosted-execution-coordinator.js';
|
|
79
80
|
import { HostHostedExecutionRunner } from './hosted-execution-runner.js';
|
|
80
|
-
import { executeHostedExecutionToSettlement } from './hosted-execution-wait.js';
|
|
81
|
+
import { executeHostedExecutionToSettlement, waitForHostedExecutionIdleOrAbort, } from './hosted-execution-wait.js';
|
|
81
82
|
import { beginRuntimeHostDomainModuleDrain, closeRuntimeHostDomainModules, composeRuntimeHostDomainHandlers, createRuntimeHostDomainModule, recoverRuntimeHostDomainModules, } from './host-composition.js';
|
|
82
83
|
import { HostInteractionCoordinator } from './interaction-coordinator.js';
|
|
83
84
|
import { HostInteractiveTurnCoordinator } from './interactive-turn-coordinator.js';
|
|
@@ -108,10 +109,11 @@ import { SessionAdmissionGate } from './session-admission-gate.js';
|
|
|
108
109
|
import { HostSessionCatalogCoordinator } from './session-catalog-coordinator.js';
|
|
109
110
|
import { HostWorkspaceResolver } from './workspace-resolver.js';
|
|
110
111
|
import { HostSessionRetirementCoordinator } from './session-retirement-coordinator.js';
|
|
112
|
+
import { HostStorageMaintenance } from './storage-maintenance.js';
|
|
111
113
|
import { HostSessionRevisionCoordinator } from './session-revision-coordinator.js';
|
|
112
114
|
import { HostSessionEffectCoordinator } from './session-effect-coordinator.js';
|
|
113
115
|
import { SessionContinuityCoordinator } from './session-continuity-coordinator.js';
|
|
114
|
-
import { createSessionTranscriptReader } from './session-transcript-reader.js';
|
|
116
|
+
import { createSessionTranscriptReader, } from './session-transcript-reader.js';
|
|
115
117
|
import { HostSkillCatalogCoordinator } from './skill-catalog-coordinator.js';
|
|
116
118
|
import { SkillCatalogRepository } from './skill-catalog-repository.js';
|
|
117
119
|
import { HostSessionTodoCoordinator } from './session-todo-coordinator.js';
|
|
@@ -119,7 +121,7 @@ import { HostTurnControlCoordinator } from './turn-control-coordinator.js';
|
|
|
119
121
|
import { HostUsagePricingCoordinator } from './usage-pricing-coordinator.js';
|
|
120
122
|
import { HostWebSearchCoordinator } from './web-search-coordinator.js';
|
|
121
123
|
import { HostWorkHubCoordinationCoordinator } from './workhub-coordination-coordinator.js';
|
|
122
|
-
import { WorkHubActionEffectFailure } from './workhub-coordination-action-gate.js';
|
|
124
|
+
import { WorkHubActionEffectFailure, workHubResumedTurnId, } from './workhub-coordination-action-gate.js';
|
|
123
125
|
import { createHostWebSearchService, createHostWebSearchToolFromService, resolveHostTavilyWebSearchReadiness, shouldResolveHostTavilyWebSearchReadiness, } from './web-search-tool.js';
|
|
124
126
|
import { createHostWebFetchService, createHostWebFetchToolFromService } from './web-fetch-tool.js';
|
|
125
127
|
import { createHostExecutionArtifactServices } from './execution-artifacts.js';
|
|
@@ -160,6 +162,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
160
162
|
let sessionEffects;
|
|
161
163
|
let memoryExtraction;
|
|
162
164
|
let unsubscribeTranscriptChanges;
|
|
165
|
+
let transcriptReader;
|
|
163
166
|
let unsubscribeUsageChanges;
|
|
164
167
|
let workspaceExecution;
|
|
165
168
|
let goalExecutions;
|
|
@@ -198,9 +201,6 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
198
201
|
cause: storage.contextOffloadUnavailable?.cause,
|
|
199
202
|
});
|
|
200
203
|
},
|
|
201
|
-
collectGarbage: async () => {
|
|
202
|
-
throw new Error('Context-offload Store is unavailable during context garbage collection', { cause: storage.contextOffloadUnavailable?.cause });
|
|
203
|
-
},
|
|
204
204
|
}
|
|
205
205
|
: undefined;
|
|
206
206
|
const openedUsageStores = storage.usage;
|
|
@@ -391,6 +391,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
391
391
|
let deepResearch;
|
|
392
392
|
let dailyReview;
|
|
393
393
|
const rootPort = {
|
|
394
|
+
readLatestRootTurnLineage: (identity) => requireRootCoordinator(rootCoordinator).readLatestRootTurnLineage(identity),
|
|
394
395
|
readSessionHeader: (sessionId) => requireRootCoordinator(rootCoordinator).readSessionHeader(sessionId),
|
|
395
396
|
readRootState: (sessionId) => requireRootCoordinator(rootCoordinator).readRootState(sessionId),
|
|
396
397
|
claimStopFence: (input, commitQueueFence, admission) => requireRootCoordinator(rootCoordinator).claimStopFence(input, commitQueueFence, admission),
|
|
@@ -403,6 +404,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
403
404
|
hostEpoch: context.hostEpoch,
|
|
404
405
|
root: rootPort,
|
|
405
406
|
durableProof: {
|
|
407
|
+
readLogicalExecution: (identity) => readLogicalRuntimeExecutionForRun(stores.runtimeEventStore, identity),
|
|
406
408
|
readRootTurnSourceMessageReceipt: (sessionId, messageId) => stores.agentRunStore.readRootTurnSourceMessageReceipt(sessionId, messageId),
|
|
407
409
|
readImmutableSteeringMessageProof: (sessionId, messageId) => stores.runtimeEventStore.readImmutableSteeringMessageProof(sessionId, messageId),
|
|
408
410
|
},
|
|
@@ -424,7 +426,12 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
424
426
|
const canonicalPermissionOutcomes = new HostCanonicalPermissionOutcomeReader({
|
|
425
427
|
store: stores.interactionStore,
|
|
426
428
|
});
|
|
427
|
-
|
|
429
|
+
transcriptReader = createSessionTranscriptReader({
|
|
430
|
+
stores,
|
|
431
|
+
canonicalPermissionOutcomes,
|
|
432
|
+
ensureTranscriptLedger: (sessionId) => requireSessionManager(manager).ensureTranscriptLedgerForRead(sessionId),
|
|
433
|
+
});
|
|
434
|
+
continuity = new SessionContinuityCoordinator(context.hostEpoch, (sessionId) => canonicalProjectionReader.read(sessionId), sessionAdmission, context.requestDrain, transcriptReader, (sessionId) => hostChanges.publishSessionCatalog(sessionId), context.sessionAccessAuthority);
|
|
428
435
|
const continuityCoordinator = continuity;
|
|
429
436
|
unsubscribeTranscriptChanges = stores.sessionStore.subscribeTranscriptChanges((sessionId) => continuityCoordinator.enqueueCanonicalRefresh(sessionId));
|
|
430
437
|
unsubscribeUsageChanges = openedUsageStores.subscribeSessionUsageChanges((sessionId) => continuityCoordinator.enqueueSessionDomainChanged(sessionId, 'usage'));
|
|
@@ -712,6 +719,10 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
712
719
|
throw new Error(preview.message);
|
|
713
720
|
return preview.value;
|
|
714
721
|
};
|
|
722
|
+
const recapReadModel = new RuntimeReadModel({
|
|
723
|
+
runtimeEventStore: stores.runtimeEventStore,
|
|
724
|
+
canonicalPermissionOutcomes,
|
|
725
|
+
});
|
|
715
726
|
const sessionEffectCoordinator = new HostSessionEffectCoordinator({
|
|
716
727
|
model: createHostSessionEffectModel({
|
|
717
728
|
runtimePolicy: runtimePolicyStores,
|
|
@@ -719,11 +730,14 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
719
730
|
usage: openedUsageStores,
|
|
720
731
|
requestDrain: context.requestDrain,
|
|
721
732
|
}),
|
|
722
|
-
readModel:
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
733
|
+
readModel: {
|
|
734
|
+
getSessionView: async (sessionId) => {
|
|
735
|
+
// A Session whose transcript predates the ledger projects an empty
|
|
736
|
+
// view, and a recap of nothing reads as a successful recap.
|
|
737
|
+
await requireSessionManager(manager).ensureTranscriptLedgerForRead(sessionId);
|
|
738
|
+
return recapReadModel.getSessionView(sessionId);
|
|
739
|
+
},
|
|
740
|
+
},
|
|
727
741
|
artifacts: openedArtifactStore,
|
|
728
742
|
sessions: stores.sessionStore,
|
|
729
743
|
readSessionHeader: (sessionId) => stores.sessionStore.readHeaderSnapshot(sessionId),
|
|
@@ -989,6 +1003,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
989
1003
|
goal = new HostGoalCoordinator({
|
|
990
1004
|
store: openedGoalStore,
|
|
991
1005
|
stores,
|
|
1006
|
+
readSessionMessages: (sessionId) => requireSessionManager(manager).getMessages(sessionId),
|
|
992
1007
|
executions: coordinator,
|
|
993
1008
|
sessionAdmission,
|
|
994
1009
|
evaluator: createHostGoalEvaluator({
|
|
@@ -1021,6 +1036,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
1021
1036
|
});
|
|
1022
1037
|
const sessionCatalog = new HostSessionCatalogCoordinator({
|
|
1023
1038
|
stores: stores.sessionStore,
|
|
1039
|
+
turnIndex: requireTranscriptReader(transcriptReader),
|
|
1024
1040
|
runtimePolicy: runtimePolicyStores,
|
|
1025
1041
|
manager,
|
|
1026
1042
|
admission: sessionAdmission,
|
|
@@ -1054,13 +1070,77 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
1054
1070
|
turnId: disposition.turnId,
|
|
1055
1071
|
runId: disposition.runId,
|
|
1056
1072
|
};
|
|
1057
|
-
|
|
1073
|
+
const latest = await coordinator.readLatestRootTurnLineage(identity);
|
|
1074
|
+
if (isActiveWorkHubRoot(coordinator, latest))
|
|
1058
1075
|
return 'not_retired';
|
|
1059
1076
|
// The same restart window as `stopOwnedWorkHubRoot`: an unregistered
|
|
1060
1077
|
// root is not evidence that its work ended.
|
|
1061
|
-
const snapshot = await coordinator.read(
|
|
1078
|
+
const snapshot = await coordinator.read(latest);
|
|
1062
1079
|
return isHostedExecutionTerminal(snapshot) ? 'retired' : 'recovering';
|
|
1063
1080
|
},
|
|
1081
|
+
// Resolve and resume only the execution lineage owned by this
|
|
1082
|
+
// delegation. A Session-wide latest-failure query could otherwise
|
|
1083
|
+
// continue unrelated work started directly in the same Session.
|
|
1084
|
+
resumeDelegation: async (assignment, context, actionId) => {
|
|
1085
|
+
const disposition = await messages.readMessageExecutionDisposition(assignment.targetSessionId, assignment.targetMessageId);
|
|
1086
|
+
if (disposition.kind === 'recovering') {
|
|
1087
|
+
throw new WorkHubActionEffectFailure('host_not_ready', 'WorkHub is still recovering the delegated execution');
|
|
1088
|
+
}
|
|
1089
|
+
if (disposition.kind !== 'owned_root') {
|
|
1090
|
+
throw new WorkHubActionEffectFailure('operation_conflict', 'WorkHub delegated execution is not resumable');
|
|
1091
|
+
}
|
|
1092
|
+
const source = await coordinator.readLatestRootTurnLineage({
|
|
1093
|
+
sessionId: assignment.targetSessionId,
|
|
1094
|
+
turnId: disposition.turnId,
|
|
1095
|
+
runId: disposition.runId,
|
|
1096
|
+
});
|
|
1097
|
+
if (isActiveWorkHubRoot(coordinator, source)) {
|
|
1098
|
+
return { outcome: 'already_running' };
|
|
1099
|
+
}
|
|
1100
|
+
const snapshot = await coordinator.read(source);
|
|
1101
|
+
if (!isHostedExecutionTerminal(snapshot)) {
|
|
1102
|
+
throw new WorkHubActionEffectFailure('host_not_ready', 'WorkHub is still recovering the delegated execution');
|
|
1103
|
+
}
|
|
1104
|
+
if (snapshot.status !== 'failed' && snapshot.status !== 'cancelled') {
|
|
1105
|
+
throw new WorkHubActionEffectFailure('operation_conflict', 'WorkHub delegated execution is not resumable');
|
|
1106
|
+
}
|
|
1107
|
+
const plan = await coordinator.handlers['turn.resume.query']({ sessionId: assignment.targetSessionId, sourceRunId: source.runId }, context);
|
|
1108
|
+
if (!plan.ok)
|
|
1109
|
+
throw new WorkHubActionEffectFailure(plan.error.code, plan.error.message);
|
|
1110
|
+
if (plan.result.disposition === 'parked') {
|
|
1111
|
+
throw new WorkHubActionEffectFailure(plan.result.reason === 'resume_feature_disabled'
|
|
1112
|
+
? 'operation_unavailable'
|
|
1113
|
+
: 'operation_conflict', plan.result.reason === 'resume_feature_disabled'
|
|
1114
|
+
? 'Safe-boundary resume is disabled for this Runtime Host'
|
|
1115
|
+
: 'WorkHub delegated execution is not resumable');
|
|
1116
|
+
}
|
|
1117
|
+
// Root planning authenticates handoff membership. Its source may be
|
|
1118
|
+
// a physical successor of this same logical Turn, never another Turn.
|
|
1119
|
+
if (plan.result.sourceTurnId !== source.turnId) {
|
|
1120
|
+
throw new WorkHubActionEffectFailure('operation_conflict', 'WorkHub resume source lineage changed during planning');
|
|
1121
|
+
}
|
|
1122
|
+
const targetTurnId = workHubResumedTurnId(actionId);
|
|
1123
|
+
const started = await coordinator.handlers['turn.resume.start']({
|
|
1124
|
+
sessionId: assignment.targetSessionId,
|
|
1125
|
+
turnId: targetTurnId,
|
|
1126
|
+
sourceRunId: plan.result.sourceRunId,
|
|
1127
|
+
sourceRuntimeEventHighWater: plan.result.sourceRuntimeEventHighWater,
|
|
1128
|
+
}, context);
|
|
1129
|
+
if (!started.ok) {
|
|
1130
|
+
throw new WorkHubActionEffectFailure(started.error.code, started.error.message);
|
|
1131
|
+
}
|
|
1132
|
+
if (started.result.kind === 'parked') {
|
|
1133
|
+
throw new WorkHubActionEffectFailure(started.result.plan.reason === 'resume_feature_disabled'
|
|
1134
|
+
? 'operation_unavailable'
|
|
1135
|
+
: 'operation_conflict', started.result.plan.reason === 'resume_feature_disabled'
|
|
1136
|
+
? 'Safe-boundary resume is disabled for this Runtime Host'
|
|
1137
|
+
: 'WorkHub delegated execution is not resumable');
|
|
1138
|
+
}
|
|
1139
|
+
return {
|
|
1140
|
+
outcome: 'resume_started',
|
|
1141
|
+
targetTurnId: started.result.turn.turnId,
|
|
1142
|
+
};
|
|
1143
|
+
},
|
|
1064
1144
|
retireDelegation: async (assignment, retirement) => {
|
|
1065
1145
|
const disposition = await messages.cancelMessageIfPending(assignment.targetSessionId, assignment.targetMessageId, retirement.cancellationClaimId);
|
|
1066
1146
|
if (disposition.kind === 'recovering') {
|
|
@@ -1076,11 +1156,11 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
1076
1156
|
return { outcome: 'not_owned', targetTurnId: disposition.turnId };
|
|
1077
1157
|
}
|
|
1078
1158
|
if (disposition.kind === 'owned_root') {
|
|
1079
|
-
const identity = {
|
|
1159
|
+
const identity = await coordinator.readLatestRootTurnLineage({
|
|
1080
1160
|
sessionId: assignment.targetSessionId,
|
|
1081
1161
|
turnId: disposition.turnId,
|
|
1082
1162
|
runId: disposition.runId,
|
|
1083
|
-
};
|
|
1163
|
+
});
|
|
1084
1164
|
return retirement.cause === 'direct_stop'
|
|
1085
1165
|
? stopOwnedWorkHubRoot(coordinator, identity, retirement.cancellationClaimId)
|
|
1086
1166
|
: stopReplacedWorkHubRoot(coordinator, identity);
|
|
@@ -1205,7 +1285,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
1205
1285
|
},
|
|
1206
1286
|
},
|
|
1207
1287
|
resolveCreateTarget: async () => {
|
|
1208
|
-
const { projectId: _projectId, ...target } = await sessionCatalog.
|
|
1288
|
+
const { projectId: _projectId, ...target } = await sessionCatalog.resolveDefaultCreateTarget();
|
|
1209
1289
|
return { ...target, permissionMode: 'explore' };
|
|
1210
1290
|
},
|
|
1211
1291
|
requestDrain: context.requestDrain,
|
|
@@ -1332,7 +1412,17 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
1332
1412
|
});
|
|
1333
1413
|
const hostedExecutions = new HostHostedExecutionCoordinator((input, signal) => hostedExecutionRunner.run(input, signal), context.requestDrain);
|
|
1334
1414
|
let recoverySessions = [];
|
|
1415
|
+
const storageMaintenance = new HostStorageMaintenance({
|
|
1416
|
+
artifacts: openedArtifactStore,
|
|
1417
|
+
contextOffload: openedContextOffloadStore,
|
|
1418
|
+
onError: (name, error) => console.error(`[runtime-host] ${name} will retry: ${generalizedErrorMessage(error)}`),
|
|
1419
|
+
});
|
|
1335
1420
|
domainModules = [
|
|
1421
|
+
createRuntimeHostDomainModule({
|
|
1422
|
+
id: 'storage-maintenance',
|
|
1423
|
+
drain: [() => storageMaintenance.beginDrain()],
|
|
1424
|
+
close: [() => storageMaintenance.close()],
|
|
1425
|
+
}),
|
|
1336
1426
|
createRuntimeHostDomainModule({
|
|
1337
1427
|
id: 'plugin-platform',
|
|
1338
1428
|
handlers: [pluginPlatformCoordinator.handlers],
|
|
@@ -1394,17 +1484,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
1394
1484
|
configuration.handlers,
|
|
1395
1485
|
],
|
|
1396
1486
|
recovery: {
|
|
1397
|
-
state:
|
|
1398
|
-
await skills.recover();
|
|
1399
|
-
try {
|
|
1400
|
-
await openedArtifactStore.reclaimUpgradeResidue();
|
|
1401
|
-
}
|
|
1402
|
-
catch (error) {
|
|
1403
|
-
// Leftover bytes are not worth refusing to start over; the next
|
|
1404
|
-
// start tries again.
|
|
1405
|
-
console.error(`[runtime-host] upgrade residue could not be reclaimed: ${generalizedErrorMessage(error)}`);
|
|
1406
|
-
}
|
|
1407
|
-
},
|
|
1487
|
+
state: () => skills.recover(),
|
|
1408
1488
|
},
|
|
1409
1489
|
drain: [
|
|
1410
1490
|
() => connectionEffects.beginDrain(),
|
|
@@ -1600,12 +1680,67 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
1600
1680
|
continuity: continuityCoordinator,
|
|
1601
1681
|
clientCapabilities,
|
|
1602
1682
|
hostChanges,
|
|
1683
|
+
prepareHandoff: async (hostEpoch, signal) => {
|
|
1684
|
+
if (draining || signal.aborted)
|
|
1685
|
+
return undefined;
|
|
1686
|
+
const goalHold = goal?.holdForHandoff();
|
|
1687
|
+
const scheduleHold = scheduledTasks?.holdForHandoff();
|
|
1688
|
+
let root;
|
|
1689
|
+
let detached = false;
|
|
1690
|
+
const cancel = () => {
|
|
1691
|
+
if (detached)
|
|
1692
|
+
return;
|
|
1693
|
+
root?.cancel();
|
|
1694
|
+
goalHold?.release();
|
|
1695
|
+
scheduleHold?.release();
|
|
1696
|
+
signal.removeEventListener('abort', cancel);
|
|
1697
|
+
};
|
|
1698
|
+
signal.addEventListener('abort', cancel, { once: true });
|
|
1699
|
+
try {
|
|
1700
|
+
if (!goalHold || !scheduleHold) {
|
|
1701
|
+
cancel();
|
|
1702
|
+
return undefined;
|
|
1703
|
+
}
|
|
1704
|
+
await waitForHostedExecutionIdleOrAbort(Promise.all([goalHold.settled(), scheduleHold.settled()]).then(() => undefined), signal);
|
|
1705
|
+
root = await requireRootCoordinator(coordinator).prepareHandoff(hostEpoch, signal);
|
|
1706
|
+
if (!root) {
|
|
1707
|
+
cancel();
|
|
1708
|
+
return undefined;
|
|
1709
|
+
}
|
|
1710
|
+
const prepared = root;
|
|
1711
|
+
return {
|
|
1712
|
+
seal: () => prepared.seal(),
|
|
1713
|
+
residencies: async () => {
|
|
1714
|
+
await waitForHostedExecutionIdleOrAbort(scheduleHold.settled(), signal);
|
|
1715
|
+
const goals = await goalHold.residencies(prepared.executions);
|
|
1716
|
+
const roots = await prepared.residencies();
|
|
1717
|
+
if (!goals || !roots || signal.aborted || draining)
|
|
1718
|
+
return undefined;
|
|
1719
|
+
return [...roots, ...goals, ...scheduleHold.residencies()];
|
|
1720
|
+
},
|
|
1721
|
+
detach: async () => {
|
|
1722
|
+
detached = true;
|
|
1723
|
+
signal.removeEventListener('abort', cancel);
|
|
1724
|
+
await prepared.detach();
|
|
1725
|
+
// Domain holds stay closed until the lifecycle owner drains us.
|
|
1726
|
+
},
|
|
1727
|
+
cancel,
|
|
1728
|
+
};
|
|
1729
|
+
}
|
|
1730
|
+
catch (error) {
|
|
1731
|
+
cancel();
|
|
1732
|
+
if (signal.aborted)
|
|
1733
|
+
return undefined;
|
|
1734
|
+
throw error;
|
|
1735
|
+
}
|
|
1736
|
+
},
|
|
1603
1737
|
releaseConnection: (connectionId) => {
|
|
1604
1738
|
for (const module of domainModules)
|
|
1605
1739
|
module.releaseConnection?.(connectionId);
|
|
1606
1740
|
},
|
|
1607
1741
|
beginDrain,
|
|
1608
1742
|
recover,
|
|
1743
|
+
startMaintenance: () => storageMaintenance.start(),
|
|
1609
1744
|
close,
|
|
1610
1745
|
};
|
|
1611
1746
|
}
|
|
@@ -1807,6 +1942,11 @@ function requireSessionManager(manager) {
|
|
|
1807
1942
|
throw new Error('Runtime Host SessionManager is not composed');
|
|
1808
1943
|
return manager;
|
|
1809
1944
|
}
|
|
1945
|
+
function requireTranscriptReader(reader) {
|
|
1946
|
+
if (!reader)
|
|
1947
|
+
throw new Error('Runtime Host transcript reader is not composed');
|
|
1948
|
+
return reader;
|
|
1949
|
+
}
|
|
1810
1950
|
function requireGraphCoordinator(coordinator) {
|
|
1811
1951
|
if (!coordinator)
|
|
1812
1952
|
throw new Error('Runtime Host Agent Graph coordinator is not composed');
|
|
@@ -27,7 +27,7 @@ import { buildSessionRecapMessages } from '@maka/runtime/session-recap';
|
|
|
27
27
|
import { buildSessionTitlePrompt, cleanGeneratedSessionTitle, SESSION_TITLE_GENERATION_TIMEOUT_MS, } from './session-title.js';
|
|
28
28
|
import { createProxiedFetchTransport, } from '@maka/runtime/network/scoped-fetch-transport';
|
|
29
29
|
import { generateToolFreeModelCall, generateProviderPrefixModelCall, ProviderPrefixModelCallUnavailableError, } from '@maka/runtime/tool-free-model-call';
|
|
30
|
-
import {
|
|
30
|
+
import { resolveModelRuntime } from '@maka/runtime/model-runtime';
|
|
31
31
|
import { memoryExtractionMaxOutputTokens, } from '@maka/runtime/memory-extraction';
|
|
32
32
|
import { createHostOAuthModelFetch, OAuthExecutionCredentialError, } from './oauth-execution-authority.js';
|
|
33
33
|
import { toRuntimePolicyProxy } from './runtime-policy-proxy.js';
|
|
@@ -267,7 +267,8 @@ async function runHostAuxiliaryModelCall(authority, input) {
|
|
|
267
267
|
let result;
|
|
268
268
|
try {
|
|
269
269
|
result = await readDuringBackendCreation(() => {
|
|
270
|
-
const
|
|
270
|
+
const runtime = resolveModelRuntime(target.connection, target.model);
|
|
271
|
+
const providerOptions = buildProviderOptions(target.connection, target.model, input.header.thinkingLevel, runtime);
|
|
271
272
|
const model = getAIModel({
|
|
272
273
|
sessionId: input.transportContextId,
|
|
273
274
|
connection: target.connection,
|
|
@@ -275,14 +276,13 @@ async function runHostAuxiliaryModelCall(authority, input) {
|
|
|
275
276
|
modelId: target.model,
|
|
276
277
|
fetch: modelFetch,
|
|
277
278
|
requestHeaders: target.requestHeaders,
|
|
279
|
+
resolvedRuntime: runtime,
|
|
278
280
|
});
|
|
279
281
|
return request.tools !== undefined
|
|
280
282
|
? generateProviderPrefixModelCall({
|
|
281
283
|
model,
|
|
282
284
|
...request,
|
|
283
|
-
toolChoicePolicy:
|
|
284
|
-
? 'omit'
|
|
285
|
-
: 'none',
|
|
285
|
+
toolChoicePolicy: runtime.wire === 'anthropic-messages' ? 'omit' : 'none',
|
|
286
286
|
abortSignal: input.abortSignal,
|
|
287
287
|
providerOptions: request.providerOptions ?? providerOptions,
|
|
288
288
|
})
|
|
@@ -215,8 +215,9 @@ async function buildHostAiSdkBackend(input, target) {
|
|
|
215
215
|
permissionMode: input.context.header.permissionMode,
|
|
216
216
|
}),
|
|
217
217
|
},
|
|
218
|
-
|
|
219
|
-
|
|
218
|
+
...(input.context.recordSystemNote
|
|
219
|
+
? { recordSystemNote: input.context.recordSystemNote }
|
|
220
|
+
: {}),
|
|
220
221
|
readExecutionBoundary: () => input.context.store.readExecutionBoundary(input.context.sessionId),
|
|
221
222
|
...(input.context.store.createSandboxBoundaryRequest
|
|
222
223
|
? {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import { ExternalSessionImporter } from '@maka/storage/external-sessions';
|
|
20
20
|
import { EXTERNAL_SESSION_CWD_MAX_BYTES, EXTERNAL_SESSION_IMPORTED_SESSION_IDS_MAX_ITEMS, EXTERNAL_SESSION_NAME_MAX_BYTES, EXTERNAL_SESSION_PAGE_MAX_ITEMS, EXTERNAL_SESSION_RESULT_MAX_BYTES, EXTERNAL_SESSION_SOURCE_MAX_ITEMS, EXTERNAL_SESSION_SOURCE_SESSION_ID_MAX_BYTES, } from '../protocol/index.js';
|
|
21
|
-
import { projectSessionCatalogRecord, SessionOperationFailure, } from './session-catalog-coordinator.js';
|
|
21
|
+
import { projectSessionCatalogRecord, SessionOperationFailure, NoUsableImportModelError, } from './session-catalog-coordinator.js';
|
|
22
22
|
import { WorkspaceResolutionError } from './workspace-resolver.js';
|
|
23
23
|
/** Source discovery/conversion stays host-side so raw transcripts never cross the wire. */
|
|
24
24
|
export class HostExternalSessionCoordinator {
|
|
@@ -172,6 +172,9 @@ export class HostExternalSessionCoordinator {
|
|
|
172
172
|
target = await this.#resolveTarget();
|
|
173
173
|
}
|
|
174
174
|
catch (error) {
|
|
175
|
+
if (error instanceof NoUsableImportModelError) {
|
|
176
|
+
return importFailure('model_unavailable', error.message);
|
|
177
|
+
}
|
|
175
178
|
if (error instanceof SessionOperationFailure) {
|
|
176
179
|
return importFailure(error.code, error.message);
|
|
177
180
|
}
|
|
@@ -194,9 +197,9 @@ export class HostExternalSessionCoordinator {
|
|
|
194
197
|
}
|
|
195
198
|
catch (error) {
|
|
196
199
|
if (!commitAttempted) {
|
|
197
|
-
return importFailure(isSourceSessionNotFound(error) ? 'not_found' : '
|
|
200
|
+
return importFailure(isSourceSessionNotFound(error) ? 'not_found' : 'source_unreadable', isSourceSessionNotFound(error)
|
|
198
201
|
? 'External Session does not exist'
|
|
199
|
-
: 'External Session could not be converted');
|
|
202
|
+
: 'External Session could not be read or converted');
|
|
200
203
|
}
|
|
201
204
|
this.#requestDrain();
|
|
202
205
|
return importFailure('commit_outcome_unknown', 'External Session import outcome is unknown; check the Session list before retrying');
|
|
@@ -85,7 +85,7 @@ export class HostGoalCoordinator {
|
|
|
85
85
|
goalManager: this.manager,
|
|
86
86
|
evaluator: options.evaluator,
|
|
87
87
|
getRecentContext: async (sessionId) => {
|
|
88
|
-
const messages = await
|
|
88
|
+
const messages = await options.readSessionMessages(sessionId);
|
|
89
89
|
tokenCache.set(sessionId, tokenCount(messages));
|
|
90
90
|
return recentContext(messages);
|
|
91
91
|
},
|
|
@@ -229,6 +229,45 @@ export class HostGoalCoordinator {
|
|
|
229
229
|
this.continuation.unarchiveSession(sessionId);
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
|
+
holdForHandoff() {
|
|
233
|
+
if (this.#draining)
|
|
234
|
+
return undefined;
|
|
235
|
+
const hold = this.continuation.holdForHandoff();
|
|
236
|
+
if (!hold)
|
|
237
|
+
return undefined;
|
|
238
|
+
const settled = async () => {
|
|
239
|
+
await hold.settled();
|
|
240
|
+
await this.#flushGoalState();
|
|
241
|
+
};
|
|
242
|
+
return {
|
|
243
|
+
settled,
|
|
244
|
+
release: hold.release,
|
|
245
|
+
residencies: async (executions) => {
|
|
246
|
+
await settled();
|
|
247
|
+
if (this.#draining)
|
|
248
|
+
return undefined;
|
|
249
|
+
for (const [sessionId] of this.#residencies) {
|
|
250
|
+
const authority = this.#authorityBySession.get(sessionId);
|
|
251
|
+
if (!authority)
|
|
252
|
+
return undefined;
|
|
253
|
+
const current = authority.record.currentExecution;
|
|
254
|
+
const paused = executions.find((execution) => execution.sessionId === sessionId);
|
|
255
|
+
// An observed external turn is not a durable Goal execution. Its
|
|
256
|
+
// in-memory completion registration cannot be silently discarded.
|
|
257
|
+
if (paused &&
|
|
258
|
+
(!current ||
|
|
259
|
+
current.execution.turnId !== paused.turnId ||
|
|
260
|
+
current.execution.runId !== paused.runId))
|
|
261
|
+
return undefined;
|
|
262
|
+
if (current && !paused)
|
|
263
|
+
return undefined;
|
|
264
|
+
if (current && !this.matchesActive(sessionId, current.checkpoint, current.controlLease))
|
|
265
|
+
return undefined;
|
|
266
|
+
}
|
|
267
|
+
return [...this.#residencies.values()];
|
|
268
|
+
},
|
|
269
|
+
};
|
|
270
|
+
}
|
|
232
271
|
beginDrain() {
|
|
233
272
|
if (this.#draining)
|
|
234
273
|
return;
|