maka-agent 0.2.0-dev.48.20260923 → 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-onboarding.js +5 -3
- package/dist/runtime-host-session-channel.js +9 -3
- package/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
- package/node_modules/@maka/core/dist/events.js +13 -0
- package/node_modules/@maka/core/dist/llm-connections.js +2 -5
- 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-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.js +2 -2
- package/node_modules/@maka/core/dist/runtime-policy/connection-catalog-codec.js +28 -16
- package/node_modules/@maka/core/dist/runtime-policy.js +1 -1
- package/node_modules/@maka/core/dist/session.js +23 -9
- package/node_modules/@maka/core/dist/transcript-search.js +1 -0
- package/node_modules/@maka/core/dist/usage-stats/types.js +1 -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/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 +2 -2
- package/node_modules/@maka/runtime/dist/local-web-fetch.js +23 -11
- 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/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/scheduled-task-tools.js +39 -8
- package/node_modules/@maka/runtime/dist/session-manager.js +12 -2
- 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/client/hosted-execution-target.js +7 -1
- package/node_modules/@maka/runtime-host/dist/client/session-subscription.js +3 -0
- package/node_modules/@maka/runtime-host/dist/protocol/connection-effects.js +6 -3
- package/node_modules/@maka/runtime-host/dist/protocol/index.js +5 -1
- package/node_modules/@maka/runtime-host/dist/protocol/operations.js +4 -1
- 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-continuity.js +2 -1
- package/node_modules/@maka/runtime-host/dist/server/connection-effect-coordinator.js +3 -0
- package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +54 -6
- package/node_modules/@maka/runtime-host/dist/server/execution-model-authority.js +38 -2
- package/node_modules/@maka/runtime-host/dist/server/generated-text.js +39 -0
- package/node_modules/@maka/runtime-host/dist/server/hosted-execution-tool-profile.js +8 -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 +2 -2
- package/node_modules/@maka/runtime-host/dist/server/session-continuity-coordinator.js +48 -16
- 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 +38 -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 +35 -11
- package/node_modules/@maka/storage/dist/config-transfer.js +14 -8
- package/node_modules/@maka/storage/dist/execution-stores.js +4 -3
- package/node_modules/@maka/storage/dist/interaction-store.js +13 -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/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/session-bundle-policy.js +11 -0
- package/node_modules/@maka/storage/dist/session-store.js +29 -6
- package/node_modules/@maka/storage/dist/sqlite-core-execution-schema.js +3 -0
- package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +125 -7
- package/node_modules/@maka/storage/dist/sqlite-session-metadata-store.js +5 -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
|
}
|
|
@@ -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
|
};
|
|
@@ -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
|
}
|
|
@@ -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)) }),
|
|
@@ -64,7 +64,11 @@ export const RUNTIME_HOST_REGISTRATION_SCHEMA_VERSION = 1;
|
|
|
64
64
|
export const RUNTIME_HOST_PROTOCOL_VERSION = 0;
|
|
65
65
|
// Increment when the same protocol version no longer guarantees safe Client-Host
|
|
66
66
|
// interoperability. Mismatches are rejected before domain commands are admitted.
|
|
67
|
-
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.
|
|
68
72
|
// 183: Jev policy snapshots, set_jev mutation and credential locator require matching peers.
|
|
69
73
|
// 182: Executor catalogs expose structured model families and thinking variant IDs.
|
|
70
74
|
// 181: Canonical executor models and retained provider stop reasons after cancellation.
|
|
@@ -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',
|
|
@@ -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
|
+
};
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* specific language governing permissions and limitations
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
|
-
import { CONNECTION_CATALOG_MAX_CONNECTIONS, CONNECTION_CATALOG_MAX_ENABLED_MODEL_IDS, CONNECTION_CATALOG_MAX_ENTRIES_PER_CONNECTION, CONNECTION_CATALOG_MAX_MODELS_PER_CONNECTION, decodeCanonicalConnectionBaseUrl, decodeModelCatalogEntry, decodeCanonicalRuntimePolicy, decodeConnectionModel, decodeConnectionModelId, decodeConnectionName, decodeConnectionSlug, decodeConnectionTarget, decodeConnectionTestSummary, decodeConnectionVersionBasis, decodeRuntimePolicyEntityId, decodeCredentialLocator, decodeCredentialStatus, decodeCredentialVersionBasis, decodeProviderType, normalizeCreateCatalogConnectionInput, normalizeDeleteCredentialInput, normalizeRemoveCatalogConnectionInput, normalizeOptionalRequestBodyOverlay, normalizeNetworkProxyUpdate, normalizeNetworkProxyCredentialTarget, normalizeRequestHeaderUpdates, normalizeRuntimePolicyMutation, normalizeSetCredentialInput, normalizeSetDefaultConnectionTargetInput, normalizeUpdateCatalogConnectionInput, REQUEST_HEADERS_MAX_BYTES, RequestCustomizationValidationError, RuntimePolicyDomainDecodeError, } from '@maka/core/runtime-policy';
|
|
19
|
+
import { CONNECTION_CATALOG_MAX_CONNECTIONS, CONNECTION_CATALOG_MAX_ENABLED_MODEL_IDS, CONNECTION_CATALOG_MAX_ENTRIES_PER_CONNECTION, CONNECTION_CATALOG_MAX_MODELS_PER_CONNECTION, decodeCanonicalConnectionBaseUrl, decodeModelCatalogEntry, decodeCanonicalRuntimePolicy, decodeConnectionModel, decodeConnectionModelId, decodeConnectionName, decodeConnectionSlug, decodeConnectionTarget, decodeConnectionTestSummary, decodeConnectionVersionBasis, decodeRuntimePolicyEntityId, decodeCredentialLocator, decodeCredentialStatus, decodeCredentialVersionBasis, decodeDefaultApiProtocol, decodeProviderType, normalizeCreateCatalogConnectionInput, normalizeDeleteCredentialInput, normalizeRemoveCatalogConnectionInput, normalizeOptionalRequestBodyOverlay, normalizeNetworkProxyUpdate, normalizeNetworkProxyCredentialTarget, normalizeRequestHeaderUpdates, normalizeRuntimePolicyMutation, normalizeSetCredentialInput, normalizeSetDefaultConnectionTargetInput, normalizeUpdateCatalogConnectionInput, REQUEST_HEADERS_MAX_BYTES, RequestCustomizationValidationError, RuntimePolicyDomainDecodeError, } from '@maka/core/runtime-policy';
|
|
20
20
|
import { normalizeModelOverrides } from '@maka/core/model-thinking';
|
|
21
21
|
import { requireExactRecord, requireShapedRecord, requireRecord } from './codec.js';
|
|
22
22
|
import { invalidProtocolFrame } from './errors.js';
|
|
@@ -359,6 +359,7 @@ function catalogPageItem(value) {
|
|
|
359
359
|
'name',
|
|
360
360
|
'providerType',
|
|
361
361
|
'baseUrl',
|
|
362
|
+
'defaultApiProtocol',
|
|
362
363
|
'enabled',
|
|
363
364
|
'modelSource',
|
|
364
365
|
'lastTest',
|
|
@@ -383,6 +384,7 @@ function catalogPageItem(value) {
|
|
|
383
384
|
const baseUrl = header.baseUrl === undefined
|
|
384
385
|
? undefined
|
|
385
386
|
: decodeDomain(() => decodeCanonicalConnectionBaseUrl(header.baseUrl, provider));
|
|
387
|
+
const defaultApiProtocol = decodeDomain(() => decodeDefaultApiProtocol(header.defaultApiProtocol, provider));
|
|
386
388
|
const modelCount = integer(header.modelCount, 'model count', 0, CONNECTION_CATALOG_MAX_MODELS_PER_CONNECTION);
|
|
387
389
|
if (header.modelSource === undefined && modelCount !== 0) {
|
|
388
390
|
throw invalidProtocolFrame('Invalid connection header model count');
|
|
@@ -403,6 +405,7 @@ function catalogPageItem(value) {
|
|
|
403
405
|
name: decodeDomain(() => decodeConnectionName(header.name)),
|
|
404
406
|
providerType: provider,
|
|
405
407
|
...(baseUrl === undefined ? {} : { baseUrl }),
|
|
408
|
+
...(defaultApiProtocol === undefined ? {} : { defaultApiProtocol }),
|
|
406
409
|
enabled: boolean(header.enabled, 'connection enabled'),
|
|
407
410
|
...(header.modelSource === undefined ? {} : { modelSource: modelSource(header.modelSource) }),
|
|
408
411
|
...(header.lastTest === undefined
|
|
@@ -268,7 +268,8 @@ export function decodeSubscriptionFrame(value) {
|
|
|
268
268
|
]);
|
|
269
269
|
if (record.reason !== 'slow_consumer' &&
|
|
270
270
|
record.reason !== 'session_removed' &&
|
|
271
|
-
record.reason !== 'access_revoked'
|
|
271
|
+
record.reason !== 'access_revoked' &&
|
|
272
|
+
record.reason !== 'transcript_changed') {
|
|
272
273
|
throw invalidProtocolFrame('Invalid subscription close reason');
|
|
273
274
|
}
|
|
274
275
|
frame = { kind: record.kind, ...envelope, reason: record.reason };
|
|
@@ -419,6 +419,9 @@ function transientConnection(identity, baseUrl = null) {
|
|
|
419
419
|
name: definition.label,
|
|
420
420
|
providerType,
|
|
421
421
|
...((baseUrl ?? definition.baseUrl) ? { baseUrl: baseUrl ?? definition.baseUrl } : {}),
|
|
422
|
+
...(identity.defaultApiProtocol === undefined
|
|
423
|
+
? {}
|
|
424
|
+
: { defaultApiProtocol: identity.defaultApiProtocol }),
|
|
422
425
|
enabled: true,
|
|
423
426
|
enabledModelIds: models.map(({ id }) => id),
|
|
424
427
|
models,
|
|
@@ -96,12 +96,13 @@ import { recoverClientCapabilityOutcomes } from './client-capability-recovery.js
|
|
|
96
96
|
import { HostConnectionEffectCoordinator } from './connection-effect-coordinator.js';
|
|
97
97
|
import { HostChangeFeed } from './host-change-feed.js';
|
|
98
98
|
import { HostConfigurationCoordinator } from './configuration-coordinator.js';
|
|
99
|
+
import { HostPromptSuggestionCoordinator, supportsPromptSuggestion } from './prompt-suggestion.js';
|
|
99
100
|
import { HostContextCoordinator } from './context-coordinator.js';
|
|
100
101
|
import { HostClientCapabilityCoordinator } from './client-capability-coordinator.js';
|
|
101
102
|
import { HostDailyReviewCoordinator } from './daily-review-coordinator.js';
|
|
102
103
|
import { prepareHostAiSdkBackend } from './execution-model-composition.js';
|
|
103
104
|
import { createInteractiveRunComposer, createInteractiveRunComposerFactory, routeInteractiveRunToolSurface, } from './interactive-run-composer.js';
|
|
104
|
-
import { readDuringBackendCreation, createHostGoalEvaluator, createHostDailyReviewModel, createHostMemoryExtractionModel, createHostPluginModel, createHostSessionEffectModel, } from './execution-model-authority.js';
|
|
105
|
+
import { readDuringBackendCreation, createHostGoalEvaluator, createHostDailyReviewModel, createHostMemoryExtractionModel, createHostPluginModel, createHostSessionEffectModel, createHostPromptSuggestionModel, } from './execution-model-authority.js';
|
|
105
106
|
import { HostExecutionInspectCoordinator } from './execution-inspect-coordinator.js';
|
|
106
107
|
import { HostExternalSessionCoordinator } from './external-session-coordinator.js';
|
|
107
108
|
import { boundedFailureDiagnostic } from './failure-diagnostic.js';
|
|
@@ -204,6 +205,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
204
205
|
let graphControlStore;
|
|
205
206
|
let graphClient;
|
|
206
207
|
let sessionEffects;
|
|
208
|
+
let promptSuggestions;
|
|
207
209
|
let memoryExtraction;
|
|
208
210
|
let unsubscribeTranscriptChanges;
|
|
209
211
|
let unsubscribeRuntimeEventCommits;
|
|
@@ -731,6 +733,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
731
733
|
unsubscribeRuntimeEventCommits = stores.runtimeEventStore.subscribeRuntimeEventCommits((sessionId) => {
|
|
732
734
|
continuityCoordinator.enqueueTranscriptAdvanced(sessionId);
|
|
733
735
|
sessionAdmission.detach(() => workHubResults?.notify(sessionId));
|
|
736
|
+
sessionAdmission.detach(() => promptSuggestions?.reconcile(sessionId));
|
|
734
737
|
});
|
|
735
738
|
unsubscribeUsageChanges = openedUsageStores.subscribeSessionUsageChanges((sessionId) => continuityCoordinator.enqueueSessionDomainChanged(sessionId, 'usage'));
|
|
736
739
|
dailyReview = new HostDailyReviewCoordinator({
|
|
@@ -1099,6 +1102,46 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
1099
1102
|
requestDrain: context.requestDrain,
|
|
1100
1103
|
});
|
|
1101
1104
|
sessionEffects = sessionEffectCoordinator;
|
|
1105
|
+
const promptSuggestionCoordinator = new HostPromptSuggestionCoordinator({
|
|
1106
|
+
generate: createHostPromptSuggestionModel({
|
|
1107
|
+
runtimePolicy: runtimePolicyStores,
|
|
1108
|
+
oauthCredentials,
|
|
1109
|
+
usage: openedUsageStores,
|
|
1110
|
+
requestDrain: context.requestDrain,
|
|
1111
|
+
}),
|
|
1112
|
+
readSource: (sessionId) => sessionAdmission.run(sessionId, async () => {
|
|
1113
|
+
if ((await runtimePolicyStores.runtimePolicy.getSnapshot()).policy.privacy.incognitoActive)
|
|
1114
|
+
return undefined;
|
|
1115
|
+
const canonical = await canonicalProjectionReader.read(sessionId);
|
|
1116
|
+
const turn = canonical?.rootTurn;
|
|
1117
|
+
if (!canonical ||
|
|
1118
|
+
!turn ||
|
|
1119
|
+
turn.status !== 'completed' ||
|
|
1120
|
+
turn.contextCompactionOutcome ||
|
|
1121
|
+
canonical.session.isArchived ||
|
|
1122
|
+
canonical.interactions.pending.length ||
|
|
1123
|
+
canonical.queue.followup.length ||
|
|
1124
|
+
canonical.queue.steering.length ||
|
|
1125
|
+
canonical.goal?.status === 'active' ||
|
|
1126
|
+
requireSessionManager(manager).runningTurnIds(sessionId).length)
|
|
1127
|
+
return undefined;
|
|
1128
|
+
const header = await stores.sessionStore.readHeaderSnapshot(sessionId);
|
|
1129
|
+
if (!supportsPromptSuggestion(sessionId, header))
|
|
1130
|
+
return undefined;
|
|
1131
|
+
await requireSessionManager(manager).ensureTranscriptLedgerForRead(sessionId);
|
|
1132
|
+
const view = await recapReadModel.getSessionView(sessionId);
|
|
1133
|
+
if (view.messages.some((message) => message.type === 'user' && message.turnId === turn.turnId && message.origin))
|
|
1134
|
+
return undefined;
|
|
1135
|
+
return {
|
|
1136
|
+
sessionId,
|
|
1137
|
+
turnId: turn.turnId,
|
|
1138
|
+
terminalEventId: turn.terminalEventId,
|
|
1139
|
+
header,
|
|
1140
|
+
messages: view.messages,
|
|
1141
|
+
};
|
|
1142
|
+
}),
|
|
1143
|
+
});
|
|
1144
|
+
promptSuggestions = promptSuggestionCoordinator;
|
|
1102
1145
|
const resolveChildTools = async (sessionId) => {
|
|
1103
1146
|
const header = await stores.sessionStore.readHeader(sessionId);
|
|
1104
1147
|
const shell = resolveTurnShellPlan((await runtimePolicyStores.runtimePolicy.getSnapshot()).policy.shell);
|
|
@@ -1847,7 +1890,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
1847
1890
|
? 'operation_unavailable'
|
|
1848
1891
|
: 'operation_conflict', plan.result.reason === 'resume_feature_disabled'
|
|
1849
1892
|
? 'Safe-boundary resume is disabled for this Runtime Host'
|
|
1850
|
-
:
|
|
1893
|
+
: `WorkHub delegated execution is not resumable (${plan.result.reason})`);
|
|
1851
1894
|
}
|
|
1852
1895
|
// Root planning authenticates handoff membership. Its source may be
|
|
1853
1896
|
// a physical successor of this same logical Turn, never another Turn.
|
|
@@ -1868,7 +1911,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
1868
1911
|
? 'operation_unavailable'
|
|
1869
1912
|
: 'operation_conflict', started.result.plan.reason === 'resume_feature_disabled'
|
|
1870
1913
|
? 'Safe-boundary resume is disabled for this Runtime Host'
|
|
1871
|
-
:
|
|
1914
|
+
: `WorkHub delegated execution is not resumable (${started.result.plan.reason})`);
|
|
1872
1915
|
}
|
|
1873
1916
|
return {
|
|
1874
1917
|
outcome: 'resume_started',
|
|
@@ -2097,9 +2140,10 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
2097
2140
|
const sessionBundles = new HostSessionBundleCoordinator({
|
|
2098
2141
|
lease: context.owner.lease,
|
|
2099
2142
|
fenceSubtree: (sessionId, operation) => requireSessionManager(manager).runSessionSubtreeQuiescentMutation(sessionId, operation),
|
|
2100
|
-
recoverInterruptedSessions: (sessionIds) =>
|
|
2101
|
-
.recoverInterruptedSessionsForSessions(sessionIds)
|
|
2102
|
-
.
|
|
2143
|
+
recoverInterruptedSessions: async (sessionIds) => {
|
|
2144
|
+
await requireSessionManager(manager).recoverInterruptedSessionsForSessions(sessionIds);
|
|
2145
|
+
await stores.runtimeEventStore.rebuildTerminalToolProjectionsForSessions(sessionIds);
|
|
2146
|
+
},
|
|
2103
2147
|
onImported: (sessionId) => hostChanges.publishSessionCatalog(sessionId),
|
|
2104
2148
|
});
|
|
2105
2149
|
const externalSessions = new HostExternalSessionCoordinator({
|
|
@@ -2400,6 +2444,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
2400
2444
|
messages.handlers,
|
|
2401
2445
|
interactions.handlers,
|
|
2402
2446
|
sessionEffectCoordinator.handlers,
|
|
2447
|
+
promptSuggestionCoordinator.handlers,
|
|
2403
2448
|
continuityCoordinator.handlers,
|
|
2404
2449
|
runtimeResources.handlers,
|
|
2405
2450
|
contextOperations.handlers,
|
|
@@ -2428,6 +2473,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
2428
2473
|
() => messages.beginDrain(),
|
|
2429
2474
|
() => interactions.beginDrain(),
|
|
2430
2475
|
() => sessionEffects?.beginDrain(),
|
|
2476
|
+
() => promptSuggestions?.beginDrain(),
|
|
2431
2477
|
],
|
|
2432
2478
|
close: [
|
|
2433
2479
|
async () => {
|
|
@@ -2441,6 +2487,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
2441
2487
|
() => runtimeResources?.close(),
|
|
2442
2488
|
() => workspaceExecution?.close(),
|
|
2443
2489
|
() => sessionEffects?.close(),
|
|
2490
|
+
() => promptSuggestions?.close(),
|
|
2444
2491
|
() => messages.close(),
|
|
2445
2492
|
() => interactions.close(),
|
|
2446
2493
|
() => turnAccessRequests?.close(),
|
|
@@ -2635,6 +2682,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
2635
2682
|
}
|
|
2636
2683
|
try {
|
|
2637
2684
|
await sessionEffects?.close();
|
|
2685
|
+
await promptSuggestions?.close();
|
|
2638
2686
|
}
|
|
2639
2687
|
catch (closeError) {
|
|
2640
2688
|
errors.push(closeError);
|