@wice24/tars-sdk 0.2.0 → 0.2.3

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/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Agent, AgentVersion, ClientTool, CreateAgentInput, FileMeta, McpCredentialInput, McpCredentialStatus, ReasoningConfig, SessionEvent, ModelInfo, SessionInfo, SessionListItem, UpdateAgentInput, UploadFileInput, UsageSummary, SessionUsageRow, DailyUsageRow, McpServer, Skill, SkillVersion, ApiKeyInfo, ClientIdentity, ClientRole, PlatformStats, Tenant } from './types.js';
1
+ import type { Agent, AgentVersion, ClientTool, CreateAgentInput, FileMeta, ListMcpToolsInput, McpCredentialInput, McpCredentialStatus, McpServerTools, ReasoningConfig, SessionEvent, ModelInfo, SessionInfo, SessionListItem, UpdateAgentInput, UploadFileInput, UsageSummary, SessionUsageRow, DailyUsageRow, McpServer, Skill, SkillVersion, ApiKeyInfo, ClientIdentity, ClientRole, PlatformStats, Tenant } from './types.js';
2
2
  type ToolHandler = (input: any) => unknown | Promise<unknown>;
3
3
  export * from './types.js';
4
4
  export declare class TarsApiError extends Error {
@@ -124,6 +124,20 @@ export declare class TarsClient {
124
124
  ok: boolean;
125
125
  }>;
126
126
  };
127
+ readonly mcp: {
128
+ /**
129
+ * Dial an MCP server once with the stored credential, list its tools, hang
130
+ * up — no session, nothing journaled. The source of truth for writing a
131
+ * `tools` / `blocked_tools` policy: what the server offers NOW, not what a
132
+ * registry says. Throws `TarsApiError` 404 `missing_credential` when
133
+ * `auth: 'required'` and no credential is stored for the end user or the
134
+ * tenant (none stored, or its refresh failed), 502 with the turn-time code
135
+ * (`mcp_authentication_failed_error` / `mcp_connection_failed_error`) when
136
+ * the dial fails or times out (15 s), and 503 `internal_error` when TARS's
137
+ * own credential store is unavailable.
138
+ */
139
+ listTools: (input: ListMcpToolsInput) => Promise<McpServerTools>;
140
+ };
127
141
  readonly skills: {
128
142
  create: (input: {
129
143
  slug: string;
package/dist/index.js CHANGED
@@ -155,6 +155,30 @@ export class TarsClient {
155
155
  return this.request('DELETE', `/v1/mcp-credentials?${params}`);
156
156
  },
157
157
  };
158
+ // ── MCP servers ──────────────────────────────────────────────
159
+ mcp = {
160
+ /**
161
+ * Dial an MCP server once with the stored credential, list its tools, hang
162
+ * up — no session, nothing journaled. The source of truth for writing a
163
+ * `tools` / `blocked_tools` policy: what the server offers NOW, not what a
164
+ * registry says. Throws `TarsApiError` 404 `missing_credential` when
165
+ * `auth: 'required'` and no credential is stored for the end user or the
166
+ * tenant (none stored, or its refresh failed), 502 with the turn-time code
167
+ * (`mcp_authentication_failed_error` / `mcp_connection_failed_error`) when
168
+ * the dial fails or times out (15 s), and 503 `internal_error` when TARS's
169
+ * own credential store is unavailable.
170
+ */
171
+ listTools: (input) => {
172
+ const params = new URLSearchParams({ name: input.name, url: input.url });
173
+ if (input.transport)
174
+ params.set('transport', input.transport);
175
+ if (input.auth)
176
+ params.set('auth', input.auth);
177
+ if (input.endUserId)
178
+ params.set('end_user_id', input.endUserId);
179
+ return this.request('GET', `/v1/mcp-servers/tools?${params}`);
180
+ },
181
+ };
158
182
  // ── skills ───────────────────────────────────────────────────
159
183
  // Versioned skill bundles (zip with SKILL.md at root), pinned per agent.
160
184
  skills = {
package/dist/types.d.ts CHANGED
@@ -83,9 +83,13 @@ export type SessionEvent = {
83
83
  type: 'turn_end';
84
84
  reason: 'completed' | 'interrupted' | 'error';
85
85
  usage?: {
86
+ /** UNCACHED input tokens only. Cache reads and writes are reported
87
+ * separately below, so the full prompt is the sum of all three. */
86
88
  inputTokens?: number;
87
89
  outputTokens?: number;
90
+ /** Input tokens served from the provider's prompt cache. */
88
91
  cacheReadTokens?: number;
92
+ /** Input tokens written to the provider's prompt cache. */
89
93
  cacheWriteTokens?: number;
90
94
  };
91
95
  });
@@ -105,6 +109,20 @@ export interface McpServer {
105
109
  url: string;
106
110
  transport: 'http' | 'sse';
107
111
  auth: 'none' | 'required';
112
+ /**
113
+ * Expose only these of the server's tools to the model (its own names, as
114
+ * the server lists them — not the `server__tool` prefixed form). Omitted or
115
+ * null = every tool. Names the server doesn't offer are ignored. Non-empty,
116
+ * ≤256 entries, no duplicates. Mutually exclusive with `blocked_tools`.
117
+ */
118
+ tools?: string[] | null;
119
+ /**
120
+ * Hide these of the server's tools from the model and expose every other
121
+ * one — the complement of `tools`, for a connector that is on by default
122
+ * and needs a few tools removed without naming the whole inventory. Same
123
+ * validation as `tools`; setting both is a `validation_error`.
124
+ */
125
+ blocked_tools?: string[] | null;
108
126
  }
109
127
  export interface ClientTool<I = any> {
110
128
  name: string;
@@ -246,6 +264,28 @@ export interface McpCredentialStatus {
246
264
  expires_at: string | null;
247
265
  updated_at: string;
248
266
  }
267
+ /** How `mcp.listTools` names the server: the same fields a declaration
268
+ * carries (so the credential lookup and the dial match a turn's), plus whose
269
+ * credential to use. `transport` defaults to `'http'`, `auth` to `'none'`. */
270
+ export interface ListMcpToolsInput {
271
+ name: string;
272
+ url: string;
273
+ transport?: 'http' | 'sse';
274
+ auth?: 'none' | 'required';
275
+ /** Resolve this end user's credential first, then the tenant-level one;
276
+ * omit for tenant-level only. Only read when `auth` is `'required'`. */
277
+ endUserId?: string;
278
+ }
279
+ /** One tool as the server lists it. `description` is capped at 500
280
+ * characters (an ellipsis marks a cut); `null` when the server gave none. */
281
+ export interface McpToolInfo {
282
+ name: string;
283
+ description: string | null;
284
+ }
285
+ export interface McpServerTools {
286
+ server: string;
287
+ tools: McpToolInfo[];
288
+ }
249
289
  export interface AgentVersion {
250
290
  version: number;
251
291
  name: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wice24/tars-sdk",
3
- "version": "0.2.0",
3
+ "version": "0.2.3",
4
4
  "description": "Client SDK for TARS — the self-hosted managed-agents platform (sessions, streaming turns, client tools, MCP credentials, skills, files, usage, tenant administration)",
5
5
  "type": "module",
6
6
  "exports": {