maka-agent 0.2.0-dev.43.20260919 → 0.2.0-dev.45.20260921

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.
Files changed (89) hide show
  1. package/LICENSE +12 -6
  2. package/dist/mcp-capability-provider.js +7 -0
  3. package/dist/runtime-host-service-manager.js +1 -6
  4. package/dist/runtime-host-tui-command.js +1 -1
  5. package/dist/runtime-host-update-command.js +39 -27
  6. package/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
  7. package/node_modules/@maka/core/dist/artifacts.js +1 -0
  8. package/node_modules/@maka/core/dist/chat-model-choice.js +3 -0
  9. package/node_modules/@maka/core/dist/llm-connections.js +3 -21
  10. package/node_modules/@maka/core/dist/model-catalog.js +8 -20
  11. package/node_modules/@maka/core/dist/model-metadata.generated.js +304 -304
  12. package/node_modules/@maka/core/dist/model-metadata.js +1 -2
  13. package/node_modules/@maka/core/dist/model-thinking.js +16 -1
  14. package/node_modules/@maka/core/dist/models-dev-projection.js +0 -1
  15. package/node_modules/@maka/core/dist/provider-auth.js +1 -7
  16. package/node_modules/@maka/core/dist/provider-registry.js +20 -58
  17. package/node_modules/@maka/core/dist/recall.js +5 -1
  18. package/node_modules/@maka/core/dist/runtime-policy/connection-catalog-codec.js +7 -0
  19. package/node_modules/@maka/core/dist/runtime-policy/model-catalog-entry-codec.js +14 -1
  20. package/node_modules/@maka/core/dist/session-start-mode.js +2 -5
  21. package/node_modules/@maka/core/dist/session.js +0 -1
  22. package/node_modules/@maka/core/dist/settings.js +19 -3
  23. package/node_modules/@maka/core/dist/tool-quiet-preview.js +2 -16
  24. package/node_modules/@maka/core/dist/transcript-search.js +46 -0
  25. package/node_modules/@maka/core/package.json +1 -4
  26. package/node_modules/@maka/mcp/dist/index.js +22 -0
  27. package/node_modules/@maka/mcp/dist/oauth.js +4 -2
  28. package/node_modules/@maka/mcp/dist/tool-progress.js +45 -0
  29. package/node_modules/@maka/runtime/dist/model-factory.js +0 -16
  30. package/node_modules/@maka/runtime/dist/model-fetcher.js +1 -4
  31. package/node_modules/@maka/runtime/dist/model-runtime.js +0 -8
  32. package/node_modules/@maka/runtime/dist/opencode-session-header.js +2 -3
  33. package/node_modules/@maka/runtime/dist/recall-tools.js +4 -0
  34. package/node_modules/@maka/runtime/dist/session-manager.js +5 -57
  35. package/node_modules/@maka/runtime/dist/subagent-tools.js +69 -11
  36. package/node_modules/@maka/runtime/dist/test-connection.js +4 -114
  37. package/node_modules/@maka/runtime/package.json +0 -1
  38. package/node_modules/@maka/runtime-host/dist/client/client-capability-channel.js +44 -9
  39. package/node_modules/@maka/runtime-host/dist/client/host-handoff-copy.js +25 -18
  40. package/node_modules/@maka/runtime-host/dist/client/host-handoff.js +3 -1
  41. package/node_modules/@maka/runtime-host/dist/client/index.js +1 -1
  42. package/node_modules/@maka/runtime-host/dist/client/session-subscription.js +33 -3
  43. package/node_modules/@maka/runtime-host/dist/protocol/connection-effects.js +0 -108
  44. package/node_modules/@maka/runtime-host/dist/protocol/index.js +12 -1
  45. package/node_modules/@maka/runtime-host/dist/protocol/message.js +10 -0
  46. package/node_modules/@maka/runtime-host/dist/protocol/operations.js +4 -6
  47. package/node_modules/@maka/runtime-host/dist/protocol/recall.js +270 -0
  48. package/node_modules/@maka/runtime-host/dist/protocol/session-catalog.js +1 -1
  49. package/node_modules/@maka/runtime-host/dist/protocol/session-continuity.js +1 -7
  50. package/node_modules/@maka/runtime-host/dist/protocol/turn.js +0 -33
  51. package/node_modules/@maka/runtime-host/dist/protocol/usage-screen.js +12 -4
  52. package/node_modules/@maka/runtime-host/dist/server/access-credential-store.js +6 -0
  53. package/node_modules/@maka/runtime-host/dist/server/bootstrap-runtime-policy.js +31 -104
  54. package/node_modules/@maka/runtime-host/dist/server/connection-effect-coordinator.js +1 -57
  55. package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +11 -35
  56. package/node_modules/@maka/runtime-host/dist/server/interactive-run-composer.js +3 -20
  57. package/node_modules/@maka/runtime-host/dist/server/interactive-turn-coordinator.js +1 -16
  58. package/node_modules/@maka/runtime-host/dist/server/message-coordinator.js +46 -28
  59. package/node_modules/@maka/runtime-host/dist/server/recall-coordinator.js +117 -0
  60. package/node_modules/@maka/runtime-host/dist/server/root-turn-coordinator.js +5 -16
  61. package/node_modules/@maka/runtime-host/dist/server/session-catalog-coordinator.js +21 -12
  62. package/node_modules/@maka/runtime-host/dist/server/session-revision-coordinator.js +0 -4
  63. package/node_modules/@maka/runtime-host/dist/server/session-turn-access-request-coordinator.js +7 -17
  64. package/node_modules/@maka/storage/dist/artifact-metadata-codec.js +4 -3
  65. package/node_modules/@maka/storage/dist/artifact-store.js +1 -11
  66. package/node_modules/@maka/storage/dist/process-lifetime-file-update-lock.js +0 -41
  67. package/node_modules/@maka/storage/dist/runtime-policy/connection-catalog-document.js +0 -62
  68. package/node_modules/@maka/storage/dist/runtime-policy/coordinator.js +0 -31
  69. package/node_modules/@maka/storage/dist/runtime-policy-stores.js +0 -3
  70. package/node_modules/@maka/storage/dist/sqlite-usage-schema.js +29 -5
  71. package/node_modules/@maka/storage/dist/sqlite-workflow-schema.js +2 -0
  72. package/node_modules/@maka/storage/dist/storage-writer-composition.js +0 -3
  73. package/node_modules/@maka/storage/dist/telemetry-file-schema.js +5 -3
  74. package/node_modules/@maka/storage/dist/usage-screen.js +5 -6
  75. package/node_modules/@maka/storage/dist/usage-stores.js +14 -4
  76. package/node_modules/@maka/storage/package.json +0 -2
  77. package/package.json +1 -1
  78. package/node_modules/@maka/core/dist/connection-usage.js +0 -27
  79. package/node_modules/@maka/core/dist/deep-research-client-progress.js +0 -132
  80. package/node_modules/@maka/core/dist/deep-research-run.js +0 -625
  81. package/node_modules/@maka/core/dist/deep-research.js +0 -208
  82. package/node_modules/@maka/core/dist/thread-search.js +0 -498
  83. package/node_modules/@maka/runtime/dist/commandcode-cli-language-model.js +0 -837
  84. package/node_modules/@maka/runtime/dist/connection-usage.js +0 -232
  85. package/node_modules/@maka/runtime/dist/deep-research-tools.js +0 -732
  86. package/node_modules/@maka/runtime-host/dist/protocol/deep-research.js +0 -233
  87. package/node_modules/@maka/runtime-host/dist/server/deep-research-coordinator.js +0 -116
  88. package/node_modules/@maka/storage/dist/deep-research-authority.js +0 -129
  89. package/node_modules/@maka/storage/dist/deep-research-store.js +0 -343
