@faces-sh/cli 0.0.0-stage → 1.0.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 (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 +42 -0
  171. package/dist/commands/face/share.d.ts +22 -0
  172. package/dist/commands/face/share.js +103 -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 +31 -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 +92 -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 { seg } from '../../utils.js';
5
+ export default class FaceLock extends BaseCommand {
6
+ static description = 'Lock a face (read-only). A locked face still reads and chats normally, but it, and everything it owns (documents, threads, built styles), cannot be changed until unlocked.';
7
+ static examples = ['<%= config.bin %> <%= command.id %> socrates'];
8
+ static flags = {
9
+ ...BaseCommand.baseFlags,
10
+ };
11
+ static args = {
12
+ face_id: Args.string({ description: 'Face alias', required: true }),
13
+ };
14
+ async run() {
15
+ const { args, flags } = await this.parse(FaceLock);
16
+ const client = this.makeClient(flags);
17
+ let data;
18
+ try {
19
+ data = await client.patch(`/v1/faces/${seg(args.face_id)}/lock`, { body: { read_only: true } });
20
+ }
21
+ catch (err) {
22
+ if (err instanceof FacesAPIError)
23
+ this.error(`HTTP ${err.statusCode}: ${err.message}`);
24
+ throw err;
25
+ }
26
+ if (!this.jsonEnabled()) {
27
+ const res = data;
28
+ this.log(`Locked '${res.alias ?? args.face_id}' is now read only.`);
29
+ const affected = res.affected ?? [];
30
+ if (affected.length > 0)
31
+ this.log(`Affected: ${affected.join(', ')}`);
32
+ }
33
+ return data;
34
+ }
35
+ }
@@ -0,0 +1,16 @@
1
+ import { BaseCommand } from '../../base.js';
2
+ export default class FaceNeighbors extends BaseCommand {
3
+ static description: string;
4
+ static flags: {
5
+ k: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
6
+ direction: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
7
+ 'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ 'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
+ };
12
+ static args: {
13
+ face_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
14
+ };
15
+ run(): Promise<unknown>;
16
+ }
@@ -0,0 +1,63 @@
1
+ import { Args, Flags } from '@oclif/core';
2
+ import { BaseCommand } from '../../base.js';
3
+ import { FacesAPIError } from '../../client.js';
4
+ import { seg, similarityText } from '../../utils.js';
5
+ export default class FaceNeighbors extends BaseCommand {
6
+ static description = 'Find the most similar or dissimilar owned faces to a given face. The face to compare against may be ' +
7
+ 'one of yours, or a published or shared face named as owner:alias; the faces it is ranked against are ' +
8
+ 'always your own. The face needs something compiled. Similarity runs from -1 to 1, and is rounded to one ' +
9
+ 'decimal place when the face compared against is not yours.';
10
+ static flags = {
11
+ ...BaseCommand.baseFlags,
12
+ k: Flags.integer({
13
+ description: 'Number of results (1-20)',
14
+ default: 5,
15
+ min: 1,
16
+ max: 20,
17
+ }),
18
+ direction: Flags.string({
19
+ description: 'nearest (most similar) or furthest (most dissimilar)',
20
+ options: ['nearest', 'furthest'],
21
+ default: 'nearest',
22
+ }),
23
+ };
24
+ static args = {
25
+ face_id: Args.string({
26
+ description: 'Face alias, or owner:alias for a face published by or shared from another account',
27
+ required: true,
28
+ }),
29
+ };
30
+ async run() {
31
+ const { args, flags } = await this.parse(FaceNeighbors);
32
+ const client = this.makeClient(flags);
33
+ const params = {
34
+ k: String(flags.k),
35
+ direction: flags.direction,
36
+ };
37
+ let data;
38
+ try {
39
+ data = await client.get(`/v1/faces/${seg(args.face_id)}/neighbors`, { params });
40
+ }
41
+ catch (err) {
42
+ if (err instanceof FacesAPIError)
43
+ this.error(`HTTP ${err.statusCode}: ${err.message}`);
44
+ throw err;
45
+ }
46
+ if (!this.jsonEnabled()) {
47
+ const res = data;
48
+ const label = res.direction === 'nearest' ? 'Nearest' : 'Most dissimilar';
49
+ this.log(`${label} neighbors to ${res.face} (by overall similarity):`);
50
+ this.log('');
51
+ if (res.neighbors.length === 0) {
52
+ this.log(' (none)');
53
+ }
54
+ else {
55
+ for (const [i, n] of res.neighbors.entries()) {
56
+ const updated = new Date(n.centroid_updated_at * 1000).toISOString().slice(0, 10);
57
+ this.log(` ${i + 1}. ${n.face.padEnd(20)} ${similarityText(n.similarity).padEnd(7)} (updated ${updated})`);
58
+ }
59
+ }
60
+ }
61
+ return data;
62
+ }
63
+ }
@@ -0,0 +1,16 @@
1
+ import { BaseCommand } from '../../base.js';
2
+ export default class FacePublish extends BaseCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
7
+ 'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ 'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
+ };
12
+ static args: {
13
+ alias: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
14
+ };
15
+ run(): Promise<unknown>;
16
+ }
@@ -0,0 +1,42 @@
1
+ import { Args, Flags } 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 FacePublish extends BaseCommand {
6
+ static description = 'Publish a face so EVERY account can chat with it. This is a global override: while it is on, ' +
7
+ 'everyone can reach the face regardless of who it is shared with. You still pay only to compile it; ' +
8
+ 'whoever chats pays for their own inference.';
9
+ static examples = ['<%= config.bin %> <%= command.id %> alice --yes'];
10
+ static flags = {
11
+ ...BaseCommand.baseFlags,
12
+ yes: Flags.boolean({ description: 'Skip confirmation', default: false }),
13
+ };
14
+ static args = {
15
+ alias: Args.string({ description: 'Face alias', required: true }),
16
+ };
17
+ async run() {
18
+ const { args, flags } = await this.parse(FacePublish);
19
+ const client = this.makeClient(flags);
20
+ if (!flags.yes) {
21
+ this.error(`This makes '${args.alias}' chattable by every account on the platform. Re-run with --yes to confirm.`);
22
+ }
23
+ let data;
24
+ try {
25
+ data = (await client.patch(`/v1/faces/${seg(args.alias)}/publish`, {
26
+ body: { published: true },
27
+ }));
28
+ }
29
+ catch (err) {
30
+ if (err instanceof FacesAPIError)
31
+ this.error(`HTTP ${err.statusCode}: ${err.message}`);
32
+ throw err;
33
+ }
34
+ if (this.jsonEnabled())
35
+ return data;
36
+ this.log(`'${args.alias}' is published.`);
37
+ if (data.handle)
38
+ this.log(`Anyone can chat it as: ${data.handle}@<model>`);
39
+ this.log(`Unpublish with: faces face:unpublish ${args.alias}`);
40
+ return data;
41
+ }
42
+ }
@@ -0,0 +1,22 @@
1
+ import { BaseCommand } from '../../base.js';
2
+ export default class FaceShare extends BaseCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ list: import("@oclif/core/interfaces").BooleanFlag<boolean>;
7
+ add: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ with: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ none: import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
+ yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
+ 'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
+ token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
+ 'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
+ toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
15
+ };
16
+ static args: {
17
+ alias: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
18
+ };
19
+ run(): Promise<unknown>;
20
+ private readList;
21
+ private report;
22
+ }
@@ -0,0 +1,103 @@
1
+ import { Args, Flags } from '@oclif/core';
2
+ import { BaseCommand } from '../../base.js';
3
+ import { FacesAPIError } from '../../client.js';
4
+ import { seg, ownsFace } from '../../utils.js';
5
+ export default class FaceShare extends BaseCommand {
6
+ static description = 'Share a face so named accounts can chat with it. Sharing grants chat and nothing else: no reading its ' +
7
+ 'documents, no compiling, no re-sharing. Sharing does not show its profile addendum, though the model ' +
8
+ 'answering as the face can be asked to repeat it. --add keeps the current list; --with replaces it.';
9
+ static examples = [
10
+ '<%= config.bin %> <%= command.id %> alice --list',
11
+ '<%= config.bin %> <%= command.id %> alice --add dana',
12
+ '<%= config.bin %> <%= command.id %> alice --with dana --with sam@example.com',
13
+ '<%= config.bin %> <%= command.id %> alice --none --yes',
14
+ ];
15
+ static flags = {
16
+ ...BaseCommand.baseFlags,
17
+ list: Flags.boolean({ description: 'Show who the face is shared with, and change nothing', default: false }),
18
+ add: Flags.string({
19
+ description: 'Add an account, keeping everyone already on the list. Username or email (repeatable)',
20
+ multiple: true,
21
+ exclusive: ['with', 'none'],
22
+ }),
23
+ with: Flags.string({
24
+ description: 'Set the list to exactly these accounts, dropping anyone else (repeatable)',
25
+ multiple: true,
26
+ exclusive: ['add', 'none'],
27
+ }),
28
+ none: Flags.boolean({ description: 'Revoke everyone', default: false, exclusive: ['add', 'with'] }),
29
+ yes: Flags.boolean({ description: 'Skip the confirmation shown when someone would lose access', default: false }),
30
+ };
31
+ static args = {
32
+ alias: Args.string({ description: 'Face alias', required: true }),
33
+ };
34
+ async run() {
35
+ const { args, flags } = await this.parse(FaceShare);
36
+ const client = this.makeClient(flags);
37
+ const json = this.jsonEnabled();
38
+ if ((await ownsFace(client, args.alias)) === false) {
39
+ this.error(`'${args.alias}' belongs to another account. Only its owner can see or change who it is shared with.`);
40
+ }
41
+ const current = await this.readList(client, args.alias);
42
+ if (flags.list) {
43
+ if (!json)
44
+ this.report(args.alias, current);
45
+ return { alias: args.alias, shared_with: current };
46
+ }
47
+ if (!flags.add && !flags.with && !flags.none) {
48
+ this.error('Provide --list, --add <account>, --with <account> (replaces), or --none.');
49
+ }
50
+ let next;
51
+ if (flags.none)
52
+ next = [];
53
+ else if (flags.add)
54
+ next = [...new Set([...current, ...flags.add])];
55
+ else
56
+ next = [...new Set(flags.with)];
57
+ const lower = new Set(next.map((u) => u.toLowerCase()));
58
+ const removed = current.filter((u) => !lower.has(u.toLowerCase()));
59
+ if (removed.length > 0 && !flags.yes) {
60
+ this.error(`This removes ${removed.length} account(s) from '${args.alias}': ${removed.join(', ')}.\n` +
61
+ 'Revocation is immediate. Re-run with --yes, or use --add to keep them.');
62
+ }
63
+ let data;
64
+ try {
65
+ data = (await client.patch(`/v1/faces/${seg(args.alias)}/share`, {
66
+ body: { shared_with: next },
67
+ }));
68
+ }
69
+ catch (err) {
70
+ if (err instanceof FacesAPIError)
71
+ this.error(`HTTP ${err.statusCode}: ${err.message}`);
72
+ throw err;
73
+ }
74
+ if (json)
75
+ return data;
76
+ if (removed.length > 0)
77
+ this.log(`Revoked: ${removed.join(', ')}`);
78
+ this.report(args.alias, data.shared_with ?? [], data.handle);
79
+ return data;
80
+ }
81
+ async readList(client, alias) {
82
+ try {
83
+ const face = (await client.get(`/v1/faces/${seg(alias)}`));
84
+ return face.shared_with ?? [];
85
+ }
86
+ catch (err) {
87
+ if (err instanceof FacesAPIError)
88
+ this.error(`HTTP ${err.statusCode}: ${err.message}`);
89
+ throw err;
90
+ }
91
+ }
92
+ report(alias, users, handle) {
93
+ if (users.length === 0) {
94
+ this.log(`'${alias}' is not shared with anyone.`);
95
+ return;
96
+ }
97
+ this.log(`'${alias}' is shared with ${users.length} account(s):`);
98
+ for (const u of users)
99
+ this.log(` ${u}`);
100
+ if (handle)
101
+ this.log(`\nThey chat with it as: ${handle}@<model>`);
102
+ }
103
+ }
@@ -0,0 +1,21 @@
1
+ import { BaseCommand } from '../../base.js';
2
+ export default class FaceSources extends BaseCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ type: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ 'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ 'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
+ };
12
+ static args: {
13
+ alias: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
14
+ };
15
+ run(): Promise<unknown>;
16
+ private fetch;
17
+ private statusOf;
18
+ private toRow;
19
+ private toJson;
20
+ private render;
21
+ }
@@ -0,0 +1,169 @@
1
+ import { Args, Flags } from '@oclif/core';
2
+ import { BaseCommand } from '../../base.js';
3
+ import { FacesAPIError } from '../../client.js';
4
+ import { compileBlockedLabel, compileProgressLabel, compileStatusOf, freshnessOf, revisionsBehind } from '../../utils.js';
5
+ const EXIT_NO_SUCH_FACE = 4;
6
+ export default class FaceSources extends BaseCommand {
7
+ static description = 'List every source compiled into a face: documents and threads together, one row each. ' +
8
+ `Exits ${EXIT_NO_SUCH_FACE} if the face does not exist, which is a different answer from a face that ` +
9
+ 'has no sources. Content is never printed; read a single source with compile:doc:get or compile:thread:get.';
10
+ static examples = [
11
+ '<%= config.bin %> <%= command.id %> alice',
12
+ '<%= config.bin %> <%= command.id %> alice --type thread',
13
+ '<%= config.bin %> <%= command.id %> alice --json',
14
+ ];
15
+ static flags = {
16
+ ...BaseCommand.baseFlags,
17
+ type: Flags.string({ description: 'Show only one kind of source', options: ['doc', 'thread'] }),
18
+ };
19
+ static args = {
20
+ alias: Args.string({ description: 'Face alias', required: true }),
21
+ };
22
+ async run() {
23
+ const { args, flags } = await this.parse(FaceSources);
24
+ const client = this.makeClient(flags);
25
+ const json = this.jsonEnabled();
26
+ const alias = encodeURIComponent(args.alias);
27
+ const wantDocs = flags.type !== 'thread';
28
+ const wantThreads = flags.type !== 'doc';
29
+ const docs = wantDocs ? await this.fetch(client, `/v1/compile/documents?alias=${alias}`, args.alias) : [];
30
+ const threads = wantThreads
31
+ ? await this.fetch(client, `/v1/compile/threads?alias=${alias}&include_uploads=true`, args.alias)
32
+ : [];
33
+ const rows = [...docs.map((d) => this.toRow(d, 'doc')), ...threads.map((t) => this.toRow(t, 'thread'))];
34
+ rows.sort((a, b) => (b.updated || '').localeCompare(a.updated || '') || a.label.localeCompare(b.label));
35
+ if (json) {
36
+ return {
37
+ alias: args.alias,
38
+ documents: docs.map((d) => this.toJson(d, 'doc')),
39
+ threads: threads.map((t) => this.toJson(t, 'thread')),
40
+ totals: {
41
+ sources: rows.length,
42
+ tokens: rows.reduce((n, r) => n + r.tokens, 0),
43
+ not_synced: rows.filter((r) => !r.synced).length,
44
+ },
45
+ };
46
+ }
47
+ this.render(args.alias, rows, flags.type);
48
+ return { alias: args.alias, sources: rows.length };
49
+ }
50
+ async fetch(client, path, alias) {
51
+ try {
52
+ const data = await client.get(path);
53
+ return (Array.isArray(data) ? data : (data.data ?? []));
54
+ }
55
+ catch (err) {
56
+ if (err instanceof FacesAPIError) {
57
+ if (err.statusCode === 404) {
58
+ this.error(`No face named '${alias}'. It does not exist, or is not owned by this account.`, {
59
+ exit: EXIT_NO_SUCH_FACE,
60
+ });
61
+ }
62
+ this.error(`HTTP ${err.statusCode}: ${err.message}`);
63
+ }
64
+ throw err;
65
+ }
66
+ }
67
+ statusOf(s) {
68
+ if (s.finishing) {
69
+ const st = compileStatusOf(s.status);
70
+ return compileProgressLabel({ ...s, status: st === 'failed' || st === null ? 'compiling' : st });
71
+ }
72
+ if (s.synced) {
73
+ const behind = revisionsBehind(s);
74
+ return behind === null ? 'compiled' : `stale (${behind} behind)`;
75
+ }
76
+ if (s.compilable === false) {
77
+ const why = compileBlockedLabel(s.compile_blocked_reason) || 'refused';
78
+ return `cannot compile: ${why}`;
79
+ }
80
+ const st = compileStatusOf(s.status);
81
+ if (st && st !== 'compiled')
82
+ return compileProgressLabel(s);
83
+ return 'not compiled';
84
+ }
85
+ toRow(s, type) {
86
+ return {
87
+ type,
88
+ id: String(s.document_id ?? s.thread_id ?? ''),
89
+ label: s.label?.trim() || '(untitled)',
90
+ tokens: s.token_count ?? 0,
91
+ status: this.statusOf(s),
92
+ medium: s.medium?.trim() || s.corpus_medium?.trim() || '-',
93
+ updated: (s.updated_at ?? s.created_at ?? '').slice(0, 10) || '-',
94
+ synced: Boolean(s.synced),
95
+ finishing: Boolean(s.finishing),
96
+ };
97
+ }
98
+ toJson(s, type) {
99
+ const out = {
100
+ type,
101
+ id: String(s.document_id ?? s.thread_id ?? ''),
102
+ label: s.label ?? null,
103
+ token_count: s.token_count ?? 0,
104
+ status: this.statusOf(s),
105
+ synced: Boolean(s.synced),
106
+ compile_status: compileStatusOf(s.status),
107
+ progress: s.progress ?? null,
108
+ starts_at: s.starts_at ?? null,
109
+ rush: s.rush ?? false,
110
+ finishing: Boolean(s.finishing),
111
+ version: s.version ?? null,
112
+ synced_version: s.synced_version ?? null,
113
+ synced_at: s.synced_at ?? null,
114
+ freshness: freshnessOf(s),
115
+ revisions_behind: revisionsBehind(s),
116
+ compilable: s.compilable ?? null,
117
+ compile_blocked_reason: s.compile_blocked_reason ?? null,
118
+ medium: s.medium ?? s.corpus_medium ?? null,
119
+ corpus_medium: s.corpus_medium ?? null,
120
+ perspective: s.perspective ?? null,
121
+ created_at: s.created_at ?? null,
122
+ updated_at: s.updated_at ?? null,
123
+ read_only: Boolean(s.read_only),
124
+ };
125
+ if (type === 'doc')
126
+ out.document_id = s.document_id;
127
+ if (type === 'thread') {
128
+ out.thread_id = s.thread_id;
129
+ out.message_count = s.message_count ?? null;
130
+ }
131
+ return out;
132
+ }
133
+ render(alias, rows, type) {
134
+ if (rows.length === 0) {
135
+ const what = type ? `${type} sources` : 'sources';
136
+ this.log(`'${alias}' exists and has no ${what}.`);
137
+ return;
138
+ }
139
+ const n = (v) => v.toLocaleString('en-US');
140
+ const cols = [
141
+ ['TYPE', (r) => r.type],
142
+ ['LABEL', (r) => r.label],
143
+ ['TOKENS', (r) => n(r.tokens)],
144
+ ['STATUS', (r) => r.status],
145
+ ['MEDIUM', (r) => r.medium],
146
+ ['UPDATED', (r) => r.updated],
147
+ ['ID', (r) => r.id],
148
+ ];
149
+ const widths = cols.map(([h, get]) => Math.max(h.length, ...rows.map((r) => get(r).length)));
150
+ const line = (cells) => cells
151
+ .map((c, i) => (cols[i][0] === 'TOKENS' ? c.padStart(widths[i]) : c.padEnd(widths[i])))
152
+ .join(' ')
153
+ .trimEnd();
154
+ this.log(line(cols.map(([h]) => h)));
155
+ for (const r of rows)
156
+ this.log(line(cols.map(([, get]) => get(r))));
157
+ const tokens = rows.reduce((a, r) => a + r.tokens, 0);
158
+ const working = rows.filter((r) => r.finishing).length;
159
+ const stopped = rows.filter((r) => !r.synced && !r.finishing).length;
160
+ this.log('');
161
+ this.log(`${n(tokens)} tokens across all ${rows.length} source(s) listed.`);
162
+ if (working > 0) {
163
+ this.log(`${working} still being worked on by the server. They need no action and will finish on their own.`);
164
+ }
165
+ if (stopped > 0) {
166
+ this.log(`${stopped} not compiled and not running. Their tokens are included in that total.`);
167
+ }
168
+ }
169
+ }
@@ -0,0 +1,12 @@
1
+ import { BaseCommand } from '../../base.js';
2
+ export default class FaceStats 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
+ private printTable;
12
+ }
@@ -0,0 +1,46 @@
1
+ import { BaseCommand } from '../../base.js';
2
+ import { FacesAPIError } from '../../client.js';
3
+ import { table, usd } from '../../utils.js';
4
+ export default class FaceStats extends BaseCommand {
5
+ static description = 'Compile and chat stats for all owned faces';
6
+ static flags = {
7
+ ...BaseCommand.baseFlags,
8
+ };
9
+ async run() {
10
+ const { flags } = await this.parse(FaceStats);
11
+ const client = this.makeClient(flags);
12
+ let data;
13
+ try {
14
+ data = await client.get('/v1/faces/stats');
15
+ }
16
+ catch (err) {
17
+ if (err instanceof FacesAPIError)
18
+ this.error(`HTTP ${err.statusCode}: ${err.message}`);
19
+ throw err;
20
+ }
21
+ if (!this.jsonEnabled())
22
+ this.printTable(data);
23
+ return data;
24
+ }
25
+ printTable(stats) {
26
+ const faces = Object.entries(stats ?? {});
27
+ if (faces.length === 0) {
28
+ this.log('No faces.');
29
+ return;
30
+ }
31
+ const n = (v) => (typeof v === 'number' ? v.toLocaleString('en-US') : '-');
32
+ const day = (v) => (typeof v === 'string' && v ? v.slice(0, 10) : '-');
33
+ const body = faces.map(([alias, s]) => [
34
+ alias,
35
+ s.compiled === true ? 'yes' : s.compiled === false ? 'no' : '-',
36
+ n(s.compile_tokens_synced),
37
+ day(s.last_synced_at),
38
+ n(s.chat_input_tokens),
39
+ n(s.chat_output_tokens),
40
+ usd(s.chat_total_cost_usd),
41
+ ]);
42
+ const cols = ['FACE', 'COMPILED', 'COMPILED TOKENS', 'LAST COMPILED', 'CHAT IN', 'CHAT OUT', 'CHAT COST'];
43
+ for (const line of table(cols, body, new Set(['COMPILED TOKENS', 'CHAT IN', 'CHAT OUT', 'CHAT COST'])))
44
+ this.log(line);
45
+ }
46
+ }
@@ -0,0 +1,15 @@
1
+ import { BaseCommand } from '../../../base.js';
2
+ export default class FaceTagAdd extends BaseCommand {
3
+ static description: string;
4
+ static flags: {
5
+ tag: 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
+ alias: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
13
+ };
14
+ run(): Promise<unknown>;
15
+ }
@@ -0,0 +1,40 @@
1
+ import { Args, Flags } from '@oclif/core';
2
+ import { BaseCommand } from '../../../base.js';
3
+ import { FacesAPIError } from '../../../client.js';
4
+ import { CatalogService } from '../../../catalog.js';
5
+ import { seg } from '../../../utils.js';
6
+ export default class FaceTagAdd extends BaseCommand {
7
+ static description = 'Add tags to a face (appends, idempotent)';
8
+ static flags = {
9
+ ...BaseCommand.baseFlags,
10
+ tag: Flags.string({ description: 'Tag to add (repeatable)', multiple: true, required: true }),
11
+ };
12
+ static args = {
13
+ alias: Args.string({ description: 'Face alias', required: true }),
14
+ };
15
+ async run() {
16
+ const { args, flags } = await this.parse(FaceTagAdd);
17
+ const client = this.makeClient(flags);
18
+ let data;
19
+ try {
20
+ data = await client.post(`/v1/iam/${seg(args.alias)}/tags`, { body: { tags: flags.tag } });
21
+ }
22
+ catch (err) {
23
+ if (err instanceof FacesAPIError) {
24
+ if (err.statusCode === 403) {
25
+ this.error(`Forbidden: face '${args.alias}' is not owned by the current account. Run \`faces catalog:doctor --fix\` to sync.`);
26
+ }
27
+ this.error(`HTTP ${err.statusCode}: ${err.message}`);
28
+ }
29
+ throw err;
30
+ }
31
+ const tags = data.tags ?? [];
32
+ try {
33
+ new CatalogService().updateTags(args.alias, tags);
34
+ }
35
+ catch { }
36
+ if (!this.jsonEnabled())
37
+ this.printHuman(data);
38
+ return data;
39
+ }
40
+ }
@@ -0,0 +1,11 @@
1
+ import { BaseCommand } from '../../../base.js';
2
+ export default class FaceTagAll 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,31 @@
1
+ import { BaseCommand } from '../../../base.js';
2
+ import { FacesAPIError } from '../../../client.js';
3
+ export default class FaceTagAll extends BaseCommand {
4
+ static description = 'List all tags across all your faces';
5
+ static flags = {
6
+ ...BaseCommand.baseFlags,
7
+ };
8
+ async run() {
9
+ const { flags } = await this.parse(FaceTagAll);
10
+ const client = this.makeClient(flags);
11
+ let data;
12
+ try {
13
+ data = await client.get('/v1/me/tags');
14
+ }
15
+ catch (err) {
16
+ if (err instanceof FacesAPIError)
17
+ this.error(`HTTP ${err.statusCode}: ${err.message}`);
18
+ throw err;
19
+ }
20
+ if (!this.jsonEnabled()) {
21
+ const tags = data.tags ?? [];
22
+ if (tags.length === 0) {
23
+ this.log('(no tags)');
24
+ }
25
+ else {
26
+ this.log(tags.join(', '));
27
+ }
28
+ }
29
+ return data;
30
+ }
31
+ }