@anthropic-ai/foundry-sdk 0.3.1 → 0.4.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/CHANGELOG.md +8 -0
- package/package.json +17 -1
- package/src/internal/message-stream-utils.ts +30 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.0 (2026-06-18)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [foundry-sdk-v0.3.1...foundry-sdk-v0.4.0](https://github.com/anthropics/anthropic-sdk-typescript/compare/foundry-sdk-v0.3.1...foundry-sdk-v0.4.0)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* **stream:** lazily parse partial tool json input ([#99](https://github.com/anthropics/anthropic-sdk-typescript/issues/99)) ([e55ceee](https://github.com/anthropics/anthropic-sdk-typescript/commit/e55ceee5e3053ada96a7fe008b1fd6ebc0e42544))
|
|
10
|
+
|
|
3
11
|
## 0.3.1 (2026-06-09)
|
|
4
12
|
|
|
5
13
|
Full Changelog: [foundry-sdk-v0.3.0...foundry-sdk-v0.3.1](https://github.com/anthropics/anthropic-sdk-typescript/compare/foundry-sdk-v0.3.0...foundry-sdk-v0.3.1)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anthropic-ai/foundry-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "The official TypeScript library for the Anthropic Foundry API",
|
|
5
5
|
"author": "Anthropic <support@anthropic.com>",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -76,6 +76,22 @@
|
|
|
76
76
|
},
|
|
77
77
|
"./index.mjs": {
|
|
78
78
|
"default": "./index.mjs"
|
|
79
|
+
},
|
|
80
|
+
"./tools/agent-toolset/node": {
|
|
81
|
+
"browser": {
|
|
82
|
+
"import": "./tools/agent-toolset/node.browser.mjs",
|
|
83
|
+
"require": "./tools/agent-toolset/node.browser.js"
|
|
84
|
+
},
|
|
85
|
+
"import": "./tools/agent-toolset/node.mjs",
|
|
86
|
+
"require": "./tools/agent-toolset/node.js"
|
|
87
|
+
},
|
|
88
|
+
"./tools/memory/node": {
|
|
89
|
+
"browser": {
|
|
90
|
+
"import": "./tools/memory/node.browser.mjs",
|
|
91
|
+
"require": "./tools/memory/node.browser.js"
|
|
92
|
+
},
|
|
93
|
+
"import": "./tools/memory/node.mjs",
|
|
94
|
+
"require": "./tools/memory/node.js"
|
|
79
95
|
}
|
|
80
96
|
}
|
|
81
97
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { partialParse } from '../_vendor/partial-json-parser/parser';
|
|
2
|
+
|
|
3
|
+
export const JSON_BUF_PROPERTY = '__json_buf';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Copies a tool-use block with an updated `__json_buf`, installing `.input` as
|
|
7
|
+
* a memoized getter so the partial-JSON parse happens on first read instead of
|
|
8
|
+
* on every delta.
|
|
9
|
+
*/
|
|
10
|
+
export function withLazyInput<T extends { input: unknown }>(prev: T, jsonBuf: string): T {
|
|
11
|
+
const next = {} as T;
|
|
12
|
+
for (const key of Object.keys(prev) as (keyof T)[]) {
|
|
13
|
+
if (key !== 'input') next[key] = prev[key];
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(next, JSON_BUF_PROPERTY, { value: jsonBuf, enumerable: false, writable: true });
|
|
16
|
+
let input: unknown;
|
|
17
|
+
let parsed = false;
|
|
18
|
+
Object.defineProperty(next, 'input', {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
configurable: true,
|
|
21
|
+
get() {
|
|
22
|
+
if (!parsed) {
|
|
23
|
+
input = jsonBuf ? partialParse(jsonBuf) : {};
|
|
24
|
+
parsed = true;
|
|
25
|
+
}
|
|
26
|
+
return input;
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
return next;
|
|
30
|
+
}
|