@faces-sh/cli 1.2.0 → 1.3.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 (53) hide show
  1. package/README.md +51 -33
  2. package/dist/chat-command.d.ts +2 -0
  3. package/dist/chat.d.ts +2 -0
  4. package/dist/choices.d.ts +9 -0
  5. package/dist/choices.js +17 -1
  6. package/dist/client.d.ts +8 -0
  7. package/dist/client.js +37 -0
  8. package/dist/commands/chat/chat.d.ts +2 -0
  9. package/dist/commands/chat/messages.d.ts +2 -0
  10. package/dist/commands/chat/responses.d.ts +2 -0
  11. package/dist/commands/chat/thread.d.ts +2 -0
  12. package/dist/commands/choices.d.ts +3 -0
  13. package/dist/commands/choices.js +36 -0
  14. package/dist/commands/conversation/add.d.ts +2 -0
  15. package/dist/commands/conversation/add.js +5 -2
  16. package/dist/commands/conversation/create.d.ts +2 -0
  17. package/dist/commands/conversation/create.js +4 -2
  18. package/dist/commands/decide.d.ts +31 -0
  19. package/dist/commands/decide.js +84 -4
  20. package/dist/commands/face/list.d.ts +2 -0
  21. package/dist/commands/face/list.js +23 -1
  22. package/dist/commands/premise/add.d.ts +30 -0
  23. package/dist/commands/premise/add.js +86 -0
  24. package/dist/commands/premise/choices.d.ts +21 -0
  25. package/dist/commands/premise/choices.js +68 -0
  26. package/dist/commands/premise/claim.d.ts +20 -0
  27. package/dist/commands/premise/claim.js +38 -0
  28. package/dist/commands/premise/decide.d.ts +18 -0
  29. package/dist/commands/premise/decide.js +36 -0
  30. package/dist/commands/premise/delete.d.ts +17 -0
  31. package/dist/commands/premise/delete.js +17 -0
  32. package/dist/commands/premise/edit.d.ts +28 -0
  33. package/dist/commands/premise/edit.js +51 -0
  34. package/dist/commands/premise/get.d.ts +22 -0
  35. package/dist/commands/premise/get.js +37 -0
  36. package/dist/commands/premise/refine.d.ts +20 -0
  37. package/dist/commands/premise/refine.js +80 -0
  38. package/dist/commands/state/create.d.ts +13 -2
  39. package/dist/commands/state/create.js +55 -2
  40. package/dist/commands/state/get.d.ts +19 -2
  41. package/dist/commands/state/get.js +30 -2
  42. package/dist/commands/state/use.d.ts +16 -0
  43. package/dist/commands/state/use.js +25 -0
  44. package/dist/conversation.d.ts +30 -3
  45. package/dist/conversation.js +202 -18
  46. package/dist/foreman.d.ts +47 -0
  47. package/dist/foreman.js +115 -0
  48. package/dist/refine.d.ts +106 -0
  49. package/dist/refine.js +601 -0
  50. package/dist/synopsis.d.ts +49 -0
  51. package/dist/synopsis.js +43 -0
  52. package/oclif.manifest.json +1415 -109
  53. package/package.json +5 -2
