@faces-sh/cli 1.1.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.
- package/README.md +106 -54
- package/dist/billing.js +11 -8
- package/dist/chat-command.d.ts +33 -0
- package/dist/chat-command.js +110 -0
- package/dist/chat.d.ts +49 -0
- package/dist/chat.js +157 -0
- package/dist/choices.d.ts +11 -5
- package/dist/choices.js +26 -9
- package/dist/client.d.ts +8 -0
- package/dist/client.js +37 -0
- package/dist/commands/billing/llm-costs.js +9 -5
- package/dist/commands/billing/subscription/index.js +1 -1
- package/dist/commands/catalog/doctor.js +2 -2
- package/dist/commands/{causes.d.ts → chat/chat.d.ts} +14 -14
- package/dist/commands/chat/chat.js +31 -0
- package/dist/commands/chat/messages.d.ts +32 -0
- package/dist/commands/chat/messages.js +21 -0
- package/dist/commands/chat/responses.d.ts +32 -0
- package/dist/commands/chat/responses.js +22 -0
- package/dist/commands/chat/thread.d.ts +40 -0
- package/dist/commands/chat/thread.js +238 -0
- package/dist/commands/choices.d.ts +4 -2
- package/dist/commands/choices.js +56 -15
- package/dist/commands/conversation/add.d.ts +2 -0
- package/dist/commands/conversation/add.js +5 -2
- package/dist/commands/conversation/compact.js +13 -16
- package/dist/commands/conversation/create.d.ts +2 -0
- package/dist/commands/conversation/create.js +14 -11
- package/dist/commands/decide.d.ts +32 -4
- package/dist/commands/decide.js +135 -83
- package/dist/commands/face/get.js +1 -1
- package/dist/commands/face/list.d.ts +2 -0
- package/dist/commands/face/list.js +23 -1
- package/dist/commands/fidelity/pick.js +2 -2
- package/dist/commands/fidelity/run.d.ts +20 -0
- package/dist/commands/fidelity/run.js +99 -0
- package/dist/commands/fidelity/start.d.ts +17 -0
- package/dist/commands/fidelity/start.js +56 -0
- package/dist/commands/fidelity/turn.d.ts +17 -0
- package/dist/commands/fidelity/turn.js +48 -0
- package/dist/commands/group/add.js +1 -1
- package/dist/commands/media/list.d.ts +12 -0
- package/dist/commands/media/list.js +35 -0
- package/dist/commands/models/list.js +13 -6
- package/dist/commands/premise/add.d.ts +30 -0
- package/dist/commands/premise/add.js +86 -0
- package/dist/commands/premise/choices.d.ts +21 -0
- package/dist/commands/premise/choices.js +68 -0
- package/dist/commands/premise/claim.d.ts +20 -0
- package/dist/commands/premise/claim.js +38 -0
- package/dist/commands/premise/decide.d.ts +18 -0
- package/dist/commands/premise/decide.js +36 -0
- package/dist/commands/premise/delete.d.ts +17 -0
- package/dist/commands/premise/delete.js +17 -0
- package/dist/commands/premise/edit.d.ts +28 -0
- package/dist/commands/premise/edit.js +51 -0
- package/dist/commands/premise/get.d.ts +22 -0
- package/dist/commands/premise/get.js +37 -0
- package/dist/commands/premise/refine.d.ts +20 -0
- package/dist/commands/premise/refine.js +80 -0
- package/dist/commands/session/compact.js +5 -8
- package/dist/commands/session/create.js +9 -8
- package/dist/commands/state/create.d.ts +13 -2
- package/dist/commands/state/create.js +55 -2
- package/dist/commands/state/get.d.ts +19 -2
- package/dist/commands/state/get.js +30 -2
- package/dist/commands/state/use.d.ts +16 -0
- package/dist/commands/state/use.js +25 -0
- package/dist/commands/style/make.js +1 -1
- package/dist/commands/style/upload.js +1 -1
- package/dist/conversation.d.ts +30 -3
- package/dist/conversation.js +202 -18
- package/dist/decisions.d.ts +0 -5
- package/dist/decisions.js +0 -18
- package/dist/fidelity.js +3 -3
- package/dist/foreman.d.ts +47 -0
- package/dist/foreman.js +115 -0
- package/dist/media.d.ts +8 -0
- package/dist/media.js +12 -0
- package/dist/model.d.ts +11 -0
- package/dist/model.js +53 -0
- package/dist/refine.d.ts +106 -0
- package/dist/refine.js +601 -0
- package/dist/routing.d.ts +1 -4
- package/dist/routing.js +4 -40
- package/dist/synopsis.d.ts +49 -0
- package/dist/synopsis.js +43 -0
- package/dist/utils.d.ts +1 -25
- package/dist/utils.js +10 -108
- package/oclif.manifest.json +3939 -1835
- package/package.json +10 -4
- package/dist/commands/causes.js +0 -146
|
@@ -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
|
+
}
|
|
@@ -5,10 +5,10 @@ import { heldDecisionError } from '../../decisions.js';
|
|
|
5
5
|
import { SESSIONS_PATH, sessionHint } from '../../session.js';
|
|
6
6
|
import { retryOnceOnWarmUp, sayWarmUp, seg } from '../../utils.js';
|
|
7
7
|
export default class SessionCompact extends BaseCommand {
|
|
8
|
-
static description = 'Compact a session:
|
|
9
|
-
'
|
|
10
|
-
'
|
|
11
|
-
'
|
|
8
|
+
static description = 'Compact a session: the face\'s position over the session, kept on the server under a compaction id. ' +
|
|
9
|
+
'Pass that id with --compaction on a later request with the same face, and send only the messages you ' +
|
|
10
|
+
'still want read. Billed on the tokens it reads and writes; on Connect and Pro it counts against the ' +
|
|
11
|
+
'plan\'s allowance. A failed compaction is not charged. ' +
|
|
12
12
|
'A compaction expires 30 days after it is written. Sessions are now called states: see faces state:compact.';
|
|
13
13
|
static examples = [
|
|
14
14
|
'<%= config.bin %> <%= command.id %> fs_SESSION_ID',
|
|
@@ -42,16 +42,13 @@ export default class SessionCompact extends BaseCommand {
|
|
|
42
42
|
throw err;
|
|
43
43
|
}
|
|
44
44
|
if (!json) {
|
|
45
|
-
if (typeof data.cause === 'string')
|
|
46
|
-
this.log(data.cause);
|
|
47
|
-
this.log('');
|
|
48
45
|
this.log(`compaction: ${data.compaction_id ?? '-'}`);
|
|
49
46
|
if (data.turns !== undefined)
|
|
50
47
|
this.log(`turns: ${data.turns}`);
|
|
51
48
|
if (data.expires_at)
|
|
52
49
|
this.log(`expires: ${data.expires_at}`);
|
|
53
50
|
if (data.compaction_id)
|
|
54
|
-
this.log(`\nUse it with: faces
|
|
51
|
+
this.log(`\nUse it with: faces chat:chat @<face>:maestro-1/<model> --compaction ${data.compaction_id} -m "..."`);
|
|
55
52
|
}
|
|
56
53
|
return data;
|
|
57
54
|
}
|
|
@@ -2,29 +2,30 @@ import { Args } from '@oclif/core';
|
|
|
2
2
|
import { BaseCommand } from '../../base.js';
|
|
3
3
|
import { FacesAPIError } from '../../client.js';
|
|
4
4
|
import { SESSIONS_PATH, sessionLines } from '../../session.js';
|
|
5
|
+
import { asFace as faceAlone } from '../../model.js';
|
|
5
6
|
export default class SessionCreate extends BaseCommand {
|
|
6
7
|
static description = 'Start a session with a face. A session groups the turns of one conversation with one face: pass its id ' +
|
|
7
|
-
'with --session on chat
|
|
8
|
+
'with --session on chat or decide, then compact it with session:compact. Opening one is free; ' +
|
|
8
9
|
'each turn costs what it costs without one. A session expires 30 days after its last turn. Sessions are now called states: see faces state:create.';
|
|
9
10
|
static examples = [
|
|
10
|
-
'<%= config.bin %> <%= command.id %> alice',
|
|
11
|
-
'<%= config.bin %> <%= command.id %> "(alice | bob)" --json',
|
|
11
|
+
'<%= config.bin %> <%= command.id %> @alice',
|
|
12
|
+
'<%= config.bin %> <%= command.id %> "(@alice | @bob)" --json',
|
|
12
13
|
];
|
|
13
14
|
static flags = {
|
|
14
15
|
...BaseCommand.baseFlags,
|
|
15
16
|
};
|
|
16
17
|
static args = {
|
|
17
18
|
face: Args.string({
|
|
18
|
-
description: 'The face alone:
|
|
19
|
+
description: 'The face alone: @alice, @owner~alice, or a composite such as "(@a | @b)". No maestro or model.',
|
|
19
20
|
required: true,
|
|
20
21
|
}),
|
|
21
22
|
};
|
|
22
23
|
async run() {
|
|
23
24
|
const { args, flags } = await this.parse(SessionCreate);
|
|
24
25
|
const client = this.makeClient(flags);
|
|
25
|
-
const face = args.face
|
|
26
|
-
if (face
|
|
27
|
-
this.error(`A session is with a face alone: ${face.
|
|
26
|
+
const face = faceAlone(args.face);
|
|
27
|
+
if (/[:/]/.test(face))
|
|
28
|
+
this.error(`A session is with a face alone, with no maestro or model: ${face.split(/[:/]/)[0]}`);
|
|
28
29
|
let data;
|
|
29
30
|
try {
|
|
30
31
|
data = (await client.post(SESSIONS_PATH, { body: { model: face } }));
|
|
@@ -38,7 +39,7 @@ export default class SessionCreate extends BaseCommand {
|
|
|
38
39
|
for (const line of sessionLines(data))
|
|
39
40
|
this.log(line);
|
|
40
41
|
if (data.id)
|
|
41
|
-
this.log(`\nAdd turns with: faces decide ${face}
|
|
42
|
+
this.log(`\nAdd turns with: faces decide ${face}:maestro-1/jev-latest --session ${data.id} --state "..." --question "..."`);
|
|
42
43
|
}
|
|
43
44
|
return data;
|
|
44
45
|
}
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
export default class StateCreate extends
|
|
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
|
|
2
|
-
|
|
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
|
|
2
|
-
export default class StateGet extends
|
|
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
|
|
2
|
-
|
|
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
|
+
}
|
|
@@ -107,7 +107,7 @@ export default class StyleMake extends BaseCommand {
|
|
|
107
107
|
for (const line of formatBuildReport(final))
|
|
108
108
|
this.log(line);
|
|
109
109
|
this.log('');
|
|
110
|
-
this.log(`'${args.alias}' has built a style.
|
|
110
|
+
this.log(`'${args.alias}' has built a style. Chat with the face uses it when a request is in that medium.`);
|
|
111
111
|
this.log(`Go back to the previous style: faces style:revert ${args.alias} --yes`);
|
|
112
112
|
return final;
|
|
113
113
|
}
|
|
@@ -12,7 +12,7 @@ export default class StyleUpload extends BaseCommand {
|
|
|
12
12
|
'for plaintextBody. The server lists every problem with a refused line, and the fields it accepts. ' +
|
|
13
13
|
'Upload ONE medium per file: a file mixing, say, email and ' +
|
|
14
14
|
'text messages produces threads with no medium at all, which no style can be built from. A message that declares ' +
|
|
15
|
-
'its own `kind` must spell one of the
|
|
15
|
+
'its own `kind` must spell one of the media in faces media:list exactly; an unknown one is refused, naming the ' +
|
|
16
16
|
'message that carried it. The file is passed through as written, so this is the server answering.';
|
|
17
17
|
static examples = [
|
|
18
18
|
'<%= config.bin %> <%= command.id %> alice ./mail.jsonl',
|
package/dist/conversation.d.ts
CHANGED
|
@@ -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?:
|
|
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?:
|
|
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
|
|
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>>;
|