@faces-sh/cli 1.0.0 → 1.0.2

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 (49) hide show
  1. package/README.md +32 -7
  2. package/dist/commands/auth/connections.js +1 -1
  3. package/dist/commands/billing/card/default.js +1 -1
  4. package/dist/commands/billing/card/remove.js +1 -1
  5. package/dist/commands/billing/card-setup.js +1 -1
  6. package/dist/commands/billing/subscription/activate.js +2 -2
  7. package/dist/commands/billing/subscription/cancel.js +1 -1
  8. package/dist/commands/billing/subscription/plan.js +1 -1
  9. package/dist/commands/billing/topup.js +2 -2
  10. package/dist/commands/causes.d.ts +6 -2
  11. package/dist/commands/causes.js +11 -0
  12. package/dist/commands/chat/chat.d.ts +12 -7
  13. package/dist/commands/chat/chat.js +19 -6
  14. package/dist/commands/chat/messages.d.ts +10 -6
  15. package/dist/commands/chat/messages.js +10 -1
  16. package/dist/commands/chat/responses.d.ts +10 -6
  17. package/dist/commands/chat/responses.js +10 -1
  18. package/dist/commands/chat/thread.d.ts +17 -10
  19. package/dist/commands/chat/thread.js +20 -6
  20. package/dist/commands/conversation/add.d.ts +18 -0
  21. package/dist/commands/conversation/add.js +66 -0
  22. package/dist/commands/conversation/close.d.ts +16 -0
  23. package/dist/commands/conversation/close.js +36 -0
  24. package/dist/commands/conversation/compact.d.ts +16 -0
  25. package/dist/commands/conversation/compact.js +69 -0
  26. package/dist/commands/conversation/create.d.ts +19 -0
  27. package/dist/commands/conversation/create.js +76 -0
  28. package/dist/commands/conversation/get.d.ts +15 -0
  29. package/dist/commands/conversation/get.js +35 -0
  30. package/dist/commands/conversation/items.d.ts +15 -0
  31. package/dist/commands/conversation/items.js +45 -0
  32. package/dist/commands/decide.d.ts +8 -4
  33. package/dist/commands/decide.js +10 -0
  34. package/dist/commands/face/delete.js +1 -1
  35. package/dist/commands/face/publish.js +1 -0
  36. package/dist/commands/face/share.js +1 -0
  37. package/dist/commands/face/unpublish.js +1 -0
  38. package/dist/commands/face/unshare.js +1 -1
  39. package/dist/commands/session/close.js +1 -1
  40. package/dist/commands/session/compact.js +1 -1
  41. package/dist/commands/session/create.js +1 -1
  42. package/dist/commands/session/get.js +1 -1
  43. package/dist/commands/style/delete.js +16 -14
  44. package/dist/conversation.d.ts +63 -0
  45. package/dist/conversation.js +237 -0
  46. package/dist/utils.d.ts +1 -1
  47. package/dist/utils.js +4 -3
  48. package/oclif.manifest.json +3007 -2319
  49. package/package.json +4 -1
package/README.md CHANGED
@@ -58,7 +58,8 @@ faces face:tag:add / list / remove / set / all
58
58
  faces causes # a face's cause alone
59
59
  faces chat:chat / messages / responses / thread
60
60
  faces decide # what a face would decide: yes/no, a choice, or a score
61
- faces session:create / get / compact / close
61
+ faces conversation:create / get / items / add / compact / close
62
+ faces session:create / get / compact / close # the old name for conversations
62
63
 
63
64
  faces compile:doc / compile:doc:create / list / get / edit / make / pause / reset / delete
64
65
  faces compile:thread:create / list / get / edit / message / replace / make / pause / reset / delete
@@ -121,18 +122,42 @@ faces chat:chat alice -m "Reply to the note below." --style email
121
122
  A build runs at no charge on Connect or Pro with a linked ChatGPT account. Anywhere else it is
122
123
  charged to credits at the build model's listed price, so `style:make` needs `--allow-paid`.
123
124
 
124
- ## Sessions
125
+ ## Conversations
125
126
 
126
- A session groups the turns of one conversation with one face. Compacting it returns a summary
127
- under a compaction id, which a later request reads in place of the history you no longer send.
127
+ A conversation keeps the whole exchange on the server: your messages, each face's reply with its
128
+ cause, decisions, and **premises**, named facts your decisions depend on. Send only what is new on
129
+ each turn; the conversation so far is read before it.
128
130
 
