@agentshouse/kit 0.2.1-ca18b01951c3b → 0.2.1-ca1f38641026d

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 (143) hide show
  1. package/README.md +31 -31
  2. package/dist/acp.js +90 -19
  3. package/dist/agents.js +61 -37
  4. package/dist/api.js +5 -5
  5. package/dist/app-git.js +10 -26
  6. package/dist/authority-main.js +2 -2
  7. package/dist/bridge.js +4 -7
  8. package/dist/building.js +46 -0
  9. package/dist/calls.js +71 -0
  10. package/dist/chatgpt.js +4 -1
  11. package/dist/clis-main.js +2 -2
  12. package/dist/clis.js +52 -16
  13. package/dist/{stream.js → connection.js} +45 -52
  14. package/dist/conversations.js +516 -175
  15. package/dist/copies.js +77 -50
  16. package/dist/end.js +15 -4
  17. package/dist/events.js +33 -8
  18. package/dist/files.js +139 -37
  19. package/dist/git.js +5 -6
  20. package/dist/home.js +27 -13
  21. package/dist/house-cli.js +299 -0
  22. package/dist/house-main.js +7 -289
  23. package/dist/instructions.js +29 -8
  24. package/dist/kit-cli.js +68 -0
  25. package/dist/kit-main.js +8 -67
  26. package/dist/login.js +18 -9
  27. package/dist/logout.js +0 -2
  28. package/dist/mcp.js +6 -2
  29. package/dist/placement.js +9 -18
  30. package/dist/relay.js +21 -0
  31. package/dist/resident.js +95 -39
  32. package/dist/scope.js +3 -0
  33. package/dist/scripts.js +255 -0
  34. package/dist/service.js +23 -1
  35. package/dist/sign-in.js +22 -39
  36. package/dist/silence.js +28 -0
  37. package/dist/skills.js +42 -97
  38. package/dist/transcription.js +83 -43
  39. package/dist/translate.js +2 -8
  40. package/dist/update.js +89 -49
  41. package/dist/wire.js +19 -3
  42. package/dist/work.js +3 -5
  43. package/package.json +20 -21
  44. package/dist/bootstrap.json +0 -24
  45. package/how-we-work.md +0 -33
  46. package/skills/ask-matt/LICENSE +0 -21
  47. package/skills/ask-matt/PHASE-BOUNDARIES.md +0 -55
  48. package/skills/ask-matt/SKILL.md +0 -97
  49. package/skills/ask-matt/agents/openai.yaml +0 -5
  50. package/skills/code-review/LICENSE +0 -21
  51. package/skills/code-review/SKILL.md +0 -89
  52. package/skills/code-review/agents/openai.yaml +0 -3
  53. package/skills/codebase-design/DEEPENING.md +0 -37
  54. package/skills/codebase-design/DESIGN-IT-TWICE.md +0 -44
  55. package/skills/codebase-design/LICENSE +0 -21
  56. package/skills/codebase-design/SKILL.md +0 -114
  57. package/skills/codebase-design/agents/openai.yaml +0 -3
  58. package/skills/diagnosing-bugs/LICENSE +0 -21
  59. package/skills/diagnosing-bugs/SKILL.md +0 -138
  60. package/skills/diagnosing-bugs/agents/openai.yaml +0 -3
  61. package/skills/diagnosing-bugs/scripts/hitl-loop.template.sh +0 -44
  62. package/skills/domain-modeling/ADR-FORMAT.md +0 -47
  63. package/skills/domain-modeling/GLOSSARY-FORMAT.md +0 -60
  64. package/skills/domain-modeling/LICENSE +0 -21
  65. package/skills/domain-modeling/SKILL.md +0 -74
  66. package/skills/domain-modeling/agents/openai.yaml +0 -3
  67. package/skills/grill-me/LICENSE +0 -21
  68. package/skills/grill-me/SKILL.md +0 -7
  69. package/skills/grill-me/agents/openai.yaml +0 -5
  70. package/skills/grill-with-docs/LICENSE +0 -21
  71. package/skills/grill-with-docs/SKILL.md +0 -7
  72. package/skills/grill-with-docs/agents/openai.yaml +0 -5
  73. package/skills/grilling/LICENSE +0 -21
  74. package/skills/grilling/SKILL.md +0 -30
  75. package/skills/grilling/agents/openai.yaml +0 -3
  76. package/skills/handoff/LICENSE +0 -21
  77. package/skills/handoff/SKILL.md +0 -16
  78. package/skills/handoff/agents/openai.yaml +0 -5
  79. package/skills/implement/LICENSE +0 -21
  80. package/skills/implement/SKILL.md +0 -17
  81. package/skills/implement/agents/openai.yaml +0 -5
  82. package/skills/implement-spec/LICENSE +0 -21
  83. package/skills/implement-spec/SKILL.md +0 -40
  84. package/skills/implement-spec/agents/openai.yaml +0 -5
  85. package/skills/improve-codebase-architecture/HTML-REPORT.md +0 -123
  86. package/skills/improve-codebase-architecture/LICENSE +0 -21
  87. package/skills/improve-codebase-architecture/SKILL.md +0 -71
  88. package/skills/improve-codebase-architecture/agents/openai.yaml +0 -5
  89. package/skills/pr/CREDITS.md +0 -3
  90. package/skills/pr/LICENSE +0 -21
  91. package/skills/pr/SKILL.md +0 -170
  92. package/skills/pr/agents/openai.yaml +0 -3
  93. package/skills/prototype/LICENSE +0 -21
  94. package/skills/prototype/LOGIC.md +0 -67
  95. package/skills/prototype/SKILL.md +0 -26
  96. package/skills/prototype/UI.md +0 -112
  97. package/skills/prototype/agents/openai.yaml +0 -3
  98. package/skills/research/LICENSE +0 -21
  99. package/skills/research/SKILL.md +0 -12
  100. package/skills/research/agents/openai.yaml +0 -3
  101. package/skills/retro/LICENSE +0 -21
  102. package/skills/retro/SKILL.md +0 -44
  103. package/skills/retro/agents/openai.yaml +0 -5
  104. package/skills/tdd/LICENSE +0 -21
  105. package/skills/tdd/SKILL.md +0 -38
  106. package/skills/tdd/agents/openai.yaml +0 -3
  107. package/skills/tdd/mocking.md +0 -59
  108. package/skills/tdd/tests.md +0 -77
  109. package/skills/teach/GLOSSARY-FORMAT.md +0 -35
  110. package/skills/teach/LEARNING-RECORD-FORMAT.md +0 -46
  111. package/skills/teach/LICENSE +0 -21
  112. package/skills/teach/MISSION-FORMAT.md +0 -31
  113. package/skills/teach/RESOURCES-FORMAT.md +0 -32
  114. package/skills/teach/SKILL.md +0 -140
  115. package/skills/teach/agents/openai.yaml +0 -5
  116. package/skills/to-questionnaire/LICENSE +0 -21
  117. package/skills/to-questionnaire/SKILL.md +0 -54
  118. package/skills/to-questionnaire/agents/openai.yaml +0 -5
  119. package/skills/to-spec/LICENSE +0 -21
  120. package/skills/to-spec/SKILL.md +0 -75
  121. package/skills/to-spec/agents/openai.yaml +0 -5
  122. package/skills/to-tickets/LICENSE +0 -21
  123. package/skills/to-tickets/SKILL.md +0 -105
  124. package/skills/to-tickets/agents/openai.yaml +0 -5
  125. package/skills/triage/AGENT-BRIEF.md +0 -207
  126. package/skills/triage/LICENSE +0 -21
  127. package/skills/triage/OUT-OF-SCOPE.md +0 -105
  128. package/skills/triage/SKILL.md +0 -112
  129. package/skills/triage/agents/openai.yaml +0 -5
  130. package/skills/wait-what/LICENSE +0 -21
  131. package/skills/wait-what/SKILL.md +0 -7
  132. package/skills/wait-what/agents/openai.yaml +0 -5
  133. package/skills/wayfinder/LICENSE +0 -21
  134. package/skills/wayfinder/SKILL.md +0 -128
  135. package/skills/wayfinder/agents/openai.yaml +0 -5
  136. package/skills/wizard/LICENSE +0 -21
  137. package/skills/wizard/SKILL.md +0 -44
  138. package/skills/wizard/agents/openai.yaml +0 -3
  139. package/skills/wizard/template.sh +0 -223
  140. package/skills/writing-for-agents/LICENSE +0 -21
  141. package/skills/writing-for-agents/SKILL-MECHANICS.md +0 -22
  142. package/skills/writing-for-agents/SKILL.md +0 -81
  143. package/skills/writing-for-agents/agents/openai.yaml +0 -3
