@faces-sh/cli 1.0.1 → 1.0.3

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 (35) hide show
  1. package/README.md +32 -7
  2. package/dist/commands/causes.d.ts +6 -2
  3. package/dist/commands/causes.js +11 -0
  4. package/dist/commands/chat/chat.d.ts +12 -7
  5. package/dist/commands/chat/chat.js +19 -6
  6. package/dist/commands/chat/messages.d.ts +10 -6
  7. package/dist/commands/chat/messages.js +10 -1
  8. package/dist/commands/chat/responses.d.ts +10 -6
  9. package/dist/commands/chat/responses.js +10 -1
  10. package/dist/commands/chat/thread.d.ts +17 -10
  11. package/dist/commands/chat/thread.js +20 -6
  12. package/dist/commands/conversation/add.d.ts +18 -0
  13. package/dist/commands/conversation/add.js +66 -0
  14. package/dist/commands/conversation/close.d.ts +16 -0
  15. package/dist/commands/conversation/close.js +36 -0
  16. package/dist/commands/conversation/compact.d.ts +16 -0
  17. package/dist/commands/conversation/compact.js +69 -0
  18. package/dist/commands/conversation/create.d.ts +19 -0
  19. package/dist/commands/conversation/create.js +76 -0
  20. package/dist/commands/conversation/get.d.ts +15 -0
  21. package/dist/commands/conversation/get.js +35 -0
  22. package/dist/commands/conversation/items.d.ts +15 -0
  23. package/dist/commands/conversation/items.js +56 -0
  24. package/dist/commands/decide.d.ts +8 -4
  25. package/dist/commands/decide.js +10 -0
  26. package/dist/commands/session/close.js +1 -1
  27. package/dist/commands/session/compact.js +1 -1
  28. package/dist/commands/session/create.js +1 -1
  29. package/dist/commands/session/get.js +1 -1
  30. package/dist/conversation.d.ts +63 -0
  31. package/dist/conversation.js +246 -0
  32. package/dist/utils.d.ts +1 -1
  33. package/dist/utils.js +4 -3
  34. package/oclif.manifest.json +1501 -813
  35. 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:
@@ -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;
@@ -4,6 +4,7 @@ import fs from 'node:fs';
4
4
  import os from 'node:os';
5
5
  import path from 'node:path';
6
6
  import { BaseCommand } from '../../base.js';
7
+ import { conversationFields, conversationTurnFlags } from '../../conversation.js';
7
8
  import { FacesAPIError } from '../../client.js';
8
9
  import { postChat, streamChat, resolveCause, CAUSE_FLAG_DESCRIPTION, CAUSE_FILE_FLAG_DESCRIPTION, retryOnceOnWarmUp, sayWarmUp, faceRefusalHint, STREAM_FLAG_DESCRIPTION, extractCause, extractStreamDelta, FACES_REASONING_ITEM_PREFIX, FACES_THINKING_SIGNATURE, extractStreamReasoning, isMaxTokensRenameError, MIN_MAX_OUTPUT_TOKENS, STYLE_FLAG_DESCRIPTION, MEDIUM_FLAG_DESCRIPTION, SESSION_FLAG_DESCRIPTION, COMPACTION_FLAG_DESCRIPTION, chatExtras, reasoningHeading, REASONING_FLAG_DESCRIPTION, parseTemperature } from '../../utils.js';
9
10
  import { resolveEndpoint, isCompositeFormula, llmFromArg, MESSAGES_ENDPOINT, RESPONSES_ENDPOINT, CHAT_COMPLETIONS_ENDPOINT } from '../../routing.js';
