@shardflux/sdk 0.7.0 → 0.8.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 +21 -1
- package/README.md +14 -6
- package/dist/http.d.ts +1 -1
- package/dist/http.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/tools.d.ts +44 -21
- package/dist/tools.js +3 -2
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,27 @@
|
|
|
3
3
|
Every API the README shows is available from the version named here. Below 1.0, a minor release may break
|
|
4
4
|
compatibility; breaking changes are marked **Breaking**.
|
|
5
5
|
|
|
6
|
-
## 0.
|
|
6
|
+
## 0.8.0 (2026-09-28)
|
|
7
|
+
|
|
8
|
+
Types only; nothing changes at run time and the API is unchanged.
|
|
9
|
+
|
|
10
|
+
### Provider tool exports type-check without casts
|
|
11
|
+
|
|
12
|
+
- `toAnthropicTools(tools)` is assignable to `Anthropic.Tool[]` (`@anthropic-ai/sdk`) and `toOpenAITools(tools, { api:
|
|
13
|
+
'responses' })` to `OpenAI.Responses.FunctionTool[]` (`openai`) under TypeScript's `strict` checks, with no `as`
|
|
14
|
+
casts. `toOpenAITools(tools)` (and `{ api: 'chat' }`) is assignable to `OpenAI.Chat.ChatCompletionTool[]`.
|
|
15
|
+
- `toOpenAITools` has one return type per format (overloads): an `api` known only at run time still returns either
|
|
16
|
+
array, as before.
|
|
17
|
+
- `JsonSchema` is a type alias instead of an interface, so a schema is assignable to the providers' open schema types
|
|
18
|
+
(`{ [key: string]: unknown }`). An object literal typed as `JsonSchema` still rejects a misspelt keyword.
|
|
19
|
+
- `executeToolCall(tools, call)` takes `input` as `unknown`, as the Anthropic SDK's `ToolUseBlock` types it, so a
|
|
20
|
+
`tool_use` block is passed as it is (no `block.input as Record<string, unknown>`); `execute` validates it as before.
|
|
21
|
+
- New exported types for the three formats: `AnthropicToolDefinition`, `OpenAIChatToolDefinition`,
|
|
22
|
+
`OpenAIResponsesToolDefinition`.
|
|
23
|
+
- Checked at compile time against `@anthropic-ai/sdk` 0.128.0 and `openai` 7.23.0 (devDependencies only; the SDK still
|
|
24
|
+
has no runtime dependencies).
|
|
25
|
+
|
|
26
|
+
## 0.7.0 (2026-09-28)
|
|
7
27
|
|
|
8
28
|
Needs an API with the template editor (contracts §24); every new field is additive and older fields are unchanged.
|
|
9
29
|
|
package/README.md
CHANGED
|
@@ -10,8 +10,8 @@ tool calls into the workspace ([tool-call capture](#tool-call-capture-070)).
|
|
|
10
10
|
> **Early access.** Shardflux is in early access. The API is versioned (`/v1`), but this SDK is
|
|
11
11
|
> below 1.0: a minor release may contain breaking changes (see [Compatibility](#compatibility)).
|
|
12
12
|
|
|
13
|
-
> **Versions.** This README describes 0.
|
|
14
|
-
> 0.5.0; [CHANGELOG.md](./CHANGELOG.md) lists what each version added. Check yours with
|
|
13
|
+
> **Versions.** This README describes 0.8.0. Anything marked **(0.8.0+)** is not in 0.7.x, **(0.7.0+)** not in 0.6.x
|
|
14
|
+
> and **(0.6.0+)** not in 0.5.0; [CHANGELOG.md](./CHANGELOG.md) lists what each version added. Check yours with
|
|
15
15
|
> `npm ls @shardflux/sdk` or the exported `SDK_VERSION`.
|
|
16
16
|
|
|
17
17
|
- ESM only, no runtime dependencies, Node.js 24 or later. Reading a YAML template file uses the optional peer
|
|
@@ -383,15 +383,23 @@ parameters and an `execute` function. Export them for your model provider and di
|
|
|
383
383
|
calls:
|
|
384
384
|
|
|
385
385
|
```ts
|
|
386
|
+
import Anthropic from '@anthropic-ai/sdk';
|
|
386
387
|
import { executeToolCall, toAnthropicTools, toOpenAITools, workspaceTools } from '@shardflux/sdk';
|
|
387
388
|
|
|
388
389
|
const tools = workspaceTools(workspace);
|
|
389
|
-
const anthropicTools = toAnthropicTools(tools);
|
|
390
|
+
const anthropicTools: Anthropic.Tool[] = toAnthropicTools(tools);
|
|
391
|
+
const chatTools = toOpenAITools(tools); // OpenAI Chat Completions
|
|
392
|
+
const responsesTools = toOpenAITools(tools, { api: 'responses' }); // OpenAI Responses API
|
|
390
393
|
|
|
391
|
-
// For each tool call the model makes:
|
|
392
|
-
const output = await executeToolCall(tools,
|
|
394
|
+
// For each tool call the model makes (an Anthropic tool_use block, or an OpenAI function_call item, as it is):
|
|
395
|
+
const output = await executeToolCall(tools, block);
|
|
393
396
|
```
|
|
394
397
|
|
|
398
|
+
**(0.8.0+)** The exports type-check as the provider SDKs' own types under `strict`, with no casts:
|
|
399
|
+
`Anthropic.Tool[]`, `OpenAI.Chat.ChatCompletionTool[]` and, with `{ api: 'responses' }`,
|
|
400
|
+
`OpenAI.Responses.FunctionTool[]`. `executeToolCall` takes a `tool_use` block's `unknown` input as it is and validates
|
|
401
|
+
it.
|
|
402
|
+
|
|
395
403
|
Your agent loop and model calls stay in your application; the workspace is the computer the tools
|
|
396
404
|
act on.
|
|
397
405
|
|
|
@@ -561,7 +569,7 @@ route. The package exports the OpenAPI-generated types as well (`paths`, `compon
|
|
|
561
569
|
|
|
562
570
|
- The SDK follows the API's `/v1` contract. New fields, enum values and error codes can appear in
|
|
563
571
|
any release; ignore unknown fields.
|
|
564
|
-
- While below 1.0, a breaking change bumps the minor version (0.
|
|
572
|
+
- While below 1.0, a breaking change bumps the minor version (0.7 to 0.8).
|
|
565
573
|
- `SDK_VERSION` is exported; requests send `User-Agent: shardflux-sdk-ts/<version>`.
|
|
566
574
|
- Examples in this README, in `examples/` and on shardflux.dev name the version they need. The examples on the
|
|
567
575
|
website and in the console are checked against the version published on npm before they ship.
|
package/dist/http.d.ts
CHANGED
package/dist/http.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { ShardfluxApiError, ShardfluxProtocolError, isErrorBody } from "./errors.js";
|
|
8
8
|
import { describeFailure } from "./progress.js";
|
|
9
|
-
export const SDK_VERSION = '0.
|
|
9
|
+
export const SDK_VERSION = '0.8.0';
|
|
10
10
|
export const defaultSleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
11
11
|
/**
|
|
12
12
|
* The fetch the SDK uses when none is given. On runtimes whose bundled undici is 8.x (Node 26) it sends
|
package/dist/index.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ export type { BrowserContent, BrowserContentRequest, BrowserScreenshotRequest, C
|
|
|
39
39
|
export { ToolTokenManager } from './tokens.js';
|
|
40
40
|
export type { ToolName, ToolToken, ToolTokenOptions } from './tokens.js';
|
|
41
41
|
export { ToolArgumentError, executeToolCall, toAnthropicTools, toOpenAITools, validateArgs, workspaceTools } from './tools.js';
|
|
42
|
-
export type { JsonSchema, WorkspaceTool, WorkspaceToolsOptions } from './tools.js';
|
|
42
|
+
export type { AnthropicToolDefinition, JsonSchema, OpenAIChatToolDefinition, OpenAIResponsesToolDefinition, WorkspaceTool, WorkspaceToolsOptions } from './tools.js';
|
|
43
43
|
export { CaptureError, ToolCallCapture, captureTool } from './capture.js';
|
|
44
44
|
export type { CallLike, CallRef, CaptureCall, CaptureErrorKind, CaptureEvent, CaptureFlushResult, CapturePart, CaptureSelector, CaptureSource, CaptureStats, CaptureStatus, DropReason, ToolCallCaptureOptions, WrapOptions, } from './capture.js';
|
|
45
45
|
export type { AiSdkAdapter, AiSdkToolEndEvent, AnthropicAdapter, ClaudeAdapter, ClaudeCaptureHooks, ClaudeHookCallback, ClaudeHookMatcher, LangChainAdapter, LangChainToolHandler, MastraAdapter, MastraAfterToolCallContext, McpAdapter, OpenAIAgentsAdapter, } from './capture-adapters.js';
|
package/dist/tools.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import type { CellClientOptions } from './cell.js';
|
|
2
2
|
import type { ToolName } from './tokens.js';
|
|
3
3
|
import type { Workspace } from './workspace.js';
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* The JSON Schema subset of the tool definitions. A type alias rather than an interface (0.8.0+), so a schema is
|
|
6
|
+
* assignable to the providers' open schema types (`{ [key: string]: unknown }`) without a cast, and an object literal
|
|
7
|
+
* typed as JsonSchema still rejects a misspelt keyword.
|
|
8
|
+
*/
|
|
9
|
+
export type JsonSchema = {
|
|
5
10
|
type?: 'object' | 'string' | 'integer' | 'number' | 'boolean' | 'array';
|
|
6
11
|
description?: string;
|
|
7
12
|
properties?: Record<string, JsonSchema>;
|
|
@@ -16,7 +21,7 @@ export interface JsonSchema {
|
|
|
16
21
|
minItems?: number;
|
|
17
22
|
maxItems?: number;
|
|
18
23
|
default?: unknown;
|
|
19
|
-
}
|
|
24
|
+
};
|
|
20
25
|
export interface WorkspaceTool<A extends Record<string, unknown> = Record<string, unknown>, R = unknown> {
|
|
21
26
|
name: string;
|
|
22
27
|
description: string;
|
|
@@ -56,44 +61,62 @@ export interface WorkspaceToolsOptions {
|
|
|
56
61
|
}
|
|
57
62
|
/** Builds the tool list for a workspace. Synchronous: tokens are fetched on first use. */
|
|
58
63
|
export declare function workspaceTools(workspace: Workspace, opts?: WorkspaceToolsOptions): WorkspaceTool[];
|
|
59
|
-
/**
|
|
60
|
-
export
|
|
61
|
-
api?: 'chat' | 'responses';
|
|
62
|
-
}): {
|
|
63
|
-
type: "function";
|
|
64
|
+
/** Anthropic Messages API tool definition; assignable to `Anthropic.Tool` (0.8.0+). */
|
|
65
|
+
export type AnthropicToolDefinition = {
|
|
64
66
|
name: string;
|
|
65
67
|
description: string;
|
|
66
|
-
|
|
67
|
-
type:
|
|
68
|
+
input_schema: JsonSchema & {
|
|
69
|
+
type: 'object';
|
|
68
70
|
};
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
};
|
|
72
|
+
/** OpenAI Chat Completions tool definition; assignable to `OpenAI.Chat.ChatCompletionFunctionTool` (0.8.0+). */
|
|
73
|
+
export type OpenAIChatToolDefinition = {
|
|
74
|
+
type: 'function';
|
|
72
75
|
function: {
|
|
73
76
|
name: string;
|
|
74
77
|
description: string;
|
|
75
78
|
parameters: JsonSchema & {
|
|
76
|
-
type:
|
|
79
|
+
type: 'object';
|
|
77
80
|
};
|
|
78
81
|
};
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
export
|
|
82
|
+
};
|
|
83
|
+
/** OpenAI Responses API tool definition; assignable to `OpenAI.Responses.FunctionTool` (0.8.0+). */
|
|
84
|
+
export type OpenAIResponsesToolDefinition = {
|
|
85
|
+
type: 'function';
|
|
82
86
|
name: string;
|
|
83
87
|
description: string;
|
|
84
|
-
|
|
85
|
-
type:
|
|
88
|
+
parameters: JsonSchema & {
|
|
89
|
+
type: 'object';
|
|
86
90
|
};
|
|
87
|
-
|
|
91
|
+
strict: boolean;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* OpenAI tool definitions: Chat Completions (`{type:'function', function:{...}}`, the default) or, with
|
|
95
|
+
* `{ api: 'responses' }`, the Responses API. The return type follows `api` (0.8.0+); an `api` known only at run time
|
|
96
|
+
* gives either array.
|
|
97
|
+
*/
|
|
98
|
+
export declare function toOpenAITools(tools: readonly WorkspaceTool[], opts: {
|
|
99
|
+
api: 'responses';
|
|
100
|
+
}): OpenAIResponsesToolDefinition[];
|
|
101
|
+
export declare function toOpenAITools(tools: readonly WorkspaceTool[], opts?: {
|
|
102
|
+
api?: 'chat';
|
|
103
|
+
}): OpenAIChatToolDefinition[];
|
|
104
|
+
export declare function toOpenAITools(tools: readonly WorkspaceTool[], opts?: {
|
|
105
|
+
api?: 'chat' | 'responses';
|
|
106
|
+
}): OpenAIChatToolDefinition[] | OpenAIResponsesToolDefinition[];
|
|
107
|
+
/** Anthropic Messages API tool definitions (`{ name, description, input_schema }`). */
|
|
108
|
+
export declare function toAnthropicTools(tools: readonly WorkspaceTool[]): AnthropicToolDefinition[];
|
|
88
109
|
/**
|
|
89
110
|
* Runs a model's tool call: `arguments` may be the JSON string (OpenAI) or an object (Anthropic
|
|
90
111
|
* `input`). Throws for unknown tools and invalid arguments (ToolArgumentError). The call's `id` / `call_id` is passed
|
|
91
|
-
* to `execute` as `toolCallId` (0.7.0+), so `executeToolCall(capture.tools(tools), call)` records it.
|
|
112
|
+
* to `execute` as `toolCallId` (0.7.0+), so `executeToolCall(capture.tools(tools), call)` records it. `input` is
|
|
113
|
+
* `unknown` (0.8.0+), as in the Anthropic SDK's `ToolUseBlock`, so a tool_use block is passed as it is; `execute`
|
|
114
|
+
* validates it.
|
|
92
115
|
*/
|
|
93
116
|
export declare function executeToolCall(tools: readonly WorkspaceTool[], call: {
|
|
94
117
|
name: string;
|
|
95
118
|
arguments?: string | Record<string, unknown>;
|
|
96
|
-
input?:
|
|
119
|
+
input?: unknown;
|
|
97
120
|
id?: string;
|
|
98
121
|
call_id?: string;
|
|
99
122
|
}, options?: {
|
package/dist/tools.js
CHANGED
|
@@ -305,7 +305,6 @@ export function workspaceTools(workspace, opts = {}) {
|
|
|
305
305
|
},
|
|
306
306
|
}));
|
|
307
307
|
}
|
|
308
|
-
/** OpenAI tool definitions: Chat Completions (`{type:'function', function:{...}}`) or Responses API. */
|
|
309
308
|
export function toOpenAITools(tools, opts = {}) {
|
|
310
309
|
return opts.api === 'responses'
|
|
311
310
|
? tools.map((t) => ({ type: 'function', name: t.name, description: t.description, parameters: t.parameters, strict: false }))
|
|
@@ -318,7 +317,9 @@ export function toAnthropicTools(tools) {
|
|
|
318
317
|
/**
|
|
319
318
|
* Runs a model's tool call: `arguments` may be the JSON string (OpenAI) or an object (Anthropic
|
|
320
319
|
* `input`). Throws for unknown tools and invalid arguments (ToolArgumentError). The call's `id` / `call_id` is passed
|
|
321
|
-
* to `execute` as `toolCallId` (0.7.0+), so `executeToolCall(capture.tools(tools), call)` records it.
|
|
320
|
+
* to `execute` as `toolCallId` (0.7.0+), so `executeToolCall(capture.tools(tools), call)` records it. `input` is
|
|
321
|
+
* `unknown` (0.8.0+), as in the Anthropic SDK's `ToolUseBlock`, so a tool_use block is passed as it is; `execute`
|
|
322
|
+
* validates it.
|
|
322
323
|
*/
|
|
323
324
|
export async function executeToolCall(tools, call, options = {}) {
|
|
324
325
|
const tool = tools.find((t) => t.name === call.name);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shardflux/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Shardflux TypeScript SDK: open persistent agent workspaces by key and give your agent workspace tools (exec, files, processes, PTY, git, browser).",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
"ajv": "8.20.0",
|
|
61
61
|
"eslint": "10.11.0",
|
|
62
62
|
"langchain": "1.5.14",
|
|
63
|
+
"openai": "7.23.0",
|
|
63
64
|
"openapi-typescript": "7.13.0",
|
|
64
65
|
"typescript": "5.9.3",
|
|
65
66
|
"typescript-eslint": "8.70.1",
|