@@ -1,33 +1,39 @@
1
- import { createHash } from 'node:crypto';
2
- import { createReadStream } from 'node:fs';
3
1
  import { chmod, mkdir, mkdtemp, readdir, readFile, rename, rm, stat } from 'node:fs/promises';
4
2
  import { availableParallelism, tmpdir } from 'node:os';
5
3
  import { basename, join } from 'node:path';
6
- import { pipeline } from 'node:stream/promises';
7
4
  import { unlessAborted } from './abort.js';
5
+ import { downloadServed } from './building.js';
8
6
  import { failureOf, run } from './clis.js';
7
+ import { downloaded, fetched } from './files.js';
9
8
  import { kitHome } from './home.js';
10
9
  const RELEASE = 'https://github.com/agentshouse/kit/releases/download/engine-2';
11
10
  export const MODEL = {
12
- url: 'https://huggingface.co/ggml-org/parakeet-GGUF/resolve/35156454d1a39de06863303dd209fd2bed6ee079/ggml-parakeet-tdt-0.6b-v3-q4_k.bin',
11
+ name: 'ggml-parakeet-tdt-0.6b-v3-q4_k.bin',
12
+ from: 'https://huggingface.co/ggml-org/parakeet-GGUF/resolve/35156454d1a39de06863303dd209fd2bed6ee079/ggml-parakeet-tdt-0.6b-v3-q4_k.bin',
13
13
  sha256: '8b205b8b39c6535e153de6fb11c51db46125d45c4f16ba496fe41a0fe71b885e',
14
+ bytes: 415_611_879,
14
15
  executable: false,
15
16
  };
