@faces-sh/cli 1.0.1 → 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 (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 +45 -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 +237 -0
  32. package/dist/utils.d.ts +1 -1
  33. package/dist/utils.js +4 -3
  34. package/oclif.manifest.json +708 -20
  35. package/package.json +4 -1
@@ -0,0 +1,66 @@
1
+ import { Args, Flags } from '@oclif/core';
2
+ import { BaseCommand } from '../../base.js';
3
+ import { FacesAPIError } from '../../client.js';
4
+ import { CONVERSATIONS_PATH, MAX_CONVERSATION_ITEMS, PREMISE_DESCRIPTION_FLAG_DESCRIPTION, PREMISE_FLAG_DESCRIPTION, clientItems, conversationHint, itemLines, parsePremises, premiseLines, staleDecisionLines, } from '../../conversation.js';
5
+ import { seg } from '../../utils.js';
6
+ export default class ConversationAdd extends BaseCommand {
7
+ static description = 'Add your own messages and premises to a conversation, without a face answering. Premises go in ' +
8
+ 'first, then messages. A newer value of a key replaces it from here on, and every earlier decision ' +
9
+ 'made while that key held a different value is listed, so you can choose which to ask again: nothing ' +
10
+ `is decided again for you. At most ${MAX_CONVERSATION_ITEMS} at a time. Free.`;
11
+ static examples = [
12
+ '<%= config.bin %> <%= command.id %> fs_CONVERSATION_ID --premise vendor_certified=false',
13
+ '<%= config.bin %> <%= command.id %> fs_CONVERSATION_ID --premise budget_usd=50000 --premise-description budget_usd="the most we can spend this year"',
14
+ '<%= config.bin %> <%= command.id %> fs_CONVERSATION_ID -m "The vendor sent their audit report."',
15
+ ];
16
+ static flags = {
17
+ ...BaseCommand.baseFlags,
18
+ message: Flags.string({ char: 'm', description: 'A message of yours (repeatable, kept in order).', multiple: true }),
19
+ premise: Flags.string({ description: PREMISE_FLAG_DESCRIPTION, multiple: true }),
20
+ 'premise-description': Flags.string({ description: PREMISE_DESCRIPTION_FLAG_DESCRIPTION, multiple: true }),
21
+ };
22
+ static args = {
23
+ conversation_id: Args.string({ description: 'Conversation id (from conversation:create)', required: true }),
24
+ };
25
+ async run() {
26
+ const { args, flags } = await this.parse(ConversationAdd);
27
+ const client = this.makeClient(flags);
28
+ let items;
29
+ try {
30
+ items = clientItems(flags.message, parsePremises(flags.premise, flags['premise-description']));
31
+ }
32
+ catch (err) {
33
+ this.error(err instanceof Error ? err.message : String(err));
34
+ }
35
+ if (items.length === 0)
36
+ this.error('Nothing to add: give a message with -m, or a premise with --premise key=value.');
37
+ if (items.length > MAX_CONVERSATION_ITEMS) {
38
+ this.error(`At most ${MAX_CONVERSATION_ITEMS} messages and premises at a time (got ${items.length}). Split them across calls.`);
39
+ }
40
+ let data;
41
+ try {
42
+ data = (await client.post(`${CONVERSATIONS_PATH}/${seg(args.conversation_id)}/items`, { body: { items } }));
43
+ }
44
+ catch (err) {
45
+ if (err instanceof FacesAPIError) {
46
+ const hint = conversationHint(err);
47
+ this.error(`HTTP ${err.statusCode}: ${err.message}${hint ? `\n${hint}` : ''}`);
48
+ }
49
+ throw err;
50
+ }
51
+ if (!this.jsonEnabled()) {
52
+ for (const line of itemLines(data.data ?? []))
53
+ this.log(line);
54
+ this.log('');
55
+ for (const line of premiseLines(data.premises))
56
+ this.log(line);
57
+ const stale = staleDecisionLines(data.decisions_made_under_old_values);
58
+ if (stale.length > 0) {
59
+ this.log('');
60
+ for (const line of stale)
61
+ this.log(line);
62
+ }
63
+ }
64
+ return data;
65
+ }
66
+ }
@@ -0,0 +1,16 @@
1
+ import { BaseCommand } from '../../base.js';
2
+ export default class ConversationClose extends BaseCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
7
+ 'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ 'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
+ };
12
+ static args: {
13
+ conversation_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
14
+ };
15
+ run(): Promise<unknown>;
16
+ }
@@ -0,0 +1,36 @@
1
+ import { Args, Flags } from '@oclif/core';
2
+ import { BaseCommand } from '../../base.js';
3
+ import { FacesAPIError } from '../../client.js';
4
+ import { CONVERSATIONS_PATH, conversationHint } from '../../conversation.js';
5
+ import { seg } from '../../utils.js';
6
+ export default class ConversationClose extends BaseCommand {
7
+ static description = 'Close a conversation. A closed conversation takes no more turns and cannot be read or compacted. Its ' +
8
+ 'compactions stay usable until they expire. Free.';
9
+ static examples = ['<%= config.bin %> <%= command.id %> fs_CONVERSATION_ID --yes'];
10
+ static flags = {
11
+ ...BaseCommand.baseFlags,
12
+ yes: Flags.boolean({ description: 'Skip confirmation', default: false }),
13
+ };
14
+ static args = {
15
+ conversation_id: Args.string({ description: 'Conversation id (from conversation:create)', required: true }),
16
+ };
17
+ async run() {
18
+ const { args, flags } = await this.parse(ConversationClose);
19
+ const client = this.makeClient(flags);
20
+ await this.confirmOrRefuse(`Close conversation ${args.conversation_id}? It cannot be reopened.`, flags.yes);
21
+ let data;
22
+ try {
23
+ data = await client.delete(`${CONVERSATIONS_PATH}/${seg(args.conversation_id)}`);
24
+ }
25
+ catch (err) {
26
+ if (err instanceof FacesAPIError) {
27
+ const hint = conversationHint(err);
28
+ this.error(`HTTP ${err.statusCode}: ${err.message}${hint ? `\n${hint}` : ''}`);
29
+ }
30
+ throw err;
31
+ }
32
+ if (!this.jsonEnabled())
33
+ this.log(`Closed conversation ${args.conversation_id}.`);
34
+ return data;
35
+ }
36
+ }
@@ -0,0 +1,16 @@
1
+ import { BaseCommand } from '../../base.js';
2
+ export default class ConversationCompact extends BaseCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ 'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ 'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
+ };
11
+ static args: {
12
+ conversation_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
13
+ face: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
14
+ };
15
+ run(): Promise<unknown>;
16
+ }
@@ -0,0 +1,69 @@
1
+ import { Args } from '@oclif/core';
2
+ import { BaseCommand } from '../../base.js';
3
+ import { FacesAPIError } from '../../client.js';
4
+ import { heldDecisionError } from '../../decisions.js';
5
+ import { CONVERSATIONS_PATH, conversationHint } from '../../conversation.js';
6
+ import { retryOnceOnWarmUp, sayWarmUp, seg } from '../../utils.js';
7
+ export default class ConversationCompact extends BaseCommand {
8
+ static description = 'Compact a conversation: a summary of one face\'s position over the conversation, in the face\'s own ' +
9
+ 'terms, stored under a compaction id. Pass that id with --compaction on a later request with the same ' +
10
+ 'face. A conversation that takes any face needs the face named. Billed at the cause rate on the tokens ' +
11
+ 'it reads and writes; on Connect and Pro it counts against the cause allowance. A failed compaction is ' +
12
+ 'not charged. A compaction expires 30 days after it is written.';
13
+ static examples = [
14
+ '<%= config.bin %> <%= command.id %> fs_CONVERSATION_ID',
15
+ '<%= config.bin %> <%= command.id %> fs_CONVERSATION_ID alice --json',
16
+ ];
17
+ static flags = {
18
+ ...BaseCommand.baseFlags,
19
+ };
20
+ static args = {
21
+ conversation_id: Args.string({ description: 'Conversation id (from conversation:create)', required: true }),
22
+ face: Args.string({
23
+ description: 'The face to compact, alone (no @model). Needed when the conversation takes any face; a ' +
24
+ 'conversation opened with one face compacts that face.',
25
+ required: false,
26
+ }),
27
+ };
28
+ async run() {
29
+ const { args, flags } = await this.parse(ConversationCompact);
30
+ const client = this.makeClient(flags);
31
+ const json = this.jsonEnabled();
32
+ const face = args.face?.trim();
33
+ if (face?.includes('@'))
34
+ this.error(`Compact a face alone, so leave the model off: ${face.slice(0, face.lastIndexOf('@'))}`);
35
+ let data;
36
+ try {
37
+ data = (await retryOnceOnWarmUp(async () => {
38
+ const res = await client.post(`${CONVERSATIONS_PATH}/${seg(args.conversation_id)}/compact`, { body: face ? { model: face } : {} });
39
+ const held = heldDecisionError(res);
40
+ if (held)
41
+ throw held;
42
+ return res;
43
+ }, json ? undefined : sayWarmUp));
44
+ }
45
+ catch (err) {
46
+ if (err instanceof FacesAPIError) {
47
+ if (err.statusCode === 422 && !face && /takes any face/.test(err.message)) {
48
+ this.error(`HTTP ${err.statusCode}: ${err.message}\nName the face: faces conversation:compact ${args.conversation_id} <face>`);
49
+ }
50
+ const hint = conversationHint(err);
51
+ this.error(`HTTP ${err.statusCode}: ${err.message}${hint ? `\n${hint}` : ''}`);
52
+ }
53
+ throw err;
54
+ }
55
+ if (!json) {
56
+ if (typeof data.cause === 'string')
57
+ this.log(data.cause);
58
+ this.log('');
59
+ this.log(`compaction: ${data.compaction_id ?? '-'}`);
60
+ if (data.turns !== undefined)
61
+ this.log(`turns: ${data.turns}`);
62
+ if (data.expires_at)
63
+ this.log(`expires: ${data.expires_at}`);
64
+ if (data.compaction_id)
65
+ this.log(`\nUse it with: faces chat:chat ${face ?? '<face>'}@<model> --compaction ${data.compaction_id} -m "..."`);
66
+ }
67
+ return data;
68
+ }
69
+ }
@@ -0,0 +1,19 @@
1
+ import { BaseCommand } from '../../base.js';
2
+ export default class ConversationCreate extends BaseCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ 'causes-visible': import("@oclif/core/interfaces").BooleanFlag<boolean>;
7
+ message: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ premise: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ 'premise-description': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ 'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
+ 'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
+ toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
14
+ };
15
+ static args: {
16
+ face: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
17
+ };
18
+ run(): Promise<unknown>;
19
+ }
@@ -0,0 +1,76 @@
1
+ import { Args, Flags } from '@oclif/core';
2
+ import { BaseCommand } from '../../base.js';
3
+ import { FacesAPIError } from '../../client.js';
4
+ import { CONVERSATIONS_PATH, MAX_CONVERSATION_ITEMS, PREMISE_DESCRIPTION_FLAG_DESCRIPTION, PREMISE_FLAG_DESCRIPTION, clientItems, conversationHint, conversationLines, parsePremises, } from '../../conversation.js';
5
+ export default class ConversationCreate extends BaseCommand {
6
+ static description = 'Start a conversation. The server keeps the whole conversation: your messages, each face\'s reply with ' +
7
+ 'its cause, decisions, and premises (named facts you declare). Pass its id with --conversation on chat, ' +
8
+ 'causes or decide and send only what is new. Name a face and the conversation takes that face only; ' +
9
+ 'leave it out and it takes any of your faces. Opening one is free; each turn costs what it costs ' +
10
+ 'without one. A conversation expires 30 days after it was last used.';
11
+ static examples = [
12
+ '<%= config.bin %> <%= command.id %> alice',
13
+ '<%= config.bin %> <%= command.id %>',
14
+ '<%= config.bin %> <%= command.id %> --no-causes-visible --json',
15
+ '<%= config.bin %> <%= command.id %> alice --premise budget_usd=50000 --premise-description budget_usd="the most we can spend this year"',
16
+ ];
17
+ static flags = {
18
+ ...BaseCommand.baseFlags,
19
+ 'causes-visible': Flags.boolean({
20
+ description: 'Whether each face reads the other faces\' causes. On by default; --no-causes-visible keeps each ' +
21
+ 'face to its own. Matters only in a conversation with several faces.',
22
+ default: true,
23
+ allowNo: true,
24
+ }),
25
+ message: Flags.string({ char: 'm', description: 'A first message of yours (repeatable, kept in order).', multiple: true }),
26
+ premise: Flags.string({ description: PREMISE_FLAG_DESCRIPTION, multiple: true }),
27
+ 'premise-description': Flags.string({ description: PREMISE_DESCRIPTION_FLAG_DESCRIPTION, multiple: true }),
28
+ };
29
+ static args = {
30
+ face: Args.string({
31
+ description: 'The face alone: an alias, owner:alias, or a composite such as "(a | b)". No @model. Leave it out ' +
32
+ 'for a conversation that takes any of your faces.',
33
+ required: false,
34
+ }),
35
+ };
36
+ async run() {
37
+ const { args, flags } = await this.parse(ConversationCreate);
38
+ const client = this.makeClient(flags);
39
+ const face = args.face?.trim();
40
+ if (face?.includes('@'))
41
+ this.error(`A conversation is with a face alone: ${face.slice(0, face.lastIndexOf('@'))}`);
42
+ let items;
43
+ try {
44
+ items = clientItems(flags.message, parsePremises(flags.premise, flags['premise-description']));
45
+ }
46
+ catch (err) {
47
+ this.error(err instanceof Error ? err.message : String(err));
48
+ }
49
+ if (items.length > MAX_CONVERSATION_ITEMS) {
50
+ this.error(`At most ${MAX_CONVERSATION_ITEMS} messages and premises at a time (got ${items.length}). Add the rest with faces conversation:add.`);
51
+ }
52
+ const body = { causes_visible: flags['causes-visible'] };
53
+ if (face)
54
+ body.model = face;
55
+ if (items.length > 0)
56
+ body.items = items;
57
+ let data;
58
+ try {
59
+ data = (await client.post(CONVERSATIONS_PATH, { body }));
60
+ }
61
+ catch (err) {
62
+ if (err instanceof FacesAPIError) {
63
+ const hint = conversationHint(err);
64
+ this.error(`HTTP ${err.statusCode}: ${err.message}${hint ? `\n${hint}` : ''}`);
65
+ }
66
+ throw err;
67
+ }
68
+ if (!this.jsonEnabled()) {
69
+ for (const line of conversationLines(data))
70
+ this.log(line);
71
+ if (data.id)
72
+ this.log(`\nTake a turn with: faces chat:chat ${face ?? '<face>'}@<model> --conversation ${data.id} -m "..."`);
73
+ }
74
+ return data;
75
+ }
76
+ }
@@ -0,0 +1,15 @@
1
+ import { BaseCommand } from '../../base.js';
2
+ export default class ConversationGet extends BaseCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ 'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ 'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
+ };
11
+ static args: {
12
+ conversation_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
13
+ };
14
+ run(): Promise<unknown>;
15
+ }
@@ -0,0 +1,35 @@
1
+ import { Args } from '@oclif/core';
2
+ import { BaseCommand } from '../../base.js';
3
+ import { FacesAPIError } from '../../client.js';
4
+ import { CONVERSATIONS_PATH, conversationHint, conversationLines } from '../../conversation.js';
5
+ import { seg } from '../../utils.js';
6
+ export default class ConversationGet extends BaseCommand {
7
+ static description = 'Read a conversation: its face (or any), status, how many turns and items it holds, whether faces ' +
8
+ 'read each other\'s causes, and when it expires. Free. See its items with faces conversation:items.';
9
+ static examples = ['<%= config.bin %> <%= command.id %> fs_CONVERSATION_ID'];
10
+ static flags = {
11
+ ...BaseCommand.baseFlags,
12
+ };
13
+ static args = {
14
+ conversation_id: Args.string({ description: 'Conversation id (from conversation:create)', required: true }),
15
+ };
16
+ async run() {
17
+ const { args, flags } = await this.parse(ConversationGet);
18
+ const client = this.makeClient(flags);
19
+ let data;
20
+ try {
21
+ data = (await client.get(`${CONVERSATIONS_PATH}/${seg(args.conversation_id)}`));
22
+ }
23
+ catch (err) {
24
+ if (err instanceof FacesAPIError) {
25
+ const hint = conversationHint(err);
26
+ this.error(`HTTP ${err.statusCode}: ${err.message}${hint ? `\n${hint}` : ''}`);
27
+ }
28
+ throw err;
29
+ }
30
+ if (!this.jsonEnabled())
31
+ for (const line of conversationLines(data))
32
+ this.log(line);
33
+ return data;
34
+ }
35
+ }
@@ -0,0 +1,15 @@
1
+ import { BaseCommand } from '../../base.js';
2
+ export default class ConversationItems extends BaseCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ 'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ 'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
+ };
11
+ static args: {
12
+ conversation_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
13
+ };
14
+ run(): Promise<unknown>;
15
+ }
@@ -0,0 +1,45 @@
1
+ import { Args } from '@oclif/core';
2
+ import { BaseCommand } from '../../base.js';
3
+ import { FacesAPIError } from '../../client.js';
4
+ import { CONVERSATIONS_PATH, conversationHint, itemLines, premiseLines } from '../../conversation.js';
5
+ import { seg } from '../../utils.js';
6
+ export default class ConversationItems extends BaseCommand {
7
+ static description = 'List a conversation\'s items in order: your messages, each face\'s reply with its cause, decisions ' +
8
+ 'with their choice and cause, and premises. Ends with the premises in force now. Free.';
9
+ static examples = [
10
+ '<%= config.bin %> <%= command.id %> fs_CONVERSATION_ID',
11
+ '<%= config.bin %> <%= command.id %> fs_CONVERSATION_ID --json',
12
+ ];
13
+ static flags = {
14
+ ...BaseCommand.baseFlags,
15
+ };
16
+ static args = {
17
+ conversation_id: Args.string({ description: 'Conversation id (from conversation:create)', required: true }),
18
+ };
19
+ async run() {
20
+ const { args, flags } = await this.parse(ConversationItems);
21
+ const client = this.makeClient(flags);
22
+ let data;
23
+ try {
24
+ data = (await client.get(`${CONVERSATIONS_PATH}/${seg(args.conversation_id)}/items`));
25
+ }
26
+ catch (err) {
27
+ if (err instanceof FacesAPIError) {
28
+ const hint = conversationHint(err);
29
+ this.error(`HTTP ${err.statusCode}: ${err.message}${hint ? `\n${hint}` : ''}`);
30
+ }
31
+ throw err;
32
+ }
33
+ if (!this.jsonEnabled()) {
34
+ const items = data.data ?? [];
35
+ if (items.length === 0)
36
+ this.log('No items yet.');
37
+ for (const line of itemLines(items))
38
+ this.log(line);
39
+ this.log('');
40
+ for (const line of premiseLines(data.premises))
41
+ this.log(line);
42
+ }
43
+ return data;
44
+ }
45
+ }
@@ -3,6 +3,14 @@ export default class Decide 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
+ format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
9
+ retry: import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
+ conversation: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ premise: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
+ 'premise-description': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
+ 'causes-visible': import("@oclif/core/interfaces").BooleanFlag<boolean>;
6
14
  state: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
