@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.
- package/dist/src/agent.d.ts +10 -0
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +39 -0
- package/dist/src/agent.js.map +1 -1
- package/dist/src/framework.d.ts +5 -2
- package/dist/src/framework.d.ts.map +1 -1
- package/dist/src/framework.js +126 -36
- package/dist/src/framework.js.map +1 -1
- package/dist/src/modules/history/index.d.ts +69 -0
- package/dist/src/modules/history/index.d.ts.map +1 -0
- package/dist/src/modules/history/index.js +519 -0
- package/dist/src/modules/history/index.js.map +1 -0
- package/dist/src/modules/history/search-regex-worker.d.ts +23 -0
- package/dist/src/modules/history/search-regex-worker.d.ts.map +1 -0
- package/dist/src/modules/history/search-regex-worker.js +57 -0
- package/dist/src/modules/history/search-regex-worker.js.map +1 -0
- package/dist/src/modules/index.d.ts +1 -0
- package/dist/src/modules/index.d.ts.map +1 -1
- package/dist/src/modules/index.js +1 -0
- package/dist/src/modules/index.js.map +1 -1
- package/dist/src/modules/workspace/index.d.ts.map +1 -1
- package/dist/src/modules/workspace/index.js +42 -1
- package/dist/src/modules/workspace/index.js.map +1 -1
- package/dist/src/modules/workspace/types.d.ts +5 -0
- package/dist/src/modules/workspace/types.d.ts.map +1 -1
- package/dist/src/modules/workspace/types.js.map +1 -1
- package/dist/src/types/trace.d.ts +4 -0
- package/dist/src/types/trace.d.ts.map +1 -1
- package/dist/test/history-module.test.d.ts +2 -0
- package/dist/test/history-module.test.d.ts.map +1 -0
- package/dist/test/history-module.test.js +449 -0
- package/dist/test/history-module.test.js.map +1 -0
- package/dist/test/kv-unified-open-flight-retry.test.d.ts +2 -0
- package/dist/test/kv-unified-open-flight-retry.test.d.ts.map +1 -0
- package/dist/test/kv-unified-open-flight-retry.test.js +189 -0
- package/dist/test/kv-unified-open-flight-retry.test.js.map +1 -0
- package/dist/test/kv-unified-wiring.test.js +39 -0
- package/dist/test/kv-unified-wiring.test.js.map +1 -1
- package/dist/test/puppet-tool-call.test.js +113 -1
- package/dist/test/puppet-tool-call.test.js.map +1 -1
- package/dist/test/puppet-turn-reservation.test.d.ts +2 -0
- package/dist/test/puppet-turn-reservation.test.d.ts.map +1 -0
- package/dist/test/puppet-turn-reservation.test.js +139 -0
- package/dist/test/puppet-turn-reservation.test.js.map +1 -0
- package/dist/test/save-recent-image.test.js +29 -0
- package/dist/test/save-recent-image.test.js.map +1 -1
- package/dist/test/tool-result-spill.test.js +114 -0
- package/dist/test/tool-result-spill.test.js.map +1 -1
- package/dist/test/workspace-read-text.test.d.ts +2 -0
- package/dist/test/workspace-read-text.test.d.ts.map +1 -0
- package/dist/test/workspace-read-text.test.js +101 -0
- package/dist/test/workspace-read-text.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/agent.ts +41 -0
- package/src/framework.ts +132 -43
- package/src/modules/history/index.ts +613 -0
- package/src/modules/history/search-regex-worker.ts +76 -0
- package/src/modules/index.ts +2 -0
- package/src/modules/workspace/index.ts +42 -1
- package/src/modules/workspace/types.ts +5 -0
- package/src/types/trace.ts +4 -0
package/src/modules/index.ts
CHANGED
|
@@ -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.
|
|
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 {
|
package/src/types/trace.ts
CHANGED
|
@@ -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).
|