@agentshouse/kit 0.2.1-cb997daca91ed → 0.2.1-cba216f2c559c

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,8 +1,17 @@
1
+ const AUTONOMOUS_ORIGINS = new Set(['task-notification', 'peer', 'coordinator', 'observer', 'observer-activity']);
1
2
  const COMMAND = { shown: 'command' };
2
3
  const HIDDEN = { shown: 'hidden' };
3
4
  const FINISHED = new Set(['completed', 'failed']);
4
5
  export const RUNNING_JOB = new Set(['running', 'paused']);
5
- const MESSAGE_TARGETS = { send_routine_request: 'access', cancel_routine_request: 'request', send_mail: 'request' };
6
+ const MESSAGE_TARGETS = new Map([
7
+ ['agent-functions/send', ['agent_function', 'agent']],
8
+ ['agent-functions/cancel', ['request']],
9
+ ['agent-functions/mail/send', ['conversation', 'request']],
10
+ ]);
11
+ function counted(reports) {
12
+ const whole = reports.every((tokens) => Object.values(tokens).every((count) => Number.isSafeInteger(count) && count >= 0));
13
+ return whole ? reports.map((tokens) => ({ kind: 'tokens', tokens })) : [];
14
+ }
6
15
  function words(line) {
7
16
  const found = [];
8
17
  let word = null;
@@ -48,11 +57,13 @@ export function houseMessage(line) {
48
57
  catch {
49
58
  return null;
50
59
  }
51
- const argument = MESSAGE_TARGETS[call.command];
52
- if (argument === undefined)
60
+ if (call === null)
61
+ return null;
62
+ const targets = MESSAGE_TARGETS.get(call.command);
63
+ if (targets === undefined)
53
64
  return null;
54
- const target = call.arguments?.[argument];
55
- return { shown: 'message', command: call.command, target: typeof target === 'string' ? target : null };
65
+ const target = targets.map((argument) => call.arguments?.[argument]).find((value) => typeof value === 'string');
66
+ return { shown: 'message', command: call.command, target: target ?? null };
56
67
  }
57
68
  function decidedByLine(command, final) {
58
69
  const line = typeof command === 'string' ? command : Array.isArray(command) ? command.at(-1) : undefined;
@@ -269,6 +280,17 @@ class Reader {
269
280
  class ClaudeReader extends Reader {
270
281
  watchedOptions = { model: 'model' };
271
282
  tasks = new Map();
283
+ stop = null;
284
+ answered(result) {
285
+ const models = (result?._meta?.quota?.model_usage ?? []);
286
+ const spent = counted(models.map(({ token_count: count }) => ({
287
+ input: count?.inputTokens,
288
+ output: count?.outputTokens,
289
+ cache_read: count?.cachedInputTokens,
290
+ cache_write: count?.cachedWriteTokens,
291
+ })));
292
+ return [...spent, ...super.answered(result)];
293
+ }
272
294
  own(message) {
273
295
  if (message.params?.update?._meta?.claudeCode?.parentToolUseId !== undefined)
274
296
  return [];
@@ -276,7 +298,9 @@ class ClaudeReader extends Reader {
276
298
  }
277
299
  update(update) {
278
300
  if (update.sessionUpdate === 'usage_update' && update._meta?.['_claude/origin'] !== undefined) {
279
- return [...super.update(update), { kind: 'ended' }];
301
+ const stop = this.stop;
302
+ this.stop = null;
303
+ return [...super.update(update), { kind: 'ended', stop }];
280
304
  }
281
305
  if (update.sessionUpdate === 'session_info_update' && update._meta?.jetbrains?.air?.sessionFailure !== undefined) {
282
306
  return [{ kind: 'marker', marker: 'retry', text: update._meta.jetbrains.air.sessionFailure.title }];
@@ -287,6 +311,13 @@ class ClaudeReader extends Reader {
287
311
  if (message.method !== '_claude/sdkMessage')
288
312
  return [];
289
313
  const sdk = message.params.message;
314
+ if (sdk.type === 'result') {
315
+ if (AUTONOMOUS_ORIGINS.has(sdk.origin?.kind))
316
+ this.stop = null;
317
+ else
318
+ this.stop = sdk.stop_reason === 'refusal' ? 'refusal' : sdk.is_error === true ? null : 'end_turn';
319
+ return [];
320
+ }
290
321
  switch (sdk.subtype) {
291
322
  case 'task_started':
292
323
  if (sdk.tool_use_id !== undefined)
@@ -294,6 +325,10 @@ class ClaudeReader extends Reader {
294
325
  return [];
295
326
  case 'task_notification':
296
327
  return sdk.tool_use_id === undefined ? [] : this.finish(sdk.tool_use_id, sdk.summary ?? null);
328
+ case 'task_progress':
329
+ if (!this.subagents.has(sdk.tool_use_id) || this.done.has(sdk.tool_use_id) || typeof sdk.description !== 'string')
330
+ return [];
331
+ return [{ kind: 'subagent-activity', id: sdk.tool_use_id, activity: sdk.description }];
297
332
  default:
298
333
  return [];
299
334
  }
@@ -343,6 +378,20 @@ const COLLABORATION = new Set(['spawnAgent', 'sendInput', 'resumeAgent', 'wait',
343
378
  class CodexReader extends Reader {
344
379
  watchedOptions = { mode: 'mode', collaboration_mode: 'mode' };
345
380
  children = new Map();
381
+ answered(result) {
382
+ const usage = result?.usage;
383
+ const spent = usage === null || usage === undefined
384
+ ? []
385
+ : counted([
386
+ {
387
+ input: usage.inputTokens,
388
+ output: usage.outputTokens,
389
+ cache_read: usage.cachedReadTokens,
390
+ cache_write: usage.cachedWriteTokens,
391
+ },
392
+ ]);
393
+ return [...spent, ...super.answered(result)];
394
+ }
346
395
  own(message) {
347
396
  if (message.method === 'session/request_permission' && message.params.toolCall?.kind === 'switch_mode') {
348
397
  return [{ kind: 'started' }, { kind: 'marker', marker: 'mode', text: message.params.toolCall.title ?? '' }];
@@ -356,7 +405,7 @@ class CodexReader extends Reader {
356
405
  if (codex?.threadStatus?.type === 'active')
357
406
  return [{ kind: 'started' }];
358
407
  if (codex?.threadStatus?.type === 'idle')
359
- return [{ kind: 'ended' }];
408
+ return [{ kind: 'ended', stop: null }];
360
409
  if (codex?.error !== undefined)
361
410
  return [{ kind: 'marker', marker: 'retry', text: codex.error.message ?? '' }];
362
411
  return [];
@@ -429,7 +478,9 @@ class GrokReader extends Reader {
429
478
  return (message.params.runningPromptId ?? null) !== null && session === this.session ? [{ kind: 'started' }] : [];
430
479
  }
431
480
  if (message.params?.update?.sessionUpdate === 'turn_completed') {
432
- return session === this.session ? [{ kind: 'ended' }] : [];
481
+ if (session !== this.session)
482
+ return [];
483
+ return [...this.spent(message.params.update.usage), { kind: 'ended', stop: null }];
433
484
  }
434
485
  if (message.method === '_x.ai/models/update') {
435
486
  this.offered(message.params);
@@ -437,6 +488,13 @@ class GrokReader extends Reader {
437
488
  }
438
489
  return super.read(message);
439
490
  }
491
+ spent(usage) {
492
+ if (usage === null || usage === undefined)
493
+ return [];
494
+ const { inputTokens, outputTokens, cachedReadTokens, cacheCreationTokens } = usage;
495
+ const input = inputTokens - cachedReadTokens - cacheCreationTokens;
496
+ return counted([{ input, output: outputTokens, cache_read: cachedReadTokens, cache_write: cacheCreationTokens }]);
497
+ }
440
498
  offered(models) {
441
499
  this.models = models.availableModels ?? this.models;
442
500
  this.model = models.currentModelId ?? this.model;
package/dist/files.js CHANGED
@@ -27,7 +27,7 @@ export function inspectedFile(answer) {
27
27
  media_type: typeof inspected.media_type === 'string' ? inspected.media_type : null,
28
28
  };
29
29
  }
30
- function paused(milliseconds) {
30
+ export function paused(milliseconds) {
31
31
  return new Promise((resolve) => setTimeout(resolve, milliseconds));
32
32
  }
33
33
  export function storeRefusal(act, status) {
@@ -140,5 +140,5 @@ export async function downloaded(address, fetching, destination, name) {
140
140
  }
141
141
  export async function fetched(url, signal) {
142
142
  const answer = await fetch(relayed(url), { signal });
143
- return { status: answer.status, body: answer.body ?? Readable.from([]) };
143
+ return { status: answer.status, body: answer.body === null ? Readable.from([]) : Readable.fromWeb(answer.body) };
144
144
  }
package/dist/git.js CHANGED
@@ -70,18 +70,52 @@ function data(text) {
70
70
  const bytes = Buffer.from(text, 'utf8');
71
71
  return [Buffer.from(`data ${bytes.length}\n`), bytes, Buffer.from('\n')];
72
72
  }
73
- export async function importCommits(repository, commits) {
74
- const stream = [];
73
+ function written(stream, bytes) {
74
+ return new Promise((resolve, reject) => {
75
+ stream.write(bytes, (error) => (error ? reject(error) : resolve()));
76
+ });
77
+ }
78
+ async function imported(stream, commits) {
79
+ await written(stream, Buffer.from('feature done\n'));
75
80
  for (const [index, commit] of commits.entries()) {
76
- stream.push(Buffer.from(`commit ${HOUSE_REF}\nmark :${index + 1}\ncommitter ${COMMITTER} ${Math.floor(Date.now() / 1000)} +0000\n`), ...data(commit.message), ...(commit.from === null ? [] : [Buffer.from(`from ${commit.from}\n`)]), ...(commit.merge === undefined ? [] : [Buffer.from(`merge ${commit.merge}\n`)]), ...(commit.replaces === true ? [Buffer.from('deleteall\n')] : []));
77
- for (const [path, content] of commit.files) {
78
- if (content === null)
79
- stream.push(Buffer.from(`D ${quoted(path)}\n`));
80
- else
81
- stream.push(Buffer.from(`M 100644 inline ${quoted(path)}\n`), ...data(content));
81
+ await written(stream, Buffer.concat([
82
+ Buffer.from(`commit ${HOUSE_REF}\nmark :${index + 1}\ncommitter ${COMMITTER} ${Math.floor(Date.now() / 1000)} +0000\n`),
83
+ ...data(commit.message),
84
+ ...(commit.from === null ? [] : [Buffer.from(`from ${commit.from}\n`)]),
85
+ ...(commit.merge === undefined ? [] : [Buffer.from(`merge ${commit.merge}\n`)]),
86
+ ...(commit.replaces === true ? [Buffer.from('deleteall\n')] : []),
87
+ ]));
88
+ for await (const [path, content] of commit.files) {
89
+ await written(stream, content === null
90
+ ? Buffer.from(`D ${quoted(path)}\n`)
91
+ : Buffer.concat([Buffer.from(`M 100644 inline ${quoted(path)}\n`), ...data(content)]));
82
92
  }
83
- stream.push(Buffer.from('\n'));
93
+ await written(stream, Buffer.from('\n'));
94
+ }
95
+ await written(stream, Buffer.from('done\n'));
96
+ }
97
+ export async function importCommits(repository, commits) {
98
+ const child = spawn('git', ['fast-import', '--quiet', '--force'], { cwd: repository, env: childEnvironment() });
99
+ let stderr = '';
100
+ child.stdout.resume();
101
+ child.stderr.on('data', (chunk) => {
102
+ stderr += chunk.toString('utf8');
103
+ });
104
+ child.stdin.on('error', () => undefined);
105
+ const closed = new Promise((resolve, reject) => {
106
+ child.on('error', reject);
107
+ child.on('close', resolve);
108
+ });
109
+ try {
110
+ await imported(child.stdin, commits);
111
+ child.stdin.end();
112
+ }
113
+ catch (error) {
114
+ child.stdin.destroy();
115
+ await closed;
116
+ throw error.code === 'EPIPE' ? new Error(`git fast-import failed: ${stderr.trim()}`) : error;
84
117
  }
85
- await git(repository, ['fast-import', '--quiet', '--force'], Buffer.concat(stream));
118
+ if ((await closed) !== 0)
119
+ throw new Error(`git fast-import failed: ${stderr.trim()}`);
86
120
  return revision(repository, HOUSE_REF);
87
121
  }
package/dist/grok.js ADDED
@@ -0,0 +1,39 @@
1
+ const PLAN = 'plan';
2
+ const PLAN_ABANDONED = 'abandoned';
3
+ const PLAN_FIELD = {
4
+ type: 'string',
5
+ title: 'Approve this plan?',
6
+ oneOf: [
7
+ { const: 'approved', title: 'Approve' },
8
+ { const: PLAN_ABANDONED, title: 'Abandon' },
9
+ ],
10
+ };
11
+ function form(sessionId, message, properties) {
12
+ return { mode: 'form', sessionId, message, requestedSchema: { type: 'object', properties } };
13
+ }
14
+ function questionField({ options, multiSelect }, title) {
15
+ const choices = options.map(({ label, description }) => ({ const: label, title: label, description }));
16
+ return multiSelect === true ? { type: 'array', title, items: { anyOf: choices } } : { type: 'string', title, oneOf: choices };
17
+ }
18
+ export function grokQuestionForm({ sessionId, questions }) {
19
+ const lone = questions.length === 1;
20
+ return form(sessionId, questions.map(({ question }) => question).join('\n\n'), Object.fromEntries(questions.map((one) => [one.question, questionField(one, lone ? 'Answer' : one.question)])));
21
+ }
22
+ function answerText(value) {
23
+ return Array.isArray(value) ? value.join(', ') : String(value);
24
+ }
25
+ function contentOf(response) {
26
+ return response.action === 'accept' ? (response.content ?? {}) : {};
27
+ }
28
+ export function grokQuestionAnswer(response) {
29
+ if (response.action !== 'accept')
30
+ return { outcome: 'cancelled' };
31
+ const answers = Object.entries(contentOf(response)).map(([question, value]) => [question, answerText(value)]);
32
+ return { outcome: 'accepted', answers: Object.fromEntries(answers) };
33
+ }
34
+ export function grokPlanForm({ sessionId, planContent }) {
35
+ return form(sessionId, planContent, { [PLAN]: PLAN_FIELD });
36
+ }
37
+ export function grokPlanAnswer(response) {
38
+ return { outcome: contentOf(response)[PLAN] ?? PLAN_ABANDONED };
39
+ }
package/dist/home.js CHANGED
@@ -8,7 +8,6 @@ const ENROLMENT = 'credential.json';
8
8
  const DISCONNECTED = 'disconnected.json';
9
9
  const CONFIGURATION = 'kit.json';
10
10
  const OWN_AGENT = 'own-agent.json';
11
- const RESTART = 'restart';
12
11
  let defaulted;
13
12
  function writable(directory) {
14
13
  try {
@@ -132,12 +131,6 @@ export async function forgetRejected(rejected) {
132
131
  export function enrolled() {
133
132
  return existsSync(join(kitHome(), ENROLMENT));
134
133
  }
135
- export function restartAsked() {
136
- return existsSync(join(kitHome(), RESTART));
137
- }
138
- export function forgetRestart() {
139
- return rm(join(kitHome(), RESTART), { force: true });
140
- }
141
134
  export function readOwnAgent() {
142
135
  return readHome(OWN_AGENT);
143
136
  }
package/dist/login.js CHANGED
@@ -10,6 +10,7 @@ import { refusalOf } from './refusals.js';
10
10
  import { selectRelay } from './relay.js';
11
11
  import { startService } from './service.js';
12
12
  import { placeSkillSet } from './skills.js';
13
+ import { endUnserved } from './wire.js';
13
14
  export const DEFAULT_HOUSE = 'https://agents.house';
14
15
  const OPENER = process.platform === 'darwin' ? 'open' : 'xdg-open';
15
16
  // Polling every two seconds brings the User's confirmation to the waiting Kit moments after they give it.
@@ -25,6 +26,7 @@ export async function accepted(house, credential) {
25
26
  return true;
26
27
  if (checked.status === 401)
27
28
  return false;
29
+ endUnserved(checked.text);
28
30
  throw new Error(`House answered ${checked.status} when Kit checked this computer's own agent's connection: ${checked.text}`);
29
31
  }
30
32
  const USAGE = `usage: kit login [--house <origin>] [--environment <id>] [--rooms <ref>[,<ref>...] | --no-private]
package/dist/logout.js CHANGED
@@ -4,7 +4,7 @@ export async function logout() {
4
4
  const enrolled = await readEnrolment();
5
5
  if (enrolled !== null) {
6
6
  try {
7
- await post(enrolled.house, '/kit/logout', {}, enrolled.credential);
7
+ await post(enrolled.house, '/kit/kits/log-out', {}, enrolled.credential);
8
8
  }
9
9
  catch (error) {
10
10
  if (!(error instanceof HouseRefusal && error.status === 401))
package/dist/mcp.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { randomUUID } from 'node:crypto';
2
2
  import { KIT_RELEASE } from './clis.js';
3
3
  import { relayed } from './relay.js';
4
+ import { KIT_WIRE, KIT_WIRE_HEADER } from './wire.js';
4
5
  const MCP_PROTOCOL_VERSION = '2026-07-28';
5
6
  export const UNREACHABLE = 'House is unreachable; call again in a minute';
6
7
  export class Unsettled extends Error {
@@ -33,6 +34,7 @@ export async function callHouse(origin, credential, message, operation = null, s
33
34
  'mcp-protocol-version': MCP_PROTOCOL_VERSION,
34
35
  'mcp-method': message.method,
35
36
  ...(tool === null ? {} : { 'mcp-name': tool }),
37
+ [KIT_WIRE_HEADER]: String(KIT_WIRE),
36
38
  },
37
39
  body: mcpBody(message, operation),
38
40
  signal,
package/dist/parts.js CHANGED
@@ -1,3 +1,13 @@
1
+ export function addedTokens(sum, tokens) {
2
+ if (sum === null)
3
+ return tokens;
4
+ return {
5
+ input: sum.input + tokens.input,
6
+ output: sum.output + tokens.output,
7
+ cache_read: sum.cache_read + tokens.cache_read,
8
+ cache_write: sum.cache_write + tokens.cache_write,
9
+ };
10
+ }
1
11
  export class Parts {
2
12
  parts = [];
3
13
  context = null;
package/dist/placement.js CHANGED
@@ -1,23 +1,6 @@
1
1
  import { readFileSync } from 'node:fs';
2
- import { join } from 'node:path';
3
- import { run } from './clis.js';
2
+ import { join, resolve } from 'node:path';
4
3
  import { kitHome } from './home.js';
5
- export function service() {
6
- if (process.platform !== 'linux' || !process.env.INVOCATION_ID)
7
- return null;
8
- return process.env.MANAGERPID ? 'user' : 'system';
9
- }
10
- export function throughSudo() {
11
- return service() === 'system' && process.getuid() !== 0;
12
- }
13
- export async function updatesItself() {
14
- if (service() === null)
15
- return false;
16
- if (!throughSudo())
17
- return true;
18
- // sudo answers at once, so ten seconds only bounds a stuck sudo.
19
- return (await run('sudo', ['-n', 'true'], 10_000)).status === 0;
20
- }
21
4
  function recorded(name) {
22
5
  try {
23
6
  return readFileSync(join(kitHome(), name), 'utf8').trim();
@@ -37,3 +20,12 @@ export function machine() {
37
20
  return placed;
38
21
  return process.platform === 'darwin' ? 'macos' : 'linux';
39
22
  }
23
+ export function placedPrefix() {
24
+ const prefix = process.env.HOUSE_KIT_PREFIX;
25
+ if (prefix === undefined || prefix === '')
26
+ throw new Error('this Kit process was not started by a launcher its installer placed');
27
+ return resolve(prefix);
28
+ }
29
+ export function releaseDirectory(release) {
30
+ return join(placedPrefix(), 'releases', release);
31
+ }
package/dist/resident.js CHANGED
@@ -10,16 +10,17 @@ import { house } from './api.js';
10
10
  import { received } from './bridge.js';
11
11
  import { CONVERSATION_METHODS, Conversations } from './conversations.js';
12
12
  import { LocalCopies } from './copies.js';
13
- import { restart } from './end.js';
14
- import { agentBase, enrolled, forgetRestart, kitHome, ownerLock, ownerSocket, readEnrolment, restartAsked } from './home.js';
13
+ import { restart, unknownMethod } from './end.js';
14
+ import { agentBase, enrolled, kitHome, ownerLock, ownerSocket, readEnrolment } from './home.js';
15
15
  import { Calls } from './calls.js';
16
16
  import { killDescendants } from './scope.js';
17
+ import { removeInputs, Scripts } from './scripts.js';
17
18
  import { quoted } from './shell.js';
18
19
  import { SignIns } from './sign-in.js';
19
20
  import { placeSkillSet } from './skills.js';
20
21
  import { holdConnection } from './connection.js';
21
22
  import { KitUpdate } from './update.js';
22
- import { WebWizards } from './web-wizard.js';
23
+ import { takeUnservedRelease } from './wire.js';
23
24
  import { codexLauncher } from './work.js';
24
25
  function report(error) {
25
26
  process.stderr.write(`kit: ${error instanceof Error ? error.message : String(error)}\n`);
@@ -110,7 +111,6 @@ function connected() {
110
111
  }
111
112
  async function started() {
112
113
  await connected();
113
- await forgetRestart();
114
114
  watch(kitHome(), () => {
115
115
  if (enrolled())
116
116
  return;
@@ -127,6 +127,7 @@ export async function resident() {
127
127
  const copies = new LocalCopies(house);
128
128
  await copies.load();
129
129
  await serveOwner(copies);
130
+ await copies.swept();
130
131
  await started().catch((error) => {
131
132
  report(error);
132
133
  process.exit(1);
@@ -140,15 +141,12 @@ export async function resident() {
140
141
  if (!idle()) {
141
142
  reported = false;
142
143
  }
143
- else if (restartAsked() && conversations.quiet()) {
144
- restart('restarting for an updated CLI');
145
- }
146
- else if (update.held() && conversations.quiet()) {
147
- update.apply(connection.pause());
144
+ else if (update.placedRelease() !== null && conversations.quiet()) {
145
+ restart(`Kit ${update.placedRelease()} is placed; its supervisor starts it`);
148
146
  }
149
147
  else if (!reported) {
150
148
  reported = true;
151
- logged(house.deliver('/kit/idle', {}, idle));
149
+ logged(house.deliver('/kit/kits/report-idle', {}, idle));
152
150
  }
153
151
  };
154
152
  const calls = new Calls(house, changed);
@@ -157,50 +155,54 @@ export async function resident() {
157
155
  agents,
158
156
  copies,
159
157
  calls,
160
- send: (notification) => connection?.send(notification) ?? false,
158
+ send: (oneWayCall) => connection?.send(oneWayCall) ?? false,
161
159
  changed,
162
160
  });
163
161
  const signIns = new SignIns(house, agents, calls);
164
- const update = new KitUpdate(calls, changed);
165
- const wizards = new WebWizards(calls, (notification) => connection?.send(notification) ?? false);
162
+ const update = new KitUpdate(calls);
163
+ if (process.env.HOUSE_KIT_SANDBOX !== '1')
164
+ takeUnservedRelease((release) => logged(update.takeRefused(release)));
165
+ removeInputs();
166
+ const scripts = new Scripts(calls, (oneWayCall) => connection?.send(oneWayCall) ?? false);
166
167
  for (const signal of ['SIGTERM', 'SIGINT']) {
167
168
  process.once(signal, () => {
168
169
  killDescendants();
170
+ removeInputs();
169
171
  process.kill(process.pid, signal);
170
172
  });
171
173
  }
172
- await house.deliver('/kit/restarted', {}).catch(report);
173
- await update.resumed().catch(report);
174
+ await house.deliver('/kit/kits/report-restart', {}).catch(report);
174
175
  logged(agents.refresh());
176
+ agents.keepCurrent(() => process.env.HOUSE_KIT_SANDBOX === '1' && reported);
175
177
  connection = holdConnection({
176
178
  opened: () => {
177
179
  conversations.opened();
178
180
  changed();
179
181
  logged(copies.connected());
180
182
  },
181
- closed: () => wizards.disconnected(),
183
+ closed: () => scripts.disconnected(),
182
184
  call: (call) => {
183
185
  if (call.kind === 'sign_in')
184
186
  signIns.start(call);
185
187
  else if (call.kind === 'update')
186
- update.hold(call);
187
- else if (call.kind === 'run_wizard')
188
- wizards.start(call);
188
+ update.take(call);
189
+ else if (call.kind === 'run_wizard' || call.kind === 'run_function')
190
+ scripts.start(call);
189
191
  else if (CONVERSATION_METHODS.has(call.kind))
190
192
  conversations.call(call);
191
193
  else {
192
- const refused = { refused: `This Kit does not know ${call.kind}; update the Kit` };
194
+ const refused = { refused: unknownMethod(call.kind) };
193
195
  void calls.carry(call.input_id, async () => ({ result: refused }));
194
196
  }
195
197
  },
196
- notification: (notification) => {
197
- if (notification.type === 'watching')
198
- conversations.watching(notification.watching === true);
199
- if (notification.type === 'authority_changed')
200
- logged(copies.changed(notification.rooms));
201
- if (notification.type === 'work_available' && notification.subject === 'agents')
198
+ oneWayCall: (oneWayCall) => {
199
+ if (oneWayCall.type === 'watching')
200
+ conversations.watching(oneWayCall.watching === true);
201
+ if (oneWayCall.type === 'authority_changed')
202
+ logged(copies.changed(oneWayCall.rooms));
203
+ if (oneWayCall.type === 'work_available' && oneWayCall.subject === 'agents')
202
204
  logged(agents.refresh());
203
- wizards.notified(notification);
205
+ scripts.notified(oneWayCall);
204
206
  },
205
207
  });
206
208
  }
package/dist/scope.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { execFileSync } from 'node:child_process';
2
- import { mkdirSync, readdirSync, readFileSync, rmdirSync, statSync, writeFileSync } from 'node:fs';
2
+ import { mkdirSync, readdirSync, readFileSync, realpathSync, rmdirSync, statSync, writeFileSync } from 'node:fs';
3
3
  import { join } from 'node:path';
4
4
  const LISTING_BYTES = 1 << 28;
5
5
  const CGROUPS = '/sys/fs/cgroup';
@@ -122,15 +122,23 @@ function members(group) {
122
122
  }
123
123
  return pids;
124
124
  }
125
+ function besideCli(cli) {
126
+ try {
127
+ return `${realpathSync(cli)}-`;
128
+ }
129
+ catch {
130
+ return null;
131
+ }
132
+ }
125
133
  export class Scope {
126
134
  marker;
127
- cli;
135
+ helpers;
128
136
  group;
129
137
  session = null;
130
138
  recorded = null;
131
139
  constructor(marker, name, cli) {
132
140
  this.marker = marker;
133
- this.cli = cli;
141
+ this.helpers = besideCli(cli);
134
142
  const own = ownGroup();
135
143
  this.group = own === null ? null : join(own, name);
136
144
  try {
@@ -168,7 +176,7 @@ export class Scope {
168
176
  return true;
169
177
  if (this.recorded === null)
170
178
  return found.size > 0;
171
- return [...found].some(([pid, { session, command }]) => session !== this.session || !(this.recorded.has(pid) || command.startsWith(`${this.cli}-`)));
179
+ return [...found].some(([pid, { session, command }]) => session !== this.session || !(this.recorded.has(pid) || (this.helpers !== null && command.startsWith(this.helpers))));
172
180
  }
173
181
  empty() {
174
182
  return this.found()?.size === 0;