@faces-sh/cli 0.0.0-stage → 1.0.1
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 +43 -0
- package/dist/commands/face/share.d.ts +22 -0
- package/dist/commands/face/share.js +104 -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 +32 -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 +94 -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,14 @@
|
|
|
1
|
+
import { BaseCommand } from '../../../base.js';
|
|
2
|
+
export default class FaceTagList 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
|
+
alias: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
12
|
+
};
|
|
13
|
+
run(): Promise<unknown>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Args } 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 FaceTagList extends BaseCommand {
|
|
6
|
+
static description = 'List tags on a face';
|
|
7
|
+
static flags = {
|
|
8
|
+
...BaseCommand.baseFlags,
|
|
9
|
+
};
|
|
10
|
+
static args = {
|
|
11
|
+
alias: Args.string({ description: 'Face alias', required: true }),
|
|
12
|
+
};
|
|
13
|
+
async run() {
|
|
14
|
+
const { args, flags } = await this.parse(FaceTagList);
|
|
15
|
+
const client = this.makeClient(flags);
|
|
16
|
+
let data;
|
|
17
|
+
try {
|
|
18
|
+
data = await client.get(`/v1/iam/${seg(args.alias)}/tags`);
|
|
19
|
+
}
|
|
20
|
+
catch (err) {
|
|
21
|
+
if (err instanceof FacesAPIError)
|
|
22
|
+
this.error(`HTTP ${err.statusCode}: ${err.message}`);
|
|
23
|
+
throw err;
|
|
24
|
+
}
|
|
25
|
+
if (!this.jsonEnabled()) {
|
|
26
|
+
const tags = data.tags ?? [];
|
|
27
|
+
if (tags.length === 0) {
|
|
28
|
+
this.log('(no tags)');
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
this.log(tags.join(', '));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return data;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseCommand } from '../../../base.js';
|
|
2
|
+
export default class FaceTagRemove extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
tag: import("@oclif/core/interfaces").OptionFlag<string | undefined, 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
|
+
tag: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
14
|
+
};
|
|
15
|
+
run(): Promise<unknown>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
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 } from '../../../utils.js';
|
|
6
|
+
export default class FaceTagRemove extends BaseCommand {
|
|
7
|
+
static description = 'Remove a tag from a face';
|
|
8
|
+
static flags = {
|
|
9
|
+
...BaseCommand.baseFlags,
|
|
10
|
+
tag: Flags.string({ description: 'Tag to remove (or give it as the second argument)' }),
|
|
11
|
+
};
|
|
12
|
+
static args = {
|
|
13
|
+
alias: Args.string({ description: 'Face alias', required: true }),
|
|
14
|
+
tag: Args.string({ description: 'Tag to remove' }),
|
|
15
|
+
};
|
|
16
|
+
async run() {
|
|
17
|
+
const { args, flags } = await this.parse(FaceTagRemove);
|
|
18
|
+
const client = this.makeClient(flags);
|
|
19
|
+
const tag = args.tag ?? flags.tag;
|
|
20
|
+
if (!tag)
|
|
21
|
+
this.error('Name the tag to remove: faces face:tag:remove <alias> <tag>, or --tag <tag>');
|
|
22
|
+
let data;
|
|
23
|
+
try {
|
|
24
|
+
data = await client.delete(`/v1/iam/${seg(args.alias)}/tags/${seg(tag)}`);
|
|
25
|
+
}
|
|
26
|
+
catch (err) {
|
|
27
|
+
if (err instanceof FacesAPIError) {
|
|
28
|
+
if (err.statusCode === 403) {
|
|
29
|
+
this.error(`Forbidden: face '${args.alias}' is not owned by the current account. Run \`faces catalog:doctor --fix\` to sync.`);
|
|
30
|
+
}
|
|
31
|
+
this.error(`HTTP ${err.statusCode}: ${err.message}`);
|
|
32
|
+
}
|
|
33
|
+
throw err;
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
const tagResp = await client.get(`/v1/iam/${seg(args.alias)}/tags`);
|
|
37
|
+
new CatalogService().updateTags(args.alias, tagResp.tags ?? []);
|
|
38
|
+
}
|
|
39
|
+
catch { }
|
|
40
|
+
if (!this.jsonEnabled())
|
|
41
|
+
this.log(`Removed tag '${tag}' from ${args.alias}`);
|
|
42
|
+
return data;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseCommand } from '../../../base.js';
|
|
2
|
+
export default class FaceTagSet extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
tag: 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,40 @@
|
|
|
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 } from '../../../utils.js';
|
|
6
|
+
export default class FaceTagSet extends BaseCommand {
|
|
7
|
+
static description = 'Replace all tags on a face';
|
|
8
|
+
static flags = {
|
|
9
|
+
...BaseCommand.baseFlags,
|
|
10
|
+
tag: Flags.string({ description: 'Tag to set (repeatable, replaces all)', multiple: true, required: true }),
|
|
11
|
+
};
|
|
12
|
+
static args = {
|
|
13
|
+
alias: Args.string({ description: 'Face alias', required: true }),
|
|
14
|
+
};
|
|
15
|
+
async run() {
|
|
16
|
+
const { args, flags } = await this.parse(FaceTagSet);
|
|
17
|
+
const client = this.makeClient(flags);
|
|
18
|
+
let data;
|
|
19
|
+
try {
|
|
20
|
+
data = await client.put(`/v1/iam/${seg(args.alias)}/tags`, { body: { tags: flags.tag } });
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
if (err instanceof FacesAPIError) {
|
|
24
|
+
if (err.statusCode === 403) {
|
|
25
|
+
this.error(`Forbidden: face '${args.alias}' is not owned by the current account. Run \`faces catalog:doctor --fix\` to sync.`);
|
|
26
|
+
}
|
|
27
|
+
this.error(`HTTP ${err.statusCode}: ${err.message}`);
|
|
28
|
+
}
|
|
29
|
+
throw err;
|
|
30
|
+
}
|
|
31
|
+
const tags = data.tags ?? [];
|
|
32
|
+
try {
|
|
33
|
+
new CatalogService().updateTags(args.alias, tags);
|
|
34
|
+
}
|
|
35
|
+
catch { }
|
|
36
|
+
if (!this.jsonEnabled())
|
|
37
|
+
this.printHuman(data);
|
|
38
|
+
return data;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base.js';
|
|
2
|
+
export default class FaceUnlock 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
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Args } 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 FaceUnlock extends BaseCommand {
|
|
6
|
+
static description = 'Unlock a face (make it writable again). Thaws the face and everything it owns (documents, threads, built styles).';
|
|
7
|
+
static examples = ['<%= config.bin %> <%= command.id %> socrates'];
|
|
8
|
+
static flags = {
|
|
9
|
+
...BaseCommand.baseFlags,
|
|
10
|
+
};
|
|
11
|
+
static args = {
|
|
12
|
+
face_id: Args.string({ description: 'Face alias', required: true }),
|
|
13
|
+
};
|
|
14
|
+
async run() {
|
|
15
|
+
const { args, flags } = await this.parse(FaceUnlock);
|
|
16
|
+
const client = this.makeClient(flags);
|
|
17
|
+
let data;
|
|
18
|
+
try {
|
|
19
|
+
data = await client.patch(`/v1/faces/${seg(args.face_id)}/lock`, { body: { read_only: false } });
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
if (err instanceof FacesAPIError)
|
|
23
|
+
this.error(`HTTP ${err.statusCode}: ${err.message}`);
|
|
24
|
+
throw err;
|
|
25
|
+
}
|
|
26
|
+
if (!this.jsonEnabled()) {
|
|
27
|
+
const res = data;
|
|
28
|
+
this.log(`Unlocked '${res.alias ?? args.face_id}' is now writable.`);
|
|
29
|
+
const affected = res.affected ?? [];
|
|
30
|
+
if (affected.length > 0)
|
|
31
|
+
this.log(`Affected: ${affected.join(', ')}`);
|
|
32
|
+
}
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base.js';
|
|
2
|
+
export default class FaceUnpublish 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
|
+
alias: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
12
|
+
};
|
|
13
|
+
run(): Promise<unknown>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Args } 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 FaceUnpublish extends BaseCommand {
|
|
6
|
+
static description = 'Stop publishing a face. Anyone it is individually shared with keeps their access. Publishing is an ' +
|
|
7
|
+
'override on top of sharing, not a replacement for it.';
|
|
8
|
+
static flags = { ...BaseCommand.baseFlags };
|
|
9
|
+
static args = {
|
|
10
|
+
alias: Args.string({ description: 'Face alias', required: true }),
|
|
11
|
+
};
|
|
12
|
+
async run() {
|
|
13
|
+
const { args, flags } = await this.parse(FaceUnpublish);
|
|
14
|
+
const client = this.makeClient(flags);
|
|
15
|
+
let data;
|
|
16
|
+
try {
|
|
17
|
+
data = (await client.patch(`/v1/faces/${seg(args.alias)}/publish`, {
|
|
18
|
+
requireJwt: true,
|
|
19
|
+
body: { published: false },
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
if (err instanceof FacesAPIError)
|
|
24
|
+
this.error(`HTTP ${err.statusCode}: ${err.message}`);
|
|
25
|
+
throw err;
|
|
26
|
+
}
|
|
27
|
+
if (this.jsonEnabled())
|
|
28
|
+
return data;
|
|
29
|
+
this.log(`'${args.alias}' is no longer published.`);
|
|
30
|
+
return data;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base.js';
|
|
2
|
+
export default class FaceUnshare extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
from: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
all: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
|
+
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
};
|
|
14
|
+
static args: {
|
|
15
|
+
alias: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
16
|
+
};
|
|
17
|
+
run(): Promise<unknown>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
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 FaceUnshare extends BaseCommand {
|
|
6
|
+
static description = 'Revoke access to a shared face. Takes effect immediately. There is no grace period.';
|
|
7
|
+
static examples = [
|
|
8
|
+
'<%= config.bin %> <%= command.id %> alice --from dana --yes',
|
|
9
|
+
'<%= config.bin %> <%= command.id %> alice --all --yes',
|
|
10
|
+
];
|
|
11
|
+
static flags = {
|
|
12
|
+
...BaseCommand.baseFlags,
|
|
13
|
+
from: Flags.string({ description: 'Account to revoke (repeatable)', multiple: true, exclusive: ['all'] }),
|
|
14
|
+
all: Flags.boolean({ description: 'Revoke everyone', default: false, exclusive: ['from'] }),
|
|
15
|
+
yes: Flags.boolean({ description: 'Skip confirmation', default: false }),
|
|
16
|
+
};
|
|
17
|
+
static args = {
|
|
18
|
+
alias: Args.string({ description: 'Face alias', required: true }),
|
|
19
|
+
};
|
|
20
|
+
async run() {
|
|
21
|
+
const { args, flags } = await this.parse(FaceUnshare);
|
|
22
|
+
const client = this.makeClient(flags);
|
|
23
|
+
const json = this.jsonEnabled();
|
|
24
|
+
if (!flags.from && !flags.all)
|
|
25
|
+
this.error('Provide --from <account> (repeatable) or --all.');
|
|
26
|
+
let current;
|
|
27
|
+
try {
|
|
28
|
+
const face = (await client.get(`/v1/faces/${seg(args.alias)}`));
|
|
29
|
+
current = face.shared_with ?? [];
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
if (err instanceof FacesAPIError)
|
|
33
|
+
this.error(`HTTP ${err.statusCode}: ${err.message}`);
|
|
34
|
+
throw err;
|
|
35
|
+
}
|
|
36
|
+
if (current.length === 0) {
|
|
37
|
+
if (!json)
|
|
38
|
+
this.log(`'${args.alias}' is not shared with anyone.`);
|
|
39
|
+
return { alias: args.alias, shared_with: [] };
|
|
40
|
+
}
|
|
41
|
+
const drop = new Set((flags.from ?? []).map((u) => u.toLowerCase()));
|
|
42
|
+
const next = flags.all ? [] : current.filter((u) => !drop.has(u.toLowerCase()));
|
|
43
|
+
const removed = current.filter((u) => !next.includes(u));
|
|
44
|
+
if (removed.length === 0) {
|
|
45
|
+
this.error(`None of those accounts are on '${args.alias}'. Currently shared with: ${current.join(', ')}.\n` +
|
|
46
|
+
'The list stores usernames, so revoke by username even if you shared by email.');
|
|
47
|
+
}
|
|
48
|
+
if (!flags.yes) {
|
|
49
|
+
this.error(`This revokes ${removed.join(', ')} from '${args.alias}', immediately. Re-run with --yes.`);
|
|
50
|
+
}
|
|
51
|
+
let data;
|
|
52
|
+
try {
|
|
53
|
+
data = await client.patch(`/v1/faces/${seg(args.alias)}/share`, { requireJwt: true, body: { shared_with: next } });
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
if (err instanceof FacesAPIError)
|
|
57
|
+
this.error(`HTTP ${err.statusCode}: ${err.message}`);
|
|
58
|
+
throw err;
|
|
59
|
+
}
|
|
60
|
+
if (json)
|
|
61
|
+
return data;
|
|
62
|
+
this.log(`Revoked: ${removed.join(', ')}`);
|
|
63
|
+
this.log(next.length > 0 ? `Still shared with: ${next.join(', ')}` : `'${args.alias}' is no longer shared with anyone.`);
|
|
64
|
+
return data;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base.js';
|
|
2
|
+
export default class FidelityGet 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
|
+
run_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
13
|
+
};
|
|
14
|
+
run(): Promise<unknown>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base.js';
|
|
3
|
+
import { FacesAPIError } from '../../client.js';
|
|
4
|
+
import { fidelityError, getRun, nextStep, runLines, turnLines } from '../../fidelity.js';
|
|
5
|
+
export default class FidelityGet extends BaseCommand {
|
|
6
|
+
static description = 'Read a fidelity run: its progress, its turns and, once finished, its score. Which answer was the ' +
|
|
7
|
+
'face\'s is shown only after the run is finished. --json has every message and answer.';
|
|
8
|
+
static examples = ['<%= config.bin %> <%= command.id %> <run>'];
|
|
9
|
+
static flags = {
|
|
10
|
+
...BaseCommand.baseFlags,
|
|
11
|
+
};
|
|
12
|
+
static args = {
|
|
13
|
+
run_id: Args.string({ description: 'Fidelity run id', required: true }),
|
|
14
|
+
};
|
|
15
|
+
async run() {
|
|
16
|
+
const { args, flags } = await this.parse(FidelityGet);
|
|
17
|
+
const client = this.makeClient(flags);
|
|
18
|
+
let run;
|
|
19
|
+
try {
|
|
20
|
+
run = await getRun(client, args.run_id);
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
if (err instanceof FacesAPIError)
|
|
24
|
+
this.error(fidelityError(err, { run: args.run_id }));
|
|
25
|
+
throw err;
|
|
26
|
+
}
|
|
27
|
+
if (this.jsonEnabled())
|
|
28
|
+
return run;
|
|
29
|
+
for (const line of runLines(run))
|
|
30
|
+
this.log(line);
|
|
31
|
+
const turns = turnLines(run);
|
|
32
|
+
if (turns.length > 0) {
|
|
33
|
+
this.log('');
|
|
34
|
+
for (const line of turns)
|
|
35
|
+
this.log(line);
|
|
36
|
+
}
|
|
37
|
+
const next = nextStep(run);
|
|
38
|
+
if (next)
|
|
39
|
+
this.log(`\n${next}`);
|
|
40
|
+
return run;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base.js';
|
|
2
|
+
export default class FidelityPick extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
correction: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
'correction-file': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
turn: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
};
|
|
14
|
+
static args: {
|
|
15
|
+
run_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
16
|
+
pick: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
17
|
+
};
|
|
18
|
+
run(): Promise<unknown>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import { BaseCommand } from '../../base.js';
|
|
4
|
+
import { FacesAPIError } from '../../client.js';
|
|
5
|
+
import { FIDELITY_TURNS, fidelityError, fidelityPost, getRun, score10 } from '../../fidelity.js';
|
|
6
|
+
import { seg } from '../../utils.js';
|
|
7
|
+
export default class FidelityPick extends BaseCommand {
|
|
8
|
+
static description = 'Pick the answer, a or b, that sounds more like the person on the open turn of a fidelity run. ' +
|
|
9
|
+
'Without --correction the pick is accepted as it is; with one, it says what the person would ' +
|
|
10
|
+
'actually have said, and how much it changes the face\'s answer lowers that turn\'s score. The pick ' +
|
|
11
|
+
'must be the person\'s own, not an agent\'s. After the tenth, the run\'s score is saved on the face.';
|
|
12
|
+
static examples = [
|
|
13
|
+
'<%= config.bin %> <%= command.id %> <run> a',
|
|
14
|
+
'<%= config.bin %> <%= command.id %> <run> b --correction "Fine, thanks. Long drive."',
|
|
15
|
+
];
|
|
16
|
+
static flags = {
|
|
17
|
+
...BaseCommand.baseFlags,
|
|
18
|
+
correction: Flags.string({ description: 'What the person would actually have said, if the pick is not quite right', exclusive: ['correction-file'] }),
|
|
19
|
+
'correction-file': Flags.string({ description: 'Read the correction from a file' }),
|
|
20
|
+
turn: Flags.integer({ description: 'The turn to pick for (default: the open one)', min: 1, max: FIDELITY_TURNS }),
|
|
21
|
+
};
|
|
22
|
+
static args = {
|
|
23
|
+
run_id: Args.string({ description: 'Fidelity run id', required: true }),
|
|
24
|
+
pick: Args.string({ description: 'a or b', required: true, options: ['a', 'b'] }),
|
|
25
|
+
};
|
|
26
|
+
async run() {
|
|
27
|
+
const { args, flags } = await this.parse(FidelityPick);
|
|
28
|
+
const client = this.makeClient(flags);
|
|
29
|
+
let correction = flags.correction;
|
|
30
|
+
if (flags['correction-file']) {
|
|
31
|
+
if (!fs.existsSync(flags['correction-file']))
|
|
32
|
+
this.error(`File not found: ${flags['correction-file']}`);
|
|
33
|
+
correction = fs.readFileSync(flags['correction-file'], 'utf8');
|
|
34
|
+
}
|
|
35
|
+
let data;
|
|
36
|
+
try {
|
|
37
|
+
let turn = flags.turn;
|
|
38
|
+
if (turn === undefined) {
|
|
39
|
+
const run = await getRun(client, args.run_id);
|
|
40
|
+
if (!run.next)
|
|
41
|
+
this.error(`This run is finished. Read it with: faces fidelity:get ${args.run_id}`);
|
|
42
|
+
if (run.next.awaiting !== 'choice') {
|
|
43
|
+
this.error(`Turn ${run.next.turn} has no answers to pick from yet. Send its message: faces fidelity:turn ${args.run_id} -m "..."`);
|
|
44
|
+
}
|
|
45
|
+
turn = run.next.turn;
|
|
46
|
+
}
|
|
47
|
+
const body = { pick: args.pick };
|
|
48
|
+
if (correction?.trim())
|
|
49
|
+
body.correction = correction;
|
|
50
|
+
data = await fidelityPost(client, `/v1/fidelity/${seg(args.run_id)}/turns/${turn}/choice`, body);
|
|
51
|
+
}
|
|
52
|
+
catch (err) {
|
|
53
|
+
if (err instanceof FacesAPIError)
|
|
54
|
+
this.error(fidelityError(err, { run: args.run_id }));
|
|
55
|
+
throw err;
|
|
56
|
+
}
|
|
57
|
+
if (this.jsonEnabled())
|
|
58
|
+
return data;
|
|
59
|
+
this.log(`turn ${data.turn}: scored ${score10(data.score)}, ${score10(data.score_so_far)} so far`);
|
|
60
|
+
if (data.done) {
|
|
61
|
+
this.log(`\nFinished. Fidelity: ${score10(data.fidelity)} out of ${FIDELITY_TURNS}, saved on the face.`);
|
|
62
|
+
this.log(`See which answers were the face's: faces fidelity:get ${args.run_id}`);
|
|
63
|
+
this.log(`Keep the conversation as a thread, to compile: faces fidelity:save-thread ${args.run_id}`);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
this.log(`Next turn: faces fidelity:turn ${args.run_id} -m "..."`);
|
|
67
|
+
}
|
|
68
|
+
return data;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base.js';
|
|
2
|
+
export default class FidelityRunCommand extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
competitor: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
model: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
run: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
};
|
|
14
|
+
static args: {
|
|
15
|
+
alias: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
16
|
+
};
|
|
17
|
+
private rl?;
|
|
18
|
+
run(): Promise<unknown>;
|
|
19
|
+
private ask;
|
|
20
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { createInterface } from 'node:readline';
|
|
3
|
+
import { BaseCommand } from '../../base.js';
|
|
4
|
+
import { FacesAPIError } from '../../client.js';
|
|
5
|
+
import { FIDELITY_TURNS, answerLines, fidelityError, fidelityPost, getRun, runLines, score10, turnLines } from '../../fidelity.js';
|
|
6
|
+
import { seg, usd } from '../../utils.js';
|
|
7
|
+
export default class FidelityRunCommand extends BaseCommand {
|
|
8
|
+
static description = 'Play a fidelity run in the terminal: ten turns of writing a message, reading answers a and b, and ' +
|
|
9
|
+
'picking the one that sounds more like the person, with an optional correction. Needs a person at ' +
|
|
10
|
+
'the keyboard; without a terminal, use fidelity:start, fidelity:turn and fidelity:pick. Resume a run ' +
|
|
11
|
+
'with --run.';
|
|
12
|
+
static examples = [
|
|
13
|
+
'<%= config.bin %> <%= command.id %> alice',
|
|
14
|
+
'<%= config.bin %> <%= command.id %> alice --run <run>',
|
|
15
|
+
];
|
|
16
|
+
static flags = {
|
|
17
|
+
...BaseCommand.baseFlags,
|
|
18
|
+
competitor: Flags.string({ description: 'The chat model the face is compared with (default: the cheapest Codex-eligible chat model)' }),
|
|
19
|
+
model: Flags.string({ description: 'The model the face answers on (default: its own default model)' }),
|
|
20
|
+
run: Flags.string({ description: 'Resume this run instead of starting one', exclusive: ['competitor', 'model'] }),
|
|
21
|
+
};
|
|
22
|
+
static args = {
|
|
23
|
+
alias: Args.string({ description: 'Alias of a face you own', required: true }),
|
|
24
|
+
};
|
|
25
|
+
rl;
|
|
26
|
+
async run() {
|
|
27
|
+
const { args, flags } = await this.parse(FidelityRunCommand);
|
|
28
|
+
if (this.jsonEnabled() || !process.stdin.isTTY) {
|
|
29
|
+
this.error('fidelity:run needs a person at a terminal. Without one, use fidelity:start, fidelity:turn and fidelity:pick.');
|
|
30
|
+
}
|
|
31
|
+
const client = this.makeClient(flags);
|
|
32
|
+
this.rl = createInterface({ input: process.stdin, output: process.stderr });
|
|
33
|
+
try {
|
|
34
|
+
let run;
|
|
35
|
+
if (flags.run) {
|
|
36
|
+
run = await getRun(client, flags.run);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
const body = {};
|
|
40
|
+
if (flags.competitor)
|
|
41
|
+
body.competitor = flags.competitor;
|
|
42
|
+
if (flags.model)
|
|
43
|
+
body.model = flags.model;
|
|
44
|
+
run = (await fidelityPost(client, `/v1/faces/${seg(args.alias)}/fidelity`, body));
|
|
45
|
+
this.log(`Run ${run.run_id} against ${run.competitor ?? 'the competitor'}, up to ${usd(run.estimated_usd)} from credits.`);
|
|
46
|
+
}
|
|
47
|
+
const id = run.run_id;
|
|
48
|
+
this.log('Each turn, pick the answer that sounds more like the person. Ctrl-C stops; --run resumes.\n');
|
|
49
|
+
while (run.next) {
|
|
50
|
+
const n = run.next.turn;
|
|
51
|
+
if (run.next.awaiting === 'message') {
|
|
52
|
+
const message = await this.ask(`Turn ${n} of ${FIDELITY_TURNS}, your message: `);
|
|
53
|
+
if (!message.trim())
|
|
54
|
+
continue;
|
|
55
|
+
process.stderr.write('Waiting for both answers...\n');
|
|
56
|
+
const t = await fidelityPost(client, `/v1/fidelity/${seg(id)}/turns`, { message });
|
|
57
|
+
this.log('');
|
|
58
|
+
for (const line of answerLines(n, (t.answers ?? {})))
|
|
59
|
+
this.log(line);
|
|
60
|
+
this.log('');
|
|
61
|
+
}
|
|
62
|
+
let pick = '';
|
|
63
|
+
while (pick !== 'a' && pick !== 'b')
|
|
64
|
+
pick = (await this.ask('Which sounds more like them, a or b? ')).trim().toLowerCase();
|
|
65
|
+
const correction = await this.ask('What would they actually have said? (Enter to accept it as it is) ');
|
|
66
|
+
const body = { pick };
|
|
67
|
+
if (correction.trim())
|
|
68
|
+
body.correction = correction;
|
|
69
|
+
const c = await fidelityPost(client, `/v1/fidelity/${seg(id)}/turns/${n}/choice`, body);
|
|
70
|
+
this.log(`Turn ${n} scored ${score10(c.score)}, ${score10(c.score_so_far)} so far.\n`);
|
|
71
|
+
run = await getRun(client, id);
|
|
72
|
+
}
|
|
73
|
+
for (const line of runLines(run))
|
|
74
|
+
this.log(line);
|
|
75
|
+
this.log('');
|
|
76
|
+
for (const line of turnLines(run))
|
|
77
|
+
this.log(line);
|
|
78
|
+
if (!run.thread_id) {
|
|
79
|
+
const save = await this.ask('\nSave the conversation as a thread on the face, to compile? [y/N] ');
|
|
80
|
+
if (save.trim().toLowerCase() === 'y') {
|
|
81
|
+
const s = await fidelityPost(client, `/v1/fidelity/${seg(id)}/save-thread`, {});
|
|
82
|
+
this.log(`Saved as thread ${s.thread_id}. Compile it: faces compile:thread:make ${s.thread_id}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return run;
|
|
86
|
+
}
|
|
87
|
+
catch (err) {
|
|
88
|
+
if (err instanceof FacesAPIError)
|
|
89
|
+
this.error(fidelityError(err, { run: flags.run, alias: args.alias }));
|
|
90
|
+
throw err;
|
|
91
|
+
}
|
|
92
|
+
finally {
|
|
93
|
+
this.rl.close();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
ask(question) {
|
|
97
|
+
return new Promise((resolve) => this.rl.question(question, resolve));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base.js';
|
|
2
|
+
export default class FidelitySaveThread 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
|
+
run_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
13
|
+
};
|
|
14
|
+
run(): Promise<unknown>;
|
|
15
|
+
}
|