clark-platform-client-js 0.1.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.
@@ -0,0 +1,293 @@
1
+ // Hand-written declaration file for editor/TS-consumer support.
2
+ // The shipped runtime is plain JavaScript (src/*.js) with JSDoc type hints —
3
+ // this file is not generated by a build step and is not required to consume
4
+ // the package from JavaScript; it exists purely for editors/TS projects that
5
+ // want IntelliSense and type-checking against clark-platform-client-js.
6
+
7
+ export type MemoryScope = "user" | "conversation";
8
+ export type ResponseStatus = "in_progress" | "completed" | "failed";
9
+ export type ReasoningEffort = "minimal" | "low" | "medium" | "high" | "xhigh";
10
+
11
+ export interface ClarkErrorEnvelope {
12
+ message: string;
13
+ type:
14
+ | "invalid_request_error"
15
+ | "authentication_error"
16
+ | "permission_error"
17
+ | "not_found_error"
18
+ | "upstream_error"
19
+ | "server_error"
20
+ | string;
21
+ param?: string | null;
22
+ code?: string;
23
+ }
24
+
25
+ export declare class ClarkApiError extends Error {
26
+ status: number | null;
27
+ type: string;
28
+ param: string | null;
29
+ code: string;
30
+ cause?: unknown;
31
+ response?: Response;
32
+ static fromResponse(response: Response): Promise<ClarkApiError>;
33
+ static fromNetworkError(cause: unknown): ClarkApiError;
34
+ }
35
+
36
+ export declare const DEFAULT_BASE_URL: string;
37
+ export declare const DEFAULT_TIMEOUT_MS: number;
38
+
39
+ export interface PublicUsageCost {
40
+ amount: string | null;
41
+ currency: string;
42
+ type: "estimated" | "unavailable" | string;
43
+ }
44
+
45
+ export interface PublicUsage {
46
+ input_tokens: number;
47
+ input_tokens_details: { cached_tokens: number };
48
+ output_tokens: number;
49
+ output_tokens_details: { reasoning_tokens: number };
50
+ total_tokens: number;
51
+ artifact_bytes?: number;
52
+ cost: PublicUsageCost;
53
+ }
54
+
55
+ export interface PublicArtifact {
56
+ id: string;
57
+ name: string;
58
+ kind: string;
59
+ role: string;
60
+ mime_type: string;
61
+ size_bytes: number;
62
+ summary?: string;
63
+ download_url: string;
64
+ }
65
+
66
+ export interface PublicResponseMetadata {
67
+ response_id: string;
68
+ conversation_id: string;
69
+ run_id: string;
70
+ status: ResponseStatus;
71
+ artifacts: PublicArtifact[];
72
+ }
73
+
74
+ export interface ClarkModelPricing {
75
+ currency: string;
76
+ unit: string;
77
+ input: number;
78
+ output: number;
79
+ cache_write?: number;
80
+ cache_read?: number;
81
+ }
82
+
83
+ export interface ClarkModelCapabilities {
84
+ public_input_modalities: string[];
85
+ model_input_modalities: string[];
86
+ output_modalities: string[];
87
+ features: string[];
88
+ public_file_upload: boolean;
89
+ }
90
+
91
+ export interface ClarkModelDetail {
92
+ tier_id: string;
93
+ label: string;
94
+ description: string;
95
+ context_window_tokens: number;
96
+ max_output_tokens: number;
97
+ pricing: ClarkModelPricing;
98
+ capabilities: ClarkModelCapabilities;
99
+ model_options?: ClarkModelEntry[];
100
+ }
101
+
102
+ export interface ClarkModelEntry {
103
+ id: string;
104
+ object: "model";
105
+ owned_by: string;
106
+ clark: ClarkModelDetail;
107
+ }
108
+
109
+ export interface ClarkModelList {
110
+ object: "list";
111
+ data: ClarkModelEntry[];
112
+ }
113
+
114
+ export type ResponseInputRole = "user" | "assistant" | string;
115
+
116
+ export interface ResponseInputTextPart {
117
+ type: "text" | "input_text";
118
+ text: string;
119
+ }
120
+
121
+ export interface ResponseInputItem {
122
+ role?: ResponseInputRole;
123
+ content: string | ResponseInputTextPart[];
124
+ }
125
+
126
+ export interface CreateResponseParams {
127
+ model: string;
128
+ tierModelId?: string;
129
+ input: string | ResponseInputItem[];
130
+ conversationId?: string;
131
+ memoryScope?: MemoryScope;
132
+ previousResponseId?: string;
133
+ background?: boolean;
134
+ metadata?: Record<string, unknown>;
135
+ signal?: AbortSignal;
136
+ }
137
+
138
+ export interface ResponseObject {
139
+ id: string;
140
+ object: "response";
141
+ status: ResponseStatus;
142
+ created_at: number;
143
+ model: string;
144
+ previous_response_id: string | null;
145
+ background: boolean;
146
+ output: Array<Record<string, unknown>>;
147
+ artifacts: PublicArtifact[];
148
+ usage?: PublicUsage;
149
+ metadata?: Record<string, unknown>;
150
+ clark: PublicResponseMetadata;
151
+ error: { type: string; message: string } | null;
152
+ }
153
+
154
+ export interface ResponseStreamEvent {
155
+ type: string;
156
+ sequence_number: number;
157
+ [key: string]: unknown;
158
+ }
159
+
160
+ export interface ListResponseEventsOptions {
161
+ afterSeq?: number;
162
+ limit?: number;
163
+ types?: string[] | string;
164
+ signal?: AbortSignal;
165
+ }
166
+
167
+ export interface ResponseEventList {
168
+ object: "list";
169
+ data: Array<Record<string, unknown>>;
170
+ next_after_seq: number;
171
+ }
172
+
173
+ export declare class Responses {
174
+ create(params: CreateResponseParams): Promise<ResponseObject>;
175
+ stream(params: CreateResponseParams): AsyncGenerator<ResponseStreamEvent, void, unknown>;
176
+ get(responseId: string, options?: { signal?: AbortSignal }): Promise<ResponseObject>;
177
+ listEvents(responseId: string, options?: ListResponseEventsOptions): Promise<ResponseEventList>;
178
+ }
179
+
180
+ export declare class Models {
181
+ list(options?: { signal?: AbortSignal }): Promise<ClarkModelList>;
182
+ }
183
+
184
+ export interface ChatMessageTextPart {
185
+ type: "text";
186
+ text: string;
187
+ }
188
+
189
+ export interface ChatMessage {
190
+ role: "system" | "user" | "assistant" | "tool" | string;
191
+ content?: string | ChatMessageTextPart[] | null;
192
+ name?: string;
193
+ tool_call_id?: string;
194
+ tool_calls?: Array<Record<string, unknown>>;
195
+ }
196
+
197
+ export interface CreateChatCompletionParams {
198
+ model: string;
199
+ tierModelId?: string;
200
+ messages: ChatMessage[];
201
+ conversationId?: string;
202
+ memoryScope?: MemoryScope;
203
+ previousResponseId?: string;
204
+ streamOptions?: { include_usage?: boolean };
205
+ metadata?: Record<string, unknown>;
206
+ temperature?: number;
207
+ topP?: number;
208
+ maxTokens?: number;
209
+ stop?: string | string[];
210
+ signal?: AbortSignal;
211
+ }
212
+
213
+ export interface CreatePassthroughChatCompletionParams extends CreateChatCompletionParams {
214
+ tools?: Array<Record<string, unknown>>;
215
+ toolChoice?: string | Record<string, unknown>;
216
+ parallelToolCalls?: boolean;
217
+ reasoningEffort?: ReasoningEffort;
218
+ }
219
+
220
+ export interface ChatCompletionChoice {
221
+ index: number;
222
+ message: { role: "assistant"; content: string };
223
+ finish_reason: "stop" | "error" | "timeout" | string;
224
+ }
225
+
226
+ export interface ChatCompletionObject {
227
+ id: string;
228
+ object: "chat.completion";
229
+ created: number;
230
+ model: string;
231
+ choices: ChatCompletionChoice[];
232
+ usage?: PublicUsage;
233
+ clark?: PublicResponseMetadata;
234
+ }
235
+
236
+ export interface ChatCompletionChunk {
237
+ id: string;
238
+ object: "chat.completion.chunk";
239
+ created: number;
240
+ model: string;
241
+ choices: Array<{ index: number; delta: Record<string, unknown>; finish_reason: string | null }>;
242
+ usage?: PublicUsage | null;
243
+ clark?: PublicResponseMetadata | null;
244
+ }
245
+
246
+ export declare class ChatCompletions {
247
+ create(params: CreateChatCompletionParams): Promise<ChatCompletionObject>;
248
+ stream(params: CreateChatCompletionParams): AsyncGenerator<ChatCompletionChunk, void, unknown>;
249
+ createPassthrough(params: CreatePassthroughChatCompletionParams): Promise<Record<string, unknown>>;
250
+ streamPassthrough(
251
+ params: CreatePassthroughChatCompletionParams
252
+ ): AsyncGenerator<Record<string, unknown>, void, unknown>;
253
+ }
254
+
255
+ export interface MemoryListParams {
256
+ q?: string;
257
+ tags?: string;
258
+ conversationId?: string;
259
+ signal?: AbortSignal;
260
+ }
261
+
262
+ export interface MemoryList {
263
+ object: "list";
264
+ data: Array<Record<string, unknown>>;
265
+ }
266
+
267
+ export declare class Memories {
268
+ list(params?: MemoryListParams): Promise<MemoryList>;
269
+ }
270
+
271
+ export declare class Artifacts {
272
+ download(
273
+ conversationId: string,
274
+ artifactName: string,
275
+ options?: { headers?: Record<string, string>; signal?: AbortSignal }
276
+ ): Promise<Response>;
277
+ }
278
+
279
+ export interface ClarkClientOptions {
280
+ apiKey: string;
281
+ baseUrl?: string;
282
+ timeoutMs?: number;
283
+ fetchFn?: typeof fetch;
284
+ }
285
+
286
+ export declare class ClarkClient {
287
+ constructor(options: ClarkClientOptions);
288
+ models: Models;
289
+ responses: Responses;
290
+ chat: { completions: ChatCompletions };
291
+ memories: Memories;
292
+ artifacts: Artifacts;
293
+ }