maka-agent 0.2.0-dev.46.20260922 → 0.2.0-dev.48.20260923
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/DISCLAIMER-WIP +6 -1
- package/README.md +6 -1
- package/dist/acp/maka-acp-agent.js +1 -1
- package/dist/acp/session-mcp.js +212 -0
- package/dist/acp/session-registry.js +52 -8
- package/dist/acp/stdio-server.js +3 -0
- package/dist/cli-core.js +1 -1
- package/dist/mcp-capability-provider.js +6 -1
- package/dist/mcp-capability-publication.js +139 -0
- package/dist/pi-tui-layout.js +46 -17
- package/dist/pi-tui-pickers.js +25 -14
- package/dist/pi-tui-runner.js +24 -15
- package/dist/runtime-host-capability-provider-command.js +25 -6
- package/dist/runtime-host-service-manager.js +26 -2
- package/dist/tui-context-refresh.js +15 -26
- package/dist/tui-mcp-control.js +66 -112
- package/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
- package/node_modules/@maka/acp-executor-plugin/dist/acp-errors.js +26 -0
- package/node_modules/@maka/acp-executor-plugin/dist/acp-filesystem.js +103 -0
- package/node_modules/@maka/acp-executor-plugin/dist/acp-process.js +119 -0
- package/node_modules/@maka/acp-executor-plugin/dist/acp-projection.js +146 -0
- package/node_modules/@maka/acp-executor-plugin/dist/index.js +653 -0
- package/node_modules/@maka/acp-executor-plugin/dist/plugin.mjs +24446 -0
- package/node_modules/@maka/acp-executor-plugin/package.json +15 -0
- package/node_modules/@maka/antigravity-acp-plugin/dist/index.js +88 -0
- package/node_modules/@maka/antigravity-acp-plugin/dist/model-presentation.js +53 -0
- package/node_modules/@maka/antigravity-acp-plugin/dist/plugin.mjs +115 -0
- package/node_modules/@maka/antigravity-acp-plugin/package.json +15 -0
- package/node_modules/@maka/core/dist/client-capability-grant.js +2 -2
- package/node_modules/@maka/core/dist/executor-catalog.js +106 -0
- package/node_modules/@maka/core/dist/mcp.js +4 -1
- package/node_modules/@maka/core/dist/model-metadata.js +28 -1
- package/node_modules/@maka/core/dist/model-thinking.js +36 -1
- package/node_modules/@maka/core/dist/provider-registry.js +0 -1
- package/node_modules/@maka/core/dist/refresh-read-coordinator.js +62 -0
- package/node_modules/@maka/core/dist/runtime-event-store.js +25 -0
- package/node_modules/@maka/core/dist/runtime-invocation.js +5 -0
- package/node_modules/@maka/core/dist/runtime-policy/connection-catalog-codec.js +4 -0
- package/node_modules/@maka/core/dist/runtime-policy/credential-vault-codec.js +6 -0
- package/node_modules/@maka/core/dist/runtime-policy/policy-codec.js +21 -0
- package/node_modules/@maka/core/dist/session.js +19 -1
- package/node_modules/@maka/core/dist/settings.js +3 -0
- package/node_modules/@maka/core/dist/tool-ledger-scanner.js +365 -104
- package/node_modules/@maka/core/dist/turn-origin.js +14 -0
- package/node_modules/@maka/core/package.json +3 -0
- package/node_modules/@maka/mcp/dist/credential-coordinator.js +6 -1
- package/node_modules/@maka/mcp/dist/index.js +31 -5
- package/node_modules/@maka/mcp/dist/oauth.js +54 -6
- package/node_modules/@maka/runtime/dist/agent-run-inspect.js +1 -1
- package/node_modules/@maka/runtime/dist/ai-sdk-message-projection.js +15 -60
- package/node_modules/@maka/runtime/dist/ai-sdk-turn.js +18 -0
- package/node_modules/@maka/runtime/dist/apply-patch-profile.js +64 -14
- package/node_modules/@maka/runtime/dist/builtin-tools.js +3 -2
- package/node_modules/@maka/runtime/dist/codex-v4a-patch.js +18 -0
- package/node_modules/@maka/runtime/dist/conversation-copy.js +56 -1
- package/node_modules/@maka/runtime/dist/mcp-tools.js +9 -2
- package/node_modules/@maka/runtime/dist/model-adapter.js +80 -3
- package/node_modules/@maka/runtime/dist/model-runtime.js +6 -0
- package/node_modules/@maka/runtime/dist/openai-apply-patch.js +5 -0
- package/node_modules/@maka/runtime/dist/plugin-executor-backend.js +122 -3
- package/node_modules/@maka/runtime/dist/plugin-executor-service.js +212 -16
- package/node_modules/@maka/runtime/dist/runtime-ledger-repair.js +2 -2
- package/node_modules/@maka/runtime/dist/session-event-runtime-mapper.js +3 -0
- package/node_modules/@maka/runtime/dist/session-manager.js +184 -126
- package/node_modules/@maka/runtime/dist/shell-run-manager.js +3 -0
- package/node_modules/@maka/runtime/dist/stream-graph-coordinator.js +29 -4
- package/node_modules/@maka/runtime-host/dist/candidate-entry.js +8 -5
- package/node_modules/@maka/runtime-host/dist/client/capability-provider-service.js +2 -0
- package/node_modules/@maka/runtime-host/dist/client/client-capability-channel.js +59 -20
- package/node_modules/@maka/runtime-host/dist/client/connection.js +6 -4
- package/node_modules/@maka/runtime-host/dist/client/index.js +1 -1
- package/node_modules/@maka/runtime-host/dist/client/reconnect-lifecycle.js +8 -1
- package/node_modules/@maka/runtime-host/dist/client/reconnecting-connection.js +4 -4
- package/node_modules/@maka/runtime-host/dist/client/session-catalog-summary.js +6 -1
- package/node_modules/@maka/runtime-host/dist/composition-identity.js +19 -0
- package/node_modules/@maka/runtime-host/dist/protocol/client-capability.js +20 -3
- package/node_modules/@maka/runtime-host/dist/protocol/external-session.js +8 -5
- package/node_modules/@maka/runtime-host/dist/protocol/index.js +20 -2
- package/node_modules/@maka/runtime-host/dist/protocol/plugin-platform.js +34 -0
- package/node_modules/@maka/runtime-host/dist/protocol/session-catalog.js +75 -5
- package/node_modules/@maka/runtime-host/dist/protocol/workhub-coordination.js +1 -5
- package/node_modules/@maka/runtime-host/dist/server/builtin-external-agent-plugins.js +188 -0
- package/node_modules/@maka/runtime-host/dist/server/candidate.js +12 -7
- package/node_modules/@maka/runtime-host/dist/server/client-capability-coordinator.js +234 -70
- package/node_modules/@maka/runtime-host/dist/server/client-capability-invocation-broker.js +14 -8
- package/node_modules/@maka/runtime-host/dist/server/client-capability-recovery.js +44 -46
- package/node_modules/@maka/runtime-host/dist/server/context-coordinator.js +2 -0
- package/node_modules/@maka/runtime-host/dist/server/execution-composition-factory.js +1 -1
- package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +188 -21
- package/node_modules/@maka/runtime-host/dist/server/execution-model-authority.js +6 -0
- package/node_modules/@maka/runtime-host/dist/server/extension-bundle.js +4 -0
- package/node_modules/@maka/runtime-host/dist/server/external-session-coordinator.js +29 -7
- package/node_modules/@maka/runtime-host/dist/server/host-composition-source.js +47 -0
- package/node_modules/@maka/runtime-host/dist/server/host-composition.js +1 -29
- package/node_modules/@maka/runtime-host/dist/server/host-kernel.js +2 -9
- package/node_modules/@maka/runtime-host/dist/server/hosted-execution-recovery.js +75 -9
- package/node_modules/@maka/runtime-host/dist/server/hosted-execution-tool-profile.js +5 -1
- package/node_modules/@maka/runtime-host/dist/server/interaction-coordinator.js +45 -0
- package/node_modules/@maka/runtime-host/dist/server/jev-routing-model.js +157 -0
- package/node_modules/@maka/runtime-host/dist/server/listener-set.js +2 -2
- package/node_modules/@maka/runtime-host/dist/server/message-coordinator.js +4 -0
- package/node_modules/@maka/runtime-host/dist/server/plugin-platform-coordinator.js +11 -1
- package/node_modules/@maka/runtime-host/dist/server/process-lifecycle.js +1 -1
- package/node_modules/@maka/runtime-host/dist/server/process-termination-error.js +27 -0
- package/node_modules/@maka/runtime-host/dist/server/root-turn-coordinator.js +91 -12
- package/node_modules/@maka/runtime-host/dist/server/runtime-policy-coordinator.js +2 -0
- package/node_modules/@maka/runtime-host/dist/server/session-bundle-coordinator.js +4 -1
- package/node_modules/@maka/runtime-host/dist/server/session-catalog-coordinator.js +128 -13
- package/node_modules/@maka/runtime-host/dist/server/session-effect-coordinator.js +12 -6
- package/node_modules/@maka/runtime-host/dist/server/session-retirement-coordinator.js +2 -2
- package/node_modules/@maka/runtime-host/dist/server/session-transcript-reader.js +33 -0
- package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-coordinator.js +4 -0
- package/node_modules/@maka/runtime-host/dist/server/workhub-result-coordinator.js +173 -0
- package/node_modules/@maka/runtime-host/dist/server/workhub-result-runtime.js +293 -0
- package/node_modules/@maka/runtime-host/package.json +2 -0
- package/node_modules/@maka/storage/dist/agent-run-store-contract.js +8 -0
- package/node_modules/@maka/storage/dist/execution-stores.js +15 -3
- package/node_modules/@maka/storage/dist/mcp-config-store.js +91 -2
- package/node_modules/@maka/storage/dist/operational-state-store.js +15 -1
- package/node_modules/@maka/storage/dist/plan-authority.js +2 -0
- package/node_modules/@maka/storage/dist/plan-store.js +30 -0
- package/node_modules/@maka/storage/dist/runtime-event-persistence.js +1 -0
- package/node_modules/@maka/storage/dist/runtime-policy/credential-vault-document.js +4 -1
- package/node_modules/@maka/storage/dist/runtime-policy/policy-document.js +2 -0
- package/node_modules/@maka/storage/dist/session-store-values.js +16 -4
- package/node_modules/@maka/storage/dist/shell-run-authority.js +1 -0
- package/node_modules/@maka/storage/dist/shell-run-store.js +15 -0
- package/node_modules/@maka/storage/dist/sqlite-runtime-schema.js +74 -1
- package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +724 -84
- package/node_modules/@maka/storage/dist/sqlite-session-metadata-store.js +16 -0
- package/package.json +1 -1
|
@@ -24,74 +24,82 @@ export class ClientCapabilityChannel {
|
|
|
24
24
|
#registrations = new Map();
|
|
25
25
|
#invocations = new Map();
|
|
26
26
|
#releasedRegistrationIds = new Set();
|
|
27
|
-
#
|
|
28
|
-
#
|
|
27
|
+
#currentRegistrationIds = new Map();
|
|
28
|
+
#pendingMutations = new Set();
|
|
29
29
|
#closedError;
|
|
30
30
|
constructor(options) {
|
|
31
31
|
this.#options = options;
|
|
32
32
|
}
|
|
33
|
-
async replace(provider, timeoutMs) {
|
|
33
|
+
async replace(provider, timeoutMs, sessionId) {
|
|
34
34
|
this.#assertOpen();
|
|
35
|
-
if (this.#
|
|
35
|
+
if (this.#pendingMutations.has(sessionId)) {
|
|
36
36
|
throw new Error('A Client Capability registration mutation is already pending');
|
|
37
37
|
}
|
|
38
|
-
this.#
|
|
38
|
+
this.#pendingMutations.add(sessionId);
|
|
39
39
|
const registrationId = randomUUID();
|
|
40
40
|
let registration;
|
|
41
41
|
try {
|
|
42
42
|
const services = provider.services?.() ?? [];
|
|
43
43
|
const canonical = decodeClientCapabilityReplaceInput({
|
|
44
44
|
registrationId,
|
|
45
|
+
...(sessionId === undefined ? {} : { sessionId }),
|
|
45
46
|
offers: provider.offers(),
|
|
46
47
|
...(services.length === 0 ? {} : { services }),
|
|
47
48
|
});
|
|
48
49
|
registration = {
|
|
49
50
|
registrationId,
|
|
51
|
+
...(canonical.sessionId === undefined ? {} : { sessionId: canonical.sessionId }),
|
|
50
52
|
provider,
|
|
51
53
|
offers: canonical.offers,
|
|
52
54
|
services: canonical.services ?? [],
|
|
53
55
|
};
|
|
54
56
|
this.#registrations.set(registrationId, registration);
|
|
55
57
|
const result = await this.#options.replace(canonical, timeoutMs);
|
|
58
|
+
this.#assertOpen();
|
|
56
59
|
if (result.registrationId !== registrationId) {
|
|
57
60
|
throw new Error('Runtime Host replaced a different Client Capability registration');
|
|
58
61
|
}
|
|
59
|
-
this.#
|
|
62
|
+
this.#currentRegistrationIds.set(sessionId, registrationId);
|
|
60
63
|
this.#collectReleasedRegistrations();
|
|
61
64
|
return result;
|
|
62
65
|
}
|
|
63
66
|
catch (error) {
|
|
64
|
-
if (registration && this.#
|
|
67
|
+
if (registration && this.#currentRegistrationIds.get(sessionId) !== registrationId) {
|
|
65
68
|
this.#registrations.delete(registrationId);
|
|
66
69
|
}
|
|
67
70
|
throw error;
|
|
68
71
|
}
|
|
69
72
|
finally {
|
|
70
|
-
this.#
|
|
73
|
+
this.#pendingMutations.delete(sessionId);
|
|
74
|
+
this.#settleReleasedCurrentRegistration(sessionId);
|
|
75
|
+
this.#collectReleasedRegistrations();
|
|
71
76
|
}
|
|
72
77
|
}
|
|
73
|
-
async unregister(timeoutMs) {
|
|
78
|
+
async unregister(timeoutMs, sessionId) {
|
|
74
79
|
this.#assertOpen();
|
|
75
|
-
if (this.#
|
|
80
|
+
if (this.#pendingMutations.has(sessionId)) {
|
|
76
81
|
throw new Error('A Client Capability registration mutation is already pending');
|
|
77
82
|
}
|
|
78
|
-
const registrationId = this.#
|
|
83
|
+
const registrationId = this.#currentRegistrationIds.get(sessionId);
|
|
79
84
|
if (!registrationId)
|
|
80
85
|
throw new Error('No Client Capability registration is active');
|
|
81
|
-
this.#
|
|
86
|
+
this.#pendingMutations.add(sessionId);
|
|
82
87
|
try {
|
|
83
88
|
const result = await this.#options.unregister({ registrationId }, timeoutMs);
|
|
89
|
+
this.#assertOpen();
|
|
84
90
|
if (result.registrationId !== registrationId) {
|
|
85
91
|
throw new Error('Runtime Host unregistered a different Client Capability registration');
|
|
86
92
|
}
|
|
87
|
-
if (this.#
|
|
88
|
-
this.#
|
|
93
|
+
if (this.#currentRegistrationIds.get(sessionId) === registrationId) {
|
|
94
|
+
this.#currentRegistrationIds.delete(sessionId);
|
|
89
95
|
}
|
|
90
96
|
this.#collectReleasedRegistrations();
|
|
91
97
|
return result;
|
|
92
98
|
}
|
|
93
99
|
finally {
|
|
94
|
-
this.#
|
|
100
|
+
this.#pendingMutations.delete(sessionId);
|
|
101
|
+
this.#settleReleasedCurrentRegistration(sessionId);
|
|
102
|
+
this.#collectReleasedRegistrations();
|
|
95
103
|
}
|
|
96
104
|
}
|
|
97
105
|
accept(frame) {
|
|
@@ -124,10 +132,17 @@ export class ClientCapabilityChannel {
|
|
|
124
132
|
this.#invocations.delete(frame.invocationId);
|
|
125
133
|
return;
|
|
126
134
|
}
|
|
127
|
-
case 'client.capability.registration_release':
|
|
135
|
+
case 'client.capability.registration_release': {
|
|
136
|
+
const registration = this.#registrations.get(frame.registrationId);
|
|
128
137
|
this.#releasedRegistrationIds.add(frame.registrationId);
|
|
138
|
+
// A successful replacement can enqueue the old release before its response. Defer
|
|
139
|
+
// current-slot retirement until the in-flight mutation establishes which ID won.
|
|
140
|
+
if (registration && !this.#pendingMutations.has(registration.sessionId)) {
|
|
141
|
+
this.#settleReleasedCurrentRegistration(registration.sessionId);
|
|
142
|
+
}
|
|
129
143
|
this.#collectReleasedRegistrations();
|
|
130
144
|
return;
|
|
145
|
+
}
|
|
131
146
|
case 'client.capability.admitted': {
|
|
132
147
|
const invocation = this.#invocations.get(frame.invocationId);
|
|
133
148
|
if (!invocation?.admission || !invocation.admission.resolve()) {
|
|
@@ -161,7 +176,7 @@ export class ClientCapabilityChannel {
|
|
|
161
176
|
const providers = new Set([...this.#registrations.values()].map((registration) => registration.provider));
|
|
162
177
|
this.#registrations.clear();
|
|
163
178
|
this.#releasedRegistrationIds.clear();
|
|
164
|
-
this.#
|
|
179
|
+
this.#currentRegistrationIds.clear();
|
|
165
180
|
for (const provider of providers)
|
|
166
181
|
this.#closeProvider(provider);
|
|
167
182
|
}
|
|
@@ -172,7 +187,11 @@ export class ClientCapabilityChannel {
|
|
|
172
187
|
const registration = this.#registrations.get(frame.registrationId);
|
|
173
188
|
const offer = registration?.offers.find((candidate) => candidate.offerId === frame.offerId);
|
|
174
189
|
const offered = offer?.tools.some((tool) => tool.serverId === frame.serverId && tool.name === frame.toolName);
|
|
175
|
-
if (!registration ||
|
|
190
|
+
if (!registration ||
|
|
191
|
+
(registration.sessionId !== undefined && registration.sessionId !== frame.sessionId) ||
|
|
192
|
+
!offer ||
|
|
193
|
+
!offered ||
|
|
194
|
+
!registration.provider.call) {
|
|
176
195
|
void this.#options
|
|
177
196
|
.write({
|
|
178
197
|
kind: 'client.capability.rejected',
|
|
@@ -403,10 +422,12 @@ export class ClientCapabilityChannel {
|
|
|
403
422
|
}
|
|
404
423
|
#collectReleasedRegistrations() {
|
|
405
424
|
for (const registrationId of this.#releasedRegistrationIds) {
|
|
406
|
-
if (
|
|
425
|
+
if ([...this.#currentRegistrationIds.values()].includes(registrationId))
|
|
407
426
|
continue;
|
|
408
|
-
this.#releasedRegistrationIds.delete(registrationId);
|
|
409
427
|
const registration = this.#registrations.get(registrationId);
|
|
428
|
+
if (registration && this.#pendingMutations.has(registration.sessionId))
|
|
429
|
+
continue;
|
|
430
|
+
this.#releasedRegistrationIds.delete(registrationId);
|
|
410
431
|
if (!registration)
|
|
411
432
|
continue;
|
|
412
433
|
this.#registrations.delete(registrationId);
|
|
@@ -415,6 +436,16 @@ export class ClientCapabilityChannel {
|
|
|
415
436
|
}
|
|
416
437
|
}
|
|
417
438
|
}
|
|
439
|
+
#settleReleasedCurrentRegistration(sessionId) {
|
|
440
|
+
const registrationId = this.#currentRegistrationIds.get(sessionId);
|
|
441
|
+
if (!registrationId || !this.#releasedRegistrationIds.has(registrationId))
|
|
442
|
+
return;
|
|
443
|
+
const registration = this.#registrations.get(registrationId);
|
|
444
|
+
this.#currentRegistrationIds.delete(sessionId);
|
|
445
|
+
this.#collectReleasedRegistrations();
|
|
446
|
+
if (registration)
|
|
447
|
+
this.#notifyCurrentRegistrationRetired(registration.provider);
|
|
448
|
+
}
|
|
418
449
|
#closeProvider(provider) {
|
|
419
450
|
try {
|
|
420
451
|
void Promise.resolve(provider.close?.()).catch((error) => this.#options.onFailure(asError(error)));
|
|
@@ -423,6 +454,14 @@ export class ClientCapabilityChannel {
|
|
|
423
454
|
this.#options.onFailure(asError(error));
|
|
424
455
|
}
|
|
425
456
|
}
|
|
457
|
+
#notifyCurrentRegistrationRetired(provider) {
|
|
458
|
+
try {
|
|
459
|
+
void Promise.resolve(provider.currentRegistrationRetired?.()).catch((error) => this.#options.onFailure(asError(error)));
|
|
460
|
+
}
|
|
461
|
+
catch (error) {
|
|
462
|
+
this.#options.onFailure(asError(error));
|
|
463
|
+
}
|
|
464
|
+
}
|
|
426
465
|
#assertOpen() {
|
|
427
466
|
if (this.#closedError)
|
|
428
467
|
throw this.#closedError;
|
|
@@ -299,11 +299,13 @@ class RuntimeHostConnectionImpl {
|
|
|
299
299
|
this.#fail(new RuntimeHostTransportError('closed', 'Runtime Host connection closed by Client'), true);
|
|
300
300
|
await this.closed;
|
|
301
301
|
}
|
|
302
|
-
async replaceClientCapabilities(provider,
|
|
303
|
-
|
|
302
|
+
async replaceClientCapabilities(provider, options) {
|
|
303
|
+
const { timeoutMs = DEFAULT_HANDSHAKE_TIMEOUT_MS, sessionId } = typeof options === 'number' ? { timeoutMs: options } : (options ?? {});
|
|
304
|
+
return this.#clientCapabilities.replace(provider, timeoutMs, sessionId);
|
|
304
305
|
}
|
|
305
|
-
async unregisterClientCapabilities(
|
|
306
|
-
|
|
306
|
+
async unregisterClientCapabilities(options) {
|
|
307
|
+
const { timeoutMs = DEFAULT_HANDSHAKE_TIMEOUT_MS, sessionId } = typeof options === 'number' ? { timeoutMs: options } : (options ?? {});
|
|
308
|
+
return this.#clientCapabilities.unregister(timeoutMs, sessionId);
|
|
307
309
|
}
|
|
308
310
|
subscribeConfigurationChanges(listener) {
|
|
309
311
|
this.#configurationChangeListeners.add(listener);
|
|
@@ -28,7 +28,7 @@ export { LOCAL_RUNTIME_HOST_PROFILE, RUNTIME_HOST_ACCESS_CREDENTIAL_MAX_BYTES, c
|
|
|
28
28
|
export { createRuntimeHostReconnectingConnection, isRuntimeHostReconnectingConnection, } from './reconnecting-connection.js';
|
|
29
29
|
export { RuntimeHostSshOperatorActivationError, activateRuntimeHostSshOperator, runtimeHostSshOperatorRemoteCommand, } from './ssh-operator-activation.js';
|
|
30
30
|
export { normalizeRuntimeHostSshDestination, openRuntimeHostSshTunnel, } from './ssh-tunnel.js';
|
|
31
|
-
export { RuntimeHostPermanentReconnectError, startRuntimeHostReconnectLifecycle, } from './reconnect-lifecycle.js';
|
|
31
|
+
export { RuntimeHostPermanentReconnectError, createRuntimeHostReconnectLifecycle, startRuntimeHostReconnectLifecycle, } from './reconnect-lifecycle.js';
|
|
32
32
|
export { RUNTIME_HOST_REMOTE_INCOMPATIBLE_CODE, RuntimeHostRemoteCompatibilityError, } from './remote-compatibility-error.js';
|
|
33
33
|
export { RuntimeHostSubscriptionError, SessionRemovedSubscriptionError, subscriptionClosedError, } from './session-subscription.js';
|
|
34
34
|
export { RuntimeHostStartupError, runtimeHostStartupError, } from './startup-error.js';
|
|
@@ -26,8 +26,15 @@ export class RuntimeHostPermanentReconnectError extends Error {
|
|
|
26
26
|
this.name = 'RuntimeHostPermanentReconnectError';
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* A lifecycle that exists before its first connection. `waitForCurrent` parks
|
|
31
|
+
* until `start()` installs one and rejects if the start fails permanently.
|
|
32
|
+
*/
|
|
33
|
+
export function createRuntimeHostReconnectLifecycle(input) {
|
|
34
|
+
return new RuntimeHostReconnectLifecycleImpl(input);
|
|
35
|
+
}
|
|
29
36
|
export async function startRuntimeHostReconnectLifecycle(input) {
|
|
30
|
-
const lifecycle =
|
|
37
|
+
const lifecycle = createRuntimeHostReconnectLifecycle(input);
|
|
31
38
|
await lifecycle.start();
|
|
32
39
|
return lifecycle;
|
|
33
40
|
}
|
|
@@ -142,13 +142,13 @@ class RuntimeHostReconnectingConnectionImpl {
|
|
|
142
142
|
openSessionSubscriptionOnce(input, timeoutMs) {
|
|
143
143
|
return this.#requireCurrent('subscription.open').openSessionSubscription(input, timeoutMs);
|
|
144
144
|
}
|
|
145
|
-
async replaceClientCapabilities(provider,
|
|
145
|
+
async replaceClientCapabilities(provider, options) {
|
|
146
146
|
const connection = this.#requireCurrent('client.capability.replace');
|
|
147
|
-
return connection.replaceClientCapabilities(provider,
|
|
147
|
+
return connection.replaceClientCapabilities(provider, options);
|
|
148
148
|
}
|
|
149
|
-
async unregisterClientCapabilities(
|
|
149
|
+
async unregisterClientCapabilities(options) {
|
|
150
150
|
const connection = this.#requireCurrent('client.capability.unregister');
|
|
151
|
-
return connection.unregisterClientCapabilities(
|
|
151
|
+
return connection.unregisterClientCapabilities(options);
|
|
152
152
|
}
|
|
153
153
|
subscribeConfigurationChanges(listener) {
|
|
154
154
|
this.#configurationListeners.add(listener);
|
|
@@ -54,7 +54,12 @@ export function projectSessionCatalogSummary(session) {
|
|
|
54
54
|
...(session.revisionIndex === undefined ? {} : { revisionIndex: session.revisionIndex }),
|
|
55
55
|
...(session.revisionState === undefined ? {} : { revisionState: session.revisionState }),
|
|
56
56
|
backend: session.backend,
|
|
57
|
-
...(session.executorId
|
|
57
|
+
...(session.executorId
|
|
58
|
+
? {
|
|
59
|
+
executorId: session.executorId,
|
|
60
|
+
...(session.executorConfig ? { executorConfig: session.executorConfig } : {}),
|
|
61
|
+
}
|
|
62
|
+
: {}),
|
|
58
63
|
...(session.llmConnectionId === null ? {} : { llmConnectionId: session.llmConnectionId }),
|
|
59
64
|
llmConnectionSlug: session.llmConnectionSlug,
|
|
60
65
|
connectionLocked: session.connectionLocked,
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
export const INTERACTIVE_RUNTIME_HOST_COMPOSITION_ID = 'maka.interactive';
|
|
@@ -59,7 +59,7 @@ export const CLIENT_CAPABILITY_OPERATION_SPECS = {
|
|
|
59
59
|
};
|
|
60
60
|
export function decodeClientCapabilityReplaceInput(value) {
|
|
61
61
|
const record = requireRecord(value, 'Client Capability replacement');
|
|
62
|
-
assertOptionalExactKeys(record, 'Client Capability replacement', ['registrationId', 'offers'], ['services']);
|
|
62
|
+
assertOptionalExactKeys(record, 'Client Capability replacement', ['registrationId', 'offers'], ['services', 'sessionId']);
|
|
63
63
|
if (!Array.isArray(record.offers) || record.offers.length > CLIENT_CAPABILITY_MAX_OFFERS) {
|
|
64
64
|
throw invalidProtocolFrame('Invalid Client Capability offers');
|
|
65
65
|
}
|
|
@@ -67,11 +67,23 @@ export function decodeClientCapabilityReplaceInput(value) {
|
|
|
67
67
|
if (!Array.isArray(serviceValues) || serviceValues.length > CLIENT_CAPABILITY_MAX_SERVICES) {
|
|
68
68
|
throw invalidProtocolFrame('Invalid Client Capability services');
|
|
69
69
|
}
|
|
70
|
-
|
|
70
|
+
// An empty Session snapshot clears lost contracts after reconnect and keeps
|
|
71
|
+
// a bounded registration through which the Host can signal Session retirement.
|
|
72
|
+
// Connection-wide publications still use unregister for withdrawal.
|
|
73
|
+
if (record.offers.length === 0 && serviceValues.length === 0 && record.sessionId === undefined) {
|
|
71
74
|
throw invalidProtocolFrame('Client Capability registration is empty');
|
|
72
75
|
}
|
|
73
76
|
const offers = record.offers.map((offer) => decodeClientCapabilityOffer(offer));
|
|
74
77
|
const services = serviceValues.map((service) => decodeClientCapabilityServiceOffer(service));
|
|
78
|
+
const sessionId = record.sessionId === undefined ? undefined : requireEntityId(record.sessionId, 'sessionId');
|
|
79
|
+
if (sessionId !== undefined &&
|
|
80
|
+
(services.length > 0 ||
|
|
81
|
+
offers.some((offer) => offer.affinity !== 'session' || offer.hostPathAccess !== 'none'))) {
|
|
82
|
+
throw invalidProtocolFrame('Session capabilities must be path-independent session tools');
|
|
83
|
+
}
|
|
84
|
+
if (offers.some((offer) => offer.admission === 'mcp') && sessionId === undefined) {
|
|
85
|
+
throw invalidProtocolFrame('MCP admission requires a target Session');
|
|
86
|
+
}
|
|
75
87
|
const offerIds = new Set();
|
|
76
88
|
const serviceContracts = new Set();
|
|
77
89
|
const toolIdentities = new Set();
|
|
@@ -102,6 +114,7 @@ export function decodeClientCapabilityReplaceInput(value) {
|
|
|
102
114
|
}
|
|
103
115
|
const decoded = {
|
|
104
116
|
registrationId: requireEntityId(record.registrationId, 'registrationId'),
|
|
117
|
+
...(sessionId === undefined ? {} : { sessionId }),
|
|
105
118
|
offers,
|
|
106
119
|
...(record.services === undefined ? {} : { services }),
|
|
107
120
|
};
|
|
@@ -427,17 +440,21 @@ function decodeClientCapabilityFormResult(value) {
|
|
|
427
440
|
}
|
|
428
441
|
function decodeClientCapabilityOffer(value) {
|
|
429
442
|
const record = requireRecord(value, 'Client Capability offer');
|
|
430
|
-
assertOptionalExactKeys(record, 'Client Capability offer', ['offerId', 'version', 'affinity', 'hostPathAccess', 'label', 'tools'], ['description']);
|
|
443
|
+
assertOptionalExactKeys(record, 'Client Capability offer', ['offerId', 'version', 'affinity', 'hostPathAccess', 'label', 'tools'], ['description', 'admission']);
|
|
431
444
|
if (!Array.isArray(record.tools) ||
|
|
432
445
|
record.tools.length === 0 ||
|
|
433
446
|
record.tools.length > CLIENT_CAPABILITY_MAX_TOOLS_PER_OFFER) {
|
|
434
447
|
throw invalidProtocolFrame('Invalid Client Capability offer tools');
|
|
435
448
|
}
|
|
449
|
+
if (record.admission !== undefined && record.admission !== 'mcp') {
|
|
450
|
+
throw invalidProtocolFrame('Invalid Client Capability admission');
|
|
451
|
+
}
|
|
436
452
|
return {
|
|
437
453
|
offerId: requireEntityId(record.offerId, 'offerId'),
|
|
438
454
|
version: requireString(record.version, 'version', 64),
|
|
439
455
|
affinity: decodeClientCapabilityAffinity(record.affinity),
|
|
440
456
|
hostPathAccess: decodeClientCapabilityHostPathAccess(record.hostPathAccess),
|
|
457
|
+
...(record.admission === 'mcp' ? { admission: 'mcp' } : {}),
|
|
441
458
|
label: requireString(record.label, 'label', 128),
|
|
442
459
|
...(record.description === undefined
|
|
443
460
|
? {}
|
|
@@ -120,15 +120,18 @@ export function decodeExternalSessionCatalogQueryResult(value) {
|
|
|
120
120
|
return decoded;
|
|
121
121
|
}
|
|
122
122
|
export function decodeExternalSessionImportInput(value) {
|
|
123
|
-
const input =
|
|
124
|
-
'adapterId',
|
|
125
|
-
'sourceSessionId',
|
|
126
|
-
]);
|
|
123
|
+
const input = requireShapedRecord(value, 'external Session import input', ['adapterId', 'sourceSessionId'], ['workspace']);
|
|
127
124
|
const sourceSessionId = requireUtf8String(input.sourceSessionId, 'external source Session id', EXTERNAL_SESSION_SOURCE_SESSION_ID_MAX_BYTES);
|
|
128
125
|
if (/[\u0000-\u001f\u007f]/.test(sourceSessionId)) {
|
|
129
126
|
throw invalidProtocolFrame('Invalid external source Session id');
|
|
130
127
|
}
|
|
131
|
-
return {
|
|
128
|
+
return {
|
|
129
|
+
adapterId: adapterId(input.adapterId),
|
|
130
|
+
sourceSessionId,
|
|
131
|
+
...(Object.hasOwn(input, 'workspace')
|
|
132
|
+
? { workspace: decodeWorkspaceTarget(input.workspace) }
|
|
133
|
+
: {}),
|
|
134
|
+
};
|
|
132
135
|
}
|
|
133
136
|
export function decodeExternalSessionImportResult(value) {
|
|
134
137
|
const result = requireRecord(value, 'external Session import result');
|
|
@@ -28,6 +28,7 @@ import { decodeProjectCatalogChangedFrame, } from './project-catalog-change.js';
|
|
|
28
28
|
import { decodeConnectionCatalogChangedFrame, } from './connection-catalog-change.js';
|
|
29
29
|
import { decodeRequestFrame, decodeResponseFrame, } from './operations.js';
|
|
30
30
|
import { isCanonicalRuntimeHostWebSocketPath } from './websocket-path.js';
|
|
31
|
+
import { INTERACTIVE_RUNTIME_HOST_COMPOSITION_ID } from '../composition-identity.js';
|
|
31
32
|
export * from './access-authority.js';
|
|
32
33
|
export * from './agent-graph.js';
|
|
33
34
|
export * from './interaction.js';
|
|
@@ -58,11 +59,29 @@ export * from './session-todo.js';
|
|
|
58
59
|
export * from './workspace.js';
|
|
59
60
|
export * from './workhub-coordination.js';
|
|
60
61
|
export * from './websocket-path.js';
|
|
62
|
+
export { INTERACTIVE_RUNTIME_HOST_COMPOSITION_ID } from '../composition-identity.js';
|
|
61
63
|
export const RUNTIME_HOST_REGISTRATION_SCHEMA_VERSION = 1;
|
|
62
64
|
export const RUNTIME_HOST_PROTOCOL_VERSION = 0;
|
|
63
65
|
// Increment when the same protocol version no longer guarantees safe Client-Host
|
|
64
66
|
// interoperability. Mismatches are rejected before domain commands are admitted.
|
|
65
|
-
export const RUNTIME_HOST_COMPATIBILITY_EPOCH =
|
|
67
|
+
export const RUNTIME_HOST_COMPATIBILITY_EPOCH = 183;
|
|
68
|
+
// 183: Jev policy snapshots, set_jev mutation and credential locator require matching peers.
|
|
69
|
+
// 182: Executor catalogs expose structured model families and thinking variant IDs.
|
|
70
|
+
// 181: Canonical executor models and retained provider stop reasons after cancellation.
|
|
71
|
+
// 180: Reject contradictory executor configuration and legacy model targets.
|
|
72
|
+
// 179: Generic executor discovery and confirmed per-Session configuration.
|
|
73
|
+
// 178: WorkHub result turns carry a Host-owned workhub_result origin. Older
|
|
74
|
+
// Clients reject that origin and cannot render the result notification.
|
|
75
|
+
// 177: External Session import input may carry an optional Host-resolved
|
|
76
|
+
// workspace target. Epoch-176 peers reject the unknown `workspace` key.
|
|
77
|
+
// 176: Session-scoped capability publication and MCP admission require compatible
|
|
78
|
+
// Client and Host builds; older peers do not enforce their isolation contract.
|
|
79
|
+
// 175: WorkHub coordinator model configuration again accepts only native
|
|
80
|
+
// explicit targets. Epoch-174 peers may send an executor target it must reject.
|
|
81
|
+
// 174: WorkHub new-Work defaults may select an executor-specific model and
|
|
82
|
+
// thinking level. Epoch-173 peers reject these fields on strict action shapes.
|
|
83
|
+
// 173: Plugin executor Sessions may select an executor-specific model at
|
|
84
|
+
// creation and configuration time, and propagate its reasoning effort.
|
|
66
85
|
// 172: Usage screen requests and results accept fractional timestamps in the
|
|
67
86
|
// persisted domain. Older peers reject these otherwise valid wire values.
|
|
68
87
|
// 171: Removed the `connection.usage.read` operation along with the Command
|
|
@@ -405,7 +424,6 @@ export const RUNTIME_HOST_COMPATIBILITY_EPOCH = 172;
|
|
|
405
424
|
// one transport message; narrower domains retain their own encoded limits.
|
|
406
425
|
export const RUNTIME_HOST_MAX_MESSAGE_BYTES = 768 * 1024;
|
|
407
426
|
export const RUNTIME_HOST_MAX_IN_FLIGHT_DOMAIN_REQUESTS = 64;
|
|
408
|
-
export const INTERACTIVE_RUNTIME_HOST_COMPOSITION_ID = 'maka.interactive';
|
|
409
427
|
export function negotiateProtocol(client, host) {
|
|
410
428
|
validateProtocolRange(client);
|
|
411
429
|
validateProtocolRange(host);
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
* specific language governing permissions and limitations
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
|
+
import { normalizeCatalogEntry } from '@maka/core/executor-catalog';
|
|
19
20
|
import { validateCompositionEntry, validatePluginRootId, } from '@maka/runtime/plugin-runtime';
|
|
20
21
|
import { requireCount, requireEncodedByteLimit, requireExactRecord, requireId, requireRecord, requireShapedRecord, requireString, } from './codec.js';
|
|
21
22
|
import { invalidProtocolFrame } from './errors.js';
|
|
@@ -85,6 +86,39 @@ export const PLUGIN_PLATFORM_OPERATION_SPECS = {
|
|
|
85
86
|
decodeInput: decodePluginClientRemoteStreamCursorInput,
|
|
86
87
|
decodeOutput: decodePluginClientRemoteStreamCloseResult,
|
|
87
88
|
}),
|
|
89
|
+
'plugin.executor.query': defineOperation({
|
|
90
|
+
mode: 'query',
|
|
91
|
+
availability: 'ready',
|
|
92
|
+
errors: QUERY_ERRORS,
|
|
93
|
+
decodeInput: (value) => {
|
|
94
|
+
const record = requireRecord(value, 'Executor query');
|
|
95
|
+
if (record.kind === 'catalog') {
|
|
96
|
+
const input = requireExactRecord(record, 'Executor catalog', ['kind', 'cwd']);
|
|
97
|
+
return { kind: 'catalog', cwd: requireString(input.cwd, 'cwd', 4096) };
|
|
98
|
+
}
|
|
99
|
+
const input = requireExactRecord(record, 'Executor conversation', ['kind', 'sessionId']);
|
|
100
|
+
if (input.kind !== 'conversation')
|
|
101
|
+
throw invalidProtocolFrame('Invalid executor query');
|
|
102
|
+
return { kind: 'conversation', sessionId: requireId(input.sessionId, 'sessionId') };
|
|
103
|
+
},
|
|
104
|
+
decodeOutput: (value) => {
|
|
105
|
+
requireEncodedByteLimit(value, 'Executor catalog', MAX_FRAME_BYTES);
|
|
106
|
+
const output = requireExactRecord(value, 'Executor catalog result', ['items']);
|
|
107
|
+
if (!Array.isArray(output.items) || output.items.length > 256)
|
|
108
|
+
throw invalidProtocolFrame('Invalid executor catalog');
|
|
109
|
+
return {
|
|
110
|
+
items: output.items.map((entry) => {
|
|
111
|
+
const record = requireRecord(entry, 'Executor catalog entry');
|
|
112
|
+
try {
|
|
113
|
+
return normalizeCatalogEntry(record, requireString(record.id, 'executor id', 256));
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
throw invalidProtocolFrame('Invalid executor catalog entry');
|
|
117
|
+
}
|
|
118
|
+
}),
|
|
119
|
+
};
|
|
120
|
+
},
|
|
121
|
+
}),
|
|
88
122
|
'plugin.platform.query': defineOperation({
|
|
89
123
|
mode: 'query',
|
|
90
124
|
availability: 'ready',
|
|
@@ -16,11 +16,12 @@
|
|
|
16
16
|
* specific language governing permissions and limitations
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
|
+
import { isExecutorConfiguration } from '@maka/core/executor-catalog';
|
|
19
20
|
import { isCollaborationMode } from '@maka/core/collaboration';
|
|
20
21
|
import { isOrchestrationMode } from '@maka/core/orchestration';
|
|
21
22
|
import { isPermissionMode } from '@maka/core/permission';
|
|
22
23
|
import { isSessionStartMode } from '@maka/core/session-start-mode';
|
|
23
|
-
import { isSessionBlockedReason, isSessionToolProfile, } from '@maka/core/session';
|
|
24
|
+
import { isSessionBlockedReason, isSessionToolProfile, SESSION_MODEL_ID_MAX_BYTES, } from '@maka/core/session';
|
|
24
25
|
import { isThinkingLevel } from '@maka/core/model-thinking';
|
|
25
26
|
import { isExecutorId } from '@maka/core/executor-id';
|
|
26
27
|
import { assertAllowedKeys, requireCount, requireEncodedByteLimit, requireEntityId, requireExactRecord, requireRecord, requireShapedRecord, requireUtf8String, } from './codec.js';
|
|
@@ -36,7 +37,7 @@ export const SESSION_CATALOG_NAME_MAX_BYTES = 320;
|
|
|
36
37
|
export const SESSION_CATALOG_LABEL_MAX_ITEMS = 32;
|
|
37
38
|
export const SESSION_CATALOG_LABEL_MAX_BYTES = 128;
|
|
38
39
|
export const SESSION_CATALOG_PREVIEW_MAX_BYTES = 4 * 1024;
|
|
39
|
-
export const SESSION_CATALOG_MODEL_MAX_BYTES =
|
|
40
|
+
export const SESSION_CATALOG_MODEL_MAX_BYTES = SESSION_MODEL_ID_MAX_BYTES;
|
|
40
41
|
export const SESSION_CATALOG_CONNECTION_SLUG_MAX_BYTES = 256;
|
|
41
42
|
export const SESSION_CATALOG_LIVE_RUN_STATE_SCHEMA_VERSION = 1;
|
|
42
43
|
export const SESSION_CATALOG_RUNNING_TURN_MAX_ITEMS = 64;
|
|
@@ -94,6 +95,7 @@ const PROJECTION_FIELDS = [
|
|
|
94
95
|
'revisionIndex',
|
|
95
96
|
'revisionState',
|
|
96
97
|
'executorId',
|
|
98
|
+
'executorConfig',
|
|
97
99
|
'thinkingLevel',
|
|
98
100
|
'lastReadMessageId',
|
|
99
101
|
'liveRunState',
|
|
@@ -251,6 +253,8 @@ export function decodeSessionCreateInput(value) {
|
|
|
251
253
|
'labels',
|
|
252
254
|
'modelTarget',
|
|
253
255
|
'executorId',
|
|
256
|
+
'executorModel',
|
|
257
|
+
'executorConfig',
|
|
254
258
|
'thinkingLevel',
|
|
255
259
|
'toolProfile',
|
|
256
260
|
'permissionMode',
|
|
@@ -260,10 +264,24 @@ export function decodeSessionCreateInput(value) {
|
|
|
260
264
|
const executorId = Object.hasOwn(input, 'executorId')
|
|
261
265
|
? executorIdValue(input.executorId)
|
|
262
266
|
: undefined;
|
|
267
|
+
if (input.executorConfig !== undefined &&
|
|
268
|
+
(!executorId || !isExecutorConfiguration(input.executorConfig)))
|
|
269
|
+
throw invalidProtocolFrame('Invalid executor configuration');
|
|
263
270
|
const target = Object.hasOwn(input, 'modelTarget') ? modelTarget(input.modelTarget) : undefined;
|
|
271
|
+
const executorModel = Object.hasOwn(input, 'executorModel')
|
|
272
|
+
? requireUtf8String(input.executorModel, 'Executor model', SESSION_CATALOG_MODEL_MAX_BYTES)
|
|
273
|
+
: undefined;
|
|
264
274
|
if ((executorId === undefined) === (target === undefined)) {
|
|
265
275
|
throw invalidProtocolFrame('Session creation requires exactly one model target or executor id');
|
|
266
276
|
}
|
|
277
|
+
if (executorModel !== undefined &&
|
|
278
|
+
input.executorConfig?.model !== undefined &&
|
|
279
|
+
executorModel !== input.executorConfig.model) {
|
|
280
|
+
throw invalidProtocolFrame('Conflicting executor models');
|
|
281
|
+
}
|
|
282
|
+
if (executorModel !== undefined && executorId === undefined) {
|
|
283
|
+
throw invalidProtocolFrame('Executor model requires an executor id');
|
|
284
|
+
}
|
|
267
285
|
return {
|
|
268
286
|
sessionId: requireEntityId(input.sessionId, 'sessionId'),
|
|
269
287
|
workspace: decodeWorkspaceTarget(input.workspace),
|
|
@@ -272,6 +290,15 @@ export function decodeSessionCreateInput(value) {
|
|
|
272
290
|
...(Object.hasOwn(input, 'labels') ? { labels: labels(input.labels) } : {}),
|
|
273
291
|
...(target ? { modelTarget: target } : {}),
|
|
274
292
|
...(executorId ? { executorId } : {}),
|
|
293
|
+
...(executorModel ? { executorModel } : {}),
|
|
294
|
+
...(executorId
|
|
295
|
+
? {
|
|
296
|
+
executorId,
|
|
297
|
+
...(input.executorConfig
|
|
298
|
+
? { executorConfig: input.executorConfig }
|
|
299
|
+
: {}),
|
|
300
|
+
}
|
|
301
|
+
: {}),
|
|
275
302
|
...(Object.hasOwn(input, 'thinkingLevel')
|
|
276
303
|
? { thinkingLevel: input.thinkingLevel === null ? null : thinkingLevel(input.thinkingLevel) }
|
|
277
304
|
: {}),
|
|
@@ -327,17 +354,39 @@ export function decodeSessionConfigurationUpdateInput(value) {
|
|
|
327
354
|
'expectedRevision',
|
|
328
355
|
'patch',
|
|
329
356
|
]);
|
|
330
|
-
const patch = requireShapedRecord(input.patch, 'Session configuration patch', [], [
|
|
357
|
+
const patch = requireShapedRecord(input.patch, 'Session configuration patch', [], [
|
|
358
|
+
'executorConfig',
|
|
359
|
+
'modelTarget',
|
|
360
|
+
'executorTarget',
|
|
361
|
+
'thinkingLevel',
|
|
362
|
+
'permissionMode',
|
|
363
|
+
'collaborationMode',
|
|
364
|
+
'orchestrationMode',
|
|
365
|
+
]);
|
|
366
|
+
if (patch.executorConfig !== undefined &&
|
|
367
|
+
(!isExecutorConfiguration(patch.executorConfig) ||
|
|
368
|
+
patch.modelTarget !== undefined ||
|
|
369
|
+
patch.executorTarget !== undefined))
|
|
370
|
+
throw invalidProtocolFrame('Invalid executor configuration');
|
|
331
371
|
if (Object.keys(patch).length === 0) {
|
|
332
372
|
throw invalidProtocolFrame('Session configuration patch is empty');
|
|
333
373
|
}
|
|
374
|
+
if (Object.hasOwn(patch, 'modelTarget') && Object.hasOwn(patch, 'executorTarget')) {
|
|
375
|
+
throw invalidProtocolFrame('Session configuration cannot select two execution targets');
|
|
376
|
+
}
|
|
334
377
|
return {
|
|
335
378
|
sessionId: requireEntityId(input.sessionId, 'sessionId'),
|
|
336
379
|
expectedRevision: positiveRevision(input.expectedRevision, 'expected Session revision'),
|
|
337
380
|
patch: {
|
|
381
|
+
...(patch.executorConfig
|
|
382
|
+
? { executorConfig: patch.executorConfig }
|
|
383
|
+
: {}),
|
|
338
384
|
...(Object.hasOwn(patch, 'modelTarget')
|
|
339
385
|
? { modelTarget: explicitModelTarget(patch.modelTarget) }
|
|
340
386
|
: {}),
|
|
387
|
+
...(Object.hasOwn(patch, 'executorTarget')
|
|
388
|
+
? { executorTarget: executorTarget(patch.executorTarget) }
|
|
389
|
+
: {}),
|
|
341
390
|
...(Object.hasOwn(patch, 'thinkingLevel')
|
|
342
391
|
? {
|
|
343
392
|
thinkingLevel: patch.thinkingLevel === null ? null : thinkingLevel(patch.thinkingLevel),
|
|
@@ -659,10 +708,31 @@ function executorIdValue(value) {
|
|
|
659
708
|
}
|
|
660
709
|
return id;
|
|
661
710
|
}
|
|
711
|
+
function executorTarget(value) {
|
|
712
|
+
const exact = requireShapedRecord(value, 'Session executor target', ['executorId'], ['model']);
|
|
713
|
+
return {
|
|
714
|
+
executorId: executorIdValue(exact.executorId),
|
|
715
|
+
...(Object.hasOwn(exact, 'model')
|
|
716
|
+
? {
|
|
717
|
+
model: requireUtf8String(exact.model, 'Executor model', SESSION_CATALOG_MODEL_MAX_BYTES),
|
|
718
|
+
}
|
|
719
|
+
: {}),
|
|
720
|
+
};
|
|
721
|
+
}
|
|
662
722
|
function optionalExecutorId(record) {
|
|
663
|
-
if (record.executorId === undefined)
|
|
723
|
+
if (record.executorId === undefined) {
|
|
724
|
+
if (record.executorConfig !== undefined)
|
|
725
|
+
throw invalidProtocolFrame('Executor configuration requires an executor');
|
|
664
726
|
return {};
|
|
665
|
-
|
|
727
|
+
}
|
|
728
|
+
if (record.executorConfig !== undefined && !isExecutorConfiguration(record.executorConfig))
|
|
729
|
+
throw invalidProtocolFrame('Invalid executor configuration');
|
|
730
|
+
return {
|
|
731
|
+
executorId: executorIdValue(record.executorId),
|
|
732
|
+
...(record.executorConfig
|
|
733
|
+
? { executorConfig: record.executorConfig }
|
|
734
|
+
: {}),
|
|
735
|
+
};
|
|
666
736
|
}
|
|
667
737
|
function thinkingLevel(value) {
|
|
668
738
|
if (!isThinkingLevel(value))
|
|
@@ -25,11 +25,7 @@ import { defineOperation } from './operation-spec.js';
|
|
|
25
25
|
import { decodeWorkspaceProjection, decodeWorkspaceTarget, } from './workspace.js';
|
|
26
26
|
import { decodeSessionConfigurationUpdateInput, decodeSessionUpdateResult, decodeSessionCatalogItem, SESSION_CATALOG_OPERATION_SPECS, } from './session-catalog.js';
|
|
27
27
|
export function decodeWorkHubCoordinationConfigureModelInput(value) {
|
|
28
|
-
const input =
|
|
29
|
-
'expectedRevision',
|
|
30
|
-
'modelTarget',
|
|
31
|
-
'thinkingLevel',
|
|
32
|
-
]);
|
|
28
|
+
const input = requireShapedRecord(value, 'WorkHub model configuration', ['expectedRevision', 'modelTarget', 'thinkingLevel'], []);
|
|
33
29
|
const decoded = decodeSessionConfigurationUpdateInput({
|
|
34
30
|
sessionId: WORKHUB_COORDINATION_SESSION_ID,
|
|
35
31
|
expectedRevision: input.expectedRevision,
|