maka-agent 0.2.0-dev.25.20260908 → 0.2.0-dev.27.20260910
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/cli-core.js +21 -0
- package/dist/mcp-capability-provider.js +4 -1
- package/dist/pi-tui-mcp-status.js +2 -2
- package/dist/pi-tui-pickers.js +19 -29
- package/dist/runtime-host-cli.js +43 -3
- package/dist/runtime-host-handoff-surface.js +10 -8
- package/dist/runtime-host-lifecycle-transaction.js +28 -3
- package/dist/runtime-host-local-source-retirement.js +1 -1
- package/dist/runtime-host-setup-command.js +29 -6
- package/dist/runtime-host-update-command.js +49 -5
- package/dist/session-export-command.js +72 -0
- package/dist/tui-autocomplete-layout.js +3 -1
- package/dist/tui-copy-catalog.js +6 -3
- package/dist/tui-editor-render.js +36 -0
- package/dist/tui-mcp-control.js +41 -6
- package/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
- package/node_modules/@maka/core/dist/runtime-event.js +3 -0
- package/node_modules/@maka/core/dist/session.js +29 -4
- package/node_modules/@maka/core/dist/usage-stats/types.js +2 -0
- package/node_modules/@maka/core/dist/workhub-action-result.js +68 -0
- package/node_modules/@maka/core/dist/workhub-routing.js +126 -0
- package/node_modules/@maka/core/package.json +3 -3
- package/node_modules/@maka/eval/dist/toolchain-verification.js +1 -1
- package/node_modules/@maka/mcp/dist/form-elicitation.js +213 -0
- package/node_modules/@maka/mcp/dist/index.js +337 -71
- package/node_modules/@maka/runtime/dist/agent-run.js +10 -1
- package/node_modules/@maka/runtime/dist/ai-sdk-turn.js +7 -3
- package/node_modules/@maka/runtime/dist/builtin-tools.js +21 -2
- package/node_modules/@maka/runtime/dist/goal-continuation.js +5 -1
- package/node_modules/@maka/runtime/dist/plugin-agent-service.js +131 -0
- package/node_modules/@maka/runtime/dist/plugin-approval-service.js +33 -0
- package/node_modules/@maka/runtime/dist/plugin-attachment-service.js +53 -0
- package/node_modules/@maka/runtime/dist/plugin-command-service.js +100 -0
- package/node_modules/@maka/runtime/dist/plugin-data-services.js +332 -0
- package/node_modules/@maka/runtime/dist/plugin-fs-service.js +62 -0
- package/node_modules/@maka/runtime/dist/plugin-goal-service.js +61 -0
- package/node_modules/@maka/runtime/dist/plugin-invocation-signal.js +24 -0
- package/node_modules/@maka/runtime/dist/plugin-llm-service.js +85 -0
- package/node_modules/@maka/runtime/dist/plugin-lsp-service.js +94 -0
- package/node_modules/@maka/runtime/dist/plugin-scope-registry.js +91 -0
- package/node_modules/@maka/runtime/dist/plugin-session-query-service.js +71 -0
- package/node_modules/@maka/runtime/dist/plugin-shell-env-service.js +87 -0
- package/node_modules/@maka/runtime/dist/plugin-shell-service.js +74 -0
- package/node_modules/@maka/runtime/dist/plugin-skill-service.js +93 -0
- package/node_modules/@maka/runtime/dist/plugin-system-prompt-service.js +346 -0
- package/node_modules/@maka/runtime/dist/plugin-tool-service.js +18 -52
- package/node_modules/@maka/runtime/dist/plugin-user-question-service.js +43 -0
- package/node_modules/@maka/runtime/dist/plugin-web-service.js +69 -0
- package/node_modules/@maka/runtime/dist/runtime-event-read-model.js +20 -1
- package/node_modules/@maka/runtime/dist/runtime-kernel.js +120 -13
- package/node_modules/@maka/runtime/dist/session-export.js +177 -0
- package/node_modules/@maka/runtime/dist/session-manager.js +20 -36
- package/node_modules/@maka/runtime/package.json +18 -0
- package/node_modules/@maka/runtime-host/dist/client/connection.js +30 -5
- package/node_modules/@maka/runtime-host/dist/client/host-handoff-copy.js +83 -18
- package/node_modules/@maka/runtime-host/dist/client/host-handoff.js +46 -12
- package/node_modules/@maka/runtime-host/dist/client/host-retirement.js +4 -2
- package/node_modules/@maka/runtime-host/dist/client/peer-client.js +18 -1
- package/node_modules/@maka/runtime-host/dist/operator/setup-frame.js +31 -21
- package/node_modules/@maka/runtime-host/dist/protocol/index.js +13 -1
- package/node_modules/@maka/runtime-host/dist/protocol/operations.js +3 -2
- package/node_modules/@maka/runtime-host/dist/protocol/plugin-platform.js +30 -5
- package/node_modules/@maka/runtime-host/dist/protocol/session-continuity.js +1 -0
- package/node_modules/@maka/runtime-host/dist/protocol/workhub-coordination.js +90 -188
- package/node_modules/@maka/runtime-host/dist/server/access-credential-store.js +4 -0
- package/node_modules/@maka/runtime-host/dist/server/canonical-session-projection.js +2 -1
- package/node_modules/@maka/runtime-host/dist/server/client-capability-coordinator.js +62 -4
- package/node_modules/@maka/runtime-host/dist/server/connection-session.js +28 -8
- package/node_modules/@maka/runtime-host/dist/server/daily-review-coordinator.js +112 -56
- package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +497 -27
- package/node_modules/@maka/runtime-host/dist/server/execution-model-authority.js +74 -0
- package/node_modules/@maka/runtime-host/dist/server/failure-diagnostic.js +24 -0
- package/node_modules/@maka/runtime-host/dist/server/goal-coordinator.js +7 -3
- package/node_modules/@maka/runtime-host/dist/server/host-kernel.js +3 -3
- package/node_modules/@maka/runtime-host/dist/server/host-session-availability.js +5 -2
- package/node_modules/@maka/runtime-host/dist/server/hosted-execution-recovery.js +4 -3
- package/node_modules/@maka/runtime-host/dist/server/hosted-execution-tool-profile.js +64 -4
- package/node_modules/@maka/runtime-host/dist/server/interactive-run-composer.js +83 -17
- package/node_modules/@maka/runtime-host/dist/server/message-coordinator.js +25 -4
- package/node_modules/@maka/runtime-host/dist/server/operation-dispatcher.js +2 -7
- package/node_modules/@maka/runtime-host/dist/server/plugin-data-runtime.js +234 -0
- package/node_modules/@maka/runtime-host/dist/server/plugin-platform-coordinator.js +6 -0
- package/node_modules/@maka/runtime-host/dist/server/plugin-platform.js +12 -0
- package/node_modules/@maka/runtime-host/dist/server/root-turn-coordinator.js +289 -96
- package/node_modules/@maka/runtime-host/dist/server/runtime-resource-coordinator.js +11 -8
- package/node_modules/@maka/runtime-host/dist/server/scheduled-task-coordinator.js +31 -21
- package/node_modules/@maka/runtime-host/dist/server/serial-outbound-writer.js +1 -1
- package/node_modules/@maka/runtime-host/dist/server/session-catalog-coordinator.js +20 -8
- package/node_modules/@maka/runtime-host/dist/server/session-transcript-reader.js +15 -104
- 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 +85 -117
- package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-coordinator.js +201 -136
- package/node_modules/@maka/storage/dist/agent-run-store.js +60 -3
- package/node_modules/@maka/storage/dist/artifact-store.js +40 -3
- package/node_modules/@maka/storage/dist/atomic-file-write.js +74 -0
- package/node_modules/@maka/storage/dist/context-offload-snapshot.js +13 -6
- package/node_modules/@maka/storage/dist/credential-store.js +12 -63
- package/node_modules/@maka/storage/dist/execution-stores.js +5 -2
- package/node_modules/@maka/storage/dist/mcp-config-store.js +10 -25
- package/node_modules/@maka/storage/dist/session-bundle-policy.js +333 -30
- package/node_modules/@maka/storage/dist/session-store.js +16 -4
- package/node_modules/@maka/storage/dist/settings-store.js +8 -4
- package/node_modules/@maka/storage/dist/sqlite-artifact-metadata.js +11 -0
- package/node_modules/@maka/storage/dist/sqlite-session-metadata-schema.js +12 -1
- package/node_modules/@maka/storage/dist/sqlite-session-metadata-store.js +79 -8
- package/node_modules/@maka/storage/dist/stable-storage.js +14 -1
- package/node_modules/@maka/storage/package.json +2 -0
- package/package.json +1 -1
- package/node_modules/@maka/core/dist/workhub-creation-intent.js +0 -990
- package/node_modules/@maka/core/dist/workhub-session-resolver.js +0 -50
|
@@ -418,28 +418,38 @@ export class HostScheduledTaskCoordinator {
|
|
|
418
418
|
}
|
|
419
419
|
}
|
|
420
420
|
async #refresh() {
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
421
|
+
if (this.#handoffHeld || this.#draining)
|
|
422
|
+
return;
|
|
423
|
+
// Cover claim admission, native delivery, and persistence, while an idle
|
|
424
|
+
// schedule or a read-only catalog query does not claim active work.
|
|
425
|
+
const residency = this.#acquireResidency();
|
|
426
|
+
try {
|
|
427
|
+
await this.#exclusive(async () => {
|
|
425
428
|
if (this.#handoffHeld || this.#draining)
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
+
return;
|
|
430
|
+
for (const claim of await this.#store.listPendingFires()) {
|
|
431
|
+
if (this.#handoffHeld || this.#draining)
|
|
432
|
+
break;
|
|
433
|
+
if (claim.nativeState === 'waiting_for_provider') {
|
|
434
|
+
await this.#fulfill(claim, true);
|
|
435
|
+
}
|
|
429
436
|
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
}
|
|
437
|
+
while (!this.#draining && !this.#handoffHeld) {
|
|
438
|
+
const scan = await this.#store.claimNextDue(this.#now());
|
|
439
|
+
for (const expired of scan.expired)
|
|
440
|
+
this.#publish('updated', expired.id);
|
|
441
|
+
const claim = scan.claim;
|
|
442
|
+
if (!claim)
|
|
443
|
+
break;
|
|
444
|
+
await this.#refreshResidency();
|
|
445
|
+
await this.#fulfill(claim, false);
|
|
446
|
+
}
|
|
447
|
+
await this.#refreshSchedule();
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
finally {
|
|
451
|
+
residency.release();
|
|
452
|
+
}
|
|
443
453
|
}
|
|
444
454
|
async #fulfill(claim, recovering) {
|
|
445
455
|
const incognito = (await this.#runtimePolicy.runtimePolicy.getSnapshot()).policy.privacy
|
|
@@ -680,7 +690,7 @@ export class HostScheduledTaskCoordinator {
|
|
|
680
690
|
(claims.length > 0 ||
|
|
681
691
|
tasks.some((task) => task.status === 'active' && task.nextFireAt !== null));
|
|
682
692
|
if (shouldHold && !this.#residency)
|
|
683
|
-
this.#residency = this.#acquireResidency();
|
|
693
|
+
this.#residency = this.#acquireResidency('idle');
|
|
684
694
|
if (!shouldHold)
|
|
685
695
|
this.#releaseResidency();
|
|
686
696
|
}
|
|
@@ -24,7 +24,7 @@ import { thinkingVariantsForConnection } from '@maka/core/model-thinking';
|
|
|
24
24
|
import { executionBoundaryDisplayMode, } from '@maka/core/sandbox-boundary';
|
|
25
25
|
import { DEFAULT_SESSION_NAME, normalizeUserSessionName } from '@maka/core/session-name';
|
|
26
26
|
import { isSessionStartModeLabel as isExecutionSemanticLabel, sessionStartModeSpec, } from '@maka/core/session-start-mode';
|
|
27
|
-
import { isWorkHubCoordinationSessionId, isWorkHubCoordinationSessionTarget, } from '@maka/core/session';
|
|
27
|
+
import { WORKHUB_COORDINATION_SESSION_ID, isWorkHubCoordinationSession, isWorkHubCoordinationSessionId, isWorkHubCoordinationSessionTarget, } from '@maka/core/session';
|
|
28
28
|
import { isSessionNotFoundError, SessionMetadataConflictError, SessionMetadataVersionConflictError, } from '@maka/storage/execution-stores';
|
|
29
29
|
import { isVisibleSessionMessage } from '@maka/storage/session-message-projection';
|
|
30
30
|
import { SessionConfigurationRevisionConflictError, SessionConfigurationTransitionError, } from '@maka/runtime/session-manager';
|
|
@@ -438,15 +438,27 @@ export class HostSessionCatalogCoordinator {
|
|
|
438
438
|
}
|
|
439
439
|
});
|
|
440
440
|
}
|
|
441
|
-
|
|
442
|
-
|
|
441
|
+
configureWorkHubModel(input) {
|
|
442
|
+
return this.#updateConfiguration({
|
|
443
|
+
sessionId: WORKHUB_COORDINATION_SESSION_ID,
|
|
444
|
+
expectedRevision: input.expectedRevision,
|
|
445
|
+
patch: { modelTarget: input.modelTarget },
|
|
446
|
+
}, 'workhub');
|
|
447
|
+
}
|
|
448
|
+
async #updateConfiguration(input, authority = 'ordinary') {
|
|
449
|
+
if (authority === 'ordinary' && isWorkHubCoordinationSessionId(input.sessionId)) {
|
|
443
450
|
return configurationFailure('operation_conflict', 'WorkHub Coordination Session configuration requires WorkHub authority');
|
|
444
451
|
}
|
|
445
452
|
return this.#admission.run(input.sessionId, async (lease) => {
|
|
446
453
|
let commitAttempted = false;
|
|
447
454
|
try {
|
|
448
455
|
const current = await this.#stores.readHeaderRecordSnapshot(input.sessionId);
|
|
449
|
-
if (
|
|
456
|
+
if (authority === 'workhub' &&
|
|
457
|
+
(!isWorkHubCoordinationSessionId(current.header.id) ||
|
|
458
|
+
!isWorkHubCoordinationSession(current.header))) {
|
|
459
|
+
return configurationFailure('operation_conflict', 'WorkHub Coordination Session identity is unavailable');
|
|
460
|
+
}
|
|
461
|
+
if (authority === 'ordinary' && isWorkHubCoordinationSessionTarget(current.header)) {
|
|
450
462
|
return configurationFailure('operation_conflict', 'WorkHub Coordination Session configuration requires WorkHub authority');
|
|
451
463
|
}
|
|
452
464
|
if (current.revision !== input.expectedRevision) {
|
|
@@ -461,7 +473,7 @@ export class HostSessionCatalogCoordinator {
|
|
|
461
473
|
if (!clearsConnectionBlock && sessionConfigurationMatches(current.header, configuration)) {
|
|
462
474
|
return configurationSuccess({
|
|
463
475
|
kind: 'committed',
|
|
464
|
-
session: projectSessionCatalogRecord(await this.#stores.readCatalogRecord(input.sessionId)),
|
|
476
|
+
session: projectSessionCatalogRecord(await this.#stores.readCatalogRecord(input.sessionId, authority === 'workhub' ? 'recoverable' : 'ordinary')),
|
|
465
477
|
});
|
|
466
478
|
}
|
|
467
479
|
commitAttempted = true;
|
|
@@ -470,7 +482,7 @@ export class HostSessionCatalogCoordinator {
|
|
|
470
482
|
clearConnectionBlock: input.patch.modelTarget !== undefined,
|
|
471
483
|
configuration,
|
|
472
484
|
});
|
|
473
|
-
return configurationSuccess(await this.#committedUpdate(input.sessionId, lease));
|
|
485
|
+
return configurationSuccess(await this.#committedUpdate(input.sessionId, lease, authority === 'workhub' ? 'recoverable' : 'ordinary'));
|
|
474
486
|
}
|
|
475
487
|
catch (error) {
|
|
476
488
|
if (!commitAttempted &&
|
|
@@ -597,11 +609,11 @@ export class HostSessionCatalogCoordinator {
|
|
|
597
609
|
position = page.nextPosition;
|
|
598
610
|
}
|
|
599
611
|
}
|
|
600
|
-
async #committedUpdate(sessionId, lease) {
|
|
612
|
+
async #committedUpdate(sessionId, lease, roleScope = 'ordinary') {
|
|
601
613
|
await this.#continuity.refreshCanonical(sessionId, lease);
|
|
602
614
|
return {
|
|
603
615
|
kind: 'committed',
|
|
604
|
-
session: projectSessionCatalogRecord(await this.#stores.readCatalogRecord(sessionId)),
|
|
616
|
+
session: projectSessionCatalogRecord(await this.#stores.readCatalogRecord(sessionId, roleScope)),
|
|
605
617
|
};
|
|
606
618
|
}
|
|
607
619
|
#metadataMutationFailure(input, error, unknownMessage) {
|
|
@@ -46,18 +46,9 @@ const TRANSCRIPT_TURN_SCAN_LIMIT = 1;
|
|
|
46
46
|
* as absent rather than searched for down the Session.
|
|
47
47
|
*/
|
|
48
48
|
const TRANSCRIPT_LOOKUP_MAX_TURNS = 2;
|
|
49
|
-
/** One storage round trip of Coordination rows, sized like one ledger Turn. */
|
|
50
|
-
const COORDINATION_TRANSCRIPT_SCAN_LIMIT = 64;
|
|
51
|
-
const COORDINATION_TRANSCRIPT_SCAN_MAX_BYTES = DURABLE_TRANSCRIPT_TURN_MAX_BYTES;
|
|
52
49
|
export function createSessionTranscriptReader(input) {
|
|
53
50
|
const ledger = createDurableLedgerTranscriptReader(input);
|
|
54
|
-
const coordination = createCoordinationTranscriptReader(input.stores);
|
|
55
|
-
const isCoordination = (sessionId) => sessionId === WORKHUB_COORDINATION_SESSION_ID;
|
|
56
|
-
// Only a ledger-backed Session has a conversion; the Coordination Session's
|
|
57
|
-
// rows are the transcript, not something a run left behind.
|
|
58
51
|
const prepared = async (sessionId) => {
|
|
59
|
-
if (isCoordination(sessionId))
|
|
60
|
-
return coordination;
|
|
61
52
|
await input.ensureTranscriptLedger?.(sessionId);
|
|
62
53
|
return ledger;
|
|
63
54
|
};
|
|
@@ -148,6 +139,12 @@ function createDurableLedgerTranscriptReader(input) {
|
|
|
148
139
|
if (projected.diagnostics.some(isHardRuntimeEventReadModelDiagnostic)) {
|
|
149
140
|
throw new Error('Durable RuntimeEvent transcript projection is incomplete');
|
|
150
141
|
}
|
|
142
|
+
const admission = turn.invocation.sessionId === WORKHUB_COORDINATION_SESSION_ID
|
|
143
|
+
? await input.stores.agentRunStore.readRootTurnAdmission(turn.invocation.sessionId, turn.invocation.turnId)
|
|
144
|
+
: undefined;
|
|
145
|
+
const actionId = admission?.execution.kind === 'workhub_coordination'
|
|
146
|
+
? admission.execution.actionId
|
|
147
|
+
: undefined;
|
|
151
148
|
const ordinals = new Map(turn.events.map((entry) => [entry.event.id, entry.ordinal]));
|
|
152
149
|
const emitted = new Map();
|
|
153
150
|
return projected.messages.map((message, index) => {
|
|
@@ -160,7 +157,12 @@ function createDurableLedgerTranscriptReader(input) {
|
|
|
160
157
|
throw new Error('RuntimeEvent exceeds its transcript sequence stride');
|
|
161
158
|
}
|
|
162
159
|
emitted.set(ordinal, offset + 1);
|
|
163
|
-
return {
|
|
160
|
+
return {
|
|
161
|
+
sequence: ordinal * EVENT_SEQUENCE_STRIDE + offset,
|
|
162
|
+
message: message.type === 'user' && actionId
|
|
163
|
+
? { ...message, coordinationActionId: actionId }
|
|
164
|
+
: message,
|
|
165
|
+
};
|
|
164
166
|
});
|
|
165
167
|
};
|
|
166
168
|
const readTurns = async (sessionId, request) => store.readTranscriptInvocations(sessionId, {
|
|
@@ -221,9 +223,11 @@ function createDurableLedgerTranscriptReader(input) {
|
|
|
221
223
|
ordinal = older ? low - 1 : high + 1;
|
|
222
224
|
}
|
|
223
225
|
};
|
|
226
|
+
const source = { readHighWater: highWater, scan };
|
|
224
227
|
return {
|
|
228
|
+
source,
|
|
225
229
|
readHighWater: highWater,
|
|
226
|
-
...pagedTranscriptReads(
|
|
230
|
+
...pagedTranscriptReads(source),
|
|
227
231
|
/** One row per Turn, folded from the Turn's own projected messages. */
|
|
228
232
|
async readTurnContributions(sessionId, throughSequence, position, maxContributions) {
|
|
229
233
|
const watermark = throughSequence ?? (await highWater(sessionId));
|
|
@@ -395,99 +399,6 @@ function pagedTranscriptReads(source) {
|
|
|
395
399
|
},
|
|
396
400
|
};
|
|
397
401
|
}
|
|
398
|
-
/**
|
|
399
|
-
* The WorkHub Coordination Session's transcript, read from the rows the WorkHub
|
|
400
|
-
* writes.
|
|
401
|
-
*
|
|
402
|
-
* Every other Session's transcript is what its runs did, so the ledger holds
|
|
403
|
-
* all of it. The Coordination Session's is not: a delegation, a stop and a
|
|
404
|
-
* routing summary are appended under a Turn id that no root Turn admission ever
|
|
405
|
-
* minted, so there is no invocation for the ledger to hang them on and no
|
|
406
|
-
* conversion that could lift them. `workhub.coordination.answer` is the one
|
|
407
|
-
* path that would admit a real Turn and nothing in the renderer calls it.
|
|
408
|
-
*
|
|
409
|
-
* Delete this source once the WorkHub admits a Coordination Turn for every
|
|
410
|
-
* action, which its own ADR already requires (#3492,
|
|
411
|
-
* `docs/architecture/workhub-coordination-session-adr.md`): the Session then
|
|
412
|
-
* reads like any other and this reader has nothing left to do.
|
|
413
|
-
*/
|
|
414
|
-
function createCoordinationTranscriptReader(stores) {
|
|
415
|
-
const store = stores.sessionStore;
|
|
416
|
-
const highWater = (sessionId) => store.readTranscriptHighWaterSnapshot(sessionId);
|
|
417
|
-
const scan = async function* (sessionId, request) {
|
|
418
|
-
const throughSequence = request.throughSequence === undefined ? await highWater(sessionId) : request.throughSequence;
|
|
419
|
-
if (throughSequence === null)
|
|
420
|
-
return;
|
|
421
|
-
const older = request.direction === 'older';
|
|
422
|
-
const position = request.position ?? (older ? throughSequence : 0);
|
|
423
|
-
let cursor = older ? Math.min(position, throughSequence) + 1 : position - 1;
|
|
424
|
-
for (;;) {
|
|
425
|
-
const page = await store.readMessagesAfter(sessionId, {
|
|
426
|
-
...(older ? { beforeSequence: cursor } : { afterSequence: cursor }),
|
|
427
|
-
maxMessages: COORDINATION_TRANSCRIPT_SCAN_LIMIT,
|
|
428
|
-
maxStoredBytes: COORDINATION_TRANSCRIPT_SCAN_MAX_BYTES,
|
|
429
|
-
});
|
|
430
|
-
if (page.records.length === 0)
|
|
431
|
-
return;
|
|
432
|
-
for (const record of page.records) {
|
|
433
|
-
if (!older && record.sequence > throughSequence)
|
|
434
|
-
return;
|
|
435
|
-
yield record;
|
|
436
|
-
}
|
|
437
|
-
cursor = page.records.at(-1).sequence;
|
|
438
|
-
}
|
|
439
|
-
};
|
|
440
|
-
const source = { readHighWater: highWater, scan };
|
|
441
|
-
return {
|
|
442
|
-
readHighWater: highWater,
|
|
443
|
-
...pagedTranscriptReads(source),
|
|
444
|
-
/** Folded from the rows themselves; these Turns have nothing else. */
|
|
445
|
-
async readTurnContributions(sessionId, throughSequence, position, maxContributions) {
|
|
446
|
-
const watermark = throughSequence ?? (await highWater(sessionId));
|
|
447
|
-
if (watermark === null) {
|
|
448
|
-
return { throughSequence: null, contributions: [], nextPosition: null };
|
|
449
|
-
}
|
|
450
|
-
const byTurn = new Map();
|
|
451
|
-
let nextPosition = null;
|
|
452
|
-
for await (const { sequence, message } of scan(sessionId, {
|
|
453
|
-
direction: 'newer',
|
|
454
|
-
throughSequence: watermark,
|
|
455
|
-
position,
|
|
456
|
-
})) {
|
|
457
|
-
const turnId = message.turnId;
|
|
458
|
-
if (turnId === undefined)
|
|
459
|
-
continue;
|
|
460
|
-
if (!byTurn.has(turnId) && byTurn.size === maxContributions) {
|
|
461
|
-
nextPosition = sequence;
|
|
462
|
-
break;
|
|
463
|
-
}
|
|
464
|
-
byTurn.set(turnId, foldTurnContribution(byTurn.get(turnId), turnId, sequence, message));
|
|
465
|
-
}
|
|
466
|
-
return { throughSequence: watermark, contributions: [...byTurn.values()], nextPosition };
|
|
467
|
-
},
|
|
468
|
-
/** Every prompt, in order: this transcript has no index to sample from. */
|
|
469
|
-
async readTurnLandmarks(sessionId, maxLandmarks) {
|
|
470
|
-
const throughSequence = await highWater(sessionId);
|
|
471
|
-
if (throughSequence === null)
|
|
472
|
-
return { throughSequence: null, landmarks: [] };
|
|
473
|
-
const landmarks = [];
|
|
474
|
-
for await (const { sequence, message } of scan(sessionId, {
|
|
475
|
-
direction: 'newer',
|
|
476
|
-
throughSequence,
|
|
477
|
-
})) {
|
|
478
|
-
if (message.type !== 'user' || message.turnId === undefined)
|
|
479
|
-
continue;
|
|
480
|
-
const label = (message.displayText ?? message.text ?? '').trim();
|
|
481
|
-
if (!label)
|
|
482
|
-
continue;
|
|
483
|
-
landmarks.push({ turnId: message.turnId, sequence, label });
|
|
484
|
-
if (landmarks.length === maxLandmarks)
|
|
485
|
-
break;
|
|
486
|
-
}
|
|
487
|
-
return { throughSequence, landmarks };
|
|
488
|
-
},
|
|
489
|
-
};
|
|
490
|
-
}
|
|
491
402
|
function ordinalOf(sequence) {
|
|
492
403
|
return Math.floor(sequence / EVENT_SEQUENCE_STRIDE);
|
|
493
404
|
}
|
|
@@ -44,6 +44,9 @@ export function projectSharedSessionTranscriptMessage(message, sessionId) {
|
|
|
44
44
|
? {}
|
|
45
45
|
: { steeringEventId: message.steeringEventId }),
|
|
46
46
|
...(message.origin === undefined ? {} : { origin: message.origin }),
|
|
47
|
+
...(message.coordinationActionId === undefined
|
|
48
|
+
? {}
|
|
49
|
+
: { coordinationActionId: message.coordinationActionId }),
|
|
47
50
|
};
|
|
48
51
|
}
|
|
49
52
|
case 'assistant':
|