@agentshouse/kit 0.2.1-cf6a92e13f031 → 0.2.1-cfbadfb5b5e28

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 (48) hide show
  1. package/README.md +14 -15
  2. package/dist/acp.js +58 -7
  3. package/dist/afk.js +17 -0
  4. package/dist/agents.js +58 -32
  5. package/dist/authority-main.js +3 -3
  6. package/dist/bridge.js +4 -4
  7. package/dist/building.js +50 -0
  8. package/dist/calls.js +12 -4
  9. package/dist/chunks.js +49 -0
  10. package/dist/clis.js +41 -42
  11. package/dist/connection.js +27 -33
  12. package/dist/content.js +63 -0
  13. package/dist/conversations.js +348 -126
  14. package/dist/copies.js +294 -148
  15. package/dist/end.js +8 -2
  16. package/dist/events.js +742 -210
  17. package/dist/files.js +35 -19
  18. package/dist/git.js +46 -12
  19. package/dist/grok.js +39 -0
  20. package/dist/home.js +0 -7
  21. package/dist/house-cli.js +26 -13
  22. package/dist/house-main.js +3 -3
  23. package/dist/instructions.js +5 -7
  24. package/dist/kit-cli.js +3 -6
  25. package/dist/kit-main.js +3 -3
  26. package/dist/login.js +5 -3
  27. package/dist/logout.js +1 -1
  28. package/dist/mcp.js +2 -0
  29. package/dist/placement.js +10 -18
  30. package/dist/relay.js +21 -0
  31. package/dist/resident.js +47 -32
  32. package/dist/scope.js +12 -4
  33. package/dist/scripts.js +255 -0
  34. package/dist/secret-input.js +1 -1
  35. package/dist/sign-in.js +3 -2
  36. package/dist/silence.js +28 -0
  37. package/dist/skills.js +38 -12
  38. package/dist/transcription.js +37 -25
  39. package/dist/translate.js +18 -9
  40. package/dist/update.js +109 -120
  41. package/dist/wire.js +23 -5
  42. package/dist/work.js +9 -2
  43. package/package.json +18 -17
  44. package/dist/bootstrap.json +0 -24
  45. package/dist/chatgpt.js +0 -32
  46. package/dist/clis-main.js +0 -23
  47. package/dist/parts.js +0 -82
  48. package/dist/web-wizard.js +0 -100
@@ -1,31 +1,32 @@
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';
4
+ import { isDeepStrictEqual } from 'node:util';
7
5
  import { unlessAborted } from './abort.js';
6
+ import { downloadServed } from './building.js';
8
7
  import { failureOf, run } from './clis.js';
9
8
  import { downloaded, fetched } from './files.js';
10
9
  import { kitHome } from './home.js';
11
10
  const RELEASE = 'https://github.com/agentshouse/kit/releases/download/engine-2';
12
11
  export const MODEL = {
13
- url: 'https://huggingface.co/ggml-org/parakeet-GGUF/resolve/35156454d1a39de06863303dd209fd2bed6ee079/ggml-parakeet-tdt-0.6b-v3-q4_k.bin',
12
+ name: 'ggml-parakeet-tdt-0.6b-v3-q4_k.bin',
13
+ from: 'https://huggingface.co/ggml-org/parakeet-GGUF/resolve/35156454d1a39de06863303dd209fd2bed6ee079/ggml-parakeet-tdt-0.6b-v3-q4_k.bin',
14
14
  sha256: '8b205b8b39c6535e153de6fb11c51db46125d45c4f16ba496fe41a0fe71b885e',
15
+ bytes: 415_611_879,
15
16
  executable: false,
16
17
  };
