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,232 +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 { providerReportsUsage } from '@maka/core/connection-usage';
20
- import { commandCodeCliHeaders } from './commandcode-cli-language-model.js';
21
- import { fetchForConnectionEffect } from './connection-effect-fetch.js';
22
- export async function fetchConnectionUsage(input) {
23
- if (!providerReportsUsage(input.providerType)) {
24
- return { kind: 'unavailable', reason: 'unsupported' };
25
- }
26
- switch (input.providerType) {
27
- case 'commandcode-go':
28
- return fetchCommandCodeGoUsage(input);
29
- // `commandcode` (the Provider-API plan) is deliberately NOT wired yet: its
30
- // usage lives behind the same `/alpha/*` endpoints, but only a GO-tier key
31
- // has been verified against them. Wiring it from inference alone could
32
- // mis-report a plan's windows, which is worse than showing nothing.
33
- default:
34
- return { kind: 'unavailable', reason: 'unsupported' };
35
- }
36
- }
37
- /**
38
- * Command Code's account endpoints, fetched together with per-endpoint
39
- * degradation: whichever endpoints answer, their facts land in the report, and
40
- * only a total failure (no credential, or nothing answered) becomes
41
- * `unavailable`.
42
- */
43
- async function fetchCommandCodeGoUsage(input) {
44
- if (!input.apiKey)
45
- return { kind: 'unavailable', reason: 'no-credential' };
46
- const base = (input.baseUrl ?? 'https://api.commandcode.ai').replace(/\/+$/u, '');
47
- const headers = commandCodeCliHeaders(input.apiKey, 'maka');
48
- const get = async (path) => {
49
- try {
50
- const response = await fetchForConnectionEffect(input.fetch, `${base}${path}`, { headers });
51
- if (!response.ok) {
52
- return { ok: false, unauthorized: response.status === 401 || response.status === 403 };
53
- }
54
- return {
55
- ok: true,
56
- body: (await response.readJson()),
57
- };
58
- }
59
- catch {
60
- return { ok: false, unauthorized: false };
61
- }
62
- };
63
- const [whoami, summary, credits, subscriptions] = await Promise.all([
64
- get('/alpha/whoami'),
65
- get('/alpha/usage/summary'),
66
- get('/alpha/billing/credits'),
67
- get('/alpha/billing/subscriptions'),
68
- ]);
69
- const endpoints = [whoami, summary, credits, subscriptions];
70
- const answered = endpoints.filter((endpoint) => endpoint.ok);
71
- const refused = endpoints.some((endpoint) => !endpoint.ok && endpoint.unauthorized);
72
- if (answered.length === 0) {
73
- // Every endpoint failed at once. If any rejection was an auth rejection, the
74
- // credential is the problem, not the network.
75
- return { kind: 'unavailable', reason: refused ? 'unauthorized' : 'network' };
76
- }
77
- // Some answered and some refused: a key that is valid but lacks a scope. The
78
- // read is reported (so the card shows what it has) with the refusal flagged, so
79
- // it can also say why the rest is missing — otherwise a partial report reads
80
- // as a complete one and the page cannot name the credential as the cause.
81
- const partiallyUnauthorized = refused;
82
- const body = (endpoint) => endpoint.body;
83
- const [whoamiBody, summaryBody, creditsBody, subscriptionsBody] = [
84
- whoami.ok ? body(whoami) : undefined,
85
- summary.ok ? body(summary) : undefined,
86
- credits.ok ? body(credits) : undefined,
87
- subscriptions.ok ? body(subscriptions) : undefined,
88
- ];
89
- const plan = subscriptionFacts(subscriptionsBody);
90
- const windowLimits = record(record(creditsBody)?.windowLimits);
91
- const windows = [];
92
- const fiveHour = parseWindow('fiveHour', windowLimits?.fiveHour);
93
- if (fiveHour)
94
- windows.push(fiveHour);
95
- const weekly = parseWindow('weekly', windowLimits?.weekly);
96
- if (weekly)
97
- windows.push(weekly);
98
- const monthly = parseMonthly(creditsBody, plan);
99
- if (monthly)
100
- windows.push(monthly);
101
- const stats = parseStats(summaryBody);
102
- const report = {
103
- ...(accountLabel(whoamiBody) !== undefined ? { accountLabel: accountLabel(whoamiBody) } : {}),
104
- ...(plan.name !== undefined ? { planLabel: plan.name } : {}),
105
- ...(stats !== undefined ? { stats } : {}),
106
- windows,
107
- ...(plan.periodEnd !== undefined ? { periodEnd: plan.periodEnd } : {}),
108
- ...(partiallyUnauthorized ? { partiallyUnauthorized: true } : {}),
109
- fetchedAt: Date.now(),
110
- };
111
- return { kind: 'report', report };
112
- }
113
- /**
114
- * `command-code` subscription plans and their monthly credit allowance. The
115
- * billing endpoint reports the monthly REMAINING balance, not the total, so the
116
- * monthly window's cap has to come from the plan — the same table the official
117
- * CLI resolves `getPlanInfo` from. Longest-prefix match so `individual-pro-v1`
118
- * wins over `individual-pro`.
119
- */
120
- const SUBSCRIPTION_PLAN_MONTHLY_CREDITS = {
121
- 'individual-go': 10,
122
- 'individual-goat': 70,
123
- 'individual-pro-v1': 80,
124
- 'individual-pro': 30,
125
- 'individual-provider': 15,
126
- 'individual-max': 150,
127
- 'individual-ultra': 300,
128
- 'teams-pro': 40,
129
- };
130
- const SUBSCRIPTION_PLAN_NAMES = {
131
- 'individual-go': 'Go',
132
- 'individual-goat': 'GOAT',
133
- 'individual-pro': 'Pro',
134
- 'individual-provider': 'Provider',
135
- 'individual-max': 'Max',
136
- 'individual-ultra': 'Ultra',
137
- 'teams-pro': 'Teams Pro',
138
- };
139
- function subscriptionFacts(subscriptions) {
140
- const data = record(subscriptions?.data);
141
- const planId = text(data?.planId);
142
- const periodEnd = date(data?.currentPeriodEnd);
143
- if (planId === undefined)
144
- return periodEnd === undefined ? {} : { periodEnd };
145
- const prefixes = Object.keys(SUBSCRIPTION_PLAN_MONTHLY_CREDITS).sort((a, b) => b.length - a.length);
146
- const prefix = prefixes.find((candidate) => planId.startsWith(candidate));
147
- return {
148
- ...(prefix === undefined ? {} : { name: SUBSCRIPTION_PLAN_NAMES[prefix] }),
149
- ...(prefix === undefined ? {} : { monthlyCredits: SUBSCRIPTION_PLAN_MONTHLY_CREDITS[prefix] }),
150
- ...(periodEnd === undefined ? {} : { periodEnd }),
151
- };
152
- }
153
- function parseWindow(id, value) {
154
- const block = record(value);
155
- if (block === undefined)
156
- return undefined;
157
- const used = number(block.used);
158
- const cap = number(block.cap);
159
- if (used === undefined && cap === undefined)
160
- return undefined;
161
- const resetAt = number(block.resetAt);
162
- return {
163
- id,
164
- used: used ?? 0,
165
- cap: cap ?? 0,
166
- unit: 'credits',
167
- ...(resetAt !== undefined && resetAt > 0 ? { resetsAt: resetAt } : {}),
168
- };
169
- }
170
- /**
171
- * The monthly window: cap from the plan, consumed = cap − remaining balance.
172
- * Absent unless both the plan's total and the reported remaining balance are
173
- * known — an unknown plan would otherwise render `limit − 0`, i.e. a confident
174
- * "100% used" that is really "we do not know the limit".
175
- */
176
- function parseMonthly(credits, plan) {
177
- const remaining = number(record(record(credits)?.credits)?.monthlyCredits);
178
- if (plan.monthlyCredits === undefined || remaining === undefined)
179
- return undefined;
180
- const used = Math.max(0, plan.monthlyCredits - remaining);
181
- return {
182
- id: 'monthly',
183
- used,
184
- cap: plan.monthlyCredits,
185
- unit: 'credits',
186
- ...(plan.periodEnd !== undefined ? { resetsAt: plan.periodEnd } : {}),
187
- };
188
- }
189
- function parseStats(summary) {
190
- if (summary === undefined)
191
- return undefined;
192
- const stats = {
193
- ...(number(summary.totalCount) !== undefined ? { requests: number(summary.totalCount) } : {}),
194
- ...(number(summary.failedCount) !== undefined ? { failed: number(summary.failedCount) } : {}),
195
- ...(number(summary.successRate) !== undefined
196
- ? { successRate: number(summary.successRate) }
197
- : {}),
198
- ...(number(summary.totalCost) !== undefined ? { cost: number(summary.totalCost) } : {}),
199
- ...(number(summary.totalTokensIn) !== undefined
200
- ? { tokensIn: number(summary.totalTokensIn) }
201
- : {}),
202
- ...(number(summary.totalTokensOut) !== undefined
203
- ? { tokensOut: number(summary.totalTokensOut) }
204
- : {}),
205
- };
206
- return Object.keys(stats).length > 0 ? stats : undefined;
207
- }
208
- function accountLabel(whoami) {
209
- const user = record(whoami?.user);
210
- return text(user?.userName) ?? text(user?.name);
211
- }
212
- function record(value) {
213
- return typeof value === 'object' && value !== null && !Array.isArray(value)
214
- ? value
215
- : undefined;
216
- }
217
- function number(value) {
218
- return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
219
- }
220
- function text(value) {
221
- return typeof value === 'string' && value.length > 0 ? value : undefined;
222
- }
223
- function date(value) {
224
- if (typeof value === 'number' && Number.isFinite(value))
225
- return value;
226
- if (typeof value === 'string') {
227
- const parsed = Date.parse(value);
228
- if (Number.isFinite(parsed))
229
- return parsed;
230
- }
231
- return undefined;
232
- }