@@ -0,0 +1,51 @@
1
+ import { Args, Flags } from '@oclif/core';
2
+ import { BaseCommand } from '../../base.js';
3
+ import { ReplyCommand, asFlag, compact, keyList, premiseValue, stateIdFlag } from '../../foreman.js';
4
+ export default class PremiseEdit extends ReplyCommand {
5
+ static description = 'Change a premise; fails if the key does not exist. Only what you give changes. A test run is an edit: ' +
6
+ '--status verified|invalidated --tested <candidate> --evidence "<what the run showed>". Filling a premise is ' +
7
+ '--value with --await none. A goal\'s new value sets its refinement back to incomplete. Free.';
8
+ static examples = [
9
+ '<%= config.bin %> <%= command.id %> "each guest can eat each dish" --status verified --tested "the vegan menu" --evidence "every dish checked"',
10
+ '<%= config.bin %> <%= command.id %> "the budget" --value "60 euros" --await none --said "Sixty euros."',
11
+ '<%= config.bin %> <%= command.id %> "the menu" --key "what we serve"',
12
+ '<%= config.bin %> <%= command.id %> "the menu" --note "ask about allergies too"',
13
+ ];
14
+ static flags = {
15
+ ...BaseCommand.baseFlags,
16
+ ...stateIdFlag,
17
+ ...asFlag,
18
+ value: Flags.string({ description: 'Its new value: JSON when it is JSON, text otherwise.' }),
19
+ key: Flags.string({ description: 'Rename it to this key; its edges, claims and messages follow.' }),
20
+ status: Flags.string({ description: 'stated, verified, assumed, unresolved or invalidated.' }),
21
+ description: Flags.string({ description: 'What the premise is, in a line.' }),
22
+ await: Flags.string({ description: 'What it waits on: human, environment, a test\'s key, or none.' }),
23
+ tested: Flags.string({ description: 'With --status on a test: the candidate the run was on.' }),
24
+ evidence: Flags.string({ description: 'What a test run showed (stored as a message).' }),
25
+ note: Flags.string({ description: 'A note linked to the premise.' }),
26
+ on: Flags.string({ description: 'Replace the inputs it reads: premise keys, comma separated (repeatable).', multiple: true }),
27
+ refinement: Flags.string({ description: 'complete or incomplete: whether its refinement is sufficient (what premise:refine records).', options: ['complete', 'incomplete'] }),
28
+ said: Flags.string({ description: 'The human\'s words behind this change.' }),
29
+ };
30
+ static args = { key: Args.string({ description: 'The premise to change.', required: true }) };
31
+ async run() {
32
+ const { args, flags } = await this.parse(PremiseEdit);
33
+ const client = this.makeClient(flags);
34
+ const body = compact({
35
+ key: args.key,
36
+ value: flags.value === undefined ? undefined : premiseValue(flags.value),
37
+ to: flags.key,
38
+ status: flags.status,
39
+ description: flags.description,
40
+ await: flags.await,
41
+ tested: flags.tested,
42
+ evidence: flags.evidence,
43
+ note: flags.note,
44
+ on: flags.on === undefined ? undefined : (keyList(flags.on, '--on') ?? []),
45
+ refinement: flags.refinement,
46
+ said: flags.said,
47
+ as: flags.as,
48
+ });
49
+ return this.reply(client, 'PATCH', this.statePath(this.stateId(flags), '/premises'), { body });
50
+ }
51
+ }
@@ -0,0 +1,22 @@
1
+ import { ReplyCommand } from '../../foreman.js';
2
+ export default class PremiseGet extends ReplyCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ depth: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ up: import("@oclif/core/interfaces").BooleanFlag<boolean>;
8
+ query: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ all: import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
+ problog: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
+ dot: import("@oclif/core/interfaces").BooleanFlag<boolean>;
12
+ 'state-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
+ 'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
+ token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
15
+ 'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
16
+ toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
17
+ };
18
+ static args: {
19
+ key: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
20
+ };
21
+ run(): Promise<unknown>;
22
+ }
@@ -0,0 +1,37 @@
1
+ import { Args, Flags } from '@oclif/core';
2
+ import { BaseCommand } from '../../base.js';
3
+ import { ReplyCommand, formatFlags, formatOf, stateIdFlag } from '../../foreman.js';
4
+ export default class PremiseGet extends ReplyCommand {
5
+ static description = 'One premise and its branch, numbered as in state:get, then every message linked to it in full (what the ' +
6
+ 'human said, notes, evidence). --depth N levels (default all); --up the path from its root down to it; ' +
7
+ '--query a search by meaning limited to its branch. Free.';
8
+ static examples = [
9
+ '<%= config.bin %> <%= command.id %> "the dinner is planned" --depth 2',
10
+ '<%= config.bin %> <%= command.id %> "the menu" --up',
11
+ '<%= config.bin %> <%= command.id %> "the menu" --query "allergies"',
12
+ ];
13
+ static flags = {
14
+ ...BaseCommand.baseFlags,
15
+ ...stateIdFlag,
16
+ ...formatFlags,
17
+ depth: Flags.integer({ description: 'How many levels below it, 0 to 50. Default: all.', min: 0, max: 50 }),
18
+ up: Flags.boolean({ description: 'The path from its root down to it, instead of its branch.', default: false }),
19
+ query: Flags.string({ description: 'The premises in its branch that best match this text, by meaning.' }),
20
+ all: Flags.boolean({ description: 'Also premises pruned by an earlier version.', default: false }),
21
+ };
22
+ static args = { key: Args.string({ description: 'The premise.', required: true }) };
23
+ async run() {
24
+ const { args, flags } = await this.parse(PremiseGet);
25
+ const client = this.makeClient(flags);
26
+ const params = { key: args.key, format: formatOf(flags, this.jsonEnabled()) };
27
+ if (flags.depth !== undefined)
28
+ params.depth = String(flags.depth);
29
+ if (flags.up)
30
+ params.up = 'true';
31
+ if (flags.query)
32
+ params.query = flags.query;
33
+ if (flags.all)
34
+ params.all = 'true';
35
+ return this.reply(client, 'GET', this.statePath(this.stateId(flags), '/premise'), { params });
36
+ }
37
+ }
@@ -0,0 +1,20 @@
1
+ import { ReplyCommand } from '../../foreman.js';
2
+ export default class PremiseRefine extends ReplyCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ recursive: import("@oclif/core/interfaces").BooleanFlag<boolean>;
7
+ depth: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ face: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
9
+ as: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ 'state-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ 'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
+ token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
+ 'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
+ toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
15
+ };
16
+ static args: {
17
+ key: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
18
+ };
19
+ run(): Promise<unknown>;
20
+ }
@@ -0,0 +1,80 @@
1
+ import { Args, Flags } from '@oclif/core';
2
+ import { BaseCommand } from '../../base.js';
3
+ import { FacesAPIError } from '../../client.js';
4
+ import { ReplyCommand, asFlag, faceFlag, faceRef, stateIdFlag } from '../../foreman.js';
5
+ import { Loop, refine, refineTree } from '../../refine.js';
6
+ export default class PremiseRefine extends ReplyCommand {
7
+ static description = 'Break a goal into sub-goals: a fixed loop of billed /v1/choices and /v1/decisions calls. A decision judges ' +
8
+ 'what it needs (conditions that must all hold, meanings to pick from, one test, or the human); the face ' +
9
+ 'proposes; each condition must pass two judges; a gap check adds what they leave out. A goal rewritten since ' +
10
+ 'is checked again against its new value. -r refines what it refines into too, breadth first. Billed per ' +
11
+ 'model call; prints how many it made.';
12
+ static examples = [
13
+ '<%= config.bin %> <%= command.id %> "the dinner is planned" --face @home-cook',
14
+ '<%= config.bin %> <%= command.id %> "the dinner is planned" --face @home-cook -r --depth 2',
15
+ ];
16
+ static flags = {
17
+ ...BaseCommand.baseFlags,
18
+ ...stateIdFlag,
19
+ ...asFlag,
20
+ ...faceFlag,
21
+ recursive: Flags.boolean({ char: 'r', description: 'Refine what it refines into too, breadth first: a branch stops at a test, the human\'s fact or an await; on an OR only the next candidate to try is refined.', default: false }),
22
+ depth: Flags.string({ description: 'With -r: how many levels to refine, a whole number from 1, or all for no limit. Default 3. Every level\'s calls are billed.', dependsOn: ['recursive'] }),
23
+ };
24
+ static args = { key: Args.string({ description: 'The premise to refine.', required: true }) };
25
+ async run() {
26
+ const { args, flags } = await this.parse(PremiseRefine);
27
+ const client = this.makeClient(flags);
28
+ const id = this.stateId(flags);
29
+ const steps = [];
30
+ const L = new Loop(client, id, faceRef(flags.face), flags.as, (l) => steps.push(l));
31
+ let lines;
32
+ const depth = flags.depth === undefined ? 3 : flags.depth.trim().toLowerCase() === 'all' ? Number.POSITIVE_INFINITY : Number(flags.depth);
33
+ if (!(depth === Number.POSITIVE_INFINITY || (Number.isInteger(depth) && depth >= 1))) {
34
+ this.error('--depth is a whole number from 1, or all for no limit');
35
+ }
36
+ const before = flags.recursive ? await balance(client) : undefined;
37
+ try {
38
+ if (flags.recursive) {
39
+ const got = await refineTree(L, args.key, depth, (l) => steps.push(l));
40
+ const after = await balance(client);
41
+ const spent = before !== undefined && after !== undefined ? `$${(before - after).toFixed(4)} spent` : 'spend unknown';
42
+ const waits = got.awaits.length ? ' (' + got.awaits.map((k) => `"${k}"`).join(', ') + ')' : '';
43
+ lines = [`Refined ${got.refined.length} premise(s): ${L.calls} billed call(s), ${spent}, ${got.awaits.length} branch(es) stopped on an await${waits}.`];
44
+ if (got.beyond.length) {
45
+ lines.push(`Stopped at depth ${depth}; ${got.beyond.length} premise(s) below it are not refined (${got.beyond.map((k) => `"${k}"`).join(', ')}). ` +
46
+ `Run again with --depth ${depth + 1}, or --depth all for no limit.`);
47
+ }
48
+ }
49
+ else {
50
+ lines = await refine(L, args.key);
51
+ }
52
+ }
53
+ catch (err) {
54
+ if (err instanceof FacesAPIError) {
55
+ process.exitCode = 1;
56
+ process.stderr.write([...steps, `Stopped (${err.statusCode}): ${err.message}`,
57
+ `${L.calls} billed call(s) made before it stopped; what they wrote is in the state.`].join('\n') + '\n');
58
+ return { error: { status: err.statusCode, message: err.message }, steps, calls: L.calls, usage: L.usage };
59
+ }
60
+ throw err;
61
+ }
62
+ const got = await client.stateReply('GET', this.statePath(id, '/premise'), { params: { key: args.key } });
63
+ const view = typeof got.data.text === 'string' ? got.data.text : '';
64
+ const text = flags.recursive
65
+ ? [...steps, '', view, '', ...lines].join('\n')
66
+ : [...steps, ...lines, `${L.calls} billed call(s) (${L.usage.input_tokens} in, ${L.usage.output_tokens} out).`, '', view].join('\n');
67
+ if (!this.jsonEnabled())
68
+ this.log(text);
69
+ return { steps, result: lines, calls: L.calls, usage: L.usage, text };
70
+ }
71
+ }
72
+ async function balance(client) {
73
+ try {
74
+ const d = (await client.get('/v1/billing/balance'));
75
+ return typeof d.balance_usd === 'number' ? d.balance_usd : undefined;
76
+ }
77
+ catch {
78
+ return undefined;
79
+ }
80
+ }
@@ -1,3 +1,14 @@
1
- import ConversationCreate from '../conversation/create.js';
2
- export default class StateCreate extends ConversationCreate {
1
+ import { BaseCommand } from '../../base.js';
2
+ export default class StateCreate extends BaseCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ use: import("@oclif/core/interfaces").BooleanFlag<boolean>;
7
+ local: import("@oclif/core/interfaces").BooleanFlag<boolean>;
8
+ 'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ 'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
12
+ };
13
+ run(): Promise<unknown>;
3
14
  }
