@wice24/tars-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/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Agent, AgentVersion, ClientTool, CreateAgentInput, FileMeta, McpCredentialInput, McpCredentialStatus, SessionEvent, SessionInfo, SessionListItem, UpdateAgentInput, UploadFileInput, UsageSummary, McpServer, Skill, SkillVersion, ApiKeyInfo } from './types.js';
1
+ import type { Agent, AgentVersion, ClientTool, CreateAgentInput, FileMeta, McpCredentialInput, McpCredentialStatus, SessionEvent, SessionInfo, SessionListItem, UpdateAgentInput, UploadFileInput, UsageSummary, SessionUsageRow, McpServer, Skill, SkillVersion, ApiKeyInfo } 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 {
@@ -66,6 +66,12 @@ export declare class TarsClient {
66
66
  setMcpServers: (id: string, servers: McpServer[]) => Promise<{
67
67
  ok: boolean;
68
68
  }>;
69
+ /** Replace the session's client-executed tool declarations (takes effect
70
+ * next turn; 409s while a turn is in flight). How a host app rolls new
71
+ * tools out to sessions created before the tools existed. */
72
+ setCustomTools: (id: string, tools: Array<Pick<ClientTool, "name" | "description" | "inputSchema" | "timeoutSec">>) => Promise<{
73
+ ok: boolean;
74
+ }>;
69
75
  /** Abort the in-flight turn, if any. Idempotent. */
70
76
  interrupt: (id: string) => Promise<{
71
77
  ok: boolean;
@@ -150,6 +156,7 @@ export declare class TarsClient {
150
156
  sessionId?: string;
151
157
  endUserId?: string;
152
158
  }) => Promise<UsageSummary>;
159
+ sessions: (from: string | Date) => Promise<SessionUsageRow[]>;
153
160
  };
154
161
  readonly files: {
155
162
  upload: (input: UploadFileInput) => Promise<FileMeta>;
package/dist/index.js CHANGED
@@ -96,6 +96,17 @@ export class TarsClient {
96
96
  /** Replace the session's extra MCP server set (takes effect next turn;
97
97
  * 409s while a turn is in flight). */
98
98
  setMcpServers: (id, servers) => this.request('PATCH', `/v1/sessions/${id}`, { mcp_servers: servers }),
99
+ /** Replace the session's client-executed tool declarations (takes effect
100
+ * next turn; 409s while a turn is in flight). How a host app rolls new
101
+ * tools out to sessions created before the tools existed. */
102
+ setCustomTools: (id, tools) => this.request('PATCH', `/v1/sessions/${id}`, {
103
+ custom_tools: tools.map((t) => ({
104
+ name: t.name,
105
+ description: t.description,
106
+ input_schema: t.inputSchema,
107
+ ...(t.timeoutSec ? { timeout_sec: t.timeoutSec } : {}),
108
+ })),
109
+ }),
99
110
  /** Abort the in-flight turn, if any. Idempotent. */
100
111
  interrupt: (id) => this.request('POST', `/v1/sessions/${id}/interrupt`),
101
112
  usage: (id) => this.request('GET', `/v1/sessions/${id}/usage`),
@@ -184,6 +195,13 @@ export class TarsClient {
184
195
  const qs = params.size ? `?${params}` : '';
185
196
  return this.request('GET', `/v1/usage${qs}`);
186
197
  },
198
+ // Per-session usage snapshots for sessions created since `from` — the
199
+ // shape usage dashboards want (one row per session, buckets + cost).
200
+ sessions: async (from) => {
201
+ const qs = `?from=${encodeURIComponent(new Date(from).toISOString())}`;
202
+ const { sessions } = await this.request('GET', `/v1/usage/sessions${qs}`);
203
+ return sessions;
204
+ },
187
205
  };
188
206
  // ── files ────────────────────────────────────────────────────
189
207
  files = {
package/dist/types.d.ts CHANGED
@@ -190,6 +190,13 @@ export interface SessionInfo {
190
190
  sandboxId: string | null;
191
191
  title?: string | null;
192
192
  metadata?: Record<string, string> | null;
193
+ /** Wire-shaped client-tool declarations stored on the session (no execute). */
194
+ custom_tools?: Array<{
195
+ name: string;
196
+ description: string;
197
+ input_schema: Record<string, unknown>;
198
+ timeout_sec?: number;
199
+ }> | null;
193
200
  archived?: boolean;
194
201
  last_seq?: number;
195
202
  events?: SessionEvent[];
@@ -233,6 +240,22 @@ export interface UsageSummary {
233
240
  end_user_id: string | null;
234
241
  })[];
235
242
  }
243
+ export interface SessionUsageRow {
244
+ session_id: string;
245
+ title: string | null;
246
+ model: string;
247
+ metadata: Record<string, string> | null;
248
+ end_user_id: string | null;
249
+ created_at: string;
250
+ usage: {
251
+ input_tokens: number;
252
+ output_tokens: number;
253
+ cache_read_tokens: number;
254
+ cache_write_tokens: number;
255
+ cost_usd: number | null;
256
+ turns: number;
257
+ };
258
+ }
236
259
  export interface SessionListItem {
237
260
  id: string;
238
261
  status: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wice24/tars-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Client SDK for TARS \u2014 the self-hosted managed-agents platform (sessions, streaming turns, client tools, MCP credentials, skills, files, usage)",
5
5
  "type": "module",
6
6
  "exports": {