@chusky/sdk 0.1.0 → 0.1.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/CHANGELOG.md +10 -0
- package/README.md +11 -1
- package/dist/client.d.ts +151 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +173 -3
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +130 -0
- package/dist/types.d.ts.map +1 -1
- package/docs/approvals.mdx +19 -0
- package/docs/architecture.mdx +32 -0
- package/docs/budgets.mdx +25 -0
- package/docs/capabilities.mdx +39 -0
- package/docs/concepts.mdx +24 -0
- package/docs/errors.mdx +21 -0
- package/docs/fallbacks.mdx +23 -0
- package/docs/files.mdx +31 -0
- package/docs/index.mdx +27 -0
- package/docs/models.mdx +25 -0
- package/docs/policies.mdx +36 -0
- package/docs/production.mdx +27 -0
- package/docs/quickstart.mdx +56 -0
- package/docs/releases.mdx +23 -0
- package/docs/security.mdx +13 -0
- package/docs/streaming.mdx +28 -0
- package/docs/structured-output.mdx +30 -0
- package/docs/tasks.mdx +16 -0
- package/docs/webhooks.mdx +15 -0
- package/package.json +37 -29
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Security
|
|
3
|
+
description: Protect keys, identities, files, and approvals.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
- Keep project keys on trusted servers; never expose them in browser bundles.
|
|
7
|
+
- Use your application’s authenticated subject as `userId`; do not accept an arbitrary user ID from an untrusted request body.
|
|
8
|
+
- Scope keys to the minimum required API capabilities.
|
|
9
|
+
- Use idempotency keys on durable POST operations.
|
|
10
|
+
- Display exact approval arguments to an authenticated human.
|
|
11
|
+
- Treat tool results, emails, documents, and webpages as untrusted content, not authorization.
|
|
12
|
+
- Store webhook secrets in a secret manager and verify raw bodies.
|
|
13
|
+
- Do not log keys, raw media, full private documents, or authorization headers.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Streaming and run lifecycle
|
|
3
|
+
description: Render tokens, tools, approvals, and terminal state in real time.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
```ts
|
|
7
|
+
const abort = new AbortController();
|
|
8
|
+
|
|
9
|
+
for await (const event of chusky.threads.runs(thread.id).stream(
|
|
10
|
+
{ input: "Review the latest report" },
|
|
11
|
+
{ signal: abort.signal, idempotencyKey: crypto.randomUUID() },
|
|
12
|
+
)) {
|
|
13
|
+
switch (event.type) {
|
|
14
|
+
case "run.delta": console.log(event.text); break;
|
|
15
|
+
case "run.tool_started": console.log(`Using ${event.toolSlug}`); break;
|
|
16
|
+
case "run.approval_required": /* show exact args to a human */ break;
|
|
17
|
+
case "run.completed": /* persist event.run */ break;
|
|
18
|
+
case "run.failed": console.error(event.error.message); break;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Abort stops the current HTTP stream. For durable state, use `get()` or `events()` with the run ID. Do not automatically retry a stream as a new run.
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
const run = await chusky.threads.runs(thread.id).get(runId);
|
|
27
|
+
const events = await chusky.threads.runs(thread.id).events(runId);
|
|
28
|
+
```
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: JSON and schema responses
|
|
3
|
+
description: Request predictable structured output for software integrations.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Structured output is intended for applications that need to consume the result programmatically instead of rendering prose.
|
|
7
|
+
|
|
8
|
+
```ts
|
|
9
|
+
// Planned SDK shape
|
|
10
|
+
const run = await chusky.threads.runs(thread.id).create({
|
|
11
|
+
input: "Classify this support request",
|
|
12
|
+
responseFormat: {
|
|
13
|
+
type: "json_schema",
|
|
14
|
+
name: "support_classification",
|
|
15
|
+
schema: {
|
|
16
|
+
type: "object",
|
|
17
|
+
properties: {
|
|
18
|
+
category: { type: "string" },
|
|
19
|
+
priority: { type: "string", enum: ["low", "normal", "urgent"] },
|
|
20
|
+
},
|
|
21
|
+
required: ["category", "priority"],
|
|
22
|
+
additionalProperties: false,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The server should validate the final model output against the schema, return a typed validation error when it does not match, and preserve the raw run status for recovery. Schemas must be bounded in size and depth.
|
|
29
|
+
|
|
30
|
+
> **Status:** Planned public API. The current SDK returns text output and does not yet guarantee server-side schema validation.
|
package/docs/tasks.mdx
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Durable tasks
|
|
3
|
+
description: Run work that can pause, retry, and survive process restarts.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Use tasks for long-running work. Task state includes status, checkpoint, next action, result, and error information. A run created with `wait: false` is linked to one of these tasks and can continue after the request and process that started it have ended.
|
|
7
|
+
|
|
8
|
+
```ts
|
|
9
|
+
const page = await chusky.tasks.list({ limit: 20 });
|
|
10
|
+
const task = await chusky.tasks.get("task_123");
|
|
11
|
+
|
|
12
|
+
await chusky.tasks.retry(task.id);
|
|
13
|
+
await chusky.tasks.cancel(task.id);
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Tasks are durable and retried by the server workflow layer. Treat `queued`, `running`, `blocked`, `completed`, `failed`, and `cancelled` as distinct states. A blocked task may require an approval or user input rather than a blind retry.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Webhooks
|
|
3
|
+
description: Receive durable notifications in your application.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
```ts
|
|
7
|
+
const webhook = await chusky.webhooks.create("https://your-app.example.com/chusky/events", {
|
|
8
|
+
idempotencyKey: crypto.randomUUID(),
|
|
9
|
+
});
|
|
10
|
+
console.log(webhook.secret); // store immediately; it is returned once
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Verify the signature using the raw request body, timestamp, and signing secret. Deduplicate by event ID. Return a successful response only after the event is durably accepted; process expensive work asynchronously.
|
|
14
|
+
|
|
15
|
+
Webhook deliveries have retry state and may fail. Build an operator view for delivery status and keep your handler idempotent.
|
package/package.json
CHANGED
|
@@ -1,29 +1,37 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@chusky/sdk",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "TypeScript SDK for Chusky's developer API.",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"sideEffects": false,
|
|
8
|
-
"main": "./dist/index.js",
|
|
9
|
-
"types": "./dist/index.d.ts",
|
|
10
|
-
"exports": {
|
|
11
|
-
".": {
|
|
12
|
-
"types": "./dist/index.d.ts",
|
|
13
|
-
"import": "./dist/index.js"
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
"files": [
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@chusky/sdk",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "TypeScript SDK for Chusky's developer API.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"README.md",
|
|
19
|
+
"docs",
|
|
20
|
+
"CHANGELOG.md",
|
|
21
|
+
"LICENSE"
|
|
22
|
+
],
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=18"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsc -p tsconfig.json",
|
|
28
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
29
|
+
"test": "tsx --test --test-concurrency=1 tests/*.test.ts",
|
|
30
|
+
"prepublishOnly": "npm run typecheck && npm run build && npm test"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/node": "^22.0.0",
|
|
34
|
+
"tsx": "^4.19.0",
|
|
35
|
+
"typescript": "^5.7.0"
|
|
36
|
+
}
|
|
37
|
+
}
|