Repository navigation
Expand file tree
/
Copy pathsetup.ts
More file actions
48 lines (44 loc) · 1.72 KB
/
Copy pathsetup.ts
File metadata and controls
48 lines (44 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { Command } from "commander";
import { createCredentialStore } from "../auth/credentials.js";
import { createInferenceCredentialStore } from "../inference/credentials.js";
import {
setupInference,
type InferenceSetupResult,
} from "../inference/service.js";
import { formatOutput } from "../output.js";
export interface SetupCommandDependencies {
setup(replace: boolean): Promise<InferenceSetupResult>;
output(message: string): void;
}
export function createSetupCommandDependencies(): SetupCommandDependencies {
const authStore = createCredentialStore();
const inferenceStore = createInferenceCredentialStore();
return {
setup: (replace) => setupInference({ authStore, inferenceStore, replace }),
output: (message) => process.stdout.write(`${message}\n`),
};
}
export function addSetupCommand(
program: Command,
dependencies: SetupCommandDependencies,
): void {
program
.command("setup")
.description("Prepare private inference access for CLI probes and replay.")
.option("--replace", "Replace stored inference access.")
.action(async function (this: Command, options: { replace?: boolean }) {
const result = await dependencies.setup(options.replace === true);
dependencies.output(
formatOutput(
this,
{ ready: true, status: result.status },
[result.status === "created"
? "Private CLI inference access is ready."
: result.status === "replaced"
? "Private CLI inference access replaced."
: "Private CLI inference access is already ready.",
"To connect your application, install skills with `understudy skills install` and ask your agent to use setup-understudy."],
),
);
});
}