@faces-sh/cli 1.0.3 → 1.2.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 (70) hide show
  1. package/README.md +107 -53
  2. package/dist/billing.js +11 -8
  3. package/dist/{commands/causes.d.ts → chat-command.d.ts} +13 -13
  4. package/dist/chat-command.js +110 -0
  5. package/dist/chat.d.ts +47 -0
  6. package/dist/chat.js +157 -0
  7. package/dist/choices.d.ts +20 -0
  8. package/dist/choices.js +49 -0
  9. package/dist/commands/auth/connect.js +2 -2
  10. package/dist/commands/billing/llm-costs.js +9 -5
  11. package/dist/commands/billing/subscription/index.js +1 -1
  12. package/dist/commands/catalog/doctor.js +9 -68
  13. package/dist/commands/chat/chat.d.ts +10 -26
  14. package/dist/commands/chat/chat.js +21 -366
  15. package/dist/commands/chat/messages.d.ts +13 -13
  16. package/dist/commands/chat/messages.js +15 -142
  17. package/dist/commands/chat/responses.d.ts +13 -14
  18. package/dist/commands/chat/responses.js +16 -153
  19. package/dist/commands/chat/thread.d.ts +3 -15
  20. package/dist/commands/chat/thread.js +128 -362
  21. package/dist/commands/choices.d.ts +20 -0
  22. package/dist/commands/choices.js +91 -0
  23. package/dist/commands/conversation/add.d.ts +2 -0
  24. package/dist/commands/conversation/add.js +21 -10
  25. package/dist/commands/conversation/close.js +5 -5
  26. package/dist/commands/conversation/compact.js +15 -18
  27. package/dist/commands/conversation/create.d.ts +2 -0
  28. package/dist/commands/conversation/create.js +20 -17
  29. package/dist/commands/conversation/get.js +4 -4
  30. package/dist/commands/conversation/items.js +5 -5
  31. package/dist/commands/decide.d.ts +4 -4
  32. package/dist/commands/decide.js +70 -81
  33. package/dist/commands/face/get.js +2 -2
  34. package/dist/commands/group/add.js +1 -1
  35. package/dist/commands/media/list.d.ts +12 -0
  36. package/dist/commands/media/list.js +35 -0
  37. package/dist/commands/models/list.js +16 -5
  38. package/dist/commands/session/close.js +1 -1
  39. package/dist/commands/session/compact.js +6 -9
  40. package/dist/commands/session/create.js +10 -9
  41. package/dist/commands/session/get.js +1 -1
  42. package/dist/commands/state/add.d.ts +3 -0
  43. package/dist/commands/state/add.js +3 -0
  44. package/dist/commands/state/close.d.ts +3 -0
  45. package/dist/commands/state/close.js +3 -0
  46. package/dist/commands/state/compact.d.ts +3 -0
  47. package/dist/commands/state/compact.js +3 -0
  48. package/dist/commands/state/create.d.ts +3 -0
  49. package/dist/commands/state/create.js +3 -0
  50. package/dist/commands/state/get.d.ts +3 -0
  51. package/dist/commands/state/get.js +3 -0
  52. package/dist/commands/state/items.d.ts +3 -0
  53. package/dist/commands/state/items.js +3 -0
  54. package/dist/commands/style/make.js +2 -6
  55. package/dist/commands/style/upload.js +1 -1
  56. package/dist/conversation.d.ts +27 -2
  57. package/dist/conversation.js +91 -16
  58. package/dist/decisions.d.ts +0 -5
  59. package/dist/decisions.js +0 -18
  60. package/dist/media.d.ts +8 -0
  61. package/dist/media.js +12 -0
  62. package/dist/model.d.ts +11 -0
  63. package/dist/model.js +53 -0
  64. package/dist/routing.d.ts +1 -4
  65. package/dist/routing.js +4 -40
  66. package/dist/utils.d.ts +1 -25
  67. package/dist/utils.js +10 -108
  68. package/oclif.manifest.json +2054 -1649
  69. package/package.json +10 -7
  70. package/dist/commands/causes.js +0 -146
