@wice24/tars-sdk 0.2.0 → 0.2.4

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
@@ -67,6 +67,17 @@ export type SessionEvent = {
67
67
  } & ({
68
68
  status: 'connected';
69
69
  tool_count: number;
70
+ /** The tool names the model received from this server (its own
71
+ * unprefixed names, in server order) — what `tool_count` counts.
72
+ * Absent on rows journaled by servers before 0.2.4. */
73
+ tools?: string[];
74
+ /** Offered by the server but removed by the declaration's policy:
75
+ * the `blocked_tools` it offered (deny), or everything not in
76
+ * `tools` (allow). Empty with no policy. Absent before 0.2.4. */
77
+ filtered_out?: string[];
78
+ /** Either list was cut — at 256 names, a 200-character name, or
79
+ * the row's character budget; `tool_count` stays exact. */
80
+ truncated?: true;
70
81
  } | {
71
82
  status: 'failed';
72
83
  code: AgentErrorCode;
@@ -83,9 +94,13 @@ export type SessionEvent = {
83
94
  type: 'turn_end';
84
95
  reason: 'completed' | 'interrupted' | 'error';
85
96
  usage?: {
97
+ /** UNCACHED input tokens only. Cache reads and writes are reported
98
+ * separately below, so the full prompt is the sum of all three. */
86
99
  inputTokens?: number;
87
100
  outputTokens?: number;
101
+ /** Input tokens served from the provider's prompt cache. */
88
102
  cacheReadTokens?: number;
103
+ /** Input tokens written to the provider's prompt cache. */
89
104
  cacheWriteTokens?: number;
90
105
  };
91
106
  });
@@ -105,6 +120,20 @@ export interface McpServer {
105
120
  url: string;
106
121
  transport: 'http' | 'sse';
107
122
  auth: 'none' | 'required';
123
+ /**
124
+ * Expose only these of the server's tools to the model (its own names, as
125
+ * the server lists them — not the `server__tool` prefixed form). Omitted or
126
+ * null = every tool. Names the server doesn't offer are ignored. Non-empty,
127
+ * ≤256 entries, no duplicates. Mutually exclusive with `blocked_tools`.
128
+ */
129
+ tools?: string[] | null;
130
+ /**
131
+ * Hide these of the server's tools from the model and expose every other
132
+ * one — the complement of `tools`, for a connector that is on by default
133
+ * and needs a few tools removed without naming the whole inventory. Same
134
+ * validation as `tools`; setting both is a `validation_error`.
135
+ */
136
+ blocked_tools?: string[] | null;
108
137
  }
109
138
  export interface ClientTool<I = any> {
110
139
  name: string;
@@ -246,6 +275,28 @@ export interface McpCredentialStatus {
246
275
  expires_at: string | null;
247
276
  updated_at: string;
248
277
  }
278
+ /** How `mcp.listTools` names the server: the same fields a declaration
279
+ * carries (so the credential lookup and the dial match a turn's), plus whose
280
+ * credential to use. `transport` defaults to `'http'`, `auth` to `'none'`. */
281
+ export interface ListMcpToolsInput {
282
+ name: string;
283
+ url: string;
284
+ transport?: 'http' | 'sse';
285
+ auth?: 'none' | 'required';
286
+ /** Resolve this end user's credential first, then the tenant-level one;
287
+ * omit for tenant-level only. Only read when `auth` is `'required'`. */
288
+ endUserId?: string;
289
+ }
290
+ /** One tool as the server lists it. `description` is capped at 500
291
+ * characters (an ellipsis marks a cut); `null` when the server gave none. */
292
+ export interface McpToolInfo {
293
+ name: string;
294
+ description: string | null;
295
+ }
296
+ export interface McpServerTools {
297
+ server: string;
298
+ tools: McpToolInfo[];
299
+ }
249
300
  export interface AgentVersion {
250
301
  version: number;
251
302
  name: string;
@@ -269,6 +320,30 @@ export interface CreateAgentInput {
269
320
  mcp_servers?: McpServer[] | null;
270
321
  }
271
322
  export type UpdateAgentInput = Partial<CreateAgentInput>;
323
+ /** A client-executed tool as a session stores it: the wire declaration,
324
+ * without `execute` (that runs in your app) — the same shape as a
325
+ * `SessionInfo.custom_tools` element. */
326
+ export interface SessionClientTool {
327
+ name: string;
328
+ description: string;
329
+ input_schema: Record<string, unknown>;
330
+ timeout_sec?: number;
331
+ }
332
+ /**
333
+ * The complete tool surface a session's turns are built with, as declared:
334
+ * the enabled built-ins with the descriptions the model is shown, the
335
+ * client-executed tools, and the MCP servers with their `tools` /
336
+ * `blocked_tools` policy. What each MCP server actually contributed on a
337
+ * given turn is in that turn's `mcp_connect` event (`tools` / `filtered_out`).
338
+ */
339
+ export interface SessionToolSurface {
340
+ builtin: Array<{
341
+ name: BuiltInTool;
342
+ description: string;
343
+ }>;
344
+ client: SessionClientTool[];
345
+ mcp_servers: McpServer[];
346
+ }
272
347
  export interface SessionInfo {
273
348
  id: string;
274
349
  status: SessionStatus;
@@ -288,6 +363,12 @@ export interface SessionInfo {
288
363
  input_schema: Record<string, unknown>;
289
364
  timeout_sec?: number;
290
365
  }> | null;
366
+ /**
367
+ * The declared tool surface (built-ins, client tools, MCP servers with
368
+ * policy) the session's turns run with. Optional: absent from servers
369
+ * predating this field.
370
+ */
371
+ tools?: SessionToolSurface;
291
372
  /**
292
373
  * The EFFECTIVE system prompt the session's turns run with — agent base
293
374
  * prompt + session system_suffix + skills appendix, fused at creation.
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.4",
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": {