16
17
  export const ENGINES = {
17
18
  'linux-x64': {
18
- decoder: { url: `${RELEASE}/ffmpeg-linux-x86_64`, sha256: '1f8235d206428305afb89c6e8ab99d100425a0ba61e22bb4c7aff017db8c8de5', executable: true },
19
- engine: { url: `${RELEASE}/parakeet-cli-linux-x86_64`, sha256: 'bb2585695992fe1927a33960002cdf51b8a90a96ad65593c3d0a9f1fbc0865c2', executable: true },
19
+ decoder: { name: 'ffmpeg-linux-x86_64', from: `${RELEASE}/ffmpeg-linux-x86_64`, sha256: '1f8235d206428305afb89c6e8ab99d100425a0ba61e22bb4c7aff017db8c8de5', bytes: 5_175_832, executable: true },
20
+ engine: { name: 'parakeet-cli-linux-x86_64', from: `${RELEASE}/parakeet-cli-linux-x86_64`, sha256: 'bb2585695992fe1927a33960002cdf51b8a90a96ad65593c3d0a9f1fbc0865c2', bytes: 3_801_616, executable: true },
20
21
  },
21
22
  'linux-arm64': {
22
- decoder: { url: `${RELEASE}/ffmpeg-linux-aarch64`, sha256: 'a7e08a0fae0179d1078312f6bb13d2a9aa4d4c71a1d82a022953f25dee452f5e', executable: true },
23
- engine: { url: `${RELEASE}/parakeet-cli-linux-aarch64`, sha256: 'cbc0bedc8daae97f1ef9dcee4200c06226218e300e0fd62ead1306d22742b7ed', executable: true },
23
+ decoder: { name: 'ffmpeg-linux-aarch64', from: `${RELEASE}/ffmpeg-linux-aarch64`, sha256: 'a7e08a0fae0179d1078312f6bb13d2a9aa4d4c71a1d82a022953f25dee452f5e', bytes: 4_590_208, executable: true },
24
+ engine: { name: 'parakeet-cli-linux-aarch64', from: `${RELEASE}/parakeet-cli-linux-aarch64`, sha256: 'cbc0bedc8daae97f1ef9dcee4200c06226218e300e0fd62ead1306d22742b7ed', bytes: 3_477_624, executable: true },
24
25
  },
25
26
  'darwin-arm64': {
26
- decoder: { url: `${RELEASE}/ffmpeg-darwin-arm64`, sha256: '7abe154aaed3d6b49f5167ca7221bb66bed51388925d99a7e4261a41fe52fba6', executable: true },
27
- engine: { url: `${RELEASE}/parakeet-cli-darwin-arm64`, sha256: '9a2aafc0922ad7c0b6db6eff1641e96572ba32ac40bf995a1df242ed2febf297', executable: true },
27
+ decoder: { name: 'ffmpeg-darwin-arm64', from: `${RELEASE}/ffmpeg-darwin-arm64`, sha256: '7abe154aaed3d6b49f5167ca7221bb66bed51388925d99a7e4261a41fe52fba6', bytes: 3_696_768, executable: true },
28
+ engine: { name: 'parakeet-cli-darwin-arm64', from: `${RELEASE}/parakeet-cli-darwin-arm64`, sha256: '9a2aafc0922ad7c0b6db6eff1641e96572ba32ac40bf995a1df242ed2febf297', bytes: 1_939_728, executable: true },
28
29
  },
29
30
  };
30
31
  const CHUNK_SECONDS = 20;
32
+ const OFF = "transcription is off on the Agent's Environment, so this message's audio has no text; turn it on or write instead";
33
+ const NOT_INSTALLED = "the speech engine is not installed on the Agent's Environment, so this message's audio has no text";
34
+ const NOT_DOWNLOADED = 'an audio file this message links could not be downloaded; send the message again';
35
+ const UNDECODABLE = 'an audio file this message links could not be decoded';
36
+ const UNTRANSCRIBED = 'an audio file this message links could not be transcribed';
31
37
  let held = Promise.resolve();
32
38
  let holding = Promise.resolve();
33
39
  let setting = null;
@@ -40,7 +46,7 @@ function installed(artifact) {
40
46
  return join(directory(), artifact.sha256);
41
47
  }
