@hasna/accounts 0.1.12 → 0.1.14

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/README.md CHANGED
@@ -97,8 +97,8 @@ Implementation details: [docs/IMPLEMENT.md](docs/IMPLEMENT.md).
97
97
  | `accounts login <name> --tool <tool>` | Launch the tool's login flow in an isolated profile dir. |
98
98
  | `accounts apply <name> --tool claude` | Apply profile auth to live Claude paths (requires snapshot; Claude-only). |
99
99
  | `accounts pick` | Interactive picker; default applies. `--env`, `--no-act`. |
100
- | `accounts switch <name> --tool <tool>` | Switch profile and print a restart/resume command. Add `--resume`; add `--launch` to run it. |
101
- | `accounts switch <name> --tool <tool> --supervisor` | Ask a running `accounts run <tool>` supervisor to restart under that profile. |
100
+ | `accounts switch <name> --tool <tool>` | Switch profile and print a restart/resume command. Add `--resume`, `--launch`, or `--permissions <preset>`. |
101
+ | `accounts switch <name> --tool <tool> --supervisor` | Ask a running `accounts run <tool>` supervisor to restart under that profile. Supports `--permissions <preset>`. |
102
102
  | `accounts use <name> --tool <tool>` | Mark profile active; prints apply/env hints. |
103
103
  | `accounts list` (`ls`) | List profiles (`●` active, `◉` applied, `●◉` both). |
104
104
  | `accounts show <name> --tool <tool>` | Profile details including active/applied flags. |
@@ -106,8 +106,8 @@ Implementation details: [docs/IMPLEMENT.md](docs/IMPLEMENT.md).
106
106
  | `accounts active [tool]` | Print active profile name (scripting). |
107
107
  | `accounts applied [tool]` | Print applied profile name (scripting). |
108
108
  | `accounts env [name] --tool <tool>` | Print one or more `export ...` lines for the profile. |
109
- | `accounts launch <name> --tool <tool>` | Launch tool once with profile env. |
110
- | `accounts run <tool> [args...]` | Run a tool under the supervisor so MCP/CLI can switch and restart it. |
109
+ | `accounts launch <name> --tool <tool>` | Launch tool once with profile env. Supports `--permissions <preset>`. |
110
+ | `accounts run <tool> [args...]` | Run a tool under the supervisor so MCP/CLI can switch and restart it. Supports `--permissions <preset>`. |
111
111
  | `accounts supervisor status [tool]` | Show running supervisors. |
112
112
  | `accounts supervisor switch <name> --tool <tool>` | Switch a running supervisor to another profile. |
113
113
  | `accounts supervisor stop <tool>` | Stop a running supervisor and its child process. |
@@ -159,11 +159,18 @@ Human equivalent:
159
159
  ```bash
160
160
  accounts switch account001 --tool claude --resume
161
161
  accounts switch account001 --tool claude --resume --launch
162
+ accounts switch account001 --tool claude --resume --permissions dangerous
162
163
  accounts switch account001 --tool claude --supervisor
163
164
  accounts switch codex-work --tool codex --resume
164
165
  accounts switch ops --tool opencode --resume
165
166
  ```
166
167
 
168
+ `--permissions <preset>` maps a permission mode to the tool's own flags. For
169
+ example, `--permissions dangerous` launches Claude/Takumi with
170
+ `--dangerously-skip-permissions`, Codex with
171
+ `--dangerously-bypass-approvals-and-sandbox`, and Gemini/Hermes/Kimi with their
172
+ YOLO mode flags. Unsupported tools fail with a list of configured presets.
173
+
167
174
  ## Shell hook (optional)
168
175
 
