@agentshouse/kit 0.2.1-c3cf4b145dcda → 0.2.1-c4beedfd8b549

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/dist/events.js CHANGED
@@ -1,7 +1,7 @@
1
1
  const COMMAND = { shown: 'command' };
2
2
  const HIDDEN = { shown: 'hidden' };
3
3
  const FINISHED = new Set(['completed', 'failed']);
4
- const RUNNING_JOB = new Set(['running', 'paused']);
4
+ export const RUNNING_JOB = new Set(['running', 'paused']);
5
5
  const ROUTINE_TARGETS = { send_routine_request: 'access', cancel_routine_request: 'request' };
6
6
  function words(line) {
7
7
  const found = [];
@@ -113,9 +113,6 @@ class Reader {
113
113
  refused(option) {
114
114
  this.requestedOptions.delete(option);
115
115
  }
116
- turnStarted() {
117
- return [];
118
- }
119
116
  closeTurn() {
120
117
  const events = [];
121
118
  for (const [id, call] of this.calls) {
@@ -187,10 +184,7 @@ class Reader {
187
184
  const label = this.jobs.get(id) ?? '';
188
185
  if (state !== 'running')
189
186
  this.jobs.delete(id);
190
- return [
191
- { kind: 'busy', key: `job:${id}`, running: state === 'running' },
192
- { kind: 'marker', marker: 'job', text: `${label}: ${state}` },
193
- ];
187
+ return [{ kind: 'marker', marker: 'job', text: `${label}: ${state}` }];
194
188
  }
195
189
  optionsChanged(options) {
196
190
  const events = [];
@@ -275,7 +269,6 @@ class Reader {
275
269
  class ClaudeReader extends Reader {
276
270
  watchedOptions = { model: 'model' };
277
271
  tasks = new Map();
278
- scheduled = new Map();
279
272
  own(message) {
280
273
  if (message.params?.update?._meta?.claudeCode?.parentToolUseId !== undefined)
281
274
  return [];
@@ -295,10 +288,6 @@ class ClaudeReader extends Reader {
295
288
  return [];
296
289
  const sdk = message.params.message;
297
290
  switch (sdk.subtype) {
298
- case 'background_tasks_changed':
299
- return [{ kind: 'busy', key: 'tasks', running: sdk.tasks.length > 0 }];
300
- case 'session_state_changed':
301
- return [{ kind: 'busy', key: 'state', running: sdk.state === 'running' }];
302
291
  case 'task_started':
303
292
  if (sdk.tool_use_id !== undefined)
304
293
  this.tasks.set(sdk.task_id, sdk.tool_use_id);
@@ -309,16 +298,6 @@ class ClaudeReader extends Reader {
309
298
  return [];
310
299
  }
311
300
  }
312
- turnStarted() {
313
- const events = [];
314
- for (const [id, entry] of this.scheduled) {
315
- if (entry.recurring)
316
- continue;
317
- this.scheduled.delete(id);
318
- events.push({ kind: 'busy', key: `scheduled:${id}`, running: false });
319
- }
320
- return events;
321
- }
322
301
  decide(call, final) {
323
302
  const tool = call.meta.claudeCode?.toolName;
324
303
  if (tool === 'Agent' || tool === 'Task' || call.meta.jetbrains?.air?.subagent === true) {
@@ -350,22 +329,7 @@ class ClaudeReader extends Reader {
350
329
  if (call.status !== 'completed')
351
330
  return [];
352
331
  if (tool === 'CronCreate' || (tool === 'ScheduleWakeup' && call.rawInput?.stop !== true)) {
353
- this.scheduled.set(call.id, {
354
- recurring: tool === 'CronCreate' && call.rawInput?.recurring !== false,
355
- text: contentText(call.content) ?? '',
356
- });
357
- return [
358
- { kind: 'busy', key: `scheduled:${call.id}`, running: true },
359
- { kind: 'marker', marker: 'job', text: `${call.rawInput?.prompt ?? call.title ?? ''}: scheduled` },
360
- ];
361
- }
362
- if (tool === 'CronDelete') {
363
- for (const [id, entry] of this.scheduled) {
364
- if (!entry.text.includes(String(call.rawInput?.id)))
365
- continue;
366
- this.scheduled.delete(id);
367
- return [{ kind: 'busy', key: `scheduled:${id}`, running: false }];
368
- }
332
+ return [{ kind: 'marker', marker: 'job', text: `${call.rawInput?.prompt ?? call.title ?? ''}: scheduled` }];
369
333
  }
370
334
  return [];
371
335
  }
@@ -402,15 +366,9 @@ class CodexReader extends Reader {
402
366
  case 'subagent_spawned':
403
367
  this.children.set(update.subagentSessionId, { id: null, text: '' });
404
368
  this.subagents.add(update.subagentSessionId);
405
- return [
406
- { kind: 'busy', key: `subagent:${update.subagentSessionId}`, running: true },
407
- { kind: 'subagent', id: update.subagentSessionId, description: update.name },
408
- ];
369
+ return [{ kind: 'subagent', id: update.subagentSessionId, description: update.name }];
409
370
  case 'subagent_state_update':
410
- return [
411
- { kind: 'busy', key: `subagent:${update.subagentSessionId}`, running: false },
412
- ...this.finish(update.subagentSessionId, this.children.get(update.subagentSessionId)?.text || null),
413
- ];
371
+ return this.finish(update.subagentSessionId, this.children.get(update.subagentSessionId)?.text || null);
414
372
  default:
415
373
  return super.update(update);
416
374
  }
@@ -427,10 +385,6 @@ class CodexReader extends Reader {
427
385
  child.id = id;
428
386
  child.text += update.content.text;
429
387
  }
430
- const status = update._meta?.codex?.threadStatus?.type;
431
- if (update.sessionUpdate === 'session_info_update' && status !== undefined) {
432
- return [{ kind: 'busy', key: `thread:${session}`, running: status === 'active' }];
433
- }
434
388
  return [];
435
389
  }
436
390
  decide(call) {
@@ -460,7 +414,6 @@ class CodexReader extends Reader {
460
414
  class GrokReader extends Reader {
461
415
  watchedOptions = {};
462
416
  children = new Map();
463
- queues = new Map();
464
417
  models = [];
465
418
  model = null;
466
419
  answered(result) {
@@ -473,15 +426,10 @@ class GrokReader extends Reader {
473
426
  if (this.session !== null && session !== undefined && session !== this.session && !this.children.has(session))
474
427
  return [];
475
428
  if (message.method === '_x.ai/queue/changed') {
476
- const running = message.params.runningPromptId ?? null;
477
- this.queues.set(session, { running, entries: message.params.entries.length });
478
- return [this.queued(session), ...(running !== null && session === this.session ? [{ kind: 'started' }] : [])];
429
+ return (message.params.runningPromptId ?? null) !== null && session === this.session ? [{ kind: 'started' }] : [];
479
430
  }
480
431
  if (message.params?.update?.sessionUpdate === 'turn_completed') {
481
- const queue = this.queues.get(session);
482
- if (queue !== undefined && queue.running === message.params.update.prompt_id)
483
- queue.running = null;
484
- return [this.queued(session), ...(session === this.session ? [{ kind: 'ended' }] : [])];
432
+ return session === this.session ? [{ kind: 'ended' }] : [];
485
433
  }
486
434
  if (message.method === '_x.ai/models/update') {
487
435
  this.offered(message.params);
@@ -489,10 +437,6 @@ class GrokReader extends Reader {
489
437
  }
490
438
  return super.read(message);
491
439
  }
492
- queued(session) {
493
- const queue = this.queues.get(session);
494
- return { kind: 'busy', key: `queue:${session}`, running: queue !== undefined && (queue.running !== null || queue.entries > 0) };
495
- }
496
440
  offered(models) {
497
441
  this.models = models.availableModels ?? this.models;
498
442
  this.model = models.currentModelId ?? this.model;
@@ -508,16 +452,9 @@ class GrokReader extends Reader {
508
452
  case '_x.ai/task_completed':
509
453
  return this.job(update.task_snapshot.task_id, null, update.task_snapshot.exit_code === 0 ? 'completed' : 'failed');
510
454
  case '_x.ai/scheduled_task_created':
511
- return [
512
- { kind: 'busy', key: `scheduled:${update.task_id}`, running: true },
513
- { kind: 'marker', marker: 'job', text: `${update.prompt}: next run ${update.next_fire_at}` },
514
- ];
515
- case '_x.ai/scheduled_task_deleted':
516
- return [{ kind: 'busy', key: `scheduled:${update.task_id}`, running: false }];
455
+ return [{ kind: 'marker', marker: 'job', text: `${update.prompt}: next run ${update.next_fire_at}` }];
517
456
  case '_x.ai/session_notification':
518
457
  return this.notification(update);
519
- case '_x.ai/mcp_initialized':
520
- return [{ kind: 'servers' }];
521
458
  default:
522
459
  return [];
523
460
  }
@@ -538,14 +475,11 @@ class GrokReader extends Reader {
538
475
  candidate.decided.description === update.description) ??
539
476
  [...this.calls.values()].find((candidate) => candidate.decided?.shown === 'subagent' && ![...this.children.values()].includes(candidate.id));
540
477
  this.children.set(update.child_session_id, call?.id ?? null);
541
- return [{ kind: 'busy', key: `subagent:${update.child_session_id}`, running: true }];
478
+ return [];
542
479
  }
543
480
  case 'subagent_finished': {
544
481
  const call = this.children.get(update.child_session_id);
545
- return [
546
- { kind: 'busy', key: `subagent:${update.child_session_id}`, running: false },
547
- ...(typeof call === 'string' ? this.finish(call, update.output ?? null) : []),
548
- ];
482
+ return typeof call === 'string' ? this.finish(call, update.output ?? null) : [];
549
483
  }
550
484
  case 'auto_compact_completed':
551
485
  return [{ kind: 'marker', marker: 'compaction', text: '' }];
@@ -6,12 +6,14 @@ import { basename, join } from 'node:path';
6
6
  import { kitHome, readOwnAgent } from './home.js';
7
7
  import { callHouse, rpc, UNREACHABLE } from './mcp.js';
8
8
  import { refusalOf } from './refusals.js';
9
+ import { relayed } from './relay.js';
10
+ import { parse } from 'yaml';
9
11
  const USAGE = "usage: house <tool> ['<arguments as JSON>']";
10
12
  const PUSH_USAGE = 'usage: house push [commit] [--owner]';
11
13
  const PUSH = "push [commit]: sends the Local copy's committed changes to House";
12
14
  const ARGUMENTS = `the arguments are one JSON object in single quotes, like house search '{"query":"invoice"}'`;
13
15
  const CLOSED = "this conversation's House connection is closed; nothing to do from here";
14
- const SANDBOXED = "your CLI's sandbox kept house from House; run house as a command of its own, with no pipe, chain or redirect";
16
+ const SANDBOXED = "your CLI's sandbox kept house from House; run house directly, not through another program";
15
17
  const REVOKED = 'this conversation no longer has House access; nothing to do from here';
16
18
  const UNCONNECTED = "this computer's own agent has no House connection; run kit login";
17
19
  const DISCONNECTED = "House no longer accepts this computer's own agent; run kit login";
@@ -79,11 +81,24 @@ async function localFile(path) {
79
81
  : `${path} is not a readable file`);
80
82
  }
81
83
  }
84
+ async function sent(url, bytes, operation) {
85
+ const headers = { 'content-type': 'application/octet-stream', 'x-house-byte-operation': operation };
86
+ if (socketPath !== undefined)
87
+ return bridged(url, bytes, headers);
88
+ setGlobalProxyFromEnv();
89
+ const answer = await fetch(relayed(url), { method: 'POST', headers, body: bytes }).catch(() => {
90
+ throw new Error(UNREACHABLE);
91
+ });
92
+ const text = await answer.text();
93
+ if (answer.status === 200)
94
+ return text;
95
+ throw new Error(refused(url, answer.status, text));
96
+ }
82
97
  async function upload(path, roomRef, missing) {
83
98
  if (typeof path !== 'string' || path === '')
84
99
  throw new Error(missing);
85
100
  const bytes = await localFile(path);
86
- const declared = JSON.parse(await bridged('/kit/attachments/upload', {
101
+ const declared = parse(await called('upload', {
87
102
  ...(roomRef === undefined ? {} : { room_ref: roomRef }),
88
103
  name: basename(path),
89
104
  bytes: bytes.length,
@@ -91,10 +106,7 @@ async function upload(path, roomRef, missing) {
91
106
  }));
92
107
  if (declared.upload === undefined)
93
108
  return declared.attachment;
94
- const saved = JSON.parse(await bridged(declared.upload.url, bytes, {
95
- 'content-type': 'application/octet-stream',
96
- 'x-house-byte-operation': declared.upload.operation,
97
- }));
109
+ const saved = JSON.parse(await sent(declared.upload.url, bytes, declared.upload.operation));
98
110
  if (saved.upload_failure !== undefined)
99
111
  throw new Error(`${path} was not saved: ${saved.upload_failure}; call again later`);
100
112
  return saved.attachment;
@@ -138,17 +150,20 @@ async function house([verb, argument]) {
138
150
  return [...(tool.description === undefined ? [] : [tool.description]), JSON.stringify(tool.inputSchema)].join('\n');
139
151
  }
140
152
  const args = argumentsOf(argument);
141
- if (socketPath !== undefined && verb === 'upload_attachment') {
142
- return JSON.stringify({ attachment: await upload(args.path, args.room_ref, 'upload_attachment needs "path", a local file') });
153
+ if (verb === 'upload') {
154
+ return JSON.stringify({ attachment: await upload(args.path, args.room_ref, 'upload needs "path", a local file') });
143
155
  }
144
- if (socketPath !== undefined && verb === 'append_record' && Array.isArray(args.attachments)) {
156
+ if (verb === 'append_record' && Array.isArray(args.attachments)) {
145
157
  const attachments = [];
146
158
  for (const path of args.attachments) {
147
159
  attachments.push(await upload(path, args.room_ref, 'each attachments entry is the path of a local file'));
148
160
  }
149
161
  args.attachments = attachments;
150
162
  }
151
- const result = await mcp('tools/call', { name: verb, arguments: args });
163
+ return called(verb, args);
164
+ }
165
+ async function called(name, args) {
166
+ const result = await mcp('tools/call', { name, arguments: args });
152
167
  const text = result.content.map((content) => content.text).join('\n');
153
168
  if (result.isError === true)
154
169
  throw new Error(text.replace(/\n+$/, ''));
@@ -1,6 +1,6 @@
1
1
  import { HOW_WE_WORK } from './skills.js';
2
2
  const HOUSE_LINE = 'Work with House through the `house` CLI: run `house --help`.';
3
- const FILE_LINE = 'To give the User a file or a page, upload it with `house upload_attachment` and link it; never start a server.';
3
+ const FILE_LINE = 'To give the User a file or a page, upload it with `house upload` and link it; never start a server.';
4
4
  const READ_LINE = 'Before working in a Room, read `/rooms/private/rooms/<handle>/AGENTS.md`.';
5
5
  const COPIES_LINE = 'House Local copies; commit, then `house push`:';
6
6
  const UNREADABLE = /^(?:\S+: )?(?:path_not_found|room_not_found|operation_denied)\b/;
package/dist/resident.js CHANGED
@@ -2,32 +2,31 @@ import { once } from 'node:events';
2
2
  import { watch } from 'node:fs';
3
3
  import { mkdir, rm, writeFile } from 'node:fs/promises';
4
4
  import { createServer } from 'node:http';
5
- import { extname, join } from 'node:path';
5
+ import { dirname, extname, join } from 'node:path';
6
6
  import { fileURLToPath } from 'node:url';
7
- import { killDescendants } from './acp.js';
8
7
  import { Agents } from './agents.js';
9
8
  import { house } from './api.js';
10
9
  import { received } from './bridge.js';
11
10
  import { Conversations } from './conversations.js';
12
11
  import { LocalCopies } from './copies.js';
13
12
  import { agentBase, enrolled, kitHome } from './home.js';
13
+ import { killDescendants } from './scope.js';
14
14
  import { quoted } from './shell.js';
15
15
  import { SignIns } from './sign-in.js';
16
16
  import { placeSkillSet } from './skills.js';
17
17
  import { holdStream } from './stream.js';
18
18
  import { Updates } from './update.js';
19
+ import { codexLauncher } from './work.js';
19
20
  function report(error) {
20
21
  process.stderr.write(`kit: ${error instanceof Error ? error.message : String(error)}\n`);
21
22
  }
22
23
  function logged(work) {
23
24
  work.catch(report);
24
25
  }
25
- async function installShim() {
26
- const main = fileURLToPath(new URL(`./git-main${extname(fileURLToPath(import.meta.url))}`, import.meta.url));
27
- await mkdir(join(kitHome(), 'shim'), { recursive: true });
28
- await writeFile(join(kitHome(), 'shim', 'git'), `#!/bin/sh\nexec ${quoted(process.execPath)} ${quoted(main)} "$@"\n`, {
29
- mode: 0o755,
30
- });
26
+ async function installShim(path, module) {
27
+ const main = fileURLToPath(new URL(`./${module}${extname(fileURLToPath(import.meta.url))}`, import.meta.url));
28
+ await mkdir(dirname(path), { recursive: true });
29
+ await writeFile(path, `#!/bin/sh\nexec ${quoted(process.execPath)} ${quoted(main)} "$@"\n`, { mode: 0o755 });
31
30
  }
32
31
  async function serveOwner(copies) {
33
32
  const socketPath = join(kitHome(), 'owner.sock');
@@ -79,7 +78,8 @@ export async function resident() {
79
78
  const agents = new Agents(house);
80
79
  const copies = new LocalCopies(house);
81
80
  await copies.load();
82
- await installShim();
81
+ await installShim(join(kitHome(), 'shim', 'git'), 'git-main');
82
+ await installShim(codexLauncher(), 'codex-main');
83
83
  await serveOwner(copies);
84
84
  let stream = null;
85
85
  let reported = false;
package/dist/scope.js ADDED
@@ -0,0 +1,203 @@
1
+ import { execFileSync } from 'node:child_process';
2
+ import { mkdirSync, readdirSync, readFileSync, rmdirSync, statSync, writeFileSync } from 'node:fs';
3
+ import { join } from 'node:path';
4
+ const LISTING_BYTES = 1 << 28;
5
+ const CGROUPS = '/sys/fs/cgroup';
6
+ const GONE = new Set(['ENOENT', 'ESRCH']);
7
+ function failure(error) {
8
+ return error.code ?? '';
9
+ }
10
+ function listed(environment) {
11
+ const found = new Map();
12
+ const output = execFileSync('ps', [environment ? '-AEww' : '-Aww', '-o', 'pid=,ppid=,sess=,command='], {
13
+ encoding: 'utf8',
14
+ maxBuffer: LISTING_BYTES,
15
+ });
16
+ for (const line of output.split('\n')) {
17
+ const fields = /^\s*(\d+)\s+(\d+)\s+(\S+)\s?(.*)$/.exec(line);
18
+ if (fields !== null)
19
+ found.set(Number(fields[1]), { parent: Number(fields[2]), session: fields[3], command: fields[4] });
20
+ }
21
+ return found;
22
+ }
23
+ function read(pid) {
24
+ try {
25
+ const stat = readFileSync(`/proc/${pid}/stat`, 'utf8');
26
+ const fields = stat.slice(stat.lastIndexOf(')') + 2).split(' ');
27
+ const command = readFileSync(`/proc/${pid}/cmdline`, 'utf8').replaceAll('\0', ' ');
28
+ return { parent: Number(fields[1]), session: fields[3], command };
29
+ }
30
+ catch (error) {
31
+ if (GONE.has(failure(error)))
32
+ return null;
33
+ throw error;
34
+ }
35
+ }
36
+ function processes() {
37
+ if (process.platform === 'darwin')
38
+ return listed(false);
39
+ const found = new Map();
40
+ for (const entry of readdirSync('/proc')) {
41
+ const running = /^\d+$/.test(entry) ? read(entry) : null;
42
+ if (running !== null)
43
+ found.set(Number(entry), running);
44
+ }
45
+ return found;
46
+ }
47
+ function descendants(roots, table = processes()) {
48
+ const children = new Map();
49
+ for (const [pid, { parent }] of table)
50
+ children.set(parent, [...(children.get(parent) ?? []), pid]);
51
+ const tree = [];
52
+ const pending = roots.flatMap((root) => children.get(root) ?? []);
53
+ while (pending.length > 0) {
54
+ const pid = pending.pop();
55
+ tree.push(pid);
56
+ pending.push(...(children.get(pid) ?? []));
57
+ }
58
+ return tree;
59
+ }
60
+ function marked(marker, doubted) {
61
+ if (process.platform === 'darwin') {
62
+ return [...listed(true)].filter(([, { command }]) => ` ${command} `.includes(` ${marker} `)).map(([pid]) => pid);
63
+ }
64
+ return readdirSync('/proc')
65
+ .filter((entry) => /^\d+$/.test(entry) && carries(entry, marker, doubted))
66
+ .map(Number);
67
+ }
68
+ function carries(pid, marker, doubted) {
69
+ try {
70
+ return readFileSync(`/proc/${pid}/environ`, 'utf8').split('\0').includes(marker);
71
+ }
72
+ catch (error) {
73
+ if (GONE.has(failure(error)))
74
+ return false;
75
+ if (failure(error) !== 'EACCES')
76
+ throw error;
77
+ return doubted && statSync(`/proc/${pid}`, { throwIfNoEntry: false })?.uid === process.getuid();
78
+ }
79
+ }
80
+ function killAll(pids) {
81
+ for (const pid of pids) {
82
+ for (const target of [-pid, pid]) {
83
+ try {
84
+ process.kill(target, 'SIGKILL');
85
+ }
86
+ catch { }
87
+ }
88
+ }
89
+ }
90
+ export function killTree(child) {
91
+ killAll([child.pid, ...descendants([child.pid])]);
92
+ }
93
+ export function killMarked(marker) {
94
+ const pids = marked(marker, false);
95
+ killAll([...pids, ...descendants(pids)]);
96
+ }
97
+ export function killDescendants() {
98
+ const pids = marked(`HOUSE_KIT_RESIDENT=${process.pid}`, false);
99
+ killAll([...pids, ...descendants([process.pid, ...pids])]);
100
+ }
101
+ function ownGroup() {
102
+ if (process.platform !== 'linux')
103
+ return null;
104
+ try {
105
+ const line = readFileSync('/proc/self/cgroup', 'utf8')
106
+ .split('\n')
107
+ .find((entry) => entry.startsWith('0::'));
108
+ return line === undefined ? null : join(CGROUPS, line.slice(3));
109
+ }
110
+ catch {
111
+ return null;
112
+ }
113
+ }
114
+ function members(group) {
115
+ const pids = readFileSync(join(group, 'cgroup.procs'), 'utf8').split('\n').filter(Boolean).map(Number);
116
+ for (const entry of readdirSync(group, { withFileTypes: true })) {
117
+ if (entry.isDirectory())
118
+ pids.push(...members(join(group, entry.name)));
119
+ }
120
+ return pids;
121
+ }
122
+ export class Scope {
123
+ marker;
124
+ cli;
125
+ group;
126
+ session = null;
127
+ recorded = null;
128
+ constructor(marker, name, cli) {
129
+ this.marker = marker;
130
+ this.cli = cli;
131
+ const own = ownGroup();
132
+ this.group = own === null ? null : join(own, name);
133
+ try {
134
+ if (this.group !== null)
135
+ mkdirSync(this.group);
136
+ }
137
+ catch {
138
+ this.group = null;
139
+ }
140
+ }
141
+ command(command, args) {
142
+ if (this.group === null)
143
+ return [command, args];
144
+ return ['/bin/sh', ['-c', 'echo $$ > "$0/cgroup.procs" 2>/dev/null; exec "$@"', this.group, command, ...args]];
145
+ }
146
+ entered(pid) {
147
+ this.session = process.platform === 'darwin' ? (listed(false).get(pid)?.session ?? null) : String(pid);
148
+ if (this.group === null)
149
+ return;
150
+ const joined = readFileSync(`/proc/${pid}/cgroup`, 'utf8').split('\n').find((entry) => entry.startsWith('0::'));
151
+ if (joined !== undefined && join(CGROUPS, joined.slice(3)) === this.group)
152
+ return;
153
+ this.close();
154
+ this.group = null;
155
+ }
156
+ record() {
157
+ const found = this.found();
158
+ if (found === null)
159
+ return;
160
+ this.recorded = new Set([...found].filter(([, { session }]) => session === this.session).map(([pid]) => pid));
161
+ }
162
+ working() {
163
+ const found = this.found();
164
+ if (found === null)
165
+ return true;
166
+ if (this.recorded === null)
167
+ return found.size > 0;
168
+ return [...found].some(([pid, { session, command }]) => session !== this.session || !(this.recorded.has(pid) || command.startsWith(`${this.cli}-`)));
169
+ }
170
+ empty() {
171
+ return this.found()?.size === 0;
172
+ }
173
+ kill() {
174
+ killMarked(this.marker);
175
+ if (this.group === null)
176
+ return;
177
+ try {
178
+ writeFileSync(join(this.group, 'cgroup.kill'), '1');
179
+ }
180
+ catch {
181
+ killAll([...(this.found()?.keys() ?? [])]);
182
+ }
183
+ }
184
+ close() {
185
+ if (this.group === null)
186
+ return;
187
+ try {
188
+ rmdirSync(this.group);
189
+ }
190
+ catch { }
191
+ }
192
+ found() {
193
+ try {
194
+ const table = processes();
195
+ const roots = this.group === null ? marked(this.marker, true) : members(this.group);
196
+ const pids = this.group === null ? [...roots, ...descendants(roots, table)] : roots;
197
+ return new Map(pids.flatMap((pid) => (table.has(pid) ? [[pid, table.get(pid)]] : [])));
198
+ }
199
+ catch {
200
+ return null;
201
+ }
202
+ }
203
+ }
package/dist/sign-in.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { spawn } from 'node:child_process';
2
2
  import { createInterface } from 'node:readline';
3
- import { killTree } from './acp.js';
4
3
  import { CLIS, withoutProxy } from './clis.js';
4
+ import { killTree } from './scope.js';
5
5
  import { holdSecretInput } from './secret-input.js';
6
6
  const ESCAPE = /\u001b\[[\d;]*m/g;
7
7
  const LINK = /https:\/\/\S+/;