faces-cli 1.5.0 → 1.5.2
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/dist/commands/compile/doc/make.d.ts +1 -0
- package/dist/commands/compile/doc/make.js +11 -0
- package/dist/commands/compile/import.d.ts +1 -0
- package/dist/commands/compile/import.js +13 -1
- package/dist/commands/compile/thread/edit.d.ts +2 -1
- package/dist/commands/compile/thread/edit.js +68 -4
- package/dist/commands/compile/thread/make.d.ts +1 -0
- package/dist/commands/compile/thread/make.js +11 -0
- package/dist/commands/compile/upload.d.ts +1 -0
- package/dist/commands/compile/upload.js +13 -1
- package/oclif.manifest.json +675 -645
- package/package.json +1 -1
|
@@ -3,6 +3,7 @@ export default class CompileDocMake extends BaseCommand {
|
|
|
3
3
|
static description: string;
|
|
4
4
|
static flags: {
|
|
5
5
|
timeout: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
'no-wait': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
6
7
|
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
8
|
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
9
|
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -7,6 +7,10 @@ export default class CompileDocMake extends BaseCommand {
|
|
|
7
7
|
static flags = {
|
|
8
8
|
...BaseCommand.baseFlags,
|
|
9
9
|
timeout: Flags.integer({ description: 'Compile timeout in seconds (default: 600)', default: 600 }),
|
|
10
|
+
'no-wait': Flags.boolean({
|
|
11
|
+
description: 'Return immediately after triggering compilation. Prints the document ID for manual polling.',
|
|
12
|
+
default: false,
|
|
13
|
+
}),
|
|
10
14
|
};
|
|
11
15
|
static args = {
|
|
12
16
|
doc_id: Args.string({ description: 'Document ID', required: true }),
|
|
@@ -25,6 +29,13 @@ export default class CompileDocMake extends BaseCommand {
|
|
|
25
29
|
throw err;
|
|
26
30
|
}
|
|
27
31
|
const chunksTotal = makeResponse.chunks_total;
|
|
32
|
+
if (flags['no-wait']) {
|
|
33
|
+
if (!json) {
|
|
34
|
+
process.stderr.write(`Compilation started in background${chunksTotal ? ` (${chunksTotal} chunks)` : ''}.\n`);
|
|
35
|
+
process.stderr.write(`Poll with: faces compile:doc:get ${args.doc_id} --json\n`);
|
|
36
|
+
}
|
|
37
|
+
return makeResponse;
|
|
38
|
+
}
|
|
28
39
|
if (!json)
|
|
29
40
|
process.stderr.write(`Compiling${chunksTotal ? ` (${chunksTotal} chunks)` : ''}:\n`);
|
|
30
41
|
let result;
|
|
@@ -6,6 +6,7 @@ export default class CompileImport extends BaseCommand {
|
|
|
6
6
|
type: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
7
|
perspective: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
8
|
'face-speaker': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
'no-wait': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
10
|
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
11
|
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
12
|
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -25,6 +25,10 @@ export default class CompileImport extends BaseCommand {
|
|
|
25
25
|
'face-speaker': Flags.string({
|
|
26
26
|
description: 'For --type thread: AssemblyAI speaker label (e.g. "A") that corresponds to the face. Defaults to first detected speaker.',
|
|
27
27
|
}),
|
|
28
|
+
'no-wait': Flags.boolean({
|
|
29
|
+
description: 'Return immediately after import starts (do not poll for transcription). Prints the ID for manual polling.',
|
|
30
|
+
default: false,
|
|
31
|
+
}),
|
|
28
32
|
};
|
|
29
33
|
static args = {
|
|
30
34
|
face_id: Args.string({ description: 'Face alias', required: true }),
|
|
@@ -58,7 +62,15 @@ export default class CompileImport extends BaseCommand {
|
|
|
58
62
|
}
|
|
59
63
|
throw err;
|
|
60
64
|
}
|
|
61
|
-
// Poll until transcription completes
|
|
65
|
+
// Poll until transcription completes — unless --no-wait
|
|
66
|
+
if (data.prepare_status === 'transcribing' && flags['no-wait']) {
|
|
67
|
+
const id = (data.thread_id ?? data.document_id);
|
|
68
|
+
if (!json) {
|
|
69
|
+
process.stderr.write(`Import started in background (downloading + transcribing).\n`);
|
|
70
|
+
process.stderr.write(`Poll with: faces compile:${flags.type === 'thread' ? 'thread' : 'doc'}:get ${id} --json\n`);
|
|
71
|
+
}
|
|
72
|
+
return data;
|
|
73
|
+
}
|
|
62
74
|
if (data.prepare_status === 'transcribing') {
|
|
63
75
|
const id = (data.thread_id ?? data.document_id);
|
|
64
76
|
const endpoint = flags.type === 'thread'
|
|
@@ -2,7 +2,8 @@ import { BaseCommand } from '../../../base.js';
|
|
|
2
2
|
export default class CompileThreadEdit extends BaseCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static flags: {
|
|
5
|
-
label: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
5
|
+
label: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
'face-speaker': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
7
|
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
8
|
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
9
|
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -2,10 +2,13 @@ import { Args, Flags } from '@oclif/core';
|
|
|
2
2
|
import { BaseCommand } from '../../../base.js';
|
|
3
3
|
import { FacesAPIError } from '../../../client.js';
|
|
4
4
|
export default class CompileThreadEdit extends BaseCommand {
|
|
5
|
-
static description = 'Edit a thread (label)';
|
|
5
|
+
static description = 'Edit a thread (label and/or reassign face speaker)';
|
|
6
6
|
static flags = {
|
|
7
7
|
...BaseCommand.baseFlags,
|
|
8
|
-
label: Flags.string({ description: 'New thread label'
|
|
8
|
+
label: Flags.string({ description: 'New thread label' }),
|
|
9
|
+
'face-speaker': Flags.string({
|
|
10
|
+
description: 'Reassign face speaker: set this speaker to role=user, all others to role=assistant',
|
|
11
|
+
}),
|
|
9
12
|
};
|
|
10
13
|
static args = {
|
|
11
14
|
thread_id: Args.string({ description: 'Thread ID', required: true }),
|
|
@@ -13,16 +16,77 @@ export default class CompileThreadEdit extends BaseCommand {
|
|
|
13
16
|
async run() {
|
|
14
17
|
const { args, flags } = await this.parse(CompileThreadEdit);
|
|
15
18
|
const client = this.makeClient(flags);
|
|
19
|
+
const json = this.jsonEnabled();
|
|
20
|
+
if (!flags.label && !flags['face-speaker']) {
|
|
21
|
+
this.error('Provide at least one of --label or --face-speaker');
|
|
22
|
+
}
|
|
23
|
+
// If --face-speaker, fetch messages, remap roles, PATCH back
|
|
24
|
+
if (flags['face-speaker']) {
|
|
25
|
+
const speaker = flags['face-speaker'];
|
|
26
|
+
// Fetch current thread
|
|
27
|
+
let thread;
|
|
28
|
+
try {
|
|
29
|
+
thread = await client.get(`/v1/compile/threads/${args.thread_id}`);
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
if (err instanceof FacesAPIError)
|
|
33
|
+
this.error(`Error (${err.statusCode}): ${err.message}`);
|
|
34
|
+
throw err;
|
|
35
|
+
}
|
|
36
|
+
const messages = thread.messages;
|
|
37
|
+
if (!messages || messages.length === 0) {
|
|
38
|
+
this.error('Thread has no messages to remap');
|
|
39
|
+
}
|
|
40
|
+
// Remap roles
|
|
41
|
+
let remapped = 0;
|
|
42
|
+
const updated = messages.map((m) => {
|
|
43
|
+
const isFace = m.name && m.name.toLowerCase() === speaker.toLowerCase();
|
|
44
|
+
const newRole = isFace ? 'user' : 'assistant';
|
|
45
|
+
if (m.role !== newRole)
|
|
46
|
+
remapped++;
|
|
47
|
+
return { role: newRole, content: m.content, from: m.name };
|
|
48
|
+
});
|
|
49
|
+
// PATCH messages
|
|
50
|
+
try {
|
|
51
|
+
await client.patch(`/v1/compile/threads/${args.thread_id}/messages`, {
|
|
52
|
+
body: { messages: updated },
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
if (err instanceof FacesAPIError)
|
|
57
|
+
this.error(`Error (${err.statusCode}): ${err.message}`);
|
|
58
|
+
throw err;
|
|
59
|
+
}
|
|
60
|
+
if (!json) {
|
|
61
|
+
const userCount = updated.filter((m) => m.role === 'user').length;
|
|
62
|
+
const assistantCount = updated.filter((m) => m.role === 'assistant').length;
|
|
63
|
+
process.stderr.write(`Remapped ${remapped} messages: "${speaker}" → user (${userCount}), all others → assistant (${assistantCount})\n`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// If --label, update it
|
|
67
|
+
if (flags.label) {
|
|
68
|
+
try {
|
|
69
|
+
await client.patch(`/v1/compile/threads/${args.thread_id}`, { body: { label: flags.label } });
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
if (err instanceof FacesAPIError)
|
|
73
|
+
this.error(`Error (${err.statusCode}): ${err.message}`);
|
|
74
|
+
throw err;
|
|
75
|
+
}
|
|
76
|
+
if (!json)
|
|
77
|
+
process.stderr.write(`Label updated to "${flags.label}"\n`);
|
|
78
|
+
}
|
|
79
|
+
// Fetch final state and return
|
|
16
80
|
let data;
|
|
17
81
|
try {
|
|
18
|
-
data = await client.
|
|
82
|
+
data = await client.get(`/v1/compile/threads/${args.thread_id}`);
|
|
19
83
|
}
|
|
20
84
|
catch (err) {
|
|
21
85
|
if (err instanceof FacesAPIError)
|
|
22
86
|
this.error(`Error (${err.statusCode}): ${err.message}`);
|
|
23
87
|
throw err;
|
|
24
88
|
}
|
|
25
|
-
if (!
|
|
89
|
+
if (!json)
|
|
26
90
|
this.printHuman(data);
|
|
27
91
|
return data;
|
|
28
92
|
}
|
|
@@ -3,6 +3,7 @@ export default class CompileThreadMake extends BaseCommand {
|
|
|
3
3
|
static description: string;
|
|
4
4
|
static flags: {
|
|
5
5
|
timeout: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
'no-wait': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
6
7
|
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
8
|
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
9
|
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -7,6 +7,10 @@ export default class CompileThreadMake extends BaseCommand {
|
|
|
7
7
|
static flags = {
|
|
8
8
|
...BaseCommand.baseFlags,
|
|
9
9
|
timeout: Flags.integer({ description: 'Compile timeout in seconds (default: 600)', default: 600 }),
|
|
10
|
+
'no-wait': Flags.boolean({
|
|
11
|
+
description: 'Return immediately after triggering compilation. Prints the thread ID for manual polling.',
|
|
12
|
+
default: false,
|
|
13
|
+
}),
|
|
10
14
|
};
|
|
11
15
|
static args = {
|
|
12
16
|
thread_id: Args.string({ description: 'Thread ID', required: true }),
|
|
@@ -25,6 +29,13 @@ export default class CompileThreadMake extends BaseCommand {
|
|
|
25
29
|
throw err;
|
|
26
30
|
}
|
|
27
31
|
const chunksTotal = makeResponse.chunks_total;
|
|
32
|
+
if (flags['no-wait']) {
|
|
33
|
+
if (!json) {
|
|
34
|
+
process.stderr.write(`Compilation started in background${chunksTotal ? ` (${chunksTotal} chunks)` : ''}.\n`);
|
|
35
|
+
process.stderr.write(`Poll with: faces compile:thread:get ${args.thread_id} --json\n`);
|
|
36
|
+
}
|
|
37
|
+
return makeResponse;
|
|
38
|
+
}
|
|
28
39
|
if (!json)
|
|
29
40
|
process.stderr.write(`Compiling${chunksTotal ? ` (${chunksTotal} chunks)` : ''}:\n`);
|
|
30
41
|
let result;
|
|
@@ -6,6 +6,7 @@ export default class CompileUpload extends BaseCommand {
|
|
|
6
6
|
kind: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
7
|
perspective: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
8
|
'face-speaker': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
'no-wait': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
10
|
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
11
|
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
12
|
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -24,6 +24,10 @@ export default class CompileUpload extends BaseCommand {
|
|
|
24
24
|
'face-speaker': Flags.string({
|
|
25
25
|
description: 'Speaker name to map to the face (thread only). If omitted, auto-detected from face name.',
|
|
26
26
|
}),
|
|
27
|
+
'no-wait': Flags.boolean({
|
|
28
|
+
description: 'Return immediately after upload (do not poll for transcription). Prints the ID for manual polling.',
|
|
29
|
+
default: false,
|
|
30
|
+
}),
|
|
27
31
|
};
|
|
28
32
|
static args = {
|
|
29
33
|
alias: Args.string({ description: 'Face alias', required: true }),
|
|
@@ -52,7 +56,15 @@ export default class CompileUpload extends BaseCommand {
|
|
|
52
56
|
this.error(`Error (${err.statusCode}): ${err.message}`);
|
|
53
57
|
throw err;
|
|
54
58
|
}
|
|
55
|
-
// If transcribing (audio/video upload), poll until complete
|
|
59
|
+
// If transcribing (audio/video upload), poll until complete — unless --no-wait
|
|
60
|
+
if (data.prepare_status === 'transcribing' && flags['no-wait']) {
|
|
61
|
+
const id = (data.thread_id ?? data.document_id);
|
|
62
|
+
if (!json) {
|
|
63
|
+
process.stderr.write(`Transcription started in background.\n`);
|
|
64
|
+
process.stderr.write(`Poll with: faces compile:${flags.kind === 'thread' ? 'thread' : 'doc'}:get ${id} --json\n`);
|
|
65
|
+
}
|
|
66
|
+
return data;
|
|
67
|
+
}
|
|
56
68
|
if (data.prepare_status === 'transcribing') {
|
|
57
69
|
const id = (data.thread_id ?? data.document_id);
|
|
58
70
|
const endpoint = flags.kind === 'thread'
|