@animalabs/agent-framework 0.14.0 → 0.15.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.
Files changed (62) hide show
  1. package/dist/src/agent.d.ts +10 -0
  2. package/dist/src/agent.d.ts.map +1 -1
  3. package/dist/src/agent.js +39 -0
  4. package/dist/src/agent.js.map +1 -1
  5. package/dist/src/framework.d.ts +5 -2
  6. package/dist/src/framework.d.ts.map +1 -1
  7. package/dist/src/framework.js +126 -36
  8. package/dist/src/framework.js.map +1 -1
  9. package/dist/src/modules/history/index.d.ts +69 -0
  10. package/dist/src/modules/history/index.d.ts.map +1 -0
  11. package/dist/src/modules/history/index.js +519 -0
  12. package/dist/src/modules/history/index.js.map +1 -0
  13. package/dist/src/modules/history/search-regex-worker.d.ts +23 -0
  14. package/dist/src/modules/history/search-regex-worker.d.ts.map +1 -0
  15. package/dist/src/modules/history/search-regex-worker.js +57 -0
  16. package/dist/src/modules/history/search-regex-worker.js.map +1 -0
  17. package/dist/src/modules/index.d.ts +1 -0
  18. package/dist/src/modules/index.d.ts.map +1 -1
  19. package/dist/src/modules/index.js +1 -0
  20. package/dist/src/modules/index.js.map +1 -1
  21. package/dist/src/modules/workspace/index.d.ts.map +1 -1
  22. package/dist/src/modules/workspace/index.js +42 -1
  23. package/dist/src/modules/workspace/index.js.map +1 -1
  24. package/dist/src/modules/workspace/types.d.ts +5 -0
  25. package/dist/src/modules/workspace/types.d.ts.map +1 -1
  26. package/dist/src/modules/workspace/types.js.map +1 -1
  27. package/dist/src/types/trace.d.ts +4 -0
  28. package/dist/src/types/trace.d.ts.map +1 -1
  29. package/dist/test/history-module.test.d.ts +2 -0
  30. package/dist/test/history-module.test.d.ts.map +1 -0
  31. package/dist/test/history-module.test.js +449 -0
  32. package/dist/test/history-module.test.js.map +1 -0
  33. package/dist/test/kv-unified-open-flight-retry.test.d.ts +2 -0
  34. package/dist/test/kv-unified-open-flight-retry.test.d.ts.map +1 -0
  35. package/dist/test/kv-unified-open-flight-retry.test.js +189 -0
  36. package/dist/test/kv-unified-open-flight-retry.test.js.map +1 -0
  37. package/dist/test/kv-unified-wiring.test.js +39 -0
  38. package/dist/test/kv-unified-wiring.test.js.map +1 -1
  39. package/dist/test/puppet-tool-call.test.js +113 -1
  40. package/dist/test/puppet-tool-call.test.js.map +1 -1
  41. package/dist/test/puppet-turn-reservation.test.d.ts +2 -0
  42. package/dist/test/puppet-turn-reservation.test.d.ts.map +1 -0
  43. package/dist/test/puppet-turn-reservation.test.js +139 -0
  44. package/dist/test/puppet-turn-reservation.test.js.map +1 -0
  45. package/dist/test/save-recent-image.test.js +29 -0
  46. package/dist/test/save-recent-image.test.js.map +1 -1
  47. package/dist/test/tool-result-spill.test.js +114 -0
  48. package/dist/test/tool-result-spill.test.js.map +1 -1
  49. package/dist/test/workspace-read-text.test.d.ts +2 -0
  50. package/dist/test/workspace-read-text.test.d.ts.map +1 -0
  51. package/dist/test/workspace-read-text.test.js +101 -0
  52. package/dist/test/workspace-read-text.test.js.map +1 -0
  53. package/dist/tsconfig.tsbuildinfo +1 -1
  54. package/package.json +3 -3
  55. package/src/agent.ts +41 -0
  56. package/src/framework.ts +132 -43
  57. package/src/modules/history/index.ts +613 -0
  58. package/src/modules/history/search-regex-worker.ts +76 -0
  59. package/src/modules/index.ts +2 -0
  60. package/src/modules/workspace/index.ts +42 -1
  61. package/src/modules/workspace/types.ts +5 -0
  62. package/src/types/trace.ts +4 -0
@@ -8,6 +8,8 @@ export type { ApiEvent } from './api/index.js';
8
8
  export { HealthModule } from './health/index.js';
9
9
  export type { HealthModuleConfig } from './health/index.js';
10
10
 
11
+ export { HistoryModule } from './history/index.js';
12
+
11
13
  export { WorkspaceModule, WorkspaceReadError } from './workspace/index.js';
12
14
  export type { WorkspaceReadErrorCode, WorkspaceReadStage, WorkspaceDiskReadResult, ReadFileFromDiskOptions } from './workspace/index.js';