169
176
  ```bash
@@ -233,6 +240,7 @@ For Grok Build, prefer `accounts launch` or `accounts shell`; exporting `HOME`
233
240
  globally is intentionally not recommended.
234
241
 
235
242
  Custom tools can join supervised resume switching with `accounts tools add ... --resume-arg <arg>`.
243
+ They can also define permission presets with `--permission-arg preset=--flag`.
236
244
 
237
245
  ## Library
238
246
 
package/dist/cli.js CHANGED
@@ -41977,6 +41977,7 @@ var toolDefSchema = exports_external.object({
41977
41977
  loginArgs: exports_external.array(exports_external.string()).optional(),
41978
41978
  loginHint: exports_external.string().optional(),
41979
41979
  resumeArgs: exports_external.array(exports_external.string()).optional(),
41980
+ permissionArgs: exports_external.record(exports_external.array(exports_external.string())).optional(),
41980
41981
  accountFile: exports_external.string().optional(),
41981
41982
  emailPath: exports_external.array(exports_external.string()).optional()
41982
41983
  });
@@ -42304,6 +42305,15 @@ var BUILTIN_TOOLS = [
42304
42305
  bin: "claude",
42305
42306
  loginHint: "run /login inside Claude, then /exit when done",
42306
42307
  resumeArgs: ["--continue"],
42308
+ permissionArgs: {
42309
+ dangerous: ["--dangerously-skip-permissions"],
42310
+ "allow-dangerous": ["--allow-dangerously-skip-permissions"],
42311
+ bypass: ["--permission-mode", "bypassPermissions"],
42312
+ auto: ["--permission-mode", "auto"],
42313
+ "accept-edits": ["--permission-mode", "acceptEdits"],
42314
+ "dont-ask": ["--permission-mode", "dontAsk"],
42315
+ plan: ["--permission-mode", "plan"]
42316
+ },
42307
42317
  accountFile: ".claude.json",
42308
42318
  emailPath: ["oauthAccount", "emailAddress"]
42309
42319
  },
@@ -42315,7 +42325,10 @@ var BUILTIN_TOOLS = [
42315
42325
  bin: "codex",
42316
42326
  loginArgs: ["login"],
42317
42327
  loginHint: "complete the Codex login flow for this CODEX_HOME",
42318
- resumeArgs: ["resume", "--last"]
42328
+ resumeArgs: ["resume", "--last"],
42329
+ permissionArgs: {
42330
+ dangerous: ["--dangerously-bypass-approvals-and-sandbox"]
42331
+ }
42319
42332
  },
42320
42333
  {
42321
42334
  id: "takumi",
@@ -42325,6 +42338,15 @@ var BUILTIN_TOOLS = [
42325
42338
  bin: "takumi",
42326
42339
  loginHint: "complete Takumi auth in this TAKUMI_CONFIG_DIR",
42327
42340
  resumeArgs: ["--continue"],
42341
+ permissionArgs: {
42342
+ dangerous: ["--dangerously-skip-permissions"],
42343
+ "allow-dangerous": ["--allow-dangerously-skip-permissions"],
42344
+ bypass: ["--permission-mode", "bypassPermissions"],
42345
+ auto: ["--permission-mode", "auto"],
42346
+ "accept-edits": ["--permission-mode", "acceptEdits"],
42347
+ "dont-ask": ["--permission-mode", "dontAsk"],
42348
+ plan: ["--permission-mode", "plan"]
42349
+ },
42328
42350
  accountFile: ".claude.json",
42329
42351
  emailPath: ["oauthAccount", "emailAddress"]
42330
42352
  },
@@ -42334,7 +42356,13 @@ var BUILTIN_TOOLS = [
42334
42356
  envVar: "GEMINI_CONFIG_DIR",
42335
42357
  defaultDir: join3(homedir3(), ".gemini"),
42336
42358
  bin: "gemini",
42337
- loginHint: "complete Gemini auth in this GEMINI_CONFIG_DIR"
42359
+ loginHint: "complete Gemini auth in this GEMINI_CONFIG_DIR",
42360
+ permissionArgs: {
42361
+ dangerous: ["--yolo"],
42362
+ yolo: ["--yolo"],
42363
+ "auto-edit": ["--approval-mode", "auto_edit"],
42364
+ plan: ["--approval-mode", "plan"]
42365
+ }
42338
42366
  },
42339
42367
  {
42340
42368
  id: "opencode",
@@ -42373,7 +42401,11 @@ var BUILTIN_TOOLS = [
42373
42401
  envVar: "HERMES_HOME",
42374
42402
  defaultDir: join3(homedir3(), ".hermes"),
42375
42403
  bin: "hermes",
42376
- loginHint: "complete Hermes auth in this HERMES_HOME"
42404
+ loginHint: "complete Hermes auth in this HERMES_HOME",
42405
+ permissionArgs: {
42406
+ dangerous: ["--yolo"],
42407
+ yolo: ["--yolo"]
42408
+ }
42377
42409
  },
42378
42410
  {
42379
42411
  id: "kimi",
@@ -42382,7 +42414,13 @@ var BUILTIN_TOOLS = [
42382
42414
  defaultDir: join3(homedir3(), ".kimi-code"),
42383
42415
  bin: "kimi",
42384
42416
  loginArgs: ["login"],
42385
- loginHint: "complete kimi login for this KIMI_CODE_HOME"
42417
+ loginHint: "complete kimi login for this KIMI_CODE_HOME",
42418
+ permissionArgs: {
42419
+ dangerous: ["--yolo"],
42420
+ yolo: ["--yolo"],
42421
+ auto: ["--auto"],
42422
+ plan: ["--plan"]
42423
+ }
42386
42424
  },
42387
42425
  {
42388
42426
  id: "grok",
@@ -42395,6 +42433,43 @@ var BUILTIN_TOOLS = [
42395
42433
  }
42396
42434
  ];
42397
42435
  var DEFAULT_TOOL = "claude";
42436
+ var PERMISSION_ALIASES = new Map([
42437
+ ["danger", "dangerous"],
42438
+ ["dangerously-skip-permissions", "dangerous"],
42439
+ ["skip-permissions", "dangerous"],
42440
+ ["skip", "dangerous"],
42441
+ ["bypasspermissions", "bypass"],
42442
+ ["bypass-permissions", "bypass"],
42443
+ ["acceptedits", "accept-edits"],
42444
+ ["accept-edit", "accept-edits"],
42445
+ ["autoedit", "auto-edit"],
42446
+ ["auto-edits", "auto-edit"],
42447
+ ["auto_edit", "auto-edit"],
42448
+ ["dontask", "dont-ask"],
42449
+ ["dont-ask-permissions", "dont-ask"]
42450
+ ]);
42451
+ function normalizePermissionPreset(value) {
42452
+ const normalized = value.trim().replace(/^--/, "").replaceAll("_", "-").toLowerCase();
42453
+ return PERMISSION_ALIASES.get(normalized) ?? normalized;
42454
+ }
42455
+ function permissionArgsFor(tool, permissions) {
42456
+ if (!permissions)
42457
+ return [];
42458
+ const preset = normalizePermissionPreset(permissions);
42459
+ if (preset === "default" || preset === "none" || preset === "off")
42460
+ return [];
42461
+ const args = tool.permissionArgs?.[preset];
42462
+ if (!args) {
42463
+ const supported = Object.keys(tool.permissionArgs ?? {}).sort();
42464
+ const suffix = supported.length > 0 ? ` Supported permissions: ${supported.join(", ")}.` : " No permission presets are configured.";
42465
+ throw new AccountsError(`tool "${tool.id}" does not support permissions "${permissions}".${suffix}`);
42466
+ }
42467
+ return args;
42468
+ }
42469
+ function mergeToolArgs(tool, args, opts = {}) {
42470
+ const permissionArgs = permissionArgsFor(tool, opts.permissions).filter((arg) => !args.includes(arg));
42471
+ return [...permissionArgs, ...args];
42472
+ }
42398
42473
  var BUILTIN_IDS = new Set(BUILTIN_TOOLS.map((t) => t.id));
42399
42474
  function isBuiltinTool(id) {
42400
42475
  return BUILTIN_IDS.has(id);
@@ -42760,6 +42835,22 @@ function readKeychainAccount() {
42760
42835
  return;
42761
42836
  }
42762
42837
  }
42838
+ function bufferText(value) {
42839
+ if (typeof value === "string")
42840
+ return value;
42841
+ if (value instanceof Uint8Array)
42842
+ return new TextDecoder().decode(value);
42843
+ return;
42844
+ }
42845
+ function keychainWriteFailureMessage(err) {
42846
+ const record = err && typeof err === "object" ? err : {};
42847
+ const stderr = bufferText(record.stderr);
42848
+ const stdout = bufferText(record.stdout);
42849
+ const detail = (stderr || stdout || "").split(/\r?\n/).map((line) => line.trim()).filter(Boolean).at(-1);
42850
+ if (detail)
42851
+ return detail;
42852
+ return typeof record.status === "number" ? `security exited with status ${record.status}` : "security command failed";
42853
+ }
42763
42854
  function writeClaudeKeychain(cred) {
42764
42855
  if (!keychainSupported()) {
42765
42856
  throw new AccountsError("macOS keychain is only available on darwin");
@@ -42773,7 +42864,7 @@ function writeClaudeKeychain(cred) {
42773
42864
  stdio: ["ignore", "pipe", "pipe"]
42774
42865
  });
42775
42866
  } catch (err) {
42776
- throw new AccountsError(`keychain write failed: ${err.message}`);
42867
+ throw new AccountsError(`keychain write failed: ${keychainWriteFailureMessage(err)}`);
42777
42868
  }
42778
42869
  }
42779
42870
 
@@ -43441,7 +43532,8 @@ function commandLine(env2, command) {
43441
43532
  return `${formatEnvAssignments(env2)} ${command.map(shellQuote).join(" ")}`.trim();
43442
43533
  }
43443
43534
  function commandFor(tool, opts) {
43444
- return [tool.bin, ...opts.resume ? tool.resumeArgs ?? [] : [], ...opts.args ?? []];
43535
+ const args = [...opts.resume ? tool.resumeArgs ?? [] : [], ...opts.args ?? []];
43536
+ return [tool.bin, ...mergeToolArgs(tool, args, { permissions: opts.permissions })];
43445
43537
  }
43446
43538
  function switchProfile(name, opts = {}) {
43447
43539
  const profile = getProfile(name, opts.tool);
@@ -43470,6 +43562,7 @@ function switchProfile(name, opts = {}) {
43470
43562
  exports: formatExportLines(env2),
43471
43563
  command,
43472
43564
  commandLine: commandLine(env2, command),
43565
+ ...opts.permissions ? { permissions: normalizePermissionPreset(opts.permissions) } : {},
43473
43566
  restartRequired,
43474
43567
  message
43475
43568
  };
@@ -43795,7 +43888,8 @@ async function runSupervisedTool(initialProfile, tool, initialArgs = [], opts =
43795
43888
  tool: tool.id,
43796
43889
  mode: request.mode ?? "auto",
43797
43890
  resume: request.resume ?? true,
43798
- args: request.args ?? []
43891
+ args: request.args ?? [],
43892
+ permissions: request.permissions
43799
43893
  });
43800
43894
  log(`accounts supervisor: switching ${tool.id} to ${result.profile.name}`);
43801
43895
  setTimeout(() => void restartWith(result), 0);
@@ -43887,6 +43981,20 @@ function printStorageSyncResult(result, json) {
43887
43981
  console.log(source_default.green(`pushed ${result.pushed}, pulled ${result.pulled}`));
43888
43982
  console.log(source_default.dim(`key: ${result.key}`));
43889
43983
  }
43984
+ function parsePermissionArgs(entries) {
43985
+ const permissionArgs = {};
43986
+ for (const entry of entries ?? []) {
43987
+ const idx = entry.indexOf("=");
43988
+ if (idx <= 0)
43989
+ die(`invalid --permission-arg ${entry}; expected PRESET=ARG`);
43990
+ const preset = normalizePermissionPreset(entry.slice(0, idx));
43991
+ const arg = entry.slice(idx + 1);
43992
+ if (!arg)
43993
+ die(`invalid --permission-arg ${entry}; expected PRESET=ARG`);
43994
+ (permissionArgs[preset] ??= []).push(arg);
43995
+ }
43996
+ return permissionArgs;
43997
+ }
43890
43998
  program2.name("accounts").description("Manage and switch between multiple Claude Code (and other AI tool) profiles/accounts.").version(getVersion());
43891
43999
  program2.command("add").argument("<name>", "profile name (lowercase, hyphenated)").description("create a new profile with an isolated config dir").option("-t, --tool <tool>", "tool the profile is for", DEFAULT_TOOL).option("-e, --email <email>", "account email (auto-detected when omitted)").option("-d, --dir <path>", "config dir to use (default: managed dir under ~/.hasna/accounts)").option("--description <text>", "free-text description").action(action((name, opts) => {
43892
44000
  const p = addProfile({ name, tool: opts.tool, email: opts.email, dir: opts.dir, description: opts.description });
@@ -44017,12 +44125,20 @@ program2.command("applied").argument("[tool]", "tool id (default: claude)").desc
44017
44125
  die(`no applied profile for "${tool}". Run \`accounts apply <name>\` first.`);
