@faces-sh/cli 1.0.3 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +107 -53
- package/dist/billing.js +11 -8
- package/dist/{commands/causes.d.ts → chat-command.d.ts} +13 -13
- package/dist/chat-command.js +110 -0
- package/dist/chat.d.ts +47 -0
- package/dist/chat.js +157 -0
- package/dist/choices.d.ts +20 -0
- package/dist/choices.js +49 -0
- package/dist/commands/auth/connect.js +2 -2
- package/dist/commands/billing/llm-costs.js +9 -5
- package/dist/commands/billing/subscription/index.js +1 -1
- package/dist/commands/catalog/doctor.js +9 -68
- package/dist/commands/chat/chat.d.ts +10 -26
- package/dist/commands/chat/chat.js +21 -366
- package/dist/commands/chat/messages.d.ts +13 -13
- package/dist/commands/chat/messages.js +15 -142
- package/dist/commands/chat/responses.d.ts +13 -14
- package/dist/commands/chat/responses.js +16 -153
- package/dist/commands/chat/thread.d.ts +3 -15
- package/dist/commands/chat/thread.js +128 -362
- package/dist/commands/choices.d.ts +20 -0
- package/dist/commands/choices.js +91 -0
- package/dist/commands/conversation/add.d.ts +2 -0
- package/dist/commands/conversation/add.js +21 -10
- package/dist/commands/conversation/close.js +5 -5
- package/dist/commands/conversation/compact.js +15 -18
- package/dist/commands/conversation/create.d.ts +2 -0
- package/dist/commands/conversation/create.js +20 -17
- package/dist/commands/conversation/get.js +4 -4
- package/dist/commands/conversation/items.js +5 -5
- package/dist/commands/decide.d.ts +4 -4
- package/dist/commands/decide.js +70 -81
- package/dist/commands/face/get.js +2 -2
- 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 +16 -5
- package/dist/commands/session/close.js +1 -1
- package/dist/commands/session/compact.js +6 -9
- package/dist/commands/session/create.js +10 -9
- package/dist/commands/session/get.js +1 -1
- package/dist/commands/state/add.d.ts +3 -0
- package/dist/commands/state/add.js +3 -0
- package/dist/commands/state/close.d.ts +3 -0
- package/dist/commands/state/close.js +3 -0
- package/dist/commands/state/compact.d.ts +3 -0
- package/dist/commands/state/compact.js +3 -0
- package/dist/commands/state/create.d.ts +3 -0
- package/dist/commands/state/create.js +3 -0
- package/dist/commands/state/get.d.ts +3 -0
- package/dist/commands/state/get.js +3 -0
- package/dist/commands/state/items.d.ts +3 -0
- package/dist/commands/state/items.js +3 -0
- package/dist/commands/style/make.js +2 -6
- package/dist/commands/style/upload.js +1 -1
- package/dist/conversation.d.ts +27 -2
- package/dist/conversation.js +91 -16
- package/dist/decisions.d.ts +0 -5
- package/dist/decisions.js +0 -18
- 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/routing.d.ts +1 -4
- package/dist/routing.js +4 -40
- package/dist/utils.d.ts +1 -25
- package/dist/utils.js +10 -108
- package/oclif.manifest.json +2054 -1649
- package/package.json +10 -7
- package/dist/commands/causes.js +0 -146
|
@@ -1,31 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class ChatResponses extends
|
|
1
|
+
import { ChatCommand } from '../../chat-command.js';
|
|
2
|
+
export default class ChatResponses extends ChatCommand {
|
|
3
3
|
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
model: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
7
|
+
};
|
|
4
8
|
static flags: {
|
|
5
9
|
session: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
10
|
compaction: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
11
|
'oauth-only': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
|
-
'show-cause': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
|
-
cause: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
-
'cause-file': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
12
|
conversation: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
13
|
premise: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
14
|
'premise-description': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
'premise-status': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
'premise-depends-on': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
17
|
'causes-visible': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
15
|
-
message: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
-
|
|
18
|
+
message: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
|
+
file: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
20
|
+
system: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
21
|
+
stream: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
17
22
|
'max-tokens': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
23
|
temperature: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
|
-
stream: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
20
|
-
style: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
21
|
-
medium: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
22
24
|
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
23
25
|
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
24
26
|
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
25
27
|
toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
26
28
|
};
|
|
27
|
-
|
|
28
|
-
face_model: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
29
|
-
};
|
|
30
|
-
run(): Promise<unknown>;
|
|
29
|
+
protected forcedEndpoint(): string;
|
|
31
30
|
}
|
|
@@ -1,159 +1,22 @@
|
|
|
1
|
-
import { Args
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
2
2
|
import { BaseCommand } from '../../base.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import { RESPONSES_ENDPOINT, chatFlags, MODEL_ARG_DESCRIPTION } from '../../chat.js';
|
|
4
|
+
import { ChatCommand } from '../../chat-command.js';
|
|
5
|
+
export default class ChatResponses extends ChatCommand {
|
|
6
|
+
static description = 'Chat with a face in the OpenAI Responses format (/v1/responses). The same as chat:chat --responses. On ' +
|
|
7
|
+
'Connect and Pro with ChatGPT linked, Codex-eligible models (faces models:list --chatgpt) run on the ChatGPT plan.';
|
|
8
|
+
static examples = [
|
|
9
|
+
'<%= config.bin %> <%= command.id %> @socrates:maestro-1/gpt-5.4 -m "What is virtue?"',
|
|
10
|
+
'<%= config.bin %> <%= command.id %> @socrates:maestro-1/gpt-5.4 -m "What is virtue?" --oauth-only',
|
|
11
|
+
];
|
|
12
|
+
static args = {
|
|
13
|
+
model: Args.string({ description: MODEL_ARG_DESCRIPTION, required: true }),
|
|
14
|
+
};
|
|
8
15
|
static flags = {
|
|
9
16
|
...BaseCommand.baseFlags,
|
|
10
|
-
|
|
11
|
-
instructions: Flags.string({ description: 'System instructions' }),
|
|
12
|
-
'max-tokens': Flags.integer({ description: `Max output tokens (at least ${MIN_MAX_OUTPUT_TOKENS})` }),
|
|
13
|
-
temperature: Flags.string({ description: 'Temperature (0.0-2.0)' }),
|
|
14
|
-
stream: Flags.boolean({ description: STREAM_FLAG_DESCRIPTION, default: true, allowNo: true }),
|
|
15
|
-
style: Flags.string({ description: STYLE_FLAG_DESCRIPTION }),
|
|
16
|
-
medium: Flags.string({ description: MEDIUM_FLAG_DESCRIPTION }),
|
|
17
|
-
...conversationTurnFlags(),
|
|
18
|
-
session: Flags.string({ description: SESSION_FLAG_DESCRIPTION }),
|
|
19
|
-
compaction: Flags.string({ description: COMPACTION_FLAG_DESCRIPTION }),
|
|
20
|
-
'oauth-only': Flags.boolean({ description: 'On a linked ChatGPT plan, run there or fail: never fall back to credits', default: false }),
|
|
21
|
-
'show-cause': Flags.boolean({ description: REASONING_FLAG_DESCRIPTION, default: false }),
|
|
22
|
-
cause: Flags.string({ description: CAUSE_FLAG_DESCRIPTION }),
|
|
23
|
-
'cause-file': Flags.string({ description: CAUSE_FILE_FLAG_DESCRIPTION, exclusive: ['cause'] }),
|
|
24
|
-
};
|
|
25
|
-
static args = {
|
|
26
|
-
face_model: Args.string({
|
|
27
|
-
description: 'Face model, sent as typed (e.g. myface@gpt-4o, head:socrates@gpt-5.4). A face named without a model ' +
|
|
28
|
-
'returns only its cause, with no answer: name the model for one, or use chat:chat, which adds the ' +
|
|
29
|
-
'face\'s default model.',
|
|
30
|
-
required: true,
|
|
31
|
-
}),
|
|
17
|
+
...chatFlags(),
|
|
32
18
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const client = this.makeClient(flags);
|
|
36
|
-
let turn;
|
|
37
|
-
try {
|
|
38
|
-
turn = conversationFields(flags);
|
|
39
|
-
}
|
|
40
|
-
catch (err) {
|
|
41
|
-
this.error(err instanceof Error ? err.message : String(err));
|
|
42
|
-
}
|
|
43
|
-
let cause;
|
|
44
|
-
try {
|
|
45
|
-
cause = resolveCause(flags.cause, flags['cause-file']);
|
|
46
|
-
}
|
|
47
|
-
catch (err) {
|
|
48
|
-
this.error(err instanceof Error ? err.message : String(err));
|
|
49
|
-
}
|
|
50
|
-
const model = args.face_model;
|
|
51
|
-
if (cause && !model.includes('@'))
|
|
52
|
-
this.error(causeNeedsModel(model));
|
|
53
|
-
const stream = flags.stream && !this.jsonEnabled();
|
|
54
|
-
const payload = {
|
|
55
|
-
model,
|
|
56
|
-
input: flags.message,
|
|
57
|
-
stream,
|
|
58
|
-
};
|
|
59
|
-
if (flags.instructions)
|
|
60
|
-
payload.instructions = flags.instructions;
|
|
61
|
-
if (flags['max-tokens'] !== undefined) {
|
|
62
|
-
if (flags['max-tokens'] < MIN_MAX_OUTPUT_TOKENS) {
|
|
63
|
-
this.error(`--max-tokens must be at least ${MIN_MAX_OUTPUT_TOKENS} (got ${flags['max-tokens']}). The Responses API rejects a smaller output cap.`);
|
|
64
|
-
}
|
|
65
|
-
payload.max_output_tokens = flags['max-tokens'];
|
|
66
|
-
}
|
|
67
|
-
if (flags.temperature !== undefined)
|
|
68
|
-
payload.temperature = parseTemperature(flags.temperature, (m) => this.error(m));
|
|
69
|
-
Object.assign(payload, chatExtras(flags), turn);
|
|
70
|
-
if (flags['oauth-only'])
|
|
71
|
-
payload.oauth_only = true;
|
|
72
|
-
if (cause)
|
|
73
|
-
payload.cause = cause;
|
|
74
|
-
try {
|
|
75
|
-
if (stream) {
|
|
76
|
-
let reasoning = '';
|
|
77
|
-
let replied = false;
|
|
78
|
-
for await (const line of client.stream('/v1/responses', payload, { onHeaders: (h) => warnDroppedParams(h, CHAT_PARAM_FLAGS) })) {
|
|
79
|
-
if (!line.startsWith('data: '))
|
|
80
|
-
continue;
|
|
81
|
-
const chunk = line.slice(6);
|
|
82
|
-
if (chunk.trim() === '[DONE]' || chunk.trim() === '')
|
|
83
|
-
continue;
|
|
84
|
-
try {
|
|
85
|
-
const obj = JSON.parse(chunk);
|
|
86
|
-
const thought = extractStreamReasoning(obj);
|
|
87
|
-
if (thought) {
|
|
88
|
-
if (flags['show-cause'] && !reasoning)
|
|
89
|
-
process.stderr.write(`${reasoningHeading(model)}\n`);
|
|
90
|
-
if (flags['show-cause'])
|
|
91
|
-
process.stderr.write(thought);
|
|
92
|
-
reasoning += thought;
|
|
93
|
-
}
|
|
94
|
-
if (obj.type === 'response.output_text.delta') {
|
|
95
|
-
const delta = obj.delta ?? '';
|
|
96
|
-
if (delta) {
|
|
97
|
-
if (flags['show-cause'] && reasoning && !replied)
|
|
98
|
-
process.stderr.write('\n\n');
|
|
99
|
-
replied = true;
|
|
100
|
-
process.stdout.write(String(delta));
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
catch {
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
if (!replied && reasoning) {
|
|
108
|
-
if (flags['show-cause'])
|
|
109
|
-
process.stderr.write('\n');
|
|
110
|
-
else
|
|
111
|
-
process.stdout.write(`${reasoning}\n`);
|
|
112
|
-
process.stderr.write(`\n${reasoningOnlyNote(model, false)}\n`);
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
process.stdout.write('\n');
|
|
116
|
-
}
|
|
117
|
-
return {};
|
|
118
|
-
}
|
|
119
|
-
const { data, headers } = await retryOnceOnWarmUp(() => postChat(client, '/v1/responses', payload), sayWarmUp);
|
|
120
|
-
const body = data;
|
|
121
|
-
if (!this.jsonEnabled())
|
|
122
|
-
warnDroppedParams(headers, CHAT_PARAM_FLAGS);
|
|
123
|
-
if (this.jsonEnabled()) {
|
|
124
|
-
const meta = {};
|
|
125
|
-
if (headers['x-faces-provider'])
|
|
126
|
-
meta.provider = headers['x-faces-provider'];
|
|
127
|
-
if (headers['x-faces-cost-usd'])
|
|
128
|
-
meta.cost_usd = headers['x-faces-cost-usd'];
|
|
129
|
-
if (headers['x-faces-billing'])
|
|
130
|
-
meta.billing = headers['x-faces-billing'];
|
|
131
|
-
if (Object.keys(meta).length > 0)
|
|
132
|
-
body._meta = meta;
|
|
133
|
-
return body;
|
|
134
|
-
}
|
|
135
|
-
let outputText = '';
|
|
136
|
-
for (const item of body.output ?? []) {
|
|
137
|
-
for (const block of item.content ?? []) {
|
|
138
|
-
if (block.type === 'output_text')
|
|
139
|
-
outputText += String(block.text ?? '');
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
writeReply(model, extractReasoning(body, '/v1/responses'), outputText, flags['show-cause'], reasoningOnlyNote(model, false));
|
|
143
|
-
return body;
|
|
144
|
-
}
|
|
145
|
-
catch (err) {
|
|
146
|
-
if (err instanceof FacesAPIError) {
|
|
147
|
-
if (err.errorCode === 'oauth_rejected') {
|
|
148
|
-
const hint = err.fallbackAvailable
|
|
149
|
-
? 'Run `faces account:preferences api_fallback true` to allow paid fallback.'
|
|
150
|
-
: 'Run `faces billing:topup` to add credits, then enable fallback with `faces account:preferences api_fallback true`.';
|
|
151
|
-
this.error(`OAuth failed: ${err.message}\n${hint}`);
|
|
152
|
-
}
|
|
153
|
-
const hint = faceRefusalHint(err, model, flags.style);
|
|
154
|
-
this.error(`HTTP ${err.statusCode}: ${err.message}${hint ? `\n${hint}` : ''}`);
|
|
155
|
-
}
|
|
156
|
-
throw err;
|
|
157
|
-
}
|
|
19
|
+
forcedEndpoint() {
|
|
20
|
+
return RESPONSES_ENDPOINT;
|
|
158
21
|
}
|
|
159
22
|
}
|
|
@@ -6,9 +6,6 @@ export default class ChatThread extends BaseCommand {
|
|
|
6
6
|
session: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
7
|
compaction: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
8
|
'oauth-only': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
|
-
'show-cause': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
-
cause: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
-
'cause-file': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
9
|
list: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
10
|
show: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
14
11
|
delete: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
@@ -16,35 +13,26 @@ export default class ChatThread extends BaseCommand {
|
|
|
16
13
|
conversation: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
14
|
premise: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
15
|
'premise-description': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
'premise-status': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
'premise-depends-on': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
18
|
'causes-visible': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
20
19
|
id: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
21
20
|
message: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
22
21
|
file: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
23
|
-
llm: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
24
22
|
system: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
25
23
|
'max-tokens': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
26
24
|
temperature: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
27
25
|
stream: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
28
|
-
style: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
29
|
-
medium: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
30
26
|
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
31
27
|
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
32
28
|
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
33
29
|
toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
34
30
|
};
|
|
35
31
|
static args: {
|
|
36
|
-
|
|
32
|
+
model: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
37
33
|
};
|
|
38
34
|
run(): Promise<unknown>;
|
|
39
35
|
private handleList;
|
|
40
36
|
private handleDelete;
|
|
41
37
|
private handleShow;
|
|
42
|
-
private handleMessage;
|
|
43
|
-
private conversationBody;
|
|
44
|
-
private newOnly;
|
|
45
|
-
private sent;
|
|
46
|
-
private sendChatCompletions;
|
|
47
|
-
private sendResponses;
|
|
48
|
-
private sendAnthropic;
|
|
49
|
-
private streamAndAccumulate;
|
|
50
38
|
}
|