@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.
- package/README.md +51 -33
- package/dist/chat-command.d.ts +2 -0
- package/dist/chat.d.ts +2 -0
- package/dist/choices.d.ts +9 -0
- package/dist/choices.js +17 -1
- package/dist/client.d.ts +8 -0
- package/dist/client.js +37 -0
- package/dist/commands/chat/chat.d.ts +2 -0
- package/dist/commands/chat/messages.d.ts +2 -0
- package/dist/commands/chat/responses.d.ts +2 -0
- package/dist/commands/chat/thread.d.ts +2 -0
- package/dist/commands/choices.d.ts +3 -0
- package/dist/commands/choices.js +36 -0
- package/dist/commands/conversation/add.d.ts +2 -0
- package/dist/commands/conversation/add.js +5 -2
- package/dist/commands/conversation/create.d.ts +2 -0
- package/dist/commands/conversation/create.js +4 -2
- package/dist/commands/decide.d.ts +31 -0
- package/dist/commands/decide.js +84 -4
- package/dist/commands/face/list.d.ts +2 -0
- package/dist/commands/face/list.js +23 -1
- 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/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/conversation.d.ts +30 -3
- package/dist/conversation.js +202 -18
- package/dist/foreman.d.ts +47 -0
- package/dist/foreman.js +115 -0
- package/dist/refine.d.ts +106 -0
- package/dist/refine.js +601 -0
- package/dist/synopsis.d.ts +49 -0
- package/dist/synopsis.js +43 -0
- package/oclif.manifest.json +1415 -109
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -60,7 +60,10 @@ faces face:tag:add / list / remove / set / all
|
|
|
60
60
|
faces choices # what a face would do: its options, or the question it would ask
|
|
61
61
|
faces chat:chat / messages / responses / thread # chat with a face on any chat model
|
|
62
62
|
faces decide # what a face would decide: yes/no, a choice, or a score
|
|
63
|
-
faces state:create /
|
|
63
|
+
faces state:create --use / use / get # a state for this directory (.faces/state) and its proof
|
|
64
|
+
faces premise:add / edit / get / delete / claim
|
|
65
|
+
faces premise:refine / choices / decide # billed: refine a premise with a face, its candidates, their ranking
|
|
66
|
+
faces state:items / add / compact / close # the older premise-list commands, still served
|
|
64
67
|
faces conversation:create / ... # the old name for state:*
|
|
65
68
|
faces session:create / get / compact / close # an older name
|
|
66
69
|
|
|
@@ -146,12 +149,25 @@ faces choices @head~socrates:maestro-1 --state-id fs_STATE_ID --question "What s
|
|
|
146
149
|
faces choices "(@alice | @bob):maestro-1-flash" --state-file situation.txt -q "What next?"
|
|
147
150
|
```
|
|
148
151
|
|
|
152
|
+
With `--state-id`, `--depends-on` names what the options rest on, comma separated: premise
|
|
153
|
+
keys, decision ids, option ids and choices ids in the state. The face is shown each of them, and
|
|
154
|
+
the premises each directly depends on, in full, and the options written into the state record
|
|
155
|
+
it:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
faces choices @alice:maestro-1 --state-id fs_STATE_ID --question "How do we get there?" --depends-on goal,budget
|
|
159
|
+
```
|
|
160
|
+
|
|
149
161
|
With both `--state-id` and `--state`, the prose is an addendum for that one call: read with the
|
|
150
162
|
state, never saved to it. Anything that should persist goes in the state as premises, with
|
|
151
|
-
`faces
|
|
163
|
+
`faces premise:add`.
|
|
152
164
|
|
|
153
165
|
The face proposes the options it would weigh, strongest first. Leave `--question` out and it
|
|
154
|
-
proposes the question it would ask.
|
|
166
|
+
proposes the question it would ask. With `--state-id` and a question, the options are also added
|
|
167
|
+
to the state: each is printed with its id (`opt_...`), and the list with its own (`cho_...`). A
|
|
168
|
+
premise or a decision that rests on an option names its id in `--premise-depends-on` or
|
|
169
|
+
`--depends-on` (the list's id names all of its options), and a decision resting on it, directly or
|
|
170
|
+
through a premise, is shown why the face proposed it. Prices: `faces models:list --kind upstream`.
|
|
155
171
|
|
|
156
172
|
## Chat
|
|
157
173
|
|
|
@@ -172,40 +188,42 @@ The face's style is chosen for each request, from the face's built styles. `styl
|
|
|
172
188
|
|
|
173
189
|
## States
|
|
174
190
|
|
|
175
|
-
A state
|
|
176
|
-
|
|
177
|
-
|
|
191
|
+
A state is a proof in progress, kept on the server: a tree of premises joined by AND and OR,
|
|
192
|
+
each box proved `[x]`, open `[ ]` or refuted `[-]`, and a last line that names what still stands
|
|
193
|
+
between you and a proved goal. `faces state:create --use` makes one for this directory (its id
|
|
194
|
+
goes in `.faces/state`), and every `premise:*` and `state:*` command here or below works on it.
|
|
178
195
|
|
|
179
196
|
```bash
|
|
180
|
-
faces state:create
|
|
181
|
-
faces
|
|
182
|
-
|
|
183
|
-
faces
|
|
184
|
-
|
|
185
|
-
faces decide @alice:maestro-1/jev-latest --conversation fs_STATE_ID --depends-on can_afford \
|
|
186
|
-
--state "Decide about the lease." --question "Move the shop to a cheaper street?"
|
|
187
|
-
faces state:add fs_STATE_ID --premise rent_rises='"no rise this year"' --premise-status rent_rises=invalidated
|
|
188
|
-
faces choices @alice:maestro-1 --state-id fs_STATE_ID --question "What should the shop do?"
|
|
189
|
-
faces state:items fs_STATE_ID
|
|
197
|
+
faces state:create --use
|
|
198
|
+
faces premise:add "the dinner is planned" "A dinner party for six" --role goal --said "Plan a dinner party for six."
|
|
199
|
+
faces premise:add "the guests" "Six, one vegan" --and "the dinner is planned"
|
|
200
|
+
faces premise:refine "the dinner is planned" --face alice
|
|
201
|
+
faces state:get
|
|
190
202
|
```
|
|
191
203
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
204
|
+
`premise:add` writes a box: `--role goal` or `--role test` (none is a fact), under a parent with
|
|
205
|
+
`--and` (all such children must hold) or `--or` (one candidate is enough), reading inputs with
|
|
206
|
+
`--on a,b`. `premise:edit` changes one: a new value, a status, a test's run (`--status verified
|
|
207
|
+
--tested "<candidate>" --evidence "..."`), or what it waits on (`--await human`). `premise:get`
|
|
208
|
+
shows one box, its branch and its messages; `premise:delete` removes one. Writing and reading a
|
|
209
|
+
state are free.
|
|
210
|
+
|
|
211
|
+
`premise:refine "<key>" --face <alias>` asks the face to refine a premise: it decides whether
|
|
212
|
+
the premise needs conditions (AND), a pinned meaning (OR, its candidates ranked), one test, or
|
|
213
|
+
the human's answer, and writes one tier of children (`-r` goes on down, `--depth N|all`).
|
|
214
|
+
`premise:choices` asks the face for candidates, and `premise:decide` ranks them; a ranking never
|
|
215
|
+
rules a candidate out, only a failed test or the human does. These three are billed per call.
|
|
216
|
+
|
|
217
|
+
Several agents can work one state: `premise:claim "<key>" <name>` gives a branch to one of them,
|
|
218
|
+
and writes into it by anyone else are refused until it is released (`--release`) or expires.
|
|
219
|
+
Every write takes `--as <name>`.
|
|
220
|
+
|
|
221
|
+
The whole guide, with how to read the tree and the hooks that show it to your agent, is in the
|
|
222
|
+
Faces skill: [STATES.md](https://github.com/faces-sh/skill/blob/main/skills/faces/references/STATES.md).
|
|
223
|
+
|
|
224
|
+
The older premise-list commands (`state:add --premise`, `state:items`, `state:compact`,
|
|
225
|
+
`state:close`) still work. States were called conversations, and before that sessions: the
|
|
226
|
+
`conversation:*` and `session:*` commands still name the same thing.
|
|
209
227
|
|
|
210
228
|
## Authentication
|
|
211
229
|
|
package/dist/chat-command.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ export declare abstract class ChatCommand extends BaseCommand {
|
|
|
10
10
|
'premise-description': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
11
|
'premise-status': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
12
|
'premise-depends-on': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
'premise-role': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
'premise-origin': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
15
|
'causes-visible': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
14
16
|
message: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
17
|
file: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
package/dist/chat.d.ts
CHANGED
|
@@ -25,6 +25,8 @@ export declare function chatFlags(): {
|
|
|
25
25
|
'premise-description': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
26
26
|
'premise-status': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
27
27
|
'premise-depends-on': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
28
|
+
'premise-role': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
29
|
+
'premise-origin': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
28
30
|
'causes-visible': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
29
31
|
message: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
30
32
|
file: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
package/dist/choices.d.ts
CHANGED
|
@@ -6,9 +6,18 @@ export interface ChoicesResponse {
|
|
|
6
6
|
object?: string;
|
|
7
7
|
model?: string;
|
|
8
8
|
choices?: Array<{
|
|
9
|
+
id?: string;
|
|
9
10
|
name?: string;
|
|
10
11
|
description?: string;
|
|
12
|
+
premise?: string;
|
|
11
13
|
}>;
|
|
14
|
+
choices_item?: string;
|
|
15
|
+
into?: {
|
|
16
|
+
premise?: string;
|
|
17
|
+
kind?: string;
|
|
18
|
+
side_node?: string;
|
|
19
|
+
};
|
|
20
|
+
warnings?: string[];
|
|
12
21
|
question?: string;
|
|
13
22
|
alternatives?: string[];
|
|
14
23
|
usage?: {
|
package/dist/choices.js
CHANGED
|
@@ -23,11 +23,24 @@ export function choicesLines(data) {
|
|
|
23
23
|
if (choices.length === 0)
|
|
24
24
|
lines.push('No options.');
|
|
25
25
|
choices.forEach((c, i) => {
|
|
26
|
-
lines.push(`${i + 1}. ${c.name ?? '-'}`);
|
|
26
|
+
lines.push(`${i + 1}. ${c.name ?? '-'}${c.id ? ` [${c.id}]` : ''}`);
|
|
27
27
|
if (c.description)
|
|
28
28
|
lines.push(` ${c.description}`);
|
|
29
|
+
if (c.premise && c.premise !== c.name)
|
|
30
|
+
lines.push(` premise: ${c.premise}`);
|
|
29
31
|
});
|
|
32
|
+
if (data.into?.premise) {
|
|
33
|
+
lines.push('', `Written into the state as premises that ${data.into.premise} rests on (${data.into.kind ?? 'or'} edges, ` +
|
|
34
|
+
`side node ${data.into.side_node ?? '-'}). Weigh them: faces decide <model> --conversation <id> --weigh ` +
|
|
35
|
+
`${JSON.stringify(data.into.premise)}`);
|
|
36
|
+
}
|
|
37
|
+
else if (data.choices_item) {
|
|
38
|
+
lines.push('', `Added to the state as ${data.choices_item}. Name an option id (or ${data.choices_item} for all of them) ` +
|
|
39
|
+
'in --premise-depends-on or decide --depends-on.');
|
|
40
|
+
}
|
|
30
41
|
}
|
|
42
|
+
for (const w of data.warnings ?? [])
|
|
43
|
+
lines.push('', `Warning: ${w}`);
|
|
31
44
|
const u = data.usage;
|
|
32
45
|
if (u && (typeof u.input_tokens === 'number' || typeof u.output_tokens === 'number')) {
|
|
33
46
|
lines.push('', `${data.model ?? 'model'}: ${(u.input_tokens ?? 0).toLocaleString('en-US')} input, ${(u.output_tokens ?? 0).toLocaleString('en-US')} output tokens`);
|
|
@@ -43,6 +56,9 @@ export function choicesHint(status, message, model) {
|
|
|
43
56
|
return `Give it a first source: faces compile:upload ${face} --file <file>.`;
|
|
44
57
|
if (status === 409 && /compiled before/i.test(message))
|
|
45
58
|
return `Recompile one of its sources (list them with: faces face:sources ${face}).`;
|
|
59
|
+
if (status === 422 && /depends_on` names no premise or decision/.test(message)) {
|
|
60
|
+
return 'Name premise keys, decision ids and choices ids already in the state (faces state:items <id>).';
|
|
61
|
+
}
|
|
46
62
|
if (status === 404 && /state/i.test(message))
|
|
47
63
|
return 'A state expires 30 days after it was last used. Start another with: faces state:create';
|
|
48
64
|
return undefined;
|
package/dist/client.d.ts
CHANGED
|
@@ -60,6 +60,14 @@ export declare class FacesClient {
|
|
|
60
60
|
requireJwt?: boolean;
|
|
61
61
|
body?: unknown;
|
|
62
62
|
}): Promise<unknown>;
|
|
63
|
+
stateReply(method: 'GET' | 'POST' | 'PATCH' | 'DELETE', path: string, opts?: {
|
|
64
|
+
body?: unknown;
|
|
65
|
+
params?: Record<string, string>;
|
|
66
|
+
}): Promise<{
|
|
67
|
+
status: number;
|
|
68
|
+
ok: boolean;
|
|
69
|
+
data: Record<string, unknown>;
|
|
70
|
+
}>;
|
|
63
71
|
postWithHeaders(path: string, opts?: {
|
|
64
72
|
requireJwt?: boolean;
|
|
65
73
|
body?: unknown;
|
package/dist/client.js
CHANGED
|
@@ -363,6 +363,43 @@ export class FacesClient {
|
|
|
363
363
|
throw await this.parseError(resp);
|
|
364
364
|
return resp.json();
|
|
365
365
|
}
|
|
366
|
+
async stateReply(method, path, opts = {}) {
|
|
367
|
+
let url = this.url(path);
|
|
368
|
+
if (opts.params && Object.keys(opts.params).length > 0)
|
|
369
|
+
url += '?' + new URLSearchParams(opts.params).toString();
|
|
370
|
+
const headers = { ...this.authHeader() };
|
|
371
|
+
const withBody = method === 'POST' || method === 'PATCH';
|
|
372
|
+
if (withBody)
|
|
373
|
+
headers['Content-Type'] = 'application/json';
|
|
374
|
+
const session = process.env.FACES_SESSION?.trim();
|
|
375
|
+
if (session)
|
|
376
|
+
headers['X-Faces-Session'] = session;
|
|
377
|
+
const resp = await this.send(path, url, {
|
|
378
|
+
method,
|
|
379
|
+
headers,
|
|
380
|
+
body: withBody ? JSON.stringify(opts.body ?? {}) : undefined,
|
|
381
|
+
});
|
|
382
|
+
if (resp.ok) {
|
|
383
|
+
const body = (await resp.json());
|
|
384
|
+
const held = resp.headers.get('x-faces-held') === '1' && body?.object !== 'state.reply' ? heldChatError(body) : undefined;
|
|
385
|
+
if (held) {
|
|
386
|
+
this.lastError = held;
|
|
387
|
+
return { status: held.statusCode, ok: false, data: { ...body, error: held.message, text: held.message, held: true } };
|
|
388
|
+
}
|
|
389
|
+
return { status: resp.status, ok: true, data: body };
|
|
390
|
+
}
|
|
391
|
+
let data;
|
|
392
|
+
try {
|
|
393
|
+
data = (await resp.clone().json());
|
|
394
|
+
}
|
|
395
|
+
catch {
|
|
396
|
+
data = undefined;
|
|
397
|
+
}
|
|
398
|
+
if (data && data.object === 'state.reply' && typeof data.text === 'string') {
|
|
399
|
+
return { status: resp.status, ok: false, data };
|
|
400
|
+
}
|
|
401
|
+
throw await this.parseError(resp);
|
|
402
|
+
}
|
|
366
403
|
async postWithHeaders(path, opts = {}) {
|
|
367
404
|
const resp = await this.send(path, this.url(path), {
|
|
368
405
|
method: 'POST',
|
|
@@ -15,6 +15,8 @@ export default class ChatChat extends ChatCommand {
|
|
|
15
15
|
'premise-description': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
16
|
'premise-status': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
17
|
'premise-depends-on': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
+
'premise-role': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
|
+
'premise-origin': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
20
|
'causes-visible': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
19
21
|
message: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
20
22
|
file: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -14,6 +14,8 @@ export default class ChatMessages extends ChatCommand {
|
|
|
14
14
|
'premise-description': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
15
|
'premise-status': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
16
|
'premise-depends-on': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
'premise-role': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
+
'premise-origin': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
19
|
'causes-visible': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
18
20
|
message: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
21
|
file: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -14,6 +14,8 @@ export default class ChatResponses extends ChatCommand {
|
|
|
14
14
|
'premise-description': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
15
|
'premise-status': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
16
|
'premise-depends-on': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
'premise-role': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
+
'premise-origin': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
19
|
'causes-visible': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
18
20
|
message: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
21
|
file: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -15,6 +15,8 @@ export default class ChatThread extends BaseCommand {
|
|
|
15
15
|
'premise-description': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
16
|
'premise-status': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
17
|
'premise-depends-on': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
+
'premise-role': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
|
+
'premise-origin': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
20
|
'causes-visible': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
19
21
|
id: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
20
22
|
message: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -7,6 +7,9 @@ export default class Choices extends BaseCommand {
|
|
|
7
7
|
state: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
8
|
'state-file': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
9
|
'state-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
'depends-on': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
into: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
kind: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
13
|
'max-choices': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
14
|
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
15
|
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
package/dist/commands/choices.js
CHANGED
|
@@ -5,6 +5,7 @@ import { CHOICES_PATH, MAX_CHOICES, choicesHint, choicesLines } from '../choices
|
|
|
5
5
|
import { modelProblem } from '../model.js';
|
|
6
6
|
import { heldDecisionError, readStateFlags } from '../decisions.js';
|
|
7
7
|
import { retryOnceOnWarmUp, sayWarmUp } from '../utils.js';
|
|
8
|
+
import { MAX_DEPENDS_ON, parseDependsOn } from '../conversation.js';
|
|
8
9
|
export default class Choices extends BaseCommand {
|
|
9
10
|
static description = 'Ask a face what it would do (POST /v1/choices). Name the upstream model, a face and its maestro: ' +
|
|
10
11
|
'@alice:maestro-1, @dana~alice:maestro-1 for a face shared with you, or a composite such as ' +
|
|
@@ -17,6 +18,8 @@ export default class Choices extends BaseCommand {
|
|
|
17
18
|
'<%= 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
19
|
'<%= config.bin %> <%= command.id %> @head~socrates:maestro-1 --state "A chain bakery opened across the street."',
|
|
19
20
|
'<%= config.bin %> <%= command.id %> @alice:maestro-1 --state-id fs_STATE_ID --question "What should the shop do?" --max-choices 3',
|
|
21
|
+
'<%= config.bin %> <%= command.id %> @alice:maestro-1 --state-id fs_STATE_ID --question "How do we get there?" --depends-on goal,budget',
|
|
22
|
+
'<%= config.bin %> <%= command.id %> @alice:maestro-1 --state-id fs_STATE_ID --question "What does \'handle bad input\' mean here?" --into "handle bad input" --kind or',
|
|
20
23
|
'<%= config.bin %> <%= command.id %> "(@alice | @bob):maestro-1-flash" --state-file situation.txt -q "What next?" --json',
|
|
21
24
|
];
|
|
22
25
|
static flags = {
|
|
@@ -28,6 +31,24 @@ export default class Choices extends BaseCommand {
|
|
|
28
31
|
description: 'A state (from faces state:create) as the situation. With --state, the prose is an addendum for this call only: ' +
|
|
29
32
|
'read with the state, never saved to it. Write anything that should persist with faces state:add --premise.',
|
|
30
33
|
}),
|
|
34
|
+
'depends-on': Flags.string({
|
|
35
|
+
description: 'With --state-id, what these options rest on, comma separated: premise keys, decision ids, option ids (opt_...) ' +
|
|
36
|
+
`and choices ids (cho_...) in the state, at most ${MAX_DEPENDS_ON}. The face is shown each of them, and the ` +
|
|
37
|
+
'premises each directly depends on, in full. The options written into the state record it.',
|
|
38
|
+
dependsOn: ['state-id'],
|
|
39
|
+
}),
|
|
40
|
+
into: Flags.string({
|
|
41
|
+
description: 'With --state-id and --question: the premise these options are for. Each option is written into the state ' +
|
|
42
|
+
'as a premise of its own (assumed, proposed by the face), and the premise rests on each through an edge of ' +
|
|
43
|
+
'--kind. Weigh them next with faces decide --weigh <premise>.',
|
|
44
|
+
dependsOn: ['state-id', 'question'],
|
|
45
|
+
}),
|
|
46
|
+
kind: Flags.string({
|
|
47
|
+
description: 'With --into: or (the default) when the options are alternatives, readings of an ambiguity or ways to do ' +
|
|
48
|
+
'it, one of which holds; and when they are facets that must all hold.',
|
|
49
|
+
options: ['or', 'and'],
|
|
50
|
+
dependsOn: ['into'],
|
|
51
|
+
}),
|
|
31
52
|
'max-choices': Flags.integer({ description: `The most options to return, 1 to ${MAX_CHOICES}. Default 8.`, min: 1, max: MAX_CHOICES }),
|
|
32
53
|
};
|
|
33
54
|
static args = {
|
|
@@ -63,8 +84,23 @@ export default class Choices extends BaseCommand {
|
|
|
63
84
|
this.error('--question is empty. Leave it out to have the face propose the question.');
|
|
64
85
|
body.instructions = flags.question;
|
|
65
86
|
}
|
|
87
|
+
if (flags['depends-on'] !== undefined) {
|
|
88
|
+
try {
|
|
89
|
+
body.depends_on = parseDependsOn(flags['depends-on']);
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
this.error(err instanceof Error ? err.message : String(err));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
66
95
|
if (flags['max-choices'] !== undefined)
|
|
67
96
|
body.max_choices = flags['max-choices'];
|
|
97
|
+
if (flags.into !== undefined) {
|
|
98
|
+
if (flags.into.trim() === '')
|
|
99
|
+
this.error('--into is empty: name a premise key of the state.');
|
|
100
|
+
body.into = flags.into.trim();
|
|
101
|
+
if (flags.kind)
|
|
102
|
+
body.kind = flags.kind;
|
|
103
|
+
}
|
|
68
104
|
let data;
|
|
69
105
|
try {
|
|
70
106
|
data = (await retryOnceOnWarmUp(async () => {
|
|
@@ -8,6 +8,8 @@ export default class ConversationAdd extends BaseCommand {
|
|
|
8
8
|
'premise-description': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
9
|
'premise-status': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
10
|
'premise-depends-on': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
'premise-role': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
'premise-origin': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
13
|
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
14
|
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
15
|
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -1,7 +1,7 @@
|
|
|
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_DEPENDS_ON_FLAG_DESCRIPTION, PREMISE_FLAG_DESCRIPTION, PREMISE_STATUS_FLAG_DESCRIPTION, clientItems, conversationHint, itemLines, parsePremises, premiseLines, staleDecisionLines, statusChangeLines, } from '../../conversation.js';
|
|
4
|
+
import { CONVERSATIONS_PATH, MAX_CONVERSATION_ITEMS, PREMISE_DESCRIPTION_FLAG_DESCRIPTION, PREMISE_DEPENDS_ON_FLAG_DESCRIPTION, PREMISE_ORIGIN_FLAG_DESCRIPTION, PREMISE_ROLE_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
7
|
static description = 'Add your own premises and messages to a state, without a face answering. Premises go in first, then ' +
|
|
@@ -14,6 +14,7 @@ export default class ConversationAdd extends BaseCommand {
|
|
|
14
14
|
'<%= config.bin %> <%= command.id %> fs_STATE_ID --premise rent_rises="no rise" --premise-status rent_rises=invalidated',
|
|
15
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
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 --premise ship_by=friday --premise-description ship_by="when we want it shipped" --premise-role ship_by=wanted --premise-origin ship_by=human',
|
|
17
18
|
'<%= config.bin %> <%= command.id %> fs_STATE_ID -m "The vendor sent their audit report."',
|
|
18
19
|
];
|
|
19
20
|
static flags = {
|
|
@@ -23,6 +24,8 @@ export default class ConversationAdd extends BaseCommand {
|
|
|
23
24
|
'premise-description': Flags.string({ description: PREMISE_DESCRIPTION_FLAG_DESCRIPTION, multiple: true }),
|
|
24
25
|
'premise-status': Flags.string({ description: PREMISE_STATUS_FLAG_DESCRIPTION, multiple: true }),
|
|
25
26
|
'premise-depends-on': Flags.string({ description: PREMISE_DEPENDS_ON_FLAG_DESCRIPTION, multiple: true }),
|
|
27
|
+
'premise-role': Flags.string({ description: PREMISE_ROLE_FLAG_DESCRIPTION, multiple: true }),
|
|
28
|
+
'premise-origin': Flags.string({ description: PREMISE_ORIGIN_FLAG_DESCRIPTION, multiple: true }),
|
|
26
29
|
};
|
|
27
30
|
static args = {
|
|
28
31
|
conversation_id: Args.string({ description: 'State id (from state:create)', required: true }),
|
|
@@ -32,7 +35,7 @@ export default class ConversationAdd extends BaseCommand {
|
|
|
32
35
|
const client = this.makeClient(flags);
|
|
33
36
|
let items;
|
|
34
37
|
try {
|
|
35
|
-
items = clientItems(flags.message, parsePremises(flags.premise, flags['premise-description'], flags['premise-status'], flags['premise-depends-on']));
|
|
38
|
+
items = clientItems(flags.message, parsePremises(flags.premise, flags['premise-description'], flags['premise-status'], flags['premise-depends-on'], flags['premise-role'], flags['premise-origin']));
|
|
36
39
|
}
|
|
37
40
|
catch (err) {
|
|
38
41
|
this.error(err instanceof Error ? err.message : String(err));
|
|
@@ -9,6 +9,8 @@ export default class ConversationCreate extends BaseCommand {
|
|
|
9
9
|
'premise-description': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
10
|
'premise-status': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
11
|
'premise-depends-on': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
'premise-role': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
'premise-origin': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
14
|
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
15
|
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
16
|
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -1,7 +1,7 @@
|
|
|
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_DEPENDS_ON_FLAG_DESCRIPTION, PREMISE_FLAG_DESCRIPTION, PREMISE_STATUS_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_ORIGIN_FLAG_DESCRIPTION, PREMISE_ROLE_FLAG_DESCRIPTION, PREMISE_FLAG_DESCRIPTION, PREMISE_STATUS_FLAG_DESCRIPTION, clientItems, conversationHint, conversationLines, parsePremises, } from '../../conversation.js';
|
|
5
5
|
import { asFace as faceAlone } from '../../model.js';
|
|
6
6
|
export default class ConversationCreate extends BaseCommand {
|
|
7
7
|
static description = 'Start a state (formerly a conversation). The server keeps the situation your agent builds: premises ' +
|
|
@@ -28,6 +28,8 @@ export default class ConversationCreate extends BaseCommand {
|
|
|
28
28
|
'premise-description': Flags.string({ description: PREMISE_DESCRIPTION_FLAG_DESCRIPTION, multiple: true }),
|
|
29
29
|
'premise-status': Flags.string({ description: PREMISE_STATUS_FLAG_DESCRIPTION, multiple: true }),
|
|
30
30
|
'premise-depends-on': Flags.string({ description: PREMISE_DEPENDS_ON_FLAG_DESCRIPTION, multiple: true }),
|
|
31
|
+
'premise-role': Flags.string({ description: PREMISE_ROLE_FLAG_DESCRIPTION, multiple: true }),
|
|
32
|
+
'premise-origin': Flags.string({ description: PREMISE_ORIGIN_FLAG_DESCRIPTION, multiple: true }),
|
|
31
33
|
};
|
|
32
34
|
static args = {
|
|
33
35
|
face: Args.string({
|
|
@@ -44,7 +46,7 @@ export default class ConversationCreate extends BaseCommand {
|
|
|
44
46
|
this.error(`A state is with a face alone, with no maestro or model: ${face.split(/[:/]/)[0]}`);
|
|
45
47
|
let items;
|
|
46
48
|
try {
|
|
47
|
-
items = clientItems(flags.message, parsePremises(flags.premise, flags['premise-description'], flags['premise-status'], flags['premise-depends-on']));
|
|
49
|
+
items = clientItems(flags.message, parsePremises(flags.premise, flags['premise-description'], flags['premise-status'], flags['premise-depends-on'], flags['premise-role'], flags['premise-origin']));
|
|
48
50
|
}
|
|
49
51
|
catch (err) {
|
|
50
52
|
this.error(err instanceof Error ? err.message : String(err));
|
|
@@ -1,9 +1,37 @@
|
|
|
1
1
|
import { BaseCommand } from '../base.js';
|
|
2
|
+
export interface WeighResponse {
|
|
3
|
+
answers?: Array<{
|
|
4
|
+
probabilities?: Array<{
|
|
5
|
+
value?: string;
|
|
6
|
+
probability?: number;
|
|
7
|
+
}>;
|
|
8
|
+
choice?: string;
|
|
9
|
+
}>;
|
|
10
|
+
decision_ids?: Record<string, string>;
|
|
11
|
+
weigh?: {
|
|
12
|
+
premise?: string;
|
|
13
|
+
kind?: string;
|
|
14
|
+
cutoff?: number;
|
|
15
|
+
edges?: Array<{
|
|
16
|
+
id?: string;
|
|
17
|
+
p?: number;
|
|
18
|
+
}>;
|
|
19
|
+
pruned?: string[];
|
|
20
|
+
side_node?: string;
|
|
21
|
+
written?: boolean;
|
|
22
|
+
decision?: string;
|
|
23
|
+
reason?: string;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export declare function weighLines(data: WeighResponse): string[];
|
|
2
27
|
export default class Decide extends BaseCommand {
|
|
3
28
|
static description: string;
|
|
4
29
|
static examples: string[];
|
|
5
30
|
static flags: {
|
|
6
31
|
'depends-on': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
32
|
+
weigh: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
33
|
+
'weigh-kind': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
34
|
+
cutoff: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
35
|
session: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
36
|
compaction: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
37
|
format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -13,6 +41,8 @@ export default class Decide extends BaseCommand {
|
|
|
13
41
|
'premise-description': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
42
|
'premise-status': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
43
|
'premise-depends-on': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
44
|
+
'premise-role': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
45
|
+
'premise-origin': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
46
|
'causes-visible': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
17
47
|
state: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
48
|
'state-file': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -32,6 +62,7 @@ export default class Decide extends BaseCommand {
|
|
|
32
62
|
};
|
|
33
63
|
run(): Promise<unknown>;
|
|
34
64
|
private ask;
|
|
65
|
+
private weigh;
|
|
35
66
|
private readState;
|
|
36
67
|
private readQuestions;
|
|
37
68
|
private models?;
|