@codelia/runtime 0.1.35 → 0.1.36
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 +58 -12
- package/dist/index.js +58 -12
- package/package.json +9 -9
package/dist/index.cjs
CHANGED
|
@@ -4724,13 +4724,44 @@ var import_zod9 = require("zod");
|
|
|
4724
4724
|
var DEFAULT_READ_LIMIT = 2e3;
|
|
4725
4725
|
var MAX_LINE_LENGTH = 2e3;
|
|
4726
4726
|
var MAX_BYTES = 50 * 1024;
|
|
4727
|
+
var splitLongLine = (line) => {
|
|
4728
|
+
if (line.length <= MAX_LINE_LENGTH) {
|
|
4729
|
+
return [line];
|
|
4730
|
+
}
|
|
4731
|
+
const chunks = [];
|
|
4732
|
+
for (let start = 0; start < line.length; start += MAX_LINE_LENGTH) {
|
|
4733
|
+
chunks.push(line.slice(start, start + MAX_LINE_LENGTH));
|
|
4734
|
+
}
|
|
4735
|
+
return chunks;
|
|
4736
|
+
};
|
|
4737
|
+
var toDisplayLines = (physicalLines, wrapLongLines) => {
|
|
4738
|
+
let wrapped = false;
|
|
4739
|
+
let clipped = false;
|
|
4740
|
+
const display = [];
|
|
4741
|
+
for (const line of physicalLines) {
|
|
4742
|
+
if (wrapLongLines) {
|
|
4743
|
+
const chunks = splitLongLine(line);
|
|
4744
|
+
if (chunks.length > 1) wrapped = true;
|
|
4745
|
+
display.push(...chunks);
|
|
4746
|
+
continue;
|
|
4747
|
+
}
|
|
4748
|
+
if (line.length > MAX_LINE_LENGTH) {
|
|
4749
|
+
clipped = true;
|
|
4750
|
+
display.push(`${line.slice(0, MAX_LINE_LENGTH)}...`);
|
|
4751
|
+
continue;
|
|
4752
|
+
}
|
|
4753
|
+
display.push(line);
|
|
4754
|
+
}
|
|
4755
|
+
return { lines: display, wrapped, clipped };
|
|
4756
|
+
};
|
|
4727
4757
|
var createReadTool = (sandboxKey) => (0, import_core10.defineTool)({
|
|
4728
4758
|
name: "read",
|
|
4729
4759
|
description: "Read a text file with optional 0-based line offset and line limit.",
|
|
4730
4760
|
input: import_zod9.z.object({
|
|
4731
4761
|
file_path: import_zod9.z.string().describe("File path under the sandbox root."),
|
|
4732
4762
|
offset: import_zod9.z.number().int().nonnegative().optional().describe("0-based start line. Default 0."),
|
|
4733
|
-
limit: import_zod9.z.number().int().positive().optional().describe("Max lines to read. Default 2000.")
|
|
4763
|
+
limit: import_zod9.z.number().int().positive().optional().describe("Max lines to read. Default 2000."),
|
|
4764
|
+
wrap_long_lines: import_zod9.z.boolean().optional().describe("Enable to paginate very long single-line output. Default false.")
|
|
4734
4765
|
}),
|
|
4735
4766
|
execute: async (input, ctx) => {
|
|
4736
4767
|
let resolved;
|
|
@@ -4750,21 +4781,24 @@ var createReadTool = (sandboxKey) => (0, import_core10.defineTool)({
|
|
|
4750
4781
|
}
|
|
4751
4782
|
try {
|
|
4752
4783
|
const content = await import_node_fs13.promises.readFile(resolved, "utf8");
|
|
4753
|
-
const
|
|
4754
|
-
if (
|
|
4784
|
+
const physicalLines = content.split(/\r?\n/);
|
|
4785
|
+
if (physicalLines.length === 0) {
|
|
4755
4786
|
return "";
|
|
4756
4787
|
}
|
|
4788
|
+
const wrapLongLines = input.wrap_long_lines ?? false;
|
|
4789
|
+
const display = toDisplayLines(physicalLines, wrapLongLines);
|
|
4757
4790
|
const offset = input.offset ?? 0;
|
|
4758
4791
|
const limit = input.limit ?? DEFAULT_READ_LIMIT;
|
|
4759
|
-
if (offset >= lines.length) {
|
|
4760
|
-
return `Offset exceeds
|
|
4792
|
+
if (offset >= display.lines.length) {
|
|
4793
|
+
return `Offset exceeds output length: ${input.file_path}`;
|
|
4761
4794
|
}
|
|
4762
4795
|
const raw = [];
|
|
4763
4796
|
let bytes = 0;
|
|
4764
4797
|
let truncatedByBytes = false;
|
|
4765
|
-
for (let index = offset; index < Math.min(lines.length, offset + limit); index += 1) {
|
|
4766
|
-
const line =
|
|
4767
|
-
const
|
|
4798
|
+
for (let index = offset; index < Math.min(display.lines.length, offset + limit); index += 1) {
|
|
4799
|
+
const line = display.lines[index] ?? "";
|
|
4800
|
+
const numberedLine = `${String(index + 1).padStart(5, " ")} ${line}`;
|
|
4801
|
+
const size = Buffer.byteLength(numberedLine, "utf8") + (raw.length > 0 ? 1 : 0);
|
|
4768
4802
|
if (bytes + size > MAX_BYTES) {
|
|
4769
4803
|
truncatedByBytes = true;
|
|
4770
4804
|
break;
|
|
@@ -4776,14 +4810,24 @@ var createReadTool = (sandboxKey) => (0, import_core10.defineTool)({
|
|
|
4776
4810
|
(line, index) => `${String(index + offset + 1).padStart(5, " ")} ${line}`
|
|
4777
4811
|
);
|
|
4778
4812
|
const lastReadLine = offset + raw.length;
|
|
4779
|
-
const hasMoreLines = lines.length > lastReadLine;
|
|
4813
|
+
const hasMoreLines = display.lines.length > lastReadLine;
|
|
4780
4814
|
const truncated = truncatedByBytes || hasMoreLines;
|
|
4781
4815
|
let output = numbered.join("\n");
|
|
4782
4816
|
if (truncated) {
|
|
4783
|
-
const reason = truncatedByBytes ? `Output truncated at ${MAX_BYTES} bytes.` : "
|
|
4817
|
+
const reason = truncatedByBytes ? `Output truncated at ${MAX_BYTES} bytes.` : "Output has more lines.";
|
|
4784
4818
|
output += `
|
|
4785
4819
|
|
|
4786
4820
|
${reason} Use offset to read beyond line ${lastReadLine}.`;
|
|
4821
|
+
}
|
|
4822
|
+
if (display.wrapped) {
|
|
4823
|
+
output += `
|
|
4824
|
+
|
|
4825
|
+
Long physical lines are wrapped at ${MAX_LINE_LENGTH} chars per display line. Wrapped chunks are display-only and may not match exact source text for edit.`;
|
|
4826
|
+
}
|
|
4827
|
+
if (display.clipped) {
|
|
4828
|
+
output += `
|
|
4829
|
+
|
|
4830
|
+
Long physical lines are clipped at ${MAX_LINE_LENGTH} chars. Set wrap_long_lines=true to paginate full lines. Clipped output is display-only and may not match exact source text for edit.`;
|
|
4787
4831
|
}
|
|
4788
4832
|
return output;
|
|
4789
4833
|
} catch (error) {
|
|
@@ -5395,7 +5439,8 @@ var createToolOutputCacheTool = (store) => (0, import_core16.defineTool)({
|
|
|
5395
5439
|
input: import_zod15.z.object({
|
|
5396
5440
|
ref_id: import_zod15.z.string().describe("Tool output reference ID."),
|
|
5397
5441
|
offset: import_zod15.z.number().int().nonnegative().optional().describe("Optional 0-based line offset."),
|
|
5398
|
-
limit: import_zod15.z.number().int().positive().optional().describe("Optional max number of lines to return.")
|
|
5442
|
+
limit: import_zod15.z.number().int().positive().optional().describe("Optional max number of lines to return."),
|
|
5443
|
+
wrap_long_lines: import_zod15.z.boolean().optional().describe("Enable to paginate very long single-line output. Default false.")
|
|
5399
5444
|
}),
|
|
5400
5445
|
execute: async (input) => {
|
|
5401
5446
|
if (!store.read) {
|
|
@@ -5404,7 +5449,8 @@ var createToolOutputCacheTool = (store) => (0, import_core16.defineTool)({
|
|
|
5404
5449
|
try {
|
|
5405
5450
|
return await store.read(input.ref_id, {
|
|
5406
5451
|
offset: input.offset,
|
|
5407
|
-
limit: input.limit
|
|
5452
|
+
limit: input.limit,
|
|
5453
|
+
wrap_long_lines: input.wrap_long_lines
|
|
5408
5454
|
});
|
|
5409
5455
|
} catch (error) {
|
|
5410
5456
|
return `Error reading tool output cache: ${String(error)}`;
|
package/dist/index.js
CHANGED
|
@@ -4723,13 +4723,44 @@ import { z as z9 } from "zod";
|
|
|
4723
4723
|
var DEFAULT_READ_LIMIT = 2e3;
|
|
4724
4724
|
var MAX_LINE_LENGTH = 2e3;
|
|
4725
4725
|
var MAX_BYTES = 50 * 1024;
|
|
4726
|
+
var splitLongLine = (line) => {
|
|
4727
|
+
if (line.length <= MAX_LINE_LENGTH) {
|
|
4728
|
+
return [line];
|
|
4729
|
+
}
|
|
4730
|
+
const chunks = [];
|
|
4731
|
+
for (let start = 0; start < line.length; start += MAX_LINE_LENGTH) {
|
|
4732
|
+
chunks.push(line.slice(start, start + MAX_LINE_LENGTH));
|
|
4733
|
+
}
|
|
4734
|
+
return chunks;
|
|
4735
|
+
};
|
|
4736
|
+
var toDisplayLines = (physicalLines, wrapLongLines) => {
|
|
4737
|
+
let wrapped = false;
|
|
4738
|
+
let clipped = false;
|
|
4739
|
+
const display = [];
|
|
4740
|
+
for (const line of physicalLines) {
|
|
4741
|
+
if (wrapLongLines) {
|
|
4742
|
+
const chunks = splitLongLine(line);
|
|
4743
|
+
if (chunks.length > 1) wrapped = true;
|
|
4744
|
+
display.push(...chunks);
|
|
4745
|
+
continue;
|
|
4746
|
+
}
|
|
4747
|
+
if (line.length > MAX_LINE_LENGTH) {
|
|
4748
|
+
clipped = true;
|
|
4749
|
+
display.push(`${line.slice(0, MAX_LINE_LENGTH)}...`);
|
|
4750
|
+
continue;
|
|
4751
|
+
}
|
|
4752
|
+
display.push(line);
|
|
4753
|
+
}
|
|
4754
|
+
return { lines: display, wrapped, clipped };
|
|
4755
|
+
};
|
|
4726
4756
|
var createReadTool = (sandboxKey) => defineTool8({
|
|
4727
4757
|
name: "read",
|
|
4728
4758
|
description: "Read a text file with optional 0-based line offset and line limit.",
|
|
4729
4759
|
input: z9.object({
|
|
4730
4760
|
file_path: z9.string().describe("File path under the sandbox root."),
|
|
4731
4761
|
offset: z9.number().int().nonnegative().optional().describe("0-based start line. Default 0."),
|
|
4732
|
-
limit: z9.number().int().positive().optional().describe("Max lines to read. Default 2000.")
|
|
4762
|
+
limit: z9.number().int().positive().optional().describe("Max lines to read. Default 2000."),
|
|
4763
|
+
wrap_long_lines: z9.boolean().optional().describe("Enable to paginate very long single-line output. Default false.")
|
|
4733
4764
|
}),
|
|
4734
4765
|
execute: async (input, ctx) => {
|
|
4735
4766
|
let resolved;
|
|
@@ -4749,21 +4780,24 @@ var createReadTool = (sandboxKey) => defineTool8({
|
|
|
4749
4780
|
}
|
|
4750
4781
|
try {
|
|
4751
4782
|
const content = await fs13.readFile(resolved, "utf8");
|
|
4752
|
-
const
|
|
4753
|
-
if (
|
|
4783
|
+
const physicalLines = content.split(/\r?\n/);
|
|
4784
|
+
if (physicalLines.length === 0) {
|
|
4754
4785
|
return "";
|
|
4755
4786
|
}
|
|
4787
|
+
const wrapLongLines = input.wrap_long_lines ?? false;
|
|
4788
|
+
const display = toDisplayLines(physicalLines, wrapLongLines);
|
|
4756
4789
|
const offset = input.offset ?? 0;
|
|
4757
4790
|
const limit = input.limit ?? DEFAULT_READ_LIMIT;
|
|
4758
|
-
if (offset >= lines.length) {
|
|
4759
|
-
return `Offset exceeds
|
|
4791
|
+
if (offset >= display.lines.length) {
|
|
4792
|
+
return `Offset exceeds output length: ${input.file_path}`;
|
|
4760
4793
|
}
|
|
4761
4794
|
const raw = [];
|
|
4762
4795
|
let bytes = 0;
|
|
4763
4796
|
let truncatedByBytes = false;
|
|
4764
|
-
for (let index = offset; index < Math.min(lines.length, offset + limit); index += 1) {
|
|
4765
|
-
const line =
|
|
4766
|
-
const
|
|
4797
|
+
for (let index = offset; index < Math.min(display.lines.length, offset + limit); index += 1) {
|
|
4798
|
+
const line = display.lines[index] ?? "";
|
|
4799
|
+
const numberedLine = `${String(index + 1).padStart(5, " ")} ${line}`;
|
|
4800
|
+
const size = Buffer.byteLength(numberedLine, "utf8") + (raw.length > 0 ? 1 : 0);
|
|
4767
4801
|
if (bytes + size > MAX_BYTES) {
|
|
4768
4802
|
truncatedByBytes = true;
|
|
4769
4803
|
break;
|
|
@@ -4775,14 +4809,24 @@ var createReadTool = (sandboxKey) => defineTool8({
|
|
|
4775
4809
|
(line, index) => `${String(index + offset + 1).padStart(5, " ")} ${line}`
|
|
4776
4810
|
);
|
|
4777
4811
|
const lastReadLine = offset + raw.length;
|
|
4778
|
-
const hasMoreLines = lines.length > lastReadLine;
|
|
4812
|
+
const hasMoreLines = display.lines.length > lastReadLine;
|
|
4779
4813
|
const truncated = truncatedByBytes || hasMoreLines;
|
|
4780
4814
|
let output = numbered.join("\n");
|
|
4781
4815
|
if (truncated) {
|
|
4782
|
-
const reason = truncatedByBytes ? `Output truncated at ${MAX_BYTES} bytes.` : "
|
|
4816
|
+
const reason = truncatedByBytes ? `Output truncated at ${MAX_BYTES} bytes.` : "Output has more lines.";
|
|
4783
4817
|
output += `
|
|
4784
4818
|
|
|
4785
4819
|
${reason} Use offset to read beyond line ${lastReadLine}.`;
|
|
4820
|
+
}
|
|
4821
|
+
if (display.wrapped) {
|
|
4822
|
+
output += `
|
|
4823
|
+
|
|
4824
|
+
Long physical lines are wrapped at ${MAX_LINE_LENGTH} chars per display line. Wrapped chunks are display-only and may not match exact source text for edit.`;
|
|
4825
|
+
}
|
|
4826
|
+
if (display.clipped) {
|
|
4827
|
+
output += `
|
|
4828
|
+
|
|
4829
|
+
Long physical lines are clipped at ${MAX_LINE_LENGTH} chars. Set wrap_long_lines=true to paginate full lines. Clipped output is display-only and may not match exact source text for edit.`;
|
|
4786
4830
|
}
|
|
4787
4831
|
return output;
|
|
4788
4832
|
} catch (error) {
|
|
@@ -5394,7 +5438,8 @@ var createToolOutputCacheTool = (store) => defineTool14({
|
|
|
5394
5438
|
input: z15.object({
|
|
5395
5439
|
ref_id: z15.string().describe("Tool output reference ID."),
|
|
5396
5440
|
offset: z15.number().int().nonnegative().optional().describe("Optional 0-based line offset."),
|
|
5397
|
-
limit: z15.number().int().positive().optional().describe("Optional max number of lines to return.")
|
|
5441
|
+
limit: z15.number().int().positive().optional().describe("Optional max number of lines to return."),
|
|
5442
|
+
wrap_long_lines: z15.boolean().optional().describe("Enable to paginate very long single-line output. Default false.")
|
|
5398
5443
|
}),
|
|
5399
5444
|
execute: async (input) => {
|
|
5400
5445
|
if (!store.read) {
|
|
@@ -5403,7 +5448,8 @@ var createToolOutputCacheTool = (store) => defineTool14({
|
|
|
5403
5448
|
try {
|
|
5404
5449
|
return await store.read(input.ref_id, {
|
|
5405
5450
|
offset: input.offset,
|
|
5406
|
-
limit: input.limit
|
|
5451
|
+
limit: input.limit,
|
|
5452
|
+
wrap_long_lines: input.wrap_long_lines
|
|
5407
5453
|
});
|
|
5408
5454
|
} catch (error) {
|
|
5409
5455
|
return `Error reading tool output cache: ${String(error)}`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codelia/runtime",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.36",
|
|
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.36",
|
|
27
|
+
"@codelia/config-loader": "0.1.36",
|
|
28
|
+
"@codelia/core": "0.1.36",
|
|
29
|
+
"@codelia/logger": "0.1.36",
|
|
30
|
+
"@codelia/model-metadata": "0.1.36",
|
|
31
|
+
"@codelia/protocol": "0.1.36",
|
|
32
|
+
"@codelia/shared-types": "0.1.36",
|
|
33
|
+
"@codelia/storage": "0.1.36",
|
|
34
34
|
"eventsource-parser": "^3.0.6",
|
|
35
35
|
"oauth4webapi": "^3.8.4",
|
|
36
36
|
"zod": "^4.3.5"
|