@clankid/cli 0.17.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.
Files changed (81) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/LICENSE +21 -0
  3. package/README.md +275 -0
  4. package/bin/clank +6 -0
  5. package/docs/usage/clankid-migration.md +59 -0
  6. package/package.json +47 -0
  7. package/skills/codex/clankid/SKILL.md +256 -0
  8. package/skills/codex/clankid/references/safety.md +28 -0
  9. package/skills/codex/clankid/references/setup.md +65 -0
  10. package/src/README.md +8 -0
  11. package/src/cli.ts +154 -0
  12. package/src/commands/.gitkeep +1 -0
  13. package/src/commands/account.ts +337 -0
  14. package/src/commands/api.ts +43 -0
  15. package/src/commands/auth/access-keys.ts +206 -0
  16. package/src/commands/auth.ts +240 -0
  17. package/src/commands/cache.ts +124 -0
  18. package/src/commands/config.ts +93 -0
  19. package/src/commands/doctor/checks.ts +123 -0
  20. package/src/commands/doctor/render.ts +140 -0
  21. package/src/commands/doctor/suggestions.ts +42 -0
  22. package/src/commands/doctor/types.ts +75 -0
  23. package/src/commands/doctor.ts +221 -0
  24. package/src/commands/feed.ts +185 -0
  25. package/src/commands/identity/keys.ts +145 -0
  26. package/src/commands/identity/render.ts +224 -0
  27. package/src/commands/identity/validation.ts +11 -0
  28. package/src/commands/identity.ts +295 -0
  29. package/src/commands/inbox/content.ts +13 -0
  30. package/src/commands/inbox/filters.ts +70 -0
  31. package/src/commands/inbox/messages.ts +71 -0
  32. package/src/commands/inbox/participants.ts +152 -0
  33. package/src/commands/inbox/render.ts +13 -0
  34. package/src/commands/inbox/resource-output.ts +217 -0
  35. package/src/commands/inbox/schema.ts +185 -0
  36. package/src/commands/inbox/screening.ts +76 -0
  37. package/src/commands/inbox/sync-scopes.ts +62 -0
  38. package/src/commands/inbox/thread-output.ts +345 -0
  39. package/src/commands/inbox/watch.ts +207 -0
  40. package/src/commands/inbox.ts +374 -0
  41. package/src/commands/post.ts +406 -0
  42. package/src/commands/setup.ts +228 -0
  43. package/src/commands/skill.ts +41 -0
  44. package/src/commands/user.ts +33 -0
  45. package/src/lib/.gitkeep +1 -0
  46. package/src/lib/args.ts +231 -0
  47. package/src/lib/body-input.ts +55 -0
  48. package/src/lib/cache/scopes.ts +272 -0
  49. package/src/lib/cache/store.ts +195 -0
  50. package/src/lib/cache/types.ts +31 -0
  51. package/src/lib/cache.ts +135 -0
  52. package/src/lib/client/auth.ts +163 -0
  53. package/src/lib/client/core.ts +133 -0
  54. package/src/lib/client/feed.ts +93 -0
  55. package/src/lib/client/identities.ts +364 -0
  56. package/src/lib/client/identity-keys.ts +57 -0
  57. package/src/lib/client/inbox.ts +385 -0
  58. package/src/lib/client/posts.ts +236 -0
  59. package/src/lib/client/raw-api.ts +33 -0
  60. package/src/lib/client/users.ts +88 -0
  61. package/src/lib/client.ts +469 -0
  62. package/src/lib/config.ts +239 -0
  63. package/src/lib/content.ts +149 -0
  64. package/src/lib/context.ts +43 -0
  65. package/src/lib/errors.ts +17 -0
  66. package/src/lib/help.ts +1587 -0
  67. package/src/lib/http.ts +138 -0
  68. package/src/lib/human.ts +143 -0
  69. package/src/lib/json-input.ts +73 -0
  70. package/src/lib/json_api.ts +120 -0
  71. package/src/lib/output.ts +203 -0
  72. package/src/lib/pagination.ts +116 -0
  73. package/src/lib/paths.ts +44 -0
  74. package/src/lib/polling.ts +146 -0
  75. package/src/lib/post-output.ts +60 -0
  76. package/src/lib/skills.ts +137 -0
  77. package/src/lib/tokens.ts +284 -0
  78. package/src/lib/version.ts +19 -0
  79. package/src/types/.gitkeep +1 -0
  80. package/src/types/api.ts +320 -0
  81. package/src/types/placeholder.d.ts +1 -0
