Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

fix: email command no longer silently falls back to workspaces[0]

Gener40fb035df24b
diff --git a/src/cli/commands/email.ts b/src/cli/commands/email.ts
index 61decaeb0..38ad41258 100644
--- a/src/cli/commands/email.ts
+++ b/src/cli/commands/email.ts
@@ -83,14 +83,34 @@ function resolveClientOpts(command: Command, opts: { workspace?: string; agentId
const serverUrl = parentOpts.server || cfg.server_url;
const workspaces = cfg.watched_workspaces || [];
- // Resolve workspace: explicit flag > lookup by agent_id > first workspace
+ // Resolve workspace: explicit flag > lookup by agent_id > single workspace
let ws;
if (opts.workspace) {
ws = workspaces.find((w) => w.id === opts.workspace);
+ if (!ws) {
+ console.error(`Error: workspace ${opts.workspace} not found in config.`);
+ process.exit(1);
+ }
} else if (opts.agentId) {
ws = workspaces.find((w) => w.agent_ids?.includes(opts.agentId!));
+ if (!ws) {
+ if (workspaces.length === 1) {
+ ws = workspaces[0];
+ } else {
+ console.error(
+ `Error: agent ${opts.agentId} not found in any registered workspace. Use --workspace to specify.`,
+ );
+ process.exit(1);
+ }
+ }
+ } else if (workspaces.length === 1) {
+ ws = workspaces[0];
+ } else {
+ console.error(
+ `Error: multiple workspaces registered. Use --workspace to specify which one.`,
+ );
+ process.exit(1);
}
- if (!ws) ws = workspaces[0];
const token = ws?.token;