@@ -1,3 +1,56 @@
1
- import ConversationCreate from '../conversation/create.js';
2
- export default class StateCreate extends ConversationCreate {
1
+ import { 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 { writeStateFile } from '../../foreman.js';
6
+ import { seg } from '../../utils.js';
7
+ export default class StateCreate extends BaseCommand {
8
+ static description = 'Create a new, empty state: a proof in progress, built with premise:add and read with state:get. ' +
9
+ '--use makes this directory use it (.faces/state, read by every faces call here or below). Free. ' +
10
+ 'A state expires 30 days after it was last used.';
11
+ static examples = [
12
+ '<%= config.bin %> <%= command.id %> --use',
13
+ '<%= config.bin %> <%= command.id %> --use --local',
14
+ '<%= config.bin %> <%= command.id %>',
15
+ ];
16
+ static flags = {
17
+ ...BaseCommand.baseFlags,
18
+ use: Flags.boolean({ description: 'Use it in this directory: write .faces/state, which every faces call here or below reads.', default: false }),
19
+ local: Flags.boolean({ description: 'With --use: write .faces/state.local instead (overrides .faces/state, for you alone).', default: false, dependsOn: ['use'] }),
20
+ };
21
+ async run() {
22
+ const { flags } = await this.parse(StateCreate);
23
+ const client = this.makeClient(flags);
24
+ let data;
25
+ try {
26
+ data = (await client.post(CONVERSATIONS_PATH, { body: {} }));
27
+ }
28
+ catch (err) {
29
+ if (err instanceof FacesAPIError) {
30
+ const hint = conversationHint(err);
31
+ this.error(`HTTP ${err.statusCode}: ${err.message}${hint ? `\n${hint}` : ''}`);
32
+ }
33
+ throw err;
34
+ }
35
+ if (!data.id)
36
+ this.error('The server returned no state id.');
37
+ if (!flags.use) {
38
+ if (this.jsonEnabled())
39
+ return data;
40
+ this.log(`Created an empty state, ${data.id}. faces state:use ${data.id} makes this directory use it.`);
41
+ return data;
42
+ }
43
+ const file = writeStateFile(data.id, flags.local);
44
+ if (this.jsonEnabled())
45
+ return { ...data, state_file: file };
46
+ this.log(`Created an empty state, ${data.id}. Every faces call in this directory now uses it (${file}).`);
47
+ try {
48
+ const got = await client.stateReply('GET', `${CONVERSATIONS_PATH}/${seg(data.id)}/proof`);
49
+ if (typeof got.data.text === 'string')
50
+ this.log('\n' + got.data.text);
51
+ }
52
+ catch {
53
+ }
54
+ return { ...data, state_file: file };
55
+ }
3
56
  }
@@ -1,3 +1,20 @@
1
- import ConversationGet from '../conversation/get.js';
2
- export default class StateGet extends ConversationGet {
1
+ import { ReplyCommand } from '../../foreman.js';
2
+ export default class StateGet extends ReplyCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ query: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ all: import("@oclif/core/interfaces").BooleanFlag<boolean>;
8
+ problog: import("@oclif/core/interfaces").BooleanFlag<boolean>;
9
+ dot: import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
+ 'state-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ 'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
+ token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
+ 'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
+ toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
15
+ };
16
+ static args: {
17
+ id: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
18
+ };
19
+ run(): Promise<unknown>;
3
20
  }
@@ -1,3 +1,31 @@
1
- import ConversationGet from '../conversation/get.js';
2
- export default class StateGet extends ConversationGet {
1
+ import { Args, Flags } from '@oclif/core';
2
+ import { BaseCommand } from '../../base.js';
3
+ import { ReplyCommand, formatFlags, formatOf, stateIdFlag } from '../../foreman.js';
4
+ export default class StateGet extends ReplyCommand {
5
+ static description = 'The whole proof: one line per premise, numbered (1, 1.2, 1.2.1), [x] proved, [ ] open, [-] refuted, the ' +
6
+ 'operator on each parent, candidates highest p first; then the last line: proved, refuted or open, the next ' +
7
+ 'candidate to try, and what would prove it. --query: the premises that best match a text, by meaning. Free.';
8
+ static examples = [
9
+ '<%= config.bin %> <%= command.id %>',
10
+ '<%= config.bin %> <%= command.id %> --query "dietary needs"',
11
+ '<%= config.bin %> <%= command.id %> --problog > proof.pl',
12
+ ];
13
+ static flags = {
14
+ ...BaseCommand.baseFlags,
15
+ ...stateIdFlag,
16
+ ...formatFlags,
17
+ query: Flags.string({ description: 'The premises that best match this text, by meaning.' }),
18
+ all: Flags.boolean({ description: 'Also premises pruned by an earlier version.', default: false }),
19
+ };
20
+ static args = { id: Args.string({ description: 'The state (fs_...). Default: .faces/state here or above.', required: false }) };
21
+ async run() {
22
+ const { args, flags } = await this.parse(StateGet);
23
+ const client = this.makeClient(flags);
24
+ const params = { format: formatOf(flags, this.jsonEnabled()) };
25
+ if (flags.query)
26
+ params.query = flags.query;
27
+ if (flags.all)
28
+ params.all = 'true';
29
+ return this.reply(client, 'GET', this.statePath(this.stateId(flags, args.id), '/proof'), { params });
30
+ }
3
31
  }
@@ -0,0 +1,16 @@
1
+ import { ReplyCommand } from '../../foreman.js';
2
+ export default class StateUse extends ReplyCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ local: 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
+ state_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
14
+ };
15
+ run(): Promise<unknown>;
16
+ }
@@ -0,0 +1,25 @@
1
+ import { Args, Flags } from '@oclif/core';
2
+ import { BaseCommand } from '../../base.js';
3
+ import { ReplyCommand, writeStateFile } from '../../foreman.js';
4
+ export default class StateUse extends ReplyCommand {
5
+ static description = 'Use a state in this directory: writes .faces/state (or .faces/state.local with --local, which overrides it), ' +
6
+ 'so every faces call run here or below finds it. Prints its synopsis. Free.';
7
+ static examples = ['<%= config.bin %> <%= command.id %> fs_STATE_ID', '<%= config.bin %> <%= command.id %> fs_STATE_ID --local'];
8
+ static flags = {
9
+ ...BaseCommand.baseFlags,
10
+ local: Flags.boolean({ description: 'Write .faces/state.local (yours, not shared) instead of .faces/state.', default: false }),
11
+ };
12
+ static args = { state_id: Args.string({ description: 'The state (fs_...).', required: true }) };
13
+ async run() {
14
+ const { args, flags } = await this.parse(StateUse);
15
+ const client = this.makeClient(flags);
16
+ const got = await client.stateReply('GET', this.statePath(args.state_id, '/synopsis'), { params: { reply: '1' } })
17
+ .catch((err) => this.error(err.message));
18
+ if (got.ok) {
19
+ const file = writeStateFile(args.state_id, flags.local);
20
+ if (!this.jsonEnabled())
21
+ this.log(`${args.state_id} is used here (${file}).`);
22
+ }
23
+ return this.show(got);
24
+ }
25
+ }
@@ -1,7 +1,18 @@
1
1
  import { FacesAPIError } from './client.js';
