@agentshouse/kit 0.2.1-ccb257fa8a318 → 0.2.1-ccffb3f637815

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.
Files changed (57) hide show
  1. package/README.md +27 -31
  2. package/dist/acp.js +17 -10
  3. package/dist/afk.js +17 -0
  4. package/dist/agents.js +121 -52
  5. package/dist/api.js +11 -6
  6. package/dist/binaries.js +89 -0
  7. package/dist/bridge.js +28 -27
  8. package/dist/building.js +7 -3
  9. package/dist/calls.js +18 -1
  10. package/dist/chunks.js +49 -0
  11. package/dist/clis.js +52 -63
  12. package/dist/connect.js +108 -0
  13. package/dist/connection.js +24 -20
  14. package/dist/content.js +106 -0
  15. package/dist/conversations.js +255 -134
  16. package/dist/copies.js +748 -248
  17. package/dist/earlier.js +263 -0
  18. package/dist/end.js +9 -6
  19. package/dist/events.js +549 -281
  20. package/dist/files.js +77 -11
  21. package/dist/git-main.js +24 -29
  22. package/dist/git.js +87 -12
  23. package/dist/grok.js +39 -0
  24. package/dist/home.js +80 -29
  25. package/dist/house-cli.js +106 -123
  26. package/dist/instructions.js +2 -4
  27. package/dist/keys.js +238 -0
  28. package/dist/kit-cli.js +14 -4
  29. package/dist/login.js +34 -20
  30. package/dist/logout.js +2 -2
  31. package/dist/mcp.js +38 -3
  32. package/dist/old-references.js +27 -0
  33. package/dist/owner.js +46 -0
  34. package/dist/placement.js +9 -23
  35. package/dist/refusals.js +37 -21
  36. package/dist/resident.js +107 -72
  37. package/dist/scope.js +12 -4
  38. package/dist/scripts.js +59 -11
  39. package/dist/secret-input.js +1 -1
  40. package/dist/settings.js +188 -0
  41. package/dist/sign-in.js +49 -4
  42. package/dist/supervisor.js +163 -0
  43. package/dist/transcription.js +5 -2
  44. package/dist/translate.js +18 -11
  45. package/dist/update.js +115 -160
  46. package/dist/wire.js +19 -9
  47. package/dist/work.js +27 -2
  48. package/dist/workspace.js +103 -0
  49. package/package.json +13 -8
  50. package/dist/authority-main.js +0 -22
  51. package/dist/chatgpt.js +0 -32
  52. package/dist/clis-main.js +0 -23
  53. package/dist/configure-main.js +0 -6
  54. package/dist/enrol-main.js +0 -10
  55. package/dist/parts.js +0 -82
  56. package/dist/service-main.js +0 -9
  57. package/dist/service.js +0 -55
package/dist/wire.js CHANGED
@@ -1,9 +1,8 @@
1
- import { newerThanHouse, updateRequired } from './end.js';
2
- import { machine } from './placement.js';
1
+ import { updateRequired } from './end.js';
3
2
  import { refusalOf } from './refusals.js';
