@agentshouse/kit 0.2.1-ccf188e02985d → 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 (164) hide show
  1. package/README.md +37 -41
  2. package/dist/acp.js +66 -12
  3. package/dist/afk.js +17 -0
  4. package/dist/agents.js +122 -53
  5. package/dist/api.js +15 -10
  6. package/dist/binaries.js +89 -0
  7. package/dist/bridge.js +29 -28
  8. package/dist/building.js +50 -0
  9. package/dist/calls.js +88 -0
  10. package/dist/chunks.js +49 -0
  11. package/dist/clis.js +62 -50
  12. package/dist/connect.js +108 -0
  13. package/dist/connection.js +120 -0
  14. package/dist/content.js +106 -0
  15. package/dist/conversations.js +594 -219
  16. package/dist/copies.js +772 -279
  17. package/dist/earlier.js +263 -0
  18. package/dist/end.js +12 -5
  19. package/dist/events.js +549 -281
  20. package/dist/files.js +206 -38
  21. package/dist/git-main.js +24 -29
  22. package/dist/git.js +90 -15
  23. package/dist/grok.js +39 -0
  24. package/dist/home.js +80 -29
  25. package/dist/house-cli.js +155 -164
  26. package/dist/house-main.js +3 -3
  27. package/dist/instructions.js +29 -11
  28. package/dist/keys.js +238 -0
  29. package/dist/kit-cli.js +18 -8
  30. package/dist/kit-main.js +3 -3
  31. package/dist/login.js +36 -22
  32. package/dist/logout.js +2 -2
  33. package/dist/mcp.js +42 -3
  34. package/dist/old-references.js +27 -0
  35. package/dist/owner.js +46 -0
  36. package/dist/placement.js +15 -20
  37. package/dist/refusals.js +37 -21
  38. package/dist/relay.js +21 -0
  39. package/dist/resident.js +128 -82
  40. package/dist/scope.js +15 -4
  41. package/dist/scripts.js +303 -0
  42. package/dist/secret-input.js +1 -1
  43. package/dist/settings.js +188 -0
  44. package/dist/sign-in.js +67 -21
  45. package/dist/silence.js +28 -0
  46. package/dist/skills.js +42 -97
  47. package/dist/supervisor.js +163 -0
  48. package/dist/transcription.js +88 -45
  49. package/dist/translate.js +19 -18
  50. package/dist/update.js +118 -120
  51. package/dist/wire.js +30 -4
  52. package/dist/work.js +27 -2
  53. package/dist/workspace.js +103 -0
  54. package/package.json +26 -22
  55. package/dist/authority-main.js +0 -22
  56. package/dist/bootstrap.json +0 -24
  57. package/dist/chatgpt.js +0 -32
  58. package/dist/clis-main.js +0 -23
  59. package/dist/configure-main.js +0 -6
  60. package/dist/enrol-main.js +0 -10
  61. package/dist/inputs.js +0 -37
  62. package/dist/parts.js +0 -82
  63. package/dist/service-main.js +0 -9
  64. package/dist/service.js +0 -55
  65. package/dist/stream.js +0 -123
  66. package/how-we-work.md +0 -33
  67. package/skills/ask-matt/LICENSE +0 -21
  68. package/skills/ask-matt/PHASE-BOUNDARIES.md +0 -55
  69. package/skills/ask-matt/SKILL.md +0 -97
  70. package/skills/ask-matt/agents/openai.yaml +0 -5
  71. package/skills/code-review/LICENSE +0 -21
  72. package/skills/code-review/SKILL.md +0 -89
  73. package/skills/code-review/agents/openai.yaml +0 -3
  74. package/skills/codebase-design/DEEPENING.md +0 -37
  75. package/skills/codebase-design/DESIGN-IT-TWICE.md +0 -44
  76. package/skills/codebase-design/LICENSE +0 -21
  77. package/skills/codebase-design/SKILL.md +0 -114
  78. package/skills/codebase-design/agents/openai.yaml +0 -3
  79. package/skills/diagnosing-bugs/LICENSE +0 -21
  80. package/skills/diagnosing-bugs/SKILL.md +0 -138
  81. package/skills/diagnosing-bugs/agents/openai.yaml +0 -3
  82. package/skills/diagnosing-bugs/scripts/hitl-loop.template.sh +0 -44
  83. package/skills/domain-modeling/ADR-FORMAT.md +0 -47
  84. package/skills/domain-modeling/GLOSSARY-FORMAT.md +0 -60
  85. package/skills/domain-modeling/LICENSE +0 -21
  86. package/skills/domain-modeling/SKILL.md +0 -74
  87. package/skills/domain-modeling/agents/openai.yaml +0 -3
  88. package/skills/grill-me/LICENSE +0 -21
  89. package/skills/grill-me/SKILL.md +0 -7
  90. package/skills/grill-me/agents/openai.yaml +0 -5
  91. package/skills/grill-with-docs/LICENSE +0 -21
  92. package/skills/grill-with-docs/SKILL.md +0 -7
  93. package/skills/grill-with-docs/agents/openai.yaml +0 -5
  94. package/skills/grilling/LICENSE +0 -21
  95. package/skills/grilling/SKILL.md +0 -30
  96. package/skills/grilling/agents/openai.yaml +0 -3
  97. package/skills/handoff/LICENSE +0 -21
  98. package/skills/handoff/SKILL.md +0 -16
  99. package/skills/handoff/agents/openai.yaml +0 -5
  100. package/skills/implement/LICENSE +0 -21
  101. package/skills/implement/SKILL.md +0 -17
  102. package/skills/implement/agents/openai.yaml +0 -5
  103. package/skills/implement-spec/LICENSE +0 -21
  104. package/skills/implement-spec/SKILL.md +0 -40
  105. package/skills/implement-spec/agents/openai.yaml +0 -5
  106. package/skills/improve-codebase-architecture/HTML-REPORT.md +0 -123
  107. package/skills/improve-codebase-architecture/LICENSE +0 -21
  108. package/skills/improve-codebase-architecture/SKILL.md +0 -71
  109. package/skills/improve-codebase-architecture/agents/openai.yaml +0 -5
  110. package/skills/pr/CREDITS.md +0 -3
  111. package/skills/pr/LICENSE +0 -21
  112. package/skills/pr/SKILL.md +0 -170
  113. package/skills/pr/agents/openai.yaml +0 -3
  114. package/skills/prototype/LICENSE +0 -21
  115. package/skills/prototype/LOGIC.md +0 -67
  116. package/skills/prototype/SKILL.md +0 -26
  117. package/skills/prototype/UI.md +0 -112
  118. package/skills/prototype/agents/openai.yaml +0 -3
  119. package/skills/research/LICENSE +0 -21
  120. package/skills/research/SKILL.md +0 -12
  121. package/skills/research/agents/openai.yaml +0 -3
  122. package/skills/retro/LICENSE +0 -21
  123. package/skills/retro/SKILL.md +0 -44
  124. package/skills/retro/agents/openai.yaml +0 -5
  125. package/skills/tdd/LICENSE +0 -21
  126. package/skills/tdd/SKILL.md +0 -38
  127. package/skills/tdd/agents/openai.yaml +0 -3
  128. package/skills/tdd/mocking.md +0 -59
  129. package/skills/tdd/tests.md +0 -77
  130. package/skills/teach/GLOSSARY-FORMAT.md +0 -35
  131. package/skills/teach/LEARNING-RECORD-FORMAT.md +0 -46
  132. package/skills/teach/LICENSE +0 -21
  133. package/skills/teach/MISSION-FORMAT.md +0 -31
  134. package/skills/teach/RESOURCES-FORMAT.md +0 -32
  135. package/skills/teach/SKILL.md +0 -140
  136. package/skills/teach/agents/openai.yaml +0 -5
  137. package/skills/to-questionnaire/LICENSE +0 -21
  138. package/skills/to-questionnaire/SKILL.md +0 -54
  139. package/skills/to-questionnaire/agents/openai.yaml +0 -5
  140. package/skills/to-spec/LICENSE +0 -21
  141. package/skills/to-spec/SKILL.md +0 -75
  142. package/skills/to-spec/agents/openai.yaml +0 -5
  143. package/skills/to-tickets/LICENSE +0 -21
  144. package/skills/to-tickets/SKILL.md +0 -105
  145. package/skills/to-tickets/agents/openai.yaml +0 -5
  146. package/skills/triage/AGENT-BRIEF.md +0 -207
  147. package/skills/triage/LICENSE +0 -21
  148. package/skills/triage/OUT-OF-SCOPE.md +0 -105
  149. package/skills/triage/SKILL.md +0 -112
  150. package/skills/triage/agents/openai.yaml +0 -5
  151. package/skills/wait-what/LICENSE +0 -21
  152. package/skills/wait-what/SKILL.md +0 -7
  153. package/skills/wait-what/agents/openai.yaml +0 -5
  154. package/skills/wayfinder/LICENSE +0 -21
  155. package/skills/wayfinder/SKILL.md +0 -128
  156. package/skills/wayfinder/agents/openai.yaml +0 -5
  157. package/skills/wizard/LICENSE +0 -21
  158. package/skills/wizard/SKILL.md +0 -44
  159. package/skills/wizard/agents/openai.yaml +0 -3
  160. package/skills/wizard/template.sh +0 -223
  161. package/skills/writing-for-agents/LICENSE +0 -21
  162. package/skills/writing-for-agents/SKILL-MECHANICS.md +0 -22
  163. package/skills/writing-for-agents/SKILL.md +0 -81
  164. package/skills/writing-for-agents/agents/openai.yaml +0 -3
