@vellumai/assistant 0.4.35 → 0.4.37
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/AGENTS.md +1 -1
- package/ARCHITECTURE.md +44 -49
- package/README.md +32 -20
- package/docs/architecture/keychain-broker.md +186 -0
- package/docs/architecture/security.md +110 -116
- package/docs/runbook-trusted-contacts.md +2 -2
- package/docs/skills.md +25 -25
- package/package.json +5 -2
- package/src/__tests__/__snapshots__/ipc-snapshot.test.ts.snap +11 -2
- package/src/__tests__/actor-token-service.test.ts +1 -0
- package/src/__tests__/amazon-cdp-integration.test.ts +74 -0
- package/src/__tests__/assistant-feature-flags-integration.test.ts +38 -9
- package/src/__tests__/assistant-id-boundary-guard.test.ts +29 -0
- package/src/__tests__/browser-fill-credential.test.ts +1 -1
- package/src/__tests__/bundle-scanner.test.ts +1 -1
- package/src/__tests__/channel-guardian.test.ts +102 -102
- package/src/__tests__/channel-invite-transport.test.ts +155 -256
- package/src/__tests__/channel-readiness-routes.test.ts +336 -0
- package/src/__tests__/checker.test.ts +6 -6
- package/src/__tests__/chrome-cdp.test.ts +350 -0
- package/src/__tests__/computer-use-session-lifecycle.test.ts +3 -3
- package/src/__tests__/computer-use-session-working-dir.test.ts +86 -52
- package/src/__tests__/computer-use-skill-lifecycle-cleanup.test.ts +1 -1
- package/src/__tests__/config-loader-migration.test.ts +85 -0
- package/src/__tests__/conversation-pairing.test.ts +370 -5
- package/src/__tests__/credential-broker-browser-fill.test.ts +1 -10
- package/src/__tests__/credential-broker-server-use.test.ts +1 -10
- package/src/__tests__/credential-security-e2e.test.ts +7 -1
- package/src/__tests__/credential-security-invariants.test.ts +14 -20
- package/src/__tests__/credential-vault-unit.test.ts +1 -11
- package/src/__tests__/credential-vault.test.ts +5 -19
- package/src/__tests__/credentials-cli.test.ts +814 -0
- package/src/__tests__/dynamic-skill-workflow-prompt.test.ts +23 -4
- package/src/__tests__/email-invite-adapter.test.ts +78 -0
- package/src/__tests__/email-service-config-fallback.test.ts +102 -0
- package/src/__tests__/encrypted-store.test.ts +6 -6
- package/src/__tests__/ephemeral-permissions.test.ts +3 -3
- package/src/__tests__/gateway-only-enforcement.test.ts +5 -1
- package/src/__tests__/guardian-actions-endpoint.test.ts +70 -12
- package/src/__tests__/guardian-outbound-http.test.ts +53 -47
- package/src/__tests__/handle-user-message-secret-resume.test.ts +23 -0
- package/src/__tests__/handlers-add-trust-rule-metadata.test.ts +32 -23
- package/src/__tests__/handlers-telegram-config.test.ts +8 -2
- package/src/__tests__/handlers-twitter-config.test.ts +2 -2
- package/src/__tests__/handlers-user-message-approval-consumption.test.ts +108 -7
- package/src/__tests__/ingress-reconcile.test.ts +6 -0
- package/src/__tests__/intent-routing.test.ts +23 -4
- package/src/__tests__/invite-routes-http.test.ts +12 -0
- package/src/__tests__/ipc-snapshot.test.ts +8 -2
- package/src/__tests__/keychain-broker-client.test.ts +543 -0
- package/src/__tests__/llm-usage-store.test.ts +344 -0
- package/src/__tests__/mcp-client-auth.test.ts +2 -2
- package/src/__tests__/media-reuse-story.e2e.test.ts +1 -1
- package/src/__tests__/migration-transport.test.ts +49 -0
- package/src/__tests__/notification-broadcaster.test.ts +205 -5
- package/src/__tests__/notification-deep-link.test.ts +365 -1
- package/src/__tests__/oauth-connect-handler.test.ts +2 -2
- package/src/__tests__/onboarding-starter-tasks.test.ts +17 -4
- package/src/__tests__/proxy-approval-callback.test.ts +1 -1
- package/src/__tests__/recording-handler.test.ts +1 -1
- package/src/__tests__/recording-intent-handler.test.ts +6 -1
- package/src/__tests__/recording-state-machine.test.ts +1 -1
- package/src/__tests__/relay-server.test.ts +9 -1
- package/src/__tests__/ride-shotgun-handler.test.ts +499 -0
- package/src/__tests__/runtime-attachment-metadata.test.ts +160 -1
- package/src/__tests__/script-proxy-injection-runtime.test.ts +299 -2
- package/src/__tests__/script-proxy-profile-template-fallback.test.ts +1 -1
- package/src/__tests__/secret-onetime-send.test.ts +8 -2
- package/src/__tests__/secure-keys.test.ts +175 -216
- package/src/__tests__/session-confirmation-signals.test.ts +1 -1
- package/src/__tests__/session-messaging-secret-redirect.test.ts +1 -1
- package/src/__tests__/session-queue.test.ts +2 -1
- package/src/__tests__/session-tool-setup-app-refresh.test.ts +2 -2
- package/src/__tests__/skill-feature-flags-integration.test.ts +29 -4
- package/src/__tests__/skill-feature-flags.test.ts +12 -9
- package/src/__tests__/skill-load-feature-flag.test.ts +26 -5
- package/src/__tests__/skill-projection.benchmark.test.ts +0 -1
- package/src/__tests__/skills.test.ts +34 -4
- package/src/__tests__/slack-channel-config.test.ts +2 -2
- package/src/__tests__/system-prompt.test.ts +26 -4
- package/src/__tests__/telegram-bot-username-resolution.test.ts +212 -0
- package/src/__tests__/telegram-invite-adapter.test.ts +164 -0
- package/src/__tests__/tool-execution-pipeline.benchmark.test.ts +1 -1
- package/src/__tests__/tool-permission-simulate-handler.test.ts +8 -2
- package/src/__tests__/trusted-contact-approval-notifier.test.ts +9 -1
- package/src/__tests__/twitter-auth-handler.test.ts +2 -2
- package/src/__tests__/twitter-oauth-client.test.ts +1 -1
- package/src/__tests__/usage-routes.test.ts +339 -0
- package/src/__tests__/whatsapp-invite-adapter.test.ts +94 -0
- package/src/agent/loop.ts +3 -0
- package/src/amazon/checkout.ts +0 -1
- package/src/approvals/guardian-request-resolvers.ts +9 -1
- package/src/bundler/app-bundler.ts +28 -12
- package/src/bundler/bundle-scanner.ts +1 -1
- package/src/bundler/bundle-signer.ts +3 -3
- package/src/bundler/manifest.ts +1 -1
- package/src/bundler/signature-verifier.ts +3 -3
- package/src/channels/config.ts +1 -1
- package/src/cli/AGENTS.md +63 -0
- package/src/cli/__tests__/notifications.test.ts +470 -0
- package/src/cli/amazon.ts +344 -167
- package/src/cli/audit.ts +85 -0
- package/src/cli/autonomy.ts +369 -0
- package/src/cli/channels.ts +51 -0
- package/src/cli/completions.ts +208 -0
- package/src/cli/config.ts +220 -0
- package/src/cli/contacts.ts +471 -0
- package/src/cli/credentials.ts +564 -0
- package/src/cli/default-action.ts +14 -0
- package/src/cli/dev.ts +131 -0
- package/src/cli/doctor.ts +398 -0
- package/src/cli/email.ts +494 -0
- package/src/cli/influencer.ts +72 -0
- package/src/cli/integrations.ts +248 -57
- package/src/cli/keys.ts +114 -0
- package/src/cli/map.ts +46 -54
- package/src/cli/mcp.ts +111 -3
- package/src/cli/{config-commands.ts → memory.ts} +134 -245
- package/src/cli/notifications.ts +407 -0
- package/src/cli/program.ts +65 -0
- package/src/cli/reference.ts +48 -0
- package/src/cli/sequence.ts +154 -0
- package/src/cli/sessions.ts +262 -0
- package/src/cli/trust.ts +175 -0
- package/src/cli/twitter.ts +323 -106
- package/src/config/__tests__/build-cli-reference-section.test.ts +49 -0
- package/src/config/bundled-skills/amazon/SKILL.md +2 -2
- package/src/config/bundled-skills/app-builder/TOOLS.json +26 -0
- package/src/config/bundled-skills/app-builder/tools/app-generate-icon.ts +13 -0
- package/src/config/bundled-skills/contacts/SKILL.md +178 -10
- package/src/config/bundled-skills/doordash/doordash-cli.ts +23 -168
- package/src/config/bundled-skills/google-oauth-setup/SKILL.md +135 -34
- package/src/config/bundled-skills/messaging/tools/shared.ts +4 -1
- package/src/config/bundled-skills/twilio-setup/SKILL.md +70 -17
- package/src/config/bundled-tool-registry.ts +2 -0
- package/src/config/core-schema.ts +7 -0
- package/src/config/feature-flag-registry.json +16 -0
- package/src/config/loader.ts +26 -0
- package/src/config/schema.ts +4 -0
- package/src/config/skill-state.ts +0 -13
- package/src/config/system-prompt.ts +27 -0
- package/src/contacts/contact-store.ts +25 -0
- package/src/daemon/computer-use-session.ts +1 -1
- package/src/daemon/handlers/apps.ts +1 -0
- package/src/daemon/handlers/config-channels.ts +3 -3
- package/src/daemon/handlers/config-dispatch.ts +29 -0
- package/src/daemon/handlers/config-inbox.ts +4 -3
- package/src/daemon/handlers/config.ts +3 -43
- package/src/daemon/handlers/contacts.ts +34 -0
- package/src/daemon/handlers/index.ts +17 -3
- package/src/daemon/handlers/session-user-message.ts +7 -0
- package/src/daemon/handlers/sessions.ts +21 -2
- package/src/daemon/handlers/shared.ts +17 -0
- package/src/daemon/ipc-contract/apps.ts +2 -0
- package/src/daemon/ipc-contract/computer-use.ts +9 -0
- package/src/daemon/ipc-contract/contacts.ts +3 -3
- package/src/daemon/ipc-contract/inbox.ts +2 -0
- package/src/daemon/ipc-contract/messages.ts +4 -0
- package/src/daemon/ipc-contract/sessions.ts +8 -0
- package/src/daemon/ipc-contract-inventory.json +1 -0
- package/src/daemon/lifecycle.ts +0 -5
- package/src/daemon/ride-shotgun-handler.ts +139 -25
- package/src/daemon/session-agent-loop-handlers.ts +100 -0
- package/src/daemon/session-agent-loop.ts +72 -0
- package/src/daemon/session-tool-setup.ts +7 -0
- package/src/daemon/session.ts +23 -1
- package/src/daemon/tool-side-effects.ts +39 -1
- package/src/email/service.ts +59 -2
- package/src/index.ts +2 -60
- package/src/mcp/mcp-oauth-provider.ts +90 -8
- package/src/media/app-icon-generator.ts +86 -0
- package/src/memory/db-init.ts +11 -0
- package/src/memory/llm-usage-store.ts +186 -0
- package/src/memory/migrations/137-usage-dashboard-indexes.ts +26 -0
- package/src/memory/migrations/139-drop-usage-composite-indexes.ts +30 -0
- package/src/memory/migrations/index.ts +2 -0
- package/src/memory/schema-migration.ts +1 -0
- package/src/memory/shared-app-links-store.ts +1 -1
- package/src/messaging/registry.ts +27 -0
- package/src/notifications/README.md +79 -70
- package/src/notifications/broadcaster.ts +2 -1
- package/src/notifications/conversation-pairing.ts +147 -13
- package/src/notifications/copy-composer.ts +7 -3
- package/src/notifications/destination-resolver.ts +14 -1
- package/src/notifications/emit-signal.ts +3 -2
- package/src/notifications/signal.ts +105 -1
- package/src/notifications/types.ts +16 -0
- package/src/permissions/checker.ts +29 -3
- package/src/permissions/prompter.ts +11 -3
- package/src/runtime/access-request-helper.ts +2 -1
- package/src/runtime/auth/route-policy.ts +7 -1
- package/src/runtime/channel-invite-transport.ts +40 -63
- package/src/runtime/channel-invite-transports/email.ts +13 -39
- package/src/runtime/channel-invite-transports/slack.ts +5 -34
- package/src/runtime/channel-invite-transports/sms.ts +8 -29
- package/src/runtime/channel-invite-transports/telegram.ts +69 -28
- package/src/runtime/channel-invite-transports/voice.ts +0 -7
- package/src/runtime/channel-invite-transports/whatsapp.ts +43 -0
- package/src/runtime/channel-readiness-service.ts +202 -45
- package/src/runtime/confirmation-request-guardian-bridge.ts +2 -1
- package/src/runtime/guardian-outbound-actions.ts +8 -5
- package/src/runtime/http-server.ts +2 -0
- package/src/runtime/invite-instruction-generator.ts +178 -0
- package/src/runtime/invite-service.ts +22 -25
- package/src/runtime/migrations/migration-transport.ts +13 -0
- package/src/runtime/routes/app-routes.ts +1 -1
- package/src/runtime/routes/approval-strategies/guardian-callback-strategy.ts +8 -7
- package/src/runtime/routes/channel-readiness-routes.ts +30 -11
- package/src/runtime/routes/contact-routes.ts +54 -26
- package/src/runtime/routes/inbound-stages/bootstrap-intercept.ts +1 -1
- package/src/runtime/routes/inbound-stages/escalation-intercept.ts +2 -1
- package/src/runtime/routes/inbound-stages/verification-intercept.ts +2 -1
- package/src/runtime/routes/integration-routes.ts +1 -1
- package/src/runtime/routes/invite-routes.ts +1 -1
- package/src/runtime/routes/secret-routes.ts +31 -7
- package/src/runtime/routes/twilio-routes.ts +32 -1
- package/src/runtime/routes/usage-routes.ts +114 -0
- package/src/runtime/tool-grant-request-helper.ts +2 -1
- package/src/security/encrypted-store.ts +9 -5
- package/src/security/keychain-broker-client.ts +393 -0
- package/src/security/secure-keys.ts +106 -321
- package/src/tools/apps/executors.ts +73 -0
- package/src/tools/browser/auto-navigate.ts +15 -6
- package/src/tools/browser/chrome-cdp.ts +211 -0
- package/src/tools/browser/network-recorder.test.ts +83 -0
- package/src/tools/browser/network-recorder.ts +8 -7
- package/src/tools/browser/x-auto-navigate.ts +12 -6
- package/src/tools/credentials/policy-types.ts +24 -0
- package/src/tools/credentials/vault.ts +22 -27
- package/src/tools/network/script-proxy/session-manager.ts +47 -3
- package/src/tools/permission-checker.ts +1 -0
- package/src/tools/types.ts +2 -0
- package/src/tools/ui-surface/definitions.ts +1 -2
- package/src/tools/watch/watch-state.ts +2 -0
- package/src/__tests__/key-migration.test.ts +0 -240
- package/src/__tests__/keychain.test.ts +0 -286
- package/src/cli/core-commands.ts +0 -899
- package/src/security/keychain-to-encrypted-migration.ts +0 -66
- package/src/security/keychain.ts +0 -490
package/src/cli/core-commands.ts
DELETED
|
@@ -1,899 +0,0 @@
|
|
|
1
|
-
import { spawn } from "node:child_process";
|
|
2
|
-
import { execSync } from "node:child_process";
|
|
3
|
-
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
4
|
-
import * as net from "node:net";
|
|
5
|
-
import { join } from "node:path";
|
|
6
|
-
|
|
7
|
-
import type { Command } from "commander";
|
|
8
|
-
|
|
9
|
-
import { startCli } from "../cli.js";
|
|
10
|
-
import { getQdrantUrlEnv } from "../config/env.js";
|
|
11
|
-
import { loadRawConfig } from "../config/loader.js";
|
|
12
|
-
import { getConfig } from "../config/loader.js";
|
|
13
|
-
import {
|
|
14
|
-
hasSocketOverride,
|
|
15
|
-
shouldAutoStartDaemon,
|
|
16
|
-
} from "../daemon/connection-policy.js";
|
|
17
|
-
import {
|
|
18
|
-
ensureDaemonRunning,
|
|
19
|
-
getDaemonStatus,
|
|
20
|
-
stopDaemon,
|
|
21
|
-
} from "../daemon/lifecycle.js";
|
|
22
|
-
import { formatJson, formatMarkdown } from "../export/formatter.js";
|
|
23
|
-
import {
|
|
24
|
-
clearAll as clearAllConversations,
|
|
25
|
-
getConversation,
|
|
26
|
-
getMessages,
|
|
27
|
-
listConversations,
|
|
28
|
-
} from "../memory/conversation-store.js";
|
|
29
|
-
import { initializeDb } from "../memory/db.js";
|
|
30
|
-
import { initQdrantClient } from "../memory/qdrant-client.js";
|
|
31
|
-
import { getRecentInvocations } from "../memory/tool-usage-store.js";
|
|
32
|
-
import { IpcError } from "../util/errors.js";
|
|
33
|
-
import { getCliLogger } from "../util/logger.js";
|
|
34
|
-
import {
|
|
35
|
-
getDataDir,
|
|
36
|
-
getDbPath,
|
|
37
|
-
getLogPath,
|
|
38
|
-
getRootDir,
|
|
39
|
-
getSocketPath,
|
|
40
|
-
getWorkspaceDir,
|
|
41
|
-
getWorkspaceHooksDir,
|
|
42
|
-
getWorkspaceSkillsDir,
|
|
43
|
-
} from "../util/platform.js";
|
|
44
|
-
import { timeAgo } from "../util/time.js";
|
|
45
|
-
import { sendOneMessage } from "./ipc-client.js";
|
|
46
|
-
|
|
47
|
-
const log = getCliLogger("cli");
|
|
48
|
-
|
|
49
|
-
export function registerDefaultAction(program: Command): void {
|
|
50
|
-
program.action(async () => {
|
|
51
|
-
if (shouldAutoStartDaemon()) {
|
|
52
|
-
await ensureDaemonRunning();
|
|
53
|
-
}
|
|
54
|
-
await startCli();
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export function registerDevCommand(program: Command): void {
|
|
59
|
-
program
|
|
60
|
-
.command("dev")
|
|
61
|
-
.description("Run the daemon in dev mode")
|
|
62
|
-
.option(
|
|
63
|
-
"--watch",
|
|
64
|
-
"Auto-restart on source file changes (disruptive during Claude Code sessions)",
|
|
65
|
-
)
|
|
66
|
-
.action(async (opts: { watch?: boolean }) => {
|
|
67
|
-
let status = await getDaemonStatus();
|
|
68
|
-
if (status.running) {
|
|
69
|
-
log.info("Stopping existing daemon...");
|
|
70
|
-
const stopResult = await stopDaemon();
|
|
71
|
-
if (!stopResult.stopped && stopResult.reason === "stop_failed") {
|
|
72
|
-
log.error(
|
|
73
|
-
"Failed to stop existing daemon — process survived SIGKILL",
|
|
74
|
-
);
|
|
75
|
-
process.exit(1);
|
|
76
|
-
}
|
|
77
|
-
} else if (status.pid) {
|
|
78
|
-
// PID file references a live process but the socket is unresponsive.
|
|
79
|
-
// This can happen during the daemon startup window before the socket
|
|
80
|
-
// is bound. Wait briefly for it to come up before replacing.
|
|
81
|
-
log.info(
|
|
82
|
-
"Daemon process alive but socket unresponsive — waiting for startup...",
|
|
83
|
-
);
|
|
84
|
-
const maxWait = 5000;
|
|
85
|
-
const interval = 500;
|
|
86
|
-
let waited = 0;
|
|
87
|
-
let resolved = false;
|
|
88
|
-
while (waited < maxWait) {
|
|
89
|
-
await new Promise((r) => setTimeout(r, interval));
|
|
90
|
-
waited += interval;
|
|
91
|
-
status = await getDaemonStatus();
|
|
92
|
-
if (status.running) {
|
|
93
|
-
// Socket came up — stop the daemon normally.
|
|
94
|
-
log.info("Daemon became responsive, stopping it...");
|
|
95
|
-
const stopResult = await stopDaemon();
|
|
96
|
-
if (!stopResult.stopped && stopResult.reason === "stop_failed") {
|
|
97
|
-
log.error(
|
|
98
|
-
"Failed to stop existing daemon — process survived SIGKILL",
|
|
99
|
-
);
|
|
100
|
-
process.exit(1);
|
|
101
|
-
}
|
|
102
|
-
resolved = true;
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
if (!status.pid) {
|
|
106
|
-
// Process exited on its own — PID file already cleaned up.
|
|
107
|
-
resolved = true;
|
|
108
|
-
break;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
if (!resolved) {
|
|
112
|
-
// Still alive but unresponsive after waiting — stop it via stopDaemon()
|
|
113
|
-
// which handles SIGTERM → SIGKILL escalation and PID file cleanup.
|
|
114
|
-
log.info("Daemon still unresponsive after wait — stopping it...");
|
|
115
|
-
const stopResult = await stopDaemon();
|
|
116
|
-
if (!stopResult.stopped && stopResult.reason === "stop_failed") {
|
|
117
|
-
log.error(
|
|
118
|
-
"Failed to stop existing daemon — process survived SIGKILL",
|
|
119
|
-
);
|
|
120
|
-
process.exit(1);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const mainPath = `${import.meta.dirname}/../daemon/main.ts`;
|
|
126
|
-
|
|
127
|
-
const useWatch = opts.watch === true;
|
|
128
|
-
log.info(
|
|
129
|
-
`Starting daemon in dev mode${
|
|
130
|
-
useWatch ? " with file watching" : ""
|
|
131
|
-
} (Ctrl+C to stop)`,
|
|
132
|
-
);
|
|
133
|
-
|
|
134
|
-
const repoRoot = join(import.meta.dirname, "..", "..", "..");
|
|
135
|
-
const args = useWatch ? ["--watch", "run", mainPath] : ["run", mainPath];
|
|
136
|
-
const child = spawn("bun", args, {
|
|
137
|
-
stdio: "inherit",
|
|
138
|
-
env: {
|
|
139
|
-
...process.env,
|
|
140
|
-
BASE_DATA_DIR: repoRoot,
|
|
141
|
-
VELLUM_LOG_STDERR: "1",
|
|
142
|
-
VELLUM_DEBUG: "1",
|
|
143
|
-
},
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
const forward = (signal: NodeJS.Signals) => {
|
|
147
|
-
child.kill(signal);
|
|
148
|
-
};
|
|
149
|
-
process.on("SIGINT", () => forward("SIGINT"));
|
|
150
|
-
process.on("SIGTERM", () => forward("SIGTERM"));
|
|
151
|
-
|
|
152
|
-
child.on("exit", (code) => {
|
|
153
|
-
process.exit(code ?? 0);
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
export function registerSessionsCommand(program: Command): void {
|
|
159
|
-
const sessions = program.command("sessions").description("Manage sessions");
|
|
160
|
-
|
|
161
|
-
sessions
|
|
162
|
-
.command("list")
|
|
163
|
-
.description("List all sessions")
|
|
164
|
-
.action(async () => {
|
|
165
|
-
if (shouldAutoStartDaemon()) await ensureDaemonRunning();
|
|
166
|
-
const response = await sendOneMessage({ type: "session_list" });
|
|
167
|
-
if (response.type === "session_list_response") {
|
|
168
|
-
if (response.sessions.length === 0) {
|
|
169
|
-
log.info("No sessions");
|
|
170
|
-
} else {
|
|
171
|
-
for (const s of response.sessions) {
|
|
172
|
-
log.info(` ${s.id} ${s.title} ${timeAgo(s.updatedAt)}`);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
} else if (response.type === "error") {
|
|
176
|
-
log.error(`Error: ${response.message}`);
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
sessions
|
|
181
|
-
.command("new [title]")
|
|
182
|
-
.description("Create a new session")
|
|
183
|
-
.action(async (title?: string) => {
|
|
184
|
-
if (shouldAutoStartDaemon()) await ensureDaemonRunning();
|
|
185
|
-
const response = await sendOneMessage({
|
|
186
|
-
type: "session_create",
|
|
187
|
-
title,
|
|
188
|
-
});
|
|
189
|
-
if (response.type === "session_info") {
|
|
190
|
-
log.info(`Created session: ${response.title} (${response.sessionId})`);
|
|
191
|
-
} else if (response.type === "error") {
|
|
192
|
-
log.error(`Error: ${response.message}`);
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
sessions
|
|
197
|
-
.command("export [sessionId]")
|
|
198
|
-
.description("Export a conversation as markdown or JSON")
|
|
199
|
-
.option("-f, --format <format>", "Output format: md or json", "md")
|
|
200
|
-
.option("-o, --output <file>", "Write to file instead of stdout")
|
|
201
|
-
.action(
|
|
202
|
-
async (
|
|
203
|
-
sessionId?: string,
|
|
204
|
-
opts?: { format: string; output?: string },
|
|
205
|
-
) => {
|
|
206
|
-
initializeDb();
|
|
207
|
-
const format = opts?.format ?? "md";
|
|
208
|
-
if (format !== "md" && format !== "json") {
|
|
209
|
-
log.error('Error: format must be "md" or "json"');
|
|
210
|
-
process.exit(1);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
let id = sessionId;
|
|
214
|
-
if (!id) {
|
|
215
|
-
const all = listConversations(1);
|
|
216
|
-
if (all.length === 0) {
|
|
217
|
-
log.error("No sessions found");
|
|
218
|
-
process.exit(1);
|
|
219
|
-
}
|
|
220
|
-
id = all[0].id;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
// Support prefix matching for session IDs
|
|
224
|
-
let conversation = getConversation(id);
|
|
225
|
-
if (!conversation) {
|
|
226
|
-
const all = listConversations(Number.MAX_SAFE_INTEGER);
|
|
227
|
-
const match = all.find((c) => c.id.startsWith(id!));
|
|
228
|
-
if (match) {
|
|
229
|
-
conversation = match;
|
|
230
|
-
} else {
|
|
231
|
-
log.error(`Session not found: ${id}`);
|
|
232
|
-
process.exit(1);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
const msgs = getMessages(conversation.id);
|
|
237
|
-
const exportData = {
|
|
238
|
-
...conversation,
|
|
239
|
-
messages: msgs.map((m) => ({
|
|
240
|
-
role: m.role,
|
|
241
|
-
content: JSON.parse(m.content),
|
|
242
|
-
createdAt: m.createdAt,
|
|
243
|
-
})),
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
const output =
|
|
247
|
-
format === "json"
|
|
248
|
-
? formatJson(exportData)
|
|
249
|
-
: formatMarkdown(exportData);
|
|
250
|
-
|
|
251
|
-
if (opts?.output) {
|
|
252
|
-
const { writeFileSync } = await import("node:fs");
|
|
253
|
-
writeFileSync(opts.output, output);
|
|
254
|
-
log.info(`Exported to ${opts.output}`);
|
|
255
|
-
} else {
|
|
256
|
-
process.stdout.write(output);
|
|
257
|
-
}
|
|
258
|
-
},
|
|
259
|
-
);
|
|
260
|
-
|
|
261
|
-
sessions
|
|
262
|
-
.command("clear")
|
|
263
|
-
.description(
|
|
264
|
-
"Clear all conversations, messages, and vector data (dev only)",
|
|
265
|
-
)
|
|
266
|
-
.action(async () => {
|
|
267
|
-
log.info(
|
|
268
|
-
"This will permanently delete all conversations, messages, and vector data.",
|
|
269
|
-
);
|
|
270
|
-
|
|
271
|
-
const readline = await import("node:readline");
|
|
272
|
-
const rl = readline.createInterface({
|
|
273
|
-
input: process.stdin,
|
|
274
|
-
output: process.stdout,
|
|
275
|
-
});
|
|
276
|
-
const answer = await new Promise<string>((resolve) => {
|
|
277
|
-
rl.question("Are you sure? (y/N) ", resolve);
|
|
278
|
-
});
|
|
279
|
-
rl.close();
|
|
280
|
-
if (answer.toLowerCase() !== "y") {
|
|
281
|
-
log.info("Cancelled");
|
|
282
|
-
return;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
initializeDb();
|
|
286
|
-
const result = clearAllConversations();
|
|
287
|
-
log.info(
|
|
288
|
-
`Cleared ${result.conversations} conversations, ${result.messages} messages`,
|
|
289
|
-
);
|
|
290
|
-
|
|
291
|
-
// Notify a running daemon to drop its in-memory sessions so it
|
|
292
|
-
// doesn't keep serving stale history from deleted conversation rows.
|
|
293
|
-
try {
|
|
294
|
-
await sendOneMessage({ type: "sessions_clear" });
|
|
295
|
-
} catch {
|
|
296
|
-
// Daemon may not be running — that's fine, no sessions to invalidate.
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
const config = getConfig();
|
|
300
|
-
const qdrantUrl = getQdrantUrlEnv() || config.memory.qdrant.url;
|
|
301
|
-
const qdrant = initQdrantClient({
|
|
302
|
-
url: qdrantUrl,
|
|
303
|
-
collection: config.memory.qdrant.collection,
|
|
304
|
-
vectorSize: config.memory.qdrant.vectorSize,
|
|
305
|
-
onDisk: config.memory.qdrant.onDisk,
|
|
306
|
-
quantization: config.memory.qdrant.quantization,
|
|
307
|
-
});
|
|
308
|
-
const deleted = await qdrant.deleteCollection();
|
|
309
|
-
if (deleted) {
|
|
310
|
-
log.info(
|
|
311
|
-
`Deleted Qdrant collection "${config.memory.qdrant.collection}"`,
|
|
312
|
-
);
|
|
313
|
-
} else {
|
|
314
|
-
log.info("Qdrant collection not found or not reachable (skipped)");
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
log.info("Done.");
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
export function registerAuditCommand(program: Command): void {
|
|
322
|
-
program
|
|
323
|
-
.command("audit")
|
|
324
|
-
.description("Show recent tool invocations")
|
|
325
|
-
.option("-l, --limit <n>", "Number of entries to show", "20")
|
|
326
|
-
.action((opts: { limit: string }) => {
|
|
327
|
-
const limit = parseInt(opts.limit, 10) || 20;
|
|
328
|
-
const rows = getRecentInvocations(limit);
|
|
329
|
-
if (rows.length === 0) {
|
|
330
|
-
log.info("No tool invocations recorded");
|
|
331
|
-
return;
|
|
332
|
-
}
|
|
333
|
-
const tsW = 20;
|
|
334
|
-
const toolW = 14;
|
|
335
|
-
const inputW = 30;
|
|
336
|
-
const decW = 8;
|
|
337
|
-
const riskW = 8;
|
|
338
|
-
const durW = 8;
|
|
339
|
-
log.info(
|
|
340
|
-
"Timestamp".padEnd(tsW) +
|
|
341
|
-
"Tool".padEnd(toolW) +
|
|
342
|
-
"Input".padEnd(inputW) +
|
|
343
|
-
"Decision".padEnd(decW) +
|
|
344
|
-
"Risk".padEnd(riskW) +
|
|
345
|
-
"Duration",
|
|
346
|
-
);
|
|
347
|
-
log.info("-".repeat(tsW + toolW + inputW + decW + riskW + durW));
|
|
348
|
-
for (const r of rows) {
|
|
349
|
-
const ts = new Date(r.createdAt)
|
|
350
|
-
.toISOString()
|
|
351
|
-
.slice(0, 19)
|
|
352
|
-
.replace("T", " ");
|
|
353
|
-
let inputSummary = "";
|
|
354
|
-
try {
|
|
355
|
-
const parsed = JSON.parse(r.input);
|
|
356
|
-
if (parsed.command) inputSummary = parsed.command;
|
|
357
|
-
else if (parsed.path) inputSummary = parsed.path;
|
|
358
|
-
else inputSummary = r.input;
|
|
359
|
-
} catch {
|
|
360
|
-
inputSummary = r.input;
|
|
361
|
-
}
|
|
362
|
-
if (inputSummary.length > inputW - 2) {
|
|
363
|
-
inputSummary = inputSummary.slice(0, inputW - 4) + "..";
|
|
364
|
-
}
|
|
365
|
-
const dur =
|
|
366
|
-
r.durationMs < 1000
|
|
367
|
-
? `${r.durationMs}ms`
|
|
368
|
-
: `${(r.durationMs / 1000).toFixed(1)}s`;
|
|
369
|
-
log.info(
|
|
370
|
-
ts.padEnd(tsW) +
|
|
371
|
-
r.toolName.padEnd(toolW) +
|
|
372
|
-
inputSummary.padEnd(inputW) +
|
|
373
|
-
r.decision.padEnd(decW) +
|
|
374
|
-
r.riskLevel.padEnd(riskW) +
|
|
375
|
-
dur,
|
|
376
|
-
);
|
|
377
|
-
}
|
|
378
|
-
});
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
export function registerDoctorCommand(program: Command): void {
|
|
382
|
-
program
|
|
383
|
-
.command("doctor")
|
|
384
|
-
.description("Run diagnostic checks")
|
|
385
|
-
.action(async () => {
|
|
386
|
-
const pass = (label: string) => log.info(` \u2713 ${label}`);
|
|
387
|
-
const fail = (label: string, detail?: string) =>
|
|
388
|
-
log.info(` \u2717 ${label}${detail ? ` — ${detail}` : ""}`);
|
|
389
|
-
|
|
390
|
-
log.info("Vellum Doctor\n");
|
|
391
|
-
|
|
392
|
-
// 0. Connection policy info
|
|
393
|
-
const socketPath = getSocketPath();
|
|
394
|
-
const isOverride = hasSocketOverride();
|
|
395
|
-
const autostart = shouldAutoStartDaemon();
|
|
396
|
-
log.info(
|
|
397
|
-
` Socket: ${socketPath}${
|
|
398
|
-
isOverride ? " (override via VELLUM_DAEMON_SOCKET)" : ""
|
|
399
|
-
}`,
|
|
400
|
-
);
|
|
401
|
-
log.info(` Autostart: ${autostart ? "enabled" : "disabled"}\n`);
|
|
402
|
-
|
|
403
|
-
// 1. Bun installed
|
|
404
|
-
try {
|
|
405
|
-
execSync("bun --version", { stdio: "pipe" });
|
|
406
|
-
pass("Bun is installed");
|
|
407
|
-
} catch {
|
|
408
|
-
fail("Bun is installed", "bun not found in PATH");
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
// 2. Provider/API key configured
|
|
412
|
-
const raw = loadRawConfig();
|
|
413
|
-
const provider =
|
|
414
|
-
typeof raw.provider === "string" ? raw.provider : "anthropic";
|
|
415
|
-
const providerEnvVar: Record<string, string> = {
|
|
416
|
-
anthropic: "ANTHROPIC_API_KEY",
|
|
417
|
-
openai: "OPENAI_API_KEY",
|
|
418
|
-
gemini: "GEMINI_API_KEY",
|
|
419
|
-
ollama: "OLLAMA_API_KEY",
|
|
420
|
-
fireworks: "FIREWORKS_API_KEY",
|
|
421
|
-
openrouter: "OPENROUTER_API_KEY",
|
|
422
|
-
};
|
|
423
|
-
const configKey = (raw.apiKeys as Record<string, string> | undefined)?.[
|
|
424
|
-
provider
|
|
425
|
-
];
|
|
426
|
-
const envVar = providerEnvVar[provider];
|
|
427
|
-
const envKey = envVar ? process.env[envVar] : undefined;
|
|
428
|
-
|
|
429
|
-
if (provider === "ollama") {
|
|
430
|
-
pass("Provider configured (Ollama; API key optional)");
|
|
431
|
-
} else if (envKey || configKey) {
|
|
432
|
-
pass("API key configured");
|
|
433
|
-
} else {
|
|
434
|
-
fail(
|
|
435
|
-
"API key configured",
|
|
436
|
-
envVar
|
|
437
|
-
? `set ${envVar} or run: vellum config set apiKeys.${provider} <key>`
|
|
438
|
-
: `set API key for provider "${provider}"`,
|
|
439
|
-
);
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
// 3. Daemon reachable
|
|
443
|
-
try {
|
|
444
|
-
const sock = getSocketPath();
|
|
445
|
-
if (!existsSync(sock)) {
|
|
446
|
-
fail("Daemon reachable", "socket not found (is the daemon running?)");
|
|
447
|
-
} else {
|
|
448
|
-
await new Promise<void>((resolve, reject) => {
|
|
449
|
-
const s = net.createConnection(sock);
|
|
450
|
-
const timer = setTimeout(() => {
|
|
451
|
-
s.destroy();
|
|
452
|
-
reject(new IpcError("timeout"));
|
|
453
|
-
}, 2000);
|
|
454
|
-
s.on("connect", () => {
|
|
455
|
-
clearTimeout(timer);
|
|
456
|
-
s.end();
|
|
457
|
-
resolve();
|
|
458
|
-
});
|
|
459
|
-
s.on("error", (err) => {
|
|
460
|
-
clearTimeout(timer);
|
|
461
|
-
reject(err);
|
|
462
|
-
});
|
|
463
|
-
});
|
|
464
|
-
pass("Daemon reachable");
|
|
465
|
-
}
|
|
466
|
-
} catch {
|
|
467
|
-
fail("Daemon reachable", "could not connect to daemon socket");
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
// 4. DB exists and readable
|
|
471
|
-
const dbPath = getDbPath();
|
|
472
|
-
if (existsSync(dbPath)) {
|
|
473
|
-
try {
|
|
474
|
-
const { Database } = await import("bun:sqlite");
|
|
475
|
-
const db = new Database(dbPath, { readonly: true });
|
|
476
|
-
db.query("SELECT 1").get();
|
|
477
|
-
db.close();
|
|
478
|
-
pass("Database exists and readable");
|
|
479
|
-
} catch {
|
|
480
|
-
fail(
|
|
481
|
-
"Database exists and readable",
|
|
482
|
-
"file exists but cannot be read",
|
|
483
|
-
);
|
|
484
|
-
}
|
|
485
|
-
} else {
|
|
486
|
-
fail("Database exists and readable", `not found at ${dbPath}`);
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
// 5. ~/.vellum/ directory structure (workspace layout)
|
|
490
|
-
const rootDir = getRootDir();
|
|
491
|
-
const dataDir = getDataDir();
|
|
492
|
-
const workspaceDir = getWorkspaceDir();
|
|
493
|
-
const requiredDirs = [
|
|
494
|
-
rootDir,
|
|
495
|
-
workspaceDir,
|
|
496
|
-
dataDir,
|
|
497
|
-
`${dataDir}/db`,
|
|
498
|
-
`${dataDir}/logs`,
|
|
499
|
-
getWorkspaceSkillsDir(),
|
|
500
|
-
getWorkspaceHooksDir(),
|
|
501
|
-
`${rootDir}/protected`,
|
|
502
|
-
];
|
|
503
|
-
const missing = requiredDirs.filter((d) => !existsSync(d));
|
|
504
|
-
if (missing.length === 0) {
|
|
505
|
-
pass("Directory structure exists");
|
|
506
|
-
} else {
|
|
507
|
-
fail("Directory structure exists", `missing: ${missing.join(", ")}`);
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
// 6. Disk space
|
|
511
|
-
try {
|
|
512
|
-
const output = execSync(`df -k "${rootDir}"`, {
|
|
513
|
-
stdio: "pipe",
|
|
514
|
-
encoding: "utf-8",
|
|
515
|
-
});
|
|
516
|
-
const lines = output.trim().split("\n");
|
|
517
|
-
if (lines.length >= 2) {
|
|
518
|
-
const cols = lines[1].trim().split(/\s+/);
|
|
519
|
-
const availKB = parseInt(cols[3], 10);
|
|
520
|
-
if (isNaN(availKB)) {
|
|
521
|
-
fail("Disk space", "could not parse available space");
|
|
522
|
-
} else if (availKB < 100 * 1024) {
|
|
523
|
-
fail(
|
|
524
|
-
"Disk space",
|
|
525
|
-
`only ${Math.round(availKB / 1024)}MB free (< 100MB)`,
|
|
526
|
-
);
|
|
527
|
-
} else {
|
|
528
|
-
pass(`Disk space (${Math.round(availKB / 1024)}MB free)`);
|
|
529
|
-
}
|
|
530
|
-
} else {
|
|
531
|
-
fail("Disk space", "unexpected df output");
|
|
532
|
-
}
|
|
533
|
-
} catch {
|
|
534
|
-
fail("Disk space", "could not check disk space");
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
// 7. Log file size
|
|
538
|
-
const logPath = getLogPath();
|
|
539
|
-
if (existsSync(logPath)) {
|
|
540
|
-
try {
|
|
541
|
-
const logStat = statSync(logPath);
|
|
542
|
-
const logSizeMB = logStat.size / (1024 * 1024);
|
|
543
|
-
if (logSizeMB > 50) {
|
|
544
|
-
fail("Log file size", `${logSizeMB.toFixed(1)}MB (> 50MB)`);
|
|
545
|
-
} else {
|
|
546
|
-
pass(`Log file size (${logSizeMB.toFixed(1)}MB)`);
|
|
547
|
-
}
|
|
548
|
-
} catch {
|
|
549
|
-
fail("Log file size", "could not stat log file");
|
|
550
|
-
}
|
|
551
|
-
} else {
|
|
552
|
-
pass("Log file size (no log file yet)");
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
// 8. DB integrity check
|
|
556
|
-
if (existsSync(dbPath)) {
|
|
557
|
-
try {
|
|
558
|
-
const { Database } = await import("bun:sqlite");
|
|
559
|
-
const db = new Database(dbPath, { readonly: true });
|
|
560
|
-
const result = db.query("PRAGMA integrity_check").get() as {
|
|
561
|
-
integrity_check: string;
|
|
562
|
-
} | null;
|
|
563
|
-
db.close();
|
|
564
|
-
if (result?.integrity_check === "ok") {
|
|
565
|
-
pass("Database integrity check");
|
|
566
|
-
} else {
|
|
567
|
-
fail(
|
|
568
|
-
"Database integrity check",
|
|
569
|
-
result?.integrity_check ?? "unknown result",
|
|
570
|
-
);
|
|
571
|
-
}
|
|
572
|
-
} catch (err) {
|
|
573
|
-
fail(
|
|
574
|
-
"Database integrity check",
|
|
575
|
-
err instanceof Error ? err.message : "unknown error",
|
|
576
|
-
);
|
|
577
|
-
}
|
|
578
|
-
} else {
|
|
579
|
-
fail("Database integrity check", "database file not found");
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
// 9. Socket permissions
|
|
583
|
-
const sockPath = getSocketPath();
|
|
584
|
-
if (existsSync(sockPath)) {
|
|
585
|
-
try {
|
|
586
|
-
const sockStat = statSync(sockPath);
|
|
587
|
-
const mode = sockStat.mode & 0o777;
|
|
588
|
-
if (mode === 0o600 || mode === 0o700) {
|
|
589
|
-
pass(`Socket permissions (${mode.toString(8).padStart(4, "0")})`);
|
|
590
|
-
} else {
|
|
591
|
-
fail(
|
|
592
|
-
"Socket permissions",
|
|
593
|
-
`expected 0600 or 0700, got 0${mode.toString(8)}`,
|
|
594
|
-
);
|
|
595
|
-
}
|
|
596
|
-
} catch {
|
|
597
|
-
fail("Socket permissions", "could not stat socket");
|
|
598
|
-
}
|
|
599
|
-
} else {
|
|
600
|
-
pass("Socket permissions (socket not present — daemon not running)");
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
// 10. Trust rule syntax
|
|
604
|
-
const trustPath = `${rootDir}/protected/trust.json`;
|
|
605
|
-
if (existsSync(trustPath)) {
|
|
606
|
-
try {
|
|
607
|
-
const rawTrust = readFileSync(trustPath, "utf-8");
|
|
608
|
-
const data = JSON.parse(rawTrust);
|
|
609
|
-
if (typeof data !== "object" || data == null) {
|
|
610
|
-
fail("Trust rule syntax", "trust.json is not a JSON object");
|
|
611
|
-
} else if (typeof data.version !== "number") {
|
|
612
|
-
fail("Trust rule syntax", 'missing or invalid "version" field');
|
|
613
|
-
} else if (!Array.isArray(data.rules)) {
|
|
614
|
-
fail("Trust rule syntax", 'missing or invalid "rules" array');
|
|
615
|
-
} else {
|
|
616
|
-
const invalid = data.rules.filter(
|
|
617
|
-
(r: unknown) =>
|
|
618
|
-
typeof r !== "object" ||
|
|
619
|
-
r == null ||
|
|
620
|
-
typeof (r as Record<string, unknown>).tool !== "string" ||
|
|
621
|
-
typeof (r as Record<string, unknown>).pattern !== "string" ||
|
|
622
|
-
typeof (r as Record<string, unknown>).scope !== "string",
|
|
623
|
-
);
|
|
624
|
-
if (invalid.length > 0) {
|
|
625
|
-
fail(
|
|
626
|
-
"Trust rule syntax",
|
|
627
|
-
`${invalid.length} rule(s) have invalid structure`,
|
|
628
|
-
);
|
|
629
|
-
} else {
|
|
630
|
-
pass(`Trust rule syntax (${data.rules.length} rule(s))`);
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
} catch (err) {
|
|
634
|
-
fail(
|
|
635
|
-
"Trust rule syntax",
|
|
636
|
-
err instanceof Error ? err.message : "could not parse",
|
|
637
|
-
);
|
|
638
|
-
}
|
|
639
|
-
} else {
|
|
640
|
-
pass("Trust rule syntax (no trust.json yet)");
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
// 11. WASM files
|
|
644
|
-
const wasmFiles = [
|
|
645
|
-
{ pkg: "web-tree-sitter", file: "web-tree-sitter.wasm" },
|
|
646
|
-
{ pkg: "tree-sitter-bash", file: "tree-sitter-bash.wasm" },
|
|
647
|
-
];
|
|
648
|
-
let wasmOk = true;
|
|
649
|
-
const missingWasm: string[] = [];
|
|
650
|
-
for (const wasm of wasmFiles) {
|
|
651
|
-
const dir = import.meta.dirname ?? __dirname;
|
|
652
|
-
let fullPath = `${dir}/../../node_modules/${wasm.pkg}/${wasm.file}`;
|
|
653
|
-
// In compiled binaries, fall back to Resources/ or next to the binary
|
|
654
|
-
if (!existsSync(fullPath) && dir.startsWith("/$bunfs/")) {
|
|
655
|
-
const { dirname: pathDirname, join: pathJoin } =
|
|
656
|
-
await import("node:path");
|
|
657
|
-
const execDir = pathDirname(process.execPath);
|
|
658
|
-
const resourcesPath = pathJoin(execDir, "..", "Resources", wasm.file);
|
|
659
|
-
fullPath = existsSync(resourcesPath)
|
|
660
|
-
? resourcesPath
|
|
661
|
-
: pathJoin(execDir, wasm.file);
|
|
662
|
-
}
|
|
663
|
-
if (!existsSync(fullPath)) {
|
|
664
|
-
missingWasm.push(wasm.file);
|
|
665
|
-
wasmOk = false;
|
|
666
|
-
} else {
|
|
667
|
-
try {
|
|
668
|
-
const wasmStat = statSync(fullPath);
|
|
669
|
-
if (wasmStat.size === 0) {
|
|
670
|
-
missingWasm.push(`${wasm} (empty)`);
|
|
671
|
-
wasmOk = false;
|
|
672
|
-
}
|
|
673
|
-
} catch {
|
|
674
|
-
missingWasm.push(`${wasm} (unreadable)`);
|
|
675
|
-
wasmOk = false;
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
}
|
|
679
|
-
if (wasmOk) {
|
|
680
|
-
pass("WASM files present and non-empty");
|
|
681
|
-
} else {
|
|
682
|
-
fail("WASM files", missingWasm.join(", "));
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
// 12. Browser runtime (Playwright + Chromium)
|
|
686
|
-
const { checkBrowserRuntime } =
|
|
687
|
-
await import("../tools/browser/runtime-check.js");
|
|
688
|
-
const browserStatus = await checkBrowserRuntime();
|
|
689
|
-
if (
|
|
690
|
-
browserStatus.playwrightAvailable &&
|
|
691
|
-
browserStatus.chromiumInstalled
|
|
692
|
-
) {
|
|
693
|
-
pass("Browser runtime (Playwright + Chromium)");
|
|
694
|
-
} else if (!browserStatus.playwrightAvailable) {
|
|
695
|
-
fail("Browser runtime", "playwright not available");
|
|
696
|
-
} else {
|
|
697
|
-
fail(
|
|
698
|
-
"Browser runtime",
|
|
699
|
-
browserStatus.error ?? "Chromium not installed",
|
|
700
|
-
);
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
// 13. Sandbox backend diagnostics
|
|
704
|
-
const { runSandboxDiagnostics } =
|
|
705
|
-
await import("../tools/terminal/sandbox-diagnostics.js");
|
|
706
|
-
const sandbox = runSandboxDiagnostics();
|
|
707
|
-
log.info(
|
|
708
|
-
`\n Sandbox: ${sandbox.config.enabled ? "enabled" : "disabled"}`,
|
|
709
|
-
);
|
|
710
|
-
log.info(` Reason: ${sandbox.activeBackendReason}`);
|
|
711
|
-
log.info("");
|
|
712
|
-
for (const check of sandbox.checks) {
|
|
713
|
-
if (check.ok) {
|
|
714
|
-
pass(check.label);
|
|
715
|
-
} else {
|
|
716
|
-
fail(check.label, check.detail);
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
});
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
export function registerCompletionsCommand(program: Command): void {
|
|
723
|
-
program
|
|
724
|
-
.command("completions")
|
|
725
|
-
.argument("<shell>", "Shell type: bash, zsh, or fish")
|
|
726
|
-
.description(
|
|
727
|
-
"Generate shell completion script (e.g. vellum completions bash >> ~/.bashrc)",
|
|
728
|
-
)
|
|
729
|
-
.action((shell: string) => {
|
|
730
|
-
const subcommands: Record<string, string[]> = {
|
|
731
|
-
sessions: ["list", "new", "export", "clear"],
|
|
732
|
-
config: ["set", "get", "list", "validate-allowlist"],
|
|
733
|
-
keys: ["list", "set", "delete"],
|
|
734
|
-
trust: ["list", "remove", "clear"],
|
|
735
|
-
memory: ["status", "backfill", "cleanup", "query", "rebuild-index"],
|
|
736
|
-
hooks: ["list", "enable", "disable", "install", "remove"],
|
|
737
|
-
contacts: ["list", "invites", "get", "merge"],
|
|
738
|
-
autonomy: ["get", "set"],
|
|
739
|
-
};
|
|
740
|
-
const topLevel = [
|
|
741
|
-
"dev",
|
|
742
|
-
"sessions",
|
|
743
|
-
"config",
|
|
744
|
-
"keys",
|
|
745
|
-
"trust",
|
|
746
|
-
"memory",
|
|
747
|
-
"hooks",
|
|
748
|
-
"contacts",
|
|
749
|
-
"autonomy",
|
|
750
|
-
"audit",
|
|
751
|
-
"doctor",
|
|
752
|
-
"completions",
|
|
753
|
-
"help",
|
|
754
|
-
];
|
|
755
|
-
|
|
756
|
-
switch (shell) {
|
|
757
|
-
case "bash":
|
|
758
|
-
process.stdout.write(generateBashCompletion(topLevel, subcommands));
|
|
759
|
-
break;
|
|
760
|
-
case "zsh":
|
|
761
|
-
process.stdout.write(generateZshCompletion(topLevel, subcommands));
|
|
762
|
-
break;
|
|
763
|
-
case "fish":
|
|
764
|
-
process.stdout.write(generateFishCompletion(topLevel, subcommands));
|
|
765
|
-
break;
|
|
766
|
-
default:
|
|
767
|
-
log.error(
|
|
768
|
-
`Unknown shell: ${shell}. Supported shells: bash, zsh, fish`,
|
|
769
|
-
);
|
|
770
|
-
process.exit(1);
|
|
771
|
-
}
|
|
772
|
-
});
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
function generateBashCompletion(
|
|
776
|
-
topLevel: string[],
|
|
777
|
-
subcommands: Record<string, string[]>,
|
|
778
|
-
): string {
|
|
779
|
-
const subcmdCases = Object.entries(subcommands)
|
|
780
|
-
.map(
|
|
781
|
-
([cmd, subs]) =>
|
|
782
|
-
` ${cmd}) COMPREPLY=( $(compgen -W "${subs.join(
|
|
783
|
-
" ",
|
|
784
|
-
)}" -- "$cur") ) ;;`,
|
|
785
|
-
)
|
|
786
|
-
.join("\n");
|
|
787
|
-
|
|
788
|
-
return `# vellum bash completion
|
|
789
|
-
# Add to ~/.bashrc: eval "$(vellum completions bash)"
|
|
790
|
-
_vellum_completions() {
|
|
791
|
-
local cur prev words cword
|
|
792
|
-
_init_completion || return
|
|
793
|
-
|
|
794
|
-
if [[ $cword -eq 1 ]]; then
|
|
795
|
-
COMPREPLY=( $(compgen -W "${topLevel.join(
|
|
796
|
-
" ",
|
|
797
|
-
)} --help --version" -- "$cur") )
|
|
798
|
-
return
|
|
799
|
-
fi
|
|
800
|
-
|
|
801
|
-
case "\${words[1]}" in
|
|
802
|
-
${subcmdCases}
|
|
803
|
-
audit) COMPREPLY=( $(compgen -W "--limit -l" -- "$cur") ) ;;
|
|
804
|
-
completions) COMPREPLY=( $(compgen -W "bash zsh fish" -- "$cur") ) ;;
|
|
805
|
-
esac
|
|
806
|
-
}
|
|
807
|
-
complete -F _vellum_completions vellum
|
|
808
|
-
`;
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
function generateZshCompletion(
|
|
812
|
-
topLevel: string[],
|
|
813
|
-
subcommands: Record<string, string[]>,
|
|
814
|
-
): string {
|
|
815
|
-
const subcmdCases = Object.entries(subcommands)
|
|
816
|
-
.map(([cmd, subs]) => ` ${cmd}) compadd ${subs.join(" ")} ;;`)
|
|
817
|
-
.join("\n");
|
|
818
|
-
|
|
819
|
-
return `#compdef vellum
|
|
820
|
-
# vellum zsh completion
|
|
821
|
-
# Add to ~/.zshrc: eval "$(vellum completions zsh)"
|
|
822
|
-
_vellum() {
|
|
823
|
-
local -a commands
|
|
824
|
-
commands=(
|
|
825
|
-
'dev:Run daemon in dev mode with auto-restart'
|
|
826
|
-
'sessions:Manage sessions'
|
|
827
|
-
'config:Manage configuration'
|
|
828
|
-
'keys:Manage API keys in secure storage'
|
|
829
|
-
'trust:Manage trust rules'
|
|
830
|
-
'memory:Manage long-term memory'
|
|
831
|
-
'hooks:Manage hooks'
|
|
832
|
-
'contacts:Manage the contact graph'
|
|
833
|
-
'autonomy:View and configure autonomy tiers'
|
|
834
|
-
'audit:Show recent tool invocations'
|
|
835
|
-
'doctor:Run diagnostic checks'
|
|
836
|
-
'completions:Generate shell completion script'
|
|
837
|
-
'help:Display help'
|
|
838
|
-
)
|
|
839
|
-
|
|
840
|
-
if (( CURRENT == 2 )); then
|
|
841
|
-
_describe 'command' commands
|
|
842
|
-
_arguments '--help[Show help]' '--version[Show version]'
|
|
843
|
-
return
|
|
844
|
-
fi
|
|
845
|
-
|
|
846
|
-
case "\${words[2]}" in
|
|
847
|
-
${subcmdCases}
|
|
848
|
-
audit) _arguments '-l[Number of entries]' '--limit[Number of entries]' ;;
|
|
849
|
-
completions) compadd bash zsh fish ;;
|
|
850
|
-
esac
|
|
851
|
-
}
|
|
852
|
-
compdef _vellum vellum
|
|
853
|
-
`;
|
|
854
|
-
}
|
|
855
|
-
|
|
856
|
-
function generateFishCompletion(
|
|
857
|
-
topLevel: string[],
|
|
858
|
-
subcommands: Record<string, string[]>,
|
|
859
|
-
): string {
|
|
860
|
-
let script = `# vellum fish completion
|
|
861
|
-
# Add to ~/.config/fish/completions/vellum.fish or eval: vellum completions fish | source
|
|
862
|
-
`;
|
|
863
|
-
|
|
864
|
-
script += `complete -c vellum -f\n`;
|
|
865
|
-
|
|
866
|
-
const descriptions: Record<string, string> = {
|
|
867
|
-
dev: "Run daemon in dev mode with auto-restart",
|
|
868
|
-
sessions: "Manage sessions",
|
|
869
|
-
config: "Manage configuration",
|
|
870
|
-
keys: "Manage API keys in secure storage",
|
|
871
|
-
trust: "Manage trust rules",
|
|
872
|
-
memory: "Manage long-term memory",
|
|
873
|
-
hooks: "Manage hooks",
|
|
874
|
-
contacts: "Manage the contact graph",
|
|
875
|
-
autonomy: "View and configure autonomy tiers",
|
|
876
|
-
audit: "Show recent tool invocations",
|
|
877
|
-
doctor: "Run diagnostic checks",
|
|
878
|
-
completions: "Generate shell completion script",
|
|
879
|
-
help: "Display help",
|
|
880
|
-
};
|
|
881
|
-
|
|
882
|
-
for (const cmd of topLevel) {
|
|
883
|
-
const desc = descriptions[cmd] ?? "";
|
|
884
|
-
script += `complete -c vellum -n '__fish_use_subcommand' -a '${cmd}' -d '${desc}'\n`;
|
|
885
|
-
}
|
|
886
|
-
script += `complete -c vellum -n '__fish_use_subcommand' -l help -d 'Show help'\n`;
|
|
887
|
-
script += `complete -c vellum -n '__fish_use_subcommand' -l version -d 'Show version'\n`;
|
|
888
|
-
|
|
889
|
-
for (const [cmd, subs] of Object.entries(subcommands)) {
|
|
890
|
-
for (const sub of subs) {
|
|
891
|
-
script += `complete -c vellum -n '__fish_seen_subcommand_from ${cmd}' -a '${sub}'\n`;
|
|
892
|
-
}
|
|
893
|
-
}
|
|
894
|
-
|
|
895
|
-
script += `complete -c vellum -n '__fish_seen_subcommand_from audit' -s l -l limit -d 'Number of entries'\n`;
|
|
896
|
-
script += `complete -c vellum -n '__fish_seen_subcommand_from completions' -a 'bash zsh fish'\n`;
|
|
897
|
-
|
|
898
|
-
return script;
|
|
899
|
-
}
|