@agentshouse/kit 0.2.1-ce3d2bb67177c → 0.2.1-ce8e5419af3f9

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 (146) hide show
  1. package/README.md +17 -18
  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 +5 -5
  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 +46 -44
  11. package/dist/connection.js +28 -33
  12. package/dist/content.js +63 -0
  13. package/dist/conversations.js +344 -127
  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 +29 -57
  22. package/dist/house-main.js +3 -3
  23. package/dist/instructions.js +29 -11
  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 -26
  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 +41 -96
  38. package/dist/transcription.js +37 -24
  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 +21 -20
  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/how-we-work.md +0 -33
  49. package/skills/ask-matt/LICENSE +0 -21
  50. package/skills/ask-matt/PHASE-BOUNDARIES.md +0 -55
  51. package/skills/ask-matt/SKILL.md +0 -97
  52. package/skills/ask-matt/agents/openai.yaml +0 -5
  53. package/skills/code-review/LICENSE +0 -21
  54. package/skills/code-review/SKILL.md +0 -89
  55. package/skills/code-review/agents/openai.yaml +0 -3
  56. package/skills/codebase-design/DEEPENING.md +0 -37
  57. package/skills/codebase-design/DESIGN-IT-TWICE.md +0 -44
  58. package/skills/codebase-design/LICENSE +0 -21
  59. package/skills/codebase-design/SKILL.md +0 -114
  60. package/skills/codebase-design/agents/openai.yaml +0 -3
  61. package/skills/diagnosing-bugs/LICENSE +0 -21
  62. package/skills/diagnosing-bugs/SKILL.md +0 -138
  63. package/skills/diagnosing-bugs/agents/openai.yaml +0 -3
  64. package/skills/diagnosing-bugs/scripts/hitl-loop.template.sh +0 -44
  65. package/skills/domain-modeling/ADR-FORMAT.md +0 -47
  66. package/skills/domain-modeling/GLOSSARY-FORMAT.md +0 -60
  67. package/skills/domain-modeling/LICENSE +0 -21
  68. package/skills/domain-modeling/SKILL.md +0 -74
  69. package/skills/domain-modeling/agents/openai.yaml +0 -3
  70. package/skills/grill-me/LICENSE +0 -21
  71. package/skills/grill-me/SKILL.md +0 -7
  72. package/skills/grill-me/agents/openai.yaml +0 -5
  73. package/skills/grill-with-docs/LICENSE +0 -21
  74. package/skills/grill-with-docs/SKILL.md +0 -7
  75. package/skills/grill-with-docs/agents/openai.yaml +0 -5
  76. package/skills/grilling/LICENSE +0 -21
  77. package/skills/grilling/SKILL.md +0 -30
  78. package/skills/grilling/agents/openai.yaml +0 -3
  79. package/skills/handoff/LICENSE +0 -21
  80. package/skills/handoff/SKILL.md +0 -16
  81. package/skills/handoff/agents/openai.yaml +0 -5
  82. package/skills/implement/LICENSE +0 -21
  83. package/skills/implement/SKILL.md +0 -17
  84. package/skills/implement/agents/openai.yaml +0 -5
  85. package/skills/implement-spec/LICENSE +0 -21
  86. package/skills/implement-spec/SKILL.md +0 -40
  87. package/skills/implement-spec/agents/openai.yaml +0 -5
  88. package/skills/improve-codebase-architecture/HTML-REPORT.md +0 -123
  89. package/skills/improve-codebase-architecture/LICENSE +0 -21
  90. package/skills/improve-codebase-architecture/SKILL.md +0 -71
  91. package/skills/improve-codebase-architecture/agents/openai.yaml +0 -5
  92. package/skills/pr/CREDITS.md +0 -3
  93. package/skills/pr/LICENSE +0 -21
  94. package/skills/pr/SKILL.md +0 -170
  95. package/skills/pr/agents/openai.yaml +0 -3
  96. package/skills/prototype/LICENSE +0 -21
  97. package/skills/prototype/LOGIC.md +0 -67
  98. package/skills/prototype/SKILL.md +0 -26
  99. package/skills/prototype/UI.md +0 -112
  100. package/skills/prototype/agents/openai.yaml +0 -3
  101. package/skills/research/LICENSE +0 -21
  102. package/skills/research/SKILL.md +0 -12
  103. package/skills/research/agents/openai.yaml +0 -3
  104. package/skills/retro/LICENSE +0 -21
  105. package/skills/retro/SKILL.md +0 -44
  106. package/skills/retro/agents/openai.yaml +0 -5
  107. package/skills/tdd/LICENSE +0 -21
  108. package/skills/tdd/SKILL.md +0 -38
  109. package/skills/tdd/agents/openai.yaml +0 -3
  110. package/skills/tdd/mocking.md +0 -59
  111. package/skills/tdd/tests.md +0 -77
  112. package/skills/teach/GLOSSARY-FORMAT.md +0 -35
  113. package/skills/teach/LEARNING-RECORD-FORMAT.md +0 -46
  114. package/skills/teach/LICENSE +0 -21
  115. package/skills/teach/MISSION-FORMAT.md +0 -31
  116. package/skills/teach/RESOURCES-FORMAT.md +0 -32
  117. package/skills/teach/SKILL.md +0 -140
  118. package/skills/teach/agents/openai.yaml +0 -5
  119. package/skills/to-questionnaire/LICENSE +0 -21
  120. package/skills/to-questionnaire/SKILL.md +0 -54
  121. package/skills/to-questionnaire/agents/openai.yaml +0 -5
  122. package/skills/to-spec/LICENSE +0 -21
  123. package/skills/to-spec/SKILL.md +0 -75
  124. package/skills/to-spec/agents/openai.yaml +0 -5
  125. package/skills/to-tickets/LICENSE +0 -21
  126. package/skills/to-tickets/SKILL.md +0 -105
  127. package/skills/to-tickets/agents/openai.yaml +0 -5
  128. package/skills/triage/AGENT-BRIEF.md +0 -207
  129. package/skills/triage/LICENSE +0 -21
  130. package/skills/triage/OUT-OF-SCOPE.md +0 -105
  131. package/skills/triage/SKILL.md +0 -112
  132. package/skills/triage/agents/openai.yaml +0 -5
  133. package/skills/wait-what/LICENSE +0 -21
  134. package/skills/wait-what/SKILL.md +0 -7
  135. package/skills/wait-what/agents/openai.yaml +0 -5
  136. package/skills/wayfinder/LICENSE +0 -21
  137. package/skills/wayfinder/SKILL.md +0 -128
  138. package/skills/wayfinder/agents/openai.yaml +0 -5
  139. package/skills/wizard/LICENSE +0 -21
  140. package/skills/wizard/SKILL.md +0 -44
  141. package/skills/wizard/agents/openai.yaml +0 -3
  142. package/skills/wizard/template.sh +0 -223
  143. package/skills/writing-for-agents/LICENSE +0 -21
  144. package/skills/writing-for-agents/SKILL-MECHANICS.md +0 -22
  145. package/skills/writing-for-agents/SKILL.md +0 -81
  146. package/skills/writing-for-agents/agents/openai.yaml +0 -3
