maka-agent 0.2.0-dev.67.20261002 → 0.2.0-dev.69.20261004
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/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-catalog.js +132 -0
- package/node_modules/@maka/acp-executor-plugin/dist/index.js +251 -113
- package/node_modules/@maka/acp-executor-plugin/dist/plugin.mjs +431 -108
- package/node_modules/@maka/core/dist/executor-catalog.js +25 -3
- package/node_modules/@maka/core/dist/recall.js +13 -14
- package/node_modules/@maka/runtime/dist/admission-limiter.js +3 -2
- package/node_modules/@maka/runtime/dist/ai-sdk-turn.js +0 -3
- package/node_modules/@maka/runtime/dist/model-history.js +4 -14
- package/node_modules/@maka/runtime/dist/plugin-data-services.js +7 -0
- package/node_modules/@maka/runtime/dist/plugin-executor-service.js +19 -3
- package/node_modules/@maka/runtime/dist/runtime-read-model.js +23 -4
- package/node_modules/@maka/runtime/dist/session-manager.js +1 -0
- package/node_modules/@maka/runtime/package.json +1 -0
- package/node_modules/@maka/runtime-host/dist/antigravity-program.js +49 -0
- package/node_modules/@maka/runtime-host/dist/protocol/index.js +3 -1
- package/node_modules/@maka/runtime-host/dist/protocol/plugin-platform.js +8 -2
- package/node_modules/@maka/runtime-host/dist/server/acp/antigravity.js +5 -19
- package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +14 -3
- package/node_modules/@maka/runtime-host/dist/server/external-agent-setup-coordinator.js +3 -0
- package/node_modules/@maka/runtime-host/dist/server/plugin-data-runtime.js +6 -0
- package/node_modules/@maka/runtime-host/dist/server/plugin-scratch-directory.js +55 -0
- package/node_modules/@maka/runtime-host/dist/server/session-catalog-coordinator.js +40 -6
- package/node_modules/@maka/runtime-host/package.json +1 -0
- package/node_modules/@maka/storage/dist/execution-stores.js +10 -0
- package/node_modules/@maka/storage/dist/runtime-event-persistence.js +1 -0
- package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +74 -5
- package/package.json +1 -1
|
@@ -147,6 +147,7 @@ export class HostSessionCatalogCoordinator {
|
|
|
147
147
|
#turnIndex;
|
|
148
148
|
#runtimePolicy;
|
|
149
149
|
#manager;
|
|
150
|
+
#isTurnBusy;
|
|
150
151
|
#admission;
|
|
151
152
|
#continuity;
|
|
152
153
|
#workspaceResolver;
|
|
@@ -160,6 +161,7 @@ export class HostSessionCatalogCoordinator {
|
|
|
160
161
|
this.#turnIndex = options.turnIndex;
|
|
161
162
|
this.#runtimePolicy = options.runtimePolicy;
|
|
162
163
|
this.#manager = options.manager;
|
|
164
|
+
this.#isTurnBusy = options.isTurnBusy;
|
|
163
165
|
this.#admission = options.admission;
|
|
164
166
|
this.#continuity = options.continuity;
|
|
165
167
|
this.#workspaceResolver = options.workspaceResolver;
|
|
@@ -512,7 +514,7 @@ export class HostSessionCatalogCoordinator {
|
|
|
512
514
|
if (current.header.isArchived) {
|
|
513
515
|
return configurationFailure('operation_conflict', 'Archived Session configuration cannot be changed');
|
|
514
516
|
}
|
|
515
|
-
|
|
517
|
+
let configuration = await this.#mergeConfigurationPatch(current.header, input.patch);
|
|
516
518
|
const clearsConnectionBlock = input.patch.modelTarget !== undefined &&
|
|
517
519
|
current.header.blockedReason === 'NO_REAL_CONNECTION';
|
|
518
520
|
if (!clearsConnectionBlock &&
|
|
@@ -525,12 +527,34 @@ export class HostSessionCatalogCoordinator {
|
|
|
525
527
|
}
|
|
526
528
|
if (input.patch.executorConfig) {
|
|
527
529
|
if (this.#manager.runningTurnIds(input.sessionId).length ||
|
|
530
|
+
this.#isTurnBusy?.(input.sessionId) ||
|
|
531
|
+
current.header.status === 'running' ||
|
|
528
532
|
current.header.status === 'waiting_for_user')
|
|
529
533
|
throw new SessionOperationFailure('operation_conflict', 'Executor model can only change while idle');
|
|
530
534
|
if (!this.#configureExecutor)
|
|
531
535
|
throw new SessionOperationFailure('operation_unavailable', 'Executor configuration is unavailable');
|
|
532
536
|
try {
|
|
533
|
-
await this.#configureExecutor(current.header,
|
|
537
|
+
const confirmed = await this.#configureExecutor(current.header,
|
|
538
|
+
// A model-only edit lets the Agent confirm mode side effects.
|
|
539
|
+
// Do not turn the previous mode into an explicit requirement.
|
|
540
|
+
input.patch.executorConfig.model && input.patch.executorConfig.mode === undefined
|
|
541
|
+
? { model: input.patch.executorConfig.model }
|
|
542
|
+
: configuration.executorConfig);
|
|
543
|
+
if (confirmed) {
|
|
544
|
+
if ((input.patch.executorConfig.model &&
|
|
545
|
+
confirmed.model !== input.patch.executorConfig.model) ||
|
|
546
|
+
(input.patch.executorConfig.mode &&
|
|
547
|
+
confirmed.mode !== input.patch.executorConfig.mode))
|
|
548
|
+
throw new Error('Executor confirmation differs from the requested configuration');
|
|
549
|
+
configuration = {
|
|
550
|
+
...configuration,
|
|
551
|
+
// A provider confirmation is the complete current snapshot. In
|
|
552
|
+
// particular, omission clears an option the provider removed as
|
|
553
|
+
// a side effect of changing another option.
|
|
554
|
+
executorConfig: confirmed,
|
|
555
|
+
model: confirmed.model ?? current.header.executorId ?? configuration.model,
|
|
556
|
+
};
|
|
557
|
+
}
|
|
534
558
|
confirmedExecutor = current.header;
|
|
535
559
|
}
|
|
536
560
|
catch {
|
|
@@ -567,7 +591,7 @@ export class HostSessionCatalogCoordinator {
|
|
|
567
591
|
try {
|
|
568
592
|
const actual = (await this.#stores.readHeaderRecordSnapshot(previous.id)).header;
|
|
569
593
|
if (actual.executorId !== previous.executorId ||
|
|
570
|
-
!actual.executorConfig
|
|
594
|
+
!actual.executorConfig ||
|
|
571
595
|
!this.#configureExecutor)
|
|
572
596
|
throw new Error('Confirmed executor model is unavailable');
|
|
573
597
|
await this.#configureExecutor(actual, actual.executorConfig);
|
|
@@ -959,7 +983,9 @@ export class HostSessionCatalogCoordinator {
|
|
|
959
983
|
return {
|
|
960
984
|
backend: patch.modelTarget || current.backend === 'ai-sdk' ? 'ai-sdk' : 'plugin-executor',
|
|
961
985
|
executorId: patch.modelTarget ? undefined : current.executorId,
|
|
962
|
-
executorConfig: patch.executorConfig
|
|
986
|
+
executorConfig: patch.executorConfig
|
|
987
|
+
? { ...current.executorConfig, ...patch.executorConfig }
|
|
988
|
+
: current.executorConfig,
|
|
963
989
|
llmConnectionId: model.connectionId,
|
|
964
990
|
llmConnectionSlug: model.connectionSlug,
|
|
965
991
|
model: patch.executorConfig?.model ?? model.model,
|
|
@@ -975,7 +1001,9 @@ export class HostSessionCatalogCoordinator {
|
|
|
975
1001
|
const requestedModel = input.executorConfig?.model ?? input.executorModel;
|
|
976
1002
|
let executorConfig;
|
|
977
1003
|
try {
|
|
978
|
-
executorConfig = await this.#assertExecutorAvailable?.(input.sessionId, input.executorId, requestedModel
|
|
1004
|
+
executorConfig = await this.#assertExecutorAvailable?.(input.sessionId, input.executorId, requestedModel
|
|
1005
|
+
? { ...input.executorConfig, model: requestedModel }
|
|
1006
|
+
: input.executorConfig, cwd);
|
|
979
1007
|
}
|
|
980
1008
|
catch {
|
|
981
1009
|
throw new SessionOperationFailure('operation_unavailable', `Plugin executor is unavailable: ${input.executorId}`);
|
|
@@ -1008,6 +1036,7 @@ function sessionConfigurationMatches(header, configuration) {
|
|
|
1008
1036
|
return (header.backend === configuration.backend &&
|
|
1009
1037
|
header.executorId === configuration.executorId &&
|
|
1010
1038
|
header.executorConfig?.model === configuration.executorConfig?.model &&
|
|
1039
|
+
header.executorConfig?.mode === configuration.executorConfig?.mode &&
|
|
1011
1040
|
header.llmConnectionId === configuration.llmConnectionId &&
|
|
1012
1041
|
header.llmConnectionSlug === configuration.llmConnectionSlug &&
|
|
1013
1042
|
header.model === configuration.model &&
|
|
@@ -1070,7 +1099,12 @@ function createRequestFingerprint(input, prepared) {
|
|
|
1070
1099
|
prepared.name,
|
|
1071
1100
|
prepared.labels,
|
|
1072
1101
|
input.executorId
|
|
1073
|
-
? [
|
|
1102
|
+
? [
|
|
1103
|
+
'executor',
|
|
1104
|
+
input.executorId,
|
|
1105
|
+
input.executorConfig?.model ?? input.executorModel ?? null,
|
|
1106
|
+
input.executorConfig?.mode ?? null,
|
|
1107
|
+
]
|
|
1074
1108
|
: input.modelTarget?.kind === 'default'
|
|
1075
1109
|
? ['default']
|
|
1076
1110
|
: [
|
|
@@ -354,6 +354,11 @@ async function createExecutionStoresForWrite(lease, provider) {
|
|
|
354
354
|
ensureTerminalRuntimeEventDurable: (sessionId, runId, event) => run(() => runtimeEventStore.ensureTerminalRuntimeEventDurable(sessionId, runId, event)),
|
|
355
355
|
ensureRecoveredTerminalRuntimeEventDurable: (sessionId, runId, event, operationIds) => run(() => runtimeEventStore.ensureRecoveredTerminalRuntimeEventDurable(sessionId, runId, event, operationIds)),
|
|
356
356
|
readRuntimeEvents: (sessionId, runId) => run(() => runtimeEventStore.readRuntimeEvents(sessionId, runId)),
|
|
357
|
+
...(runtimeEventStore.readSessionRuntimeSnapshot
|
|
358
|
+
? {
|
|
359
|
+
readSessionRuntimeSnapshot: (sessionId) => run(() => runtimeEventStore.readSessionRuntimeSnapshot(sessionId)),
|
|
360
|
+
}
|
|
361
|
+
: {}),
|
|
357
362
|
scanRuntimeEvents: (sessionId, runId, budget, visit) => run(() => runtimeEventStore.scanRuntimeEvents(sessionId, runId, budget, visit)),
|
|
358
363
|
readRuntimeEventsBounded: (sessionId, runId, budget) => run(() => runtimeEventStore.readRuntimeEventsBounded(sessionId, runId, budget)),
|
|
359
364
|
readImmutableRuntimeEvents: (sessionId, runId) => run(() => runtimeEventStore.readImmutableRuntimeEvents(sessionId, runId)),
|
|
@@ -466,6 +471,11 @@ async function openExecutionStoresForRead(lease, kind, extension) {
|
|
|
466
471
|
},
|
|
467
472
|
runtimeEventStore: {
|
|
468
473
|
readRuntimeEvents: (sessionId, runId) => run(() => runtimeEventStore.readRuntimeEvents(sessionId, runId)),
|
|
474
|
+
...(runtimeEventStore.readSessionRuntimeSnapshot
|
|
475
|
+
? {
|
|
476
|
+
readSessionRuntimeSnapshot: (sessionId) => run(() => runtimeEventStore.readSessionRuntimeSnapshot(sessionId)),
|
|
477
|
+
}
|
|
478
|
+
: {}),
|
|
469
479
|
readRuntimeEventsBounded: (sessionId, runId, budget) => run(() => runtimeEventStore.readRuntimeEventsBounded(sessionId, runId, budget)),
|
|
470
480
|
readImmutableRuntimeEvents: (sessionId, runId) => run(() => runtimeEventStore.readImmutableRuntimeEvents(sessionId, runId)),
|
|
471
481
|
listSessionInvocations: (sessionId) => run(() => runtimeEventStore.listSessionInvocations(sessionId)),
|
|
@@ -39,6 +39,7 @@ export async function openRuntimeEventReadPersistence(input) {
|
|
|
39
39
|
return {
|
|
40
40
|
kind: 'sqlite',
|
|
41
41
|
runtimeEventStore: Object.freeze({
|
|
42
|
+
readSessionRuntimeSnapshot: (sessionId) => store.readSessionRuntimeSnapshot(sessionId),
|
|
42
43
|
listSessionInvocations: (sessionId) => store.listSessionInvocations(sessionId),
|
|
43
44
|
listInvocationRecoveryInventory: (sessionIds) => store.listInvocationRecoveryInventory(sessionIds),
|
|
44
45
|
readRunInvocation: (sessionId, runId) => store.readRunInvocation(sessionId, runId),
|
|
@@ -369,6 +369,74 @@ export class SqliteRuntimeStore {
|
|
|
369
369
|
async readRuntimeEvents(sessionId, runId) {
|
|
370
370
|
return this.readRuntimeEventsSync(sessionId, runId);
|
|
371
371
|
}
|
|
372
|
+
async readSessionRuntimeSnapshot(sessionId) {
|
|
373
|
+
assertRuntimeStorageSafeId(sessionId, 'Invalid session id');
|
|
374
|
+
return this.readTransaction(() => {
|
|
375
|
+
const decodedEvents = new Map();
|
|
376
|
+
const openings = this.readInvocationOpeningsSync(sessionId, { direction: 'asc' }, decodedEvents);
|
|
377
|
+
const eventsByRun = new Map();
|
|
378
|
+
const durableEventOrdinalById = new Map();
|
|
379
|
+
if (openings.length === 0) {
|
|
380
|
+
return { invocations: [], eventsByRun, durableEventOrdinalById };
|
|
381
|
+
}
|
|
382
|
+
// Read each payload once. The opening query already decoded its events;
|
|
383
|
+
// reuse those same objects. Global event_seq order also gives each run
|
|
384
|
+
// its immutable order and each invocation its first terminal fact.
|
|
385
|
+
const rows = this.db
|
|
386
|
+
.prepare(`
|
|
387
|
+
SELECT event_id, session_id, invocation_id, run_id, turn_id,
|
|
388
|
+
CASE WHEN event_kind = 'invocation_opened' THEN '' ELSE payload_json END AS payload_json
|
|
389
|
+
FROM runtime_events
|
|
390
|
+
WHERE session_id = ?
|
|
391
|
+
ORDER BY event_seq ASC, event_id ASC
|
|
392
|
+
`)
|
|
393
|
+
.all(sessionId);
|
|
394
|
+
const terminalByInvocation = new Map();
|
|
395
|
+
for (const row of rows) {
|
|
396
|
+
const event = decodedEvents.get(row.event_id) ?? decodeRuntimeEventStorageRow(row);
|
|
397
|
+
const events = eventsByRun.get(event.runId) ?? [];
|
|
398
|
+
events.push(event);
|
|
399
|
+
eventsByRun.set(event.runId, events);
|
|
400
|
+
if (isTerminalRuntimeEvent(event) && !terminalByInvocation.has(event.invocationId)) {
|
|
401
|
+
terminalByInvocation.set(event.invocationId, event);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
// Only identities and ordinals are needed here, not a second copy of
|
|
405
|
+
// every payload. Keep the same join and identity checks as the entry reader.
|
|
406
|
+
const ordinals = this.db
|
|
407
|
+
.prepare(`
|
|
408
|
+
SELECT o.ordinal, e.event_id, e.session_id
|
|
409
|
+
FROM runtime_session_event_ordinals o
|
|
410
|
+
JOIN runtime_events e ON e.event_id = o.event_id
|
|
411
|
+
WHERE o.session_id = ?
|
|
412
|
+
ORDER BY o.ordinal ASC
|
|
413
|
+
`)
|
|
414
|
+
.all(sessionId);
|
|
415
|
+
for (const row of ordinals) {
|
|
416
|
+
if (!Number.isSafeInteger(row.ordinal) || row.ordinal < 1) {
|
|
417
|
+
throw new Error(`Invalid RuntimeEvent Session ordinal for ${sessionId}`);
|
|
418
|
+
}
|
|
419
|
+
if (row.session_id !== sessionId) {
|
|
420
|
+
throw new Error(`RuntimeEvent Session ordinal identity mismatch for ${row.event_id}`);
|
|
421
|
+
}
|
|
422
|
+
durableEventOrdinalById.set(row.event_id, row.ordinal);
|
|
423
|
+
}
|
|
424
|
+
const partialsByRun = new Map();
|
|
425
|
+
for (const partial of this.readRuntimePartialSnapshotsSync(sessionId)) {
|
|
426
|
+
const partials = partialsByRun.get(partial.event.runId) ?? [];
|
|
427
|
+
partials.push(partial);
|
|
428
|
+
partialsByRun.set(partial.event.runId, partials);
|
|
429
|
+
}
|
|
430
|
+
for (const [runId, partials] of partialsByRun) {
|
|
431
|
+
eventsByRun.set(runId, mergeRuntimePartialSnapshots(eventsByRun.get(runId) ?? [], partials));
|
|
432
|
+
}
|
|
433
|
+
const invocations = openings.map((opening) => {
|
|
434
|
+
const terminalEvent = terminalByInvocation.get(opening.invocationId);
|
|
435
|
+
return { ...opening, ...(terminalEvent ? { terminalEvent } : {}) };
|
|
436
|
+
});
|
|
437
|
+
return { invocations, eventsByRun, durableEventOrdinalById };
|
|
438
|
+
});
|
|
439
|
+
}
|
|
372
440
|
transcriptQuery() {
|
|
373
441
|
return new RuntimeTranscriptQuery(this.db, (sessionId, invocationId) => {
|
|
374
442
|
// By invocation rather than by run: both shelves key their opening on it,
|
|
@@ -692,7 +760,7 @@ export class SqliteRuntimeStore {
|
|
|
692
760
|
* Ordering and paging therefore happen in SQL, and a bounded caller decodes
|
|
693
761
|
* only the openings it asked for.
|
|
694
762
|
*/
|
|
695
|
-
readInvocationOpeningsSync(sessionId, options) {
|
|
763
|
+
readInvocationOpeningsSync(sessionId, options, decodedEvents) {
|
|
696
764
|
const order = options.direction === 'desc' ? 'DESC' : 'ASC';
|
|
697
765
|
const rows = this.db
|
|
698
766
|
.prepare(`
|
|
@@ -767,6 +835,7 @@ export class SqliteRuntimeStore {
|
|
|
767
835
|
if (!opening) {
|
|
768
836
|
throw new Error(`RuntimeEvent ${event.id} is indexed as an opening fact but is not one`);
|
|
769
837
|
}
|
|
838
|
+
decodedEvents?.set(event.id, event);
|
|
770
839
|
return {
|
|
771
840
|
sessionId: event.sessionId,
|
|
772
841
|
invocationId: event.invocationId,
|
|
@@ -958,10 +1027,10 @@ export class SqliteRuntimeStore {
|
|
|
958
1027
|
SELECT stream_key, session_id, invocation_id, run_id, turn_id,
|
|
959
1028
|
payload_json, text_content, after_event_id
|
|
960
1029
|
FROM runtime_partial_snapshots
|
|
961
|
-
WHERE session_id = ? AND run_id = ?
|
|
1030
|
+
WHERE session_id = ? ${runId === undefined ? '' : 'AND run_id = ?'}
|
|
962
1031
|
ORDER BY updated_at ASC, stream_key ASC
|
|
963
1032
|
`)
|
|
964
|
-
.all(sessionId, runId);
|
|
1033
|
+
.all(...(runId === undefined ? [sessionId] : [sessionId, runId]));
|
|
965
1034
|
const segmentText = new Map();
|
|
966
1035
|
const segments = this.db
|
|
967
1036
|
.prepare(`
|
|
@@ -969,10 +1038,10 @@ export class SqliteRuntimeStore {
|
|
|
969
1038
|
FROM runtime_partial_segments AS segment
|
|
970
1039
|
INNER JOIN runtime_partial_snapshots AS snapshot
|
|
971
1040
|
ON snapshot.stream_key = segment.stream_key
|
|
972
|
-
WHERE snapshot.session_id = ? AND snapshot.run_id = ?
|
|
1041
|
+
WHERE snapshot.session_id = ? ${runId === undefined ? '' : 'AND snapshot.run_id = ?'}
|
|
973
1042
|
ORDER BY segment.stream_key ASC, segment.segment_seq ASC
|
|
974
1043
|
`)
|
|
975
|
-
.iterate(sessionId, runId);
|
|
1044
|
+
.iterate(...(runId === undefined ? [sessionId] : [sessionId, runId]));
|
|
976
1045
|
let streamKey;
|
|
977
1046
|
let chunks = [];
|
|
978
1047
|
let tail = [];
|