@superclerk/sdk 0.4.0 → 0.5.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 CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.5.0 (2026-11-28)
6
+
7
+ Still pinned to API version `2026-11-05`.
8
+
9
+ - `connections.tools.run(connectionID, { tool, input })` runs one of a connection's tools by its name and answers its
10
+ output, waiting and throwing `ToolRunError` as `tools.run` does. It is for a tool `tools.run` can't type, such as a
11
+ connected MCP server's: an MCP server a member connected with a sign-in or a key is now a connection with `appID`
12
+ `mcp`, listed by `connections.list`, whose tools `connections.tools.list` describes as the server does.
13
+
5
14
  ## 0.4.0 (2026-11-25)
6
15
 
7
16
  Still pinned to API version `2026-11-05`.
package/README.md CHANGED
@@ -55,8 +55,15 @@ const { messageId } = await superclerk.tools.run({
55
55
  })
56
56
  ```
57
57
 
58
- A run that ends failed throws `ToolRunError`, whose `code` is the run's error kind. To start a run without waiting for
59
- it, call `tools.runs.create` and read it later with `tools.runs.wait`.
58
+ A run that ends failed throws `ToolRunError`, whose `code` is the run's error kind and whose `message` says what went
59
+ wrong. To start a run without waiting for it, call `tools.runs.create` and read it later with `tools.runs.wait`.
60
+
61
+ A connected MCP server's tools are its own, so `tools.run` can't type them. `connections.tools.run` runs one by its
62
+ name, the same way, and answers the server's output:
63
+
64
+ ```ts
65
+ const output = await superclerk.connections.tools.run("itn_456", { tool: "search_docs", input: { query: "webhooks" } })
66
+ ```
60
67
 
61
68
  ## Call a provider's API
62
69
 
@@ -161,8 +168,10 @@ const superclerk = new Superclerk({ apiKey: null, baseURL: `${location.origin}/_
161
168
  const { items } = await superclerk.contacts.list({ limit: 20 })
162
169
  ```
163
170
 
164
- It reaches what Superclerk's own pages use, such as contacts, deals, tasks, conversations and the Inbox. Operations
165
- that take only an API key, such as running a connection's tools, answer `403 not_available_to_team_apps`.
171
+ It reaches what Superclerk's own pages use, such as contacts, deals, tasks, conversations and the Inbox, and it runs
172
+ connected apps' tools (`tools.run`) on the teammate's own connections and the ones shared with the workspace.
173
+ Operations that take only an API key, such as a connection's raw provider API (`connections.fetch`), connect links and
174
+ webhooks, answer `403 not_available_to_team_apps`.
166
175
 
167
176
  ## Errors
168
177
 
@@ -264,7 +273,7 @@ this to your repository's `AGENTS.md` or `CLAUDE.md` so an agent reads them befo
264
273
 
265
274
  - Call the Superclerk API through `@superclerk/sdk`. Read `node_modules/@superclerk/sdk/README.md`, and `api.md`
266
275
  beside it for every method, before writing Superclerk code.
267
- - Run tools with `superclerk.tools.run`; it waits for the run and throws `ToolRunError` when the run fails.
276
+ - Run tools with `superclerk.tools.run`, or a connected MCP server's with `superclerk.connections.tools.run`; both wait for the run and throw `ToolRunError` when it fails.
268
277
  - Ask before running a tool that writes, sends or posts. Never print or commit the API key.
269
278
  - Docs: https://docs.superclerk.com/llms.txt, or the docs MCP server at https://docs.superclerk.com/mcp.
270
279
  ```
package/api.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Superclerk TypeScript SDK reference
2
2
 
3
- Generated from the public OpenAPI document. Every method returns an `APIPromise`; a list method returns a `PagePromise` you can await for one page or iterate for every item. See the README for the hand-written helpers: `tools.run`, `tools.runs.wait`, `connect.links.wait`, `connections.fetch`, `social.media.upload` and `webhooks.unwrap`.
3
+ Generated from the public OpenAPI document. Every method returns an `APIPromise`; a list method returns a `PagePromise` you can await for one page or iterate for every item. See the README for the hand-written helpers: `tools.run`, `tools.runs.wait`, `connections.tools.run`, `connect.links.wait`, `connections.fetch`, `social.media.upload` and `webhooks.unwrap`.
4
4
 
5
5
  ## connect
6
6
 
