@faces-sh/cli 1.0.3 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/README.md +107 -53
  2. package/dist/billing.js +11 -8
  3. package/dist/{commands/causes.d.ts → chat-command.d.ts} +13 -13
  4. package/dist/chat-command.js +110 -0
  5. package/dist/chat.d.ts +47 -0
  6. package/dist/chat.js +157 -0
  7. package/dist/choices.d.ts +20 -0
  8. package/dist/choices.js +49 -0
  9. package/dist/commands/auth/connect.js +2 -2
  10. package/dist/commands/billing/llm-costs.js +9 -5
  11. package/dist/commands/billing/subscription/index.js +1 -1
  12. package/dist/commands/catalog/doctor.js +9 -68
  13. package/dist/commands/chat/chat.d.ts +10 -26
  14. package/dist/commands/chat/chat.js +21 -366
  15. package/dist/commands/chat/messages.d.ts +13 -13
  16. package/dist/commands/chat/messages.js +15 -142
  17. package/dist/commands/chat/responses.d.ts +13 -14
  18. package/dist/commands/chat/responses.js +16 -153
  19. package/dist/commands/chat/thread.d.ts +3 -15
  20. package/dist/commands/chat/thread.js +128 -362
  21. package/dist/commands/choices.d.ts +20 -0
  22. package/dist/commands/choices.js +91 -0
  23. package/dist/commands/conversation/add.d.ts +2 -0
  24. package/dist/commands/conversation/add.js +21 -10
  25. package/dist/commands/conversation/close.js +5 -5
  26. package/dist/commands/conversation/compact.js +15 -18
  27. package/dist/commands/conversation/create.d.ts +2 -0
  28. package/dist/commands/conversation/create.js +20 -17
  29. package/dist/commands/conversation/get.js +4 -4
  30. package/dist/commands/conversation/items.js +5 -5
  31. package/dist/commands/decide.d.ts +4 -4
  32. package/dist/commands/decide.js +70 -81
  33. package/dist/commands/face/get.js +2 -2
  34. package/dist/commands/group/add.js +1 -1
  35. package/dist/commands/media/list.d.ts +12 -0
  36. package/dist/commands/media/list.js +35 -0
  37. package/dist/commands/models/list.js +16 -5
  38. package/dist/commands/session/close.js +1 -1
  39. package/dist/commands/session/compact.js +6 -9
  40. package/dist/commands/session/create.js +10 -9
  41. package/dist/commands/session/get.js +1 -1
  42. package/dist/commands/state/add.d.ts +3 -0
  43. package/dist/commands/state/add.js +3 -0
  44. package/dist/commands/state/close.d.ts +3 -0
  45. package/dist/commands/state/close.js +3 -0
  46. package/dist/commands/state/compact.d.ts +3 -0
  47. package/dist/commands/state/compact.js +3 -0
  48. package/dist/commands/state/create.d.ts +3 -0
  49. package/dist/commands/state/create.js +3 -0
  50. package/dist/commands/state/get.d.ts +3 -0
  51. package/dist/commands/state/get.js +3 -0
  52. package/dist/commands/state/items.d.ts +3 -0
  53. package/dist/commands/state/items.js +3 -0
  54. package/dist/commands/style/make.js +2 -6
  55. package/dist/commands/style/upload.js +1 -1
  56. package/dist/conversation.d.ts +27 -2
  57. package/dist/conversation.js +91 -16
  58. package/dist/decisions.d.ts +0 -5
  59. package/dist/decisions.js +0 -18
  60. package/dist/media.d.ts +8 -0
  61. package/dist/media.js +12 -0
  62. package/dist/model.d.ts +11 -0
  63. package/dist/model.js +53 -0
  64. package/dist/routing.d.ts +1 -4
  65. package/dist/routing.js +4 -40
  66. package/dist/utils.d.ts +1 -25
  67. package/dist/utils.js +10 -108
  68. package/oclif.manifest.json +2054 -1649
  69. package/package.json +10 -7
  70. package/dist/commands/causes.js +0 -146