@@ -0,0 +1,20 @@
1
+ export declare const CHOICES_PATH = "/v1/choices";
2
+ export { MAESTROS as CHOICES_MAESTROS } from './model.js';
3
+ export declare const MAX_CHOICES = 32;
4
+ export declare const MAX_STATE_TOKENS = 3000;
5
+ export interface ChoicesResponse {
6
+ object?: string;
7
+ model?: string;
8
+ choices?: Array<{
9
+ name?: string;
10
+ description?: string;
11
+ }>;
12
+ question?: string;
13
+ alternatives?: string[];
14
+ usage?: {
15
+ input_tokens?: number;
16
+ output_tokens?: number;
17
+ };
18
+ }
19
+ export declare function choicesLines(data: ChoicesResponse): string[];
20
+ export declare function choicesHint(status: number, message: string, model: string): string | undefined;
@@ -0,0 +1,49 @@
1
+ import { parseModel } from './model.js';
2
+ export const CHOICES_PATH = '/v1/choices';
3
+ export { MAESTROS as CHOICES_MAESTROS } from './model.js';
4
+ export const MAX_CHOICES = 32;
5
+ export const MAX_STATE_TOKENS = 3000;
6
+ function faceOf(model) {
7
+ return model ? parseModel(model).faces ?? model : undefined;
8
+ }
9
+ export function choicesLines(data) {
10
+ const lines = [];
11
+ if (data.object === 'choices.question') {
12
+ lines.push(`${faceOf(data.model) ?? 'The face'} would ask: ${data.question ?? '-'}`);
13
+ const alts = data.alternatives ?? [];
14
+ if (alts.length > 0) {
15
+ lines.push('', 'Or:');
16
+ for (const a of alts)
17
+ lines.push(` - ${a}`);
18
+ }
19
+ lines.push('', 'Ask it with --question to get the options.');
20
+ }
21
+ else {
22
+ const choices = data.choices ?? [];
23
+ if (choices.length === 0)
24
+ lines.push('No options.');
25
+ choices.forEach((c, i) => {
26
+ lines.push(`${i + 1}. ${c.name ?? '-'}`);
27
+ if (c.description)
28
+ lines.push(` ${c.description}`);
29
+ });
30
+ }
31
+ const u = data.usage;
32
+ if (u && (typeof u.input_tokens === 'number' || typeof u.output_tokens === 'number')) {
33
+ lines.push('', `${data.model ?? 'model'}: ${(u.input_tokens ?? 0).toLocaleString('en-US')} input, ${(u.output_tokens ?? 0).toLocaleString('en-US')} output tokens`);
34
+ }
35
+ return lines;
36
+ }
37
+ export function choicesHint(status, message, model) {
38
+ const face = (parseModel(model).faces ?? model).replace(/^@/, '').replace('~', ':');
39
+ if (status === 422 && /at most 3,000/.test(message)) {
40
+ return 'Put the situation in a state, one premise per fact (faces state:create, then faces state:add), and pass --state-id.';
41
+ }
42
+ if (status === 409 && /nothing compiled/i.test(message))
43
+ return `Give it a first source: faces compile:upload ${face} --file <file>.`;
44
+ if (status === 409 && /compiled before/i.test(message))
45
+ return `Recompile one of its sources (list them with: faces face:sources ${face}).`;
46
+ if (status === 404 && /state/i.test(message))
47
+ return 'A state expires 30 days after it was last used. Start another with: faces state:create';
48
+ return undefined;
49
+ }
@@ -17,7 +17,7 @@ function planLabel(plan) {
17
17
  return plan.charAt(0).toUpperCase() + plan.slice(1);
18
18
  }
