maka-agent 0.2.0-dev.23.20260906 → 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-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
- package/node_modules/@maka/core/dist/canonical-runtime-event.js +3 -1
- 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 +9 -2
- 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.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-record-schema.js +26 -35
- package/node_modules/@maka/core/package.json +4 -0
- 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 +127 -133
- 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/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/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 +2 -0
- package/node_modules/@maka/runtime-host/dist/client/launcher.js +3 -0
- 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/protocol/host-status.js +21 -12
- package/node_modules/@maka/runtime-host/dist/protocol/index.js +25 -1
- package/node_modules/@maka/runtime-host/dist/protocol/operations.js +1 -0
- 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/server/access-credential-store.js +1 -0
- package/node_modules/@maka/runtime-host/dist/server/canonical-turn-snapshot.js +19 -4
- package/node_modules/@maka/runtime-host/dist/server/connection-session.js +7 -6
- package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +100 -24
- 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/goal-coordinator.js +40 -1
- package/node_modules/@maka/runtime-host/dist/server/host-kernel.js +96 -17
- 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 +76 -6
- package/node_modules/@maka/runtime-host/dist/server/root-turn-coordinator.js +325 -73
- 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 +50 -7
- 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/workhub-coordination-coordinator.js +0 -1
- 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/execution-stores.js +9 -7
- package/node_modules/@maka/storage/dist/file-session-repository.js +1012 -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/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 +7 -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/tool-result-archive-evidence.js +111 -0
- package/node_modules/@maka/storage/package.json +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
* or more contributor license agreements. See the NOTICE file
|
|
4
|
+
* distributed with this work for additional information
|
|
5
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
* to you under the Apache License, Version 2.0 (the
|
|
7
|
+
* "License"); you may not use this file except in compliance
|
|
8
|
+
* with the License. You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
|
13
|
+
* software distributed under the License is distributed on an
|
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
* KIND, either express or implied. See the License for the
|
|
16
|
+
* specific language governing permissions and limitations
|
|
17
|
+
* under the License.
|
|
18
|
+
*/
|
|
19
|
+
import { randomUUID } from 'node:crypto';
|
|
20
|
+
import { isHostActivityIdle } from '../protocol/host-status.js';
|
|
21
|
+
import { RuntimeHostPermanentReconnectError } from './reconnect-lifecycle.js';
|
|
22
|
+
import { formatHostHandoff } from './host-handoff-copy.js';
|
|
23
|
+
import { redactSecrets } from '@maka/core/redaction';
|
|
24
|
+
export class HostHandoffCancelledError extends RuntimeHostPermanentReconnectError {
|
|
25
|
+
code = 'runtime_host_handoff_cancelled';
|
|
26
|
+
constructor() {
|
|
27
|
+
super('Runtime Host handoff was cancelled');
|
|
28
|
+
this.name = 'HostHandoffCancelledError';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/** Noninteractive callers receive the same decision instead of prompting or silently stopping work. */
|
|
32
|
+
export class HostHandoffRequiredError extends RuntimeHostPermanentReconnectError {
|
|
33
|
+
view;
|
|
34
|
+
code = 'runtime_host_handoff_required';
|
|
35
|
+
constructor(view) {
|
|
36
|
+
const copy = formatHostHandoff(view, 'en');
|
|
37
|
+
super([copy.title, copy.description, copy.detail, view.diagnostic].filter(Boolean).join('\n'));
|
|
38
|
+
this.view = view;
|
|
39
|
+
this.name = 'HostHandoffRequiredError';
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** One live attempt; persisted deployment transactions remain the sole recovery authority. */
|
|
43
|
+
export async function runHostHandoff(input) {
|
|
44
|
+
const interval = input.pollIntervalMs ?? 1_000;
|
|
45
|
+
if (!Number.isFinite(interval) || interval <= 0)
|
|
46
|
+
throw new RangeError('Invalid handoff observation interval');
|
|
47
|
+
let surface;
|
|
48
|
+
let view;
|
|
49
|
+
let signature;
|
|
50
|
+
let choice;
|
|
51
|
+
let wake;
|
|
52
|
+
let attemptAbort;
|
|
53
|
+
let cancelled = false;
|
|
54
|
+
// Admission can refuse an apparently idle snapshot. Do not turn that race
|
|
55
|
+
// (or a broken successor) into an automatic replacement storm.
|
|
56
|
+
const attempted = new Set();
|
|
57
|
+
let automaticAttempts = 0;
|
|
58
|
+
let recovery;
|
|
59
|
+
const publish = (next) => {
|
|
60
|
+
view = next;
|
|
61
|
+
surface?.update(next);
|
|
62
|
+
};
|
|
63
|
+
const submit = (revision, action) => {
|
|
64
|
+
if (!view || revision !== view.revision || !view.actions.includes(action))
|
|
65
|
+
return;
|
|
66
|
+
if (view.state === 'progress') {
|
|
67
|
+
if (action !== 'cancel' || cancelled)
|
|
68
|
+
return;
|
|
69
|
+
cancelled = true;
|
|
70
|
+
attemptAbort?.abort(new HostHandoffCancelledError());
|
|
71
|
+
publish({ ...view, revision: randomUUID(), actions: [] });
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (choice)
|
|
75
|
+
return;
|
|
76
|
+
choice = { revision, action };
|
|
77
|
+
wake?.();
|
|
78
|
+
};
|
|
79
|
+
try {
|
|
80
|
+
for (;;) {
|
|
81
|
+
input.signal?.throwIfAborted();
|
|
82
|
+
if (cancelled)
|
|
83
|
+
throw new HostHandoffCancelledError();
|
|
84
|
+
if (choice?.action === 'cancel')
|
|
85
|
+
throw new HostHandoffCancelledError();
|
|
86
|
+
// Every action, including an explicit interruption, gets a fresh observation.
|
|
87
|
+
// Final identity/admission fencing is still the mutation adapter's responsibility.
|
|
88
|
+
let observed;
|
|
89
|
+
try {
|
|
90
|
+
observed = await input.observe(input.signal);
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
input.signal?.throwIfAborted();
|
|
94
|
+
if (!view)
|
|
95
|
+
throw error;
|
|
96
|
+
// Lost observation is not permission to reuse the last mutation capability.
|
|
97
|
+
// Keep this journey visible and retry without chaining a fatal dialog.
|
|
98
|
+
observed = {
|
|
99
|
+
kind: 'blocked',
|
|
100
|
+
blocker: {
|
|
101
|
+
identity: JSON.stringify(['unavailable', view.target]),
|
|
102
|
+
target: view.target,
|
|
103
|
+
reason: 'unavailable',
|
|
104
|
+
mayExitNaturally: false,
|
|
105
|
+
diagnostic: boundedDiagnostic(error),
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
if (observed.kind === 'ready') {
|
|
110
|
+
if (input.signal?.aborted ||
|
|
111
|
+
choice?.action === 'cancel') {
|
|
112
|
+
await observed.value.close();
|
|
113
|
+
input.signal?.throwIfAborted();
|
|
114
|
+
throw new HostHandoffCancelledError();
|
|
115
|
+
}
|
|
116
|
+
return observed.value;
|
|
117
|
+
}
|
|
118
|
+
input.signal?.throwIfAborted();
|
|
119
|
+
// Cancellation belongs to the attempt, not to the observed Host. A new
|
|
120
|
+
// epoch or newly idle snapshot must not erase a click made during observe.
|
|
121
|
+
if (choice?.action === 'cancel') {
|
|
122
|
+
throw new HostHandoffCancelledError();
|
|
123
|
+
}
|
|
124
|
+
const blocker = observed.blocker;
|
|
125
|
+
if (recovery?.identity !== blocker.identity)
|
|
126
|
+
recovery = undefined;
|
|
127
|
+
const nextSignature = blockerSignature(blocker);
|
|
128
|
+
if (signature !== nextSignature) {
|
|
129
|
+
signature = nextSignature;
|
|
130
|
+
choice = undefined;
|
|
131
|
+
publish(projectBlocker(blocker, randomUUID(), recovery?.diagnostic));
|
|
132
|
+
}
|
|
133
|
+
const current = view;
|
|
134
|
+
const selected = choice;
|
|
135
|
+
choice = undefined;
|
|
136
|
+
if (selected?.action === 'cancel')
|
|
137
|
+
throw new HostHandoffCancelledError();
|
|
138
|
+
const cooperative = blocker.target.location === 'local' &&
|
|
139
|
+
blocker.activity?.cooperativeHandoff === true &&
|
|
140
|
+
blocker.activity.connections === 0 &&
|
|
141
|
+
blocker.activity.activeOperations === 0;
|
|
142
|
+
const automatic = !recovery &&
|
|
143
|
+
automaticAttempts < 3 &&
|
|
144
|
+
!attempted.has(nextSignature) &&
|
|
145
|
+
blocker.replacement?.canReplaceIdle &&
|
|
146
|
+
blocker.activity &&
|
|
147
|
+
(isHostActivityIdle(blocker.activity) || cooperative);
|
|
148
|
+
const interrupt = selected?.revision === current.revision && selected.action === 'interrupt';
|
|
149
|
+
const retry = selected?.revision === current.revision && selected.action === 'retry';
|
|
150
|
+
if ((automatic || interrupt || (retry && blocker.replacement?.canReplaceIdle)) &&
|
|
151
|
+
blocker.replacement) {
|
|
152
|
+
if (automatic) {
|
|
153
|
+
attempted.add(nextSignature);
|
|
154
|
+
automaticAttempts += 1;
|
|
155
|
+
}
|
|
156
|
+
attemptAbort = new AbortController();
|
|
157
|
+
const operationSignal = input.signal
|
|
158
|
+
? AbortSignal.any([input.signal, attemptAbort.signal])
|
|
159
|
+
: attemptAbort.signal;
|
|
160
|
+
const progress = (phase) => publish({
|
|
161
|
+
...current,
|
|
162
|
+
revision: randomUUID(),
|
|
163
|
+
state: 'progress',
|
|
164
|
+
phase: cooperative && !interrupt && phase === 'retiring' ? 'pausing' : phase,
|
|
165
|
+
actions: cancelled ? [] : ['cancel'],
|
|
166
|
+
});
|
|
167
|
+
if (input.openSurface)
|
|
168
|
+
surface ??= input.openSurface(submit);
|
|
169
|
+
progress(cooperative && !interrupt ? 'pausing' : 'checking');
|
|
170
|
+
// Do not abandon an irreversible cutover when the Surface closes. Its
|
|
171
|
+
// transaction settles (or persists recovery) before cancellation is observed.
|
|
172
|
+
let result;
|
|
173
|
+
try {
|
|
174
|
+
result = await blocker.replacement.execute(interrupt ? 'interrupt_active_work' : 'refuse_active_work', progress, automatic && !retry && !interrupt ? 'automatic' : 'explicit', operationSignal);
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
result = { kind: 'recovery_required', diagnostic: boundedDiagnostic(error) };
|
|
178
|
+
}
|
|
179
|
+
finally {
|
|
180
|
+
attemptAbort = undefined;
|
|
181
|
+
}
|
|
182
|
+
recovery =
|
|
183
|
+
result.kind === 'recovery_required'
|
|
184
|
+
? { identity: blocker.identity, diagnostic: result.diagnostic.slice(0, 8_192) }
|
|
185
|
+
: undefined;
|
|
186
|
+
// A completed attempt is not proof of readiness; observe the successor.
|
|
187
|
+
signature = undefined;
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
if (selected?.action === 'retry') {
|
|
191
|
+
// Explicit retry permits another safe probe, never an implicit interruption.
|
|
192
|
+
attempted.delete(nextSignature);
|
|
193
|
+
automaticAttempts = 0;
|
|
194
|
+
recovery = undefined;
|
|
195
|
+
signature = undefined;
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
const attention = projectBlocker(blocker, current.revision, recovery?.diagnostic);
|
|
199
|
+
if (!input.openSurface)
|
|
200
|
+
throw new HostHandoffRequiredError(attention);
|
|
201
|
+
surface ??= input.openSurface(submit);
|
|
202
|
+
publish(attention);
|
|
203
|
+
await new Promise((resolve, reject) => {
|
|
204
|
+
const finish = (error) => {
|
|
205
|
+
clearTimeout(timer);
|
|
206
|
+
input.signal?.removeEventListener('abort', abort);
|
|
207
|
+
wake = undefined;
|
|
208
|
+
if (error !== undefined)
|
|
209
|
+
reject(error);
|
|
210
|
+
else
|
|
211
|
+
resolve();
|
|
212
|
+
};
|
|
213
|
+
const abort = () => finish(input.signal?.reason);
|
|
214
|
+
const timer = setTimeout(finish, interval);
|
|
215
|
+
wake = () => finish();
|
|
216
|
+
input.signal?.addEventListener('abort', abort, { once: true });
|
|
217
|
+
if (input.signal?.aborted)
|
|
218
|
+
abort();
|
|
219
|
+
else if (choice)
|
|
220
|
+
finish();
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
finally {
|
|
225
|
+
surface?.close();
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
function projectBlocker(blocker, revision, recovery) {
|
|
229
|
+
const replacement = blocker.replacement;
|
|
230
|
+
return {
|
|
231
|
+
revision,
|
|
232
|
+
target: blocker.target,
|
|
233
|
+
state: 'attention',
|
|
234
|
+
reason: blocker.reason === 'unavailable'
|
|
235
|
+
? 'retry_required'
|
|
236
|
+
: recovery || blocker.reason === 'repair'
|
|
237
|
+
? 'repair_required'
|
|
238
|
+
: !replacement
|
|
239
|
+
? 'operator_required'
|
|
240
|
+
: !blocker.activity
|
|
241
|
+
? 'activity_unknown'
|
|
242
|
+
: isHostActivityIdle(blocker.activity)
|
|
243
|
+
? 'retry_required'
|
|
244
|
+
: 'busy',
|
|
245
|
+
...(blocker.activity ? { activity: blocker.activity } : {}),
|
|
246
|
+
mayExitNaturally: blocker.mayExitNaturally,
|
|
247
|
+
...(replacement ? { operation: replacement.kind } : {}),
|
|
248
|
+
actions: replacement?.canInterrupt ? ['cancel', 'retry', 'interrupt'] : ['cancel', 'retry'],
|
|
249
|
+
defaultAction: 'cancel',
|
|
250
|
+
...(blocker.operatorStep ? { operatorStep: blocker.operatorStep } : {}),
|
|
251
|
+
...((recovery ?? blocker.diagnostic)
|
|
252
|
+
? { diagnostic: redactSecrets((recovery ?? blocker.diagnostic)).slice(0, 8_192) }
|
|
253
|
+
: {}),
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
function blockerSignature(blocker) {
|
|
257
|
+
const { processUptimeSeconds: _uptime, ...activity } = blocker.activity ?? {};
|
|
258
|
+
return JSON.stringify([
|
|
259
|
+
blocker.identity,
|
|
260
|
+
blocker.target,
|
|
261
|
+
blocker.reason,
|
|
262
|
+
activity,
|
|
263
|
+
blocker.mayExitNaturally,
|
|
264
|
+
blocker.replacement?.kind,
|
|
265
|
+
blocker.replacement?.canReplaceIdle,
|
|
266
|
+
blocker.replacement?.canInterrupt,
|
|
267
|
+
blocker.operatorStep,
|
|
268
|
+
blocker.diagnostic,
|
|
269
|
+
]);
|
|
270
|
+
}
|
|
271
|
+
function boundedDiagnostic(error) {
|
|
272
|
+
return redactSecrets(error instanceof Error ? error.message : String(error)).slice(0, 8_192);
|
|
273
|
+
}
|
|
@@ -23,9 +23,30 @@
|
|
|
23
23
|
* transport detail here so lifecycle owners can model the operation as
|
|
24
24
|
* retirement instead of spreading update-specific authority.
|
|
25
25
|
*/
|
|
26
|
-
export function prepareConnectedRuntimeHostRetirement(connection, mode, timeoutMs) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
export async function prepareConnectedRuntimeHostRetirement(connection, mode, timeoutMs, signal) {
|
|
27
|
+
signal?.throwIfAborted();
|
|
28
|
+
// Retirement uses a dedicated lifecycle connection. Closing it cancels the
|
|
29
|
+
// Host's reversible preparation; a committed retirement remains committed.
|
|
30
|
+
const cancel = () => {
|
|
31
|
+
void connection.close().catch(() => undefined);
|
|
32
|
+
};
|
|
33
|
+
signal?.addEventListener('abort', cancel, { once: true });
|
|
34
|
+
try {
|
|
35
|
+
return await connection.request('host.upgrade.prepare', {
|
|
36
|
+
expectedHostEpoch: connection.hostEpoch,
|
|
37
|
+
allowInterruptActiveTasks: mode === 'interrupt_active_work',
|
|
38
|
+
...(mode === 'refuse_active_work' && connection.cooperativeHandoff
|
|
39
|
+
? { allowCooperativeHandoff: true }
|
|
40
|
+
: {}),
|
|
41
|
+
}, timeoutMs);
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
// Cancellation is not an unavailable protocol: lifecycle fallback must
|
|
45
|
+
// never turn this deliberate disconnect into supervisor interruption.
|
|
46
|
+
signal?.throwIfAborted();
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
finally {
|
|
50
|
+
signal?.removeEventListener('abort', cancel);
|
|
51
|
+
}
|
|
31
52
|
}
|
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
* specific language governing permissions and limitations
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
|
+
export * from './host-handoff.js';
|
|
20
|
+
export { formatHostHandoff } from './host-handoff-copy.js';
|
|
19
21
|
export { RuntimeHostManagedActivationError, activateRuntimeHostManagedDeployment, } from './managed-activation.js';
|
|
20
22
|
export { decodeRuntimeHostWebRtcStunPolicy, resolveRuntimeHostWebRtcStunUrls, } from '../webrtc-stun-policy.js';
|
|
21
23
|
export { openRuntimeHostManagedStdioBridge } from './managed-stdio-bridge.js';
|
|
@@ -32,6 +32,9 @@ export function launchDetachedRuntimeHostCandidate(input) {
|
|
|
32
32
|
const startupFailure = readStartupFailure(exited, startupAttemptId);
|
|
33
33
|
const spawned = spawnedPid(child).then(({ pid }) => {
|
|
34
34
|
child.unref();
|
|
35
|
+
// The guard observes launcher death; its IPC channel must not prevent
|
|
36
|
+
// that launcher from exiting naturally after its own work has finished.
|
|
37
|
+
child.channel?.unref();
|
|
35
38
|
return { pid, startupAttemptId, exited, startupFailure };
|
|
36
39
|
});
|
|
37
40
|
return { spawned };
|
|
@@ -23,6 +23,7 @@ export class RuntimeHostRemoteCompatibilityError extends RuntimeHostPermanentRec
|
|
|
23
23
|
name = 'RuntimeHostRemoteCompatibilityError';
|
|
24
24
|
code = RUNTIME_HOST_REMOTE_INCOMPATIBLE_CODE;
|
|
25
25
|
details;
|
|
26
|
+
hostEpoch;
|
|
26
27
|
constructor(profileId, handshake) {
|
|
27
28
|
const details = Object.freeze({
|
|
28
29
|
profileId,
|
|
@@ -42,6 +43,7 @@ export class RuntimeHostRemoteCompatibilityError extends RuntimeHostPermanentRec
|
|
|
42
43
|
});
|
|
43
44
|
super(formatRuntimeHostRemoteCompatibilityMessage(details));
|
|
44
45
|
this.details = details;
|
|
46
|
+
this.hostEpoch = handshake.hostEpoch;
|
|
45
47
|
}
|
|
46
48
|
}
|
|
47
49
|
function formatRuntimeHostRemoteCompatibilityMessage(details) {
|
|
@@ -42,6 +42,7 @@ export class ClientSessionSubscription {
|
|
|
42
42
|
#releaseTranscriptOverlay;
|
|
43
43
|
#expectedSessionId;
|
|
44
44
|
#queue = [];
|
|
45
|
+
#ptyListeners = new Set();
|
|
45
46
|
#queuedBytes = 0;
|
|
46
47
|
#expectedSequence;
|
|
47
48
|
#latestProjectionRevision;
|
|
@@ -72,6 +73,12 @@ export class ClientSessionSubscription {
|
|
|
72
73
|
[Symbol.asyncIterator]() {
|
|
73
74
|
return this;
|
|
74
75
|
}
|
|
76
|
+
subscribePtyData(listener) {
|
|
77
|
+
if (this.#done || this.#terminalError || this.#closing)
|
|
78
|
+
return () => undefined;
|
|
79
|
+
this.#ptyListeners.add(listener);
|
|
80
|
+
return () => this.#ptyListeners.delete(listener);
|
|
81
|
+
}
|
|
75
82
|
next() {
|
|
76
83
|
const queued = this.#queue.shift();
|
|
77
84
|
if (queued) {
|
|
@@ -101,6 +108,7 @@ export class ClientSessionSubscription {
|
|
|
101
108
|
if (this.#done || this.#terminalError)
|
|
102
109
|
return Promise.resolve();
|
|
103
110
|
this.#closing = true;
|
|
111
|
+
this.#ptyListeners.clear();
|
|
104
112
|
if (!this.#closeTask)
|
|
105
113
|
this.#closeTask = this.#requestClose();
|
|
106
114
|
return this.#closeTask;
|
|
@@ -208,9 +216,6 @@ export class ClientSessionSubscription {
|
|
|
208
216
|
}
|
|
209
217
|
const overlay = await this.#consumeTranscriptOverlay(bootstrap);
|
|
210
218
|
const durable = await this.#loadTranscriptSource(bootstrap.durable);
|
|
211
|
-
if (bootstrap.durableCoverage === 'complete') {
|
|
212
|
-
assertCompleteIdentities(durable, bootstrap.throughSequence);
|
|
213
|
-
}
|
|
214
219
|
const messages = durable.map((entry) => entry.value);
|
|
215
220
|
const indexById = new Map();
|
|
216
221
|
for (const [index, message] of messages.entries()) {
|
|
@@ -317,6 +322,22 @@ export class ClientSessionSubscription {
|
|
|
317
322
|
if (frame.subscriptionId !== this.subscriptionId) {
|
|
318
323
|
throw new RuntimeHostSubscriptionError('correlation_changed', 'Session subscription correlation changed');
|
|
319
324
|
}
|
|
325
|
+
if (frame.kind === 'subscription.runtime_resource_pty_data') {
|
|
326
|
+
if (frame.sessionId !== this.#expectedSessionId) {
|
|
327
|
+
throw new RuntimeHostSubscriptionError('correlation_changed', 'PTY Session identity changed');
|
|
328
|
+
}
|
|
329
|
+
// No iterator backlog when nobody is displaying a terminal. Attaching
|
|
330
|
+
// consumers hydrate from a snapshot, including bytes before attachment.
|
|
331
|
+
for (const listener of this.#ptyListeners) {
|
|
332
|
+
try {
|
|
333
|
+
listener(frame);
|
|
334
|
+
}
|
|
335
|
+
catch {
|
|
336
|
+
/* A display consumer cannot terminate Session state. */
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
320
341
|
if (frame.sequence !== this.#expectedSequence) {
|
|
321
342
|
throw new RuntimeHostSubscriptionError('sequence_gap', `Session subscription expected sequence ${this.#expectedSequence} but received ${frame.sequence}`);
|
|
322
343
|
}
|
|
@@ -333,8 +354,7 @@ export class ClientSessionSubscription {
|
|
|
333
354
|
else if ((frame.kind === 'subscription.session_delta' ||
|
|
334
355
|
frame.kind === 'subscription.session_event' ||
|
|
335
356
|
frame.kind === 'subscription.transcript_advanced' ||
|
|
336
|
-
frame.kind === 'subscription.session_domain_changed'
|
|
337
|
-
frame.kind === 'subscription.runtime_resource_pty_data') &&
|
|
357
|
+
frame.kind === 'subscription.session_domain_changed') &&
|
|
338
358
|
frame.sessionId !== this.#expectedSessionId) {
|
|
339
359
|
throw new RuntimeHostSubscriptionError('correlation_changed', 'Session subscription frame identity changed');
|
|
340
360
|
}
|
|
@@ -354,6 +374,7 @@ export class ClientSessionSubscription {
|
|
|
354
374
|
this.#doneAfterQueue = true;
|
|
355
375
|
}
|
|
356
376
|
finish() {
|
|
377
|
+
this.#ptyListeners.clear();
|
|
357
378
|
if (this.#done || this.#terminalError)
|
|
358
379
|
return;
|
|
359
380
|
this.#doneAfterQueue = true;
|
|
@@ -364,6 +385,7 @@ export class ClientSessionSubscription {
|
|
|
364
385
|
}
|
|
365
386
|
}
|
|
366
387
|
fail(error) {
|
|
388
|
+
this.#ptyListeners.clear();
|
|
367
389
|
if (this.#done || this.#terminalError)
|
|
368
390
|
return;
|
|
369
391
|
this.#terminalError = error;
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
* specific language governing permissions and limitations
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
|
+
export { RUNTIME_HOST_OPERATOR_RETIREMENT_CANCELLATION_ENV } from './retirement-cancellation.js';
|
|
19
20
|
export { RUNTIME_HOST_ACTIVATION_ERROR_CODE_MAX_BYTES, RUNTIME_HOST_ACTIVATION_ERROR_MESSAGE_MAX_BYTES, RUNTIME_HOST_ACTIVATION_FRAME_MAX_BYTES, RUNTIME_HOST_ACTIVATION_FRAME_PREFIX, decodeRuntimeHostActivationFrame, encodeRuntimeHostActivationFrame, } from './activation-frame.js';
|
|
20
21
|
export { RUNTIME_HOST_ACCESS_MANAGEMENT_ERROR_CODE_MAX_BYTES, RUNTIME_HOST_ACCESS_MANAGEMENT_ERROR_MESSAGE_MAX_BYTES, RUNTIME_HOST_ACCESS_MANAGEMENT_FRAME_PREFIX, decodeRuntimeHostAccessManagementFrame, encodeRuntimeHostAccessManagementFrame, } from './access-management-frame.js';
|
|
21
22
|
export { runtimeHostAccessCredentialFingerprint } from '../access-credential-identity.js';
|
|
@@ -27,6 +28,6 @@ export { RUNTIME_HOST_OPERATOR_ACCESS_MANAGEMENT_CAPABILITY, RUNTIME_HOST_OPERAT
|
|
|
27
28
|
export { RUNTIME_HOST_SETUP_ERROR_CODE_MAX_BYTES, RUNTIME_HOST_SETUP_ERROR_MESSAGE_MAX_BYTES, RUNTIME_HOST_SETUP_FRAME_PREFIX, decodeRuntimeHostSetupFrame, encodeRuntimeHostSetupFrame, parseRuntimeHostSetupEndpoint, } from './setup-frame.js';
|
|
28
29
|
export { createRuntimeHostOperatorCommand, createRuntimeHostLegacyPosixOperatorCommand, decodeRuntimeHostOperatorCommand, decodeRuntimeHostPosixOperatorCommand, runtimeHostManagedOperatorCommand, runtimeHostManagedOperatorModulePath, runtimeHostOperatorInvocation, } from './operator-command.js';
|
|
29
30
|
export { RUNTIME_HOST_SETUP_SOURCE_PACKAGE_INTEGRITY_ENV, compareProductReleaseVersions, isProductReleaseVersion, isRuntimeHostNpmDeploymentIdentity, isSha512PackageIntegrity, resolveRuntimeHostNpmDeploymentLayout, } from './update-package-evidence.js';
|
|
30
|
-
export { applyLocalHostDeploymentTransition, LocalHostDeploymentAuthorityError, readLocalHostDeploymentRecord, resolveLocalHostDeploymentAuthorityRoot, } from './local-deployment-owner.js';
|
|
31
|
+
export { applyLocalHostDeploymentTransition, LocalHostDeploymentAuthorityError, readLocalHostDeploymentRecord, withLocalHostDeploymentAuthority, resolveLocalHostDeploymentAuthorityRoot, } from './local-deployment-owner.js';
|
|
31
32
|
export { claimLocalHostProcessDeployment, handoffLocalHostProcessDeployment, } from './local-process-deployment-handoff.js';
|
|
32
33
|
export { RUNTIME_HOST_MANAGED_DEPLOYMENT_CONFIG_FILE, RuntimeHostManagedDeploymentError, beginRuntimeHostManagedDeploymentTransition, blockRuntimeHostManagedDeploymentTransition, claimRuntimeHostManagedDeployment, commitRuntimeHostManagedDeploymentTransition, commitRuntimeHostManagedDeployment, decodeRuntimeHostManagedDeploymentAuthorityRecord, decodeRuntimeHostManagedDeploymentConfig, readRuntimeHostManagedDeploymentAuthorityRecord, assertRuntimeHostManagedDeploymentAuthorityDurablyAbsent, readRuntimeHostManagedDeploymentConfig, resolveRuntimeHostManagedDeployment, resolveRuntimeHostManagedDeploymentAuthority, resolveRuntimeHostManagedDeploymentAuthorityRoot, resolveRuntimeHostManagedDeploymentConfigPath, rollbackRuntimeHostManagedDeploymentTransition, runtimeHostManagedLaunchClaim, } from './managed-deployment.js';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
* or more contributor license agreements. See the NOTICE file
|
|
4
|
+
* distributed with this work for additional information
|
|
5
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
* to you under the Apache License, Version 2.0 (the
|
|
7
|
+
* "License"); you may not use this file except in compliance
|
|
8
|
+
* with the License. You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
|
13
|
+
* software distributed under the License is distributed on an
|
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
* KIND, either express or implied. See the License for the
|
|
16
|
+
* specific language governing permissions and limitations
|
|
17
|
+
* under the License.
|
|
18
|
+
*/
|
|
19
|
+
/** EOF on inherited stdin cancels only the first retirement, never its transaction or rollback. */
|
|
20
|
+
export const RUNTIME_HOST_OPERATOR_RETIREMENT_CANCELLATION_ENV = 'MAKA_RUNTIME_HOST_OPERATOR_RETIREMENT_CANCELLATION_STDIN';
|
|
@@ -17,13 +17,15 @@
|
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
19
|
import { invalidProtocolFrame } from './errors.js';
|
|
20
|
-
import { requireCount, requireEncodedByteLimit, requireExactRecord, requireId, requireRecord, requireString, requireUtf8String, } from './codec.js';
|
|
20
|
+
import { requireCount, requireEncodedByteLimit, requireExactRecord, requireId, requireRecord, requireShapedRecord, requireString, requireUtf8String, } from './codec.js';
|
|
21
21
|
import { defineOperation } from './operation-spec.js';
|
|
22
22
|
import { decodeSignedPeerReachabilityLease, } from '../peer-reachability/model.js';
|
|
23
23
|
export function isHostActivityIdle(activity) {
|
|
24
24
|
return (activity.connections === 0 &&
|
|
25
25
|
activity.activeOperations === 0 &&
|
|
26
|
-
activity.
|
|
26
|
+
(activity.drainResidencies === undefined
|
|
27
|
+
? activity.residencies.length === 0
|
|
28
|
+
: activity.drainResidencies === 0));
|
|
27
29
|
}
|
|
28
30
|
export const HOST_DIAGNOSTICS_RESULT_MAX_BYTES = 72 * 1024;
|
|
29
31
|
export const HOST_DIAGNOSTIC_LOG_MAX_ENTRIES = 256;
|
|
@@ -132,16 +134,21 @@ function requireUpgradeBlockingActivity(value) {
|
|
|
132
134
|
return value;
|
|
133
135
|
}
|
|
134
136
|
export function decodeHostActivitySnapshot(value) {
|
|
135
|
-
const record =
|
|
136
|
-
'connections',
|
|
137
|
-
'activeOperations',
|
|
138
|
-
'processUptimeSeconds',
|
|
139
|
-
'residencies',
|
|
140
|
-
]);
|
|
137
|
+
const record = requireShapedRecord(value, 'Runtime Host activity', ['connections', 'activeOperations', 'processUptimeSeconds', 'residencies'], ['drainResidencies', 'cooperativeHandoff']);
|
|
141
138
|
if (!Array.isArray(record.residencies) || record.residencies.length > 128) {
|
|
142
139
|
throw invalidProtocolFrame('Invalid Runtime Host activity residencies');
|
|
143
140
|
}
|
|
144
141
|
return {
|
|
142
|
+
...(record.cooperativeHandoff === undefined
|
|
143
|
+
? {}
|
|
144
|
+
: {
|
|
145
|
+
cooperativeHandoff: requireBoolean(record.cooperativeHandoff, 'Runtime Host cooperative handoff capability'),
|
|
146
|
+
}),
|
|
147
|
+
...(record.drainResidencies === undefined
|
|
148
|
+
? {}
|
|
149
|
+
: {
|
|
150
|
+
drainResidencies: requireCount(record.drainResidencies, 'Runtime Host drain residencies'),
|
|
151
|
+
}),
|
|
145
152
|
connections: requireCount(record.connections, 'Runtime Host activity connections'),
|
|
146
153
|
activeOperations: requireCount(record.activeOperations, 'Runtime Host activity active operations'),
|
|
147
154
|
processUptimeSeconds: requireCount(record.processUptimeSeconds, 'Runtime Host activity process uptime'),
|
|
@@ -158,13 +165,15 @@ export function decodeHostActivitySnapshot(value) {
|
|
|
158
165
|
};
|
|
159
166
|
}
|
|
160
167
|
function decodeHostUpgradePrepareInput(value) {
|
|
161
|
-
const record =
|
|
162
|
-
'expectedHostEpoch',
|
|
163
|
-
'allowInterruptActiveTasks',
|
|
164
|
-
]);
|
|
168
|
+
const record = requireShapedRecord(value, 'Runtime Host upgrade prepare input', ['expectedHostEpoch', 'allowInterruptActiveTasks'], ['allowCooperativeHandoff']);
|
|
165
169
|
return {
|
|
166
170
|
expectedHostEpoch: requireId(record.expectedHostEpoch, 'Runtime Host expected Host Epoch'),
|
|
167
171
|
allowInterruptActiveTasks: requireBoolean(record.allowInterruptActiveTasks, 'Runtime Host upgrade interrupt authority'),
|
|
172
|
+
...(record.allowCooperativeHandoff === undefined
|
|
173
|
+
? {}
|
|
174
|
+
: {
|
|
175
|
+
allowCooperativeHandoff: requireBoolean(record.allowCooperativeHandoff, 'Runtime Host cooperative handoff authority'),
|
|
176
|
+
}),
|
|
168
177
|
};
|
|
169
178
|
}
|
|
170
179
|
function requireBoolean(value, label) {
|
|
@@ -62,7 +62,26 @@ export const RUNTIME_HOST_REGISTRATION_SCHEMA_VERSION = 1;
|
|
|
62
62
|
export const RUNTIME_HOST_PROTOCOL_VERSION = 0;
|
|
63
63
|
// Increment when the same protocol version no longer guarantees safe Client-Host
|
|
64
64
|
// interoperability. Mismatches are rejected before domain commands are admitted.
|
|
65
|
-
export const RUNTIME_HOST_COMPATIBILITY_EPOCH =
|
|
65
|
+
export const RUNTIME_HOST_COMPATIBILITY_EPOCH = 130;
|
|
66
|
+
// 130: Turn contributions carry the optional bounded `failureMessage` diagnostic.
|
|
67
|
+
// Epoch-129 peers reject this added field on the strict contribution shape.
|
|
68
|
+
// 129: Turn states and Turn records drop `partialOutputRetained`. The fact was
|
|
69
|
+
// derived twice — once from the Turn's output rows, once off the state message
|
|
70
|
+
// — and read by nothing; older peers require the field on both.
|
|
71
|
+
// 128: Session transcript bootstraps drop `durableCoverage`. A durable sequence
|
|
72
|
+
// is an event ordinal times its stride, so no projection has contiguous
|
|
73
|
+
// sequences any more and the claim the field made is unavailable to make.
|
|
74
|
+
// 127: Session Turn contributions carry only the Turn's recorded state. Older
|
|
75
|
+
// peers require the derived shape booleans this projection no longer sends.
|
|
76
|
+
// 126: Durable transcript cursors seek Session event ordinals instead of run indexes.
|
|
77
|
+
// 125: Live Turn snapshots carry an optional `rootExecutionKind:'context_compact'`
|
|
78
|
+
// so a running context-compaction Turn can render a transcript row. Epoch-124
|
|
79
|
+
// peers reject the added optional field on the strict live snapshot shape.
|
|
80
|
+
// 124: PTY delivery is independent of the ordered Session state stream. A
|
|
81
|
+
// bounded PTY overflow requests terminal-only snapshot recovery.
|
|
82
|
+
// 123: Failed turns carry canonical retry decisions through bounded projections.
|
|
83
|
+
// 122: Authenticated physical handoff continuations retain logical Turn identity.
|
|
84
|
+
// Older peers cannot decode the handoff source and sealed invocation facts.
|
|
66
85
|
// 121: Host diagnostics report `upgradeBlockingActivity`, the Host's
|
|
67
86
|
// authoritative activity answer for maintenance probes, computed by the same
|
|
68
87
|
// authority that gates `host.upgrade.prepare`. Older Clients reject the
|
|
@@ -353,6 +372,7 @@ export function decodeClientFrame(value) {
|
|
|
353
372
|
}
|
|
354
373
|
return {
|
|
355
374
|
kind: 'hello',
|
|
375
|
+
...(frame.activitySnapshotVersion === 2 ? { activitySnapshotVersion: 2 } : {}),
|
|
356
376
|
clientInstanceId: requireClientInstanceId(frame.clientInstanceId),
|
|
357
377
|
protocolMin,
|
|
358
378
|
protocolMax,
|
|
@@ -370,8 +390,12 @@ export function decodeClientFrame(value) {
|
|
|
370
390
|
export function decodeHostFrame(value) {
|
|
371
391
|
const frame = requireRecord(value, 'host frame');
|
|
372
392
|
if (frame.kind === 'accepted') {
|
|
393
|
+
if (frame.cooperativeHandoff !== undefined && frame.cooperativeHandoff !== true) {
|
|
394
|
+
throw invalidProtocolFrame('Invalid Runtime Host cooperative handoff capability');
|
|
395
|
+
}
|
|
373
396
|
return {
|
|
374
397
|
kind: 'accepted',
|
|
398
|
+
...(frame.cooperativeHandoff === true ? { cooperativeHandoff: true } : {}),
|
|
375
399
|
rootId: requireHostRootId(frame.rootId),
|
|
376
400
|
hostEpoch: requireId(frame.hostEpoch, 'hostEpoch'),
|
|
377
401
|
connectionId: requireId(frame.connectionId, 'connectionId'),
|
|
@@ -203,6 +203,7 @@ export const REMOTE_OWNER_OPERATION_GRANTS = Object.freeze([
|
|
|
203
203
|
'skill.catalog.query',
|
|
204
204
|
'subscription.close',
|
|
205
205
|
'subscription.open',
|
|
206
|
+
'subscription.pty_interest.set',
|
|
206
207
|
'session.todo.query',
|
|
207
208
|
'turn.interrupt',
|
|
208
209
|
'turn.message.execution.query',
|