2
2
  export declare const CONVERSATIONS_PATH = "/v1/states";
3
3
  export declare const MAX_CONVERSATION_ITEMS = 20;
4
+ export declare const MAX_KEY_CHARS = 120;
4
5
  export declare const PREMISE_STATUSES: readonly ["stated", "verified", "assumed", "unresolved", "invalidated"];
6
+ export declare const PREMISE_ROLES: readonly ["goal", "test"];
7
+ export declare const EDGE_KINDS: readonly ["and", "or"];
8
+ export interface DependsOnEdge {
9
+ id: string;
10
+ kind: string;
11
+ p?: number;
12
+ decision?: string;
13
+ }
14
+ export type DependsOnEntry = string | DependsOnEdge;
15
+ export declare const PREMISE_ORIGINS: readonly ["human", "agent", "tool", "web"];
5
16
  export declare const MAX_DEPENDS_ON = 200;
6
17
  export interface Conversation {
7
18
  object?: string;
@@ -20,7 +31,9 @@ export interface Premise {
20
31
  value: unknown;
21
32
  description?: string;
22
33
  status?: string;
23
- depends_on?: string[];
34
+ depends_on?: DependsOnEntry[];
35
+ role?: string | null;
36
+ origin?: string | null;
24
37
  }
25
38
  export interface PremiseState {
26
39
  value?: unknown;
@@ -28,7 +41,11 @@ export interface PremiseState {
28
41
  status?: string;
29
42
  asserted_status?: string;
30
43
  because?: string | null;
31
- depends_on?: string[];
44
+ depends_on?: DependsOnEntry[];
45
+ role?: string;
46
+ face?: string;
47
+ reason?: string;
48
+ origin?: string;
32
49
  }
33
50
  export interface StatusChange {
34
51
  kind?: string;
@@ -43,6 +60,8 @@ export declare const PREMISE_FLAG_DESCRIPTION: string;
43
60
  export declare const PREMISE_DESCRIPTION_FLAG_DESCRIPTION: string;
44
61
  export declare const PREMISE_STATUS_FLAG_DESCRIPTION: string;
45
62
  export declare const PREMISE_DEPENDS_ON_FLAG_DESCRIPTION: string;
63
+ export declare const PREMISE_ROLE_FLAG_DESCRIPTION: string;
64
+ export declare const PREMISE_ORIGIN_FLAG_DESCRIPTION: string;
46
65
  export declare const CAUSES_VISIBLE_TURN_FLAG_DESCRIPTION: string;
47
66
  export declare function conversationTurnFlags(opts?: {
48
67
  suffix?: string;
@@ -53,13 +72,19 @@ export declare function conversationTurnFlags(opts?: {
53
72
  'premise-description': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
54
73
  'premise-status': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
55
74
  'premise-depends-on': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
75
+ 'premise-role': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
76
+ 'premise-origin': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
56
77
  'causes-visible': import("@oclif/core/interfaces").BooleanFlag<boolean>;
57
78
  };
58
79
  export declare function conversationLines(c: Conversation): string[];
59
80
  export declare function conversationHint(err: FacesAPIError): string | undefined;
60
81
  export declare function premiseValue(raw: string): unknown;
61
- export declare function parsePremises(premises?: string[], descriptions?: string[], statuses?: string[], dependsOn?: string[]): Premise[];
82
+ export declare function keyArg(key: string): string;
83
+ export declare function parsePremises(premises?: string[], descriptions?: string[], statuses?: string[], dependsOn?: string[], roles?: string[], origins?: string[]): Premise[];
62
84
  export declare function parseDependsOn(raw: string, flag?: string): string[];
85
+ export declare function entryId(d: DependsOnEntry): string;
86
+ export declare function entryText(d: DependsOnEntry): string;
87
+ export declare function parseWeightedDependsOn(raw: string, flag?: string): DependsOnEntry[];
63
88
  export declare function conversationFields(flags: {
64
89
  conversation?: string;
65
90
  session?: string;
@@ -67,6 +92,8 @@ export declare function conversationFields(flags: {
67
92
  'premise-description'?: string[];
68
93
  'premise-status'?: string[];
69
94
  'premise-depends-on'?: string[];
95
+ 'premise-role'?: string[];
96
+ 'premise-origin'?: string[];
70
97
  'causes-visible'?: boolean;
71
98
  }): Record<string, unknown>;
72
99
  export declare function clientItems(messages?: string[], premises?: Premise[]): Array<Record<string, unknown>>;