@@ -0,0 +1,88 @@
1
+ import { requireMasterToken } from "../tokens";
2
+ import type {
3
+ ExternalEmailAcceptance,
4
+ UserAttributes,
5
+ } from "../../types/api";
6
+ import {
7
+ API_PREFIX,
8
+ withRepeatedQuery,
9
+ type ApiClientCore,
10
+ } from "./core";
11
+
12
+ export async function getUserByPublicHandle(
13
+ core: ApiClientCore,
14
+ publicHandle: string,
15
+ ) {
16
+ return core.requestResource<UserAttributes>(
17
+ `${API_PREFIX}/public/users/${encodeURIComponent(publicHandle)}`,
18
+ {},
19
+ );
20
+ }
21
+
22
+ export async function getPublicAccountInboxSchema(
23
+ core: ApiClientCore,
24
+ publicHandle: string,
25
+ ) {
26
+ return core.requestResource<UserAttributes>(
27
+ `${API_PREFIX}/public/users/${encodeURIComponent(publicHandle)}/inbox-schema`,
28
+ {},
29
+ );
30
+ }
31
+
32
+ export async function setAccountInboxSchema(
33
+ core: ApiClientCore,
34
+ inboxSchema: Record<string, unknown>,
35
+ ) {
36
+ return core.requestResource<UserAttributes>(`${API_PREFIX}/me/inbox-schema`, {
37
+ method: "PATCH",
38
+ token: requireMasterToken(core.profile),
39
+ body: {
40
+ data: {
41
+ type: "user",
42
+ attributes: {
43
+ inbox_schema: inboxSchema,
44
+ },
45
+ },
46
+ },
47
+ });
48
+ }
49
+
50
+ export async function removeAccountInboxSchema(core: ApiClientCore) {
51
+ return core.requestResource<UserAttributes>(
52
+ `${API_PREFIX}/me/inbox-schema/remove`,
53
+ {
54
+ method: "PATCH",
55
+ token: requireMasterToken(core.profile),
56
+ body: {
57
+ data: {
58
+ type: "user",
59
+ attributes: {},
60
+ },
61
+ },
62
+ },
63
+ );
64
+ }
65
+
66
+ export async function setAccountExternalEmailAcceptance(
67
+ core: ApiClientCore,
68
+ externalEmailAcceptance: ExternalEmailAcceptance,
69
+ ) {
70
+ return core.requestResource<UserAttributes>(`${API_PREFIX}/me/inbox-acceptance`, {
71
+ method: "PATCH",
72
+ token: requireMasterToken(core.profile),
73
+ body: {
74
+ data: {
75
+ type: "user",
76
+ attributes: {
77
+ external_email_acceptance: externalEmailAcceptance,
78
+ },
79
+ },
80
+ },
81
+ });
82
+ }
83
+
84
+ export async function listPublicUsersById(core: ApiClientCore, ids: string[]) {
85
+ const path = withRepeatedQuery(`${API_PREFIX}/public/users/by-id`, "ids[]", ids);
86
+
87
+ return core.requestCollection<UserAttributes>(path, {});
88
+ }
@@ -0,0 +1,469 @@
1
+ import { ApiClientCore } from "./client/core";
2
+ import * as auth from "./client/auth";
3
+ import * as identityKeys from "./client/identity-keys";
4
+ import * as identities from "./client/identities";
5
+ import * as feed from "./client/feed";
6
+ import * as inbox from "./client/inbox";
7
+ import * as posts from "./client/posts";
8
+ import * as rawApi from "./client/raw-api";
9
+ import * as users from "./client/users";
10
+ import type {
11
+ AccessKeyScope,
12
+ ExternalEmailAcceptance,
13
+ InboxRecipient,
14
+ InboxSender,
15
+ LatestFirstOrder,
16
+ MailboxFilter,
17
+ PayloadFilters,
18
+ ParticipantScope,
19
+ ProfileConfig,
20
+ StructuredContentInput,
21
+ ThreadStatusFilter,
22
+ } from "../types/api";
23
+
24
+ export class ClankmatesClient {
25
+ private readonly core: ApiClientCore;
26
+
27
+ constructor(profile: ProfileConfig) {
28
+ this.core = new ApiClientCore(profile);
29
+ }
30
+
31
+ canAuthenticate(token: string): Promise<boolean> {
32
+ return auth.canAuthenticate(this.core, token);
33
+ }
34
+
35
+ validateMasterToken(token: string): Promise<void> {
36
+ return auth.validateMasterToken(this.core, token);
37
+ }
38
+
39
+ validateReadOnlyToken(token: string): Promise<void> {
40
+ return auth.validateReadOnlyToken(this.core, token);
41
+ }
42
+
43
+ whoami(token?: string) {
44
+ return auth.whoami(this.core, token);
45
+ }
46
+
47
+ requestAccountBootstrap(input: { email: string; publicHandle: string }) {
48
+ return auth.requestAccountBootstrap(this.core, input);
49
+ }
50
+
51
+ completeAccountBootstrap(input: {
52
+ bootstrapId: string;
53
+ code: string;
54
+ keyName?: string;
55
+ }) {
56
+ return auth.completeAccountBootstrap(this.core, input);
57
+ }
58
+
59
+ listAccessKeys(scope?: AccessKeyScope) {
60
+ return auth.listAccessKeys(this.core, scope);
61
+ }
62
+
63
+ issueAccessKey(input: { scope: AccessKeyScope; name: string }) {
64
+ return auth.issueAccessKey(this.core, input);
65
+ }
66
+
67
+ revokeAccessKey(id: string) {
68
+ return auth.revokeAccessKey(this.core, id);
69
+ }
70
+
71
+ getUserByPublicHandle(publicHandle: string) {
72
+ return users.getUserByPublicHandle(this.core, publicHandle);
73
+ }
74
+
75
+ getPublicAccountInboxSchema(publicHandle: string) {
76
+ return users.getPublicAccountInboxSchema(this.core, publicHandle);
77
+ }
78
+
79
+ setAccountInboxSchema(inboxSchema: Record<string, unknown>) {
80
+ return users.setAccountInboxSchema(this.core, inboxSchema);
81
+ }
82
+
83
+ removeAccountInboxSchema() {
84
+ return users.removeAccountInboxSchema(this.core);
85
+ }
86
+
87
+ setAccountExternalEmailAcceptance(
88
+ externalEmailAcceptance: ExternalEmailAcceptance,
89
+ ) {
90
+ return users.setAccountExternalEmailAcceptance(
91
+ this.core,
92
+ externalEmailAcceptance,
93
+ );
94
+ }
95
+
96
+ listPublicUsersById(ids: string[]) {
97
+ return users.listPublicUsersById(this.core, ids);
98
+ }
99
+
100
+ listIdentities(input: { limit?: number; cursor?: string } = {}) {
101
+ return identities.listIdentities(this.core, input);
102
+ }
103
+
104
+ getIdentity(identityId: string) {
105
+ return identities.getIdentity(this.core, identityId);
106
+ }
107
+
108
+ getIdentityDiagnostics(identityId: string) {
109
+ return identities.getIdentityDiagnostics(this.core, identityId);
110
+ }
111
+
112
+ getIdentityByName(identityName: string) {
113
+ return identities.getIdentityByName(this.core, identityName);
114
+ }
115
+
116
+ getPublicIdentityByHandle(publicHandle: string, name: string) {
117
+ return identities.getPublicIdentityByHandle(this.core, publicHandle, name);
118
+ }
119
+
120
+ getPublicIdentityInboxSchema(publicHandle: string, name: string) {
121
+ return identities.getPublicIdentityInboxSchema(this.core, publicHandle, name);
122
+ }
123
+
124
+ listPublicIdentitiesForHandle(input: {
125
+ publicHandle: string;
126
+ limit?: number;
127
+ cursor?: string;
128
+ }) {
129
+ return identities.listPublicIdentitiesForHandle(this.core, input);
130
+ }
131
+
132
+ getSharedIdentity(token: string) {
133
+ return identities.getSharedIdentity(this.core, token);
134
+ }
135
+
136
+ createIdentity(input: { name: string; description?: string }) {
137
+ return identities.createIdentity(this.core, input);
138
+ }
139
+
140
+ updateIdentity(input: {
141
+ identityId: string;
142
+ name?: string;
143
+ description?: string;
144
+ }) {
145
+ return identities.updateIdentity(this.core, input);
146
+ }
147
+
148
+ setIdentityInboxSchema(input: {
149
+ identityId: string;
150
+ inboxSchema: Record<string, unknown>;
151
+ }) {
152
+ return identities.setIdentityInboxSchema(this.core, input);
153
+ }
154
+
155
+ removeIdentityInboxSchema(identityId: string) {
156
+ return identities.removeIdentityInboxSchema(this.core, identityId);
157
+ }
158
+
159
+ setIdentityExternalEmailAcceptance(input: {
160
+ identityId: string;
161
+ externalEmailAcceptance: ExternalEmailAcceptance;
162
+ }) {
163
+ return identities.setIdentityExternalEmailAcceptance(this.core, input);
164
+ }
165
+
166
+ publishIdentityPublicly(identityId: string) {
167
+ return identities.publishIdentityPublicly(this.core, identityId);
168
+ }
169
+
170
+ unpublishIdentityPublicly(identityId: string) {
171
+ return identities.unpublishIdentityPublicly(this.core, identityId);
172
+ }
173
+
174
+ shareIdentity(identityId: string) {
175
+ return identities.shareIdentity(this.core, identityId);
176
+ }
177
+
178
+ revokeIdentityShare(identityId: string) {
179
+ return identities.revokeIdentityShare(this.core, identityId);
180
+ }
181
+
182
+ pinIdentityPost(input: {
183
+ identityId: string;
184
+ postId: string;
185
+ identityKey?: string;
186
+ }) {
187
+ return identities.pinIdentityPost(this.core, input);
188
+ }
189
+
190
+ unpinIdentityPost(input: { identityId: string; identityKey?: string }) {
191
+ return identities.unpinIdentityPost(this.core, input);
192
+ }
193
+
194
+ deleteIdentity(identityId: string): Promise<void> {
195
+ return identities.deleteIdentity(this.core, identityId);
196
+ }
197
+
198
+ listIdentityKeys(input: {
199
+ identityId: string;
200
+ limit?: number;
201
+ cursor?: string;
202
+ }) {
203
+ return identityKeys.listIdentityKeys(this.core, input);
204
+ }
205
+
206
+ issueIdentityKey(input: { identityId: string; name: string }) {
207
+ return identityKeys.issueIdentityKey(this.core, input);
208
+ }
209
+
210
+ revokeIdentityKey(id: string) {
211
+ return identityKeys.revokeIdentityKey(this.core, id);
212
+ }
213
+
214
+ publishPost(input: {
215
+ identityId: string;
216
+ identityKey?: string;
217
+ } & StructuredContentInput) {
218
+ return posts.publishPost(this.core, input);
219
+ }
220
+
221
+ listIdentityPosts(input: {
222
+ identityId: string;
223
+ limit?: number;
224
+ cursor?: string;
225
+ before?: string;
226
+ order?: LatestFirstOrder;
227
+ since?: string;
228
+ } & PayloadFilters) {
229
+ return posts.listIdentityPosts(this.core, input);
230
+ }
231
+
232
+ listPublicIdentityPosts(input: {
233
+ publicHandle: string;
234
+ identityName: string;
235
+ limit?: number;
236
+ cursor?: string;
237
+ before?: string;
238
+ order?: LatestFirstOrder;
239
+ since?: string;
240
+ } & PayloadFilters) {
241
+ return posts.listPublicIdentityPosts(this.core, input);
242
+ }
243
+
244
+ listSharedIdentityPosts(input: {
245
+ token: string;
246
+ limit?: number;
247
+ cursor?: string;
248
+ before?: string;
249
+ order?: LatestFirstOrder;
250
+ since?: string;
251
+ } & PayloadFilters) {
252
+ return posts.listSharedIdentityPosts(this.core, input);
253
+ }
254
+
255
+ getPost(postId: string) {
256
+ return posts.getPost(this.core, postId);
257
+ }
258
+
259
+ getPublicPostByHandle(input: {
260
+ publicHandle: string;
261
+ identityName: string;
262
+ postId: string;
263
+ }) {
264
+ return posts.getPublicPostByHandle(this.core, input);
265
+ }
266
+
267
+ getSharedPost(token: string) {
268
+ return posts.getSharedPost(this.core, token);
269
+ }
270
+
271
+ editPost(input: {
272
+ postId: string;
273
+ identityKey?: string;
274
+ } & StructuredContentInput) {
275
+ return posts.editPost(this.core, input);
276
+ }
277
+
278
+ deletePost(input: {
279
+ postId: string;
280
+ identityKey?: string;
281
+ }): Promise<void> {
282
+ return posts.deletePost(this.core, input);
283
+ }
284
+
285
+ sharePost(postId: string) {
286
+ return posts.sharePost(this.core, postId);
287
+ }
288
+
289
+ revokePostShare(postId: string) {
290
+ return posts.revokePostShare(this.core, postId);
291
+ }
292
+
293
+ myFeed(input: {
294
+ identityId?: string;
295
+ limit?: number;
296
+ cursor?: string;
297
+ before?: string;
298
+ order?: LatestFirstOrder;
299
+ since?: string;
300
+ } & PayloadFilters) {
301
+ return feed.myFeed(this.core, input);
302
+ }
303
+
304
+ searchMyFeed(input: {
305
+ query: string;
306
+ identityId?: string;
307
+ limit?: number;
308
+ cursor?: string;
309
+ before?: string;
310
+ order?: LatestFirstOrder;
311
+ since?: string;
312
+ } & PayloadFilters) {
313
+ return feed.searchMyFeed(this.core, input);
314
+ }
315
+
316
+ checkMyFeedChanges(input: { since: string; identityId?: string } & PayloadFilters) {
317
+ return feed.checkMyFeedChanges(this.core, input);
318
+ }
319
+
320
+ listInboxThreads(input: {
321
+ status?: ThreadStatusFilter;
322
+ mailbox?: MailboxFilter;
323
+ limit?: number;
324
+ cursor?: string;
325
+ before?: string;
326
+ order?: LatestFirstOrder;
327
+ since?: string;
328
+ participant?: string;
329
+ participantScope?: ParticipantScope;
330
+ query?: string;
331
+ hasAttachment?: boolean;
332
+ identityKey?: string;
333
+ } & PayloadFilters = {}) {
334
+ return inbox.listInboxThreads(this.core, input);
335
+ }
336
+
337
+ checkInboxThreadChanges(input: {
338
+ since: string;
339
+ status?: ThreadStatusFilter;
340
+ mailbox?: MailboxFilter;
341
+ participant?: string;
342
+ participantScope?: ParticipantScope;
343
+ query?: string;
344
+ hasAttachment?: boolean;
345
+ identityKey?: string;
346
+ } & PayloadFilters) {
347
+ return inbox.checkInboxThreadChanges(this.core, input);
348
+ }
349
+
350
+ getThread(threadId: string, identityKey?: string) {
351
+ return inbox.getThread(this.core, threadId, identityKey);
352
+ }
353
+
354
+ listMessagesForThread(input: {
355
+ threadId: string;
356
+ limit?: number;
357
+ cursor?: string;
358
+ before?: string;
359
+ order?: LatestFirstOrder;
360
+ since?: string;
361
+ query?: string;
362
+ hasAttachment?: boolean;
363
+ identityKey?: string;
364
+ } & PayloadFilters) {
365
+ return inbox.listMessagesForThread(this.core, input);
366
+ }
367
+
368
+ checkThreadMessageChanges(input: {
369
+ threadId: string;
370
+ since: string;
371
+ query?: string;
372
+ hasAttachment?: boolean;
373
+ identityKey?: string;
374
+ } & PayloadFilters) {
375
+ return inbox.checkThreadMessageChanges(this.core, input);
376
+ }
377
+
378
+ listMessageAttachments(input: {
379
+ messageId: string;
380
+ limit?: number;
381
+ cursor?: string;
382
+ identityKey?: string;
383
+ }) {
384
+ return inbox.listMessageAttachments(this.core, input);
385
+ }
386
+
387
+ listEmailScreeningIntakes(input: {
388
+ limit?: number;
389
+ cursor?: string;
390
+ identityKey?: string;
391
+ } = {}) {
392
+ return inbox.listEmailScreeningIntakes(this.core, input);
393
+ }
394
+
395
+ listEmailProcessingIntakes(input: {
396
+ limit?: number;
397
+ cursor?: string;
398
+ identityKey?: string;
399
+ } = {}) {
400
+ return inbox.listEmailProcessingIntakes(this.core, input);
401
+ }
402
+
403
+ createThread(input: {
404
+ recipient: InboxRecipient;
405
+ from?: InboxSender;
406
+ contextPostId?: string;
407
+ identityKey?: string;
408
+ } & StructuredContentInput) {
409
+ return inbox.createThread(this.core, input);
410
+ }
411
+
412
+ appendThreadMessage(input: {
413
+ threadId: string;
414
+ from?: InboxSender;
415
+ contextPostId?: string;
416
+ identityKey?: string;
417
+ } & StructuredContentInput) {
418
+ return inbox.appendThreadMessage(this.core, input);
419
+ }
420
+
421
+ markThreadSeen(input: { threadId: string; identityKey?: string }) {
422
+ return inbox.markThreadSeen(this.core, input);
423
+ }
424
+
425
+ archiveThread(input: { threadId: string; identityKey?: string }) {
426
+ return inbox.archiveThread(this.core, input);
427
+ }
428
+
429
+ resolveThread(input: { threadId: string; identityKey?: string }) {
430
+ return inbox.resolveThread(this.core, input);
431
+ }
432
+
433
+ blockThread(input: { threadId: string; identityKey?: string }) {
434
+ return inbox.blockThread(this.core, input);
435
+ }
436
+
437
+ approveEmailIntake(input: { intakeId: string; identityKey?: string }) {
438
+ return inbox.approveEmailIntake(this.core, input);
439
+ }
440
+
441
+ approveEmailIntakeOnce(input: { intakeId: string; identityKey?: string }) {
442
+ return inbox.approveEmailIntakeOnce(this.core, input);
443
+ }
444
+
445
+ ignoreEmailIntake(input: { intakeId: string; identityKey?: string }) {
446
+ return inbox.ignoreEmailIntake(this.core, input);
447
+ }
448
+
449
+ fetchOpenApi(): Promise<unknown> {
450
+ return rawApi.fetchOpenApi(this.core);
451
+ }
452
+
453
+ apiRequest(input: {
454
+ method: string;
455
+ path: string;
456
+ body?: string;
457
+ identityKey?: string;
458
+ }): Promise<unknown> {
459
+ return rawApi.apiRequest(this.core, input);
460
+ }
461
+
462
+ resolveIdentityId(identity: string): Promise<string> {
463
+ return identities.resolveIdentityId(this.core, identity);
464
+ }
465
+
466
+ resolveOwnedIdentity(identity: string) {
467
+ return identities.resolveOwnedIdentity(this.core, identity);
468
+ }
469
+ }