15
  'state-file': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
16
  question: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
@@ -14,10 +22,6 @@ export default class Decide extends BaseCommand {
14
22
  model: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
15
23
  baseline: import("@oclif/core/interfaces").BooleanFlag<boolean>;
16
24
  'show-cause': import("@oclif/core/interfaces").BooleanFlag<boolean>;
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
- format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
20
- retry: import("@oclif/core/interfaces").BooleanFlag<boolean>;
21
25
  'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
22
26
  token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
23
27
  'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
@@ -1,6 +1,7 @@
1
1
  import { Args, Flags } from '@oclif/core';
2
2
  import { BaseCommand } from '../base.js';
3
3
  import { FacesAPIError, missingFieldsNote } from '../client.js';
4
+ import { conversationFields, conversationTurnFlags } from '../conversation.js';
4
5
  import { DECISION_MODELS, decisionModels, DECISION_FORMATS, fromOpenAIAnswers, toOpenAIDecision, questionsProblem, MAX_WARM_UP_WAIT_S, QUESTION_TYPES, causeLines, decisionLines, heldDecisionError, readStateFlags, readQuestionFlags, warmUpWait, } from '../decisions.js';
5
6
  import { compileHint, reasoningHeading, sayWarmUp, SESSION_FLAG_DESCRIPTION, COMPACTION_FLAG_DESCRIPTION } from '../utils.js';
6
7
  const OPENAI_FORMAT_ONLY = ['gpt-6-luna'];
@@ -90,6 +91,7 @@ export default class Decide extends BaseCommand {
90
91
  'the answers. It is always in --json, as cause and causes.',
91
92
  default: false,
92
93
  }),
