fastclaw-cli 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/README.md +117 -0
- package/dist/index.js +1413 -0
- package/dist/sdk.d.ts +312 -0
- package/dist/sdk.js +409 -0
- package/package.json +50 -0
package/dist/sdk.d.ts
ADDED
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
interface ApiResponse<T = unknown> {
|
|
2
|
+
code: number;
|
|
3
|
+
message: string;
|
|
4
|
+
data?: T;
|
|
5
|
+
}
|
|
6
|
+
interface App {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
url?: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
owner_email?: string;
|
|
12
|
+
api_token: string;
|
|
13
|
+
bot_domain_template?: string;
|
|
14
|
+
status: "active" | "disabled";
|
|
15
|
+
created_at: string;
|
|
16
|
+
updated_at: string;
|
|
17
|
+
}
|
|
18
|
+
interface CreateAppRequest {
|
|
19
|
+
name: string;
|
|
20
|
+
url?: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
owner_email?: string;
|
|
23
|
+
bot_domain_template?: string;
|
|
24
|
+
}
|
|
25
|
+
interface UpdateAppRequest {
|
|
26
|
+
name?: string;
|
|
27
|
+
url?: string;
|
|
28
|
+
description?: string;
|
|
29
|
+
owner_email?: string;
|
|
30
|
+
bot_domain_template?: string;
|
|
31
|
+
status?: "active" | "disabled";
|
|
32
|
+
}
|
|
33
|
+
type BotStatus = "created" | "running" | "stopped" | "error";
|
|
34
|
+
interface Bot {
|
|
35
|
+
id: string;
|
|
36
|
+
app_id: string;
|
|
37
|
+
user_id: string;
|
|
38
|
+
name: string;
|
|
39
|
+
slug: string;
|
|
40
|
+
access_token: string;
|
|
41
|
+
status: BotStatus;
|
|
42
|
+
config?: Record<string, unknown>;
|
|
43
|
+
endpoint: string;
|
|
44
|
+
expires_at?: string;
|
|
45
|
+
created_at: string;
|
|
46
|
+
updated_at: string;
|
|
47
|
+
access_url?: string;
|
|
48
|
+
deployment_status?: {
|
|
49
|
+
status: "ready" | "updating" | "error";
|
|
50
|
+
ready_replicas: number;
|
|
51
|
+
desired_replicas: number;
|
|
52
|
+
};
|
|
53
|
+
image?: string;
|
|
54
|
+
latest_image?: string;
|
|
55
|
+
image_up_to_date?: boolean;
|
|
56
|
+
}
|
|
57
|
+
interface CreateBotRequest {
|
|
58
|
+
user_id: string;
|
|
59
|
+
name: string;
|
|
60
|
+
slug?: string;
|
|
61
|
+
config?: Record<string, unknown>;
|
|
62
|
+
expires_at?: string;
|
|
63
|
+
}
|
|
64
|
+
interface UpdateBotRequest {
|
|
65
|
+
name?: string;
|
|
66
|
+
slug?: string;
|
|
67
|
+
config?: Record<string, unknown>;
|
|
68
|
+
expires_at?: string;
|
|
69
|
+
}
|
|
70
|
+
interface BotStatusResponse {
|
|
71
|
+
id: string;
|
|
72
|
+
name: string;
|
|
73
|
+
status: BotStatus;
|
|
74
|
+
ready: boolean;
|
|
75
|
+
endpoint: string;
|
|
76
|
+
}
|
|
77
|
+
interface BotConnectResponse {
|
|
78
|
+
id: string;
|
|
79
|
+
name: string;
|
|
80
|
+
status: BotStatus;
|
|
81
|
+
ready: boolean;
|
|
82
|
+
token: string;
|
|
83
|
+
endpoint: string;
|
|
84
|
+
ws_url: string;
|
|
85
|
+
webchat_url: string;
|
|
86
|
+
}
|
|
87
|
+
interface ResetTokenResponse {
|
|
88
|
+
id: string;
|
|
89
|
+
access_token: string;
|
|
90
|
+
access_url: string;
|
|
91
|
+
message: string;
|
|
92
|
+
}
|
|
93
|
+
interface ProviderModel {
|
|
94
|
+
id: string;
|
|
95
|
+
name: string;
|
|
96
|
+
reasoning?: boolean;
|
|
97
|
+
input?: string[];
|
|
98
|
+
context_window?: number;
|
|
99
|
+
max_tokens?: number;
|
|
100
|
+
}
|
|
101
|
+
interface ModelProvider {
|
|
102
|
+
name: string;
|
|
103
|
+
baseUrl?: string;
|
|
104
|
+
apiKey?: string;
|
|
105
|
+
auth?: string;
|
|
106
|
+
api?: string;
|
|
107
|
+
models: ProviderModel[];
|
|
108
|
+
}
|
|
109
|
+
interface ModelDefaults {
|
|
110
|
+
primary_model?: string;
|
|
111
|
+
fallback_model?: string;
|
|
112
|
+
max_concurrent?: number;
|
|
113
|
+
}
|
|
114
|
+
interface AddChannelRequest {
|
|
115
|
+
channel: string;
|
|
116
|
+
account?: string;
|
|
117
|
+
botToken?: string;
|
|
118
|
+
token?: string;
|
|
119
|
+
appToken?: string;
|
|
120
|
+
appId?: string;
|
|
121
|
+
appSecret?: string;
|
|
122
|
+
appPassword?: string;
|
|
123
|
+
channelSecret?: string;
|
|
124
|
+
dmPolicy?: string;
|
|
125
|
+
groupPolicy?: string;
|
|
126
|
+
allowFrom?: string[];
|
|
127
|
+
enabled?: boolean;
|
|
128
|
+
extra?: Record<string, unknown>;
|
|
129
|
+
}
|
|
130
|
+
interface ChannelResponse {
|
|
131
|
+
message: string;
|
|
132
|
+
channel: string;
|
|
133
|
+
account?: string;
|
|
134
|
+
}
|
|
135
|
+
type ChannelsMap = Record<string, Record<string, Record<string, unknown>>>;
|
|
136
|
+
interface PairingRequest {
|
|
137
|
+
code?: string;
|
|
138
|
+
user_id?: string;
|
|
139
|
+
channel?: string;
|
|
140
|
+
status?: string;
|
|
141
|
+
}
|
|
142
|
+
interface PairingApproveRequest {
|
|
143
|
+
code: string;
|
|
144
|
+
}
|
|
145
|
+
interface PairingRevokeRequest {
|
|
146
|
+
user_id: string;
|
|
147
|
+
}
|
|
148
|
+
interface PairedUsersResponse {
|
|
149
|
+
channel: string;
|
|
150
|
+
users: string[];
|
|
151
|
+
}
|
|
152
|
+
interface DeviceInfo {
|
|
153
|
+
request_id: string;
|
|
154
|
+
device_id: string;
|
|
155
|
+
role: string;
|
|
156
|
+
platform: string;
|
|
157
|
+
client_id: string;
|
|
158
|
+
client_mode: string;
|
|
159
|
+
ip: string;
|
|
160
|
+
age: string;
|
|
161
|
+
revoked: boolean;
|
|
162
|
+
connected: boolean;
|
|
163
|
+
status: "pending" | "paired" | "revoked";
|
|
164
|
+
}
|
|
165
|
+
interface DeviceListResponse {
|
|
166
|
+
bot_id: string;
|
|
167
|
+
devices: DeviceInfo[];
|
|
168
|
+
}
|
|
169
|
+
interface SkillInfo {
|
|
170
|
+
name: string;
|
|
171
|
+
}
|
|
172
|
+
interface SetSkillRequest {
|
|
173
|
+
content: string;
|
|
174
|
+
}
|
|
175
|
+
interface UpgradeRequest {
|
|
176
|
+
image?: string;
|
|
177
|
+
}
|
|
178
|
+
interface UpgradeResponse {
|
|
179
|
+
status: "upgraded" | "skipped";
|
|
180
|
+
image: string;
|
|
181
|
+
previous_image?: string;
|
|
182
|
+
}
|
|
183
|
+
interface BulkUpgradeResponse {
|
|
184
|
+
image: string;
|
|
185
|
+
total: number;
|
|
186
|
+
upgraded: number;
|
|
187
|
+
failed: number;
|
|
188
|
+
skipped: number;
|
|
189
|
+
results: Array<{
|
|
190
|
+
bot_id: string;
|
|
191
|
+
status: "upgraded" | "failed" | "skipped";
|
|
192
|
+
message: string;
|
|
193
|
+
}>;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
interface ClientOptions {
|
|
197
|
+
url: string;
|
|
198
|
+
adminToken?: string;
|
|
199
|
+
appToken?: string;
|
|
200
|
+
}
|
|
201
|
+
declare class FastClawClient {
|
|
202
|
+
private baseUrl;
|
|
203
|
+
private adminToken?;
|
|
204
|
+
private appToken?;
|
|
205
|
+
constructor(opts: ClientOptions);
|
|
206
|
+
private request;
|
|
207
|
+
createApp(req: CreateAppRequest): Promise<App>;
|
|
208
|
+
listApps(): Promise<App[]>;
|
|
209
|
+
getApp(id: string): Promise<App>;
|
|
210
|
+
updateApp(id: string, req: UpdateAppRequest): Promise<App>;
|
|
211
|
+
deleteApp(id: string): Promise<{
|
|
212
|
+
message: string;
|
|
213
|
+
}>;
|
|
214
|
+
rotateAppToken(id: string): Promise<{
|
|
215
|
+
api_token: string;
|
|
216
|
+
}>;
|
|
217
|
+
upgradeBot(id: string, req?: UpgradeRequest): Promise<UpgradeResponse>;
|
|
218
|
+
upgradeAllBots(req?: UpgradeRequest): Promise<BulkUpgradeResponse>;
|
|
219
|
+
createBot(req: CreateBotRequest): Promise<Bot>;
|
|
220
|
+
listBots(userId: string): Promise<Bot[]>;
|
|
221
|
+
getBot(id: string): Promise<Bot>;
|
|
222
|
+
updateBot(id: string, req: UpdateBotRequest): Promise<Bot>;
|
|
223
|
+
deleteBot(id: string): Promise<{
|
|
224
|
+
message: string;
|
|
225
|
+
}>;
|
|
226
|
+
startBot(id: string): Promise<Bot>;
|
|
227
|
+
stopBot(id: string): Promise<Bot>;
|
|
228
|
+
restartBot(id: string): Promise<Bot>;
|
|
229
|
+
getBotStatus(id: string): Promise<BotStatusResponse>;
|
|
230
|
+
getBotConnect(id: string): Promise<BotConnectResponse>;
|
|
231
|
+
resetBotToken(id: string): Promise<ResetTokenResponse>;
|
|
232
|
+
listProviders(botId: string): Promise<Record<string, ModelProvider>>;
|
|
233
|
+
addProvider(botId: string, provider: ModelProvider): Promise<ModelProvider>;
|
|
234
|
+
getProvider(botId: string, name: string): Promise<ModelProvider>;
|
|
235
|
+
updateProvider(botId: string, name: string, provider: ModelProvider): Promise<ModelProvider>;
|
|
236
|
+
deleteProvider(botId: string, name: string): Promise<void>;
|
|
237
|
+
getDefaults(botId: string): Promise<ModelDefaults>;
|
|
238
|
+
setDefaults(botId: string, defaults: ModelDefaults): Promise<ModelDefaults>;
|
|
239
|
+
addChannel(botId: string, req: AddChannelRequest): Promise<ChannelResponse>;
|
|
240
|
+
listChannels(botId: string): Promise<ChannelsMap>;
|
|
241
|
+
removeChannel(botId: string, channel: string, account?: string): Promise<ChannelResponse>;
|
|
242
|
+
listPairing(botId: string, channel: string): Promise<unknown[]>;
|
|
243
|
+
approvePairing(botId: string, channel: string, req: PairingApproveRequest): Promise<unknown>;
|
|
244
|
+
revokePairing(botId: string, channel: string, req: PairingRevokeRequest): Promise<unknown>;
|
|
245
|
+
listPairedUsers(botId: string, channel: string): Promise<PairedUsersResponse>;
|
|
246
|
+
listDevices(botId: string, opts?: {
|
|
247
|
+
status?: string;
|
|
248
|
+
client_mode?: string;
|
|
249
|
+
}): Promise<DeviceListResponse>;
|
|
250
|
+
approveDevice(botId: string, requestId: string): Promise<unknown>;
|
|
251
|
+
revokeDevice(botId: string, deviceId: string, role?: string): Promise<unknown>;
|
|
252
|
+
listSkills(botId: string): Promise<SkillInfo[]>;
|
|
253
|
+
setSkill(botId: string, name: string, req: SetSkillRequest): Promise<unknown>;
|
|
254
|
+
deleteSkill(botId: string, name: string): Promise<unknown>;
|
|
255
|
+
waitForReady(botId: string, timeoutMs?: number, intervalMs?: number): Promise<BotStatusResponse>;
|
|
256
|
+
health(): Promise<boolean>;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
interface FastClawConfig {
|
|
260
|
+
url?: string;
|
|
261
|
+
admin_token?: string;
|
|
262
|
+
app_token?: string;
|
|
263
|
+
default_user_id?: string;
|
|
264
|
+
default_bot_id?: string;
|
|
265
|
+
}
|
|
266
|
+
declare function loadConfig(): FastClawConfig;
|
|
267
|
+
declare function saveConfig(config: FastClawConfig): void;
|
|
268
|
+
declare function updateConfig(updates: Partial<FastClawConfig>): FastClawConfig;
|
|
269
|
+
interface ResolvedConfig {
|
|
270
|
+
url: string;
|
|
271
|
+
adminToken?: string;
|
|
272
|
+
appToken?: string;
|
|
273
|
+
userId: string;
|
|
274
|
+
botId?: string;
|
|
275
|
+
json: boolean;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Resolve config with priority: CLI flags > env vars > config file > defaults.
|
|
279
|
+
* Used by CLI commands. SDK users construct FastClawClient directly.
|
|
280
|
+
*/
|
|
281
|
+
declare function resolveConfig(opts: {
|
|
282
|
+
url?: string;
|
|
283
|
+
adminToken?: string;
|
|
284
|
+
appToken?: string;
|
|
285
|
+
userId?: string;
|
|
286
|
+
botId?: string;
|
|
287
|
+
json?: boolean;
|
|
288
|
+
}): ResolvedConfig;
|
|
289
|
+
declare function getConfigPath(): string;
|
|
290
|
+
|
|
291
|
+
declare const DEFAULT_URL = "https://claw.yesy.dev";
|
|
292
|
+
declare const API_BASE = "/bot/api/v1";
|
|
293
|
+
declare const MODEL_PRESETS: Record<string, Omit<ModelProvider, "apiKey">>;
|
|
294
|
+
declare const PROVIDER_DEFAULTS: Record<string, string>;
|
|
295
|
+
declare const CHANNEL_FIELDS: Record<string, {
|
|
296
|
+
required: string[];
|
|
297
|
+
optional: string[];
|
|
298
|
+
}>;
|
|
299
|
+
declare const DM_POLICIES: readonly ["open", "pairing", "allowlist", "disabled"];
|
|
300
|
+
declare const GROUP_POLICIES: readonly ["open", "allowlist", "disabled"];
|
|
301
|
+
|
|
302
|
+
declare class ApiError extends Error {
|
|
303
|
+
statusCode: number;
|
|
304
|
+
apiCode: number;
|
|
305
|
+
constructor(statusCode: number, apiCode: number, message: string);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
declare function isValidSlug(slug: string): boolean;
|
|
309
|
+
declare function isValidUrl(url: string): boolean;
|
|
310
|
+
declare function slugify(name: string): string;
|
|
311
|
+
|
|
312
|
+
export { API_BASE, type AddChannelRequest, ApiError, type ApiResponse, type App, type Bot, type BotConnectResponse, type BotStatus, type BotStatusResponse, type BulkUpgradeResponse, CHANNEL_FIELDS, type ChannelResponse, type ChannelsMap, type ClientOptions, type CreateAppRequest, type CreateBotRequest, DEFAULT_URL, DM_POLICIES, type DeviceInfo, type DeviceListResponse, FastClawClient, type FastClawConfig, GROUP_POLICIES, MODEL_PRESETS, type ModelDefaults, type ModelProvider, PROVIDER_DEFAULTS, type PairedUsersResponse, type PairingApproveRequest, type PairingRequest, type PairingRevokeRequest, type ProviderModel, type ResetTokenResponse, type ResolvedConfig, type SetSkillRequest, type SkillInfo, type UpdateAppRequest, type UpdateBotRequest, type UpgradeRequest, type UpgradeResponse, getConfigPath, isValidSlug, isValidUrl, loadConfig, resolveConfig, saveConfig, slugify, updateConfig };
|