@vellumai/assistant 0.10.7-dev.202607101106.c87f4e3 → 0.10.7-dev.202607101343.e727d4c
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/package.json +1 -1
- package/src/agent/loop-exclusive-tool.test.ts +28 -5
- package/src/agent/loop.ts +4 -14
- package/src/cli/commands/attachment.help.ts +100 -0
- package/src/cli/commands/attachment.ts +92 -157
- package/src/cli/commands/audit.help.ts +40 -0
- package/src/cli/commands/audit.ts +66 -86
- package/src/cli/commands/auth.help.ts +46 -0
- package/src/cli/commands/auth.ts +10 -43
- package/src/cli/index.help.ts +23 -0
- package/src/cli/lib/__tests__/install-from-github.test.ts +36 -4
- package/src/cli/lib/cli-command-help.ts +80 -0
- package/src/cli/lib/install-from-github.ts +42 -1
- package/src/daemon/conversation.ts +21 -4
- package/src/plugin-api/index.ts +14 -0
- package/src/plugins/defaults/memory/v2/__tests__/cli-command-store.test.ts +6 -0
- package/src/plugins/defaults/memory/v2/cli-command-content.ts +52 -0
- package/src/plugins/defaults/memory/v2/cli-command-store.ts +31 -10
- package/src/telemetry/turn-trace-store.test.ts +12 -24
- package/src/telemetry/turn-trace-store.ts +5 -11
- package/src/tts/synthesize-text.ts +15 -5
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { Command } from "commander";
|
|
2
2
|
|
|
3
3
|
import { cliIpcCall, exitFromIpcResult } from "../../ipc/cli-client.js";
|
|
4
|
+
import { applyCommandHelp } from "../lib/cli-command-help.js";
|
|
4
5
|
import { registerCommand } from "../lib/register-command.js";
|
|
5
6
|
import { log } from "../logger.js";
|
|
7
|
+
import { auditHelp } from "./audit.help.js";
|
|
6
8
|
|
|
7
9
|
interface ToolInvocationRow {
|
|
8
10
|
toolName: string;
|
|
@@ -15,100 +17,78 @@ interface ToolInvocationRow {
|
|
|
15
17
|
|
|
16
18
|
export function registerAuditCommand(program: Command): void {
|
|
17
19
|
registerCommand(program, {
|
|
18
|
-
name:
|
|
20
|
+
name: auditHelp.name,
|
|
19
21
|
transport: "ipc",
|
|
20
|
-
description:
|
|
22
|
+
description: auditHelp.description,
|
|
21
23
|
build: (audit) => {
|
|
22
|
-
audit
|
|
23
|
-
|
|
24
|
-
.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
Tool Tool name (e.g. bash, read_file, write_file, browser)
|
|
35
|
-
Input Truncated summary of the tool input (command, path, etc.)
|
|
36
|
-
Decision Approval decision: allow, deny, or ask
|
|
37
|
-
Risk Risk classification: none, low, medium, high
|
|
38
|
-
Duration Wall-clock execution time (e.g. 120ms, 1.3s)
|
|
24
|
+
applyCommandHelp(audit, auditHelp);
|
|
25
|
+
audit.action(async (opts: { limit: string; json?: boolean }) => {
|
|
26
|
+
const limit = parseInt(opts.limit, 10) || 20;
|
|
27
|
+
const response = await cliIpcCall<{
|
|
28
|
+
invocations: ToolInvocationRow[];
|
|
29
|
+
}>("audit_list", {
|
|
30
|
+
queryParams: { limit: String(limit) },
|
|
31
|
+
});
|
|
32
|
+
if (!response.ok) {
|
|
33
|
+
return exitFromIpcResult(response);
|
|
34
|
+
}
|
|
35
|
+
const rows = response.result!.invocations;
|
|
39
36
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
)
|
|
45
|
-
.action(async (opts: { limit: string; json?: boolean }) => {
|
|
46
|
-
const limit = parseInt(opts.limit, 10) || 20;
|
|
47
|
-
const response = await cliIpcCall<{
|
|
48
|
-
invocations: ToolInvocationRow[];
|
|
49
|
-
}>("audit_list", {
|
|
50
|
-
queryParams: { limit: String(limit) },
|
|
51
|
-
});
|
|
52
|
-
if (!response.ok) {
|
|
53
|
-
return exitFromIpcResult(response);
|
|
54
|
-
}
|
|
55
|
-
const rows = response.result!.invocations;
|
|
37
|
+
if (opts.json) {
|
|
38
|
+
console.log(JSON.stringify(rows, null, 2));
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
56
41
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
42
|
+
if (rows.length === 0) {
|
|
43
|
+
log.info("No tool invocations recorded");
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const tsW = 20;
|
|
47
|
+
const toolW = 14;
|
|
48
|
+
const inputW = 30;
|
|
49
|
+
const decW = 8;
|
|
50
|
+
const riskW = 8;
|
|
51
|
+
const durW = 8;
|
|
52
|
+
log.info(
|
|
53
|
+
"Timestamp".padEnd(tsW) +
|
|
54
|
+
"Tool".padEnd(toolW) +
|
|
55
|
+
"Input".padEnd(inputW) +
|
|
56
|
+
"Decision".padEnd(decW) +
|
|
57
|
+
"Risk".padEnd(riskW) +
|
|
58
|
+
"Duration",
|
|
59
|
+
);
|
|
60
|
+
log.info("-".repeat(tsW + toolW + inputW + decW + riskW + durW));
|
|
61
|
+
for (const r of rows) {
|
|
62
|
+
const ts = new Date(r.createdAt)
|
|
63
|
+
.toISOString()
|
|
64
|
+
.slice(0, 19)
|
|
65
|
+
.replace("T", " ");
|
|
66
|
+
let inputSummary = "";
|
|
67
|
+
try {
|
|
68
|
+
const parsed = JSON.parse(r.input);
|
|
69
|
+
if (parsed.command) inputSummary = parsed.command;
|
|
70
|
+
else if (parsed.path) inputSummary = parsed.path;
|
|
71
|
+
else inputSummary = r.input;
|
|
72
|
+
} catch {
|
|
73
|
+
inputSummary = r.input;
|
|
60
74
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
log.info("No tool invocations recorded");
|
|
64
|
-
return;
|
|
75
|
+
if (inputSummary.length > inputW - 2) {
|
|
76
|
+
inputSummary = inputSummary.slice(0, inputW - 4) + "..";
|
|
65
77
|
}
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const riskW = 8;
|
|
71
|
-
const durW = 8;
|
|
78
|
+
const dur =
|
|
79
|
+
r.durationMs < 1000
|
|
80
|
+
? `${r.durationMs}ms`
|
|
81
|
+
: `${(r.durationMs / 1000).toFixed(1)}s`;
|
|
72
82
|
log.info(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
83
|
+
ts.padEnd(tsW) +
|
|
84
|
+
r.toolName.padEnd(toolW) +
|
|
85
|
+
inputSummary.padEnd(inputW) +
|
|
86
|
+
r.decision.padEnd(decW) +
|
|
87
|
+
r.riskLevel.padEnd(riskW) +
|
|
88
|
+
dur,
|
|
79
89
|
);
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const ts = new Date(r.createdAt)
|
|
83
|
-
.toISOString()
|
|
84
|
-
.slice(0, 19)
|
|
85
|
-
.replace("T", " ");
|
|
86
|
-
let inputSummary = "";
|
|
87
|
-
try {
|
|
88
|
-
const parsed = JSON.parse(r.input);
|
|
89
|
-
if (parsed.command) inputSummary = parsed.command;
|
|
90
|
-
else if (parsed.path) inputSummary = parsed.path;
|
|
91
|
-
else inputSummary = r.input;
|
|
92
|
-
} catch {
|
|
93
|
-
inputSummary = r.input;
|
|
94
|
-
}
|
|
95
|
-
if (inputSummary.length > inputW - 2) {
|
|
96
|
-
inputSummary = inputSummary.slice(0, inputW - 4) + "..";
|
|
97
|
-
}
|
|
98
|
-
const dur =
|
|
99
|
-
r.durationMs < 1000
|
|
100
|
-
? `${r.durationMs}ms`
|
|
101
|
-
: `${(r.durationMs / 1000).toFixed(1)}s`;
|
|
102
|
-
log.info(
|
|
103
|
-
ts.padEnd(tsW) +
|
|
104
|
-
r.toolName.padEnd(toolW) +
|
|
105
|
-
inputSummary.padEnd(inputW) +
|
|
106
|
-
r.decision.padEnd(decW) +
|
|
107
|
-
r.riskLevel.padEnd(riskW) +
|
|
108
|
-
dur,
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
});
|
|
90
|
+
}
|
|
91
|
+
});
|
|
112
92
|
},
|
|
113
93
|
});
|
|
114
94
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Declarative help for the `assistant auth` command.
|
|
3
|
+
*
|
|
4
|
+
* Plain data (no action handlers, imports only the help contract type) so the
|
|
5
|
+
* memory capability indexer can read it without pulling in the daemon/IPC action
|
|
6
|
+
* graph. The handlers live in `auth.ts`, which applies this via `applyCommandHelp`
|
|
7
|
+
* and attaches them.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { CliCommandHelp } from "../lib/cli-command-help.js";
|
|
11
|
+
|
|
12
|
+
export const authHelp: CliCommandHelp = {
|
|
13
|
+
name: "auth",
|
|
14
|
+
description: "Manage platform authentication and identity",
|
|
15
|
+
options: [
|
|
16
|
+
{ flags: "--json", description: "Machine-readable compact JSON output" },
|
|
17
|
+
],
|
|
18
|
+
helpText: `
|
|
19
|
+
The auth namespace manages the assistant's authentication state with the
|
|
20
|
+
Vellum platform. It provides commands to inspect identity and connection
|
|
21
|
+
status, helping diagnose configuration issues.
|
|
22
|
+
|
|
23
|
+
Examples:
|
|
24
|
+
$ assistant auth info
|
|
25
|
+
$ assistant auth info --json`,
|
|
26
|
+
subcommands: [
|
|
27
|
+
{
|
|
28
|
+
name: "info",
|
|
29
|
+
description: "Show platform identity and authentication status",
|
|
30
|
+
helpText: `
|
|
31
|
+
Fields:
|
|
32
|
+
platformUrl The Vellum platform base URL this assistant connects to
|
|
33
|
+
assistantId This assistant's platform UUID
|
|
34
|
+
organizationId The organization this assistant belongs to (from PLATFORM_ORGANIZATION_ID)
|
|
35
|
+
userId The user who owns this assistant (from PLATFORM_USER_ID)
|
|
36
|
+
authenticated Whether all prerequisites for platform authentication are met
|
|
37
|
+
(platform URL and assistant API key both present)
|
|
38
|
+
|
|
39
|
+
When not authenticated, a message field provides guidance on next steps.
|
|
40
|
+
|
|
41
|
+
Examples:
|
|
42
|
+
$ assistant auth info
|
|
43
|
+
$ assistant auth info --json`,
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
};
|
package/src/cli/commands/auth.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { Command } from "commander";
|
|
2
2
|
|
|
3
3
|
import { cliIpcCall, exitFromIpcResult } from "../../ipc/cli-client.js";
|
|
4
|
+
import { applyCommandHelp, subcommand } from "../lib/cli-command-help.js";
|
|
4
5
|
import { registerCommand } from "../lib/register-command.js";
|
|
5
6
|
import { log } from "../logger.js";
|
|
6
7
|
import { shouldOutputJson, writeOutput } from "../output.js";
|
|
8
|
+
import { authHelp } from "./auth.help.js";
|
|
7
9
|
|
|
8
10
|
interface AuthInfoResponse {
|
|
9
11
|
platformUrl: string | null;
|
|
@@ -16,51 +18,15 @@ interface AuthInfoResponse {
|
|
|
16
18
|
|
|
17
19
|
export function registerAuthCommand(program: Command): void {
|
|
18
20
|
registerCommand(program, {
|
|
19
|
-
name:
|
|
21
|
+
name: authHelp.name,
|
|
20
22
|
transport: "ipc",
|
|
21
|
-
description:
|
|
23
|
+
description: authHelp.description,
|
|
22
24
|
build: (auth) => {
|
|
23
|
-
auth
|
|
25
|
+
applyCommandHelp(auth, authHelp);
|
|
24
26
|
|
|
25
|
-
auth.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
The auth namespace manages the assistant's authentication state with the
|
|
29
|
-
Vellum platform. It provides commands to inspect identity and connection
|
|
30
|
-
status, helping diagnose configuration issues.
|
|
31
|
-
|
|
32
|
-
Examples:
|
|
33
|
-
$ assistant auth info
|
|
34
|
-
$ assistant auth info --json`,
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
// -----------------------------------------------------------------------
|
|
38
|
-
// info
|
|
39
|
-
// -----------------------------------------------------------------------
|
|
40
|
-
|
|
41
|
-
auth
|
|
42
|
-
.command("info")
|
|
43
|
-
.description("Show platform identity and authentication status")
|
|
44
|
-
.addHelpText(
|
|
45
|
-
"after",
|
|
46
|
-
`
|
|
47
|
-
Fields:
|
|
48
|
-
platformUrl The Vellum platform base URL this assistant connects to
|
|
49
|
-
assistantId This assistant's platform UUID
|
|
50
|
-
organizationId The organization this assistant belongs to (from PLATFORM_ORGANIZATION_ID)
|
|
51
|
-
userId The user who owns this assistant (from PLATFORM_USER_ID)
|
|
52
|
-
authenticated Whether all prerequisites for platform authentication are met
|
|
53
|
-
(platform URL and assistant API key both present)
|
|
54
|
-
|
|
55
|
-
When not authenticated, a message field provides guidance on next steps.
|
|
56
|
-
|
|
57
|
-
Examples:
|
|
58
|
-
$ assistant auth info
|
|
59
|
-
$ assistant auth info --json`,
|
|
60
|
-
)
|
|
61
|
-
.action(async (_opts: Record<string, unknown>, cmd: Command) => {
|
|
62
|
-
const response =
|
|
63
|
-
await cliIpcCall<AuthInfoResponse>("auth_info");
|
|
27
|
+
subcommand(auth, "info").action(
|
|
28
|
+
async (_opts: Record<string, unknown>, cmd: Command) => {
|
|
29
|
+
const response = await cliIpcCall<AuthInfoResponse>("auth_info");
|
|
64
30
|
|
|
65
31
|
if (!response.ok) {
|
|
66
32
|
return exitFromIpcResult(response);
|
|
@@ -89,7 +55,8 @@ Examples:
|
|
|
89
55
|
log.info(result.message);
|
|
90
56
|
}
|
|
91
57
|
}
|
|
92
|
-
}
|
|
58
|
+
},
|
|
59
|
+
);
|
|
93
60
|
},
|
|
94
61
|
});
|
|
95
62
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Aggregated declarative help for the top-level `assistant` CLI commands that
|
|
3
|
+
* have adopted the static-help split (`<command>.help.ts`).
|
|
4
|
+
*
|
|
5
|
+
* Plugins — notably the memory capability indexer — import this to read command
|
|
6
|
+
* help without importing `cli/program.ts`, which pulls every command's action
|
|
7
|
+
* handler (and its daemon/IPC deps) into the import graph. Entries are pure data
|
|
8
|
+
* (see {@link ./lib/cli-command-help.CliCommandHelp}); consumers iterate them.
|
|
9
|
+
*
|
|
10
|
+
* Extend this as commands adopt the split. Once every command is listed here,
|
|
11
|
+
* the memory indexer no longer needs `buildCliProgramTree()`.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { attachmentHelp } from "./commands/attachment.help.js";
|
|
15
|
+
import { auditHelp } from "./commands/audit.help.js";
|
|
16
|
+
import { authHelp } from "./commands/auth.help.js";
|
|
17
|
+
import type { CliCommandHelp } from "./lib/cli-command-help.js";
|
|
18
|
+
|
|
19
|
+
export const CLI_COMMAND_HELP: readonly CliCommandHelp[] = [
|
|
20
|
+
attachmentHelp,
|
|
21
|
+
auditHelp,
|
|
22
|
+
authHelp,
|
|
23
|
+
];
|
|
@@ -78,14 +78,14 @@ function makeContentsFetch(opts: {
|
|
|
78
78
|
const prefix = apiPath ? `${apiPath}/` : "";
|
|
79
79
|
const direct = new Map<string, boolean>();
|
|
80
80
|
for (const key of Object.keys(tree)) {
|
|
81
|
-
if (!key.startsWith(prefix)) continue;
|
|
81
|
+
if (!key.startsWith(prefix)) {continue;}
|
|
82
82
|
const remainder = key.slice(prefix.length);
|
|
83
|
-
if (!remainder) continue;
|
|
83
|
+
if (!remainder) {continue;}
|
|
84
84
|
const seg = remainder.split("/")[0]!;
|
|
85
85
|
const isDir = remainder.includes("/") || tree[`${prefix}${seg}`] === null;
|
|
86
86
|
direct.set(seg, (direct.get(seg) ?? false) || isDir);
|
|
87
87
|
}
|
|
88
|
-
if (direct.size === 0) return null;
|
|
88
|
+
if (direct.size === 0) {return null;}
|
|
89
89
|
return Array.from(direct.entries()).map(([name, isDir]) => {
|
|
90
90
|
const path = `${prefix}${name}`;
|
|
91
91
|
return isDir
|
|
@@ -157,7 +157,7 @@ function fakeGitRunner(opts: {
|
|
|
157
157
|
opts.calls?.push([...args]);
|
|
158
158
|
switch (args[0]) {
|
|
159
159
|
case "fetch": {
|
|
160
|
-
if (opts.fetchError) throw opts.fetchError;
|
|
160
|
+
if (opts.fetchError) {throw opts.fetchError;}
|
|
161
161
|
mkdirSync(join(cwd, ".git"), { recursive: true });
|
|
162
162
|
writeFileSync(join(cwd, ".git", "config"), "[core]\n");
|
|
163
163
|
for (const [rel, content] of Object.entries(opts.tree)) {
|
|
@@ -1097,6 +1097,38 @@ describe("installPlugin — direct (untrusted) install", () => {
|
|
|
1097
1097
|
).rejects.toBeInstanceOf(PluginSourceUnavailableError);
|
|
1098
1098
|
expect(readdirSync(pluginsDir)).toEqual([]);
|
|
1099
1099
|
});
|
|
1100
|
+
|
|
1101
|
+
test("synthesizes a minimal package.json when the upstream repo ships none", async () => {
|
|
1102
|
+
// GIVEN a plugin tree with no package.json at all
|
|
1103
|
+
const fetch = makeContentsFetch({ tree: {} });
|
|
1104
|
+
const runGit = fakeGitRunner({
|
|
1105
|
+
tree: { "hooks/init.ts": "//", "README.md": "# bare" },
|
|
1106
|
+
commit: "f".repeat(40),
|
|
1107
|
+
});
|
|
1108
|
+
|
|
1109
|
+
// WHEN we install directly
|
|
1110
|
+
await installPlugin(
|
|
1111
|
+
{
|
|
1112
|
+
name: "bare-plugin",
|
|
1113
|
+
directSource: {
|
|
1114
|
+
owner: "owner",
|
|
1115
|
+
repo: "bare",
|
|
1116
|
+
rootPath: "",
|
|
1117
|
+
ref: "HEAD",
|
|
1118
|
+
},
|
|
1119
|
+
},
|
|
1120
|
+
{ fetch, runGit, workspacePluginsDir: pluginsDir },
|
|
1121
|
+
);
|
|
1122
|
+
|
|
1123
|
+
// THEN a minimal package.json is synthesized with the install name and
|
|
1124
|
+
// the default plugin-api peer dependency range
|
|
1125
|
+
const pkgPath = join(pluginsDir, "bare-plugin", "package.json");
|
|
1126
|
+
expect(existsSync(pkgPath)).toBe(true);
|
|
1127
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
1128
|
+
expect(pkg.name).toBe("bare-plugin");
|
|
1129
|
+
expect(pkg.version).toBe("0.0.0");
|
|
1130
|
+
expect(pkg.peerDependencies["@vellumai/plugin-api"]).toBeDefined();
|
|
1131
|
+
});
|
|
1100
1132
|
});
|
|
1101
1133
|
|
|
1102
1134
|
describe("sanitizePluginName", () => {
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Fully declarative description of a top-level `assistant` CLI command and its
|
|
5
|
+
* subcommands. Plain data by design — no action handlers — so plugins (e.g. the
|
|
6
|
+
* memory capability indexer) can import a command's help and iterate over it
|
|
7
|
+
* without dragging in the CLI's daemon/IPC action graph. Command modules apply
|
|
8
|
+
* the same data via {@link applyCommandHelp}, then attach their handlers.
|
|
9
|
+
*/
|
|
10
|
+
export interface CliCommandHelp {
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
/** Options declared directly on the top-level command. */
|
|
14
|
+
options?: CliOptionHelp[];
|
|
15
|
+
/** Extra help appended after the option list (`addHelpText("after", …)`). */
|
|
16
|
+
helpText?: string;
|
|
17
|
+
subcommands?: CliSubcommandHelp[];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface CliSubcommandHelp {
|
|
21
|
+
name: string;
|
|
22
|
+
description: string;
|
|
23
|
+
options?: CliOptionHelp[];
|
|
24
|
+
/** Extra help appended after the option list (`addHelpText("after", …)`). */
|
|
25
|
+
helpText?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface CliOptionHelp {
|
|
29
|
+
/** Commander flag spec, e.g. `"--path <file>"` or `"-l, --limit <n>"`. */
|
|
30
|
+
flags: string;
|
|
31
|
+
description: string;
|
|
32
|
+
/** When true, applied via `requiredOption` (missing → error) rather than `option`. */
|
|
33
|
+
required?: boolean;
|
|
34
|
+
/** Default value passed to `option(flags, description, defaultValue)`. */
|
|
35
|
+
defaultValue?: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function applyOptions(command: Command, options?: CliOptionHelp[]): void {
|
|
39
|
+
for (const option of options ?? []) {
|
|
40
|
+
if (option.required) {
|
|
41
|
+
command.requiredOption(option.flags, option.description);
|
|
42
|
+
} else if (option.defaultValue !== undefined) {
|
|
43
|
+
command.option(option.flags, option.description, option.defaultValue);
|
|
44
|
+
} else {
|
|
45
|
+
command.option(option.flags, option.description);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Configure a Commander command from its declarative {@link CliCommandHelp}:
|
|
52
|
+
* top-level options, appended help text, and subcommands (with their options).
|
|
53
|
+
* Does not set the top-level name/description — `registerCommand` owns those —
|
|
54
|
+
* and does not attach action handlers; the command module attaches those to the
|
|
55
|
+
* command or its subcommands.
|
|
56
|
+
*/
|
|
57
|
+
export function applyCommandHelp(command: Command, help: CliCommandHelp): void {
|
|
58
|
+
applyOptions(command, help.options);
|
|
59
|
+
if (help.helpText) {
|
|
60
|
+
command.addHelpText("after", help.helpText);
|
|
61
|
+
}
|
|
62
|
+
for (const sub of help.subcommands ?? []) {
|
|
63
|
+
const child = command.command(sub.name).description(sub.description);
|
|
64
|
+
applyOptions(child, sub.options);
|
|
65
|
+
if (sub.helpText) {
|
|
66
|
+
child.addHelpText("after", sub.helpText);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Return a subcommand by name, throwing if absent. */
|
|
72
|
+
export function subcommand(parent: Command, name: string): Command {
|
|
73
|
+
const found = parent.commands.find((c) => c.name() === name);
|
|
74
|
+
if (!found) {
|
|
75
|
+
throw new Error(
|
|
76
|
+
`Subcommand "${name}" not found on "${parent.name()}" — is it declared in the command's .help module?`,
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
return found;
|
|
80
|
+
}
|
|
@@ -714,10 +714,23 @@ export async function materializePluginTree(
|
|
|
714
714
|
// An external clone is often a foreign-ecosystem plugin (e.g. a Claude Code
|
|
715
715
|
// plugin) that the Vellum loader can't run as-is. When we curate an adapter
|
|
716
716
|
// stub for it, overlay the stub and run its transform so the materialized
|
|
717
|
-
// tree is a valid Vellum plugin. Raw clones (no stub) are left untouched
|
|
717
|
+
// tree is a valid Vellum plugin. Raw clones (no stub) are left untouched,
|
|
718
|
+
// except for a minimal package.json synthesis when the upstream repo shipped
|
|
719
|
+
// none — the Vellum loader hard-requires one and would silently skip the
|
|
720
|
+
// plugin without it. The synthesis runs only for direct installs
|
|
721
|
+
// (stubRef === null); the upgrade path re-materializes baselines through
|
|
722
|
+
// this function with a non-null stubRef, and synthesizing a package.json
|
|
723
|
+
// not present at install time would corrupt the fingerprint comparison.
|
|
718
724
|
if (cloned.fileCount > 0 && opts.stubRef !== null) {
|
|
719
725
|
await applyAdapterStub(opts.name, opts.stubRef, opts.destDir, deps);
|
|
720
726
|
}
|
|
727
|
+
if (
|
|
728
|
+
cloned.fileCount > 0 &&
|
|
729
|
+
opts.stubRef === null &&
|
|
730
|
+
!existsSync(join(opts.destDir, "package.json"))
|
|
731
|
+
) {
|
|
732
|
+
synthesizeMinimalPackageJson(opts.name, opts.destDir);
|
|
733
|
+
}
|
|
721
734
|
return cloned;
|
|
722
735
|
}
|
|
723
736
|
|
|
@@ -974,6 +987,34 @@ function normalizeInstalledManifest(
|
|
|
974
987
|
writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`, "utf8");
|
|
975
988
|
}
|
|
976
989
|
|
|
990
|
+
/**
|
|
991
|
+
* Write a minimal Vellum-compatible `package.json` into a staged plugin that
|
|
992
|
+
* shipped no manifest of its own. The Vellum external plugin loader
|
|
993
|
+
* (`buildPluginFromDir`) hard-requires a `package.json` validated against
|
|
994
|
+
* `PluginPackageJsonSchema` and silently skips the plugin when it's missing.
|
|
995
|
+
*
|
|
996
|
+
* The synthesized manifest carries the install name and the default
|
|
997
|
+
* `@vellumai/plugin-api` peer dependency range. No foreign-ecosystem manifest
|
|
998
|
+
* data is read — the install name is the only identity we trust for an
|
|
999
|
+
* untrusted direct install.
|
|
1000
|
+
*/
|
|
1001
|
+
function synthesizeMinimalPackageJson(
|
|
1002
|
+
name: string,
|
|
1003
|
+
stagingDir: string,
|
|
1004
|
+
): void {
|
|
1005
|
+
const manifestPath = join(stagingDir, "package.json");
|
|
1006
|
+
|
|
1007
|
+
const manifest: PackageManifest = {
|
|
1008
|
+
name,
|
|
1009
|
+
version: "0.0.0",
|
|
1010
|
+
peerDependencies: {
|
|
1011
|
+
"@vellumai/plugin-api": PLUGIN_API_PEER_RANGE,
|
|
1012
|
+
},
|
|
1013
|
+
};
|
|
1014
|
+
|
|
1015
|
+
writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`, "utf8");
|
|
1016
|
+
}
|
|
1017
|
+
|
|
977
1018
|
/**
|
|
978
1019
|
* Resolve the absolute path of the adapter script named by the (overlaid stub)
|
|
979
1020
|
* `package.json`'s `scripts.postinstall`, or `null` when there is no stub
|
|
@@ -74,7 +74,7 @@ import {
|
|
|
74
74
|
type SystemPromptPersonaOverride,
|
|
75
75
|
} from "../prompts/system-prompt.js";
|
|
76
76
|
import type { ContentBlock, Message } from "../providers/types.js";
|
|
77
|
-
import type { Provider } from "../providers/types.js";
|
|
77
|
+
import type { Provider, ToolDefinition } from "../providers/types.js";
|
|
78
78
|
import { type TrustClass } from "../runtime/actor-trust-resolver.js";
|
|
79
79
|
import { broadcastMessage } from "../runtime/assistant-event-hub.js";
|
|
80
80
|
import type { AuthContext } from "../runtime/auth/types.js";
|
|
@@ -768,9 +768,6 @@ export class Conversation {
|
|
|
768
768
|
tools: toolDefs.length > 0 ? toolDefs : undefined,
|
|
769
769
|
toolExecutor: toolDefs.length > 0 ? toolExecutor : undefined,
|
|
770
770
|
resolveTools,
|
|
771
|
-
// A tool the registry marks exclusive (e.g. `advisor`) runs alone in its
|
|
772
|
-
// turn; the loop defers any sibling calls until the next turn.
|
|
773
|
-
isExclusiveTool: (name) => getTool(name)?.exclusive === true,
|
|
774
771
|
resolveConversationDir: () => {
|
|
775
772
|
const conv = getConversation(this.conversationId);
|
|
776
773
|
if (!conv) {
|
|
@@ -2379,6 +2376,26 @@ export class Conversation {
|
|
|
2379
2376
|
return new Set(this.lastResolvedToolNames ?? this.coreToolNames);
|
|
2380
2377
|
}
|
|
2381
2378
|
|
|
2379
|
+
/**
|
|
2380
|
+
* The {@link getRegisteredToolNames} inventory resolved to full definitions
|
|
2381
|
+
* (name, description, input schema), sorted by name. Resolution reads the
|
|
2382
|
+
* live registry so skill/MCP tools — whose definitions are not in the base
|
|
2383
|
+
* turn snapshot — are included. Consumers (e.g. turn-trace telemetry) read
|
|
2384
|
+
* this instead of reaching into the tool registry themselves.
|
|
2385
|
+
*/
|
|
2386
|
+
getRegisteredToolDefinitions(): ToolDefinition[] {
|
|
2387
|
+
return Array.from(this.getRegisteredToolNames())
|
|
2388
|
+
.sort((a, b) => a.localeCompare(b))
|
|
2389
|
+
.map((name) => {
|
|
2390
|
+
const tool = getTool(name);
|
|
2391
|
+
return {
|
|
2392
|
+
name,
|
|
2393
|
+
description: tool?.description ?? "",
|
|
2394
|
+
input_schema: tool?.input_schema ?? {},
|
|
2395
|
+
};
|
|
2396
|
+
});
|
|
2397
|
+
}
|
|
2398
|
+
|
|
2382
2399
|
// ── History ──────────────────────────────────────────────────────
|
|
2383
2400
|
|
|
2384
2401
|
getMessages(): Message[] {
|
package/src/plugin-api/index.ts
CHANGED
|
@@ -180,6 +180,11 @@ export {
|
|
|
180
180
|
getAssistantName,
|
|
181
181
|
resolveUserName,
|
|
182
182
|
} from "../daemon/identity-helpers.js";
|
|
183
|
+
// Declarative help for the top-level `assistant` CLI commands that have adopted
|
|
184
|
+
// the static-help split. Plugins (e.g. the memory capability indexer) read this
|
|
185
|
+
// to embed CLI command capabilities without importing the CLI action graph.
|
|
186
|
+
// Pure data — iterate the fields directly.
|
|
187
|
+
export { CLI_COMMAND_HELP } from "../cli/index.help.js";
|
|
183
188
|
// Embeddings — self-contained operations on the host's shared embedding /
|
|
184
189
|
// vector-store subsystem. Host-resolved: each reads the live workspace config
|
|
185
190
|
// internally, so plugins hold no config. Async because the facade loads the
|
|
@@ -230,3 +235,12 @@ export {
|
|
|
230
235
|
syncMessageToDisk,
|
|
231
236
|
updateMessageMetadata,
|
|
232
237
|
} from "../persistence/conversation-plugin-facade.js";
|
|
238
|
+
// Synthesize text to speech through the assistant's globally configured TTS
|
|
239
|
+
// provider (ElevenLabs, Fish Audio, etc.). Plugins that need voice output —
|
|
240
|
+
// e.g. a meeting bot speaking into a live call — use this instead of managing
|
|
241
|
+
// TTS credentials and provider config themselves. Returns a Buffer + MIME type.
|
|
242
|
+
// Text is sanitized internally (markdown/URLs/emoji stripped) so callers can
|
|
243
|
+
// pass raw model output directly.
|
|
244
|
+
export type { SynthesizeTextOptions } from "../tts/synthesize-text.js";
|
|
245
|
+
export { synthesizeText, TtsSynthesisError } from "../tts/synthesize-text.js";
|
|
246
|
+
export type { TtsSynthesisResult } from "../tts/types.js";
|
|
@@ -109,6 +109,12 @@ mock.module("../../../../../cli/program.js", () => ({
|
|
|
109
109
|
},
|
|
110
110
|
}));
|
|
111
111
|
|
|
112
|
+
// Keep the suite driven entirely by the mocked program tree above: no commands
|
|
113
|
+
// are sourced from the declarative `cli/index.help.ts` aggregate.
|
|
114
|
+
mock.module("../../../../../cli/index.help.js", () => ({
|
|
115
|
+
CLI_COMMAND_HELP: [],
|
|
116
|
+
}));
|
|
117
|
+
|
|
112
118
|
mock.module(
|
|
113
119
|
"../../../../../persistence/embeddings/embedding-backend.js",
|
|
114
120
|
() => ({
|