@faces-sh/cli 0.0.0-stage → 1.0.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/LICENSE +21 -0
- package/README.md +158 -2
- package/bin/dev.js +5 -0
- package/bin/run.js +5 -0
- package/dist/base.d.ts +26 -0
- package/dist/base.js +181 -0
- package/dist/benchmark.d.ts +21 -0
- package/dist/benchmark.js +95 -0
- package/dist/billing.d.ts +17 -0
- package/dist/billing.js +101 -0
- package/dist/catalog.d.ts +35 -0
- package/dist/catalog.js +242 -0
- package/dist/client.d.ts +98 -0
- package/dist/client.js +590 -0
- package/dist/commands/account/preferences.d.ts +20 -0
- package/dist/commands/account/preferences.js +190 -0
- package/dist/commands/account/state.d.ts +11 -0
- package/dist/commands/account/state.js +24 -0
- package/dist/commands/auth/connect.d.ts +17 -0
- package/dist/commands/auth/connect.js +190 -0
- package/dist/commands/auth/connections.d.ts +12 -0
- package/dist/commands/auth/connections.js +40 -0
- package/dist/commands/auth/disconnect.d.ts +15 -0
- package/dist/commands/auth/disconnect.js +49 -0
- package/dist/commands/auth/login.d.ts +13 -0
- package/dist/commands/auth/login.js +42 -0
- package/dist/commands/auth/logout.d.ts +11 -0
- package/dist/commands/auth/logout.js +14 -0
- package/dist/commands/auth/refresh.d.ts +11 -0
- package/dist/commands/auth/refresh.js +30 -0
- package/dist/commands/auth/register.d.ts +15 -0
- package/dist/commands/auth/register.js +98 -0
- package/dist/commands/auth/whoami.d.ts +11 -0
- package/dist/commands/auth/whoami.js +108 -0
- package/dist/commands/benchmark/get.d.ts +16 -0
- package/dist/commands/benchmark/get.js +42 -0
- package/dist/commands/benchmark/list.d.ts +13 -0
- package/dist/commands/benchmark/list.js +47 -0
- package/dist/commands/benchmark/start.d.ts +22 -0
- package/dist/commands/benchmark/start.js +80 -0
- package/dist/commands/billing/balance.d.ts +11 -0
- package/dist/commands/billing/balance.js +27 -0
- package/dist/commands/billing/card/default.d.ts +15 -0
- package/dist/commands/billing/card/default.js +33 -0
- package/dist/commands/billing/card/remove.d.ts +16 -0
- package/dist/commands/billing/card/remove.js +41 -0
- package/dist/commands/billing/card-setup.d.ts +13 -0
- package/dist/commands/billing/card-setup.js +41 -0
- package/dist/commands/billing/cards.d.ts +11 -0
- package/dist/commands/billing/cards.js +34 -0
- package/dist/commands/billing/llm-costs.d.ts +14 -0
- package/dist/commands/billing/llm-costs.js +95 -0
- package/dist/commands/billing/subscription/activate.d.ts +14 -0
- package/dist/commands/billing/subscription/activate.js +91 -0
- package/dist/commands/billing/subscription/cancel.d.ts +12 -0
- package/dist/commands/billing/subscription/cancel.js +54 -0
- package/dist/commands/billing/subscription/index.d.ts +11 -0
- package/dist/commands/billing/subscription/index.js +46 -0
- package/dist/commands/billing/subscription/plan.d.ts +16 -0
- package/dist/commands/billing/subscription/plan.js +86 -0
- package/dist/commands/billing/topup.d.ts +16 -0
- package/dist/commands/billing/topup.js +60 -0
- package/dist/commands/billing/usage.d.ts +15 -0
- package/dist/commands/billing/usage.js +68 -0
- package/dist/commands/catalog/backup.d.ts +11 -0
- package/dist/commands/catalog/backup.js +169 -0
- package/dist/commands/catalog/doctor.d.ts +14 -0
- package/dist/commands/catalog/doctor.js +303 -0
- package/dist/commands/catalog/list.d.ts +11 -0
- package/dist/commands/catalog/list.js +39 -0
- package/dist/commands/catalog/restore.d.ts +17 -0
- package/dist/commands/catalog/restore.js +259 -0
- package/dist/commands/causes.d.ts +27 -0
- package/dist/commands/causes.js +135 -0
- package/dist/commands/chat/chat.d.ts +42 -0
- package/dist/commands/chat/chat.js +363 -0
- package/dist/commands/chat/messages.d.ts +26 -0
- package/dist/commands/chat/messages.js +139 -0
- package/dist/commands/chat/responses.d.ts +27 -0
- package/dist/commands/chat/responses.js +150 -0
- package/dist/commands/chat/thread.d.ts +43 -0
- package/dist/commands/chat/thread.js +458 -0
- package/dist/commands/compile/all.d.ts +14 -0
- package/dist/commands/compile/all.js +186 -0
- package/dist/commands/compile/doc/create.d.ts +19 -0
- package/dist/commands/compile/doc/create.js +58 -0
- package/dist/commands/compile/doc/delete.d.ts +15 -0
- package/dist/commands/compile/doc/delete.js +33 -0
- package/dist/commands/compile/doc/edit.d.ts +19 -0
- package/dist/commands/compile/doc/edit.js +59 -0
- package/dist/commands/compile/doc/get.d.ts +15 -0
- package/dist/commands/compile/doc/get.js +43 -0
- package/dist/commands/compile/doc/index.d.ts +24 -0
- package/dist/commands/compile/doc/index.js +211 -0
- package/dist/commands/compile/doc/list.d.ts +15 -0
- package/dist/commands/compile/doc/list.js +46 -0
- package/dist/commands/compile/doc/make.d.ts +17 -0
- package/dist/commands/compile/doc/make.js +95 -0
- package/dist/commands/compile/doc/pause.d.ts +17 -0
- package/dist/commands/compile/doc/pause.js +74 -0
- package/dist/commands/compile/doc/reset.d.ts +15 -0
- package/dist/commands/compile/doc/reset.js +33 -0
- package/dist/commands/compile/import.d.ts +20 -0
- package/dist/commands/compile/import.js +138 -0
- package/dist/commands/compile/stats.d.ts +11 -0
- package/dist/commands/compile/stats.js +75 -0
- package/dist/commands/compile/status.d.ts +17 -0
- package/dist/commands/compile/status.js +110 -0
- package/dist/commands/compile/thread/create.d.ts +16 -0
- package/dist/commands/compile/thread/create.js +42 -0
- package/dist/commands/compile/thread/delete.d.ts +15 -0
- package/dist/commands/compile/thread/delete.js +33 -0
- package/dist/commands/compile/thread/edit.d.ts +19 -0
- package/dist/commands/compile/thread/edit.js +120 -0
- package/dist/commands/compile/thread/get.d.ts +15 -0
- package/dist/commands/compile/thread/get.js +48 -0
- package/dist/commands/compile/thread/list.d.ts +14 -0
- package/dist/commands/compile/thread/list.js +38 -0
- package/dist/commands/compile/thread/make.d.ts +17 -0
- package/dist/commands/compile/thread/make.js +87 -0
- package/dist/commands/compile/thread/message.d.ts +16 -0
- package/dist/commands/compile/thread/message.js +43 -0
- package/dist/commands/compile/thread/pause.d.ts +17 -0
- package/dist/commands/compile/thread/pause.js +75 -0
- package/dist/commands/compile/thread/replace.d.ts +27 -0
- package/dist/commands/compile/thread/replace.js +114 -0
- package/dist/commands/compile/thread/reset.d.ts +15 -0
- package/dist/commands/compile/thread/reset.js +33 -0
- package/dist/commands/compile/upload.d.ts +21 -0
- package/dist/commands/compile/upload.js +162 -0
- package/dist/commands/config/clear.d.ts +12 -0
- package/dist/commands/config/clear.js +17 -0
- package/dist/commands/config/set.d.ts +15 -0
- package/dist/commands/config/set.js +43 -0
- package/dist/commands/config/show.d.ts +11 -0
- package/dist/commands/config/show.js +19 -0
- package/dist/commands/decide.d.ts +35 -0
- package/dist/commands/decide.js +242 -0
- package/dist/commands/face/attributes.d.ts +11 -0
- package/dist/commands/face/attributes.js +44 -0
- package/dist/commands/face/avatar/delete.d.ts +15 -0
- package/dist/commands/face/avatar/delete.js +38 -0
- package/dist/commands/face/avatar/get.d.ts +20 -0
- package/dist/commands/face/avatar/get.js +100 -0
- package/dist/commands/face/avatar/list.d.ts +14 -0
- package/dist/commands/face/avatar/list.js +56 -0
- package/dist/commands/face/avatar/make.d.ts +16 -0
- package/dist/commands/face/avatar/make.js +64 -0
- package/dist/commands/face/avatar/upload.d.ts +15 -0
- package/dist/commands/face/avatar/upload.js +67 -0
- package/dist/commands/face/create.d.ts +23 -0
- package/dist/commands/face/create.js +122 -0
- package/dist/commands/face/delete.d.ts +15 -0
- package/dist/commands/face/delete.js +39 -0
- package/dist/commands/face/diff.d.ts +12 -0
- package/dist/commands/face/diff.js +50 -0
- package/dist/commands/face/edit.d.ts +25 -0
- package/dist/commands/face/edit.js +155 -0
- package/dist/commands/face/get.d.ts +16 -0
- package/dist/commands/face/get.js +145 -0
- package/dist/commands/face/groups.d.ts +15 -0
- package/dist/commands/face/groups.js +34 -0
- package/dist/commands/face/list.d.ts +23 -0
- package/dist/commands/face/list.js +168 -0
- package/dist/commands/face/lock.d.ts +15 -0
- package/dist/commands/face/lock.js +35 -0
- package/dist/commands/face/neighbors.d.ts +16 -0
- package/dist/commands/face/neighbors.js +63 -0
- package/dist/commands/face/publish.d.ts +16 -0
- package/dist/commands/face/publish.js +42 -0
- package/dist/commands/face/share.d.ts +22 -0
- package/dist/commands/face/share.js +103 -0
- package/dist/commands/face/sources.d.ts +21 -0
- package/dist/commands/face/sources.js +169 -0
- package/dist/commands/face/stats.d.ts +12 -0
- package/dist/commands/face/stats.js +46 -0
- package/dist/commands/face/tag/add.d.ts +15 -0
- package/dist/commands/face/tag/add.js +40 -0
- package/dist/commands/face/tag/all.d.ts +11 -0
- package/dist/commands/face/tag/all.js +31 -0
- package/dist/commands/face/tag/list.d.ts +14 -0
- package/dist/commands/face/tag/list.js +36 -0
- package/dist/commands/face/tag/remove.d.ts +16 -0
- package/dist/commands/face/tag/remove.js +44 -0
- package/dist/commands/face/tag/set.d.ts +15 -0
- package/dist/commands/face/tag/set.js +40 -0
- package/dist/commands/face/unlock.d.ts +15 -0
- package/dist/commands/face/unlock.js +35 -0
- package/dist/commands/face/unpublish.d.ts +14 -0
- package/dist/commands/face/unpublish.js +31 -0
- package/dist/commands/face/unshare.d.ts +18 -0
- package/dist/commands/face/unshare.js +66 -0
- package/dist/commands/fidelity/get.d.ts +15 -0
- package/dist/commands/fidelity/get.js +42 -0
- package/dist/commands/fidelity/pick.d.ts +19 -0
- package/dist/commands/fidelity/pick.js +70 -0
- package/dist/commands/fidelity/run.d.ts +20 -0
- package/dist/commands/fidelity/run.js +99 -0
- package/dist/commands/fidelity/save-thread.d.ts +15 -0
- package/dist/commands/fidelity/save-thread.js +35 -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.d.ts +16 -0
- package/dist/commands/group/add.js +83 -0
- package/dist/commands/group/create.d.ts +16 -0
- package/dist/commands/group/create.js +68 -0
- package/dist/commands/group/delete.d.ts +15 -0
- package/dist/commands/group/delete.js +39 -0
- package/dist/commands/group/edit.d.ts +18 -0
- package/dist/commands/group/edit.js +75 -0
- package/dist/commands/group/get.d.ts +14 -0
- package/dist/commands/group/get.js +29 -0
- package/dist/commands/group/list.d.ts +11 -0
- package/dist/commands/group/list.js +39 -0
- package/dist/commands/group/members.d.ts +15 -0
- package/dist/commands/group/members.js +68 -0
- package/dist/commands/group/remove.d.ts +15 -0
- package/dist/commands/group/remove.js +55 -0
- package/dist/commands/group/tag/add.d.ts +15 -0
- package/dist/commands/group/tag/add.js +30 -0
- package/dist/commands/group/tag/list.d.ts +14 -0
- package/dist/commands/group/tag/list.js +36 -0
- package/dist/commands/group/tag/remove.d.ts +15 -0
- package/dist/commands/group/tag/remove.js +30 -0
- package/dist/commands/group/tag/set.d.ts +15 -0
- package/dist/commands/group/tag/set.js +30 -0
- package/dist/commands/keys/create.d.ts +17 -0
- package/dist/commands/keys/create.js +72 -0
- package/dist/commands/keys/list.d.ts +11 -0
- package/dist/commands/keys/list.js +24 -0
- package/dist/commands/keys/revoke.d.ts +15 -0
- package/dist/commands/keys/revoke.js +49 -0
- package/dist/commands/keys/update.d.ts +17 -0
- package/dist/commands/keys/update.js +41 -0
- package/dist/commands/models/list.d.ts +15 -0
- package/dist/commands/models/list.js +98 -0
- package/dist/commands/session/close.d.ts +16 -0
- package/dist/commands/session/close.js +36 -0
- package/dist/commands/session/compact.d.ts +15 -0
- package/dist/commands/session/compact.js +58 -0
- package/dist/commands/session/create.d.ts +15 -0
- package/dist/commands/session/create.js +45 -0
- package/dist/commands/session/get.d.ts +15 -0
- package/dist/commands/session/get.js +34 -0
- package/dist/commands/style/delete.d.ts +19 -0
- package/dist/commands/style/delete.js +92 -0
- package/dist/commands/style/make.d.ts +28 -0
- package/dist/commands/style/make.js +298 -0
- package/dist/commands/style/revert.d.ts +17 -0
- package/dist/commands/style/revert.js +66 -0
- package/dist/commands/style/status.d.ts +20 -0
- package/dist/commands/style/status.js +109 -0
- package/dist/commands/style/upload.d.ts +19 -0
- package/dist/commands/style/upload.js +100 -0
- package/dist/commands/style/versions.d.ts +15 -0
- package/dist/commands/style/versions.js +104 -0
- package/dist/commands/user/follow.d.ts +14 -0
- package/dist/commands/user/follow.js +38 -0
- package/dist/commands/user/followers.d.ts +14 -0
- package/dist/commands/user/followers.js +50 -0
- package/dist/commands/user/following.d.ts +14 -0
- package/dist/commands/user/following.js +50 -0
- package/dist/commands/user/get.d.ts +14 -0
- package/dist/commands/user/get.js +49 -0
- package/dist/commands/user/unfollow.d.ts +14 -0
- package/dist/commands/user/unfollow.js +38 -0
- package/dist/config.d.ts +32 -0
- package/dist/config.js +139 -0
- package/dist/decisions.d.ts +42 -0
- package/dist/decisions.js +262 -0
- package/dist/fidelity.d.ts +50 -0
- package/dist/fidelity.js +92 -0
- package/dist/group-catalog.d.ts +22 -0
- package/dist/group-catalog.js +133 -0
- package/dist/paths.d.ts +1 -0
- package/dist/paths.js +8 -0
- package/dist/poll.d.ts +26 -0
- package/dist/poll.js +75 -0
- package/dist/routing.d.ts +15 -0
- package/dist/routing.js +135 -0
- package/dist/session.d.ts +14 -0
- package/dist/session.js +18 -0
- package/dist/style.d.ts +46 -0
- package/dist/style.js +285 -0
- package/dist/utils.d.ts +149 -0
- package/dist/utils.js +865 -0
- package/oclif.manifest.json +11070 -0
- package/package.json +127 -4
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../../base.js';
|
|
3
|
+
import { FacesAPIError } from '../../../client.js';
|
|
4
|
+
import { seg } from '../../../utils.js';
|
|
5
|
+
export default class FaceAvatarDelete extends BaseCommand {
|
|
6
|
+
static description = "Remove the picture you uploaded for a face. The generated avatar versions are not touched, and the " +
|
|
7
|
+
'face goes back to being served one of those.';
|
|
8
|
+
static flags = {
|
|
9
|
+
...BaseCommand.baseFlags,
|
|
10
|
+
yes: Flags.boolean({ description: 'Skip the confirmation', default: false }),
|
|
11
|
+
};
|
|
12
|
+
static args = {
|
|
13
|
+
face_id: Args.string({ description: 'Face alias (must be one of yours)', required: true }),
|
|
14
|
+
};
|
|
15
|
+
async run() {
|
|
16
|
+
const { args, flags } = await this.parse(FaceAvatarDelete);
|
|
17
|
+
const client = this.makeClient(flags);
|
|
18
|
+
if (!flags.yes) {
|
|
19
|
+
this.error(`This removes the picture uploaded for '${args.face_id}'. The generated avatar versions stay, ` +
|
|
20
|
+
'and one of them will be served instead.\nRe-run with --yes to go ahead.');
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
await client.delete(`/v1/faces/${seg(args.face_id)}/avatar/upload`);
|
|
24
|
+
}
|
|
25
|
+
catch (err) {
|
|
26
|
+
if (err instanceof FacesAPIError) {
|
|
27
|
+
this.error(`HTTP ${err.statusCode}: ${err.message}`);
|
|
28
|
+
}
|
|
29
|
+
throw err;
|
|
30
|
+
}
|
|
31
|
+
const result = { alias: args.face_id, deleted: true };
|
|
32
|
+
if (!this.jsonEnabled()) {
|
|
33
|
+
this.log(`${args.face_id} has no uploaded picture now.`);
|
|
34
|
+
this.log(`It is served a generated avatar: faces face:avatar:get ${args.face_id}`);
|
|
35
|
+
}
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BaseCommand } from '../../../base.js';
|
|
2
|
+
export default class FaceAvatarGet extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
size: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
width: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
version: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
prefer: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
out: 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
|
+
face_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
18
|
+
};
|
|
19
|
+
run(): Promise<unknown>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { BaseCommand } from '../../../base.js';
|
|
5
|
+
import { FacesAPIError } from '../../../client.js';
|
|
6
|
+
import { seg } from '../../../utils.js';
|
|
7
|
+
export default class FaceAvatarGet extends BaseCommand {
|
|
8
|
+
static description = 'Download a face avatar as an image file. Reading one is free; only generating a new version bills.';
|
|
9
|
+
static flags = {
|
|
10
|
+
...BaseCommand.baseFlags,
|
|
11
|
+
size: Flags.string({
|
|
12
|
+
description: 'Dot grid across: sm (32), md (64) or lg (128). Coarser sizes are exact averages of the stored grid.',
|
|
13
|
+
options: ['sm', 'md', 'lg'],
|
|
14
|
+
}),
|
|
15
|
+
format: Flags.string({ description: 'Image format', options: ['png', 'svg'], default: 'png' }),
|
|
16
|
+
width: Flags.integer({ description: 'Render width in pixels (32-2048). Defaults to 9 per dot.', min: 32, max: 2048 }),
|
|
17
|
+
version: Flags.integer({ description: 'A specific version. Omit for the one being served.', min: 1 }),
|
|
18
|
+
prefer: Flags.string({
|
|
19
|
+
description: "uploaded serves the owner's own picture when there is one, falling back to the generated avatar. " +
|
|
20
|
+
'organic always serves the generated one.',
|
|
21
|
+
options: ['organic', 'uploaded'],
|
|
22
|
+
}),
|
|
23
|
+
out: Flags.string({ description: 'Where to write the file. Defaults to <alias>-avatar-v<version>.<ext> here.' }),
|
|
24
|
+
};
|
|
25
|
+
static args = {
|
|
26
|
+
face_id: Args.string({
|
|
27
|
+
description: 'Face alias, or owner:alias for a face published by or shared from another account',
|
|
28
|
+
required: true,
|
|
29
|
+
}),
|
|
30
|
+
};
|
|
31
|
+
async run() {
|
|
32
|
+
const { args, flags } = await this.parse(FaceAvatarGet);
|
|
33
|
+
const client = this.makeClient(flags);
|
|
34
|
+
const params = new URLSearchParams();
|
|
35
|
+
params.set('format', flags.format);
|
|
36
|
+
if (flags.size)
|
|
37
|
+
params.set('size', flags.size);
|
|
38
|
+
if (flags.width !== undefined)
|
|
39
|
+
params.set('width', String(flags.width));
|
|
40
|
+
if (flags.version !== undefined)
|
|
41
|
+
params.set('v', String(flags.version));
|
|
42
|
+
if (flags.prefer)
|
|
43
|
+
params.set('prefer', flags.prefer);
|
|
44
|
+
let result;
|
|
45
|
+
try {
|
|
46
|
+
result = await client.getBinary(`/v1/faces/${seg(args.face_id)}/avatar?${params.toString()}`);
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
if (err instanceof FacesAPIError) {
|
|
50
|
+
if (err.statusCode === 404) {
|
|
51
|
+
this.error(`No avatar for '${args.face_id}'. See what it has with: faces face:avatar:list ${args.face_id}`);
|
|
52
|
+
}
|
|
53
|
+
this.error(`HTTP ${err.statusCode}: ${err.message}`);
|
|
54
|
+
}
|
|
55
|
+
throw err;
|
|
56
|
+
}
|
|
57
|
+
const h = result.headers;
|
|
58
|
+
const served = h['x-avatar-version'];
|
|
59
|
+
const source = h['x-avatar-source'];
|
|
60
|
+
const stale = h['x-avatar-stale'];
|
|
61
|
+
const ext = flags.format === 'svg' ? 'svg' : 'png';
|
|
62
|
+
const safe = args.face_id.replace(/[^a-zA-Z0-9_-]/g, '-');
|
|
63
|
+
const which = source === 'uploaded' ? 'uploaded' : `v${served ?? 'current'}`;
|
|
64
|
+
const outPath = flags.out ?? path.join(process.cwd(), `${safe}-avatar-${which}.${ext}`);
|
|
65
|
+
try {
|
|
66
|
+
fs.mkdirSync(path.dirname(path.resolve(outPath)), { recursive: true });
|
|
67
|
+
fs.writeFileSync(outPath, result.bytes);
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
this.error(`Could not write ${outPath}: ${err instanceof Error ? err.message : String(err)}`);
|
|
71
|
+
}
|
|
72
|
+
const report = {
|
|
73
|
+
alias: args.face_id,
|
|
74
|
+
path: path.resolve(outPath),
|
|
75
|
+
bytes: result.bytes.length,
|
|
76
|
+
content_type: result.contentType,
|
|
77
|
+
version: served ? Number(served) : null,
|
|
78
|
+
source: source ?? null,
|
|
79
|
+
stale: stale === undefined ? null : stale === 'true',
|
|
80
|
+
cols: h['x-avatar-cols'] ? Number(h['x-avatar-cols']) : null,
|
|
81
|
+
width: h['x-avatar-width'] ? Number(h['x-avatar-width']) : null,
|
|
82
|
+
owner: h['x-avatar-owner'] ?? null,
|
|
83
|
+
etag: h.etag ?? null,
|
|
84
|
+
};
|
|
85
|
+
if (!this.jsonEnabled()) {
|
|
86
|
+
this.log(`Saved ${report.path}`);
|
|
87
|
+
this.log(` ${report.bytes.toLocaleString()} bytes, ${report.content_type}`);
|
|
88
|
+
this.log(source === 'uploaded'
|
|
89
|
+
? " the owner's uploaded picture, not a generated avatar"
|
|
90
|
+
: source === 'default'
|
|
91
|
+
? ' the default placeholder: no avatar has been generated or uploaded yet'
|
|
92
|
+
: ` generated avatar, version ${report.version ?? 'unknown'}`);
|
|
93
|
+
if (report.stale === true) {
|
|
94
|
+
this.log(' This image no longer matches the face as it is compiled now.');
|
|
95
|
+
this.log(` A current one has to be generated, which bills: faces face:avatar:make ${args.face_id} --allow-paid`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return report;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BaseCommand } from '../../../base.js';
|
|
2
|
+
export default class FaceAvatarList extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
|
+
};
|
|
10
|
+
static args: {
|
|
11
|
+
face_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
12
|
+
};
|
|
13
|
+
run(): Promise<unknown>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../../base.js';
|
|
3
|
+
import { FacesAPIError } from '../../../client.js';
|
|
4
|
+
import { seg, ownsFace } from '../../../utils.js';
|
|
5
|
+
export default class FaceAvatarList extends BaseCommand {
|
|
6
|
+
static description = 'List the avatar versions a face has. Marks which one is served and which no longer match the face ' +
|
|
7
|
+
'as it is compiled now.';
|
|
8
|
+
static flags = {
|
|
9
|
+
...BaseCommand.baseFlags,
|
|
10
|
+
};
|
|
11
|
+
static args = {
|
|
12
|
+
face_id: Args.string({
|
|
13
|
+
description: 'Face alias, or owner:alias for a face published by or shared from another account',
|
|
14
|
+
required: true,
|
|
15
|
+
}),
|
|
16
|
+
};
|
|
17
|
+
async run() {
|
|
18
|
+
const { args, flags } = await this.parse(FaceAvatarList);
|
|
19
|
+
const client = this.makeClient(flags);
|
|
20
|
+
let data;
|
|
21
|
+
try {
|
|
22
|
+
data = (await client.get(`/v1/faces/${seg(args.face_id)}/avatars`));
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
if (err instanceof FacesAPIError)
|
|
26
|
+
this.error(`HTTP ${err.statusCode}: ${err.message}`);
|
|
27
|
+
throw err;
|
|
28
|
+
}
|
|
29
|
+
if (!this.jsonEnabled()) {
|
|
30
|
+
const rows = data.versions ?? [];
|
|
31
|
+
const own = (await ownsFace(client, args.face_id)) !== false;
|
|
32
|
+
if (rows.length === 0) {
|
|
33
|
+
this.log(`${data.alias} has no generated avatar yet.`);
|
|
34
|
+
if (own)
|
|
35
|
+
this.log('Make one with: faces face:avatar:make ' + args.face_id + ' --allow-paid');
|
|
36
|
+
return data;
|
|
37
|
+
}
|
|
38
|
+
this.log('VERSION SERVED MATCHES FACE GRID BYTES CREATED');
|
|
39
|
+
for (const v of rows) {
|
|
40
|
+
const served = v.version === data.current_version ? 'yes' : '-';
|
|
41
|
+
const matches = v.stale === undefined ? '-' : v.stale ? 'no' : 'yes';
|
|
42
|
+
const grid = `${v.cols}x${v.rows}`;
|
|
43
|
+
const created = (v.created_at ?? '').slice(0, 10) || '-';
|
|
44
|
+
this.log(`${String(v.version).padEnd(7)} ${served.padEnd(6)} ${matches.padEnd(12)} ${grid.padEnd(8)} ` +
|
|
45
|
+
`${String(v.bytes).padStart(6)} ${created}`);
|
|
46
|
+
}
|
|
47
|
+
const stale = rows.filter((v) => v.stale).length;
|
|
48
|
+
if (stale > 0 && own) {
|
|
49
|
+
this.log('');
|
|
50
|
+
this.log(`${stale} version(s) no longer match the face as it is compiled now. Regenerating bills, so this is only ` +
|
|
51
|
+
'worth doing if the picture matters: faces face:avatar:make ' + args.face_id + ' --allow-paid');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return data;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseCommand } from '../../../base.js';
|
|
2
|
+
export default class FaceAvatarMake extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
'allow-paid': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
6
|
+
seed: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
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
|
+
face_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
14
|
+
};
|
|
15
|
+
run(): Promise<unknown>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../../base.js';
|
|
3
|
+
import { FacesAPIError } from '../../../client.js';
|
|
4
|
+
import { seg } from '../../../utils.js';
|
|
5
|
+
export default class FaceAvatarMake extends BaseCommand {
|
|
6
|
+
static description = 'Generate a new avatar version for a face. This bills, so it needs --allow-paid. Reading an existing ' +
|
|
7
|
+
'avatar with face:avatar:get is free.';
|
|
8
|
+
static flags = {
|
|
9
|
+
...BaseCommand.baseFlags,
|
|
10
|
+
'allow-paid': Flags.boolean({
|
|
11
|
+
description: 'Permit the charge. Generating an avatar always bills; without this flag nothing is sent and ' +
|
|
12
|
+
'nothing is charged.',
|
|
13
|
+
default: false,
|
|
14
|
+
}),
|
|
15
|
+
seed: Flags.integer({
|
|
16
|
+
description: 'Fix the seed to reproduce a particular avatar (0-999999999).',
|
|
17
|
+
min: 0,
|
|
18
|
+
max: 999_999_999,
|
|
19
|
+
}),
|
|
20
|
+
};
|
|
21
|
+
static args = {
|
|
22
|
+
face_id: Args.string({ description: 'Face alias (must be one of yours)', required: true }),
|
|
23
|
+
};
|
|
24
|
+
async run() {
|
|
25
|
+
const { args, flags } = await this.parse(FaceAvatarMake);
|
|
26
|
+
const client = this.makeClient(flags);
|
|
27
|
+
if (!flags['allow-paid']) {
|
|
28
|
+
this.error('Generating an avatar bills your account. Re-run with --allow-paid if you meant to pay.\n' +
|
|
29
|
+
`To see the versions this face already has, which is free: faces face:avatar:list ${args.face_id}\n` +
|
|
30
|
+
`To download one: faces face:avatar:get ${args.face_id}`);
|
|
31
|
+
}
|
|
32
|
+
const params = new URLSearchParams();
|
|
33
|
+
if (flags.seed !== undefined)
|
|
34
|
+
params.set('seed', String(flags.seed));
|
|
35
|
+
const query = params.toString() ? `?${params.toString()}` : '';
|
|
36
|
+
let data;
|
|
37
|
+
try {
|
|
38
|
+
data = (await client.post(`/v1/faces/${seg(args.face_id)}/avatar${query}`));
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
if (err instanceof FacesAPIError && err.statusCode === 422 && /compiled/i.test(err.message)) {
|
|
42
|
+
this.error(`HTTP 422: ${err.message}\nNothing was charged. Give it a first source, then try again: ` +
|
|
43
|
+
`faces compile:upload ${args.face_id} --file <file>`);
|
|
44
|
+
}
|
|
45
|
+
if (err instanceof FacesAPIError)
|
|
46
|
+
this.error(`HTTP ${err.statusCode}: ${err.message}`);
|
|
47
|
+
throw err;
|
|
48
|
+
}
|
|
49
|
+
if (!this.jsonEnabled()) {
|
|
50
|
+
const num = (v) => (typeof v === 'number' ? v.toLocaleString() : String(v ?? '?'));
|
|
51
|
+
this.log(`Generated version ${data.version ?? '?'} for ${data.alias ?? args.face_id}`);
|
|
52
|
+
this.log(` ${num(data.cols)}x${num(data.rows)} grid, ${num(data.bytes)} bytes`);
|
|
53
|
+
if (data.seed !== null && data.seed !== undefined) {
|
|
54
|
+
this.log(` seed ${data.seed} (pass --seed ${data.seed} to generate this one again)`);
|
|
55
|
+
}
|
|
56
|
+
this.log(typeof data.amount_charged_usd === 'number'
|
|
57
|
+
? ` charged $${data.amount_charged_usd.toFixed(4)}`
|
|
58
|
+
: ' charged: the response did not say how much; check faces billing:balance');
|
|
59
|
+
this.log('');
|
|
60
|
+
this.log(`Download it with: faces face:avatar:get ${args.face_id}`);
|
|
61
|
+
}
|
|
62
|
+
return data;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseCommand } from '../../../base.js';
|
|
2
|
+
export default class FaceAvatarUpload extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
file: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
};
|
|
11
|
+
static args: {
|
|
12
|
+
face_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
13
|
+
};
|
|
14
|
+
run(): Promise<unknown>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { BaseCommand } from '../../../base.js';
|
|
5
|
+
import { FacesAPIError } from '../../../client.js';
|
|
6
|
+
import { seg } from '../../../utils.js';
|
|
7
|
+
const IMAGE_TYPES = {
|
|
8
|
+
'.bmp': 'image/bmp',
|
|
9
|
+
'.gif': 'image/gif',
|
|
10
|
+
'.jpeg': 'image/jpeg',
|
|
11
|
+
'.jpg': 'image/jpeg',
|
|
12
|
+
'.png': 'image/png',
|
|
13
|
+
'.webp': 'image/webp',
|
|
14
|
+
};
|
|
15
|
+
export default class FaceAvatarUpload extends BaseCommand {
|
|
16
|
+
static description = 'Use your own picture for a face instead of a generated avatar. Free, and it replaces any picture ' +
|
|
17
|
+
'already uploaded.';
|
|
18
|
+
static flags = {
|
|
19
|
+
...BaseCommand.baseFlags,
|
|
20
|
+
file: Flags.string({
|
|
21
|
+
description: 'Image file to upload: png, jpeg, webp, gif or bmp',
|
|
22
|
+
required: true,
|
|
23
|
+
}),
|
|
24
|
+
};
|
|
25
|
+
static args = {
|
|
26
|
+
face_id: Args.string({ description: 'Face alias (must be one of yours)', required: true }),
|
|
27
|
+
};
|
|
28
|
+
async run() {
|
|
29
|
+
const { args, flags } = await this.parse(FaceAvatarUpload);
|
|
30
|
+
const client = this.makeClient(flags);
|
|
31
|
+
const filePath = path.resolve(flags.file);
|
|
32
|
+
if (!fs.existsSync(filePath))
|
|
33
|
+
this.error(`No such file: ${flags.file}`);
|
|
34
|
+
const stat = fs.statSync(filePath);
|
|
35
|
+
if (stat.isDirectory())
|
|
36
|
+
this.error(`${flags.file} is a directory, not an image.`);
|
|
37
|
+
if (stat.size === 0)
|
|
38
|
+
this.error(`${flags.file} is empty.`);
|
|
39
|
+
const type = IMAGE_TYPES[path.extname(filePath).toLowerCase()];
|
|
40
|
+
if (!type) {
|
|
41
|
+
this.error(`${path.basename(filePath)} is not an image this accepts.\n` +
|
|
42
|
+
`Accepted: ${[...new Set(Object.values(IMAGE_TYPES))].sort().join(', ')}`);
|
|
43
|
+
}
|
|
44
|
+
const form = new FormData();
|
|
45
|
+
form.append('file', new Blob([fs.readFileSync(filePath)], { type }), path.basename(filePath));
|
|
46
|
+
let data;
|
|
47
|
+
try {
|
|
48
|
+
data = (await client.putForm(`/v1/faces/${seg(args.face_id)}/avatar/upload`, form));
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
if (err instanceof FacesAPIError)
|
|
52
|
+
this.error(`HTTP ${err.statusCode}: ${err.message}`);
|
|
53
|
+
throw err;
|
|
54
|
+
}
|
|
55
|
+
if (!this.jsonEnabled()) {
|
|
56
|
+
this.log(`${data.replaced ? 'Replaced the uploaded picture for' : 'Uploaded a picture for'} ${data.alias}`);
|
|
57
|
+
this.log(` rendered to a ${data.cols}x${data.rows} grid`);
|
|
58
|
+
if (data.source_width && data.source_height) {
|
|
59
|
+
this.log(` from ${data.source_width}x${data.source_height}`);
|
|
60
|
+
}
|
|
61
|
+
this.log('');
|
|
62
|
+
this.log(`Serve it with: faces face:avatar:get ${args.face_id} --prefer uploaded`);
|
|
63
|
+
this.log(`Remove it with: faces face:avatar:delete ${args.face_id}`);
|
|
64
|
+
}
|
|
65
|
+
return data;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base.js';
|
|
2
|
+
export default class FaceCreate extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
name: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
alias: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
description: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
specialty: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
tag: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
'default-model': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
formula: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
attr: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
tool: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
'profile-addendum': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
'profile-addendum-file': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
|
+
toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
20
|
+
};
|
|
21
|
+
static args: {};
|
|
22
|
+
run(): Promise<unknown>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base.js';
|
|
3
|
+
import { FacesAPIError } from '../../client.js';
|
|
4
|
+
import { CatalogService } from '../../catalog.js';
|
|
5
|
+
import { renameFaceFields, resolveProfileAddendum, seg, badFaceName, badToolNames, compact } from '../../utils.js';
|
|
6
|
+
export default class FaceCreate extends BaseCommand {
|
|
7
|
+
static description = 'Create a new face';
|
|
8
|
+
static flags = {
|
|
9
|
+
...BaseCommand.baseFlags,
|
|
10
|
+
name: Flags.string({ description: 'Display name', required: true }),
|
|
11
|
+
alias: Flags.string({ description: 'Unique alias slug', required: true }),
|
|
12
|
+
description: Flags.string({ description: 'Plain-text description / bio (max 1500 chars)' }),
|
|
13
|
+
specialty: Flags.string({
|
|
14
|
+
description: 'A short line saying what this face is for, shown beside its name in listings and on its card ' +
|
|
15
|
+
'(for example "tax law", or "my own voice")',
|
|
16
|
+
}),
|
|
17
|
+
tag: Flags.string({ description: 'Tag label (repeatable, lowercase)', multiple: true }),
|
|
18
|
+
'default-model': Flags.string({ description: 'Default LLM for chat (e.g. gpt-4o-mini, claude-sonnet-4-6)' }),
|
|
19
|
+
formula: Flags.string({ description: 'Boolean formula over owned concrete face aliases (e.g. "a | b", "(a | b) - c"). Creates a composite face.' }),
|
|
20
|
+
attr: Flags.string({
|
|
21
|
+
description: 'Set attribute KEY=VALUE (repeatable). age, gender and location take a bare value ("45", "Lisbon, ' +
|
|
22
|
+
'Portugal"); identity, education, occupation, religion, family, relationships, health, languages and ' +
|
|
23
|
+
'background take a short sentence. Any other key is refused, and then nothing is saved. See faces face:attributes.',
|
|
24
|
+
multiple: true,
|
|
25
|
+
}),
|
|
26
|
+
tool: Flags.string({ description: 'Tool name to enable (repeatable). The server stores any name without checking it, so spell it as the tool expects.', multiple: true }),
|
|
27
|
+
'profile-addendum': Flags.string({ description: 'A saved system prompt fragment, sent to the model on each chat request with this face (max 100,000 chars). Anyone who can chat with the face may be able to get the model to repeat it.' }),
|
|
28
|
+
'profile-addendum-file': Flags.string({ description: 'Read the per-face system prompt from a file (alternative to --profile-addendum). Anyone who can chat with the face may be able to get the model to repeat it.', exclusive: ['profile-addendum'] }),
|
|
29
|
+
};
|
|
30
|
+
static args = {};
|
|
31
|
+
async run() {
|
|
32
|
+
const { flags } = await this.parse(FaceCreate);
|
|
33
|
+
const client = this.makeClient(flags);
|
|
34
|
+
if (flags.formula && (flags.attr?.length || flags.tool?.length)) {
|
|
35
|
+
this.error('--formula cannot be combined with --attr or --tool. A composite face has nothing compiled of its own.');
|
|
36
|
+
}
|
|
37
|
+
const nameProblem = badFaceName(flags.name);
|
|
38
|
+
if (nameProblem)
|
|
39
|
+
this.error(`--name: ${nameProblem}`);
|
|
40
|
+
const payload = { name: flags.name, alias: flags.alias };
|
|
41
|
+
if (flags.description)
|
|
42
|
+
payload.description = flags.description;
|
|
43
|
+
if (flags.specialty !== undefined)
|
|
44
|
+
payload.specialty = flags.specialty;
|
|
45
|
+
let addendum;
|
|
46
|
+
try {
|
|
47
|
+
addendum = resolveProfileAddendum(flags['profile-addendum'], flags['profile-addendum-file']);
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
this.error(err instanceof Error ? err.message : String(err));
|
|
51
|
+
}
|
|
52
|
+
if (addendum !== undefined)
|
|
53
|
+
payload.profile_addendum = addendum;
|
|
54
|
+
if (flags.formula) {
|
|
55
|
+
payload.formula = flags.formula;
|
|
56
|
+
if (flags['default-model'])
|
|
57
|
+
payload.default_model = flags['default-model'];
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
const parsedAttrs = {};
|
|
61
|
+
for (const a of flags.attr ?? []) {
|
|
62
|
+
if (!a.includes('=') || !a.slice(0, a.indexOf('=')).trim())
|
|
63
|
+
this.error(`Attributes must be KEY=VALUE, got: ${a}. See the keys with: faces face:attributes`);
|
|
64
|
+
const idx = a.indexOf('=');
|
|
65
|
+
parsedAttrs[a.slice(0, idx).trim()] = a.slice(idx + 1).trim();
|
|
66
|
+
}
|
|
67
|
+
if (Object.keys(parsedAttrs).length > 0)
|
|
68
|
+
payload.basic_facts = parsedAttrs;
|
|
69
|
+
if (flags.tool && flags.tool.length > 0) {
|
|
70
|
+
const toolProblem = badToolNames(flags.tool);
|
|
71
|
+
if (toolProblem)
|
|
72
|
+
this.error(`--tool: ${toolProblem}`);
|
|
73
|
+
payload.default_tools = flags.tool.map((t) => t.trim());
|
|
74
|
+
}
|
|
75
|
+
if (flags['default-model'])
|
|
76
|
+
payload.default_model = flags['default-model'];
|
|
77
|
+
}
|
|
78
|
+
let data;
|
|
79
|
+
try {
|
|
80
|
+
data = await client.post('/v1/faces', { body: payload });
|
|
81
|
+
}
|
|
82
|
+
catch (err) {
|
|
83
|
+
if (err instanceof FacesAPIError)
|
|
84
|
+
this.error(`HTTP ${err.statusCode}: ${err.message}`);
|
|
85
|
+
throw err;
|
|
86
|
+
}
|
|
87
|
+
const face = data;
|
|
88
|
+
if (Array.isArray(face.warnings) && face.warnings.length > 0) {
|
|
89
|
+
for (const w of face.warnings)
|
|
90
|
+
this.warn(w);
|
|
91
|
+
}
|
|
92
|
+
const tags = flags.tag ?? [];
|
|
93
|
+
if (tags.length > 0) {
|
|
94
|
+
try {
|
|
95
|
+
await client.post(`/v1/iam/${seg(flags.alias)}/tags`, { body: { tags } });
|
|
96
|
+
face.tags = tags;
|
|
97
|
+
}
|
|
98
|
+
catch (err) {
|
|
99
|
+
if (err instanceof FacesAPIError) {
|
|
100
|
+
this.warn(`Tags failed (${err.statusCode}): ${err.message}`);
|
|
101
|
+
process.exitCode = 1;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
renameFaceFields(face);
|
|
106
|
+
try {
|
|
107
|
+
const catalog = new CatalogService();
|
|
108
|
+
catalog.writeFace({
|
|
109
|
+
...face,
|
|
110
|
+
basic_facts: face.attributes,
|
|
111
|
+
tags: face.tags ?? undefined,
|
|
112
|
+
description: face.description ?? flags.description ?? undefined,
|
|
113
|
+
default_model: face.default_model,
|
|
114
|
+
formula: face.formula,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
catch { }
|
|
118
|
+
if (!this.jsonEnabled())
|
|
119
|
+
this.printHuman(compact(data));
|
|
120
|
+
return data;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base.js';
|
|
2
|
+
export default class FaceDelete extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
6
|
+
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
};
|
|
11
|
+
static args: {
|
|
12
|
+
face_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
13
|
+
};
|
|
14
|
+
run(): Promise<unknown>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base.js';
|
|
3
|
+
import { FacesAPIError } from '../../client.js';
|
|
4
|
+
import { CatalogService } from '../../catalog.js';
|
|
5
|
+
import { seg, isMeAlias, ME_MISSING } from '../../utils.js';
|
|
6
|
+
export default class FaceDelete extends BaseCommand {
|
|
7
|
+
static description = 'Delete a face permanently';
|
|
8
|
+
static flags = {
|
|
9
|
+
...BaseCommand.baseFlags,
|
|
10
|
+
yes: Flags.boolean({ description: 'Skip confirmation', default: false }),
|
|
11
|
+
};
|
|
12
|
+
static args = {
|
|
13
|
+
face_id: Args.string({ description: 'Face alias', required: true }),
|
|
14
|
+
};
|
|
15
|
+
async run() {
|
|
16
|
+
const { args, flags } = await this.parse(FaceDelete);
|
|
17
|
+
const client = this.makeClient(flags);
|
|
18
|
+
await this.confirmOrRefuse(`Delete face '${args.face_id}'? This cannot be undone.`, flags.yes);
|
|
19
|
+
let data;
|
|
20
|
+
try {
|
|
21
|
+
data = await client.delete(`/v1/faces/${seg(args.face_id)}`);
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
if (err instanceof FacesAPIError && err.statusCode === 404 && isMeAlias(args.face_id))
|
|
25
|
+
this.error(`HTTP 404: ${err.message}\n${ME_MISSING}`);
|
|
26
|
+
if (err instanceof FacesAPIError)
|
|
27
|
+
this.error(`HTTP ${err.statusCode}: ${err.message}`);
|
|
28
|
+
throw err;
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const catalog = new CatalogService();
|
|
32
|
+
catalog.deleteFace(args.face_id);
|
|
33
|
+
}
|
|
34
|
+
catch { }
|
|
35
|
+
if (!this.jsonEnabled())
|
|
36
|
+
this.printHuman(data);
|
|
37
|
+
return data;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base.js';
|
|
2
|
+
export default class FaceDiff extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
face: import("@oclif/core/interfaces").OptionFlag<string[], import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
};
|
|
11
|
+
run(): Promise<unknown>;
|
|
12
|
+
}
|