maka-agent 0.2.0-dev.26.20260909 → 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/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/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
- package/node_modules/@maka/core/dist/usage-stats/types.js +2 -0
- package/node_modules/@maka/core/dist/workhub-routing.js +126 -0
- package/node_modules/@maka/core/package.json +2 -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/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/session-export.js +177 -0
- package/node_modules/@maka/runtime/package.json +18 -0
- package/node_modules/@maka/runtime-host/dist/client/host-handoff-copy.js +67 -18
- package/node_modules/@maka/runtime-host/dist/client/host-handoff.js +46 -12
- package/node_modules/@maka/runtime-host/dist/operator/setup-frame.js +31 -21
- package/node_modules/@maka/runtime-host/dist/protocol/index.js +9 -1
- package/node_modules/@maka/runtime-host/dist/protocol/plugin-platform.js +30 -5
- package/node_modules/@maka/runtime-host/dist/protocol/workhub-coordination.js +25 -23
- package/node_modules/@maka/runtime-host/dist/server/client-capability-coordinator.js +62 -4
- package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +452 -7
- package/node_modules/@maka/runtime-host/dist/server/execution-model-authority.js +74 -0
- package/node_modules/@maka/runtime-host/dist/server/hosted-execution-recovery.js +2 -2
- package/node_modules/@maka/runtime-host/dist/server/hosted-execution-tool-profile.js +30 -0
- package/node_modules/@maka/runtime-host/dist/server/interactive-run-composer.js +79 -16
- package/node_modules/@maka/runtime-host/dist/server/message-coordinator.js +25 -4
- 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 +189 -92
- package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-action-gate.js +44 -35
- package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-coordinator.js +92 -10
- package/node_modules/@maka/storage/dist/agent-run-store.js +54 -10
- package/node_modules/@maka/storage/dist/context-offload-snapshot.js +13 -6
- package/node_modules/@maka/storage/dist/execution-stores.js +1 -1
- package/node_modules/@maka/storage/dist/session-bundle-policy.js +333 -30
- package/node_modules/@maka/storage/dist/session-store.js +2 -2
- package/node_modules/@maka/storage/dist/sqlite-session-metadata-store.js +12 -5
- package/node_modules/@maka/storage/package.json +2 -0
- package/package.json +1 -1
|
@@ -108,7 +108,7 @@ export const PLUGIN_PLATFORM_OPERATION_SPECS = {
|
|
|
108
108
|
};
|
|
109
109
|
function decodePluginPlatformQueryInput(value) {
|
|
110
110
|
const input = requireShapedRecord(value, 'Plugin Platform query input', ['view'], ['rootId', 'cursor', 'limit']);
|
|
111
|
-
if (!['status', 'packages', 'entries', 'tools', 'failures'].includes(input.view)) {
|
|
111
|
+
if (!['status', 'packages', 'entries', 'tools', 'commands', 'failures'].includes(input.view)) {
|
|
112
112
|
throw invalidProtocolFrame('Invalid Plugin Platform query view');
|
|
113
113
|
}
|
|
114
114
|
const view = input.view;
|
|
@@ -125,8 +125,8 @@ function decodePluginPlatformQueryInput(value) {
|
|
|
125
125
|
(input.rootId !== undefined || cursor !== undefined || limit !== undefined)) {
|
|
126
126
|
throw invalidProtocolFrame('Plugin Platform status query does not accept paging');
|
|
127
127
|
}
|
|
128
|
-
if (input.rootId !== undefined && view !== 'entries' && view !== 'tools') {
|
|
129
|
-
throw invalidProtocolFrame('Plugin root identity is only valid for Entry and
|
|
128
|
+
if (input.rootId !== undefined && view !== 'entries' && view !== 'tools' && view !== 'commands') {
|
|
129
|
+
throw invalidProtocolFrame('Plugin root identity is only valid for Entry, Tool, and Command queries');
|
|
130
130
|
}
|
|
131
131
|
let rootId;
|
|
132
132
|
if (input.rootId !== undefined) {
|
|
@@ -190,7 +190,7 @@ function decodePluginPlatformQueryResult(value) {
|
|
|
190
190
|
]);
|
|
191
191
|
if (!Array.isArray(output.items) ||
|
|
192
192
|
output.items.length > 64 ||
|
|
193
|
-
!['packages', 'entries', 'tools', 'failures'].includes(view)) {
|
|
193
|
+
!['packages', 'entries', 'tools', 'commands', 'failures'].includes(view)) {
|
|
194
194
|
throw invalidProtocolFrame('Invalid Plugin Platform page');
|
|
195
195
|
}
|
|
196
196
|
const nextCursor = output.nextCursor === null
|
|
@@ -203,11 +203,36 @@ function decodePluginPlatformQueryResult(value) {
|
|
|
203
203
|
? { view, items: decodeInspections(output.items), nextCursor }
|
|
204
204
|
: view === 'tools'
|
|
205
205
|
? { view, items: output.items.map(decodeToolInspection), nextCursor }
|
|
206
|
-
:
|
|
206
|
+
: view === 'commands'
|
|
207
|
+
? { view, items: output.items.map(decodeCommandInspection), nextCursor }
|
|
208
|
+
: { view: 'failures', items: output.items.map(decodePlatformFailure), nextCursor };
|
|
207
209
|
}
|
|
208
210
|
requireEncodedByteLimit(decoded, 'Plugin Platform query result', PLUGIN_PLATFORM_QUERY_RESULT_MAX_BYTES);
|
|
209
211
|
return decoded;
|
|
210
212
|
}
|
|
213
|
+
function decodeCommandInspection(value) {
|
|
214
|
+
const item = requireExactRecord(value, 'Plugin Command inspection', [
|
|
215
|
+
'entryId',
|
|
216
|
+
'scopeId',
|
|
217
|
+
'extensionId',
|
|
218
|
+
'generation',
|
|
219
|
+
'name',
|
|
220
|
+
'description',
|
|
221
|
+
'aliases',
|
|
222
|
+
]);
|
|
223
|
+
if (!Array.isArray(item.aliases) || item.aliases.length > 64) {
|
|
224
|
+
throw invalidProtocolFrame('Invalid Plugin Command aliases');
|
|
225
|
+
}
|
|
226
|
+
return {
|
|
227
|
+
entryId: requireId(item.entryId, 'Plugin Entry identity'),
|
|
228
|
+
scopeId: requireString(item.scopeId, 'Plugin scope identity', 256),
|
|
229
|
+
extensionId: requireId(item.extensionId, 'Plugin package identity'),
|
|
230
|
+
generation: requireCount(item.generation, 'Plugin generation'),
|
|
231
|
+
name: requireString(item.name, 'Plugin Command name', 128),
|
|
232
|
+
description: requireString(item.description, 'Plugin Command description', 4096),
|
|
233
|
+
aliases: item.aliases.map((alias) => requireString(alias, 'Plugin Command alias', 128)),
|
|
234
|
+
};
|
|
235
|
+
}
|
|
211
236
|
function decodePlatformFailure(value) {
|
|
212
237
|
const failure = requireShapedRecord(value, 'Plugin Platform failure', ['diagnostic'], ['entryId', 'extensionId']);
|
|
213
238
|
if (failure.entryId === undefined && failure.extensionId === undefined) {
|
|
@@ -182,8 +182,10 @@ function decodeWorkHubCoordinationActionFields(input) {
|
|
|
182
182
|
const proposal = decodeWorkHubCoordinationProposal(input.proposal);
|
|
183
183
|
if (input.newWorkDefaults !== undefined &&
|
|
184
184
|
(!isWorkHubCreateDefaults(input.newWorkDefaults) ||
|
|
185
|
-
!(proposal.disposition === 'create_new' ||
|
|
186
|
-
(
|
|
185
|
+
!(('disposition' in proposal && proposal.disposition === 'create_new') ||
|
|
186
|
+
('operation' in proposal &&
|
|
187
|
+
proposal.operation === 'correct' &&
|
|
188
|
+
proposal.target.disposition === 'create_new')))) {
|
|
187
189
|
throw invalidProtocolFrame('Invalid WorkHub creation defaults');
|
|
188
190
|
}
|
|
189
191
|
const delegationText = input.delegationText === undefined
|
|
@@ -191,9 +193,7 @@ function decodeWorkHubCoordinationActionFields(input) {
|
|
|
191
193
|
: requireUtf8String(input.delegationText, 'WorkHub delegation text', WORKHUB_COORDINATION_TEXT_MAX_BYTES);
|
|
192
194
|
if (delegationText !== undefined &&
|
|
193
195
|
(!delegationText.trim() ||
|
|
194
|
-
(proposal.
|
|
195
|
-
proposal.disposition !== 'create_new' &&
|
|
196
|
-
proposal.disposition !== 'replace'))) {
|
|
196
|
+
!('disposition' in proposal || ('operation' in proposal && proposal.operation === 'correct')))) {
|
|
197
197
|
throw invalidProtocolFrame('Invalid WorkHub delegation text');
|
|
198
198
|
}
|
|
199
199
|
const base = {
|
|
@@ -204,19 +204,19 @@ function decodeWorkHubCoordinationActionFields(input) {
|
|
|
204
204
|
: {}),
|
|
205
205
|
...(delegationText === undefined ? {} : { delegationText }),
|
|
206
206
|
};
|
|
207
|
-
if (proposal.disposition === 'delegate_existing') {
|
|
207
|
+
if ('disposition' in proposal && proposal.disposition === 'delegate_existing') {
|
|
208
208
|
if (input.create !== undefined || input.candidateSetId === undefined) {
|
|
209
209
|
throw invalidProtocolFrame('Invalid WorkHub delegation context');
|
|
210
210
|
}
|
|
211
211
|
return { ...base, candidateSetId: candidateSetId(input.candidateSetId) };
|
|
212
212
|
}
|
|
213
|
-
if (proposal.disposition === 'create_new') {
|
|
213
|
+
if ('disposition' in proposal && proposal.disposition === 'create_new') {
|
|
214
214
|
if (input.candidateSetId !== undefined || input.create === undefined) {
|
|
215
215
|
throw invalidProtocolFrame('Invalid WorkHub creation context');
|
|
216
216
|
}
|
|
217
217
|
return { ...base, create: decodeWorkHubCoordinationCreateContext(input.create) };
|
|
218
218
|
}
|
|
219
|
-
if (proposal.
|
|
219
|
+
if ('operation' in proposal && proposal.operation === 'correct') {
|
|
220
220
|
if (proposal.target.disposition === 'delegate_existing') {
|
|
221
221
|
if (input.candidateSetId === undefined || input.create !== undefined) {
|
|
222
222
|
throw invalidProtocolFrame('Invalid WorkHub replacement context');
|
|
@@ -285,9 +285,9 @@ function decodeWorkHubCoordinationProposal(value) {
|
|
|
285
285
|
title: requireUtf8String(exact.title, 'WorkHub Session title', COORDINATION_TITLE_MAX_BYTES),
|
|
286
286
|
};
|
|
287
287
|
}
|
|
288
|
-
if (proposal.
|
|
288
|
+
if (proposal.operation === 'correct') {
|
|
289
289
|
const exact = requireExactRecord(proposal, 'WorkHub replacement proposal', [
|
|
290
|
-
'
|
|
290
|
+
'operation',
|
|
291
291
|
'replacesActionId',
|
|
292
292
|
'target',
|
|
293
293
|
]);
|
|
@@ -298,7 +298,7 @@ function decodeWorkHubCoordinationProposal(value) {
|
|
|
298
298
|
'candidateRef',
|
|
299
299
|
]);
|
|
300
300
|
return {
|
|
301
|
-
|
|
301
|
+
operation: 'correct',
|
|
302
302
|
replacesActionId: requireEntityId(exact.replacesActionId, 'WorkHub replaced action id'),
|
|
303
303
|
target: {
|
|
304
304
|
disposition: 'delegate_existing',
|
|
@@ -312,7 +312,7 @@ function decodeWorkHubCoordinationProposal(value) {
|
|
|
312
312
|
'title',
|
|
313
313
|
]);
|
|
314
314
|
return {
|
|
315
|
-
|
|
315
|
+
operation: 'correct',
|
|
316
316
|
replacesActionId: requireEntityId(exact.replacesActionId, 'WorkHub replaced action id'),
|
|
317
317
|
target: {
|
|
318
318
|
disposition: 'create_new',
|
|
@@ -322,29 +322,31 @@ function decodeWorkHubCoordinationProposal(value) {
|
|
|
322
322
|
}
|
|
323
323
|
throw invalidProtocolFrame('Invalid WorkHub replacement target');
|
|
324
324
|
}
|
|
325
|
-
if (proposal.
|
|
326
|
-
const exact = requireExactRecord(proposal, 'WorkHub stop proposal', ['
|
|
325
|
+
if (proposal.operation === 'stop') {
|
|
326
|
+
const exact = requireExactRecord(proposal, 'WorkHub stop proposal', ['operation', 'expects']);
|
|
327
327
|
return {
|
|
328
|
-
|
|
329
|
-
expects:
|
|
328
|
+
operation: 'stop',
|
|
329
|
+
expects: decodeWorkHubCoordinationLinkedTargetPreconditions(exact.expects),
|
|
330
330
|
};
|
|
331
331
|
}
|
|
332
|
-
if (proposal.
|
|
332
|
+
if (proposal.operation === 'resume') {
|
|
333
333
|
const exact = requireExactRecord(proposal, 'WorkHub resume proposal', [
|
|
334
|
-
'
|
|
334
|
+
'operation',
|
|
335
335
|
'expects',
|
|
336
336
|
'resumesActionId',
|
|
337
337
|
]);
|
|
338
338
|
return {
|
|
339
|
-
|
|
339
|
+
operation: 'resume',
|
|
340
340
|
resumesActionId: requireEntityId(exact.resumesActionId, 'WorkHub resume assignment'),
|
|
341
|
-
expects:
|
|
341
|
+
expects: decodeWorkHubCoordinationLinkedTargetPreconditions(exact.expects),
|
|
342
342
|
};
|
|
343
343
|
}
|
|
344
|
-
throw invalidProtocolFrame('Invalid WorkHub Coordination proposal
|
|
344
|
+
throw invalidProtocolFrame('Invalid WorkHub Coordination proposal');
|
|
345
345
|
}
|
|
346
|
-
function
|
|
347
|
-
const expects = requireExactRecord(value, 'WorkHub
|
|
346
|
+
function decodeWorkHubCoordinationLinkedTargetPreconditions(value) {
|
|
347
|
+
const expects = requireExactRecord(value, 'WorkHub linked-target preconditions', [
|
|
348
|
+
'targetSessionId',
|
|
349
|
+
]);
|
|
348
350
|
return {
|
|
349
351
|
targetSessionId: requireEntityId(expects.targetSessionId, 'WorkHub target Session id'),
|
|
350
352
|
};
|
|
@@ -101,8 +101,8 @@ export class HostClientCapabilityCoordinator {
|
|
|
101
101
|
},
|
|
102
102
|
};
|
|
103
103
|
}
|
|
104
|
-
async bindSession(sessionId, initiatingConnectionId) {
|
|
105
|
-
return this.#bindSession(sessionId, initiatingConnectionId, 'strict');
|
|
104
|
+
async bindSession(sessionId, initiatingConnectionId, requiredToolNames) {
|
|
105
|
+
return this.#bindSession(sessionId, initiatingConnectionId, 'strict', requiredToolNames);
|
|
106
106
|
}
|
|
107
107
|
async bindSessionSuccessor(sessionId) {
|
|
108
108
|
const result = await this.#bindSession(sessionId, '', 'degrade');
|
|
@@ -129,17 +129,61 @@ export class HostClientCapabilityCoordinator {
|
|
|
129
129
|
this.#onModelToolsChanged();
|
|
130
130
|
});
|
|
131
131
|
}
|
|
132
|
-
async #bindSession(sessionId, initiatingConnectionId, mode) {
|
|
132
|
+
async #bindSession(sessionId, initiatingConnectionId, mode, requiredToolNames) {
|
|
133
133
|
return this.#activation.runMutation(async () => {
|
|
134
134
|
const selection = this.#selectSessionState(sessionId, initiatingConnectionId, mode);
|
|
135
135
|
if (!selection.ok)
|
|
136
136
|
return selection;
|
|
137
|
+
const capabilityBinding = requiredToolNames
|
|
138
|
+
? this.#toolProviderBinding(selection.state, requiredToolNames)
|
|
139
|
+
: undefined;
|
|
140
|
+
if (requiredToolNames && !capabilityBinding) {
|
|
141
|
+
return {
|
|
142
|
+
ok: false,
|
|
143
|
+
message: 'Required Client Capability tools do not have one available provider',
|
|
144
|
+
};
|
|
145
|
+
}
|
|
137
146
|
this.#storeSessionState(sessionId, selection.state);
|
|
138
147
|
if (selection.modelToolsChanged)
|
|
139
148
|
this.#onModelToolsChanged();
|
|
140
|
-
return { ok: true };
|
|
149
|
+
return { ok: true, ...(capabilityBinding ? { capabilityBinding } : {}) };
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
async bindRecoveredSession(sessionId, binding, toolNames) {
|
|
153
|
+
return this.#activation.runMutation(() => {
|
|
154
|
+
const provider = [...this.#providers.values()].find((candidate) => providerAuthorityDigest(candidate) === binding && this.#activeConnection(candidate));
|
|
155
|
+
if (!provider)
|
|
156
|
+
return false;
|
|
157
|
+
const connection = this.#activeConnection(provider);
|
|
158
|
+
const selection = this.#selectSessionState(sessionId, connection.connectionId, 'strict');
|
|
159
|
+
if (!selection.ok || this.#toolProviderBinding(selection.state, toolNames) !== binding)
|
|
160
|
+
return false;
|
|
161
|
+
this.#storeSessionState(sessionId, selection.state);
|
|
162
|
+
if (selection.modelToolsChanged)
|
|
163
|
+
this.#onModelToolsChanged();
|
|
164
|
+
return true;
|
|
141
165
|
});
|
|
142
166
|
}
|
|
167
|
+
#toolProviderBinding(state, toolNames) {
|
|
168
|
+
const missing = new Set(toolNames);
|
|
169
|
+
let selected;
|
|
170
|
+
for (const [contractId, binding] of state?.sessionBindings ?? []) {
|
|
171
|
+
if (binding.kind !== 'bound')
|
|
172
|
+
continue;
|
|
173
|
+
const provider = this.#providers.get(binding.providerId);
|
|
174
|
+
const offer = provider?.current?.offersByContract.get(contractId);
|
|
175
|
+
if (!provider || !this.#activeConnection(provider) || !offer)
|
|
176
|
+
continue;
|
|
177
|
+
for (const tool of offer.offer.tools) {
|
|
178
|
+
if (!missing.delete(mcpProxyToolName(tool.serverId, tool.name)))
|
|
179
|
+
continue;
|
|
180
|
+
if (selected && selected !== provider)
|
|
181
|
+
return undefined;
|
|
182
|
+
selected = provider;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return selected && missing.size === 0 ? providerAuthorityDigest(selected) : undefined;
|
|
186
|
+
}
|
|
143
187
|
async runWithSessionBindingPreview(sessionId, initiatingConnectionId, operation) {
|
|
144
188
|
return this.#activation.runReadActivation(async () => {
|
|
145
189
|
const registryRevision = this.#revision;
|
|
@@ -1274,3 +1318,17 @@ function sessionCapabilityStatesEqual(left, right) {
|
|
|
1274
1318
|
function asError(value) {
|
|
1275
1319
|
return value instanceof Error ? value : new Error(String(value));
|
|
1276
1320
|
}
|
|
1321
|
+
/** Registration IDs and connections rotate; authenticated provider authority must not. */
|
|
1322
|
+
function providerAuthorityDigest(provider) {
|
|
1323
|
+
return `sha256:${createHash('sha256')
|
|
1324
|
+
.update(JSON.stringify([
|
|
1325
|
+
'maka.client-capability-authority.v1',
|
|
1326
|
+
provider.principalKind,
|
|
1327
|
+
provider.principalId,
|
|
1328
|
+
provider.clientInstanceId,
|
|
1329
|
+
provider.credentialBoundClientInstanceId ?? null,
|
|
1330
|
+
provider.capabilityOwner?.principalId ?? null,
|
|
1331
|
+
provider.capabilityOwner?.clientInstanceId ?? null,
|
|
1332
|
+
]))
|
|
1333
|
+
.digest('hex')}`;
|
|
1334
|
+
}
|