@agentshouse/kit 0.2.1-cca9e1f43de44 → 0.2.1-ccb257fa8a318
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 +42 -40
- package/dist/acp.js +92 -115
- package/dist/agents.js +112 -24
- package/dist/api.js +10 -6
- package/dist/app-git.js +10 -26
- package/dist/authority-main.js +2 -2
- package/dist/bridge.js +11 -25
- package/dist/building.js +46 -0
- package/dist/calls.js +71 -0
- package/dist/chatgpt.js +32 -0
- package/dist/clis-main.js +2 -2
- package/dist/clis.js +131 -27
- package/dist/codex-main.js +58 -0
- package/dist/connection.js +116 -0
- package/dist/conversations.js +523 -202
- package/dist/copies.js +185 -123
- package/dist/end.js +24 -5
- package/dist/enrol-main.js +7 -1
- package/dist/events.js +16 -78
- package/dist/files.js +139 -31
- package/dist/git.js +13 -11
- package/dist/home.js +96 -7
- package/dist/house-cli.js +299 -0
- package/dist/house-main.js +7 -177
- package/dist/instructions.js +8 -10
- package/dist/kit-cli.js +68 -0
- package/dist/kit-main.js +8 -22
- package/dist/login.js +118 -107
- package/dist/logout.js +14 -16
- package/dist/mcp.js +6 -2
- package/dist/parts.js +34 -16
- package/dist/placement.js +39 -0
- package/dist/relay.js +33 -2
- package/dist/resident.js +118 -51
- package/dist/scope.js +206 -0
- package/dist/scripts.js +255 -0
- package/dist/service-main.js +9 -0
- package/dist/service.js +55 -0
- package/dist/sign-in.js +23 -40
- package/dist/silence.js +28 -0
- package/dist/skills.js +49 -35
- package/dist/transcription.js +85 -45
- package/dist/translate.js +2 -8
- package/dist/update.js +115 -53
- package/dist/wire.js +22 -0
- package/dist/work.js +346 -0
- package/package.json +20 -20
- package/dist/bootstrap.json +0 -24
- package/dist/stream.js +0 -72
- package/how-we-work.md +0 -23
- package/skills/ask-matt/LICENSE +0 -21
- package/skills/ask-matt/PHASE-BOUNDARIES.md +0 -55
- package/skills/ask-matt/SKILL.md +0 -91
- package/skills/ask-matt/agents/openai.yaml +0 -4
- 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 -116
- package/skills/codebase-design/agents/openai.yaml +0 -3
- package/skills/diagnosing-bugs/LICENSE +0 -21
- package/skills/diagnosing-bugs/SKILL.md +0 -140
- 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/CONTEXT-FORMAT.md +0 -60
- package/skills/domain-modeling/LICENSE +0 -21
- package/skills/domain-modeling/SKILL.md +0 -76
- package/skills/domain-modeling/agents/openai.yaml +0 -3
- package/skills/grill-me/LICENSE +0 -21
- package/skills/grill-me/SKILL.md +0 -8
- package/skills/grill-me/agents/openai.yaml +0 -4
- package/skills/grill-with-docs/LICENSE +0 -21
- package/skills/grill-with-docs/SKILL.md +0 -8
- package/skills/grill-with-docs/agents/openai.yaml +0 -4
- 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 -17
- package/skills/handoff/agents/openai.yaml +0 -4
- package/skills/implement/LICENSE +0 -21
- package/skills/implement/SKILL.md +0 -16
- package/skills/implement/agents/openai.yaml +0 -4
- 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 -72
- package/skills/improve-codebase-architecture/agents/openai.yaml +0 -4
- package/skills/prototype/LICENSE +0 -21
- package/skills/prototype/LOGIC.md +0 -67
- package/skills/prototype/SKILL.md +0 -28
- 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 -14
- package/skills/research/agents/openai.yaml +0 -3
- package/skills/resolving-merge-conflicts/LICENSE +0 -21
- package/skills/resolving-merge-conflicts/SKILL.md +0 -16
- package/skills/resolving-merge-conflicts/agents/openai.yaml +0 -3
- package/skills/tdd/LICENSE +0 -21
- package/skills/tdd/SKILL.md +0 -40
- 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 -141
- package/skills/teach/agents/openai.yaml +0 -4
- package/skills/to-questionnaire/LICENSE +0 -21
- package/skills/to-questionnaire/SKILL.md +0 -55
- package/skills/to-questionnaire/agents/openai.yaml +0 -4
- package/skills/to-spec/LICENSE +0 -21
- package/skills/to-spec/SKILL.md +0 -76
- package/skills/to-spec/agents/openai.yaml +0 -4
- package/skills/to-tickets/LICENSE +0 -21
- package/skills/to-tickets/SKILL.md +0 -106
- package/skills/to-tickets/agents/openai.yaml +0 -4
- package/skills/wait-what/LICENSE +0 -21
- package/skills/wait-what/SKILL.md +0 -8
- package/skills/wait-what/agents/openai.yaml +0 -4
- package/skills/wayfinder/LICENSE +0 -21
- package/skills/wayfinder/SKILL.md +0 -129
- package/skills/wayfinder/agents/openai.yaml +0 -4
- 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 -83
- package/skills/writing-for-agents/agents/openai.yaml +0 -3
package/dist/login.js
CHANGED
|
@@ -1,74 +1,58 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
1
2
|
import { createHash, randomBytes } from 'node:crypto';
|
|
2
|
-
import { createServer } from 'node:http';
|
|
3
|
-
import { hostname } from 'node:os';
|
|
4
|
-
import { createInterface } from 'node:readline/promises';
|
|
5
3
|
import { parseArgs } from 'node:util';
|
|
6
|
-
import { post } from './api.js';
|
|
4
|
+
import { HouseRefusal, post, retrying } from './api.js';
|
|
7
5
|
import { placeAppGit } from './app-git.js';
|
|
8
|
-
import {
|
|
6
|
+
import { writeCodexRule } from './clis.js';
|
|
7
|
+
import { forgetDisconnected, forgetOwnAgent, readDisconnected, readEnrolment, readOwnAgent, writeEnrolment, writeOwnAgent, } from './home.js';
|
|
9
8
|
import { callHouse, rpc } from './mcp.js';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
held = response;
|
|
25
|
-
deliver(received);
|
|
26
|
-
});
|
|
27
|
-
const close = () => {
|
|
28
|
-
server.close();
|
|
29
|
-
server.closeAllConnections();
|
|
30
|
-
};
|
|
31
|
-
const port = Number(process.env.HOUSE_KIT_LOGIN_PORT ?? 0);
|
|
32
|
-
server.once('error', reject);
|
|
33
|
-
server.listen(port, port === 0 ? '127.0.0.1' : '0.0.0.0', () => {
|
|
34
|
-
const address = server.address();
|
|
35
|
-
if (address === null || typeof address === 'string') {
|
|
36
|
-
reject(new Error('the login callback has no port'));
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
resolve({
|
|
40
|
-
uri: `http://127.0.0.1:${address.port}/callback`,
|
|
41
|
-
code,
|
|
42
|
-
answer: (text) => new Promise((written) => {
|
|
43
|
-
if (held === null || held.destroyed || !held.socket || held.socket.destroyed)
|
|
44
|
-
return written();
|
|
45
|
-
held.once('close', () => written());
|
|
46
|
-
held.writeHead(200, { 'content-type': 'text/plain; charset=utf-8', connection: 'close' }).end(`${text}\n`);
|
|
47
|
-
}),
|
|
48
|
-
close,
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
});
|
|
9
|
+
import { refusalOf } from './refusals.js';
|
|
10
|
+
import { selectRelay } from './relay.js';
|
|
11
|
+
import { startService } from './service.js';
|
|
12
|
+
import { placeSkillSet } from './skills.js';
|
|
13
|
+
import { endUnserved } from './wire.js';
|
|
14
|
+
export const DEFAULT_HOUSE = 'https://agents.house';
|
|
15
|
+
const OPENER = process.platform === 'darwin' ? 'open' : 'xdg-open';
|
|
16
|
+
// Polling every two seconds brings the User's confirmation to the waiting Kit moments after they give it.
|
|
17
|
+
const POLL_INTERVAL_MS = 2000;
|
|
18
|
+
function open(link) {
|
|
19
|
+
spawn(OPENER, [link], { detached: true, stdio: 'ignore' })
|
|
20
|
+
.on('error', () => undefined)
|
|
21
|
+
.unref();
|
|
52
22
|
}
|
|
53
|
-
async function accepted(house, credential) {
|
|
23
|
+
export async function accepted(house, credential) {
|
|
54
24
|
const checked = await callHouse(house, credential, rpc('tools/list', {}));
|
|
55
25
|
if (checked.status === 200)
|
|
56
26
|
return true;
|
|
57
27
|
if (checked.status === 401)
|
|
58
28
|
return false;
|
|
29
|
+
endUnserved(checked.text);
|
|
59
30
|
throw new Error(`House answered ${checked.status} when Kit checked this computer's own agent's connection: ${checked.text}`);
|
|
60
31
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
32
|
+
const USAGE = `usage: kit login [--house <origin>] [--environment <id>] [--rooms <ref>[,<ref>...] | --no-private]
|
|
33
|
+
kit login [--house <origin>] --code <code>
|
|
34
|
+
--house <origin> the House to connect to, ${DEFAULT_HOUSE} unless one is stored
|
|
35
|
+
--environment <id> reconnect this Environment
|
|
36
|
+
--rooms <ref>[,<ref>...] give this Environment only these Rooms
|
|
37
|
+
--no-private give this Environment every Room but your Private Room
|
|
38
|
+
--code <code> connect this machine with a login code
|
|
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
|
+
}
|
|
47
|
+
function gone(error) {
|
|
48
|
+
return error instanceof HouseRefusal && refusalOf(error.text)?.code === 'kit_environment_not_found';
|
|
49
|
+
}
|
|
50
|
+
function chosenRooms(rooms, noPrivate) {
|
|
51
|
+
if (rooms !== undefined && noPrivate)
|
|
52
|
+
throw new Error('--rooms and --no-private are two choices of Rooms; pass one');
|
|
53
|
+
if (rooms !== undefined)
|
|
54
|
+
return { rooms: { reach: 'selected', refs: rooms.split(',') } };
|
|
55
|
+
return noPrivate ? { rooms: { reach: 'all_but_private' } } : {};
|
|
72
56
|
}
|
|
73
57
|
export async function login(argv) {
|
|
74
58
|
const { values } = parseArgs({
|
|
@@ -76,65 +60,92 @@ export async function login(argv) {
|
|
|
76
60
|
options: {
|
|
77
61
|
house: { type: 'string' },
|
|
78
62
|
environment: { type: 'string' },
|
|
79
|
-
|
|
63
|
+
rooms: { type: 'string' },
|
|
64
|
+
'no-private': { type: 'boolean', default: false },
|
|
65
|
+
code: { type: 'string' },
|
|
66
|
+
help: { type: 'boolean', default: false },
|
|
80
67
|
},
|
|
81
68
|
});
|
|
69
|
+
if (values.help) {
|
|
70
|
+
process.stdout.write(USAGE);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (values.code !== undefined && values.rooms !== undefined)
|
|
74
|
+
throw new Error('--code cannot be used with --rooms');
|
|
75
|
+
if (values.code !== undefined && values['no-private'])
|
|
76
|
+
throw new Error('--code cannot be used with --no-private');
|
|
77
|
+
if (values.code !== undefined && values.environment !== undefined)
|
|
78
|
+
throw new Error('--code cannot be used with --environment');
|
|
79
|
+
const rooms = chosenRooms(values.rooms, values['no-private']);
|
|
82
80
|
const enrolled = (await readEnrolment()) ?? (await readDisconnected());
|
|
81
|
+
if (values.code !== undefined && enrolled !== null) {
|
|
82
|
+
throw new Error(`--code connects a new machine; this Kit home records Environment ${enrolled.environment}, so run kit login to reconnect it`);
|
|
83
|
+
}
|
|
84
|
+
const relay = process.env.HOUSE_KIT_RELAY || undefined;
|
|
85
|
+
selectRelay(relay);
|
|
83
86
|
const house = values.house ?? enrolled?.house ?? DEFAULT_HOUSE;
|
|
84
87
|
const replaces = process.env.HOUSE_KIT_REPLACES;
|
|
85
|
-
const
|
|
88
|
+
const remembered = replaces === undefined && values.environment === undefined && enrolled?.house === house ? enrolled.environment : undefined;
|
|
89
|
+
const environment = replaces === undefined ? (values.environment ?? remembered) : undefined;
|
|
86
90
|
const ownAgent = await readOwnAgent();
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
: { act: 'existing_environment', environment_id: environment }),
|
|
93
|
-
code_challenge: createHash('sha256').update(verifier).digest('base64url'),
|
|
94
|
-
...(held ? {} : { headless: true }),
|
|
95
|
-
};
|
|
96
|
-
const exchange = async (code) => {
|
|
97
|
-
const exchanged = await post(house, '/kit/token', { code, code_verifier: verifier });
|
|
98
|
-
await writeEnrolment({ house, environment: exchanged.environment, credential: exchanged.credential });
|
|
99
|
-
process.stdout.write(`Environment ${exchanged.environment} is connected to ${house}.\n`);
|
|
100
|
-
if (exchanged.headless_credential !== undefined) {
|
|
101
|
-
await writeOwnAgent({ house, user: exchanged.user, credential: exchanged.headless_credential });
|
|
102
|
-
}
|
|
103
|
-
else if (held && ownAgent.user !== exchanged.user) {
|
|
104
|
-
await forgetOwnAgent();
|
|
105
|
-
process.stdout.write("This computer's own agent was another User's; run kit login again to connect it to you.\n");
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
const placeGit = async () => placeAppGit(ownAgent, await readOwnAgent());
|
|
109
|
-
if (values.manual) {
|
|
110
|
-
const { start_url } = await post(house, '/kit', {
|
|
111
|
-
...started,
|
|
112
|
-
presentation: 'manual',
|
|
113
|
-
});
|
|
114
|
-
process.stdout.write(`Open this link and confirm: ${start_url}\n`);
|
|
115
|
-
await exchange(await typed('Code: '));
|
|
116
|
-
await placeGit();
|
|
117
|
-
return;
|
|
91
|
+
let held = false;
|
|
92
|
+
let named = environment;
|
|
93
|
+
let exchanged;
|
|
94
|
+
if (values.code !== undefined) {
|
|
95
|
+
exchanged = await post(house, '/kit/token', { code: values.code });
|
|
118
96
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
97
|
+
else {
|
|
98
|
+
held = ownAgent !== null && ownAgent.house === house && (await accepted(house, ownAgent.credential));
|
|
99
|
+
const verifier = randomBytes(32).toString('base64url');
|
|
100
|
+
const start = () => retrying(() => post(house, '/kit', {
|
|
101
|
+
...(named === undefined
|
|
102
|
+
? { act: 'new_environment', ...(replaces === undefined ? {} : { replaces }) }
|
|
103
|
+
: { act: 'existing_environment', environment_id: named }),
|
|
104
|
+
...rooms,
|
|
105
|
+
code_challenge: createHash('sha256').update(verifier).digest('base64url'),
|
|
106
|
+
...(held ? {} : { headless: true }),
|
|
107
|
+
}));
|
|
108
|
+
let started;
|
|
127
109
|
try {
|
|
128
|
-
await
|
|
110
|
+
started = await start();
|
|
129
111
|
}
|
|
130
112
|
catch (error) {
|
|
131
|
-
|
|
132
|
-
|
|
113
|
+
if (remembered === undefined || !gone(error))
|
|
114
|
+
throw error;
|
|
115
|
+
await forgetDisconnected();
|
|
116
|
+
process.stdout.write(`House no longer holds Environment ${remembered}; connecting this computer as a new one.\n`);
|
|
117
|
+
named = undefined;
|
|
118
|
+
started = await start();
|
|
133
119
|
}
|
|
134
|
-
|
|
120
|
+
process.stdout.write(`Open this link and confirm: ${started.start_url}\n`);
|
|
121
|
+
open(started.start_url);
|
|
122
|
+
exchanged = await retrying(() => post(house, '/kit/token', { login: started.login, code_verifier: verifier }), undefined, () => POLL_INTERVAL_MS);
|
|
123
|
+
}
|
|
124
|
+
await placeSkillSet(house);
|
|
125
|
+
await writeCodexRule().catch((error) => process.stderr.write(`kit: ${error.message}\n`));
|
|
126
|
+
const relayRecord = relay === undefined ? {} : { relay };
|
|
127
|
+
await writeEnrolment({
|
|
128
|
+
house,
|
|
129
|
+
...relayRecord,
|
|
130
|
+
environment: exchanged.environment,
|
|
131
|
+
credential: exchanged.credential,
|
|
132
|
+
});
|
|
133
|
+
process.stdout.write(connected(house, named, exchanged.environment));
|
|
134
|
+
if (exchanged.headless_credential !== undefined) {
|
|
135
|
+
await writeOwnAgent({ house, ...relayRecord, user: exchanged.user, credential: exchanged.headless_credential });
|
|
136
|
+
}
|
|
137
|
+
else if (held && ownAgent !== null && ownAgent.user !== exchanged.user) {
|
|
138
|
+
await forgetOwnAgent();
|
|
139
|
+
process.stdout.write("This computer's own agent was another User's; run kit login again to connect it to you.\n");
|
|
140
|
+
}
|
|
141
|
+
else if (held && ownAgent !== null) {
|
|
142
|
+
await writeOwnAgent({ house, ...relayRecord, user: ownAgent.user, credential: ownAgent.credential });
|
|
143
|
+
}
|
|
144
|
+
await placeAppGit(await readOwnAgent()).catch((error) => process.stderr.write(`kit: ${error.message}\n`));
|
|
145
|
+
try {
|
|
146
|
+
startService();
|
|
135
147
|
}
|
|
136
|
-
|
|
137
|
-
|
|
148
|
+
catch (error) {
|
|
149
|
+
process.stderr.write(`kit: ${error.message}\n`);
|
|
138
150
|
}
|
|
139
|
-
await placeGit();
|
|
140
151
|
}
|
package/dist/logout.js
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
import { HouseRefusal, post } from './api.js';
|
|
2
|
-
import {
|
|
3
|
-
import { forgetEnrolment, readEnrolment } from './home.js';
|
|
2
|
+
import { forgetEnrolment, forgetOwnAgent, readEnrolment } from './home.js';
|
|
4
3
|
export async function logout() {
|
|
5
4
|
const enrolled = await readEnrolment();
|
|
6
|
-
if (enrolled
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
if (enrolled !== null) {
|
|
6
|
+
try {
|
|
7
|
+
await post(enrolled.house, '/kit/logout', {}, enrolled.credential);
|
|
8
|
+
}
|
|
9
|
+
catch (error) {
|
|
10
|
+
if (!(error instanceof HouseRefusal && error.status === 401))
|
|
11
|
+
throw error;
|
|
12
|
+
}
|
|
13
|
+
await forgetEnrolment(enrolled);
|
|
10
14
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (!(error instanceof HouseRefusal && error.status === 401))
|
|
16
|
-
throw error;
|
|
17
|
-
}
|
|
18
|
-
await forgetEnrolment(enrolled);
|
|
19
|
-
await forgetAppGit();
|
|
20
|
-
process.stdout.write(`Environment ${enrolled.environment} is disconnected; kit login reconnects it.\n`);
|
|
15
|
+
await forgetOwnAgent();
|
|
16
|
+
process.stdout.write(enrolled === null
|
|
17
|
+
? 'This computer is not connected to House.\n'
|
|
18
|
+
: `Environment ${enrolled.environment} is disconnected; kit login reconnects it.\n`);
|
|
21
19
|
}
|
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,
|
package/dist/parts.js
CHANGED
|
@@ -2,7 +2,10 @@ export class Parts {
|
|
|
2
2
|
parts = [];
|
|
3
3
|
context = null;
|
|
4
4
|
emit;
|
|
5
|
+
made = [];
|
|
6
|
+
events = 0;
|
|
5
7
|
writing = null;
|
|
8
|
+
counting = null;
|
|
6
9
|
planned = null;
|
|
7
10
|
constructor(emit) {
|
|
8
11
|
this.emit = emit;
|
|
@@ -10,32 +13,34 @@ export class Parts {
|
|
|
10
13
|
write(type, id, text) {
|
|
11
14
|
if (text === '')
|
|
12
15
|
return;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
part.text += text;
|
|
17
|
-
this.emit({ op: 'append', index: last, text });
|
|
16
|
+
if (this.writing?.type === type && this.writing.id === id) {
|
|
17
|
+
this.parts[this.writing.index].text += text;
|
|
18
|
+
this.emit({ op: 'append', index: this.writing.index, text });
|
|
18
19
|
return;
|
|
19
20
|
}
|
|
20
|
-
this.start({ type, text });
|
|
21
|
-
this.writing = { type, id };
|
|
21
|
+
this.writing = { type, id, index: this.start({ type, text }) };
|
|
22
22
|
}
|
|
23
23
|
command() {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (part?.type !== 'commands') {
|
|
27
|
-
this.start({ type: 'commands', count: 1 });
|
|
24
|
+
if (this.counting === null) {
|
|
25
|
+
this.counting = this.start({ type: 'commands', count: 1 });
|
|
28
26
|
return;
|
|
29
27
|
}
|
|
28
|
+
const part = this.parts[this.counting];
|
|
30
29
|
part.count++;
|
|
31
|
-
this.emit({ op: 'count', index:
|
|
30
|
+
this.emit({ op: 'count', index: this.counting, count: part.count });
|
|
32
31
|
}
|
|
33
32
|
start(part) {
|
|
34
33
|
this.writing = null;
|
|
35
|
-
this.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
this.counting = null;
|
|
35
|
+
return this.add(part, ++this.events);
|
|
36
|
+
}
|
|
37
|
+
reserve() {
|
|
38
|
+
this.writing = null;
|
|
39
|
+
this.counting = null;
|
|
40
|
+
return ++this.events;
|
|
41
|
+
}
|
|
42
|
+
arrive(part, reserved) {
|
|
43
|
+
this.add(part, reserved);
|
|
39
44
|
}
|
|
40
45
|
done(index, result) {
|
|
41
46
|
const part = this.parts[index];
|
|
@@ -55,10 +60,23 @@ export class Parts {
|
|
|
55
60
|
this.context = context;
|
|
56
61
|
this.emit({ op: 'context', ...context });
|
|
57
62
|
}
|
|
63
|
+
saved() {
|
|
64
|
+
return this.parts
|
|
65
|
+
.map((part, index) => ({ part, made: this.made[index] }))
|
|
66
|
+
.sort((a, b) => a.made - b.made)
|
|
67
|
+
.map(({ part }) => part);
|
|
68
|
+
}
|
|
58
69
|
operations() {
|
|
59
70
|
return [
|
|
60
71
|
...this.parts.map((part, index) => ({ op: 'start', index, part })),
|
|
61
72
|
...(this.context === null ? [] : [{ op: 'context', ...this.context }]),
|
|
62
73
|
];
|
|
63
74
|
}
|
|
75
|
+
add(part, made) {
|
|
76
|
+
this.parts.push(part);
|
|
77
|
+
this.made.push(made);
|
|
78
|
+
const index = this.parts.length - 1;
|
|
79
|
+
this.emit({ op: 'start', index, part });
|
|
80
|
+
return index;
|
|
81
|
+
}
|
|
64
82
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { run } from './clis.js';
|
|
4
|
+
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
|
+
function recorded(name) {
|
|
22
|
+
try {
|
|
23
|
+
return readFileSync(join(kitHome(), name), 'utf8').trim();
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
if (error.code === 'ENOENT')
|
|
27
|
+
return null;
|
|
28
|
+
throw error;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export function installCommand() {
|
|
32
|
+
return recorded('install-command');
|
|
33
|
+
}
|
|
34
|
+
export function machine() {
|
|
35
|
+
const placed = recorded('placement');
|
|
36
|
+
if (placed === 'container' || placed === 'server' || placed === 'windows')
|
|
37
|
+
return placed;
|
|
38
|
+
return process.platform === 'darwin' ? 'macos' : 'linux';
|
|
39
|
+
}
|
package/dist/relay.js
CHANGED
|
@@ -1,7 +1,38 @@
|
|
|
1
|
+
import { setGlobalProxyFromEnv } from 'node:http';
|
|
2
|
+
const PROXY = /^https?_proxy$/i;
|
|
3
|
+
const LOOPBACK = ['127.0.0.1', 'localhost', '::1'];
|
|
4
|
+
let selected;
|
|
5
|
+
let restoreProxy;
|
|
6
|
+
export function selectRelay(relay) {
|
|
7
|
+
selected = relay === undefined || relay === '' ? null : relay;
|
|
8
|
+
proxyUnlessRelayed();
|
|
9
|
+
}
|
|
10
|
+
export function relayOrigin() {
|
|
11
|
+
if (selected !== undefined)
|
|
12
|
+
return selected ?? undefined;
|
|
13
|
+
const ambient = process.env.HOUSE_KIT_RELAY;
|
|
14
|
+
return ambient === undefined || ambient === '' ? undefined : ambient;
|
|
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
|
+
}
|
|
1
32
|
export function relayed(target) {
|
|
2
33
|
const url = new URL(target);
|
|
3
|
-
const relay =
|
|
4
|
-
if (relay === undefined
|
|
34
|
+
const relay = relayOrigin();
|
|
35
|
+
if (relay === undefined)
|
|
5
36
|
return url;
|
|
6
37
|
const through = new URL(`${url.host}${url.pathname}${url.search}`, `${relay}/`);
|
|
7
38
|
if (url.protocol === 'wss:' || url.protocol === 'ws:')
|