17
18
  export const ENGINES = {
18
19
  'linux-x64': {
19
- decoder: { url: `${RELEASE}/ffmpeg-linux-x86_64`, sha256: '1f8235d206428305afb89c6e8ab99d100425a0ba61e22bb4c7aff017db8c8de5', executable: true },
20
- engine: { url: `${RELEASE}/parakeet-cli-linux-x86_64`, sha256: 'bb2585695992fe1927a33960002cdf51b8a90a96ad65593c3d0a9f1fbc0865c2', executable: true },
20
+ decoder: { name: 'ffmpeg-linux-x86_64', from: `${RELEASE}/ffmpeg-linux-x86_64`, sha256: '1f8235d206428305afb89c6e8ab99d100425a0ba61e22bb4c7aff017db8c8de5', bytes: 5_175_832, executable: true },
21
+ engine: { name: 'parakeet-cli-linux-x86_64', from: `${RELEASE}/parakeet-cli-linux-x86_64`, sha256: 'bb2585695992fe1927a33960002cdf51b8a90a96ad65593c3d0a9f1fbc0865c2', bytes: 3_801_616, executable: true },
21
22
  },
22
23
  'linux-arm64': {
23
- decoder: { url: `${RELEASE}/ffmpeg-linux-aarch64`, sha256: 'a7e08a0fae0179d1078312f6bb13d2a9aa4d4c71a1d82a022953f25dee452f5e', executable: true },
24
- engine: { url: `${RELEASE}/parakeet-cli-linux-aarch64`, sha256: 'cbc0bedc8daae97f1ef9dcee4200c06226218e300e0fd62ead1306d22742b7ed', executable: true },
24
+ decoder: { name: 'ffmpeg-linux-aarch64', from: `${RELEASE}/ffmpeg-linux-aarch64`, sha256: 'a7e08a0fae0179d1078312f6bb13d2a9aa4d4c71a1d82a022953f25dee452f5e', bytes: 4_590_208, executable: true },
25
+ engine: { name: 'parakeet-cli-linux-aarch64', from: `${RELEASE}/parakeet-cli-linux-aarch64`, sha256: 'cbc0bedc8daae97f1ef9dcee4200c06226218e300e0fd62ead1306d22742b7ed', bytes: 3_477_624, executable: true },
25
26
  },
26
27
  'darwin-arm64': {
27
- decoder: { url: `${RELEASE}/ffmpeg-darwin-arm64`, sha256: '7abe154aaed3d6b49f5167ca7221bb66bed51388925d99a7e4261a41fe52fba6', executable: true },
28
- engine: { url: `${RELEASE}/parakeet-cli-darwin-arm64`, sha256: '9a2aafc0922ad7c0b6db6eff1641e96572ba32ac40bf995a1df242ed2febf297', executable: true },
28
+ decoder: { name: 'ffmpeg-darwin-arm64', from: `${RELEASE}/ffmpeg-darwin-arm64`, sha256: '7abe154aaed3d6b49f5167ca7221bb66bed51388925d99a7e4261a41fe52fba6', bytes: 3_696_768, executable: true },
29
+ engine: { name: 'parakeet-cli-darwin-arm64', from: `${RELEASE}/parakeet-cli-darwin-arm64`, sha256: '9a2aafc0922ad7c0b6db6eff1641e96572ba32ac40bf995a1df242ed2febf297', bytes: 1_939_728, executable: true },
29
30
  },
30
31
  };
31
32
  const CHUNK_SECONDS = 20;
@@ -46,7 +47,7 @@ function installed(artifact) {
46
47
  return join(directory(), artifact.sha256);
47
48
  }