42
48
  async function executed(command, args, signal) {
43
- // A download or a transcription runs as long as its size needs; the setting turning off or the turn's interrupt or end aborts it instead.
49
+ // A decode or a transcription runs as long as its audio needs; the setting turning off or the turn's interrupt or end aborts it instead.
44
50
  const ran = await run(command, args, 0, false, signal);
45
51
  if (ran.status !== 0)
46
52
  throw new Error(failureOf(ran, basename(command)));
@@ -54,17 +60,45 @@ async function threads() {
54
60
  const allowed = quota === 'max' ? Infinity : Math.ceil(Number(quota) / Number(period));
55
61
  return Math.max(1, Math.floor(Math.min(availableParallelism(), allowed) / 2));
56
62
  }
57
- async function sha256(path) {
58
- const hash = createHash('sha256');
59
- await pipeline(createReadStream(path), hash);
60
- return hash.digest('hex');
61
- }
62
63
  function causeOf(error) {
63
64
  return error instanceof Error ? error.message : String(error);
64
65
  }
66
+ async function failing(reason, work) {
67
+ try {
68
+ return await work;
69
+ }
70
+ catch (error) {
71
+ throw new Error(reason, { cause: error });
72
+ }
73
+ }
74
+ function ready() {
75
+ if (setting !== true)
76
+ throw new Error(OFF);
77
+ if (!readiness.installed)
78
+ throw new Error(NOT_INSTALLED);
79
+ }
65
80
  function pinnedHere() {
66
81
  return ENGINES[`${process.platform}-${process.arch}`];
67
82
  }
83
+ const DOWNLOADS = 3;
84
+ async function downloadedAgain(artifact, signal) {
85
+ // An artifact arrives at a hundred kilobytes a second or its download ends, so a stalled Building cannot hold the install open.
86
+ const deadlineMs = Math.ceil(artifact.bytes / 100);
87
+ const deadline = AbortSignal.timeout(deadlineMs);
88
+ for (let attempt = 1;; attempt++) {
89
+ try {
90
+ return await downloadServed(artifact.name, artifact.sha256, `${installed(artifact)}.part`, AbortSignal.any([signal, deadline]), artifact.bytes);
91
+ }
92
+ catch (error) {
93
+ if (signal.aborted)
94
+ throw error;
95
+ if (deadline.aborted)
96
+ throw new Error(`${artifact.name} did not arrive within ${Math.ceil(deadlineMs / 1000)} seconds`);
97
+ if (attempt === DOWNLOADS)
98
+ throw error;
99
+ }
100
+ }
101
+ }
68
102
  async function install(artifacts, signal) {
69
103
  await mkdir(directory(), { recursive: true });
70
104
  const pinned = new Set(artifacts.map((artifact) => artifact.sha256));
@@ -77,13 +111,8 @@ async function install(artifacts, signal) {
77
111
  if (!(await present(installed(artifact))))
78
112
  missing.push(artifact);
79
113
  try {
80
- for (const artifact of missing) {
81
- const part = `${installed(artifact)}.part`;
82
- // Three retries carry a large download past a dropped connection before the download fails.
83
- await executed('curl', ['-fsSL', '--retry', '3', '-o', part, artifact.url], signal);
84
- if ((await sha256(part)) !== artifact.sha256)
85
- throw new Error(`${artifact.url} does not match its sha256`);
86
- }
114
+ for (const artifact of missing)
115
+ await downloadedAgain(artifact, signal);
87
116
  for (const artifact of missing) {
88
117
  if (artifact.executable)
89
118
  await chmod(`${installed(artifact)}.part`, 0o755);
@@ -133,27 +162,23 @@ export function holdTranscription(transcribe) {
133
162
  export function transcriptionReport() {
134
163
  return readiness;
135
164
  }
136
- async function transcribed(path, signal) {
165
+ async function transcribed(audio, parts, signal) {
137
166
  const pinned = pinnedHere();
138
- const work = await mkdtemp(join(tmpdir(), 'kit-transcription-'));
139
- try {
140
- await executed(installed(pinned.decoder), ['-nostdin', '-hide_banner', '-loglevel', 'error', '-i', path, '-ar', '16000', '-ac', '1', '-c:a', 'pcm_s16le',
141
- '-f', 'segment', '-segment_time', String(CHUNK_SECONDS), join(work, '%05d.wav')], signal);
142
- const parts = (await readdir(work)).sort().flatMap((part) => ['-f', join(work, part)]);
143
- const text = await executed(installed(pinned.engine), ['-t', String(await threads()), '-np', '-m', installed(MODEL), ...parts], signal);
144
- return text
145
- .split('\n')
146
- .map((line) => line.trim())
147
- .filter((line) => line !== '')
148
- .join(' ');
149
- }
150
- finally {
151
- await rm(work, { recursive: true, force: true });
152
- }
167
+ await mkdir(parts);
168
+ await failing(UNDECODABLE, executed(installed(pinned.decoder), ['-nostdin', '-hide_banner', '-loglevel', 'error', '-i', audio, '-ar', '16000', '-ac', '1', '-c:a', 'pcm_s16le',
169
+ '-f', 'segment', '-segment_time', String(CHUNK_SECONDS), join(parts, '%05d.wav')], signal));
170
+ const segments = (await readdir(parts)).sort().flatMap((part) => ['-f', join(parts, part)]);
171
+ const said = await failing(UNTRANSCRIBED, executed(installed(pinned.engine), ['-t', String(await threads()), '-np', '-m', installed(MODEL), ...segments], signal));
172
+ const text = said
173
+ .split('\n')
174
+ .map((line) => line.trim())
175
+ .filter((line) => line !== '')
176
+ .join(' ');
177
+ if (text === '')
178
+ throw new Error(UNTRANSCRIBED);
179
+ return text;
153
180
  }
154
- export async function transcribe(path, signal) {
155
- if (!readiness.installed)
156
- return null;
181
+ async function alone(work, signal) {
157
182
  const before = held;
158
183
  let release;
159
184
  const mine = new Promise((resolve) => {
@@ -162,9 +187,24 @@ export async function transcribe(path, signal) {
162
187
  held = Promise.all([before, mine]);
163
188
  try {
164
189
  await unlessAborted(before, signal);
165
- return readiness.installed ? await transcribed(path, signal) : null;
190
+ return await work();
166
191
  }
167
192
  finally {
168
193
  release();
169
194
  }
170
195
  }
196
+ export async function transcribe(address, signal) {
197
+ ready();
198
+ const work = await mkdtemp(join(tmpdir(), 'kit-transcription-'));
199
+ try {
200
+ const audio = join(work, 'audio');
201
+ await failing(NOT_DOWNLOADED, downloaded(address, (url) => fetched(url, signal), audio, 'audio'));
202
+ return await alone(() => {
203
+ ready();
204
+ return transcribed(audio, join(work, 'parts'), signal);
205
+ }, signal);
206
+ }
207
+ finally {
208
+ await rm(work, { recursive: true, force: true });
209
+ }
210
+ }
package/dist/translate.js CHANGED
@@ -3,14 +3,8 @@ function same(left, right) {
3
3
  return JSON.stringify(left) === JSON.stringify(right);
4
4
  }
5
5
  function applied(document, changes) {
6
- let current = document;
7
- for (const change of changes) {
8
- const result = apply(current, change);
9
- if (result.outcome !== 'applied')
10
- return null;
11
- current = result.document;
12
- }
13
- return serialize(current);
6
+ const result = apply(document, changes);
7
+ return result.outcome === 'applied' ? serialize(result.document) : null;
14
8
  }
15
9
  function components(path, before, after, text) {
16
10
  const edits = [];
package/dist/update.js CHANGED
@@ -6,9 +6,13 @@ import { join } from 'node:path';
6
6
  import { run } from './clis.js';
7
7
  import { kitHome, workspaceRoot } from './home.js';
8
8
  import { service, throughSudo } from './placement.js';
9
- function logged(error) {
10
- process.stderr.write(`kit: ${error instanceof Error ? error.message : String(error)}\n`);
11
- }
9
+ import { relayed } from './relay.js';
10
+ const BOOTSTRAP_BYTES = 1_000_000;
11
+ // A bootstrap is at most a million bytes, so two minutes carry it over ten kilobytes a second and no stalled host holds the update queue.
12
+ const BOOTSTRAP_MS = 120_000;
13
+ // A bootstrap's downloads and CLI updates take minutes, so one still running after an hour has hung and is ended before it keeps the Kit offline.
14
+ const RERUN_MS = 60 * 60_000;
15
+ const TIMED_OUT = '124';
12
16
  function directory() {
13
17
  return join(kitHome(), 'update');
14
18
  }
@@ -18,8 +22,8 @@ function pending() {
18
22
  function outcome() {
19
23
  return join(directory(), 'outcome');
20
24
  }
21
- function unit(inputId) {
22
- return `house-kit-update-${inputId}`;
25
+ function unit(callId) {
26
+ return `house-kit-update-${callId}`;
23
27
  }
24
28
  function manager() {
25
29
  return service() === 'user' ? ['--user'] : [];
@@ -34,9 +38,9 @@ function placement() {
34
38
  return service() === 'user' ? ['--workspace', workspaceRoot()] : ['--linux'];
35
39
  }
36
40
  function record() {
37
- return `outcome=$1; shift; bash "$0" "$@"; printf %s "$?" > "$outcome"; ${[...elevated(), 'systemctl', ...manager(), 'start', 'house-kit.service'].join(' ')}`;
41
+ return `outcome=$1; shift; timeout ${RERUN_MS / 1000} bash "$0" "$@"; printf %s "$?" > "$outcome"; ${[...elevated(), 'systemctl', ...manager(), 'start', 'house-kit.service'].join(' ')}`;
38
42
  }
39
- async function pendingInput() {
43
+ async function pendingCall() {
40
44
  try {
41
45
  return JSON.parse(await readFile(pending(), 'utf8')).input_id;
42
46
  }
@@ -48,22 +52,41 @@ async function recorded() {
48
52
  const status = await readFile(outcome(), 'utf8').catch(() => null);
49
53
  if (status === null)
50
54
  return null;
55
+ if (status.trim() === TIMED_OUT)
56
+ return { refused: `the Kit bootstrap did not finish within ${RERUN_MS / 1000} seconds` };
51
57
  return status.trim() === '0' ? {} : { refused: `the Kit bootstrap exited with ${status.trim()}` };
52
58
  }
53
- async function finished(inputId) {
59
+ async function forget(callId) {
60
+ if ((await pendingCall()) !== callId)
61
+ return;
62
+ await rm(pending(), { force: true });
63
+ await rm(outcome(), { force: true });
64
+ }
65
+ async function finished(callId) {
54
66
  for (;;) {
55
- const ack = await recorded();
56
- if (ack !== null)
57
- return ack;
67
+ const result = await recorded();
68
+ if (result !== null)
69
+ return result;
58
70
  // systemctl answers at once, so ten seconds only bounds a stuck service manager.
59
- if ((await run('systemctl', [...manager(), 'is-active', '--quiet', unit(inputId)], 10_000)).status !== 0) {
71
+ if ((await run('systemctl', [...manager(), 'is-active', '--quiet', unit(callId)], 10_000)).status !== 0) {
60
72
  return (await recorded()) ?? { refused: 'the Kit bootstrap did not finish' };
61
73
  }
62
74
  // The bootstrap runs for minutes, so checking each second sees its outcome within a second at little cost.
63
75
  await new Promise((resolve) => setTimeout(resolve, 1000));
64
76
  }
65
77
  }
66
- function rerun(script, inputId, flags) {
78
+ async function bounded(body, most) {
79
+ const chunks = [];
80
+ let bytes = 0;
81
+ for await (const chunk of body ?? []) {
82
+ bytes += chunk.length;
83
+ if (bytes > most)
84
+ return null;
85
+ chunks.push(chunk);
86
+ }
87
+ return Buffer.concat(chunks, bytes);
88
+ }
89
+ function rerun(script, callId, flags) {
67
90
  return new Promise((resolve) => {
68
91
  const [command, ...args] = [
69
92
  ...elevated(),
@@ -73,7 +96,7 @@ function rerun(script, inputId, flags) {
73
96
  '--wait',
74
97
  '--collect',
75
98
  '--quiet',
76
- `--unit=${unit(inputId)}`,
99
+ `--unit=${unit(callId)}`,
77
100
  `--setenv=HOME=${homedir()}`,
78
101
  `--setenv=HOUSE_KIT_HOME=${kitHome()}`,
79
102
  '/bin/sh',
@@ -85,57 +108,74 @@ function rerun(script, inputId, flags) {
85
108
  ...flags,
86
109
  ];
87
110
  const child = spawn(command, args, { stdio: ['ignore', 'ignore', 'inherit'] });
88
- child.on('error', () => resolve({ refused: 'no service manager runs this Kit' }));
111
+ child.on('error', () => resolve({ refused: 'no service manager runs this Kit process' }));
89
112
  child.on('close', () => resolve(null));
90
113
  });
91
114
  }
92
- export class Updates {
93
- house;
94
- held = new Set();
115
+ export class KitUpdate {
116
+ calls;
117
+ changed;
118
+ waiting = new Map();
95
119
  queue = Promise.resolve();
96
- constructor(house) {
97
- this.house = house;
120
+ constructor(calls, changed) {
121
+ this.calls = calls;
122
+ this.changed = changed;
98
123
  }
99
124
  async resumed() {
100
- const inputId = await pendingInput();
101
- if (inputId === null)
125
+ const callId = await pendingCall();
126
+ if (callId === null)
102
127
  return;
103
- await this.acknowledge(inputId, await finished(inputId));
128
+ await this.enqueue(callId, () => finished(callId));
104
129
  }
105
- start(input) {
106
- if (this.held.has(input.input_id))
107
- return;
108
- this.held.add(input.input_id);
109
- this.queue = this.queue
110
- .then(() => this.carry(input))
111
- .then((ack) => this.acknowledge(input.input_id, ack))
112
- .catch(logged)
113
- .finally(() => this.held.delete(input.input_id));
130
+ hold(call) {
131
+ this.waiting.set(call.input_id, call);
132
+ this.changed();
133
+ }
134
+ held() {
135
+ return this.waiting.size > 0;
136
+ }
137
+ apply(resume) {
138
+ const held = [...this.waiting.values()];
139
+ this.waiting.clear();
140
+ void Promise.all(held.map((call) => this.enqueue(call.input_id, () => this.carry(call)))).then(resume);
114
141
  }
115
- async carry(input) {
116
- if ((await pendingInput()) === input.input_id)
117
- return finished(input.input_id);
118
- const answer = await fetch(input.bootstrap);
119
- if (!answer.ok)
120
- return { refused: `the Kit bootstrap could not be downloaded: ${answer.status}` };
121
- const script = Buffer.from(await answer.arrayBuffer());
122
- if (createHash('sha256').update(script).digest('hex') !== input.sha256) {
142
+ enqueue(callId, work) {
143
+ const before = this.queue;
144
+ const carried = this.calls.carry(callId, async () => {
145
+ await before;
146
+ return { result: await work(), returned: () => forget(callId) };
147
+ });
148
+ this.queue = before.then(() => carried);
149
+ return carried;
150
+ }
151
+ async carry(call) {
152
+ if ((await pendingCall()) === call.input_id)
153
+ return finished(call.input_id);
154
+ const deadline = AbortSignal.timeout(BOOTSTRAP_MS);
155
+ let script;
156
+ try {
157
+ const answer = await fetch(relayed(call.bootstrap), { signal: deadline });
158
+ if (!answer.ok)
159
+ return { refused: `the Kit bootstrap could not be downloaded: ${answer.status}` };
160
+ script = await bounded(answer.body, BOOTSTRAP_BYTES);
161
+ }
162
+ catch (error) {
163
+ if (!deadline.aborted)
164
+ throw error;
165
+ return { refused: `the Kit bootstrap did not arrive within ${BOOTSTRAP_MS / 1000} seconds` };
166
+ }
167
+ if (script === null)
168
+ return { refused: `the Kit bootstrap is larger than ${BOOTSTRAP_BYTES} bytes` };
169
+ if (createHash('sha256').update(script).digest('hex') !== call.sha256) {
123
170
  return { refused: 'the Kit bootstrap does not match its sha256' };
124
171
  }
125
172
  await mkdir(directory(), { recursive: true, mode: 0o700 });
126
173
  const path = join(directory(), 'connect-linux.sh');
127
174
  await writeFile(path, script, { mode: 0o700 });
128
175
  await rm(outcome(), { force: true });
129
- await writeFile(pending(), `${JSON.stringify({ input_id: input.input_id })}\n`, { mode: 0o600 });
130
- return (await rerun(path, input.input_id, input.update_clis ? ['--update-clis'] : [])) ?? (await recorded()) ?? {
176
+ await writeFile(pending(), `${JSON.stringify({ input_id: call.input_id })}\n`, { mode: 0o600 });
177
+ return (await rerun(path, call.input_id, call.update_clis ? ['--update-clis'] : [])) ?? (await recorded()) ?? {
131
178
  refused: 'the Kit bootstrap did not finish',
132
179
  };
133
180
  }
134
- async acknowledge(inputId, ack) {
135
- await this.house.deliver(`/kit/inputs/${inputId}/ack`, ack);
136
- if ((await pendingInput()) !== inputId)
137
- return;
138
- await rm(pending(), { force: true });
139
- await rm(outcome(), { force: true });
140
- }
141
181
  }
package/dist/wire.js CHANGED
@@ -1,6 +1,22 @@
1
+ import { newerThanHouse, updateRequired } from './end.js';
2
+ import { machine } from './placement.js';
1
3
  import { refusalOf } from './refusals.js';
2
- export const KIT_WIRE = 1;
4
+ export const KIT_WIRE = 3;
3
5
  export const KIT_WIRE_HEADER = 'x-house-kit-wire';
4
- export function tooOld(text) {
5
- return refusalOf(text)?.code === 'kit_update_required';
6
+ function newer(text) {
7
+ let body;
8
+ try {
9
+ body = JSON.parse(text);
10
+ }
11
+ catch {
12
+ return null;
13
+ }
14
+ return body?.error?.code === 'kit_newer_than_house' ? body.error : null;
15
+ }
16
+ export function endUnserved(text) {
17
+ if (refusalOf(text)?.code === 'kit_update_required')
18
+ updateRequired();
19
+ const refused = newer(text);
20
+ if (refused !== null)
21
+ newerThanHouse(refused.release, refused.commands[machine()]);
6
22
  }
package/dist/work.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import { randomUUID } from 'node:crypto';
2
2
  import { once } from 'node:events';
3
3
  import { readFileSync } from 'node:fs';
4
- import { mkdir, rm } from 'node:fs/promises';
4
+ import { rm } from 'node:fs/promises';
5
5
  import { createServer } from 'node:net';
6
6
  import { join } from 'node:path';
7
7
  import { RUNNING_JOB } from './events.js';
8
- import { kitHome } from './home.js';
8
+ import { kitHome, socketDirectory } from './home.js';
9
9
  const ENDED_TASK = new Set(['completed', 'failed', 'killed']);
10
10
  const SCHEDULING = new Set(['CronCreate', 'CronDelete', 'ScheduleWakeup']);
11
11
  const QUEUE_LIST = 'house-kit-queue-';
@@ -194,9 +194,7 @@ class CodexWork extends Work {
194
194
  proving = -1;
195
195
  proven = -1;
196
196
  async open(cli) {
197
- const sockets = join(kitHome(), 'bridges');
198
- await mkdir(sockets, { recursive: true, mode: 0o700 });
199
- this.path = join(sockets, `${randomUUID()}.sock`);
197
+ this.path = join(socketDirectory(), `${randomUUID()}.sock`);
200
198
  this.server = createServer((socket) => this.connected(socket));
201
199
  this.server.listen(this.path);
202
200
  await once(this.server, 'listening');
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@agentshouse/kit",
3
- "version": "0.2.1-ca18b01951c3b",
4
- "description": "House Kit connects an Environment to agents.house.",
3
+ "version": "0.2.1-ca1f38641026d",
4
+ "description": "Kit connects an Environment to agents.house.",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -12,28 +12,27 @@
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": "node scripts/follow-skills.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.0.1",
28
+ "@agentshouse/mdmodel": "0.1.0-c4f4d37bc9d6a",
29
+ "@agentshouse/skills": "0.1.0-c1884c2b56810",
30
+ "@lydell/node-pty": "1.2.0-beta.15",
32
31
  "yaml": "2.9.1"
33
32
  },
34
33
  "peerDependencies": {
35
- "@agentclientprotocol/claude-agent-acp": "0.85.1",
36
- "@agentclientprotocol/codex-acp": "2.1.1"
34
+ "@agentclientprotocol/claude-agent-acp": "0.94.0",
35
+ "@agentclientprotocol/codex-acp": "2.2.2"
37
36
  },
38
37
  "peerDependenciesMeta": {
39
38
  "@agentclientprotocol/claude-agent-acp": {
@@ -44,26 +43,26 @@
44
43
  }
45
44
  },
46
45
  "devDependencies": {
47
- "@types/node": "24.13.6",
46
+ "@types/node": "24.19.2",
48
47
  "@types/ws": "8.18.2",
49
48
  "typescript": "7.0.2",
50
- "vitest": "5.0.1",
49
+ "vitest": "5.0.5",
51
50
  "ws": "8.22.0"
52
51
  },
53
- "packageManager": "npm@11.19.0",
52
+ "packageManager": "npm@11.19.1",
54
53
  "engines": {
55
- "node": "24.21.0",
56
- "npm": "11.19.0"
54
+ "node": "24.22.1",
55
+ "npm": "11.19.1"
57
56
  },
58
57
  "devEngines": {
59
58
  "runtime": {
60
59
  "name": "node",
61
- "version": "24.21.0",
60
+ "version": "24.22.1",
62
61
  "onFail": "error"
63
62
  },
64
63
  "packageManager": {
65
64
  "name": "npm",
66
- "version": "11.19.0",
65
+ "version": "11.19.1",
67
66
  "onFail": "error"
68
67
  }
69
68
  }
@@ -1,24 +0,0 @@
1
- {
2
- "schemaVersion": 2,
3
- "version": "0.2.1-ca18b01951c3b",
4
- "hosts": {
5
- "macos": {
6
- "asset": {
7
- "name": "connect-linux.sh",
8
- "url": "https://github.com/agentshouse/kit/releases/download/v0.2.1-ca18b01951c3b/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-ca18b01951c3b/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-ca18b01951c3b/connect-windows.ps1"
21
- }
22
- }
23
- }
24
- }
package/how-we-work.md DELETED
@@ -1,33 +0,0 @@
1
- # How we work
2
-
3
- A Room is where information people share is kept; it is not the place for
4
- private information. Work goes into the Room it belongs to, or the First Room
5
- when none is named.
6
-
7
- Every House answer carries the `url` of what it names; send the User that link.
8
-
9
- The skills are already set up; never run `setup-matt-pocock-skills`.
10
-
11
- ## Where skill output goes
12
-
13
- - Glossary (`GLOSSARY.md`): `glossary.md`
14
- - Decisions (ADRs): `decisions/NNNN-<slug>.md`
15
- - Plan (spec): `projects/<name>/plan.md`
16
- - Tasks (tickets): `projects/<name>/tasks/NN-<slug>.md`, with a
17
- `Status:` line (`needs-triage`, `needs-info`, `ready-for-agent`,
18
- `ready-for-human`, `wontfix`, or `done` once implemented), a
19
- `Category:` line (`bug`, `enhancement`), a `Blocked by:` line and comments
20
- under `## Comments`; triage takes no pull requests
21
- - Rejected requests (triage): `out-of-scope/<concept>.md`
22
- - Implementation notes (implement-spec): `projects/<name>/notes/`
23
- - PR bodies (pr): `projects/<name>/prs/<branch>.md`
24
- - Map (Wayfinding): `projects/<name>/map.md`, its tasks under
25
- `tasks/` with `Type:`, `Status: claimed|resolved` and `Blocked by:` lines
26
- - Research: `research/<slug>.md`
27
- - Architecture reports (improve-codebase-architecture): `architecture/<slug>.html`
28
- - Handoffs: `handoffs/<slug>.md`
29
- - Questionnaires: `questionnaires/<slug>.md`
30
- - Retrospectives (retro): `retros/<date>-<slug>.md`
31
- - Wizards: `wizards/<slug>.sh`; the values they capture stay out of the Room
32
- - Learning: `learning/<topic>/`
33
- - Prototype: one HTML file with every variant on one page.
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Matt Pocock
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.