@@ -122,6 +123,7 @@ export default class ChatThread extends BaseCommand {
122
123
  stream: Flags.boolean({ description: STREAM_FLAG_DESCRIPTION, default: true, allowNo: true }),
123
124
  style: Flags.string({ description: `${STYLE_FLAG_DESCRIPTION} For this turn only.` }),
124
125
  medium: Flags.string({ description: `${MEDIUM_FLAG_DESCRIPTION} For this turn only.` }),
126
+ ...conversationTurnFlags({ suffix: 'For this turn only. Only the new message is sent: the conversation holds the rest.' }),
125
127
  session: Flags.string({ description: `${SESSION_FLAG_DESCRIPTION} For this turn only.` }),
126
128
  compaction: Flags.string({ description: `${COMPACTION_FLAG_DESCRIPTION} For this turn only.` }),
127
129
  'oauth-only': Flags.boolean({ description: 'On a linked ChatGPT plan, run there or fail: never fall back to credits', default: false }),
@@ -224,6 +226,13 @@ export default class ChatThread extends BaseCommand {
224
226
  else {
225
227
  this.error('Provide --message/-m or --file');
226
228
  }
229
+ try {
230
+ this.conversationBody = conversationFields(flags);
231
+ }
232
+ catch (err) {
233
+ this.error(err instanceof Error ? err.message : String(err));
234
+ }
235
+ this.newOnly = Boolean(flags.conversation || flags.session);
227
236
  const client = this.makeClient(flags);
228
237
  let thread;
229
238
  if (flags.id) {
@@ -333,18 +342,23 @@ export default class ChatThread extends BaseCommand {
333
342
  throw err;
334
343
  }
335
344
  }
345
+ conversationBody = {};
346
+ newOnly = false;
347
+ sent(thread) {
348
+ return this.newOnly ? thread.messages.slice(-1) : thread.messages;
349
+ }
336
350
  async sendChatCompletions(client, thread, flags) {
337
351
  const messages = [];
338
352
  if (thread.system)
339
353
  messages.push({ role: 'system', content: thread.system });
340
- for (const m of thread.messages)
354
+ for (const m of this.sent(thread))
341
355
  messages.push(chatTurn(m));
342
356
  const payload = { model: thread.model, messages, stream: flags.stream };
343
357
  if (flags['max-tokens'])
344
358
  payload.max_tokens = flags['max-tokens'];
345
359
  if (flags.temperature !== undefined)
346
360
  payload.temperature = parseTemperature(flags.temperature, (m) => this.error(m));
347
- Object.assign(payload, chatExtras(flags));
361
+ Object.assign(payload, chatExtras(flags), this.conversationBody);
348
362
  if (flags['oauth-only'])
349
363
  payload.oauth_only = true;
350
364
  if (flags.cause)
@@ -370,7 +384,7 @@ export default class ChatThread extends BaseCommand {
370
384
  return replyOf(data, CHAT_COMPLETIONS_ENDPOINT);
371
385
  }
372
386
  async sendResponses(client, thread, flags) {
373
- const input = thread.messages.flatMap((m) => responsesTurns(m));
387
+ const input = this.sent(thread).flatMap((m) => responsesTurns(m));
374
388
  const payload = { model: thread.model, input, stream: flags.stream };
375
389
  if (thread.system)
376
390
  payload.instructions = thread.system;
@@ -383,7 +397,7 @@ export default class ChatThread extends BaseCommand {
383
397
  }
384
398
  if (flags.temperature !== undefined)
385
399
  payload.temperature = parseTemperature(flags.temperature, (m) => this.error(m));
386
- Object.assign(payload, chatExtras(flags));
400
+ Object.assign(payload, chatExtras(flags), this.conversationBody);
387
401
  if (flags['oauth-only'])
388
402
  payload.oauth_only = true;
389
403
  if (flags.cause)
@@ -395,7 +409,7 @@ export default class ChatThread extends BaseCommand {
395
409
  return replyOf(data, RESPONSES_ENDPOINT);
396
410
  }
397
411
  async sendAnthropic(client, thread, flags) {
398
- const msgs = thread.messages.map((m) => messagesTurn(m));
412
+ const msgs = this.sent(thread).map((m) => messagesTurn(m));
399
413
  const payload = {
400
414
  model: thread.model,
401
415
  messages: msgs,
@@ -404,7 +418,7 @@ export default class ChatThread extends BaseCommand {
404
418
  };
405
419
  if (thread.system)
406
420
  payload.system = thread.system;
407
- Object.assign(payload, chatExtras(flags));
421
+ Object.assign(payload, chatExtras(flags), this.conversationBody);
408
422
  if (flags['oauth-only'])
409
423
  payload.oauth_only = true;
410
424
  if (flags.cause)
@@ -0,0 +1,18 @@
1
+ import { BaseCommand } from '../../base.js';
2
+ export default class ConversationAdd extends BaseCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ message: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ premise: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ 'premise-description': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ 'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ 'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
+ toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
13
+ };
14
+ static args: {
15
+ conversation_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
16
+ };
17
+ run(): Promise<unknown>;
18
+ }