package/dist/update.js CHANGED
@@ -1,138 +1,136 @@
1
1
  import { spawn } from 'node:child_process';
2
- import { createHash } from 'node:crypto';
3
- import { mkdir, readFile, rm, writeFile } from 'node:fs/promises';
4
- import { homedir } from 'node:os';
2
+ import { mkdir } from 'node:fs/promises';
5
3
  import { join } from 'node:path';
6
- import { run } from './clis.js';
7
- import { kitHome, workspaceRoot } from './home.js';
8
- import { service, throughSudo } from './placement.js';
9
- function directory() {
10
- return join(kitHome(), 'update');
4
+ import { downloadServed, servedRelease } from './building.js';
5
+ import { KIT_RELEASE } from './clis.js';
6
+ import { restartPlaced, updateLine } from './end.js';
7
+ import { kitHome, readEnrolment } from './home.js';
8
+ import { placedPrefix } from './placement.js';
9
+ import { childEnvironment, relayOrigin } from './relay.js';
10
+ const INSTALLER_BYTES = 1_000_000;
11
+ // A release's Node.js, Kit package and adapters are about a hundred megabytes, so an hour carries them at thirty kilobytes a second, and a placement still running then has hung.
12
+ const PLACEMENT_MS = 60 * 60_000;
13
+ // A refused Kit is offline until its placement succeeds, so it tries again within five minutes of its Building or this computer recovering, while a placement that fails only after its hundred-megabyte download runs at most twelve times an hour.
14
+ export const PLACEMENT_RETRY_MS = 5 * 60_000;
15
+ const REFUSED = 'kit_bootstrap_refused: ';
16
+ const OUTPUT_CHARACTERS = 4000;
17
+ function causeOf(error) {
18
+ if (error instanceof TypeError && error.cause instanceof Error)
19
+ return `the Building did not answer: ${error.cause.message}`;
20
+ return error instanceof Error ? error.message : String(error);
11
21
  }
12
- function pending() {
13
- return join(directory(), 'pending.json');
14
- }
15
- function outcome() {
16
- return join(directory(), 'outcome');
17
- }
18
- function unit(inputId) {
19
- return `house-kit-update-${inputId}`;
20
- }
21
- function manager() {
22
- return service() === 'user' ? ['--user'] : [];
23
- }
24
- function elevated() {
25
- return throughSudo() ? ['sudo', '-n'] : [];
26
- }
27
- function account() {
28
- return throughSudo() ? [`--uid=${process.getuid()}`, `--gid=${process.getgid()}`] : [];
29
- }
30
- function placement() {
31
- return service() === 'user' ? ['--workspace', workspaceRoot()] : ['--linux'];
32
- }
33
- function record() {
34
- return `outcome=$1; shift; bash "$0" "$@"; printf %s "$?" > "$outcome"; ${[...elevated(), 'systemctl', ...manager(), 'start', 'house-kit.service'].join(' ')}`;
22
+ function placing(installer, house, prefix, signal) {
23
+ return new Promise((resolve) => {
24
+ const relay = relayOrigin();
25
+ const child = spawn('bash', [installer, '--house', house, '--place', prefix], {
26
+ stdio: ['ignore', 'pipe', 'pipe'],
27
+ env: { ...childEnvironment(), ...(relay === undefined ? {} : { HOUSE_KIT_RELAY: relay }) },
28
+ detached: true,
29
+ });
30
+ const stop = () => {
31
+ try {
32
+ process.kill(-child.pid, 'SIGKILL');
33
+ }
34
+ catch { }
35
+ };
36
+ signal.addEventListener('abort', stop, { once: true });
37
+ if (signal.aborted)
38
+ stop();
39
+ let output = '';
40
+ for (const stream of [child.stdout, child.stderr]) {
41
+ stream.setEncoding('utf8').on('data', (chunk) => {
42
+ output = (output + chunk).slice(-OUTPUT_CHARACTERS);
43
+ });
44
+ }
45
+ const ended = (failure) => {
46
+ signal.removeEventListener('abort', stop);
47
+ resolve(failure);
48
+ };
49
+ child.on('error', (error) => ended(error.message));
50
+ child.on('close', (status) => {
51
+ if (status === 0)
52
+ return ended(null);
53
+ if (signal.aborted)
54
+ return ended(`the placement did not end within ${PLACEMENT_MS / 1000} seconds`);
55
+ const lines = output.split('\n').filter((line) => line.trim() !== '');
56
+ const refused = lines.findLast((line) => line.startsWith(REFUSED));
57
+ ended(refused?.slice(REFUSED.length) ?? lines.at(-1) ?? `the placement ended with status ${status ?? 'a signal'}`);
58
+ });
59
+ });
35
60
  }
36
- async function pendingInput() {
61
+ async function placed(prefix, admit) {
62
+ const signal = AbortSignal.timeout(PLACEMENT_MS);
63
+ let version = '';
37
64
  try {
38
- return JSON.parse(await readFile(pending(), 'utf8')).input_id;
65
+ const placedIn = prefix();
66
+ const served = await servedRelease(signal);
67
+ admit(served.version);
68
+ version = served.version;
69
+ await mkdir(join(kitHome(), 'update'), { recursive: true, mode: 0o700 });
70
+ const installer = join(kitHome(), 'update', served.installer);
71
+ await downloadServed(served.installer, served.sha256, installer, signal, INSTALLER_BYTES);
72
+ return { version, failure: await placing(installer, (await readEnrolment()).house, placedIn, signal) };
39
73
  }
40
- catch {
41
- return null;
74
+ catch (error) {
75
+ return { version, failure: signal.aborted ? `the placement did not end within ${PLACEMENT_MS / 1000} seconds` : causeOf(error) };
42
76
  }
43
77
  }
44
- async function recorded() {
45
- const status = await readFile(outcome(), 'utf8').catch(() => null);
46
- if (status === null)
47
- return null;
48
- return status.trim() === '0' ? {} : { refused: `the Kit bootstrap exited with ${status.trim()}` };
49
- }
50
- async function forget(inputId) {
51
- if ((await pendingInput()) !== inputId)
52
- return;
53
- await rm(pending(), { force: true });
54
- await rm(outcome(), { force: true });
78
+ export async function placeServedRelease(prefix) {
79
+ const { version, failure } = await placed(() => prefix, () => undefined);
80
+ return failure === null ? null : `${version === '' ? "The Building's Kit release" : `Kit ${version}`} could not be placed: ${failure}`;
55
81
  }
56
- async function finished(inputId) {
57
- for (;;) {
58
- const ack = await recorded();
59
- if (ack !== null)
60
- return ack;
61
- // systemctl answers at once, so ten seconds only bounds a stuck service manager.
62
- if ((await run('systemctl', [...manager(), 'is-active', '--quiet', unit(inputId)], 10_000)).status !== 0) {
63
- return (await recorded()) ?? { refused: 'the Kit bootstrap did not finish' };
82
+ export class KitUpdate {
83
+ calls;
84
+ queue = Promise.resolve();
85
+ placed = null;
86
+ constructor(calls) {
87
+ this.calls = calls;
88
+ }
89
+ take(call) {
90
+ void this.calls.carry(call.input_id, async () => ({ result: await this.queued(() => this.update(call.release)) }));
91
+ }
92
+ async takeRefused(release) {
93
+ for (;;) {
94
+ const failure = await this.queued(async () => (this.placed === null ? this.place(release, 'served') : null));
95
+ if (failure === null)
96
+ restartPlaced(this.placed);
97
+ process.stderr.write(`kit: ${updateLine(`Kit ${KIT_RELEASE} stays offline and tries again in ${PLACEMENT_RETRY_MS / 60_000} minutes`)}\n`);
98
+ await new Promise((resolve) => setTimeout(resolve, PLACEMENT_RETRY_MS));
64
99
  }
65
- // The bootstrap runs for minutes, so checking each second sees its outcome within a second at little cost.
66
- await new Promise((resolve) => setTimeout(resolve, 1000));
67
100
  }
68
- }
69
- function rerun(script, inputId, flags) {
70
- return new Promise((resolve) => {
71
- const [command, ...args] = [
72
- ...elevated(),
73
- 'systemd-run',
74
- ...manager(),
75
- ...account(),
76
- '--wait',
77
- '--collect',
78
- '--quiet',
79
- `--unit=${unit(inputId)}`,
80
- `--setenv=HOME=${homedir()}`,
81
- `--setenv=HOUSE_KIT_HOME=${kitHome()}`,
82
- '/bin/sh',
83
- '-c',
84
- record(),
85
- script,
86
- outcome(),
87
- ...placement(),
88
- ...flags,
89
- ];
90
- const child = spawn(command, args, { stdio: ['ignore', 'ignore', 'inherit'] });
91
- child.on('error', () => resolve({ refused: 'no service manager runs this Kit' }));
92
- child.on('close', () => resolve(null));
93
- });
94
- }
95
- export class Updates {
96
- inputs;
97
- queue = Promise.resolve();
98
- constructor(inputs) {
99
- this.inputs = inputs;
101
+ placedRelease() {
102
+ return this.placed;
100
103
  }
101
- async resumed() {
102
- const inputId = await pendingInput();
103
- if (inputId === null)
104
- return;
105
- await this.enqueue(inputId, () => finished(inputId));
104
+ queued(work) {
105
+ const taken = this.queue.then(work);
106
+ this.queue = taken.catch(() => undefined);
107
+ return taken;
106
108
  }
107
- start(input) {
108
- void this.enqueue(input.input_id, () => this.carry(input));
109
+ async update(release) {
110
+ if (release === (this.placed ?? KIT_RELEASE))
111
+ return {};
112
+ if (this.placed !== null)
113
+ return { refused: `Kit ${this.placed} is placed and starts first, once no turn is open` };
114
+ const failure = await this.place(release, 'named');
115
+ if (failure !== null)
116
+ return { refused: failure };
117
+ const starts = process.env.HOUSE_KIT_SANDBOX === '1' ? 'when the Sandbox starts again' : 'once no turn is open';
118
+ process.stderr.write(`kit: Kit ${release} is placed; it starts ${starts}\n`);
119
+ return {};
109
120
  }
110
- enqueue(inputId, work) {
111
- const before = this.queue;
112
- const carried = this.inputs.carry(inputId, async () => {
113
- await before;
114
- return { ack: await work(), acknowledged: () => forget(inputId) };
121
+ async place(release, which) {
122
+ const { version, failure } = await placed(placedPrefix, (served) => {
123
+ if (which === 'named' && served !== release)
124
+ throw new Error(`the Building serves Kit ${served}, not Kit ${release}`);
125
+ if (served === KIT_RELEASE)
126
+ throw new Error(`the Building serves Kit ${KIT_RELEASE}, which this Kit runs`);
115
127
  });
116
- this.queue = before.then(() => carried);
117
- return carried;
118
- }
119
- async carry(input) {
120
- if ((await pendingInput()) === input.input_id)
121
- return finished(input.input_id);
122
- const answer = await fetch(input.bootstrap);
123
- if (!answer.ok)
124
- return { refused: `the Kit bootstrap could not be downloaded: ${answer.status}` };
125
- const script = Buffer.from(await answer.arrayBuffer());
126
- if (createHash('sha256').update(script).digest('hex') !== input.sha256) {
127
- return { refused: 'the Kit bootstrap does not match its sha256' };
128
+ if (failure !== null) {
129
+ const refused = `Kit ${version || release} could not be placed: ${failure}`;
130
+ process.stderr.write(`kit: ${refused}\n`);
131
+ return refused;
128
132
  }
129
- await mkdir(directory(), { recursive: true, mode: 0o700 });
130
- const path = join(directory(), 'connect-linux.sh');
131
- await writeFile(path, script, { mode: 0o700 });
132
- await rm(outcome(), { force: true });
133
- await writeFile(pending(), `${JSON.stringify({ input_id: input.input_id })}\n`, { mode: 0o600 });
134
- return (await rerun(path, input.input_id, input.update_clis ? ['--update-clis'] : [])) ?? (await recorded()) ?? {
135
- refused: 'the Kit bootstrap did not finish',
136
- };
133
+ this.placed = version;
134
+ return null;
137
135
  }
138
136
  }
package/dist/wire.js CHANGED
@@ -1,6 +1,32 @@
1
+ import { updateRequired } from './end.js';
1
2
  import { refusalOf } from './refusals.js';
2
- export const KIT_WIRE = 2;
3
- export const KIT_WIRE_HEADER = 'x-house-kit-wire';
4
- export function tooOld(text) {
5
- return refusalOf(text)?.code === 'kit_update_required';
3
+ let take = null;
4
+ let taken = false;
5
+ function unservedBy(text) {
6
+ let body;
7
+ try {
8
+ body = JSON.parse(text);
9
+ }
10
+ catch {
11
+ return null;
12
+ }
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;
20
+ }
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
+ }
30
+ if (refusalOf(text)?.code === 'kit_update_required')
31
+ updateRequired();
6
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,7 +1,7 @@
1
1
  {
2
2
  "name": "@agentshouse/kit",
3
- "version": "0.2.1-ccf188e02985d",
4
- "description": "House Kit connects an Environment to agents.house.",
3
+ "version": "0.2.1-ccffb3f637815",
4
+ "description": "Kit connects an Environment to agents.house.",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -12,28 +12,31 @@
12
12
  "kit": "dist/kit-main.js",
13
13
  "house": "dist/house-main.js"
14
14
  },
15
- "exports": {
16
- "./bootstrap": "./dist/bootstrap.json"
17
- },
18
15
  "files": [
19
- "dist",
20
- "how-we-work.md",
21
- "skills"
16
+ "dist"
22
17
  ],
23
18
  "scripts": {
24
- "build": "tsc -p tsconfig.build.json && node scripts/bootstrap-manifest.mjs",
19
+ "bootstrap-manifest": "node scripts/bootstrap-manifest.mjs",
20
+ "build": "tsc -p tsconfig.build.json",
25
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",
26
- "sync-skills": "node scripts/sync-skills.mjs",
22
+ "follow-skills-and-kit-wire": "node scripts/follow-skills-and-kit-wire.mjs",
23
+ "release-files": "node scripts/release-files.mjs",
27
24
  "test": "tsc -p tsconfig.json && vitest run"
28
25
  },
29
26
  "dependencies": {
30
- "@agentclientprotocol/sdk": "1.7.0",
31
- "@agentshouse/mdmodel": "0.1.0-c68e2039f1ca8",
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",
32
+ "@lydell/node-pty": "1.2.0-beta.15",
33
+ "micromark": "4.0.2",
34
+ "smol-toml": "1.9.1",
32
35
  "yaml": "2.9.1"
33
36
  },
34
37
  "peerDependencies": {
35
- "@agentclientprotocol/claude-agent-acp": "0.85.1",
36
- "@agentclientprotocol/codex-acp": "2.1.1"
38
+ "@agentclientprotocol/claude-agent-acp": "0.100.0",
39
+ "@agentclientprotocol/codex-acp": "2.5.0"
37
40
  },
38
41
  "peerDependenciesMeta": {
39
42
  "@agentclientprotocol/claude-agent-acp": {
@@ -44,26 +47,27 @@
44
47
  }
45
48
  },
46
49
  "devDependencies": {
47
- "@types/node": "24.13.6",
50
+ "@types/node": "24.19.2",
48
51
  "@types/ws": "8.18.2",
49
52
  "typescript": "7.0.2",
50
- "vitest": "5.0.1",
51
- "ws": "8.22.0"
53
+ "vitest": "5.0.5",
54
+ "ws": "8.22.0",
55
+ "zod": "4.6.7"
52
56
  },
53
- "packageManager": "npm@11.19.0",
57
+ "packageManager": "npm@11.19.1",
54
58
  "engines": {
55
- "node": "24.21.0",
56
- "npm": "11.19.0"
59
+ "node": "24.22.1",
60
+ "npm": "11.19.1"
57
61
  },
58
62
  "devEngines": {
59
63
  "runtime": {
60
64
  "name": "node",
61
- "version": "24.21.0",
65
+ "version": "24.22.1",
62
66
  "onFail": "error"
63
67
  },
64
68
  "packageManager": {
65
69
  "name": "npm",
66
- "version": "11.19.0",
70
+ "version": "11.19.1",
67
71
  "onFail": "error"
68
72
  }
69
73
  }
@@ -1,22 +0,0 @@
1
- import { setGlobalProxyFromEnv } from 'node:http';
2
- import { HouseRefusal, post } from './api.js';
3
- import { readEnrolment } from './home.js';
4
- function unanswered(error) {
5
- return error instanceof HouseRefusal ? error.status >= 500 : error instanceof TypeError && error.message === 'fetch failed';
6
- }
7
- setGlobalProxyFromEnv();
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
- }
@@ -1,24 +0,0 @@
1
- {
2
- "schemaVersion": 2,
3
- "version": "0.2.1-ccf188e02985d",
4
- "hosts": {
5
- "macos": {
6
- "asset": {
7
- "name": "connect-linux.sh",
8
- "url": "https://github.com/agentshouse/kit/releases/download/v0.2.1-ccf188e02985d/connect-linux.sh"
9
- }
10
- },
11
- "linux": {
12
- "asset": {
13
- "name": "connect-linux.sh",
14
- "url": "https://github.com/agentshouse/kit/releases/download/v0.2.1-ccf188e02985d/connect-linux.sh"
15
- }
16
- },
17
- "windows": {
18
- "asset": {
19
- "name": "connect-windows.ps1",
20
- "url": "https://github.com/agentshouse/kit/releases/download/v0.2.1-ccf188e02985d/connect-windows.ps1"
21
- }
22
- }
23
- }
24
- }
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
- }