48
49
  async function executed(command, args, signal) {
49
- // 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.
50
+ // 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.
50
51
  const ran = await run(command, args, 0, false, signal);
51
52
  if (ran.status !== 0)
52
53
  throw new Error(failureOf(ran, basename(command)));
@@ -60,11 +61,6 @@ async function threads() {
60
61
  const allowed = quota === 'max' ? Infinity : Math.ceil(Number(quota) / Number(period));
61
62
  return Math.max(1, Math.floor(Math.min(availableParallelism(), allowed) / 2));
62
63
  }
63
- async function sha256(path) {
64
- const hash = createHash('sha256');
65
- await pipeline(createReadStream(path), hash);
66
- return hash.digest('hex');
67
- }
68
64
  function causeOf(error) {
69
65
  return error instanceof Error ? error.message : String(error);
70
66
  }
@@ -85,6 +81,25 @@ function ready() {
85
81
  function pinnedHere() {
86
82
  return ENGINES[`${process.platform}-${process.arch}`];
87
83
  }
84
+ const DOWNLOADS = 3;
85
+ async function downloadedAgain(artifact, signal) {
86
+ // An artifact arrives at a hundred kilobytes a second or its download ends, so a stalled Building cannot hold the install open.
87
+ const deadlineMs = Math.ceil(artifact.bytes / 100);
88
+ const deadline = AbortSignal.timeout(deadlineMs);
89
+ for (let attempt = 1;; attempt++) {
90
+ try {
91
+ return await downloadServed(artifact.name, artifact.sha256, `${installed(artifact)}.part`, AbortSignal.any([signal, deadline]), artifact.bytes);
92
+ }
93
+ catch (error) {
94
+ if (signal.aborted)
95
+ throw error;
96
+ if (deadline.aborted)
97
+ throw new Error(`${artifact.name} did not arrive within ${Math.ceil(deadlineMs / 1000)} seconds`);
98
+ if (attempt === DOWNLOADS)
99
+ throw error;
100
+ }
101
+ }
102
+ }
88
103
  async function install(artifacts, signal) {
89
104
  await mkdir(directory(), { recursive: true });
90
105
  const pinned = new Set(artifacts.map((artifact) => artifact.sha256));
@@ -97,13 +112,8 @@ async function install(artifacts, signal) {
97
112
  if (!(await present(installed(artifact))))
98
113
  missing.push(artifact);
99
114
  try {
100
- for (const artifact of missing) {
101
- const part = `${installed(artifact)}.part`;
102
- // Three retries carry a large download past a dropped connection before the download fails.
103
- await executed('curl', ['-fsSL', '--retry', '3', '-o', part, artifact.url], signal);
104
- if ((await sha256(part)) !== artifact.sha256)
105
- throw new Error(`${artifact.url} does not match its sha256`);
106
- }
115
+ for (const artifact of missing)
116
+ await downloadedAgain(artifact, signal);
107
117
  for (const artifact of missing) {
108
118
  if (artifact.executable)
109
119
  await chmod(`${installed(artifact)}.part`, 0o755);
@@ -116,7 +126,7 @@ async function install(artifacts, signal) {
116
126
  }
117
127
  }
118
128
  function reported(next) {
119
- const changed = next.installed !== readiness.installed || next.failure !== readiness.failure;
129
+ const changed = !isDeepStrictEqual(next, readiness);
120
130
  readiness = next;
121
131
  return changed;
122
132
  }
@@ -128,10 +138,12 @@ async function settle(transcribe) {
128
138
  await rm(directory(), { recursive: true, force: true });
129
139
  return reported({ installed: false, failure: null });
130
140
  }
141
+ const pinned = pinnedHere();
142
+ if (pinned === undefined)
143
+ return reported({ installed: false, failure: null, no_engine: true });
131
144
  const download = new AbortController();
132
145
  downloading = download;
133
146
  try {
134
- const pinned = pinnedHere();
135
147
  await install([pinned.decoder, pinned.engine, MODEL], download.signal);
136
148
  return reported({ installed: true, failure: null });
137
149
  }
package/dist/translate.js CHANGED
@@ -1,12 +1,21 @@
1
- import { apply, parse, serialize } from '@agentshouse/mdmodel';
1
+ import { apply, definitionAt, HOUSE_TYPED_PATHS, parse, serialize, } from '@agentshouse/mdmodel';
2
2
  function same(left, right) {
3
3
  return JSON.stringify(left) === JSON.stringify(right);
4
4
  }
5
- function applied(document, changes) {
6
- const result = apply(document, changes);
5
+ function applied(document, changes, definition) {
6
+ const result = apply(document, changes, definition);
7
7
  return result.outcome === 'applied' ? serialize(result.document) : null;
8
8
  }
9
- function components(path, before, after, text) {
9
+ export function readDocument(content, file, model) {
10
+ const definitions = definitionAt(model, file, HOUSE_TYPED_PATHS);
11
+ const parsed = parse(content, file, definitions);
12
+ if (!parsed.ok)
13
+ return null;
14
+ const { document } = parsed;
15
+ const definition = definitions(document.type);
16
+ return definition !== undefined || document.type === undefined ? { document, definition } : null;
17
+ }
18
+ function components(path, before, after, text, definition) {
10
19
  const edits = [];
11
20
  const changes = [];
12
21
  if (before.preamble !== after.preamble) {
@@ -33,13 +42,13 @@ function components(path, before, after, text) {
33
42
  edits.push({ op: 'replace_section', path, section: name, base: prior, content: value });
34
43
  changes.push({ kind: 'section', name, value, prior });
35
44
  }
36
- return edits.length > 0 && applied(before, changes) === text ? edits : null;
45
+ return edits.length > 0 && applied(before, changes, definition) === text ? edits : null;
37
46
  }
38
- export function changed(path, file, base, before, after) {
47
+ export function changed(path, file, base, before, after, model) {
39
48
  if (!file.endsWith('.md'))
40
49
  return [{ op: 'replace', path, base, content: after }];
41
- const parsedBefore = parse(before, file);
42
- const parsedAfter = parse(after, file);
43
- const structured = parsedBefore.ok && parsedAfter.ok ? components(path, parsedBefore.document, parsedAfter.document, after) : null;
50
+ const prior = readDocument(before, file, model);
51
+ const next = readDocument(after, file, model);
52
+ const structured = prior !== null && next !== null ? components(path, prior.document, next.document, after, prior.definition) : null;
44
53
  return structured ?? [{ op: 'replace', path, base, content: after }];
45
54
  }
package/dist/update.js CHANGED
@@ -1,138 +1,127 @@
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 { restart, 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(callId) {
19
- return `house-kit-update-${callId}`;
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(' ')}`;
35
- }
36
- async function pendingCall() {
37
- try {
38
- return JSON.parse(await readFile(pending(), 'utf8')).input_id;
39
- }
40
- catch {
41
- return null;
42
- }
43
- }
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(callId) {
51
- if ((await pendingCall()) !== callId)
52
- return;
53
- await rm(pending(), { force: true });
54
- await rm(outcome(), { force: true });
55
- }
56
- async function finished(callId) {
57
- for (;;) {
58
- const result = await recorded();
59
- if (result !== null)
60
- return result;
61
- // systemctl answers at once, so ten seconds only bounds a stuck service manager.
62
- if ((await run('systemctl', [...manager(), 'is-active', '--quiet', unit(callId)], 10_000)).status !== 0) {
63
- return (await recorded()) ?? { refused: 'the Kit bootstrap did not finish' };
64
- }
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
- }
68
- }
69
- function rerun(script, callId, flags) {
22
+ function placing(installer, house, prefix, signal) {
70
23
  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(callId)}`,
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 process' }));
92
- child.on('close', () => resolve(null));
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
+ });
93
59
  });
94
60
  }
95
61
  export class KitUpdate {
96
62
  calls;
97
63
  queue = Promise.resolve();
64
+ placed = null;
98
65
  constructor(calls) {
99
66
  this.calls = calls;
100
67
  }
101
- async resumed() {
102
- const callId = await pendingCall();
103
- if (callId === null)
104
- return;
105
- await this.enqueue(callId, () => finished(callId));
68
+ take(call) {
69
+ void this.calls.carry(call.input_id, async () => ({ result: await this.queued(() => this.update(call.release)) }));
106
70
  }
107
- start(call) {
108
- void this.enqueue(call.input_id, () => this.carry(call));
71
+ async takeRefused(release) {
72
+ for (;;) {
73
+ const failure = await this.queued(async () => (this.placed === null ? this.place(release, 'served') : null));
74
+ if (failure === null)
75
+ restart(`Kit ${this.placed} is placed; its supervisor starts it`);
76
+ process.stderr.write(`kit: ${updateLine(`Kit ${KIT_RELEASE} stays offline and tries again in ${PLACEMENT_RETRY_MS / 60_000} minutes`)}\n`);
77
+ await new Promise((resolve) => setTimeout(resolve, PLACEMENT_RETRY_MS));
78
+ }
109
79
  }
110
- enqueue(callId, work) {
111
- const before = this.queue;
112
- const carried = this.calls.carry(callId, async () => {
113
- await before;
114
- return { result: await work(), returned: () => forget(callId) };
115
- });
116
- this.queue = before.then(() => carried);
117
- return carried;
80
+ placedRelease() {
81
+ return this.placed;
82
+ }
83
+ queued(work) {
84
+ const taken = this.queue.then(work);
85
+ this.queue = taken.catch(() => undefined);
86
+ return taken;
118
87
  }
119
- async carry(call) {
120
- if ((await pendingCall()) === call.input_id)
121
- return finished(call.input_id);
122
- const answer = await fetch(call.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') !== call.sha256) {
127
- return { refused: 'the Kit bootstrap does not match its sha256' };
88
+ async update(release) {
89
+ if (release === (this.placed ?? KIT_RELEASE))
90
+ return {};
91
+ if (this.placed !== null)
92
+ return { refused: `Kit ${this.placed} is placed and starts first, once no turn is open` };
93
+ const failure = await this.place(release, 'named');
94
+ if (failure !== null)
95
+ return { refused: failure };
96
+ process.stderr.write(`kit: Kit ${release} is placed; it starts once no turn is open\n`);
97
+ return {};
98
+ }
99
+ async place(release, which) {
100
+ const signal = AbortSignal.timeout(PLACEMENT_MS);
101
+ let version = release;
102
+ let failure;
103
+ try {
104
+ const prefix = placedPrefix();
105
+ const served = await servedRelease(signal);
106
+ if (which === 'named' && served.version !== release)
107
+ throw new Error(`the Building serves Kit ${served.version}, not Kit ${release}`);
108
+ version = served.version;
109
+ if (version === KIT_RELEASE)
110
+ throw new Error(`the Building serves Kit ${KIT_RELEASE}, which this Kit runs`);
111
+ await mkdir(join(kitHome(), 'update'), { recursive: true, mode: 0o700 });
112
+ const installer = join(kitHome(), 'update', served.installer);
113
+ await downloadServed(served.installer, served.sha256, installer, signal, INSTALLER_BYTES);
114
+ failure = await placing(installer, (await readEnrolment()).house, prefix, signal);
128
115
  }
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: call.input_id })}\n`, { mode: 0o600 });
134
- return (await rerun(path, call.input_id, call.update_clis ? ['--update-clis'] : [])) ?? (await recorded()) ?? {
135
- refused: 'the Kit bootstrap did not finish',
136
- };
116
+ catch (error) {
117
+ failure = signal.aborted ? `the placement did not end within ${PLACEMENT_MS / 1000} seconds` : causeOf(error);
118
+ }
119
+ if (failure !== null) {
120
+ const refused = `Kit ${version} could not be placed: ${failure}`;
121
+ process.stderr.write(`kit: ${refused}\n`);
122
+ return refused;
123
+ }
124
+ this.placed = version;
125
+ return null;
137
126
  }
138
127
  }
package/dist/wire.js CHANGED
@@ -1,9 +1,11 @@
1
1
  import { newerThanHouse, updateRequired } from './end.js';
2
2
  import { machine } from './placement.js';
3
3
  import { refusalOf } from './refusals.js';
4
- export const KIT_WIRE = 3;
4
+ export const KIT_WIRE = 6;
5
5
  export const KIT_WIRE_HEADER = 'x-house-kit-wire';
6
- function newer(text) {
6
+ let take = null;
7
+ let taken = false;
8
+ function unservedBy(text) {
7
9
  let body;
8
10
  try {
9
11
  body = JSON.parse(text);
@@ -11,12 +13,28 @@ function newer(text) {
11
13
  catch {
12
14
  return null;
13
15
  }
14
- return body?.error?.code === 'kit_newer_than_house' ? body.error : null;
16
+ const error = body?.error;
17
+ if (error?.code !== 'kit_update_required' && error?.code !== 'kit_newer_than_house')
18
+ return null;
19
+ return typeof error.release === 'string' ? error : null;
20
+ }
21
+ export function takeUnservedRelease(taking) {
22
+ take = taking;
23
+ }
24
+ export function unserved() {
25
+ return taken;
15
26
  }
16
27
  export function endUnserved(text) {
28
+ const refused = unservedBy(text);
29
+ if (refused !== null && take !== null) {
30
+ if (!taken) {
31
+ taken = true;
32
+ take(refused.release);
33
+ }
34
+ return;
35
+ }
17
36
  if (refusalOf(text)?.code === 'kit_update_required')
18
37
  updateRequired();
19
- const refused = newer(text);
20
- if (refused !== null)
38
+ if (refused?.code === 'kit_newer_than_house')
21
39
  newerThanHouse(refused.release, refused.commands[machine()]);
22
40
  }
package/dist/work.js CHANGED
@@ -177,6 +177,7 @@ class ClaudeWork extends Work {
177
177
  }
178
178
  }
179
179
  class CodexWork extends Work {
180
+ tapped;
180
181
  threads = new Map();
181
182
  queues = new Map();
182
183
  goals = new Set();
@@ -193,6 +194,10 @@ class CodexWork extends Work {
193
194
  heard = 0;
194
195
  proving = -1;
195
196
  proven = -1;
197
+ constructor(changed, tapped) {
198
+ super(changed);
199
+ this.tapped = tapped;
200
+ }
196
201
  async open(cli) {
197
202
  this.path = join(socketDirectory(), `${randomUUID()}.sock`);
198
203
  this.server = createServer((socket) => this.connected(socket));
@@ -274,6 +279,8 @@ class CodexWork extends Work {
274
279
  }
275
280
  stream(message, socket) {
276
281
  const params = message.params;
282
+ if (message.method !== undefined)
283
+ this.tapped(message);
277
284
  switch (message.method) {
278
285
  case 'thread/status/changed':
279
286
  this.threads.set(params.threadId, params.status.type === 'active' && params.status.activeFlags.length === 0);
@@ -337,10 +344,10 @@ class GrokWork extends Work {
337
344
  return true;
338
345
  }
339
346
  }
340
- export function workFor(kind, cwd, changed) {
347
+ export function workFor(kind, cwd, changed, tapped) {
341
348
  if (kind === 'claude-agent-acp')
342
349
  return new ClaudeWork(cwd, changed);
343
350
  if (kind === 'codex-acp')
344
- return new CodexWork(changed);
351
+ return new CodexWork(changed, tapped);
345
352
  return new GrokWork(changed);
346
353
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentshouse/kit",
3
- "version": "0.2.1-cf6a92e13f031",
3
+ "version": "0.2.1-cfbadfb5b5e28",
4
4
  "description": "Kit connects an Environment to agents.house.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -12,28 +12,29 @@
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
16
  "dist"
20
17
  ],
21
18
  "scripts": {
22
- "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",
23
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",
24
22
  "follow-skills": "node scripts/follow-skills.mjs",
23
+ "release-files": "node scripts/release-files.mjs",
25
24
  "test": "tsc -p tsconfig.json && vitest run"
26
25
  },
27
26
  "dependencies": {
28
- "@agentclientprotocol/sdk": "1.7.0",
29
- "@agentshouse/mdmodel": "0.1.0-cabd61587647f",
30
- "@agentshouse/skills": "0.1.0-c6411c39c6d0f",
27
+ "@agentclientprotocol/sdk": "2.4.0",
28
+ "@agentshouse/mdmodel": "0.1.0-cd6a8e5bc7efc",
29
+ "@agentshouse/session-content": "0.1.0-cad437697294e",
30
+ "@agentshouse/skills": "0.1.0-ca3a9a5296c61",
31
31
  "@lydell/node-pty": "1.2.0-beta.15",
32
+ "micromark": "4.0.2",
32
33
  "yaml": "2.9.1"
33
34
  },
34
35
  "peerDependencies": {
35
- "@agentclientprotocol/claude-agent-acp": "0.85.1",
36
- "@agentclientprotocol/codex-acp": "2.1.1"
36
+ "@agentclientprotocol/claude-agent-acp": "0.100.0",
37
+ "@agentclientprotocol/codex-acp": "2.5.0"
37
38
  },
38
39
  "peerDependenciesMeta": {
39
40
  "@agentclientprotocol/claude-agent-acp": {
@@ -44,26 +45,26 @@
44
45
  }
45
46
  },
46
47
  "devDependencies": {
47
- "@types/node": "24.13.6",
48
+ "@types/node": "24.19.2",
48
49
  "@types/ws": "8.18.2",
49
50
  "typescript": "7.0.2",
50
- "vitest": "5.0.1",
51
+ "vitest": "5.0.5",
51
52
  "ws": "8.22.0"
52
53
  },
53
- "packageManager": "npm@11.19.0",
54
+ "packageManager": "npm@11.19.1",
54
55
  "engines": {
55
- "node": "24.21.0",
56
- "npm": "11.19.0"
56
+ "node": "24.22.1",
57
+ "npm": "11.19.1"
57
58
  },
58
59
  "devEngines": {
59
60
  "runtime": {
60
61
  "name": "node",
61
- "version": "24.21.0",
62
+ "version": "24.22.1",
62
63
  "onFail": "error"
63
64
  },
64
65
  "packageManager": {
65
66
  "name": "npm",
66
- "version": "11.19.0",
67
+ "version": "11.19.1",
67
68
  "onFail": "error"
68
69
  }
69
70
  }
@@ -1,24 +0,0 @@
1
- {
2
- "schemaVersion": 2,
3
- "version": "0.2.1-cf6a92e13f031",
4
- "hosts": {
5
- "macos": {
6
- "asset": {
7
- "name": "connect-linux.sh",
8
- "url": "https://github.com/agentshouse/kit/releases/download/v0.2.1-cf6a92e13f031/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-cf6a92e13f031/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-cf6a92e13f031/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
- }