@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,50 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base.js';
|
|
3
|
+
import { FacesAPIError } from '../../client.js';
|
|
4
|
+
import { similarityText } from '../../utils.js';
|
|
5
|
+
export default class FaceDiff extends BaseCommand {
|
|
6
|
+
static description = 'Compare owned faces pairwise: one overall similarity score for each pair. Every face named needs something compiled.';
|
|
7
|
+
static flags = {
|
|
8
|
+
...BaseCommand.baseFlags,
|
|
9
|
+
face: Flags.string({
|
|
10
|
+
description: 'Face alias to include (repeatable, min 2)',
|
|
11
|
+
multiple: true,
|
|
12
|
+
required: true,
|
|
13
|
+
}),
|
|
14
|
+
};
|
|
15
|
+
async run() {
|
|
16
|
+
const { flags } = await this.parse(FaceDiff);
|
|
17
|
+
const client = this.makeClient(flags);
|
|
18
|
+
if (flags.face.length < 2) {
|
|
19
|
+
this.error('At least 2 --face values are required');
|
|
20
|
+
}
|
|
21
|
+
const params = { faces: flags.face.join(',') };
|
|
22
|
+
let data;
|
|
23
|
+
try {
|
|
24
|
+
data = await client.get('/v1/faces/diff', { params });
|
|
25
|
+
}
|
|
26
|
+
catch (err) {
|
|
27
|
+
if (err instanceof FacesAPIError)
|
|
28
|
+
this.error(`HTTP ${err.statusCode}: ${err.message}`);
|
|
29
|
+
throw err;
|
|
30
|
+
}
|
|
31
|
+
if (!this.jsonEnabled()) {
|
|
32
|
+
const res = data;
|
|
33
|
+
const faces = res.faces;
|
|
34
|
+
const fmt = (v) => similarityText(v);
|
|
35
|
+
for (let i = 0; i < faces.length; i++) {
|
|
36
|
+
for (let j = i + 1; j < faces.length; j++) {
|
|
37
|
+
const a = faces[i];
|
|
38
|
+
const b = faces[j];
|
|
39
|
+
this.log(`${a} ↔ ${b} ${fmt(res.similarity[a][b]?.face)}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
this.log('');
|
|
43
|
+
const updated = Object.entries(res.centroids_updated_at)
|
|
44
|
+
.map(([face, ts]) => `${face} ${new Date(ts * 1000).toISOString().slice(0, 10)}`)
|
|
45
|
+
.join(', ');
|
|
46
|
+
this.log(`Updated: ${updated}`);
|
|
47
|
+
}
|
|
48
|
+
return data;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base.js';
|
|
2
|
+
export default class FaceEdit extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
description: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
specialty: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
tag: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
'default-model': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
formula: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
attr: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
tool: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
'profile-addendum': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
'profile-addendum-file': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
'clear-profile-addendum': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
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
|
+
face_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
23
|
+
};
|
|
24
|
+
run(): Promise<unknown>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
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 { renameFaceFields, resolveProfileAddendum, seg, isMeAlias, ME_MISSING, badFaceName, badToolNames, compact } from '../../utils.js';
|
|
6
|
+
export default class FaceEdit extends BaseCommand {
|
|
7
|
+
static description = "Edit a face's metadata";
|
|
8
|
+
static flags = {
|
|
9
|
+
...BaseCommand.baseFlags,
|
|
10
|
+
name: Flags.string({ description: 'New display name' }),
|
|
11
|
+
description: Flags.string({ description: 'Plain-text description / bio (max 1500 chars)' }),
|
|
12
|
+
specialty: Flags.string({
|
|
13
|
+
description: 'Replace the short line saying what this face is for. Pass an empty string to remove it.',
|
|
14
|
+
}),
|
|
15
|
+
tag: Flags.string({ description: 'Replace all tags (repeatable, lowercase)', multiple: true }),
|
|
16
|
+
'default-model': Flags.string({ description: 'Default LLM for chat (e.g. gpt-4o-mini, claude-sonnet-4-6)' }),
|
|
17
|
+
formula: Flags.string({
|
|
18
|
+
description: 'New formula, making the face a composite. Pass an empty string to turn a composite back into an ordinary ' +
|
|
19
|
+
'face. Refused on a face with compiled sources of its own, or one used in another composite: make a new ' +
|
|
20
|
+
'composite with faces face:create --formula instead.',
|
|
21
|
+
}),
|
|
22
|
+
attr: Flags.string({
|
|
23
|
+
description: 'Update attribute KEY=VALUE (repeatable). age, gender and location take a bare value ("45", "Lisbon, ' +
|
|
24
|
+
'Portugal"); identity, education, occupation, religion, family, relationships, health, languages and ' +
|
|
25
|
+
'background take a short sentence. Any other key is refused, and then nothing is saved. See faces face:attributes.',
|
|
26
|
+
multiple: true,
|
|
27
|
+
}),
|
|
28
|
+
tool: Flags.string({ description: 'Tool names to set (replaces list, repeatable). The server stores any name without checking it, so spell it as the tool expects.', multiple: true }),
|
|
29
|
+
'profile-addendum': Flags.string({ description: 'Replace the per-face system prompt (max 100,000 chars). Anyone who can chat with the face may be able to get the model to repeat it.' }),
|
|
30
|
+
'profile-addendum-file': Flags.string({ description: 'Replace the per-face system prompt from a file. Anyone who can chat with the face may be able to get the model to repeat it.', exclusive: ['profile-addendum'] }),
|
|
31
|
+
'clear-profile-addendum': Flags.boolean({ description: 'Remove the per-face system prompt.', exclusive: ['profile-addendum', 'profile-addendum-file'] }),
|
|
32
|
+
};
|
|
33
|
+
static args = {
|
|
34
|
+
face_id: Args.string({ description: 'Face alias', required: true }),
|
|
35
|
+
};
|
|
36
|
+
async run() {
|
|
37
|
+
const { args, flags } = await this.parse(FaceEdit);
|
|
38
|
+
const client = this.makeClient(flags);
|
|
39
|
+
const payload = {};
|
|
40
|
+
if (flags.name !== undefined) {
|
|
41
|
+
const nameProblem = badFaceName(flags.name);
|
|
42
|
+
if (nameProblem)
|
|
43
|
+
this.error(`--name: ${nameProblem}`);
|
|
44
|
+
payload.name = flags.name;
|
|
45
|
+
}
|
|
46
|
+
if (flags.formula !== undefined)
|
|
47
|
+
payload.formula = flags.formula.trim();
|
|
48
|
+
if (flags.attr && flags.attr.length > 0) {
|
|
49
|
+
const parsed = {};
|
|
50
|
+
for (const a of flags.attr) {
|
|
51
|
+
if (!a.includes('=') || !a.slice(0, a.indexOf('=')).trim())
|
|
52
|
+
this.error(`Attributes must be KEY=VALUE, got: ${a}. See the keys with: faces face:attributes`);
|
|
53
|
+
const idx = a.indexOf('=');
|
|
54
|
+
parsed[a.slice(0, idx).trim()] = a.slice(idx + 1).trim();
|
|
55
|
+
}
|
|
56
|
+
payload.basic_facts = parsed;
|
|
57
|
+
}
|
|
58
|
+
if (flags.tool && flags.tool.length > 0) {
|
|
59
|
+
const toolProblem = badToolNames(flags.tool);
|
|
60
|
+
if (toolProblem)
|
|
61
|
+
this.error(`--tool: ${toolProblem}`);
|
|
62
|
+
payload.default_tools = flags.tool.map((t) => t.trim());
|
|
63
|
+
}
|
|
64
|
+
if (flags['default-model'])
|
|
65
|
+
payload.default_model = flags['default-model'];
|
|
66
|
+
if (flags.description !== undefined)
|
|
67
|
+
payload.description = flags.description;
|
|
68
|
+
if (flags.specialty !== undefined)
|
|
69
|
+
payload.specialty = flags.specialty;
|
|
70
|
+
if (flags['clear-profile-addendum']) {
|
|
71
|
+
payload.profile_addendum = '';
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
let addendum;
|
|
75
|
+
try {
|
|
76
|
+
addendum = resolveProfileAddendum(flags['profile-addendum'], flags['profile-addendum-file']);
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
this.error(err instanceof Error ? err.message : String(err));
|
|
80
|
+
}
|
|
81
|
+
if (addendum !== undefined)
|
|
82
|
+
payload.profile_addendum = addendum;
|
|
83
|
+
}
|
|
84
|
+
const hasTags = flags.tag && flags.tag.length > 0;
|
|
85
|
+
if (Object.keys(payload).length === 0 && !hasTags)
|
|
86
|
+
this.error('Provide at least one field to update.');
|
|
87
|
+
let data;
|
|
88
|
+
if (Object.keys(payload).length > 0) {
|
|
89
|
+
try {
|
|
90
|
+
data = await client.patch(`/v1/faces/${seg(args.face_id)}`, { body: payload });
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
if (err instanceof FacesAPIError && err.statusCode === 404) {
|
|
94
|
+
this.error(isMeAlias(args.face_id) ? ME_MISSING : `No face '${args.face_id}' on this account. List yours with: faces face:list`);
|
|
95
|
+
}
|
|
96
|
+
if (err instanceof FacesAPIError && err.statusCode === 409 && payload.formula) {
|
|
97
|
+
this.error(`HTTP 409: ${err.message}\n` +
|
|
98
|
+
`Make a new composite instead: faces face:create --alias <new-alias> --name <name> --formula "${payload.formula}"`);
|
|
99
|
+
}
|
|
100
|
+
if (err instanceof FacesAPIError)
|
|
101
|
+
this.error(`HTTP ${err.statusCode}: ${err.message}`);
|
|
102
|
+
throw err;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
try {
|
|
107
|
+
data = await client.get(`/v1/faces/${seg(args.face_id)}?include=profile`);
|
|
108
|
+
}
|
|
109
|
+
catch (err) {
|
|
110
|
+
if (err instanceof FacesAPIError)
|
|
111
|
+
this.error(`HTTP ${err.statusCode}: ${err.message}`);
|
|
112
|
+
throw err;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (hasTags) {
|
|
116
|
+
try {
|
|
117
|
+
await client.put(`/v1/iam/${seg(args.face_id)}/tags`, { body: { tags: flags.tag } });
|
|
118
|
+
}
|
|
119
|
+
catch (err) {
|
|
120
|
+
if (err instanceof FacesAPIError) {
|
|
121
|
+
this.warn(`Tags failed (${err.statusCode}): ${err.message}`);
|
|
122
|
+
process.exitCode = 1;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
let currentTags = [];
|
|
127
|
+
try {
|
|
128
|
+
const tagResp = await client.get(`/v1/iam/${seg(args.face_id)}/tags`);
|
|
129
|
+
currentTags = tagResp.tags ?? [];
|
|
130
|
+
}
|
|
131
|
+
catch { }
|
|
132
|
+
const face = data;
|
|
133
|
+
if (Array.isArray(face.warnings) && face.warnings.length > 0) {
|
|
134
|
+
for (const w of face.warnings)
|
|
135
|
+
this.warn(w);
|
|
136
|
+
}
|
|
137
|
+
face.tags = currentTags;
|
|
138
|
+
renameFaceFields(face);
|
|
139
|
+
try {
|
|
140
|
+
const catalog = new CatalogService();
|
|
141
|
+
catalog.writeFace({
|
|
142
|
+
...face,
|
|
143
|
+
basic_facts: face.attributes,
|
|
144
|
+
tags: face.tags ?? undefined,
|
|
145
|
+
description: face.description ?? undefined,
|
|
146
|
+
default_model: face.default_model,
|
|
147
|
+
formula: face.formula,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
catch { }
|
|
151
|
+
if (!this.jsonEnabled())
|
|
152
|
+
this.printHuman(compact(data));
|
|
153
|
+
return data;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base.js';
|
|
2
|
+
export default class FaceGet extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
include: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
full: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
7
|
+
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
};
|
|
12
|
+
static args: {
|
|
13
|
+
face_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
14
|
+
};
|
|
15
|
+
run(): Promise<unknown>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base.js';
|
|
3
|
+
import { resolveBaseUrl } from '../../config.js';
|
|
4
|
+
import { FacesAPIError } from '../../client.js';
|
|
5
|
+
import { score10 } from '../../fidelity.js';
|
|
6
|
+
import { faceStyles, renameFaceFields, resolveFace, isMeAlias, ME_MISSING, seg } from '../../utils.js';
|
|
7
|
+
export default class FaceGet extends BaseCommand {
|
|
8
|
+
static description = 'Get details for a face, by alias or owner:alias. A published or shared face is reachable under the ' +
|
|
9
|
+
'same owner:alias address chat uses; it is shown with a note that you do not own it.';
|
|
10
|
+
static flags = {
|
|
11
|
+
...BaseCommand.baseFlags,
|
|
12
|
+
include: Flags.string({
|
|
13
|
+
description: 'Extra fields, comma-separated: tags, groups, profile, sharing, avatar, usage. `usage` adds the ' +
|
|
14
|
+
'30-day counters; `avatar` says whether the picture is current or stale.',
|
|
15
|
+
}),
|
|
16
|
+
full: Flags.boolean({ description: 'Print the full profile_addendum instead of a truncated preview' }),
|
|
17
|
+
};
|
|
18
|
+
static args = {
|
|
19
|
+
face_id: Args.string({
|
|
20
|
+
description: 'Face alias, or owner:alias for a face published by or shared from another account',
|
|
21
|
+
required: true,
|
|
22
|
+
}),
|
|
23
|
+
};
|
|
24
|
+
async run() {
|
|
25
|
+
const { args, flags } = await this.parse(FaceGet);
|
|
26
|
+
const client = this.makeClient(flags);
|
|
27
|
+
const includes = new Set(['profile', 'tags']);
|
|
28
|
+
if (flags.include) {
|
|
29
|
+
const known = ['tags', 'groups', 'profile', 'sharing', 'avatar', 'usage'];
|
|
30
|
+
for (const v of flags.include.split(',').map((x) => x.trim()).filter(Boolean)) {
|
|
31
|
+
if (!known.includes(v))
|
|
32
|
+
this.error(`--include takes ${known.join(', ')} (got "${v}").`);
|
|
33
|
+
includes.add(v);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
let resolved;
|
|
37
|
+
try {
|
|
38
|
+
resolved = await resolveFace(client, args.face_id, [...includes].join(','));
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
if (err instanceof FacesAPIError) {
|
|
42
|
+
if (err.statusCode === 404) {
|
|
43
|
+
if (args.face_id.includes(':')) {
|
|
44
|
+
this.error(`Could not find '${args.face_id}' in the face listing.\n` +
|
|
45
|
+
'A published face can be reachable before it appears there, so this may not mean it does ' +
|
|
46
|
+
`not exist. If you know the handle, try it directly: faces chat:chat ${args.face_id}@<model>`);
|
|
47
|
+
}
|
|
48
|
+
if (isMeAlias(args.face_id))
|
|
49
|
+
this.error(ME_MISSING);
|
|
50
|
+
this.error(`No face '${args.face_id}'. If it belongs to another account, name it as owner:alias, ` +
|
|
51
|
+
'the same address chat uses. Find it with: faces face:list --public');
|
|
52
|
+
}
|
|
53
|
+
this.error(`HTTP ${err.statusCode}: ${err.message}`);
|
|
54
|
+
}
|
|
55
|
+
throw err;
|
|
56
|
+
}
|
|
57
|
+
const data = resolved.face;
|
|
58
|
+
if (typeof data.alias !== 'string') {
|
|
59
|
+
this.error(`${resolveBaseUrl(flags['base-url'])} did not answer like the Faces API: the face has no alias. Check the base URL in: faces config:show`);
|
|
60
|
+
}
|
|
61
|
+
const face = data;
|
|
62
|
+
renameFaceFields(face);
|
|
63
|
+
const f = face;
|
|
64
|
+
if (!this.jsonEnabled()) {
|
|
65
|
+
this.log(`alias: ${f.alias}`);
|
|
66
|
+
this.log(`uid: ${f.uid}`);
|
|
67
|
+
this.log(`name: ${f.name}`);
|
|
68
|
+
if (f.specialty)
|
|
69
|
+
this.log(`specialty: ${f.specialty}`);
|
|
70
|
+
if (f.description)
|
|
71
|
+
this.log(`description: ${f.description}`);
|
|
72
|
+
this.log(`owned_by: ${f.owned_by}`);
|
|
73
|
+
if (!resolved.owned) {
|
|
74
|
+
this.log(`access: not yours; reachable because it is published or shared with you`);
|
|
75
|
+
this.log(`address: ${resolved.handle}@<model> (chat, or a group member; only its owner can edit it)`);
|
|
76
|
+
}
|
|
77
|
+
if (typeof f.created === 'number')
|
|
78
|
+
this.log(`created: ${new Date(f.created * 1000).toISOString().slice(0, 10)}`);
|
|
79
|
+
if (f.updated_at)
|
|
80
|
+
this.log(`updated: ${f.updated_at.slice(0, 10)}`);
|
|
81
|
+
const media = faceStyles(f);
|
|
82
|
+
if (media.length > 0)
|
|
83
|
+
this.log(`styles: ${media.join(', ')} (ask for one with --style)`);
|
|
84
|
+
if (typeof f.fidelity === 'number') {
|
|
85
|
+
const against = f.fidelity_competitor ? ` against ${f.fidelity_competitor}` : '';
|
|
86
|
+
const when = f.fidelity_at ? `, ${f.fidelity_at.slice(0, 10)}` : '';
|
|
87
|
+
this.log(`fidelity: ${score10(f.fidelity)} out of 10${against}${when}`);
|
|
88
|
+
}
|
|
89
|
+
if (f.usage && Object.keys(f.usage).length > 0) {
|
|
90
|
+
const u = f.usage;
|
|
91
|
+
const parts = [];
|
|
92
|
+
if (u.users_30d !== undefined)
|
|
93
|
+
parts.push(`${u.users_30d} user(s) in 30d`);
|
|
94
|
+
if (u.tokens_30d !== undefined)
|
|
95
|
+
parts.push(`${u.tokens_30d.toLocaleString()} tokens in 30d`);
|
|
96
|
+
if (u.tokens_total !== undefined)
|
|
97
|
+
parts.push(`${u.tokens_total.toLocaleString()} tokens all told`);
|
|
98
|
+
this.log(`usage: ${parts.length > 0 ? parts.join(', ') : JSON.stringify(u)}`);
|
|
99
|
+
}
|
|
100
|
+
let tags = data.tags;
|
|
101
|
+
if (!tags && resolved.owned) {
|
|
102
|
+
try {
|
|
103
|
+
tags = (await client.get(`/v1/iam/${seg(String(f.alias))}/tags`)).tags ?? null;
|
|
104
|
+
}
|
|
105
|
+
catch { }
|
|
106
|
+
}
|
|
107
|
+
if (tags && tags.length > 0)
|
|
108
|
+
this.log(`tags: ${tags.join(', ')}`);
|
|
109
|
+
if (f.read_only)
|
|
110
|
+
this.log('read only');
|
|
111
|
+
if (f.formula) {
|
|
112
|
+
this.log(`formula: ${f.formula}`);
|
|
113
|
+
this.log(`type: composite`);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
this.log(`type: concrete`);
|
|
117
|
+
if (f.attributes && Object.keys(f.attributes).length > 0) {
|
|
118
|
+
this.log('attributes:');
|
|
119
|
+
for (const [k, v] of Object.entries(f.attributes)) {
|
|
120
|
+
this.log(` ${k}: ${v}`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (f.default_tools && f.default_tools.length > 0)
|
|
124
|
+
this.log(`default_tools: ${f.default_tools.join(', ')}`);
|
|
125
|
+
if (f.default_model)
|
|
126
|
+
this.log(`default_model: ${f.default_model}`);
|
|
127
|
+
}
|
|
128
|
+
if (f.profile_addendum) {
|
|
129
|
+
const text = f.profile_addendum;
|
|
130
|
+
if (flags.full) {
|
|
131
|
+
this.log(`profile_addendum (${text.length} chars):`);
|
|
132
|
+
this.log(text);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
const oneLine = text.replace(/\s+/g, ' ').trim();
|
|
136
|
+
const preview = oneLine.length > 160 ? `${oneLine.slice(0, 160)}…` : oneLine;
|
|
137
|
+
this.log(`profile_addendum (${text.length} chars): ${preview}`);
|
|
138
|
+
if (oneLine.length > 160)
|
|
139
|
+
this.log(' (use --full to print the whole prompt)');
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return data;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base.js';
|
|
2
|
+
export default class FaceGroups extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
group: 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
|
+
alias: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
13
|
+
};
|
|
14
|
+
run(): Promise<unknown>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
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 FaceGroups extends BaseCommand {
|
|
6
|
+
static description = "Set a face's group memberships (replaces all)";
|
|
7
|
+
static flags = {
|
|
8
|
+
...BaseCommand.baseFlags,
|
|
9
|
+
group: Flags.string({
|
|
10
|
+
description: 'Group ID (repeatable, replaces all memberships)',
|
|
11
|
+
multiple: true,
|
|
12
|
+
required: true,
|
|
13
|
+
}),
|
|
14
|
+
};
|
|
15
|
+
static args = {
|
|
16
|
+
alias: Args.string({ description: 'Face alias', required: true }),
|
|
17
|
+
};
|
|
18
|
+
async run() {
|
|
19
|
+
const { args, flags } = await this.parse(FaceGroups);
|
|
20
|
+
const client = this.makeClient(flags);
|
|
21
|
+
let data;
|
|
22
|
+
try {
|
|
23
|
+
data = await client.put(`/v1/faces/${seg(args.alias)}/groups`, { body: { group_ids: flags.group } });
|
|
24
|
+
}
|
|
25
|
+
catch (err) {
|
|
26
|
+
if (err instanceof FacesAPIError)
|
|
27
|
+
this.error(`HTTP ${err.statusCode}: ${err.message}`);
|
|
28
|
+
throw err;
|
|
29
|
+
}
|
|
30
|
+
if (!this.jsonEnabled())
|
|
31
|
+
this.printHuman(data);
|
|
32
|
+
return data;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base.js';
|
|
2
|
+
export default class FaceList extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
tag: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
group: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
include: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
public: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
|
+
'has-style': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
shared: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
system: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
'from-users': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
'not-from-users': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
sort: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
order: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
search: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
+
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
20
|
+
toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
21
|
+
};
|
|
22
|
+
run(): Promise<unknown>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base.js';
|
|
3
|
+
import { FacesAPIError } from '../../client.js';
|
|
4
|
+
import { renameFaceFields, faceStyles, readablePatternError } from '../../utils.js';
|
|
5
|
+
const SYSTEM_OWNER = 'head';
|
|
6
|
+
export default class FaceList extends BaseCommand {
|
|
7
|
+
static description = 'List faces. By default lists owned faces, newest first; use --public to include published faces ' +
|
|
8
|
+
'from other accounts, --search to match on text, and --sort/--order to change the ordering.';
|
|
9
|
+
static flags = {
|
|
10
|
+
...BaseCommand.baseFlags,
|
|
11
|
+
tag: Flags.string({ description: 'Filter by tag (repeatable, AND logic)', multiple: true }),
|
|
12
|
+
group: Flags.string({
|
|
13
|
+
description: 'Filter by group ID (repeatable, OR logic)',
|
|
14
|
+
multiple: true,
|
|
15
|
+
}),
|
|
16
|
+
include: Flags.string({
|
|
17
|
+
description: 'Extra fields, comma-separated: tags, groups, profile, sharing, avatar, usage, owner_follow. ' +
|
|
18
|
+
'`avatar` says whether each generated avatar is current or stale; `owner_follow` says whether ' +
|
|
19
|
+
'you follow the account that published a face.',
|
|
20
|
+
}),
|
|
21
|
+
public: Flags.boolean({ description: 'Include published faces from other accounts (open to everybody)' }),
|
|
22
|
+
'has-style': Flags.boolean({
|
|
23
|
+
description: 'Show only faces with a built style',
|
|
24
|
+
default: false,
|
|
25
|
+
}),
|
|
26
|
+
shared: Flags.boolean({ description: 'Include faces other accounts have shared with YOU in particular' }),
|
|
27
|
+
system: Flags.boolean({ description: `Show only the curated system faces (published faces owned by '${SYSTEM_OWNER}')` }),
|
|
28
|
+
'from-users': Flags.string({ description: 'Only published faces from these owners (repeatable/comma-separated)', multiple: true }),
|
|
29
|
+
'not-from-users': Flags.string({ description: 'Exclude published faces from these owners (repeatable/comma-separated)', multiple: true }),
|
|
30
|
+
sort: Flags.string({
|
|
31
|
+
description: 'What to order by: created, alias, relevance or usage. relevance ranks by how well a face ' +
|
|
32
|
+
'matches --search, so it needs one.',
|
|
33
|
+
}),
|
|
34
|
+
order: Flags.string({
|
|
35
|
+
description: 'asc or desc. Omit it to keep each field\'s own direction, which is newest first for created, ' +
|
|
36
|
+
'most used first for usage, best match first for relevance, and A to Z for alias.',
|
|
37
|
+
}),
|
|
38
|
+
search: Flags.string({
|
|
39
|
+
description: 'Only faces whose alias, name or description matches this text',
|
|
40
|
+
}),
|
|
41
|
+
};
|
|
42
|
+
async run() {
|
|
43
|
+
const { flags } = await this.parse(FaceList);
|
|
44
|
+
for (const t of flags.group ?? []) {
|
|
45
|
+
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t)) {
|
|
46
|
+
this.error(`--group takes a group id (got "${t}"). Find ids with: faces group:list`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const client = this.makeClient(flags);
|
|
50
|
+
const split = (vals) => (vals ?? []).flatMap(v => v.split(',')).map(v => v.trim()).filter(Boolean);
|
|
51
|
+
const fromUsers = split(flags['from-users']);
|
|
52
|
+
if (flags.system)
|
|
53
|
+
fromUsers.push(SYSTEM_OWNER);
|
|
54
|
+
const notFromUsers = split(flags['not-from-users']);
|
|
55
|
+
if (fromUsers.length > 0 && notFromUsers.length > 0) {
|
|
56
|
+
this.error('--from-users and --not-from-users are mutually exclusive');
|
|
57
|
+
}
|
|
58
|
+
if (flags.sort === 'relevance' && !flags.search) {
|
|
59
|
+
this.error('--sort relevance ranks by how well a face matches --search, so it needs one.');
|
|
60
|
+
}
|
|
61
|
+
const includePublished = flags.public || flags.system || fromUsers.length > 0 || notFromUsers.length > 0;
|
|
62
|
+
const parts = [];
|
|
63
|
+
if (flags.tag && flags.tag.length > 0) {
|
|
64
|
+
for (const t of flags.tag)
|
|
65
|
+
parts.push(`tag=${encodeURIComponent(t)}`);
|
|
66
|
+
}
|
|
67
|
+
if (flags.group && flags.group.length > 0) {
|
|
68
|
+
for (const t of flags.group)
|
|
69
|
+
parts.push(`group_id=${encodeURIComponent(t)}`);
|
|
70
|
+
}
|
|
71
|
+
if (flags.include)
|
|
72
|
+
parts.push(`include=${encodeURIComponent(flags.include)}`);
|
|
73
|
+
if (flags.sort)
|
|
74
|
+
parts.push(`sort=${encodeURIComponent(flags.sort)}`);
|
|
75
|
+
if (flags.order)
|
|
76
|
+
parts.push(`order=${encodeURIComponent(flags.order)}`);
|
|
77
|
+
if (flags.search)
|
|
78
|
+
parts.push(`q=${encodeURIComponent(flags.search)}`);
|
|
79
|
+
if (includePublished)
|
|
80
|
+
parts.push('include_published=true');
|
|
81
|
+
if (flags.shared)
|
|
82
|
+
parts.push('include_shared=true');
|
|
83
|
+
for (const u of fromUsers)
|
|
84
|
+
parts.push(`from_users=${encodeURIComponent(u)}`);
|
|
85
|
+
for (const u of notFromUsers)
|
|
86
|
+
parts.push(`not_from_users=${encodeURIComponent(u)}`);
|
|
87
|
+
let data;
|
|
88
|
+
let truncated = false;
|
|
89
|
+
try {
|
|
90
|
+
const path = parts.length > 0 ? `/v1/faces?${parts.join('&')}` : '/v1/faces';
|
|
91
|
+
const all = await client.getAll(path);
|
|
92
|
+
truncated = all.truncated;
|
|
93
|
+
data = { object: 'list', data: all.data, has_more: all.truncated, next_cursor: null };
|
|
94
|
+
}
|
|
95
|
+
catch (err) {
|
|
96
|
+
if (err instanceof FacesAPIError) {
|
|
97
|
+
if (err.statusCode === 422)
|
|
98
|
+
this.error(readablePatternError(err.message));
|
|
99
|
+
this.error(`HTTP ${err.statusCode}: ${err.message}`);
|
|
100
|
+
}
|
|
101
|
+
throw err;
|
|
102
|
+
}
|
|
103
|
+
const raw = data.data ?? data;
|
|
104
|
+
for (const f of raw) {
|
|
105
|
+
renameFaceFields(f);
|
|
106
|
+
}
|
|
107
|
+
let faces = raw;
|
|
108
|
+
if (flags['has-style'])
|
|
109
|
+
faces = faces.filter(f => faceStyles(f).length > 0);
|
|
110
|
+
if (fromUsers.length > 0) {
|
|
111
|
+
const allow = new Set(fromUsers);
|
|
112
|
+
faces = faces.filter(f => f.owned_by != null && allow.has(f.owned_by));
|
|
113
|
+
}
|
|
114
|
+
else if (notFromUsers.length > 0) {
|
|
115
|
+
const block = new Set(notFromUsers);
|
|
116
|
+
faces = faces.filter(f => f.owned_by == null || !block.has(f.owned_by));
|
|
117
|
+
}
|
|
118
|
+
if (data.data !== undefined)
|
|
119
|
+
data.data = faces;
|
|
120
|
+
else
|
|
121
|
+
data = faces;
|
|
122
|
+
if (!this.jsonEnabled()) {
|
|
123
|
+
const isForeign = (f) => Boolean(f.published || f.via?.length);
|
|
124
|
+
const handle = (f) => isForeign(f) && f.owned_by ? `${f.owned_by}:${f.alias}` : f.alias;
|
|
125
|
+
if (faces.length === 0) {
|
|
126
|
+
this.log('(no faces)');
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
const handleWidth = Math.max(...faces.map(f => handle(f).length));
|
|
130
|
+
const nameWidth = Math.max(...faces.map(f => f.name.length));
|
|
131
|
+
for (const f of faces) {
|
|
132
|
+
let suffix = '';
|
|
133
|
+
if (f.formula) {
|
|
134
|
+
suffix = ` [composite: ${f.formula}]`;
|
|
135
|
+
}
|
|
136
|
+
const media = faceStyles(f);
|
|
137
|
+
if (media.length > 0)
|
|
138
|
+
suffix += ` [style: ${media.join(', ')}]`;
|
|
139
|
+
if (f.avatar_status) {
|
|
140
|
+
const v = f.avatar_version ? ` v${f.avatar_version}` : '';
|
|
141
|
+
suffix += f.avatar_status === 'none' ? '' : ` [avatar: ${f.avatar_status}${v}]`;
|
|
142
|
+
}
|
|
143
|
+
if (f.avatar_uploaded)
|
|
144
|
+
suffix += ' [uploaded picture]';
|
|
145
|
+
if (f.owner_followed)
|
|
146
|
+
suffix += ' [you follow the owner]';
|
|
147
|
+
if (f.via?.length) {
|
|
148
|
+
const how = f.via.includes('shared') && f.via.includes('workspace')
|
|
149
|
+
? 'shared with you, and via a workspace'
|
|
150
|
+
: f.via.includes('workspace') ? 'via a workspace' : 'shared with you';
|
|
151
|
+
suffix += ` [${how} · requires @model]`;
|
|
152
|
+
}
|
|
153
|
+
if (f.published)
|
|
154
|
+
suffix += ' [public · requires @model]';
|
|
155
|
+
if (f.read_only)
|
|
156
|
+
suffix += ' [read only]';
|
|
157
|
+
const spec = f.specialty ? ` (${f.specialty})` : '';
|
|
158
|
+
this.log(`${handle(f).padEnd(handleWidth)} ${f.name.padEnd(nameWidth)}${spec}${suffix}`.trimEnd());
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (truncated) {
|
|
162
|
+
this.log('');
|
|
163
|
+
this.log('This list is incomplete: the server had more faces than could be read in one go.');
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return data;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base.js';
|
|
2
|
+
export default class FaceLock extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
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
|
+
}
|