@codelia/runtime 0.1.64 → 0.1.66
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/index.cjs +191 -97
- package/dist/index.js +137 -40
- package/package.json +9 -9
package/dist/index.cjs
CHANGED
|
@@ -389,7 +389,7 @@ ${agentsContext}`;
|
|
|
389
389
|
|
|
390
390
|
// src/agent-factory.ts
|
|
391
391
|
var import_node_fs15 = require("fs");
|
|
392
|
-
var
|
|
392
|
+
var import_core21 = require("@codelia/core");
|
|
393
393
|
var import_model_metadata2 = require("@codelia/model-metadata");
|
|
394
394
|
var import_shared_types2 = require("@codelia/shared-types");
|
|
395
395
|
var import_storage8 = require("@codelia/storage");
|
|
@@ -808,6 +808,7 @@ var resolveModelConfig = async (workingDir) => {
|
|
|
808
808
|
name: effective.model?.name,
|
|
809
809
|
reasoning: effective.model?.reasoning,
|
|
810
810
|
verbosity: effective.model?.verbosity,
|
|
811
|
+
fast: effective.model?.fast,
|
|
811
812
|
experimental: effective.experimental
|
|
812
813
|
};
|
|
813
814
|
};
|
|
@@ -2392,6 +2393,15 @@ var ANTHROPIC_BUDGET_PRESET_TOKENS = {
|
|
|
2392
2393
|
};
|
|
2393
2394
|
var ANTHROPIC_MAX_TOKENS_FALLBACK_HEADROOM = 4096;
|
|
2394
2395
|
var ANTHROPIC_REASONING_MODEL_TABLE = {
|
|
2396
|
+
"claude-opus-4-7": {
|
|
2397
|
+
supportedLevels: ["low", "medium", "high", "xhigh"],
|
|
2398
|
+
budgetPresetByLevel: {
|
|
2399
|
+
low: "reasoning_low",
|
|
2400
|
+
medium: "reasoning_medium",
|
|
2401
|
+
high: "reasoning_high",
|
|
2402
|
+
xhigh: "reasoning_xhigh"
|
|
2403
|
+
}
|
|
2404
|
+
},
|
|
2395
2405
|
"claude-opus-4-6": {
|
|
2396
2406
|
supportedLevels: ["low", "medium", "high", "xhigh"],
|
|
2397
2407
|
budgetPresetByLevel: {
|
|
@@ -2463,6 +2473,8 @@ var ANTHROPIC_REASONING_MODEL_TABLE = {
|
|
|
2463
2473
|
}
|
|
2464
2474
|
}
|
|
2465
2475
|
};
|
|
2476
|
+
var ANTHROPIC_ADAPTIVE_THINKING_MODELS = /* @__PURE__ */ new Set(["claude-opus-4-7"]);
|
|
2477
|
+
var toAnthropicOutputEffort = (level) => level === "xhigh" ? "max" : level;
|
|
2466
2478
|
var normalizeRequestedReasoning = (value) => value ?? DEFAULT_REASONING_LEVEL;
|
|
2467
2479
|
var resolveNearestSupportedLevel = (requested, supportedLevels) => {
|
|
2468
2480
|
const supported = new Set(supportedLevels);
|
|
@@ -2543,9 +2555,16 @@ var resolveAnthropicReasoning = ({
|
|
|
2543
2555
|
const budgetTokens = ANTHROPIC_BUDGET_PRESET_TOKENS[preset];
|
|
2544
2556
|
return {
|
|
2545
2557
|
...resolution,
|
|
2546
|
-
|
|
2547
|
-
type: "
|
|
2548
|
-
|
|
2558
|
+
...ANTHROPIC_ADAPTIVE_THINKING_MODELS.has(model) ? {
|
|
2559
|
+
thinking: { type: "adaptive" },
|
|
2560
|
+
outputConfig: {
|
|
2561
|
+
effort: toAnthropicOutputEffort(resolution.applied)
|
|
2562
|
+
}
|
|
2563
|
+
} : {
|
|
2564
|
+
thinking: {
|
|
2565
|
+
type: "enabled",
|
|
2566
|
+
budget_tokens: budgetTokens
|
|
2567
|
+
}
|
|
2549
2568
|
},
|
|
2550
2569
|
budgetPreset: preset,
|
|
2551
2570
|
usedFallbackModelProfile
|
|
@@ -2563,8 +2582,26 @@ var resolveAnthropicMaxTokens = ({
|
|
|
2563
2582
|
return normalizedBudget + ANTHROPIC_MAX_TOKENS_FALLBACK_HEADROOM;
|
|
2564
2583
|
};
|
|
2565
2584
|
|
|
2566
|
-
// src/model-
|
|
2585
|
+
// src/model-fast.ts
|
|
2567
2586
|
var import_core2 = require("@codelia/core");
|
|
2587
|
+
var resolveFastMode = (params) => {
|
|
2588
|
+
if (params.requested !== true) {
|
|
2589
|
+
return { enabled: false };
|
|
2590
|
+
}
|
|
2591
|
+
if (!(0, import_core2.supportsFastMode)(import_core2.DEFAULT_MODEL_REGISTRY, params.model, params.provider)) {
|
|
2592
|
+
return { enabled: false };
|
|
2593
|
+
}
|
|
2594
|
+
if (params.provider === "openai") {
|
|
2595
|
+
return { enabled: true, provider: "openai", serviceTier: "priority" };
|
|
2596
|
+
}
|
|
2597
|
+
if (params.provider === "anthropic") {
|
|
2598
|
+
return { enabled: true, provider: "anthropic", fastMode: true };
|
|
2599
|
+
}
|
|
2600
|
+
return { enabled: false };
|
|
2601
|
+
};
|
|
2602
|
+
|
|
2603
|
+
// src/model-registry.ts
|
|
2604
|
+
var import_core3 = require("@codelia/core");
|
|
2568
2605
|
var import_model_metadata = require("@codelia/model-metadata");
|
|
2569
2606
|
var import_storage3 = require("@codelia/storage");
|
|
2570
2607
|
var stripProviderPrefix = (provider, model) => {
|
|
@@ -2576,7 +2613,7 @@ var resolveProviderModelEntry = (providerEntries, provider, model) => {
|
|
|
2576
2613
|
return null;
|
|
2577
2614
|
}
|
|
2578
2615
|
const normalized = stripProviderPrefix(provider, model);
|
|
2579
|
-
const providerModelId = (0,
|
|
2616
|
+
const providerModelId = (0, import_core3.resolveProviderModelId)(import_core3.DEFAULT_MODEL_REGISTRY, model, provider) ?? normalized;
|
|
2580
2617
|
const providerModelNormalized = stripProviderPrefix(
|
|
2581
2618
|
provider,
|
|
2582
2619
|
providerModelId
|
|
@@ -2615,13 +2652,13 @@ var resolveDefaultRegistrySpec = (provider, model) => {
|
|
|
2615
2652
|
(value, index, array) => array.indexOf(value) === index
|
|
2616
2653
|
);
|
|
2617
2654
|
for (const candidate of candidates) {
|
|
2618
|
-
const spec = (0,
|
|
2655
|
+
const spec = (0, import_core3.resolveModel)(import_core3.DEFAULT_MODEL_REGISTRY, candidate, provider);
|
|
2619
2656
|
if (spec?.provider === provider) {
|
|
2620
2657
|
return spec;
|
|
2621
2658
|
}
|
|
2622
2659
|
}
|
|
2623
2660
|
const normalizedLower = normalized.toLowerCase();
|
|
2624
|
-
for (const spec of Object.values(
|
|
2661
|
+
for (const spec of Object.values(import_core3.DEFAULT_MODEL_REGISTRY.modelsById)) {
|
|
2625
2662
|
if (spec.provider !== provider) continue;
|
|
2626
2663
|
if (spec.id.toLowerCase() === normalizedLower) {
|
|
2627
2664
|
return spec;
|
|
@@ -2640,7 +2677,7 @@ var withOpenRouterDynamicModel = (registry, llm, entry) => {
|
|
|
2640
2677
|
const contextWindow = toPositiveInteger(entry.limits?.contextWindow) ?? toPositiveInteger(entry.limits?.inputTokens);
|
|
2641
2678
|
const maxInputTokens = toPositiveInteger(entry.limits?.inputTokens) ?? contextWindow;
|
|
2642
2679
|
const maxOutputTokens = toPositiveInteger(entry.limits?.outputTokens);
|
|
2643
|
-
if (!contextWindow && !maxInputTokens
|
|
2680
|
+
if (!contextWindow && !maxInputTokens) {
|
|
2644
2681
|
return registry;
|
|
2645
2682
|
}
|
|
2646
2683
|
const aliases = [llm.model, `${llm.provider}/${normalized}`].filter((value) => value !== normalized).filter((value, index, array) => array.indexOf(value) === index);
|
|
@@ -2653,7 +2690,7 @@ var withOpenRouterDynamicModel = (registry, llm, entry) => {
|
|
|
2653
2690
|
google: { ...registry.aliasesByProvider.google }
|
|
2654
2691
|
}
|
|
2655
2692
|
};
|
|
2656
|
-
(0,
|
|
2693
|
+
(0, import_core3.registerModels)(next, [
|
|
2657
2694
|
{
|
|
2658
2695
|
id: normalized,
|
|
2659
2696
|
provider: llm.provider,
|
|
@@ -2688,13 +2725,13 @@ var buildModelRegistry = async (llm, options = {}) => {
|
|
|
2688
2725
|
}
|
|
2689
2726
|
if (!resolvedEntry) {
|
|
2690
2727
|
const fallbackSpec = resolveDefaultRegistrySpec(llm.provider, llm.model);
|
|
2691
|
-
if (strict && !fallbackSpec) {
|
|
2728
|
+
if (strict && !(0, import_core3.isUsableModelSpec)(fallbackSpec)) {
|
|
2692
2729
|
throw new Error(
|
|
2693
|
-
`
|
|
2730
|
+
`Usable model metadata not found for ${llm.provider}/${llm.model} after refresh; add required limits to the static ModelSpec to use it without metadata`
|
|
2694
2731
|
);
|
|
2695
2732
|
}
|
|
2696
2733
|
}
|
|
2697
|
-
const baseRegistry = (0,
|
|
2734
|
+
const baseRegistry = (0, import_core3.applyModelMetadata)(import_core3.DEFAULT_MODEL_REGISTRY, {
|
|
2698
2735
|
models: entries
|
|
2699
2736
|
});
|
|
2700
2737
|
return resolvedEntry ? withOpenRouterDynamicModel(baseRegistry, llm, resolvedEntry) : baseRegistry;
|
|
@@ -4191,9 +4228,9 @@ ${skillsCatalog}`;
|
|
|
4191
4228
|
};
|
|
4192
4229
|
|
|
4193
4230
|
// src/tools/agents-resolve.ts
|
|
4194
|
-
var
|
|
4231
|
+
var import_core4 = require("@codelia/core");
|
|
4195
4232
|
var import_zod2 = require("zod");
|
|
4196
|
-
var createAgentsResolveTool = (sandboxKey, agentsResolverKey) => (0,
|
|
4233
|
+
var createAgentsResolveTool = (sandboxKey, agentsResolverKey) => (0, import_core4.defineTool)({
|
|
4197
4234
|
name: "agents_resolve",
|
|
4198
4235
|
description: "Resolve AGENTS.md files applicable to a target path (metadata only).",
|
|
4199
4236
|
input: import_zod2.z.object({
|
|
@@ -4232,7 +4269,7 @@ var createAgentsResolveTool = (sandboxKey, agentsResolverKey) => (0, import_core
|
|
|
4232
4269
|
// src/tools/apply-patch.ts
|
|
4233
4270
|
var import_node_fs7 = require("fs");
|
|
4234
4271
|
var import_node_path9 = __toESM(require("path"), 1);
|
|
4235
|
-
var
|
|
4272
|
+
var import_core5 = require("@codelia/core");
|
|
4236
4273
|
var import_zod3 = require("zod");
|
|
4237
4274
|
|
|
4238
4275
|
// src/utils/diff.ts
|
|
@@ -4965,7 +5002,7 @@ var summarizeChanges = (changes, dryRun) => {
|
|
|
4965
5002
|
files: fileSummaries
|
|
4966
5003
|
};
|
|
4967
5004
|
};
|
|
4968
|
-
var createApplyPatchTool = (sandboxKey, outputCacheStore) => (0,
|
|
5005
|
+
var createApplyPatchTool = (sandboxKey, outputCacheStore) => (0, import_core5.defineTool)({
|
|
4969
5006
|
name: "apply_patch",
|
|
4970
5007
|
description: "Apply a codex-style multi-file patch; use dry_run to preview only.",
|
|
4971
5008
|
input: import_zod3.z.object({
|
|
@@ -5001,16 +5038,16 @@ var createApplyPatchTool = (sandboxKey, outputCacheStore) => (0, import_core4.de
|
|
|
5001
5038
|
});
|
|
5002
5039
|
|
|
5003
5040
|
// src/tools/done.ts
|
|
5004
|
-
var
|
|
5041
|
+
var import_core6 = require("@codelia/core");
|
|
5005
5042
|
var import_zod4 = require("zod");
|
|
5006
|
-
var createDoneTool = () => (0,
|
|
5043
|
+
var createDoneTool = () => (0, import_core6.defineTool)({
|
|
5007
5044
|
name: "done",
|
|
5008
5045
|
description: "Mark the task as complete and return a final message.",
|
|
5009
5046
|
input: import_zod4.z.object({
|
|
5010
5047
|
message: import_zod4.z.string().describe("Final user-facing completion message.")
|
|
5011
5048
|
}),
|
|
5012
5049
|
execute: async (input) => {
|
|
5013
|
-
throw new
|
|
5050
|
+
throw new import_core6.TaskComplete(input.message);
|
|
5014
5051
|
}
|
|
5015
5052
|
});
|
|
5016
5053
|
|
|
@@ -5018,7 +5055,7 @@ var createDoneTool = () => (0, import_core5.defineTool)({
|
|
|
5018
5055
|
var import_node_crypto4 = __toESM(require("crypto"), 1);
|
|
5019
5056
|
var import_node_fs8 = require("fs");
|
|
5020
5057
|
var import_node_path10 = __toESM(require("path"), 1);
|
|
5021
|
-
var
|
|
5058
|
+
var import_core7 = require("@codelia/core");
|
|
5022
5059
|
var import_zod5 = require("zod");
|
|
5023
5060
|
var trimLine = (line) => line.replace(/\r$/, "").trim();
|
|
5024
5061
|
var lineRangeToIndices = (lines, startLine, lineCount) => {
|
|
@@ -5127,7 +5164,7 @@ var applyReplacements = (content, matches, replacement) => {
|
|
|
5127
5164
|
return next;
|
|
5128
5165
|
};
|
|
5129
5166
|
var hashContent = (content) => import_node_crypto4.default.createHash("sha256").update(content).digest("hex");
|
|
5130
|
-
var createEditTool = (sandboxKey, outputCacheStore) => (0,
|
|
5167
|
+
var createEditTool = (sandboxKey, outputCacheStore) => (0, import_core7.defineTool)({
|
|
5131
5168
|
name: "edit",
|
|
5132
5169
|
description: "Edit a file by replacing matched text with new text; supports guarded match modes and dry-run preview.",
|
|
5133
5170
|
input: import_zod5.z.object({
|
|
@@ -5265,7 +5302,7 @@ var createEditTool = (sandboxKey, outputCacheStore) => (0, import_core6.defineTo
|
|
|
5265
5302
|
});
|
|
5266
5303
|
|
|
5267
5304
|
// src/tools/lane.ts
|
|
5268
|
-
var
|
|
5305
|
+
var import_core8 = require("@codelia/core");
|
|
5269
5306
|
var import_zod6 = require("zod");
|
|
5270
5307
|
|
|
5271
5308
|
// src/lanes/manager.ts
|
|
@@ -5865,7 +5902,7 @@ var buildLaneHints = (lane) => {
|
|
|
5865
5902
|
}
|
|
5866
5903
|
};
|
|
5867
5904
|
};
|
|
5868
|
-
var createLaneCreateTool = (sandboxKey) => (0,
|
|
5905
|
+
var createLaneCreateTool = (sandboxKey) => (0, import_core8.defineTool)({
|
|
5869
5906
|
name: "lane_create",
|
|
5870
5907
|
description: "Create a Task lane (worktree slot) and start autonomous execution in tmux/zellij.",
|
|
5871
5908
|
input: import_zod6.z.object({
|
|
@@ -5900,7 +5937,7 @@ var createLaneCreateTool = (sandboxKey) => (0, import_core7.defineTool)({
|
|
|
5900
5937
|
}
|
|
5901
5938
|
}
|
|
5902
5939
|
});
|
|
5903
|
-
var createLaneListTool = (sandboxKey) => (0,
|
|
5940
|
+
var createLaneListTool = (sandboxKey) => (0, import_core8.defineTool)({
|
|
5904
5941
|
name: "lane_list",
|
|
5905
5942
|
description: "List Task lanes (worktree slots) and current states.",
|
|
5906
5943
|
input: import_zod6.z.object({
|
|
@@ -5924,7 +5961,7 @@ var createLaneListTool = (sandboxKey) => (0, import_core7.defineTool)({
|
|
|
5924
5961
|
}
|
|
5925
5962
|
}
|
|
5926
5963
|
});
|
|
5927
|
-
var createLaneStatusTool = (sandboxKey) => (0,
|
|
5964
|
+
var createLaneStatusTool = (sandboxKey) => (0, import_core8.defineTool)({
|
|
5928
5965
|
name: "lane_status",
|
|
5929
5966
|
description: "Get Task lane status and backend liveness.",
|
|
5930
5967
|
input: import_zod6.z.object({
|
|
@@ -5943,7 +5980,7 @@ var createLaneStatusTool = (sandboxKey) => (0, import_core7.defineTool)({
|
|
|
5943
5980
|
}
|
|
5944
5981
|
}
|
|
5945
5982
|
});
|
|
5946
|
-
var createLaneCloseTool = (sandboxKey) => (0,
|
|
5983
|
+
var createLaneCloseTool = (sandboxKey) => (0, import_core8.defineTool)({
|
|
5947
5984
|
name: "lane_close",
|
|
5948
5985
|
description: "Close a Task lane and optionally remove its worktree.",
|
|
5949
5986
|
input: import_zod6.z.object({
|
|
@@ -5968,7 +6005,7 @@ var createLaneCloseTool = (sandboxKey) => (0, import_core7.defineTool)({
|
|
|
5968
6005
|
}
|
|
5969
6006
|
}
|
|
5970
6007
|
});
|
|
5971
|
-
var createLaneGcTool = (sandboxKey) => (0,
|
|
6008
|
+
var createLaneGcTool = (sandboxKey) => (0, import_core8.defineTool)({
|
|
5972
6009
|
name: "lane_gc",
|
|
5973
6010
|
description: "Close stale finished/error lanes after idle TTL.",
|
|
5974
6011
|
input: import_zod6.z.object({
|
|
@@ -5992,7 +6029,7 @@ var createLaneGcTool = (sandboxKey) => (0, import_core7.defineTool)({
|
|
|
5992
6029
|
|
|
5993
6030
|
// src/tools/read.ts
|
|
5994
6031
|
var import_node_fs11 = require("fs");
|
|
5995
|
-
var
|
|
6032
|
+
var import_core9 = require("@codelia/core");
|
|
5996
6033
|
var import_zod7 = require("zod");
|
|
5997
6034
|
var DEFAULT_READ_LIMIT = 2e3;
|
|
5998
6035
|
var DEFAULT_MAX_LINE_LENGTH = 1e3;
|
|
@@ -6047,7 +6084,7 @@ var buildTruncatedLinesSummary = (lineNumbers) => {
|
|
|
6047
6084
|
}
|
|
6048
6085
|
return `[truncated lines: ${lineNumbers.join(", ")}]`;
|
|
6049
6086
|
};
|
|
6050
|
-
var createReadTool = (sandboxKey) => (0,
|
|
6087
|
+
var createReadTool = (sandboxKey) => (0, import_core9.defineTool)({
|
|
6051
6088
|
name: "read",
|
|
6052
6089
|
description: "Read a bounded text-file preview by 0-based line offset/limit; large output is truncated and long lines should fall back to read_line.",
|
|
6053
6090
|
input: import_zod7.z.object({
|
|
@@ -6154,7 +6191,7 @@ For full long-line content, use read_line({"file_path":${JSON.stringify(input.fi
|
|
|
6154
6191
|
|
|
6155
6192
|
// src/tools/read-line.ts
|
|
6156
6193
|
var import_node_fs12 = require("fs");
|
|
6157
|
-
var
|
|
6194
|
+
var import_core10 = require("@codelia/core");
|
|
6158
6195
|
var import_zod8 = require("zod");
|
|
6159
6196
|
var DEFAULT_CHAR_LIMIT = 1e4;
|
|
6160
6197
|
var MAX_CHAR_LIMIT = 1e5;
|
|
@@ -6162,7 +6199,7 @@ var GRAPHEME_SEGMENTER = new Intl.Segmenter(void 0, {
|
|
|
6162
6199
|
granularity: "grapheme"
|
|
6163
6200
|
});
|
|
6164
6201
|
var splitGraphemes = (value) => Array.from(GRAPHEME_SEGMENTER.segment(value), ({ segment }) => segment);
|
|
6165
|
-
var createReadLineTool = (sandboxKey) => (0,
|
|
6202
|
+
var createReadLineTool = (sandboxKey) => (0, import_core10.defineTool)({
|
|
6166
6203
|
name: "read_line",
|
|
6167
6204
|
description: "Read one physical line as paged grapheme-based text by 1-based line number and 0-based char offset.",
|
|
6168
6205
|
input: import_zod8.z.object({
|
|
@@ -6231,7 +6268,7 @@ read_line({"file_path":${JSON.stringify(input.file_path)},"line_number":${input.
|
|
|
6231
6268
|
});
|
|
6232
6269
|
|
|
6233
6270
|
// src/tools/search.ts
|
|
6234
|
-
var
|
|
6271
|
+
var import_core11 = require("@codelia/core");
|
|
6235
6272
|
var import_zod9 = require("zod");
|
|
6236
6273
|
var normalizeDomain = (value) => value.trim().toLowerCase().replace(/\.+$/, "");
|
|
6237
6274
|
var shouldKeepUrl = (url, allowedDomains) => {
|
|
@@ -6348,7 +6385,7 @@ var runBraveSearch = async (query, maxResults, allowedDomains, apiKey) => {
|
|
|
6348
6385
|
const parsed = parseBrave(payload);
|
|
6349
6386
|
return normalizeEntries(parsed, allowedDomains, maxResults);
|
|
6350
6387
|
};
|
|
6351
|
-
var createSearchTool = (options) => (0,
|
|
6388
|
+
var createSearchTool = (options) => (0, import_core11.defineTool)({
|
|
6352
6389
|
name: "search",
|
|
6353
6390
|
description: "Search the web and return concise source candidates.",
|
|
6354
6391
|
input: import_zod9.z.object({
|
|
@@ -6391,7 +6428,7 @@ var createSearchTool = (options) => (0, import_core10.defineTool)({
|
|
|
6391
6428
|
|
|
6392
6429
|
// src/tools/shell.ts
|
|
6393
6430
|
var import_node_crypto7 = __toESM(require("crypto"), 1);
|
|
6394
|
-
var
|
|
6431
|
+
var import_core12 = require("@codelia/core");
|
|
6395
6432
|
var import_storage7 = require("@codelia/storage");
|
|
6396
6433
|
var import_zod10 = require("zod");
|
|
6397
6434
|
|
|
@@ -7351,7 +7388,7 @@ var waitForManagedTaskWindow = async (tasks, taskId, options) => {
|
|
|
7351
7388
|
};
|
|
7352
7389
|
var createShellTool = (sandboxKey, options = {}) => {
|
|
7353
7390
|
const shared = getSharedDeps(options);
|
|
7354
|
-
return (0,
|
|
7391
|
+
return (0, import_core12.defineTool)({
|
|
7355
7392
|
name: "shell",
|
|
7356
7393
|
description: "Run a shell command as a runtime-managed child process in the sandbox. Terminal results use `stdout`/`stderr` stream fields; successful results suppress `stderr` by default unless `include_stderr_on_success=true`, and `shell_logs` is available when you need explicit stream reads. By default wait for completion; with `detached_wait=true`, skip the attached wait and return compact JSON with the task key for follow-up tools.",
|
|
7357
7394
|
input: shellRunSchema,
|
|
@@ -7417,7 +7454,7 @@ var createShellTool = (sandboxKey, options = {}) => {
|
|
|
7417
7454
|
};
|
|
7418
7455
|
var createShellListTool = (options = {}) => {
|
|
7419
7456
|
const shared = getSharedDeps(options);
|
|
7420
|
-
return (0,
|
|
7457
|
+
return (0, import_core12.defineTool)({
|
|
7421
7458
|
name: "shell_list",
|
|
7422
7459
|
description: "List retained shell tasks with compact summaries, defaulting to active tasks.",
|
|
7423
7460
|
input: shellListSchema,
|
|
@@ -7448,7 +7485,7 @@ var createShellListTool = (options = {}) => {
|
|
|
7448
7485
|
};
|
|
7449
7486
|
var createShellStatusTool = (options = {}) => {
|
|
7450
7487
|
const shared = getSharedDeps(options);
|
|
7451
|
-
return (0,
|
|
7488
|
+
return (0, import_core12.defineTool)({
|
|
7452
7489
|
name: "shell_status",
|
|
7453
7490
|
description: "Get the current state for a shell task as compact JSON.",
|
|
7454
7491
|
input: shellTaskKeySchema,
|
|
@@ -7464,7 +7501,7 @@ var createShellStatusTool = (options = {}) => {
|
|
|
7464
7501
|
};
|
|
7465
7502
|
var createShellLogsTool = (options = {}) => {
|
|
7466
7503
|
const shared = getSharedDeps(options);
|
|
7467
|
-
return (0,
|
|
7504
|
+
return (0, import_core12.defineTool)({
|
|
7468
7505
|
name: "shell_logs",
|
|
7469
7506
|
description: "Read recent stdout or stderr for a running or finished shell task. Use this when a compact shell terminal result omitted a stream, such as `stderr` on success.",
|
|
7470
7507
|
input: shellLogsSchema,
|
|
@@ -7486,7 +7523,7 @@ var createShellLogsTool = (options = {}) => {
|
|
|
7486
7523
|
};
|
|
7487
7524
|
var createShellWaitTool = (options = {}) => {
|
|
7488
7525
|
const shared = getSharedDeps(options);
|
|
7489
|
-
return (0,
|
|
7526
|
+
return (0, import_core12.defineTool)({
|
|
7490
7527
|
name: "shell_wait",
|
|
7491
7528
|
description: "Wait for a shell task within a bounded window and return compact JSON describing either the running status or a terminal result with `stdout`/`stderr` stream fields. Successful terminal results suppress `stderr` by default unless `include_stderr_on_success=true`; use `shell_logs` for explicit stream reads.",
|
|
7492
7529
|
input: shellWaitSchema,
|
|
@@ -7521,7 +7558,7 @@ var createShellWaitTool = (options = {}) => {
|
|
|
7521
7558
|
};
|
|
7522
7559
|
var createShellResultTool = (options = {}) => {
|
|
7523
7560
|
const shared = getSharedDeps(options);
|
|
7524
|
-
return (0,
|
|
7561
|
+
return (0, import_core12.defineTool)({
|
|
7525
7562
|
name: "shell_result",
|
|
7526
7563
|
description: "Read the retained terminal result for a shell task as compact JSON with `stdout`/`stderr` stream fields. Successful terminal results suppress `stderr` by default unless `include_stderr_on_success=true`; use `shell_logs` for explicit stream reads.",
|
|
7527
7564
|
input: shellResultSchema,
|
|
@@ -7540,7 +7577,7 @@ var createShellResultTool = (options = {}) => {
|
|
|
7540
7577
|
};
|
|
7541
7578
|
var createShellCancelTool = (options = {}) => {
|
|
7542
7579
|
const shared = getSharedDeps(options);
|
|
7543
|
-
return (0,
|
|
7580
|
+
return (0, import_core12.defineTool)({
|
|
7544
7581
|
name: "shell_cancel",
|
|
7545
7582
|
description: "Cancel a running shell task and return compact JSON for the cancelled state.",
|
|
7546
7583
|
input: shellTaskKeySchema,
|
|
@@ -7559,7 +7596,7 @@ var createShellCancelTool = (options = {}) => {
|
|
|
7559
7596
|
};
|
|
7560
7597
|
|
|
7561
7598
|
// src/tools/skill-load.ts
|
|
7562
|
-
var
|
|
7599
|
+
var import_core13 = require("@codelia/core");
|
|
7563
7600
|
var import_zod11 = require("zod");
|
|
7564
7601
|
var SkillLoadInputSchema = import_zod11.z.object({
|
|
7565
7602
|
name: import_zod11.z.string().min(1).optional().describe("Exact skill name to load."),
|
|
@@ -7568,7 +7605,7 @@ var SkillLoadInputSchema = import_zod11.z.object({
|
|
|
7568
7605
|
message: "name or path is required",
|
|
7569
7606
|
path: ["name"]
|
|
7570
7607
|
});
|
|
7571
|
-
var createSkillLoadTool = (skillsResolverKey) => (0,
|
|
7608
|
+
var createSkillLoadTool = (skillsResolverKey) => (0, import_core13.defineTool)({
|
|
7572
7609
|
name: "skill_load",
|
|
7573
7610
|
description: "Load full SKILL.md content by exact name or path.",
|
|
7574
7611
|
input: SkillLoadInputSchema,
|
|
@@ -7614,9 +7651,9 @@ var createSkillLoadTool = (skillsResolverKey) => (0, import_core12.defineTool)({
|
|
|
7614
7651
|
});
|
|
7615
7652
|
|
|
7616
7653
|
// src/tools/skill-search.ts
|
|
7617
|
-
var
|
|
7654
|
+
var import_core14 = require("@codelia/core");
|
|
7618
7655
|
var import_zod12 = require("zod");
|
|
7619
|
-
var createSkillSearchTool = (skillsResolverKey) => (0,
|
|
7656
|
+
var createSkillSearchTool = (skillsResolverKey) => (0, import_core14.defineTool)({
|
|
7620
7657
|
name: "skill_search",
|
|
7621
7658
|
description: "Search installed local skills by name, description, or path.",
|
|
7622
7659
|
input: import_zod12.z.object({
|
|
@@ -7647,7 +7684,7 @@ var createSkillSearchTool = (skillsResolverKey) => (0, import_core13.defineTool)
|
|
|
7647
7684
|
});
|
|
7648
7685
|
|
|
7649
7686
|
// src/tools/todo-mutate.ts
|
|
7650
|
-
var
|
|
7687
|
+
var import_core15 = require("@codelia/core");
|
|
7651
7688
|
var import_zod13 = require("zod");
|
|
7652
7689
|
|
|
7653
7690
|
// src/tools/todo-store.ts
|
|
@@ -7883,7 +7920,7 @@ var applyTodoMutation = (sessionId, input, outputMode) => {
|
|
|
7883
7920
|
}
|
|
7884
7921
|
return formatSuccess(outputMode, nextTodos);
|
|
7885
7922
|
};
|
|
7886
|
-
var createTodoMutationTool = (name, description, input, executeMutation, sandboxKey, sessionContextKey) => (0,
|
|
7923
|
+
var createTodoMutationTool = (name, description, input, executeMutation, sandboxKey, sessionContextKey) => (0, import_core15.defineTool)({
|
|
7887
7924
|
name,
|
|
7888
7925
|
description,
|
|
7889
7926
|
input,
|
|
@@ -7938,14 +7975,14 @@ var createTodoClearTool = (sandboxKey, sessionContextKey) => createTodoMutationT
|
|
|
7938
7975
|
);
|
|
7939
7976
|
|
|
7940
7977
|
// src/tools/todo-read.ts
|
|
7941
|
-
var
|
|
7978
|
+
var import_core16 = require("@codelia/core");
|
|
7942
7979
|
var import_zod14 = require("zod");
|
|
7943
7980
|
var statusSymbol2 = {
|
|
7944
7981
|
pending: "[ ]",
|
|
7945
7982
|
in_progress: "[>]",
|
|
7946
7983
|
completed: "[x]"
|
|
7947
7984
|
};
|
|
7948
|
-
var createTodoReadTool = (sandboxKey, sessionContextKey) => (0,
|
|
7985
|
+
var createTodoReadTool = (sandboxKey, sessionContextKey) => (0, import_core16.defineTool)({
|
|
7949
7986
|
name: "todo_read",
|
|
7950
7987
|
description: "Read the in-session todo plan with execution order and next step.",
|
|
7951
7988
|
input: import_zod14.z.object({}),
|
|
@@ -7984,9 +8021,9 @@ var createTodoReadTool = (sandboxKey, sessionContextKey) => (0, import_core15.de
|
|
|
7984
8021
|
});
|
|
7985
8022
|
|
|
7986
8023
|
// src/tools/tool-output-cache.ts
|
|
7987
|
-
var
|
|
8024
|
+
var import_core17 = require("@codelia/core");
|
|
7988
8025
|
var import_zod15 = require("zod");
|
|
7989
|
-
var createToolOutputCacheTool = (store) => (0,
|
|
8026
|
+
var createToolOutputCacheTool = (store) => (0, import_core17.defineTool)({
|
|
7990
8027
|
name: "tool_output_cache",
|
|
7991
8028
|
description: "Read cached tool output by ref_id.",
|
|
7992
8029
|
input: import_zod15.z.object({
|
|
@@ -8008,7 +8045,7 @@ var createToolOutputCacheTool = (store) => (0, import_core16.defineTool)({
|
|
|
8008
8045
|
}
|
|
8009
8046
|
}
|
|
8010
8047
|
});
|
|
8011
|
-
var createToolOutputCacheLineTool = (store) => (0,
|
|
8048
|
+
var createToolOutputCacheLineTool = (store) => (0, import_core17.defineTool)({
|
|
8012
8049
|
name: "tool_output_cache_line",
|
|
8013
8050
|
description: "Read a single cached output line segment by line number and char offset.",
|
|
8014
8051
|
input: import_zod15.z.object({
|
|
@@ -8032,7 +8069,7 @@ var createToolOutputCacheLineTool = (store) => (0, import_core16.defineTool)({
|
|
|
8032
8069
|
}
|
|
8033
8070
|
}
|
|
8034
8071
|
});
|
|
8035
|
-
var createToolOutputCacheGrepTool = (store) => (0,
|
|
8072
|
+
var createToolOutputCacheGrepTool = (store) => (0, import_core17.defineTool)({
|
|
8036
8073
|
name: "tool_output_cache_grep",
|
|
8037
8074
|
description: "Search cached tool output by ref_id.",
|
|
8038
8075
|
input: import_zod15.z.object({
|
|
@@ -8064,7 +8101,7 @@ var createToolOutputCacheGrepTool = (store) => (0, import_core16.defineTool)({
|
|
|
8064
8101
|
// src/tools/view-image.ts
|
|
8065
8102
|
var import_node_fs13 = require("fs");
|
|
8066
8103
|
var import_node_path13 = __toESM(require("path"), 1);
|
|
8067
|
-
var
|
|
8104
|
+
var import_core18 = require("@codelia/core");
|
|
8068
8105
|
var import_zod16 = require("zod");
|
|
8069
8106
|
var DEFAULT_MAX_BYTES2 = 5 * 1024 * 1024;
|
|
8070
8107
|
var MAX_MAX_BYTES = 10 * 1024 * 1024;
|
|
@@ -8078,7 +8115,7 @@ var MIME_BY_EXTENSION = {
|
|
|
8078
8115
|
var resolveImageMime = (filePath) => {
|
|
8079
8116
|
return MIME_BY_EXTENSION[import_node_path13.default.extname(filePath).toLowerCase()] ?? null;
|
|
8080
8117
|
};
|
|
8081
|
-
var createViewImageTool = (sandboxKey) => (0,
|
|
8118
|
+
var createViewImageTool = (sandboxKey) => (0, import_core18.defineTool)({
|
|
8082
8119
|
name: "view_image",
|
|
8083
8120
|
description: "Load one local png/jpeg/webp/gif image (default max 5MB) for multimodal inspection.",
|
|
8084
8121
|
input: import_zod16.z.object({
|
|
@@ -8138,7 +8175,7 @@ var createViewImageTool = (sandboxKey) => (0, import_core17.defineTool)({
|
|
|
8138
8175
|
});
|
|
8139
8176
|
|
|
8140
8177
|
// src/tools/webfetch.ts
|
|
8141
|
-
var
|
|
8178
|
+
var import_core19 = require("@codelia/core");
|
|
8142
8179
|
var import_zod17 = require("zod");
|
|
8143
8180
|
var DEFAULT_TIMEOUT_MS3 = 1e4;
|
|
8144
8181
|
var MAX_TIMEOUT_MS = 3e4;
|
|
@@ -8392,7 +8429,7 @@ var classifyFetchError = (error, timeoutMs) => {
|
|
|
8392
8429
|
})
|
|
8393
8430
|
};
|
|
8394
8431
|
};
|
|
8395
|
-
var createWebfetchTool = () => (0,
|
|
8432
|
+
var createWebfetchTool = () => (0, import_core19.defineTool)({
|
|
8396
8433
|
name: "webfetch",
|
|
8397
8434
|
description: "Fetch an HTTP(S) URL and return bounded normalized markdown/text/html for textual content, not binary downloads.",
|
|
8398
8435
|
input: import_zod17.z.object({
|
|
@@ -8474,9 +8511,9 @@ var createWebfetchTool = () => (0, import_core18.defineTool)({
|
|
|
8474
8511
|
// src/tools/write.ts
|
|
8475
8512
|
var import_node_fs14 = require("fs");
|
|
8476
8513
|
var import_node_path14 = __toESM(require("path"), 1);
|
|
8477
|
-
var
|
|
8514
|
+
var import_core20 = require("@codelia/core");
|
|
8478
8515
|
var import_zod18 = require("zod");
|
|
8479
|
-
var createWriteTool = (sandboxKey, outputCacheStore) => (0,
|
|
8516
|
+
var createWriteTool = (sandboxKey, outputCacheStore) => (0, import_core20.defineTool)({
|
|
8480
8517
|
name: "write",
|
|
8481
8518
|
description: "Write full UTF-8 text to a file, replacing any existing contents and creating parent directories if needed.",
|
|
8482
8519
|
input: import_zod18.z.object({
|
|
@@ -8796,13 +8833,28 @@ var resolveModelMaxTokensFromEntry = (entry) => {
|
|
|
8796
8833
|
}
|
|
8797
8834
|
return null;
|
|
8798
8835
|
};
|
|
8836
|
+
var resolveAnthropicStaticModelMaxTokens = (model) => {
|
|
8837
|
+
const spec = (0, import_core21.resolveModel)(import_core21.DEFAULT_MODEL_REGISTRY, model, "anthropic");
|
|
8838
|
+
const candidates = [
|
|
8839
|
+
spec?.maxOutputTokens,
|
|
8840
|
+
spec?.maxInputTokens,
|
|
8841
|
+
spec?.contextWindow
|
|
8842
|
+
];
|
|
8843
|
+
for (const value of candidates) {
|
|
8844
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
|
|
8845
|
+
continue;
|
|
8846
|
+
}
|
|
8847
|
+
return Math.trunc(value);
|
|
8848
|
+
}
|
|
8849
|
+
return null;
|
|
8850
|
+
};
|
|
8799
8851
|
var resolveAnthropicModelMaxTokens = async (model) => {
|
|
8800
8852
|
const metadataService = new import_model_metadata2.ModelMetadataServiceImpl({
|
|
8801
8853
|
storagePathService: new import_storage8.StoragePathServiceImpl()
|
|
8802
8854
|
});
|
|
8803
8855
|
const direct = await metadataService.getModelEntry("anthropic", model);
|
|
8804
8856
|
const prefixed = model.startsWith("anthropic/") ? null : await metadataService.getModelEntry("anthropic", `anthropic/${model}`);
|
|
8805
|
-
return resolveModelMaxTokensFromEntry(direct) ?? resolveModelMaxTokensFromEntry(prefixed);
|
|
8857
|
+
return resolveModelMaxTokensFromEntry(direct) ?? resolveModelMaxTokensFromEntry(prefixed) ?? resolveAnthropicStaticModelMaxTokens(model);
|
|
8806
8858
|
};
|
|
8807
8859
|
var sleep2 = (ms) => new Promise((resolve) => {
|
|
8808
8860
|
setTimeout(resolve, ms);
|
|
@@ -9174,12 +9226,13 @@ var createAgentFactory = (state, options = {}) => {
|
|
|
9174
9226
|
let llm;
|
|
9175
9227
|
let resolvedModelName = null;
|
|
9176
9228
|
const requestedReasoning = resolveReasoningEffort(modelConfig.reasoning) ?? "medium";
|
|
9229
|
+
const isFastRequested = modelConfig.fast === true;
|
|
9177
9230
|
switch (provider) {
|
|
9178
9231
|
case "openai": {
|
|
9179
|
-
const modelName = modelConfig.name ??
|
|
9232
|
+
const modelName = modelConfig.name ?? import_core21.OPENAI_DEFAULT_MODEL;
|
|
9180
9233
|
resolvedModelName = modelName;
|
|
9181
|
-
const providerModelName = (0,
|
|
9182
|
-
|
|
9234
|
+
const providerModelName = (0, import_core21.resolveProviderModelId)(
|
|
9235
|
+
import_core21.DEFAULT_MODEL_REGISTRY,
|
|
9183
9236
|
modelName,
|
|
9184
9237
|
"openai"
|
|
9185
9238
|
) ?? modelName;
|
|
@@ -9189,7 +9242,12 @@ var createAgentFactory = (state, options = {}) => {
|
|
|
9189
9242
|
});
|
|
9190
9243
|
const textVerbosity = resolveTextVerbosity(modelConfig.verbosity);
|
|
9191
9244
|
const websocketMode = modelConfig.experimental?.openai?.websocket_mode;
|
|
9192
|
-
|
|
9245
|
+
const fastMode = resolveFastMode({
|
|
9246
|
+
provider: "openai",
|
|
9247
|
+
model: modelName,
|
|
9248
|
+
requested: isFastRequested
|
|
9249
|
+
});
|
|
9250
|
+
llm = new import_core21.ChatOpenAI({
|
|
9193
9251
|
clientOptions: buildOpenAiClientOptions(authResolver, providerAuth),
|
|
9194
9252
|
model: modelName,
|
|
9195
9253
|
providerModel: providerModelName,
|
|
@@ -9198,19 +9256,20 @@ var createAgentFactory = (state, options = {}) => {
|
|
|
9198
9256
|
reasoningLevelApplied: reasoning.applied,
|
|
9199
9257
|
reasoningFallbackApplied: reasoning.fallbackApplied,
|
|
9200
9258
|
...textVerbosity ? { textVerbosity } : {},
|
|
9259
|
+
...fastMode.enabled && fastMode.provider === "openai" ? { serviceTier: fastMode.serviceTier } : {},
|
|
9201
9260
|
...websocketMode ? { websocketMode } : {}
|
|
9202
9261
|
});
|
|
9203
9262
|
break;
|
|
9204
9263
|
}
|
|
9205
9264
|
case "openrouter": {
|
|
9206
|
-
const modelName = modelConfig.name ??
|
|
9265
|
+
const modelName = modelConfig.name ?? import_core21.OPENAI_DEFAULT_MODEL;
|
|
9207
9266
|
resolvedModelName = modelName;
|
|
9208
9267
|
const reasoning = resolveResponsesReasoning({
|
|
9209
9268
|
model: modelName,
|
|
9210
9269
|
requested: requestedReasoning
|
|
9211
9270
|
});
|
|
9212
9271
|
const textVerbosity = resolveTextVerbosity(modelConfig.verbosity);
|
|
9213
|
-
llm = new
|
|
9272
|
+
llm = new import_core21.ChatOpenRouter({
|
|
9214
9273
|
clientOptions: buildOpenRouterClientOptions(providerAuth),
|
|
9215
9274
|
model: modelName,
|
|
9216
9275
|
reasoningEffort: reasoning.effort,
|
|
@@ -9222,7 +9281,7 @@ var createAgentFactory = (state, options = {}) => {
|
|
|
9222
9281
|
break;
|
|
9223
9282
|
}
|
|
9224
9283
|
case "anthropic": {
|
|
9225
|
-
const modelName = modelConfig.name ??
|
|
9284
|
+
const modelName = modelConfig.name ?? import_core21.ANTHROPIC_DEFAULT_MODEL;
|
|
9226
9285
|
resolvedModelName = modelName;
|
|
9227
9286
|
const reasoning = resolveAnthropicReasoning({
|
|
9228
9287
|
model: modelName,
|
|
@@ -9235,27 +9294,34 @@ var createAgentFactory = (state, options = {}) => {
|
|
|
9235
9294
|
});
|
|
9236
9295
|
const modelMaxTokens = await resolveAnthropicModelMaxTokens(modelName);
|
|
9237
9296
|
const maxTokens = resolveAnthropicMaxTokens({
|
|
9238
|
-
thinkingBudgetTokens: reasoning.thinking.budget_tokens,
|
|
9297
|
+
thinkingBudgetTokens: reasoning.thinking.type === "enabled" ? reasoning.thinking.budget_tokens : 0,
|
|
9239
9298
|
modelLimitMaxTokens: modelMaxTokens
|
|
9240
9299
|
});
|
|
9241
|
-
if (typeof modelMaxTokens === "number" && modelMaxTokens <= reasoning.thinking.budget_tokens) {
|
|
9300
|
+
if (reasoning.thinking.type === "enabled" && typeof modelMaxTokens === "number" && modelMaxTokens <= reasoning.thinking.budget_tokens) {
|
|
9242
9301
|
(0, import_logger.log)(
|
|
9243
9302
|
`anthropic model '${modelName}' max token limit (${modelMaxTokens}) is not above thinking budget (${reasoning.thinking.budget_tokens}); using max_tokens=${maxTokens} to satisfy API constraint`
|
|
9244
9303
|
);
|
|
9245
9304
|
}
|
|
9246
|
-
|
|
9305
|
+
const fastMode = resolveFastMode({
|
|
9306
|
+
provider: "anthropic",
|
|
9307
|
+
model: modelName,
|
|
9308
|
+
requested: isFastRequested
|
|
9309
|
+
});
|
|
9310
|
+
llm = new import_core21.ChatAnthropic({
|
|
9247
9311
|
clientOptions: {
|
|
9248
9312
|
apiKey: requireApiKeyAuth("Anthropic", providerAuth)
|
|
9249
9313
|
},
|
|
9250
9314
|
model: modelName,
|
|
9251
9315
|
maxTokens,
|
|
9252
9316
|
invokeOptions: {
|
|
9253
|
-
thinking: reasoning.thinking
|
|
9317
|
+
thinking: reasoning.thinking,
|
|
9318
|
+
...reasoning.outputConfig ? { output_config: reasoning.outputConfig } : {}
|
|
9254
9319
|
},
|
|
9255
9320
|
reasoningLevelRequested: reasoning.requested,
|
|
9256
9321
|
reasoningLevelApplied: reasoning.applied,
|
|
9257
9322
|
reasoningFallbackApplied: reasoning.fallbackApplied,
|
|
9258
|
-
reasoningBudgetPreset: reasoning.budgetPreset
|
|
9323
|
+
reasoningBudgetPreset: reasoning.budgetPreset,
|
|
9324
|
+
...fastMode.enabled && fastMode.provider === "anthropic" ? { fastMode: true } : {}
|
|
9259
9325
|
});
|
|
9260
9326
|
break;
|
|
9261
9327
|
}
|
|
@@ -9270,12 +9336,12 @@ var createAgentFactory = (state, options = {}) => {
|
|
|
9270
9336
|
const totalBudgetTrimEnabled = envTruthy(
|
|
9271
9337
|
process.env.CODELIA_TOOL_OUTPUT_TOTAL_TRIM
|
|
9272
9338
|
);
|
|
9273
|
-
const agent = new
|
|
9339
|
+
const agent = new import_core21.Agent({
|
|
9274
9340
|
llm,
|
|
9275
9341
|
tools,
|
|
9276
9342
|
hostedTools: hostedSearchDefinitions,
|
|
9277
9343
|
systemPrompt,
|
|
9278
|
-
modelRegistry: modelRegistry ??
|
|
9344
|
+
modelRegistry: modelRegistry ?? import_core21.DEFAULT_MODEL_REGISTRY,
|
|
9279
9345
|
toolOutputCache: {
|
|
9280
9346
|
totalBudgetTrim: totalBudgetTrimEnabled
|
|
9281
9347
|
},
|
|
@@ -11109,7 +11175,7 @@ var createHistoryHandlers = ({
|
|
|
11109
11175
|
};
|
|
11110
11176
|
|
|
11111
11177
|
// src/rpc/model.ts
|
|
11112
|
-
var
|
|
11178
|
+
var import_core22 = require("@codelia/core");
|
|
11113
11179
|
var import_model_metadata3 = require("@codelia/model-metadata");
|
|
11114
11180
|
var import_protocol4 = require("@codelia/protocol");
|
|
11115
11181
|
var isSupportedProvider = (provider) => provider === "openai" || provider === "anthropic" || provider === "openrouter";
|
|
@@ -11117,7 +11183,7 @@ var resolveProviderModelEntry2 = (providerEntries, provider, model) => {
|
|
|
11117
11183
|
if (!providerEntries) {
|
|
11118
11184
|
return null;
|
|
11119
11185
|
}
|
|
11120
|
-
const providerModelId = (0,
|
|
11186
|
+
const providerModelId = (0, import_core22.resolveProviderModelId)(import_core22.DEFAULT_MODEL_REGISTRY, model, provider) ?? model;
|
|
11121
11187
|
const candidates = [
|
|
11122
11188
|
model,
|
|
11123
11189
|
`${provider}/${model}`,
|
|
@@ -11146,7 +11212,7 @@ var normalizeUsdPer1M = (value) => {
|
|
|
11146
11212
|
return value;
|
|
11147
11213
|
};
|
|
11148
11214
|
var buildModelListDetail = (entry, registry, provider, model) => {
|
|
11149
|
-
const spec = (0,
|
|
11215
|
+
const spec = (0, import_core22.resolveModel)(registry, model, provider);
|
|
11150
11216
|
if (!entry && !spec) return null;
|
|
11151
11217
|
const detail = {};
|
|
11152
11218
|
if (entry?.releaseDate?.trim()) {
|
|
@@ -11372,22 +11438,24 @@ var buildProviderModelList = async ({
|
|
|
11372
11438
|
}
|
|
11373
11439
|
}
|
|
11374
11440
|
}
|
|
11441
|
+
const mergedRegistry = (0, import_core22.applyModelMetadata)(import_core22.DEFAULT_MODEL_REGISTRY, {
|
|
11442
|
+
models: {
|
|
11443
|
+
openai: provider === "openai" ? providerEntries ?? {} : {},
|
|
11444
|
+
anthropic: provider === "anthropic" ? providerEntries ?? {} : {},
|
|
11445
|
+
openrouter: {},
|
|
11446
|
+
google: {}
|
|
11447
|
+
}
|
|
11448
|
+
});
|
|
11375
11449
|
const models = sortModelsByReleaseDate(
|
|
11376
|
-
(0,
|
|
11450
|
+
(0, import_core22.listModels)(import_core22.DEFAULT_MODEL_REGISTRY, provider).filter(
|
|
11451
|
+
(model) => (0, import_core22.isUsableModelSpec)((0, import_core22.resolveModel)(mergedRegistry, model.id, provider))
|
|
11452
|
+
).map((model) => model.id),
|
|
11377
11453
|
provider,
|
|
11378
11454
|
providerEntries
|
|
11379
11455
|
);
|
|
11380
11456
|
if (!includeDetails || !providerEntries) {
|
|
11381
11457
|
return { models };
|
|
11382
11458
|
}
|
|
11383
|
-
const mergedRegistry = (0, import_core21.applyModelMetadata)(import_core21.DEFAULT_MODEL_REGISTRY, {
|
|
11384
|
-
models: {
|
|
11385
|
-
openai: provider === "openai" ? providerEntries : {},
|
|
11386
|
-
anthropic: provider === "anthropic" ? providerEntries : {},
|
|
11387
|
-
openrouter: {},
|
|
11388
|
-
google: {}
|
|
11389
|
-
}
|
|
11390
|
-
});
|
|
11391
11459
|
const details = {};
|
|
11392
11460
|
for (const model of models) {
|
|
11393
11461
|
const detail = buildModelListDetail(
|
|
@@ -11419,6 +11487,7 @@ var createModelHandlers = ({
|
|
|
11419
11487
|
let current;
|
|
11420
11488
|
let configuredProvider;
|
|
11421
11489
|
let configuredReasoning;
|
|
11490
|
+
let configuredFast;
|
|
11422
11491
|
try {
|
|
11423
11492
|
const config = await resolveModelConfig();
|
|
11424
11493
|
configuredProvider = config.provider ?? "openai";
|
|
@@ -11426,6 +11495,13 @@ var createModelHandlers = ({
|
|
|
11426
11495
|
if (!requestedProvider || requestedProvider === configuredProvider) {
|
|
11427
11496
|
current = config.name;
|
|
11428
11497
|
}
|
|
11498
|
+
if (config.fast !== void 0 && config.name && isSupportedProvider(configuredProvider)) {
|
|
11499
|
+
configuredFast = resolveFastMode({
|
|
11500
|
+
provider: configuredProvider,
|
|
11501
|
+
model: config.name,
|
|
11502
|
+
requested: config.fast
|
|
11503
|
+
}).enabled;
|
|
11504
|
+
}
|
|
11429
11505
|
} catch (error) {
|
|
11430
11506
|
sendError(id, {
|
|
11431
11507
|
code: import_protocol4.RPC_ERROR_CODE.RUNTIME_INTERNAL,
|
|
@@ -11467,6 +11543,7 @@ var createModelHandlers = ({
|
|
|
11467
11543
|
models,
|
|
11468
11544
|
current,
|
|
11469
11545
|
...configuredReasoning ? { reasoning: configuredReasoning } : {},
|
|
11546
|
+
...configuredFast !== void 0 ? { fast: configuredFast } : {},
|
|
11470
11547
|
...details ? { details } : {}
|
|
11471
11548
|
};
|
|
11472
11549
|
sendResult(id, result);
|
|
@@ -11508,7 +11585,7 @@ var createModelHandlers = ({
|
|
|
11508
11585
|
return;
|
|
11509
11586
|
}
|
|
11510
11587
|
if (provider !== "openrouter") {
|
|
11511
|
-
const spec = (0,
|
|
11588
|
+
const spec = (0, import_core22.resolveModel)(import_core22.DEFAULT_MODEL_REGISTRY, name, provider);
|
|
11512
11589
|
if (!spec) {
|
|
11513
11590
|
sendError(id, {
|
|
11514
11591
|
code: import_protocol4.RPC_ERROR_CODE.INVALID_PARAMS,
|
|
@@ -11522,7 +11599,8 @@ var createModelHandlers = ({
|
|
|
11522
11599
|
const target = await updateModel(workingDir, {
|
|
11523
11600
|
provider,
|
|
11524
11601
|
name,
|
|
11525
|
-
...reasoning ? { reasoning } : {}
|
|
11602
|
+
...reasoning ? { reasoning } : {},
|
|
11603
|
+
...params.fast !== void 0 ? { fast: params.fast } : {}
|
|
11526
11604
|
});
|
|
11527
11605
|
state.currentModelProvider = provider;
|
|
11528
11606
|
state.currentModelName = name;
|
|
@@ -11531,10 +11609,16 @@ var createModelHandlers = ({
|
|
|
11531
11609
|
const effectiveReasoning = resolveReasoningEffort(
|
|
11532
11610
|
updatedConfig.reasoning
|
|
11533
11611
|
);
|
|
11612
|
+
const effectiveFast = resolveFastMode({
|
|
11613
|
+
provider,
|
|
11614
|
+
model: name,
|
|
11615
|
+
requested: updatedConfig.fast
|
|
11616
|
+
}).enabled;
|
|
11534
11617
|
const result = {
|
|
11535
11618
|
provider,
|
|
11536
11619
|
name,
|
|
11537
|
-
...effectiveReasoning ? { reasoning: effectiveReasoning } : {}
|
|
11620
|
+
...effectiveReasoning ? { reasoning: effectiveReasoning } : {},
|
|
11621
|
+
...updatedConfig.fast !== void 0 ? { fast: effectiveFast } : {}
|
|
11538
11622
|
};
|
|
11539
11623
|
sendResult(id, result);
|
|
11540
11624
|
log2(
|
|
@@ -11554,7 +11638,7 @@ var createModelHandlers = ({
|
|
|
11554
11638
|
var import_protocol5 = require("@codelia/protocol");
|
|
11555
11639
|
|
|
11556
11640
|
// src/rpc/run-debug.ts
|
|
11557
|
-
var
|
|
11641
|
+
var import_core23 = require("@codelia/core");
|
|
11558
11642
|
var DEBUG_MAX_CONTENT_CHARS = 2e3;
|
|
11559
11643
|
var DEBUG_MAX_LOG_CHARS = 2e4;
|
|
11560
11644
|
var DEBUG_MAX_EVENT_RESULT_CHARS = 500;
|
|
@@ -11576,7 +11660,7 @@ var stringifyUnknown = (value) => {
|
|
|
11576
11660
|
}
|
|
11577
11661
|
};
|
|
11578
11662
|
var contentToDebugText = (content, maxChars) => {
|
|
11579
|
-
const text = (0,
|
|
11663
|
+
const text = (0, import_core23.stringifyContent)(content, {
|
|
11580
11664
|
mode: "log",
|
|
11581
11665
|
joiner: "\n",
|
|
11582
11666
|
includeOtherPayload: true
|
|
@@ -11963,8 +12047,12 @@ var summarizeTrackedFileDiff = (label, savedFiles, currentFiles) => {
|
|
|
11963
12047
|
if (savedFiles.length === 0 && currentFiles.length === 0) {
|
|
11964
12048
|
return [];
|
|
11965
12049
|
}
|
|
11966
|
-
const savedByPath = new Map(
|
|
11967
|
-
|
|
12050
|
+
const savedByPath = new Map(
|
|
12051
|
+
savedFiles.map((file) => [file.path, file.mtime_ms])
|
|
12052
|
+
);
|
|
12053
|
+
const currentByPath = new Map(
|
|
12054
|
+
currentFiles.map((file) => [file.path, file.mtime_ms])
|
|
12055
|
+
);
|
|
11968
12056
|
const details = [];
|
|
11969
12057
|
for (const [filePath, savedMtime] of savedByPath) {
|
|
11970
12058
|
const currentMtime = currentByPath.get(filePath);
|
|
@@ -11989,7 +12077,9 @@ var summarizeCurrentLoadedSkillDiff = (savedSkills, currentSkills) => (async ()
|
|
|
11989
12077
|
if (savedSkills.length === 0 && currentSkills.length === 0) {
|
|
11990
12078
|
return [];
|
|
11991
12079
|
}
|
|
11992
|
-
const savedByPath = new Map(
|
|
12080
|
+
const savedByPath = new Map(
|
|
12081
|
+
savedSkills.map((file) => [file.path, file.mtime_ms])
|
|
12082
|
+
);
|
|
11993
12083
|
const currentByPath = new Map(
|
|
11994
12084
|
currentSkills.map((file) => [file.path, file.mtime_ms])
|
|
11995
12085
|
);
|
|
@@ -12668,7 +12758,8 @@ var createRunHandlers = ({
|
|
|
12668
12758
|
model: modelConfig ? {
|
|
12669
12759
|
provider: modelConfig.provider,
|
|
12670
12760
|
name: modelConfig.name,
|
|
12671
|
-
reasoning: modelConfig.reasoning
|
|
12761
|
+
reasoning: modelConfig.reasoning,
|
|
12762
|
+
...modelConfig.fast !== void 0 ? { fast: modelConfig.fast } : {}
|
|
12672
12763
|
} : void 0,
|
|
12673
12764
|
prompts: state.systemPrompt ? { system: state.systemPrompt } : void 0,
|
|
12674
12765
|
tools: state.toolDefinitions ? { definitions: state.toolDefinitions, source: "runtime" } : void 0,
|
|
@@ -12725,7 +12816,10 @@ var createRunHandlers = ({
|
|
|
12725
12816
|
);
|
|
12726
12817
|
const workspaceRoot = resolveSessionWorkspaceRoot(state);
|
|
12727
12818
|
const sessionMetaWithWorkspace = mergeWorkspaceRootIntoSessionMeta(sessionMeta, workspaceRoot);
|
|
12728
|
-
const sessionMetaWithResumeContext = mergeResumeContextIntoSessionMeta(
|
|
12819
|
+
const sessionMetaWithResumeContext = mergeResumeContextIntoSessionMeta(
|
|
12820
|
+
sessionMetaWithWorkspace,
|
|
12821
|
+
state
|
|
12822
|
+
);
|
|
12729
12823
|
const snapshot = buildSessionState(
|
|
12730
12824
|
sessionId,
|
|
12731
12825
|
runId,
|
package/dist/index.js
CHANGED
|
@@ -371,8 +371,9 @@ import {
|
|
|
371
371
|
ChatAnthropic,
|
|
372
372
|
ChatOpenAI,
|
|
373
373
|
ChatOpenRouter,
|
|
374
|
-
DEFAULT_MODEL_REGISTRY as
|
|
374
|
+
DEFAULT_MODEL_REGISTRY as DEFAULT_MODEL_REGISTRY3,
|
|
375
375
|
OPENAI_DEFAULT_MODEL,
|
|
376
|
+
resolveModel as resolveModel2,
|
|
376
377
|
resolveProviderModelId as resolveProviderModelId2
|
|
377
378
|
} from "@codelia/core";
|
|
378
379
|
import { ModelMetadataServiceImpl as ModelMetadataServiceImpl2 } from "@codelia/model-metadata";
|
|
@@ -804,6 +805,7 @@ var resolveModelConfig = async (workingDir) => {
|
|
|
804
805
|
name: effective.model?.name,
|
|
805
806
|
reasoning: effective.model?.reasoning,
|
|
806
807
|
verbosity: effective.model?.verbosity,
|
|
808
|
+
fast: effective.model?.fast,
|
|
807
809
|
experimental: effective.experimental
|
|
808
810
|
};
|
|
809
811
|
};
|
|
@@ -2388,6 +2390,15 @@ var ANTHROPIC_BUDGET_PRESET_TOKENS = {
|
|
|
2388
2390
|
};
|
|
2389
2391
|
var ANTHROPIC_MAX_TOKENS_FALLBACK_HEADROOM = 4096;
|
|
2390
2392
|
var ANTHROPIC_REASONING_MODEL_TABLE = {
|
|
2393
|
+
"claude-opus-4-7": {
|
|
2394
|
+
supportedLevels: ["low", "medium", "high", "xhigh"],
|
|
2395
|
+
budgetPresetByLevel: {
|
|
2396
|
+
low: "reasoning_low",
|
|
2397
|
+
medium: "reasoning_medium",
|
|
2398
|
+
high: "reasoning_high",
|
|
2399
|
+
xhigh: "reasoning_xhigh"
|
|
2400
|
+
}
|
|
2401
|
+
},
|
|
2391
2402
|
"claude-opus-4-6": {
|
|
2392
2403
|
supportedLevels: ["low", "medium", "high", "xhigh"],
|
|
2393
2404
|
budgetPresetByLevel: {
|
|
@@ -2459,6 +2470,8 @@ var ANTHROPIC_REASONING_MODEL_TABLE = {
|
|
|
2459
2470
|
}
|
|
2460
2471
|
}
|
|
2461
2472
|
};
|
|
2473
|
+
var ANTHROPIC_ADAPTIVE_THINKING_MODELS = /* @__PURE__ */ new Set(["claude-opus-4-7"]);
|
|
2474
|
+
var toAnthropicOutputEffort = (level) => level === "xhigh" ? "max" : level;
|
|
2462
2475
|
var normalizeRequestedReasoning = (value) => value ?? DEFAULT_REASONING_LEVEL;
|
|
2463
2476
|
var resolveNearestSupportedLevel = (requested, supportedLevels) => {
|
|
2464
2477
|
const supported = new Set(supportedLevels);
|
|
@@ -2539,9 +2552,16 @@ var resolveAnthropicReasoning = ({
|
|
|
2539
2552
|
const budgetTokens = ANTHROPIC_BUDGET_PRESET_TOKENS[preset];
|
|
2540
2553
|
return {
|
|
2541
2554
|
...resolution,
|
|
2542
|
-
|
|
2543
|
-
type: "
|
|
2544
|
-
|
|
2555
|
+
...ANTHROPIC_ADAPTIVE_THINKING_MODELS.has(model) ? {
|
|
2556
|
+
thinking: { type: "adaptive" },
|
|
2557
|
+
outputConfig: {
|
|
2558
|
+
effort: toAnthropicOutputEffort(resolution.applied)
|
|
2559
|
+
}
|
|
2560
|
+
} : {
|
|
2561
|
+
thinking: {
|
|
2562
|
+
type: "enabled",
|
|
2563
|
+
budget_tokens: budgetTokens
|
|
2564
|
+
}
|
|
2545
2565
|
},
|
|
2546
2566
|
budgetPreset: preset,
|
|
2547
2567
|
usedFallbackModelProfile
|
|
@@ -2559,10 +2579,29 @@ var resolveAnthropicMaxTokens = ({
|
|
|
2559
2579
|
return normalizedBudget + ANTHROPIC_MAX_TOKENS_FALLBACK_HEADROOM;
|
|
2560
2580
|
};
|
|
2561
2581
|
|
|
2582
|
+
// src/model-fast.ts
|
|
2583
|
+
import { DEFAULT_MODEL_REGISTRY, supportsFastMode } from "@codelia/core";
|
|
2584
|
+
var resolveFastMode = (params) => {
|
|
2585
|
+
if (params.requested !== true) {
|
|
2586
|
+
return { enabled: false };
|
|
2587
|
+
}
|
|
2588
|
+
if (!supportsFastMode(DEFAULT_MODEL_REGISTRY, params.model, params.provider)) {
|
|
2589
|
+
return { enabled: false };
|
|
2590
|
+
}
|
|
2591
|
+
if (params.provider === "openai") {
|
|
2592
|
+
return { enabled: true, provider: "openai", serviceTier: "priority" };
|
|
2593
|
+
}
|
|
2594
|
+
if (params.provider === "anthropic") {
|
|
2595
|
+
return { enabled: true, provider: "anthropic", fastMode: true };
|
|
2596
|
+
}
|
|
2597
|
+
return { enabled: false };
|
|
2598
|
+
};
|
|
2599
|
+
|
|
2562
2600
|
// src/model-registry.ts
|
|
2563
2601
|
import {
|
|
2564
2602
|
applyModelMetadata,
|
|
2565
|
-
DEFAULT_MODEL_REGISTRY,
|
|
2603
|
+
DEFAULT_MODEL_REGISTRY as DEFAULT_MODEL_REGISTRY2,
|
|
2604
|
+
isUsableModelSpec,
|
|
2566
2605
|
registerModels,
|
|
2567
2606
|
resolveModel,
|
|
2568
2607
|
resolveProviderModelId
|
|
@@ -2578,7 +2617,7 @@ var resolveProviderModelEntry = (providerEntries, provider, model) => {
|
|
|
2578
2617
|
return null;
|
|
2579
2618
|
}
|
|
2580
2619
|
const normalized = stripProviderPrefix(provider, model);
|
|
2581
|
-
const providerModelId = resolveProviderModelId(
|
|
2620
|
+
const providerModelId = resolveProviderModelId(DEFAULT_MODEL_REGISTRY2, model, provider) ?? normalized;
|
|
2582
2621
|
const providerModelNormalized = stripProviderPrefix(
|
|
2583
2622
|
provider,
|
|
2584
2623
|
providerModelId
|
|
@@ -2617,13 +2656,13 @@ var resolveDefaultRegistrySpec = (provider, model) => {
|
|
|
2617
2656
|
(value, index, array) => array.indexOf(value) === index
|
|
2618
2657
|
);
|
|
2619
2658
|
for (const candidate of candidates) {
|
|
2620
|
-
const spec = resolveModel(
|
|
2659
|
+
const spec = resolveModel(DEFAULT_MODEL_REGISTRY2, candidate, provider);
|
|
2621
2660
|
if (spec?.provider === provider) {
|
|
2622
2661
|
return spec;
|
|
2623
2662
|
}
|
|
2624
2663
|
}
|
|
2625
2664
|
const normalizedLower = normalized.toLowerCase();
|
|
2626
|
-
for (const spec of Object.values(
|
|
2665
|
+
for (const spec of Object.values(DEFAULT_MODEL_REGISTRY2.modelsById)) {
|
|
2627
2666
|
if (spec.provider !== provider) continue;
|
|
2628
2667
|
if (spec.id.toLowerCase() === normalizedLower) {
|
|
2629
2668
|
return spec;
|
|
@@ -2642,7 +2681,7 @@ var withOpenRouterDynamicModel = (registry, llm, entry) => {
|
|
|
2642
2681
|
const contextWindow = toPositiveInteger(entry.limits?.contextWindow) ?? toPositiveInteger(entry.limits?.inputTokens);
|
|
2643
2682
|
const maxInputTokens = toPositiveInteger(entry.limits?.inputTokens) ?? contextWindow;
|
|
2644
2683
|
const maxOutputTokens = toPositiveInteger(entry.limits?.outputTokens);
|
|
2645
|
-
if (!contextWindow && !maxInputTokens
|
|
2684
|
+
if (!contextWindow && !maxInputTokens) {
|
|
2646
2685
|
return registry;
|
|
2647
2686
|
}
|
|
2648
2687
|
const aliases = [llm.model, `${llm.provider}/${normalized}`].filter((value) => value !== normalized).filter((value, index, array) => array.indexOf(value) === index);
|
|
@@ -2690,13 +2729,13 @@ var buildModelRegistry = async (llm, options = {}) => {
|
|
|
2690
2729
|
}
|
|
2691
2730
|
if (!resolvedEntry) {
|
|
2692
2731
|
const fallbackSpec = resolveDefaultRegistrySpec(llm.provider, llm.model);
|
|
2693
|
-
if (strict && !fallbackSpec) {
|
|
2732
|
+
if (strict && !isUsableModelSpec(fallbackSpec)) {
|
|
2694
2733
|
throw new Error(
|
|
2695
|
-
`
|
|
2734
|
+
`Usable model metadata not found for ${llm.provider}/${llm.model} after refresh; add required limits to the static ModelSpec to use it without metadata`
|
|
2696
2735
|
);
|
|
2697
2736
|
}
|
|
2698
2737
|
}
|
|
2699
|
-
const baseRegistry = applyModelMetadata(
|
|
2738
|
+
const baseRegistry = applyModelMetadata(DEFAULT_MODEL_REGISTRY2, {
|
|
2700
2739
|
models: entries
|
|
2701
2740
|
});
|
|
2702
2741
|
return resolvedEntry ? withOpenRouterDynamicModel(baseRegistry, llm, resolvedEntry) : baseRegistry;
|
|
@@ -8800,13 +8839,28 @@ var resolveModelMaxTokensFromEntry = (entry) => {
|
|
|
8800
8839
|
}
|
|
8801
8840
|
return null;
|
|
8802
8841
|
};
|
|
8842
|
+
var resolveAnthropicStaticModelMaxTokens = (model) => {
|
|
8843
|
+
const spec = resolveModel2(DEFAULT_MODEL_REGISTRY3, model, "anthropic");
|
|
8844
|
+
const candidates = [
|
|
8845
|
+
spec?.maxOutputTokens,
|
|
8846
|
+
spec?.maxInputTokens,
|
|
8847
|
+
spec?.contextWindow
|
|
8848
|
+
];
|
|
8849
|
+
for (const value of candidates) {
|
|
8850
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
|
|
8851
|
+
continue;
|
|
8852
|
+
}
|
|
8853
|
+
return Math.trunc(value);
|
|
8854
|
+
}
|
|
8855
|
+
return null;
|
|
8856
|
+
};
|
|
8803
8857
|
var resolveAnthropicModelMaxTokens = async (model) => {
|
|
8804
8858
|
const metadataService = new ModelMetadataServiceImpl2({
|
|
8805
8859
|
storagePathService: new StoragePathServiceImpl3()
|
|
8806
8860
|
});
|
|
8807
8861
|
const direct = await metadataService.getModelEntry("anthropic", model);
|
|
8808
8862
|
const prefixed = model.startsWith("anthropic/") ? null : await metadataService.getModelEntry("anthropic", `anthropic/${model}`);
|
|
8809
|
-
return resolveModelMaxTokensFromEntry(direct) ?? resolveModelMaxTokensFromEntry(prefixed);
|
|
8863
|
+
return resolveModelMaxTokensFromEntry(direct) ?? resolveModelMaxTokensFromEntry(prefixed) ?? resolveAnthropicStaticModelMaxTokens(model);
|
|
8810
8864
|
};
|
|
8811
8865
|
var sleep2 = (ms) => new Promise((resolve) => {
|
|
8812
8866
|
setTimeout(resolve, ms);
|
|
@@ -9178,12 +9232,13 @@ var createAgentFactory = (state, options = {}) => {
|
|
|
9178
9232
|
let llm;
|
|
9179
9233
|
let resolvedModelName = null;
|
|
9180
9234
|
const requestedReasoning = resolveReasoningEffort(modelConfig.reasoning) ?? "medium";
|
|
9235
|
+
const isFastRequested = modelConfig.fast === true;
|
|
9181
9236
|
switch (provider) {
|
|
9182
9237
|
case "openai": {
|
|
9183
9238
|
const modelName = modelConfig.name ?? OPENAI_DEFAULT_MODEL;
|
|
9184
9239
|
resolvedModelName = modelName;
|
|
9185
9240
|
const providerModelName = resolveProviderModelId2(
|
|
9186
|
-
|
|
9241
|
+
DEFAULT_MODEL_REGISTRY3,
|
|
9187
9242
|
modelName,
|
|
9188
9243
|
"openai"
|
|
9189
9244
|
) ?? modelName;
|
|
@@ -9193,6 +9248,11 @@ var createAgentFactory = (state, options = {}) => {
|
|
|
9193
9248
|
});
|
|
9194
9249
|
const textVerbosity = resolveTextVerbosity(modelConfig.verbosity);
|
|
9195
9250
|
const websocketMode = modelConfig.experimental?.openai?.websocket_mode;
|
|
9251
|
+
const fastMode = resolveFastMode({
|
|
9252
|
+
provider: "openai",
|
|
9253
|
+
model: modelName,
|
|
9254
|
+
requested: isFastRequested
|
|
9255
|
+
});
|
|
9196
9256
|
llm = new ChatOpenAI({
|
|
9197
9257
|
clientOptions: buildOpenAiClientOptions(authResolver, providerAuth),
|
|
9198
9258
|
model: modelName,
|
|
@@ -9202,6 +9262,7 @@ var createAgentFactory = (state, options = {}) => {
|
|
|
9202
9262
|
reasoningLevelApplied: reasoning.applied,
|
|
9203
9263
|
reasoningFallbackApplied: reasoning.fallbackApplied,
|
|
9204
9264
|
...textVerbosity ? { textVerbosity } : {},
|
|
9265
|
+
...fastMode.enabled && fastMode.provider === "openai" ? { serviceTier: fastMode.serviceTier } : {},
|
|
9205
9266
|
...websocketMode ? { websocketMode } : {}
|
|
9206
9267
|
});
|
|
9207
9268
|
break;
|
|
@@ -9239,14 +9300,19 @@ var createAgentFactory = (state, options = {}) => {
|
|
|
9239
9300
|
});
|
|
9240
9301
|
const modelMaxTokens = await resolveAnthropicModelMaxTokens(modelName);
|
|
9241
9302
|
const maxTokens = resolveAnthropicMaxTokens({
|
|
9242
|
-
thinkingBudgetTokens: reasoning.thinking.budget_tokens,
|
|
9303
|
+
thinkingBudgetTokens: reasoning.thinking.type === "enabled" ? reasoning.thinking.budget_tokens : 0,
|
|
9243
9304
|
modelLimitMaxTokens: modelMaxTokens
|
|
9244
9305
|
});
|
|
9245
|
-
if (typeof modelMaxTokens === "number" && modelMaxTokens <= reasoning.thinking.budget_tokens) {
|
|
9306
|
+
if (reasoning.thinking.type === "enabled" && typeof modelMaxTokens === "number" && modelMaxTokens <= reasoning.thinking.budget_tokens) {
|
|
9246
9307
|
log(
|
|
9247
9308
|
`anthropic model '${modelName}' max token limit (${modelMaxTokens}) is not above thinking budget (${reasoning.thinking.budget_tokens}); using max_tokens=${maxTokens} to satisfy API constraint`
|
|
9248
9309
|
);
|
|
9249
9310
|
}
|
|
9311
|
+
const fastMode = resolveFastMode({
|
|
9312
|
+
provider: "anthropic",
|
|
9313
|
+
model: modelName,
|
|
9314
|
+
requested: isFastRequested
|
|
9315
|
+
});
|
|
9250
9316
|
llm = new ChatAnthropic({
|
|
9251
9317
|
clientOptions: {
|
|
9252
9318
|
apiKey: requireApiKeyAuth("Anthropic", providerAuth)
|
|
@@ -9254,12 +9320,14 @@ var createAgentFactory = (state, options = {}) => {
|
|
|
9254
9320
|
model: modelName,
|
|
9255
9321
|
maxTokens,
|
|
9256
9322
|
invokeOptions: {
|
|
9257
|
-
thinking: reasoning.thinking
|
|
9323
|
+
thinking: reasoning.thinking,
|
|
9324
|
+
...reasoning.outputConfig ? { output_config: reasoning.outputConfig } : {}
|
|
9258
9325
|
},
|
|
9259
9326
|
reasoningLevelRequested: reasoning.requested,
|
|
9260
9327
|
reasoningLevelApplied: reasoning.applied,
|
|
9261
9328
|
reasoningFallbackApplied: reasoning.fallbackApplied,
|
|
9262
|
-
reasoningBudgetPreset: reasoning.budgetPreset
|
|
9329
|
+
reasoningBudgetPreset: reasoning.budgetPreset,
|
|
9330
|
+
...fastMode.enabled && fastMode.provider === "anthropic" ? { fastMode: true } : {}
|
|
9263
9331
|
});
|
|
9264
9332
|
break;
|
|
9265
9333
|
}
|
|
@@ -9279,7 +9347,7 @@ var createAgentFactory = (state, options = {}) => {
|
|
|
9279
9347
|
tools,
|
|
9280
9348
|
hostedTools: hostedSearchDefinitions,
|
|
9281
9349
|
systemPrompt,
|
|
9282
|
-
modelRegistry: modelRegistry ??
|
|
9350
|
+
modelRegistry: modelRegistry ?? DEFAULT_MODEL_REGISTRY3,
|
|
9283
9351
|
toolOutputCache: {
|
|
9284
9352
|
totalBudgetTrim: totalBudgetTrimEnabled
|
|
9285
9353
|
},
|
|
@@ -11133,9 +11201,10 @@ var createHistoryHandlers = ({
|
|
|
11133
11201
|
// src/rpc/model.ts
|
|
11134
11202
|
import {
|
|
11135
11203
|
applyModelMetadata as applyModelMetadata2,
|
|
11136
|
-
DEFAULT_MODEL_REGISTRY as
|
|
11204
|
+
DEFAULT_MODEL_REGISTRY as DEFAULT_MODEL_REGISTRY4,
|
|
11205
|
+
isUsableModelSpec as isUsableModelSpec2,
|
|
11137
11206
|
listModels,
|
|
11138
|
-
resolveModel as
|
|
11207
|
+
resolveModel as resolveModel3,
|
|
11139
11208
|
resolveProviderModelId as resolveProviderModelId3
|
|
11140
11209
|
} from "@codelia/core";
|
|
11141
11210
|
import { ModelMetadataServiceImpl as ModelMetadataServiceImpl3 } from "@codelia/model-metadata";
|
|
@@ -11147,7 +11216,7 @@ var resolveProviderModelEntry2 = (providerEntries, provider, model) => {
|
|
|
11147
11216
|
if (!providerEntries) {
|
|
11148
11217
|
return null;
|
|
11149
11218
|
}
|
|
11150
|
-
const providerModelId = resolveProviderModelId3(
|
|
11219
|
+
const providerModelId = resolveProviderModelId3(DEFAULT_MODEL_REGISTRY4, model, provider) ?? model;
|
|
11151
11220
|
const candidates = [
|
|
11152
11221
|
model,
|
|
11153
11222
|
`${provider}/${model}`,
|
|
@@ -11176,7 +11245,7 @@ var normalizeUsdPer1M = (value) => {
|
|
|
11176
11245
|
return value;
|
|
11177
11246
|
};
|
|
11178
11247
|
var buildModelListDetail = (entry, registry, provider, model) => {
|
|
11179
|
-
const spec =
|
|
11248
|
+
const spec = resolveModel3(registry, model, provider);
|
|
11180
11249
|
if (!entry && !spec) return null;
|
|
11181
11250
|
const detail = {};
|
|
11182
11251
|
if (entry?.releaseDate?.trim()) {
|
|
@@ -11402,22 +11471,24 @@ var buildProviderModelList = async ({
|
|
|
11402
11471
|
}
|
|
11403
11472
|
}
|
|
11404
11473
|
}
|
|
11474
|
+
const mergedRegistry = applyModelMetadata2(DEFAULT_MODEL_REGISTRY4, {
|
|
11475
|
+
models: {
|
|
11476
|
+
openai: provider === "openai" ? providerEntries ?? {} : {},
|
|
11477
|
+
anthropic: provider === "anthropic" ? providerEntries ?? {} : {},
|
|
11478
|
+
openrouter: {},
|
|
11479
|
+
google: {}
|
|
11480
|
+
}
|
|
11481
|
+
});
|
|
11405
11482
|
const models = sortModelsByReleaseDate(
|
|
11406
|
-
listModels(
|
|
11483
|
+
listModels(DEFAULT_MODEL_REGISTRY4, provider).filter(
|
|
11484
|
+
(model) => isUsableModelSpec2(resolveModel3(mergedRegistry, model.id, provider))
|
|
11485
|
+
).map((model) => model.id),
|
|
11407
11486
|
provider,
|
|
11408
11487
|
providerEntries
|
|
11409
11488
|
);
|
|
11410
11489
|
if (!includeDetails || !providerEntries) {
|
|
11411
11490
|
return { models };
|
|
11412
11491
|
}
|
|
11413
|
-
const mergedRegistry = applyModelMetadata2(DEFAULT_MODEL_REGISTRY3, {
|
|
11414
|
-
models: {
|
|
11415
|
-
openai: provider === "openai" ? providerEntries : {},
|
|
11416
|
-
anthropic: provider === "anthropic" ? providerEntries : {},
|
|
11417
|
-
openrouter: {},
|
|
11418
|
-
google: {}
|
|
11419
|
-
}
|
|
11420
|
-
});
|
|
11421
11492
|
const details = {};
|
|
11422
11493
|
for (const model of models) {
|
|
11423
11494
|
const detail = buildModelListDetail(
|
|
@@ -11449,6 +11520,7 @@ var createModelHandlers = ({
|
|
|
11449
11520
|
let current;
|
|
11450
11521
|
let configuredProvider;
|
|
11451
11522
|
let configuredReasoning;
|
|
11523
|
+
let configuredFast;
|
|
11452
11524
|
try {
|
|
11453
11525
|
const config = await resolveModelConfig();
|
|
11454
11526
|
configuredProvider = config.provider ?? "openai";
|
|
@@ -11456,6 +11528,13 @@ var createModelHandlers = ({
|
|
|
11456
11528
|
if (!requestedProvider || requestedProvider === configuredProvider) {
|
|
11457
11529
|
current = config.name;
|
|
11458
11530
|
}
|
|
11531
|
+
if (config.fast !== void 0 && config.name && isSupportedProvider(configuredProvider)) {
|
|
11532
|
+
configuredFast = resolveFastMode({
|
|
11533
|
+
provider: configuredProvider,
|
|
11534
|
+
model: config.name,
|
|
11535
|
+
requested: config.fast
|
|
11536
|
+
}).enabled;
|
|
11537
|
+
}
|
|
11459
11538
|
} catch (error) {
|
|
11460
11539
|
sendError(id, {
|
|
11461
11540
|
code: RPC_ERROR_CODE3.RUNTIME_INTERNAL,
|
|
@@ -11497,6 +11576,7 @@ var createModelHandlers = ({
|
|
|
11497
11576
|
models,
|
|
11498
11577
|
current,
|
|
11499
11578
|
...configuredReasoning ? { reasoning: configuredReasoning } : {},
|
|
11579
|
+
...configuredFast !== void 0 ? { fast: configuredFast } : {},
|
|
11500
11580
|
...details ? { details } : {}
|
|
11501
11581
|
};
|
|
11502
11582
|
sendResult(id, result);
|
|
@@ -11538,7 +11618,7 @@ var createModelHandlers = ({
|
|
|
11538
11618
|
return;
|
|
11539
11619
|
}
|
|
11540
11620
|
if (provider !== "openrouter") {
|
|
11541
|
-
const spec =
|
|
11621
|
+
const spec = resolveModel3(DEFAULT_MODEL_REGISTRY4, name, provider);
|
|
11542
11622
|
if (!spec) {
|
|
11543
11623
|
sendError(id, {
|
|
11544
11624
|
code: RPC_ERROR_CODE3.INVALID_PARAMS,
|
|
@@ -11552,7 +11632,8 @@ var createModelHandlers = ({
|
|
|
11552
11632
|
const target = await updateModel(workingDir, {
|
|
11553
11633
|
provider,
|
|
11554
11634
|
name,
|
|
11555
|
-
...reasoning ? { reasoning } : {}
|
|
11635
|
+
...reasoning ? { reasoning } : {},
|
|
11636
|
+
...params.fast !== void 0 ? { fast: params.fast } : {}
|
|
11556
11637
|
});
|
|
11557
11638
|
state.currentModelProvider = provider;
|
|
11558
11639
|
state.currentModelName = name;
|
|
@@ -11561,10 +11642,16 @@ var createModelHandlers = ({
|
|
|
11561
11642
|
const effectiveReasoning = resolveReasoningEffort(
|
|
11562
11643
|
updatedConfig.reasoning
|
|
11563
11644
|
);
|
|
11645
|
+
const effectiveFast = resolveFastMode({
|
|
11646
|
+
provider,
|
|
11647
|
+
model: name,
|
|
11648
|
+
requested: updatedConfig.fast
|
|
11649
|
+
}).enabled;
|
|
11564
11650
|
const result = {
|
|
11565
11651
|
provider,
|
|
11566
11652
|
name,
|
|
11567
|
-
...effectiveReasoning ? { reasoning: effectiveReasoning } : {}
|
|
11653
|
+
...effectiveReasoning ? { reasoning: effectiveReasoning } : {},
|
|
11654
|
+
...updatedConfig.fast !== void 0 ? { fast: effectiveFast } : {}
|
|
11568
11655
|
};
|
|
11569
11656
|
sendResult(id, result);
|
|
11570
11657
|
log2(
|
|
@@ -11995,8 +12082,12 @@ var summarizeTrackedFileDiff = (label, savedFiles, currentFiles) => {
|
|
|
11995
12082
|
if (savedFiles.length === 0 && currentFiles.length === 0) {
|
|
11996
12083
|
return [];
|
|
11997
12084
|
}
|
|
11998
|
-
const savedByPath = new Map(
|
|
11999
|
-
|
|
12085
|
+
const savedByPath = new Map(
|
|
12086
|
+
savedFiles.map((file) => [file.path, file.mtime_ms])
|
|
12087
|
+
);
|
|
12088
|
+
const currentByPath = new Map(
|
|
12089
|
+
currentFiles.map((file) => [file.path, file.mtime_ms])
|
|
12090
|
+
);
|
|
12000
12091
|
const details = [];
|
|
12001
12092
|
for (const [filePath, savedMtime] of savedByPath) {
|
|
12002
12093
|
const currentMtime = currentByPath.get(filePath);
|
|
@@ -12021,7 +12112,9 @@ var summarizeCurrentLoadedSkillDiff = (savedSkills, currentSkills) => (async ()
|
|
|
12021
12112
|
if (savedSkills.length === 0 && currentSkills.length === 0) {
|
|
12022
12113
|
return [];
|
|
12023
12114
|
}
|
|
12024
|
-
const savedByPath = new Map(
|
|
12115
|
+
const savedByPath = new Map(
|
|
12116
|
+
savedSkills.map((file) => [file.path, file.mtime_ms])
|
|
12117
|
+
);
|
|
12025
12118
|
const currentByPath = new Map(
|
|
12026
12119
|
currentSkills.map((file) => [file.path, file.mtime_ms])
|
|
12027
12120
|
);
|
|
@@ -12700,7 +12793,8 @@ var createRunHandlers = ({
|
|
|
12700
12793
|
model: modelConfig ? {
|
|
12701
12794
|
provider: modelConfig.provider,
|
|
12702
12795
|
name: modelConfig.name,
|
|
12703
|
-
reasoning: modelConfig.reasoning
|
|
12796
|
+
reasoning: modelConfig.reasoning,
|
|
12797
|
+
...modelConfig.fast !== void 0 ? { fast: modelConfig.fast } : {}
|
|
12704
12798
|
} : void 0,
|
|
12705
12799
|
prompts: state.systemPrompt ? { system: state.systemPrompt } : void 0,
|
|
12706
12800
|
tools: state.toolDefinitions ? { definitions: state.toolDefinitions, source: "runtime" } : void 0,
|
|
@@ -12757,7 +12851,10 @@ var createRunHandlers = ({
|
|
|
12757
12851
|
);
|
|
12758
12852
|
const workspaceRoot = resolveSessionWorkspaceRoot(state);
|
|
12759
12853
|
const sessionMetaWithWorkspace = mergeWorkspaceRootIntoSessionMeta(sessionMeta, workspaceRoot);
|
|
12760
|
-
const sessionMetaWithResumeContext = mergeResumeContextIntoSessionMeta(
|
|
12854
|
+
const sessionMetaWithResumeContext = mergeResumeContextIntoSessionMeta(
|
|
12855
|
+
sessionMetaWithWorkspace,
|
|
12856
|
+
state
|
|
12857
|
+
);
|
|
12761
12858
|
const snapshot = buildSessionState(
|
|
12762
12859
|
sessionId,
|
|
12763
12860
|
runId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codelia/runtime",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.66",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=20 <25"
|
|
@@ -23,14 +23,14 @@
|
|
|
23
23
|
"typecheck": "tsc --noEmit"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@codelia/config": "0.1.
|
|
27
|
-
"@codelia/config-loader": "0.1.
|
|
28
|
-
"@codelia/core": "0.1.
|
|
29
|
-
"@codelia/logger": "0.1.
|
|
30
|
-
"@codelia/model-metadata": "0.1.
|
|
31
|
-
"@codelia/protocol": "0.1.
|
|
32
|
-
"@codelia/shared-types": "0.1.
|
|
33
|
-
"@codelia/storage": "0.1.
|
|
26
|
+
"@codelia/config": "0.1.66",
|
|
27
|
+
"@codelia/config-loader": "0.1.66",
|
|
28
|
+
"@codelia/core": "0.1.66",
|
|
29
|
+
"@codelia/logger": "0.1.66",
|
|
30
|
+
"@codelia/model-metadata": "0.1.66",
|
|
31
|
+
"@codelia/protocol": "0.1.66",
|
|
32
|
+
"@codelia/shared-types": "0.1.66",
|
|
33
|
+
"@codelia/storage": "0.1.66",
|
|
34
34
|
"eventsource-parser": "^3.0.6",
|
|
35
35
|
"oauth4webapi": "^3.8.4",
|
|
36
36
|
"zod": "^4.3.5"
|