4
- export const KIT_WIRE = 3;
5
- export const KIT_WIRE_HEADER = 'x-house-kit-wire';
6
- function newer(text) {
3
+ let take = null;
4
+ let taken = false;
5
+ function unservedBy(text) {
7
6
  let body;
8
7
  try {
9
8
  body = JSON.parse(text);
@@ -11,12 +10,23 @@ function newer(text) {
11
10
  catch {
12
11
  return null;
13
12
  }
14
- return body?.error?.code === 'kit_newer_than_house' ? body.error : null;
13
+ return body?.error?.code === 'kit_update_required' ? body.error : null;
14
+ }
15
+ export function takeUnservedRelease(taking) {
16
+ take = taking;
17
+ }
18
+ export function unserved() {
19
+ return taken;
15
20
  }
16
21
  export function endUnserved(text) {
22
+ const refused = unservedBy(text);
23
+ if (refused !== null && take !== null) {
24
+ if (!taken) {
25
+ taken = true;
26
+ take(refused.release);
27
+ }
28
+ return;
29
+ }
17
30
  if (refusalOf(text)?.code === 'kit_update_required')
18
31
  updateRequired();
19
- const refused = newer(text);
20
- if (refused !== null)
21
- newerThanHouse(refused.release, refused.commands[machine()]);
22
32
  }
package/dist/work.js CHANGED
@@ -25,6 +25,9 @@ export class Work {
25
25
  return {};
26
26
  }
27
27
  async settled() { }
28
+ caughtUp() {
29
+ return null;
30
+ }
28
31
  read(message) {
29
32
  this.take(message);
30
33
  this.changed();
@@ -177,6 +180,7 @@ class ClaudeWork extends Work {
177
180
  }
178
181
  }
179
182
  class CodexWork extends Work {
183
+ tapped;
180
184
  threads = new Map();
181
185
  queues = new Map();
182
186
  goals = new Set();
@@ -184,6 +188,7 @@ class CodexWork extends Work {
184
188
  hooks = new Set();
185
189
  starting = new Set();
186
190
  settling = [];
191
+ waiting = [];
187
192
  memories = null;
188
193
  lost = false;
189
194
  server = null;
@@ -193,6 +198,10 @@ class CodexWork extends Work {
193
198
  heard = 0;
194
199
  proving = -1;
195
200
  proven = -1;
201
+ constructor(changed, tapped) {
202
+ super(changed);
203
+ this.tapped = tapped;
204
+ }
196
205
  async open(cli) {
197
206
  this.path = join(socketDirectory(), `${randomUUID()}.sock`);
198
207
  this.server = createServer((socket) => this.connected(socket));
@@ -210,6 +219,14 @@ class CodexWork extends Work {
210
219
  super.take(message);
211
220
  this.heard++;
212
221
  }
222
+ caughtUp() {
223
+ if (this.lost || this.socket === null)
224
+ return null;
225
+ const { promise, resolve } = Promise.withResolvers();
226
+ this.waiting.push({ heard: this.heard, resolve });
227
+ this.prove();
228
+ return promise;
229
+ }
213
230
  busy() {
214
231
  if (super.busy() ||
215
232
  this.lost ||
@@ -259,6 +276,7 @@ class CodexWork extends Work {
259
276
  }
260
277
  lose() {
261
278
  this.lost = true;
279
+ this.release();
262
280
  this.changed();
263
281
  }
264
282
  prove() {
@@ -267,6 +285,10 @@ class CodexWork extends Work {
267
285
  this.proving = this.heard;
268
286
  this.socket.write(`${JSON.stringify({ jsonrpc: '2.0', id: `${SYNC}${this.heard}`, method: 'house-kit/sync' })}\n`);
269
287
  }
288
+ release() {
289
+ while (this.waiting[0] !== undefined && (this.lost || this.waiting[0].heard <= this.proven))
290
+ this.waiting.shift().resolve();
291
+ }
270
292
  settle() {
271
293
  if (this.starting.size === 0)
272
294
  for (const resolve of this.settling.splice(0))
@@ -274,6 +296,8 @@ class CodexWork extends Work {
274
296
  }
275
297
  stream(message, socket) {
276
298
  const params = message.params;
299
+ if (message.method !== undefined)
300
+ this.tapped(message);
277
301
  switch (message.method) {
278
302
  case 'thread/status/changed':
279
303
  this.threads.set(params.threadId, params.status.type === 'active' && params.status.activeFlags.length === 0);
@@ -319,6 +343,7 @@ class CodexWork extends Work {
319
343
  answered(message) {
320
344
  if (typeof message.id === 'string' && message.id.startsWith(SYNC)) {
321
345
  this.proven = Number(message.id.slice(SYNC.length));
346
+ this.release();
322
347
  }
323
348
  else if (typeof message.id === 'string' && message.id.startsWith(QUEUE_LIST)) {
324
349
  const asked = Number(message.id.slice(QUEUE_LIST.length));
@@ -337,10 +362,10 @@ class GrokWork extends Work {
337
362
  return true;
338
363
  }
339
364
  }
340
- export function workFor(kind, cwd, changed) {
365
+ export function workFor(kind, cwd, changed, tapped) {
341
366
  if (kind === 'claude-agent-acp')
342
367
  return new ClaudeWork(cwd, changed);
343
368
  if (kind === 'codex-acp')
344
- return new CodexWork(changed);
369
+ return new CodexWork(changed, tapped);
345
370
  return new GrokWork(changed);
346
371
  }
@@ -0,0 +1,103 @@
1
+ import { cp, lstat, mkdir, readdir, readFile, rename, rm, rmdir, writeFile } from 'node:fs/promises';
2
+ import { join } from 'node:path';
3
+ export async function present(path) {
4
+ try {
5
+ return await lstat(path);
6
+ }
7
+ catch (error) {
8
+ if (error.code === 'ENOENT')
9
+ return null;
10
+ throw error;
11
+ }
12
+ }
13
+ async function listed(path) {
14
+ const entries = await readdir(path, { recursive: true, withFileTypes: true });
15
+ const shown = await Promise.all(entries.map(async (entry) => {
16
+ const at = join(entry.parentPath, entry.name);
17
+ return `${at.slice(path.length)} ${entry.isFile() ? (await lstat(at)).size : entry.isDirectory() ? 'folder' : 'link'}`;
18
+ }));
19
+ return shown.sort();
20
+ }
21
+ async function moved(source, target) {
22
+ try {
23
+ await rename(source, target);
24
+ return;
25
+ }
26
+ catch (error) {
27
+ if (error.code !== 'EXDEV')
28
+ throw error;
29
+ }
30
+ const copy = `${target}.moving`;
31
+ await rm(copy, { recursive: true, force: true });
32
+ try {
33
+ await cp(source, copy, { recursive: true, preserveTimestamps: true, verbatimSymlinks: true });
34
+ const folder = (await lstat(source)).isDirectory();
35
+ if (folder && JSON.stringify(await listed(source)) !== JSON.stringify(await listed(copy))) {
36
+ throw new Error(`${source} could not be copied to ${target} whole`);
37
+ }
38
+ }
39
+ catch (error) {
40
+ await rm(copy, { recursive: true, force: true });
41
+ throw error;
42
+ }
43
+ await rename(copy, target);
44
+ await rm(source, { recursive: true, force: true });
45
+ }
46
+ export async function merged(from, to, placed = () => 'moves') {
47
+ const found = await present(from);
48
+ if (found === null || !found.isDirectory())
49
+ return;
50
+ await mkdir(to, { recursive: true, mode: 0o700 });
51
+ for (const entry of await readdir(from, { withFileTypes: true })) {
52
+ const source = join(from, entry.name);
53
+ const placement = placed(source, entry);
54
+ if (placement === 'stays')
55
+ continue;
56
+ const target = join(to, entry.name);
57
+ const held = await present(target);
58
+ if (held === null && placement === 'moves')
59
+ await moved(source, target);
60
+ else if (entry.isDirectory() && (held === null || held.isDirectory()))
61
+ await merged(source, target, placed);
62
+ else
63
+ await rm(source, { recursive: true, force: true });
64
+ }
65
+ await removeFolder(from);
66
+ }
67
+ export async function removeFolder(path) {
68
+ await rmdir(path).catch((error) => {
69
+ if (error.code !== 'ENOTEMPTY' && error.code !== 'ENOENT')
70
+ throw error;
71
+ });
72
+ }
73
+ export function within(path, folder) {
74
+ return path === folder || path.startsWith(`${folder}/`);
75
+ }
76
+ function rewritten(value, from, to, kept) {
77
+ if (typeof value === 'string') {
78
+ if (kept.some((folder) => within(value, folder)) || (within(to, from) && within(value, to)) || !within(value, from))
79
+ return value;
80
+ return `${to}${value.slice(from.length)}`;
81
+ }
82
+ if (Array.isArray(value))
83
+ return value.map((item) => rewritten(item, from, to, kept));
84
+ if (typeof value === 'object' && value !== null) {
85
+ return Object.fromEntries(Object.entries(value).map(([name, held]) => [name, rewritten(held, from, to, kept)]));
86
+ }
87
+ return value;
88
+ }
89
+ export async function followRoot(records, from, to, kept = []) {
90
+ if (from === to)
91
+ return;
92
+ for (const name of await readdir(records).catch(() => [])) {
93
+ if (!name.endsWith('.json'))
94
+ continue;
95
+ const path = join(records, name);
96
+ const text = await readFile(path, 'utf8');
97
+ const next = `${JSON.stringify(rewritten(JSON.parse(text), from, to, kept))}\n`;
98
+ if (next.trim() === text.trim())
99
+ continue;
100
+ await writeFile(`${path}.new`, next, { mode: 0o600 });
101
+ await rename(`${path}.new`, path);
102
+ }
103
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentshouse/kit",
3
- "version": "0.2.1-ccb257fa8a318",
3
+ "version": "0.2.1-ccffb3f637815",
4
4
  "description": "Kit connects an Environment to agents.house.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -19,20 +19,24 @@
19
19
  "bootstrap-manifest": "node scripts/bootstrap-manifest.mjs",
20
20
  "build": "tsc -p tsconfig.build.json",
21
21
  "engine": "mkdir -p tmp/engine && docker run --rm -v \"$PWD:/kit\" -w /kit alpine:3.24@sha256:294b683cb724975bec92580e1e685676bd4b50bda910ddb8c51d4cabeaec77e6 sh scripts/engine.sh tmp/engine",
22
- "follow-skills": "node scripts/follow-skills.mjs",
22
+ "follow-skills-and-kit-wire": "node scripts/follow-skills-and-kit-wire.mjs",
23
23
  "release-files": "node scripts/release-files.mjs",
24
24
  "test": "tsc -p tsconfig.json && vitest run"
25
25
  },
26
26
  "dependencies": {
27
- "@agentclientprotocol/sdk": "2.0.1",
28
- "@agentshouse/mdmodel": "0.1.0-c4f4d37bc9d6a",
29
- "@agentshouse/skills": "0.1.0-c104451ca0a9f",
27
+ "@agentclientprotocol/sdk": "2.4.0",
28
+ "@agentshouse/kit-wire": "0.1.0-caf9c7b612dda",
29
+ "@agentshouse/mdmodel": "0.1.0-c420026daf4fc",
30
+ "@agentshouse/session-content": "0.1.0-c560e48c9bea3",
31
+ "@agentshouse/skills": "0.1.0-cc1f045bb51fa",
30
32
  "@lydell/node-pty": "1.2.0-beta.15",
33
+ "micromark": "4.0.2",
34
+ "smol-toml": "1.9.1",
31
35
  "yaml": "2.9.1"
32
36
  },
33
37
  "peerDependencies": {
34
- "@agentclientprotocol/claude-agent-acp": "0.94.0",
35
- "@agentclientprotocol/codex-acp": "2.2.2"
38
+ "@agentclientprotocol/claude-agent-acp": "0.100.0",
39
+ "@agentclientprotocol/codex-acp": "2.5.0"
36
40
  },
37
41
  "peerDependenciesMeta": {
38
42
  "@agentclientprotocol/claude-agent-acp": {
@@ -47,7 +51,8 @@
47
51
  "@types/ws": "8.18.2",
48
52
  "typescript": "7.0.2",
49
53
  "vitest": "5.0.5",
50
- "ws": "8.22.0"
54
+ "ws": "8.22.0",
55
+ "zod": "4.6.7"
51
56
  },
52
57
  "packageManager": "npm@11.19.1",
53
58
  "engines": {
@@ -1,22 +0,0 @@
1
- import { HouseRefusal, post } from './api.js';
2
- import { readEnrolment } from './home.js';
3
- import { proxyUnlessRelayed } from './relay.js';
4
- function unanswered(error) {
5
- return error instanceof HouseRefusal ? error.status >= 500 : error instanceof TypeError && error.message === 'fetch failed';
6
- }
7
- proxyUnlessRelayed();
8
- try {
9
- const { house, credential } = (await readEnrolment());
10
- try {
11
- await post(house, '/kit/agents/desired', {}, credential);
12
- }
13
- catch (error) {
14
- if (!unanswered(error))
15
- throw error;
16
- process.stderr.write(`kit: House did not answer, so the stored credential stands: ${error.message}\n`);
17
- }
18
- }
19
- catch (error) {
20
- process.stderr.write(`kit: ${error.message}\n`);
21
- process.exitCode = 1;
22
- }
package/dist/chatgpt.js DELETED
@@ -1,32 +0,0 @@
1
- import { parseArgs } from 'node:util';
2
- import { placeAppGit } from './app-git.js';
3
- import { kitHome, readOwnAgent, writeOwnAgent } from './home.js';
4
- import { accepted, DEFAULT_HOUSE } from './login.js';
5
- const KEY_SOURCE = 'New key for a script on Connections';
6
- const USAGE = `usage: kit chatgpt --key <key> [--house <origin>]
7
- --key <key> a key from ${KEY_SOURCE}
8
- --house <origin> the House of the key, ${DEFAULT_HOUSE} unless one is stored
9
- `;
10
- export async function chatgpt(argv) {
11
- const { values } = parseArgs({
12
- args: argv,
13
- options: { key: { type: 'string' }, house: { type: 'string' }, help: { type: 'boolean', default: false } },
14
- });
15
- if (values.help) {
16
- process.stdout.write(USAGE);
17
- return;
18
- }
19
- if (values.key === undefined)
20
- throw new Error(`pass --key with a key from ${KEY_SOURCE}`);
21
- const before = await readOwnAgent();
22
- const house = values.house ?? before?.house ?? DEFAULT_HOUSE;
23
- if (!(await accepted(house, values.key)))
24
- throw new Error(`${house} does not accept this key; pass one from ${KEY_SOURCE}`);
25
- const relay = process.env.HOUSE_KIT_RELAY || undefined;
26
- await writeOwnAgent({ house, ...(relay === undefined ? {} : { relay }), credential: values.key });
27
- await placeAppGit(await readOwnAgent()).catch((error) => process.stderr.write(`kit: ${error.message}\n`));
28
- if (before !== null && before.credential !== values.key) {
29
- process.stdout.write('This replaced the key this Kit home held; give each session its own HOUSE_KIT_HOME to keep its own key.\n');
30
- }
31
- process.stdout.write(`house now calls ${house} as you, with the key kept in ${kitHome()}.\n`);
32
- }
package/dist/clis-main.js DELETED
@@ -1,23 +0,0 @@
1
- import { post } from './api.js';
2
- import { CLIS, below, locate, versionOf } from './clis.js';
3
- import { readEnrolment } from './home.js';
4
- import { proxyUnlessRelayed } from './relay.js';
5
- proxyUnlessRelayed();
6
- try {
7
- const { house, credential } = (await readEnrolment());
8
- const { agents } = await post(house, '/kit/agents/desired', {}, credential);
9
- for (const kind of agents) {
10
- const cli = await locate(kind);
11
- if (cli === null)
12
- continue;
13
- const release = await versionOf(cli);
14
- if (release === null)
15
- continue;
16
- const { bin, minimum } = CLIS[kind];
17
- process.stdout.write(`${[bin, cli, release, minimum, below(release, minimum) ? 'old' : 'current'].join('\t')}\n`);
18
- }
19
- }
20
- catch (error) {
21
- process.stderr.write(`kit: ${error.message}\n`);
22
- process.exitCode = 1;
23
- }
@@ -1,6 +0,0 @@
1
- import { readConfiguration, writeConfiguration } from './home.js';
2
- const skills = !process.argv.slice(2).includes('--no-skills');
3
- const stored = await readConfiguration();
4
- await writeConfiguration({ skills });
5
- if (stored.skills !== skills)
6
- process.stdout.write('changed\n');
@@ -1,10 +0,0 @@
1
- import { readFileSync } from 'node:fs';
2
- import { writeEnrolment } from './home.js';
3
- const [house, environment] = process.argv.slice(2);
4
- const relay = process.env.HOUSE_KIT_RELAY || undefined;
5
- await writeEnrolment({
6
- house: house,
7
- ...(relay === undefined ? {} : { relay }),
8
- environment: environment,
9
- credential: readFileSync(0, 'utf8').trim(),
10
- });
package/dist/parts.js DELETED
@@ -1,82 +0,0 @@
1
- export class Parts {
2
- parts = [];
3
- context = null;
4
- emit;
5
- made = [];
6
- events = 0;
7
- writing = null;
8
- counting = null;
9
- planned = null;
10
- constructor(emit) {
11
- this.emit = emit;
12
- }
13
- write(type, id, text) {
14
- if (text === '')
15
- return;
16
- if (this.writing?.type === type && this.writing.id === id) {
17
- this.parts[this.writing.index].text += text;
18
- this.emit({ op: 'append', index: this.writing.index, text });
19
- return;
20
- }
21
- this.writing = { type, id, index: this.start({ type, text }) };
22
- }
23
- command() {
24
- if (this.counting === null) {
25
- this.counting = this.start({ type: 'commands', count: 1 });
26
- return;
27
- }
28
- const part = this.parts[this.counting];
29
- part.count++;
30
- this.emit({ op: 'count', index: this.counting, count: part.count });
31
- }
32
- start(part) {
33
- this.writing = null;
34
- this.counting = null;
35
- return this.add(part, ++this.events);
36
- }
37
- reserve() {
38
- this.writing = null;
39
- this.counting = null;
40
- return ++this.events;
41
- }
42
- arrive(part, reserved) {
43
- this.add(part, reserved);
44
- }
45
- done(index, result) {
46
- const part = this.parts[index];
47
- part.status = 'done';
48
- part.result = result;
49
- this.emit({ op: 'status', index, status: 'done', result });
50
- }
51
- plan(entries) {
52
- if (this.planned === null) {
53
- this.planned = this.start({ type: 'plan', entries });
54
- return;
55
- }
56
- this.parts[this.planned].entries = entries;
57
- this.emit({ op: 'plan', index: this.planned, entries });
58
- }
59
- measure(context) {
60
- this.context = context;
61
- this.emit({ op: 'context', ...context });
62
- }
63
- saved() {
64
- return this.parts
65
- .map((part, index) => ({ part, made: this.made[index] }))
66
- .sort((a, b) => a.made - b.made)
67
- .map(({ part }) => part);
68
- }
69
- operations() {
70
- return [
71
- ...this.parts.map((part, index) => ({ op: 'start', index, part })),
72
- ...(this.context === null ? [] : [{ op: 'context', ...this.context }]),
73
- ];
74
- }
75
- add(part, made) {
76
- this.parts.push(part);
77
- this.made.push(made);
78
- const index = this.parts.length - 1;
79
- this.emit({ op: 'start', index, part });
80
- return index;
81
- }
82
- }
@@ -1,9 +0,0 @@
1
- import { startService } from './service.js';
2
- try {
3
- if (startService())
4
- process.stdout.write('started\n');
5
- }
6
- catch (error) {
7
- process.stderr.write(`kit: ${error.message}\n`);
8
- process.exitCode = 1;
9
- }
package/dist/service.js DELETED
@@ -1,55 +0,0 @@
1
- import { spawnSync } from 'node:child_process';
2
- import { existsSync, realpathSync } from 'node:fs';
3
- import { resolve } from 'node:path';
4
- import { kitHome } from './home.js';
5
- const UNIT = 'house-kit.service';
6
- // launchctl and systemctl answer at once, so ten seconds only bounds a stuck service manager.
7
- const MANAGER_MS = 10_000;
8
- function manage(command, args) {
9
- return spawnSync(command, args, { encoding: 'utf8', timeout: MANAGER_MS });
10
- }
11
- function start(command, args) {
12
- const started = manage(command, args);
13
- if (started.status === 0)
14
- return;
15
- const cause = started.error?.message ?? (started.stderr.trim() || `${command} exited with ${started.status ?? 'a signal'}`);
16
- throw new Error(`the Kit service could not be started: ${cause}`);
17
- }
18
- function physical(path) {
19
- return existsSync(path) ? realpathSync(path) : resolve(path);
20
- }
21
- function systemdHome(environment) {
22
- for (const [, quoted, bare] of environment.matchAll(/"((?:[^"\\]|\\.)*)"|(\S+)/g)) {
23
- const assignment = bare ?? quoted.replace(/\\(.)/g, '$1');
24
- if (assignment.startsWith('HOUSE_KIT_HOME='))
25
- return assignment.slice('HOUSE_KIT_HOME='.length);
26
- }
27
- return undefined;
28
- }
29
- function runsThisHome(served) {
30
- return served !== undefined && physical(served) === physical(kitHome());
31
- }
32
- export function startService() {
33
- if (process.platform === 'darwin') {
34
- const service = `gui/${process.getuid()}/house-kit`;
35
- const printed = manage('launchctl', ['print', service]);
36
- if (printed.status !== 0 || /^\tstate = running$/m.test(printed.stdout))
37
- return false;
38
- if (!runsThisHome(/^\t+HOUSE_KIT_HOME => (.+)$/m.exec(printed.stdout)?.[1]))
39
- return false;
40
- start('launchctl', ['kickstart', service]);
41
- return true;
42
- }
43
- for (const scope of [['--user'], []]) {
44
- if (manage('systemctl', [...scope, 'is-enabled', '--quiet', UNIT]).status !== 0)
45
- continue;
46
- const environment = manage('systemctl', [...scope, 'show', '--property=Environment', '--value', UNIT]).stdout;
47
- if (!runsThisHome(systemdHome(environment)))
48
- continue;
49
- if (manage('systemctl', [...scope, 'is-active', '--quiet', UNIT]).status === 0)
50
- return false;
51
- start('systemctl', [...scope, 'start', UNIT]);
52
- return true;
53
- }
54
- return false;
55
- }