@@ -0,0 +1,91 @@
1
+ import { Args, Flags } from '@oclif/core';
2
+ import { BaseCommand } from '../base.js';
3
+ import { FacesAPIError } from '../client.js';
4
+ import { CHOICES_PATH, MAX_CHOICES, choicesHint, choicesLines } from '../choices.js';
5
+ import { modelProblem } from '../model.js';
6
+ import { heldDecisionError, readStateFlags } from '../decisions.js';
7
+ import { retryOnceOnWarmUp, sayWarmUp } from '../utils.js';
8
+ export default class Choices extends BaseCommand {
9
+ static description = 'Ask a face what it would do (POST /v1/choices). Name the upstream model, a face and its maestro: ' +
10
+ '@alice:maestro-1, @dana~alice:maestro-1 for a face shared with you, or a composite such as ' +
11
+ '"(@alice | @bob):maestro-1". maestro-1-flash answers sooner and costs 10 times more. ' +
12
+ 'Describe the situation with --state (prose, at most ' +
13
+ '3,000 tokens) or --state-id (a state from faces state:create), ask with --question, and the face proposes ' +
14
+ 'the options it would weigh, strongest first. Leave --question out and it proposes the question it would ask. ' +
15
+ 'Billed on the tokens it processes (see faces models:list --kind upstream). Takes about 10 to 30 seconds.';
16
+ static examples = [
17
+ '<%= config.bin %> <%= command.id %> @alice:maestro-1 --state "A startup offers me a lead role at a lower salary." --question "Should I take the offer?"',
18
+ '<%= config.bin %> <%= command.id %> @head~socrates:maestro-1 --state "A chain bakery opened across the street."',
19
+ '<%= config.bin %> <%= command.id %> @alice:maestro-1 --state-id fs_STATE_ID --question "What should the shop do?" --max-choices 3',
20
+ '<%= config.bin %> <%= command.id %> "(@alice | @bob):maestro-1-flash" --state-file situation.txt -q "What next?" --json',
21
+ ];
22
+ static flags = {
23
+ ...BaseCommand.baseFlags,
24
+ question: Flags.string({ char: 'q', description: 'The question. Leave it out to have the face propose the question it would ask.' }),
25
+ state: Flags.string({ description: 'The situation, as prose: at most 3,000 tokens.', exclusive: ['state-file'] }),
26
+ 'state-file': Flags.string({ description: 'Read the situation from this file.', exclusive: ['state'] }),
27
+ 'state-id': Flags.string({
28
+ description: 'A state (from faces state:create) as the situation. With --state, the prose is an addendum for this call only: ' +
29
+ 'read with the state, never saved to it. Write anything that should persist with faces state:add --premise.',
30
+ }),
31
+ 'max-choices': Flags.integer({ description: `The most options to return, 1 to ${MAX_CHOICES}. Default 8.`, min: 1, max: MAX_CHOICES }),
32
+ };
33
+ static args = {
34
+ model: Args.string({
35
+ description: 'The upstream model: @<face>:<maestro>, e.g. @alice:maestro-1. Another account\'s face is @owner~face; ' +
36
+ 'a composite is "(@a | @b):maestro-1" (operators | & - ^). No model after it: on choices the upstream model answers.',
37
+ required: true,
38
+ }),
39
+ };
40
+ async run() {
41
+ const { args, flags } = await this.parse(Choices);
42
+ const client = this.makeClient(flags);
43
+ const json = this.jsonEnabled();
44
+ const model = args.model.trim();
45
+ const problem = modelProblem(model, 'upstream');
46
+ if (problem)
47
+ this.error(problem);
48
+ const body = { model };
49
+ const fail = (m) => this.error(m);
50
+ if (flags.state !== undefined || flags['state-file'] !== undefined) {
51
+ const state = readStateFlags(flags, fail);
52
+ if (typeof state === 'string' && state.trim() === '')
53
+ this.error('The situation is empty.');
54
+ body.state = state;
55
+ }
56
+ if (flags['state-id'])
57
+ body.state_id = flags['state-id'];
58
+ if (body.state === undefined && body.state_id === undefined) {
59
+ this.error('Describe the situation: --state "..." (or --state-file), or --state-id fs_... for a state.');
60
+ }
61
+ if (flags.question !== undefined) {
62
+ if (flags.question.trim() === '')
63
+ this.error('--question is empty. Leave it out to have the face propose the question.');
64
+ body.instructions = flags.question;
65
+ }
66
+ if (flags['max-choices'] !== undefined)
67
+ body.max_choices = flags['max-choices'];
68
+ let data;
69
+ try {
70
+ data = (await retryOnceOnWarmUp(async () => {
71
+ const res = await client.post(CHOICES_PATH, { body });
72
+ const held = heldDecisionError(res);
73
+ if (held)
74
+ throw held;
75
+ return res;
76
+ }, json ? undefined : sayWarmUp));
77
+ }
78
+ catch (err) {
79
+ if (err instanceof FacesAPIError) {
80
+ const hint = choicesHint(err.statusCode, err.message, model);
81
+ this.error(`HTTP ${err.statusCode}: ${err.message}${hint ? `\n${hint}` : ''}`);
82
+ }
83
+ throw err;
84
+ }
85
+ if (json)
86
+ return data;
87
+ for (const line of choicesLines(data))
88
+ this.log(line);
89
+ return data;
90
+ }
91
+ }
@@ -6,6 +6,8 @@ export default class ConversationAdd extends BaseCommand {
6
6
  message: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
7
  premise: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
8
  'premise-description': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ 'premise-status': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ 'premise-depends-on': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
11
  'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
12
  token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
13
  'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
@@ -1,33 +1,38 @@
1
1
  import { Args, Flags } from '@oclif/core';
2
2
  import { BaseCommand } from '../../base.js';
3
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';
4
+ import { CONVERSATIONS_PATH, MAX_CONVERSATION_ITEMS, PREMISE_DESCRIPTION_FLAG_DESCRIPTION, PREMISE_DEPENDS_ON_FLAG_DESCRIPTION, PREMISE_FLAG_DESCRIPTION, PREMISE_STATUS_FLAG_DESCRIPTION, clientItems, conversationHint, itemLines, parsePremises, premiseLines, staleDecisionLines, statusChangeLines, } from '../../conversation.js';
5
5
  import { seg } from '../../utils.js';
6
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.`;
7
+ static description = 'Add your own premises and messages to a state, without a face answering. Premises go in first, then ' +
8
+ 'messages. A newer value of a key replaces it from here on. Every status the write changes is listed ' +
9
+ '(an invalidated premise invalidates what depends on it), and so is every earlier decision that rested on ' +
10
+ 'a value you changed, so you can choose which to ask again: nothing is decided again for you. ' +
11
+ `At most ${MAX_CONVERSATION_ITEMS} at a time. Free.`;
11
12
  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."',
13
+ '<%= config.bin %> <%= command.id %> fs_STATE_ID --premise vendor_certified=false',
14
+ '<%= config.bin %> <%= command.id %> fs_STATE_ID --premise rent_rises="no rise" --premise-status rent_rises=invalidated',
15
+ '<%= config.bin %> <%= command.id %> fs_STATE_ID --premise can_afford=false --premise-description can_afford="we can carry the rent" --premise-depends-on can_afford=rent_rises',
16
+ '<%= config.bin %> <%= command.id %> fs_STATE_ID --premise budget_usd=50000 --premise-description budget_usd="the most we can spend this year"',
17
+ '<%= config.bin %> <%= command.id %> fs_STATE_ID -m "The vendor sent their audit report."',
15
18
  ];
16
19
  static flags = {
17
20
  ...BaseCommand.baseFlags,
18
21
  message: Flags.string({ char: 'm', description: 'A message of yours (repeatable, kept in order).', multiple: true }),
19
22
  premise: Flags.string({ description: PREMISE_FLAG_DESCRIPTION, multiple: true }),
20
23
  'premise-description': Flags.string({ description: PREMISE_DESCRIPTION_FLAG_DESCRIPTION, multiple: true }),
24
+ 'premise-status': Flags.string({ description: PREMISE_STATUS_FLAG_DESCRIPTION, multiple: true }),
25
+ 'premise-depends-on': Flags.string({ description: PREMISE_DEPENDS_ON_FLAG_DESCRIPTION, multiple: true }),
21
26
  };
22
27
  static args = {
23
- conversation_id: Args.string({ description: 'Conversation id (from conversation:create)', required: true }),
28
+ conversation_id: Args.string({ description: 'State id (from state:create)', required: true }),
24
29
  };
25
30
  async run() {
26
31
  const { args, flags } = await this.parse(ConversationAdd);
27
32
  const client = this.makeClient(flags);
28
33
  let items;
29
34
  try {
30
- items = clientItems(flags.message, parsePremises(flags.premise, flags['premise-description']));
35
+ items = clientItems(flags.message, parsePremises(flags.premise, flags['premise-description'], flags['premise-status'], flags['premise-depends-on']));
31
36
  }
32
37
  catch (err) {
33
38
  this.error(err instanceof Error ? err.message : String(err));
@@ -54,6 +59,12 @@ export default class ConversationAdd extends BaseCommand {
54
59
  this.log('');
55
60
  for (const line of premiseLines(data.premises))
56
61
  this.log(line);
62
+ const changes = statusChangeLines(data.status_changes);
63
+ if (changes.length > 0) {
64
+ this.log('');
65
+ for (const line of changes)
66
+ this.log(line);
67
+ }
57
68
  const stale = staleDecisionLines(data.decisions_made_under_old_values);
58
69
  if (stale.length > 0) {
59
70
  this.log('');
@@ -4,20 +4,20 @@ import { FacesAPIError } from '../../client.js';
4
4
  import { CONVERSATIONS_PATH, conversationHint } from '../../conversation.js';
5
5
  import { seg } from '../../utils.js';
6
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 ' +
7
+ static description = 'Close a state. A closed state takes no more turns and cannot be read or compacted. Its ' +
8
8
  'compactions stay usable until they expire. Free.';
9
- static examples = ['<%= config.bin %> <%= command.id %> fs_CONVERSATION_ID --yes'];
9
+ static examples = ['<%= config.bin %> <%= command.id %> fs_STATE_ID --yes'];
10
10
  static flags = {
11
11
  ...BaseCommand.baseFlags,
12
12
  yes: Flags.boolean({ description: 'Skip confirmation', default: false }),
13
13
  };
14
14
  static args = {
15
- conversation_id: Args.string({ description: 'Conversation id (from conversation:create)', required: true }),
15
+ conversation_id: Args.string({ description: 'State id (from state:create)', required: true }),
16
16
  };
17
17
  async run() {
18
18
  const { args, flags } = await this.parse(ConversationClose);
19
19
  const client = this.makeClient(flags);
20
- await this.confirmOrRefuse(`Close conversation ${args.conversation_id}? It cannot be reopened.`, flags.yes);
20
+ await this.confirmOrRefuse(`Close state ${args.conversation_id}? It cannot be reopened.`, flags.yes);
21
21
  let data;
22
22
  try {
23
23
  data = await client.delete(`${CONVERSATIONS_PATH}/${seg(args.conversation_id)}`);
@@ -30,7 +30,7 @@ export default class ConversationClose extends BaseCommand {
30
30
  throw err;
31
31
  }
32
32
  if (!this.jsonEnabled())
33
- this.log(`Closed conversation ${args.conversation_id}.`);
33
+ this.log(`Closed state ${args.conversation_id}.`);
34
34
  return data;
35
35
  }
36
36
  }
@@ -4,24 +4,24 @@ import { FacesAPIError } from '../../client.js';
4
4
  import { heldDecisionError } from '../../decisions.js';
5
5
  import { CONVERSATIONS_PATH, conversationHint } from '../../conversation.js';
6
6
  import { retryOnceOnWarmUp, sayWarmUp, seg } from '../../utils.js';
7
+ import { asFace as faceAlone } from '../../model.js';
7
8
  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.';
9
+ static description = 'Compact a state: one face\'s position over the state, kept on the server under a compaction id. ' +
10
+ 'Pass that id with --compaction on a later request with the same face. A state that takes any face ' +
11
+ 'needs the face named. Billed on the tokens it reads and writes; on Connect and Pro it counts against ' +
12
+ 'the plan\'s allowance. A failed compaction is not charged. A compaction expires 30 days after it is written.';
13
13
  static examples = [
14
- '<%= config.bin %> <%= command.id %> fs_CONVERSATION_ID',
15
- '<%= config.bin %> <%= command.id %> fs_CONVERSATION_ID alice --json',
14
+ '<%= config.bin %> <%= command.id %> fs_STATE_ID',
15
+ '<%= config.bin %> <%= command.id %> fs_STATE_ID @alice --json',
16
16
  ];
17
17
  static flags = {
18
18
  ...BaseCommand.baseFlags,
19
19
  };
20
20
  static args = {
21
- conversation_id: Args.string({ description: 'Conversation id (from conversation:create)', required: true }),
21
+ conversation_id: Args.string({ description: 'State id (from state:create)', required: true }),
22
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.',
23
+ description: 'The face to compact, as @face (or @owner~face), with no model after it. Needed when the state ' +
24
+ 'takes any face; a state opened with one face compacts that face.',
25
25
  required: false,
26
26
  }),
27
27
  };
@@ -29,9 +29,9 @@ export default class ConversationCompact extends BaseCommand {
29
29
  const { args, flags } = await this.parse(ConversationCompact);
30
30
  const client = this.makeClient(flags);
31
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('@'))}`);
32
+ const face = args.face === undefined ? undefined : faceAlone(args.face);
33
+ if (face && /[:/]/.test(face))
34
+ this.error(`Compact a face alone, with no maestro or model: ${face.split(/[:/]/)[0]}`);
35
35
  let data;
