@wice24/tars-sdk 0.1.1 → 0.1.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 +8 -1
- package/dist/index.js +18 -0
- package/dist/types.d.ts +17 -0
- package/package.json +1 -1
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, SessionUsageRow, McpServer, Skill, SkillVersion, ApiKeyInfo } from './types.js';
|
|
1
|
+
import type { Agent, AgentVersion, ClientTool, CreateAgentInput, FileMeta, McpCredentialInput, McpCredentialStatus, SessionEvent, SessionInfo, SessionListItem, UpdateAgentInput, UploadFileInput, UsageSummary, SessionUsageRow, DailyUsageRow, 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
|
+
daily: (from: string | Date) => Promise<DailyUsageRow[]>;
|
|
153
160
|
sessions: (from: string | Date) => Promise<SessionUsageRow[]>;
|
|
154
161
|
};
|
|
155
162
|
readonly files: {
|
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-day, per-model buckets by TURN time — day/MTD dashboard views
|
|
199
|
+
// (per-session rollups attribute whole sessions to their creation day).
|
|
200
|
+
daily: async (from) => {
|
|
201
|
+
const qs = `?from=${encodeURIComponent(new Date(from).toISOString())}`;
|
|
202
|
+
const { days } = await this.request('GET', `/v1/usage/daily${qs}`);
|
|
203
|
+
return days;
|
|
204
|
+
},
|
|
187
205
|
// Per-session usage snapshots for sessions created since `from` — the
|
|
188
206
|
// shape usage dashboards want (one row per session, buckets + cost).
|
|
189
207
|
sessions: async (from) => {
|
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[];
|
|
@@ -249,6 +256,16 @@ export interface SessionUsageRow {
|
|
|
249
256
|
turns: number;
|
|
250
257
|
};
|
|
251
258
|
}
|
|
259
|
+
export interface DailyUsageRow {
|
|
260
|
+
day: string;
|
|
261
|
+
model: string;
|
|
262
|
+
input_tokens: number;
|
|
263
|
+
output_tokens: number;
|
|
264
|
+
cache_read_tokens: number;
|
|
265
|
+
cache_write_tokens: number;
|
|
266
|
+
cost_usd: number | null;
|
|
267
|
+
turns: number;
|
|
268
|
+
}
|
|
252
269
|
export interface SessionListItem {
|
|
253
270
|
id: string;
|
|
254
271
|
status: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wice24/tars-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
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": {
|