@agentshouse/kit 0.2.1-ca18b01951c3b → 0.2.1-cab5821cf0a77
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.
- package/README.md +33 -33
- package/dist/acp.js +90 -19
- package/dist/agents.js +101 -45
- package/dist/api.js +5 -5
- package/dist/app-git.js +10 -26
- package/dist/authority-main.js +2 -2
- package/dist/bridge.js +4 -7
- package/dist/building.js +50 -0
- package/dist/calls.js +71 -0
- package/dist/chatgpt.js +4 -1
- package/dist/clis.js +43 -40
- package/dist/{stream.js → connection.js} +34 -52
- package/dist/conversations.js +516 -175
- package/dist/copies.js +77 -50
- package/dist/end.js +15 -4
- package/dist/events.js +33 -8
- package/dist/files.js +139 -37
- package/dist/git.js +5 -6
- package/dist/home.js +27 -20
- package/dist/house-cli.js +299 -0
- package/dist/house-main.js +7 -289
- package/dist/instructions.js +29 -8
- package/dist/kit-cli.js +68 -0
- package/dist/kit-main.js +8 -67
- package/dist/login.js +18 -9
- package/dist/logout.js +0 -2
- package/dist/mcp.js +6 -2
- package/dist/placement.js +19 -36
- package/dist/relay.js +21 -0
- package/dist/resident.js +97 -42
- package/dist/scope.js +15 -4
- package/dist/scripts.js +255 -0
- package/dist/service.js +23 -1
- package/dist/sign-in.js +22 -39
- package/dist/silence.js +28 -0
- package/dist/skills.js +42 -97
- package/dist/transcription.js +83 -43
- package/dist/translate.js +2 -8
- package/dist/update.js +113 -127
- package/dist/wire.js +37 -3
- package/dist/work.js +3 -5
- package/package.json +20 -21
- package/dist/bootstrap.json +0 -24
- package/dist/clis-main.js +0 -23
- package/how-we-work.md +0 -33
- package/skills/ask-matt/LICENSE +0 -21
- package/skills/ask-matt/PHASE-BOUNDARIES.md +0 -55
- package/skills/ask-matt/SKILL.md +0 -97
- package/skills/ask-matt/agents/openai.yaml +0 -5
- package/skills/code-review/LICENSE +0 -21
- package/skills/code-review/SKILL.md +0 -89
- package/skills/code-review/agents/openai.yaml +0 -3
- package/skills/codebase-design/DEEPENING.md +0 -37
- package/skills/codebase-design/DESIGN-IT-TWICE.md +0 -44
- package/skills/codebase-design/LICENSE +0 -21
- package/skills/codebase-design/SKILL.md +0 -114
- package/skills/codebase-design/agents/openai.yaml +0 -3
- package/skills/diagnosing-bugs/LICENSE +0 -21
- package/skills/diagnosing-bugs/SKILL.md +0 -138
- package/skills/diagnosing-bugs/agents/openai.yaml +0 -3
- package/skills/diagnosing-bugs/scripts/hitl-loop.template.sh +0 -44
- package/skills/domain-modeling/ADR-FORMAT.md +0 -47
- package/skills/domain-modeling/GLOSSARY-FORMAT.md +0 -60
- package/skills/domain-modeling/LICENSE +0 -21
- package/skills/domain-modeling/SKILL.md +0 -74
- package/skills/domain-modeling/agents/openai.yaml +0 -3
- package/skills/grill-me/LICENSE +0 -21
- package/skills/grill-me/SKILL.md +0 -7
- package/skills/grill-me/agents/openai.yaml +0 -5
- package/skills/grill-with-docs/LICENSE +0 -21
- package/skills/grill-with-docs/SKILL.md +0 -7
- package/skills/grill-with-docs/agents/openai.yaml +0 -5
- package/skills/grilling/LICENSE +0 -21
- package/skills/grilling/SKILL.md +0 -30
- package/skills/grilling/agents/openai.yaml +0 -3
- package/skills/handoff/LICENSE +0 -21
- package/skills/handoff/SKILL.md +0 -16
- package/skills/handoff/agents/openai.yaml +0 -5
- package/skills/implement/LICENSE +0 -21
- package/skills/implement/SKILL.md +0 -17
- package/skills/implement/agents/openai.yaml +0 -5
- package/skills/implement-spec/LICENSE +0 -21
- package/skills/implement-spec/SKILL.md +0 -40
- package/skills/implement-spec/agents/openai.yaml +0 -5
- package/skills/improve-codebase-architecture/HTML-REPORT.md +0 -123
- package/skills/improve-codebase-architecture/LICENSE +0 -21
- package/skills/improve-codebase-architecture/SKILL.md +0 -71
- package/skills/improve-codebase-architecture/agents/openai.yaml +0 -5
- package/skills/pr/CREDITS.md +0 -3
- package/skills/pr/LICENSE +0 -21
- package/skills/pr/SKILL.md +0 -170
- package/skills/pr/agents/openai.yaml +0 -3
- package/skills/prototype/LICENSE +0 -21
- package/skills/prototype/LOGIC.md +0 -67
- package/skills/prototype/SKILL.md +0 -26
- package/skills/prototype/UI.md +0 -112
- package/skills/prototype/agents/openai.yaml +0 -3
- package/skills/research/LICENSE +0 -21
- package/skills/research/SKILL.md +0 -12
- package/skills/research/agents/openai.yaml +0 -3
- package/skills/retro/LICENSE +0 -21
- package/skills/retro/SKILL.md +0 -44
- package/skills/retro/agents/openai.yaml +0 -5
- package/skills/tdd/LICENSE +0 -21
- package/skills/tdd/SKILL.md +0 -38
- package/skills/tdd/agents/openai.yaml +0 -3
- package/skills/tdd/mocking.md +0 -59
- package/skills/tdd/tests.md +0 -77
- package/skills/teach/GLOSSARY-FORMAT.md +0 -35
- package/skills/teach/LEARNING-RECORD-FORMAT.md +0 -46
- package/skills/teach/LICENSE +0 -21
- package/skills/teach/MISSION-FORMAT.md +0 -31
- package/skills/teach/RESOURCES-FORMAT.md +0 -32
- package/skills/teach/SKILL.md +0 -140
- package/skills/teach/agents/openai.yaml +0 -5
- package/skills/to-questionnaire/LICENSE +0 -21
- package/skills/to-questionnaire/SKILL.md +0 -54
- package/skills/to-questionnaire/agents/openai.yaml +0 -5
- package/skills/to-spec/LICENSE +0 -21
- package/skills/to-spec/SKILL.md +0 -75
- package/skills/to-spec/agents/openai.yaml +0 -5
- package/skills/to-tickets/LICENSE +0 -21
- package/skills/to-tickets/SKILL.md +0 -105
- package/skills/to-tickets/agents/openai.yaml +0 -5
- package/skills/triage/AGENT-BRIEF.md +0 -207
- package/skills/triage/LICENSE +0 -21
- package/skills/triage/OUT-OF-SCOPE.md +0 -105
- package/skills/triage/SKILL.md +0 -112
- package/skills/triage/agents/openai.yaml +0 -5
- package/skills/wait-what/LICENSE +0 -21
- package/skills/wait-what/SKILL.md +0 -7
- package/skills/wait-what/agents/openai.yaml +0 -5
- package/skills/wayfinder/LICENSE +0 -21
- package/skills/wayfinder/SKILL.md +0 -128
- package/skills/wayfinder/agents/openai.yaml +0 -5
- package/skills/wizard/LICENSE +0 -21
- package/skills/wizard/SKILL.md +0 -44
- package/skills/wizard/agents/openai.yaml +0 -3
- package/skills/wizard/template.sh +0 -223
- package/skills/writing-for-agents/LICENSE +0 -21
- package/skills/writing-for-agents/SKILL-MECHANICS.md +0 -22
- package/skills/writing-for-agents/SKILL.md +0 -81
- package/skills/writing-for-agents/agents/openai.yaml +0 -3
package/dist/house-main.js
CHANGED
|
@@ -1,292 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { verified } from './files.js';
|
|
7
|
-
import { HOUSE_REF } from './git.js';
|
|
8
|
-
import { kitHome, readOwnAgent } from './home.js';
|
|
9
|
-
import { callHouse, rpc, UNREACHABLE } from './mcp.js';
|
|
10
|
-
import { refusalOf } from './refusals.js';
|
|
11
|
-
import { relayed, selectRelay } from './relay.js';
|
|
12
|
-
import { parse, stringify } from 'yaml';
|
|
13
|
-
const USAGE = "usage: house <tool> ['<arguments as JSON>']";
|
|
14
|
-
const PUSH_USAGE = 'usage: house push [commit] [--owner]';
|
|
15
|
-
const PUSH = "push [commit]: sends the Local copy's committed changes to House";
|
|
16
|
-
const FETCH_USAGE = 'usage: house fetch';
|
|
17
|
-
const FETCH = `fetch: records House's changes on each Local copy's ${HOUSE_REF}`;
|
|
18
|
-
const DOWNLOAD_USAGE = `usage: house download '{"path":"/rooms/<handle>/<path>","file":"<local file>"}', adding "ref" for a revision`;
|
|
19
|
-
const DOWNLOAD = 'download: writes a binary file of a Room to the local file named by file';
|
|
20
|
-
const ARGUMENTS = `the arguments are one JSON object in single quotes, like house search '{"query":"invoice"}'`;
|
|
21
|
-
const CLOSED = "this conversation's House connection is closed; nothing to do from here";
|
|
22
|
-
const SANDBOXED = "your CLI's sandbox kept house from House; run house directly, not through another program";
|
|
23
|
-
const REVOKED = 'this conversation no longer has House access; nothing to do from here';
|
|
24
|
-
const UNCONNECTED = "this computer's own agent has no House connection; run kit login, or kit chatgpt --key <key> with a script key";
|
|
25
|
-
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 UNCONFIRMED = 'with no result; a write may or may not have taken effect, so read before you repeat it';
|
|
27
|
-
const socketPath = process.env.HOUSE_BRIDGE;
|
|
28
|
-
const MEDIA_TYPES = new Map([
|
|
29
|
-
['avif', 'image/avif'],
|
|
30
|
-
['csv', 'text/csv'],
|
|
31
|
-
['docx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'],
|
|
32
|
-
['gif', 'image/gif'],
|
|
33
|
-
['heic', 'image/heic'],
|
|
34
|
-
['html', 'text/html'],
|
|
35
|
-
['jpeg', 'image/jpeg'],
|
|
36
|
-
['jpg', 'image/jpeg'],
|
|
37
|
-
['json', 'application/json'],
|
|
38
|
-
['m4a', 'audio/mp4'],
|
|
39
|
-
['md', 'text/markdown'],
|
|
40
|
-
['mov', 'video/quicktime'],
|
|
41
|
-
['mp3', 'audio/mpeg'],
|
|
42
|
-
['mp4', 'video/mp4'],
|
|
43
|
-
['ogg', 'audio/ogg'],
|
|
44
|
-
['pdf', 'application/pdf'],
|
|
45
|
-
['png', 'image/png'],
|
|
46
|
-
['pptx', 'application/vnd.openxmlformats-officedocument.presentationml.presentation'],
|
|
47
|
-
['svg', 'image/svg+xml'],
|
|
48
|
-
['txt', 'text/plain'],
|
|
49
|
-
['wav', 'audio/wav'],
|
|
50
|
-
['webm', 'video/webm'],
|
|
51
|
-
['webp', 'image/webp'],
|
|
52
|
-
['xlsx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'],
|
|
53
|
-
['zip', 'application/zip'],
|
|
54
|
-
]);
|
|
55
|
-
function refused(path, method, status, text, local) {
|
|
56
|
-
const refusal = refusalOf(text);
|
|
57
|
-
if (refusal !== null)
|
|
58
|
-
return refusal.text;
|
|
59
|
-
if (status === 401)
|
|
60
|
-
return REVOKED;
|
|
61
|
-
const act = method === 'GET' ? 'download' : 'upload';
|
|
62
|
-
if (URL.canParse(path))
|
|
63
|
-
return `the ${act} answered ${status}; ${act} the file again`;
|
|
64
|
-
if (status === 502 && local)
|
|
65
|
-
return text;
|
|
66
|
-
return path === '/' ? unconfirmed(status) : `${path} answered ${status}`;
|
|
67
|
-
}
|
|
68
|
-
function unconfirmed(status) {
|
|
69
|
-
return `House answered ${status} ${UNCONFIRMED}`;
|
|
70
|
-
}
|
|
71
|
-
function exchanged(path, method, body, headers = { 'content-type': 'application/json' }, to = socketPath) {
|
|
72
|
-
return new Promise((resolve, reject) => {
|
|
73
|
-
const sent = request({ socketPath: to, path, method, headers }, (answer) => {
|
|
74
|
-
const chunks = [];
|
|
75
|
-
answer.on('data', (chunk) => chunks.push(chunk));
|
|
76
|
-
answer.on('end', () => {
|
|
77
|
-
const bytes = Buffer.concat(chunks);
|
|
78
|
-
if (answer.statusCode === 200)
|
|
79
|
-
resolve(bytes);
|
|
80
|
-
else
|
|
81
|
-
reject(new Error(refused(path, method, answer.statusCode, bytes.toString('utf8'), answer.headers['content-type'] === undefined)));
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
sent.on('error', (error) => reject(new Error(error.code === 'EPERM' || error.code === 'EACCES' ? SANDBOXED : CLOSED)));
|
|
85
|
-
sent.end(body === undefined ? undefined : body instanceof Buffer ? body : JSON.stringify(body));
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
async function bridged(path, body, headers, to = socketPath) {
|
|
89
|
-
return (await exchanged(path, 'POST', body, headers, to)).toString('utf8');
|
|
90
|
-
}
|
|
91
|
-
async function direct(message) {
|
|
92
|
-
const ownAgent = await readOwnAgent();
|
|
93
|
-
if (ownAgent === null)
|
|
94
|
-
throw new Error(UNCONNECTED);
|
|
95
|
-
selectRelay(process.env.HOUSE_KIT_RELAY || ownAgent.relay);
|
|
96
|
-
setGlobalProxyFromEnv();
|
|
97
|
-
const answer = await callHouse(ownAgent.house, ownAgent.credential, message).catch(() => {
|
|
98
|
-
throw new Error(UNREACHABLE);
|
|
99
|
-
});
|
|
100
|
-
if (answer.status === 200)
|
|
101
|
-
return answer.text;
|
|
102
|
-
throw new Error(answer.status === 401 ? DISCONNECTED : (refusalOf(answer.text)?.text ?? unconfirmed(answer.status)));
|
|
103
|
-
}
|
|
104
|
-
async function mcp(method, params) {
|
|
105
|
-
const message = rpc(method, params);
|
|
106
|
-
const answer = JSON.parse(socketPath === undefined ? await direct(message) : await bridged('/', message));
|
|
107
|
-
if (answer.error !== undefined)
|
|
108
|
-
throw new Error(answer.error.message);
|
|
109
|
-
return answer.result;
|
|
110
|
-
}
|
|
111
|
-
async function tools() {
|
|
112
|
-
return (await mcp('tools/list', {})).tools;
|
|
113
|
-
}
|
|
114
|
-
async function localFile(path) {
|
|
115
|
-
try {
|
|
116
|
-
return await readFile(path);
|
|
117
|
-
}
|
|
118
|
-
catch (error) {
|
|
119
|
-
throw new Error(error.code === 'EISDIR'
|
|
120
|
-
? `${path} is a folder; upload one file at a time`
|
|
121
|
-
: `${path} is not a readable file`);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
async function transferred(url, method, bytes, headers) {
|
|
125
|
-
if (socketPath !== undefined)
|
|
126
|
-
return exchanged(url, method, bytes, headers);
|
|
127
|
-
setGlobalProxyFromEnv();
|
|
128
|
-
const answer = await fetch(relayed(url), { method, ...(headers === undefined ? {} : { headers }), ...(bytes === undefined ? {} : { body: bytes }) }).catch(() => {
|
|
129
|
-
throw new Error(UNREACHABLE);
|
|
130
|
-
});
|
|
131
|
-
const received = Buffer.from(await answer.arrayBuffer());
|
|
132
|
-
if (answer.status === 200)
|
|
133
|
-
return received;
|
|
134
|
-
throw new Error(refused(url, method, answer.status, received.toString('utf8'), false));
|
|
135
|
-
}
|
|
136
|
-
async function sent(url, bytes, operation) {
|
|
137
|
-
const headers = { 'content-type': 'application/octet-stream', 'x-house-byte-operation': operation };
|
|
138
|
-
return (await transferred(url, 'POST', bytes, headers)).toString('utf8');
|
|
139
|
-
}
|
|
140
|
-
async function download(args) {
|
|
141
|
-
const { flags, positionals: [argument] } = accepted(args, ['--help'], 1, DOWNLOAD_USAGE);
|
|
142
|
-
if (flags.has('--help'))
|
|
143
|
-
return DOWNLOAD_USAGE;
|
|
144
|
-
const { file, ...selected } = argumentsOf(argument);
|
|
145
|
-
if (typeof file !== 'string' || file === '')
|
|
146
|
-
throw new Error('download needs "file", the local file to write');
|
|
147
|
-
const inspected = parse(await called('inspect', selected));
|
|
148
|
-
if (typeof inspected?.download !== 'string')
|
|
149
|
-
throw new Error(`${String(selected.path)} holds no binary file; shell reads its text`);
|
|
150
|
-
const bytes = verified(await transferred(inspected.download, 'GET'), String(inspected.sha256), String(selected.path));
|
|
151
|
-
const written = resolve(file);
|
|
152
|
-
await mkdir(dirname(written), { recursive: true });
|
|
153
|
-
await writeFile(written, bytes);
|
|
154
|
-
return written;
|
|
155
|
-
}
|
|
156
|
-
async function described(file) {
|
|
157
|
-
const bytes = await localFile(file);
|
|
158
|
-
const mediaType = MEDIA_TYPES.get(extname(file).slice(1).toLowerCase());
|
|
159
|
-
return {
|
|
160
|
-
bytes,
|
|
161
|
-
description: {
|
|
162
|
-
bytes: bytes.length,
|
|
163
|
-
sha256: createHash('sha256').update(bytes).digest('hex'),
|
|
164
|
-
...(mediaType === undefined ? {} : { media_type: mediaType }),
|
|
165
|
-
},
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
async function upload({ file, ...destination }) {
|
|
169
|
-
if (typeof file !== 'string' || file === '')
|
|
170
|
-
throw new Error('upload needs "file", a local file');
|
|
171
|
-
const { bytes, description } = await described(file);
|
|
172
|
-
const answer = await called('upload', { ...destination, ...description });
|
|
173
|
-
const declared = parse(answer);
|
|
174
|
-
if (declared.upload === undefined)
|
|
175
|
-
return answer;
|
|
176
|
-
const written = JSON.parse(await sent(declared.upload.url, bytes, declared.upload.operation));
|
|
177
|
-
return stringify(written, { lineWidth: 0 }).trimEnd();
|
|
178
|
-
}
|
|
179
|
-
async function appendRecord(args) {
|
|
180
|
-
const held = new Map();
|
|
181
|
-
const attachments = Array.isArray(args.attachments)
|
|
182
|
-
? await Promise.all(args.attachments.map(async (attachment) => {
|
|
183
|
-
if (typeof attachment !== 'string')
|
|
184
|
-
return attachment;
|
|
185
|
-
const { bytes, description } = await described(attachment);
|
|
186
|
-
held.set(description.sha256, bytes);
|
|
187
|
-
return { name: basename(attachment), ...description };
|
|
188
|
-
}))
|
|
189
|
-
: args.attachments;
|
|
190
|
-
const record = { ...args, attachments };
|
|
191
|
-
for (;;) {
|
|
192
|
-
const answer = await called('append_record', record);
|
|
193
|
-
const { upload } = parse(answer);
|
|
194
|
-
if (upload === undefined)
|
|
195
|
-
return answer;
|
|
196
|
-
for (const grant of upload)
|
|
197
|
-
await sent(grant.url, held.get(grant.sha256), grant.operation);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
function unexpected(argument, usage) {
|
|
201
|
-
return new Error(`unexpected argument ${argument}; ${usage}`);
|
|
202
|
-
}
|
|
203
|
-
function accepted(args, flags, positionals, usage) {
|
|
204
|
-
const given = { flags: new Set(), positionals: [] };
|
|
205
|
-
for (const arg of args) {
|
|
206
|
-
if (flags.includes(arg))
|
|
207
|
-
given.flags.add(arg);
|
|
208
|
-
else if (!arg.startsWith('-') && given.positionals.length < positionals)
|
|
209
|
-
given.positionals.push(arg);
|
|
210
|
-
else
|
|
211
|
-
throw unexpected(arg, usage);
|
|
212
|
-
}
|
|
213
|
-
return given;
|
|
214
|
-
}
|
|
215
|
-
async function push(args) {
|
|
216
|
-
const { flags, positionals: [commit = 'HEAD'] } = accepted(args, ['--help', '--owner'], 1, PUSH_USAGE);
|
|
217
|
-
if (flags.has('--help'))
|
|
218
|
-
return PUSH_USAGE;
|
|
219
|
-
const owner = flags.has('--owner');
|
|
220
|
-
if (owner && socketPath !== undefined)
|
|
221
|
-
throw new Error('--owner is not for Agent conversations; run house push without it');
|
|
222
|
-
if (!owner && socketPath === undefined)
|
|
223
|
-
throw new Error('outside an Agent conversation, house push needs --owner');
|
|
224
|
-
const pushed = JSON.parse(await bridged('/git/push', { cwd: process.cwd(), commit }, undefined, owner ? join(kitHome(), 'owner.sock') : socketPath));
|
|
225
|
-
if (pushed.refused)
|
|
226
|
-
throw new Error(pushed.text);
|
|
227
|
-
return pushed.text;
|
|
228
|
-
}
|
|
229
|
-
async function fetched(args) {
|
|
230
|
-
if (accepted(args, ['--help'], 0, FETCH_USAGE).flags.has('--help'))
|
|
231
|
-
return FETCH_USAGE;
|
|
232
|
-
const answer = JSON.parse(await bridged('/git/fetch', {}, undefined, socketPath ?? join(kitHome(), 'owner.sock')));
|
|
233
|
-
if (answer.refused)
|
|
234
|
-
throw new Error(answer.text);
|
|
235
|
-
return answer.text;
|
|
236
|
-
}
|
|
237
|
-
function argumentsOf(argument) {
|
|
238
|
-
if (argument === undefined)
|
|
239
|
-
return {};
|
|
240
|
-
let parsed;
|
|
241
|
-
try {
|
|
242
|
-
parsed = JSON.parse(argument);
|
|
243
|
-
}
|
|
244
|
-
catch {
|
|
245
|
-
throw new Error(ARGUMENTS);
|
|
246
|
-
}
|
|
247
|
-
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed))
|
|
248
|
-
throw new Error(ARGUMENTS);
|
|
249
|
-
return parsed;
|
|
250
|
-
}
|
|
251
|
-
async function house(args) {
|
|
252
|
-
const { flags, positionals: [verb, argument] } = accepted(args, ['--help'], 2, USAGE);
|
|
253
|
-
if (verb === 'help' && argument !== undefined)
|
|
254
|
-
throw unexpected(argument, USAGE);
|
|
255
|
-
if (flags.has('--help') && argument !== undefined)
|
|
256
|
-
throw unexpected('--help', USAGE);
|
|
257
|
-
if (verb === undefined || verb === 'help') {
|
|
258
|
-
return [USAGE, 'help', PUSH, FETCH, DOWNLOAD, ...(await tools()).map((tool) => (tool.description === undefined ? tool.name : `${tool.name}: ${tool.description}`))].join('\n');
|
|
259
|
-
}
|
|
260
|
-
if (flags.has('--help')) {
|
|
261
|
-
const tool = (await tools()).find((listed) => listed.name === verb);
|
|
262
|
-
if (tool === undefined)
|
|
263
|
-
throw new Error(`${verb} is no Tool; house find_command '{"query":"${verb}"}' finds Commands`);
|
|
264
|
-
return [...(tool.description === undefined ? [] : [tool.description]), JSON.stringify(tool.inputSchema)].join('\n');
|
|
265
|
-
}
|
|
266
|
-
const parsed = argumentsOf(argument);
|
|
267
|
-
return verb === 'upload' ? upload(parsed) : verb === 'append_record' ? appendRecord(parsed) : called(verb, parsed);
|
|
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
|
+
process.exitCode = 1;
|
|
268
6
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
const text = result.content.map((content) => content.text).join('\n');
|
|
272
|
-
if (result.isError === true)
|
|
273
|
-
throw new Error(text.replace(/\n+$/, ''));
|
|
274
|
-
return text;
|
|
7
|
+
else {
|
|
8
|
+
await import('./house-cli.js');
|
|
275
9
|
}
|
|
276
|
-
|
|
277
|
-
const named = argv.findIndex((arg) => !arg.startsWith('-'));
|
|
278
|
-
const rest = argv.filter((_arg, index) => index !== named);
|
|
279
|
-
(argv[named] === 'push'
|
|
280
|
-
? push(rest)
|
|
281
|
-
: argv[named] === 'fetch'
|
|
282
|
-
? fetched(rest)
|
|
283
|
-
: argv[named] === 'download'
|
|
284
|
-
? download(rest)
|
|
285
|
-
: house(argv)).then((text) => {
|
|
286
|
-
process.stdout.write(`${text}\n`);
|
|
287
|
-
if (argv[0] === 'shell')
|
|
288
|
-
process.exitCode = Number(/^exit: (\d+)(?:\n|$)/.exec(text)?.[1] ?? 0);
|
|
289
|
-
}, (error) => {
|
|
290
|
-
process.stderr.write(`house: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
291
|
-
process.exitCode = 1;
|
|
292
|
-
});
|
|
10
|
+
export {};
|
package/dist/instructions.js
CHANGED
|
@@ -1,11 +1,32 @@
|
|
|
1
|
+
import { agentInstructions } from '@agentshouse/skills';
|
|
1
2
|
import { HOUSE_REF } from './git.js';
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const
|
|
3
|
+
const OWNER_RULES = '/rooms/private/owner-rules.md';
|
|
4
|
+
const UNREADABLE = /^(?:\S+: )?(?:path_not_found|room_not_found|operation_denied)\b/;
|
|
5
|
+
const FAILED = /^exit: [1-9]\d*$/;
|
|
6
|
+
const CUT = /^stderr: shell: output_cut (\d+) of \d+ bytes; continue with: (.+)$/;
|
|
7
|
+
function cutOf(lines) {
|
|
8
|
+
const cut = CUT.exec(lines[0] ?? '');
|
|
9
|
+
return cut !== null && Buffer.byteLength(lines.slice(1).join('\n')) === Number(cut[1]) ? cut : null;
|
|
10
|
+
}
|
|
11
|
+
async function readOwnerRules(bridge) {
|
|
12
|
+
let document = '';
|
|
13
|
+
for (let command = `cat ${OWNER_RULES}`; command !== undefined;) {
|
|
14
|
+
const read = await bridge.tool('shell', { command });
|
|
15
|
+
const text = read.content.map((content) => content.text).join('\n');
|
|
16
|
+
const lines = text.split('\n');
|
|
17
|
+
if (read.isError === true || (FAILED.test(lines[0] ?? '') && lines[1]?.startsWith('stderr: '))) {
|
|
18
|
+
const refusal = read.isError === true ? text : lines.slice(1).join('\n').replace(/^stderr: /gm, '');
|
|
19
|
+
if (UNREADABLE.test(refusal))
|
|
20
|
+
return '';
|
|
21
|
+
throw new Error(refusal);
|
|
22
|
+
}
|
|
23
|
+
const cut = cutOf(lines);
|
|
24
|
+
document += lines.slice(cut === null ? 0 : 1).join('\n');
|
|
25
|
+
command = cut?.[2];
|
|
26
|
+
}
|
|
27
|
+
return document;
|
|
28
|
+
}
|
|
8
29
|
export async function instructions(bridge, base, copies) {
|
|
9
|
-
const lines =
|
|
10
|
-
return [lines.join('\n'), base, (await
|
|
30
|
+
const lines = agentInstructions(HOUSE_REF, copies);
|
|
31
|
+
return [lines.join('\n'), base, (await readOwnerRules(bridge)).replace(/\n$/, '')].filter((part) => part !== '').join('\n\n');
|
|
11
32
|
}
|
package/dist/kit-cli.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { parseArgs } from 'node:util';
|
|
2
|
+
import { answerGitCredential } from './app-git.js';
|
|
3
|
+
import { chatgpt } from './chatgpt.js';
|
|
4
|
+
import { login } from './login.js';
|
|
5
|
+
import { logout } from './logout.js';
|
|
6
|
+
import { proxyUnlessRelayed } from './relay.js';
|
|
7
|
+
import { resident } from './resident.js';
|
|
8
|
+
const USAGE = 'usage: kit <login|logout|resident|chatgpt>\n';
|
|
9
|
+
const COMMANDS = new Map([
|
|
10
|
+
[
|
|
11
|
+
'logout',
|
|
12
|
+
{
|
|
13
|
+
usage: 'usage: kit logout',
|
|
14
|
+
about: "disconnects this computer, stops the Kit process and ends your own agent's connection",
|
|
15
|
+
operands: 0,
|
|
16
|
+
run: logout,
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
[
|
|
20
|
+
'resident',
|
|
21
|
+
{
|
|
22
|
+
usage: 'usage: kit resident',
|
|
23
|
+
about: "keeps this Environment connected; Kit's service runs it",
|
|
24
|
+
operands: 0,
|
|
25
|
+
run: resident,
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
[
|
|
29
|
+
'git-credential',
|
|
30
|
+
{
|
|
31
|
+
usage: 'usage: kit git-credential <get|store|erase>',
|
|
32
|
+
about: "answers git with your own agent's House credential; git runs it",
|
|
33
|
+
operands: 1,
|
|
34
|
+
run: ([operation]) => answerGitCredential(operation),
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
]);
|
|
38
|
+
const [command, ...argv] = process.argv.slice(2);
|
|
39
|
+
proxyUnlessRelayed();
|
|
40
|
+
async function run() {
|
|
41
|
+
if (command === 'login')
|
|
42
|
+
return login(argv);
|
|
43
|
+
if (command === 'chatgpt')
|
|
44
|
+
return chatgpt(argv);
|
|
45
|
+
if (command === '--help') {
|
|
46
|
+
parseArgs({ args: argv });
|
|
47
|
+
process.stdout.write(USAGE);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const chosen = COMMANDS.get(command ?? '');
|
|
51
|
+
if (chosen === undefined) {
|
|
52
|
+
process.stderr.write(USAGE);
|
|
53
|
+
process.exitCode = 2;
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const { values, positionals } = parseArgs({ args: argv, options: { help: { type: 'boolean', default: false } }, allowPositionals: true });
|
|
57
|
+
if (positionals.length > chosen.operands)
|
|
58
|
+
throw new Error(`unexpected argument ${positionals[chosen.operands]}; ${chosen.usage}`);
|
|
59
|
+
if (values.help) {
|
|
60
|
+
process.stdout.write(`${chosen.usage}\n ${chosen.about}\n`);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
return chosen.run(positionals);
|
|
64
|
+
}
|
|
65
|
+
run().catch((error) => {
|
|
66
|
+
process.stderr.write(`kit: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
67
|
+
process.exitCode = 1;
|
|
68
|
+
});
|
package/dist/kit-main.js
CHANGED
|
@@ -1,69 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { chatgpt } from './chatgpt.js';
|
|
6
|
-
import { login } from './login.js';
|
|
7
|
-
import { logout } from './logout.js';
|
|
8
|
-
import { resident } from './resident.js';
|
|
9
|
-
const USAGE = 'usage: kit <login|logout|resident|chatgpt>\n';
|
|
10
|
-
const COMMANDS = new Map([
|
|
11
|
-
[
|
|
12
|
-
'logout',
|
|
13
|
-
{
|
|
14
|
-
usage: 'usage: kit logout',
|
|
15
|
-
about: "disconnects this computer, stops House Kit and ends your own agent's connection",
|
|
16
|
-
operands: 0,
|
|
17
|
-
run: logout,
|
|
18
|
-
},
|
|
19
|
-
],
|
|
20
|
-
[
|
|
21
|
-
'resident',
|
|
22
|
-
{
|
|
23
|
-
usage: 'usage: kit resident',
|
|
24
|
-
about: "keeps this Environment connected; House Kit's service runs it",
|
|
25
|
-
operands: 0,
|
|
26
|
-
run: resident,
|
|
27
|
-
},
|
|
28
|
-
],
|
|
29
|
-
[
|
|
30
|
-
'git-credential',
|
|
31
|
-
{
|
|
32
|
-
usage: 'usage: kit git-credential <get|store|erase>',
|
|
33
|
-
about: "answers git with your own agent's House credential; git runs it",
|
|
34
|
-
operands: 1,
|
|
35
|
-
run: ([operation]) => answerGitCredential(operation),
|
|
36
|
-
},
|
|
37
|
-
],
|
|
38
|
-
]);
|
|
39
|
-
const [command, ...argv] = process.argv.slice(2);
|
|
40
|
-
setGlobalProxyFromEnv();
|
|
41
|
-
async function run() {
|
|
42
|
-
if (command === 'login')
|
|
43
|
-
return login(argv);
|
|
44
|
-
if (command === 'chatgpt')
|
|
45
|
-
return chatgpt(argv);
|
|
46
|
-
if (command === '--help') {
|
|
47
|
-
parseArgs({ args: argv });
|
|
48
|
-
process.stdout.write(USAGE);
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
const chosen = COMMANDS.get(command ?? '');
|
|
52
|
-
if (chosen === undefined) {
|
|
53
|
-
process.stderr.write(USAGE);
|
|
54
|
-
process.exitCode = 2;
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
const { values, positionals } = parseArgs({ args: argv, options: { help: { type: 'boolean', default: false } }, allowPositionals: true });
|
|
58
|
-
if (positionals.length > chosen.operands)
|
|
59
|
-
throw new Error(`unexpected argument ${positionals[chosen.operands]}; ${chosen.usage}`);
|
|
60
|
-
if (values.help) {
|
|
61
|
-
process.stdout.write(`${chosen.usage}\n ${chosen.about}\n`);
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
return chosen.run(positionals);
|
|
65
|
-
}
|
|
66
|
-
run().catch((error) => {
|
|
67
|
-
process.stderr.write(`kit: ${error instanceof Error ? error.message : String(error)}\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`);
|
|
68
5
|
process.exitCode = 1;
|
|
69
|
-
}
|
|
6
|
+
}
|
|
7
|
+
else {
|
|
8
|
+
await import('./kit-cli.js');
|
|
9
|
+
}
|
|
10
|
+
export {};
|
package/dist/login.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
2
|
import { createHash, randomBytes } from 'node:crypto';
|
|
3
|
-
import { hostname } from 'node:os';
|
|
4
3
|
import { parseArgs } from 'node:util';
|
|
5
4
|
import { HouseRefusal, post, retrying } from './api.js';
|
|
6
5
|
import { placeAppGit } from './app-git.js';
|
|
@@ -11,6 +10,7 @@ import { refusalOf } from './refusals.js';
|
|
|
11
10
|
import { selectRelay } from './relay.js';
|
|
12
11
|
import { startService } from './service.js';
|
|
13
12
|
import { placeSkillSet } from './skills.js';
|
|
13
|
+
import { endUnserved } from './wire.js';
|
|
14
14
|
export const DEFAULT_HOUSE = 'https://agents.house';
|
|
15
15
|
const OPENER = process.platform === 'darwin' ? 'open' : 'xdg-open';
|
|
16
16
|
// Polling every two seconds brings the User's confirmation to the waiting Kit moments after they give it.
|
|
@@ -26,6 +26,7 @@ export async function accepted(house, credential) {
|
|
|
26
26
|
return true;
|
|
27
27
|
if (checked.status === 401)
|
|
28
28
|
return false;
|
|
29
|
+
endUnserved(checked.text);
|
|
29
30
|
throw new Error(`House answered ${checked.status} when Kit checked this computer's own agent's connection: ${checked.text}`);
|
|
30
31
|
}
|
|
31
32
|
const USAGE = `usage: kit login [--house <origin>] [--environment <id>] [--rooms <ref>[,<ref>...] | --no-private]
|
|
@@ -36,6 +37,13 @@ const USAGE = `usage: kit login [--house <origin>] [--environment <id>] [--rooms
|
|
|
36
37
|
--no-private give this Environment every Room but your Private Room
|
|
37
38
|
--code <code> connect this machine with a login code
|
|
38
39
|
`;
|
|
40
|
+
function connected(house, named, environment) {
|
|
41
|
+
if (named === undefined)
|
|
42
|
+
return `Environment ${environment} is connected to ${house}.\n`;
|
|
43
|
+
if (named === environment)
|
|
44
|
+
return `Environment ${environment} is reconnected to ${house}.\n`;
|
|
45
|
+
return `Environment ${named} stays with its account; this computer is connected to ${house} as new Environment ${environment} of the account that confirmed.\n`;
|
|
46
|
+
}
|
|
39
47
|
function gone(error) {
|
|
40
48
|
return error instanceof HouseRefusal && refusalOf(error.text)?.code === 'kit_environment_not_found';
|
|
41
49
|
}
|
|
@@ -81,15 +89,15 @@ export async function login(argv) {
|
|
|
81
89
|
const environment = replaces === undefined ? (values.environment ?? remembered) : undefined;
|
|
82
90
|
const ownAgent = await readOwnAgent();
|
|
83
91
|
let held = false;
|
|
92
|
+
let named = environment;
|
|
84
93
|
let exchanged;
|
|
85
94
|
if (values.code !== undefined) {
|
|
86
|
-
exchanged = await post(house, '/kit/token', { code: values.code
|
|
95
|
+
exchanged = await post(house, '/kit/token', { code: values.code });
|
|
87
96
|
}
|
|
88
97
|
else {
|
|
89
98
|
held = ownAgent !== null && ownAgent.house === house && (await accepted(house, ownAgent.credential));
|
|
90
99
|
const verifier = randomBytes(32).toString('base64url');
|
|
91
|
-
const start = (
|
|
92
|
-
label: hostname(),
|
|
100
|
+
const start = () => retrying(() => post(house, '/kit', {
|
|
93
101
|
...(named === undefined
|
|
94
102
|
? { act: 'new_environment', ...(replaces === undefined ? {} : { replaces }) }
|
|
95
103
|
: { act: 'existing_environment', environment_id: named }),
|
|
@@ -99,20 +107,21 @@ export async function login(argv) {
|
|
|
99
107
|
}));
|
|
100
108
|
let started;
|
|
101
109
|
try {
|
|
102
|
-
started = await start(
|
|
110
|
+
started = await start();
|
|
103
111
|
}
|
|
104
112
|
catch (error) {
|
|
105
113
|
if (remembered === undefined || !gone(error))
|
|
106
114
|
throw error;
|
|
107
115
|
await forgetDisconnected();
|
|
108
116
|
process.stdout.write(`House no longer holds Environment ${remembered}; connecting this computer as a new one.\n`);
|
|
109
|
-
|
|
117
|
+
named = undefined;
|
|
118
|
+
started = await start();
|
|
110
119
|
}
|
|
111
120
|
process.stdout.write(`Open this link and confirm: ${started.start_url}\n`);
|
|
112
121
|
open(started.start_url);
|
|
113
122
|
exchanged = await retrying(() => post(house, '/kit/token', { login: started.login, code_verifier: verifier }), undefined, () => POLL_INTERVAL_MS);
|
|
114
123
|
}
|
|
115
|
-
await placeSkillSet();
|
|
124
|
+
await placeSkillSet(house);
|
|
116
125
|
await writeCodexRule().catch((error) => process.stderr.write(`kit: ${error.message}\n`));
|
|
117
126
|
const relayRecord = relay === undefined ? {} : { relay };
|
|
118
127
|
await writeEnrolment({
|
|
@@ -121,7 +130,7 @@ export async function login(argv) {
|
|
|
121
130
|
environment: exchanged.environment,
|
|
122
131
|
credential: exchanged.credential,
|
|
123
132
|
});
|
|
124
|
-
process.stdout.write(
|
|
133
|
+
process.stdout.write(connected(house, named, exchanged.environment));
|
|
125
134
|
if (exchanged.headless_credential !== undefined) {
|
|
126
135
|
await writeOwnAgent({ house, ...relayRecord, user: exchanged.user, credential: exchanged.headless_credential });
|
|
127
136
|
}
|
|
@@ -132,7 +141,7 @@ export async function login(argv) {
|
|
|
132
141
|
else if (held && ownAgent !== null) {
|
|
133
142
|
await writeOwnAgent({ house, ...relayRecord, user: ownAgent.user, credential: ownAgent.credential });
|
|
134
143
|
}
|
|
135
|
-
await placeAppGit(
|
|
144
|
+
await placeAppGit(await readOwnAgent()).catch((error) => process.stderr.write(`kit: ${error.message}\n`));
|
|
136
145
|
try {
|
|
137
146
|
startService();
|
|
138
147
|
}
|
package/dist/logout.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { HouseRefusal, post } from './api.js';
|
|
2
|
-
import { forgetAppGit } from './app-git.js';
|
|
3
2
|
import { forgetEnrolment, forgetOwnAgent, readEnrolment } from './home.js';
|
|
4
3
|
export async function logout() {
|
|
5
4
|
const enrolled = await readEnrolment();
|
|
@@ -13,7 +12,6 @@ export async function logout() {
|
|
|
13
12
|
}
|
|
14
13
|
await forgetEnrolment(enrolled);
|
|
15
14
|
}
|
|
16
|
-
await forgetAppGit();
|
|
17
15
|
await forgetOwnAgent();
|
|
18
16
|
process.stdout.write(enrolled === null
|
|
19
17
|
? 'This computer is not connected to House.\n'
|
package/dist/mcp.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
|
-
import {
|
|
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';
|
|
7
|
+
export class Unsettled extends Error {
|
|
8
|
+
}
|
|
6
9
|
export function rpc(method, params) {
|
|
7
10
|
return { jsonrpc: '2.0', id: randomUUID(), method, params };
|
|
8
11
|
}
|
|
@@ -13,7 +16,7 @@ export function mcpBody(message, operation) {
|
|
|
13
16
|
...message.params,
|
|
14
17
|
_meta: {
|
|
15
18
|
'io.modelcontextprotocol/protocolVersion': MCP_PROTOCOL_VERSION,
|
|
16
|
-
'io.modelcontextprotocol/clientInfo': { name: '@agentshouse/kit', version:
|
|
19
|
+
'io.modelcontextprotocol/clientInfo': { name: '@agentshouse/kit', version: KIT_RELEASE },
|
|
17
20
|
'io.modelcontextprotocol/clientCapabilities': {},
|
|
18
21
|
...(operation === null ? {} : { 'agents.house/agent-operation': operation }),
|
|
19
22
|
},
|
|
@@ -31,6 +34,7 @@ export async function callHouse(origin, credential, message, operation = null, s
|
|
|
31
34
|
'mcp-protocol-version': MCP_PROTOCOL_VERSION,
|
|
32
35
|
'mcp-method': message.method,
|
|
33
36
|
...(tool === null ? {} : { 'mcp-name': tool }),
|
|
37
|
+
[KIT_WIRE_HEADER]: String(KIT_WIRE),
|
|
34
38
|
},
|
|
35
39
|
body: mcpBody(message, operation),
|
|
36
40
|
signal,
|