@@ -94,7 +94,7 @@ export declare class ToolsRuns extends APIResource {
94
94
  /**
95
95
  * Run a built-in or connected tool
96
96
  *
97
- * Target a built-in tool with appID or a connected tool with connectionID; provide exactly one. Every call requires the key's current issuing administrator; built-in calls create no installation. New submissions validate tool-specific input before reserving a run or idempotency key. Invalid arguments return invalid_tool_input with bounded field paths and safe constraint messages. A field the tool does not take is refused, not ignored, and fields names it by its path, unless it sits in a value of several undiscriminated shapes and not exactly one of them would fit without such fields; fields then names that value as a whole. Terminal failures may include an allowlisted providerCode; raw provider error messages are not exposed.
97
+ * Target a built-in tool with appID or a connected tool with connectionID; provide exactly one. A key's call requires its issuing administrator to be current; a team app's runs as the person signed in, on their own connections and the ones a teammate shared. Built-in calls create no installation. New submissions validate tool-specific input before reserving a run or idempotency key. Invalid arguments return invalid_tool_input with bounded field paths and safe constraint messages. A field the tool does not take is refused, not ignored, and fields names it by its path, unless it sits in a value of several undiscriminated shapes and not exactly one of them would fit without such fields; fields then names that value as a whole. A connected MCP server's tool takes the input its server's schema allows. A terminal failure's message says what went wrong, with the provider's documented reason where it says what to change; it may include an allowlisted providerCode. Raw provider response bodies are never exposed.
98
98
  *
99
99
  * Formerly `POST /v1/tool-runs`, which still answers, marked deprecated.
100
100
  *
@@ -102,9 +102,9 @@ export declare class ToolsRuns extends APIResource {
102
102
  */
103
103
  create(params: Types.ToolsRunsCreateParams, options?: RequestOptions): APIPromise<Types.ToolsRunsCreateResponse>;
104
104
  /**
105
- * Get a tool run created by an API key in this organization
105
+ * Get a tool run
106
106
  *
107
- * Polling never runs the tool again. A completed run's result expires after 24 hours; a failed or cancelled run, outcome_unknown included, stays readable.
107
+ * Polling never runs the tool again. A key reads every run in its workspace; a team app's person only their own. A completed run's result expires after 24 hours; a failed or cancelled run, outcome_unknown included, stays readable.
108
108
  *
109
109
  * Formerly `GET /v1/tool-runs/{runID}`, which still answers, marked deprecated.
110
110
  *
@@ -117,7 +117,7 @@ export declare class ToolsBase extends APIResource {
117
117
  /**
118
118
  * List built-in public tools
119
119
  *
120
- * These tools use appID targets and require no connected account or installation. Executing them requires a key bound to a current issuing administrator.
120
+ * These tools use appID targets and require no connected account or installation. Running one takes a key whose issuing administrator is current, or a person signed in to a team app.
121
121
  *
122
122
  * `GET /v1/tools`
123
123
  */
@@ -154,7 +154,7 @@ export declare class AppsTools extends APIResource {
154
154
  export declare class Apps extends APIResource {
155
155
  readonly tools: AppsTools;
156
156
  /**
157
- * List the apps an API key can use
157
+ * List the apps the API reaches
158
158
  *
159
159
  * Every app Superclerk connects to, with how its accounts sign in and how many tools it offers. A connected app's tools run on a connection; a built-in app's run on Superclerk's own account with appID.
160
160
  *
@@ -248,7 +248,7 @@ export declare class ConnectionsBase extends APIResource {
248
248
  /**
249
249
  * List the organization's connections
250
250
  *
251
- * Every connection the key reaches, with its status and, when it isn't ready, the one request that readies it. memberID narrows it to the connections one member made, such as the ones a workflow's executionMemberID can bind. MCP servers are left to the Superclerk app.
251
+ * Every connection the request reaches, with its status and, when it isn't ready, the one request that readies it: a key's, every connection of the apps it was granted; a team app's, the signed-in person's own and the ones a teammate shared. memberID narrows it to the connections one member made, such as the ones a workflow's executionMemberID can bind. An MCP server connected with a sign-in or a key is one too, with appID mcp.
252
252
  *
253
253
  * `GET /v1/connections`
254
254
  */
@@ -121,7 +121,7 @@ export class ToolsRuns extends APIResource {
121
121
  /**
122
122
  * Run a built-in or connected tool
123
123
  *
124
- * Target a built-in tool with appID or a connected tool with connectionID; provide exactly one. Every call requires the key's current issuing administrator; built-in calls create no installation. New submissions validate tool-specific input before reserving a run or idempotency key. Invalid arguments return invalid_tool_input with bounded field paths and safe constraint messages. A field the tool does not take is refused, not ignored, and fields names it by its path, unless it sits in a value of several undiscriminated shapes and not exactly one of them would fit without such fields; fields then names that value as a whole. Terminal failures may include an allowlisted providerCode; raw provider error messages are not exposed.
124
+ * Target a built-in tool with appID or a connected tool with connectionID; provide exactly one. A key's call requires its issuing administrator to be current; a team app's runs as the person signed in, on their own connections and the ones a teammate shared. Built-in calls create no installation. New submissions validate tool-specific input before reserving a run or idempotency key. Invalid arguments return invalid_tool_input with bounded field paths and safe constraint messages. A field the tool does not take is refused, not ignored, and fields names it by its path, unless it sits in a value of several undiscriminated shapes and not exactly one of them would fit without such fields; fields then names that value as a whole. A connected MCP server's tool takes the input its server's schema allows. A terminal failure's message says what went wrong, with the provider's documented reason where it says what to change; it may include an allowlisted providerCode. Raw provider response bodies are never exposed.
125
125
  *
126
126
  * Formerly `POST /v1/tool-runs`, which still answers, marked deprecated.
127
127
  *
@@ -131,9 +131,9 @@ export class ToolsRuns extends APIResource {
131
131
  return this._client.request({ method: "POST", path: `/v1/tools/runs`, body: params, idempotent: true, response: "json" }, options);
132
132
  }
133
133
  /**
134
- * Get a tool run created by an API key in this organization
134
+ * Get a tool run
135
135
  *
136
- * Polling never runs the tool again. A completed run's result expires after 24 hours; a failed or cancelled run, outcome_unknown included, stays readable.
136
+ * Polling never runs the tool again. A key reads every run in its workspace; a team app's person only their own. A completed run's result expires after 24 hours; a failed or cancelled run, outcome_unknown included, stays readable.
137
137
  *
138
138
  * Formerly `GET /v1/tool-runs/{runID}`, which still answers, marked deprecated.
139
139
  *
@@ -148,7 +148,7 @@ export class ToolsBase extends APIResource {
148
148
  /**
149
149
  * List built-in public tools
150
150
  *
151
- * These tools use appID targets and require no connected account or installation. Executing them requires a key bound to a current issuing administrator.
151
+ * These tools use appID targets and require no connected account or installation. Running one takes a key whose issuing administrator is current, or a person signed in to a team app.
152
152
  *
153
153
  * `GET /v1/tools`
154
154
  */
@@ -196,7 +196,7 @@ export class AppsTools extends APIResource {
196
196
  export class Apps extends APIResource {
197
197
  tools = new AppsTools(this._client);
198
198
  /**
199
- * List the apps an API key can use
199
+ * List the apps the API reaches
200
200
  *
201
201
  * Every app Superclerk connects to, with how its accounts sign in and how many tools it offers. A connected app's tools run on a connection; a built-in app's run on Superclerk's own account with appID.
202
202
  *
@@ -358,7 +358,7 @@ export class ConnectionsBase extends APIResource {
358
358
  /**
359
359
  * List the organization's connections
360
360
  *
361
- * Every connection the key reaches, with its status and, when it isn't ready, the one request that readies it. memberID narrows it to the connections one member made, such as the ones a workflow's executionMemberID can bind. MCP servers are left to the Superclerk app.
361
+ * Every connection the request reaches, with its status and, when it isn't ready, the one request that readies it: a key's, every connection of the apps it was granted; a team app's, the signed-in person's own and the ones a teammate shared. memberID narrows it to the connections one member made, such as the ones a workflow's executionMemberID can bind. An MCP server connected with a sign-in or a key is one too, with appID mcp.
362
362
  *
363
363
  * `GET /v1/connections`
364
364
  */
@@ -1,8 +1,8 @@
1
1
  export interface Connection {
2
2
  id: string;
3
- /** Its app's title, icon, tools and proxy are on GET /v1/apps/{appID}. */
3
+ /** Its app's title, icon, tools and proxy are on GET /v1/apps/{appID}. A connected MCP server's is mcp, which isn't there: its tools are the server's own, on GET /v1/connections/{connectionID}/tools. */
4
4
  appID: string;
5
- /** The provider account the grant reaches, such as an email address or a workspace. */
5
+ /** The provider account the grant reaches, such as an email address or a workspace, or a connected MCP server's name. */
6
6
  label: string;
7
7
  /** The member who connected it, as GET /v1/members lists them. A workflow binds only the connections of its executionMemberID. */
8
8
  memberID: string;
@@ -324,6 +324,8 @@ export interface ChatAssistantMessage {
324
324
  } | null;
325
325
  /** Why the model stopped, such as stop, length or tool-calls. */
326
326
  finish: string | null;
327
+ /** True for the agent's summary of the chat so far, which it reads in place of the earlier messages. Its words are for the agent, so it has no parts. */
328
+ summary: boolean;
327
329
  /** Who wrote it when the agent didn't: a teammate, a workflow run, or Superclerk. */
328
330
  authoredBy: {
329
331
  kind: "operator";
@@ -461,13 +463,15 @@ export interface ChatSubtaskPart {
461
463
  description: string;
462
464
  agent: string;
463
465
  }
464
- /** Where the agent summarized the chat so far to make room. */
466
+ /** Where the agent summarized the chat so far to make room. It marks a message Superclerk wrote, and the summary is the assistant message that answers it. */
465
467
  export interface ChatCompactionPart {
466
468
  type: "compaction";
467
469
  id: string;
468
470
  chatID: string;
469
471
  messageID: string;
470
472
  auto: boolean;
473
+ /** The message whose turn an automatic summary belongs to: the one the agent was answering when the chat grew too long. Null for a summary someone asked for. */
474
+ continues: string | null;
471
475
  }
472
476
  export type ChatStreamEvent = {
473
477
  event: "chat";
@@ -1,4 +1,4 @@
1
- export declare const SDK_VERSION = "0.4.0";
1
+ export declare const SDK_VERSION = "0.5.0";
2
2
  /** The API behavior this SDK was generated for. Every request pins it with the Superclerk-Version header. */
3
3
  export declare const API_VERSION = "2026-11-05";
4
4
  export declare const DEFAULT_BASE_URL = "https://api.superclerk.com";
@@ -1,5 +1,5 @@
1
1
  // Generated by script/generate.ts from the public OpenAPI document. Do not edit.
2
- export const SDK_VERSION = "0.4.0";
2
+ export const SDK_VERSION = "0.5.0";
3
3
  /** The API behavior this SDK was generated for. Every request pins it with the Superclerk-Version header. */
4
4
  export const API_VERSION = "2026-11-05";
5
5
  export const DEFAULT_BASE_URL = "https://api.superclerk.com";
@@ -1,12 +1,28 @@
1
1
  import { type RequestOptions } from "../core/client.js";
2
- import { ConnectionsBase } from "../generated/resources.js";
2
+ import { ConnectionsBase, ConnectionsTools as ConnectionsToolsBase } from "../generated/resources.js";
3
3
  export interface ProxyInit extends RequestOptions {
4
4
  /** GET, POST or DELETE, as the app's `proxy.methods` allows. Defaults to GET. */
5
5
  method?: "GET" | "POST" | "DELETE";
6
6
  /** A JSON value, or a string, Blob, FormData or URLSearchParams sent as it is. */
7
7
  body?: unknown;
8
8
  }
9
+ export declare class ConnectionsTools extends ConnectionsToolsBase {
10
+ #private;
11
+ /**
12
+ * Runs one of the connection's tools by its name and answers its output, waiting while the run goes on: for a tool
13
+ * `tools.run` can't type, such as a connected MCP server's, whose output is the server's. A run that ends failed or
14
+ * cancelled throws ToolRunError, whose `code` is the run's `error.kind`; a request the API refuses before any run
15
+ * starts throws APIError. Retries reuse one Idempotency-Key, so the tool runs once.
16
+ */
17
+ run(connectionID: string, { tool, input }: {
18
+ tool: string;
19
+ input: Record<string, unknown>;
20
+ }, options?: RequestOptions): Promise<string | number | boolean | unknown[] | {
21
+ [key: string]: unknown;
22
+ } | null>;
23
+ }
9
24
  export declare class Connections extends ConnectionsBase {
25
+ readonly tools: ConnectionsTools;
10
26
  /**
11
27
  * Calls the provider's own API through a connection, with its credentials added on the server, and answers the
12
28
  * provider's response whatever its status. `path` is the provider's path and query, sent as written, such as
@@ -1,7 +1,21 @@
1
1
  import { pathParam } from "../core/client.js";
2
2
  import { holding, isPending, settle } from "../core/timing.js";
3
- import { ConnectionsBase } from "../generated/resources.js";
3
+ import { ConnectionsBase, ConnectionsTools as ConnectionsToolsBase } from "../generated/resources.js";
4
+ import { runTool, ToolsRuns } from "./tools.js";
5
+ export class ConnectionsTools extends ConnectionsToolsBase {
6
+ #runs = new ToolsRuns(this._client);
7
+ /**
8
+ * Runs one of the connection's tools by its name and answers its output, waiting while the run goes on: for a tool
9
+ * `tools.run` can't type, such as a connected MCP server's, whose output is the server's. A run that ends failed or
10
+ * cancelled throws ToolRunError, whose `code` is the run's `error.kind`; a request the API refuses before any run
11
+ * starts throws APIError. Retries reuse one Idempotency-Key, so the tool runs once.
12
+ */
13
+ run(connectionID, { tool, input }, options = {}) {
14
+ return runTool(this._client, this.#runs, { connectionID, toolID: tool, input }, options);
15
+ }
16
+ }
4
17
  export class Connections extends ConnectionsBase {
18
+ tools = new ConnectionsTools(this._client);
5
19
  /**
6
20
  * Calls the provider's own API through a connection, with its credentials added on the server, and answers the
7
21
  * provider's response whatever its status. `path` is the provider's path and query, sent as written, such as
package/lib/tools.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import type { RequestOptions } from "../core/client.js";
1
+ import type { Core, RequestOptions } from "../core/client.js";
2
2
  import { ToolsBase, ToolsRuns as ToolsRunsBase } from "../generated/resources.js";
3
3
  import type { ToolID, Tools as ToolTypes } from "../generated/tools.js";
4
- import type { ToolsRunsGetResponse } from "../generated/types.js";
4
+ import type { ToolsRunsCreateParams, ToolsRunsGetResponse } from "../generated/types.js";
5
5
  /** The tool to run, its input, and the connection or built-in app that runs it. */
6
6
  export type ToolRunParams<Tool extends ToolID> = {
7
7
  tool: Tool;
@@ -21,6 +21,9 @@ export declare class ToolsRuns extends ToolsRunsBase {
21
21
  /** Reads a run until it ends and answers it. Aborting the signal stops the waiting, not the run. */
22
22
  wait(runID: string, options?: RequestOptions): Promise<SettledToolRun>;
23
23
  }
24
+ export declare function runTool(client: Core, runs: ToolsRuns, params: ToolsRunsCreateParams, options: RequestOptions): Promise<string | number | boolean | unknown[] | {
25
+ [key: string]: unknown;
26
+ } | null>;
24
27
  export declare class Tools extends ToolsBase {
25
28
  readonly runs: ToolsRuns;
26
29
  /**
package/lib/tools.js CHANGED
@@ -7,6 +7,18 @@ export class ToolsRuns extends ToolsRunsBase {
7
7
  return settle(this._client, (held) => this.get(runID, held), options);
8
8
  }
9
9
  }
10
+ // What tools.run and connections.tools.run share: start the run, wait while it goes on, answer its output or throw.
11
+ export async function runTool(client, runs, params, options) {
12
+ const created = await runs.create(params, holding(client, options)).catch((error) => {
13
+ // A run that ended at submission answers with the run itself as its body, not the API's `{ error }`.
14
+ const run = error instanceof APIError ? error.body : undefined;
15
+ throw run?.status === "failed" || run?.status === "cancelled" ? new ToolRunError(run) : error;
16
+ });
17
+ const finished = created.status === "running" ? await runs.wait(created.id, options) : created;
18
+ if (finished.status !== "completed")
19
+ throw new ToolRunError(finished);
20
+ return finished.output;
21
+ }
10
22
  export class Tools extends ToolsBase {
11
23
  runs = new ToolsRuns(this._client);
12
24
  /**
@@ -16,16 +28,7 @@ export class Tools extends ToolsBase {
16
28
  * once.
17
29
  */
18
30
  async run({ tool, ...params }, options = {}) {
19
- const created = await this.runs
20
- .create({ toolID: tool, ...params }, holding(this._client, options))
21
- .catch((error) => {
22
- // A run that ended at submission answers with the run itself as its body, not the API's `{ error }`.
23
- const run = error instanceof APIError ? error.body : undefined;
24
- throw run?.status === "failed" || run?.status === "cancelled" ? new ToolRunError(run) : error;
25
- });
26
- const finished = created.status === "running" ? await this.runs.wait(created.id, options) : created;
27
- if (finished.status !== "completed")
28
- throw new ToolRunError(finished);
29
- return finished.output;
31
+ const output = await runTool(this._client, this.runs, { toolID: tool, ...params }, options);
32
+ return output;
30
33
  }
31
34
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superclerk/sdk",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "The official TypeScript SDK for the Superclerk API",
5
5
  "type": "module",
6
6
  "license": "MIT",