@hasna/accounts 0.1.7 → 0.1.9

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.
@@ -1,5 +1,9 @@
1
1
  import type { Profile } from "../types.js";
2
2
  export type AgentEntry = Record<string, unknown>;
3
+ /** Minimal profile shape needed to query agents (allows synthetic entries). */
4
+ export type ProfileLike = Pick<Profile, "name" | "tool" | "dir"> & {
5
+ email?: string;
6
+ };
3
7
  export interface ProfileAgents {
4
8
  profile: string;
5
9
  tool: string;
@@ -13,7 +17,14 @@ export interface AgentsRunnerResult {
13
17
  raw: string;
14
18
  error?: string;
15
19
  }
16
- export type AgentsRunner = (profile: Profile) => AgentsRunnerResult;
20
+ export type AgentsRunner = (profile: ProfileLike) => AgentsRunnerResult;
21
+ export interface ProcessInfo {
22
+ pid: number;
23
+ ppid: number;
24
+ command: string;
25
+ configDir?: string;
26
+ }
27
+ export type ProcessScanner = () => ProcessInfo[];
17
28
  /**
18
29
  * Extract the first top-level JSON array from output that may be wrapped in
19
30
  * pty/ANSI noise (`claude agents --json` only works on a TTY, so we run it
@@ -25,13 +36,32 @@ export declare function extractJsonArray(raw: string): unknown[] | undefined;
25
36
  * Claude Code switches to print-mode argument parsing when stdout is not a
26
37
  * TTY and never reaches the `agents` subcommand, so a plain pipe won't work.
27
38
  */
28
- export declare function runClaudeAgentsJson(profile: Profile, timeoutMs?: number): AgentsRunnerResult;
39
+ export declare function runClaudeAgentsJson(profile: ProfileLike, timeoutMs?: number): AgentsRunnerResult;
40
+ /**
41
+ * True when a `ps` command line looks like a real agent session process for
42
+ * the tool — not a daemon, pty host, pre-warmed spare, shell snapshot, our
43
+ * own `agents` listing invocation, or an `accounts` wrapper.
44
+ */
45
+ export declare function isToolSessionCommand(command: string, bin: string): boolean;
46
+ /** Scan running processes for agent sessions of a tool (pid, ppid, command, config dir). */
47
+ export declare function scanToolProcesses(toolId?: string): ProcessInfo[];
29
48
  export interface ListAgentsOptions {
30
49
  tool?: string;
31
50
  profile?: string;
32
51
  backgroundOnly?: boolean;
33
52
  runner?: AgentsRunner;
53
+ /** Override the tool's default config dir (used by tests). */
54
+ defaultDir?: string;
55
+ processScanner?: ProcessScanner;
34
56
  }
35
- /** List agent sessions for every profile of a tool (default: claude). */
57
+ /**
58
+ * List agent sessions for every profile of a tool (default: claude).
59
+ *
60
+ * Besides registered profiles this also queries the tool's DEFAULT config
61
+ * dir (e.g. ~/.claude) as a synthetic "(default)" entry — headless sessions
62
+ * started without the accounts CLI live there — and cross-checks the daemon
63
+ * listings against a process scan, reporting session processes no daemon
64
+ * knows about under "(untracked)".
65
+ */
36
66
  export declare function listAgentsAcrossProfiles(opts?: ListAgentsOptions): ProfileAgents[];
37
67
  //# sourceMappingURL=agents.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/lib/agents.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAI3C,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEjD,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,OAAO,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,kBAAkB,CAAC;AAEpE;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,EAAE,GAAG,SAAS,CA+BnE;AAED;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CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,cAAc,GAAG,MAAM,WAAW,EAAE,CAAC;AAEjD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,EAAE,GAAG,SAAS,CA+BnE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,WAAW,EAAE,SAAS,SAAS,GAAG,kBAAkB,CAqBhG;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAqB1E;AAED,4FAA4F;AAC5F,wBAAgB,iBAAiB,CAAC,MAAM,SAAW,GAAG,WAAW,EAAE,CAsBlE;AAeD,MAAM,WAAW,iBAAiB;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,8DAA8D;IAC9D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,GAAE,iBAAsB,GAAG,aAAa,EAAE,CAyEtF"}
package/dist/mcp.js CHANGED
@@ -17464,7 +17464,7 @@ function ok(data) {
17464
17464
  function fail(message) {
17465
17465
  return { content: [{ type: "text", text: JSON.stringify({ error: message }) }], isError: true };
17466
17466
  }
17467
- var server = new Server({ name: "accounts", version: "0.1.7" }, { capabilities: { tools: {} } });
17467
+ var server = new Server({ name: "accounts", version: "0.1.8" }, { capabilities: { tools: {} } });
17468
17468
  server.setRequestHandler(ListToolsRequestSchema, async () => ({
17469
17469
  tools: [
17470
17470
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/accounts",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
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",
@@ -70,6 +70,7 @@
70
70
  "license": "Apache-2.0",
71
71
  "dependencies": {
72
72
  "@aws-sdk/client-s3": "^3.985.0",
73
+ "@hasna/events": "^0.1.3",
73
74
  "@modelcontextprotocol/sdk": "^1.27.1",
74
75
  "chalk": "^5.4.1",
75
76
  "commander": "^13.1.0",