13
15
  export type {
@@ -932,13 +932,19 @@ export class WorkspaceModule implements Module {
932
932
  return [
933
933
  {
934
934
  name: 'read',
935
- description: 'Read a file from the workspace. Returns content with line numbers. Reads at most 2000 lines per call by default — use offset/limit to page through larger files.',
935
+ description: 'Read a file from the workspace. Returns content with line numbers. '
936
+ + 'Reads at most 2000 lines per call by default — use offset/limit to page through larger files. '
937
+ + 'For long lines or spill files, use offsetChars/limitChars instead: returns raw text without '
938
+ + 'line numbers, with nextOffsetChars (null at EOF). Keep limitChars when continuing. '
939
+ + 'Character offsets count UTF-16 code units; do not mix character and line parameters.',
936
940
  inputSchema: {
937
941
  type: 'object' as const,
938
942
  properties: {
939
943
  path: { type: 'string', description: 'File path (mount-prefixed, e.g., "project/src/main.ts")' },
940
944
  offset: { type: 'number', description: 'Starting line number (1-indexed)' },
941
945
  limit: { type: 'number', description: 'Maximum number of lines to return (default 2000)' },
946
+ offsetChars: { type: 'integer', description: 'Character paging: zero-based UTF-16 offset (default 0); use nextOffsetChars to continue' },
947
+ limitChars: { type: 'integer', description: 'Character paging: code units to return (default 2000), plus at most one to keep a surrogate pair intact. Use the limit suggested by a spill notice.' },
942
948
  },
943
949
  required: ['path'],
944
950
  },
@@ -1741,6 +1747,19 @@ export class WorkspaceModule implements Module {
1741
1747
  // ==========================================================================
1742
1748
 
1743
1749
  private async handleRead(input: ReadInput): Promise<ToolResult> {
1750
+ const characterPaging = input.offsetChars !== undefined || input.limitChars !== undefined;
1751
+ const offsetChars = input.offsetChars ?? 0;
1752
+ const limitChars = input.limitChars ?? 2000;
1753
+ if (characterPaging) {
1754
+ if (input.offset !== undefined || input.limit !== undefined) {
1755
+ return { success: false, isError: true, error: 'Use either offset/limit (lines) or offsetChars/limitChars (characters), not both.' };
1756
+ }
1757
+ if (!Number.isSafeInteger(offsetChars) || offsetChars < 0
1758
+ || !Number.isSafeInteger(limitChars) || limitChars < 1
1759
+ || input.offsetChars === null || input.limitChars === null) {
1760
+ return { success: false, isError: true, error: 'offsetChars must be a non-negative safe integer and limitChars a positive safe integer.' };
1761
+ }
1762
+ }
1744
1763
  const { mount, relativePath } = this.parsePath(input.path);
1745
1764
  const store = this.getStore();
1746
1765
 
@@ -1757,6 +1776,28 @@ export class WorkspaceModule implements Module {
1757
1776
  }
1758
1777
 
1759
1778
  const content = blob.toString('utf-8');
1779
+ if (characterPaging) {
1780
+ const start = Math.min(offsetChars, content.length);
1781
+ const splitsPair = (at: number): boolean =>
1782
+ at > 0 && at < content.length
1783
+ && content.charCodeAt(at - 1) >= 0xd800 && content.charCodeAt(at - 1) <= 0xdbff
1784
+ && content.charCodeAt(at) >= 0xdc00 && content.charCodeAt(at) <= 0xdfff;
1785
+ if (splitsPair(start)) {
1786
+ return { success: false, isError: true, error: 'offsetChars splits a surrogate pair; use nextOffsetChars from the previous page.' };
1787
+ }
1788
+ let end = start + Math.min(limitChars, content.length - start);
1789
+ if (splitsPair(end)) end++;
1790
+ return {
1791
+ success: true,
1792
+ data: {
1793
+ path: input.path,
1794
+ totalChars: content.length,
1795
+ offsetChars: start,
1796
+ nextOffsetChars: end < content.length ? end : null,
1797
+ content: content.slice(start, end),
1798
+ },
1799
+ };
1800
+ }
1760
1801
  const lines = content.split('\n');
1761
1802
 
1762
1803
  // Apply offset/limit. An unlimited read of a large file would inject the
@@ -133,6 +133,11 @@ export interface ReadInput {
133
133
  offset?: number;
134
134
  /** Number of lines to read (optional) */
135
135
  limit?: number;
136
+ /** Zero-based UTF-16 offset; selects character paging. Cannot mix with line offset/limit. */
137
+ offsetChars?: number;
138
+ /** Character page size in UTF-16 code units (default 2000); selects character paging.
139
+ * May include one extra code unit to keep a surrogate pair intact. */
140
+ limitChars?: number;
136
141
  }
137
142
 
138
143
  export interface ReadImageInput {
@@ -351,6 +351,10 @@ export type TraceEvent =
351
351
  toolUseId: string;
352
352
  isError: boolean;
353
353
  durationMs: number;
354
+ /** The pair was queued behind a turn that replaced the puppet's
355
+ * reservation (provider-admission re-entry) instead of stored
356
+ * directly; it lands at that turn's end flush. */
357
+ deferred?: boolean;
354
358
  })
355
359
 
356
360
  // MCPL server connection lifecycle (spawn / handshake / reconnect health).