@sema-agent/core 1.448.1 → 1.449.0

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.
@@ -6,6 +6,14 @@ function normalizeContent(ret) {
6
6
  return { content: [{ type: "text", text: ret }], details: undefined, terminate: false, isError: false };
7
7
  }
8
8
  const raw = ret.content;
9
+ if (typeof raw !== "string" && !Array.isArray(raw)) {
10
+ return {
11
+ content: [{ type: "text", text: "Tool error: content must be a string or an array of content blocks." }],
12
+ details: undefined,
13
+ terminate: false,
14
+ isError: true,
15
+ };
16
+ }
9
17
  const content = typeof raw === "string" ? [{ type: "text", text: raw }] : raw;
10
18
  return { content, details: ret.details, terminate: ret.terminate ?? false, isError: ret.isError === true };
11
19
  }
@@ -586,7 +586,14 @@ export function makeReadFileTool(env, state, rootCanonical, cwdRef, additionalRo
586
586
  if (total > 0 && prev && prev.hash === hash && prev.view && prev.view.start === start && prev.view.end === end) {
587
587
  return `[${path}: unchanged since you last read it (lines ${start}-${end} of ${total}); content omitted to save context]`;
588
588
  }
589
- state.set(r.key, { hash, totalLines: countLines(content), truncated, view: { start, end }, lastReadAt: Date.now() });
589
+ state.set(r.key, {
590
+ hash,
591
+ totalLines: countLines(content),
592
+ truncated,
593
+ ...(pageMarker !== undefined ? { isPartialView: true } : {}),
594
+ view: { start, end },
595
+ lastReadAt: Date.now(),
596
+ });
590
597
  if (total === 0)
591
598
  return `<system-reminder>Warning: the file exists but is shorter than the provided offset (${start}). The file has 1 lines.</system-reminder>`;
592
599
  const header = pageMarker ?? (truncated ? `[${path}: lines ${start}-${end} of ${total}${end < total ? " — use offset to see more" : ""}]\n` : "");
@@ -5,6 +5,7 @@ export interface ReadEntry {
5
5
  hash: string;
6
6
  totalLines: number;
7
7
  truncated: boolean;
8
+ isPartialView?: boolean;
8
9
  view?: {
9
10
  start: number;
10
11
  end: number;
@@ -228,7 +228,8 @@ export function violationText(toolName, v) {
228
228
  return `Error (${toolName}): ${v.message}`;
229
229
  }
230
230
  export function requireRead(state, key) {
231
- if (!state.has(key)) {
231
+ const entry = state.get(key);
232
+ if (entry === undefined || entry.isPartialView) {
232
233
  return { code: "not_read", message: "File has not been read yet. Read it first before writing to it." };
233
234
  }
234
235
  return undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sema-agent/core",
3
- "version": "1.448.1",
3
+ "version": "1.449.0",
4
4
  "description": "Stateless, task-oriented AI agent core",
5
5
  "type": "module",
6
6
  "license": "BUSL-1.1",