@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,98 @@
1
+ import { Flags } from '@oclif/core';
2
+ import { BaseCommand } from '../../base.js';
3
+ import { FacesAPIError } from '../../client.js';
4
+ import { table } from '../../utils.js';
5
+ const KINDS = ['chat', 'image', 'transcription', 'decision', 'cause', 'compile'];
6
+ export default class ModelsList extends BaseCommand {
7
+ static description = 'List the models you can name, once each, with their kind, endpoint and price (GET /v1/models). ' +
8
+ 'Without --kind only chat models are listed. CHATGPT marks the Codex-eligible models, which run on a linked ' +
9
+ 'ChatGPT plan, at /v1/responses on Connect and Pro. Prices are per million tokens. No login needed.';
10
+ static examples = [
11
+ '<%= config.bin %> <%= command.id %>',
12
+ '<%= config.bin %> <%= command.id %> --kind decision',
13
+ '<%= config.bin %> <%= command.id %> --kind cause,compile',
14
+ '<%= config.bin %> <%= command.id %> --kind all --json',
15
+ '<%= config.bin %> <%= command.id %> --provider anthropic',
16
+ ];
17
+ static flags = {
18
+ ...BaseCommand.baseFlags,
19
+ kind: Flags.string({
20
+ description: `One kind or a comma-separated list: ${KINDS.join(', ')}; or all. Default: chat.`,
21
+ }),
22
+ provider: Flags.string({ description: 'Only models from this lab (e.g. openai, anthropic, qwen)' }),
23
+ chatgpt: Flags.boolean({
24
+ description: 'Only Codex-eligible models: the ones that run on a linked ChatGPT plan',
25
+ default: false,
26
+ }),
27
+ };
28
+ async run() {
29
+ const { flags } = await this.parse(ModelsList);
30
+ const client = this.makeClient(flags);
31
+ const kind = flags.kind?.split(',').map((k) => k.trim().toLowerCase()).filter(Boolean).join(',');
32
+ if (kind !== undefined) {
33
+ const parts = kind.split(',');
34
+ const bad = parts.filter((k) => k !== 'all' && !KINDS.includes(k));
35
+ if (bad.length > 0)
36
+ this.error(`Unknown --kind: ${bad.join(', ')}. One of: ${KINDS.join(', ')}, or all.`);
37
+ if (parts.includes('all') && parts.length > 1)
38
+ this.error('--kind all cannot be combined with another kind.');
39
+ }
40
+ let raw;
41
+ try {
42
+ raw = await client.get('/v1/models', kind ? { params: { kind }, optionalAuth: true } : { optionalAuth: true });
43
+ }
44
+ catch (err) {
45
+ if (err instanceof FacesAPIError)
46
+ this.error(`HTTP ${err.statusCode}: ${err.message}`);
47
+ throw err;
48
+ }
49
+ let rows = (Array.isArray(raw) ? raw : (raw?.data ?? []));
50
+ if (flags.provider)
51
+ rows = rows.filter((m) => String(m.provider ?? '').toLowerCase() === flags.provider.toLowerCase());
52
+ if (flags.chatgpt)
53
+ rows = rows.filter((m) => m.codex_eligible === true);
54
+ if (this.jsonEnabled())
55
+ return { object: 'list', data: rows };
56
+ if (rows.length === 0) {
57
+ this.log('No models.');
58
+ return { object: 'list', data: rows };
59
+ }
60
+ const price = (v) => (typeof v === 'number' ? `$${v}` : '-');
61
+ const body = rows.map((m) => {
62
+ const unit = typeof m.unit_cost_usd === 'number' && m.billing_unit ? `${price(m.unit_cost_usd)} per ${m.billing_unit}` : '';
63
+ return [
64
+ String(m.id ?? ''),
65
+ String(m.provider ?? '-'),
66
+ String(m.kind ?? '-'),
67
+ String(m.endpoint ?? '-'),
68
+ unit ? '' : price(m.input_cost_per_million_tokens),
69
+ unit ? '' : price(m.output_cost_per_million_tokens),
70
+ unit,
71
+ m.codex_eligible === true ? 'yes' : '',
72
+ ];
73
+ });
74
+ for (const line of table(['MODEL', 'LAB', 'KIND', 'ENDPOINT', 'IN /1M', 'OUT /1M', 'OTHER', 'CHATGPT'], body, new Set(['IN /1M', 'OUT /1M']))) {
75
+ this.log(line);
76
+ }
77
+ const notes = [];
78
+ for (const m of rows) {
79
+ if (typeof m.added_tokens_per_request === 'number' && m.added_tokens_per_request > 0) {
80
+ notes.push(`${m.id}: each request adds ${m.added_tokens_per_request.toLocaleString('en-US')} tokens before pricing.`);
81
+ }
82
+ if (m.token_basis === 'source')
83
+ notes.push(`${m.id}: priced per million source tokens compiled.`);
84
+ const inc = m.included_tokens_per_month;
85
+ if (inc && typeof inc === 'object') {
86
+ const plans = Object.entries(inc).filter(([, n]) => typeof n === 'number' && n > 0).map(([p, n]) => `${p[0].toUpperCase()}${p.slice(1)} ${n.toLocaleString('en-US')}`);
87
+ if (plans.length > 0)
88
+ notes.push(`${m.id}: included each month: ${plans.join(', ')} tokens.`);
89
+ }
90
+ }
91
+ if (notes.length > 0) {
92
+ this.log('');
93
+ for (const n of notes)
94
+ this.log(n);
95
+ }
96
+ return { object: 'list', data: rows };
97
+ }
98
+ }
@@ -0,0 +1,16 @@
1
+ import { BaseCommand } from '../../base.js';
2
+ export default class SessionClose 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
+ session_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
14
+ };
15
+ run(): Promise<unknown>;
16
+ }
@@ -0,0 +1,36 @@
1
+ import { Args, Flags } from '@oclif/core';
2
+ import { BaseCommand } from '../../base.js';
3
+ import { FacesAPIError } from '../../client.js';
4
+ import { SESSIONS_PATH, sessionHint } from '../../session.js';
5
+ import { seg } from '../../utils.js';
6
+ export default class SessionClose extends BaseCommand {
7
+ static description = 'Close a session. A closed session takes no more turns and cannot be compacted or read. Its ' +
8
+ 'compactions stay usable until they expire. Free.';
9
+ static examples = ['<%= config.bin %> <%= command.id %> fs_SESSION_ID --yes'];
10
+ static flags = {
11
+ ...BaseCommand.baseFlags,
12
+ yes: Flags.boolean({ description: 'Skip confirmation', default: false }),
13
+ };
14
+ static args = {
15
+ session_id: Args.string({ description: 'Session id (from session:create)', required: true }),
16
+ };
17
+ async run() {
18
+ const { args, flags } = await this.parse(SessionClose);
19
+ const client = this.makeClient(flags);
20
+ await this.confirmOrRefuse(`Close session ${args.session_id}? It cannot be reopened.`, flags.yes);
21
+ let data;
22
+ try {
23
+ data = await client.delete(`${SESSIONS_PATH}/${seg(args.session_id)}`);
24
+ }
25
+ catch (err) {
26
+ if (err instanceof FacesAPIError) {
27
+ const hint = sessionHint(err);
28
+ this.error(`HTTP ${err.statusCode}: ${err.message}${hint ? `\n${hint}` : ''}`);
29
+ }
30
+ throw err;
31
+ }
32
+ if (!this.jsonEnabled())
33
+ this.log(`Closed session ${args.session_id}.`);
34
+ return data;
35
+ }
36
+ }
@@ -0,0 +1,15 @@
1
+ import { BaseCommand } from '../../base.js';
2
+ export default class SessionCompact 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
+ session_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
13
+ };
14
+ run(): Promise<unknown>;
15
+ }
@@ -0,0 +1,58 @@
1
+ import { Args } from '@oclif/core';
2
+ import { BaseCommand } from '../../base.js';
3
+ import { FacesAPIError } from '../../client.js';
4
+ import { heldDecisionError } from '../../decisions.js';
5
+ import { SESSIONS_PATH, sessionHint } from '../../session.js';
6
+ import { retryOnceOnWarmUp, sayWarmUp, seg } from '../../utils.js';
7
+ export default class SessionCompact extends BaseCommand {
8
+ static description = 'Compact a session: a summary of the face\'s position over the session, in the face\'s own terms, ' +
9
+ 'stored under a compaction id. Pass that id with --compaction on a later request with the same face, ' +
10
+ 'and send only the messages you still want read. Billed at the cause rate on the tokens it reads and ' +
11
+ 'writes; on Connect and Pro it counts against the cause allowance. A failed compaction is not charged. ' +
12
+ 'A compaction expires 30 days after it is written.';
13
+ static examples = [
14
+ '<%= config.bin %> <%= command.id %> fs_SESSION_ID',
15
+ '<%= config.bin %> <%= command.id %> fs_SESSION_ID --json',
16
+ ];
17
+ static flags = {
18
+ ...BaseCommand.baseFlags,
19
+ };
20
+ static args = {
21
+ session_id: Args.string({ description: 'Session id (from session:create)', required: true }),
22
+ };
23
+ async run() {
24
+ const { args, flags } = await this.parse(SessionCompact);
25
+ const client = this.makeClient(flags);
26
+ const json = this.jsonEnabled();
27
+ let data;
28
+ try {
29
+ data = (await retryOnceOnWarmUp(async () => {
30
+ const res = await client.post(`${SESSIONS_PATH}/${seg(args.session_id)}/compact`);
31
+ const held = heldDecisionError(res);
32
+ if (held)
33
+ throw held;
34
+ return res;
35
+ }, json ? undefined : sayWarmUp));
36
+ }
37
+ catch (err) {
38
+ if (err instanceof FacesAPIError) {
39
+ const hint = sessionHint(err);
40
+ this.error(`HTTP ${err.statusCode}: ${err.message}${hint ? `\n${hint}` : ''}`);
41
+ }
42
+ throw err;
43
+ }
44
+ if (!json) {
45
+ if (typeof data.cause === 'string')
46
+ this.log(data.cause);
47
+ this.log('');
48
+ this.log(`compaction: ${data.compaction_id ?? '-'}`);
49
+ if (data.turns !== undefined)
50
+ this.log(`turns: ${data.turns}`);
51
+ if (data.expires_at)
52
+ this.log(`expires: ${data.expires_at}`);
53
+ if (data.compaction_id)
54
+ this.log(`\nUse it with: faces chat:chat <face>@<model> --compaction ${data.compaction_id} -m "..."`);
55
+ }
56
+ return data;
57
+ }
58
+ }
@@ -0,0 +1,15 @@
1
+ import { BaseCommand } from '../../base.js';
2
+ export default class SessionCreate 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
+ face: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
13
+ };
14
+ run(): Promise<unknown>;
15
+ }
@@ -0,0 +1,45 @@
1
+ import { Args } from '@oclif/core';
2
+ import { BaseCommand } from '../../base.js';
3
+ import { FacesAPIError } from '../../client.js';
4
+ import { SESSIONS_PATH, sessionLines } from '../../session.js';
5
+ export default class SessionCreate extends BaseCommand {
6
+ static description = 'Start a session with a face. A session groups the turns of one conversation with one face: pass its id ' +
7
+ 'with --session on chat, causes or decide, then compact it with session:compact. Opening one is free; ' +
8
+ 'each turn costs what it costs without one. A session expires 30 days after its last turn.';
9
+ static examples = [
10
+ '<%= config.bin %> <%= command.id %> alice',
11
+ '<%= config.bin %> <%= command.id %> "(alice | bob)" --json',
12
+ ];
13
+ static flags = {
14
+ ...BaseCommand.baseFlags,
15
+ };
16
+ static args = {
17
+ face: Args.string({
18
+ description: 'The face alone: an alias, owner:alias, or a composite such as "(a | b)". No @model.',
19
+ required: true,
20
+ }),
21
+ };
22
+ async run() {
23
+ const { args, flags } = await this.parse(SessionCreate);
24
+ const client = this.makeClient(flags);
25
+ const face = args.face.trim();
26
+ if (face.includes('@'))
27
+ this.error(`A session is with a face alone: ${face.slice(0, face.lastIndexOf('@'))}`);
28
+ let data;
29
+ try {
30
+ data = (await client.post(SESSIONS_PATH, { body: { model: face } }));
31
+ }
32
+ catch (err) {
33
+ if (err instanceof FacesAPIError)
34
+ this.error(`HTTP ${err.statusCode}: ${err.message}`);
35
+ throw err;
36
+ }
37
+ if (!this.jsonEnabled()) {
38
+ for (const line of sessionLines(data))
39
+ this.log(line);
40
+ if (data.id)
41
+ this.log(`\nAdd turns with: faces chat:chat ${face}@<model> --session ${data.id} -m "..."`);
42
+ }
43
+ return data;
44
+ }
45
+ }
@@ -0,0 +1,15 @@
1
+ import { BaseCommand } from '../../base.js';
2
+ export default class SessionGet 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
+ session_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
13
+ };
14
+ run(): Promise<unknown>;
15
+ }
@@ -0,0 +1,34 @@
1
+ import { Args } from '@oclif/core';
2
+ import { BaseCommand } from '../../base.js';
3
+ import { FacesAPIError } from '../../client.js';
4
+ import { SESSIONS_PATH, sessionHint, sessionLines } from '../../session.js';
5
+ import { seg } from '../../utils.js';
6
+ export default class SessionGet extends BaseCommand {
7
+ static description = 'Read a session: its face, status, how many turns it holds, and when it expires. Free.';
8
+ static examples = ['<%= config.bin %> <%= command.id %> fs_SESSION_ID'];
9
+ static flags = {
10
+ ...BaseCommand.baseFlags,
11
+ };
12
+ static args = {
13
+ session_id: Args.string({ description: 'Session id (from session:create)', required: true }),
14
+ };
15
+ async run() {
16
+ const { args, flags } = await this.parse(SessionGet);
17
+ const client = this.makeClient(flags);
18
+ let data;
19
+ try {
20
+ data = (await client.get(`${SESSIONS_PATH}/${seg(args.session_id)}`));
21
+ }
22
+ catch (err) {
23
+ if (err instanceof FacesAPIError) {
24
+ const hint = sessionHint(err);
25
+ this.error(`HTTP ${err.statusCode}: ${err.message}${hint ? `\n${hint}` : ''}`);
26
+ }
27
+ throw err;
28
+ }
29
+ if (!this.jsonEnabled())
30
+ for (const line of sessionLines(data))
31
+ this.log(line);
32
+ return data;
33
+ }
34
+ }
@@ -0,0 +1,19 @@
1
+ import { BaseCommand } from '../../base.js';
2
+ export default class StyleDelete extends BaseCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ medium: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ all: import("@oclif/core/interfaces").BooleanFlag<boolean>;
8
+ yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
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
+ alias: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
16
+ };
17
+ run(): Promise<unknown>;
18
+ private mediaOf;
19
+ }
@@ -0,0 +1,92 @@
1
+ import { Args, Flags } from '@oclif/core';
2
+ import { BaseCommand } from '../../base.js';
3
+ import { FacesAPIError } from '../../client.js';
4
+ import { STYLE_FACES_PATH } from '../../style.js';
5
+ import { faceStyles, seg } from '../../utils.js';
6
+ export default class StyleDelete extends BaseCommand {
7
+ static description = "Delete a face's built style. A face holds one per medium, so name which with --medium, or pass " +
8
+ '--all to remove every one. On a face with several, an unscoped delete is refused rather than taking ' +
9
+ 'them all. The material a style was built from is always kept, so it can be built again without ' +
10
+ 're-uploading; to remove source text use compile:doc:delete, or compile:doc:reset to withdraw it from ' +
11
+ 'the face while keeping it.';
12
+ static examples = [
13
+ '<%= config.bin %> <%= command.id %> alice --medium email',
14
+ '<%= config.bin %> <%= command.id %> alice --all --yes',
15
+ ];
16
+ static flags = {
17
+ ...BaseCommand.baseFlags,
18
+ medium: Flags.string({
19
+ description: 'Delete only this medium\'s style, leaving the rest. See faces style:versions <alias>.',
20
+ exclusive: ['all'],
21
+ }),
22
+ all: Flags.boolean({
23
+ description: 'Delete every style the face has. Required when it holds more than one.',
24
+ default: false,
25
+ exclusive: ['medium'],
26
+ }),
27
+ yes: Flags.boolean({ description: 'Skip confirmation', default: false }),
28
+ };
29
+ static args = {
30
+ alias: Args.string({ description: 'Face alias', required: true }),
31
+ };
32
+ async run() {
33
+ const { args, flags } = await this.parse(StyleDelete);
34
+ const client = this.makeClient(flags);
35
+ if (!flags.yes) {
36
+ const media = await this.mediaOf(client, args.alias);
37
+ const scope = flags.medium
38
+ ? `its ${flags.medium} style`
39
+ : media.length > 1
40
+ ? `all ${media.length} of its styles (${media.join(', ')})`
41
+ : media.length === 1
42
+ ? `its ${media[0]} style`
43
+ : 'its style';
44
+ const what = `'${args.alias}' will forget ${scope}. Its documents, threads and uploaded material are kept.`;
45
+ await this.confirmOrRefuse(`${what}\nDelete?`, false);
46
+ }
47
+ const params = new URLSearchParams();
48
+ if (flags.medium)
49
+ params.set('medium', flags.medium);
50
+ if (flags.all)
51
+ params.set('all', 'true');
52
+ const qs = params.toString();
53
+ let data;
54
+ try {
55
+ data = (await client.delete(`${STYLE_FACES_PATH}/${encodeURIComponent(args.alias)}${qs ? `?${qs}` : ''}`));
56
+ }
57
+ catch (err) {
58
+ if (err instanceof FacesAPIError) {
59
+ if (err.errorCode === 'style_delete_ambiguous' || err.statusCode === 409) {
60
+ this.error(`${err.message}\n` +
61
+ `Name one: faces style:delete ${args.alias} --medium <medium>\n` +
62
+ `Or all: faces style:delete ${args.alias} --all\n` +
63
+ `See what it has: faces style:versions ${args.alias}`);
64
+ }
65
+ if (err.errorCode === 'style_medium_unavailable') {
66
+ this.error(`${err.message}\nSee what it has: faces style:versions ${args.alias}`);
67
+ }
68
+ if (err.statusCode === 404)
69
+ this.error(`No face named '${args.alias}'. It does not exist, or is not yours.`);
70
+ this.error(`HTTP ${err.statusCode}: ${err.message}`);
71
+ }
72
+ throw err;
73
+ }
74
+ if (this.jsonEnabled())
75
+ return data;
76
+ const scoped = data.scoped === true || typeof data.medium === 'string';
77
+ const medium = data.medium;
78
+ this.log(scoped && medium
79
+ ? `'${args.alias}' has forgotten its ${medium} style. Its other styles and all its source material are untouched.`
80
+ : `'${args.alias}' has forgotten its styles. Its source material is untouched.`);
81
+ this.log(`Build it again with: faces style:make ${args.alias} --all`);
82
+ return data;
83
+ }
84
+ async mediaOf(client, alias) {
85
+ try {
86
+ return faceStyles((await client.get(`/v1/faces/${seg(alias)}`)));
87
+ }
88
+ catch {
89
+ return [];
90
+ }
91
+ }
92
+ }
@@ -0,0 +1,28 @@
1
+ import { BaseCommand } from '../../base.js';
2
+ export default class StyleMake extends BaseCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ source: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ all: import("@oclif/core/interfaces").BooleanFlag<boolean>;
8
+ medium: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ model: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ 'allow-paid': import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
+ compile: import("@oclif/core/interfaces").BooleanFlag<boolean>;
12
+ 'no-wait': import("@oclif/core/interfaces").BooleanFlag<boolean>;
13
+ timeout: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
14
+ 'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
15
+ token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
16
+ 'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
17
+ toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
18
+ };
19
+ static args: {
20
+ alias: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
21
+ };
22
+ run(): Promise<unknown>;
23
+ private load;
24
+ private select;
25
+ private checkBilling;
26
+ private reportStartFailure;
27
+ private awaitJob;
28
+ }