19
19
  export default class AuthConnect extends BaseCommand {
20
- static description = 'Link your ChatGPT account by device-code authorization (Connect and Pro). Codex-eligible models then run on the ChatGPT plan, at /v1/responses.';
20
+ static description = 'Link your ChatGPT account by device-code authorization (Connect and Pro). Interviews and style builds then run on the ChatGPT plan instead of credits.';
21
21
  static args = {
22
22
  provider: Args.string({
23
23
  description: 'OAuth provider to connect',
@@ -128,7 +128,7 @@ export default class AuthConnect extends BaseCommand {
128
128
  this.log('⚠️ Your ChatGPT plan may not include API access. Connecting requires a paid plan (Plus/Pro/Team, etc.).');
129
129
  }
130
130
  else {
131
- this.log('Codex-eligible models (see faces models:list --chatgpt) now run on your ChatGPT plan, at /v1/responses.');
131
+ this.log('Interviews and style builds now run on your ChatGPT plan where the model allows it.');
132
132
  }
133
133
  }
134
134
  return output;
@@ -5,7 +5,7 @@ import { table, usd } from '../../utils.js';
5
5
  import { llmCostLab } from '../../billing.js';
6
6
  export default class BillingLlmCosts extends BaseCommand {
7
7
  static description = 'List available LLMs, their per-token costs and what you have spent on each. Models are listed once, ' +
8
- 'under the id their lab gives them. Compile and cause prices, and what each plan includes, are listed ' +
8
+ 'under the id their lab gives them. Maestro and compile prices, and what each plan includes, are listed ' +
9
9
  'after the table. For the full catalog, with endpoints and which models are Codex-eligible, see faces models:list.';
10
10
  static flags = {
11
11
  ...BaseCommand.baseFlags,
@@ -65,7 +65,7 @@ export default class BillingLlmCosts extends BaseCommand {
65
65
  async facesPrices(client) {
66
66
  let models;
67
67
  try {
68
- const raw = (await client.get('/v1/models', { params: { kind: 'compile,cause' } }));
68
+ const raw = (await client.get('/v1/models', { params: { kind: 'upstream,compile' } }));
69
69
  models = (Array.isArray(raw) ? raw : (raw.data ?? []));
70
70
  }
71
71
  catch {
@@ -85,9 +85,13 @@ export default class BillingLlmCosts extends BaseCommand {
85
85
  lines.push(`Compiling (${m.id}): $${per} per million source tokens compiled${markup}.` +
86
86
  (plans.length > 0 ? ` Included each month: ${plans.join(', ')} tokens; past that, credits pay.` : ''));
87
87
  }
88
- else if (m.kind === 'cause') {
89
- const added = typeof m.added_tokens_per_request === 'number' ? ` plus ${m.added_tokens_per_request.toLocaleString('en-US')} tokens a request` : '';
90
- lines.push(`Causes (${m.id}): $${per} per million input tokens${added}${markup}.`);
88
+ else if (m.kind === 'upstream') {
89
+ const out = m.output_cost_per_million_tokens;
90
+ lines.push(`${m.id} on choices: $${per} per million input tokens${typeof out === 'number' ? `, $${out} per million output` : ''}${markup}.`);
91
+ const st = m.steering;
92
+ if (st && typeof st.input_cost_per_million_tokens === 'number') {
93
+ lines.push(`${m.id} steering chat and decisions: $${st.input_cost_per_million_tokens} per million input tokens plus $${st.cost_per_call_usd} a call, no output charge.`);
94
+ }
91
95
  }
92
96
  }
93
97
  return lines.length > 0 ? ['', ...lines] : [];
@@ -3,7 +3,7 @@ import { FacesAPIError } from '../../../client.js';
3
3
  import { allowanceLines, planName } from '../../../billing.js';
4
4
  export default class BillingSubscription extends BaseCommand {
5
5
  static description = 'Show your plan (free, connect or pro), renewal date, and on a paid plan how much of each ' +
6
- 'allowance is used: causes over 5 hours, the week and the month, and compiling over the month';
6
+ 'allowance is used: choices and steering over 5 hours, the week and the month, and compiling over the month';
7
7
  static flags = {
8
8
  ...BaseCommand.baseFlags,
9
9
  };
@@ -3,32 +3,27 @@ import path from 'node:path';
3
3
  import { Flags } from '@oclif/core';
4
4
  import { BaseCommand } from '../../base.js';
5
5
  import { FacesAPIError } from '../../client.js';
6
- import { loadConfig } from '../../config.js';
7
- import { unquoteYaml, seg, postChat } from '../../utils.js';
6
+ import { unquoteYaml, seg } from '../../utils.js';
8
7
  import { CatalogService, CATALOG_DIR } from '../../catalog.js';
9
8
  import { GroupCatalogService, GROUPS_DIR, slugifyGroupName } from '../../group-catalog.js';
10
- import { resolveEndpoint, MESSAGES_ENDPOINT, RESPONSES_ENDPOINT } from '../../routing.js';
11
9
  export default class CatalogDoctor extends BaseCommand {
12
- static description = 'Diagnose and repair the local face and group catalog. --generate bills, so it needs --allow-paid.';
10
+ static description = 'Diagnose and repair the local face and group catalog.';
13
11
  static flags = {
14
12
  ...BaseCommand.baseFlags,
15
13
  fix: Flags.boolean({ description: 'Rebuild missing or stale catalog entries from API', default: false }),
16
14
  generate: Flags.boolean({
17
- description: 'Fix, then write a description for each face that has none by asking the face. This bills: each one ' +
18
- 'is a chat on gpt-5-nano (or the catalog_model you set), charged to credits. Needs --allow-paid.',
19
- default: false,
20
- }),
21
- 'allow-paid': Flags.boolean({
22
- description: 'Permit the charge for --generate. Without this flag --generate sends nothing and nothing is charged.',
15
+ description: 'Retired. Write a description with faces face:edit <alias> --description.',
23
16
  default: false,
17
+ hidden: true,
24
18
  }),
19
+ 'allow-paid': Flags.boolean({ description: 'Retired with --generate.', default: false, hidden: true }),
25
20
  };
26
21
  async run() {
27
22
  const { flags } = await this.parse(CatalogDoctor);
28
- if (flags.generate && !flags['allow-paid']) {
29
- this.error('Generating descriptions bills your account: each one is a chat with the face, charged to credits. ' +
30
- 'Re-run with --allow-paid if you meant to pay.\n' +
31
- 'To repair the catalog without generating anything, which is free: faces catalog:doctor --fix');
23
+ if (flags.generate) {
24
+ this.error('--generate is retired. Nothing was sent.\n' +
25
+ 'Write a description with: faces face:edit <alias> --description "..."\n' +
26
+ 'To repair the catalog, which is free: faces catalog:doctor --fix');
32
27
  }
33
28
  const client = this.makeClient(flags);
34
29
  const catalog = new CatalogService();
@@ -236,60 +231,6 @@ export default class CatalogDoctor extends BaseCommand {
236
231
  if (!groupsFetched) {
237
232
  this.log('Could not reach the groups API, so local groups were not checked against the server.');
238
233
  }
239
- if (flags.generate && noDescription.length > 0) {
240
- const cfg = loadConfig();
241
- const catalogModel = cfg.catalog_model ?? 'gpt-5-nano';
242
- this.log(`Generating descriptions for ${noDescription.length} face(s) via ${catalogModel}...`);
243
- const { endpoint: descEndpoint } = await resolveEndpoint(client, `_@${catalogModel}`);
244
- let generated = 0;
245
- for (const alias of noDescription) {
246
- const remote = remoteByAlias.get(alias);
247
- if (!remote)
248
- continue;
249
- try {
250
- const prompt = 'Describe yourself in one paragraph. Who are you, what do you care about, and what kind of questions are you best suited to answer?';
251
- const faceModel = `${alias}@${catalogModel}`;
252
- let text;
253
- if (descEndpoint === MESSAGES_ENDPOINT) {
254
- const resp = (await postChat(client, '/v1/messages', { model: faceModel, messages: [{ role: 'user', content: prompt }], max_tokens: 256 })).data;
255
- text = resp.content?.find((b) => b.type === 'text')?.text;
256
- }
257
- else if (descEndpoint === RESPONSES_ENDPOINT) {
258
- const resp = (await postChat(client, '/v1/responses', { model: faceModel, input: [{ role: 'user', content: prompt }], max_output_tokens: 256 })).data;
259
- let out = '';
260
- for (const item of resp.output ?? []) {
261
- for (const block of item.content ?? []) {
262
- if (block.type === 'output_text')
263
- out += block.text ?? '';
264
- }
265
- }
266
- text = out || undefined;
267
- }
268
- else {
269
- const resp = (await postChat(client, '/v1/chat/completions', { model: faceModel, messages: [{ role: 'user', content: prompt }], max_tokens: 256 })).data;
270
- text = resp.choices?.[0]?.message?.content;
271
- }
272
- if (text) {
273
- const desc = text.trim();
274
- catalog.writeFace({ ...remote, description: desc });
275
- try {
276
- await client.patch(`/v1/faces/${seg(alias)}`, { body: { description: desc } });
277
- }
278
- catch { }
279
- generated++;
280
- this.log(` ${alias}: done`);
281
- }
282
- else {
283
- this.log(` ${alias}: no response`);
284
- }
285
- }
286
- catch (err) {
287
- const msg = err instanceof FacesAPIError ? `HTTP ${err.statusCode}: ${err.message}` : String(err);
288
- this.log(` ${alias}: failed: ${msg}`);
289
- }
290
- }
291
- this.log(`Generated ${generated} description(s).`);
292
- }
293
234
  catalog.rebuildIndex();
294
235
  return {
295
236
  fixed,
@@ -1,47 +1,31 @@
1
- import { BaseCommand } from '../../base.js';
2
- export default class ChatChat extends BaseCommand {
1
+ import { ChatCommand } from '../../chat-command.js';
2
+ export default class ChatChat extends ChatCommand {
3
3
  static description: string;
4
4
  static examples: string[];
5
+ static args: {
6
+ model: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
7
+ };
5
8
  static flags: {
9
+ responses: import("@oclif/core/interfaces").BooleanFlag<boolean>;
6
10
  session: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
11
  compaction: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
12
  'oauth-only': import("@oclif/core/interfaces").BooleanFlag<boolean>;
9
- 'show-cause': import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
- cause: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
- 'cause-file': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
- 'cause-only': import("@oclif/core/interfaces").BooleanFlag<boolean>;
13
13
  conversation: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
14
  premise: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
15
15
  'premise-description': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
16
+ 'premise-status': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
17
+ 'premise-depends-on': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
16
18
  'causes-visible': import("@oclif/core/interfaces").BooleanFlag<boolean>;
17
19
  message: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
18
- llm: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
19
- formula: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
20
+ file: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
20
21
  system: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
21
22
  stream: import("@oclif/core/interfaces").BooleanFlag<boolean>;
22
23
  'max-tokens': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
23
24
  temperature: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
24
- file: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
25
- responses: import("@oclif/core/interfaces").BooleanFlag<boolean>;
26
- style: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
27
- medium: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
28
25
  'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
29
26
  token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
30
27
  'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
31
28
  toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
32
29
  };
33
- static args: {
34
- face_username: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
35
- };
36
- run(): Promise<unknown>;
37
- private oauthHint;
38
- private metaFor;
39
- private streamDeltas;
40
- private printReply;
41
- private noteReasoningOnly;
42
- private reasoningOnly;
43
- private conversationBody;
44
- private runChatCompletions;
45
- private runMessages;
46
- private runResponses;
30
+ protected forcedEndpoint(flags: Record<string, unknown>): string | undefined;
47
31
  }