package/dist/files.js CHANGED
@@ -9,6 +9,7 @@ import { retryDelay } from './api.js';
9
9
  import { Unsettled } from './mcp.js';
10
10
  import { relayed } from './relay.js';
11
11
  const STALLED_ROUNDS = 8;
12
+ const PART_CHECKSUM = 'x-amz-checksum-sha256';
12
13
  const LINK = /\]\((\/rooms\/[^/)\s]+\/[^)\s]+)\)/gu;
13
14
  export function linkedPaths(text) {
14
15
  return [...new Set(Array.from(text.matchAll(LINK), (link) => link[1]))];
@@ -26,23 +27,45 @@ export function inspectedFile(answer) {
26
27
  media_type: typeof inspected.media_type === 'string' ? inspected.media_type : null,
27
28
  };
28
29
  }
29
- function paused(milliseconds) {
30
+ export function paused(milliseconds) {
30
31
  return new Promise((resolve) => setTimeout(resolve, milliseconds));
31
32
  }
32
33
  export function storeRefusal(act, status) {
33
34
  return new Error(`the ${act} answered ${status}; ${act} the file again`);
34
35
  }
36
+ async function partDigests(uploading, partBytes) {
37
+ const whole = createHash('sha256');
38
+ const digests = [];
39
+ for (let start = 0; digests.length === 0 || start < uploading.bytes; start += partBytes) {
40
+ const end = Math.min(start + partBytes, uploading.bytes);
41
+ const digest = createHash('sha256');
42
+ for await (const chunk of uploading.read(start, end)) {
43
+ digest.update(chunk);
44
+ whole.update(chunk);
45
+ }
46
+ digests.push(digest.digest());
47
+ }
48
+ if (whole.digest('hex') !== uploading.sha256)
49
+ throw new Error(`${uploading.name} changed while it was uploaded; upload it again`);
50
+ return digests;
51
+ }
35
52
  export async function uploaded(declared, uploading) {
36
- let upload = declared;
53
+ const partBytes = declared.part_bytes;
54
+ const digests = await partDigests(uploading, partBytes);
55
+ const partSha256 = digests.map((digest) => digest.toString('hex'));
56
+ let answer = await finishing(uploading, declared.id, partSha256);
37
57
  let idle = 0;
38
58
  let stalled = 0;
39
- for (;;) {
59
+ while ('upload' in answer) {
60
+ const { id, parts } = answer.upload;
40
61
  let sent = 0;
41
62
  let failure = null;
42
- for (const { part, url } of upload.parts) {
43
- const start = (part - 1) * upload.part_bytes;
63
+ for (const { part, url } of parts ?? []) {
64
+ const start = (part - 1) * partBytes;
44
65
  try {
45
- await uploading.send(url, start, Math.min(start + upload.part_bytes, uploading.bytes));
66
+ await uploading.send(url, start, Math.min(start + partBytes, uploading.bytes), {
67
+ [PART_CHECKSUM]: digests[part - 1].toString('base64'),
68
+ });
46
69
  sent++;
47
70
  }
48
71
  catch (error) {
@@ -57,24 +80,17 @@ export async function uploaded(declared, uploading) {
57
80
  else {
58
81
  if (failure !== null && ++stalled >= STALLED_ROUNDS)
59
82
  throw failure;
60
- // A round that sent no part, its store unreachable or not yet started, is followed by the next finishing call on the jittered curve.
83
+ // A round that sent no part, its store unreachable, is followed by the next finishing call on the jittered curve.
61
84
  await paused(retryDelay(idle++));
62
85
  }
63
- let answer = await finishing(uploading, upload.id);
64
- while ('checking' in answer) {
65
- // A finishing call that finds House still checking the stored bytes is sent again after five seconds, the cadence at which House takes up a check it handed over.
66
- await paused(5_000);
67
- answer = await finishing(uploading, upload.id);
68
- }
69
- if (!('upload' in answer))
70
- return answer;
71
- upload = answer.upload;
86
+ answer = await finishing(uploading, id, partSha256);
72
87
  }
88
+ return answer;
73
89
  }
74
- async function finishing(uploading, upload) {
90
+ async function finishing(uploading, upload, partSha256) {
75
91
  for (let unsettled = 1;; unsettled++) {
76
92
  try {
77
- return await uploading.finish(upload);
93
+ return await uploading.finish(upload, partSha256);
78
94
  }
79
95
  catch (error) {
80
96
  if (!(error instanceof Unsettled) || unsettled === STALLED_ROUNDS)
@@ -124,5 +140,5 @@ export async function downloaded(address, fetching, destination, name) {
124
140
  }
125
141
  export async function fetched(url, signal) {
126
142
  const answer = await fetch(relayed(url), { signal });
127
- return { status: answer.status, body: answer.body ?? Readable.from([]) };
143
+ return { status: answer.status, body: answer.body === null ? Readable.from([]) : Readable.fromWeb(answer.body) };
128
144
  }
package/dist/git.js CHANGED
@@ -2,8 +2,8 @@ import { spawn } from 'node:child_process';
2
2
  import { isUtf8 } from 'node:buffer';
3
3
  import { createHash } from 'node:crypto';
4
4
  import { join } from 'node:path';
5
- import { withoutProxy } from './clis.js';
6
5
  import { workspaceRoot } from './home.js';
6
+ import { childEnvironment } from './relay.js';
7
7
  export function localCopies() {
8
8
  return join(workspaceRoot(), 'local-copies');
9
9
  }
@@ -11,7 +11,7 @@ export const HOUSE_REF = 'refs/house/received';
11
11
  const COMMITTER = 'Kit <house-kit@localhost>';
12
12
  export function run(cwd, args, input, env = {}) {
13
13
  return new Promise((resolve, reject) => {
14
- const child = spawn('git', args, { cwd, env: { ...withoutProxy(), ...env } });
14
+ const child = spawn('git', args, { cwd, env: { ...childEnvironment(), ...env } });
15
15
  const stdout = [];
16
16
  let stderr = '';
17
17
  child.stdout.on('data', (chunk) => stdout.push(chunk));
@@ -70,18 +70,52 @@ function data(text) {
70
70
  const bytes = Buffer.from(text, 'utf8');
71
71
  return [Buffer.from(`data ${bytes.length}\n`), bytes, Buffer.from('\n')];
72
72
  }
73
- export async function importCommits(repository, commits) {
74
- const stream = [];
73
+ function written(stream, bytes) {
74
+ return new Promise((resolve, reject) => {
75
+ stream.write(bytes, (error) => (error ? reject(error) : resolve()));
76
+ });
77
+ }
78
+ async function imported(stream, commits) {
79
+ await written(stream, Buffer.from('feature done\n'));
75
80
  for (const [index, commit] of commits.entries()) {
76
- stream.push(Buffer.from(`commit ${HOUSE_REF}\nmark :${index + 1}\ncommitter ${COMMITTER} ${Math.floor(Date.now() / 1000)} +0000\n`), ...data(commit.message), ...(commit.from === null ? [] : [Buffer.from(`from ${commit.from}\n`)]), ...(commit.merge === undefined ? [] : [Buffer.from(`merge ${commit.merge}\n`)]), ...(commit.replaces === true ? [Buffer.from('deleteall\n')] : []));
77
- for (const [path, content] of commit.files) {
78
- if (content === null)
79
- stream.push(Buffer.from(`D ${quoted(path)}\n`));
80
- else
81
- stream.push(Buffer.from(`M 100644 inline ${quoted(path)}\n`), ...data(content));
81
+ await written(stream, Buffer.concat([
82
+ Buffer.from(`commit ${HOUSE_REF}\nmark :${index + 1}\ncommitter ${COMMITTER} ${Math.floor(Date.now() / 1000)} +0000\n`),
83
+ ...data(commit.message),
84
+ ...(commit.from === null ? [] : [Buffer.from(`from ${commit.from}\n`)]),
85
+ ...(commit.merge === undefined ? [] : [Buffer.from(`merge ${commit.merge}\n`)]),
86
+ ...(commit.replaces === true ? [Buffer.from('deleteall\n')] : []),
87
+ ]));
88
+ for await (const [path, content] of commit.files) {
89
+ await written(stream, content === null
90
+ ? Buffer.from(`D ${quoted(path)}\n`)
91
+ : Buffer.concat([Buffer.from(`M 100644 inline ${quoted(path)}\n`), ...data(content)]));
82
92
  }
83
- stream.push(Buffer.from('\n'));
93
+ await written(stream, Buffer.from('\n'));
94
+ }
95
+ await written(stream, Buffer.from('done\n'));
96
+ }
97
+ export async function importCommits(repository, commits) {
98
+ const child = spawn('git', ['fast-import', '--quiet', '--force'], { cwd: repository, env: childEnvironment() });
99
+ let stderr = '';
100
+ child.stdout.resume();
101
+ child.stderr.on('data', (chunk) => {
102
+ stderr += chunk.toString('utf8');
103
+ });
104
+ child.stdin.on('error', () => undefined);
105
+ const closed = new Promise((resolve, reject) => {
106
+ child.on('error', reject);
107
+ child.on('close', resolve);
108
+ });
109
+ try {
110
+ await imported(child.stdin, commits);
111
+ child.stdin.end();
112
+ }
113
+ catch (error) {
114
+ child.stdin.destroy();
115
+ await closed;
116
+ throw error.code === 'EPIPE' ? new Error(`git fast-import failed: ${stderr.trim()}`) : error;
84
117
  }
85
- await git(repository, ['fast-import', '--quiet', '--force'], Buffer.concat(stream));
118
+ if ((await closed) !== 0)
119
+ throw new Error(`git fast-import failed: ${stderr.trim()}`);
86
120
  return revision(repository, HOUSE_REF);
87
121
  }
package/dist/grok.js ADDED
@@ -0,0 +1,39 @@
1
+ const PLAN = 'plan';
2
+ const PLAN_ABANDONED = 'abandoned';
3
+ const PLAN_FIELD = {
4
+ type: 'string',
5
+ title: 'Approve this plan?',
6
+ oneOf: [
7
+ { const: 'approved', title: 'Approve' },
8
+ { const: PLAN_ABANDONED, title: 'Abandon' },
9
+ ],
10
+ };
11
+ function form(sessionId, message, properties) {
12
+ return { mode: 'form', sessionId, message, requestedSchema: { type: 'object', properties } };
13
+ }
14
+ function questionField({ options, multiSelect }, title) {
15
+ const choices = options.map(({ label, description }) => ({ const: label, title: label, description }));
16
+ return multiSelect === true ? { type: 'array', title, items: { anyOf: choices } } : { type: 'string', title, oneOf: choices };
17
+ }
18
+ export function grokQuestionForm({ sessionId, questions }) {
19
+ const lone = questions.length === 1;
20
+ return form(sessionId, questions.map(({ question }) => question).join('\n\n'), Object.fromEntries(questions.map((one) => [one.question, questionField(one, lone ? 'Answer' : one.question)])));
21
+ }
22
+ function answerText(value) {
23
+ return Array.isArray(value) ? value.join(', ') : String(value);
24
+ }
25
+ function contentOf(response) {
26
+ return response.action === 'accept' ? (response.content ?? {}) : {};
27
+ }
28
+ export function grokQuestionAnswer(response) {
29
+ if (response.action !== 'accept')
30
+ return { outcome: 'cancelled' };
31
+ const answers = Object.entries(contentOf(response)).map(([question, value]) => [question, answerText(value)]);
32
+ return { outcome: 'accepted', answers: Object.fromEntries(answers) };
33
+ }
34
+ export function grokPlanForm({ sessionId, planContent }) {
35
+ return form(sessionId, planContent, { [PLAN]: PLAN_FIELD });
36
+ }
37
+ export function grokPlanAnswer(response) {
38
+ return { outcome: contentOf(response)[PLAN] ?? PLAN_ABANDONED };
39
+ }
package/dist/home.js CHANGED
@@ -8,7 +8,6 @@ const ENROLMENT = 'credential.json';
8
8
  const DISCONNECTED = 'disconnected.json';
9
9
  const CONFIGURATION = 'kit.json';
10
10
  const OWN_AGENT = 'own-agent.json';
11
- const RESTART = 'restart';
12
11
  let defaulted;
13
12
  function writable(directory) {
14
13
  try {
@@ -132,12 +131,6 @@ export async function forgetRejected(rejected) {
132
131
  export function enrolled() {
133
132
  return existsSync(join(kitHome(), ENROLMENT));
134
133
  }
135
- export function restartAsked() {
136
- return existsSync(join(kitHome(), RESTART));
137
- }
138
- export function forgetRestart() {
139
- return rm(join(kitHome(), RESTART), { force: true });
140
- }
141
134
  export function readOwnAgent() {
142
135
  return readHome(OWN_AGENT);
143
136
  }
package/dist/house-cli.js CHANGED
@@ -1,9 +1,8 @@
1
1
  import { createHash } from 'node:crypto';
2
2
  import { createReadStream } from 'node:fs';
3
- import { readFile } from 'node:fs/promises';
4
- import { request, setGlobalProxyFromEnv } from 'node:http';
3
+ import { request } from 'node:http';
5
4
  import { request as httpsRequest } from 'node:https';
6
- import { basename, extname, join, resolve } from 'node:path';
5
+ import { extname, join, resolve } from 'node:path';
7
6
  import { Readable } from 'node:stream';
8
7
  import { pipeline } from 'node:stream/promises';
9
8
  import { downloaded, inspectedFile, storeRefusal, uploaded } from './files.js';
@@ -11,7 +10,7 @@ import { HOUSE_REF } from './git.js';
11
10
  import { ownerSocket, readOwnAgent } from './home.js';
12
11
  import { callHouse, rpc, UNREACHABLE, Unsettled } from './mcp.js';
13
12
  import { refusalOf, retryable } from './refusals.js';
14
- import { relayed, selectRelay } from './relay.js';
13
+ import { proxyUnlessRelayed, relayed, selectRelay } from './relay.js';
15
14
  import { parse } from 'yaml';
16
15
  const USAGE = "usage: house <tool> ['<arguments as JSON>']";
17
16
  const PUSH_USAGE = 'usage: house push [commit] [--owner]';
@@ -24,8 +23,8 @@ const ARGUMENTS = `the arguments are one JSON object in single quotes, like hous
24
23
  const CLOSED = "this conversation's House connection is closed; nothing to do from here";
25
24
  const SANDBOXED = "your CLI's sandbox kept house from House; run house directly, not through another program";
26
25
  const REVOKED = 'this conversation no longer has House access; nothing to do from here';
27
- const UNCONNECTED = "this computer's own agent has no House connection; run kit login, or kit chatgpt --key <key> with a script key";
28
- const DISCONNECTED = "House no longer accepts this computer's own agent; run kit login, or kit chatgpt --key <key> with a script key";
26
+ const UNCONNECTED = "this computer's own agent has no House connection; run kit login";
27
+ const DISCONNECTED = "House no longer accepts this computer's own agent; run kit login";
29
28
  const UNCONFIRMED = 'with no result; a write may or may not have taken effect, so read before you repeat it';
30
29
  const socketPath = process.env.HOUSE_BRIDGE;
31
30
  const MEDIA_TYPES = new Map([
@@ -90,7 +89,6 @@ async function direct(message) {
90
89
  if (ownAgent === null)
91
90
  throw new Error(UNCONNECTED);
92
91
  selectRelay(process.env.HOUSE_KIT_RELAY || ownAgent.relay);
93
- setGlobalProxyFromEnv();
94
92
  const answer = await callHouse(ownAgent.house, ownAgent.credential, message).catch(() => {
95
93
  throw new Unsettled(UNREACHABLE);
96
94
  });
@@ -116,43 +114,35 @@ function unreadable(path, error) {
116
114
  ? `${path} is a folder; upload one file at a time`
117
115
  : `${path} is not a readable file`);
118
116
  }
119
- async function localFile(path) {
120
- try {
121
- return await readFile(path);
122
- }
123
- catch (error) {
124
- throw unreadable(path, error);
125
- }
126
- }
127
117
  function opened(url, method, headers, body) {
128
118
  return new Promise((answered, failed) => {
129
119
  const local = socketPath !== undefined;
130
120
  const target = local ? null : relayed(url);
131
121
  if (!local)
132
- setGlobalProxyFromEnv();
122
+ proxyUnlessRelayed();
133
123
  const sent = target === null
134
124
  ? request({ socketPath, path: url, method, headers }, answered)
135
125
  : (target.protocol === 'https:' ? httpsRequest : request)(target, { method, headers }, answered);
136
126
  sent.on('error', (error) => failed(new Error(!local ? UNREACHABLE : error.code === 'EPERM' || error.code === 'EACCES' ? SANDBOXED : CLOSED)));
137
- if (body instanceof Readable)
138
- pipeline(body, sent).catch(() => undefined);
127
+ if (body === undefined)
128
+ sent.end();
139
129
  else
140
- sent.end(body);
130
+ pipeline(body, sent).catch(() => undefined);
141
131
  });
142
132
  }
143
- async function textOf(answer) {
144
- return Buffer.concat(await answer.toArray()).toString('utf8');
133
+ function ranged(file, start, end) {
134
+ return end === start ? undefined : createReadStream(file, { start, end: end - 1 });
145
135
  }
146
- async function sent(url, bytes, operation) {
147
- const headers = { 'content-type': 'application/octet-stream', 'x-house-byte-operation': operation };
148
- const answer = await opened(url, 'POST', headers, bytes);
149
- const text = await textOf(answer);
150
- if (answer.statusCode === 200)
151
- return text;
152
- throw new Error(refusalOf(text)?.text ?? storeRefusal('upload', answer.statusCode).message);
136
+ async function* read(file, start, end) {
137
+ try {
138
+ yield* ranged(file, start, end) ?? [];
139
+ }
140
+ catch (error) {
141
+ throw unreadable(file, error);
142
+ }
153
143
  }
154
- async function sentPart(url, file, start, end) {
155
- const answer = await opened(url, 'PUT', { 'content-length': String(end - start) }, end === start ? undefined : createReadStream(file, { start, end: end - 1 }));
144
+ async function sentPart(url, file, start, end, headers) {
145
+ const answer = await opened(url, 'PUT', { ...headers, 'content-length': String(end - start) }, ranged(file, start, end));
156
146
  await answer.toArray();
157
147
  if (answer.statusCode !== 200)
158
148
  throw storeRefusal('upload', answer.statusCode);
@@ -191,10 +181,10 @@ async function described(file) {
191
181
  const mediaType = MEDIA_TYPES.get(extname(file).slice(1).toLowerCase());
192
182
  return { bytes, sha256: digest.digest('hex'), ...(mediaType === undefined ? {} : { media_type: mediaType }) };
193
183
  }
194
- async function finished(upload, room) {
195
- const text = await called('upload', { upload, room_ref: room });
184
+ async function finished(upload, room, partSha256) {
185
+ const text = await called('upload', { upload, room_ref: room, part_sha256: partSha256 });
196
186
  const answer = parse(text);
197
- return answer !== null && ('upload' in answer || 'checking' in answer) ? answer : { text };
187
+ return answer !== null && 'upload' in answer ? answer : { text };
198
188
  }
199
189
  async function upload({ file, ...destination }) {
200
190
  if (typeof file !== 'string' || file === '')
@@ -205,33 +195,15 @@ async function upload({ file, ...destination }) {
205
195
  if (declared?.upload === undefined)
206
196
  return answer;
207
197
  const accepted = await uploaded(declared.upload, {
198
+ name: file,
208
199
  bytes: description.bytes,
209
- send: (url, start, end) => sentPart(url, file, start, end),
210
- finish: (id) => finished(id, destination.room_ref),
200
+ sha256: description.sha256,
201
+ read: (start, end) => read(file, start, end),
202
+ send: (url, start, end, headers) => sentPart(url, file, start, end, headers),
203
+ finish: (id, partSha256) => finished(id, destination.room_ref, partSha256),
211
204
  });
212
205
  return accepted.text;
213
206
  }
214
- async function appendRecord(args) {
215
- const held = new Map();
216
- const attachments = Array.isArray(args.attachments)
217
- ? await Promise.all(args.attachments.map(async (attachment) => {
218
- if (typeof attachment !== 'string')
219
- return attachment;
220
- const description = await described(attachment);
221
- held.set(description.sha256, attachment);
222
- return { name: basename(attachment), ...description };
223
- }))
224
- : args.attachments;
225
- const record = { ...args, attachments };
226
- for (;;) {
227
- const answer = await called('append_record', record);
228
- const { upload } = parse(answer);
229
- if (upload === undefined)
230
- return answer;
231
- for (const grant of upload)
232
- await sent(grant.url, await localFile(held.get(grant.sha256)), grant.operation);
233
- }
234
- }
235
207
  function unexpected(argument, usage) {
236
208
  return new Error(`unexpected argument ${argument}; ${usage}`);
237
209
  }
@@ -299,7 +271,7 @@ async function house(args) {
299
271
  return [...(tool.description === undefined ? [] : [tool.description]), JSON.stringify(tool.inputSchema)].join('\n');
300
272
  }
301
273
  const parsed = argumentsOf(argument);
302
- return verb === 'upload' ? upload(parsed) : verb === 'append_record' ? appendRecord(parsed) : called(verb, parsed);
274
+ return verb === 'upload' ? upload(parsed) : called(verb, parsed);
303
275
  }
304
276
  async function called(name, args) {
305
277
  const result = await mcp('tools/call', { name, arguments: args });
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
- const [major = 0, minor = 0] = process.versions.node.split('.').map(Number);
3
- if (major < 24 || (major === 24 && minor < 14)) {
4
- process.stderr.write(`house: the Kit needs Node 24.14.0 or newer; this is ${process.versions.node}\n`);
2
+ const [major = 0, minor = 0, patch = 0] = process.versions.node.split('.').map(Number);
3
+ if (major < 24 || (major === 24 && (minor < 22 || (minor === 22 && patch < 1)))) {
4
+ process.stderr.write(`house: the Kit needs Node 24.22.1 or newer; this is ${process.versions.node}\n`);
5
5
  process.exitCode = 1;
6
6
  }
7
7
  else {
@@ -1,12 +1,30 @@
1
- import { HOUSE_REF } from './git.js';
2
- import { readHowWeWork } from './skills.js';
3
- const SOURCE_LINE = "From House:";
4
- const HOUSE_LINE = "Work with House through the `house` CLI: run `house --help`, and `house find_command` for House's guides and formats.";
5
- const FILE_LINE = 'To give the User a file, upload it with `house upload` and link it; for an App, a Site or a website, follow `house find_command \'{"query":"app"}\'`. Never start a server.';
6
- const READ_LINE = "Optional per-Room instructions: `/rooms/private/rooms/<handle>/AGENTS.md`.";
7
- const REQUEST_LINE = "For another Agent's help, `send_routine_request`; its mail comes back into this conversation. If an Agent of your User has no Routine to call, write one in the Private Room and `create_routine_access` with your User as its only caller.";
8
- const COPIES_LINE = `House Local copies; before work run \`house fetch\` and rebase onto \`${HOUSE_REF}\`; after it commit, then \`house push\`:`;
9
- export async function instructions(bridge, base, copies) {
10
- const lines = [SOURCE_LINE, HOUSE_LINE, FILE_LINE, READ_LINE, REQUEST_LINE, ...(copies.length === 0 ? [] : [COPIES_LINE, ...copies])];
11
- return [lines.join('\n'), base, (await readHowWeWork(bridge)).replace(/\n$/, '')].filter((part) => part !== '').join('\n\n');
1
+ import { agentInstructions } from '@agentshouse/skills';
2
+ const OWNER_RULES = '/rooms/private/owner-rules.md';
3
+ const UNREADABLE = /^(?:\S+: )?(?:path_not_found|room_not_found|operation_denied)\b/;
4
+ const FAILED = /^exit: [1-9]\d*$/;
5
+ const CUT = /^stderr: shell: output_cut (\d+) of \d+ bytes; continue with: (.+)$/;
6
+ function cutOf(lines) {
7
+ const cut = CUT.exec(lines[0] ?? '');
8
+ return cut !== null && Buffer.byteLength(lines.slice(1).join('\n')) === Number(cut[1]) ? cut : null;
9
+ }
10
+ async function readOwnerRules(bridge) {
11
+ let document = '';
12
+ for (let command = `cat ${OWNER_RULES}`; command !== undefined;) {
13
+ const read = await bridge.tool('shell', { command });
14
+ const text = read.content.map((content) => content.text).join('\n');
15
+ const lines = text.split('\n');
16
+ if (read.isError === true || (FAILED.test(lines[0] ?? '') && lines[1]?.startsWith('stderr: '))) {
17
+ const refusal = read.isError === true ? text : lines.slice(1).join('\n').replace(/^stderr: /gm, '');
18
+ if (UNREADABLE.test(refusal))
19
+ return '';
20
+ throw new Error(refusal);
21
+ }
22
+ const cut = cutOf(lines);
23
+ document += lines.slice(cut === null ? 0 : 1).join('\n');
24
+ command = cut?.[2];
25
+ }
26
+ return document;
27
+ }
28
+ export async function instructions(bridge, base) {
29
+ return [agentInstructions().join('\n'), base, (await readOwnerRules(bridge)).replace(/\n$/, '')].filter((part) => part !== '').join('\n\n');
12
30
  }
package/dist/kit-cli.js CHANGED
@@ -1,11 +1,10 @@
1
- import { setGlobalProxyFromEnv } from 'node:http';
2
1
  import { parseArgs } from 'node:util';
3
2
  import { answerGitCredential } from './app-git.js';
4
- import { chatgpt } from './chatgpt.js';
5
3
  import { login } from './login.js';
6
4
  import { logout } from './logout.js';
5
+ import { proxyUnlessRelayed } from './relay.js';
7
6
  import { resident } from './resident.js';
8
- const USAGE = 'usage: kit <login|logout|resident|chatgpt>\n';
7
+ const USAGE = 'usage: kit <login|logout|resident>\n';
9
8
  const COMMANDS = new Map([
10
9
  [
11
10
  'logout',
@@ -36,12 +35,10 @@ const COMMANDS = new Map([
36
35
  ],
37
36
  ]);
38
37
  const [command, ...argv] = process.argv.slice(2);
39
- setGlobalProxyFromEnv();
38
+ proxyUnlessRelayed();
40
39
  async function run() {
41
40
  if (command === 'login')
42
41
  return login(argv);
43
- if (command === 'chatgpt')
44
- return chatgpt(argv);
45
42
  if (command === '--help') {
46
43
  parseArgs({ args: argv });
47
44
  process.stdout.write(USAGE);
package/dist/kit-main.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
- const [major = 0, minor = 0] = process.versions.node.split('.').map(Number);
3
- if (major < 24 || (major === 24 && minor < 14)) {
4
- process.stderr.write(`kit: the Kit needs Node 24.14.0 or newer; this is ${process.versions.node}\n`);
2
+ const [major = 0, minor = 0, patch = 0] = process.versions.node.split('.').map(Number);
3
+ if (major < 24 || (major === 24 && (minor < 22 || (minor === 22 && patch < 1)))) {
4
+ process.stderr.write(`kit: the Kit needs Node 24.22.1 or newer; this is ${process.versions.node}\n`);
5
5
  process.exitCode = 1;
6
6
  }
7
7
  else {
package/dist/login.js CHANGED
@@ -10,7 +10,8 @@ import { refusalOf } from './refusals.js';
10
10
  import { selectRelay } from './relay.js';
11
11
  import { startService } from './service.js';
12
12
  import { placeSkillSet } from './skills.js';
13
- export const DEFAULT_HOUSE = 'https://agents.house';
13
+ import { endUnserved } from './wire.js';
14
+ const DEFAULT_HOUSE = 'https://agents.house';
14
15
  const OPENER = process.platform === 'darwin' ? 'open' : 'xdg-open';
15
16
  // Polling every two seconds brings the User's confirmation to the waiting Kit moments after they give it.
16
17
  const POLL_INTERVAL_MS = 2000;
@@ -19,12 +20,13 @@ function open(link) {
19
20
  .on('error', () => undefined)
20
21
  .unref();
21
22
  }
22
- export async function accepted(house, credential) {
23
+ async function accepted(house, credential) {
23
24
  const checked = await callHouse(house, credential, rpc('tools/list', {}));
24
25
  if (checked.status === 200)
25
26
  return true;
26
27
  if (checked.status === 401)
27
28
  return false;
29
+ endUnserved(checked.text);
28
30
  throw new Error(`House answered ${checked.status} when Kit checked this computer's own agent's connection: ${checked.text}`);
29
31
  }
30
32
  const USAGE = `usage: kit login [--house <origin>] [--environment <id>] [--rooms <ref>[,<ref>...] | --no-private]
@@ -119,7 +121,7 @@ export async function login(argv) {
119
121
  open(started.start_url);
120
122
  exchanged = await retrying(() => post(house, '/kit/token', { login: started.login, code_verifier: verifier }), undefined, () => POLL_INTERVAL_MS);
121
123
  }
122
- await placeSkillSet();
124
+ await placeSkillSet(house);
123
125
  await writeCodexRule().catch((error) => process.stderr.write(`kit: ${error.message}\n`));
124
126
  const relayRecord = relay === undefined ? {} : { relay };
125
127
  await writeEnrolment({
package/dist/logout.js CHANGED
@@ -4,7 +4,7 @@ export async function logout() {
4
4
  const enrolled = await readEnrolment();
5
5
  if (enrolled !== null) {
6
6
  try {
7
- await post(enrolled.house, '/kit/logout', {}, enrolled.credential);
7
+ await post(enrolled.house, '/kit/kits/log-out', {}, enrolled.credential);
8
8
  }
9
9
  catch (error) {
10
10
  if (!(error instanceof HouseRefusal && error.status === 401))
package/dist/mcp.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { randomUUID } from 'node:crypto';
2
2
  import { KIT_RELEASE } from './clis.js';
3
3
  import { relayed } from './relay.js';
4
+ import { KIT_WIRE, KIT_WIRE_HEADER } from './wire.js';
4
5
  const MCP_PROTOCOL_VERSION = '2026-07-28';
5
6
  export const UNREACHABLE = 'House is unreachable; call again in a minute';
6
7
  export class Unsettled extends Error {
@@ -33,6 +34,7 @@ export async function callHouse(origin, credential, message, operation = null, s
33
34
  'mcp-protocol-version': MCP_PROTOCOL_VERSION,
34
35
  'mcp-method': message.method,
35
36
  ...(tool === null ? {} : { 'mcp-name': tool }),
37
+ [KIT_WIRE_HEADER]: String(KIT_WIRE),
36
38
  },
37
39
  body: mcpBody(message, operation),
38
40
  signal,
package/dist/placement.js CHANGED
@@ -1,23 +1,6 @@
1
1
  import { readFileSync } from 'node:fs';
2
- import { join } from 'node:path';
3
- import { run } from './clis.js';
2
+ import { join, resolve } from 'node:path';
4
3
  import { kitHome } from './home.js';
5
- export function service() {
6
- if (process.platform !== 'linux' || !process.env.INVOCATION_ID)
7
- return null;
8
- return process.env.MANAGERPID ? 'user' : 'system';
9
- }
10
- export function throughSudo() {
11
- return service() === 'system' && process.getuid() !== 0;
12
- }
13
- export async function updatesItself() {
14
- if (service() === null)
15
- return false;
16
- if (!throughSudo())
17
- return true;
18
- // sudo answers at once, so ten seconds only bounds a stuck sudo.
19
- return (await run('sudo', ['-n', 'true'], 10_000)).status === 0;
20
- }
21
4
  function recorded(name) {
22
5
  try {
23
6
  return readFileSync(join(kitHome(), name), 'utf8').trim();
@@ -37,3 +20,12 @@ export function machine() {
37
20
  return placed;
38
21
  return process.platform === 'darwin' ? 'macos' : 'linux';
39
22
  }
23
+ export function placedPrefix() {
24
+ const prefix = process.env.HOUSE_KIT_PREFIX;
25
+ if (prefix === undefined || prefix === '')
26
+ throw new Error('this Kit process was not started by a launcher its installer placed');
27
+ return resolve(prefix);
28
+ }
29
+ export function releaseDirectory(release) {
30
+ return join(placedPrefix(), 'releases', release);
31
+ }
package/dist/relay.js CHANGED
@@ -1,6 +1,11 @@
1
+ import { setGlobalProxyFromEnv } from 'node:http';
2
+ const PROXY = /^https?_proxy$/i;
3
+ const LOOPBACK = ['127.0.0.1', 'localhost', '::1'];
1
4
  let selected;
5
+ let restoreProxy;
2
6
  export function selectRelay(relay) {
3
7
  selected = relay === undefined || relay === '' ? null : relay;
8
+ proxyUnlessRelayed();
4
9
  }
5
10
  export function relayOrigin() {
6
11
  if (selected !== undefined)
@@ -8,6 +13,22 @@ export function relayOrigin() {
8
13
  const ambient = process.env.HOUSE_KIT_RELAY;
9
14
  return ambient === undefined || ambient === '' ? undefined : ambient;
10
15
  }
16
+ function unlessRelayed() {
17
+ if (relayOrigin() === undefined)
18
+ return { ...process.env };
19
+ return Object.fromEntries(Object.entries(process.env).filter(([name]) => !PROXY.test(name)));
20
+ }
21
+ export function proxyUnlessRelayed() {
22
+ restoreProxy?.();
23
+ restoreProxy = setGlobalProxyFromEnv(unlessRelayed());
24
+ }
25
+ export function childEnvironment() {
26
+ const environment = unlessRelayed();
27
+ if (!Object.keys(environment).some((name) => PROXY.test(name)))
28
+ return environment;
29
+ const bypassed = [environment.NO_PROXY ?? environment.no_proxy, ...LOOPBACK].filter((entry) => entry !== undefined && entry !== '').join(',');
30
+ return { ...environment, NO_PROXY: bypassed, no_proxy: bypassed };
31
+ }
11
32
  export function relayed(target) {
12
33
  const url = new URL(target);
13
34
  const relay = relayOrigin();