@castari/sdk 0.1.4 → 0.2.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/README.md +92 -104
- package/dist/agents.d.ts +76 -0
- package/dist/agents.d.ts.map +1 -0
- package/dist/agents.js +111 -0
- package/dist/agents.js.map +1 -0
- package/dist/auth.d.ts +27 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +33 -0
- package/dist/auth.js.map +1 -0
- package/dist/client.d.ts +51 -45
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +90 -230
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +47 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +108 -0
- package/dist/config.js.map +1 -0
- package/dist/errors.d.ts +52 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +73 -0
- package/dist/errors.js.map +1 -0
- package/dist/http.d.ts +32 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +117 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +8 -4
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -4
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +157 -58
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -0
- package/dist/usage.d.ts +26 -0
- package/dist/usage.d.ts.map +1 -0
- package/dist/usage.js +45 -0
- package/dist/usage.js.map +1 -0
- package/package.json +51 -34
- package/LICENSE +0 -21
- package/dist/const.d.ts +0 -6
- package/dist/const.js +0 -9
- package/dist/message-handler.d.ts +0 -8
- package/dist/message-handler.js +0 -96
- package/dist/server.d.ts +0 -6
- package/dist/server.js +0 -219
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAWA,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC;AAErE,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,QAAQ,CAAC,CAAsB;IACvC,OAAO,CAAC,SAAS,CAAC,CAAS;gBAEf,OAAO,EAAE,iBAAiB;IAMtC;;OAEG;IACH,OAAO,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAKvD;;OAEG;IACG,OAAO,CAAC,CAAC,EACb,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;QACR,IAAI,CAAC,EAAE,OAAO,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,CAAC;QACpD,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GACA,OAAO,CAAC,CAAC,CAAC;IA4Eb;;OAEG;IACH,OAAO,CAAC,WAAW;CA6BpB"}
|
package/dist/http.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { CastariError, AuthenticationError, NotFoundError, ValidationError, RateLimitError, BadRequestError, ServerError, } from './errors.js';
|
|
2
|
+
/**
|
|
3
|
+
* HTTP client for making API requests
|
|
4
|
+
*/
|
|
5
|
+
export class HttpClient {
|
|
6
|
+
baseUrl;
|
|
7
|
+
authType;
|
|
8
|
+
authValue;
|
|
9
|
+
constructor(options) {
|
|
10
|
+
this.baseUrl = options.baseUrl.replace(/\/$/, ''); // Remove trailing slash
|
|
11
|
+
this.authType = options.authType;
|
|
12
|
+
this.authValue = options.authValue;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Set authentication credentials
|
|
16
|
+
*/
|
|
17
|
+
setAuth(type, value) {
|
|
18
|
+
this.authType = type;
|
|
19
|
+
this.authValue = value;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Make an HTTP request to the API
|
|
23
|
+
*/
|
|
24
|
+
async request(method, path, options) {
|
|
25
|
+
const url = new URL(`/api/v1${path}`, this.baseUrl);
|
|
26
|
+
// Add query parameters
|
|
27
|
+
if (options?.query) {
|
|
28
|
+
for (const [key, value] of Object.entries(options.query)) {
|
|
29
|
+
if (value !== undefined) {
|
|
30
|
+
url.searchParams.set(key, String(value));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// Build headers
|
|
35
|
+
const headers = {
|
|
36
|
+
'Content-Type': 'application/json',
|
|
37
|
+
Accept: 'application/json',
|
|
38
|
+
};
|
|
39
|
+
// Add auth header (both token and api_key use Bearer format)
|
|
40
|
+
if (this.authValue) {
|
|
41
|
+
headers['Authorization'] = `Bearer ${this.authValue}`;
|
|
42
|
+
}
|
|
43
|
+
// Create abort controller for timeout
|
|
44
|
+
const controller = new AbortController();
|
|
45
|
+
const timeout = options?.timeout ?? 120000; // Default 2 minutes
|
|
46
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
47
|
+
try {
|
|
48
|
+
const response = await fetch(url.toString(), {
|
|
49
|
+
method,
|
|
50
|
+
headers,
|
|
51
|
+
body: options?.body ? JSON.stringify(options.body) : undefined,
|
|
52
|
+
signal: controller.signal,
|
|
53
|
+
});
|
|
54
|
+
clearTimeout(timeoutId);
|
|
55
|
+
// Handle no-content responses
|
|
56
|
+
if (response.status === 204) {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
// Parse response body
|
|
60
|
+
const contentType = response.headers.get('content-type');
|
|
61
|
+
let data;
|
|
62
|
+
if (contentType?.includes('application/json')) {
|
|
63
|
+
data = await response.json();
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
data = await response.text();
|
|
67
|
+
}
|
|
68
|
+
// Handle errors
|
|
69
|
+
if (!response.ok) {
|
|
70
|
+
this.handleError(response.status, data, response.headers);
|
|
71
|
+
}
|
|
72
|
+
return data;
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
clearTimeout(timeoutId);
|
|
76
|
+
if (error instanceof CastariError) {
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
79
|
+
if (error instanceof Error) {
|
|
80
|
+
if (error.name === 'AbortError') {
|
|
81
|
+
throw new CastariError('Request timed out');
|
|
82
|
+
}
|
|
83
|
+
throw new CastariError(`Request failed: ${error.message}`);
|
|
84
|
+
}
|
|
85
|
+
throw new CastariError('An unexpected error occurred');
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Handle HTTP error responses
|
|
90
|
+
*/
|
|
91
|
+
handleError(status, data, headers) {
|
|
92
|
+
const errorResponse = data;
|
|
93
|
+
const message = errorResponse?.detail || 'An error occurred';
|
|
94
|
+
switch (status) {
|
|
95
|
+
case 400:
|
|
96
|
+
throw new BadRequestError(message);
|
|
97
|
+
case 401:
|
|
98
|
+
throw new AuthenticationError(message);
|
|
99
|
+
case 404:
|
|
100
|
+
throw new NotFoundError(message);
|
|
101
|
+
case 422:
|
|
102
|
+
throw new ValidationError(message);
|
|
103
|
+
case 429: {
|
|
104
|
+
const retryAfter = headers.get('Retry-After');
|
|
105
|
+
throw new RateLimitError(message, retryAfter ? parseInt(retryAfter, 10) : undefined);
|
|
106
|
+
}
|
|
107
|
+
case 500:
|
|
108
|
+
case 502:
|
|
109
|
+
case 503:
|
|
110
|
+
case 504:
|
|
111
|
+
throw new ServerError(message);
|
|
112
|
+
default:
|
|
113
|
+
throw new CastariError(message, { statusCode: status });
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=http.js.map
|
package/dist/http.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRo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AO,EACP,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAClD,CAAC;YACJ,CAAC;YACD,KAAK,GAAG,CAAC;YACT,KAAK,GAAG,CAAC;YACT,KAAK,GAAG,CAAC;YACT,KAAK,GAAG;gBACN,MAAM,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC;YACjC;gBACE,MAAM,IAAI,YAAY,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export {
|
|
1
|
+
export { CastariClient } from './client.js';
|
|
2
|
+
export { AgentsAPI } from './agents.js';
|
|
3
|
+
export { UsageAPI } from './usage.js';
|
|
4
|
+
export { AuthAPI } from './auth.js';
|
|
5
|
+
export { CastariError, AuthenticationError, NotFoundError, ValidationError, RateLimitError, BadRequestError, ServerError, } from './errors.js';
|
|
6
|
+
export { loadCredentials, saveCredentials, clearCredentials, loadConfig, saveConfig, getApiUrl, getAuth, type Credentials, type Config, } from './config.js';
|
|
7
|
+
export type { Agent, AgentConfig, AgentsListResponse, AgentStatus, ApiKeyResponse, CreateAgentOptions, InvocationResponse, InvokeOptions, Secret, User, UsageSummary, UsageSummaryResponse, DailyUsage, DailyUsageResponse, CastariClientOptions, ApiErrorResponse, } from './types.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,aAAa,EACb,eAAe,EACf,cAAc,EACd,eAAe,EACf,WAAW,GACZ,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,SAAS,EACT,OAAO,EACP,KAAK,WAAW,EAChB,KAAK,MAAM,GACZ,MAAM,aAAa,CAAC;AAGrB,YAAY,EACV,KAAK,EACL,WAAW,EACX,kBAAkB,EAClB,WAAW,EACX,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EACb,MAAM,EACN,IAAI,EACJ,YAAY,EACZ,oBAAoB,EACpB,UAAU,EACV,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
export {
|
|
1
|
+
// Main client
|
|
2
|
+
export { CastariClient } from './client.js';
|
|
3
|
+
// API classes
|
|
4
|
+
export { AgentsAPI } from './agents.js';
|
|
5
|
+
export { UsageAPI } from './usage.js';
|
|
6
|
+
export { AuthAPI } from './auth.js';
|
|
7
|
+
// Errors
|
|
8
|
+
export { CastariError, AuthenticationError, NotFoundError, ValidationError, RateLimitError, BadRequestError, ServerError, } from './errors.js';
|
|
9
|
+
// Config utilities
|
|
10
|
+
export { loadCredentials, saveCredentials, clearCredentials, loadConfig, saveConfig, getApiUrl, getAuth, } from './config.js';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,cAAc;AACd,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,SAAS;AACT,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,aAAa,EACb,eAAe,EACf,cAAc,EACd,eAAe,EACf,WAAW,GACZ,MAAM,aAAa,CAAC;AAErB,mBAAmB;AACnB,OAAO,EACL,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,SAAS,EACT,OAAO,GAGR,MAAM,aAAa,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,59 +1,158 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
path: string;
|
|
10
|
-
content: string;
|
|
11
|
-
encoding?: 'utf-8' | 'base64';
|
|
12
|
-
} | {
|
|
13
|
-
type: 'read_file';
|
|
14
|
-
path: string;
|
|
15
|
-
encoding?: 'utf-8' | 'base64';
|
|
16
|
-
} | {
|
|
17
|
-
type: 'delete_file';
|
|
18
|
-
path: string;
|
|
19
|
-
} | {
|
|
20
|
-
type: 'list_files';
|
|
21
|
-
path?: string;
|
|
22
|
-
};
|
|
23
|
-
export type WSOutputMessage = {
|
|
24
|
-
type: 'connected';
|
|
25
|
-
} | {
|
|
26
|
-
type: 'sdk_message';
|
|
27
|
-
data: SDKMessage;
|
|
28
|
-
} | {
|
|
29
|
-
type: 'error';
|
|
30
|
-
error: string;
|
|
31
|
-
} | {
|
|
32
|
-
type: 'info';
|
|
33
|
-
data: string;
|
|
34
|
-
} | {
|
|
35
|
-
type: 'file_result';
|
|
36
|
-
operation: 'create_file' | 'delete_file';
|
|
37
|
-
result: 'success';
|
|
38
|
-
} | {
|
|
39
|
-
type: 'file_result';
|
|
40
|
-
operation: 'read_file';
|
|
41
|
-
result: string;
|
|
42
|
-
encoding: 'utf-8' | 'base64';
|
|
43
|
-
} | {
|
|
44
|
-
type: 'file_result';
|
|
45
|
-
operation: 'list_files';
|
|
46
|
-
result: string[];
|
|
47
|
-
};
|
|
48
|
-
export type QueryConfig = {
|
|
49
|
-
agents?: Record<string, AgentDefinition>;
|
|
50
|
-
allowedTools?: string[];
|
|
51
|
-
systemPrompt?: string | {
|
|
52
|
-
type: 'preset';
|
|
53
|
-
preset: 'claude_code';
|
|
54
|
-
append?: string;
|
|
55
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Agent status values
|
|
3
|
+
*/
|
|
4
|
+
export type AgentStatus = 'draft' | 'pending' | 'deploying' | 'active' | 'stopped' | 'failed';
|
|
5
|
+
/**
|
|
6
|
+
* Agent configuration
|
|
7
|
+
*/
|
|
8
|
+
export interface AgentConfig {
|
|
56
9
|
model?: string;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
10
|
+
max_turns?: number;
|
|
11
|
+
system_prompt?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* An AI agent on the Castari platform
|
|
15
|
+
*/
|
|
16
|
+
export interface Agent {
|
|
17
|
+
id: string;
|
|
18
|
+
user_id: string;
|
|
19
|
+
name: string;
|
|
20
|
+
slug: string;
|
|
21
|
+
description?: string | null;
|
|
22
|
+
git_repo_url: string;
|
|
23
|
+
git_branch: string;
|
|
24
|
+
agent_config?: AgentConfig;
|
|
25
|
+
default_model: string;
|
|
26
|
+
max_turns: number;
|
|
27
|
+
timeout_seconds: number;
|
|
28
|
+
status: AgentStatus;
|
|
29
|
+
status_message?: string | null;
|
|
30
|
+
sandbox_id?: string | null;
|
|
31
|
+
created_at: string;
|
|
32
|
+
updated_at: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Response from listing agents
|
|
36
|
+
*/
|
|
37
|
+
export interface AgentsListResponse {
|
|
38
|
+
agents: Agent[];
|
|
39
|
+
meta: {
|
|
40
|
+
total: number;
|
|
41
|
+
limit: number;
|
|
42
|
+
offset: number;
|
|
43
|
+
has_more: boolean;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Options for creating an agent
|
|
48
|
+
*/
|
|
49
|
+
export interface CreateAgentOptions {
|
|
50
|
+
name: string;
|
|
51
|
+
gitRepoUrl: string;
|
|
52
|
+
slug?: string;
|
|
53
|
+
description?: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Response from invoking an agent
|
|
57
|
+
*/
|
|
58
|
+
export interface InvocationResponse {
|
|
59
|
+
invocation_id: string;
|
|
60
|
+
response_content: string;
|
|
61
|
+
input_tokens: number;
|
|
62
|
+
output_tokens: number;
|
|
63
|
+
total_cost_usd: number | string;
|
|
64
|
+
duration_ms: number;
|
|
65
|
+
status: 'completed' | 'failed';
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Options for invoking an agent
|
|
69
|
+
*/
|
|
70
|
+
export interface InvokeOptions {
|
|
71
|
+
prompt: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* A secret key (values are never returned by the API)
|
|
75
|
+
*/
|
|
76
|
+
export interface Secret {
|
|
77
|
+
key: string;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The current authenticated user
|
|
81
|
+
*/
|
|
82
|
+
export interface User {
|
|
83
|
+
id: string;
|
|
84
|
+
email: string;
|
|
85
|
+
api_key_prefix?: string;
|
|
86
|
+
created_at: string;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Response from creating an API key
|
|
90
|
+
*/
|
|
91
|
+
export interface ApiKeyResponse {
|
|
92
|
+
api_key: string;
|
|
93
|
+
prefix: string;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Raw usage summary from API
|
|
97
|
+
*/
|
|
98
|
+
export interface UsageSummaryResponse {
|
|
99
|
+
total_invocations: number;
|
|
100
|
+
total_input_tokens: number;
|
|
101
|
+
total_output_tokens: number;
|
|
102
|
+
total_cost_usd: string;
|
|
103
|
+
period_start: string;
|
|
104
|
+
period_end: string;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Usage summary for a period
|
|
108
|
+
*/
|
|
109
|
+
export interface UsageSummary {
|
|
110
|
+
total_invocations: number;
|
|
111
|
+
total_input_tokens: number;
|
|
112
|
+
total_output_tokens: number;
|
|
113
|
+
total_cost_usd: number;
|
|
114
|
+
period_start: string;
|
|
115
|
+
period_end: string;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Raw daily usage from API
|
|
119
|
+
*/
|
|
120
|
+
export interface DailyUsageResponse {
|
|
121
|
+
daily_usage: Array<{
|
|
122
|
+
date: string;
|
|
123
|
+
invocation_count: number;
|
|
124
|
+
input_tokens: number;
|
|
125
|
+
output_tokens: number;
|
|
126
|
+
cost_usd: string;
|
|
127
|
+
}>;
|
|
128
|
+
total_days: number;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Daily usage breakdown
|
|
132
|
+
*/
|
|
133
|
+
export interface DailyUsage {
|
|
134
|
+
date: string;
|
|
135
|
+
invocation_count: number;
|
|
136
|
+
input_tokens: number;
|
|
137
|
+
output_tokens: number;
|
|
138
|
+
cost_usd: number;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Client configuration options
|
|
142
|
+
*/
|
|
143
|
+
export interface CastariClientOptions {
|
|
144
|
+
/** API key (starts with cap_) */
|
|
145
|
+
apiKey?: string;
|
|
146
|
+
/** OAuth token */
|
|
147
|
+
token?: string;
|
|
148
|
+
/** Base API URL (default: https://api.castari.dev) */
|
|
149
|
+
baseUrl?: string;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* API error response format
|
|
153
|
+
*/
|
|
154
|
+
export interface ApiErrorResponse {
|
|
155
|
+
detail: string;
|
|
156
|
+
code?: string;
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -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B,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,KAAK,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,gBAAgB,EAAE,MAAM,CAAC;QACzB,YAAY,EAAE,MAAM,CAAC;QACrB,aAAa,EAAE,MAAM,CAAC;QACtB,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC,CAAC;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,iCAAiC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kBAAkB;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf"}
|
package/dist/types.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/dist/usage.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { HttpClient } from './http.js';
|
|
2
|
+
import type { UsageSummary, DailyUsage } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* API for accessing usage statistics
|
|
5
|
+
*/
|
|
6
|
+
export declare class UsageAPI {
|
|
7
|
+
private client;
|
|
8
|
+
constructor(client: HttpClient);
|
|
9
|
+
/**
|
|
10
|
+
* Get usage summary for a period
|
|
11
|
+
* @param options - Options including number of days (default: 30)
|
|
12
|
+
* @returns Usage summary with totals
|
|
13
|
+
*/
|
|
14
|
+
summary(options?: {
|
|
15
|
+
days?: number;
|
|
16
|
+
}): Promise<UsageSummary>;
|
|
17
|
+
/**
|
|
18
|
+
* Get daily usage breakdown
|
|
19
|
+
* @param options - Options including number of days (default: 7)
|
|
20
|
+
* @returns Array of daily usage stats
|
|
21
|
+
*/
|
|
22
|
+
daily(options?: {
|
|
23
|
+
days?: number;
|
|
24
|
+
}): Promise<DailyUsage[]>;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=usage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../src/usage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAwB,UAAU,EAAsB,MAAM,YAAY,CAAC;AAErG;;GAEG;AACH,qBAAa,QAAQ;IACP,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAEtC;;;;OAIG;IACG,OAAO,CAAC,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,YAAY,CAAC;IAejE;;;;OAIG;IACG,KAAK,CAAC,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;CAahE"}
|
package/dist/usage.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API for accessing usage statistics
|
|
3
|
+
*/
|
|
4
|
+
export class UsageAPI {
|
|
5
|
+
client;
|
|
6
|
+
constructor(client) {
|
|
7
|
+
this.client = client;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Get usage summary for a period
|
|
11
|
+
* @param options - Options including number of days (default: 30)
|
|
12
|
+
* @returns Usage summary with totals
|
|
13
|
+
*/
|
|
14
|
+
async summary(options) {
|
|
15
|
+
const response = await this.client.request('GET', '/usage', {
|
|
16
|
+
query: { days: options?.days },
|
|
17
|
+
});
|
|
18
|
+
return {
|
|
19
|
+
total_invocations: response.total_invocations,
|
|
20
|
+
total_input_tokens: response.total_input_tokens,
|
|
21
|
+
total_output_tokens: response.total_output_tokens,
|
|
22
|
+
total_cost_usd: parseFloat(response.total_cost_usd),
|
|
23
|
+
period_start: response.period_start,
|
|
24
|
+
period_end: response.period_end,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Get daily usage breakdown
|
|
29
|
+
* @param options - Options including number of days (default: 7)
|
|
30
|
+
* @returns Array of daily usage stats
|
|
31
|
+
*/
|
|
32
|
+
async daily(options) {
|
|
33
|
+
const response = await this.client.request('GET', '/usage/daily', {
|
|
34
|
+
query: { days: options?.days },
|
|
35
|
+
});
|
|
36
|
+
return response.daily_usage.map((day) => ({
|
|
37
|
+
date: day.date,
|
|
38
|
+
invocation_count: day.invocation_count,
|
|
39
|
+
input_tokens: day.input_tokens,
|
|
40
|
+
output_tokens: day.output_tokens,
|
|
41
|
+
cost_usd: parseFloat(day.cost_usd),
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=usage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.js","sourceRoot":"","sources":["../src/usage.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,OAAO,QAAQ;IACC;IAApB,YAAoB,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;IAAG,CAAC;IAE1C;;;;OAIG;IACH,KAAK,CAAC,OAAO,CAAC,OAA2B;QACvC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAuB,KAAK,EAAE,QAAQ,EAAE;YAChF,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI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"./dist/client.d.ts"
|
|
25
|
-
},
|
|
26
|
-
"./server": {
|
|
27
|
-
"import": "./dist/server.js",
|
|
28
|
-
"types": "./dist/server.d.ts"
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
"dependencies": {
|
|
32
|
-
"@anthropic-ai/claude-agent-sdk": "^0.1.44"
|
|
33
|
-
},
|
|
34
|
-
"devDependencies": {
|
|
35
|
-
"@types/bun": "latest"
|
|
2
|
+
"name": "@castari/sdk",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Official Castari SDK for TypeScript and Node.js",
|
|
5
|
+
"author": "Castari <hello@castari.dev>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/castari/cli.git",
|
|
10
|
+
"directory": "packages/sdk"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://castari.dev",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/castari/cli/issues"
|
|
15
|
+
},
|
|
16
|
+
"type": "module",
|
|
17
|
+
"main": "dist/index.js",
|
|
18
|
+
"types": "dist/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"import": "./dist/index.js"
|
|
36
23
|
}
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsc",
|
|
27
|
+
"test": "vitest run",
|
|
28
|
+
"test:watch": "vitest",
|
|
29
|
+
"typecheck": "tsc --noEmit",
|
|
30
|
+
"clean": "rm -rf dist"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"yaml": "^2.3.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"typescript": "^5.3.0"
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"dist",
|
|
40
|
+
"README.md"
|
|
41
|
+
],
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=18.0.0"
|
|
44
|
+
},
|
|
45
|
+
"keywords": [
|
|
46
|
+
"castari",
|
|
47
|
+
"ai",
|
|
48
|
+
"agents",
|
|
49
|
+
"sdk",
|
|
50
|
+
"claude",
|
|
51
|
+
"anthropic",
|
|
52
|
+
"llm"
|
|
53
|
+
]
|
|
37
54
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Castari
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/dist/const.d.ts
DELETED
package/dist/const.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Application constants
|
|
3
|
-
*/
|
|
4
|
-
// Server configuration
|
|
5
|
-
export const SERVER_PORT = 3000;
|
|
6
|
-
// Workspace configuration
|
|
7
|
-
export const WORKSPACE_DIR_NAME = 'agent-workspace';
|
|
8
|
-
// Connection token (one-time) configuration
|
|
9
|
-
export const CONNECTION_TOKEN_TTL_MS = 5 * 60 * 1000; // 5 minutes
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { query, type SDKUserMessage } from '@anthropic-ai/claude-agent-sdk';
|
|
2
|
-
import { type ServerWebSocket } from 'bun';
|
|
3
|
-
export type MessageHandlerContext = {
|
|
4
|
-
messageQueue: SDKUserMessage[];
|
|
5
|
-
getActiveStream: () => ReturnType<typeof query> | null;
|
|
6
|
-
workspaceDirectory: string;
|
|
7
|
-
};
|
|
8
|
-
export declare function handleMessage(ws: ServerWebSocket, message: string | Buffer, context: MessageHandlerContext): Promise<void>;
|