@hasna/accounts 0.1.14 → 0.1.16
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 +57 -29
- package/dist/cli.js +111 -55
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +110 -49
- package/dist/lib/codex-app.d.ts +2 -0
- package/dist/lib/codex-app.d.ts.map +1 -0
- package/dist/lib/env.d.ts.map +1 -1
- package/dist/lib/import-profile.d.ts.map +1 -1
- package/dist/lib/tools.d.ts +3 -1
- package/dist/lib/tools.d.ts.map +1 -1
- package/dist/mcp.js +73 -13
- package/dist/storage.js +1 -0
- package/dist/types.d.ts +10 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# @hasna/accounts
|
|
2
2
|
|
|
3
3
|
> Manage and switch between multiple AI coding tool profiles/accounts on one
|
|
4
|
-
> machine — Claude Code, Takumi, Codex CLI, Gemini CLI, opencode,
|
|
5
|
-
> Agent, Pi Coding Agent, Hermes, Kimi Code, Grok Build, and custom tools.
|
|
4
|
+
> machine — Claude Code, Takumi, Codex CLI, Codex App, Gemini CLI, opencode,
|
|
5
|
+
> Cursor Agent, Pi Coding Agent, Hermes, Kimi Code, Grok Build, and custom tools.
|
|
6
6
|
|
|
7
7
|
`accounts` is a local-first CLI. Each **profile** is an isolated config directory.
|
|
8
8
|
Switch **in the terminal** with `CLAUDE_CONFIG_DIR`, or **in Cursor / VS Code** with
|
|
@@ -11,9 +11,9 @@ Switch **in the terminal** with `CLAUDE_CONFIG_DIR`, or **in Cursor / VS Code**
|
|
|
11
11
|
- **Isolated profiles** — separate config dirs (skills, settings, sessions). Nothing leaks.
|
|
12
12
|
- **Apply mode** — sync OAuth / credentials to live paths for IDEs (Claude-only today).
|
|
13
13
|
- **Remembers the email** — auto-detected from `.claude.json` when possible.
|
|
14
|
-
- **Multi-tool** — first-class built-ins for Claude, Takumi, Codex,
|
|
15
|
-
opencode, Cursor Agent, Pi, Hermes, Kimi Code, and Grok Build;
|
|
16
|
-
via `accounts tools add`.
|
|
14
|
+
- **Multi-tool** — first-class built-ins for Claude, Takumi, Codex CLI, Codex
|
|
15
|
+
App, Gemini, opencode, Cursor Agent, Pi, Hermes, Kimi Code, and Grok Build;
|
|
16
|
+
custom tools via `accounts tools add`.
|
|
17
17
|
- **Per-tool names** — `work` can exist for Claude, Codex, Cursor, etc.; pass
|
|
18
18
|
`--tool` when a bare profile name is ambiguous.
|
|
19
19
|
- **Local-first** — registry at `~/.hasna/accounts/`. No network, no telemetry.
|
|
@@ -42,23 +42,47 @@ accounts login work # run /login inside Claude, then /exit; accounts auto
|
|
|
42
42
|
accounts login personal # same: login, exit; it becomes the live/default account
|
|
43
43
|
|
|
44
44
|
# 4. Switch
|
|
45
|
-
accounts apply work
|
|
45
|
+
accounts apply work # Cursor / VS Code — live ~/.claude auth
|
|
46
46
|
accounts apply personal
|
|
47
47
|
|
|
48
48
|
# Or terminal-only (parallel sessions OK):
|
|
49
|
-
accounts launch work
|
|
50
|
-
eval "$(accounts env personal
|
|
49
|
+
accounts launch work
|
|
50
|
+
eval "$(accounts env personal)" # other terminal
|
|
51
51
|
|
|
52
52
|
# Or supervised: lets MCP switch/restart this Claude process automatically
|
|
53
|
-
accounts use work
|
|
53
|
+
accounts use work
|
|
54
54
|
accounts run claude --resume
|
|
55
|
-
accounts switch personal --
|
|
55
|
+
accounts switch personal --supervisor # from another terminal
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
After `accounts login <name
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
After `accounts login <name>`, `accounts` snapshots the auth Claude wrote,
|
|
59
|
+
updates the detected email, and applies that profile to live `~/.claude` paths
|
|
60
|
+
automatically. `accounts apply` still refuses profiles without auth so live OAuth
|
|
61
|
+
is not wiped.
|
|
62
|
+
|
|
63
|
+
## Codex App profiles on macOS
|
|
64
|
+
|
|
65
|
+
Codex CLI profiles use `--tool codex`. The macOS desktop app needs its own tool
|
|
66
|
+
because it also needs an isolated Electron user data directory:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# Create/sign into a desktop app profile. Quit Codex.app after login finishes.
|
|
70
|
+
accounts login personal --tool codex-app
|
|
71
|
+
accounts login work --tool codex-app
|
|
72
|
+
|
|
73
|
+
# Switch by launching the desired app profile.
|
|
74
|
+
accounts launch personal --tool codex-app
|
|
75
|
+
accounts launch work --tool codex-app
|
|
76
|
+
|
|
77
|
+
# Or print/launch the exact handoff command.
|
|
78
|
+
accounts switch work --tool codex-app
|
|
79
|
+
accounts switch work --tool codex-app --launch
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Each `codex-app` profile gets its own `CODEX_HOME` and
|
|
83
|
+
`--user-data-dir=<profile>/electron-user-data`. New profiles also get
|
|
84
|
+
`cli_auth_credentials_store = "file"` in `config.toml` so ChatGPT auth stays in
|
|
85
|
+
that profile directory instead of sharing one macOS Keychain credential.
|
|
62
86
|
|
|
63
87
|
## Three pointers (active, applied, isolated)
|
|
64
88
|
|
|
@@ -94,24 +118,24 @@ Implementation details: [docs/IMPLEMENT.md](docs/IMPLEMENT.md).
|
|
|
94
118
|
|---------|-------------|
|
|
95
119
|
| `accounts add <name>` | Create a profile. `--tool`, `--email`, `--dir`, `--description`. |
|
|
96
120
|
| `accounts import [name]` | Import existing config dir (default `~/.claude`). `--copy` for managed copy. |
|
|
97
|
-
| `accounts login <name
|
|
98
|
-
| `accounts apply <name
|
|
121
|
+
| `accounts login <name>` | Launch the profile's tool login flow in an isolated profile dir. Use `--tool` only for new or ambiguous profiles. |
|
|
122
|
+
| `accounts apply <name>` | Apply profile auth to live Claude paths (requires snapshot; Claude-only). |
|
|
99
123
|
| `accounts pick` | Interactive picker; default applies. `--env`, `--no-act`. |
|
|
100
|
-
| `accounts switch <name
|
|
101
|
-
| `accounts switch <name> --
|
|
102
|
-
| `accounts use <name
|
|
124
|
+
| `accounts switch <name>` | Switch profile and print a restart/resume command. Add `--resume`, `--launch`, or `--permissions <preset>`. Use `--tool` only when ambiguous. |
|
|
125
|
+
| `accounts switch <name> --supervisor` | Ask a running `accounts run <tool>` supervisor to restart under that profile. Supports `--permissions <preset>`. |
|
|
126
|
+
| `accounts use <name>` | Mark profile active; prints apply/env hints. |
|
|
103
127
|
| `accounts list` (`ls`) | List profiles (`●` active, `◉` applied, `●◉` both). |
|
|
104
128
|
| `accounts show <name> --tool <tool>` | Profile details including active/applied flags. |
|
|
105
129
|
| `accounts current` | Active profile per tool (with applied hint). |
|
|
106
130
|
| `accounts active [tool]` | Print active profile name (scripting). |
|
|
107
131
|
| `accounts applied [tool]` | Print applied profile name (scripting). |
|
|
108
|
-
| `accounts env [name]
|
|
109
|
-
| `accounts launch <name
|
|
132
|
+
| `accounts env [name]` | Print one or more `export ...` lines for the profile. Use `--tool` only when ambiguous or when no name is passed. |
|
|
133
|
+
| `accounts launch <name>` | Launch tool once with profile env. Supports `--permissions <preset>`. |
|
|
110
134
|
| `accounts run <tool> [args...]` | Run a tool under the supervisor so MCP/CLI can switch and restart it. Supports `--permissions <preset>`. |
|
|
111
135
|
| `accounts supervisor status [tool]` | Show running supervisors. |
|
|
112
|
-
| `accounts supervisor switch <name
|
|
136
|
+
| `accounts supervisor switch <name>` | Switch a running supervisor to another profile. Use `--tool` only when ambiguous. |
|
|
113
137
|
| `accounts supervisor stop <tool>` | Stop a running supervisor and its child process. |
|
|
114
|
-
| `accounts shell <name
|
|
138
|
+
| `accounts shell <name>` | Subshell with profile env. |
|
|
115
139
|
| `accounts hook install` | Install `claude()` wrapper — see [docs/hook.md](docs/hook.md). |
|
|
116
140
|
| `accounts hook uninstall` | Remove hook script. |
|
|
117
141
|
| `accounts hook path` | Print hook script path. |
|
|
@@ -140,7 +164,7 @@ Add it to Claude/Codex/opencode/Cursor MCP config as a command server named
|
|
|
140
164
|
For automatic agent restarts, start the agent through `accounts run`:
|
|
141
165
|
|
|
142
166
|
```bash
|
|
143
|
-
accounts use account001
|
|
167
|
+
accounts use account001
|
|
144
168
|
accounts run claude --resume
|
|
145
169
|
```
|
|
146
170
|
|
|
@@ -157,10 +181,10 @@ handoff behavior and returns a command such as:
|
|
|
157
181
|
Human equivalent:
|
|
158
182
|
|
|
159
183
|
```bash
|
|
160
|
-
accounts switch account001 --
|
|
161
|
-
accounts switch account001 --
|
|
162
|
-
accounts switch account001 --
|
|
163
|
-
accounts switch account001 --
|
|
184
|
+
accounts switch account001 --resume
|
|
185
|
+
accounts switch account001 --resume --launch
|
|
186
|
+
accounts switch account001 --resume --permissions dangerous
|
|
187
|
+
accounts switch account001 --supervisor
|
|
164
188
|
accounts switch codex-work --tool codex --resume
|
|
165
189
|
accounts switch ops --tool opencode --resume
|
|
166
190
|
```
|
|
@@ -224,9 +248,10 @@ JSON by default; auth snapshots stay local.
|
|
|
224
248
|
|
|
225
249
|
| Tool | id | Env var | Default dir |
|
|
226
250
|
|------|----|---------|-------------|
|
|
227
|
-
| Claude Code | `claude` | `CLAUDE_CONFIG_DIR` | `~/.claude` |
|
|
251
|
+
| Claude Code | `claude` | `CLAUDE_CONFIG_DIR`, `TELEGRAM_STATE_DIR` | `~/.claude` |
|
|
228
252
|
| Takumi | `takumi` | `TAKUMI_CONFIG_DIR` | `~/.takumi` |
|
|
229
253
|
| Codex CLI | `codex` | `CODEX_HOME` | `~/.codex` |
|
|
254
|
+
| Codex App | `codex-app` | `CODEX_HOME` + `--user-data-dir` | `~/.codex` |
|
|
230
255
|
| Gemini CLI | `gemini` | `GEMINI_CONFIG_DIR` | `~/.gemini` |
|
|
231
256
|
| opencode | `opencode` | `OPENCODE_CONFIG_DIR`, `XDG_CONFIG_HOME`, `XDG_DATA_HOME` | `~/.config/opencode` |
|
|
232
257
|
| Cursor Agent | `cursor` | `CURSOR_CONFIG_DIR` | `~/.cursor` |
|
|
@@ -241,6 +266,9 @@ globally is intentionally not recommended.
|
|
|
241
266
|
|
|
242
267
|
Custom tools can join supervised resume switching with `accounts tools add ... --resume-arg <arg>`.
|
|
243
268
|
They can also define permission presets with `--permission-arg preset=--flag`.
|
|
269
|
+
Use `--launch-arg` for app-level arguments that should be prepended to every
|
|
270
|
+
login/launch/run command; templates support `{profileDir}`, `{profileName}`, and
|
|
271
|
+
`{toolId}`.
|
|
244
272
|
|
|
245
273
|
## Library
|
|
246
274
|
|
package/dist/cli.js
CHANGED
|
@@ -992,7 +992,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
992
992
|
this._exitCallback = (err) => {
|
|
993
993
|
if (err.code !== "commander.executeSubCommandAsync") {
|
|
994
994
|
throw err;
|
|
995
|
-
}
|
|
995
|
+
}
|
|
996
996
|
};
|
|
997
997
|
}
|
|
998
998
|
return this;
|
|
@@ -12259,7 +12259,7 @@ var require_es5 = __commonJS((exports, module) => {
|
|
|
12259
12259
|
|
|
12260
12260
|
// node_modules/@aws-sdk/core/dist-cjs/submodules/client/index.js
|
|
12261
12261
|
var require_client2 = __commonJS((exports) => {
|
|
12262
|
-
var __dirname = "/home/hasna/
|
|
12262
|
+
var __dirname = "/home/hasna/Workspace/hasna/opensource/open-accounts/node_modules/@aws-sdk/core/dist-cjs/submodules/client";
|
|
12263
12263
|
var retry = require_retry();
|
|
12264
12264
|
var protocols = require_protocols();
|
|
12265
12265
|
var lambdaInvokeStore = require_invoke_store();
|
|
@@ -36797,9 +36797,9 @@ var require_dist_cjs22 = __commonJS((exports) => {
|
|
|
36797
36797
|
|
|
36798
36798
|
// src/cli.ts
|
|
36799
36799
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
36800
|
-
import { existsSync as
|
|
36800
|
+
import { existsSync as existsSync13, readFileSync as readFileSync8 } from "node:fs";
|
|
36801
36801
|
import { homedir as homedir6 } from "node:os";
|
|
36802
|
-
import { dirname as dirname5, join as
|
|
36802
|
+
import { dirname as dirname5, join as join13 } from "node:path";
|
|
36803
36803
|
import { fileURLToPath } from "node:url";
|
|
36804
36804
|
|
|
36805
36805
|
// node_modules/commander/esm.mjs
|
|
@@ -37381,15 +37381,9 @@ function print(value, json, text) {
|
|
|
37381
37381
|
else
|
|
37382
37382
|
console.log(text);
|
|
37383
37383
|
}
|
|
37384
|
-
function hasJsonOption(options) {
|
|
37385
|
-
return Boolean(options?.json || options?.opts?.().json || options?.optsWithGlobals?.().json || options?.parent?.opts?.().json || options?.parent?.optsWithGlobals?.().json);
|
|
37386
|
-
}
|
|
37387
|
-
function wantsJson(actionOptions, command) {
|
|
37388
|
-
return hasJsonOption(actionOptions) || hasJsonOption(command);
|
|
37389
|
-
}
|
|
37390
37384
|
function registerWebhookCommands(program2, options) {
|
|
37391
37385
|
const webhooks = program2.command(options.webhooksCommandName ?? "webhooks").description("Manage Hasna event webhook subscriptions");
|
|
37392
|
-
webhooks.command("add").description("Add or replace a webhook or command subscription").argument("<target>", "Webhook URL or command binary").requiredOption("--id <id>", "Subscription/channel identifier").option("--transport <kind>", "Transport kind: webhook or command", "webhook").option("--name <name>", "Display name").option("--type <pattern>", "Event type filter, e.g. todos.task.*").option("--source <pattern>", "Event source filter").option("--subject <pattern>", "Event subject filter").option("--severity <pattern>", "Event severity filter").option("--secret <secret>", "Webhook HMAC secret").option("--header <name=value...>", "Webhook header", collectValues, []).option("--arg <arg...>", "Command argument", collectValues, []).option("--timeout-ms <ms>", "Transport timeout in milliseconds", parseNumber).option("--retry-attempts <n>", "Maximum delivery attempts", parseNumber).option("--retry-backoff-ms <ms>", "Initial retry backoff in milliseconds", parseNumber).option("--redact <path...>", "Event field path to redact before delivery", collectValues, []).option("--disabled", "Create channel disabled", false).option("-j, --json", "Print JSON output", false).action(async (target, actionOptions
|
|
37386
|
+
webhooks.command("add").description("Add or replace a webhook or command subscription").argument("<target>", "Webhook URL or command binary").requiredOption("--id <id>", "Subscription/channel identifier").option("--transport <kind>", "Transport kind: webhook or command", "webhook").option("--name <name>", "Display name").option("--type <pattern>", "Event type filter, e.g. todos.task.*").option("--source <pattern>", "Event source filter").option("--subject <pattern>", "Event subject filter").option("--severity <pattern>", "Event severity filter").option("--secret <secret>", "Webhook HMAC secret").option("--header <name=value...>", "Webhook header", collectValues, []).option("--arg <arg...>", "Command argument", collectValues, []).option("--timeout-ms <ms>", "Transport timeout in milliseconds", parseNumber).option("--retry-attempts <n>", "Maximum delivery attempts", parseNumber).option("--retry-backoff-ms <ms>", "Initial retry backoff in milliseconds", parseNumber).option("--redact <path...>", "Event field path to redact before delivery", collectValues, []).option("--disabled", "Create channel disabled", false).option("-j, --json", "Print JSON output", false).action(async (target, actionOptions) => {
|
|
37393
37387
|
const timestamp = new Date().toISOString();
|
|
37394
37388
|
const channel = {
|
|
37395
37389
|
id: actionOptions.id,
|
|
@@ -37410,11 +37404,11 @@ function registerWebhookCommands(program2, options) {
|
|
|
37410
37404
|
throw new Error(`Transport ${actionOptions.transport} is reserved for future use and cannot be added yet`);
|
|
37411
37405
|
}
|
|
37412
37406
|
const saved = await createClient(options).addChannel(channel);
|
|
37413
|
-
print(sanitizeChannelForOutput(saved),
|
|
37407
|
+
print(sanitizeChannelForOutput(saved), Boolean(actionOptions.json), `Added ${saved.transport} channel ${saved.id}`);
|
|
37414
37408
|
});
|
|
37415
|
-
webhooks.command("list").description("List configured subscriptions").option("-j, --json", "Print JSON output", false).action(async (actionOptions
|
|
37409
|
+
webhooks.command("list").description("List configured subscriptions").option("-j, --json", "Print JSON output", false).action(async (actionOptions) => {
|
|
37416
37410
|
const channels = await createClient(options).listChannels();
|
|
37417
|
-
if (
|
|
37411
|
+
if (actionOptions.json) {
|
|
37418
37412
|
console.log(JSON.stringify(sanitizeChannelsForOutput(channels), null, 2));
|
|
37419
37413
|
return;
|
|
37420
37414
|
}
|
|
@@ -37426,11 +37420,11 @@ function registerWebhookCommands(program2, options) {
|
|
|
37426
37420
|
console.log(`${channel.id} ${channel.enabled ? "enabled" : "disabled"} ${channel.transport} ${channel.webhook?.url ?? channel.command?.command ?? channel.transport}`);
|
|
37427
37421
|
}
|
|
37428
37422
|
});
|
|
37429
|
-
webhooks.command("remove").description("Remove a subscription").argument("<id>", "Subscription/channel identifier").option("-j, --json", "Print JSON output", false).action(async (id, actionOptions
|
|
37423
|
+
webhooks.command("remove").description("Remove a subscription").argument("<id>", "Subscription/channel identifier").option("-j, --json", "Print JSON output", false).action(async (id, actionOptions) => {
|
|
37430
37424
|
const removed = await createClient(options).removeChannel(id);
|
|
37431
|
-
print({ removed },
|
|
37425
|
+
print({ removed }, Boolean(actionOptions.json), removed ? `Removed ${id}` : `Channel not found: ${id}`);
|
|
37432
37426
|
});
|
|
37433
|
-
webhooks.command("test").description("Send a test event to one subscription").argument("<id>", "Subscription/channel identifier").option("--type <type>", "Event type", "events.test").option("--subject <subject>", "Event subject").option("--message <message>", "Event message", "Hasna events test delivery").option("--data <json>", "Event data JSON object").option("-j, --json", "Print JSON output", false).action(async (id, actionOptions
|
|
37427
|
+
webhooks.command("test").description("Send a test event to one subscription").argument("<id>", "Subscription/channel identifier").option("--type <type>", "Event type", "events.test").option("--subject <subject>", "Event subject").option("--message <message>", "Event message", "Hasna events test delivery").option("--data <json>", "Event data JSON object").option("-j, --json", "Print JSON output", false).action(async (id, actionOptions) => {
|
|
37434
37428
|
const result = await createClient(options).testChannel(id, {
|
|
37435
37429
|
source: options.source,
|
|
37436
37430
|
type: actionOptions.type,
|
|
@@ -37438,13 +37432,13 @@ function registerWebhookCommands(program2, options) {
|
|
|
37438
37432
|
message: actionOptions.message,
|
|
37439
37433
|
data: parseJsonObject(actionOptions.data, { test: true })
|
|
37440
37434
|
});
|
|
37441
|
-
print(result,
|
|
37435
|
+
print(result, Boolean(actionOptions.json), `${result.status}: ${result.channelId}`);
|
|
37442
37436
|
});
|
|
37443
37437
|
return webhooks;
|
|
37444
37438
|
}
|
|
37445
37439
|
function registerEventCommands(program2, options) {
|
|
37446
37440
|
const events = program2.command(options.eventsCommandName ?? "events").description("Emit, list, and replay Hasna events");
|
|
37447
|
-
events.command("emit").description("Emit an event from this app").argument("<type>", "Event type").option("--source <source>", "Event source override").option("--subject <subject>", "Event subject").option("--severity <severity>", "Event severity", "info").option("--message <message>", "Event message").option("--dedupe-key <key>", "Dedupe key").option("--data <json>", "Event data JSON object").option("--metadata <json>", "Event metadata JSON object").option("--no-deliver", "Record without delivering").option("--no-dedupe", "Allow duplicate id/dedupeKey events").option("-j, --json", "Print JSON output", false).action(async (type, actionOptions
|
|
37441
|
+
events.command("emit").description("Emit an event from this app").argument("<type>", "Event type").option("--source <source>", "Event source override").option("--subject <subject>", "Event subject").option("--severity <severity>", "Event severity", "info").option("--message <message>", "Event message").option("--dedupe-key <key>", "Dedupe key").option("--data <json>", "Event data JSON object").option("--metadata <json>", "Event metadata JSON object").option("--no-deliver", "Record without delivering").option("--no-dedupe", "Allow duplicate id/dedupeKey events").option("-j, --json", "Print JSON output", false).action(async (type, actionOptions) => {
|
|
37448
37442
|
const result = await createClient(options).emit({
|
|
37449
37443
|
source: actionOptions.source ?? options.source,
|
|
37450
37444
|
type,
|
|
@@ -37455,9 +37449,9 @@ function registerEventCommands(program2, options) {
|
|
|
37455
37449
|
data: parseJsonObject(actionOptions.data, {}),
|
|
37456
37450
|
metadata: parseJsonObject(actionOptions.metadata, {})
|
|
37457
37451
|
}, { deliver: actionOptions.deliver, dedupe: actionOptions.dedupe });
|
|
37458
|
-
print(result,
|
|
37452
|
+
print(result, Boolean(actionOptions.json), `${result.deduped ? "Deduped" : "Emitted"} ${result.event.id} to ${result.deliveries.length} channel(s)`);
|
|
37459
37453
|
});
|
|
37460
|
-
events.command("list").description("List recorded events").option("--source <source>", "Filter by source").option("--type <type>", "Filter by type").option("--limit <n>", "Limit results", parseNumber).option("-j, --json", "Print JSON output", false).action(async (actionOptions
|
|
37454
|
+
events.command("list").description("List recorded events").option("--source <source>", "Filter by source").option("--type <type>", "Filter by type").option("--limit <n>", "Limit results", parseNumber).option("-j, --json", "Print JSON output", false).action(async (actionOptions) => {
|
|
37461
37455
|
let rows = await createClient(options).listEvents();
|
|
37462
37456
|
if (actionOptions.source)
|
|
37463
37457
|
rows = rows.filter((event) => event.source === actionOptions.source);
|
|
@@ -37465,7 +37459,7 @@ function registerEventCommands(program2, options) {
|
|
|
37465
37459
|
rows = rows.filter((event) => event.type === actionOptions.type);
|
|
37466
37460
|
if (actionOptions.limit)
|
|
37467
37461
|
rows = rows.slice(-actionOptions.limit);
|
|
37468
|
-
if (
|
|
37462
|
+
if (actionOptions.json) {
|
|
37469
37463
|
console.log(JSON.stringify(rows, null, 2));
|
|
37470
37464
|
return;
|
|
37471
37465
|
}
|
|
@@ -37476,14 +37470,14 @@ function registerEventCommands(program2, options) {
|
|
|
37476
37470
|
for (const event of rows)
|
|
37477
37471
|
console.log(`${event.time} ${event.id} ${event.source} ${event.type} ${event.severity}`);
|
|
37478
37472
|
});
|
|
37479
|
-
events.command("replay").description("Replay recorded events").option("--id <id>", "Replay one event id").option("--source <source>", "Filter by source").option("--type <type>", "Filter by type").option("--dry-run", "Preview without delivery", false).option("-j, --json", "Print JSON output", false).action(async (actionOptions
|
|
37473
|
+
events.command("replay").description("Replay recorded events").option("--id <id>", "Replay one event id").option("--source <source>", "Filter by source").option("--type <type>", "Filter by type").option("--dry-run", "Preview without delivery", false).option("-j, --json", "Print JSON output", false).action(async (actionOptions) => {
|
|
37480
37474
|
const result = await createClient(options).replay({
|
|
37481
37475
|
eventId: actionOptions.id,
|
|
37482
37476
|
source: actionOptions.source,
|
|
37483
37477
|
type: actionOptions.type,
|
|
37484
37478
|
dryRun: actionOptions.dryRun
|
|
37485
37479
|
});
|
|
37486
|
-
print(result,
|
|
37480
|
+
print(result, Boolean(actionOptions.json), `Replayed ${result.events.length} event(s), ${result.deliveries.length} delivery result(s)`);
|
|
37487
37481
|
});
|
|
37488
37482
|
return events;
|
|
37489
37483
|
}
|
|
@@ -41978,6 +41972,7 @@ var toolDefSchema = exports_external.object({
|
|
|
41978
41972
|
loginHint: exports_external.string().optional(),
|
|
41979
41973
|
resumeArgs: exports_external.array(exports_external.string()).optional(),
|
|
41980
41974
|
permissionArgs: exports_external.record(exports_external.array(exports_external.string())).optional(),
|
|
41975
|
+
launchArgs: exports_external.array(exports_external.string()).optional(),
|
|
41981
41976
|
accountFile: exports_external.string().optional(),
|
|
41982
41977
|
emailPath: exports_external.array(exports_external.string()).optional()
|
|
41983
41978
|
});
|
|
@@ -42301,6 +42296,9 @@ var BUILTIN_TOOLS = [
|
|
|
42301
42296
|
id: "claude",
|
|
42302
42297
|
label: "Claude Code",
|
|
42303
42298
|
envVar: "CLAUDE_CONFIG_DIR",
|
|
42299
|
+
extraEnv: {
|
|
42300
|
+
TELEGRAM_STATE_DIR: "{profileDir}/channels/telegram"
|
|
42301
|
+
},
|
|
42304
42302
|
defaultDir: join3(homedir3(), ".claude"),
|
|
42305
42303
|
bin: "claude",
|
|
42306
42304
|
loginHint: "run /login inside Claude, then /exit when done",
|
|
@@ -42317,6 +42315,16 @@ var BUILTIN_TOOLS = [
|
|
|
42317
42315
|
accountFile: ".claude.json",
|
|
42318
42316
|
emailPath: ["oauthAccount", "emailAddress"]
|
|
42319
42317
|
},
|
|
42318
|
+
{
|
|
42319
|
+
id: "codex-app",
|
|
42320
|
+
label: "Codex App",
|
|
42321
|
+
envVar: "CODEX_HOME",
|
|
42322
|
+
defaultDir: join3(homedir3(), ".codex"),
|
|
42323
|
+
bin: "/Applications/Codex.app/Contents/MacOS/Codex",
|
|
42324
|
+
loginHint: "sign in inside Codex.app, then quit the app when the profile is ready",
|
|
42325
|
+
launchArgs: ["--user-data-dir={profileDir}/electron-user-data"],
|
|
42326
|
+
accountFile: "auth.json"
|
|
42327
|
+
},
|
|
42320
42328
|
{
|
|
42321
42329
|
id: "codex",
|
|
42322
42330
|
label: "Codex CLI",
|
|
@@ -42466,9 +42474,17 @@ function permissionArgsFor(tool, permissions) {
|
|
|
42466
42474
|
}
|
|
42467
42475
|
return args;
|
|
42468
42476
|
}
|
|
42477
|
+
function renderToolArg(value, profile) {
|
|
42478
|
+
return value.replaceAll("{profileDir}", profile.dir).replaceAll("{profileName}", profile.name).replaceAll("{toolId}", profile.tool);
|
|
42479
|
+
}
|
|
42480
|
+
function launchArgsFor(tool, profile) {
|
|
42481
|
+
const args = tool.launchArgs ?? [];
|
|
42482
|
+
return profile ? args.map((arg) => renderToolArg(arg, profile)) : args;
|
|
42483
|
+
}
|
|
42469
42484
|
function mergeToolArgs(tool, args, opts = {}) {
|
|
42485
|
+
const launchArgs = launchArgsFor(tool, opts.profile).filter((arg) => !args.includes(arg));
|
|
42470
42486
|
const permissionArgs = permissionArgsFor(tool, opts.permissions).filter((arg) => !args.includes(arg));
|
|
42471
|
-
return [...permissionArgs, ...args];
|
|
42487
|
+
return [...permissionArgs, ...launchArgs, ...args];
|
|
42472
42488
|
}
|
|
42473
42489
|
var BUILTIN_IDS = new Set(BUILTIN_TOOLS.map((t) => t.id));
|
|
42474
42490
|
function isBuiltinTool(id) {
|
|
@@ -43367,11 +43383,11 @@ function importProfile(opts) {
|
|
|
43367
43383
|
ensureProfileAuthSnapshot(profile.dir, tool);
|
|
43368
43384
|
return profile;
|
|
43369
43385
|
}
|
|
43370
|
-
function ensureProfileForLogin(name, toolId
|
|
43386
|
+
function ensureProfileForLogin(name, toolId) {
|
|
43371
43387
|
const existing = findProfileByName(name, toolId);
|
|
43372
43388
|
if (existing)
|
|
43373
43389
|
return existing;
|
|
43374
|
-
return addProfile({ name, tool: toolId, description: "created for login" });
|
|
43390
|
+
return addProfile({ name, tool: toolId ?? DEFAULT_TOOL, description: "created for login" });
|
|
43375
43391
|
}
|
|
43376
43392
|
function findProfileByName(name, toolId) {
|
|
43377
43393
|
try {
|
|
@@ -43482,6 +43498,42 @@ function shellSnippet() {
|
|
|
43482
43498
|
return `source ${shellQuotePath(hookPath())}`;
|
|
43483
43499
|
}
|
|
43484
43500
|
|
|
43501
|
+
// src/lib/codex-app.ts
|
|
43502
|
+
import { existsSync as existsSync11, mkdirSync as mkdirSync7, readFileSync as readFileSync6, writeFileSync as writeFileSync5 } from "node:fs";
|
|
43503
|
+
import { join as join11 } from "node:path";
|
|
43504
|
+
var FILE_CREDENTIALS_LINE = 'cli_auth_credentials_store = "file"';
|
|
43505
|
+
function insertRootConfigLine(config, line) {
|
|
43506
|
+
if (config.trim() === "")
|
|
43507
|
+
return `${line}
|
|
43508
|
+
`;
|
|
43509
|
+
const lines = config.split(/\r?\n/);
|
|
43510
|
+
const tableIndex = lines.findIndex((entry) => /^\s*\[[^\]]+\]\s*(?:#.*)?$/.test(entry));
|
|
43511
|
+
if (tableIndex === -1)
|
|
43512
|
+
return `${config.trimEnd()}
|
|
43513
|
+
|
|
43514
|
+
${line}
|
|
43515
|
+
`;
|
|
43516
|
+
const before = lines.slice(0, tableIndex).join(`
|
|
43517
|
+
`).trimEnd();
|
|
43518
|
+
const after = lines.slice(tableIndex).join(`
|
|
43519
|
+
`).trimStart();
|
|
43520
|
+
return `${before}${before ? `
|
|
43521
|
+
|
|
43522
|
+
` : ""}${line}
|
|
43523
|
+
|
|
43524
|
+
${after}${after.endsWith(`
|
|
43525
|
+
`) ? "" : `
|
|
43526
|
+
`}`;
|
|
43527
|
+
}
|
|
43528
|
+
function ensureCodexAppProfileConfig(profileDir) {
|
|
43529
|
+
mkdirSync7(profileDir, { recursive: true });
|
|
43530
|
+
const configPath = join11(profileDir, "config.toml");
|
|
43531
|
+
const current = existsSync11(configPath) ? readFileSync6(configPath, "utf8") : "";
|
|
43532
|
+
if (/^\s*cli_auth_credentials_store\s*=/.test(current))
|
|
43533
|
+
return;
|
|
43534
|
+
writeFileSync5(configPath, insertRootConfigLine(current, FILE_CREDENTIALS_LINE), { mode: 384 });
|
|
43535
|
+
}
|
|
43536
|
+
|
|
43485
43537
|
// src/lib/env.ts
|
|
43486
43538
|
function renderTemplate(value, profile) {
|
|
43487
43539
|
return value.replaceAll("{profileDir}", profile.dir).replaceAll("{profileName}", profile.name).replaceAll("{toolId}", profile.tool);
|
|
@@ -43498,6 +43550,8 @@ function profileEnv(profile, tool) {
|
|
|
43498
43550
|
for (const key of CLAUDE_API_AUTH_ENV_KEYS)
|
|
43499
43551
|
env2[key] = "";
|
|
43500
43552
|
}
|
|
43553
|
+
if (tool.id === "codex-app")
|
|
43554
|
+
ensureCodexAppProfileConfig(profile.dir);
|
|
43501
43555
|
return env2;
|
|
43502
43556
|
}
|
|
43503
43557
|
function formatEnvAssignments(env2) {
|
|
@@ -43531,9 +43585,9 @@ function shellQuote(value) {
|
|
|
43531
43585
|
function commandLine(env2, command) {
|
|
43532
43586
|
return `${formatEnvAssignments(env2)} ${command.map(shellQuote).join(" ")}`.trim();
|
|
43533
43587
|
}
|
|
43534
|
-
function commandFor(tool, opts) {
|
|
43588
|
+
function commandFor(profile, tool, opts) {
|
|
43535
43589
|
const args = [...opts.resume ? tool.resumeArgs ?? [] : [], ...opts.args ?? []];
|
|
43536
|
-
return [tool.bin, ...mergeToolArgs(tool, args, { permissions: opts.permissions })];
|
|
43590
|
+
return [tool.bin, ...mergeToolArgs(tool, args, { permissions: opts.permissions, profile })];
|
|
43537
43591
|
}
|
|
43538
43592
|
function switchProfile(name, opts = {}) {
|
|
43539
43593
|
const profile = getProfile(name, opts.tool);
|
|
@@ -43550,7 +43604,7 @@ function switchProfile(name, opts = {}) {
|
|
|
43550
43604
|
} else {
|
|
43551
43605
|
useProfile(name, tool.id);
|
|
43552
43606
|
}
|
|
43553
|
-
const command = commandFor(tool, opts);
|
|
43607
|
+
const command = commandFor(profile, tool, opts);
|
|
43554
43608
|
const restartRequired = opts.resume === true || applied || mode === "env";
|
|
43555
43609
|
const message = applied ? `${profile.name} is now the live/default ${tool.label} profile` : `${profile.name} is now the active ${tool.label} profile`;
|
|
43556
43610
|
return {
|
|
@@ -43571,22 +43625,22 @@ function switchProfile(name, opts = {}) {
|
|
|
43571
43625
|
// src/lib/supervisor.ts
|
|
43572
43626
|
import { spawn as spawn2 } from "node:child_process";
|
|
43573
43627
|
import { createHash } from "node:crypto";
|
|
43574
|
-
import { existsSync as
|
|
43628
|
+
import { existsSync as existsSync12, mkdirSync as mkdirSync8, readFileSync as readFileSync7, readdirSync, rmSync as rmSync2, writeFileSync as writeFileSync6 } from "node:fs";
|
|
43575
43629
|
import { createConnection, createServer } from "node:net";
|
|
43576
|
-
import { basename, join as
|
|
43630
|
+
import { basename, join as join12 } from "node:path";
|
|
43577
43631
|
var STATE_SUFFIX = ".json";
|
|
43578
43632
|
function supervisorDir() {
|
|
43579
|
-
return
|
|
43633
|
+
return join12(accountsHome(), "supervisors");
|
|
43580
43634
|
}
|
|
43581
43635
|
function supervisorStatePath(toolId) {
|
|
43582
|
-
return
|
|
43636
|
+
return join12(supervisorDir(), `${toolId}${STATE_SUFFIX}`);
|
|
43583
43637
|
}
|
|
43584
43638
|
function supervisorSocketPath(toolId) {
|
|
43585
43639
|
if (process.platform === "win32") {
|
|
43586
43640
|
const hash = createHash("sha1").update(accountsHome()).digest("hex").slice(0, 12);
|
|
43587
43641
|
return `\\\\.\\pipe\\hasna-accounts-${hash}-${toolId}`;
|
|
43588
43642
|
}
|
|
43589
|
-
return
|
|
43643
|
+
return join12(supervisorDir(), `${toolId}.sock`);
|
|
43590
43644
|
}
|
|
43591
43645
|
function nowIso2() {
|
|
43592
43646
|
return new Date().toISOString();
|
|
@@ -43600,23 +43654,23 @@ function parseState(raw) {
|
|
|
43600
43654
|
}
|
|
43601
43655
|
function readSupervisorState(toolId) {
|
|
43602
43656
|
const path = supervisorStatePath(toolId);
|
|
43603
|
-
if (!
|
|
43657
|
+
if (!existsSync12(path))
|
|
43604
43658
|
return;
|
|
43605
43659
|
try {
|
|
43606
|
-
return parseState(
|
|
43660
|
+
return parseState(readFileSync7(path, "utf8"));
|
|
43607
43661
|
} catch {
|
|
43608
43662
|
return;
|
|
43609
43663
|
}
|
|
43610
43664
|
}
|
|
43611
43665
|
function listSupervisorStates() {
|
|
43612
43666
|
const dir = supervisorDir();
|
|
43613
|
-
if (!
|
|
43667
|
+
if (!existsSync12(dir))
|
|
43614
43668
|
return [];
|
|
43615
43669
|
return readdirSync(dir).filter((name) => name.endsWith(STATE_SUFFIX)).map((name) => basename(name, STATE_SUFFIX)).map((toolId) => readSupervisorState(toolId)).filter((state) => state !== undefined);
|
|
43616
43670
|
}
|
|
43617
43671
|
function writeSupervisorState(state) {
|
|
43618
|
-
|
|
43619
|
-
|
|
43672
|
+
mkdirSync8(supervisorDir(), { recursive: true });
|
|
43673
|
+
writeFileSync6(supervisorStatePath(state.tool), JSON.stringify(state, null, 2) + `
|
|
43620
43674
|
`, { mode: 384 });
|
|
43621
43675
|
}
|
|
43622
43676
|
function removeSupervisorFiles(toolId) {
|
|
@@ -43757,7 +43811,7 @@ async function runSupervisedTool(initialProfile, tool, initialArgs = [], opts =
|
|
|
43757
43811
|
throw new AccountsError(`an accounts supervisor for ${tool.label} is already running (pid ${existing.pid})`);
|
|
43758
43812
|
}
|
|
43759
43813
|
removeSupervisorFiles(tool.id);
|
|
43760
|
-
|
|
43814
|
+
mkdirSync8(supervisorDir(), { recursive: true });
|
|
43761
43815
|
const startedAt = nowIso2();
|
|
43762
43816
|
const restartDelayMs = opts.restartDelayMs ?? 350;
|
|
43763
43817
|
const log = opts.log ?? (() => {
|
|
@@ -44002,7 +44056,7 @@ program2.command("add").argument("<name>", "profile name (lowercase, hyphenated)
|
|
|
44002
44056
|
console.log(` config dir: ${p.dir}`);
|
|
44003
44057
|
console.log(` email: ${p.email ?? source_default.dim("(none — set with `accounts set " + p.name + " --email ...`)")}`);
|
|
44004
44058
|
const tool = getTool(p.tool);
|
|
44005
|
-
console.log(source_default.dim(` launch it: accounts launch ${p.name}
|
|
44059
|
+
console.log(source_default.dim(` launch it: accounts launch ${p.name} (sets ${tool.envVar} and runs ${tool.bin})`));
|
|
44006
44060
|
}));
|
|
44007
44061
|
program2.command("list").alias("ls").description("list all profiles").option("-t, --tool <tool>", "filter by tool").option("--json", "output JSON").action(action((opts) => {
|
|
44008
44062
|
const profiles = listProfiles(opts.tool);
|
|
@@ -44032,7 +44086,7 @@ program2.command("show").argument("<name>", "profile name").description("show fu
|
|
|
44032
44086
|
console.log(` tool: ${p.tool} (${getTool(p.tool).label})`);
|
|
44033
44087
|
console.log(` active: ${active ? source_default.green("yes") : source_default.dim("no")}`);
|
|
44034
44088
|
console.log(` applied: ${isApplied ? source_default.magenta("yes") : source_default.dim("no")}`);
|
|
44035
|
-
console.log(` config dir: ${p.dir}${
|
|
44089
|
+
console.log(` config dir: ${p.dir}${existsSync13(p.dir) ? "" : source_default.red(" [missing]")}`);
|
|
44036
44090
|
console.log(` email: ${p.email ?? source_default.dim("(none)")}`);
|
|
44037
44091
|
console.log(` created: ${p.createdAt}`);
|
|
44038
44092
|
if (p.lastUsedAt)
|
|
@@ -44067,9 +44121,9 @@ program2.command("import").argument("[name]", "profile name (default: main)").de
|
|
|
44067
44121
|
console.log(source_default.green(`✓ imported profile ${source_default.bold(p.name)}`));
|
|
44068
44122
|
console.log(` config dir: ${p.dir}`);
|
|
44069
44123
|
console.log(` email: ${p.email ?? source_default.dim("(none)")}`);
|
|
44070
|
-
console.log(source_default.dim(` next: accounts login ${p.name}
|
|
44124
|
+
console.log(source_default.dim(` next: accounts login ${p.name} OR accounts apply ${p.name}`));
|
|
44071
44125
|
}));
|
|
44072
|
-
program2.command("login").argument("<name>", "profile name").description("launch the tool's login flow inside an isolated profile dir").option("-t, --tool <tool>", "tool"
|
|
44126
|
+
program2.command("login").argument("<name>", "profile name").description("launch the tool's login flow inside an isolated profile dir").option("-t, --tool <tool>", "tool when creating a missing profile or when the profile name is ambiguous").action(action((name, opts) => {
|
|
44073
44127
|
const profile = ensureProfileForLogin(name, opts.tool);
|
|
44074
44128
|
const tool = getTool(profile.tool);
|
|
44075
44129
|
const env2 = profileEnv(profile, tool);
|
|
@@ -44082,7 +44136,7 @@ program2.command("login").argument("<name>", "profile name").description("launch
|
|
|
44082
44136
|
if (tool.id === "claude") {
|
|
44083
44137
|
console.log(source_default.dim(" After Claude exits, accounts will make this the live/default Claude account."));
|
|
44084
44138
|
}
|
|
44085
|
-
const res = spawnSync2(tool.bin, loginArgs, {
|
|
44139
|
+
const res = spawnSync2(tool.bin, mergeToolArgs(tool, loginArgs, { profile }), {
|
|
44086
44140
|
stdio: "inherit",
|
|
44087
44141
|
env: { ...process.env, ...env2 }
|
|
44088
44142
|
});
|
|
@@ -44184,7 +44238,7 @@ program2.command("switch").argument("<name>", "profile name").argument("[args...
|
|
|
44184
44238
|
}
|
|
44185
44239
|
}));
|
|
44186
44240
|
var hook = program2.command("hook").description("install a shell wrapper for claude");
|
|
44187
|
-
hook.command("install").description(`write ${
|
|
44241
|
+
hook.command("install").description(`write ${join13(accountsHome(), "claude-hook.sh")}`).action(action(() => {
|
|
44188
44242
|
const { path, created } = installHook();
|
|
44189
44243
|
console.log(source_default.green(created ? `✓ installed hook at ${path}` : `✓ updated hook at ${path}`));
|
|
44190
44244
|
console.log(source_default.dim(` add to ~/.zshrc: ${shellSnippet()}`));
|
|
@@ -44210,7 +44264,7 @@ program2.command("launch").argument("<name>", "profile name").argument("[args...
|
|
|
44210
44264
|
const profile = getProfile(name, opts.tool);
|
|
44211
44265
|
const tool = getTool(profile.tool);
|
|
44212
44266
|
const env2 = profileEnv(profile, tool);
|
|
44213
|
-
const launchArgs = mergeToolArgs(tool, args, { permissions: opts.permissions });
|
|
44267
|
+
const launchArgs = mergeToolArgs(tool, args, { permissions: opts.permissions, profile });
|
|
44214
44268
|
useProfile(name, tool.id);
|
|
44215
44269
|
console.log(source_default.dim(`→ ${formatEnvAssignments(env2)} ${tool.bin} ${launchArgs.join(" ")}`));
|
|
44216
44270
|
const res = spawnSync2(tool.bin, launchArgs, {
|
|
@@ -44224,7 +44278,8 @@ program2.command("launch").argument("<name>", "profile name").argument("[args...
|
|
|
44224
44278
|
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) => {
|
|
44225
44279
|
const plan = resolveSupervisorLaunch(target, { profile: opts.profile, tool: opts.tool });
|
|
44226
44280
|
const runArgs = mergeToolArgs(plan.tool, [...opts.resume ? plan.tool.resumeArgs ?? [] : [], ...args], {
|
|
44227
|
-
permissions: opts.permissions
|
|
44281
|
+
permissions: opts.permissions,
|
|
44282
|
+
profile: plan.profile
|
|
44228
44283
|
});
|
|
44229
44284
|
console.error(source_default.green(`✓ accounts supervisor running ${plan.tool.label} as ${source_default.bold(plan.profile.name)}`));
|
|
44230
44285
|
console.error(source_default.dim(` control: accounts supervisor status ${plan.tool.id}`));
|
|
@@ -44409,7 +44464,7 @@ tools.command("list", { isDefault: true }).description("list supported tools (bu
|
|
|
44409
44464
|
console.log(`${source_default.cyan(t.id.padEnd(10))} ${t.label.padEnd(16)} ${source_default.dim(envNames)} → ${source_default.dim(t.defaultDir)} ${tag}${permissionsHint}`);
|
|
44410
44465
|
}
|
|
44411
44466
|
}));
|
|
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) => {
|
|
44467
|
+
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("--launch-arg <arg...>", "arguments prepended when launching; supports {profileDir}, {profileName}, {toolId}").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) => {
|
|
44413
44468
|
const extraEnv = {};
|
|
44414
44469
|
for (const entry of opts.extraEnv ?? []) {
|
|
44415
44470
|
const idx = entry.indexOf("=");
|
|
@@ -44423,9 +44478,10 @@ tools.command("add").argument("<id>", "tool id, e.g. cursor").description("regis
|
|
|
44423
44478
|
label: opts.label,
|
|
44424
44479
|
envVar: opts.envVar,
|
|
44425
44480
|
bin: opts.bin,
|
|
44426
|
-
defaultDir: opts.defaultDir ? expandPath(opts.defaultDir) :
|
|
44481
|
+
defaultDir: opts.defaultDir ? expandPath(opts.defaultDir) : join13(homedir6(), `.${id}`),
|
|
44427
44482
|
...Object.keys(extraEnv).length > 0 ? { extraEnv } : {},
|
|
44428
44483
|
...opts.loginArg ? { loginArgs: opts.loginArg } : {},
|
|
44484
|
+
...opts.launchArg ? { launchArgs: opts.launchArg } : {},
|
|
44429
44485
|
...opts.resumeArg ? { resumeArgs: opts.resumeArg } : {},
|
|
44430
44486
|
...Object.keys(permissionArgs).length > 0 ? { permissionArgs } : {},
|
|
44431
44487
|
...opts.accountFile ? { accountFile: opts.accountFile } : {},
|
|
@@ -44445,7 +44501,7 @@ program2.command("doctor").description("check the store and profile dirs for pro
|
|
|
44445
44501
|
const profiles = listProfiles();
|
|
44446
44502
|
let problems = 0;
|
|
44447
44503
|
for (const p of profiles) {
|
|
44448
|
-
const missing = !
|
|
44504
|
+
const missing = !existsSync13(p.dir);
|
|
44449
44505
|
const noEmail = !p.email;
|
|
44450
44506
|
if (missing) {
|
|
44451
44507
|
console.log(source_default.red(` ✗ ${p.name}: config dir missing (${p.dir})`));
|
|
@@ -44494,9 +44550,9 @@ program2.parseAsync(process.argv);
|
|
|
44494
44550
|
function getVersion() {
|
|
44495
44551
|
try {
|
|
44496
44552
|
const here = dirname5(fileURLToPath(import.meta.url));
|
|
44497
|
-
for (const candidate of [
|
|
44498
|
-
if (
|
|
44499
|
-
const pkg = JSON.parse(
|
|
44553
|
+
for (const candidate of [join13(here, "..", "package.json"), join13(here, "package.json")]) {
|
|
44554
|
+
if (existsSync13(candidate)) {
|
|
44555
|
+
const pkg = JSON.parse(readFileSync8(candidate, "utf8"));
|
|
44500
44556
|
if (pkg.version)
|
|
44501
44557
|
return pkg.version;
|
|
44502
44558
|
}
|
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, mergeToolArgs, normalizePermissionPreset, permissionArgsFor, } from "./lib/tools.js";
|
|
3
|
+
export { BUILTIN_TOOLS, DEFAULT_TOOL, getTool, listTools, isBuiltinTool, addCustomTool, removeCustomTool, mergeToolArgs, launchArgsFor, 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";
|
package/dist/index.d.ts.map
CHANGED
|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