44018
44126
  console.log(p.name);
44019
44127
  }));
44020
- program2.command("switch").argument("<name>", "profile name").argument("[args...]", "extra args passed when printing/launching the tool").description("switch to a profile and print a restart/resume command; use --launch to run it").option("-t, --tool <tool>", "tool when the profile name exists for multiple tools").option("--mode <mode>", "switch mode: auto, apply, env, active", "auto").option("--resume", "include the tool's resume/continue args in the handoff command").option("--launch", "launch the tool after switching").option("--supervisor", "ask a running accounts supervisor to restart the tool").option("--json", "output JSON").action(action(async (name, args, opts) => {
44128
+ program2.command("switch").argument("<name>", "profile name").argument("[args...]", "extra args passed when printing/launching the tool").description("switch to a profile and print a restart/resume command; use --launch to run it").option("-t, --tool <tool>", "tool when the profile name exists for multiple tools").option("--mode <mode>", "switch mode: auto, apply, env, active", "auto").option("--resume", "include the tool's resume/continue args in the handoff command").option("--permissions <preset>", "tool-specific permission preset, e.g. dangerous").option("--launch", "launch the tool after switching").option("--supervisor", "ask a running accounts supervisor to restart the tool").option("--json", "output JSON").action(action(async (name, args, opts) => {
44021
44129
  if (opts.supervisor && opts.launch)
44022
44130
  die("--supervisor and --launch cannot be used together");
44023
44131
  if (opts.supervisor) {
44024
44132
  const profile = getProfile(name, opts.tool);
44025
- const response = await sendSupervisorRequest(profile.tool, { type: "switch_profile", name: profile.name, tool: profile.tool, mode: opts.mode, resume: opts.resume ?? true, args }, { allowMissing: true });
44133
+ const response = await sendSupervisorRequest(profile.tool, {
44134
+ type: "switch_profile",
44135
+ name: profile.name,
44136
+ tool: profile.tool,
44137
+ mode: opts.mode,
44138
+ resume: opts.resume ?? true,
44139
+ args,
44140
+ permissions: opts.permissions
44141
+ }, { allowMissing: true });
44026
44142
  if (!response) {
44027
44143
  die(`no running accounts supervisor for ${getTool(profile.tool).label}. Start one with \`accounts run ${profile.tool}\`.`);
44028
44144
  }
@@ -44038,7 +44154,13 @@ program2.command("switch").argument("<name>", "profile name").argument("[args...
44038
44154
  }
44039
44155
  return;
44040
44156
  }
44041
- const result = switchProfile(name, { tool: opts.tool, mode: opts.mode, resume: opts.resume, args });
44157
+ const result = switchProfile(name, {
44158
+ tool: opts.tool,
44159
+ mode: opts.mode,
44160
+ resume: opts.resume,
44161
+ args,
44162
+ permissions: opts.permissions
44163
+ });
44042
44164
  if (opts.json) {
44043
44165
  console.log(JSON.stringify(result, null, 2));
44044
44166
  } else {
@@ -44084,13 +44206,14 @@ program2.command("env").argument("[name]", "profile name (defaults to the active
44084
44206
  const tool = getTool(profile.tool);
44085
44207
  console.log(formatExportLines(profileEnv(profile, tool)));
44086
44208
  }));
44087
- program2.command("launch").argument("<name>", "profile name").argument("[args...]", "extra args passed to the tool binary").description("launch the tool's binary with the profile's config dir active").option("-t, --tool <tool>", "tool when the profile name exists for multiple tools").action(action((name, args, opts) => {
44209
+ program2.command("launch").argument("<name>", "profile name").argument("[args...]", "extra args passed to the tool binary").description("launch the tool's binary with the profile's config dir active").option("-t, --tool <tool>", "tool when the profile name exists for multiple tools").option("--permissions <preset>", "tool-specific permission preset, e.g. dangerous").action(action((name, args, opts) => {
44088
44210
  const profile = getProfile(name, opts.tool);
44089
44211
  const tool = getTool(profile.tool);
44090
44212
  const env2 = profileEnv(profile, tool);
44213
+ const launchArgs = mergeToolArgs(tool, args, { permissions: opts.permissions });
44091
44214
  useProfile(name, tool.id);
44092
- console.log(source_default.dim(`→ ${formatEnvAssignments(env2)} ${tool.bin} ${args.join(" ")}`));
44093
- const res = spawnSync2(tool.bin, args, {
44215
+ console.log(source_default.dim(`→ ${formatEnvAssignments(env2)} ${tool.bin} ${launchArgs.join(" ")}`));
44216
+ const res = spawnSync2(tool.bin, launchArgs, {
44094
44217
  stdio: "inherit",
44095
44218
  env: { ...process.env, ...env2 }
44096
44219
  });
@@ -44098,9 +44221,11 @@ program2.command("launch").argument("<name>", "profile name").argument("[args...
44098
44221
  die(`failed to launch ${tool.bin}: ${res.error.message}`);
44099
44222
  process.exit(res.status ?? 0);
44100
44223
  }));
44101
- program2.command("run").argument("<target>", "tool id to supervise (claude, codex, opencode...) or a profile name").argument("[args...]", "extra args passed to the tool binary").description("run a tool under the accounts supervisor so MCP can switch/restart it").option("-p, --profile <name>", "profile to run when target is a tool id").option("-t, --tool <tool>", "tool when target is a profile name").option("--resume", "start with the tool's resume/continue args").action(action(async (target, args, opts) => {
44224
+ program2.command("run").argument("<target>", "tool id to supervise (claude, codex, opencode...) or a profile name").argument("[args...]", "extra args passed to the tool binary").description("run a tool under the accounts supervisor so MCP can switch/restart it").option("-p, --profile <name>", "profile to run when target is a tool id").option("-t, --tool <tool>", "tool when target is a profile name").option("--resume", "start with the tool's resume/continue args").option("--permissions <preset>", "tool-specific permission preset, e.g. dangerous").action(action(async (target, args, opts) => {
44102
44225
  const plan = resolveSupervisorLaunch(target, { profile: opts.profile, tool: opts.tool });
44103
- const runArgs = [...opts.resume ? plan.tool.resumeArgs ?? [] : [], ...args];
44226
+ const runArgs = mergeToolArgs(plan.tool, [...opts.resume ? plan.tool.resumeArgs ?? [] : [], ...args], {
44227
+ permissions: opts.permissions
44228
+ });
44104
44229
  console.error(source_default.green(`✓ accounts supervisor running ${plan.tool.label} as ${source_default.bold(plan.profile.name)}`));
44105
44230
  console.error(source_default.dim(` control: accounts supervisor status ${plan.tool.id}`));
44106
44231
  console.error(source_default.dim(` switch: accounts switch <profile> --tool ${plan.tool.id} --supervisor`));
@@ -44133,9 +44258,17 @@ supervisor.command("status").argument("[tool]", "tool id").description("show run
44133
44258
  console.log(source_default.dim(` ${state2.command.join(" ")}`));
44134
44259
  }
44135
44260
  }));
44136
- supervisor.command("switch").argument("<name>", "profile name").argument("[args...]", "extra args passed after resume/continue args").description("switch a running supervisor to another profile").option("-t, --tool <tool>", "tool when the profile name exists for multiple tools").option("--mode <mode>", "switch mode: auto, apply, env, active", "auto").option("--no-resume", "restart without the tool's resume/continue args").option("--json", "output JSON").action(action(async (name, args, opts) => {
44261
+ supervisor.command("switch").argument("<name>", "profile name").argument("[args...]", "extra args passed after resume/continue args").description("switch a running supervisor to another profile").option("-t, --tool <tool>", "tool when the profile name exists for multiple tools").option("--mode <mode>", "switch mode: auto, apply, env, active", "auto").option("--no-resume", "restart without the tool's resume/continue args").option("--permissions <preset>", "tool-specific permission preset, e.g. dangerous").option("--json", "output JSON").action(action(async (name, args, opts) => {
44137
44262
  const profile = getProfile(name, opts.tool);
44138
- const response = await sendSupervisorRequest(profile.tool, { type: "switch_profile", name: profile.name, tool: profile.tool, mode: opts.mode, resume: opts.resume !== false, args }, { allowMissing: true });
44263
+ const response = await sendSupervisorRequest(profile.tool, {
44264
+ type: "switch_profile",
44265
+ name: profile.name,
44266
+ tool: profile.tool,
44267
+ mode: opts.mode,
44268
+ resume: opts.resume !== false,
44269
+ args,
44270
+ permissions: opts.permissions
44271
+ }, { allowMissing: true });
44139
44272
  if (!response)
44140
44273
  die(`no running accounts supervisor for ${getTool(profile.tool).label}`);
44141
44274
  if (!response.ok)
@@ -44271,10 +44404,12 @@ tools.command("list", { isDefault: true }).description("list supported tools (bu
44271
44404
  for (const t of all) {
44272
44405
  const tag = isBuiltinTool(t.id) ? source_default.dim("built-in") : source_default.magenta("custom");
44273
44406
  const envNames = [t.envVar, ...Object.keys(t.extraEnv ?? {})].join(", ");
44274
- console.log(`${source_default.cyan(t.id.padEnd(10))} ${t.label.padEnd(16)} ${source_default.dim(envNames)} → ${source_default.dim(t.defaultDir)} ${tag}`);
44407
+ const permissions = Object.keys(t.permissionArgs ?? {});
44408
+ const permissionsHint = permissions.length > 0 ? source_default.dim(` permissions: ${permissions.sort().join(",")}`) : "";
44409
+ console.log(`${source_default.cyan(t.id.padEnd(10))} ${t.label.padEnd(16)} ${source_default.dim(envNames)} → ${source_default.dim(t.defaultDir)} ${tag}${permissionsHint}`);
44275
44410
  }
44276
44411
  }));
44277
- tools.command("add").argument("<id>", "tool id, e.g. cursor").description("register a custom tool/app so profiles can target it").requiredOption("--label <label>", 'display name, e.g. "Cursor"').requiredOption("--env-var <VAR>", "env var that points the tool at its config dir").requiredOption("--bin <bin>", "binary to launch").option("--default-dir <path>", "default config dir (default: ~/.<id>)").option("--extra-env <VAR=VALUE...>", "additional env var templates; supports {profileDir}, {profileName}, {toolId}").option("--login-arg <arg...>", "arguments for `accounts login <profile> --tool <id>`").option("--resume-arg <arg...>", "arguments for supervised resume/restart, e.g. --continue").option("--account-file <file>", "file inside the config dir holding the email").option("--email-path <path>", "dot-path to the email inside that file (e.g. account.email)").action(action((id, opts) => {
44412
+ tools.command("add").argument("<id>", "tool id, e.g. cursor").description("register a custom tool/app so profiles can target it").requiredOption("--label <label>", 'display name, e.g. "Cursor"').requiredOption("--env-var <VAR>", "env var that points the tool at its config dir").requiredOption("--bin <bin>", "binary to launch").option("--default-dir <path>", "default config dir (default: ~/.<id>)").option("--extra-env <VAR=VALUE...>", "additional env var templates; supports {profileDir}, {profileName}, {toolId}").option("--login-arg <arg...>", "arguments for `accounts login <profile> --tool <id>`").option("--resume-arg <arg...>", "arguments for supervised resume/restart, e.g. --continue").option("--permission-arg <preset=arg...>", "tool permission preset args, e.g. dangerous=--yolo").option("--account-file <file>", "file inside the config dir holding the email").option("--email-path <path>", "dot-path to the email inside that file (e.g. account.email)").action(action((id, opts) => {
44278
44413
  const extraEnv = {};
44279
44414
  for (const entry of opts.extraEnv ?? []) {
44280
44415
  const idx = entry.indexOf("=");
@@ -44282,6 +44417,7 @@ tools.command("add").argument("<id>", "tool id, e.g. cursor").description("regis
44282
44417
  die(`invalid --extra-env ${entry}; expected VAR=VALUE`);
44283
44418
  extraEnv[entry.slice(0, idx)] = entry.slice(idx + 1);
44284
44419
  }
44420
+ const permissionArgs = parsePermissionArgs(opts.permissionArg);
44285
44421
  const def = {
44286
44422
  id,
44287
44423
  label: opts.label,
@@ -44291,6 +44427,7 @@ tools.command("add").argument("<id>", "tool id, e.g. cursor").description("regis
44291
44427
  ...Object.keys(extraEnv).length > 0 ? { extraEnv } : {},
44292
44428
  ...opts.loginArg ? { loginArgs: opts.loginArg } : {},
44293
44429
  ...opts.resumeArg ? { resumeArgs: opts.resumeArg } : {},
44430
+ ...Object.keys(permissionArgs).length > 0 ? { permissionArgs } : {},
44294
44431
  ...opts.accountFile ? { accountFile: opts.accountFile } : {},
44295
44432
  ...opts.emailPath ? { emailPath: opts.emailPath.split(".") } : {}
44296
44433
  };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export * from "./types.js";
2
2
  export { loadStore, saveStore, storePath, accountsHome, profilesDir } from "./storage.js";
3
- export { BUILTIN_TOOLS, DEFAULT_TOOL, getTool, listTools, isBuiltinTool, addCustomTool, removeCustomTool, } from "./lib/tools.js";
3
+ export { BUILTIN_TOOLS, DEFAULT_TOOL, getTool, listTools, isBuiltinTool, addCustomTool, removeCustomTool, mergeToolArgs, normalizePermissionPreset, permissionArgsFor, } from "./lib/tools.js";
4
4
  export { profileEnv, formatEnvAssignments, formatExportLines } from "./lib/env.js";
5
5
  export { detectEmail } from "./lib/detect.js";
6
6
  export { expandPath, listProfiles, findProfile, getProfile, addProfile, removeProfile, renameProfile, updateProfile, redetectEmail, useProfile, currentProfile, } from "./lib/profiles.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC1F,OAAO,EACL,aAAa,EACb,YAAY,EACZ,OAAO,EACP,SAAS,EACT,aAAa,EACb,aAAa,EACb,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACnF,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EACL,UAAU,EACV,YAAY,EACZ,WAAW,EACX,UAAU,EACV,UAAU,EACV,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,UAAU,EACV,cAAc,GACf,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC/E,YAAY,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,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EAAE,MAAM,eAAe,CAAC;AAC5C,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,QAAQ,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,EACL,2BAA2B,EAC3B,yBAAyB,EACzB,4BAA4B,EAC5B,yBAAyB,EACzB,eAAe,EACf,cAAc,EACd,gCAAgC,EAChC,kCAAkC,EAClC,+BAA+B,EAC/B,wBAAwB,GACzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC"}
package/dist/index.js CHANGED
@@ -3999,6 +3999,7 @@ var toolDefSchema = exports_external.object({
3999
3999
  loginArgs: exports_external.array(exports_external.string()).optional(),
4000
4000
  loginHint: exports_external.string().optional(),
4001
4001
  resumeArgs: exports_external.array(exports_external.string()).optional(),
4002
+ permissionArgs: exports_external.record(exports_external.array(exports_external.string())).optional(),
4002
4003
  accountFile: exports_external.string().optional(),
4003
4004
  emailPath: exports_external.array(exports_external.string()).optional()
4004
4005
  });
@@ -4174,6 +4175,15 @@ var BUILTIN_TOOLS = [
4174
4175
  bin: "claude",
4175
4176
  loginHint: "run /login inside Claude, then /exit when done",
4176
4177
  resumeArgs: ["--continue"],
4178
+ permissionArgs: {
4179
+ dangerous: ["--dangerously-skip-permissions"],
4180
+ "allow-dangerous": ["--allow-dangerously-skip-permissions"],
4181
+ bypass: ["--permission-mode", "bypassPermissions"],
4182
+ auto: ["--permission-mode", "auto"],
4183
+ "accept-edits": ["--permission-mode", "acceptEdits"],
4184
+ "dont-ask": ["--permission-mode", "dontAsk"],
4185
+ plan: ["--permission-mode", "plan"]
4186
+ },
4177
4187
  accountFile: ".claude.json",
4178
4188
  emailPath: ["oauthAccount", "emailAddress"]
4179
4189
  },
@@ -4185,7 +4195,10 @@ var BUILTIN_TOOLS = [
4185
4195
  bin: "codex",
4186
4196
  loginArgs: ["login"],
4187
4197
  loginHint: "complete the Codex login flow for this CODEX_HOME",
4188
- resumeArgs: ["resume", "--last"]
4198
+ resumeArgs: ["resume", "--last"],
4199
+ permissionArgs: {
4200
+ dangerous: ["--dangerously-bypass-approvals-and-sandbox"]
4201
+ }
4189
4202
  },
4190
4203
  {
4191
4204
  id: "takumi",
@@ -4195,6 +4208,15 @@ var BUILTIN_TOOLS = [
4195
4208
  bin: "takumi",
4196
4209
  loginHint: "complete Takumi auth in this TAKUMI_CONFIG_DIR",
4197
4210
  resumeArgs: ["--continue"],
4211
+ permissionArgs: {
4212
+ dangerous: ["--dangerously-skip-permissions"],
4213
+ "allow-dangerous": ["--allow-dangerously-skip-permissions"],
4214
+ bypass: ["--permission-mode", "bypassPermissions"],
4215
+ auto: ["--permission-mode", "auto"],
4216
+ "accept-edits": ["--permission-mode", "acceptEdits"],
4217
+ "dont-ask": ["--permission-mode", "dontAsk"],
4218
+ plan: ["--permission-mode", "plan"]
4219
+ },
4198
4220
  accountFile: ".claude.json",
4199
4221
  emailPath: ["oauthAccount", "emailAddress"]
4200
4222
  },
@@ -4204,7 +4226,13 @@ var BUILTIN_TOOLS = [
4204
4226
  envVar: "GEMINI_CONFIG_DIR",
4205
4227
  defaultDir: join2(homedir2(), ".gemini"),
4206
4228
  bin: "gemini",
4207
- loginHint: "complete Gemini auth in this GEMINI_CONFIG_DIR"
4229
+ loginHint: "complete Gemini auth in this GEMINI_CONFIG_DIR",
4230
+ permissionArgs: {
4231
+ dangerous: ["--yolo"],
4232
+ yolo: ["--yolo"],
4233
+ "auto-edit": ["--approval-mode", "auto_edit"],
4234
+ plan: ["--approval-mode", "plan"]
4235
+ }
4208
4236
  },
4209
4237
  {
4210
4238
  id: "opencode",
@@ -4243,7 +4271,11 @@ var BUILTIN_TOOLS = [
4243
4271
  envVar: "HERMES_HOME",
4244
4272
  defaultDir: join2(homedir2(), ".hermes"),
4245
4273
  bin: "hermes",
4246
- loginHint: "complete Hermes auth in this HERMES_HOME"
4274
+ loginHint: "complete Hermes auth in this HERMES_HOME",
4275
+ permissionArgs: {
4276
+ dangerous: ["--yolo"],
4277
+ yolo: ["--yolo"]
4278
+ }
4247
4279
  },
4248
4280
  {
4249
4281
  id: "kimi",
@@ -4252,7 +4284,13 @@ var BUILTIN_TOOLS = [
4252
4284
  defaultDir: join2(homedir2(), ".kimi-code"),
4253
4285
  bin: "kimi",
4254
4286
  loginArgs: ["login"],
4255
- loginHint: "complete kimi login for this KIMI_CODE_HOME"
4287
+ loginHint: "complete kimi login for this KIMI_CODE_HOME",
4288
+ permissionArgs: {
4289
+ dangerous: ["--yolo"],
4290
+ yolo: ["--yolo"],
4291
+ auto: ["--auto"],
4292
+ plan: ["--plan"]
4293
+ }
4256
4294
  },
4257
4295
  {
4258
4296
  id: "grok",
@@ -4265,6 +4303,43 @@ var BUILTIN_TOOLS = [
4265
4303
  }
4266
4304
  ];
4267
4305
  var DEFAULT_TOOL = "claude";
4306
+ var PERMISSION_ALIASES = new Map([
4307
+ ["danger", "dangerous"],
4308
+ ["dangerously-skip-permissions", "dangerous"],
4309
+ ["skip-permissions", "dangerous"],
4310
+ ["skip", "dangerous"],
4311
+ ["bypasspermissions", "bypass"],
4312
+ ["bypass-permissions", "bypass"],
4313
+ ["acceptedits", "accept-edits"],
4314
+ ["accept-edit", "accept-edits"],
4315
+ ["autoedit", "auto-edit"],
4316
+ ["auto-edits", "auto-edit"],
4317
+ ["auto_edit", "auto-edit"],
4318
+ ["dontask", "dont-ask"],
4319
+ ["dont-ask-permissions", "dont-ask"]
4320
+ ]);
4321
+ function normalizePermissionPreset(value) {
4322
+ const normalized = value.trim().replace(/^--/, "").replaceAll("_", "-").toLowerCase();
4323
+ return PERMISSION_ALIASES.get(normalized) ?? normalized;
4324
+ }
4325
+ function permissionArgsFor(tool, permissions) {
4326
+ if (!permissions)
4327
+ return [];
4328
+ const preset = normalizePermissionPreset(permissions);
4329
+ if (preset === "default" || preset === "none" || preset === "off")
4330
+ return [];
4331
+ const args = tool.permissionArgs?.[preset];
4332
+ if (!args) {
4333
+ const supported = Object.keys(tool.permissionArgs ?? {}).sort();
4334
+ const suffix = supported.length > 0 ? ` Supported permissions: ${supported.join(", ")}.` : " No permission presets are configured.";
4335
+ throw new AccountsError(`tool "${tool.id}" does not support permissions "${permissions}".${suffix}`);
4336
+ }
4337
+ return args;
4338
+ }
4339
+ function mergeToolArgs(tool, args, opts = {}) {
4340
+ const permissionArgs = permissionArgsFor(tool, opts.permissions).filter((arg) => !args.includes(arg));
4341
+ return [...permissionArgs, ...args];
4342
+ }
4268
4343
  var BUILTIN_IDS = new Set(BUILTIN_TOOLS.map((t) => t.id));
4269
4344
  function isBuiltinTool(id) {
4270
4345
  return BUILTIN_IDS.has(id);
@@ -4406,6 +4481,22 @@ function readKeychainAccount() {
4406
4481
  return;
4407
4482
  }
4408
4483
  }
4484
+ function bufferText(value) {
4485
+ if (typeof value === "string")
4486
+ return value;
4487
+ if (value instanceof Uint8Array)
4488
+ return new TextDecoder().decode(value);
4489
+ return;
4490
+ }
4491
+ function keychainWriteFailureMessage(err) {
4492
+ const record = err && typeof err === "object" ? err : {};
4493
+ const stderr = bufferText(record.stderr);
4494
+ const stdout = bufferText(record.stdout);
4495
+ const detail = (stderr || stdout || "").split(/\r?\n/).map((line) => line.trim()).filter(Boolean).at(-1);
4496
+ if (detail)
4497
+ return detail;
4498
+ return typeof record.status === "number" ? `security exited with status ${record.status}` : "security command failed";
4499
+ }
4409
4500
  function writeClaudeKeychain(cred) {
4410
4501
  if (!keychainSupported()) {
4411
4502
  throw new AccountsError("macOS keychain is only available on darwin");
@@ -4419,7 +4510,7 @@ function writeClaudeKeychain(cred) {
4419
4510
  stdio: ["ignore", "pipe", "pipe"]
4420
4511
  });
4421
4512
  } catch (err) {
4422
- throw new AccountsError(`keychain write failed: ${err.message}`);
4513
+ throw new AccountsError(`keychain write failed: ${keychainWriteFailureMessage(err)}`);
4423
4514
  }
4424
4515
  }
4425
4516
 
@@ -5032,7 +5123,8 @@ function commandLine(env, command) {
5032
5123
  return `${formatEnvAssignments(env)} ${command.map(shellQuote).join(" ")}`.trim();
5033
5124
  }
5034
5125
  function commandFor(tool, opts) {
5035
- return [tool.bin, ...opts.resume ? tool.resumeArgs ?? [] : [], ...opts.args ?? []];
5126
+ const args = [...opts.resume ? tool.resumeArgs ?? [] : [], ...opts.args ?? []];
5127
+ return [tool.bin, ...mergeToolArgs(tool, args, { permissions: opts.permissions })];
5036
5128
  }
5037
5129
  function switchProfile(name, opts = {}) {
5038
5130
  const profile = getProfile(name, opts.tool);
@@ -5061,6 +5153,7 @@ function switchProfile(name, opts = {}) {
5061
5153
  exports: formatExportLines(env),
5062
5154
  command,
5063
5155
  commandLine: commandLine(env, command),
5156
+ ...opts.permissions ? { permissions: normalizePermissionPreset(opts.permissions) } : {},
5064
5157
  restartRequired,
5065
5158
  message
5066
5159
  };
@@ -5385,7 +5478,8 @@ async function runSupervisedTool(initialProfile, tool, initialArgs = [], opts =
5385
5478
  tool: tool.id,
5386
5479
  mode: request.mode ?? "auto",
5387
5480
  resume: request.resume ?? true,
5388
- args: request.args ?? []
5481
+ args: request.args ?? [],
5482
+ permissions: request.permissions
5389
5483
  });
5390
5484
  log(`accounts supervisor: switching ${tool.id} to ${result.profile.name}`);
5391
5485
  setTimeout(() => void restartWith(result), 0);
@@ -5553,6 +5647,9 @@ export {
5553
5647
  profileHasAuth,
5554
5648
  profileEnv,
5555
5649
  pickProfile,
5650
+ permissionArgsFor,
5651
+ normalizePermissionPreset,
5652
+ mergeToolArgs,
5556
5653
  loadStore,
5557
5654
  listTools,
5558
5655
  listSupervisorStates,
@@ -8,6 +8,7 @@ export interface KeychainCredential {
8
8
  export declare function assertAllowedKeychainCredential(cred: KeychainCredential): void;
9
9
  /** Read Claude Code OAuth payload from macOS login keychain. */
10
10
  export declare function readClaudeKeychain(): KeychainCredential | undefined;
11
+ export declare function keychainWriteFailureMessage(err: unknown): string;
11
12
  /** Write Claude Code credentials into the login keychain (replaces existing entry). */
12
13
  export declare function writeClaudeKeychain(cred: KeychainCredential): void;
13
14
  //# sourceMappingURL=keychain.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"keychain.d.ts","sourceRoot":"","sources":["../../src/lib/keychain.ts"],"names":[],"mappings":"AAKA,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAID,yFAAyF;AACzF,wBAAgB,+BAA+B,CAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI,CAU9E;AAED,gEAAgE;AAChE,wBAAgB,kBAAkB,IAAI,kBAAkB,GAAG,SAAS,CAgBnE;AAgBD,uFAAuF;AACvF,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI,CAqBlE"}
1
+ {"version":3,"file":"keychain.d.ts","sourceRoot":"","sources":["../../src/lib/keychain.ts"],"names":[],"mappings":"AAKA,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAID,yFAAyF;AACzF,wBAAgB,+BAA+B,CAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI,CAU9E;AAED,gEAAgE;AAChE,wBAAgB,kBAAkB,IAAI,kBAAkB,GAAG,SAAS,CAgBnE;AAsBD,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAWhE;AAED,uFAAuF;AACvF,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI,CAqBlE"}
@@ -21,6 +21,7 @@ export type SupervisorRequest = {
21
21
  mode?: SwitchMode;
22
22
  resume?: boolean;
23
23
  args?: string[];
24
+ permissions?: string;
24
25
  } | {
25
26
  type: "stop";
26
27
  };
@@ -1 +1 @@
1
- {"version":3,"file":"supervisor.d.ts","sourceRoot":"","sources":["../../src/lib/supervisor.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAMjF,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAKpD,OAAO,EAAiB,KAAK,UAAU,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAGhF,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,CAAC,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,iBAAiB,GACzB;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IACE,IAAI,EAAE,gBAAgB,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB,GACD;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAErB,MAAM,MAAM,kBAAkB,GAC1B;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,eAAe,CAAA;CAAE,GACpC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,MAAM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,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAO,GAC7C,oBAAoB,CAuBtB;AA0CD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,iBAAiB,EAC1B,IAAI,GAAE,uBAA4B,GACjC,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAoDzC;AAED,wBAAsB,iBAAiB,CACrC,cAAc,EAAE,OAAO,EACvB,IAAI,EAAE,OAAO,EACb,WAAW,GAAE,MAAM,EAAO,EAC1B,IAAI,GAAE,oBAAyB,GAC9B,OAAO,CAAC,MAAM,CAAC,CAoLjB"}
@@ -5,6 +5,7 @@ export interface SwitchOptions {
5
5
  mode?: SwitchMode;
6
6
  resume?: boolean;
7
7
  args?: string[];
8
+ permissions?: string;
8
9
  }
9
10
  export interface SwitchResult {
10
11
  profile: Profile;
@@ -15,6 +16,7 @@ export interface SwitchResult {
15
16
  exports: string;
16
17
  command: string[];
17
18
  commandLine: string;
19
+ permissions?: string;
18
20
  restartRequired: boolean;
19
21
  message: string;
20
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../src/lib/switch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAOpD,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,CAAC;AAE7D,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,G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AoClF"}
@@ -6,6 +6,12 @@ import { type ToolDef } from "../types.js";
6
6
  */
7
7
  export declare const BUILTIN_TOOLS: ToolDef[];
8
8
  export declare const DEFAULT_TOOL = "claude";
9
+ export interface ToolArgOptions {
10
+ permissions?: string;
11
+ }
12
+ export declare function normalizePermissionPreset(value: string): string;
13
+ export declare function permissionArgsFor(tool: ToolDef, permissions?: string): string[];
14
+ export declare function mergeToolArgs(tool: ToolDef, args: string[], opts?: ToolArgOptions): string[];
9
15
  export declare function isBuiltinTool(id: string): boolean;
10
16
  /** All tools: built-ins plus any user-registered ones (custom wins on id clash). */
11
17
  export declare function listTools(): ToolDef[];
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/lib/tools.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,OAAO,EAAgC,MAAM,aAAa,CAAC;AAGzE;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,OAAO,EAkGlC,CAAC;AAEF,eAAO,MAAM,YAAY,WAAW,CAAC;AAIrC,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAEjD;AAED,oFAAoF;AACpF,wBAAgB,SAAS,IAAI,OAAO,EAAE,CAMrC;AAED,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAS3C;AAED,kEAAkE;AAClE,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAanD;AAED,kEAAkE;AAClE,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAWjD"}
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/lib/tools.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,OAAO,EAAgC,MAAM,aAAa,CAAC;AAGzE;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,OAAO,EAuIlC,CAAC;AAEF,eAAO,MAAM,YAAY,WAAW,CAAC;AAErC,MAAM,WAAW,cAAc;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAkBD,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAG/D;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAW/E;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,GAAE,cAAmB,GAAG,MAAM,EAAE,CAGhG;AAID,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAEjD;AAED,oFAAoF;AACpF,wBAAgB,SAAS,IAAI,OAAO,EAAE,CAMrC;AAED,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAS3C;AAED,kEAAkE;AAClE,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAanD;AAED,kEAAkE;AAClE,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAWjD"}
package/dist/mcp.js CHANGED
@@ -16634,6 +16634,7 @@ var toolDefSchema = exports_external.object({
16634
16634
  loginArgs: exports_external.array(exports_external.string()).optional(),
16635
16635
  loginHint: exports_external.string().optional(),
16636
16636
  resumeArgs: exports_external.array(exports_external.string()).optional(),
16637
+ permissionArgs: exports_external.record(exports_external.array(exports_external.string())).optional(),
16637
16638
  accountFile: exports_external.string().optional(),
16638
16639
  emailPath: exports_external.array(exports_external.string()).optional()
16639
16640
  });
@@ -16808,6 +16809,15 @@ var BUILTIN_TOOLS = [
16808
16809
  bin: "claude",
16809
16810
  loginHint: "run /login inside Claude, then /exit when done",
16810
16811
  resumeArgs: ["--continue"],
16812
+ permissionArgs: {
16813
+ dangerous: ["--dangerously-skip-permissions"],
16814
+ "allow-dangerous": ["--allow-dangerously-skip-permissions"],
16815
+ bypass: ["--permission-mode", "bypassPermissions"],
16816
+ auto: ["--permission-mode", "auto"],
16817
+ "accept-edits": ["--permission-mode", "acceptEdits"],
16818
+ "dont-ask": ["--permission-mode", "dontAsk"],
16819
+ plan: ["--permission-mode", "plan"]
16820
+ },
16811
16821
  accountFile: ".claude.json",
16812
16822
  emailPath: ["oauthAccount", "emailAddress"]
16813
16823
  },
@@ -16819,7 +16829,10 @@ var BUILTIN_TOOLS = [
16819
16829
  bin: "codex",
16820
16830
  loginArgs: ["login"],
16821
16831
  loginHint: "complete the Codex login flow for this CODEX_HOME",
16822
- resumeArgs: ["resume", "--last"]
16832
+ resumeArgs: ["resume", "--last"],
16833
+ permissionArgs: {
16834
+ dangerous: ["--dangerously-bypass-approvals-and-sandbox"]
16835
+ }
16823
16836
  },
16824
16837
  {
16825
16838
  id: "takumi",
@@ -16829,6 +16842,15 @@ var BUILTIN_TOOLS = [
16829
16842
  bin: "takumi",
16830
16843
  loginHint: "complete Takumi auth in this TAKUMI_CONFIG_DIR",
16831
16844
  resumeArgs: ["--continue"],
16845
+ permissionArgs: {
16846
+ dangerous: ["--dangerously-skip-permissions"],
16847
+ "allow-dangerous": ["--allow-dangerously-skip-permissions"],
16848
+ bypass: ["--permission-mode", "bypassPermissions"],
16849
+ auto: ["--permission-mode", "auto"],
16850
+ "accept-edits": ["--permission-mode", "acceptEdits"],
16851
+ "dont-ask": ["--permission-mode", "dontAsk"],
16852
+ plan: ["--permission-mode", "plan"]
16853
+ },
16832
16854
  accountFile: ".claude.json",
16833
16855
  emailPath: ["oauthAccount", "emailAddress"]
16834
16856
  },
@@ -16838,7 +16860,13 @@ var BUILTIN_TOOLS = [
16838
16860
  envVar: "GEMINI_CONFIG_DIR",
16839
16861
  defaultDir: join2(homedir2(), ".gemini"),
16840
16862
  bin: "gemini",
16841
- loginHint: "complete Gemini auth in this GEMINI_CONFIG_DIR"
16863
+ loginHint: "complete Gemini auth in this GEMINI_CONFIG_DIR",
16864
+ permissionArgs: {
16865
+ dangerous: ["--yolo"],
16866
+ yolo: ["--yolo"],
16867
+ "auto-edit": ["--approval-mode", "auto_edit"],
16868
+ plan: ["--approval-mode", "plan"]
16869
+ }
16842
16870
  },
16843
16871
  {
16844
16872
  id: "opencode",
@@ -16877,7 +16905,11 @@ var BUILTIN_TOOLS = [
16877
16905
  envVar: "HERMES_HOME",
16878
16906
  defaultDir: join2(homedir2(), ".hermes"),
16879
16907
  bin: "hermes",
16880
- loginHint: "complete Hermes auth in this HERMES_HOME"
16908
+ loginHint: "complete Hermes auth in this HERMES_HOME",
16909
+ permissionArgs: {
16910
+ dangerous: ["--yolo"],
16911
+ yolo: ["--yolo"]
16912
+ }
16881
16913
  },
16882
16914
  {
16883
16915
  id: "kimi",
@@ -16886,7 +16918,13 @@ var BUILTIN_TOOLS = [
16886
16918
  defaultDir: join2(homedir2(), ".kimi-code"),
16887
16919
  bin: "kimi",
16888
16920
  loginArgs: ["login"],
16889
- loginHint: "complete kimi login for this KIMI_CODE_HOME"
16921
+ loginHint: "complete kimi login for this KIMI_CODE_HOME",
16922
+ permissionArgs: {
16923
+ dangerous: ["--yolo"],
16924
+ yolo: ["--yolo"],
16925
+ auto: ["--auto"],
16926
+ plan: ["--plan"]
16927
+ }
16890
16928
  },
16891
16929
  {
16892
16930
  id: "grok",
@@ -16898,6 +16936,43 @@ var BUILTIN_TOOLS = [
16898
16936
  loginHint: "complete grok login in this process-scoped HOME; prefer launch/shell over exporting HOME globally"
16899
16937
  }
16900
16938
  ];
16939
+ var PERMISSION_ALIASES = new Map([
16940
+ ["danger", "dangerous"],
16941
+ ["dangerously-skip-permissions", "dangerous"],
16942
+ ["skip-permissions", "dangerous"],
16943
+ ["skip", "dangerous"],
16944
+ ["bypasspermissions", "bypass"],
16945
+ ["bypass-permissions", "bypass"],
16946
+ ["acceptedits", "accept-edits"],
16947
+ ["accept-edit", "accept-edits"],
16948
+ ["autoedit", "auto-edit"],
16949
+ ["auto-edits", "auto-edit"],
16950
+ ["auto_edit", "auto-edit"],
16951
+ ["dontask", "dont-ask"],
16952
+ ["dont-ask-permissions", "dont-ask"]
16953
+ ]);
16954
+ function normalizePermissionPreset(value) {
16955
+ const normalized = value.trim().replace(/^--/, "").replaceAll("_", "-").toLowerCase();
16956
+ return PERMISSION_ALIASES.get(normalized) ?? normalized;
16957
+ }
16958
+ function permissionArgsFor(tool, permissions) {
16959
+ if (!permissions)
16960
+ return [];
16961
+ const preset = normalizePermissionPreset(permissions);
16962
+ if (preset === "default" || preset === "none" || preset === "off")
16963
+ return [];
16964
+ const args = tool.permissionArgs?.[preset];
16965
+ if (!args) {
16966
+ const supported = Object.keys(tool.permissionArgs ?? {}).sort();
16967
+ const suffix = supported.length > 0 ? ` Supported permissions: ${supported.join(", ")}.` : " No permission presets are configured.";
16968
+ throw new AccountsError(`tool "${tool.id}" does not support permissions "${permissions}".${suffix}`);
16969
+ }
16970
+ return args;
16971
+ }
16972
+ function mergeToolArgs(tool, args, opts = {}) {
16973
+ const permissionArgs = permissionArgsFor(tool, opts.permissions).filter((arg) => !args.includes(arg));
16974
+ return [...permissionArgs, ...args];
16975
+ }
16901
16976
  var BUILTIN_IDS = new Set(BUILTIN_TOOLS.map((t) => t.id));
16902
16977
  function listTools() {
16903
16978
  const custom3 = loadStore().tools;
@@ -17054,6 +17129,22 @@ function readKeychainAccount() {
17054
17129
  return;
17055
17130
  }
17056
17131
  }
17132
+ function bufferText(value) {
17133
+ if (typeof value === "string")
17134
+ return value;
17135
+ if (value instanceof Uint8Array)
17136
+ return new TextDecoder().decode(value);
17137
+ return;
17138
+ }
17139
+ function keychainWriteFailureMessage(err) {
17140
+ const record3 = err && typeof err === "object" ? err : {};
17141
+ const stderr = bufferText(record3.stderr);
17142
+ const stdout = bufferText(record3.stdout);
17143
+ const detail = (stderr || stdout || "").split(/\r?\n/).map((line) => line.trim()).filter(Boolean).at(-1);
17144
+ if (detail)
17145
+ return detail;
17146
+ return typeof record3.status === "number" ? `security exited with status ${record3.status}` : "security command failed";
17147
+ }
17057
17148
  function writeClaudeKeychain(cred) {
17058
17149
  if (!keychainSupported()) {
17059
17150
  throw new AccountsError("macOS keychain is only available on darwin");
@@ -17067,7 +17158,7 @@ function writeClaudeKeychain(cred) {
17067
17158
  stdio: ["ignore", "pipe", "pipe"]
17068
17159
  });
17069
17160
  } catch (err) {
17070
- throw new AccountsError(`keychain write failed: ${err.message}`);
17161
+ throw new AccountsError(`keychain write failed: ${keychainWriteFailureMessage(err)}`);
17071
17162
  }
17072
17163
  }
17073
17164
 
@@ -17388,7 +17479,8 @@ function commandLine(env, command) {
17388
17479
  return `${formatEnvAssignments(env)} ${command.map(shellQuote).join(" ")}`.trim();
17389
17480
  }
17390
17481
  function commandFor(tool, opts) {
17391
- return [tool.bin, ...opts.resume ? tool.resumeArgs ?? [] : [], ...opts.args ?? []];
17482
+ const args = [...opts.resume ? tool.resumeArgs ?? [] : [], ...opts.args ?? []];
17483
+ return [tool.bin, ...mergeToolArgs(tool, args, { permissions: opts.permissions })];
17392
17484
  }
17393
17485
  function switchProfile(name, opts = {}) {
17394
17486
  const profile = getProfile(name, opts.tool);
@@ -17417,6 +17509,7 @@ function switchProfile(name, opts = {}) {
17417
17509
  exports: formatExportLines(env),
17418
17510
  command,
17419
17511
  commandLine: commandLine(env, command),
17512
+ ...opts.permissions ? { permissions: normalizePermissionPreset(opts.permissions) } : {},
17420
17513
  restartRequired,
17421
17514
  message
17422
17515
  };
@@ -17526,7 +17619,7 @@ function ok(data) {
17526
17619
  function fail(message) {
17527
17620
  return { content: [{ type: "text", text: JSON.stringify({ error: message }) }], isError: true };
17528
17621
  }
17529
- var server = new Server({ name: "accounts", version: "0.1.12" }, { capabilities: { tools: {} } });
17622
+ var server = new Server({ name: "accounts", version: "0.1.14" }, { capabilities: { tools: {} } });
17530
17623
  server.setRequestHandler(ListToolsRequestSchema, async () => ({
17531
17624
  tools: [
17532
17625
  {
@@ -17559,6 +17652,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => ({
17559
17652
  tool: { type: "string" },
17560
17653
  mode: { type: "string", enum: ["auto", "apply", "env", "active"] },
17561
17654
  resume: { type: "boolean" },
17655
+ permissions: { type: "string" },
17562
17656
  args: { type: "array", items: { type: "string" } }
17563
17657
  },
17564
17658
  required: ["name"]
@@ -17592,13 +17686,15 @@ server.setRequestHandler(CallToolRequestSchema, async (req) => {
17592
17686
  const profile = getProfile(name, typeof args["tool"] === "string" ? args["tool"] : undefined);
17593
17687
  const resume = args["resume"] !== false;
17594
17688
  const switchArgs = Array.isArray(args["args"]) ? args["args"].filter((value) => typeof value === "string") : undefined;
17689
+ const permissions = typeof args["permissions"] === "string" ? args["permissions"] : undefined;
17595
17690
  const supervisor = await sendSupervisorRequest(profile.tool, {
17596
17691
  type: "switch_profile",
17597
17692
  name: profile.name,
17598
17693
  tool: profile.tool,
17599
17694
  mode: typeof args["mode"] === "string" ? args["mode"] : "auto",
17600
17695
  resume,
17601
- args: switchArgs
17696
+ args: switchArgs,
17697
+ permissions
17602
17698
  }, { allowMissing: true });
17603
17699
  if (supervisor) {
17604
17700
  if (!supervisor.ok)
@@ -17613,7 +17709,8 @@ server.setRequestHandler(CallToolRequestSchema, async (req) => {
17613
17709
  tool: profile.tool,
17614
17710
  mode: typeof args["mode"] === "string" ? args["mode"] : "auto",
17615
17711
  resume,
17616
- args: switchArgs
17712
+ args: switchArgs,
17713
+ permissions
17617
17714
  });
17618
17715
  return ok({
17619
17716
  supervised: false,
package/dist/storage.js CHANGED
@@ -4007,6 +4007,7 @@ var toolDefSchema = exports_external.object({
4007
4007
  loginArgs: exports_external.array(exports_external.string()).optional(),
4008
4008
  loginHint: exports_external.string().optional(),
4009
4009
  resumeArgs: exports_external.array(exports_external.string()).optional(),
4010
+ permissionArgs: exports_external.record(exports_external.array(exports_external.string())).optional(),
4010
4011
  accountFile: exports_external.string().optional(),
4011
4012
  emailPath: exports_external.array(exports_external.string()).optional()
4012
4013
  });
package/dist/types.d.ts CHANGED
@@ -12,6 +12,8 @@ export declare const toolDefSchema: z.ZodObject<{
12
12
  loginArgs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
13
13
  loginHint: z.ZodOptional<z.ZodString>;
14
14
  resumeArgs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
15
+ /** Tool-specific permission presets exposed through `--permissions <preset>`. */
16
+ permissionArgs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
15
17
  accountFile: z.ZodOptional<z.ZodString>;
16
18
  emailPath: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
17
19
  }, "strip", z.ZodTypeAny, {
@@ -24,6 +26,7 @@ export declare const toolDefSchema: z.ZodObject<{
24
26
  loginArgs?: string[] | undefined;
25
27
  loginHint?: string | undefined;
26
28
  resumeArgs?: string[] | undefined;
29
+ permissionArgs?: Record<string, string[]> | undefined;
27
30
  accountFile?: string | undefined;
28
31
  emailPath?: string[] | undefined;
29
32
  }, {
@@ -36,6 +39,7 @@ export declare const toolDefSchema: z.ZodObject<{
36
39
  loginArgs?: string[] | undefined;
37
40
  loginHint?: string | undefined;
38
41
  resumeArgs?: string[] | undefined;
42
+ permissionArgs?: Record<string, string[]> | undefined;
39
43
  accountFile?: string | undefined;
40
44
  emailPath?: string[] | undefined;
41
45
  }>;
@@ -117,6 +121,8 @@ export declare const storeSchema: z.ZodObject<{
117
121
  loginArgs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
118
122
  loginHint: z.ZodOptional<z.ZodString>;
119
123
  resumeArgs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
124
+ /** Tool-specific permission presets exposed through `--permissions <preset>`. */
125
+ permissionArgs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
120
126
  accountFile: z.ZodOptional<z.ZodString>;
121
127
  emailPath: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
122
128
  }, "strip", z.ZodTypeAny, {
@@ -129,6 +135,7 @@ export declare const storeSchema: z.ZodObject<{
129
135
  loginArgs?: string[] | undefined;
130
136
  loginHint?: string | undefined;
131
137
  resumeArgs?: string[] | undefined;
138
+ permissionArgs?: Record<string, string[]> | undefined;
132
139
  accountFile?: string | undefined;
133
140
  emailPath?: string[] | undefined;
134
141
  }, {
@@ -141,6 +148,7 @@ export declare const storeSchema: z.ZodObject<{
141
148
  loginArgs?: string[] | undefined;
142
149
  loginHint?: string | undefined;
143
150
  resumeArgs?: string[] | undefined;
151
+ permissionArgs?: Record<string, string[]> | undefined;
144
152
  accountFile?: string | undefined;
145
153
  emailPath?: string[] | undefined;
146
154
  }>, "many">>;
@@ -167,6 +175,7 @@ export declare const storeSchema: z.ZodObject<{
167
175
  loginArgs?: string[] | undefined;
168
176
  loginHint?: string | undefined;
169
177
  resumeArgs?: string[] | undefined;
178
+ permissionArgs?: Record<string, string[]> | undefined;
170
179
  accountFile?: string | undefined;
171
180
  emailPath?: string[] | undefined;
172
181
  }[];
@@ -193,6 +202,7 @@ export declare const storeSchema: z.ZodObject<{
193
202
  loginArgs?: string[] | undefined;
194
203
  loginHint?: string | undefined;
195
204
  resumeArgs?: string[] | undefined;
205
+ permissionArgs?: Record<string, string[]> | undefined;
196
206
  accountFile?: string | undefined;
197
207
  emailPath?: string[] | undefined;
198
208
  }[] | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AASxB,8BAA8B;AAC9B,eAAO,MAAM,iBAAiB,aAAa,CAAC;AAE5C,uEAAuE;AACvE,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYxB,CAAC;AAEH;;;;;GAKG;AACH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAEpD,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;EAQxB,CAAC;AAEH,MAAM,MAAM,OAAO,GAAG,CAAC,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AAC,OAAO,WAAW,CAAC,CAAC;AAEhD,qBAAa,aAAc,SAAQ,KAAK;gBAC1B,OAAO,EAAE,MAAM;CAI5B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/accounts",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "description": "Manage and switch between multiple Claude Code (and other AI coding tool) profiles/accounts locally — isolated config dirs, per-account email, one-command switching.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",