94
+ ...conversationTurnFlags({ exclusive: ['baseline'] }),
93
95
  session: Flags.string({ description: SESSION_FLAG_DESCRIPTION, exclusive: ['baseline'] }),
94
96
  compaction: Flags.string({ description: COMPACTION_FLAG_DESCRIPTION, exclusive: ['baseline'] }),
95
97
  format: Flags.string({
@@ -116,6 +118,13 @@ export default class Decide extends BaseCommand {
116
118
  this.error('--baseline asks with no face, so leave the face out.');
117
119
  if (!flags.baseline && !args.face)
118
120
  this.error('Name a face to ask, or pass --baseline to ask with none.');
121
+ let turn = {};
122
+ try {
123
+ turn = conversationFields(flags);
124
+ }
125
+ catch (err) {
126
+ this.error(err instanceof Error ? err.message : String(err));
127
+ }
119
128
  const state = this.readState(flags);
120
129
  const questions = this.readQuestions(flags);
121
130
  if (!questions && flags.baseline)
@@ -151,6 +160,7 @@ export default class Decide extends BaseCommand {
151
160
  body.session = flags.session;
152
161
  if (flags.compaction)
153
162
  body.compaction = flags.compaction;
163
+ Object.assign(body, turn);
154
164
  if (!json) {
155
165
  process.stderr.write(!questions
156
166
  ? `Asking ${face} for its cause alone, with no questions.\n`
@@ -5,7 +5,7 @@ import { SESSIONS_PATH, sessionHint } from '../../session.js';
5
5
  import { seg } from '../../utils.js';
6
6
  export default class SessionClose extends BaseCommand {
7
7
  static description = 'Close a session. A closed session takes no more turns and cannot be compacted or read. Its ' +
8
- 'compactions stay usable until they expire. Free.';
8
+ 'compactions stay usable until they expire. Free. Sessions are now called conversations: see faces conversation:close.';
9
9
  static examples = ['<%= config.bin %> <%= command.id %> fs_SESSION_ID --yes'];
10
10
  static flags = {
11
11
  ...BaseCommand.baseFlags,
@@ -9,7 +9,7 @@ export default class SessionCompact extends BaseCommand {
9
9
  'stored under a compaction id. Pass that id with --compaction on a later request with the same face, ' +
10
10
  'and send only the messages you still want read. Billed at the cause rate on the tokens it reads and ' +
11
11
  'writes; on Connect and Pro it counts against the cause allowance. A failed compaction is not charged. ' +
12
- 'A compaction expires 30 days after it is written.';
12
+ 'A compaction expires 30 days after it is written. Sessions are now called conversations: see faces conversation:compact.';
13
13
  static examples = [
14
14
  '<%= config.bin %> <%= command.id %> fs_SESSION_ID',
15
15
  '<%= config.bin %> <%= command.id %> fs_SESSION_ID --json',
@@ -5,7 +5,7 @@ import { SESSIONS_PATH, sessionLines } from '../../session.js';
5
5
  export default class SessionCreate extends BaseCommand {
6
6
  static description = 'Start a session with a face. A session groups the turns of one conversation with one face: pass its id ' +
7
7
  'with --session on chat, causes or decide, then compact it with session:compact. Opening one is free; ' +
8
- 'each turn costs what it costs without one. A session expires 30 days after its last turn.';
8
+ 'each turn costs what it costs without one. A session expires 30 days after its last turn. Sessions are now called conversations: see faces conversation:create.';
9
9
  static examples = [
10
10
  '<%= config.bin %> <%= command.id %> alice',
11
11
  '<%= config.bin %> <%= command.id %> "(alice | bob)" --json',
@@ -4,7 +4,7 @@ import { FacesAPIError } from '../../client.js';
4
4
  import { SESSIONS_PATH, sessionHint, sessionLines } from '../../session.js';
5
5
  import { seg } from '../../utils.js';
6
6
  export default class SessionGet extends BaseCommand {
7
- static description = 'Read a session: its face, status, how many turns it holds, and when it expires. Free.';
7
+ static description = 'Read a session: its face, status, how many turns it holds, and when it expires. Free. Sessions are now called conversations: see faces conversation:get.';
8
8
  static examples = ['<%= config.bin %> <%= command.id %> fs_SESSION_ID'];
9
9
  static flags = {
10
10
  ...BaseCommand.baseFlags,
@@ -0,0 +1,63 @@
1
+ import { FacesAPIError } from './client.js';
2
+ export declare const CONVERSATIONS_PATH = "/v1/conversations";
3
+ export declare const MAX_CONVERSATION_ITEMS = 20;
4
+ export interface Conversation {
5
+ object?: string;
6
+ id?: string;
7
+ model?: string | null;
8
+ turns?: number;
9
+ items?: number;
10
+ causes_visible?: boolean;
11
+ status?: string;
12
+ created_at?: string;
13
+ last_used_at?: string;
14
+ expires_at?: string;
15
+ }
16
+ export interface Premise {
17
+ key: string;
18
+ value: unknown;
19
+ description?: string;
20
+ }
21
+ export interface PremiseState {
22
+ value?: unknown;
23
+ description?: string | null;
24
+ }
25
+ export declare const CONVERSATION_FLAG_DESCRIPTION: string;
26
+ export declare const PREMISE_FLAG_DESCRIPTION: string;
27
+ export declare const PREMISE_DESCRIPTION_FLAG_DESCRIPTION: string;
28
+ export declare const CAUSES_VISIBLE_TURN_FLAG_DESCRIPTION: string;
29
+ export declare function conversationTurnFlags(opts?: {
30
+ suffix?: string;
31
+ exclusive?: string[];
32
+ }): {
33
+ conversation: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
34
+ premise: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
35
+ 'premise-description': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
36
+ 'causes-visible': import("@oclif/core/interfaces").BooleanFlag<boolean>;
37
+ };
38
+ export declare function conversationLines(c: Conversation): string[];
39
+ export declare function conversationHint(err: FacesAPIError): string | undefined;
40
+ export declare function premiseValue(raw: string): unknown;
41
+ export declare function parsePremises(premises?: string[], descriptions?: string[]): Premise[];
42
+ export declare function conversationFields(flags: {
43
+ conversation?: string;
44
+ session?: string;
45
+ premise?: string[];
46
+ 'premise-description'?: string[];
47
+ 'causes-visible'?: boolean;
48
+ }): Record<string, unknown>;
49
+ export declare function clientItems(messages?: string[], premises?: Premise[]): Array<Record<string, unknown>>;
50
+ export declare function shownValue(v: unknown): string;
51
+ export declare function premiseLines(premises: Record<string, PremiseState> | undefined): string[];
52
+ export declare function itemLines(items: Array<Record<string, unknown>>): string[];
53
+ export interface StaleDecision {
54
+ call_id?: string;
55
+ question?: Record<string, unknown>;
56
+ choice?: unknown;
57
+ face?: string;
58
+ changed?: Record<string, {
59
+ was?: unknown;
60
+ now?: unknown;
61
+ }>;
62
+ }
63
+ export declare function staleDecisionLines(stale: StaleDecision[] | undefined): string[];