@pickaxe/harnesslayer 1.0.0 → 1.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/dist/index.d.ts DELETED
@@ -1,578 +0,0 @@
1
- type Method = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
2
- type FetchLike = typeof fetch;
3
-
4
- interface DriftstoneClientOptions {
5
- apiKey: string;
6
- version: "v1";
7
- timeoutMs: number;
8
- fetch?: FetchLike;
9
- baseUrl?: string;
10
- }
11
- interface DriftstoneRepository {
12
- id: string;
13
- orgId: string;
14
- name: string;
15
- slug: string;
16
- branch: string;
17
- }
18
- interface DriftstoneBranch {
19
- id: string;
20
- repoId: string;
21
- name: string;
22
- storagePath: string | null;
23
- runId: string | null;
24
- status: string | null;
25
- }
26
- interface DriftstoneCopy {
27
- repoId: string;
28
- runId: string;
29
- status: string;
30
- sourceDir: string | null;
31
- destDir: string | null;
32
- }
33
- interface DriftstoneCopyStatus {
34
- repoId: string;
35
- runId: string;
36
- status: string;
37
- result?: Record<string, unknown> | null;
38
- }
39
- interface DriftstoneUpload {
40
- repoId: string;
41
- uploadId: string;
42
- uploadUrls: Array<{
43
- name: string;
44
- url: string;
45
- }>;
46
- }
47
- interface UploadFilePayload {
48
- name: string;
49
- hash: string;
50
- }
51
- declare class DriftstoneClient {
52
- readonly repos: DriftstoneRepositories;
53
- private readonly baseUrl;
54
- private readonly headers;
55
- private readonly timeoutMs;
56
- private readonly fetchImpl;
57
- constructor(options: DriftstoneClientOptions);
58
- request<T extends Record<string, unknown> = Record<string, unknown>>(method: Method, requestPath: string, payload?: Record<string, unknown>): Promise<T>;
59
- uploadFile(url: string, filePath: string): Promise<boolean>;
60
- uploadFiles(upload: DriftstoneUpload, files: UploadFilePayload[], root: string): Promise<boolean>;
61
- private parseResponse;
62
- }
63
- declare class DriftstoneRepositories {
64
- private readonly client;
65
- constructor(client: DriftstoneClient);
66
- create(name: string): Promise<DriftstoneRepository>;
67
- get(repo: string): Promise<DriftstoneRepository>;
68
- createBranch(repo: string, name: string, options: {
69
- storageDir: string;
70
- message?: string;
71
- transforms?: Record<string, unknown>;
72
- archive?: boolean;
73
- }): Promise<DriftstoneBranch>;
74
- createUpload(repo: string, options: {
75
- files: UploadFilePayload[];
76
- storageDir: string;
77
- branch?: string;
78
- }): Promise<DriftstoneUpload>;
79
- completeUpload(repo: string, uploadId: string): Promise<boolean>;
80
- copyDirectory(repo: string, options: {
81
- sourceDir: string;
82
- destDir: string;
83
- sourceBranch?: string;
84
- destBranch?: string;
85
- transforms?: Record<string, unknown>;
86
- archive?: boolean;
87
- }): Promise<DriftstoneCopy>;
88
- getCopyStatus(repo: string, runId: string): Promise<DriftstoneCopyStatus>;
89
- }
90
-
91
- declare class ResourceBase {
92
- protected readonly client: Harnesslayer;
93
- protected readonly driftstone: DriftstoneClient;
94
- constructor(client: Harnesslayer);
95
- }
96
- declare class AppBase extends ResourceBase {
97
- protected readonly appId: string;
98
- constructor(client: Harnesslayer, appId: string);
99
- }
100
- declare class ProfileBase extends AppBase {
101
- protected readonly profileId: string;
102
- constructor(client: Harnesslayer, appId: string, profileId: string);
103
- }
104
-
105
- declare class HarnesslayerAccessGroup extends AppBase {
106
- create(name: string, limit: number, options?: {
107
- limitReset: AccessGroupLimitReset;
108
- limitMessage?: string;
109
- }): Promise<HarnesslayerAccessGroupModel>;
110
- retrieve(accessGroupId: string): Promise<HarnesslayerAccessGroupModel | null>;
111
- update(accessGroupId: string, options: {
112
- name?: string;
113
- limit?: number;
114
- limitReset?: AccessGroupLimitReset;
115
- limitMessage?: string;
116
- }): Promise<HarnesslayerAccessGroupModel>;
117
- list(options?: {
118
- page?: number;
119
- pageSize?: number;
120
- }): Promise<HarnesslayerAccessGroupModel[]>;
121
- delete(accessGroupId: string): Promise<boolean>;
122
- }
123
-
124
- declare class HarnesslayerChannel extends AppBase {
125
- init(slug: string, options: {
126
- type: "api";
127
- name?: string;
128
- webhook?: ChannelAPIWebhook;
129
- data?: never;
130
- } | {
131
- type: "imessage";
132
- name?: string;
133
- webhook?: never;
134
- data: ChannelIMessageData;
135
- }): Promise<HarnesslayerChannelModel>;
136
- run(channelId: string, options: ChannelRunOptions): AsyncIterable<ResponseRunStreamEvent>;
137
- private validateWebhook;
138
- private validateIMessageData;
139
- }
140
-
141
- declare class HarnesslayerConflict extends AppBase {
142
- retrieve(conflictId: string): Promise<HarnesslayerConflictModel | null>;
143
- list(options?: {
144
- page?: number;
145
- pageSize?: number;
146
- }): Promise<HarnesslayerConflictModel[]>;
147
- }
148
-
149
- declare class HarnesslayerInstance extends AppBase {
150
- retrieve(instanceId: string): Promise<HarnesslayerInstanceModel | null>;
151
- list(options?: {
152
- page?: number;
153
- pageSize?: number;
154
- }): Promise<HarnesslayerInstanceModel[]>;
155
- }
156
-
157
- declare class HarnesslayerState extends ProfileBase {
158
- create(options: {
159
- stateId?: string;
160
- statePath?: string;
161
- }): Promise<boolean>;
162
- download(outPath: string, stateId?: string): Promise<boolean>;
163
- clone(options?: {
164
- stateId?: string;
165
- transform?: CloneTransform;
166
- }): Promise<boolean>;
167
- waitForCopyRun(runId: string | null | undefined, operation: string): Promise<{
168
- status: string;
169
- result?: Record<string, unknown> | null;
170
- } | null>;
171
- private resolveStateId;
172
- private tryResolveStateId;
173
- }
174
-
175
- declare class HarnesslayerProfile extends AppBase {
176
- init(identifier: string, options?: {
177
- statePath?: string;
178
- accessGroupId?: string;
179
- metadata?: JsonObject;
180
- }): Promise<HarnesslayerProfileModel>;
181
- retrieve(profileId: string): Promise<HarnesslayerProfileModel | null>;
182
- update(profileId: string, options: {
183
- identifier?: string;
184
- accessGroupId?: string;
185
- metadata?: JsonObject;
186
- }): Promise<HarnesslayerProfileModel>;
187
- state(profileId: string): HarnesslayerState;
188
- delete(profileId: string): Promise<boolean>;
189
- }
190
-
191
- declare class HarnesslayerSession extends AppBase {
192
- create(type: ChannelType): Promise<HarnesslayerSessionModel>;
193
- retrieve(sessionId: string): Promise<HarnesslayerSessionModel | null>;
194
- update(sessionId: string, options: {
195
- type?: SessionType;
196
- userIds?: string[];
197
- }): Promise<HarnesslayerSessionModel>;
198
- list(options?: {
199
- page?: number;
200
- pageSize?: number;
201
- }): Promise<HarnesslayerSessionModel[]>;
202
- delete(sessionId: string): Promise<boolean>;
203
- }
204
-
205
- declare class HarnesslayerVersion extends AppBase {
206
- create(options: {
207
- versionId?: string;
208
- versionPath?: string;
209
- }): Promise<boolean>;
210
- download(outPath: string, versionId?: string): Promise<boolean>;
211
- clone(options?: {
212
- versionId?: string;
213
- transform?: CloneTransform;
214
- }): Promise<boolean>;
215
- sync(strategy?: SyncStrategy): Promise<boolean>;
216
- private resolveVersionId;
217
- }
218
-
219
- type ApiVersion = "v1";
220
- type JsonObject = Record<string, unknown>;
221
- type ApplicationType = "claude" | "openclaw";
222
- type ChannelType = "api" | "imessage";
223
- type SessionType = "single" | "multiple";
224
- type AccessGroupLimitReset = "daily" | "monthly" | "yearly";
225
- type SyncStrategy = "manual" | "current" | "incoming" | "smart";
226
- type SyncStatus = "in_progress" | "complete" | "failed" | "conflict";
227
- type InstanceStatus = "running" | "terminated";
228
- type ConflictReason = "missing_head_state" | "missing_state_branch" | "merge_conflict";
229
- type MessageType = "user" | "assistant";
230
- type WebhookEvent = "profile.created";
231
- type WebhookMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
232
- interface AppInitLimit {
233
- name?: string | null;
234
- amount: number;
235
- interval: "daily" | "weekly" | "monthly";
236
- message?: string | null;
237
- }
238
- type AppInitCredentialMCPOAuthNoneParam = {
239
- type: "none";
240
- };
241
- type AppInitCredentialMCPOAuthBasicParam = {
242
- type: "client_secret_basic";
243
- client_secret: string;
244
- };
245
- type AppInitCredentialMCPOAuthPostParam = {
246
- type: "client_secret_post";
247
- client_secret: string;
248
- };
249
- interface AppInitCredentialMCPOAuthRefresh {
250
- client_id: string;
251
- refresh_token: string;
252
- token_endpoint: string;
253
- token_endpoint_auth: AppInitCredentialMCPOAuthNoneParam | AppInitCredentialMCPOAuthBasicParam | AppInitCredentialMCPOAuthPostParam;
254
- resource?: string | null;
255
- scope?: string | null;
256
- }
257
- interface AppInitCredentialMCPOAuth {
258
- access_token: string;
259
- mcp_server_url: string;
260
- type: "mcp_oauth";
261
- expires_at?: Date | string | null;
262
- refresh?: AppInitCredentialMCPOAuthRefresh | null;
263
- }
264
- interface AppInitCredentialMCPStaticBearer {
265
- token: string;
266
- mcp_server_url: string;
267
- type: "mcp_oauth" | "mcp_static_bearer";
268
- }
269
- type AppInitCredential = AppInitCredentialMCPOAuth | AppInitCredentialMCPStaticBearer;
270
- interface ChannelAPIWebhook {
271
- name: string;
272
- url: string;
273
- headers?: Record<string, string> | null;
274
- }
275
- interface ChannelIMessageData {
276
- sendBlueAPIKey: string;
277
- sendBlueSecretKey: string;
278
- fromNumber: string;
279
- }
280
- interface ResponseRunStreamEvent {
281
- instanceId: string;
282
- index: number;
283
- data: unknown;
284
- done?: boolean;
285
- error?: string | null;
286
- }
287
- interface HarnesslayerAppModel {
288
- id: string;
289
- orgId: string;
290
- type: ApplicationType;
291
- name: string;
292
- slug: string;
293
- vaultId: string | null;
294
- defaultAccessGroupId: string | null;
295
- headVersionId: string | null;
296
- metadata: JsonObject | null;
297
- createdAt: Date;
298
- updatedAt: Date;
299
- version: HarnesslayerVersion;
300
- channel: HarnesslayerChannel;
301
- session: HarnesslayerSession;
302
- accessGroup: HarnesslayerAccessGroup;
303
- access_group: HarnesslayerAccessGroup;
304
- profile: HarnesslayerProfile;
305
- instance: HarnesslayerInstance;
306
- conflict: HarnesslayerConflict;
307
- }
308
- interface HarnesslayerChannelModel {
309
- id: string;
310
- appId: string;
311
- type: ChannelType;
312
- slug: string;
313
- name: string;
314
- webhook: ChannelAPIWebhook | null;
315
- data: ChannelIMessageData | null;
316
- createdAt: Date;
317
- updatedAt: Date;
318
- run(options: ChannelRunOptions): AsyncIterable<ResponseRunStreamEvent>;
319
- }
320
- interface HarnesslayerAccessGroupModel {
321
- id: string;
322
- appId: string;
323
- name: string;
324
- limit: number;
325
- limitReset: AccessGroupLimitReset;
326
- limitMessage: string;
327
- createdAt: Date;
328
- updatedAt: Date;
329
- }
330
- interface HarnesslayerOrganizationModel {
331
- id: string;
332
- name: string;
333
- slug: string;
334
- createdBy: string;
335
- createdAt: Date;
336
- updatedAt: Date;
337
- }
338
- interface HarnesslayerProfileModel {
339
- id: string;
340
- appId: string;
341
- identifier: string;
342
- currentSpending: number;
343
- totalSpending: number;
344
- metadata: JsonObject | null;
345
- headStateId: string | null;
346
- initialChannelId: string | null;
347
- accessGroupId: string | null;
348
- lastResetAt: Date | null;
349
- createdAt: Date;
350
- updatedAt: Date;
351
- state: HarnesslayerState;
352
- }
353
- interface HarnesslayerSessionModel {
354
- id: string;
355
- appId: string;
356
- type: SessionType;
357
- userIds: string[];
358
- profileIds: string[];
359
- metadata: JsonObject | null;
360
- externalId: string | null;
361
- createdAt: Date;
362
- updatedAt: Date;
363
- }
364
- interface HarnesslayerInstanceModel {
365
- id: string;
366
- appId: string;
367
- versionId: string;
368
- channelId: string;
369
- sessionId: string;
370
- profileId: string;
371
- accessGroupId: string;
372
- stateId: string | null;
373
- identifier: string;
374
- timeout: number;
375
- totalCost: number;
376
- costBreakdown: Record<string, number>;
377
- tokenBreakdown: Record<string, number>;
378
- metadata: JsonObject | null;
379
- status: InstanceStatus;
380
- error: string | null;
381
- createdAt: Date;
382
- updatedAt: Date;
383
- }
384
- interface HarnesslayerConflictModel {
385
- id: string;
386
- appId: string;
387
- syncId: string;
388
- profileId: string;
389
- versionId: string;
390
- stateId: string;
391
- stateBranch: string;
392
- reason: ConflictReason;
393
- error: string | null;
394
- createdAt: Date;
395
- updatedAt: Date;
396
- }
397
- interface HarnesslayerMessageModel {
398
- id: string;
399
- appId: string;
400
- sessionId: string;
401
- historyId: string | null;
402
- type: MessageType;
403
- parts: JsonObject[];
404
- createdAt: Date;
405
- updatedAt: Date;
406
- }
407
- interface HarnesslayerHistoryModel {
408
- id: string;
409
- appId: string;
410
- sessionId: string;
411
- profileId: string;
412
- identifier: string;
413
- timestamp: number;
414
- messages: HarnesslayerMessageModel[];
415
- createdAt: Date;
416
- updatedAt: Date;
417
- }
418
- interface HarnesslayerStateModel {
419
- id: string;
420
- appId: string;
421
- profileId: string;
422
- version: number;
423
- baseVersionId: string | null;
424
- baseStateId: string | null;
425
- storageUrl: string;
426
- downloadUrl: string;
427
- map: Record<string, HashMapItem> | null;
428
- metadata: JsonObject | null;
429
- status: string | null;
430
- snapshotStorageUrl: string | null;
431
- sandboxId: string | null;
432
- createdAt: Date;
433
- updatedAt: Date;
434
- }
435
- interface HarnesslayerVersionModel {
436
- id: string;
437
- appId: string;
438
- version: number;
439
- storageUrl: string;
440
- downloadUrl: string;
441
- map: Record<string, HashMapItem> | null;
442
- metadata: JsonObject | null;
443
- createdAt: Date;
444
- updatedAt: Date;
445
- }
446
- interface HarnesslayerSyncModel {
447
- id: string;
448
- appId: string;
449
- versionId: string;
450
- status: SyncStatus;
451
- dispatchingChunks: boolean;
452
- totalChunks: number;
453
- pendingChunks: number;
454
- failedChunks: number;
455
- profilesExpected: number;
456
- profilesTotal: number;
457
- profilesMerged: number;
458
- profilesSkipped: number;
459
- profilesConflicted: number;
460
- error: string | null;
461
- createdAt: Date;
462
- updatedAt: Date;
463
- }
464
- interface HarnesslayerWebhookModel {
465
- id: string;
466
- appId: string;
467
- event: WebhookEvent;
468
- method: WebhookMethod;
469
- url: string;
470
- runCount: number;
471
- headers: Record<string, string> | null;
472
- lastTriggeredAt: Date | null;
473
- createdAt: Date;
474
- updatedAt: Date;
475
- }
476
- interface HashMapItem {
477
- id: string;
478
- hash: string;
479
- }
480
- interface ChannelRunOptions {
481
- userId: string;
482
- sessionId?: string | null;
483
- input?: string;
484
- images?: JsonObject[];
485
- }
486
- type CloneTransformValue = JsonObject | string;
487
- type CloneTransform = Record<string, CloneTransformValue>;
488
-
489
- declare class HarnesslayerApp extends ResourceBase {
490
- init(slug: string, options: {
491
- type: ApplicationType;
492
- versionPath: string;
493
- name?: string;
494
- limit?: AppInitLimit;
495
- credentials?: AppInitCredential[];
496
- }): Promise<HarnesslayerAppModel>;
497
- retrieve(options: {
498
- appId?: string;
499
- slug?: string;
500
- }): Promise<HarnesslayerAppModel | null>;
501
- delete(appId: string): Promise<boolean>;
502
- channel(appId: string): HarnesslayerChannel;
503
- instance(appId: string): HarnesslayerInstance;
504
- accessGroup(appId: string): HarnesslayerAccessGroup;
505
- profile(appId: string): HarnesslayerProfile;
506
- conflict(appId: string): HarnesslayerConflict;
507
- private buildAppModel;
508
- }
509
-
510
- declare class HarnesslayerOrganization extends ResourceBase {
511
- create(name: string, options: {
512
- slug: string;
513
- }): Promise<HarnesslayerOrganizationModel>;
514
- init(name: string, options: {
515
- slug: string;
516
- returnIfExist?: boolean;
517
- return_if_exist?: boolean;
518
- }): Promise<HarnesslayerOrganizationModel>;
519
- update(organizationId: string, options: {
520
- name?: string;
521
- slug?: string;
522
- }): Promise<HarnesslayerOrganizationModel>;
523
- }
524
-
525
- declare class HarnesslayerResponse extends ResourceBase {
526
- stop(instanceId: string): Promise<Record<string, unknown>>;
527
- }
528
-
529
- interface HarnesslayerOptions {
530
- apiKey: string;
531
- version?: ApiVersion;
532
- timeoutMs?: number;
533
- timeout?: number;
534
- fetch?: FetchLike;
535
- baseUrl?: string;
536
- driftstoneBaseUrl?: string;
537
- }
538
- declare class Harnesslayer {
539
- readonly apiKey: string;
540
- readonly apiVersion: ApiVersion;
541
- readonly timeoutMs: number;
542
- readonly baseUrl: string;
543
- readonly driftstone: DriftstoneClient;
544
- private readonly transport;
545
- constructor(options: HarnesslayerOptions);
546
- constructor(apiKey: string, options?: Omit<HarnesslayerOptions, "apiKey">);
547
- request<T extends Record<string, unknown> = Record<string, unknown>>(method: Method, path: string, payload?: Record<string, unknown>): Promise<T>;
548
- get app(): HarnesslayerApp;
549
- get organization(): HarnesslayerOrganization;
550
- get response(): HarnesslayerResponse;
551
- }
552
-
553
- declare class HarnesslayerError extends Error {
554
- name: string;
555
- }
556
- declare class HarnesslayerHTTPError extends HarnesslayerError {
557
- name: string;
558
- }
559
- declare class HarnesslayerResponseError extends HarnesslayerError {
560
- name: string;
561
- }
562
- declare class HarnesslayerAPIError extends HarnesslayerError {
563
- name: string;
564
- }
565
- declare class DriftstoneError extends Error {
566
- name: string;
567
- }
568
- declare class DriftstoneHTTPError extends DriftstoneError {
569
- name: string;
570
- }
571
- declare class DriftstoneResponseError extends DriftstoneError {
572
- name: string;
573
- }
574
- declare class DriftstoneAPIError extends DriftstoneError {
575
- name: string;
576
- }
577
-
578
- export { type AccessGroupLimitReset, type ApiVersion, type AppInitCredential, type AppInitCredentialMCPOAuth, type AppInitCredentialMCPOAuthBasicParam, type AppInitCredentialMCPOAuthNoneParam, type AppInitCredentialMCPOAuthPostParam, type AppInitCredentialMCPOAuthRefresh, type AppInitCredentialMCPStaticBearer, type AppInitLimit, type ApplicationType, type ChannelAPIWebhook, type ChannelIMessageData, type ChannelRunOptions, type ChannelType, type CloneTransform, type CloneTransformValue, type ConflictReason, DriftstoneAPIError, DriftstoneError, DriftstoneHTTPError, DriftstoneResponseError, Harnesslayer, HarnesslayerAPIError, HarnesslayerAccessGroup, type HarnesslayerAccessGroupModel, HarnesslayerApp, type HarnesslayerAppModel, HarnesslayerChannel, type HarnesslayerChannelModel, HarnesslayerConflict, type HarnesslayerConflictModel, HarnesslayerError, HarnesslayerHTTPError, type HarnesslayerHistoryModel, HarnesslayerInstance, type HarnesslayerInstanceModel, type HarnesslayerMessageModel, type HarnesslayerOptions, HarnesslayerOrganization, type HarnesslayerOrganizationModel, HarnesslayerProfile, type HarnesslayerProfileModel, HarnesslayerResponse, HarnesslayerResponseError, HarnesslayerSession, type HarnesslayerSessionModel, HarnesslayerState, type HarnesslayerStateModel, type HarnesslayerSyncModel, HarnesslayerVersion, type HarnesslayerVersionModel, type HarnesslayerWebhookModel, type HashMapItem, type InstanceStatus, type JsonObject, type MessageType, type ResponseRunStreamEvent, type SessionType, type SyncStatus, type SyncStrategy, type WebhookEvent, type WebhookMethod, Harnesslayer as default };