@vellumai/assistant 0.10.8-dev.202607141817.ebca77a â 0.10.8-dev.202607141934.5251257
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/__tests__/list-all-apps.test.ts +9 -9
- package/src/__tests__/messaging-send-tool.test.ts +67 -0
- package/src/__tests__/outlook-messaging-provider.test.ts +71 -0
- package/src/apps/app-store.ts +19 -12
- package/src/cli/AGENTS.md +17 -0
- package/src/cli/commands/routes.ts +5 -3
- package/src/cli/commands/status.help.ts +24 -0
- package/src/cli/commands/status.ts +29 -0
- package/src/cli/lib/__tests__/global-json-option.test.ts +97 -0
- package/src/cli/lib/bundled-marketplace.json +5 -5
- package/src/cli/lib/global-json-option.ts +41 -0
- package/src/cli/program.ts +5 -0
- package/src/config/bundled-skills/messaging/TOOLS.json +2 -2
- package/src/config/bundled-skills/messaging/tools/messaging-send.ts +27 -19
- package/src/messaging/provider-types.ts +9 -0
- package/src/messaging/providers/outlook/adapter.ts +17 -2
- package/src/messaging/providers/outlook/client.ts +11 -2
- package/src/messaging/providers/outlook/types.ts +9 -0
- package/src/plugins/defaults/memory/__tests__/memory-retrospective-skill-card.test.ts +5 -5
- package/src/plugins/defaults/memory/graph/tool-handlers.ts +2 -2
- package/src/plugins/defaults/memory/memory-retrospective-skill-card.ts +10 -2
- package/src/runtime/routes/__tests__/user-routes-cli.test.ts +154 -0
- package/src/runtime/routes/user-route-dispatcher.ts +6 -86
- package/src/runtime/routes/user-route-resolution.ts +141 -0
- package/src/runtime/routes/user-routes-cli.ts +56 -35
package/package.json
CHANGED
|
@@ -93,7 +93,7 @@ describe("listAllApps", () => {
|
|
|
93
93
|
const plugin = listPluginApps();
|
|
94
94
|
expect(plugin).toHaveLength(1);
|
|
95
95
|
expect(plugin[0].origin).toEqual({ kind: "plugin", pluginName: "acme" });
|
|
96
|
-
expect(plugin[0].id).toBe("plugins
|
|
96
|
+
expect(plugin[0].id).toBe("plugins~acme~acme-dashboard");
|
|
97
97
|
expect(plugin[0].name).toBe("acme-dashboard");
|
|
98
98
|
expect(plugin[0].sourcePath).toBe(
|
|
99
99
|
join(pluginDir, "apps", "acme-dashboard"),
|
|
@@ -157,11 +157,11 @@ describe("resolveAppSource", () => {
|
|
|
157
157
|
expect(source!.formatVersion).toBe(1);
|
|
158
158
|
});
|
|
159
159
|
|
|
160
|
-
test("resolves a plugin app by its plugins
|
|
160
|
+
test("resolves a plugin app by its plugins~<name>~<app> id", () => {
|
|
161
161
|
const pluginDir = installPlugin("acme");
|
|
162
162
|
bundleApp(pluginDir, "acme-dashboard");
|
|
163
163
|
|
|
164
|
-
const source = resolveAppSource("plugins
|
|
164
|
+
const source = resolveAppSource("plugins~acme~acme-dashboard");
|
|
165
165
|
expect(source).not.toBeNull();
|
|
166
166
|
expect(source!.origin).toEqual({ kind: "plugin", pluginName: "acme" });
|
|
167
167
|
expect(source!.name).toBe("acme-dashboard");
|
|
@@ -178,7 +178,7 @@ describe("resolveAppSource", () => {
|
|
|
178
178
|
const pluginDir = installPlugin("acme", { disabled: true });
|
|
179
179
|
bundleApp(pluginDir, "acme-dashboard");
|
|
180
180
|
|
|
181
|
-
expect(resolveAppSource("plugins
|
|
181
|
+
expect(resolveAppSource("plugins~acme~acme-dashboard")).toBeNull();
|
|
182
182
|
});
|
|
183
183
|
|
|
184
184
|
test("returns null for a plugin dir without a package.json manifest", () => {
|
|
@@ -191,14 +191,14 @@ describe("resolveAppSource", () => {
|
|
|
191
191
|
);
|
|
192
192
|
mkdirSync(strayApp, { recursive: true });
|
|
193
193
|
|
|
194
|
-
expect(resolveAppSource("plugins
|
|
194
|
+
expect(resolveAppSource("plugins~not-a-plugin~x")).toBeNull();
|
|
195
195
|
});
|
|
196
196
|
|
|
197
197
|
test("returns null for traversal and malformed plugin ids", () => {
|
|
198
198
|
installPlugin("acme");
|
|
199
|
-
expect(resolveAppSource("plugins
|
|
200
|
-
expect(resolveAppSource("plugins
|
|
201
|
-
expect(resolveAppSource("plugins
|
|
202
|
-
expect(resolveAppSource("plugins
|
|
199
|
+
expect(resolveAppSource("plugins~..~secrets")).toBeNull(); // traversal name
|
|
200
|
+
expect(resolveAppSource("plugins~acme~..")).toBeNull(); // traversal app
|
|
201
|
+
expect(resolveAppSource("plugins~acme")).toBeNull(); // missing app segment
|
|
202
|
+
expect(resolveAppSource("plugins~acme~sub/dir")).toBeNull(); // slash in app
|
|
203
203
|
});
|
|
204
204
|
});
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { tmpdir } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
1
4
|
import { beforeEach, describe, expect, mock, test } from "bun:test";
|
|
2
5
|
|
|
3
6
|
import type { MessagingProvider } from "../messaging/provider.js";
|
|
@@ -129,6 +132,7 @@ describe("messaging-send tool", () => {
|
|
|
129
132
|
subject: undefined,
|
|
130
133
|
inReplyTo: undefined,
|
|
131
134
|
threadId: undefined,
|
|
135
|
+
attachments: undefined,
|
|
132
136
|
assistantId: "ast-alpha",
|
|
133
137
|
},
|
|
134
138
|
);
|
|
@@ -159,11 +163,74 @@ describe("messaging-send tool", () => {
|
|
|
159
163
|
subject: undefined,
|
|
160
164
|
inReplyTo: undefined,
|
|
161
165
|
threadId: "thread-abc",
|
|
166
|
+
attachments: undefined,
|
|
162
167
|
assistantId: "ast-alpha",
|
|
163
168
|
},
|
|
164
169
|
);
|
|
165
170
|
});
|
|
166
171
|
|
|
172
|
+
test("rejects attachments on platforms that can't carry them", async () => {
|
|
173
|
+
const result = await run(
|
|
174
|
+
{
|
|
175
|
+
platform: "phone",
|
|
176
|
+
conversation_id: "+12025550142",
|
|
177
|
+
text: "with a file",
|
|
178
|
+
attachment_paths: ["/tmp/does-not-matter.pdf"],
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
workingDir: "/tmp",
|
|
182
|
+
conversationId: "conv-1",
|
|
183
|
+
assistantId: "ast-alpha",
|
|
184
|
+
trustClass: "guardian" as const,
|
|
185
|
+
},
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
expect(result.isError).toBe(true);
|
|
189
|
+
expect(result.content).toContain("Gmail and Outlook");
|
|
190
|
+
expect(sendMessageMock).not.toHaveBeenCalled();
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
test("reads and forwards attachments to attachment-capable non-Gmail providers", async () => {
|
|
194
|
+
const dir = mkdtempSync(join(tmpdir(), "msg-send-att-"));
|
|
195
|
+
const filePath = join(dir, "report.pdf");
|
|
196
|
+
writeFileSync(filePath, "pdf-bytes");
|
|
197
|
+
provider.id = "outlook";
|
|
198
|
+
|
|
199
|
+
try {
|
|
200
|
+
const result = await run(
|
|
201
|
+
{
|
|
202
|
+
platform: "outlook",
|
|
203
|
+
conversation_id: "user@example.com",
|
|
204
|
+
text: "see attached",
|
|
205
|
+
subject: "Docs",
|
|
206
|
+
attachment_paths: [filePath],
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
workingDir: "/tmp",
|
|
210
|
+
conversationId: "conv-1",
|
|
211
|
+
assistantId: "ast-alpha",
|
|
212
|
+
trustClass: "guardian" as const,
|
|
213
|
+
},
|
|
214
|
+
);
|
|
215
|
+
|
|
216
|
+
expect(result.isError).toBe(false);
|
|
217
|
+
const options = sendMessageMock.mock.calls[0][3] as {
|
|
218
|
+
attachments?: Array<{
|
|
219
|
+
filename: string;
|
|
220
|
+
mimeType: string;
|
|
221
|
+
data: Buffer;
|
|
222
|
+
}>;
|
|
223
|
+
};
|
|
224
|
+
expect(options.attachments).toHaveLength(1);
|
|
225
|
+
expect(options.attachments?.[0]?.filename).toBe("report.pdf");
|
|
226
|
+
expect(options.attachments?.[0]?.mimeType).toBe("application/pdf");
|
|
227
|
+
expect(options.attachments?.[0]?.data.toString()).toBe("pdf-bytes");
|
|
228
|
+
} finally {
|
|
229
|
+
provider.id = "phone";
|
|
230
|
+
rmSync(dir, { recursive: true, force: true });
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
|
|
167
234
|
test("cross-posts outbound message to bound conversation", async () => {
|
|
168
235
|
getBindingByChannelChatMock.mockImplementation(() => ({
|
|
169
236
|
conversationId: "bound-conv-99",
|
|
@@ -473,6 +473,7 @@ describe("Outlook messaging provider", () => {
|
|
|
473
473
|
conn,
|
|
474
474
|
"original-msg-id",
|
|
475
475
|
"Reply text",
|
|
476
|
+
undefined,
|
|
476
477
|
);
|
|
477
478
|
expect(mockSendMessage).not.toHaveBeenCalled();
|
|
478
479
|
expect(result).toMatchObject({
|
|
@@ -481,6 +482,76 @@ describe("Outlook messaging provider", () => {
|
|
|
481
482
|
});
|
|
482
483
|
});
|
|
483
484
|
|
|
485
|
+
test("attaches files to a new message as Graph file attachments", async () => {
|
|
486
|
+
const conn = createMockConnection();
|
|
487
|
+
await outlookMessagingProvider.sendMessage(
|
|
488
|
+
conn,
|
|
489
|
+
"recipient@example.com",
|
|
490
|
+
"See attached",
|
|
491
|
+
{
|
|
492
|
+
subject: "Docs",
|
|
493
|
+
attachments: [
|
|
494
|
+
{
|
|
495
|
+
filename: "report.pdf",
|
|
496
|
+
mimeType: "application/pdf",
|
|
497
|
+
data: Buffer.from("pdf-bytes"),
|
|
498
|
+
},
|
|
499
|
+
],
|
|
500
|
+
},
|
|
501
|
+
);
|
|
502
|
+
|
|
503
|
+
expect(mockSendMessage).toHaveBeenCalledWith(conn, {
|
|
504
|
+
message: {
|
|
505
|
+
subject: "Docs",
|
|
506
|
+
body: { contentType: "text", content: "See attached" },
|
|
507
|
+
toRecipients: [
|
|
508
|
+
{ emailAddress: { address: "recipient@example.com" } },
|
|
509
|
+
],
|
|
510
|
+
attachments: [
|
|
511
|
+
{
|
|
512
|
+
"@odata.type": "#microsoft.graph.fileAttachment",
|
|
513
|
+
name: "report.pdf",
|
|
514
|
+
contentType: "application/pdf",
|
|
515
|
+
contentBytes: Buffer.from("pdf-bytes").toString("base64"),
|
|
516
|
+
},
|
|
517
|
+
],
|
|
518
|
+
},
|
|
519
|
+
});
|
|
520
|
+
});
|
|
521
|
+
|
|
522
|
+
test("forwards attachments to replyToMessage when replying", async () => {
|
|
523
|
+
const conn = createMockConnection();
|
|
524
|
+
await outlookMessagingProvider.sendMessage(
|
|
525
|
+
conn,
|
|
526
|
+
"conv-id",
|
|
527
|
+
"Reply body",
|
|
528
|
+
{
|
|
529
|
+
inReplyTo: "original-msg-id",
|
|
530
|
+
attachments: [
|
|
531
|
+
{
|
|
532
|
+
filename: "report.pdf",
|
|
533
|
+
mimeType: "application/pdf",
|
|
534
|
+
data: Buffer.from("pdf-bytes"),
|
|
535
|
+
},
|
|
536
|
+
],
|
|
537
|
+
},
|
|
538
|
+
);
|
|
539
|
+
|
|
540
|
+
expect(mockReplyToMessage).toHaveBeenCalledWith(
|
|
541
|
+
conn,
|
|
542
|
+
"original-msg-id",
|
|
543
|
+
"Reply body",
|
|
544
|
+
[
|
|
545
|
+
{
|
|
546
|
+
"@odata.type": "#microsoft.graph.fileAttachment",
|
|
547
|
+
name: "report.pdf",
|
|
548
|
+
contentType: "application/pdf",
|
|
549
|
+
contentBytes: Buffer.from("pdf-bytes").toString("base64"),
|
|
550
|
+
},
|
|
551
|
+
],
|
|
552
|
+
);
|
|
553
|
+
});
|
|
554
|
+
|
|
484
555
|
test("throws when connection is undefined", async () => {
|
|
485
556
|
await expect(
|
|
486
557
|
outlookMessagingProvider.sendMessage(
|
package/src/apps/app-store.ts
CHANGED
|
@@ -661,24 +661,29 @@ export type AppOrigin =
|
|
|
661
661
|
| { readonly kind: "plugin"; readonly pluginName: string };
|
|
662
662
|
|
|
663
663
|
/**
|
|
664
|
-
* Id prefix marking a plugin-bundled app. A plugin app's id
|
|
665
|
-
* `plugins
|
|
664
|
+
* Id prefix marking a plugin-bundled app. A plugin app's id encodes its
|
|
665
|
+
* location: `plugins~<pluginName>~<appDir>`, which maps to
|
|
666
666
|
* `<workspace>/plugins/<pluginName>/apps/<appDir>` (the `apps/` segment is
|
|
667
667
|
* implied). Unlike workspace apps â whose id is an opaque UUID looked up by
|
|
668
668
|
* scanning â a plugin app is resolved by a direct path build.
|
|
669
|
+
*
|
|
670
|
+
* The delimiter is `~` (a URL-unreserved character), not `/`, so the id is a
|
|
671
|
+
* single URL path segment: it survives `:id` route params and proxies without
|
|
672
|
+
* percent-encoding (`%2F` in a path is widely mishandled).
|
|
669
673
|
*/
|
|
670
|
-
const PLUGIN_APP_ID_PREFIX = "plugins
|
|
674
|
+
const PLUGIN_APP_ID_PREFIX = "plugins~";
|
|
675
|
+
const PLUGIN_APP_ID_SEP = "~";
|
|
671
676
|
|
|
672
677
|
/** Build the addressable id for a plugin-bundled app. */
|
|
673
678
|
function pluginAppId(pluginName: string, appDir: string): string {
|
|
674
|
-
return `${PLUGIN_APP_ID_PREFIX}${pluginName}
|
|
679
|
+
return `${PLUGIN_APP_ID_PREFIX}${pluginName}${PLUGIN_APP_ID_SEP}${appDir}`;
|
|
675
680
|
}
|
|
676
681
|
|
|
677
682
|
/** An app paired with the absolute path to its source and its origin. */
|
|
678
683
|
export interface EnumeratedApp {
|
|
679
684
|
/**
|
|
680
685
|
* Addressable app id: an opaque UUID for workspace apps, or
|
|
681
|
-
* `plugins
|
|
686
|
+
* `plugins~<name>~<app>` for plugin-bundled apps.
|
|
682
687
|
*/
|
|
683
688
|
readonly id: string;
|
|
684
689
|
/** Human-readable app name. */
|
|
@@ -818,21 +823,23 @@ function isSafeIdSegment(segment: string): boolean {
|
|
|
818
823
|
/**
|
|
819
824
|
* Resolve an app id to its on-disk source, for both workspace apps (opaque
|
|
820
825
|
* UUID, looked up via {@link getApp}) and plugin-bundled apps
|
|
821
|
-
* (`plugins
|
|
826
|
+
* (`plugins~<name>~<app>`, resolved by direct path build). Returns null when
|
|
822
827
|
* the app does not exist, or when a plugin id fails the same installed-plugin
|
|
823
828
|
* gates as discovery (directory, `package.json` manifest, not disabled).
|
|
824
829
|
*/
|
|
825
830
|
export function resolveAppSource(id: string): ResolvedAppSource | null {
|
|
826
831
|
if (id.startsWith(PLUGIN_APP_ID_PREFIX)) {
|
|
827
832
|
const rest = id.slice(PLUGIN_APP_ID_PREFIX.length);
|
|
828
|
-
|
|
829
|
-
|
|
833
|
+
// Split on the first delimiter: the plugin name is kebab-case (no `~`), so
|
|
834
|
+
// everything after it is the app directory (which may itself contain `~`).
|
|
835
|
+
const sep = rest.indexOf(PLUGIN_APP_ID_SEP);
|
|
836
|
+
if (sep === -1) {
|
|
830
837
|
return null;
|
|
831
838
|
}
|
|
832
|
-
const pluginName = rest.slice(0,
|
|
833
|
-
const appDirName = rest.slice(
|
|
834
|
-
// Both
|
|
835
|
-
//
|
|
839
|
+
const pluginName = rest.slice(0, sep);
|
|
840
|
+
const appDirName = rest.slice(sep + PLUGIN_APP_ID_SEP.length);
|
|
841
|
+
// Both must be safe single path components â the app segment, used as a
|
|
842
|
+
// directory name, must not smuggle in separators or traversal.
|
|
836
843
|
if (!isSafeIdSegment(pluginName) || !isSafeIdSegment(appDirName)) {
|
|
837
844
|
return null;
|
|
838
845
|
}
|
package/src/cli/AGENTS.md
CHANGED
|
@@ -154,6 +154,23 @@ registerFooCommand(program);
|
|
|
154
154
|
`console.log` results directly; that bypasses the convention and
|
|
155
155
|
breaks downstream scripting.
|
|
156
156
|
|
|
157
|
+
**`--json` is global.** `registerGlobalJsonOption` (called once in
|
|
158
|
+
`program.ts` after every command is registered) attaches `--json` to
|
|
159
|
+
every **leaf** command in the tree, so a caller can append `--json` to
|
|
160
|
+
any command it actually invokes without hitting "unknown option". Only
|
|
161
|
+
leaves get it: Commander consumes a recognized option at the outermost
|
|
162
|
+
command that declares it, even when the flag appears after the
|
|
163
|
+
subcommand name, so a group-level `--json` would swallow
|
|
164
|
+
`clients list --json` before the `list` action reads `opts.json`. You
|
|
165
|
+
therefore do **not** need to declare `--json` yourself â but a command
|
|
166
|
+
only _honors_ it when its action routes output through
|
|
167
|
+
`writeOutput`/`shouldOutputJson` (or reads `opts.json`). When a command
|
|
168
|
+
emits bespoke human-readable text, branch on `shouldOutputJson(cmd)` and
|
|
169
|
+
emit a JSON object in the `--json` case (see `commands/status.ts`).
|
|
170
|
+
Declare `--json` explicitly in the command's `.help` module only when
|
|
171
|
+
you want a more specific description than the generic one; the global
|
|
172
|
+
registration skips any leaf that already declares it.
|
|
173
|
+
|
|
157
174
|
### Anti-patterns
|
|
158
175
|
|
|
159
176
|
- â Hoisting a daemon import â `import { x } from "../../runtime/foo.js"`
|
|
@@ -68,7 +68,9 @@ export function registerRoutesCommand(program: Command): void {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
if (discovered.length === 0) {
|
|
71
|
-
log.info(
|
|
71
|
+
log.info(
|
|
72
|
+
"No route handlers found in /workspace/routes/ or /workspace/plugins/<name>/routes/.",
|
|
73
|
+
);
|
|
72
74
|
log.info(
|
|
73
75
|
"Create a .ts or .js file exporting named HTTP method functions (GET, POST, etc.).",
|
|
74
76
|
);
|
|
@@ -108,7 +110,7 @@ export function registerRoutesCommand(program: Command): void {
|
|
|
108
110
|
route.routePath.padEnd(routeWidth),
|
|
109
111
|
formatMethods(route.methods).padEnd(methodsWidth),
|
|
110
112
|
(route.description ?? "").padEnd(descWidth),
|
|
111
|
-
|
|
113
|
+
route.filePath,
|
|
112
114
|
].join(" ");
|
|
113
115
|
log.info(` ${cols}`);
|
|
114
116
|
}
|
|
@@ -130,7 +132,7 @@ export function registerRoutesCommand(program: Command): void {
|
|
|
130
132
|
async (routePath: string, opts: { json?: boolean }) => {
|
|
131
133
|
const r = await cliIpcCall<{ route: InspectedRoute }>(
|
|
132
134
|
"user_routes_inspect",
|
|
133
|
-
{ path: routePath },
|
|
135
|
+
{ body: { path: routePath } },
|
|
134
136
|
);
|
|
135
137
|
if (!r.ok) {
|
|
136
138
|
if (opts.json) {
|
|
@@ -5,4 +5,28 @@ import type { CliCommandHelp } from "../lib/cli-command-help.js";
|
|
|
5
5
|
export const statusHelp: CliCommandHelp = {
|
|
6
6
|
name: "status",
|
|
7
7
|
description: "Show assistant version, workspace, and runtime health",
|
|
8
|
+
options: [
|
|
9
|
+
{
|
|
10
|
+
flags: "--json",
|
|
11
|
+
description: "Emit the status as machine-readable JSON",
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
helpText: `
|
|
15
|
+
Behavior:
|
|
16
|
+
Reports the running assistant's version, workspace path, and memory/disk
|
|
17
|
+
usage. When the assistant is unreachable, falls back to the installed CLI
|
|
18
|
+
version and whether the assistant socket is present.
|
|
19
|
+
|
|
20
|
+
With --json, the same fields are emitted as a single JSON object:
|
|
21
|
+
- reachable: whether the assistant answered the health check
|
|
22
|
+
- cliVersion: the installed CLI version
|
|
23
|
+
- assistantVersion: the running assistant version (null when unreachable)
|
|
24
|
+
- versionStale: true when the CLI and assistant versions differ
|
|
25
|
+
- workspace: the workspace directory
|
|
26
|
+
- memory / disk: usage in MB (null when unreachable)
|
|
27
|
+
|
|
28
|
+
Examples:
|
|
29
|
+
$ assistant status
|
|
30
|
+
$ assistant status --json
|
|
31
|
+
$ assistant status --json | jq '.assistantVersion'`,
|
|
8
32
|
};
|
|
@@ -8,6 +8,7 @@ import { getWorkspaceDirDisplay } from "../../util/platform.js";
|
|
|
8
8
|
import { APP_VERSION } from "../../version.js";
|
|
9
9
|
import { applyCommandHelp } from "../lib/cli-command-help.js";
|
|
10
10
|
import { registerCommand } from "../lib/register-command.js";
|
|
11
|
+
import { shouldOutputJson, writeOutput } from "../output.js";
|
|
11
12
|
import { statusHelp } from "./status.help.js";
|
|
12
13
|
|
|
13
14
|
interface HealthResponse {
|
|
@@ -30,6 +31,7 @@ export function registerStatusCommand(program: Command): void {
|
|
|
30
31
|
applyCommandHelp(cmd, statusHelp);
|
|
31
32
|
|
|
32
33
|
cmd.action(async () => {
|
|
34
|
+
const json = shouldOutputJson(cmd);
|
|
33
35
|
const result = await cliIpcCall<HealthResponse>("health");
|
|
34
36
|
|
|
35
37
|
if (!result.ok) {
|
|
@@ -41,6 +43,19 @@ export function registerStatusCommand(program: Command): void {
|
|
|
41
43
|
const socketPath = getAssistantSocketPath();
|
|
42
44
|
const socketExists = existsSync(socketPath);
|
|
43
45
|
const workspace = getWorkspaceDirDisplay();
|
|
46
|
+
if (json) {
|
|
47
|
+
writeOutput(cmd, {
|
|
48
|
+
reachable: false,
|
|
49
|
+
cliVersion: APP_VERSION,
|
|
50
|
+
assistantVersion: null,
|
|
51
|
+
versionStale: false,
|
|
52
|
+
running: socketExists,
|
|
53
|
+
workspace,
|
|
54
|
+
memory: null,
|
|
55
|
+
disk: null,
|
|
56
|
+
});
|
|
57
|
+
process.exit(0);
|
|
58
|
+
}
|
|
44
59
|
// Daemon unreachable, so its runtime version is unknown; show the
|
|
45
60
|
// installed CLI version so there's always one reliable number.
|
|
46
61
|
process.stdout.write(`CLI Version: ${APP_VERSION}\n`);
|
|
@@ -62,6 +77,20 @@ export function registerStatusCommand(program: Command): void {
|
|
|
62
77
|
const h = result.result;
|
|
63
78
|
const workspace = getWorkspaceDirDisplay();
|
|
64
79
|
|
|
80
|
+
if (json) {
|
|
81
|
+
writeOutput(cmd, {
|
|
82
|
+
reachable: true,
|
|
83
|
+
cliVersion: APP_VERSION,
|
|
84
|
+
assistantVersion: h.version,
|
|
85
|
+
versionStale: h.version !== APP_VERSION,
|
|
86
|
+
running: true,
|
|
87
|
+
workspace,
|
|
88
|
+
memory: h.memory,
|
|
89
|
+
disk: h.disk,
|
|
90
|
+
});
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
65
94
|
// h.version is the running runtime; APP_VERSION is the installed CLI.
|
|
66
95
|
// They drift mid-upgrade (CLI bumped, daemon not yet restarted).
|
|
67
96
|
const runtimeVersion =
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { describe, expect, it } from "bun:test";
|
|
2
|
+
|
|
3
|
+
import { Command } from "commander";
|
|
4
|
+
|
|
5
|
+
import { registerGlobalJsonOption } from "../global-json-option.js";
|
|
6
|
+
|
|
7
|
+
function hasJsonOption(cmd: Command): boolean {
|
|
8
|
+
return cmd.options.some((opt) => opt.long === "--json");
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
describe("registerGlobalJsonOption", () => {
|
|
12
|
+
it("adds --json to leaf commands (including nested leaves)", () => {
|
|
13
|
+
const program = new Command();
|
|
14
|
+
program.name("assistant");
|
|
15
|
+
const memory = program.command("memory");
|
|
16
|
+
const items = memory.command("items");
|
|
17
|
+
const list = items.command("list");
|
|
18
|
+
const status = program.command("status");
|
|
19
|
+
|
|
20
|
+
registerGlobalJsonOption(program);
|
|
21
|
+
|
|
22
|
+
expect(hasJsonOption(list)).toBe(true);
|
|
23
|
+
expect(hasJsonOption(status)).toBe(true);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("does NOT add --json to group commands (would steal the flag from subcommands)", () => {
|
|
27
|
+
const program = new Command();
|
|
28
|
+
program.name("assistant");
|
|
29
|
+
const clients = program.command("clients");
|
|
30
|
+
const list = clients.command("list");
|
|
31
|
+
|
|
32
|
+
registerGlobalJsonOption(program);
|
|
33
|
+
|
|
34
|
+
// Commander consumes a recognized option at the outermost declaring
|
|
35
|
+
// command, so a group-level --json would swallow `clients list --json`
|
|
36
|
+
// before the leaf action reads it.
|
|
37
|
+
expect(hasJsonOption(clients)).toBe(false);
|
|
38
|
+
expect(hasJsonOption(list)).toBe(true);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("keeps `<group> <leaf> --json` bound to the leaf's own opts", () => {
|
|
42
|
+
const program = new Command();
|
|
43
|
+
program.name("assistant").exitOverride();
|
|
44
|
+
const clients = program.command("clients");
|
|
45
|
+
let leafJson: unknown;
|
|
46
|
+
clients.command("list").action((opts: { json?: boolean }) => {
|
|
47
|
+
leafJson = opts.json;
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
registerGlobalJsonOption(program);
|
|
51
|
+
|
|
52
|
+
program.parse(["node", "assistant", "clients", "list", "--json"]);
|
|
53
|
+
expect(leafJson).toBe(true);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("does not duplicate --json on a command that already declares it", () => {
|
|
57
|
+
const program = new Command();
|
|
58
|
+
program.name("assistant");
|
|
59
|
+
const sub = program.command("nodes");
|
|
60
|
+
sub.option("--json", "Machine-readable compact JSON output");
|
|
61
|
+
|
|
62
|
+
registerGlobalJsonOption(program);
|
|
63
|
+
|
|
64
|
+
const jsonOptions = sub.options.filter((opt) => opt.long === "--json");
|
|
65
|
+
expect(jsonOptions).toHaveLength(1);
|
|
66
|
+
// The original description is preserved, not overwritten.
|
|
67
|
+
expect(jsonOptions[0]!.description).toBe(
|
|
68
|
+
"Machine-readable compact JSON output",
|
|
69
|
+
);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("leaves the root program without a --json option", () => {
|
|
73
|
+
const program = new Command();
|
|
74
|
+
program.name("assistant");
|
|
75
|
+
program.command("status");
|
|
76
|
+
|
|
77
|
+
registerGlobalJsonOption(program);
|
|
78
|
+
|
|
79
|
+
expect(hasJsonOption(program)).toBe(false);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("makes --json parse without error on a command that lacked it", () => {
|
|
83
|
+
const program = new Command();
|
|
84
|
+
program.name("assistant").exitOverride();
|
|
85
|
+
let seenJson: unknown;
|
|
86
|
+
program.command("status").action((opts: { json?: boolean }) => {
|
|
87
|
+
seenJson = opts.json;
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
registerGlobalJsonOption(program);
|
|
91
|
+
|
|
92
|
+
expect(() =>
|
|
93
|
+
program.parse(["node", "assistant", "status", "--json"]),
|
|
94
|
+
).not.toThrow();
|
|
95
|
+
expect(seenJson).toBe(true);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"source": {
|
|
23
23
|
"source": "github",
|
|
24
24
|
"repo": "vellum-ai/agent-wrapped",
|
|
25
|
-
"ref": "
|
|
25
|
+
"ref": "5889e3717f46f798c78c002f56c00eb0f7d88a98"
|
|
26
26
|
},
|
|
27
|
-
"description": "Your agent's year in review: conversations, days together, memories formed, swear count, top topics, and
|
|
27
|
+
"description": "Your agent's year in review: conversations, days together, memories formed, swear count, top topics, and the receipt (total tokens + LLM calls). Works with Vellum agents and Claude Code. Ships a stats collector tool, a CLI, a Claude Code plugin, and a skill for the shareable cards experience.",
|
|
28
28
|
"category": "creative",
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"submittedBy": "marina",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"repo": "marinatrajk/ai-hero-engineer-kit",
|
|
38
38
|
"ref": "18d33c62b15a3e2cc22dc070723fe3077749dcec"
|
|
39
39
|
},
|
|
40
|
-
"description": "Five engineering skills adapted from Matt Pocock's '5 Agent Skills I Use Every Day'
|
|
40
|
+
"description": "Five engineering skills adapted from Matt Pocock's '5 Agent Skills I Use Every Day' \u2014 plans, PRDs, vertical-slice issues, TDD loop, and codebase deepening in one install.",
|
|
41
41
|
"category": "developer",
|
|
42
42
|
"homepage": "https://github.com/marinatrajk/ai-hero-engineer-kit",
|
|
43
43
|
"license": "MIT"
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"category": "productivity",
|
|
78
78
|
"homepage": "https://github.com/JuliusBrussee/caveman",
|
|
79
79
|
"license": "MIT",
|
|
80
|
-
"icon": "
|
|
80
|
+
"icon": "\ud83e\uddb4"
|
|
81
81
|
},
|
|
82
82
|
{
|
|
83
83
|
"name": "coffee-aficionado",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"category": "lifestyle",
|
|
91
91
|
"homepage": "https://github.com/vellum-ai/coffee-aficionado",
|
|
92
92
|
"license": "MIT",
|
|
93
|
-
"icon": "
|
|
93
|
+
"icon": "\u2615"
|
|
94
94
|
},
|
|
95
95
|
{
|
|
96
96
|
"name": "cofounder",
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
|
|
3
|
+
const JSON_FLAG = "--json";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Register a `--json` option on every leaf command in the tree that does not
|
|
7
|
+
* already declare one.
|
|
8
|
+
*
|
|
9
|
+
* Commander only recognizes an option at the position of the command it is
|
|
10
|
+
* attached to, so a single option on the root program would still reject
|
|
11
|
+
* `assistant status --json` with "unknown option '--json'". Attaching `--json`
|
|
12
|
+
* to each leaf command makes the flag accepted everywhere it is actually
|
|
13
|
+
* invoked, which is what callers (and agents) expect when they append `--json`
|
|
14
|
+
* to a command.
|
|
15
|
+
*
|
|
16
|
+
* Only **leaf** commands (those with no subcommands) get the option. Commander
|
|
17
|
+
* consumes a recognized option at the *outermost* command that declares it,
|
|
18
|
+
* even when the flag appears after the subcommand name â so putting `--json`
|
|
19
|
+
* on a group command like `clients` would swallow `clients list --json` before
|
|
20
|
+
* the `list` action ever sees it (`opts.json` would be undefined). Attaching it
|
|
21
|
+
* only to leaves keeps the flag bound to the command that reads it.
|
|
22
|
+
*
|
|
23
|
+
* Commands that render output through `writeOutput`/`shouldOutputJson` (which
|
|
24
|
+
* walk the parent chain) honor the flag automatically; leaves that declare
|
|
25
|
+
* their own `--json` are left untouched so their description and behavior win.
|
|
26
|
+
*/
|
|
27
|
+
export function registerGlobalJsonOption(program: Command): void {
|
|
28
|
+
const walk = (cmd: Command): void => {
|
|
29
|
+
const isLeaf = cmd.commands.length === 0;
|
|
30
|
+
const alreadyDeclared = cmd.options.some((opt) => opt.long === JSON_FLAG);
|
|
31
|
+
if (isLeaf && !alreadyDeclared) {
|
|
32
|
+
cmd.option(JSON_FLAG, "Output machine-readable JSON");
|
|
33
|
+
}
|
|
34
|
+
for (const child of cmd.commands) {
|
|
35
|
+
walk(child);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
for (const child of program.commands) {
|
|
39
|
+
walk(child);
|
|
40
|
+
}
|
|
41
|
+
}
|
package/src/cli/program.ts
CHANGED
|
@@ -55,6 +55,7 @@ import { registerUsageCommand } from "./commands/usage.js";
|
|
|
55
55
|
import { registerWatchersCommand } from "./commands/watchers.js";
|
|
56
56
|
import { registerWebhooksCommand } from "./commands/webhooks.js";
|
|
57
57
|
import { red } from "./lib/cli-colors.js";
|
|
58
|
+
import { registerGlobalJsonOption } from "./lib/global-json-option.js";
|
|
58
59
|
import { log } from "./logger.js";
|
|
59
60
|
|
|
60
61
|
/**
|
|
@@ -151,6 +152,10 @@ Examples:
|
|
|
151
152
|
registerWatchersCommand(program);
|
|
152
153
|
registerWebhooksCommand(program);
|
|
153
154
|
|
|
155
|
+
// Every command accepts `--json` â see registerGlobalJsonOption. Must run
|
|
156
|
+
// after all commands are registered so the whole tree is covered.
|
|
157
|
+
registerGlobalJsonOption(program);
|
|
158
|
+
|
|
154
159
|
// Fail fast when no assistant workspace exists on disk. The workspace is
|
|
155
160
|
// created by `vellum hatch` and must be present for any command to work.
|
|
156
161
|
// Commander handles --help and --version before preAction fires, so those
|
|
@@ -125,7 +125,7 @@
|
|
|
125
125
|
},
|
|
126
126
|
{
|
|
127
127
|
"name": "messaging_send",
|
|
128
|
-
"description": "Send a message, reply to a thread, or create a draft. On Gmail, always creates a draft for review. Supports replies (via thread_id), attachments (via attachment_paths, Gmail
|
|
128
|
+
"description": "Send a message, reply to a thread, or create a draft. On Gmail, always creates a draft for review. Supports replies (via thread_id), attachments (via attachment_paths, Gmail and Outlook), and all messaging platforms.",
|
|
129
129
|
"category": "messaging",
|
|
130
130
|
"risk": "high",
|
|
131
131
|
"input_schema": {
|
|
@@ -160,7 +160,7 @@
|
|
|
160
160
|
"items": {
|
|
161
161
|
"type": "string"
|
|
162
162
|
},
|
|
163
|
-
"description": "Absolute file paths of attachments to include (Gmail
|
|
163
|
+
"description": "Absolute file paths of attachments to include (Gmail and Outlook)"
|
|
164
164
|
},
|
|
165
165
|
"thread_id": {
|
|
166
166
|
"type": "string",
|