@puku-ai/sdk 3.0.0 → 3.0.2
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/README.md +6 -4
- package/package.json +1 -1
- package/sdk.cjs +16 -7
- package/sdk.cjs.map +11 -11
- package/sdk.d.ts +52 -29
- package/sdk.mjs +18 -18
- package/sdk.mjs.map +11 -11
package/README.md
CHANGED
|
@@ -114,7 +114,8 @@ try {
|
|
|
114
114
|
// rate limited — back off and retry
|
|
115
115
|
} else if (err instanceof PukuAI.AuthenticationError) {
|
|
116
116
|
// bad api key
|
|
117
|
-
} else if (err instanceof PukuAI.
|
|
117
|
+
} else if (err instanceof PukuAI.PukuError) {
|
|
118
|
+
// any other SDK error (base class — all errors extend this)
|
|
118
119
|
console.error(err.status, err.type, err.message);
|
|
119
120
|
}
|
|
120
121
|
}
|
|
@@ -122,7 +123,8 @@ try {
|
|
|
122
123
|
|
|
123
124
|
All error classes are static members of the `PukuAI` class,
|
|
124
125
|
|
|
125
|
-
- `PukuAI.
|
|
126
|
+
- `PukuAI.PukuError` (branded base — every error the SDK throws is an instance of this)
|
|
127
|
+
- `PukuAI.AnthropicError` (deprecated alias of `PukuError`, kept for backward compat)
|
|
126
128
|
- `PukuAI.APIError`
|
|
127
129
|
- `PukuAI.APIConnectionError`
|
|
128
130
|
- `PukuAI.APIConnectionTimeoutError`
|
|
@@ -263,6 +265,8 @@ const reply = await client.beta.messages.create({
|
|
|
263
265
|
|
|
264
266
|
### Example: agent toolset (bash / read / write / edit / glob / grep)
|
|
265
267
|
|
|
268
|
+
`currently ignore this`
|
|
269
|
+
|
|
266
270
|
The SDK ships the upstream `tools/agent-toolset` surface — the same `BetaRunnableTool[]`
|
|
267
271
|
factory used by puku-cli's agent mode to give the model a sandboxed shell + filesystem.
|
|
268
272
|
|
|
@@ -340,8 +344,6 @@ const client = new PukuAI({ apiKey, baseURL }); // works the same in both
|
|
|
340
344
|
```
|
|
341
345
|
|
|
342
346
|
> The default export is the callable constructor, not the `PukuAI` class
|
|
343
|
-
> itself. This matches `@anthropic-ai/sdk` exactly. To check class membership
|
|
344
|
-
> use `client.constructor.name === "PukuAI"`, not `instanceof PukuAI`.
|
|
345
347
|
|
|
346
348
|
|
|
347
349
|
## License
|
package/package.json
CHANGED
package/sdk.cjs
CHANGED
|
@@ -98,6 +98,7 @@ __export(__pukuExports, {
|
|
|
98
98
|
UnprocessableEntityError: () => UnprocessableEntityError,
|
|
99
99
|
ToolError: () => ToolError,
|
|
100
100
|
RateLimitError: () => RateLimitError,
|
|
101
|
+
PukuError: () => PukuError,
|
|
101
102
|
PukuAI: () => PukuAI,
|
|
102
103
|
PermissionDeniedError: () => PermissionDeniedError,
|
|
103
104
|
PagePromise: () => PagePromise,
|
|
@@ -107,7 +108,7 @@ __export(__pukuExports, {
|
|
|
107
108
|
ConflictError: () => ConflictError,
|
|
108
109
|
BashTimeoutError: () => BashTimeoutError,
|
|
109
110
|
BashSession: () => BashSession,
|
|
110
|
-
|
|
111
|
+
BasePuku: () => BasePuku,
|
|
111
112
|
BadRequestError: () => BadRequestError,
|
|
112
113
|
AuthenticationError: () => AuthenticationError,
|
|
113
114
|
AnthropicError: () => AnthropicError,
|
|
@@ -162,7 +163,14 @@ var castToError = (err) => {
|
|
|
162
163
|
class AnthropicError extends Error {
|
|
163
164
|
}
|
|
164
165
|
|
|
165
|
-
class
|
|
166
|
+
class PukuError extends AnthropicError {
|
|
167
|
+
constructor(message) {
|
|
168
|
+
super(message);
|
|
169
|
+
this.name = "PukuError";
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
class APIError extends PukuError {
|
|
166
174
|
status;
|
|
167
175
|
headers;
|
|
168
176
|
error;
|
|
@@ -3715,7 +3723,7 @@ var readEnv = (env) => {
|
|
|
3715
3723
|
var HUMAN_PROMPT = "\\n\\nHuman:";
|
|
3716
3724
|
var AI_PROMPT = "\\n\\nAssistant:";
|
|
3717
3725
|
|
|
3718
|
-
class
|
|
3726
|
+
class BasePuku {
|
|
3719
3727
|
apiKey;
|
|
3720
3728
|
baseURL;
|
|
3721
3729
|
maxRetries;
|
|
@@ -3733,7 +3741,7 @@ class BaseAnthropic {
|
|
|
3733
3741
|
...opts
|
|
3734
3742
|
} = {}) {
|
|
3735
3743
|
if (!baseURL) {
|
|
3736
|
-
throw new
|
|
3744
|
+
throw new PukuError("Missing baseURL: pass `baseURL` to the constructor or set the PUKU_BASE_URL environment variable.");
|
|
3737
3745
|
}
|
|
3738
3746
|
const options = {
|
|
3739
3747
|
apiKey,
|
|
@@ -3754,7 +3762,7 @@ new Anthropic({ apiKey, dangerouslyAllowBrowser: true });
|
|
|
3754
3762
|
if (this.baseURL.endsWith("/v1")) {
|
|
3755
3763
|
this.baseURL = this.baseURL.slice(0, -3);
|
|
3756
3764
|
}
|
|
3757
|
-
this.timeout = options.timeout ??
|
|
3765
|
+
this.timeout = options.timeout ?? BasePuku.DEFAULT_TIMEOUT;
|
|
3758
3766
|
this.logger = options.logger ?? console;
|
|
3759
3767
|
const defaultLogLevel = "warn";
|
|
3760
3768
|
this.logLevel = defaultLogLevel;
|
|
@@ -4129,6 +4137,7 @@ new Anthropic({ apiKey, dangerouslyAllowBrowser: true });
|
|
|
4129
4137
|
static AI_PROMPT = AI_PROMPT;
|
|
4130
4138
|
static DEFAULT_TIMEOUT = 600000;
|
|
4131
4139
|
static AnthropicError = AnthropicError;
|
|
4140
|
+
static PukuError = PukuError;
|
|
4132
4141
|
static APIError = APIError;
|
|
4133
4142
|
static APIConnectionError = APIConnectionError;
|
|
4134
4143
|
static APIConnectionTimeoutError = APIConnectionTimeoutError;
|
|
@@ -4144,7 +4153,7 @@ new Anthropic({ apiKey, dangerouslyAllowBrowser: true });
|
|
|
4144
4153
|
static toFile = toFile;
|
|
4145
4154
|
}
|
|
4146
4155
|
|
|
4147
|
-
class PukuAI extends
|
|
4156
|
+
class PukuAI extends BasePuku {
|
|
4148
4157
|
completions = new Completions(this);
|
|
4149
4158
|
messages = new Messages2(this);
|
|
4150
4159
|
models = new Models2(this);
|
|
@@ -5212,7 +5221,7 @@ async function findRg() {
|
|
|
5212
5221
|
return null;
|
|
5213
5222
|
}
|
|
5214
5223
|
|
|
5215
|
-
//# debugId=
|
|
5224
|
+
//# debugId=E40F809F89B47F8464756E2164756E21
|
|
5216
5225
|
|
|
5217
5226
|
|
|
5218
5227
|
// Capture in a closure so the callable shim doesn't lose the export
|