36
36
  try {
37
37
  data = (await retryOnceOnWarmUp(async () => {
@@ -45,7 +45,7 @@ export default class ConversationCompact extends BaseCommand {
45
45
  catch (err) {
46
46
  if (err instanceof FacesAPIError) {
47
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>`);
48
+ this.error(`HTTP ${err.statusCode}: ${err.message}\nName the face: faces state:compact ${args.conversation_id} @<face>`);
49
49
  }
50
50
  const hint = conversationHint(err);
51
51
  this.error(`HTTP ${err.statusCode}: ${err.message}${hint ? `\n${hint}` : ''}`);
@@ -53,16 +53,13 @@ export default class ConversationCompact extends BaseCommand {
53
53
  throw err;
54
54
  }
55
55
  if (!json) {
56
- if (typeof data.cause === 'string')
57
- this.log(data.cause);
58
- this.log('');
59
56
  this.log(`compaction: ${data.compaction_id ?? '-'}`);
60
57
  if (data.turns !== undefined)
61
58
  this.log(`turns: ${data.turns}`);
62
59
  if (data.expires_at)
63
60
  this.log(`expires: ${data.expires_at}`);
64
61
  if (data.compaction_id)
65
- this.log(`\nUse it with: faces chat:chat ${face ?? '<face>'}@<model> --compaction ${data.compaction_id} -m "..."`);
62
+ this.log(`\nUse it with: faces chat:chat ${face ?? '@<face>'}:maestro-1/<model> --compaction ${data.compaction_id} -m "..."`);
66
63
  }
67
64
  return data;
68
65
  }
@@ -7,6 +7,8 @@ export default class ConversationCreate extends BaseCommand {
7
7
  message: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
8
  premise: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
9
  'premise-description': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ 'premise-status': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ 'premise-depends-on': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
12
  'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
13
  token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
14
  'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
@@ -1,53 +1,56 @@
1
1
  import { Args, Flags } from '@oclif/core';
2
2
  import { BaseCommand } from '../../base.js';
3
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';
4
+ import { CONVERSATIONS_PATH, MAX_CONVERSATION_ITEMS, PREMISE_DESCRIPTION_FLAG_DESCRIPTION, PREMISE_DEPENDS_ON_FLAG_DESCRIPTION, PREMISE_FLAG_DESCRIPTION, PREMISE_STATUS_FLAG_DESCRIPTION, clientItems, conversationHint, conversationLines, parsePremises, } from '../../conversation.js';
5
+ import { asFace as faceAlone } from '../../model.js';
5
6
  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.';
7
+ static description = 'Start a state (formerly a conversation). The server keeps the situation your agent builds: premises ' +
8
+ '(named facts, each with a status and what it depends on), the decisions faces made, and your messages. ' +
9
+ 'Ask a face about it with faces choices --state-id, or pass its id with --conversation on chat or decide ' +
10
+ 'and send only what is new. Name a face and the state takes that face only; leave it out and it takes any ' +
11
+ 'of your faces. Opening one is free. A state expires 30 days after it was last used.';
11
12
  static examples = [
12
- '<%= config.bin %> <%= command.id %> alice',
13
+ '<%= config.bin %> <%= command.id %> @alice',
13
14
  '<%= config.bin %> <%= command.id %>',
14
15
  '<%= 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
+ '<%= config.bin %> <%= command.id %> @alice --premise budget_usd=50000 --premise-description budget_usd="the most we can spend this year"',
16
17
  ];
17
18
  static flags = {
18
19
  ...BaseCommand.baseFlags,
19
20
  'causes-visible': Flags.boolean({
20
21
  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
+ 'face to its own. Matters only in a state with several faces.',
22
23
  default: true,
23
24
  allowNo: true,
24
25
  }),
25
26
  message: Flags.string({ char: 'm', description: 'A first message of yours (repeatable, kept in order).', multiple: true }),
26
27
  premise: Flags.string({ description: PREMISE_FLAG_DESCRIPTION, multiple: true }),
27
28
  'premise-description': Flags.string({ description: PREMISE_DESCRIPTION_FLAG_DESCRIPTION, multiple: true }),
29
+ 'premise-status': Flags.string({ description: PREMISE_STATUS_FLAG_DESCRIPTION, multiple: true }),
30
+ 'premise-depends-on': Flags.string({ description: PREMISE_DEPENDS_ON_FLAG_DESCRIPTION, multiple: true }),
28
31
  };
29
32
  static args = {
30
33
  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.',
34
+ description: 'The face alone: @alice, @owner~alice, or a composite such as "(@a | @b)". No maestro or model. ' +
35
+ 'Leave it out for a state that takes any of your faces.',
33
36
  required: false,
34
37
  }),
35
38
  };
36
39
  async run() {
37
40
  const { args, flags } = await this.parse(ConversationCreate);
38
41
  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
+ const face = args.face === undefined ? undefined : faceAlone(args.face);
43
+ if (face && /[:/]/.test(face))
44
+ this.error(`A state is with a face alone, with no maestro or model: ${face.split(/[:/]/)[0]}`);
42
45
  let items;
43
46
  try {
44
- items = clientItems(flags.message, parsePremises(flags.premise, flags['premise-description']));
47
+ items = clientItems(flags.message, parsePremises(flags.premise, flags['premise-description'], flags['premise-status'], flags['premise-depends-on']));
45
48
  }
46
49
  catch (err) {
47
50
  this.error(err instanceof Error ? err.message : String(err));
48
51
  }
49
52
  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.`);
53
+ this.error(`At most ${MAX_CONVERSATION_ITEMS} messages and premises at a time (got ${items.length}). Add the rest with faces state:add.`);
51
54
  }
52
55
  const body = { causes_visible: flags['causes-visible'] };
53
56
  if (face)
@@ -69,7 +72,7 @@ export default class ConversationCreate extends BaseCommand {
69
72
  for (const line of conversationLines(data))
70
73
  this.log(line);
71
74
  if (data.id)
72
- this.log(`\nTake a turn with: faces chat:chat ${face ?? '<face>'}@<model> --conversation ${data.id} -m "..."`);
75
+ this.log(`\nAsk a face about it with: faces choices ${face ?? '@<face>'}:maestro-1 --state-id ${data.id} --question "..."`);
73
76
  }
74
77
  return data;
75
78
  }
@@ -4,14 +4,14 @@ import { FacesAPIError } from '../../client.js';
4
4
  import { CONVERSATIONS_PATH, conversationHint, conversationLines } from '../../conversation.js';
5
5
  import { seg } from '../../utils.js';
6
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'];
7
+ static description = 'Read a state: 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 state:items.';
9
+ static examples = ['<%= config.bin %> <%= command.id %> fs_STATE_ID'];
10
10
  static flags = {
11
11
  ...BaseCommand.baseFlags,
12
12
  };
13
13
  static args = {
14
- conversation_id: Args.string({ description: 'Conversation id (from conversation:create)', required: true }),
14
+ conversation_id: Args.string({ description: 'State id (from state:create)', required: true }),
15
15
  };
16
16
  async run() {
17
17
  const { args, flags } = await this.parse(ConversationGet);
@@ -4,17 +4,17 @@ import { FacesAPIError } from '../../client.js';
4
4
  import { CONVERSATIONS_PATH, conversationHint, itemLines, premiseLines } from '../../conversation.js';
5
5
  import { seg } from '../../utils.js';
6
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.';
7
+ static description = 'List a state\'s items in order: premises, decisions with their choice, cause and status, your messages ' +
8
+ 'and each face\'s reply. Ends with the premises in force now, each with its status. Free.';
9
9
  static examples = [
10
- '<%= config.bin %> <%= command.id %> fs_CONVERSATION_ID',
11
- '<%= config.bin %> <%= command.id %> fs_CONVERSATION_ID --json',
10
+ '<%= config.bin %> <%= command.id %> fs_STATE_ID',
11
+ '<%= config.bin %> <%= command.id %> fs_STATE_ID --json',
12
12
  ];
13
13
  static flags = {
14
14
  ...BaseCommand.baseFlags,
15
15
  };
16
16
  static args = {
17
- conversation_id: Args.string({ description: 'Conversation id (from conversation:create)', required: true }),
17
+ conversation_id: Args.string({ description: 'State id (from state:create)', required: true }),
18
18
  };
19
19
  async run() {
20
20
  const { args, flags } = await this.parse(ConversationItems);
@@ -3,6 +3,7 @@ export default class Decide extends BaseCommand {
3
3
  static description: string;
4
4
  static examples: string[];
5
5
  static flags: {
6
+ 'depends-on': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
6
7
  session: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
8
  compaction: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
9
  format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
@@ -10,6 +11,8 @@ export default class Decide extends BaseCommand {
10
11
  conversation: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
12
  premise: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
13
  'premise-description': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
+ 'premise-status': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
15
+ 'premise-depends-on': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
16
  'causes-visible': import("@oclif/core/interfaces").BooleanFlag<boolean>;
14
17
  state: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
15
18
  'state-file': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
@@ -19,16 +22,13 @@ export default class Decide extends BaseCommand {
19
22
  level: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
20
23
  id: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
21
24
  'questions-file': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
22
- model: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
23
- baseline: import("@oclif/core/interfaces").BooleanFlag<boolean>;
24
- 'show-cause': import("@oclif/core/interfaces").BooleanFlag<boolean>;
25
25
  'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
26
26
  token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
27
27
  'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
28
28
  toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
29
29
  };
30
30
  static args: {
31
- face: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
31
+ model: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
32
32
  };
33
33
  run(): Promise<unknown>;
34
34
  private ask;