@faces-sh/cli 0.0.0-stage → 1.0.1

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 (290) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +158 -2
  3. package/bin/dev.js +5 -0
  4. package/bin/run.js +5 -0
  5. package/dist/base.d.ts +26 -0
  6. package/dist/base.js +181 -0
  7. package/dist/benchmark.d.ts +21 -0
  8. package/dist/benchmark.js +95 -0
  9. package/dist/billing.d.ts +17 -0
  10. package/dist/billing.js +101 -0
  11. package/dist/catalog.d.ts +35 -0
  12. package/dist/catalog.js +242 -0
  13. package/dist/client.d.ts +98 -0
  14. package/dist/client.js +590 -0
  15. package/dist/commands/account/preferences.d.ts +20 -0
  16. package/dist/commands/account/preferences.js +190 -0
  17. package/dist/commands/account/state.d.ts +11 -0
  18. package/dist/commands/account/state.js +24 -0
  19. package/dist/commands/auth/connect.d.ts +17 -0
  20. package/dist/commands/auth/connect.js +190 -0
  21. package/dist/commands/auth/connections.d.ts +12 -0
  22. package/dist/commands/auth/connections.js +40 -0
  23. package/dist/commands/auth/disconnect.d.ts +15 -0
  24. package/dist/commands/auth/disconnect.js +49 -0
  25. package/dist/commands/auth/login.d.ts +13 -0
  26. package/dist/commands/auth/login.js +42 -0
  27. package/dist/commands/auth/logout.d.ts +11 -0
  28. package/dist/commands/auth/logout.js +14 -0
  29. package/dist/commands/auth/refresh.d.ts +11 -0
  30. package/dist/commands/auth/refresh.js +30 -0
  31. package/dist/commands/auth/register.d.ts +15 -0
  32. package/dist/commands/auth/register.js +98 -0
  33. package/dist/commands/auth/whoami.d.ts +11 -0
  34. package/dist/commands/auth/whoami.js +108 -0
  35. package/dist/commands/benchmark/get.d.ts +16 -0
  36. package/dist/commands/benchmark/get.js +42 -0
  37. package/dist/commands/benchmark/list.d.ts +13 -0
  38. package/dist/commands/benchmark/list.js +47 -0
  39. package/dist/commands/benchmark/start.d.ts +22 -0
  40. package/dist/commands/benchmark/start.js +80 -0
  41. package/dist/commands/billing/balance.d.ts +11 -0
  42. package/dist/commands/billing/balance.js +27 -0
  43. package/dist/commands/billing/card/default.d.ts +15 -0
  44. package/dist/commands/billing/card/default.js +33 -0
  45. package/dist/commands/billing/card/remove.d.ts +16 -0
  46. package/dist/commands/billing/card/remove.js +41 -0
  47. package/dist/commands/billing/card-setup.d.ts +13 -0
  48. package/dist/commands/billing/card-setup.js +41 -0
  49. package/dist/commands/billing/cards.d.ts +11 -0
  50. package/dist/commands/billing/cards.js +34 -0
  51. package/dist/commands/billing/llm-costs.d.ts +14 -0
  52. package/dist/commands/billing/llm-costs.js +95 -0
  53. package/dist/commands/billing/subscription/activate.d.ts +14 -0
  54. package/dist/commands/billing/subscription/activate.js +91 -0
  55. package/dist/commands/billing/subscription/cancel.d.ts +12 -0
  56. package/dist/commands/billing/subscription/cancel.js +54 -0
  57. package/dist/commands/billing/subscription/index.d.ts +11 -0
  58. package/dist/commands/billing/subscription/index.js +46 -0
  59. package/dist/commands/billing/subscription/plan.d.ts +16 -0
  60. package/dist/commands/billing/subscription/plan.js +86 -0
  61. package/dist/commands/billing/topup.d.ts +16 -0
  62. package/dist/commands/billing/topup.js +60 -0
  63. package/dist/commands/billing/usage.d.ts +15 -0
  64. package/dist/commands/billing/usage.js +68 -0
  65. package/dist/commands/catalog/backup.d.ts +11 -0
  66. package/dist/commands/catalog/backup.js +169 -0
  67. package/dist/commands/catalog/doctor.d.ts +14 -0
  68. package/dist/commands/catalog/doctor.js +303 -0
  69. package/dist/commands/catalog/list.d.ts +11 -0
  70. package/dist/commands/catalog/list.js +39 -0
  71. package/dist/commands/catalog/restore.d.ts +17 -0
  72. package/dist/commands/catalog/restore.js +259 -0
  73. package/dist/commands/causes.d.ts +27 -0
  74. package/dist/commands/causes.js +135 -0
  75. package/dist/commands/chat/chat.d.ts +42 -0
  76. package/dist/commands/chat/chat.js +363 -0
  77. package/dist/commands/chat/messages.d.ts +26 -0
  78. package/dist/commands/chat/messages.js +139 -0
  79. package/dist/commands/chat/responses.d.ts +27 -0
  80. package/dist/commands/chat/responses.js +150 -0
  81. package/dist/commands/chat/thread.d.ts +43 -0
  82. package/dist/commands/chat/thread.js +458 -0
  83. package/dist/commands/compile/all.d.ts +14 -0
  84. package/dist/commands/compile/all.js +186 -0
  85. package/dist/commands/compile/doc/create.d.ts +19 -0
  86. package/dist/commands/compile/doc/create.js +58 -0
  87. package/dist/commands/compile/doc/delete.d.ts +15 -0
  88. package/dist/commands/compile/doc/delete.js +33 -0
  89. package/dist/commands/compile/doc/edit.d.ts +19 -0
  90. package/dist/commands/compile/doc/edit.js +59 -0
  91. package/dist/commands/compile/doc/get.d.ts +15 -0
  92. package/dist/commands/compile/doc/get.js +43 -0
  93. package/dist/commands/compile/doc/index.d.ts +24 -0
  94. package/dist/commands/compile/doc/index.js +211 -0
  95. package/dist/commands/compile/doc/list.d.ts +15 -0
  96. package/dist/commands/compile/doc/list.js +46 -0
  97. package/dist/commands/compile/doc/make.d.ts +17 -0
  98. package/dist/commands/compile/doc/make.js +95 -0
  99. package/dist/commands/compile/doc/pause.d.ts +17 -0
  100. package/dist/commands/compile/doc/pause.js +74 -0
  101. package/dist/commands/compile/doc/reset.d.ts +15 -0
  102. package/dist/commands/compile/doc/reset.js +33 -0
  103. package/dist/commands/compile/import.d.ts +20 -0
  104. package/dist/commands/compile/import.js +138 -0
  105. package/dist/commands/compile/stats.d.ts +11 -0
  106. package/dist/commands/compile/stats.js +75 -0
  107. package/dist/commands/compile/status.d.ts +17 -0
  108. package/dist/commands/compile/status.js +110 -0
  109. package/dist/commands/compile/thread/create.d.ts +16 -0
  110. package/dist/commands/compile/thread/create.js +42 -0
  111. package/dist/commands/compile/thread/delete.d.ts +15 -0
  112. package/dist/commands/compile/thread/delete.js +33 -0
  113. package/dist/commands/compile/thread/edit.d.ts +19 -0
  114. package/dist/commands/compile/thread/edit.js +120 -0
  115. package/dist/commands/compile/thread/get.d.ts +15 -0
  116. package/dist/commands/compile/thread/get.js +48 -0
  117. package/dist/commands/compile/thread/list.d.ts +14 -0
  118. package/dist/commands/compile/thread/list.js +38 -0
  119. package/dist/commands/compile/thread/make.d.ts +17 -0
  120. package/dist/commands/compile/thread/make.js +87 -0
  121. package/dist/commands/compile/thread/message.d.ts +16 -0
  122. package/dist/commands/compile/thread/message.js +43 -0
  123. package/dist/commands/compile/thread/pause.d.ts +17 -0
  124. package/dist/commands/compile/thread/pause.js +75 -0
  125. package/dist/commands/compile/thread/replace.d.ts +27 -0
  126. package/dist/commands/compile/thread/replace.js +114 -0
  127. package/dist/commands/compile/thread/reset.d.ts +15 -0
  128. package/dist/commands/compile/thread/reset.js +33 -0
  129. package/dist/commands/compile/upload.d.ts +21 -0
  130. package/dist/commands/compile/upload.js +162 -0
  131. package/dist/commands/config/clear.d.ts +12 -0
  132. package/dist/commands/config/clear.js +17 -0
  133. package/dist/commands/config/set.d.ts +15 -0
  134. package/dist/commands/config/set.js +43 -0
  135. package/dist/commands/config/show.d.ts +11 -0
  136. package/dist/commands/config/show.js +19 -0
  137. package/dist/commands/decide.d.ts +35 -0
  138. package/dist/commands/decide.js +242 -0
  139. package/dist/commands/face/attributes.d.ts +11 -0
  140. package/dist/commands/face/attributes.js +44 -0
  141. package/dist/commands/face/avatar/delete.d.ts +15 -0
  142. package/dist/commands/face/avatar/delete.js +38 -0
  143. package/dist/commands/face/avatar/get.d.ts +20 -0
  144. package/dist/commands/face/avatar/get.js +100 -0
  145. package/dist/commands/face/avatar/list.d.ts +14 -0
  146. package/dist/commands/face/avatar/list.js +56 -0
  147. package/dist/commands/face/avatar/make.d.ts +16 -0
  148. package/dist/commands/face/avatar/make.js +64 -0
  149. package/dist/commands/face/avatar/upload.d.ts +15 -0
  150. package/dist/commands/face/avatar/upload.js +67 -0
  151. package/dist/commands/face/create.d.ts +23 -0
  152. package/dist/commands/face/create.js +122 -0
  153. package/dist/commands/face/delete.d.ts +15 -0
  154. package/dist/commands/face/delete.js +39 -0
  155. package/dist/commands/face/diff.d.ts +12 -0
  156. package/dist/commands/face/diff.js +50 -0
  157. package/dist/commands/face/edit.d.ts +25 -0
  158. package/dist/commands/face/edit.js +155 -0
  159. package/dist/commands/face/get.d.ts +16 -0
  160. package/dist/commands/face/get.js +145 -0
  161. package/dist/commands/face/groups.d.ts +15 -0
  162. package/dist/commands/face/groups.js +34 -0
  163. package/dist/commands/face/list.d.ts +23 -0
  164. package/dist/commands/face/list.js +168 -0
  165. package/dist/commands/face/lock.d.ts +15 -0
  166. package/dist/commands/face/lock.js +35 -0
  167. package/dist/commands/face/neighbors.d.ts +16 -0
  168. package/dist/commands/face/neighbors.js +63 -0
  169. package/dist/commands/face/publish.d.ts +16 -0
  170. package/dist/commands/face/publish.js +43 -0
  171. package/dist/commands/face/share.d.ts +22 -0
  172. package/dist/commands/face/share.js +104 -0
  173. package/dist/commands/face/sources.d.ts +21 -0
  174. package/dist/commands/face/sources.js +169 -0
  175. package/dist/commands/face/stats.d.ts +12 -0
  176. package/dist/commands/face/stats.js +46 -0
  177. package/dist/commands/face/tag/add.d.ts +15 -0
  178. package/dist/commands/face/tag/add.js +40 -0
  179. package/dist/commands/face/tag/all.d.ts +11 -0
  180. package/dist/commands/face/tag/all.js +31 -0
  181. package/dist/commands/face/tag/list.d.ts +14 -0
  182. package/dist/commands/face/tag/list.js +36 -0
  183. package/dist/commands/face/tag/remove.d.ts +16 -0
  184. package/dist/commands/face/tag/remove.js +44 -0
  185. package/dist/commands/face/tag/set.d.ts +15 -0
  186. package/dist/commands/face/tag/set.js +40 -0
  187. package/dist/commands/face/unlock.d.ts +15 -0
  188. package/dist/commands/face/unlock.js +35 -0
  189. package/dist/commands/face/unpublish.d.ts +14 -0
  190. package/dist/commands/face/unpublish.js +32 -0
  191. package/dist/commands/face/unshare.d.ts +18 -0
  192. package/dist/commands/face/unshare.js +66 -0
  193. package/dist/commands/fidelity/get.d.ts +15 -0
  194. package/dist/commands/fidelity/get.js +42 -0
  195. package/dist/commands/fidelity/pick.d.ts +19 -0
  196. package/dist/commands/fidelity/pick.js +70 -0
  197. package/dist/commands/fidelity/run.d.ts +20 -0
  198. package/dist/commands/fidelity/run.js +99 -0
  199. package/dist/commands/fidelity/save-thread.d.ts +15 -0
  200. package/dist/commands/fidelity/save-thread.js +35 -0
  201. package/dist/commands/fidelity/start.d.ts +17 -0
  202. package/dist/commands/fidelity/start.js +56 -0
  203. package/dist/commands/fidelity/turn.d.ts +17 -0
  204. package/dist/commands/fidelity/turn.js +48 -0
  205. package/dist/commands/group/add.d.ts +16 -0
  206. package/dist/commands/group/add.js +83 -0
  207. package/dist/commands/group/create.d.ts +16 -0
  208. package/dist/commands/group/create.js +68 -0
  209. package/dist/commands/group/delete.d.ts +15 -0
  210. package/dist/commands/group/delete.js +39 -0
  211. package/dist/commands/group/edit.d.ts +18 -0
  212. package/dist/commands/group/edit.js +75 -0
  213. package/dist/commands/group/get.d.ts +14 -0
  214. package/dist/commands/group/get.js +29 -0
  215. package/dist/commands/group/list.d.ts +11 -0
  216. package/dist/commands/group/list.js +39 -0
  217. package/dist/commands/group/members.d.ts +15 -0
  218. package/dist/commands/group/members.js +68 -0
  219. package/dist/commands/group/remove.d.ts +15 -0
  220. package/dist/commands/group/remove.js +55 -0
  221. package/dist/commands/group/tag/add.d.ts +15 -0
  222. package/dist/commands/group/tag/add.js +30 -0
  223. package/dist/commands/group/tag/list.d.ts +14 -0
  224. package/dist/commands/group/tag/list.js +36 -0
  225. package/dist/commands/group/tag/remove.d.ts +15 -0
  226. package/dist/commands/group/tag/remove.js +30 -0
  227. package/dist/commands/group/tag/set.d.ts +15 -0
  228. package/dist/commands/group/tag/set.js +30 -0
  229. package/dist/commands/keys/create.d.ts +17 -0
  230. package/dist/commands/keys/create.js +72 -0
  231. package/dist/commands/keys/list.d.ts +11 -0
  232. package/dist/commands/keys/list.js +24 -0
  233. package/dist/commands/keys/revoke.d.ts +15 -0
  234. package/dist/commands/keys/revoke.js +49 -0
  235. package/dist/commands/keys/update.d.ts +17 -0
  236. package/dist/commands/keys/update.js +41 -0
  237. package/dist/commands/models/list.d.ts +15 -0
  238. package/dist/commands/models/list.js +98 -0
  239. package/dist/commands/session/close.d.ts +16 -0
  240. package/dist/commands/session/close.js +36 -0
  241. package/dist/commands/session/compact.d.ts +15 -0
  242. package/dist/commands/session/compact.js +58 -0
  243. package/dist/commands/session/create.d.ts +15 -0
  244. package/dist/commands/session/create.js +45 -0
  245. package/dist/commands/session/get.d.ts +15 -0
  246. package/dist/commands/session/get.js +34 -0
  247. package/dist/commands/style/delete.d.ts +19 -0
  248. package/dist/commands/style/delete.js +94 -0
  249. package/dist/commands/style/make.d.ts +28 -0
  250. package/dist/commands/style/make.js +298 -0
  251. package/dist/commands/style/revert.d.ts +17 -0
  252. package/dist/commands/style/revert.js +66 -0
  253. package/dist/commands/style/status.d.ts +20 -0
  254. package/dist/commands/style/status.js +109 -0
  255. package/dist/commands/style/upload.d.ts +19 -0
  256. package/dist/commands/style/upload.js +100 -0
  257. package/dist/commands/style/versions.d.ts +15 -0
  258. package/dist/commands/style/versions.js +104 -0
  259. package/dist/commands/user/follow.d.ts +14 -0
  260. package/dist/commands/user/follow.js +38 -0
  261. package/dist/commands/user/followers.d.ts +14 -0
  262. package/dist/commands/user/followers.js +50 -0
  263. package/dist/commands/user/following.d.ts +14 -0
  264. package/dist/commands/user/following.js +50 -0
  265. package/dist/commands/user/get.d.ts +14 -0
  266. package/dist/commands/user/get.js +49 -0
  267. package/dist/commands/user/unfollow.d.ts +14 -0
  268. package/dist/commands/user/unfollow.js +38 -0
  269. package/dist/config.d.ts +32 -0
  270. package/dist/config.js +139 -0
  271. package/dist/decisions.d.ts +42 -0
  272. package/dist/decisions.js +262 -0
  273. package/dist/fidelity.d.ts +50 -0
  274. package/dist/fidelity.js +92 -0
  275. package/dist/group-catalog.d.ts +22 -0
  276. package/dist/group-catalog.js +133 -0
  277. package/dist/paths.d.ts +1 -0
  278. package/dist/paths.js +8 -0
  279. package/dist/poll.d.ts +26 -0
  280. package/dist/poll.js +75 -0
  281. package/dist/routing.d.ts +15 -0
  282. package/dist/routing.js +135 -0
  283. package/dist/session.d.ts +14 -0
  284. package/dist/session.js +18 -0
  285. package/dist/style.d.ts +46 -0
  286. package/dist/style.js +285 -0
  287. package/dist/utils.d.ts +149 -0
  288. package/dist/utils.js +865 -0
  289. package/oclif.manifest.json +11070 -0
  290. package/package.json +127 -4
