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
|
@@ -47,6 +47,7 @@ import { CONTEXT_OFFLOAD_DATABASE_NAME, CONTEXT_OFFLOAD_VALUES_DIRECTORY_NAME, }
|
|
|
47
47
|
import { acquireOperationalStateDatabase, inspectOperationalStateSchema, OPERATIONAL_STATE_DATABASE_NAME, OperationalStateMigrationBlockedError, } from './operational-state-store.js';
|
|
48
48
|
import { TERMINAL_RUNTIME_EVENT_SQL } from './runtime-transcript-query.js';
|
|
49
49
|
import { isSafeStorageId } from './storage-id.js';
|
|
50
|
+
import { createSqliteRuntimeStore } from './sqlite-runtime-store.js';
|
|
50
51
|
export const SESSION_BUNDLE_STATE_ENTRIES = [
|
|
51
52
|
'artifacts',
|
|
52
53
|
OPERATIONAL_STATE_DATABASE_NAME,
|
|
@@ -288,6 +289,16 @@ async function backupOperationalState(stateRoot, destinationPath) {
|
|
|
288
289
|
}
|
|
289
290
|
}
|
|
290
291
|
async function filterBackedUpDatabase(destinationPath, sessionIds, options) {
|
|
292
|
+
const runtimeStore = createSqliteRuntimeStore(destinationPath);
|
|
293
|
+
try {
|
|
294
|
+
// Repair only terminal facts for currently unsettled tools. A full
|
|
295
|
+
// projection rebuild decodes every RuntimeEvent in the Session, including
|
|
296
|
+
// legacy payloads that this build must preserve opaquely in the bundle.
|
|
297
|
+
await runtimeStore.rebuildTerminalToolProjectionsForSessions(sessionIds);
|
|
298
|
+
}
|
|
299
|
+
finally {
|
|
300
|
+
runtimeStore.close();
|
|
301
|
+
}
|
|
291
302
|
const database = new DatabaseSync(destinationPath);
|
|
292
303
|
try {
|
|
293
304
|
// Quiescence is asserted here, on the copy, not on the live database.
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
* specific language governing permissions and limitations
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
|
+
import { isExecutorConfiguration } from '@maka/core/executor-catalog';
|
|
19
20
|
import { randomUUID } from 'node:crypto';
|
|
20
21
|
import { DEFAULT_SESSION_NAME, normalizeUserSessionName } from '@maka/core/session-name';
|
|
21
22
|
import { isExecutorId } from '@maka/core/executor-id';
|
|
@@ -72,7 +73,12 @@ export function buildSessionHeader(workspaceRoot, input, sessionId = randomUUID(
|
|
|
72
73
|
...(input.revisionState ? { revisionState: input.revisionState } : {}),
|
|
73
74
|
hasUnread: false,
|
|
74
75
|
backend: input.executorId ? 'plugin-executor' : 'ai-sdk',
|
|
75
|
-
...(input.executorId
|
|
76
|
+
...(input.executorId
|
|
77
|
+
? {
|
|
78
|
+
executorId: input.executorId,
|
|
79
|
+
...(input.executorConfig ? { executorConfig: input.executorConfig } : {}),
|
|
80
|
+
}
|
|
81
|
+
: {}),
|
|
76
82
|
...(input.llmConnectionId === undefined ? {} : { llmConnectionId: input.llmConnectionId }),
|
|
77
83
|
llmConnectionSlug: input.llmConnectionSlug,
|
|
78
84
|
// A subagent Session's route is chosen by the spawn that created it and is
|
|
@@ -273,9 +279,10 @@ function isPersistedBackendKind(value) {
|
|
|
273
279
|
}
|
|
274
280
|
function isValidExecutorSelection(header) {
|
|
275
281
|
if (header.backend === 'plugin-executor') {
|
|
276
|
-
return isExecutorId(header.executorId)
|
|
282
|
+
return (isExecutorId(header.executorId) &&
|
|
283
|
+
(header.executorConfig === undefined || isExecutorConfiguration(header.executorConfig)));
|
|
277
284
|
}
|
|
278
|
-
return header.executorId === undefined;
|
|
285
|
+
return header.executorId === undefined && header.executorConfig === undefined;
|
|
279
286
|
}
|
|
280
287
|
function isFiniteNumber(value) {
|
|
281
288
|
return typeof value === 'number' && Number.isFinite(value);
|
|
@@ -314,7 +321,12 @@ export function toSummary(header) {
|
|
|
314
321
|
...(header.revisionIndex !== undefined ? { revisionIndex: header.revisionIndex } : {}),
|
|
315
322
|
...(header.revisionState ? { revisionState: header.revisionState } : {}),
|
|
316
323
|
backend: header.backend,
|
|
317
|
-
...(header.executorId
|
|
324
|
+
...(header.executorId
|
|
325
|
+
? {
|
|
326
|
+
executorId: header.executorId,
|
|
327
|
+
...(header.executorConfig ? { executorConfig: header.executorConfig } : {}),
|
|
328
|
+
}
|
|
329
|
+
: {}),
|
|
318
330
|
...(header.llmConnectionId === undefined ? {} : { llmConnectionId: header.llmConnectionId }),
|
|
319
331
|
llmConnectionSlug: header.llmConnectionSlug,
|
|
320
332
|
connectionLocked: header.connectionLocked,
|
|
@@ -169,9 +169,9 @@ class SqliteSessionStore {
|
|
|
169
169
|
? message
|
|
170
170
|
: undefined;
|
|
171
171
|
}
|
|
172
|
-
async readActiveWorkHubAssignmentsByTarget(targetSessionIds, maxAssignmentsPerTarget) {
|
|
172
|
+
async readActiveWorkHubAssignmentsByTarget(targetSessionIds, maxAssignmentsPerTarget, includeStopped) {
|
|
173
173
|
await this.ensureReady();
|
|
174
|
-
return this.metadata.readActiveWorkHubAssignmentsByTarget(targetSessionIds, maxAssignmentsPerTarget);
|
|
174
|
+
return this.metadata.readActiveWorkHubAssignmentsByTarget(targetSessionIds, maxAssignmentsPerTarget, includeStopped);
|
|
175
175
|
}
|
|
176
176
|
async readWorkHubReplacement(delegationId) {
|
|
177
177
|
const message = await this.readWorkHubCoordinationMessage(`whp_${workHubIdentitySuffix(delegationId)}`);
|
|
@@ -193,14 +193,37 @@ class SqliteSessionStore {
|
|
|
193
193
|
? message
|
|
194
194
|
: undefined;
|
|
195
195
|
}
|
|
196
|
-
async readWorkHubStopRequest(delegationId) {
|
|
197
|
-
const
|
|
196
|
+
async readWorkHubStopRequest(delegationId, actionId) {
|
|
197
|
+
const first = await this.readWorkHubCoordinationMessage(`whq_${workHubIdentitySuffix(delegationId)}`);
|
|
198
|
+
const message = actionId &&
|
|
199
|
+
first?.type === 'workhub_coordination' &&
|
|
200
|
+
first.kind === 'delegation_stop_requested' &&
|
|
201
|
+
first.actionId !== actionId
|
|
202
|
+
? await this.readWorkHubCoordinationMessage(`whq_${workHubIdentitySuffix(JSON.stringify([delegationId, actionId]))}`)
|
|
203
|
+
: first;
|
|
198
204
|
return message?.type === 'workhub_coordination' && message.kind === 'delegation_stop_requested'
|
|
199
205
|
? message
|
|
200
206
|
: undefined;
|
|
201
207
|
}
|
|
202
|
-
async readWorkHubStopResolution(delegationId) {
|
|
203
|
-
|
|
208
|
+
async readWorkHubStopResolution(delegationId, actionId) {
|
|
209
|
+
if (!actionId) {
|
|
210
|
+
const terminal = await this.readWorkHubCoordinationMessage(`whzt_${workHubIdentitySuffix(delegationId)}`);
|
|
211
|
+
if (terminal?.type === 'workhub_coordination' &&
|
|
212
|
+
terminal.kind === 'delegation_stop_resolved' &&
|
|
213
|
+
terminal.outcome !== 'not_owned')
|
|
214
|
+
return terminal;
|
|
215
|
+
}
|
|
216
|
+
const scoped = actionId
|
|
217
|
+
? await this.readWorkHubCoordinationMessage(`whz_${workHubIdentitySuffix(JSON.stringify([delegationId, actionId]))}`)
|
|
218
|
+
: undefined;
|
|
219
|
+
const primary = await this.readWorkHubCoordinationMessage(`whz_${workHubIdentitySuffix(delegationId)}`);
|
|
220
|
+
const message = scoped ??
|
|
221
|
+
(actionId &&
|
|
222
|
+
primary?.type === 'workhub_coordination' &&
|
|
223
|
+
primary.kind === 'delegation_stop_resolved' &&
|
|
224
|
+
primary.actionId !== actionId
|
|
225
|
+
? undefined
|
|
226
|
+
: primary);
|
|
204
227
|
return message?.type === 'workhub_coordination' && message.kind === 'delegation_stop_resolved'
|
|
205
228
|
? message
|
|
206
229
|
: undefined;
|
|
@@ -97,6 +97,7 @@ function createWriterFacade(lease, store) {
|
|
|
97
97
|
},
|
|
98
98
|
readShellRun: (sessionId, shellRunId) => run(() => store.readShellRun(sessionId, shellRunId)),
|
|
99
99
|
listSessionShellRuns: (sessionId) => run(() => store.listSessionShellRuns(sessionId)),
|
|
100
|
+
listShellRunRecoverySessionIds: () => run(() => store.listShellRunRecoverySessionIds()),
|
|
100
101
|
close: () => {
|
|
101
102
|
if (closed)
|
|
102
103
|
return;
|
|
@@ -90,6 +90,21 @@ class SqliteShellRunStore {
|
|
|
90
90
|
return normalizeShellRunRecord(JSON.parse(row.record_json), sessionId, row.shell_run_id);
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
|
+
async listShellRunRecoverySessionIds() {
|
|
94
|
+
const rows = this.#lease.database
|
|
95
|
+
.prepare(`
|
|
96
|
+
SELECT DISTINCT session_id
|
|
97
|
+
FROM core_shell_runs
|
|
98
|
+
WHERE json_extract(record_json, '$.status') IN ('starting', 'running')
|
|
99
|
+
ORDER BY session_id
|
|
100
|
+
`)
|
|
101
|
+
.all();
|
|
102
|
+
return rows.map((row) => {
|
|
103
|
+
if (typeof row.session_id !== 'string')
|
|
104
|
+
throw new Error('Invalid SQLite ShellRun row');
|
|
105
|
+
return row.session_id;
|
|
106
|
+
});
|
|
107
|
+
}
|
|
93
108
|
close() {
|
|
94
109
|
this.#lease.close();
|
|
95
110
|
}
|
|
@@ -105,6 +105,9 @@ export function migrateSqliteCoreExecutionDatabase(db) {
|
|
|
105
105
|
CREATE INDEX IF NOT EXISTS core_interaction_pending
|
|
106
106
|
ON core_interaction_requests(session_id, created_at, request_id);
|
|
107
107
|
|
|
108
|
+
CREATE INDEX IF NOT EXISTS core_interaction_requests_by_turn
|
|
109
|
+
ON core_interaction_requests(session_id, turn_id, created_at, request_id);
|
|
110
|
+
|
|
108
111
|
CREATE TABLE IF NOT EXISTS core_interaction_outcomes (
|
|
109
112
|
request_id TEXT PRIMARY KEY,
|
|
110
113
|
record_json TEXT NOT NULL,
|
|
@@ -20,7 +20,7 @@ import { decodePersistedLegacyRunHeader, invocationOpeningFromLegacyRunHeader, }
|
|
|
20
20
|
import { encodeCanonicalRuntimeEvent } from '@maka/core/canonical-runtime-event';
|
|
21
21
|
import { rebuildTranscriptTurnExtents, TERMINAL_RUNTIME_EVENT_SQL, } from './runtime-transcript-query.js';
|
|
22
22
|
import { buildInvocationOpenedEvent, buildSyntheticTerminalRuntimeEvent, } from '@maka/core/runtime-invocation';
|
|
23
|
-
export const SQLITE_RUNTIME_SCHEMA_VERSION =
|
|
23
|
+
export const SQLITE_RUNTIME_SCHEMA_VERSION = 20;
|
|
24
24
|
export const RUNTIME_RECOVERY_AUTHORITY_CAPABILITY = 'runtime_recovery_authority';
|
|
25
25
|
export const RUNTIME_RECOVERY_AUTHORITY_CAPABILITY_VERSION = 1;
|
|
26
26
|
export const RUNTIME_CONTINUATION_AUTHORITY_CAPABILITY = 'runtime_continuation_authority';
|
|
@@ -624,6 +624,79 @@ const MIGRATIONS = new Map([
|
|
|
624
624
|
ON runtime_session_turn_extents(session_id, first_ordinal, last_ordinal);
|
|
625
625
|
`,
|
|
626
626
|
],
|
|
627
|
+
[
|
|
628
|
+
20,
|
|
629
|
+
`
|
|
630
|
+
CREATE INDEX runtime_events_recovery_user_message
|
|
631
|
+
ON runtime_events(
|
|
632
|
+
session_id,
|
|
633
|
+
turn_id,
|
|
634
|
+
event_id,
|
|
635
|
+
event_kind,
|
|
636
|
+
CASE
|
|
637
|
+
WHEN json_valid(payload_json)
|
|
638
|
+
THEN json_extract(payload_json, '$.partial')
|
|
639
|
+
END,
|
|
640
|
+
CASE
|
|
641
|
+
WHEN json_valid(payload_json)
|
|
642
|
+
THEN json_extract(payload_json, '$.role')
|
|
643
|
+
END,
|
|
644
|
+
coalesce(CASE
|
|
645
|
+
WHEN json_valid(payload_json)
|
|
646
|
+
THEN json_extract(payload_json, '$.content.steering')
|
|
647
|
+
END, 0)
|
|
648
|
+
)
|
|
649
|
+
WHERE event_kind = 'text'
|
|
650
|
+
AND CASE
|
|
651
|
+
WHEN json_valid(payload_json)
|
|
652
|
+
THEN json_extract(payload_json, '$.partial')
|
|
653
|
+
END = 0
|
|
654
|
+
AND CASE
|
|
655
|
+
WHEN json_valid(payload_json)
|
|
656
|
+
THEN json_extract(payload_json, '$.role')
|
|
657
|
+
END = 'user'
|
|
658
|
+
AND coalesce(CASE
|
|
659
|
+
WHEN json_valid(payload_json)
|
|
660
|
+
THEN json_extract(payload_json, '$.content.steering')
|
|
661
|
+
END, 0) = 0;
|
|
662
|
+
|
|
663
|
+
-- Historical duplicates must remain readable so the affected identity can
|
|
664
|
+
-- fail closed. This is intentionally non-unique. CASE keeps a malformed
|
|
665
|
+
-- legacy payload from aborting the whole schema migration.
|
|
666
|
+
CREATE INDEX runtime_events_steering_message
|
|
667
|
+
ON runtime_events(
|
|
668
|
+
session_id,
|
|
669
|
+
CASE
|
|
670
|
+
WHEN json_valid(payload_json)
|
|
671
|
+
THEN json_extract(payload_json, '$.refs.providerEventId')
|
|
672
|
+
END
|
|
673
|
+
)
|
|
674
|
+
WHERE event_kind = 'text'
|
|
675
|
+
AND CASE
|
|
676
|
+
WHEN json_valid(payload_json)
|
|
677
|
+
THEN json_extract(payload_json, '$.partial')
|
|
678
|
+
END = 0
|
|
679
|
+
AND CASE
|
|
680
|
+
WHEN json_valid(payload_json)
|
|
681
|
+
THEN json_extract(payload_json, '$.content.steering')
|
|
682
|
+
END = 1;
|
|
683
|
+
|
|
684
|
+
CREATE INDEX runtime_events_tool_dispatch_operation
|
|
685
|
+
ON runtime_events(
|
|
686
|
+
CASE
|
|
687
|
+
WHEN json_valid(payload_json)
|
|
688
|
+
THEN json_extract(payload_json, '$.actions.toolDispatch.operationId')
|
|
689
|
+
END
|
|
690
|
+
)
|
|
691
|
+
WHERE event_kind = 'tool_dispatch';
|
|
692
|
+
|
|
693
|
+
CREATE INDEX tool_operations_unsettled
|
|
694
|
+
ON tool_operations(invocation_id, operation_id)
|
|
695
|
+
WHERE current_state = 'prepared'
|
|
696
|
+
AND result_event_id IS NULL
|
|
697
|
+
AND dispatch_event_id IS NOT NULL;
|
|
698
|
+
`,
|
|
699
|
+
],
|
|
627
700
|
]);
|
|
628
701
|
/**
|
|
629
702
|
* Data migrations that a SQL statement cannot express, applied inside the same
|