@codelia/runtime 0.1.34 → 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 +91 -38
- package/dist/index.js +91 -38
- 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) {
|
|
@@ -5150,24 +5194,10 @@ var getTodoStats = (todos) => ({
|
|
|
5150
5194
|
inProgress: todos.filter((todo) => todo.status === "in_progress").length,
|
|
5151
5195
|
completed: todos.filter((todo) => todo.status === "completed").length
|
|
5152
5196
|
});
|
|
5153
|
-
var statusOrder = {
|
|
5154
|
-
in_progress: 0,
|
|
5155
|
-
pending: 1,
|
|
5156
|
-
completed: 2
|
|
5157
|
-
};
|
|
5158
|
-
var sortTodosForDisplay = (todos) => todos.map((todo, index) => ({ todo, index })).sort((a, b) => {
|
|
5159
|
-
const statusDiff = statusOrder[a.todo.status] - statusOrder[b.todo.status];
|
|
5160
|
-
if (statusDiff !== 0) return statusDiff;
|
|
5161
|
-
const priorityDiff = a.todo.priority - b.todo.priority;
|
|
5162
|
-
if (priorityDiff !== 0) return priorityDiff;
|
|
5163
|
-
return a.index - b.index;
|
|
5164
|
-
}).map((entry) => entry.todo);
|
|
5165
5197
|
var pickNextTodo = (todos) => {
|
|
5166
5198
|
const inProgress = todos.find((todo) => todo.status === "in_progress");
|
|
5167
5199
|
if (inProgress) return inProgress;
|
|
5168
|
-
const pending =
|
|
5169
|
-
(todo) => todo.status === "pending"
|
|
5170
|
-
);
|
|
5200
|
+
const pending = todos.find((todo) => todo.status === "pending");
|
|
5171
5201
|
return pending ?? null;
|
|
5172
5202
|
};
|
|
5173
5203
|
var todoStore = /* @__PURE__ */ new Map();
|
|
@@ -5188,28 +5218,25 @@ var createTodoReadTool = (sandboxKey, sessionContextKey) => (0, import_core14.de
|
|
|
5188
5218
|
const todoSessionId = sessionContext?.sessionId && sessionContext.sessionId.length > 0 ? sessionContext.sessionId : sandbox.sessionId;
|
|
5189
5219
|
const todos = getTodosForSession(todoSessionId);
|
|
5190
5220
|
if (!todos.length) return "Todo list is empty";
|
|
5191
|
-
const
|
|
5221
|
+
const displayedTodos = [...todos];
|
|
5192
5222
|
const lines = ["Todo plan:"];
|
|
5193
|
-
for (const [index, todo] of
|
|
5223
|
+
for (const [index, todo] of displayedTodos.entries()) {
|
|
5194
5224
|
const label = todo.status === "in_progress" && todo.activeForm ? todo.activeForm : todo.content;
|
|
5195
5225
|
lines.push(
|
|
5196
5226
|
`${index + 1}. ${statusSymbol[todo.status]} [${todo.id}] (p${todo.priority}) ${label}`
|
|
5197
5227
|
);
|
|
5198
|
-
if (todo.notes) {
|
|
5199
|
-
lines.push(` note: ${todo.notes}`);
|
|
5200
|
-
}
|
|
5201
5228
|
}
|
|
5202
|
-
const stats = getTodoStats(
|
|
5203
|
-
const nextTodo = pickNextTodo(
|
|
5229
|
+
const stats = getTodoStats(displayedTodos);
|
|
5230
|
+
const nextTodo = pickNextTodo(displayedTodos);
|
|
5204
5231
|
lines.push(
|
|
5205
5232
|
`Summary: ${stats.pending} pending, ${stats.inProgress} in progress, ${stats.completed} completed`
|
|
5206
5233
|
);
|
|
5207
5234
|
if (nextTodo) {
|
|
5208
|
-
lines.push(`Next: [${nextTodo.id}]
|
|
5235
|
+
lines.push(`Next: [${nextTodo.id}]`);
|
|
5209
5236
|
} else {
|
|
5210
5237
|
lines.push("Next: none");
|
|
5211
5238
|
}
|
|
5212
|
-
const inProgressCount = countInProgressTodos(
|
|
5239
|
+
const inProgressCount = countInProgressTodos(displayedTodos);
|
|
5213
5240
|
if (inProgressCount > 1) {
|
|
5214
5241
|
lines.push(
|
|
5215
5242
|
`Warning: ${inProgressCount} items are in_progress (expected at most 1).`
|
|
@@ -5297,12 +5324,36 @@ var todoWriteInputSchema = import_zod14.z.object({
|
|
|
5297
5324
|
});
|
|
5298
5325
|
}
|
|
5299
5326
|
});
|
|
5327
|
+
var statusSymbol2 = {
|
|
5328
|
+
pending: "[ ]",
|
|
5329
|
+
in_progress: "[>]",
|
|
5330
|
+
completed: "[x]"
|
|
5331
|
+
};
|
|
5300
5332
|
var loadSessionTodos = (sessionId) => getTodosForSession(sessionId);
|
|
5301
5333
|
var formatSuccess = (mode, todos) => {
|
|
5302
5334
|
const stats = getTodoStats(todos);
|
|
5303
5335
|
const nextTodo = pickNextTodo(todos);
|
|
5304
|
-
const nextHint = nextTodo ? ` Next: [${nextTodo.id}]
|
|
5305
|
-
|
|
5336
|
+
const nextHint = nextTodo ? ` Next: [${nextTodo.id}].` : " Next: none.";
|
|
5337
|
+
const summary = `Updated todos (${mode}): ${stats.pending} pending, ${stats.inProgress} in progress, ${stats.completed} completed.${nextHint}`;
|
|
5338
|
+
if (todos.length === 0) {
|
|
5339
|
+
return summary;
|
|
5340
|
+
}
|
|
5341
|
+
const lines = [summary, "Todo plan:"];
|
|
5342
|
+
for (const [index, todo] of todos.entries()) {
|
|
5343
|
+
const label = todo.status === "in_progress" && todo.activeForm ? todo.activeForm : todo.content;
|
|
5344
|
+
lines.push(
|
|
5345
|
+
`${index + 1}. ${statusSymbol2[todo.status]} [${todo.id}] (p${todo.priority}) ${label}`
|
|
5346
|
+
);
|
|
5347
|
+
}
|
|
5348
|
+
lines.push(
|
|
5349
|
+
`Summary: ${stats.pending} pending, ${stats.inProgress} in progress, ${stats.completed} completed`
|
|
5350
|
+
);
|
|
5351
|
+
if (nextTodo) {
|
|
5352
|
+
lines.push(`Next: [${nextTodo.id}]`);
|
|
5353
|
+
} else {
|
|
5354
|
+
lines.push("Next: none");
|
|
5355
|
+
}
|
|
5356
|
+
return lines.join("\n");
|
|
5306
5357
|
};
|
|
5307
5358
|
var withPatchApplied = (currentTodos, updates) => {
|
|
5308
5359
|
const normalizedUpdates = updates.map((update) => ({
|
|
@@ -5388,7 +5439,8 @@ var createToolOutputCacheTool = (store) => (0, import_core16.defineTool)({
|
|
|
5388
5439
|
input: import_zod15.z.object({
|
|
5389
5440
|
ref_id: import_zod15.z.string().describe("Tool output reference ID."),
|
|
5390
5441
|
offset: import_zod15.z.number().int().nonnegative().optional().describe("Optional 0-based line offset."),
|
|
5391
|
-
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.")
|
|
5392
5444
|
}),
|
|
5393
5445
|
execute: async (input) => {
|
|
5394
5446
|
if (!store.read) {
|
|
@@ -5397,7 +5449,8 @@ var createToolOutputCacheTool = (store) => (0, import_core16.defineTool)({
|
|
|
5397
5449
|
try {
|
|
5398
5450
|
return await store.read(input.ref_id, {
|
|
5399
5451
|
offset: input.offset,
|
|
5400
|
-
limit: input.limit
|
|
5452
|
+
limit: input.limit,
|
|
5453
|
+
wrap_long_lines: input.wrap_long_lines
|
|
5401
5454
|
});
|
|
5402
5455
|
} catch (error) {
|
|
5403
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) {
|
|
@@ -5149,24 +5193,10 @@ var getTodoStats = (todos) => ({
|
|
|
5149
5193
|
inProgress: todos.filter((todo) => todo.status === "in_progress").length,
|
|
5150
5194
|
completed: todos.filter((todo) => todo.status === "completed").length
|
|
5151
5195
|
});
|
|
5152
|
-
var statusOrder = {
|
|
5153
|
-
in_progress: 0,
|
|
5154
|
-
pending: 1,
|
|
5155
|
-
completed: 2
|
|
5156
|
-
};
|
|
5157
|
-
var sortTodosForDisplay = (todos) => todos.map((todo, index) => ({ todo, index })).sort((a, b) => {
|
|
5158
|
-
const statusDiff = statusOrder[a.todo.status] - statusOrder[b.todo.status];
|
|
5159
|
-
if (statusDiff !== 0) return statusDiff;
|
|
5160
|
-
const priorityDiff = a.todo.priority - b.todo.priority;
|
|
5161
|
-
if (priorityDiff !== 0) return priorityDiff;
|
|
5162
|
-
return a.index - b.index;
|
|
5163
|
-
}).map((entry) => entry.todo);
|
|
5164
5196
|
var pickNextTodo = (todos) => {
|
|
5165
5197
|
const inProgress = todos.find((todo) => todo.status === "in_progress");
|
|
5166
5198
|
if (inProgress) return inProgress;
|
|
5167
|
-
const pending =
|
|
5168
|
-
(todo) => todo.status === "pending"
|
|
5169
|
-
);
|
|
5199
|
+
const pending = todos.find((todo) => todo.status === "pending");
|
|
5170
5200
|
return pending ?? null;
|
|
5171
5201
|
};
|
|
5172
5202
|
var todoStore = /* @__PURE__ */ new Map();
|
|
@@ -5187,28 +5217,25 @@ var createTodoReadTool = (sandboxKey, sessionContextKey) => defineTool12({
|
|
|
5187
5217
|
const todoSessionId = sessionContext?.sessionId && sessionContext.sessionId.length > 0 ? sessionContext.sessionId : sandbox.sessionId;
|
|
5188
5218
|
const todos = getTodosForSession(todoSessionId);
|
|
5189
5219
|
if (!todos.length) return "Todo list is empty";
|
|
5190
|
-
const
|
|
5220
|
+
const displayedTodos = [...todos];
|
|
5191
5221
|
const lines = ["Todo plan:"];
|
|
5192
|
-
for (const [index, todo] of
|
|
5222
|
+
for (const [index, todo] of displayedTodos.entries()) {
|
|
5193
5223
|
const label = todo.status === "in_progress" && todo.activeForm ? todo.activeForm : todo.content;
|
|
5194
5224
|
lines.push(
|
|
5195
5225
|
`${index + 1}. ${statusSymbol[todo.status]} [${todo.id}] (p${todo.priority}) ${label}`
|
|
5196
5226
|
);
|
|
5197
|
-
if (todo.notes) {
|
|
5198
|
-
lines.push(` note: ${todo.notes}`);
|
|
5199
|
-
}
|
|
5200
5227
|
}
|
|
5201
|
-
const stats = getTodoStats(
|
|
5202
|
-
const nextTodo = pickNextTodo(
|
|
5228
|
+
const stats = getTodoStats(displayedTodos);
|
|
5229
|
+
const nextTodo = pickNextTodo(displayedTodos);
|
|
5203
5230
|
lines.push(
|
|
5204
5231
|
`Summary: ${stats.pending} pending, ${stats.inProgress} in progress, ${stats.completed} completed`
|
|
5205
5232
|
);
|
|
5206
5233
|
if (nextTodo) {
|
|
5207
|
-
lines.push(`Next: [${nextTodo.id}]
|
|
5234
|
+
lines.push(`Next: [${nextTodo.id}]`);
|
|
5208
5235
|
} else {
|
|
5209
5236
|
lines.push("Next: none");
|
|
5210
5237
|
}
|
|
5211
|
-
const inProgressCount = countInProgressTodos(
|
|
5238
|
+
const inProgressCount = countInProgressTodos(displayedTodos);
|
|
5212
5239
|
if (inProgressCount > 1) {
|
|
5213
5240
|
lines.push(
|
|
5214
5241
|
`Warning: ${inProgressCount} items are in_progress (expected at most 1).`
|
|
@@ -5296,12 +5323,36 @@ var todoWriteInputSchema = z14.object({
|
|
|
5296
5323
|
});
|
|
5297
5324
|
}
|
|
5298
5325
|
});
|
|
5326
|
+
var statusSymbol2 = {
|
|
5327
|
+
pending: "[ ]",
|
|
5328
|
+
in_progress: "[>]",
|
|
5329
|
+
completed: "[x]"
|
|
5330
|
+
};
|
|
5299
5331
|
var loadSessionTodos = (sessionId) => getTodosForSession(sessionId);
|
|
5300
5332
|
var formatSuccess = (mode, todos) => {
|
|
5301
5333
|
const stats = getTodoStats(todos);
|
|
5302
5334
|
const nextTodo = pickNextTodo(todos);
|
|
5303
|
-
const nextHint = nextTodo ? ` Next: [${nextTodo.id}]
|
|
5304
|
-
|
|
5335
|
+
const nextHint = nextTodo ? ` Next: [${nextTodo.id}].` : " Next: none.";
|
|
5336
|
+
const summary = `Updated todos (${mode}): ${stats.pending} pending, ${stats.inProgress} in progress, ${stats.completed} completed.${nextHint}`;
|
|
5337
|
+
if (todos.length === 0) {
|
|
5338
|
+
return summary;
|
|
5339
|
+
}
|
|
5340
|
+
const lines = [summary, "Todo plan:"];
|
|
5341
|
+
for (const [index, todo] of todos.entries()) {
|
|
5342
|
+
const label = todo.status === "in_progress" && todo.activeForm ? todo.activeForm : todo.content;
|
|
5343
|
+
lines.push(
|
|
5344
|
+
`${index + 1}. ${statusSymbol2[todo.status]} [${todo.id}] (p${todo.priority}) ${label}`
|
|
5345
|
+
);
|
|
5346
|
+
}
|
|
5347
|
+
lines.push(
|
|
5348
|
+
`Summary: ${stats.pending} pending, ${stats.inProgress} in progress, ${stats.completed} completed`
|
|
5349
|
+
);
|
|
5350
|
+
if (nextTodo) {
|
|
5351
|
+
lines.push(`Next: [${nextTodo.id}]`);
|
|
5352
|
+
} else {
|
|
5353
|
+
lines.push("Next: none");
|
|
5354
|
+
}
|
|
5355
|
+
return lines.join("\n");
|
|
5305
5356
|
};
|
|
5306
5357
|
var withPatchApplied = (currentTodos, updates) => {
|
|
5307
5358
|
const normalizedUpdates = updates.map((update) => ({
|
|
@@ -5387,7 +5438,8 @@ var createToolOutputCacheTool = (store) => defineTool14({
|
|
|
5387
5438
|
input: z15.object({
|
|
5388
5439
|
ref_id: z15.string().describe("Tool output reference ID."),
|
|
5389
5440
|
offset: z15.number().int().nonnegative().optional().describe("Optional 0-based line offset."),
|
|
5390
|
-
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.")
|
|
5391
5443
|
}),
|
|
5392
5444
|
execute: async (input) => {
|
|
5393
5445
|
if (!store.read) {
|
|
@@ -5396,7 +5448,8 @@ var createToolOutputCacheTool = (store) => defineTool14({
|
|
|
5396
5448
|
try {
|
|
5397
5449
|
return await store.read(input.ref_id, {
|
|
5398
5450
|
offset: input.offset,
|
|
5399
|
-
limit: input.limit
|
|
5451
|
+
limit: input.limit,
|
|
5452
|
+
wrap_long_lines: input.wrap_long_lines
|
|
5400
5453
|
});
|
|
5401
5454
|
} catch (error) {
|
|
5402
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"
|