@@ -0,0 +1,35 @@
1
+ import { Args } from '@oclif/core';
2
+ import { BaseCommand } from '../../base.js';
3
+ import { FacesAPIError } from '../../client.js';
4
+ import { fidelityError, fidelityPost } from '../../fidelity.js';
5
+ import { seg } from '../../utils.js';
6
+ export default class FidelitySaveThread extends BaseCommand {
7
+ static description = 'Save a finished fidelity run\'s conversation as a thread on the face, so it can be compiled. Each turn ' +
8
+ 'becomes your message and the reply you settled on: your correction where you made one, otherwise the ' +
9
+ 'answer you accepted. Saving again returns the same thread.';
10
+ static examples = ['<%= config.bin %> <%= command.id %> <run>'];
11
+ static flags = {
12
+ ...BaseCommand.baseFlags,
13
+ };
14
+ static args = {
15
+ run_id: Args.string({ description: 'Fidelity run id', required: true }),
16
+ };
17
+ async run() {
18
+ const { args, flags } = await this.parse(FidelitySaveThread);
19
+ const client = this.makeClient(flags);
20
+ let data;
21
+ try {
22
+ data = await fidelityPost(client, `/v1/fidelity/${seg(args.run_id)}/save-thread`, {});
23
+ }
24
+ catch (err) {
25
+ if (err instanceof FacesAPIError)
26
+ this.error(fidelityError(err, { run: args.run_id }));
27
+ throw err;
28
+ }
29
+ if (this.jsonEnabled())
30
+ return data;
31
+ this.log(`${data.created ? 'Saved as' : 'Already saved as'} thread ${data.thread_id}`);
32
+ this.log(`Compile it into the face: faces compile:thread:make ${data.thread_id}`);
33
+ return data;
34
+ }
35
+ }
@@ -0,0 +1,17 @@
1
+ import { BaseCommand } from '../../base.js';
2
+ export default class FidelityStart extends BaseCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ competitor: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ model: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ 'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ 'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
12
+ };
13
+ static args: {
14
+ alias: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
15
+ };
16
+ run(): Promise<unknown>;
17
+ }
@@ -0,0 +1,56 @@
1
+ import { Args, Flags } from '@oclif/core';
2
+ import { BaseCommand } from '../../base.js';
3
+ import { FacesAPIError } from '../../client.js';
4
+ import { fidelityError, fidelityPost, nextStep } from '../../fidelity.js';
5
+ import { seg, usd } from '../../utils.js';
6
+ export default class FidelityStart extends BaseCommand {
7
+ static description = 'Start a fidelity run on a face you own: ten blind turns, scored out of 10. Each turn you send a ' +
8
+ 'message, read two answers labelled a and b (one is the face, one a competitor model given the ' +
9
+ 'face\'s own writing), and pick the one that sounds more like the person, accepting it or correcting ' +
10
+ 'it. The picks must be the person\'s own: an agent shows both answers and passes on the choice it is ' +
11
+ 'given, never its own. The score is saved on the face, and a new run replaces it. On Connect or Pro ' +
12
+ 'with ChatGPT linked, answers from Codex-eligible models run on the ChatGPT plan; the rest, and grading ' +
13
+ 'a correction, is paid from credits. To play it in the terminal, use faces fidelity:run.';
14
+ static examples = [
15
+ '<%= config.bin %> <%= command.id %> alice',
16
+ '<%= config.bin %> <%= command.id %> alice --competitor <model>',
17
+ ];
18
+ static flags = {
19
+ ...BaseCommand.baseFlags,
20
+ competitor: Flags.string({
21
+ description: 'The chat model the face is compared with (default: the cheapest Codex-eligible chat model)',
22
+ }),
23
+ model: Flags.string({ description: 'The model the face answers on (default: its own default model)' }),
24
+ };
25
+ static args = {
26
+ alias: Args.string({ description: 'Alias of a face you own', required: true }),
27
+ };
28
+ async run() {
29
+ const { args, flags } = await this.parse(FidelityStart);
30
+ const client = this.makeClient(flags);
31
+ const body = {};
32
+ if (flags.competitor)
33
+ body.competitor = flags.competitor;
34
+ if (flags.model)
35
+ body.model = flags.model;
36
+ let run;
37
+ try {
38
+ run = (await fidelityPost(client, `/v1/faces/${seg(args.alias)}/fidelity`, body));
39
+ }
40
+ catch (err) {
41
+ if (err instanceof FacesAPIError)
42
+ this.error(fidelityError(err, { alias: args.alias }));
43
+ throw err;
44
+ }
45
+ if (this.jsonEnabled())
46
+ return run;
47
+ this.log(`run: ${run.run_id}`);
48
+ this.log(`face: ${run.alias ?? args.alias}`);
49
+ this.log(`competitor: ${run.competitor ?? '-'}`);
50
+ if (run.estimated_usd !== undefined)
51
+ this.log(`up to: ${usd(run.estimated_usd)} from credits`);
52
+ this.log('');
53
+ this.log(nextStep(run) ?? '');
54
+ return run;
55
+ }
56
+ }
@@ -0,0 +1,17 @@
1
+ import { BaseCommand } from '../../base.js';
2
+ export default class FidelityTurn extends BaseCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ message: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ file: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ 'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ 'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
12
+ };
13
+ static args: {
14
+ run_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
15
+ };
16
+ run(): Promise<unknown>;
17
+ }
@@ -0,0 +1,48 @@
1
+ import { Args, Flags } from '@oclif/core';
2
+ import fs from 'node:fs';
3
+ import { BaseCommand } from '../../base.js';
4
+ import { FacesAPIError } from '../../client.js';
5
+ import { answerLines, fidelityError, fidelityPost } from '../../fidelity.js';
6
+ import { seg } from '../../utils.js';
7
+ export default class FidelityTurn extends BaseCommand {
8
+ static description = 'Send the next turn\'s message on a fidelity run. Prints two answers, a and b, in random order, with ' +
9
+ 'nothing saying which is the face. Pick one with faces fidelity:pick before the next turn.';
10
+ static examples = ['<%= config.bin %> <%= command.id %> <run> -m "How was the trip?"'];
11
+ static flags = {
12
+ ...BaseCommand.baseFlags,
13
+ message: Flags.string({ char: 'm', description: 'Your message for this turn', exclusive: ['file'] }),
14
+ file: Flags.string({ description: 'Read the message from a file' }),
15
+ };
16
+ static args = {
17
+ run_id: Args.string({ description: 'Fidelity run id, from faces fidelity:start', required: true }),
18
+ };
19
+ async run() {
20
+ const { args, flags } = await this.parse(FidelityTurn);
21
+ const client = this.makeClient(flags);
22
+ let message = flags.message;
23
+ if (flags.file) {
24
+ if (!fs.existsSync(flags.file))
25
+ this.error(`File not found: ${flags.file}`);
26
+ message = fs.readFileSync(flags.file, 'utf8');
27
+ }
28
+ if (!message?.trim())
29
+ this.error('Give the message with -m "..." or --file <path>.');
30
+ let data;
31
+ try {
32
+ data = await fidelityPost(client, `/v1/fidelity/${seg(args.run_id)}/turns`, { message });
33
+ }
34
+ catch (err) {
35
+ if (err instanceof FacesAPIError)
36
+ this.error(fidelityError(err, { run: args.run_id }));
37
+ throw err;
38
+ }
39
+ if (this.jsonEnabled())
40
+ return data;
41
+ const turn = Number(data.turn);
42
+ for (const line of answerLines(turn, (data.answers ?? {})))
43
+ this.log(line);
44
+ this.log('');
45
+ this.log(`Pick one: faces fidelity:pick ${args.run_id} a|b [--correction "what they would have said"]`);
46
+ return data;
47
+ }
48
+ }
@@ -0,0 +1,16 @@
1
+ import { BaseCommand } from '../../base.js';
2
+ export default class GroupAdd extends BaseCommand {
3
+ static description: string;
4
+ static flags: {
5
+ face: import("@oclif/core/interfaces").OptionFlag<string[], import("@oclif/core/interfaces").CustomOptions>;
6
+ 'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ 'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
+ };
11
+ static args: {
12
+ group_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
13
+ };
14
+ static examples: string[];
15
+ run(): Promise<unknown>;
16
+ }
@@ -0,0 +1,83 @@
1
+ import { Args, Flags } from '@oclif/core';
2
+ import { BaseCommand } from '../../base.js';
3
+ import { FacesAPIError } from '../../client.js';
4
+ import { GroupCatalogService } from '../../group-catalog.js';
5
+ import { resolveFace, seg } from '../../utils.js';
6
+ export default class GroupAdd extends BaseCommand {
7
+ static description = 'Add face(s) to a group. Any face this account can reach may join: your own, a published one, or one ' +
8
+ 'shared with you. Name someone else\'s as owner:alias, the same address chat uses.';
9
+ static flags = {
10
+ ...BaseCommand.baseFlags,
11
+ face: Flags.string({ description: 'Face alias to add (repeatable)', multiple: true, required: true }),
12
+ };
13
+ static args = {
14
+ group_id: Args.string({ description: 'Group ID', required: true }),
15
+ };
16
+ static examples = [
17
+ '<%= config.bin %> <%= command.id %> GROUP_ID --face alice --face bob',
18
+ '<%= config.bin %> <%= command.id %> GROUP_ID --face head:socrates',
19
+ ];
20
+ async run() {
21
+ const { args, flags } = await this.parse(GroupAdd);
22
+ const client = this.makeClient(flags);
23
+ const iamIds = [];
24
+ for (const alias of flags.face) {
25
+ if (alias.includes(':')) {
26
+ iamIds.push(alias);
27
+ continue;
28
+ }
29
+ let resolved;
30
+ try {
31
+ resolved = await resolveFace(client, alias);
32
+ }
33
+ catch (err) {
34
+ if (err instanceof FacesAPIError) {
35
+ if (err.statusCode === 404) {
36
+ this.error(`No face '${alias}'. If it belongs to another account, name it as owner:alias. ` +
37
+ 'Find it with: faces face:list --public');
38
+ }
39
+ this.error(`Could not resolve '${alias}' (HTTP ${err.statusCode}): ${err.message}`);
40
+ }
41
+ throw err;
42
+ }
43
+ const face = resolved.face;
44
+ const id = (face.uid ?? face.id ?? face.iam_id);
45
+ if (!id)
46
+ this.error(`Could not find the owner of face '${alias}'.`);
47
+ iamIds.push(id);
48
+ }
49
+ let data;
50
+ try {
51
+ if (iamIds.length === 1) {
52
+ data = await client.post(`/v1/groups/${seg(args.group_id)}/members`, { body: { iam_id: iamIds[0] } });
53
+ }
54
+ else {
55
+ data = await client.post(`/v1/groups/${seg(args.group_id)}/members`, { body: { iam_ids: iamIds } });
56
+ }
57
+ }
58
+ catch (err) {
59
+ if (err instanceof FacesAPIError)
60
+ this.error(`HTTP ${err.statusCode}: ${err.message}`);
61
+ throw err;
62
+ }
63
+ try {
64
+ const groupCatalog = new GroupCatalogService();
65
+ for (const name of groupCatalog.listGroups()) {
66
+ const group = groupCatalog.readGroup(name);
67
+ if (group?.frontmatter.id === args.group_id) {
68
+ const members = new Set(group.frontmatter.members ?? []);
69
+ for (const alias of flags.face)
70
+ members.add(alias);
71
+ group.frontmatter.members = [...members];
72
+ groupCatalog.writeGroup(name, group.frontmatter, group.body || undefined);
73
+ break;
74
+ }
75
+ }
76
+ }
77
+ catch { }
78
+ if (!this.jsonEnabled()) {
79
+ this.log(`Added ${flags.face.join(', ')} to group.`);
80
+ }
81
+ return data;
82
+ }
83
+ }
@@ -0,0 +1,16 @@
1
+ import { BaseCommand } from '../../base.js';
2
+ export default class GroupCreate extends BaseCommand {
3
+ static description: string;
4
+ static flags: {
5
+ name: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
6
+ description: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ protocol: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ 'protocol-file': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ tag: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ 'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
+ 'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
+ toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
14
+ };
15
+ run(): Promise<unknown>;
16
+ }
@@ -0,0 +1,68 @@
1
+ import { Flags } from '@oclif/core';
2
+ import fs from 'node:fs';
3
+ import { BaseCommand } from '../../base.js';
4
+ import { FacesAPIError } from '../../client.js';
5
+ import { GroupCatalogService, stripFrontmatter } from '../../group-catalog.js';
6
+ import { seg } from '../../utils.js';
7
+ export default class GroupCreate extends BaseCommand {
8
+ static description = 'Create a new group';
9
+ static flags = {
10
+ ...BaseCommand.baseFlags,
11
+ name: Flags.string({ description: 'Group name', required: true }),
12
+ description: Flags.string({ description: 'Plain-text group description (max 1500 chars)' }),
13
+ protocol: Flags.string({ description: 'Protocol content (mermaid diagram or markdown, max 1000 words)' }),
14
+ 'protocol-file': Flags.string({ description: 'Read protocol from file' }),
15
+ tag: Flags.string({ description: 'Tag label (repeatable, lowercase)', multiple: true }),
16
+ };
17
+ async run() {
18
+ const { flags } = await this.parse(GroupCreate);
19
+ const client = this.makeClient(flags);
20
+ let protocol = flags.protocol;
21
+ if (flags['protocol-file']) {
22
+ if (!fs.existsSync(flags['protocol-file']))
23
+ this.error(`File not found: ${flags['protocol-file']}`);
24
+ protocol = stripFrontmatter(fs.readFileSync(flags['protocol-file'], 'utf8'));
25
+ }
26
+ const payload = { name: flags.name };
27
+ if (flags.description)
28
+ payload.description = flags.description;
29
+ if (protocol)
30
+ payload.protocol = protocol;
31
+ let data;
32
+ try {
33
+ data = await client.post('/v1/groups', { body: payload });
34
+ }
35
+ catch (err) {
36
+ if (err instanceof FacesAPIError)
37
+ this.error(`HTTP ${err.statusCode}: ${err.message}`);
38
+ throw err;
39
+ }
40
+ const group = data;
41
+ const tags = flags.tag ?? [];
42
+ if (tags.length > 0) {
43
+ try {
44
+ await client.post(`/v1/groups/${seg(String(group.id))}/tags`, { body: { tags } });
45
+ group.tags = tags;
46
+ }
47
+ catch (err) {
48
+ if (err instanceof FacesAPIError)
49
+ this.warn(`Tags failed (${err.statusCode}): ${err.message}`);
50
+ }
51
+ }
52
+ try {
53
+ const groupCatalog = new GroupCatalogService();
54
+ const slug = String(group.name).toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '');
55
+ groupCatalog.writeGroup(slug, {
56
+ id: group.id,
57
+ name: group.name,
58
+ description: group.description ?? undefined,
59
+ tags: group.tags ?? undefined,
60
+ members: [],
61
+ }, group.protocol ?? protocol ?? undefined);
62
+ }
63
+ catch { }
64
+ if (!this.jsonEnabled())
65
+ this.printHuman(data);
66
+ return data;
67
+ }
68
+ }
@@ -0,0 +1,15 @@
1
+ import { BaseCommand } from '../../base.js';
2
+ export default class GroupDelete extends BaseCommand {
3
+ static description: string;
4
+ static flags: {
5
+ yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
6
+ 'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ 'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
+ };
11
+ static args: {
12
+ group_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
13
+ };
14
+ run(): Promise<unknown>;
15
+ }
@@ -0,0 +1,39 @@
1
+ import { Args, Flags } from '@oclif/core';
2
+ import { BaseCommand } from '../../base.js';
3
+ import { FacesAPIError } from '../../client.js';
4
+ import { GroupCatalogService } from '../../group-catalog.js';
5
+ import { seg } from '../../utils.js';
6
+ export default class GroupDelete extends BaseCommand {
7
+ static description = 'Delete a group';
8
+ static flags = {
9
+ ...BaseCommand.baseFlags,
10
+ yes: Flags.boolean({ description: 'Skip confirmation', default: false }),
11
+ };
12
+ static args = {
13
+ group_id: Args.string({ description: 'Group ID', required: true }),
14
+ };
15
+ async run() {
16
+ const { args, flags } = await this.parse(GroupDelete);
17
+ const client = this.makeClient(flags);
18
+ await this.confirmOrRefuse(`Delete group '${args.group_id}'?`, flags.yes);
19
+ let data;
20
+ try {
21
+ data = await client.delete(`/v1/groups/${seg(args.group_id)}`);
22
+ }
23
+ catch (err) {
24
+ if (err instanceof FacesAPIError)
25
+ this.error(`HTTP ${err.statusCode}: ${err.message}`);
26
+ throw err;
27
+ }
28
+ const groupCatalog = new GroupCatalogService();
29
+ const local = groupCatalog.findById(args.group_id);
30
+ if (local)
31
+ groupCatalog.deleteGroup(local);
32
+ if (!this.jsonEnabled()) {
33
+ this.printHuman(data);
34
+ if (local)
35
+ this.log(`Removed the local copy: ~/.faces/teams/${local}`);
36
+ }
37
+ return data;
38
+ }
39
+ }
@@ -0,0 +1,18 @@
1
+ import { BaseCommand } from '../../base.js';
2
+ export default class GroupEdit extends BaseCommand {
3
+ static description: string;
4
+ static flags: {
5
+ name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
6
+ description: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ protocol: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ 'protocol-file': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ 'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ 'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
+ toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
13
+ };
14
+ static args: {
15
+ group_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
16
+ };
17
+ run(): Promise<unknown>;
18
+ }
@@ -0,0 +1,75 @@
1
+ import { Args, Flags } from '@oclif/core';
2
+ import fs from 'node:fs';
3
+ import { BaseCommand } from '../../base.js';
4
+ import { FacesAPIError } from '../../client.js';
5
+ import { GroupCatalogService, stripFrontmatter } from '../../group-catalog.js';
6
+ import { seg } from '../../utils.js';
7
+ export default class GroupEdit extends BaseCommand {
8
+ static description = 'Edit a group';
9
+ static flags = {
10
+ ...BaseCommand.baseFlags,
11
+ name: Flags.string({ description: 'New group name' }),
12
+ description: Flags.string({ description: 'New description (max 1500 chars)' }),
13
+ protocol: Flags.string({ description: 'New protocol content' }),
14
+ 'protocol-file': Flags.string({ description: 'Read protocol from file' }),
15
+ };
16
+ static args = {
17
+ group_id: Args.string({ description: 'Group ID', required: true }),
18
+ };
19
+ async run() {
20
+ const { args, flags } = await this.parse(GroupEdit);
21
+ const client = this.makeClient(flags);
22
+ let protocol = flags.protocol;
23
+ if (flags['protocol-file']) {
24
+ if (!fs.existsSync(flags['protocol-file']))
25
+ this.error(`File not found: ${flags['protocol-file']}`);
26
+ protocol = stripFrontmatter(fs.readFileSync(flags['protocol-file'], 'utf8'));
27
+ }
28
+ const payload = {};
29
+ if (flags.name)
30
+ payload.name = flags.name;
31
+ if (flags.description !== undefined)
32
+ payload.description = flags.description;
33
+ if (protocol !== undefined)
34
+ payload.protocol = protocol;
35
+ if (Object.keys(payload).length === 0)
36
+ this.error('Provide at least one field to update.');
37
+ let data;
38
+ try {
39
+ data = await client.patch(`/v1/groups/${seg(args.group_id)}`, { body: payload });
40
+ }
41
+ catch (err) {
42
+ if (err instanceof FacesAPIError)
43
+ this.error(`HTTP ${err.statusCode}: ${err.message}`);
44
+ throw err;
45
+ }
46
+ try {
47
+ const group = data;
48
+ const groupCatalog = new GroupCatalogService();
49
+ const slug = String(group.name).toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '');
50
+ let members = [];
51
+ try {
52
+ const membersResp = await client.get(`/v1/groups/${seg(args.group_id)}/members`);
53
+ members = (membersResp.data ?? []).map(m => (m.alias ?? m.iam_id));
54
+ }
55
+ catch { }
56
+ let tags = [];
57
+ try {
58
+ const tagResp = await client.get(`/v1/groups/${seg(args.group_id)}/tags`);
59
+ tags = tagResp.tags ?? [];
60
+ }
61
+ catch { }
62
+ groupCatalog.writeGroup(slug, {
63
+ id: args.group_id,
64
+ name: group.name,
65
+ description: group.description ?? undefined,
66
+ tags,
67
+ members,
68
+ }, group.protocol ?? undefined);
69
+ }
70
+ catch { }
71
+ if (!this.jsonEnabled())
72
+ this.printHuman(data);
73
+ return data;
74
+ }
75
+ }
@@ -0,0 +1,14 @@
1
+ import { BaseCommand } from '../../base.js';
2
+ export default class GroupGet extends BaseCommand {
3
+ static description: string;
4
+ static flags: {
5
+ 'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
6
+ token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ 'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
9
+ };
10
+ static args: {
11
+ group_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
12
+ };
13
+ run(): Promise<unknown>;
14
+ }
@@ -0,0 +1,29 @@
1
+ import { Args } from '@oclif/core';
2
+ import { BaseCommand } from '../../base.js';
3
+ import { FacesAPIError } from '../../client.js';
4
+ import { seg } from '../../utils.js';
5
+ export default class GroupGet extends BaseCommand {
6
+ static description = 'Get a group by ID';
7
+ static flags = {
8
+ ...BaseCommand.baseFlags,
9
+ };
10
+ static args = {
11
+ group_id: Args.string({ description: 'Group ID', required: true }),
12
+ };
13
+ async run() {
14
+ const { args, flags } = await this.parse(GroupGet);
15
+ const client = this.makeClient(flags);
16
+ let data;
17
+ try {
18
+ data = await client.get(`/v1/groups/${seg(args.group_id)}`);
19
+ }
20
+ catch (err) {
21
+ if (err instanceof FacesAPIError)
22
+ this.error(`HTTP ${err.statusCode}: ${err.message}`);
23
+ throw err;
24
+ }
25
+ if (!this.jsonEnabled())
26
+ this.printHuman(data);
27
+ return data;
28
+ }
29
+ }
@@ -0,0 +1,11 @@
1
+ import { BaseCommand } from '../../base.js';
2
+ export default class GroupList extends BaseCommand {
3
+ static description: string;
4
+ static flags: {
5
+ 'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
6
+ token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ 'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
9
+ };
10
+ run(): Promise<unknown>;
11
+ }
@@ -0,0 +1,39 @@
1
+ import { BaseCommand } from '../../base.js';
2
+ import { FacesAPIError } from '../../client.js';
3
+ export default class GroupList extends BaseCommand {
4
+ static description = 'List your groups';
5
+ static flags = {
6
+ ...BaseCommand.baseFlags,
7
+ };
8
+ async run() {
9
+ const { flags } = await this.parse(GroupList);
10
+ const client = this.makeClient(flags);
11
+ let data;
12
+ try {
13
+ data = await client.get('/v1/me/groups');
14
+ }
15
+ catch (err) {
16
+ if (err instanceof FacesAPIError)
17
+ this.error(`HTTP ${err.statusCode}: ${err.message}`);
18
+ throw err;
19
+ }
20
+ const resp = data;
21
+ let groups = resp.data ?? data;
22
+ groups = groups.filter(t => t.kind !== 'personal');
23
+ if (this.jsonEnabled())
24
+ return groups;
25
+ if (groups.length === 0) {
26
+ this.log('(no groups)');
27
+ }
28
+ else {
29
+ const nameWidth = Math.max(...groups.map(t => String(t.name ?? '').length));
30
+ for (const t of groups) {
31
+ const name = String(t.name ?? '').padEnd(nameWidth);
32
+ const members = t.member_count != null ? ` [${t.member_count} members]` : '';
33
+ const desc = t.description ? ` ${String(t.description).slice(0, 50)}` : '';
34
+ this.log(`${t.id} ${name}${members}${desc}`);
35
+ }
36
+ }
37
+ return groups;
38
+ }
39
+ }
@@ -0,0 +1,15 @@
1
+ import { BaseCommand } from '../../base.js';
2
+ export default class GroupMembers extends BaseCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ 'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ 'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
+ };
11
+ static args: {
12
+ group_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
13
+ };
14
+ run(): Promise<unknown>;
15
+ }