maka-agent 0.2.0-dev.47.20260922 → 0.2.0-dev.49.20260924
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/session-event-mapper.js +1 -4
- package/dist/onboarding-catalog.js +20 -4
- package/dist/pi-transcript.js +0 -8
- package/dist/pi-tui-pickers.js +1 -1
- package/dist/pi-tui-runner.js +6 -4
- package/dist/runtime-host-capability-provider-command.js +25 -6
- package/dist/runtime-host-onboarding.js +5 -3
- package/dist/runtime-host-session-channel.js +9 -3
- package/dist/tui-mcp-control.js +37 -24
- 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/events.js +13 -0
- package/node_modules/@maka/core/dist/executor-catalog.js +106 -0
- package/node_modules/@maka/core/dist/llm-connections.js +2 -5
- package/node_modules/@maka/core/dist/mcp.js +4 -1
- package/node_modules/@maka/core/dist/model-facts.js +2 -4
- package/node_modules/@maka/core/dist/model-metadata.generated.js +345 -248
- package/node_modules/@maka/core/dist/model-metadata.js +28 -1
- package/node_modules/@maka/core/dist/model-thinking.js +17 -17
- package/node_modules/@maka/core/dist/model-web-search.js +7 -9
- package/node_modules/@maka/core/dist/models-dev-projection.js +1 -1
- package/node_modules/@maka/core/dist/onboarding.js +1 -4
- package/node_modules/@maka/core/dist/provider-registry.js +60 -86
- package/node_modules/@maka/core/dist/runtime-event-store.js +25 -0
- package/node_modules/@maka/core/dist/runtime-event.js +2 -2
- package/node_modules/@maka/core/dist/runtime-invocation.js +5 -0
- package/node_modules/@maka/core/dist/runtime-policy/connection-catalog-codec.js +28 -16
- 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/runtime-policy.js +1 -1
- package/node_modules/@maka/core/dist/session.js +25 -9
- package/node_modules/@maka/core/dist/settings.js +1 -0
- package/node_modules/@maka/core/dist/tool-ledger-scanner.js +365 -104
- package/node_modules/@maka/core/dist/transcript-search.js +1 -0
- package/node_modules/@maka/core/dist/turn-origin.js +14 -0
- package/node_modules/@maka/core/dist/usage-stats/types.js +1 -0
- package/node_modules/@maka/core/package.json +2 -0
- package/node_modules/@maka/eval/dist/harbor-maka-subject.js +3 -0
- package/node_modules/@maka/eval/dist/maka-subject.js +8 -1
- 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-backend.js +1 -11
- package/node_modules/@maka/runtime/dist/ai-sdk-compaction.js +2 -12
- package/node_modules/@maka/runtime/dist/ai-sdk-turn.js +3 -71
- package/node_modules/@maka/runtime/dist/conversation-copy.js +58 -3
- package/node_modules/@maka/runtime/dist/local-web-fetch.js +23 -11
- package/node_modules/@maka/runtime/dist/mcp-tools.js +9 -2
- package/node_modules/@maka/runtime/dist/model-adapter.js +10 -5
- package/node_modules/@maka/runtime/dist/model-factory.js +33 -30
- package/node_modules/@maka/runtime/dist/model-fetcher.js +4 -1
- package/node_modules/@maka/runtime/dist/model-runtime.js +3 -9
- package/node_modules/@maka/runtime/dist/plugin-executor-backend.js +116 -3
- package/node_modules/@maka/runtime/dist/plugin-executor-service.js +212 -16
- package/node_modules/@maka/runtime/dist/read-page.js +11 -8
- package/node_modules/@maka/runtime/dist/recovery-resolver.js +47 -20
- package/node_modules/@maka/runtime/dist/runtime-event-backfill.js +1 -0
- package/node_modules/@maka/runtime/dist/runtime-ledger-repair.js +2 -2
- package/node_modules/@maka/runtime/dist/scheduled-task-tools.js +39 -8
- package/node_modules/@maka/runtime/dist/session-event-runtime-mapper.js +3 -0
- package/node_modules/@maka/runtime/dist/session-manager.js +182 -127
- 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/dist/telemetry/model-pricing.generated.js +141 -134
- package/node_modules/@maka/runtime/dist/tool-result-archive-transition.js +3 -3
- package/node_modules/@maka/runtime/dist/workers/filesystem-worker.js +7 -6
- package/node_modules/@maka/runtime-host/dist/adapter/session-projector.js +28 -62
- package/node_modules/@maka/runtime-host/dist/candidate-entry.js +8 -5
- package/node_modules/@maka/runtime-host/dist/client/hosted-execution-target.js +7 -1
- 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/session-catalog-summary.js +6 -1
- package/node_modules/@maka/runtime-host/dist/client/session-subscription.js +3 -0
- package/node_modules/@maka/runtime-host/dist/composition-identity.js +19 -0
- package/node_modules/@maka/runtime-host/dist/protocol/connection-effects.js +6 -3
- package/node_modules/@maka/runtime-host/dist/protocol/index.js +14 -2
- package/node_modules/@maka/runtime-host/dist/protocol/operations.js +4 -1
- package/node_modules/@maka/runtime-host/dist/protocol/plugin-platform.js +34 -0
- package/node_modules/@maka/runtime-host/dist/protocol/prompt-suggestions.js +61 -0
- package/node_modules/@maka/runtime-host/dist/protocol/runtime-policy.js +4 -1
- package/node_modules/@maka/runtime-host/dist/protocol/session-catalog.js +40 -2
- package/node_modules/@maka/runtime-host/dist/protocol/session-continuity.js +2 -1
- 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-recovery.js +44 -46
- package/node_modules/@maka/runtime-host/dist/server/connection-effect-coordinator.js +3 -0
- 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 +212 -24
- package/node_modules/@maka/runtime-host/dist/server/execution-model-authority.js +41 -2
- package/node_modules/@maka/runtime-host/dist/server/extension-bundle.js +4 -0
- package/node_modules/@maka/runtime-host/dist/server/generated-text.js +39 -0
- 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 +12 -0
- 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/prompt-suggestion.js +179 -0
- package/node_modules/@maka/runtime-host/dist/server/root-turn-coordinator.js +93 -14
- package/node_modules/@maka/runtime-host/dist/server/runtime-policy-coordinator.js +2 -0
- package/node_modules/@maka/runtime-host/dist/server/session-catalog-coordinator.js +99 -12
- package/node_modules/@maka/runtime-host/dist/server/session-continuity-coordinator.js +48 -16
- package/node_modules/@maka/runtime-host/dist/server/session-effect-coordinator.js +12 -6
- package/node_modules/@maka/runtime-host/dist/server/session-title.js +3 -16
- package/node_modules/@maka/runtime-host/dist/server/session-transcript-reader.js +71 -3
- package/node_modules/@maka/runtime-host/dist/server/shared-session-transcript.js +3 -0
- package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-action-gate.js +6 -13
- package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-coordinator.js +39 -11
- 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/config-transfer.js +14 -8
- package/node_modules/@maka/storage/dist/execution-stores.js +19 -6
- package/node_modules/@maka/storage/dist/interaction-store.js +13 -0
- 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/connection-catalog-document.js +28 -17
- package/node_modules/@maka/storage/dist/runtime-policy/coordinator.js +9 -3
- package/node_modules/@maka/storage/dist/runtime-policy/credential-vault-document.js +4 -1
- package/node_modules/@maka/storage/dist/runtime-policy/legacy-custom-connection.js +65 -0
- package/node_modules/@maka/storage/dist/runtime-policy/onboarding-transaction.js +10 -5
- package/node_modules/@maka/storage/dist/runtime-policy/policy-document.js +2 -0
- package/node_modules/@maka/storage/dist/session-bundle-policy.js +11 -0
- package/node_modules/@maka/storage/dist/session-store-values.js +16 -4
- package/node_modules/@maka/storage/dist/session-store.js +29 -6
- 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-core-execution-schema.js +3 -0
- package/node_modules/@maka/storage/dist/sqlite-runtime-schema.js +74 -1
- package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +849 -91
- package/node_modules/@maka/storage/dist/sqlite-session-metadata-store.js +21 -3
- package/node_modules/@maka/storage/dist/usage-screen.js +138 -108
- package/package.json +1 -1
|
@@ -24,7 +24,7 @@ import { projectionArtifactMedia } from './durable-tool-result-projection.js';
|
|
|
24
24
|
import { baseToolResultProjection } from './model-projection-transition-ledger.js';
|
|
25
25
|
import { ARCHIVED_TOOL_RESULT_REWRITE_VERSION, buildArchivedToolResultPlaceholder, buildLedgerArchivedToolResultPlaceholder, isArchivedToolResultPlaceholder, } from './tool-result-archive.js';
|
|
26
26
|
import { serializeToolResultProjectionV1 } from './tool-result-archive-encoding.js';
|
|
27
|
-
import {
|
|
27
|
+
import { READ_PAGE_MAX_BYTES, readToolResultPage } from './read-page.js';
|
|
28
28
|
/**
|
|
29
29
|
* What the model actually reads for one Tool Result, as bytes.
|
|
30
30
|
*
|
|
@@ -103,7 +103,7 @@ export async function archiveToolResultAsTransition(services, request) {
|
|
|
103
103
|
: {}),
|
|
104
104
|
})
|
|
105
105
|
: buildArchivedToolResultPlaceholder({ ...common, artifactId: archived.artifactId });
|
|
106
|
-
placeholder.page = readToolResultPage(request.serializedResult, { path: placeholder.resourceRef },
|
|
106
|
+
placeholder.page = readToolResultPage(request.serializedResult, { path: placeholder.resourceRef }, READ_PAGE_MAX_BYTES - utf8ByteLength(JSON.stringify(placeholder)) - 32);
|
|
107
107
|
}
|
|
108
108
|
catch {
|
|
109
109
|
return undefined;
|
|
@@ -166,7 +166,7 @@ export function collectToolResultArchiveCandidates(events, prunePolicy, charsPer
|
|
|
166
166
|
const media = projectionArtifactMedia(sourceProjection);
|
|
167
167
|
const originalEstimatedTokens = estimateTokens(serializedResult.length, charsPerToken) +
|
|
168
168
|
media.length * MATERIALIZED_IMAGE_TOKENS;
|
|
169
|
-
if (media.length > 0 ||
|
|
169
|
+
if (media.length > 0 || originalBytes <= READ_PAGE_MAX_BYTES)
|
|
170
170
|
continue;
|
|
171
171
|
candidates.push({
|
|
172
172
|
runtimeEventId: event.id,
|
|
@@ -23815,7 +23815,7 @@ function date4(params) {
|
|
|
23815
23815
|
}
|
|
23816
23816
|
|
|
23817
23817
|
// src/read-page.ts
|
|
23818
|
-
var
|
|
23818
|
+
var READ_PAGE_MAX_BYTES = 7500;
|
|
23819
23819
|
var readParameters = external_exports.object({
|
|
23820
23820
|
path: external_exports.string({
|
|
23821
23821
|
error: "path is required. Provide a file path or the Maka address returned by a tool."
|
|
@@ -23863,7 +23863,7 @@ function resolveReadInput(input2) {
|
|
|
23863
23863
|
function digestText(content) {
|
|
23864
23864
|
return createHash("sha256").update(content).digest("hex").slice(0, 32);
|
|
23865
23865
|
}
|
|
23866
|
-
function readPage(content, input2,
|
|
23866
|
+
function readPage(content, input2, maxBytes = READ_PAGE_MAX_BYTES, continuation) {
|
|
23867
23867
|
const resolved = continuation ? { path: input2.path, ...continuation } : resolveReadInput(input2);
|
|
23868
23868
|
if (resolved.digest && digestText(content) !== resolved.digest) {
|
|
23869
23869
|
throw new Error(
|
|
@@ -23918,15 +23918,16 @@ function readPage(content, input2, maxChars = READ_PAGE_MAX_CHARS, continuation)
|
|
|
23918
23918
|
next
|
|
23919
23919
|
};
|
|
23920
23920
|
};
|
|
23921
|
-
|
|
23921
|
+
const fits = (page) => Buffer.byteLength(JSON.stringify(page)) <= maxBytes;
|
|
23922
|
+
if (end - start <= maxBytes) {
|
|
23922
23923
|
const page = makePage(end);
|
|
23923
|
-
if (
|
|
23924
|
+
if (fits(page)) return page;
|
|
23924
23925
|
}
|
|
23925
23926
|
let low = start;
|
|
23926
|
-
let high = Math.min(end, start +
|
|
23927
|
+
let high = Math.min(end, start + maxBytes);
|
|
23927
23928
|
while (low < high) {
|
|
23928
23929
|
const middle = Math.ceil((low + high) / 2);
|
|
23929
|
-
if (
|
|
23930
|
+
if (fits(makePage(middle))) low = middle;
|
|
23930
23931
|
else high = middle - 1;
|
|
23931
23932
|
}
|
|
23932
23933
|
if (low > start && /[\uD800-\uDBFF]/.test(content[low - 1])) low--;
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
19
|
import { isDeepStrictEqual } from 'node:util';
|
|
20
|
+
import { foldAssistantDelta, } from '@maka/core/events';
|
|
20
21
|
export function createRuntimeHostSessionProjectionSeed(transcript, snapshot) {
|
|
21
22
|
return {
|
|
22
23
|
durableUserMessages: transcript
|
|
@@ -31,11 +32,8 @@ export class RuntimeHostSessionProjector {
|
|
|
31
32
|
#snapshot;
|
|
32
33
|
#now;
|
|
33
34
|
#durableTurnByMessage;
|
|
34
|
-
// Only live/synthesized messages for the current root belong here. Durable
|
|
35
|
-
// transcript identity stays in the admission map above, so this render
|
|
36
|
-
// ledger cannot grow with the lifetime of the session.
|
|
37
|
-
#renderedSteeringMessageIds = new Set();
|
|
38
35
|
#accumulators = new Map();
|
|
36
|
+
#placedSteeringMessageIds = new Set();
|
|
39
37
|
#projectMessageAdmissions;
|
|
40
38
|
constructor(snapshot, seed, now = Date.now, activeAssistantStreams = [], projectMessageAdmissions = false) {
|
|
41
39
|
this.#snapshot = structuredClone(snapshot);
|
|
@@ -55,7 +53,7 @@ export class RuntimeHostSessionProjector {
|
|
|
55
53
|
messageId: message.id,
|
|
56
54
|
text: message.thinking.text,
|
|
57
55
|
complete: true,
|
|
58
|
-
|
|
56
|
+
replaced: false,
|
|
59
57
|
});
|
|
60
58
|
}
|
|
61
59
|
if (message.text || message.interrupted) {
|
|
@@ -66,7 +64,7 @@ export class RuntimeHostSessionProjector {
|
|
|
66
64
|
text: message.text,
|
|
67
65
|
...(message.interrupted ? { interrupted: true } : {}),
|
|
68
66
|
complete: true,
|
|
69
|
-
|
|
67
|
+
replaced: false,
|
|
70
68
|
});
|
|
71
69
|
}
|
|
72
70
|
}
|
|
@@ -81,7 +79,7 @@ export class RuntimeHostSessionProjector {
|
|
|
81
79
|
messageId: stream.messageId,
|
|
82
80
|
text: current?.text ?? '',
|
|
83
81
|
complete: false,
|
|
84
|
-
|
|
82
|
+
replaced: false,
|
|
85
83
|
});
|
|
86
84
|
}
|
|
87
85
|
}
|
|
@@ -97,7 +95,7 @@ export class RuntimeHostSessionProjector {
|
|
|
97
95
|
return [];
|
|
98
96
|
const events = [];
|
|
99
97
|
const queueEvents = this.#projectMessageAdmissions || queueHasEntries(this.#snapshot.queue)
|
|
100
|
-
? [projectQueueUpdate(this.#snapshot.queue, root.turnId, this.#now())]
|
|
98
|
+
? [projectQueueUpdate(this.#unplacedQueue(this.#snapshot.queue), root.turnId, this.#now())]
|
|
101
99
|
: [];
|
|
102
100
|
if (this.#projectMessageAdmissions) {
|
|
103
101
|
events.push(...projectMessageAdmissionEvents(root, [...this.#durableTurnByMessage]
|
|
@@ -134,20 +132,6 @@ export class RuntimeHostSessionProjector {
|
|
|
134
132
|
for (const interaction of this.#snapshot.interactions.pending) {
|
|
135
133
|
events.push(...projectRuntimeHostInteractionRequest(interaction, this.#now()));
|
|
136
134
|
}
|
|
137
|
-
for (const entry of rootQueueInFlight(this.#snapshot.queue)) {
|
|
138
|
-
if (this.#durableTurnByMessage.has(entry.messageId) ||
|
|
139
|
-
this.#renderedSteeringMessageIds.has(entry.messageId))
|
|
140
|
-
continue;
|
|
141
|
-
this.#renderedSteeringMessageIds.add(entry.messageId);
|
|
142
|
-
events.push({
|
|
143
|
-
type: 'steering_message',
|
|
144
|
-
id: `host-queue:${this.#snapshot.queue.hostEpoch}:${this.#snapshot.queue.queueRevision}:${entry.entryId}`,
|
|
145
|
-
turnId: root.turnId,
|
|
146
|
-
messageId: entry.messageId,
|
|
147
|
-
ts: this.#now(),
|
|
148
|
-
content: structuredClone(entry.content),
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
135
|
return [...events, ...queueEvents];
|
|
152
136
|
}
|
|
153
137
|
noteDurableTranscriptMessages(messages) {
|
|
@@ -286,7 +270,7 @@ export class RuntimeHostSessionProjector {
|
|
|
286
270
|
const key = accumulatorKey(delta.kind, delta.messageId);
|
|
287
271
|
const current = this.#accumulators.get(key);
|
|
288
272
|
const folded = foldRuntimeHostAssistantDelta(delta.reset ? '' : (current?.text ?? ''), delta);
|
|
289
|
-
const
|
|
273
|
+
const replaced = delta.reset === true || (current?.replaced ?? false);
|
|
290
274
|
this.#accumulators.set(key, {
|
|
291
275
|
kind: delta.kind,
|
|
292
276
|
turnId: delta.turnId,
|
|
@@ -294,7 +278,7 @@ export class RuntimeHostSessionProjector {
|
|
|
294
278
|
text: folded.text,
|
|
295
279
|
...(delta.interrupted ? { interrupted: true } : {}),
|
|
296
280
|
complete: delta.complete === true,
|
|
297
|
-
|
|
281
|
+
replaced,
|
|
298
282
|
});
|
|
299
283
|
if (delta.complete === true) {
|
|
300
284
|
events.push({
|
|
@@ -307,7 +291,7 @@ export class RuntimeHostSessionProjector {
|
|
|
307
291
|
...(delta.interrupted ? { interrupted: true } : {}),
|
|
308
292
|
});
|
|
309
293
|
}
|
|
310
|
-
else if (folded.tail && !
|
|
294
|
+
else if (folded.tail && !replaced) {
|
|
311
295
|
events.push({
|
|
312
296
|
type: delta.kind === 'text' ? 'text_delta' : 'thinking_delta',
|
|
313
297
|
id: frameIdentity(frame),
|
|
@@ -323,11 +307,13 @@ export class RuntimeHostSessionProjector {
|
|
|
323
307
|
if (frame.kind === 'subscription.session_event') {
|
|
324
308
|
const event = projectSessionEvent(frame);
|
|
325
309
|
if (event.type === 'steering_message') {
|
|
326
|
-
if (this.#durableTurnByMessage.has(event.messageId)
|
|
327
|
-
this.#renderedSteeringMessageIds.has(event.messageId)) {
|
|
310
|
+
if (this.#durableTurnByMessage.has(event.messageId))
|
|
328
311
|
return emptyUpdate(events);
|
|
312
|
+
this.#placedSteeringMessageIds.add(event.messageId);
|
|
313
|
+
const { queue, rootTurn } = this.#snapshot;
|
|
314
|
+
if (rootTurn && queue.steering.some((entry) => entry.messageId === event.messageId)) {
|
|
315
|
+
events.push(projectQueueUpdate(this.#unplacedQueue(queue), rootTurn.turnId, this.#now()));
|
|
329
316
|
}
|
|
330
|
-
this.#renderedSteeringMessageIds.add(event.messageId);
|
|
331
317
|
}
|
|
332
318
|
events.push(event);
|
|
333
319
|
return emptyUpdate(events);
|
|
@@ -341,30 +327,11 @@ export class RuntimeHostSessionProjector {
|
|
|
341
327
|
const previousRoot = previousSnapshot.rootTurn;
|
|
342
328
|
const root = next.rootTurn;
|
|
343
329
|
const startedTurn = root && (!previousRoot || root.runId !== previousRoot.runId) ? root : undefined;
|
|
344
|
-
if (startedTurn)
|
|
345
|
-
this.#renderedSteeringMessageIds.clear();
|
|
346
330
|
for (const interaction of newlyPendingInteractions(previousSnapshot, next)) {
|
|
347
331
|
events.push(...projectRuntimeHostInteractionRequest(interaction, this.#now()));
|
|
348
332
|
}
|
|
349
|
-
const enteredActiveTurn = root && queueChanged(previousSnapshot.queue, next.queue)
|
|
350
|
-
? newlyInFlight(previousSnapshot.queue, next.queue)
|
|
351
|
-
: [];
|
|
352
333
|
if (root && queueChanged(previousSnapshot.queue, next.queue)) {
|
|
353
|
-
|
|
354
|
-
if (this.#durableTurnByMessage.has(entry.messageId) ||
|
|
355
|
-
this.#renderedSteeringMessageIds.has(entry.messageId))
|
|
356
|
-
continue;
|
|
357
|
-
this.#renderedSteeringMessageIds.add(entry.messageId);
|
|
358
|
-
events.push({
|
|
359
|
-
type: 'steering_message',
|
|
360
|
-
id: `host-queue:${next.queue.hostEpoch}:${next.queue.queueRevision}:${entry.entryId}`,
|
|
361
|
-
turnId: root.turnId,
|
|
362
|
-
messageId: entry.messageId,
|
|
363
|
-
ts: this.#now(),
|
|
364
|
-
content: structuredClone(entry.content),
|
|
365
|
-
});
|
|
366
|
-
}
|
|
367
|
-
events.push(projectQueueUpdate(next.queue, root.turnId, this.#now()));
|
|
334
|
+
events.push(projectQueueUpdate(this.#unplacedQueue(next.queue), root.turnId, this.#now()));
|
|
368
335
|
}
|
|
369
336
|
if (startedTurn)
|
|
370
337
|
this.#accumulators.clear();
|
|
@@ -449,6 +416,13 @@ export class RuntimeHostSessionProjector {
|
|
|
449
416
|
}
|
|
450
417
|
return events;
|
|
451
418
|
}
|
|
419
|
+
// The runtime writes a steering message before the Host acknowledges its
|
|
420
|
+
// lease, so the queue can still list an entry the timeline already shows.
|
|
421
|
+
#unplacedQueue(queue) {
|
|
422
|
+
const steering = queue.steering.filter((entry) => !this.#placedSteeringMessageIds.has(entry.messageId) &&
|
|
423
|
+
!this.#durableTurnByMessage.has(entry.messageId));
|
|
424
|
+
return steering.length === queue.steering.length ? queue : { ...queue, steering };
|
|
425
|
+
}
|
|
452
426
|
}
|
|
453
427
|
function emptyUpdate(events) {
|
|
454
428
|
return { events, resolvedInteractions: [] };
|
|
@@ -608,16 +582,15 @@ function projectSessionEvent(frame) {
|
|
|
608
582
|
};
|
|
609
583
|
}
|
|
610
584
|
export function foldRuntimeHostAssistantDelta(current, delta) {
|
|
611
|
-
|
|
585
|
+
const folded = foldAssistantDelta(current.length, delta);
|
|
586
|
+
if (!folded)
|
|
612
587
|
throw new Error('Runtime Host assistant delta has a gap');
|
|
613
|
-
const
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
delta.text.slice(0, overlapLength)) {
|
|
588
|
+
const startOffset = delta.startOffset ?? current.length;
|
|
589
|
+
const overlap = delta.text.slice(0, delta.text.length - folded.tail.length);
|
|
590
|
+
if (current.slice(startOffset, startOffset + overlap.length) !== overlap) {
|
|
617
591
|
throw new Error('Runtime Host assistant delta conflicts with prior output');
|
|
618
592
|
}
|
|
619
|
-
|
|
620
|
-
return { text: current + tail, tail };
|
|
593
|
+
return { text: current + folded.tail, tail: folded.tail };
|
|
621
594
|
}
|
|
622
595
|
function newlyPendingInteractions(previous, next) {
|
|
623
596
|
const previousIds = new Set(previous.interactions.pending.map((interaction) => interaction.interactionId));
|
|
@@ -630,13 +603,6 @@ function removedPendingInteractions(previous, next) {
|
|
|
630
603
|
function queueChanged(previous, next) {
|
|
631
604
|
return previous.hostEpoch !== next.hostEpoch || previous.queueRevision !== next.queueRevision;
|
|
632
605
|
}
|
|
633
|
-
function newlyInFlight(previous, next) {
|
|
634
|
-
const previousIds = new Set(rootQueueInFlight(previous).map((entry) => entry.entryId));
|
|
635
|
-
return rootQueueInFlight(next).filter((entry) => !previousIds.has(entry.entryId));
|
|
636
|
-
}
|
|
637
|
-
function rootQueueInFlight(queue) {
|
|
638
|
-
return queue.steering.filter((entry) => entry.state === 'in_flight');
|
|
639
|
-
}
|
|
640
606
|
function queueHasEntries(queue) {
|
|
641
607
|
return queue.steering.length > 0 || queue.followup.length > 0;
|
|
642
608
|
}
|
|
@@ -21,7 +21,6 @@ import { fileURLToPath } from 'node:url';
|
|
|
21
21
|
import { candidateStartupFailureExitCode, classifyCandidateStartupFailure, } from './candidate-startup-failure.js';
|
|
22
22
|
import { createRuntimeHostLaunchOwnerGuard } from './candidate-launch-owner-guard.js';
|
|
23
23
|
import { parseInteractiveRuntimeHostCandidateArguments } from './candidate-cli.js';
|
|
24
|
-
import { writeCandidateStartupDiagnostic } from './control/startup-diagnostic.js';
|
|
25
24
|
import { installRuntimeHostLogCapture, runtimeHostLogBuffer } from './process-diagnostics.js';
|
|
26
25
|
import { startExecutionRuntimeHostCandidate, } from './server/execution-candidate.js';
|
|
27
26
|
import { runRuntimeHostProcessLifecycle } from './server/process-lifecycle.js';
|
|
@@ -60,13 +59,17 @@ export async function runExecutionCandidateEntry(argv, entrypointUrl, hooks = {}
|
|
|
60
59
|
const logs = runtimeHostLogBuffer.snapshot();
|
|
61
60
|
console.error('[runtime-host] startup failed:', error);
|
|
62
61
|
if (rootId && startupAttemptId) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
const diagnosticRootId = rootId;
|
|
63
|
+
const diagnosticStartupAttemptId = startupAttemptId;
|
|
64
|
+
await import('./control/startup-diagnostic.js')
|
|
65
|
+
.then(({ writeCandidateStartupDiagnostic }) => writeCandidateStartupDiagnostic({
|
|
66
|
+
rootId: diagnosticRootId,
|
|
67
|
+
startupAttemptId: diagnosticStartupAttemptId,
|
|
66
68
|
failure,
|
|
67
69
|
error,
|
|
68
70
|
logs,
|
|
69
|
-
})
|
|
71
|
+
}))
|
|
72
|
+
.catch(() => undefined);
|
|
70
73
|
}
|
|
71
74
|
process.exit(candidateStartupFailureExitCode(failure));
|
|
72
75
|
}
|
|
@@ -23,7 +23,10 @@ export async function configureHostedExecutionTarget(connection, input, signal)
|
|
|
23
23
|
const before = await abortable(() => readRuntimeHostConnectionCatalog(connection), signal);
|
|
24
24
|
const target = before.connections.find((candidate) => candidate.slug === input.connectionSlug);
|
|
25
25
|
const onboarding = input.connection;
|
|
26
|
-
if (onboarding &&
|
|
26
|
+
if (onboarding &&
|
|
27
|
+
target &&
|
|
28
|
+
(target.providerType !== onboarding.providerType ||
|
|
29
|
+
target.defaultApiProtocol !== onboarding.defaultApiProtocol)) {
|
|
27
30
|
throw new Error('Runtime Host connection provider does not match');
|
|
28
31
|
}
|
|
29
32
|
if (onboarding) {
|
|
@@ -32,6 +35,9 @@ export async function configureHostedExecutionTarget(connection, input, signal)
|
|
|
32
35
|
: {
|
|
33
36
|
kind: 'create',
|
|
34
37
|
providerType: onboarding.providerType,
|
|
38
|
+
...(onboarding.defaultApiProtocol === undefined
|
|
39
|
+
? {}
|
|
40
|
+
: { defaultApiProtocol: onboarding.defaultApiProtocol }),
|
|
35
41
|
slug: input.connectionSlug,
|
|
36
42
|
name: input.connectionSlug,
|
|
37
43
|
};
|
|
@@ -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
|
}
|
|
@@ -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,
|
|
@@ -32,6 +32,9 @@ export class SessionRemovedSubscriptionError extends Error {
|
|
|
32
32
|
name = 'SessionRemovedSubscriptionError';
|
|
33
33
|
}
|
|
34
34
|
export function subscriptionClosedError(reason) {
|
|
35
|
+
if (reason === 'transcript_changed') {
|
|
36
|
+
return new RuntimeHostSubscriptionError('transcript_changed', 'Settled choice history requires a fresh transcript');
|
|
37
|
+
}
|
|
35
38
|
if (reason === 'session_removed') {
|
|
36
39
|
return new SessionRemovedSubscriptionError('Runtime Host Session was removed while it was observed');
|
|
37
40
|
}
|
|
@@ -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';
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* specific language governing permissions and limitations
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
|
-
import { CONNECTION_CATALOG_MAX_MODELS_PER_CONNECTION, decodeConnectionModelId, decodeConnectionModel, decodeConnectionName, decodeConnectionSlug, decodeProviderType, decodeConnectionTestSummary, decodeConnectionVersionBasis, RuntimePolicyDomainDecodeError, } from '@maka/core/runtime-policy';
|
|
19
|
+
import { CONNECTION_CATALOG_MAX_MODELS_PER_CONNECTION, decodeConnectionModelId, decodeConnectionModel, decodeConnectionName, decodeConnectionSlug, decodeDefaultApiProtocol, decodeProviderType, decodeConnectionTestSummary, decodeConnectionVersionBasis, RuntimePolicyDomainDecodeError, } from '@maka/core/runtime-policy';
|
|
20
20
|
import { requireCount, requireEntityId, requireExactRecord, requireRecord, requireShapedRecord, requireString, requireUtf8String, } from './codec.js';
|
|
21
21
|
import { invalidProtocolFrame } from './errors.js';
|
|
22
22
|
import { defineOperation } from './operation-spec.js';
|
|
@@ -167,10 +167,13 @@ function decodeConnectionOnboardingTarget(value) {
|
|
|
167
167
|
// slug/name are optional so a surface that accepts the derived identity
|
|
168
168
|
// can keep talking to any Host vintage; a surface that lets the user name
|
|
169
169
|
// the connection must tolerate an older Host rejecting the extra fields.
|
|
170
|
-
const exact = requireShapedRecord(target, 'create connection onboarding target', ['kind', 'providerType'], ['slug', 'name']);
|
|
170
|
+
const exact = requireShapedRecord(target, 'create connection onboarding target', ['kind', 'providerType'], ['slug', 'name', 'defaultApiProtocol']);
|
|
171
|
+
const providerType = decodeDomain(() => decodeProviderType(exact.providerType));
|
|
172
|
+
const defaultApiProtocol = decodeDomain(() => decodeDefaultApiProtocol(exact.defaultApiProtocol, providerType));
|
|
171
173
|
return {
|
|
172
174
|
kind: 'create',
|
|
173
|
-
providerType
|
|
175
|
+
providerType,
|
|
176
|
+
...(defaultApiProtocol === undefined ? {} : { defaultApiProtocol }),
|
|
174
177
|
...(exact.slug === undefined
|
|
175
178
|
? {}
|
|
176
179
|
: { slug: decodeDomain(() => decodeConnectionSlug(exact.slug)) }),
|
|
@@ -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,23 @@ 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 = 187;
|
|
68
|
+
// 187: transcript_changed closes a subscription for automatic bounded-tail reseeding.
|
|
69
|
+
// 186: Settled form/question history adds form_interaction transcript messages.
|
|
70
|
+
// 185: Add the bounded next-prompt suggestion operation.
|
|
71
|
+
// 184: the unified `custom` provider type and its defaultApiProtocol require matching peers.
|
|
72
|
+
// 183: Jev policy snapshots, set_jev mutation and credential locator require matching peers.
|
|
73
|
+
// 182: Executor catalogs expose structured model families and thinking variant IDs.
|
|
74
|
+
// 181: Canonical executor models and retained provider stop reasons after cancellation.
|
|
75
|
+
// 180: Reject contradictory executor configuration and legacy model targets.
|
|
76
|
+
// 179: Generic executor discovery and confirmed per-Session configuration.
|
|
77
|
+
// 178: WorkHub result turns carry a Host-owned workhub_result origin. Older
|
|
78
|
+
// Clients reject that origin and cannot render the result notification.
|
|
66
79
|
// 177: External Session import input may carry an optional Host-resolved
|
|
67
80
|
// workspace target. Epoch-176 peers reject the unknown `workspace` key.
|
|
68
81
|
// 176: Session-scoped capability publication and MCP admission require compatible
|
|
@@ -415,7 +428,6 @@ export const RUNTIME_HOST_COMPATIBILITY_EPOCH = 177;
|
|
|
415
428
|
// one transport message; narrower domains retain their own encoded limits.
|
|
416
429
|
export const RUNTIME_HOST_MAX_MESSAGE_BYTES = 768 * 1024;
|
|
417
430
|
export const RUNTIME_HOST_MAX_IN_FLIGHT_DOMAIN_REQUESTS = 64;
|
|
418
|
-
export const INTERACTIVE_RUNTIME_HOST_COMPOSITION_ID = 'maka.interactive';
|
|
419
431
|
export function negotiateProtocol(client, host) {
|
|
420
432
|
validateProtocolRange(client);
|
|
421
433
|
validateProtocolRange(host);
|
|
@@ -55,6 +55,7 @@ import { SESSION_COLLABORATION_OPERATION_SPECS } from './session-collaboration.j
|
|
|
55
55
|
import { SESSION_REVISION_OPERATION_SPECS } from './session-revision.js';
|
|
56
56
|
import { SESSION_BUNDLE_OPERATION_SPECS } from './session-bundle.js';
|
|
57
57
|
import { SESSION_RETIREMENT_OPERATION_SPECS } from './session-retirement.js';
|
|
58
|
+
import { PROMPT_SUGGESTION_OPERATION_SPECS } from './prompt-suggestions.js';
|
|
58
59
|
import { SESSION_EFFECT_OPERATION_SPECS } from './session-effects.js';
|
|
59
60
|
import { SKILL_CATALOG_OPERATION_SPECS } from './skill-catalog.js';
|
|
60
61
|
import { TURN_OPERATION_SPECS } from './turn.js';
|
|
@@ -93,12 +94,13 @@ export * from './session-transcript.js';
|
|
|
93
94
|
export * from './session-turns.js';
|
|
94
95
|
export * from './session-todo.js';
|
|
95
96
|
export * from './session-effects.js';
|
|
97
|
+
export * from './prompt-suggestions.js';
|
|
96
98
|
export * from './skill-catalog.js';
|
|
97
99
|
export * from './usage-pricing.js';
|
|
98
100
|
export * from './web-search.js';
|
|
99
101
|
export * from './recall.js';
|
|
100
102
|
export * from './workspace.js';
|
|
101
|
-
export const HOST_OPERATION_SPECS = composeOperationSpecMaps(HOST_BOOTSTRAP_OPERATION_SPECS, HOST_RESOURCE_OPERATION_SPECS, PEER_MESH_OPERATION_SPECS, HOSTED_EXECUTION_OPERATION_SPECS, ACCESS_AUTHORITY_OPERATION_SPECS, SESSION_COLLABORATION_OPERATION_SPECS, AGENT_GRAPH_OPERATION_SPECS, GOAL_OPERATION_SPECS, TURN_OPERATION_SPECS, CONTEXT_OPERATION_SPECS, CONNECTION_EFFECT_OPERATION_SPECS, DAILY_REVIEW_OPERATION_SPECS, EXECUTION_INSPECT_OPERATION_SPECS, EXTERNAL_SESSION_OPERATION_SPECS, RUNTIME_POLICY_OPERATION_SPECS, RUNTIME_RESOURCE_OPERATION_SPECS, SCHEDULED_TASK_OPERATION_SPECS, PLAN_OPERATION_SPECS, PROJECT_CATALOG_OPERATION_SPECS, MESSAGE_OPERATION_SPECS, SESSION_TODO_OPERATION_SPECS, INTERACTION_OPERATION_SPECS, SESSION_CONTINUITY_OPERATION_SPECS, SESSION_TRANSCRIPT_OPERATION_SPECS, SESSION_TURNS_OPERATION_SPECS, SESSION_CATALOG_OPERATION_SPECS, SESSION_EFFECT_OPERATION_SPECS, SESSION_REVISION_OPERATION_SPECS, SESSION_BUNDLE_OPERATION_SPECS, SESSION_RETIREMENT_OPERATION_SPECS, ARTIFACT_OPERATION_SPECS, SKILL_CATALOG_OPERATION_SPECS, USAGE_PRICING_OPERATION_SPECS, MEMORY_OPERATION_SPECS, OAUTH_OPERATION_SPECS, EXTERNAL_AGENT_SETUP_OPERATION_SPECS, CLIENT_CAPABILITY_OPERATION_SPECS, WEB_SEARCH_OPERATION_SPECS, NETWORK_PROXY_OPERATION_SPECS, RECALL_OPERATION_SPECS, CONFIGURATION_OPERATION_SPECS, WORKHUB_COORDINATION_OPERATION_SPECS, PLUGIN_PLATFORM_OPERATION_SPECS);
|
|
103
|
+
export const HOST_OPERATION_SPECS = composeOperationSpecMaps(HOST_BOOTSTRAP_OPERATION_SPECS, HOST_RESOURCE_OPERATION_SPECS, PEER_MESH_OPERATION_SPECS, HOSTED_EXECUTION_OPERATION_SPECS, ACCESS_AUTHORITY_OPERATION_SPECS, SESSION_COLLABORATION_OPERATION_SPECS, AGENT_GRAPH_OPERATION_SPECS, GOAL_OPERATION_SPECS, TURN_OPERATION_SPECS, CONTEXT_OPERATION_SPECS, CONNECTION_EFFECT_OPERATION_SPECS, DAILY_REVIEW_OPERATION_SPECS, EXECUTION_INSPECT_OPERATION_SPECS, EXTERNAL_SESSION_OPERATION_SPECS, RUNTIME_POLICY_OPERATION_SPECS, RUNTIME_RESOURCE_OPERATION_SPECS, SCHEDULED_TASK_OPERATION_SPECS, PLAN_OPERATION_SPECS, PROJECT_CATALOG_OPERATION_SPECS, MESSAGE_OPERATION_SPECS, SESSION_TODO_OPERATION_SPECS, INTERACTION_OPERATION_SPECS, SESSION_CONTINUITY_OPERATION_SPECS, SESSION_TRANSCRIPT_OPERATION_SPECS, SESSION_TURNS_OPERATION_SPECS, SESSION_CATALOG_OPERATION_SPECS, SESSION_EFFECT_OPERATION_SPECS, PROMPT_SUGGESTION_OPERATION_SPECS, SESSION_REVISION_OPERATION_SPECS, SESSION_BUNDLE_OPERATION_SPECS, SESSION_RETIREMENT_OPERATION_SPECS, ARTIFACT_OPERATION_SPECS, SKILL_CATALOG_OPERATION_SPECS, USAGE_PRICING_OPERATION_SPECS, MEMORY_OPERATION_SPECS, OAUTH_OPERATION_SPECS, EXTERNAL_AGENT_SETUP_OPERATION_SPECS, CLIENT_CAPABILITY_OPERATION_SPECS, WEB_SEARCH_OPERATION_SPECS, NETWORK_PROXY_OPERATION_SPECS, RECALL_OPERATION_SPECS, CONFIGURATION_OPERATION_SPECS, WORKHUB_COORDINATION_OPERATION_SPECS, PLUGIN_PLATFORM_OPERATION_SPECS);
|
|
102
104
|
// Remote credentials are fail-closed: adding a protocol operation does not
|
|
103
105
|
// grant it to remote owners until this policy is deliberately updated.
|
|
104
106
|
export const REMOTE_OWNER_OPERATION_GRANTS = Object.freeze([
|
|
@@ -194,6 +196,7 @@ export const REMOTE_OWNER_OPERATION_GRANTS = Object.freeze([
|
|
|
194
196
|
'session.lifecycle.set',
|
|
195
197
|
'session.shared.query',
|
|
196
198
|
'session.metadata.update',
|
|
199
|
+
'session.prompt-suggestion.generate',
|
|
197
200
|
'session.read_marker.set',
|
|
198
201
|
'session.recap.generate',
|
|
199
202
|
'session.remove',
|
|
@@ -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',
|
|
@@ -0,0 +1,61 @@
|
|
|
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 { requireEntityId, requireExactRecord, requireUtf8String } from './codec.js';
|
|
20
|
+
import { invalidProtocolFrame } from './errors.js';
|
|
21
|
+
import { defineOperation } from './operation-spec.js';
|
|
22
|
+
export const PROMPT_SUGGESTION_OPERATION_SPECS = {
|
|
23
|
+
'session.prompt-suggestion.generate': defineOperation({
|
|
24
|
+
mode: 'command',
|
|
25
|
+
availability: 'ready',
|
|
26
|
+
errors: [
|
|
27
|
+
'host_not_ready',
|
|
28
|
+
'host_draining',
|
|
29
|
+
'operation_unavailable',
|
|
30
|
+
'not_found',
|
|
31
|
+
'internal_failure',
|
|
32
|
+
],
|
|
33
|
+
decodeInput: (value) => {
|
|
34
|
+
const input = requireExactRecord(value, 'Prompt suggestion input', ['sessionId']);
|
|
35
|
+
return { sessionId: requireEntityId(input.sessionId, 'sessionId') };
|
|
36
|
+
},
|
|
37
|
+
decodeOutput: (value) => {
|
|
38
|
+
if (typeof value === 'object' && value !== null && 'kind' in value && value.kind === 'none') {
|
|
39
|
+
requireExactRecord(value, 'Empty prompt suggestion', ['kind']);
|
|
40
|
+
return { kind: 'none' };
|
|
41
|
+
}
|
|
42
|
+
const result = requireExactRecord(value, 'Prompt suggestion', [
|
|
43
|
+
'kind',
|
|
44
|
+
'turnId',
|
|
45
|
+
'terminalEventId',
|
|
46
|
+
'text',
|
|
47
|
+
]);
|
|
48
|
+
if (result.kind !== 'generated')
|
|
49
|
+
throw invalidProtocolFrame('Invalid prompt suggestion kind');
|
|
50
|
+
const text = requireUtf8String(result.text, 'Suggestion text', 512);
|
|
51
|
+
if (!text.trim() || /[\r\n]/u.test(text))
|
|
52
|
+
throw invalidProtocolFrame('Invalid suggestion text');
|
|
53
|
+
return {
|
|
54
|
+
kind: 'generated',
|
|
55
|
+
turnId: requireEntityId(result.turnId, 'turnId'),
|
|
56
|
+
terminalEventId: requireEntityId(result.terminalEventId, 'terminalEventId'),
|
|
57
|
+
text,
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
}),
|
|
61
|
+
};
|