maka-agent 0.2.0-dev.47.20260922 → 0.2.0-dev.48.20260923
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/runtime-host-capability-provider-command.js +25 -6
- 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/executor-catalog.js +106 -0
- package/node_modules/@maka/core/dist/mcp.js +4 -1
- package/node_modules/@maka/core/dist/model-metadata.js +28 -1
- package/node_modules/@maka/core/dist/runtime-event-store.js +25 -0
- package/node_modules/@maka/core/dist/runtime-invocation.js +5 -0
- 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/session.js +2 -0
- 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/turn-origin.js +14 -0
- package/node_modules/@maka/core/package.json +2 -0
- 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/conversation-copy.js +56 -1
- package/node_modules/@maka/runtime/dist/mcp-tools.js +9 -2
- 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/runtime-ledger-repair.js +2 -2
- package/node_modules/@maka/runtime/dist/session-event-runtime-mapper.js +3 -0
- package/node_modules/@maka/runtime/dist/session-manager.js +170 -125
- 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-host/dist/candidate-entry.js +8 -5
- 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/composition-identity.js +19 -0
- package/node_modules/@maka/runtime-host/dist/protocol/index.js +10 -2
- package/node_modules/@maka/runtime-host/dist/protocol/plugin-platform.js +34 -0
- package/node_modules/@maka/runtime-host/dist/protocol/session-catalog.js +40 -2
- 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/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 +159 -19
- package/node_modules/@maka/runtime-host/dist/server/execution-model-authority.js +3 -0
- package/node_modules/@maka/runtime-host/dist/server/extension-bundle.js +4 -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 +4 -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/root-turn-coordinator.js +91 -12
- 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-effect-coordinator.js +12 -6
- package/node_modules/@maka/runtime-host/dist/server/session-transcript-reader.js +33 -0
- package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-coordinator.js +4 -0
- 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/execution-stores.js +15 -3
- 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/credential-vault-document.js +4 -1
- package/node_modules/@maka/storage/dist/runtime-policy/policy-document.js +2 -0
- package/node_modules/@maka/storage/dist/session-store-values.js +16 -4
- 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-runtime-schema.js +74 -1
- package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +724 -84
- package/node_modules/@maka/storage/dist/sqlite-session-metadata-store.js +16 -0
- package/package.json +1 -1
|
@@ -0,0 +1,293 @@
|
|
|
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 { z } from 'zod';
|
|
20
|
+
import { WORKHUB_COORDINATION_SESSION_ID, } from '@maka/core/session';
|
|
21
|
+
import { isSessionNotFoundError } from '@maka/storage/execution-stores';
|
|
22
|
+
import { projectSessionInteractions } from './interaction-projection.js';
|
|
23
|
+
import { HostWorkHubResultCoordinator, } from './workhub-result-coordinator.js';
|
|
24
|
+
export function createWorkHubResultRuntime(options) {
|
|
25
|
+
const { stores, executions, messages, admission, readTurnResult } = options;
|
|
26
|
+
async function listAssignments() {
|
|
27
|
+
const targets = (await stores.sessionStore.listHeaders())
|
|
28
|
+
.filter((h) => h.id !== WORKHUB_COORDINATION_SESSION_ID && !h.isArchived)
|
|
29
|
+
.map((h) => h.id);
|
|
30
|
+
const result = [];
|
|
31
|
+
for (let i = 0; i < targets.length; i += 256)
|
|
32
|
+
result.push(...(await stores.sessionStore.readActiveWorkHubAssignmentsByTarget(targets.slice(i, i + 256))));
|
|
33
|
+
return result.filter((a) => a.returnResults);
|
|
34
|
+
}
|
|
35
|
+
async function pending(sessionId) {
|
|
36
|
+
return projectSessionInteractions(await stores.interactionStore.listSessionPending(sessionId), await stores.sessionStore.listPendingSandboxBoundaryRequests(sessionId)).pending;
|
|
37
|
+
}
|
|
38
|
+
async function isActive(assignment) {
|
|
39
|
+
try {
|
|
40
|
+
const header = await stores.sessionStore.readHeaderSnapshot(assignment.targetSessionId);
|
|
41
|
+
if (header.isArchived)
|
|
42
|
+
return false;
|
|
43
|
+
const active = await stores.sessionStore.readActiveWorkHubAssignmentsByTarget([
|
|
44
|
+
assignment.targetSessionId,
|
|
45
|
+
]);
|
|
46
|
+
if (!active.some((a) => a.delegationId === assignment.delegationId && a.returnResults))
|
|
47
|
+
return false;
|
|
48
|
+
// Retirement intent takes precedence even before its final receipt exists.
|
|
49
|
+
if (await stores.sessionStore.readWorkHubReplacement(assignment.delegationId))
|
|
50
|
+
return false;
|
|
51
|
+
if (await stores.sessionStore.readWorkHubStopRequest(assignment.delegationId)) {
|
|
52
|
+
const resolution = await stores.sessionStore.readWorkHubStopResolution(assignment.delegationId);
|
|
53
|
+
if (resolution?.outcome !== 'not_owned')
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
if (isSessionNotFoundError(error))
|
|
60
|
+
return false;
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async function inspectLocked(assignment, lease, includeResult = true) {
|
|
65
|
+
try {
|
|
66
|
+
// The lightweight sweep receives active assignments from listAssignments.
|
|
67
|
+
// Delivery and tool reads still revalidate under both Session admissions.
|
|
68
|
+
if (includeResult && !(await isActive(assignment)))
|
|
69
|
+
return undefined;
|
|
70
|
+
const disposition = await messages.readMessageExecutionDispositionAdmitted(assignment.targetSessionId, assignment.targetMessageId, lease);
|
|
71
|
+
if (disposition.kind === 'cancelled') {
|
|
72
|
+
return {
|
|
73
|
+
turnId: assignment.targetTurnId,
|
|
74
|
+
runId: `message:${assignment.targetMessageId}`,
|
|
75
|
+
eventKey: 'message_cancelled_before_execution',
|
|
76
|
+
status: 'cancelled',
|
|
77
|
+
result: 'The delegated message was cancelled before execution.',
|
|
78
|
+
details: { abortSource: 'message_cancelled_before_execution' },
|
|
79
|
+
sharedTurn: false,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
if (disposition.kind !== 'owned_root' && disposition.kind !== 'shared_turn')
|
|
83
|
+
return undefined;
|
|
84
|
+
const identity = await executions.readLatestRootTurnLineage({
|
|
85
|
+
sessionId: assignment.targetSessionId,
|
|
86
|
+
turnId: disposition.turnId,
|
|
87
|
+
runId: disposition.runId,
|
|
88
|
+
});
|
|
89
|
+
const snapshot = await executions.read(identity);
|
|
90
|
+
const sharedTurn = disposition.kind === 'shared_turn';
|
|
91
|
+
if (snapshot.status === 'waiting_for_user' || snapshot.status === 'running') {
|
|
92
|
+
const requests = (await pending(assignment.targetSessionId)).filter((p) => p.turnId === identity.turnId);
|
|
93
|
+
if (!requests.length)
|
|
94
|
+
return undefined;
|
|
95
|
+
return {
|
|
96
|
+
turnId: identity.turnId,
|
|
97
|
+
runId: identity.runId,
|
|
98
|
+
eventKey: 'interaction:' +
|
|
99
|
+
requests
|
|
100
|
+
.map((p) => p.interactionId)
|
|
101
|
+
.sort()
|
|
102
|
+
.join(','),
|
|
103
|
+
status: 'waiting_for_user',
|
|
104
|
+
result: 'The delegated task needs user input. Questions may be presented in WorkHub with WorkHubResult; approvals must be handled at the original task.',
|
|
105
|
+
details: requests.map((p) => ({ interactionId: p.interactionId, request: p.request })),
|
|
106
|
+
sharedTurn,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
if (snapshot.status !== 'completed' &&
|
|
110
|
+
snapshot.status !== 'failed' &&
|
|
111
|
+
snapshot.status !== 'cancelled')
|
|
112
|
+
return undefined;
|
|
113
|
+
const answer = includeResult
|
|
114
|
+
? await readTurnResult(assignment.targetSessionId, identity.turnId)
|
|
115
|
+
: '';
|
|
116
|
+
return {
|
|
117
|
+
turnId: identity.turnId,
|
|
118
|
+
runId: identity.runId,
|
|
119
|
+
eventKey: snapshot.terminalEventId,
|
|
120
|
+
status: snapshot.status,
|
|
121
|
+
result: answer,
|
|
122
|
+
details: snapshot.status === 'failed'
|
|
123
|
+
? {
|
|
124
|
+
failureClass: snapshot.failureClass ?? null,
|
|
125
|
+
message: snapshot.failureMessage ?? null,
|
|
126
|
+
}
|
|
127
|
+
: snapshot.status === 'cancelled'
|
|
128
|
+
? { abortSource: snapshot.abortSource ?? null }
|
|
129
|
+
: null,
|
|
130
|
+
sharedTurn,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
if (isSessionNotFoundError(error))
|
|
135
|
+
return undefined;
|
|
136
|
+
throw error;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
async function inspect(assignment, lease, includeResult = true) {
|
|
140
|
+
return lease
|
|
141
|
+
? inspectLocked(assignment, lease, includeResult)
|
|
142
|
+
: admission.runMany([WORKHUB_COORDINATION_SESSION_ID, assignment.targetSessionId], (lane) => inspectLocked(assignment, lane, includeResult));
|
|
143
|
+
}
|
|
144
|
+
const coordinator = new HostWorkHubResultCoordinator({
|
|
145
|
+
listAssignments,
|
|
146
|
+
inspect,
|
|
147
|
+
deliver: (origin, prepare) => executions.startWorkHubResult(origin, prepare),
|
|
148
|
+
acquireResidency: options.acquireResidency,
|
|
149
|
+
onError: options.onError,
|
|
150
|
+
});
|
|
151
|
+
const relayWatchers = new Map();
|
|
152
|
+
function notify(sessionId) {
|
|
153
|
+
coordinator.notify(sessionId);
|
|
154
|
+
for (const wake of relayWatchers.get(sessionId) ?? [])
|
|
155
|
+
wake();
|
|
156
|
+
}
|
|
157
|
+
const parameters = z
|
|
158
|
+
.object({
|
|
159
|
+
actionId: z.string().min(1),
|
|
160
|
+
operation: z.enum(['read', 'ask_question']).default('read'),
|
|
161
|
+
interactionId: z.string().optional(),
|
|
162
|
+
offset: z.number().int().nonnegative().default(0),
|
|
163
|
+
})
|
|
164
|
+
.strict();
|
|
165
|
+
const tool = {
|
|
166
|
+
name: 'WorkHubResult',
|
|
167
|
+
description: 'Read a delegated task result in pages, or present its exact pending question to the user here and forward their actual answer. Use actionId from a Host result notification. Never use this tool to approve permissions. The read operation returns Unicode character offsets.',
|
|
168
|
+
parameters,
|
|
169
|
+
categoryHint: 'read',
|
|
170
|
+
recoveryMode: 'never_auto_retry',
|
|
171
|
+
async impl(raw, ctx) {
|
|
172
|
+
const input = parameters.parse(raw);
|
|
173
|
+
if (ctx.sessionId !== WORKHUB_COORDINATION_SESSION_ID)
|
|
174
|
+
throw new Error('WorkHub result access requires the coordination Session');
|
|
175
|
+
const assignment = await stores.sessionStore.readWorkHubAssignment(input.actionId);
|
|
176
|
+
if (!assignment?.returnResults)
|
|
177
|
+
throw new Error('Unknown WorkHub result assignment');
|
|
178
|
+
const observation = await inspect(assignment);
|
|
179
|
+
if (!observation) {
|
|
180
|
+
if (input.operation !== 'read')
|
|
181
|
+
throw new Error('No pending delegated question');
|
|
182
|
+
const active = await admission.runMany([WORKHUB_COORDINATION_SESSION_ID, assignment.targetSessionId], () => isActive(assignment));
|
|
183
|
+
return active
|
|
184
|
+
? {
|
|
185
|
+
status: 'pending',
|
|
186
|
+
targetSessionId: assignment.targetSessionId,
|
|
187
|
+
message: 'No result is ready yet. The Host will automatically notify WorkHub when a result or user question is available. Acknowledge the delegation and end this response; do not poll tools to wait.',
|
|
188
|
+
}
|
|
189
|
+
: { status: 'obsolete', targetSessionId: assignment.targetSessionId };
|
|
190
|
+
}
|
|
191
|
+
if (input.operation === 'read') {
|
|
192
|
+
const chars = Array.from(observation.result), end = input.offset + 16000;
|
|
193
|
+
return {
|
|
194
|
+
...observation,
|
|
195
|
+
result: chars.slice(input.offset, end).join(''),
|
|
196
|
+
nextOffset: end < chars.length ? end : null,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
if (!input.interactionId || !ctx.askUserQuestion)
|
|
200
|
+
throw new Error('A pending question and interactive WorkHub are required');
|
|
201
|
+
const request = await admission.run(assignment.targetSessionId, async () => (await pending(assignment.targetSessionId)).find((p) => p.interactionId === input.interactionId && p.turnId === observation.turnId));
|
|
202
|
+
if (!request || request.request.kind !== 'question')
|
|
203
|
+
throw new Error('Only pending user questions can be relayed');
|
|
204
|
+
const relayState = {
|
|
205
|
+
closed: false,
|
|
206
|
+
status: 'obsolete',
|
|
207
|
+
};
|
|
208
|
+
let checking = false;
|
|
209
|
+
const checkOriginal = () => {
|
|
210
|
+
if (checking || relayState.closed)
|
|
211
|
+
return;
|
|
212
|
+
checking = true;
|
|
213
|
+
void admission
|
|
214
|
+
.run(assignment.targetSessionId, async () => ({
|
|
215
|
+
active: await isActive(assignment),
|
|
216
|
+
questionPending: (await pending(assignment.targetSessionId)).some((item) => item.interactionId === request.interactionId),
|
|
217
|
+
}))
|
|
218
|
+
.then(async ({ active, questionPending }) => {
|
|
219
|
+
if (active && questionPending)
|
|
220
|
+
return;
|
|
221
|
+
relayState.status = active ? 'question_settled_in_target' : 'obsolete';
|
|
222
|
+
relayState.closed = true;
|
|
223
|
+
if (!(await options.interactions.closeRelayedQuestion(ctx.turnId, ctx.toolCallId)))
|
|
224
|
+
relayState.closed = false;
|
|
225
|
+
})
|
|
226
|
+
.catch((error) => {
|
|
227
|
+
relayState.closed = false;
|
|
228
|
+
try {
|
|
229
|
+
options.onError(error);
|
|
230
|
+
}
|
|
231
|
+
catch {
|
|
232
|
+
// The relay watcher must not leave an unhandled timer rejection.
|
|
233
|
+
}
|
|
234
|
+
})
|
|
235
|
+
.finally(() => {
|
|
236
|
+
checking = false;
|
|
237
|
+
});
|
|
238
|
+
};
|
|
239
|
+
let watchers = relayWatchers.get(assignment.targetSessionId);
|
|
240
|
+
if (!watchers) {
|
|
241
|
+
watchers = new Set();
|
|
242
|
+
relayWatchers.set(assignment.targetSessionId, watchers);
|
|
243
|
+
}
|
|
244
|
+
watchers.add(checkOriginal);
|
|
245
|
+
const timer = setInterval(checkOriginal, 5000);
|
|
246
|
+
timer.unref();
|
|
247
|
+
let answer;
|
|
248
|
+
try {
|
|
249
|
+
answer = await ctx.askUserQuestion(request.request.questions.map((q) => ({
|
|
250
|
+
question: q.question,
|
|
251
|
+
options: q.options.map((o) => ({ ...o })),
|
|
252
|
+
})));
|
|
253
|
+
}
|
|
254
|
+
catch (error) {
|
|
255
|
+
if (relayState.closed)
|
|
256
|
+
return {
|
|
257
|
+
status: relayState.status,
|
|
258
|
+
targetSessionId: assignment.targetSessionId,
|
|
259
|
+
message: relayState.status === 'question_settled_in_target'
|
|
260
|
+
? 'The original task question has settled. Wait for the automatic task result; do not ask again.'
|
|
261
|
+
: 'The delegated task is no longer active.',
|
|
262
|
+
};
|
|
263
|
+
throw error;
|
|
264
|
+
}
|
|
265
|
+
finally {
|
|
266
|
+
clearInterval(timer);
|
|
267
|
+
watchers.delete(checkOriginal);
|
|
268
|
+
if (watchers.size === 0)
|
|
269
|
+
relayWatchers.delete(assignment.targetSessionId);
|
|
270
|
+
}
|
|
271
|
+
ctx.abortSignal.throwIfAborted();
|
|
272
|
+
// Recheck the original delegation after the human responds. A late answer
|
|
273
|
+
// must not revive a cancelled/replaced task or answer another interaction.
|
|
274
|
+
const outcome = await admission.runMany([WORKHUB_COORDINATION_SESSION_ID, assignment.targetSessionId], async (lease) => {
|
|
275
|
+
const current = await inspectLocked(assignment, lease);
|
|
276
|
+
if (!current || current.turnId !== request.turnId)
|
|
277
|
+
return undefined;
|
|
278
|
+
return options.interactions.answerDelegatedQuestion({
|
|
279
|
+
sessionId: assignment.targetSessionId,
|
|
280
|
+
interactionId: request.interactionId,
|
|
281
|
+
answer: { kind: 'question', answers: answer.answers.map((a) => a.answer) },
|
|
282
|
+
}, lease);
|
|
283
|
+
});
|
|
284
|
+
if (!outcome)
|
|
285
|
+
return { status: 'obsolete' };
|
|
286
|
+
if (!outcome.ok)
|
|
287
|
+
throw new Error(outcome.error.message);
|
|
288
|
+
notify(assignment.targetSessionId);
|
|
289
|
+
return { status: outcome.result.status, targetSessionId: assignment.targetSessionId };
|
|
290
|
+
},
|
|
291
|
+
};
|
|
292
|
+
return { coordinator, tool, notify };
|
|
293
|
+
}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
* specific language governing permissions and limitations
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
|
+
import { decodeTurnOrigin } from '@maka/core/turn-origin';
|
|
19
20
|
import { isDeepStrictEqual } from 'node:util';
|
|
20
21
|
import { normalizeSubmittedTurnIntent, submittedTurnIntentsEqual, } from './submitted-turn-intent.js';
|
|
21
22
|
import { assertNoReservedWorkspaceAuthorityAppend } from './runtime-event-authority.js';
|
|
@@ -683,6 +684,7 @@ export function normalizeRootExecutionDescriptor(value) {
|
|
|
683
684
|
}
|
|
684
685
|
if (value.kind === 'workhub_coordination') {
|
|
685
686
|
const routingDecision = normalizeWorkHubRoutingDecision(value.routingDecision);
|
|
687
|
+
const feedback = decodeTurnOrigin(value.feedback);
|
|
686
688
|
if (!hasExactKeys(value, [
|
|
687
689
|
'kind',
|
|
688
690
|
'inputDigest',
|
|
@@ -690,7 +692,12 @@ export function normalizeRootExecutionDescriptor(value) {
|
|
|
690
692
|
...(value.routingDecision === undefined ? [] : ['routingDecision']),
|
|
691
693
|
...(value.operation === undefined ? [] : ['operation']),
|
|
692
694
|
...(value.actionId === undefined ? [] : ['actionId']),
|
|
695
|
+
...(value.feedback === undefined ? [] : ['feedback']),
|
|
693
696
|
]) ||
|
|
697
|
+
(value.feedback !== undefined &&
|
|
698
|
+
(feedback?.kind !== 'workhub_result' ||
|
|
699
|
+
value.operation !== undefined ||
|
|
700
|
+
value.routingDecision !== undefined)) ||
|
|
694
701
|
(value.capabilityBinding !== undefined && !isSha256Digest(value.capabilityBinding)) ||
|
|
695
702
|
(value.actionId !== undefined && value.operation !== 'action') ||
|
|
696
703
|
(value.operation !== undefined && routingDecision !== undefined) ||
|
|
@@ -709,6 +716,7 @@ export function normalizeRootExecutionDescriptor(value) {
|
|
|
709
716
|
: {}),
|
|
710
717
|
...(typeof value.actionId === 'string' ? { actionId: value.actionId } : {}),
|
|
711
718
|
...(routingDecision ? { routingDecision } : {}),
|
|
719
|
+
...(feedback?.kind === 'workhub_result' ? { feedback } : {}),
|
|
712
720
|
});
|
|
713
721
|
}
|
|
714
722
|
if (value.kind === 'regenerate') {
|
|
@@ -32,7 +32,7 @@ const executionStoresWriterKinds = new WeakMap();
|
|
|
32
32
|
const executionStoresReaderKinds = new WeakMap();
|
|
33
33
|
const executionStoresWritersByLease = new WeakMap();
|
|
34
34
|
const executionStoresWritersOpeningByLease = new WeakMap();
|
|
35
|
-
export { normalizeRootTurnAdmissionPayload, rootTurnAdmissionRecordFits, rootTurnSourceMessagePayloadsEqual, } from './agent-run-store.js';
|
|
35
|
+
export { ROOT_TURN_ADMISSION_MAX_RECORD_BYTES, ROOT_TURN_ADMISSION_MAX_SOURCE_MESSAGES, normalizeRootTurnAdmissionPayload, rootTurnAdmissionRecordFits, rootTurnSourceMessagePayloadsEqual, } from './agent-run-store.js';
|
|
36
36
|
export { isSessionNotFoundError } from './session-store-contract.js';
|
|
37
37
|
export { SessionMetadataConflictError, SessionMetadataVersionConflictError, } from './session-store-contract.js';
|
|
38
38
|
export { submittedTurnIntentsEqual } from './submitted-turn-intent.js';
|
|
@@ -225,6 +225,11 @@ async function createExecutionStoresForWrite(lease, provider) {
|
|
|
225
225
|
]));
|
|
226
226
|
const graphControlStore = Object.freeze({
|
|
227
227
|
...graphMethods,
|
|
228
|
+
...(persistence.graphControlStore.listAgentGraphScheduleRecoveryGraphIds
|
|
229
|
+
? {
|
|
230
|
+
listAgentGraphScheduleRecoveryGraphIds: () => run(() => persistence.graphControlStore.listAgentGraphScheduleRecoveryGraphIds()),
|
|
231
|
+
}
|
|
232
|
+
: {}),
|
|
228
233
|
close: () => { },
|
|
229
234
|
});
|
|
230
235
|
const stores = {
|
|
@@ -351,9 +356,11 @@ async function createExecutionStoresForWrite(lease, provider) {
|
|
|
351
356
|
scanRuntimeEvents: (sessionId, runId, budget, visit) => run(() => runtimeEventStore.scanRuntimeEvents(sessionId, runId, budget, visit)),
|
|
352
357
|
readRuntimeEventsBounded: (sessionId, runId, budget) => run(() => runtimeEventStore.readRuntimeEventsBounded(sessionId, runId, budget)),
|
|
353
358
|
readImmutableRuntimeEvents: (sessionId, runId) => run(() => runtimeEventStore.readImmutableRuntimeEvents(sessionId, runId)),
|
|
359
|
+
readRecoveryMessageEvents: (input) => run(() => runtimeEventStore.readRecoveryMessageEvents(input)),
|
|
354
360
|
readImmutableRuntimePrefix: (input) => run(() => runtimeEventStore.readImmutableRuntimePrefix(input)),
|
|
355
361
|
readImmutableRuntimePrefixProof: (input, budget) => run(() => runtimeEventStore.readImmutableRuntimePrefixProof(input, budget)),
|
|
356
362
|
listSessionInvocations: (sessionId) => run(() => runtimeEventStore.listSessionInvocations(sessionId)),
|
|
363
|
+
listInvocationRecoveryInventory: (sessionIds) => run(() => runtimeEventStore.listInvocationRecoveryInventory(sessionIds)),
|
|
357
364
|
readRunInvocation: (sessionId, runId) => run(() => runtimeEventStore.readRunInvocation(sessionId, runId)),
|
|
358
365
|
listSessionInvocationsBounded: (sessionId, limit) => run(() => runtimeEventStore.listSessionInvocationsBounded(sessionId, limit)),
|
|
359
366
|
listSessionInvocationsPage: (sessionId, input) => run(() => runtimeEventStore.listSessionInvocationsPage(sessionId, input)),
|
|
@@ -384,14 +391,18 @@ async function createExecutionStoresForWrite(lease, provider) {
|
|
|
384
391
|
claimContinuation: (input) => run(() => runtimeEventStore.claimContinuation(input)),
|
|
385
392
|
readContinuationClaimByBoundary: (boundaryDigest) => run(() => runtimeEventStore.readContinuationClaimByBoundary(boundaryDigest)),
|
|
386
393
|
readContinuationClaimStateByBoundary: (boundaryDigest) => run(() => runtimeEventStore.readContinuationClaimStateByBoundary(boundaryDigest)),
|
|
394
|
+
...(runtimeEventStore.listUnsettledContinuationClaimsForRecovery
|
|
395
|
+
? {
|
|
396
|
+
listUnsettledContinuationClaimsForRecovery: (sessionIds) => run(() => runtimeEventStore.listUnsettledContinuationClaimsForRecovery(sessionIds)),
|
|
397
|
+
}
|
|
398
|
+
: {}),
|
|
387
399
|
listContinuationClaimsForRecovery: (sessionId) => run(() => runtimeEventStore.listContinuationClaimsForRecovery(sessionId)),
|
|
388
400
|
commitContinuationStart: (input) => run(() => runtimeEventStore.commitContinuationStart(input)),
|
|
389
401
|
commitContinuationRepairStart: (input) => run(() => runtimeEventStore.commitContinuationRepairStart(input)),
|
|
390
402
|
readImmutableSteeringMessageProof: (sessionId, messageId) => run(() => runtimeEventStore.readImmutableSteeringMessageProof(sessionId, messageId)),
|
|
391
|
-
repairImmutableSteeringMessageProofsForRecovery: (sessionId) => run(() => runtimeEventStore.repairImmutableSteeringMessageProofsForRecovery(sessionId)),
|
|
392
403
|
commitToolPrepared: (input) => run(() => runtimePersistence.runtimeCommitStore.commitToolPrepared(input)),
|
|
393
404
|
commitToolOutcome: (input) => run(() => runtimePersistence.runtimeCommitStore.commitToolOutcome(input)),
|
|
394
|
-
listUnsettledToolOperations: (
|
|
405
|
+
listUnsettledToolOperations: (sessionIds) => run(() => runtimePersistence.runtimeCommitStore.listUnsettledToolOperations(sessionIds)),
|
|
395
406
|
},
|
|
396
407
|
};
|
|
397
408
|
freezeExecutionStoresFacade(stores);
|
|
@@ -456,6 +467,7 @@ async function openExecutionStoresForRead(lease, kind, extension) {
|
|
|
456
467
|
readRuntimeEventsBounded: (sessionId, runId, budget) => run(() => runtimeEventStore.readRuntimeEventsBounded(sessionId, runId, budget)),
|
|
457
468
|
readImmutableRuntimeEvents: (sessionId, runId) => run(() => runtimeEventStore.readImmutableRuntimeEvents(sessionId, runId)),
|
|
458
469
|
listSessionInvocations: (sessionId) => run(() => runtimeEventStore.listSessionInvocations(sessionId)),
|
|
470
|
+
listInvocationRecoveryInventory: (sessionIds) => run(() => runtimeEventStore.listInvocationRecoveryInventory(sessionIds)),
|
|
459
471
|
readRunInvocation: (sessionId, runId) => run(() => runtimeEventStore.readRunInvocation(sessionId, runId)),
|
|
460
472
|
listSessionInvocationsBounded: (sessionId, limit) => run(() => runtimeEventStore.listSessionInvocationsBounded(sessionId, limit)),
|
|
461
473
|
listSessionInvocationsPage: (sessionId, input) => run(() => runtimeEventStore.listSessionInvocationsPage(sessionId, input)),
|
|
@@ -16,9 +16,10 @@
|
|
|
16
16
|
* specific language governing permissions and limitations
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
|
+
import { watch } from 'node:fs';
|
|
19
20
|
import { readFile } from 'node:fs/promises';
|
|
20
|
-
import { dirname, join } from 'node:path';
|
|
21
|
-
import { MCP_CONFIG_VERSION, createDefaultMcpConfig, isNonLoopbackCleartextHttp, } from '@maka/core/mcp';
|
|
21
|
+
import { basename, dirname, join } from 'node:path';
|
|
22
|
+
import { MCP_CONFIG_VERSION, createDefaultMcpConfig, isNonLoopbackCleartextHttp, mcpConfigChangeRetiresCredentials, } from '@maka/core/mcp';
|
|
22
23
|
import { writeAtomicFile } from './atomic-file-write.js';
|
|
23
24
|
import { withProcessLifetimeFileUpdateLock } from './process-lifetime-file-update-lock.js';
|
|
24
25
|
import { hardenDirectory } from './stable-storage.js';
|
|
@@ -30,6 +31,9 @@ const MAX_ID_LENGTH = 128;
|
|
|
30
31
|
const MAX_STRING_LENGTH = 8_192;
|
|
31
32
|
const MAX_CONFIG_BYTES = 1_048_576;
|
|
32
33
|
const FORBIDDEN_KEYS = new Set(['__proto__', 'prototype', 'constructor']);
|
|
34
|
+
// An atomic replace is a temp write plus a rename; one settle window turns
|
|
35
|
+
// that burst into one notification.
|
|
36
|
+
const CHANGE_SETTLE_MS = 150;
|
|
33
37
|
export class McpConfigSourceError extends Error {
|
|
34
38
|
reason;
|
|
35
39
|
version;
|
|
@@ -54,6 +58,64 @@ export class McpServerExistsError extends Error {
|
|
|
54
58
|
export function createMcpConfigStore(workspaceRoot) {
|
|
55
59
|
return new FileMcpConfigStore(join(workspaceRoot, 'mcp.json'));
|
|
56
60
|
}
|
|
61
|
+
/** Watches the directory, not the file: an atomic replace renames a new
|
|
62
|
+
* inode over the old one, which ends a watch on the file itself. */
|
|
63
|
+
export function subscribeMcpConfigFileChanges(path, listener) {
|
|
64
|
+
const name = basename(path);
|
|
65
|
+
let timer;
|
|
66
|
+
let watcher;
|
|
67
|
+
const settle = () => {
|
|
68
|
+
clearTimeout(timer);
|
|
69
|
+
timer = setTimeout(() => listener(), CHANGE_SETTLE_MS);
|
|
70
|
+
};
|
|
71
|
+
try {
|
|
72
|
+
watcher = watch(dirname(path), { persistent: false }, (_event, filename) => {
|
|
73
|
+
if (filename === null || filename.toString() === name)
|
|
74
|
+
settle();
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
queueMicrotask(() => listener(error));
|
|
79
|
+
return () => { };
|
|
80
|
+
}
|
|
81
|
+
settle();
|
|
82
|
+
const stop = () => {
|
|
83
|
+
clearTimeout(timer);
|
|
84
|
+
watcher.close();
|
|
85
|
+
};
|
|
86
|
+
watcher.on('error', (error) => {
|
|
87
|
+
stop();
|
|
88
|
+
listener(error);
|
|
89
|
+
});
|
|
90
|
+
return stop;
|
|
91
|
+
}
|
|
92
|
+
export class McpConfigurationValidationError extends Error {
|
|
93
|
+
constructor(cause) {
|
|
94
|
+
super(cause instanceof Error ? cause.message : 'Invalid MCP configuration', { cause });
|
|
95
|
+
this.name = 'McpConfigurationValidationError';
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/** Validate before retiring credentials, and retire before publishing the
|
|
99
|
+
* replacement. Both effects run under the config file's cross-process lock. */
|
|
100
|
+
export function updateMcpConfiguration(store, prepare, retireCredentials) {
|
|
101
|
+
return store.transform(async (current) => {
|
|
102
|
+
const proposed = prepare(current);
|
|
103
|
+
let next;
|
|
104
|
+
try {
|
|
105
|
+
next = normalizeMcpConfig(proposed);
|
|
106
|
+
assertMcpEndpointPolicyOnChanges(current, next);
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
throw new McpConfigurationValidationError(error);
|
|
110
|
+
}
|
|
111
|
+
for (const [serverId, previous] of Object.entries(current.mcpServers)) {
|
|
112
|
+
if (mcpConfigChangeRetiresCredentials(previous, next.mcpServers[serverId])) {
|
|
113
|
+
await retireCredentials(serverId, previous);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return next;
|
|
117
|
+
});
|
|
118
|
+
}
|
|
57
119
|
export function normalizeMcpConfig(value) {
|
|
58
120
|
if (!isRecord(value))
|
|
59
121
|
throw new Error('MCP config must be an object');
|
|
@@ -114,6 +176,21 @@ class FileMcpConfigStore {
|
|
|
114
176
|
return this.withUpdateLock(() => this.readOrCreate());
|
|
115
177
|
}
|
|
116
178
|
}
|
|
179
|
+
subscribeChanges(listener) {
|
|
180
|
+
let stop;
|
|
181
|
+
let stopped = false;
|
|
182
|
+
void this.ensureDirectory().then(() => {
|
|
183
|
+
if (!stopped)
|
|
184
|
+
stop = subscribeMcpConfigFileChanges(this.path, listener);
|
|
185
|
+
}, (error) => {
|
|
186
|
+
if (!stopped)
|
|
187
|
+
listener(error);
|
|
188
|
+
});
|
|
189
|
+
return () => {
|
|
190
|
+
stopped = true;
|
|
191
|
+
stop?.();
|
|
192
|
+
};
|
|
193
|
+
}
|
|
117
194
|
async transform(apply) {
|
|
118
195
|
return this.withUpdateLock(async () => {
|
|
119
196
|
const current = await this.readOrCreate();
|
|
@@ -280,6 +357,18 @@ function normalizeOAuth(value, serverId) {
|
|
|
280
357
|
if (!isRecord(value))
|
|
281
358
|
throw new Error(`${serverId}.oauth must be an object`);
|
|
282
359
|
const result = {};
|
|
360
|
+
if (value.issuer !== undefined) {
|
|
361
|
+
const issuer = nonEmptyString(value.issuer, `${serverId}.oauth.issuer`);
|
|
362
|
+
const parsed = new URL(issuer);
|
|
363
|
+
if (!['https:', 'http:'].includes(parsed.protocol) ||
|
|
364
|
+
parsed.username ||
|
|
365
|
+
parsed.password ||
|
|
366
|
+
parsed.search ||
|
|
367
|
+
parsed.hash) {
|
|
368
|
+
throw new Error(`${serverId}.oauth.issuer must be an HTTP(S) issuer URL without credentials, query or fragment`);
|
|
369
|
+
}
|
|
370
|
+
result.issuer = issuer;
|
|
371
|
+
}
|
|
283
372
|
if (value.clientId !== undefined) {
|
|
284
373
|
result.clientId = nonEmptyString(value.clientId, `${serverId}.oauth.clientId`);
|
|
285
374
|
}
|
|
@@ -138,6 +138,8 @@ class OperationalStateDatabaseOwner {
|
|
|
138
138
|
references = 0;
|
|
139
139
|
closed = false;
|
|
140
140
|
transactionDepth = 0;
|
|
141
|
+
transactionWrote = false;
|
|
142
|
+
writeViewRevisionValue = 0;
|
|
141
143
|
settledCallbacks = [];
|
|
142
144
|
constructor(databasePath, options) {
|
|
143
145
|
this.databasePath = databasePath;
|
|
@@ -173,6 +175,7 @@ class OperationalStateDatabaseOwner {
|
|
|
173
175
|
return {
|
|
174
176
|
database: this.database,
|
|
175
177
|
databasePath: this.databasePath,
|
|
178
|
+
writeViewRevision: () => this.writeViewRevisionValue,
|
|
176
179
|
transaction: (mode, operation) => this.transaction(mode, operation),
|
|
177
180
|
onTransactionSettled: (callback) => {
|
|
178
181
|
if (this.transactionDepth === 0)
|
|
@@ -220,22 +223,33 @@ class OperationalStateDatabaseOwner {
|
|
|
220
223
|
transaction(mode, operation) {
|
|
221
224
|
if (this.closed)
|
|
222
225
|
throw new Error('Operational state database is closed');
|
|
223
|
-
if (this.transactionDepth > 0)
|
|
226
|
+
if (this.transactionDepth > 0) {
|
|
227
|
+
if (mode === 'write')
|
|
228
|
+
this.transactionWrote = true;
|
|
224
229
|
return operation();
|
|
230
|
+
}
|
|
225
231
|
this.database.exec(mode === 'write' ? 'BEGIN IMMEDIATE' : 'BEGIN');
|
|
226
232
|
this.transactionDepth += 1;
|
|
233
|
+
this.transactionWrote = mode === 'write';
|
|
227
234
|
let result;
|
|
228
235
|
try {
|
|
229
236
|
result = operation();
|
|
230
237
|
this.database.exec('COMMIT');
|
|
231
238
|
}
|
|
232
239
|
catch (error) {
|
|
240
|
+
const transactionWrote = this.transactionWrote;
|
|
233
241
|
rollback(this.database);
|
|
234
242
|
this.transactionDepth -= 1;
|
|
243
|
+
this.transactionWrote = false;
|
|
244
|
+
if (transactionWrote)
|
|
245
|
+
this.writeViewRevisionValue += 1;
|
|
235
246
|
this.settle(false);
|
|
236
247
|
throw error;
|
|
237
248
|
}
|
|
238
249
|
this.transactionDepth -= 1;
|
|
250
|
+
if (this.transactionWrote)
|
|
251
|
+
this.writeViewRevisionValue += 1;
|
|
252
|
+
this.transactionWrote = false;
|
|
239
253
|
this.settle(true);
|
|
240
254
|
return result;
|
|
241
255
|
}
|
|
@@ -53,6 +53,7 @@ export function observeInteractivePlanStoreWriter(source, onChanged, onPublicati
|
|
|
53
53
|
access: writer.access,
|
|
54
54
|
[writerBrand]: true,
|
|
55
55
|
readState: (sessionId) => writer.readState(sessionId),
|
|
56
|
+
listPlanRecoverySessionIds: () => writer.listPlanRecoverySessionIds(),
|
|
56
57
|
readOperationReceipt: (sessionId, operationId, operationInput) => writer.readOperationReceipt(sessionId, operationId, operationInput),
|
|
57
58
|
submitProposal: (input) => publish(input.sessionId, () => writer.submitProposal(input)),
|
|
58
59
|
requestRevision: (input) => publish(input.sessionId, () => writer.requestRevision(input)),
|
|
@@ -136,6 +137,7 @@ function createWriterFacade(lease, store) {
|
|
|
136
137
|
access: 'write',
|
|
137
138
|
[writerBrand]: true,
|
|
138
139
|
readState: (sessionId) => run(() => store.readState(sessionId)),
|
|
140
|
+
listPlanRecoverySessionIds: () => run(() => store.listPlanRecoverySessionIds()),
|
|
139
141
|
readOperationReceipt: (sessionId, operationId, operationInput) => run(() => store.readOperationReceipt(sessionId, operationId, structuredClone(operationInput))),
|
|
140
142
|
submitProposal: (input) => run(() => store.submitProposal(cloneSubmit(input))),
|
|
141
143
|
requestRevision: (input) => run(() => store.requestRevision(cloneInput(input))),
|
|
@@ -43,6 +43,36 @@ class SqlitePlanStoreImpl {
|
|
|
43
43
|
async readState(sessionId) {
|
|
44
44
|
return (await this.readLedger(sessionId)).state;
|
|
45
45
|
}
|
|
46
|
+
async listPlanRecoverySessionIds() {
|
|
47
|
+
const rows = this.#lease.database
|
|
48
|
+
.prepare(`
|
|
49
|
+
WITH lifecycle AS (
|
|
50
|
+
SELECT
|
|
51
|
+
session_id,
|
|
52
|
+
json_extract(record_json, '$.type') AS event_type,
|
|
53
|
+
ROW_NUMBER() OVER (PARTITION BY session_id ORDER BY sequence DESC) AS position
|
|
54
|
+
FROM workflow_plan_events
|
|
55
|
+
WHERE json_extract(record_json, '$.type') IN (
|
|
56
|
+
'plan_approved',
|
|
57
|
+
'plan_execution_completed',
|
|
58
|
+
'plan_execution_cancelled',
|
|
59
|
+
'plan_execution_interrupted',
|
|
60
|
+
'plan_execution_resumed'
|
|
61
|
+
)
|
|
62
|
+
)
|
|
63
|
+
SELECT session_id
|
|
64
|
+
FROM lifecycle
|
|
65
|
+
WHERE position = 1
|
|
66
|
+
AND event_type IN ('plan_approved', 'plan_execution_resumed')
|
|
67
|
+
ORDER BY session_id
|
|
68
|
+
`)
|
|
69
|
+
.all();
|
|
70
|
+
return rows.map((row) => {
|
|
71
|
+
if (typeof row.session_id !== 'string')
|
|
72
|
+
throw new Error('Invalid SQLite Plan row');
|
|
73
|
+
return row.session_id;
|
|
74
|
+
});
|
|
75
|
+
}
|
|
46
76
|
async readOperationReceipt(sessionId, operationId, operationInput) {
|
|
47
77
|
assertSafeId(sessionId);
|
|
48
78
|
assertSafeId(operationId);
|
|
@@ -40,6 +40,7 @@ export async function openRuntimeEventReadPersistence(input) {
|
|
|
40
40
|
kind: 'sqlite',
|
|
41
41
|
runtimeEventStore: Object.freeze({
|
|
42
42
|
listSessionInvocations: (sessionId) => store.listSessionInvocations(sessionId),
|
|
43
|
+
listInvocationRecoveryInventory: (sessionIds) => store.listInvocationRecoveryInventory(sessionIds),
|
|
43
44
|
readRunInvocation: (sessionId, runId) => store.readRunInvocation(sessionId, runId),
|
|
44
45
|
listSessionInvocationsBounded: (sessionId, limit) => store.listSessionInvocationsBounded(sessionId, limit),
|
|
45
46
|
listSessionInvocationsPage: (sessionId, input) => store.listSessionInvocationsPage(sessionId, input),
|
|
@@ -237,7 +237,8 @@ function sameLocator(left, right) {
|
|
|
237
237
|
if (left.scope === 'web_search' && right.scope === 'web_search') {
|
|
238
238
|
return left.provider === right.provider;
|
|
239
239
|
}
|
|
240
|
-
return left.scope === 'network_proxy' && right.scope === 'network_proxy'
|
|
240
|
+
return ((left.scope === 'network_proxy' && right.scope === 'network_proxy') ||
|
|
241
|
+
(left.scope === 'jev' && right.scope === 'jev'));
|
|
241
242
|
}
|
|
242
243
|
function locatorKey(locator) {
|
|
243
244
|
switch (locator.scope) {
|
|
@@ -245,6 +246,8 @@ function locatorKey(locator) {
|
|
|
245
246
|
return `connection:${locator.connectionId}:${locator.kind}`;
|
|
246
247
|
case 'web_search':
|
|
247
248
|
return `web_search:${locator.provider}:api_key`;
|
|
249
|
+
case 'jev':
|
|
250
|
+
return 'jev:api_key';
|
|
248
251
|
case 'network_proxy':
|
|
249
252
|
return 'network_proxy:password';
|
|
250
253
|
}
|