maka-agent 0.2.0-dev.42.20260918 → 0.2.0-dev.44.20260920
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/LICENSE +12 -6
- package/dist/acp/maka-acp-agent.js +17 -6
- package/dist/acp/session-event-mapper.js +6 -0
- package/dist/acp/session-interactions.js +520 -0
- package/dist/acp/session-registry.js +80 -9
- package/dist/acp/tool-event-mapper.js +60 -2
- package/dist/mcp-capability-provider.js +7 -0
- package/dist/pi-tui-runner.js +57 -6
- package/dist/runtime-host-tui-command.js +1 -1
- package/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
- package/node_modules/@maka/core/dist/chat-model-choice.js +3 -0
- package/node_modules/@maka/core/dist/connection-usage.js +27 -0
- package/node_modules/@maka/core/dist/external-session.js +4 -3
- package/node_modules/@maka/core/dist/llm-connections.js +3 -21
- package/node_modules/@maka/core/dist/model-catalog.js +8 -20
- package/node_modules/@maka/core/dist/model-metadata.generated.js +304 -304
- package/node_modules/@maka/core/dist/model-thinking.js +16 -1
- package/node_modules/@maka/core/dist/models-dev-projection.js +0 -1
- package/node_modules/@maka/core/dist/provider-auth.js +9 -1
- package/node_modules/@maka/core/dist/provider-registry.js +7 -51
- package/node_modules/@maka/core/dist/runtime-policy/connection-catalog-codec.js +7 -0
- package/node_modules/@maka/core/dist/runtime-policy/model-catalog-entry-codec.js +14 -1
- package/node_modules/@maka/core/dist/settings.js +2 -3
- package/node_modules/@maka/core/dist/skill-locations.js +29 -0
- package/node_modules/@maka/core/package.json +2 -0
- package/node_modules/@maka/mcp/dist/index.js +22 -0
- package/node_modules/@maka/mcp/dist/oauth.js +4 -2
- package/node_modules/@maka/mcp/dist/tool-progress.js +45 -0
- package/node_modules/@maka/runtime/dist/commandcode-cli-language-model.js +27 -3
- package/node_modules/@maka/runtime/dist/connection-usage.js +232 -0
- package/node_modules/@maka/runtime/dist/opencode-session-header.js +2 -3
- package/node_modules/@maka/runtime/dist/session-manager.js +1 -44
- package/node_modules/@maka/runtime/dist/skills-discovery.js +17 -23
- package/node_modules/@maka/runtime/dist/test-connection.js +3 -66
- package/node_modules/@maka/runtime/package.json +1 -0
- package/node_modules/@maka/runtime-host/dist/client/client-capability-channel.js +44 -9
- package/node_modules/@maka/runtime-host/dist/client/index.js +1 -1
- package/node_modules/@maka/runtime-host/dist/client/session-subscription.js +33 -3
- package/node_modules/@maka/runtime-host/dist/protocol/connection-effects.js +132 -1
- package/node_modules/@maka/runtime-host/dist/protocol/index.js +13 -3
- package/node_modules/@maka/runtime-host/dist/protocol/message.js +10 -0
- package/node_modules/@maka/runtime-host/dist/protocol/operations.js +1 -1
- package/node_modules/@maka/runtime-host/dist/protocol/session-catalog.js +1 -1
- package/node_modules/@maka/runtime-host/dist/protocol/turn.js +0 -33
- package/node_modules/@maka/runtime-host/dist/server/access-credential-store.js +2 -0
- package/node_modules/@maka/runtime-host/dist/server/bootstrap-runtime-policy.js +31 -104
- package/node_modules/@maka/runtime-host/dist/server/connection-effect-coordinator.js +57 -1
- package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +4 -5
- package/node_modules/@maka/runtime-host/dist/server/interactive-turn-coordinator.js +1 -16
- package/node_modules/@maka/runtime-host/dist/server/message-coordinator.js +46 -28
- package/node_modules/@maka/runtime-host/dist/server/root-turn-coordinator.js +5 -16
- package/node_modules/@maka/runtime-host/dist/server/session-catalog-coordinator.js +21 -12
- package/node_modules/@maka/runtime-host/dist/server/session-turn-access-request-coordinator.js +7 -17
- package/node_modules/@maka/storage/dist/codex-session-adapter.js +26 -28
- package/node_modules/@maka/storage/dist/runtime-policy/connection-catalog-document.js +0 -62
- package/node_modules/@maka/storage/dist/runtime-policy/coordinator.js +34 -4
- package/node_modules/@maka/storage/dist/runtime-policy-stores.js +2 -1
- package/node_modules/@maka/storage/dist/session-store.js +5 -2
- package/package.json +1 -1
|
@@ -85,6 +85,9 @@ function normalizeModelOverride(entry) {
|
|
|
85
85
|
declared.thinkingLevels = DECLARABLE_RELAY_THINKING_LEVELS.filter((level) => declaredSet.has(level));
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
+
if (isThinkingLevel(entry.defaultThinkingLevel)) {
|
|
89
|
+
declared.defaultThinkingLevel = entry.defaultThinkingLevel;
|
|
90
|
+
}
|
|
88
91
|
if (typeof entry.vision === 'boolean')
|
|
89
92
|
declared.vision = entry.vision;
|
|
90
93
|
for (const field of [
|
|
@@ -188,6 +191,18 @@ export function thinkingVariantsForConnection(connection, modelId) {
|
|
|
188
191
|
return declared;
|
|
189
192
|
return thinkingVariantsForModel(connection.providerType, modelId);
|
|
190
193
|
}
|
|
194
|
+
/**
|
|
195
|
+
* Resolve the configured new-Session default against the model's effective
|
|
196
|
+
* capability ladder. A stale declaration falls back to the provider default
|
|
197
|
+
* instead of reaching Session creation as an unsupported level.
|
|
198
|
+
*/
|
|
199
|
+
export function defaultThinkingLevelForConnection(connection, modelId) {
|
|
200
|
+
const configured = modelOverride(connection, modelId)?.defaultThinkingLevel;
|
|
201
|
+
return configured !== undefined &&
|
|
202
|
+
thinkingVariantsForConnection(connection, modelId).includes(configured)
|
|
203
|
+
? configured
|
|
204
|
+
: undefined;
|
|
205
|
+
}
|
|
191
206
|
/**
|
|
192
207
|
* Discard-semantics gate: returns the level when the model offers it,
|
|
193
208
|
* `undefined` otherwise. Callers that must *reject* a bad level (IPC/session
|
|
@@ -225,7 +240,7 @@ export function thinkingVariantsForModel(providerType, modelId) {
|
|
|
225
240
|
export function applyModelOverride(model, override) {
|
|
226
241
|
if (!override)
|
|
227
242
|
return model;
|
|
228
|
-
const { thinkingLevels: _thinking, serviceTier: _tier, compactionThreshold: _threshold, maxOutputTokens: _outputBudget, vision, capabilities, ...facts } = override;
|
|
243
|
+
const { thinkingLevels: _thinking, defaultThinkingLevel: _defaultThinking, serviceTier: _tier, compactionThreshold: _threshold, maxOutputTokens: _outputBudget, vision, capabilities, ...facts } = override;
|
|
229
244
|
return {
|
|
230
245
|
...model,
|
|
231
246
|
...facts,
|
|
@@ -203,7 +203,6 @@ export function projectModelsDevModel(providerId, modelId, provider, model) {
|
|
|
203
203
|
...(model.knowledge !== undefined ? { knowledgeCutoff: model.knowledge } : {}),
|
|
204
204
|
...(model.structured_output !== undefined ? { structuredOutput: model.structured_output } : {}),
|
|
205
205
|
...(model.last_updated !== undefined ? { lastUpdated: model.last_updated } : {}),
|
|
206
|
-
...(model.cost?.input === 0 ? { isFree: true } : {}),
|
|
207
206
|
capabilities: {
|
|
208
207
|
...(modalities ? { vision: modalities.input.includes('image') } : {}),
|
|
209
208
|
reasoning: model.reasoning === true,
|
|
@@ -22,7 +22,12 @@ import { providerAuthRequiresSecret, providerDefaultsOf, providerSupportsModelDi
|
|
|
22
22
|
* storage coordinator actually gates — an operation with no admission point
|
|
23
23
|
* does not belong here, however natural it sounds beside these three.
|
|
24
24
|
*/
|
|
25
|
-
export const PROVIDER_AUTH_ACTIONS = [
|
|
25
|
+
export const PROVIDER_AUTH_ACTIONS = [
|
|
26
|
+
'test_credentials',
|
|
27
|
+
'fetch_models',
|
|
28
|
+
'read_usage',
|
|
29
|
+
'start_oauth',
|
|
30
|
+
];
|
|
26
31
|
/**
|
|
27
32
|
* Which credential operations a connection may run. This is an admission
|
|
28
33
|
* answer, not a UI state: the storage layer refuses an unavailable action, so a
|
|
@@ -67,6 +72,9 @@ export function deriveProviderAuthContract(input) {
|
|
|
67
72
|
actionAvailability: actions({
|
|
68
73
|
test_credentials: reachableWithoutSecret || hasSecret,
|
|
69
74
|
fetch_models: canFetchModels && (reachableWithoutSecret || hasSecret),
|
|
75
|
+
// Reading account usage needs the same reachability as a connection test:
|
|
76
|
+
// a credential the provider accepts over HTTP.
|
|
77
|
+
read_usage: reachableWithoutSecret || hasSecret,
|
|
70
78
|
}),
|
|
71
79
|
};
|
|
72
80
|
}
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
19
|
import { GENERATED_MODELS_DEV_METADATA, GENERATED_MODELS_DEV_MODEL_PROVIDER_OVERRIDES, GENERATED_MODELS_DEV_PROVIDER_FACTS, } from './model-metadata.generated.js';
|
|
20
|
-
export const OPENCODE_FREE_DEFAULT_MODEL = 'nemotron-3-ultra-free';
|
|
21
20
|
const siliconflow = GENERATED_MODELS_DEV_PROVIDER_FACTS.siliconflow;
|
|
22
21
|
if (!siliconflow.api)
|
|
23
22
|
throw new Error('models.dev SiliconFlow provider facts are missing api');
|
|
@@ -423,37 +422,6 @@ if (opencodeGo.id !== 'opencode-go' || opencodeGo.api !== 'https://opencode.ai/z
|
|
|
423
422
|
throw new Error('models.dev OpenCode Go provider facts are missing the stable id or API');
|
|
424
423
|
}
|
|
425
424
|
const opencodeGoModelIds = toolCallingModelIds('OpenCode Go', GENERATED_MODELS_DEV_METADATA['opencode-go'], ['minimax-m3']).filter((id) => GENERATED_MODELS_DEV_METADATA['opencode-go'][id]?.lifecycle !== 'deprecated');
|
|
426
|
-
// opencode-free is Maka's first-class free anonymous default. It shares the
|
|
427
|
-
// OpenCode Zen endpoint and model ids, exposing the active tool-capable
|
|
428
|
-
// models the models.dev snapshot marks `isFree` (zero input cost). Deriving
|
|
429
|
-
// the set from the snapshot lets routine metadata refreshes rotate free
|
|
430
|
-
// models in and out instead of letting a hardcoded pin rot (#3409).
|
|
431
|
-
//
|
|
432
|
-
// Persistently broken free models, excluded with dated evidence. Deny-only:
|
|
433
|
-
// a stale entry hides at most one healthy model, the opposite failure mode of
|
|
434
|
-
// the allow-list pin this replaced. Entries should be re-probed on snapshot
|
|
435
|
-
// refreshes and removed once the model produces content again.
|
|
436
|
-
// 2026-08-21 muse-spark-1.2-contributor-free: anonymous completions return
|
|
437
|
-
// 200 with an empty message and bill the full token budget (4 consecutive
|
|
438
|
-
// probes, max_tokens 8–200) — a failure shape that even "the send settles it"
|
|
439
|
-
// cannot surface, which is why these ids are also vetoed in
|
|
440
|
-
// `authorizeConnectionModel` rather than merely dropped from this derivation.
|
|
441
|
-
// 2026-08-30 x-preview-f-free (Ox Alpha Free): retired upstream — dropped from
|
|
442
|
-
// the anonymous /models listing and every completion returns HTTP 401
|
|
443
|
-
// {"type":"ModelError","message":"Model x-preview-f-free is not supported"}.
|
|
444
|
-
// models.dev still snapshots it as free+active, so the derivation kept offering
|
|
445
|
-
// it as a default-enabled, picker-visible row until this quarantine. Remove
|
|
446
|
-
// once the snapshot marks it deprecated (or upstream serves it again).
|
|
447
|
-
const OPENCODE_FREE_BROKEN_MODEL_IDS = new Set([
|
|
448
|
-
'muse-spark-1.2-contributor-free',
|
|
449
|
-
'x-preview-f-free',
|
|
450
|
-
]);
|
|
451
|
-
const opencodeFreeModelIds = toolCallingModelIds('OpenCode Free', Object.fromEntries(Object.entries(GENERATED_MODELS_DEV_METADATA.opencode).filter(([id, model]) => model.isFree === true &&
|
|
452
|
-
model.lifecycle !== 'deprecated' &&
|
|
453
|
-
!OPENCODE_FREE_BROKEN_MODEL_IDS.has(id))), [OPENCODE_FREE_DEFAULT_MODEL]);
|
|
454
|
-
if (opencodeFreeModelIds[0] !== OPENCODE_FREE_DEFAULT_MODEL) {
|
|
455
|
-
throw new Error(`models.dev opencode snapshot no longer serves ${OPENCODE_FREE_DEFAULT_MODEL} as an active tool-capable free model; pick a new OPENCODE_FREE_DEFAULT_MODEL`);
|
|
456
|
-
}
|
|
457
425
|
const githubCopilot = GENERATED_MODELS_DEV_PROVIDER_FACTS['github-copilot'];
|
|
458
426
|
if (githubCopilot.id !== 'github-copilot') {
|
|
459
427
|
throw new Error('models.dev GitHub Copilot provider facts are missing stable id github-copilot');
|
|
@@ -968,22 +936,15 @@ const providerRegistry = {
|
|
|
968
936
|
label: 'OpenCode Free',
|
|
969
937
|
baseUrl: opencode.api,
|
|
970
938
|
authKind: 'none',
|
|
971
|
-
fallbackModels: [
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
brokenModelIds: [...OPENCODE_FREE_BROKEN_MODEL_IDS],
|
|
976
|
-
status: 'ready',
|
|
977
|
-
runtimeAdapter: { kind: 'openai-compatible', name: 'provider' },
|
|
939
|
+
fallbackModels: [],
|
|
940
|
+
status: 'phase3-experimental',
|
|
941
|
+
runtimeAdapter: { kind: 'unavailable' },
|
|
942
|
+
retired: true,
|
|
978
943
|
modelDiscovery: {
|
|
979
944
|
kind: 'fallback',
|
|
980
|
-
reason: '
|
|
945
|
+
reason: 'OpenCode restricts its free tier to the OpenCode client.',
|
|
981
946
|
},
|
|
982
947
|
category: 'overseas',
|
|
983
|
-
catalogGroup: 'plans',
|
|
984
|
-
signupUrl: 'https://opencode.ai/zen',
|
|
985
|
-
catalogOrder: 0,
|
|
986
|
-
recommendedOrder: 0,
|
|
987
948
|
},
|
|
988
949
|
togetherai: {
|
|
989
950
|
label: together.name,
|
|
@@ -1471,16 +1432,11 @@ export function providerDefaultsOf(providerType) {
|
|
|
1471
1432
|
}
|
|
1472
1433
|
/**
|
|
1473
1434
|
* The models a provider offers with no live list to go on: the baseline it
|
|
1474
|
-
* ships
|
|
1435
|
+
* ships. This is the only reader of
|
|
1475
1436
|
* `fallbackModels` — a provider's offline offer has exactly one authority.
|
|
1476
|
-
*
|
|
1477
|
-
* `brokenModelIds` subtracts here rather than being pruned from the baseline at
|
|
1478
|
-
* the source because the ids it names are ones a stored connection may still
|
|
1479
|
-
* carry from an older shipped list.
|
|
1480
1437
|
*/
|
|
1481
1438
|
export function providerFallbackModelIds(defaults) {
|
|
1482
|
-
|
|
1483
|
-
return defaults.fallbackModels.filter((id) => !broken.has(id));
|
|
1439
|
+
return [...defaults.fallbackModels];
|
|
1484
1440
|
}
|
|
1485
1441
|
/**
|
|
1486
1442
|
* The provider's name as a model row shows it, or `undefined` when this build
|
|
@@ -168,6 +168,7 @@ export function decodeModelOverridesTable(value) {
|
|
|
168
168
|
decodeConnectionModelId(modelId);
|
|
169
169
|
const entry = exactRecord(rawEntry, `relay model profile for ${modelId}`, [
|
|
170
170
|
'thinkingLevels',
|
|
171
|
+
'defaultThinkingLevel',
|
|
171
172
|
'vision',
|
|
172
173
|
'contextWindow',
|
|
173
174
|
'serviceTier',
|
|
@@ -200,6 +201,12 @@ export function decodeModelOverridesTable(value) {
|
|
|
200
201
|
}
|
|
201
202
|
declared.thinkingLevels = [...entry.thinkingLevels];
|
|
202
203
|
}
|
|
204
|
+
if (entry.defaultThinkingLevel !== undefined) {
|
|
205
|
+
if (!isThinkingLevel(entry.defaultThinkingLevel)) {
|
|
206
|
+
throw domainError(`default thinking level for ${modelId} is invalid`);
|
|
207
|
+
}
|
|
208
|
+
declared.defaultThinkingLevel = entry.defaultThinkingLevel;
|
|
209
|
+
}
|
|
203
210
|
if (entry.vision !== undefined) {
|
|
204
211
|
declared.vision = booleanValue(entry.vision, `declared vision for ${modelId}`);
|
|
205
212
|
}
|
|
@@ -36,6 +36,7 @@ export function decodeModelCatalogEntry(value) {
|
|
|
36
36
|
'defaultSupportsVision',
|
|
37
37
|
'compactionThreshold',
|
|
38
38
|
'thinkingLevels',
|
|
39
|
+
'defaultThinkingLevel',
|
|
39
40
|
'contextWindow',
|
|
40
41
|
'inputLimit',
|
|
41
42
|
'defaultContextWindow',
|
|
@@ -49,6 +50,7 @@ export function decodeModelCatalogEntry(value) {
|
|
|
49
50
|
id: item.id,
|
|
50
51
|
...pick(item, ['displayName', 'description', 'contextWindow', 'inputLimit', 'knowledgeCutoff']),
|
|
51
52
|
});
|
|
53
|
+
const thinkingLevels = decodeThinkingLevels(item.thinkingLevels);
|
|
52
54
|
return {
|
|
53
55
|
...shared,
|
|
54
56
|
...Object.fromEntries(['defaultContextWindow', 'defaultInputLimit'].flatMap((field) => item[field] === undefined
|
|
@@ -67,9 +69,20 @@ export function decodeModelCatalogEntry(value) {
|
|
|
67
69
|
defaultSupportsVision: booleanValue(item.defaultSupportsVision, 'entry default vision support'),
|
|
68
70
|
}
|
|
69
71
|
: {}),
|
|
70
|
-
thinkingLevels
|
|
72
|
+
thinkingLevels,
|
|
73
|
+
...(item.defaultThinkingLevel === undefined
|
|
74
|
+
? {}
|
|
75
|
+
: {
|
|
76
|
+
defaultThinkingLevel: decodeDefaultThinkingLevel(item.defaultThinkingLevel, thinkingLevels),
|
|
77
|
+
}),
|
|
71
78
|
};
|
|
72
79
|
}
|
|
80
|
+
function decodeDefaultThinkingLevel(value, available) {
|
|
81
|
+
if (!isThinkingLevel(value) || !available.includes(value)) {
|
|
82
|
+
throw domainError('entry default thinking level is invalid');
|
|
83
|
+
}
|
|
84
|
+
return value;
|
|
85
|
+
}
|
|
73
86
|
function decodeThinkingLevels(value) {
|
|
74
87
|
if (!Array.isArray(value))
|
|
75
88
|
throw domainError('entry thinking levels must be an array');
|
|
@@ -608,9 +608,8 @@ function defaultChatDefaultsSettings() {
|
|
|
608
608
|
function normalizeChatDefaultsSettings(settings) {
|
|
609
609
|
return {
|
|
610
610
|
...(settings.codeModeEnabled === true ? { codeModeEnabled: true } : {}),
|
|
611
|
-
//
|
|
612
|
-
//
|
|
613
|
-
// session creation as a rung no picker recognizes.
|
|
611
|
+
// Preserve the retired field while older settings documents still carry it.
|
|
612
|
+
// No task creation path consumes it; defaults now live on model overrides.
|
|
614
613
|
thinkingLevel: isThinkingLevel(settings.thinkingLevel) ? settings.thinkingLevel : undefined,
|
|
615
614
|
// A retired mode is decoded (not rejected) so an existing settings file
|
|
616
615
|
// keeps working; knowing which modes are retired lives in one place.
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
/** Standard discovery locations in precedence order; also the directory-opening allowlist. */
|
|
20
|
+
export const STANDARD_SKILL_LOCATIONS = [
|
|
21
|
+
{ ref: 'project:maka', scope: 'project', source: 'maka', segments: ['.maka', 'skills'] },
|
|
22
|
+
{ ref: 'project:agents', scope: 'project', source: 'agents', segments: ['.agents', 'skills'] },
|
|
23
|
+
{ ref: 'workspace:legacy', scope: 'workspace', source: 'legacy', segments: ['skills'] },
|
|
24
|
+
{ ref: 'user:maka', scope: 'user', source: 'maka', segments: ['.maka', 'skills'] },
|
|
25
|
+
{ ref: 'user:agents', scope: 'user', source: 'agents', segments: ['.agents', 'skills'] },
|
|
26
|
+
];
|
|
27
|
+
export function findSkillLocation(ref) {
|
|
28
|
+
return STANDARD_SKILL_LOCATIONS.find((location) => location.ref === ref);
|
|
29
|
+
}
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
"./artifacts": "./dist/artifacts.js",
|
|
63
63
|
"./pet": "./dist/pet.js",
|
|
64
64
|
"./skill-invocation": "./dist/skill-invocation.js",
|
|
65
|
+
"./skill-locations": "./dist/skill-locations.js",
|
|
65
66
|
"./runtime-inputs": "./dist/runtime-inputs.js",
|
|
66
67
|
"./e2e-fixture": "./dist/e2e-fixture.js",
|
|
67
68
|
"./capabilities": "./dist/capabilities.js",
|
|
@@ -134,6 +135,7 @@
|
|
|
134
135
|
"./bot-onboarding": "./dist/bot-onboarding.js",
|
|
135
136
|
"./computer-use": "./dist/computer-use.js",
|
|
136
137
|
"./connection-error-copy": "./dist/connection-error-copy.js",
|
|
138
|
+
"./connection-usage": "./dist/connection-usage.js",
|
|
137
139
|
"./git-review": "./dist/git-review.js",
|
|
138
140
|
"./graph-command": "./dist/graph-command.js",
|
|
139
141
|
"./project": "./dist/project.js",
|
|
@@ -31,6 +31,7 @@ import { createMcpToolBinding, parseMcpToolBinding } from './tool-binding.js';
|
|
|
31
31
|
import { McpToolCallError, normalizeToolCallError } from './tool-call-error.js';
|
|
32
32
|
import { discoverMcpTools } from './tool-discovery.js';
|
|
33
33
|
import { McpToolCallPreparer } from './tool-output-validation.js';
|
|
34
|
+
import { mapMcpToolProgress } from './tool-progress.js';
|
|
34
35
|
import { McpCredentialCoordinator } from './credential-coordinator.js';
|
|
35
36
|
import { assertTransportSecurity, urlProvenance, } from './transport-security.js';
|
|
36
37
|
import { McpAuthRequiredError, McpOAuthProvider, } from './oauth.js';
|
|
@@ -597,6 +598,26 @@ export class McpClientManager {
|
|
|
597
598
|
entry.toolSnapshot.get(toolName)?.binding !== binding)
|
|
598
599
|
throw new McpToolCallError(serverId, toolName, 'tool binding is stale');
|
|
599
600
|
};
|
|
601
|
+
const progressListener = options.onProgress ?? options.emitProgress;
|
|
602
|
+
let forwardedProgressTotal;
|
|
603
|
+
let forwardedProgressCurrent = -1;
|
|
604
|
+
const forwardProgress = (progress) => {
|
|
605
|
+
const mapped = mapMcpToolProgress(progress);
|
|
606
|
+
if (!mapped)
|
|
607
|
+
return;
|
|
608
|
+
if ((forwardedProgressTotal !== undefined && mapped.total !== forwardedProgressTotal) ||
|
|
609
|
+
mapped.current <= forwardedProgressCurrent) {
|
|
610
|
+
return;
|
|
611
|
+
}
|
|
612
|
+
forwardedProgressTotal ??= mapped.total;
|
|
613
|
+
forwardedProgressCurrent = mapped.current;
|
|
614
|
+
try {
|
|
615
|
+
progressListener?.(mapped.current, mapped.total);
|
|
616
|
+
}
|
|
617
|
+
catch {
|
|
618
|
+
// Progress is advisory: a listener failure must not fail the tool.
|
|
619
|
+
}
|
|
620
|
+
};
|
|
600
621
|
try {
|
|
601
622
|
const originalArguments = requestInteraction ? structuredClone(args) : args;
|
|
602
623
|
let continuation = {};
|
|
@@ -618,6 +639,7 @@ export class McpClientManager {
|
|
|
618
639
|
signal,
|
|
619
640
|
timeout: options.timeoutMs ?? this.timeouts.callToolMs,
|
|
620
641
|
toolDefinition: structuredClone(preparation.value.definitionForSdk),
|
|
642
|
+
...(progressListener ? { onprogress: forwardProgress } : {}),
|
|
621
643
|
...(requestInteraction ? { allowInputRequired: true } : {}),
|
|
622
644
|
});
|
|
623
645
|
refreshInventory();
|
|
@@ -51,6 +51,8 @@ export class McpAuthRequiredError extends Error {
|
|
|
51
51
|
* redirectToAuthorization. The URL itself is never opened or sent in a
|
|
52
52
|
* token request. */
|
|
53
53
|
const BACKGROUND_REDIRECT_URL = 'http://127.0.0.1/maka-mcp-oauth-noninteractive';
|
|
54
|
+
/** Product homepage sent in OAuth dynamic client registration. */
|
|
55
|
+
const MCP_OAUTH_CLIENT_URI = 'https://maka.apache.org/en/';
|
|
54
56
|
export class McpOAuthProvider {
|
|
55
57
|
options;
|
|
56
58
|
/** Present only when an interactive state was supplied — the SDK treats
|
|
@@ -68,8 +70,8 @@ export class McpOAuthProvider {
|
|
|
68
70
|
get clientMetadata() {
|
|
69
71
|
return {
|
|
70
72
|
client_name: this.options.clientName,
|
|
71
|
-
client_uri:
|
|
72
|
-
software_id:
|
|
73
|
+
client_uri: MCP_OAUTH_CLIENT_URI,
|
|
74
|
+
software_id: this.options.clientName,
|
|
73
75
|
software_version: this.options.clientVersion,
|
|
74
76
|
redirect_uris: this.options.interactive ? [this.options.interactive.redirectUrl] : [],
|
|
75
77
|
grant_types: ['authorization_code', 'refresh_token'],
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
export const MCP_TOOL_PROGRESS_MAX_TOTAL = 1_024;
|
|
20
|
+
/**
|
|
21
|
+
* Map an SDK `notifications/progress` payload onto the Host progress pair.
|
|
22
|
+
* First slice: only finite step counts that the shared tool-progress codec
|
|
23
|
+
* already accepts. Missing `total`, fractions, and inverted ranges are
|
|
24
|
+
* dropped so a noisy server cannot fail the tool call.
|
|
25
|
+
*/
|
|
26
|
+
export function mapMcpToolProgress(value) {
|
|
27
|
+
if (!isRecord(value))
|
|
28
|
+
return undefined;
|
|
29
|
+
const current = value.progress;
|
|
30
|
+
const total = value.total;
|
|
31
|
+
if (typeof current !== 'number' || typeof total !== 'number')
|
|
32
|
+
return undefined;
|
|
33
|
+
if (!Number.isSafeInteger(current) ||
|
|
34
|
+
!Number.isSafeInteger(total) ||
|
|
35
|
+
current < 0 ||
|
|
36
|
+
total < 1 ||
|
|
37
|
+
total > MCP_TOOL_PROGRESS_MAX_TOTAL ||
|
|
38
|
+
current > total) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
return { current, total };
|
|
42
|
+
}
|
|
43
|
+
function isRecord(value) {
|
|
44
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
45
|
+
}
|
|
@@ -576,6 +576,12 @@ function cliEventsToStreamParts(input) {
|
|
|
576
576
|
let reasoningId;
|
|
577
577
|
let nextId = 0;
|
|
578
578
|
let finished = false;
|
|
579
|
+
// The wire splits one call's usage across two events: `finish-step` carries
|
|
580
|
+
// the provider's OWN body (`prompt_tokens`, `prompt_cache_hit_tokens`, …)
|
|
581
|
+
// under `usage.raw`, and `finish` carries only the normalized totals. The
|
|
582
|
+
// provider keys are what telemetry's cache accounting reads, so keep the
|
|
583
|
+
// body here until the finish event can carry it out.
|
|
584
|
+
let providerUsageRaw;
|
|
579
585
|
const closeText = (controller) => {
|
|
580
586
|
if (textId === undefined)
|
|
581
587
|
return;
|
|
@@ -644,13 +650,20 @@ function cliEventsToStreamParts(input) {
|
|
|
644
650
|
controller.enqueue({ type: 'tool-call', toolCallId: id, toolName, input: args });
|
|
645
651
|
break;
|
|
646
652
|
}
|
|
653
|
+
case 'finish-step': {
|
|
654
|
+
// Carries the provider's own usage body; `finish` normalizes it away.
|
|
655
|
+
const usage = isRecord(event.usage) ? event.usage : undefined;
|
|
656
|
+
if (isRecord(usage?.raw))
|
|
657
|
+
providerUsageRaw = usage.raw;
|
|
658
|
+
break;
|
|
659
|
+
}
|
|
647
660
|
case 'finish': {
|
|
648
661
|
closeText(controller);
|
|
649
662
|
closeReasoning(controller);
|
|
650
663
|
finished = true;
|
|
651
664
|
controller.enqueue({
|
|
652
665
|
type: 'finish',
|
|
653
|
-
usage: usageFromEvent(event.totalUsage),
|
|
666
|
+
usage: usageFromEvent(event.totalUsage, providerUsageRaw),
|
|
654
667
|
finishReason: mapFinishReason(event.finishReason),
|
|
655
668
|
});
|
|
656
669
|
break;
|
|
@@ -685,7 +698,7 @@ function cliEventsToStreamParts(input) {
|
|
|
685
698
|
},
|
|
686
699
|
});
|
|
687
700
|
}
|
|
688
|
-
function usageFromEvent(value) {
|
|
701
|
+
function usageFromEvent(value, providerRaw) {
|
|
689
702
|
if (!isRecord(value))
|
|
690
703
|
return emptyUsage();
|
|
691
704
|
const inputDetails = isRecord(value.inputTokenDetails) ? value.inputTokenDetails : undefined;
|
|
@@ -702,7 +715,18 @@ function usageFromEvent(value) {
|
|
|
702
715
|
text: undefined,
|
|
703
716
|
reasoning: numberValue(outputDetails?.reasoningTokens),
|
|
704
717
|
},
|
|
705
|
-
raw
|
|
718
|
+
// `raw` must stay the PROVIDER's own usage body, which is where the
|
|
719
|
+
// OpenAI/Anthropic cache keys live (`prompt_tokens`,
|
|
720
|
+
// `prompt_tokens_details.cached_tokens`, `cache_read_input_tokens`, …).
|
|
721
|
+
// Only `finish-step` carries that body; `finish.totalUsage` is already
|
|
722
|
+
// normalized, so carrying the envelope here left telemetry's strict reader
|
|
723
|
+
// looking for `prompt_tokens` on an object that had only `inputTokens` —
|
|
724
|
+
// every attempt settled as `usageBasis: 'missing'` and the composer's
|
|
725
|
+
// context gauge never moved.
|
|
726
|
+
//
|
|
727
|
+
// The fallback keeps a body-less event readable on the normalized keys
|
|
728
|
+
// rather than handing telemetry `undefined`.
|
|
729
|
+
raw: (providerRaw ?? value),
|
|
706
730
|
};
|
|
707
731
|
}
|
|
708
732
|
function emptyUsage() {
|