@codelia/runtime 0.1.39 → 0.1.41
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 +56 -65
- package/dist/index.js +61 -67
- package/package.json +9 -9
package/dist/index.cjs
CHANGED
|
@@ -1737,10 +1737,18 @@ var resolveProviderModelEntry = (providerEntries, provider, model) => {
|
|
|
1737
1737
|
return null;
|
|
1738
1738
|
}
|
|
1739
1739
|
const normalized = stripProviderPrefix(provider, model);
|
|
1740
|
+
const providerModelId = (0, import_core2.resolveProviderModelId)(import_core2.DEFAULT_MODEL_REGISTRY, model, provider) ?? normalized;
|
|
1741
|
+
const providerModelNormalized = stripProviderPrefix(
|
|
1742
|
+
provider,
|
|
1743
|
+
providerModelId
|
|
1744
|
+
);
|
|
1740
1745
|
const directCandidates = [
|
|
1741
1746
|
model,
|
|
1742
1747
|
normalized,
|
|
1743
|
-
`${provider}/${normalized}
|
|
1748
|
+
`${provider}/${normalized}`,
|
|
1749
|
+
providerModelId,
|
|
1750
|
+
providerModelNormalized,
|
|
1751
|
+
`${provider}/${providerModelNormalized}`
|
|
1744
1752
|
].filter((value, index, array) => array.indexOf(value) === index);
|
|
1745
1753
|
for (const candidate of directCandidates) {
|
|
1746
1754
|
const entry = providerEntries[candidate];
|
|
@@ -4745,7 +4753,7 @@ var import_node_fs13 = require("fs");
|
|
|
4745
4753
|
var import_core10 = require("@codelia/core");
|
|
4746
4754
|
var import_zod9 = require("zod");
|
|
4747
4755
|
var DEFAULT_READ_LIMIT = 2e3;
|
|
4748
|
-
var DEFAULT_MAX_LINE_LENGTH =
|
|
4756
|
+
var DEFAULT_MAX_LINE_LENGTH = 1e3;
|
|
4749
4757
|
var DEFAULT_MAX_BYTES = 64 * 1024;
|
|
4750
4758
|
var parsePositiveIntEnv = (key, fallback) => {
|
|
4751
4759
|
const raw = process.env[key];
|
|
@@ -4787,34 +4795,20 @@ var clipLineToByteBudget = (line, maxBytes) => {
|
|
|
4787
4795
|
}
|
|
4788
4796
|
return `${clipUtf8ToBytes(line, maxBytes - suffixBytes)}${suffix}`;
|
|
4789
4797
|
};
|
|
4790
|
-
var
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
var buildSingleLineByteCapError = (options) => [
|
|
4798
|
-
`TOO_LARGE_TO_READ: requested line ${options.lineNumber} exceeds per-call byte limit (${MAX_BYTES} bytes).`,
|
|
4799
|
-
`file_path=${options.filePath} line_number=${options.lineNumber}`,
|
|
4800
|
-
"Offset-based pagination cannot continue within one physical line.",
|
|
4801
|
-
"Use read_line for char-based paging or retry with allow_truncate=true.",
|
|
4802
|
-
`read_line({"file_path":"${options.filePath}","line_number":${options.lineNumber},"char_offset":0,"char_limit":10000})`
|
|
4803
|
-
].join("\n").trim();
|
|
4804
|
-
var buildLineTooLongError = (options) => [
|
|
4805
|
-
`LINE_TOO_LONG: line ${options.lineNumber} has ${options.lineLength} chars (max ${MAX_LINE_LENGTH}).`,
|
|
4806
|
-
`file_path=${options.filePath}`,
|
|
4807
|
-
"Use read_line for char-based paging or retry with allow_truncate=true.",
|
|
4808
|
-
`read_line({"file_path":"${options.filePath}","line_number":${options.lineNumber},"char_offset":0,"char_limit":10000})`
|
|
4809
|
-
].join("\n").trim();
|
|
4798
|
+
var buildTruncatedLinesSummary = (lineNumbers) => {
|
|
4799
|
+
if (lineNumbers.length === 0) return null;
|
|
4800
|
+
if (lineNumbers.length > 3) {
|
|
4801
|
+
return "[truncated lines: many]";
|
|
4802
|
+
}
|
|
4803
|
+
return `[truncated lines: ${lineNumbers.join(", ")}]`;
|
|
4804
|
+
};
|
|
4810
4805
|
var createReadTool = (sandboxKey) => (0, import_core10.defineTool)({
|
|
4811
4806
|
name: "read",
|
|
4812
4807
|
description: "Read a text file with optional 0-based line offset and line limit.",
|
|
4813
4808
|
input: import_zod9.z.object({
|
|
4814
4809
|
file_path: import_zod9.z.string().describe("File path under the sandbox root."),
|
|
4815
4810
|
offset: import_zod9.z.number().int().nonnegative().optional().describe("0-based start line. Default 0."),
|
|
4816
|
-
limit: import_zod9.z.number().int().positive().optional().describe("Max lines to read. Default 2000.")
|
|
4817
|
-
allow_truncate: import_zod9.z.boolean().optional().describe("Allow truncation when output is too large. Default false.")
|
|
4811
|
+
limit: import_zod9.z.number().int().positive().optional().describe("Max lines to read. Default 2000.")
|
|
4818
4812
|
}),
|
|
4819
4813
|
execute: async (input, ctx) => {
|
|
4820
4814
|
let resolved;
|
|
@@ -4840,27 +4834,19 @@ var createReadTool = (sandboxKey) => (0, import_core10.defineTool)({
|
|
|
4840
4834
|
}
|
|
4841
4835
|
const offset = input.offset ?? 0;
|
|
4842
4836
|
const limit = input.limit ?? DEFAULT_READ_LIMIT;
|
|
4843
|
-
const allowTruncate = input.allow_truncate ?? false;
|
|
4844
4837
|
if (offset >= lines.length) {
|
|
4845
4838
|
return `Offset exceeds output length: ${input.file_path}`;
|
|
4846
4839
|
}
|
|
4847
4840
|
const outputLines = [];
|
|
4848
4841
|
let bytes = 0;
|
|
4849
4842
|
let truncatedByBytes = false;
|
|
4850
|
-
|
|
4843
|
+
const truncatedLineNumbers = [];
|
|
4851
4844
|
let firstClippedLineNumber = null;
|
|
4852
4845
|
for (let index = offset; index < Math.min(lines.length, offset + limit); index += 1) {
|
|
4853
4846
|
const originalLine = lines[index] ?? "";
|
|
4854
|
-
|
|
4855
|
-
return buildLineTooLongError({
|
|
4856
|
-
filePath: input.file_path,
|
|
4857
|
-
lineNumber: index + 1,
|
|
4858
|
-
lineLength: originalLine.length
|
|
4859
|
-
});
|
|
4860
|
-
}
|
|
4861
|
-
const line = allowTruncate ? clipLongLine(originalLine) : originalLine;
|
|
4847
|
+
const line = clipLongLine(originalLine);
|
|
4862
4848
|
if (line.length !== originalLine.length) {
|
|
4863
|
-
|
|
4849
|
+
truncatedLineNumbers.push(index + 1);
|
|
4864
4850
|
if (firstClippedLineNumber === null) {
|
|
4865
4851
|
firstClippedLineNumber = index + 1;
|
|
4866
4852
|
}
|
|
@@ -4868,31 +4854,14 @@ var createReadTool = (sandboxKey) => (0, import_core10.defineTool)({
|
|
|
4868
4854
|
const numberedLine = `${String(index + 1).padStart(5, " ")} ${line}`;
|
|
4869
4855
|
const size = Buffer.byteLength(numberedLine, "utf8") + (outputLines.length > 0 ? 1 : 0);
|
|
4870
4856
|
if (bytes + size > MAX_BYTES) {
|
|
4871
|
-
if (!allowTruncate) {
|
|
4872
|
-
if (outputLines.length === 0) {
|
|
4873
|
-
return buildSingleLineByteCapError({
|
|
4874
|
-
filePath: input.file_path,
|
|
4875
|
-
lineNumber: index + 1
|
|
4876
|
-
});
|
|
4877
|
-
}
|
|
4878
|
-
return buildTooLargeToReadError({
|
|
4879
|
-
filePath: input.file_path,
|
|
4880
|
-
offset,
|
|
4881
|
-
limit,
|
|
4882
|
-
nextOffset: Math.max(offset + outputLines.length, offset + 1)
|
|
4883
|
-
});
|
|
4884
|
-
}
|
|
4885
4857
|
if (outputLines.length === 0) {
|
|
4886
4858
|
const prefix = `${String(index + 1).padStart(5, " ")} `;
|
|
4887
4859
|
const budget = MAX_BYTES - Buffer.byteLength(prefix, "utf8");
|
|
4888
4860
|
const clippedByBytes = clipLineToByteBudget(line, budget);
|
|
4889
4861
|
if (clippedByBytes.length > 0) {
|
|
4890
4862
|
outputLines.push(clippedByBytes);
|
|
4891
|
-
bytes = Buffer.byteLength(
|
|
4892
|
-
|
|
4893
|
-
"utf8"
|
|
4894
|
-
);
|
|
4895
|
-
clipped = true;
|
|
4863
|
+
bytes = Buffer.byteLength(`${prefix}${clippedByBytes}`, "utf8");
|
|
4864
|
+
truncatedLineNumbers.push(index + 1);
|
|
4896
4865
|
if (firstClippedLineNumber === null) {
|
|
4897
4866
|
firstClippedLineNumber = index + 1;
|
|
4898
4867
|
}
|
|
@@ -4911,17 +4880,20 @@ var createReadTool = (sandboxKey) => (0, import_core10.defineTool)({
|
|
|
4911
4880
|
const hasMoreLines = lines.length > lastReadLine;
|
|
4912
4881
|
let output = numbered.join("\n");
|
|
4913
4882
|
if (truncatedByBytes || hasMoreLines) {
|
|
4914
|
-
const reason = truncatedByBytes ? `
|
|
4883
|
+
const reason = truncatedByBytes ? `[output truncated at ${MAX_BYTES} bytes]` : "Output has more lines.";
|
|
4915
4884
|
output += `
|
|
4916
4885
|
|
|
4917
4886
|
${reason} Use offset to read beyond line ${lastReadLine}.`;
|
|
4918
4887
|
}
|
|
4919
|
-
|
|
4888
|
+
const truncatedLinesSummary = buildTruncatedLinesSummary(
|
|
4889
|
+
Array.from(new Set(truncatedLineNumbers))
|
|
4890
|
+
);
|
|
4891
|
+
if (truncatedLinesSummary) {
|
|
4920
4892
|
output += `
|
|
4921
4893
|
|
|
4922
|
-
|
|
4894
|
+
${truncatedLinesSummary}`;
|
|
4923
4895
|
}
|
|
4924
|
-
if (
|
|
4896
|
+
if (firstClippedLineNumber !== null) {
|
|
4925
4897
|
output += `
|
|
4926
4898
|
|
|
4927
4899
|
For full long-line content, use read_line({"file_path":"${input.file_path}","line_number":${firstClippedLineNumber},"char_offset":0,"char_limit":10000}).`;
|
|
@@ -5538,8 +5510,7 @@ var createToolOutputCacheTool = (store) => (0, import_core16.defineTool)({
|
|
|
5538
5510
|
input: import_zod15.z.object({
|
|
5539
5511
|
ref_id: import_zod15.z.string().describe("Tool output reference ID."),
|
|
5540
5512
|
offset: import_zod15.z.number().int().nonnegative().optional().describe("Optional 0-based line offset."),
|
|
5541
|
-
limit: import_zod15.z.number().int().positive().optional().describe("Optional max number of lines to return.")
|
|
5542
|
-
allow_truncate: import_zod15.z.boolean().optional().describe("Allow truncation when output is too large. Default false.")
|
|
5513
|
+
limit: import_zod15.z.number().int().positive().optional().describe("Optional max number of lines to return.")
|
|
5543
5514
|
}),
|
|
5544
5515
|
execute: async (input) => {
|
|
5545
5516
|
if (!store.read) {
|
|
@@ -5548,8 +5519,7 @@ var createToolOutputCacheTool = (store) => (0, import_core16.defineTool)({
|
|
|
5548
5519
|
try {
|
|
5549
5520
|
return await store.read(input.ref_id, {
|
|
5550
5521
|
offset: input.offset,
|
|
5551
|
-
limit: input.limit
|
|
5552
|
-
allow_truncate: input.allow_truncate
|
|
5522
|
+
limit: input.limit
|
|
5553
5523
|
});
|
|
5554
5524
|
} catch (error) {
|
|
5555
5525
|
return `Error reading tool output cache: ${String(error)}`;
|
|
@@ -6278,8 +6248,13 @@ var createAgentFactory = (state, options = {}) => {
|
|
|
6278
6248
|
switch (provider) {
|
|
6279
6249
|
case "openai": {
|
|
6280
6250
|
const modelName = modelConfig.name ?? import_core19.OPENAI_DEFAULT_MODEL;
|
|
6251
|
+
const providerModelName = (0, import_core19.resolveProviderModelId)(
|
|
6252
|
+
import_core19.DEFAULT_MODEL_REGISTRY,
|
|
6253
|
+
modelName,
|
|
6254
|
+
"openai"
|
|
6255
|
+
) ?? modelName;
|
|
6281
6256
|
const reasoning = resolveResponsesReasoning({
|
|
6282
|
-
model:
|
|
6257
|
+
model: providerModelName,
|
|
6283
6258
|
requested: requestedReasoning
|
|
6284
6259
|
});
|
|
6285
6260
|
const textVerbosity = resolveTextVerbosity(modelConfig.verbosity);
|
|
@@ -6287,6 +6262,7 @@ var createAgentFactory = (state, options = {}) => {
|
|
|
6287
6262
|
llm = new import_core19.ChatOpenAI({
|
|
6288
6263
|
clientOptions: buildOpenAiClientOptions(authResolver, providerAuth),
|
|
6289
6264
|
model: modelName,
|
|
6265
|
+
providerModel: providerModelName,
|
|
6290
6266
|
reasoningEffort: reasoning.effort,
|
|
6291
6267
|
reasoningLevelRequested: reasoning.requested,
|
|
6292
6268
|
reasoningLevelApplied: reasoning.applied,
|
|
@@ -8118,8 +8094,23 @@ var import_model_metadata3 = require("@codelia/model-metadata");
|
|
|
8118
8094
|
var import_protocol4 = require("@codelia/protocol");
|
|
8119
8095
|
var isSupportedProvider = (provider) => provider === "openai" || provider === "anthropic" || provider === "openrouter";
|
|
8120
8096
|
var resolveProviderModelEntry2 = (providerEntries, provider, model) => {
|
|
8121
|
-
if (!providerEntries)
|
|
8122
|
-
|
|
8097
|
+
if (!providerEntries) {
|
|
8098
|
+
return null;
|
|
8099
|
+
}
|
|
8100
|
+
const providerModelId = (0, import_core20.resolveProviderModelId)(import_core20.DEFAULT_MODEL_REGISTRY, model, provider) ?? model;
|
|
8101
|
+
const candidates = [
|
|
8102
|
+
model,
|
|
8103
|
+
`${provider}/${model}`,
|
|
8104
|
+
providerModelId,
|
|
8105
|
+
`${provider}/${providerModelId}`
|
|
8106
|
+
].filter((value, index, array) => array.indexOf(value) === index);
|
|
8107
|
+
for (const candidate of candidates) {
|
|
8108
|
+
const entry = providerEntries[candidate];
|
|
8109
|
+
if (entry) {
|
|
8110
|
+
return entry;
|
|
8111
|
+
}
|
|
8112
|
+
}
|
|
8113
|
+
return null;
|
|
8123
8114
|
};
|
|
8124
8115
|
var parseReleaseTimestamp = (entry) => {
|
|
8125
8116
|
const releaseDate = entry?.releaseDate?.trim();
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,8 @@ import {
|
|
|
11
11
|
ChatOpenAI,
|
|
12
12
|
ChatOpenRouter,
|
|
13
13
|
DEFAULT_MODEL_REGISTRY as DEFAULT_MODEL_REGISTRY2,
|
|
14
|
-
OPENAI_DEFAULT_MODEL
|
|
14
|
+
OPENAI_DEFAULT_MODEL,
|
|
15
|
+
resolveProviderModelId as resolveProviderModelId2
|
|
15
16
|
} from "@codelia/core";
|
|
16
17
|
import { ModelMetadataServiceImpl as ModelMetadataServiceImpl2 } from "@codelia/model-metadata";
|
|
17
18
|
import { parseApprovalMode as parseApprovalMode2 } from "@codelia/shared-types";
|
|
@@ -1724,6 +1725,7 @@ import {
|
|
|
1724
1725
|
applyModelMetadata,
|
|
1725
1726
|
DEFAULT_MODEL_REGISTRY,
|
|
1726
1727
|
resolveModel,
|
|
1728
|
+
resolveProviderModelId,
|
|
1727
1729
|
registerModels
|
|
1728
1730
|
} from "@codelia/core";
|
|
1729
1731
|
import { ModelMetadataServiceImpl } from "@codelia/model-metadata";
|
|
@@ -1737,10 +1739,18 @@ var resolveProviderModelEntry = (providerEntries, provider, model) => {
|
|
|
1737
1739
|
return null;
|
|
1738
1740
|
}
|
|
1739
1741
|
const normalized = stripProviderPrefix(provider, model);
|
|
1742
|
+
const providerModelId = resolveProviderModelId(DEFAULT_MODEL_REGISTRY, model, provider) ?? normalized;
|
|
1743
|
+
const providerModelNormalized = stripProviderPrefix(
|
|
1744
|
+
provider,
|
|
1745
|
+
providerModelId
|
|
1746
|
+
);
|
|
1740
1747
|
const directCandidates = [
|
|
1741
1748
|
model,
|
|
1742
1749
|
normalized,
|
|
1743
|
-
`${provider}/${normalized}
|
|
1750
|
+
`${provider}/${normalized}`,
|
|
1751
|
+
providerModelId,
|
|
1752
|
+
providerModelNormalized,
|
|
1753
|
+
`${provider}/${providerModelNormalized}`
|
|
1744
1754
|
].filter((value, index, array) => array.indexOf(value) === index);
|
|
1745
1755
|
for (const candidate of directCandidates) {
|
|
1746
1756
|
const entry = providerEntries[candidate];
|
|
@@ -4745,7 +4755,7 @@ import { promises as fs13 } from "fs";
|
|
|
4745
4755
|
import { defineTool as defineTool8 } from "@codelia/core";
|
|
4746
4756
|
import { z as z9 } from "zod";
|
|
4747
4757
|
var DEFAULT_READ_LIMIT = 2e3;
|
|
4748
|
-
var DEFAULT_MAX_LINE_LENGTH =
|
|
4758
|
+
var DEFAULT_MAX_LINE_LENGTH = 1e3;
|
|
4749
4759
|
var DEFAULT_MAX_BYTES = 64 * 1024;
|
|
4750
4760
|
var parsePositiveIntEnv = (key, fallback) => {
|
|
4751
4761
|
const raw = process.env[key];
|
|
@@ -4787,34 +4797,20 @@ var clipLineToByteBudget = (line, maxBytes) => {
|
|
|
4787
4797
|
}
|
|
4788
4798
|
return `${clipUtf8ToBytes(line, maxBytes - suffixBytes)}${suffix}`;
|
|
4789
4799
|
};
|
|
4790
|
-
var
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
var buildSingleLineByteCapError = (options) => [
|
|
4798
|
-
`TOO_LARGE_TO_READ: requested line ${options.lineNumber} exceeds per-call byte limit (${MAX_BYTES} bytes).`,
|
|
4799
|
-
`file_path=${options.filePath} line_number=${options.lineNumber}`,
|
|
4800
|
-
"Offset-based pagination cannot continue within one physical line.",
|
|
4801
|
-
"Use read_line for char-based paging or retry with allow_truncate=true.",
|
|
4802
|
-
`read_line({"file_path":"${options.filePath}","line_number":${options.lineNumber},"char_offset":0,"char_limit":10000})`
|
|
4803
|
-
].join("\n").trim();
|
|
4804
|
-
var buildLineTooLongError = (options) => [
|
|
4805
|
-
`LINE_TOO_LONG: line ${options.lineNumber} has ${options.lineLength} chars (max ${MAX_LINE_LENGTH}).`,
|
|
4806
|
-
`file_path=${options.filePath}`,
|
|
4807
|
-
"Use read_line for char-based paging or retry with allow_truncate=true.",
|
|
4808
|
-
`read_line({"file_path":"${options.filePath}","line_number":${options.lineNumber},"char_offset":0,"char_limit":10000})`
|
|
4809
|
-
].join("\n").trim();
|
|
4800
|
+
var buildTruncatedLinesSummary = (lineNumbers) => {
|
|
4801
|
+
if (lineNumbers.length === 0) return null;
|
|
4802
|
+
if (lineNumbers.length > 3) {
|
|
4803
|
+
return "[truncated lines: many]";
|
|
4804
|
+
}
|
|
4805
|
+
return `[truncated lines: ${lineNumbers.join(", ")}]`;
|
|
4806
|
+
};
|
|
4810
4807
|
var createReadTool = (sandboxKey) => defineTool8({
|
|
4811
4808
|
name: "read",
|
|
4812
4809
|
description: "Read a text file with optional 0-based line offset and line limit.",
|
|
4813
4810
|
input: z9.object({
|
|
4814
4811
|
file_path: z9.string().describe("File path under the sandbox root."),
|
|
4815
4812
|
offset: z9.number().int().nonnegative().optional().describe("0-based start line. Default 0."),
|
|
4816
|
-
limit: z9.number().int().positive().optional().describe("Max lines to read. Default 2000.")
|
|
4817
|
-
allow_truncate: z9.boolean().optional().describe("Allow truncation when output is too large. Default false.")
|
|
4813
|
+
limit: z9.number().int().positive().optional().describe("Max lines to read. Default 2000.")
|
|
4818
4814
|
}),
|
|
4819
4815
|
execute: async (input, ctx) => {
|
|
4820
4816
|
let resolved;
|
|
@@ -4840,27 +4836,19 @@ var createReadTool = (sandboxKey) => defineTool8({
|
|
|
4840
4836
|
}
|
|
4841
4837
|
const offset = input.offset ?? 0;
|
|
4842
4838
|
const limit = input.limit ?? DEFAULT_READ_LIMIT;
|
|
4843
|
-
const allowTruncate = input.allow_truncate ?? false;
|
|
4844
4839
|
if (offset >= lines.length) {
|
|
4845
4840
|
return `Offset exceeds output length: ${input.file_path}`;
|
|
4846
4841
|
}
|
|
4847
4842
|
const outputLines = [];
|
|
4848
4843
|
let bytes = 0;
|
|
4849
4844
|
let truncatedByBytes = false;
|
|
4850
|
-
|
|
4845
|
+
const truncatedLineNumbers = [];
|
|
4851
4846
|
let firstClippedLineNumber = null;
|
|
4852
4847
|
for (let index = offset; index < Math.min(lines.length, offset + limit); index += 1) {
|
|
4853
4848
|
const originalLine = lines[index] ?? "";
|
|
4854
|
-
|
|
4855
|
-
return buildLineTooLongError({
|
|
4856
|
-
filePath: input.file_path,
|
|
4857
|
-
lineNumber: index + 1,
|
|
4858
|
-
lineLength: originalLine.length
|
|
4859
|
-
});
|
|
4860
|
-
}
|
|
4861
|
-
const line = allowTruncate ? clipLongLine(originalLine) : originalLine;
|
|
4849
|
+
const line = clipLongLine(originalLine);
|
|
4862
4850
|
if (line.length !== originalLine.length) {
|
|
4863
|
-
|
|
4851
|
+
truncatedLineNumbers.push(index + 1);
|
|
4864
4852
|
if (firstClippedLineNumber === null) {
|
|
4865
4853
|
firstClippedLineNumber = index + 1;
|
|
4866
4854
|
}
|
|
@@ -4868,31 +4856,14 @@ var createReadTool = (sandboxKey) => defineTool8({
|
|
|
4868
4856
|
const numberedLine = `${String(index + 1).padStart(5, " ")} ${line}`;
|
|
4869
4857
|
const size = Buffer.byteLength(numberedLine, "utf8") + (outputLines.length > 0 ? 1 : 0);
|
|
4870
4858
|
if (bytes + size > MAX_BYTES) {
|
|
4871
|
-
if (!allowTruncate) {
|
|
4872
|
-
if (outputLines.length === 0) {
|
|
4873
|
-
return buildSingleLineByteCapError({
|
|
4874
|
-
filePath: input.file_path,
|
|
4875
|
-
lineNumber: index + 1
|
|
4876
|
-
});
|
|
4877
|
-
}
|
|
4878
|
-
return buildTooLargeToReadError({
|
|
4879
|
-
filePath: input.file_path,
|
|
4880
|
-
offset,
|
|
4881
|
-
limit,
|
|
4882
|
-
nextOffset: Math.max(offset + outputLines.length, offset + 1)
|
|
4883
|
-
});
|
|
4884
|
-
}
|
|
4885
4859
|
if (outputLines.length === 0) {
|
|
4886
4860
|
const prefix = `${String(index + 1).padStart(5, " ")} `;
|
|
4887
4861
|
const budget = MAX_BYTES - Buffer.byteLength(prefix, "utf8");
|
|
4888
4862
|
const clippedByBytes = clipLineToByteBudget(line, budget);
|
|
4889
4863
|
if (clippedByBytes.length > 0) {
|
|
4890
4864
|
outputLines.push(clippedByBytes);
|
|
4891
|
-
bytes = Buffer.byteLength(
|
|
4892
|
-
|
|
4893
|
-
"utf8"
|
|
4894
|
-
);
|
|
4895
|
-
clipped = true;
|
|
4865
|
+
bytes = Buffer.byteLength(`${prefix}${clippedByBytes}`, "utf8");
|
|
4866
|
+
truncatedLineNumbers.push(index + 1);
|
|
4896
4867
|
if (firstClippedLineNumber === null) {
|
|
4897
4868
|
firstClippedLineNumber = index + 1;
|
|
4898
4869
|
}
|
|
@@ -4911,17 +4882,20 @@ var createReadTool = (sandboxKey) => defineTool8({
|
|
|
4911
4882
|
const hasMoreLines = lines.length > lastReadLine;
|
|
4912
4883
|
let output = numbered.join("\n");
|
|
4913
4884
|
if (truncatedByBytes || hasMoreLines) {
|
|
4914
|
-
const reason = truncatedByBytes ? `
|
|
4885
|
+
const reason = truncatedByBytes ? `[output truncated at ${MAX_BYTES} bytes]` : "Output has more lines.";
|
|
4915
4886
|
output += `
|
|
4916
4887
|
|
|
4917
4888
|
${reason} Use offset to read beyond line ${lastReadLine}.`;
|
|
4918
4889
|
}
|
|
4919
|
-
|
|
4890
|
+
const truncatedLinesSummary = buildTruncatedLinesSummary(
|
|
4891
|
+
Array.from(new Set(truncatedLineNumbers))
|
|
4892
|
+
);
|
|
4893
|
+
if (truncatedLinesSummary) {
|
|
4920
4894
|
output += `
|
|
4921
4895
|
|
|
4922
|
-
|
|
4896
|
+
${truncatedLinesSummary}`;
|
|
4923
4897
|
}
|
|
4924
|
-
if (
|
|
4898
|
+
if (firstClippedLineNumber !== null) {
|
|
4925
4899
|
output += `
|
|
4926
4900
|
|
|
4927
4901
|
For full long-line content, use read_line({"file_path":"${input.file_path}","line_number":${firstClippedLineNumber},"char_offset":0,"char_limit":10000}).`;
|
|
@@ -5538,8 +5512,7 @@ var createToolOutputCacheTool = (store) => defineTool14({
|
|
|
5538
5512
|
input: z15.object({
|
|
5539
5513
|
ref_id: z15.string().describe("Tool output reference ID."),
|
|
5540
5514
|
offset: z15.number().int().nonnegative().optional().describe("Optional 0-based line offset."),
|
|
5541
|
-
limit: z15.number().int().positive().optional().describe("Optional max number of lines to return.")
|
|
5542
|
-
allow_truncate: z15.boolean().optional().describe("Allow truncation when output is too large. Default false.")
|
|
5515
|
+
limit: z15.number().int().positive().optional().describe("Optional max number of lines to return.")
|
|
5543
5516
|
}),
|
|
5544
5517
|
execute: async (input) => {
|
|
5545
5518
|
if (!store.read) {
|
|
@@ -5548,8 +5521,7 @@ var createToolOutputCacheTool = (store) => defineTool14({
|
|
|
5548
5521
|
try {
|
|
5549
5522
|
return await store.read(input.ref_id, {
|
|
5550
5523
|
offset: input.offset,
|
|
5551
|
-
limit: input.limit
|
|
5552
|
-
allow_truncate: input.allow_truncate
|
|
5524
|
+
limit: input.limit
|
|
5553
5525
|
});
|
|
5554
5526
|
} catch (error) {
|
|
5555
5527
|
return `Error reading tool output cache: ${String(error)}`;
|
|
@@ -6278,8 +6250,13 @@ var createAgentFactory = (state, options = {}) => {
|
|
|
6278
6250
|
switch (provider) {
|
|
6279
6251
|
case "openai": {
|
|
6280
6252
|
const modelName = modelConfig.name ?? OPENAI_DEFAULT_MODEL;
|
|
6253
|
+
const providerModelName = resolveProviderModelId2(
|
|
6254
|
+
DEFAULT_MODEL_REGISTRY2,
|
|
6255
|
+
modelName,
|
|
6256
|
+
"openai"
|
|
6257
|
+
) ?? modelName;
|
|
6281
6258
|
const reasoning = resolveResponsesReasoning({
|
|
6282
|
-
model:
|
|
6259
|
+
model: providerModelName,
|
|
6283
6260
|
requested: requestedReasoning
|
|
6284
6261
|
});
|
|
6285
6262
|
const textVerbosity = resolveTextVerbosity(modelConfig.verbosity);
|
|
@@ -6287,6 +6264,7 @@ var createAgentFactory = (state, options = {}) => {
|
|
|
6287
6264
|
llm = new ChatOpenAI({
|
|
6288
6265
|
clientOptions: buildOpenAiClientOptions(authResolver, providerAuth),
|
|
6289
6266
|
model: modelName,
|
|
6267
|
+
providerModel: providerModelName,
|
|
6290
6268
|
reasoningEffort: reasoning.effort,
|
|
6291
6269
|
reasoningLevelRequested: reasoning.requested,
|
|
6292
6270
|
reasoningLevelApplied: reasoning.applied,
|
|
@@ -8135,7 +8113,8 @@ import {
|
|
|
8135
8113
|
applyModelMetadata as applyModelMetadata2,
|
|
8136
8114
|
DEFAULT_MODEL_REGISTRY as DEFAULT_MODEL_REGISTRY3,
|
|
8137
8115
|
listModels,
|
|
8138
|
-
resolveModel as resolveModel2
|
|
8116
|
+
resolveModel as resolveModel2,
|
|
8117
|
+
resolveProviderModelId as resolveProviderModelId3
|
|
8139
8118
|
} from "@codelia/core";
|
|
8140
8119
|
import { ModelMetadataServiceImpl as ModelMetadataServiceImpl3 } from "@codelia/model-metadata";
|
|
8141
8120
|
import {
|
|
@@ -8143,8 +8122,23 @@ import {
|
|
|
8143
8122
|
} from "@codelia/protocol";
|
|
8144
8123
|
var isSupportedProvider = (provider) => provider === "openai" || provider === "anthropic" || provider === "openrouter";
|
|
8145
8124
|
var resolveProviderModelEntry2 = (providerEntries, provider, model) => {
|
|
8146
|
-
if (!providerEntries)
|
|
8147
|
-
|
|
8125
|
+
if (!providerEntries) {
|
|
8126
|
+
return null;
|
|
8127
|
+
}
|
|
8128
|
+
const providerModelId = resolveProviderModelId3(DEFAULT_MODEL_REGISTRY3, model, provider) ?? model;
|
|
8129
|
+
const candidates = [
|
|
8130
|
+
model,
|
|
8131
|
+
`${provider}/${model}`,
|
|
8132
|
+
providerModelId,
|
|
8133
|
+
`${provider}/${providerModelId}`
|
|
8134
|
+
].filter((value, index, array) => array.indexOf(value) === index);
|
|
8135
|
+
for (const candidate of candidates) {
|
|
8136
|
+
const entry = providerEntries[candidate];
|
|
8137
|
+
if (entry) {
|
|
8138
|
+
return entry;
|
|
8139
|
+
}
|
|
8140
|
+
}
|
|
8141
|
+
return null;
|
|
8148
8142
|
};
|
|
8149
8143
|
var parseReleaseTimestamp = (entry) => {
|
|
8150
8144
|
const releaseDate = entry?.releaseDate?.trim();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codelia/runtime",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.41",
|
|
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.41",
|
|
27
|
+
"@codelia/config-loader": "0.1.41",
|
|
28
|
+
"@codelia/core": "0.1.41",
|
|
29
|
+
"@codelia/logger": "0.1.41",
|
|
30
|
+
"@codelia/model-metadata": "0.1.41",
|
|
31
|
+
"@codelia/protocol": "0.1.41",
|
|
32
|
+
"@codelia/shared-types": "0.1.41",
|
|
33
|
+
"@codelia/storage": "0.1.41",
|
|
34
34
|
"eventsource-parser": "^3.0.6",
|
|
35
35
|
"oauth4webapi": "^3.8.4",
|
|
36
36
|
"zod": "^4.3.5"
|