129
131
  ```bash
130
- faces session:create alice
131
- faces chat:chat alice -m "Should I take the offer?" --session fs_SESSION_ID
132
- faces session:compact fs_SESSION_ID
132
+ faces conversation:create alice # leave the face out to take any of your faces
133
+ faces chat:chat alice -m "Is this vendor worth a closer look?" --conversation fs_CONVERSATION_ID \
134
+ --premise budget_usd=50000 --premise-description budget_usd="the most we can spend this year"
135
+ faces decide alice --conversation fs_CONVERSATION_ID --state "The vendor sent a contract." \
136
+ --question "Does the speaker sign?"
137
+ faces conversation:add fs_CONVERSATION_ID --premise vendor_certified=false \
138
+ --premise-description vendor_certified="the vendor holds a security audit report"
139
+ faces conversation:items fs_CONVERSATION_ID
140
+ faces conversation:compact fs_CONVERSATION_ID
133
141
  faces chat:chat alice -m "So what do I tell them tomorrow?" --compaction fcmp_COMPACTION_ID
134
142
  ```
135
143
 
144
+ `--conversation`, `--premise` and `--premise-description` work on `chat:chat`, `chat:messages`,
145
+ `chat:responses`, `chat:thread`, `decide` and `causes`.
146
+
147
+ A premise is `--premise key=value`, repeatable. The key is 1 to 64 letters, digits, `_` or `-`. The
148
+ value is read as JSON when it is JSON (`50000`, `true`, `null`, `["a","b"]`) and as text otherwise;
149
+ quote it to keep a number as text: `--premise 'code="007"'`. The first time a key is used it needs
150
+ a description, given by key: `--premise-description key="what it means"`. A newer value of a key
151
+ replaces it from then on, and `conversation:add` lists every earlier decision made under the old
152
+ value. Nothing is decided again for you.
153
+
154
+ In a conversation that takes any face, each turn names its face, and `--no-causes-visible` on
155
+ `conversation:create` (or on a turn) keeps each face from reading the others' causes. Compacting
156
+ one names the face: `faces conversation:compact fs_CONVERSATION_ID alice`.
157
+
158
+ Conversations were called sessions. The `session:*` commands and `--session` still work and name
159
+ the same thing.
160
+
136
161
  ## Authentication
137
162
 
138
163
  Login stores a JWT at `~/.faces/config.json`. You can also authenticate with environment variables:
@@ -11,7 +11,7 @@ export default class AuthConnections extends BaseCommand {
11
11
  async run() {
12
12
  const { flags } = await this.parse(AuthConnections);
13
13
  const client = this.makeClient(flags);
14
- const data = await client.get('/v1/oauth');
14
+ const data = await client.get('/v1/oauth', { requireJwt: true });
15
15
  if (!this.jsonEnabled()) {
16
16
  const rows = data;
17
17
  if (!rows || rows.length === 0) {
@@ -16,7 +16,7 @@ export default class BillingCardDefault extends BaseCommand {
16
16
  const client = this.makeClient(flags);
17
17
  let data;
18
18
  try {
19
- data = await client.post(`/v1/billing/payment-methods/${seg(args.card_id)}/default`);
19
+ data = await client.post(`/v1/billing/payment-methods/${seg(args.card_id)}/default`, { requireJwt: true });
20
20
  }
21
21
  catch (err) {
22
22
  if (err instanceof FacesAPIError) {
@@ -19,7 +19,7 @@ export default class BillingCardRemove extends BaseCommand {
19
19
  await this.confirmOrRefuse(`Remove card ${args.card_id}?`, flags.yes);
20
20
  let data;
21
21
  try {
22
- data = await client.delete(`/v1/billing/payment-methods/${seg(args.card_id)}`);
22
+ data = await client.delete(`/v1/billing/payment-methods/${seg(args.card_id)}`, { requireJwt: true });
23
23
  }
24
24
  catch (err) {
25
25
  if (err instanceof FacesAPIError) {
@@ -18,7 +18,7 @@ export default class BillingCardSetup extends BaseCommand {
18
18
  const client = this.makeClient(flags);
19
19
  let data;
20
20
  try {
21
- data = await client.post('/v1/billing/card-setup', flags.default ? {} : { body: { make_default: false } });
21
+ data = await client.post('/v1/billing/card-setup', flags.default ? { requireJwt: true } : { requireJwt: true, body: { make_default: false } });
22
22
  }
23
23
  catch (err) {
24
24
  if (err instanceof FacesAPIError)
@@ -41,7 +41,7 @@ export default class BillingSubscriptionActivate extends BaseCommand {
41
41
  if (plan === want && cancelAtPeriodEnd) {
42
42
  let data;
43
43
  try {
44
- data = await client.post('/v1/billing/subscription/reactivate');
44
+ data = await client.post('/v1/billing/subscription/reactivate', { requireJwt: true });
45
45
  }
46
46
  catch (err) {
47
47
  if (err instanceof FacesAPIError)
@@ -66,7 +66,7 @@ export default class BillingSubscriptionActivate extends BaseCommand {
66
66
  }
67
67
  let data;
68
68
  try {
69
- data = await client.post(`/v1/billing/checkout?plan=${want}&source=cli`);
69
+ data = await client.post(`/v1/billing/checkout?plan=${want}&source=cli`, { requireJwt: true });
70
70
  }
71
71
  catch (err) {
72
72
  if (err instanceof FacesAPIError) {
@@ -37,7 +37,7 @@ export default class BillingSubscriptionCancel extends BaseCommand {
37
37
  await this.confirmOrRefuse(`Cancel the ${name} plan? You'll keep access until ${periodEnd}.`, flags.yes);
38
38
  let data;
39
39
  try {
40
- data = await client.post('/v1/billing/subscription/cancel');
40
+ data = await client.post('/v1/billing/subscription/cancel', { requireJwt: true });
41
41
  }
42
42
  catch (err) {
43
43
  if (err instanceof FacesAPIError)
@@ -49,7 +49,7 @@ export default class BillingSubscriptionPlan extends BaseCommand {
49
49
  await this.confirmOrRefuse(`Switch from ${planName(plan)} to ${planName(want)} (${PLAN_PRICE[want]})? The difference is prorated on your default card.`, flags.yes);
50
50
  let data;
51
51
  try {
52
- data = await client.post(`/v1/billing/subscription/plan?plan=${want}`);
52
+ data = await client.post(`/v1/billing/subscription/plan?plan=${want}`, { requireJwt: true });
53
53
  }
54
54
  catch (err) {
55
55
  if (err instanceof FacesAPIError && err.statusCode >= 500) {
@@ -29,7 +29,7 @@ export default class BillingTopup extends BaseCommand {
29
29
  payload.allow_duplicate = true;
30
30
  let data;
31
31
  try {
32
- data = await client.post('/v1/billing/topup', { body: payload });
32
+ data = await client.post('/v1/billing/topup', { requireJwt: true, body: payload });
33
33
  }
34
34
  catch (err) {
35
35
  if (!(err instanceof FacesAPIError && err.statusCode === 409 && err.errorCode === 'duplicate_topup'))
@@ -39,7 +39,7 @@ export default class BillingTopup extends BaseCommand {
39
39
  }
40
40
  await this.confirmOrRefuse(`${err.message}\nCharge $${amount.toFixed(2)} again anyway?`, false);
41
41
  try {
42
- data = await client.post('/v1/billing/topup', { body: { ...payload, allow_duplicate: true } });
42
+ data = await client.post('/v1/billing/topup', { requireJwt: true, body: { ...payload, allow_duplicate: true } });
43
43
  }
44
44
  catch (again) {
45
45
  this.fail(again, flags.card);
@@ -3,6 +3,12 @@ export default class Causes extends BaseCommand {
3
3
  static description: string;
4
4
  static examples: string[];
5
5
  static flags: {
6
+ session: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ compaction: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ conversation: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ premise: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ 'premise-description': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ 'causes-visible': import("@oclif/core/interfaces").BooleanFlag<boolean>;
6
12
  message: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
13
  file: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
14
  state: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
@@ -13,8 +19,6 @@ export default class Causes extends BaseCommand {
13
19
  level: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
20
  id: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
15
21
  'questions-file': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
16
- session: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
17
- compaction: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
18
22
  'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
19
23
  token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
20
24
  'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
@@ -2,6 +2,7 @@ import fs from 'node:fs';
2
2
  import { Args, Flags } from '@oclif/core';
3
3
  import { BaseCommand } from '../base.js';
4
4
  import { FacesAPIError } from '../client.js';
5
+ import { conversationFields, conversationTurnFlags } from '../conversation.js';
5
6
  import { QUESTION_TYPES, causeLines, heldDecisionError, readQuestionFlags, readStateFlags } from '../decisions.js';
6
7
  import { compileHint, isMeAlias, ME_MISSING, retryOnceOnWarmUp, sayWarmUp, SESSION_FLAG_DESCRIPTION, COMPACTION_FLAG_DESCRIPTION } from '../utils.js';
7
8
  const MAX_CAUSE_QUESTIONS = 10;
@@ -16,6 +17,7 @@ export default class Causes extends BaseCommand {
16
17
  '<%= config.bin %> <%= command.id %> alice --state-file situation.txt --question "Does the speaker take the money?"',
17
18
  '<%= config.bin %> <%= command.id %> "(alice | bob)" -m "What matters most here?" --json',
18
19
  '<%= config.bin %> <%= command.id %> alice -m "So what do I tell them tomorrow?" --compaction fcmp_COMPACTION_ID',
20
+ '<%= config.bin %> <%= command.id %> alice -m "And now?" --conversation fs_CONVERSATION_ID --premise vendor_certified=false',
19
21
  ];
20
22
  static flags = {
21
23
  ...BaseCommand.baseFlags,
@@ -47,6 +49,7 @@ export default class Causes extends BaseCommand {
47
49
  description: `A JSON file of 1 to ${MAX_CAUSE_QUESTIONS} questions in System One's format, as for faces decide. Needs --state or --state-file.`,
48
50
  exclusive: ['question'],
49
51
  }),
52
+ ...conversationTurnFlags(),
50
53
  session: Flags.string({ description: SESSION_FLAG_DESCRIPTION }),
51
54
  compaction: Flags.string({ description: COMPACTION_FLAG_DESCRIPTION }),
52
55
  };
@@ -65,6 +68,13 @@ export default class Causes extends BaseCommand {
65
68
  this.error(`A cause is the face's alone, so leave the model off: ${face.slice(0, face.lastIndexOf('@'))}\nTo have a model answer, use faces chat:chat.`);
66
69
  }
67
70
  const fail = (m) => this.error(m);
71
+ let turn = {};
72
+ try {
73
+ turn = conversationFields(flags);
74
+ }
75
+ catch (err) {
76
+ fail(err instanceof Error ? err.message : String(err));
77
+ }
68
78
  const body = { model: face };
69
79
  const situation = flags.state !== undefined || flags['state-file'] !== undefined;
70
80
  const questions = readQuestionFlags(flags, fail);
@@ -98,6 +108,7 @@ export default class Causes extends BaseCommand {
98
108
  body.session = flags.session;
99
109
  if (flags.compaction)
100
110
  body.compaction = flags.compaction;
111
+ Object.assign(body, turn);
101
112
  let data;
102
113
  try {
103
114
  data = (await retryOnceOnWarmUp(async () => {
@@ -3,6 +3,17 @@ export default class ChatChat extends BaseCommand {
3
3
  static description: string;
4
4
  static examples: string[];
5
5
  static flags: {
6
+ session: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ compaction: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ '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
+ conversation: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
+ premise: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
15
+ 'premise-description': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
16
+ 'causes-visible': import("@oclif/core/interfaces").BooleanFlag<boolean>;
6
17
  message: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
18
  llm: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
19
  formula: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
@@ -14,13 +25,6 @@ export default class ChatChat extends BaseCommand {
14
25
  responses: import("@oclif/core/interfaces").BooleanFlag<boolean>;
15
26
  style: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
16
27
  medium: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
17
- session: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
18
- compaction: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
19
- 'oauth-only': import("@oclif/core/interfaces").BooleanFlag<boolean>;
20
- 'show-cause': import("@oclif/core/interfaces").BooleanFlag<boolean>;
21
- cause: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
22
- 'cause-file': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
23
- 'cause-only': import("@oclif/core/interfaces").BooleanFlag<boolean>;
24
28
  'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
25
29
  token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
26
30
  'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
@@ -36,6 +40,7 @@ export default class ChatChat extends BaseCommand {
36
40
  private printReply;
37
41
  private noteReasoningOnly;
38
42
  private reasoningOnly;
43
+ private conversationBody;
39
44
  private runChatCompletions;
40
45
  private runMessages;
41
46
  private runResponses;
@@ -4,20 +4,23 @@ import { BaseCommand } from '../../base.js';
4
4
  import { chatgptLinked } from '../../style.js';
5
5
  import { FacesAPIError } from '../../client.js';
6
6
  import { postChat, writeReply, streamChat, resolveCause, CAUSE_FLAG_DESCRIPTION, CAUSE_FILE_FLAG_DESCRIPTION, retryOnceOnWarmUp, sayWarmUp, faceRefusalHint, STREAM_FLAG_DESCRIPTION, extractReasoning, extractStreamDelta, extractStreamReasoning, reasoningHeading, reasoningOnlyNote, REASONING_FLAG_DESCRIPTION, isMaxTokensRenameError, MIN_MAX_OUTPUT_TOKENS, STYLE_FLAG_DESCRIPTION, MEDIUM_FLAG_DESCRIPTION, SESSION_FLAG_DESCRIPTION, COMPACTION_FLAG_DESCRIPTION, chatExtras, warnDroppedParams, CHAT_PARAM_FLAGS, parseTemperature } from '../../utils.js';
7
+ import { conversationFields, conversationTurnFlags } from '../../conversation.js';
7
8
  import { resolveEndpoint, MESSAGES_ENDPOINT, RESPONSES_ENDPOINT, isCompositeFormula, faceSpecOf, llmFromArg } from '../../routing.js';
8
9
  export default class ChatChat extends BaseCommand {
9
10
  static description = 'Chat with a face on any supported model. The face\'s cause steers the model\'s answer. Routes to the ' +
10
11
  'right endpoint from the model catalog. A face named without a model answers on its default model. ' +
11
12
  '--show-cause also prints the cause, and --cause-only asks for the cause alone, with no answer. ' +
12
- 'Add --style <medium> to apply a style the face has built, and --session or --compaction to use a ' +
13
- 'session (see faces session:create).';
13
+ 'Add --style <medium> to apply a style the face has built, --conversation to take the turn in a ' +
14
+ 'conversation (see faces conversation:create), and --compaction to read a compaction.';
14
15
  static examples = [
15
16
  '<%= config.bin %> <%= command.id %> socrates -m "What is virtue?"',
16
17
  '<%= config.bin %> <%= command.id %> alice -m "Reply to the note below." --style email',
17
18
  '<%= config.bin %> <%= command.id %> socrates -m "Should I sign a grant I have not read?" --show-cause',
18
19
  '<%= config.bin %> <%= command.id %> socrates -m "Should I sign a grant I have not read?" --cause-only',
19
20
  '<%= config.bin %> <%= command.id %> socrates -m "Can you just sign it?" --cause "I will not sign what I have not read."',
20
- '<%= config.bin %> <%= command.id %> alice -m "So what do I tell them tomorrow?" --session fs_SESSION_ID',
21
+ '<%= config.bin %> <%= command.id %> alice -m "So what do I tell them tomorrow?" --conversation fs_CONVERSATION_ID',
22
+ '<%= config.bin %> <%= command.id %> alice -m "Is this vendor worth a closer look?" --conversation fs_CONVERSATION_ID ' +
23
+ '--premise budget_usd=50000 --premise-description budget_usd="the most we can spend this year"',
21
24
  '<%= config.bin %> <%= command.id %> "(socrates | nietzsche)@claude-sonnet-4-6" -m "What is virtue?"',
22
25
  '<%= config.bin %> <%= command.id %> --formula "socrates | nietzsche" --llm claude-sonnet-4-6 -m "What is virtue?"',
23
26
  ];
@@ -34,6 +37,7 @@ export default class ChatChat extends BaseCommand {
34
37
  responses: Flags.boolean({ description: 'Force the OpenAI Responses API endpoint (escape hatch; routing is automatic otherwise)', default: false }),
35
38
  style: Flags.string({ description: STYLE_FLAG_DESCRIPTION }),
36
39
  medium: Flags.string({ description: MEDIUM_FLAG_DESCRIPTION }),
40
+ ...conversationTurnFlags(),
37
41
  session: Flags.string({ description: SESSION_FLAG_DESCRIPTION }),
38
42
  compaction: Flags.string({ description: COMPACTION_FLAG_DESCRIPTION }),
39
43
  'oauth-only': Flags.boolean({ description: 'On a linked ChatGPT plan, run there or fail: never fall back to credits', default: false }),
@@ -98,6 +102,14 @@ export default class ChatChat extends BaseCommand {
98
102
  if (flags['cause-only'] && llmFromArg(model)) {
99
103
  this.error(`--cause-only asks the face alone, so leave the model off: ${faceSpecOf(model)}`);
100
104
  }
105
+ let turn;
106
+ try {
107
+ turn = conversationFields(flags);
108
+ }
109
+ catch (err) {
110
+ this.error(err instanceof Error ? err.message : String(err));
111
+ }
112
+ this.conversationBody = turn;
101
113
  const route = await resolveEndpoint(client, model);
102
114
  const endpoint = flags.responses ? RESPONSES_ENDPOINT : route.endpoint;
103
115
  if (!flags['cause-only'] && !llmFromArg(model)) {
@@ -233,6 +245,7 @@ export default class ChatChat extends BaseCommand {
233
245
  process.stderr.write(`\n${reasoningOnlyNote(model)}\n`);
234
246
  }
235
247
  reasoningOnly = false;
248
+ conversationBody = {};
236
249
  async runChatCompletions(client, model, userMessages, flags) {
237
250
  const messages = [];
238
251
  if (flags.system)
@@ -244,7 +257,7 @@ export default class ChatChat extends BaseCommand {
244
257
  payload.max_tokens = flags['max-tokens'];
245
258
  if (flags.temperature !== undefined)
246
259
  payload.temperature = parseTemperature(flags.temperature, (m) => this.error(m));
247
- Object.assign(payload, chatExtras(flags));
260
+ Object.assign(payload, chatExtras(flags), this.conversationBody);
248
261
  if (flags['oauth-only'])
249
262
  payload.oauth_only = true;
250
263
  if (flags.cause)
@@ -291,7 +304,7 @@ export default class ChatChat extends BaseCommand {
291
304
  };
292
305
  if (flags.system)
293
306
  payload.system = flags.system;
294
- Object.assign(payload, chatExtras(flags));
307
+ Object.assign(payload, chatExtras(flags), this.conversationBody);
295
308
  if (flags['oauth-only'])
296
309
  payload.oauth_only = true;
297
310
  if (flags.cause)
@@ -333,7 +346,7 @@ export default class ChatChat extends BaseCommand {
333
346
  }
334
347
  if (flags.temperature !== undefined)
335
348
  payload.temperature = parseTemperature(flags.temperature, (m) => this.error(m));
336
- Object.assign(payload, chatExtras(flags));
349
+ Object.assign(payload, chatExtras(flags), this.conversationBody);
337
350
  if (flags['oauth-only'])
338
351
  payload.oauth_only = true;
339
352
  if (flags.cause)
@@ -2,18 +2,22 @@ import { BaseCommand } from '../../base.js';
2
2
  export default class ChatMessages extends BaseCommand {
3
3
  static description: string;
4
4
  static flags: {
5
- message: import("@oclif/core/interfaces").OptionFlag<string[], import("@oclif/core/interfaces").CustomOptions>;
6
- system: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
- stream: import("@oclif/core/interfaces").BooleanFlag<boolean>;
8
- 'max-tokens': import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
9
- style: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
- medium: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
5
  session: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
6
  compaction: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
7
  'oauth-only': import("@oclif/core/interfaces").BooleanFlag<boolean>;
14
8
  'show-cause': import("@oclif/core/interfaces").BooleanFlag<boolean>;
15
9
  cause: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
16
10
  'cause-file': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ conversation: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
+ premise: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
+ 'premise-description': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
+ 'causes-visible': import("@oclif/core/interfaces").BooleanFlag<boolean>;
15
+ message: import("@oclif/core/interfaces").OptionFlag<string[], import("@oclif/core/interfaces").CustomOptions>;
16
+ system: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
17
+ stream: import("@oclif/core/interfaces").BooleanFlag<boolean>;
18
+ 'max-tokens': import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
19
+ style: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
20
+ medium: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
17
21
  'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
18
22
  token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
19
23
  'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
@@ -2,6 +2,7 @@ import { Args, Flags } from '@oclif/core';
2
2
  import { BaseCommand } from '../../base.js';
3
3
  import { postChat, writeReply, resolveCause, causeNeedsModel, CAUSE_FLAG_DESCRIPTION, CAUSE_FILE_FLAG_DESCRIPTION, retryOnceOnWarmUp, sayWarmUp, faceRefusalHint, STREAM_FLAG_DESCRIPTION, extractReasoning, extractStreamReasoning, STYLE_FLAG_DESCRIPTION, MEDIUM_FLAG_DESCRIPTION, SESSION_FLAG_DESCRIPTION, COMPACTION_FLAG_DESCRIPTION, chatExtras, reasoningHeading, reasoningOnlyNote, REASONING_FLAG_DESCRIPTION } from '../../utils.js';
4
4
  import { FacesAPIError } from '../../client.js';
5
+ import { conversationFields, conversationTurnFlags } from '../../conversation.js';
5
6
  export default class ChatMessages extends BaseCommand {
6
7
  static description = 'Chat with a face in the Anthropic Messages format (/v1/messages). chat:chat routes Anthropic models here on its own.';
7
8
  static flags = {
@@ -12,6 +13,7 @@ export default class ChatMessages extends BaseCommand {
12
13
  'max-tokens': Flags.integer({ description: 'Max tokens (at least 1)', default: 1024, min: 1 }),
13
14
  style: Flags.string({ description: STYLE_FLAG_DESCRIPTION }),
14
15
  medium: Flags.string({ description: MEDIUM_FLAG_DESCRIPTION }),
16
+ ...conversationTurnFlags(),
15
17
  session: Flags.string({ description: SESSION_FLAG_DESCRIPTION }),
16
18
  compaction: Flags.string({ description: COMPACTION_FLAG_DESCRIPTION }),
17
19
  'oauth-only': Flags.boolean({ description: 'On a linked ChatGPT plan, run there or fail: never fall back to credits', default: false }),
@@ -31,6 +33,13 @@ export default class ChatMessages extends BaseCommand {
31
33
  const { args, flags } = await this.parse(ChatMessages);
32
34
  const client = this.makeClient(flags);
33
35
  const msgs = flags.message.map((m) => ({ role: 'user', content: m }));
36
+ let turn;
37
+ try {
38
+ turn = conversationFields(flags);
39
+ }
40
+ catch (err) {
41
+ this.error(err instanceof Error ? err.message : String(err));
42
+ }
34
43
  let cause;
35
44
  try {
36
45
  cause = resolveCause(flags.cause, flags['cause-file']);
@@ -50,7 +59,7 @@ export default class ChatMessages extends BaseCommand {
50
59
  };
51
60
  if (flags.system)
52
61
  payload.system = flags.system;
53
- Object.assign(payload, chatExtras(flags));
62
+ Object.assign(payload, chatExtras(flags), turn);
54
63
  if (flags['oauth-only'])
55
64
  payload.oauth_only = true;
56
65
  if (cause)
@@ -2,6 +2,16 @@ import { BaseCommand } from '../../base.js';
2
2
  export default class ChatResponses extends BaseCommand {
3
3
  static description: string;
4
4
  static flags: {
5
+ session: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
6
+ compaction: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ 'oauth-only': import("@oclif/core/interfaces").BooleanFlag<boolean>;
8
+ 'show-cause': import("@oclif/core/interfaces").BooleanFlag<boolean>;
9
+ cause: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ 'cause-file': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ conversation: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
+ premise: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
+ 'premise-description': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
+ 'causes-visible': import("@oclif/core/interfaces").BooleanFlag<boolean>;
5
15
  message: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
6
16
  instructions: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
17
  'max-tokens': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
@@ -9,12 +19,6 @@ export default class ChatResponses extends BaseCommand {
9
19
  stream: import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
20
  style: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
21
  medium: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
- session: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
- compaction: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
- 'oauth-only': import("@oclif/core/interfaces").BooleanFlag<boolean>;
15
- 'show-cause': import("@oclif/core/interfaces").BooleanFlag<boolean>;
16
- cause: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
17
- 'cause-file': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
18
22
  'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
19
23
  token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
20
24
  'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
@@ -2,6 +2,7 @@ import { Args, Flags } from '@oclif/core';
2
2
  import { BaseCommand } from '../../base.js';
3
3
  import { postChat, writeReply, resolveCause, causeNeedsModel, CAUSE_FLAG_DESCRIPTION, CAUSE_FILE_FLAG_DESCRIPTION, retryOnceOnWarmUp, sayWarmUp, faceRefusalHint, STREAM_FLAG_DESCRIPTION, extractReasoning, extractStreamReasoning, STYLE_FLAG_DESCRIPTION, MEDIUM_FLAG_DESCRIPTION, SESSION_FLAG_DESCRIPTION, COMPACTION_FLAG_DESCRIPTION, chatExtras, reasoningHeading, reasoningOnlyNote, REASONING_FLAG_DESCRIPTION, MIN_MAX_OUTPUT_TOKENS, parseTemperature, warnDroppedParams, CHAT_PARAM_FLAGS } from '../../utils.js';
4
4
  import { FacesAPIError } from '../../client.js';
5
+ import { conversationFields, conversationTurnFlags } from '../../conversation.js';
5
6
  export default class ChatResponses extends BaseCommand {
6
7
  static description = 'Chat with a face in the OpenAI Responses format (/v1/responses). The same as chat:chat --responses. On Connect and Pro with ChatGPT linked, Codex-eligible models (see faces models:list --chatgpt) run on the ChatGPT plan.';
7
8
  static flags = {
@@ -13,6 +14,7 @@ export default class ChatResponses extends BaseCommand {
13
14
  stream: Flags.boolean({ description: STREAM_FLAG_DESCRIPTION, default: true, allowNo: true }),
14
15
  style: Flags.string({ description: STYLE_FLAG_DESCRIPTION }),
15
16
  medium: Flags.string({ description: MEDIUM_FLAG_DESCRIPTION }),
17
+ ...conversationTurnFlags(),
16
18
  session: Flags.string({ description: SESSION_FLAG_DESCRIPTION }),
17
19
  compaction: Flags.string({ description: COMPACTION_FLAG_DESCRIPTION }),
18
20
  'oauth-only': Flags.boolean({ description: 'On a linked ChatGPT plan, run there or fail: never fall back to credits', default: false }),
@@ -31,6 +33,13 @@ export default class ChatResponses extends BaseCommand {
31
33
  async run() {
32
34
  const { args, flags } = await this.parse(ChatResponses);
33
35
  const client = this.makeClient(flags);
36
+ let turn;
37
+ try {
38
+ turn = conversationFields(flags);
39
+ }
40
+ catch (err) {
41
+ this.error(err instanceof Error ? err.message : String(err));
42
+ }
34
43
  let cause;
35
44
  try {
36
45
  cause = resolveCause(flags.cause, flags['cause-file']);
@@ -57,7 +66,7 @@ export default class ChatResponses extends BaseCommand {
57
66
  }
58
67
  if (flags.temperature !== undefined)
59
68
  payload.temperature = parseTemperature(flags.temperature, (m) => this.error(m));
60
- Object.assign(payload, chatExtras(flags));
69
+ Object.assign(payload, chatExtras(flags), turn);
61
70
  if (flags['oauth-only'])
62
71
  payload.oauth_only = true;
63
72
  if (cause)
@@ -3,16 +3,6 @@ export default class ChatThread extends BaseCommand {
3
3
  static description: string;
4
4
  static examples: string[];
5
5
  static flags: {
6
- id: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
- message: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
- file: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
- llm: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
- system: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
- 'max-tokens': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
- temperature: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
- stream: import("@oclif/core/interfaces").BooleanFlag<boolean>;
14
- style: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
15
- medium: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
16
6
  session: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
17
7
  compaction: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
18
8
  'oauth-only': import("@oclif/core/interfaces").BooleanFlag<boolean>;
@@ -23,6 +13,20 @@ export default class ChatThread extends BaseCommand {
23
13
  show: import("@oclif/core/interfaces").BooleanFlag<boolean>;
24
14
  delete: import("@oclif/core/interfaces").BooleanFlag<boolean>;
25
15
  yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
16
+ conversation: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
17
+ premise: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
18
+ 'premise-description': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
19
+ 'causes-visible': import("@oclif/core/interfaces").BooleanFlag<boolean>;
20
+ id: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
21
+ message: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
22
+ file: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
23
+ llm: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
24
+ system: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
25
+ 'max-tokens': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
26
+ temperature: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
27
+ stream: import("@oclif/core/interfaces").BooleanFlag<boolean>;
28
+ style: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
29
+ medium: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
26
30
  'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
27
31
  token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
28
32
  'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
@@ -36,6 +40,9 @@ export default class ChatThread extends BaseCommand {
36
40
  private handleDelete;
37
41
  private handleShow;
38
42
  private handleMessage;
43
+ private conversationBody;
44
+ private newOnly;
45
+ private sent;
39
46
  private sendChatCompletions;
40
47
  private sendResponses;
41
48
  private sendAnthropic;