@chatpanel/sdk 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.
- package/LICENSE +202 -0
- package/README.md +71 -0
- package/dist/api.generated.d.ts +1009 -0
- package/dist/api.generated.js +384 -0
- package/dist/discover.d.ts +10 -0
- package/dist/discover.js +35 -0
- package/dist/errors.d.ts +34 -0
- package/dist/errors.js +62 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.js +94 -0
- package/dist/runtime.d.ts +76 -0
- package/dist/runtime.js +265 -0
- package/dist/sse.d.ts +14 -0
- package/dist/sse.js +67 -0
- package/dist/types.generated.d.ts +392 -0
- package/dist/types.generated.js +3 -0
- package/package.json +26 -0
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
/** A domain object whose shape is owned by `@chatpanel/events`; the SDK carries it as-is. */
|
|
2
|
+
export interface AnyObject {
|
|
3
|
+
[key: string]: unknown;
|
|
4
|
+
}
|
|
5
|
+
export interface ErrorResponse {
|
|
6
|
+
error: string | {
|
|
7
|
+
message: string;
|
|
8
|
+
/** A stable machine word — `not_found`, `invalid_request`, `unavailable`, `auth`, `policy`, … */
|
|
9
|
+
type?: string;
|
|
10
|
+
/** A finer word when there is one — `agent_lane_token_required`, `org_policy`. */
|
|
11
|
+
code?: string;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export interface Health {
|
|
15
|
+
ok: boolean;
|
|
16
|
+
/** The gateway's semver; every version gate reads this. */
|
|
17
|
+
version: string;
|
|
18
|
+
backend?: string;
|
|
19
|
+
/** Redaction tier. */
|
|
20
|
+
tier?: "basic" | "full";
|
|
21
|
+
/** Present from 0.9.0 — this gateway can pair a client. */
|
|
22
|
+
pairing?: boolean;
|
|
23
|
+
managed?: AnyObject;
|
|
24
|
+
managedBy?: string;
|
|
25
|
+
bridge?: AnyObject;
|
|
26
|
+
stt?: AnyObject;
|
|
27
|
+
tts?: AnyObject;
|
|
28
|
+
[key: string]: unknown;
|
|
29
|
+
}
|
|
30
|
+
export interface WhoAmI {
|
|
31
|
+
ok: boolean;
|
|
32
|
+
trust: "token" | "pinned" | "unpaired" | "local" | "web";
|
|
33
|
+
/** True when this caller may reach token-gated routes. */
|
|
34
|
+
paired: boolean;
|
|
35
|
+
version: string;
|
|
36
|
+
}
|
|
37
|
+
export interface PairingCode {
|
|
38
|
+
ok: boolean;
|
|
39
|
+
code: string;
|
|
40
|
+
display?: string;
|
|
41
|
+
/** ms since epoch */
|
|
42
|
+
expiresAt: number;
|
|
43
|
+
}
|
|
44
|
+
export interface Paired {
|
|
45
|
+
ok: boolean;
|
|
46
|
+
/** The gateway token. A secret — store it 0600 or in the platform keychain; never log it. */
|
|
47
|
+
token: string;
|
|
48
|
+
/** The bridge's token when this machine has one. */
|
|
49
|
+
bridgeToken?: string;
|
|
50
|
+
}
|
|
51
|
+
export interface Audit {
|
|
52
|
+
version?: string;
|
|
53
|
+
startedAt?: number;
|
|
54
|
+
[key: string]: unknown;
|
|
55
|
+
}
|
|
56
|
+
export interface Model {
|
|
57
|
+
id: string;
|
|
58
|
+
object: "model";
|
|
59
|
+
owned_by?: string;
|
|
60
|
+
provider?: string;
|
|
61
|
+
/** 0.6.64+ */
|
|
62
|
+
provider_type?: "agent" | "openai" | "anthropic";
|
|
63
|
+
api?: string;
|
|
64
|
+
endpoints?: Array<string>;
|
|
65
|
+
/** 0.6.64+ for bridge agents — whether the CLI is installed. */
|
|
66
|
+
available?: boolean;
|
|
67
|
+
/** 0.6.66+ — false when a turn is known to fail for something the user can fix. */
|
|
68
|
+
configured?: boolean;
|
|
69
|
+
reason?: string;
|
|
70
|
+
/** False when the agent cannot take per-turn tools. */
|
|
71
|
+
tools?: boolean;
|
|
72
|
+
[key: string]: unknown;
|
|
73
|
+
}
|
|
74
|
+
export interface ModelList {
|
|
75
|
+
object: "list";
|
|
76
|
+
data: Array<Model>;
|
|
77
|
+
}
|
|
78
|
+
export interface ChatMessage {
|
|
79
|
+
role: "system" | "user" | "assistant" | "tool";
|
|
80
|
+
content?: string | Array<ChatContentPart> | null;
|
|
81
|
+
name?: string;
|
|
82
|
+
tool_calls?: Array<AnyObject>;
|
|
83
|
+
tool_call_id?: string;
|
|
84
|
+
[key: string]: unknown;
|
|
85
|
+
}
|
|
86
|
+
/** One part of a multi-part message — `text`, `image_url`, … in the OpenAI shape. */
|
|
87
|
+
export interface ChatContentPart {
|
|
88
|
+
type: string;
|
|
89
|
+
text?: string;
|
|
90
|
+
image_url?: AnyObject;
|
|
91
|
+
[key: string]: unknown;
|
|
92
|
+
}
|
|
93
|
+
export interface ChatCompletionRequest {
|
|
94
|
+
/** A model id from `GET /v1/models`; `claude/opus` names an agent and its model. */
|
|
95
|
+
model: string;
|
|
96
|
+
messages: Array<ChatMessage>;
|
|
97
|
+
stream?: boolean;
|
|
98
|
+
stream_options?: AnyObject;
|
|
99
|
+
tools?: Array<AnyObject>;
|
|
100
|
+
tool_choice?: unknown;
|
|
101
|
+
temperature?: number;
|
|
102
|
+
max_tokens?: number;
|
|
103
|
+
[key: string]: unknown;
|
|
104
|
+
}
|
|
105
|
+
export interface ChatCompletion {
|
|
106
|
+
id: string;
|
|
107
|
+
object: string;
|
|
108
|
+
created?: number;
|
|
109
|
+
model?: string;
|
|
110
|
+
choices: Array<{
|
|
111
|
+
index?: number;
|
|
112
|
+
message?: ChatMessage;
|
|
113
|
+
finish_reason?: string | null;
|
|
114
|
+
[key: string]: unknown;
|
|
115
|
+
}>;
|
|
116
|
+
usage?: AnyObject;
|
|
117
|
+
[key: string]: unknown;
|
|
118
|
+
}
|
|
119
|
+
/** One `data:` frame of a streamed completion. */
|
|
120
|
+
export interface ChatCompletionChunk {
|
|
121
|
+
id: string;
|
|
122
|
+
object: string;
|
|
123
|
+
model?: string;
|
|
124
|
+
choices: Array<{
|
|
125
|
+
index?: number;
|
|
126
|
+
delta?: AnyObject;
|
|
127
|
+
finish_reason?: string | null;
|
|
128
|
+
[key: string]: unknown;
|
|
129
|
+
}>;
|
|
130
|
+
usage?: AnyObject;
|
|
131
|
+
[key: string]: unknown;
|
|
132
|
+
}
|
|
133
|
+
export interface RedactionPreview {
|
|
134
|
+
/** What the model would receive. */
|
|
135
|
+
text: string;
|
|
136
|
+
count: number;
|
|
137
|
+
sanitized?: number;
|
|
138
|
+
tier?: "basic" | "full";
|
|
139
|
+
/** Placeholder tokens and their types — never the real values. */
|
|
140
|
+
entities?: Array<AnyObject>;
|
|
141
|
+
detector?: AnyObject;
|
|
142
|
+
}
|
|
143
|
+
export type RecordType = "chat" | "note" | "meeting" | "brief";
|
|
144
|
+
export interface SearchFilters {
|
|
145
|
+
type?: RecordType;
|
|
146
|
+
/** ms since epoch */
|
|
147
|
+
since?: number;
|
|
148
|
+
/** ms since epoch */
|
|
149
|
+
before?: number;
|
|
150
|
+
limit?: number;
|
|
151
|
+
}
|
|
152
|
+
export type SearchRequest = (SearchFilters) & ({
|
|
153
|
+
query: string;
|
|
154
|
+
offset?: number;
|
|
155
|
+
});
|
|
156
|
+
export type SmartSearchRequest = (SearchFilters) & ({
|
|
157
|
+
/** The natural-language question. */
|
|
158
|
+
question: string;
|
|
159
|
+
/** 2–4 keyword phrasings of your own; they lead. */
|
|
160
|
+
queries?: Array<string>;
|
|
161
|
+
maxQueries?: number;
|
|
162
|
+
});
|
|
163
|
+
export interface SearchHit {
|
|
164
|
+
id: string;
|
|
165
|
+
score?: number;
|
|
166
|
+
title?: string;
|
|
167
|
+
type?: RecordType;
|
|
168
|
+
date?: number;
|
|
169
|
+
snippet?: string;
|
|
170
|
+
[key: string]: unknown;
|
|
171
|
+
}
|
|
172
|
+
export interface SearchResponse {
|
|
173
|
+
ok: boolean;
|
|
174
|
+
size?: number;
|
|
175
|
+
newest?: number;
|
|
176
|
+
results: Array<SearchHit>;
|
|
177
|
+
}
|
|
178
|
+
export type SmartSearchResponse = (SearchResponse) & ({
|
|
179
|
+
queries?: Array<string>;
|
|
180
|
+
});
|
|
181
|
+
export interface HistoryStatus {
|
|
182
|
+
ok: boolean;
|
|
183
|
+
size: number;
|
|
184
|
+
newest?: number;
|
|
185
|
+
bytes?: number;
|
|
186
|
+
lossless?: {
|
|
187
|
+
records?: number;
|
|
188
|
+
newest?: number;
|
|
189
|
+
} | null;
|
|
190
|
+
}
|
|
191
|
+
export interface HistoryItem {
|
|
192
|
+
id: string;
|
|
193
|
+
title?: string;
|
|
194
|
+
type?: RecordType;
|
|
195
|
+
date?: number;
|
|
196
|
+
chars?: number;
|
|
197
|
+
[key: string]: unknown;
|
|
198
|
+
}
|
|
199
|
+
export interface HistoryPage {
|
|
200
|
+
ok: boolean;
|
|
201
|
+
total: number;
|
|
202
|
+
items: Array<HistoryItem>;
|
|
203
|
+
}
|
|
204
|
+
export interface HistoryRecord {
|
|
205
|
+
id: string;
|
|
206
|
+
title?: string;
|
|
207
|
+
type?: RecordType;
|
|
208
|
+
date?: number;
|
|
209
|
+
text: string;
|
|
210
|
+
[key: string]: unknown;
|
|
211
|
+
}
|
|
212
|
+
export interface RecordsPage {
|
|
213
|
+
ok: boolean;
|
|
214
|
+
/** Whole records; a tombstone carries `deletedAt`. */
|
|
215
|
+
records: Array<AnyObject>;
|
|
216
|
+
/** The cursor for the next page — pass it as `cursor`; absent on the last page. */
|
|
217
|
+
next?: string;
|
|
218
|
+
size?: number;
|
|
219
|
+
newest?: number;
|
|
220
|
+
[key: string]: unknown;
|
|
221
|
+
}
|
|
222
|
+
export interface PutRecordsRequest {
|
|
223
|
+
/** Who is pushing — recorded on every record. */
|
|
224
|
+
host?: string;
|
|
225
|
+
at?: number;
|
|
226
|
+
records?: Array<AnyObject>;
|
|
227
|
+
/** Sealed backup entries, opened with the stored passphrase. */
|
|
228
|
+
entries?: Array<AnyObject>;
|
|
229
|
+
}
|
|
230
|
+
export interface PutRecordsResponse {
|
|
231
|
+
ok: boolean;
|
|
232
|
+
written: number;
|
|
233
|
+
ids?: Array<string>;
|
|
234
|
+
sealed?: number;
|
|
235
|
+
size?: number;
|
|
236
|
+
}
|
|
237
|
+
export interface IngestRequest {
|
|
238
|
+
upserts?: Array<{
|
|
239
|
+
id: string;
|
|
240
|
+
title?: string;
|
|
241
|
+
type?: RecordType;
|
|
242
|
+
date?: number;
|
|
243
|
+
text: string;
|
|
244
|
+
[key: string]: unknown;
|
|
245
|
+
}>;
|
|
246
|
+
removes?: Array<string>;
|
|
247
|
+
}
|
|
248
|
+
export interface Memory {
|
|
249
|
+
id: string;
|
|
250
|
+
text: string;
|
|
251
|
+
kind?: string;
|
|
252
|
+
scope?: string;
|
|
253
|
+
tags?: Array<string>;
|
|
254
|
+
createdAt?: number;
|
|
255
|
+
updatedAt?: number;
|
|
256
|
+
source?: MemorySource;
|
|
257
|
+
[key: string]: unknown;
|
|
258
|
+
}
|
|
259
|
+
/** Who proposed the memory. There is no confirm dialog on a CLI, so attribution is the accountability. */
|
|
260
|
+
export interface MemorySource {
|
|
261
|
+
/** The client — e.g. `sdk`, `cli`, `mcp`. */
|
|
262
|
+
via?: string;
|
|
263
|
+
surface?: string;
|
|
264
|
+
agent?: string;
|
|
265
|
+
ref?: string;
|
|
266
|
+
}
|
|
267
|
+
export interface MemoryList {
|
|
268
|
+
ok: boolean;
|
|
269
|
+
size?: number;
|
|
270
|
+
memories: Array<Memory>;
|
|
271
|
+
}
|
|
272
|
+
export interface RecallRequest {
|
|
273
|
+
text: string;
|
|
274
|
+
scopes?: Array<string>;
|
|
275
|
+
limit?: number;
|
|
276
|
+
maxChars?: number;
|
|
277
|
+
}
|
|
278
|
+
export interface RecallResponse {
|
|
279
|
+
ok: boolean;
|
|
280
|
+
size?: number;
|
|
281
|
+
memories: Array<Memory>;
|
|
282
|
+
/** A prompt block carrying the recalled memories. */
|
|
283
|
+
block?: string;
|
|
284
|
+
[key: string]: unknown;
|
|
285
|
+
}
|
|
286
|
+
export interface RememberRequest {
|
|
287
|
+
/** One short sentence. */
|
|
288
|
+
text: string;
|
|
289
|
+
kind?: string;
|
|
290
|
+
scope?: string;
|
|
291
|
+
tags?: Array<string>;
|
|
292
|
+
source?: MemorySource;
|
|
293
|
+
}
|
|
294
|
+
export interface RememberResponse {
|
|
295
|
+
ok: boolean;
|
|
296
|
+
action: string;
|
|
297
|
+
record: Memory;
|
|
298
|
+
replaced?: Memory | null;
|
|
299
|
+
size?: number;
|
|
300
|
+
}
|
|
301
|
+
export interface MemorySyncResponse {
|
|
302
|
+
ok: boolean;
|
|
303
|
+
size?: number;
|
|
304
|
+
memories: Array<Memory>;
|
|
305
|
+
[key: string]: unknown;
|
|
306
|
+
}
|
|
307
|
+
export interface HistoryStreamEvent {
|
|
308
|
+
/** The SSE event name. */
|
|
309
|
+
event: "hello" | "records";
|
|
310
|
+
newest?: number;
|
|
311
|
+
size?: number;
|
|
312
|
+
version?: string;
|
|
313
|
+
ids?: Array<string>;
|
|
314
|
+
at?: number;
|
|
315
|
+
}
|
|
316
|
+
export interface PrefsEvent {
|
|
317
|
+
type: "hello" | "changed";
|
|
318
|
+
revision?: number;
|
|
319
|
+
stamps?: {
|
|
320
|
+
[key: string]: number;
|
|
321
|
+
};
|
|
322
|
+
/** The sections the other client wrote. */
|
|
323
|
+
applied?: Array<string>;
|
|
324
|
+
by?: string;
|
|
325
|
+
[key: string]: unknown;
|
|
326
|
+
}
|
|
327
|
+
export interface PrefSection {
|
|
328
|
+
value: unknown;
|
|
329
|
+
updatedAt?: number;
|
|
330
|
+
by?: string;
|
|
331
|
+
}
|
|
332
|
+
export interface Prefs {
|
|
333
|
+
ok: boolean;
|
|
334
|
+
revision: number;
|
|
335
|
+
sections?: {
|
|
336
|
+
[key: string]: PrefSection;
|
|
337
|
+
};
|
|
338
|
+
stamps?: {
|
|
339
|
+
[key: string]: number;
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
export interface PrefsWrite {
|
|
343
|
+
sections: {
|
|
344
|
+
[key: string]: PrefSection;
|
|
345
|
+
};
|
|
346
|
+
/** Which client is writing. */
|
|
347
|
+
by?: string;
|
|
348
|
+
}
|
|
349
|
+
export interface PrefsWriteResult {
|
|
350
|
+
ok: boolean;
|
|
351
|
+
revision: number;
|
|
352
|
+
applied?: Array<string>;
|
|
353
|
+
kept?: Array<string>;
|
|
354
|
+
[key: string]: unknown;
|
|
355
|
+
}
|
|
356
|
+
export interface RunEvent {
|
|
357
|
+
seq?: number;
|
|
358
|
+
type: string;
|
|
359
|
+
at?: number;
|
|
360
|
+
payload?: AnyObject;
|
|
361
|
+
[key: string]: unknown;
|
|
362
|
+
}
|
|
363
|
+
export interface TeamRun {
|
|
364
|
+
id: string;
|
|
365
|
+
client?: string;
|
|
366
|
+
team?: AnyObject;
|
|
367
|
+
status?: string;
|
|
368
|
+
events?: Array<RunEvent>;
|
|
369
|
+
[key: string]: unknown;
|
|
370
|
+
}
|
|
371
|
+
export interface TeamRunCreate {
|
|
372
|
+
id?: string;
|
|
373
|
+
/** Which client is running it. */
|
|
374
|
+
client?: string;
|
|
375
|
+
team?: AnyObject;
|
|
376
|
+
request?: AnyObject;
|
|
377
|
+
}
|
|
378
|
+
export interface Project {
|
|
379
|
+
id: string;
|
|
380
|
+
status?: string;
|
|
381
|
+
jobs?: Array<AnyObject>;
|
|
382
|
+
[key: string]: unknown;
|
|
383
|
+
}
|
|
384
|
+
export interface Skill {
|
|
385
|
+
id: string;
|
|
386
|
+
name?: string;
|
|
387
|
+
description?: string;
|
|
388
|
+
promptChars?: number;
|
|
389
|
+
/** Only on `GET /skills/{skillId}`. */
|
|
390
|
+
prompt?: string;
|
|
391
|
+
[key: string]: unknown;
|
|
392
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@chatpanel/sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Typed client for the local ChatPanel gateway — chat through the privacy proxy, search the user's history, read and write memory, follow team runs. Zero dependencies.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" }
|
|
10
|
+
},
|
|
11
|
+
"files": ["dist", "README.md", "LICENSE"],
|
|
12
|
+
"sideEffects": false,
|
|
13
|
+
"engines": { "node": ">=20" },
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc -p tsconfig.json",
|
|
16
|
+
"test": "npm run build && node --test tests/*.test.mjs",
|
|
17
|
+
"prepack": "npm run build"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"typescript": "^5.9.0"
|
|
21
|
+
},
|
|
22
|
+
"keywords": ["chatpanel", "sdk", "client", "gateway", "privacy", "llm", "agents"],
|
|
23
|
+
"license": "Apache-2.0",
|
|
24
|
+
"repository": { "type": "git", "url": "git+https://github.com/chatpanel/chatpanel-sdk.git", "directory": "sdk/typescript" },
|
|
25
|
+
"homepage": "https://chatpanel.net"
|
|
26
|
+
}
|