@@ -1,343 +0,0 @@
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 { randomUUID } from 'node:crypto';
20
- import { resolve } from 'node:path';
21
- import { isDeepResearchEvent, isDeepResearchScopeLevel, normalizeDeepResearchObjective, projectDeepResearchEvents, } from '@maka/core/deep-research-run';
22
- import { assertSafeSessionId } from './session-store.js';
23
- import { chainWrite } from './write-queue.js';
24
- import { acquireOperationalStateDatabase, } from './operational-state-store.js';
25
- export function createSqliteDeepResearchStore(workspaceRoot, options = {}) {
26
- return new SqliteDeepResearchStoreImpl(workspaceRoot, options.newId ?? randomUUID, options.now ?? Date.now);
27
- }
28
- class SqliteDeepResearchStoreImpl {
29
- newId;
30
- now;
31
- #lease;
32
- writeQueues = new Map();
33
- subscribers = new Set();
34
- constructor(workspaceRoot, newId, now) {
35
- this.newId = newId;
36
- this.now = now;
37
- this.#lease = acquireOperationalStateDatabase(resolve(workspaceRoot));
38
- }
39
- ready() {
40
- return Promise.resolve();
41
- }
42
- close() {
43
- this.#lease.close();
44
- }
45
- async read(sessionId) {
46
- const events = await this.readEvents(sessionId);
47
- return this.project(events);
48
- }
49
- async readEvents(sessionId) {
50
- assertSafeSessionId(sessionId);
51
- return readSqliteDeepResearchEvents(this.#lease.database, sessionId);
52
- }
53
- async purgeSessionState(sessionId) {
54
- assertSafeSessionId(sessionId);
55
- await chainWrite(this.writeQueues, sessionId, async () => {
56
- this.#lease.transaction('write', () => {
57
- this.#lease.database
58
- .prepare('DELETE FROM workflow_deep_research_events WHERE session_id = ?')
59
- .run(sessionId);
60
- });
61
- });
62
- }
63
- subscribe(listener) {
64
- this.subscribers.add(listener);
65
- return () => this.subscribers.delete(listener);
66
- }
67
- async start(sessionId, objective, scopeLevel, context = {}) {
68
- const normalized = normalizeDeepResearchObjective(objective);
69
- if (!normalized)
70
- throw new Error('Deep Research objective must be a non-empty bounded string');
71
- if (!isDeepResearchScopeLevel(scopeLevel))
72
- throw new Error('Invalid Deep Research scope level');
73
- return this.mutate(sessionId, 'research_started', context, (events) => {
74
- if (events.length > 0)
75
- throw new Error('Deep Research workspace is already initialized');
76
- const ts = this.now();
77
- return {
78
- eventId: this.newId(),
79
- type: 'research_started',
80
- sessionId,
81
- ts,
82
- objective: normalized,
83
- scopeLevel,
84
- ...refsFromContext(context),
85
- };
86
- }, (event) => event.type === 'research_started' &&
87
- event.objective === normalized &&
88
- event.scopeLevel === scopeLevel);
89
- }
90
- async recordArtifact(sessionId, artifact, context = {}) {
91
- return this.mutate(sessionId, 'research_artifact_recorded', context, () => ({
92
- eventId: this.newId(),
93
- type: 'research_artifact_recorded',
94
- sessionId,
95
- ts: this.now(),
96
- artifact: {
97
- ...artifact,
98
- sourceArtifactIds: [...artifact.sourceArtifactIds],
99
- },
100
- ...refsFromContext(context),
101
- }), (event) => event.type === 'research_artifact_recorded' && sameArtifact(event.artifact, artifact));
102
- }
103
- async updateChecklist(sessionId, item, context = {}) {
104
- return this.mutate(sessionId, 'research_checklist_updated', context, (events) => {
105
- const run = this.project(events);
106
- const current = run?.checklist.find((candidate) => candidate.itemId === item.itemId);
107
- if (!current)
108
- throw new Error(`Unknown Deep Research checklist item ${item.itemId}`);
109
- return {
110
- eventId: this.newId(),
111
- type: 'research_checklist_updated',
112
- sessionId,
113
- ts: this.now(),
114
- item: {
115
- ...item,
116
- title: current.title,
117
- evidenceArtifactIds: [...item.evidenceArtifactIds],
118
- updatedAt: this.now(),
119
- },
120
- ...refsFromContext(context),
121
- };
122
- }, (event) => event.type === 'research_checklist_updated' &&
123
- event.item.itemId === item.itemId &&
124
- event.item.status === item.status &&
125
- event.item.blockedReason === item.blockedReason &&
126
- sameStrings(event.item.evidenceArtifactIds, item.evidenceArtifactIds));
127
- }
128
- async recordStep(sessionId, step, context = {}) {
129
- return this.mutate(sessionId, 'research_step_recorded', context, () => ({
130
- eventId: this.newId(),
131
- type: 'research_step_recorded',
132
- sessionId,
133
- ts: this.now(),
134
- step: {
135
- ...step,
136
- stepId: this.newId(),
137
- roots: [...step.roots],
138
- keywords: [...step.keywords],
139
- ignoredPaths: [...step.ignoredPaths],
140
- evidenceArtifactIds: [...step.evidenceArtifactIds],
141
- inspectedRefs: step.inspectedRefs.map((ref) => ({ ...ref })),
142
- workerRunIds: [...step.workerRunIds],
143
- createdAt: this.now(),
144
- },
145
- ...refsFromContext(context),
146
- }), (event) => event.type === 'research_step_recorded' && sameStep(event.step, step));
147
- }
148
- async recordCheckpoint(sessionId, checkpoint, context = {}) {
149
- return this.mutate(sessionId, 'research_checkpoint_recorded', context, () => ({
150
- eventId: this.newId(),
151
- type: 'research_checkpoint_recorded',
152
- sessionId,
153
- ts: this.now(),
154
- checkpoint: {
155
- ...checkpoint,
156
- checkpointId: this.newId(),
157
- createdAt: this.now(),
158
- openQuestions: [...checkpoint.openQuestions],
159
- nextSteps: [...checkpoint.nextSteps],
160
- taskIds: [...checkpoint.taskIds],
161
- artifactIds: [...checkpoint.artifactIds],
162
- },
163
- ...refsFromContext(context),
164
- }), (event) => event.type === 'research_checkpoint_recorded' &&
165
- sameCheckpoint(event.checkpoint, checkpoint));
166
- }
167
- async complete(sessionId, reportArtifactId, handoff, context = {}) {
168
- return this.mutate(sessionId, 'research_completed', context, () => ({
169
- eventId: this.newId(),
170
- type: 'research_completed',
171
- sessionId,
172
- ts: this.now(),
173
- reportArtifactId,
174
- handoff: {
175
- ...handoff,
176
- implementationTasks: [...handoff.implementationTasks],
177
- recommendedIssues: [...handoff.recommendedIssues],
178
- recommendedPullRequests: [...handoff.recommendedPullRequests],
179
- verificationCommands: [...handoff.verificationCommands],
180
- },
181
- ...refsFromContext(context),
182
- }), (event) => event.type === 'research_completed' &&
183
- event.reportArtifactId === reportArtifactId &&
184
- sameHandoff(event.handoff, handoff));
185
- }
186
- async mutate(sessionId, expectedType, context, buildEvent, replayMatches) {
187
- assertSafeSessionId(sessionId);
188
- let nextRun;
189
- await chainWrite(this.writeQueues, sessionId, async () => {
190
- const current = await this.readEvents(sessionId);
191
- if (context.toolCallId) {
192
- const replay = current.find((event) => event.refs?.toolCallId === context.toolCallId);
193
- if (replay) {
194
- if (replay.type !== expectedType) {
195
- throw new Error(`Deep Research tool call ${context.toolCallId} was already used for ${replay.type}`);
196
- }
197
- if (replayMatches && !replayMatches(replay)) {
198
- throw new Error(`Deep Research tool call ${context.toolCallId} was retried with different input`);
199
- }
200
- nextRun = this.project(current);
201
- return;
202
- }
203
- }
204
- const event = buildEvent(current);
205
- if (!isDeepResearchEvent(event)) {
206
- throw new Error('Invalid Deep Research mutation event');
207
- }
208
- const next = projectDeepResearchEvents([...current, event]);
209
- if (next.diagnostics.length > 0 || !next.run) {
210
- throw new Error(`Deep Research mutation rejected: ${next.diagnostics.join('; ') || 'missing run projection'}`);
211
- }
212
- await this.appendEvent(sessionId, event);
213
- nextRun = next.run;
214
- const changed = { sessionId, ts: event.ts };
215
- for (const subscriber of this.subscribers) {
216
- try {
217
- subscriber(changed);
218
- }
219
- catch {
220
- // Durable mutation success must not depend on a best-effort UI subscriber.
221
- }
222
- }
223
- });
224
- if (!nextRun)
225
- throw new Error('Deep Research mutation did not produce a run');
226
- return nextRun;
227
- }
228
- project(events) {
229
- const projection = projectDeepResearchEvents(events);
230
- if (projection.diagnostics.length > 0) {
231
- throw new Error(`Deep Research ledger projection failed: ${projection.diagnostics.join('; ')}`);
232
- }
233
- return projection.run;
234
- }
235
- async appendEvent(sessionId, event) {
236
- this.#lease.transaction('write', () => {
237
- insertDeepResearchEvent(this.#lease.database, sessionId, event);
238
- });
239
- }
240
- }
241
- function readSqliteDeepResearchEvents(database, sessionId) {
242
- assertSafeSessionId(sessionId);
243
- const rows = database
244
- .prepare(`
245
- SELECT record_json
246
- FROM workflow_deep_research_events
247
- WHERE session_id = ?
248
- ORDER BY sequence
249
- `)
250
- .all(sessionId);
251
- return rows.map((row, index) => {
252
- if (typeof row.record_json !== 'string') {
253
- throw new Error(`Invalid SQLite Deep Research event at sequence ${index}`);
254
- }
255
- const parsed = JSON.parse(row.record_json);
256
- if (!isDeepResearchEvent(parsed) || parsed.sessionId !== sessionId) {
257
- throw new Error(`Invalid SQLite Deep Research event at sequence ${index}`);
258
- }
259
- return parsed;
260
- });
261
- }
262
- function insertDeepResearchEvent(database, sessionId, event) {
263
- const row = database
264
- .prepare(`
265
- SELECT COALESCE(MAX(sequence), -1) + 1 AS sequence
266
- FROM workflow_deep_research_events
267
- WHERE session_id = ?
268
- `)
269
- .get(sessionId);
270
- if (typeof row.sequence !== 'number' || !Number.isSafeInteger(row.sequence)) {
271
- throw new Error('Invalid next Deep Research event sequence');
272
- }
273
- database
274
- .prepare(`
275
- INSERT INTO workflow_deep_research_events(
276
- session_id, sequence, event_id, record_json
277
- ) VALUES (?, ?, ?, ?)
278
- `)
279
- .run(sessionId, row.sequence, event.eventId, JSON.stringify(event));
280
- }
281
- function refsFromContext(context) {
282
- const refs = {
283
- ...(context.runId ? { runId: context.runId } : {}),
284
- ...(context.turnId ? { turnId: context.turnId } : {}),
285
- ...(context.toolCallId ? { toolCallId: context.toolCallId } : {}),
286
- };
287
- return Object.keys(refs).length > 0 ? { refs } : {};
288
- }
289
- function sameStrings(left, right) {
290
- return left.length === right.length && left.every((value, index) => value === right[index]);
291
- }
292
- function sameArtifact(left, right) {
293
- return (left.artifactId === right.artifactId &&
294
- left.role === right.role &&
295
- left.name === right.name &&
296
- left.summary === right.summary &&
297
- left.createdAt === right.createdAt &&
298
- left.locator === right.locator &&
299
- left.contentHash === right.contentHash &&
300
- left.reportSectionKey === right.reportSectionKey &&
301
- left.reportSectionStatus === right.reportSectionStatus &&
302
- sameStrings(left.sourceArtifactIds, right.sourceArtifactIds));
303
- }
304
- function sameStep(left, right) {
305
- return (left.kind === right.kind &&
306
- left.status === right.status &&
307
- left.objective === right.objective &&
308
- left.summary === right.summary &&
309
- left.stoppingCondition === right.stoppingCondition &&
310
- left.expectedEvidence === right.expectedEvidence &&
311
- left.blockedReason === right.blockedReason &&
312
- sameStrings(left.roots, right.roots) &&
313
- sameStrings(left.keywords, right.keywords) &&
314
- sameStrings(left.ignoredPaths, right.ignoredPaths) &&
315
- sameStrings(left.evidenceArtifactIds, right.evidenceArtifactIds) &&
316
- sameStrings(left.workerRunIds, right.workerRunIds) &&
317
- left.inspectedRefs.length === right.inspectedRefs.length &&
318
- left.inspectedRefs.every((ref, index) => {
319
- const candidate = right.inspectedRefs[index];
320
- return (candidate !== undefined &&
321
- ref.kind === candidate.kind &&
322
- ref.locator === candidate.locator &&
323
- ref.label === candidate.label &&
324
- ref.sourceArtifactId === candidate.sourceArtifactId);
325
- }));
326
- }
327
- function sameCheckpoint(left, right) {
328
- return (left.round === right.round &&
329
- left.stage === right.stage &&
330
- left.status === right.status &&
331
- left.summary === right.summary &&
332
- sameStrings(left.openQuestions, right.openQuestions) &&
333
- sameStrings(left.nextSteps, right.nextSteps) &&
334
- sameStrings(left.taskIds, right.taskIds) &&
335
- sameStrings(left.artifactIds, right.artifactIds));
336
- }
337
- function sameHandoff(left, right) {
338
- return (left.artifactId === right.artifactId &&
339
- sameStrings(left.implementationTasks, right.implementationTasks) &&
340
- sameStrings(left.recommendedIssues, right.recommendedIssues) &&
341
- sameStrings(left.recommendedPullRequests, right.recommendedPullRequests) &&
342
- sameStrings(left.verificationCommands, right.verificationCommands));
343
- }