@agentshouse/kit 0.2.1-c96543a4c8b15 → 0.2.1-ca18b01951c3b
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 +11 -10
- package/dist/agents.js +58 -4
- package/dist/api.js +5 -1
- package/dist/bootstrap.json +4 -4
- package/dist/chatgpt.js +29 -0
- package/dist/clis.js +10 -3
- package/dist/conversations.js +11 -1
- package/dist/copies.js +18 -8
- package/dist/end.js +4 -0
- package/dist/files.js +7 -1
- package/dist/git.js +11 -8
- package/dist/home.js +41 -4
- package/dist/house-main.js +101 -40
- package/dist/instructions.js +2 -27
- package/dist/kit-main.js +4 -1
- package/dist/login.js +34 -26
- package/dist/placement.js +48 -0
- package/dist/relay.js +1 -1
- package/dist/resident.js +8 -4
- package/dist/skills.js +81 -12
- package/dist/stream.js +62 -13
- package/dist/transcription.js +3 -3
- package/dist/update.js +28 -6
- package/dist/wire.js +6 -0
- package/how-we-work.md +13 -3
- package/package.json +2 -1
- package/skills/ask-matt/SKILL.md +17 -11
- package/skills/ask-matt/agents/openai.yaml +1 -0
- package/skills/code-review/SKILL.md +5 -5
- package/skills/codebase-design/DESIGN-IT-TWICE.md +1 -1
- package/skills/codebase-design/SKILL.md +0 -2
- package/skills/diagnosing-bugs/SKILL.md +2 -4
- package/skills/domain-modeling/{CONTEXT-FORMAT.md → GLOSSARY-FORMAT.md} +10 -10
- package/skills/domain-modeling/SKILL.md +12 -14
- package/skills/grill-me/SKILL.md +1 -2
- package/skills/grill-me/agents/openai.yaml +1 -0
- package/skills/grill-with-docs/SKILL.md +1 -2
- package/skills/grill-with-docs/agents/openai.yaml +1 -0
- package/skills/grilling/SKILL.md +2 -2
- package/skills/handoff/SKILL.md +2 -3
- package/skills/handoff/agents/openai.yaml +1 -0
- package/skills/implement/SKILL.md +5 -4
- package/skills/implement/agents/openai.yaml +1 -0
- package/skills/implement-spec/SKILL.md +40 -0
- package/skills/implement-spec/agents/openai.yaml +5 -0
- package/skills/improve-codebase-architecture/SKILL.md +6 -7
- package/skills/improve-codebase-architecture/agents/openai.yaml +1 -0
- package/skills/pr/CREDITS.md +3 -0
- package/skills/pr/LICENSE +21 -0
- package/skills/pr/SKILL.md +170 -0
- package/skills/pr/agents/openai.yaml +3 -0
- package/skills/prototype/SKILL.md +0 -2
- package/skills/research/SKILL.md +0 -2
- package/skills/retro/LICENSE +21 -0
- package/skills/retro/SKILL.md +44 -0
- package/skills/retro/agents/openai.yaml +5 -0
- package/skills/tdd/SKILL.md +2 -4
- package/skills/teach/SKILL.md +3 -4
- package/skills/teach/agents/openai.yaml +1 -0
- package/skills/to-questionnaire/SKILL.md +1 -2
- package/skills/to-questionnaire/agents/openai.yaml +1 -0
- package/skills/to-spec/SKILL.md +1 -2
- package/skills/to-spec/agents/openai.yaml +1 -0
- package/skills/to-tickets/SKILL.md +3 -4
- package/skills/to-tickets/agents/openai.yaml +1 -0
- package/skills/triage/AGENT-BRIEF.md +207 -0
- package/skills/triage/LICENSE +21 -0
- package/skills/triage/OUT-OF-SCOPE.md +105 -0
- package/skills/triage/SKILL.md +112 -0
- package/skills/triage/agents/openai.yaml +5 -0
- package/skills/wait-what/SKILL.md +2 -3
- package/skills/wait-what/agents/openai.yaml +1 -0
- package/skills/wayfinder/SKILL.md +5 -6
- package/skills/wayfinder/agents/openai.yaml +1 -0
- package/skills/wizard/LICENSE +21 -0
- package/skills/wizard/SKILL.md +44 -0
- package/skills/wizard/agents/openai.yaml +3 -0
- package/skills/wizard/template.sh +223 -0
- package/skills/writing-for-agents/SKILL.md +0 -2
- package/skills/resolving-merge-conflicts/SKILL.md +0 -16
- package/skills/resolving-merge-conflicts/agents/openai.yaml +0 -3
- /package/skills/{resolving-merge-conflicts → implement-spec}/LICENSE +0 -0
package/README.md
CHANGED
|
@@ -33,26 +33,27 @@ them out; running it again without the flag brings them back.
|
|
|
33
33
|
|
|
34
34
|
`kit login` opens or prints a link you confirm in any browser, on this computer
|
|
35
35
|
or another, continues on its own and keeps the Environment's credential in
|
|
36
|
-
`~/.house-kit`, or in
|
|
36
|
+
`$HOUSE_KIT_HOME` when it is set, else in `~/.house-kit`, or in `house-kit-<uid>` under the temporary directory when your home is read-only. `--environment <id>`
|
|
37
37
|
reconnects an Environment you already have; `--rooms <ref>[,<ref>...]` gives it
|
|
38
|
-
only those Rooms and `--no-private` every Room but your Private Room;
|
|
39
|
-
`--code <code>` connects immediately without a link.
|
|
38
|
+
only those Rooms and `--no-private` every Room but your Private Room; `--code <code>` connects immediately without a link.
|
|
40
39
|
A login also connects your own agent: outside an Agent conversation, `house <tool>` calls
|
|
41
40
|
House as you and `git` clones and pushes your Apps at `<house>/app/` as you, until you revoke
|
|
42
41
|
that connection on Connections. `house help` lists the Tools. Codex sessions started after a
|
|
43
42
|
login run a lone `house` command outside their sandbox. `kit logout` disconnects this
|
|
44
43
|
computer, stops House Kit and ends your own agent's connection, so `house` and `git` no
|
|
45
|
-
longer act as you here; a later `kit login` reconnects the same Environment
|
|
44
|
+
longer act as you here; a later `kit login` reconnects the same Environment, or connects
|
|
45
|
+
this computer as a new one when House no longer holds it.
|
|
46
|
+
In a container you do not control, such as ChatGPT's, `npm i -g @agentshouse/kit` and `kit chatgpt --key <key>` with a key made on Connections let `house <tool>` act as you, starting and configuring nothing else.
|
|
46
47
|
|
|
47
|
-
`kit resident` keeps the Environment connected and, as it connects, copies each
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
`kit resident` keeps the Environment connected and, as it connects, copies the text of each Room
|
|
49
|
+
you chose for it as a Git repository in the workspace's `local-copies`. `house fetch` records
|
|
50
|
+
House's changes on each copy's `refs/house/received`; rebase onto it, commit and run
|
|
51
|
+
`house push --owner` in the copy, through the install command in the container. An Agent runs
|
|
52
|
+
both, without `--owner`. `house upload` and `house download` move a Room's other files.
|
|
52
53
|
|
|
53
54
|
House Kit turns each audio file of your message to an Agent into text on this
|
|
54
55
|
computer before the Agent reads it. While transcription is on, the speech
|
|
55
|
-
engine and model use about 425 MB
|
|
56
|
+
engine and model use about 425 MB beside the Environment's credential; turning it off deletes them.
|
|
56
57
|
|
|
57
58
|
## License
|
|
58
59
|
|
package/dist/agents.js
CHANGED
|
@@ -3,8 +3,10 @@ import { readFile, realpath } from 'node:fs/promises';
|
|
|
3
3
|
import { startAdapter } from './acp.js';
|
|
4
4
|
import { CLIS, KIT_VERSION, below, installAdapter, installCli, locate, run, versionOf } from './clis.js';
|
|
5
5
|
import { agentBase, kitHome } from './home.js';
|
|
6
|
+
import { updatesItself } from './placement.js';
|
|
6
7
|
import { killTree } from './scope.js';
|
|
7
8
|
import { holdTranscription, transcriptionReport } from './transcription.js';
|
|
9
|
+
import { KIT_WIRE } from './wire.js';
|
|
8
10
|
const SIGNED_OUT = { signed_in: false, models: [], modes: [] };
|
|
9
11
|
function select(options, category) {
|
|
10
12
|
const option = options.find((candidate) => candidate.category === category);
|
|
@@ -22,6 +24,22 @@ function causeOf(error) {
|
|
|
22
24
|
function logged(error) {
|
|
23
25
|
process.stderr.write(`kit: ${causeOf(error)}\n`);
|
|
24
26
|
}
|
|
27
|
+
const LAPTOP_CHASSIS = new Set(['8', '9', '10', '14', '30', '31', '32']);
|
|
28
|
+
const DESKTOP_CHASSIS = new Set(['3', '4', '5', '6', '7', '15', '16']);
|
|
29
|
+
const SERVER_CHASSIS = new Set(['17', '18', '19', '20', '21', '22', '23', '24']);
|
|
30
|
+
export function chassisForm(value) {
|
|
31
|
+
const chassis = value.trim();
|
|
32
|
+
if (LAPTOP_CHASSIS.has(chassis))
|
|
33
|
+
return 'laptop';
|
|
34
|
+
if (DESKTOP_CHASSIS.has(chassis))
|
|
35
|
+
return 'desktop';
|
|
36
|
+
if (SERVER_CHASSIS.has(chassis))
|
|
37
|
+
return 'server';
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
export function hostVm(version) {
|
|
41
|
+
return /docker desktop|microsoft|wsl|linuxkit/i.test(version);
|
|
42
|
+
}
|
|
25
43
|
async function models(kind, adapter, known) {
|
|
26
44
|
const agent = adapter.connection.agent;
|
|
27
45
|
const opened = await agent.request('session/new', { cwd: kitHome(), mcpServers: [] });
|
|
@@ -120,6 +138,22 @@ async function operatingSystem() {
|
|
|
120
138
|
const release = await readFile('/etc/os-release', 'utf8');
|
|
121
139
|
return /^PRETTY_NAME="?([^"\n]*)"?$/m.exec(release)?.[1] ?? release;
|
|
122
140
|
}
|
|
141
|
+
async function hostForm() {
|
|
142
|
+
if (process.platform === 'darwin') {
|
|
143
|
+
const battery = await run('pmset', ['-g', 'batt'], 10_000);
|
|
144
|
+
return battery.status === 0 && battery.output.includes('InternalBattery') ? 'laptop' : 'desktop';
|
|
145
|
+
}
|
|
146
|
+
if (process.platform !== 'linux')
|
|
147
|
+
return undefined;
|
|
148
|
+
const [container, version, chassis] = await Promise.all([
|
|
149
|
+
readFile('/.dockerenv', 'utf8').then(() => true).catch(() => false),
|
|
150
|
+
readFile('/proc/version', 'utf8').catch(() => ''),
|
|
151
|
+
readFile('/sys/class/dmi/id/chassis_type', 'utf8').catch(() => ''),
|
|
152
|
+
]);
|
|
153
|
+
if (container && hostVm(version))
|
|
154
|
+
return undefined;
|
|
155
|
+
return chassisForm(chassis);
|
|
156
|
+
}
|
|
123
157
|
export class Agents {
|
|
124
158
|
desired = { agents: [], routes: [], transcribe: false };
|
|
125
159
|
house;
|
|
@@ -130,8 +164,14 @@ export class Agents {
|
|
|
130
164
|
reads = new Map();
|
|
131
165
|
sending = Promise.resolve();
|
|
132
166
|
sent = null;
|
|
133
|
-
|
|
167
|
+
refreshing = 0;
|
|
168
|
+
changed;
|
|
169
|
+
constructor(house, changed = () => undefined) {
|
|
134
170
|
this.house = house;
|
|
171
|
+
this.changed = changed;
|
|
172
|
+
}
|
|
173
|
+
idle() {
|
|
174
|
+
return this.refreshing === 0;
|
|
135
175
|
}
|
|
136
176
|
read() {
|
|
137
177
|
return this.reading.then(() => undefined, () => undefined);
|
|
@@ -140,19 +180,28 @@ export class Agents {
|
|
|
140
180
|
return this.desired.routes.find((route) => route.agent_id === agentId);
|
|
141
181
|
}
|
|
142
182
|
refresh() {
|
|
183
|
+
this.refreshing++;
|
|
184
|
+
this.changed();
|
|
143
185
|
const reading = this.read().then(async () => {
|
|
144
186
|
this.desired = await this.house.deliver('/kit/agents/desired', {});
|
|
145
187
|
return this.desired;
|
|
146
188
|
});
|
|
147
189
|
this.reading = reading;
|
|
148
|
-
|
|
190
|
+
reading
|
|
191
|
+
.then(({ agents, transcribe }) => Promise.all([
|
|
149
192
|
holdTranscription(transcribe)
|
|
150
193
|
.then((changed) => (changed ? this.report() : undefined))
|
|
151
|
-
.catch(logged)
|
|
194
|
+
.catch(logged),
|
|
152
195
|
Promise.all(agents.map((kind) => this.load(kind)))
|
|
153
196
|
.then(() => this.report())
|
|
154
|
-
.catch(logged)
|
|
197
|
+
.catch(logged),
|
|
198
|
+
]))
|
|
199
|
+
.catch(() => undefined)
|
|
200
|
+
.finally(() => {
|
|
201
|
+
this.refreshing--;
|
|
202
|
+
this.changed();
|
|
155
203
|
});
|
|
204
|
+
return reading.then(() => undefined);
|
|
156
205
|
}
|
|
157
206
|
cli(kind) {
|
|
158
207
|
return this.queue(kind, async () => {
|
|
@@ -260,6 +309,7 @@ export class Agents {
|
|
|
260
309
|
if (known !== undefined && known.failure === null && known.minimum === undefined)
|
|
261
310
|
return;
|
|
262
311
|
await this.examine(kind, SIGNED_OUT, offer);
|
|
312
|
+
await this.report();
|
|
263
313
|
}
|
|
264
314
|
async send() {
|
|
265
315
|
const agents = this.desired.agents.flatMap((kind) => {
|
|
@@ -267,9 +317,13 @@ export class Agents {
|
|
|
267
317
|
return reading === undefined ? [] : [reported(kind, reading)];
|
|
268
318
|
});
|
|
269
319
|
const hostKey = await sshHostKey();
|
|
320
|
+
const form = await hostForm();
|
|
270
321
|
const body = {
|
|
271
322
|
os: await operatingSystem(),
|
|
323
|
+
...(form === undefined ? {} : { form }),
|
|
272
324
|
kit_version: KIT_VERSION,
|
|
325
|
+
wire: KIT_WIRE,
|
|
326
|
+
updates_itself: await updatesItself(),
|
|
273
327
|
agent_base: agentBase(),
|
|
274
328
|
agents,
|
|
275
329
|
transcription: transcriptionReport(),
|
package/dist/api.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { setTimeout as delay } from 'node:timers/promises';
|
|
2
|
-
import { signInAgain } from './end.js';
|
|
2
|
+
import { signInAgain, updateRequired } from './end.js';
|
|
3
3
|
import { readEnrolment } from './home.js';
|
|
4
4
|
import { retryable } from './refusals.js';
|
|
5
5
|
import { relayed } from './relay.js';
|
|
6
|
+
import { KIT_WIRE, KIT_WIRE_HEADER, tooOld } from './wire.js';
|
|
6
7
|
export class HouseRefusal extends Error {
|
|
7
8
|
status;
|
|
8
9
|
text;
|
|
@@ -37,12 +38,15 @@ export async function post(house, path, body, credential, signal) {
|
|
|
37
38
|
method: 'POST',
|
|
38
39
|
headers: {
|
|
39
40
|
'content-type': 'application/json',
|
|
41
|
+
[KIT_WIRE_HEADER]: String(KIT_WIRE),
|
|
40
42
|
...(credential === undefined ? {} : { authorization: `Bearer ${credential}` }),
|
|
41
43
|
},
|
|
42
44
|
body: JSON.stringify(body),
|
|
43
45
|
signal,
|
|
44
46
|
});
|
|
45
47
|
const text = await answer.text();
|
|
48
|
+
if (!answer.ok && tooOld(text))
|
|
49
|
+
updateRequired(house);
|
|
46
50
|
if (!answer.ok)
|
|
47
51
|
throw new HouseRefusal(path, answer.status, text);
|
|
48
52
|
return JSON.parse(text);
|
package/dist/bootstrap.json
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 2,
|
|
3
|
-
"version": "0.2.1-
|
|
3
|
+
"version": "0.2.1-ca18b01951c3b",
|
|
4
4
|
"hosts": {
|
|
5
5
|
"macos": {
|
|
6
6
|
"asset": {
|
|
7
7
|
"name": "connect-linux.sh",
|
|
8
|
-
"url": "https://github.com/agentshouse/kit/releases/download/v0.2.1-
|
|
8
|
+
"url": "https://github.com/agentshouse/kit/releases/download/v0.2.1-ca18b01951c3b/connect-linux.sh"
|
|
9
9
|
}
|
|
10
10
|
},
|
|
11
11
|
"linux": {
|
|
12
12
|
"asset": {
|
|
13
13
|
"name": "connect-linux.sh",
|
|
14
|
-
"url": "https://github.com/agentshouse/kit/releases/download/v0.2.1-
|
|
14
|
+
"url": "https://github.com/agentshouse/kit/releases/download/v0.2.1-ca18b01951c3b/connect-linux.sh"
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
"windows": {
|
|
18
18
|
"asset": {
|
|
19
19
|
"name": "connect-windows.ps1",
|
|
20
|
-
"url": "https://github.com/agentshouse/kit/releases/download/v0.2.1-
|
|
20
|
+
"url": "https://github.com/agentshouse/kit/releases/download/v0.2.1-ca18b01951c3b/connect-windows.ps1"
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
}
|
package/dist/chatgpt.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { parseArgs } from 'node:util';
|
|
2
|
+
import { placeAppGit } from './app-git.js';
|
|
3
|
+
import { kitHome, readOwnAgent, writeOwnAgent } from './home.js';
|
|
4
|
+
import { accepted, DEFAULT_HOUSE } from './login.js';
|
|
5
|
+
const KEY_SOURCE = 'New key for a script on Connections';
|
|
6
|
+
const USAGE = `usage: kit chatgpt --key <key> [--house <origin>]
|
|
7
|
+
--key <key> a key from ${KEY_SOURCE}
|
|
8
|
+
--house <origin> the House of the key, ${DEFAULT_HOUSE} unless one is stored
|
|
9
|
+
`;
|
|
10
|
+
export async function chatgpt(argv) {
|
|
11
|
+
const { values } = parseArgs({
|
|
12
|
+
args: argv,
|
|
13
|
+
options: { key: { type: 'string' }, house: { type: 'string' }, help: { type: 'boolean', default: false } },
|
|
14
|
+
});
|
|
15
|
+
if (values.help) {
|
|
16
|
+
process.stdout.write(USAGE);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (values.key === undefined)
|
|
20
|
+
throw new Error(`pass --key with a key from ${KEY_SOURCE}`);
|
|
21
|
+
const before = await readOwnAgent();
|
|
22
|
+
const house = values.house ?? before?.house ?? DEFAULT_HOUSE;
|
|
23
|
+
if (!(await accepted(house, values.key)))
|
|
24
|
+
throw new Error(`${house} does not accept this key; pass one from ${KEY_SOURCE}`);
|
|
25
|
+
const relay = process.env.HOUSE_KIT_RELAY || undefined;
|
|
26
|
+
await writeOwnAgent({ house, ...(relay === undefined ? {} : { relay }), credential: values.key });
|
|
27
|
+
await placeAppGit(before, await readOwnAgent()).catch((error) => process.stderr.write(`kit: ${error.message}\n`));
|
|
28
|
+
process.stdout.write(`house now calls ${house} as you, with the key kept in ${kitHome()}.\n`);
|
|
29
|
+
}
|
package/dist/clis.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
|
+
import { randomUUID } from 'node:crypto';
|
|
2
3
|
import { constants, readFileSync } from 'node:fs';
|
|
3
4
|
import { access, mkdir, readFile, rename, writeFile } from 'node:fs/promises';
|
|
4
5
|
import { homedir, userInfo } from 'node:os';
|
|
5
|
-
import { delimiter, isAbsolute, join } from 'node:path';
|
|
6
|
+
import { delimiter, dirname, isAbsolute, join } from 'node:path';
|
|
6
7
|
import { kitHome } from './home.js';
|
|
7
8
|
const HOUSE_EXECUTABLES = /^host_executable\(name = "house", paths = (\[.*\])\)$/m;
|
|
8
9
|
function houseRule(houses) {
|
|
@@ -54,7 +55,7 @@ export async function allowHouseInCodex(path) {
|
|
|
54
55
|
houses.push(house);
|
|
55
56
|
}
|
|
56
57
|
await mkdir(rules, { recursive: true });
|
|
57
|
-
const temporary = `${file}.${
|
|
58
|
+
const temporary = `${file}.${randomUUID()}`;
|
|
58
59
|
await writeFile(temporary, houseRule(houses));
|
|
59
60
|
await rename(temporary, file);
|
|
60
61
|
}
|
|
@@ -199,7 +200,7 @@ export async function installAdapter(kind, signal) {
|
|
|
199
200
|
const release = KIT_PACKAGE.peerDependencies[adapter.package];
|
|
200
201
|
if ((await installedAdapter(kind)) === release)
|
|
201
202
|
return null;
|
|
202
|
-
const ran = await run('npm', ['install', '--prefix', prefix(kind), '--no-save', '--no-audit', '--no-fund', '--omit=optional', `${adapter.package}@${release}`], INSTALL_MS, true, signal);
|
|
203
|
+
const ran = await run('npm', ['install', '--prefix', prefix(kind), '--cache', join(kitHome(), 'npm-cache'), '--no-save', '--no-audit', '--no-fund', '--omit=optional', `${adapter.package}@${release}`], INSTALL_MS, true, signal);
|
|
203
204
|
return ran.status === 0 ? null : failureOf(ran, 'npm');
|
|
204
205
|
}
|
|
205
206
|
export async function installCli(kind, signal) {
|
|
@@ -224,6 +225,12 @@ export async function loginPath() {
|
|
|
224
225
|
const ran = await inLoginShell(`printf "${marker}%s\\n" "$PATH"`);
|
|
225
226
|
return ran.stdout.split('\n').findLast((line) => line.startsWith(marker)).slice(marker.length);
|
|
226
227
|
}
|
|
228
|
+
export async function writeCodexRule() {
|
|
229
|
+
const shell = await loginPath().catch(() => '');
|
|
230
|
+
await allowHouseInCodex([dirname(process.execPath), process.env.PATH ?? '', shell].join(delimiter)).catch((error) => {
|
|
231
|
+
throw new Error(`Codex's rule for house could not be written: ${error.message}`);
|
|
232
|
+
});
|
|
233
|
+
}
|
|
227
234
|
export async function versionOf(path, signal) {
|
|
228
235
|
return VERSION.exec((await run(path, ['--version'], READ_MS, false, signal)).stdout)?.[0] ?? null;
|
|
229
236
|
}
|
package/dist/conversations.js
CHANGED
|
@@ -17,6 +17,15 @@ import { createHowWeWork } from './skills.js';
|
|
|
17
17
|
import { transcribe } from './transcription.js';
|
|
18
18
|
import { workFor } from './work.js';
|
|
19
19
|
const KILLED = 'the conversation was killed';
|
|
20
|
+
const EXIT_PLAN_MODE = {
|
|
21
|
+
parse(value) {
|
|
22
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
23
|
+
throw new Error('_x.ai/exit_plan_mode needs an object');
|
|
24
|
+
}
|
|
25
|
+
return value;
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
export const CONVERSATION_INPUTS = new Set(['open', 'message', 'interrupt', 'kill', 'option', 'answer']);
|
|
20
29
|
function causeOf(error) {
|
|
21
30
|
return error instanceof Error ? error.message : String(error);
|
|
22
31
|
}
|
|
@@ -347,7 +356,8 @@ export class Conversations {
|
|
|
347
356
|
reader.session = sessionId;
|
|
348
357
|
const app = client({ name: '@agentshouse/kit' })
|
|
349
358
|
.onRequest('session/request_permission', ({ params, signal }) => this.ask(conversation, 'session/request_permission', params, false, signal))
|
|
350
|
-
.onRequest('elicitation/create', ({ params, signal }) => this.ask(conversation, 'elicitation/create', params, asksSecret(params), signal))
|
|
359
|
+
.onRequest('elicitation/create', ({ params, signal }) => this.ask(conversation, 'elicitation/create', params, asksSecret(params), signal))
|
|
360
|
+
.onRequest('_x.ai/exit_plan_mode', EXIT_PLAN_MODE, ({ params, signal }) => this.ask(conversation, '_x.ai/exit_plan_mode', params, false, signal));
|
|
351
361
|
const cli = await unlessAborted(this.kit.agents.cli(route.kind), conversation.killed.signal);
|
|
352
362
|
const bridge = await openBridge(this.kit.house, this.kit.copies, conversation.id, conversation.killed.signal);
|
|
353
363
|
if (conversation.kills > 0) {
|
package/dist/copies.js
CHANGED
|
@@ -3,7 +3,7 @@ import { randomUUID } from 'node:crypto';
|
|
|
3
3
|
import { mkdir, readFile, readdir, realpath, rename, rm, rmdir, stat, writeFile } from 'node:fs/promises';
|
|
4
4
|
import { dirname, join } from 'node:path';
|
|
5
5
|
import { finalRefusal, HouseRefusal, retrying } from './api.js';
|
|
6
|
-
import { blobId, blobText, git, HOUSE_REF, importCommits, localCopies, revision, run, succeeded, tree, } from './git.js';
|
|
6
|
+
import { blobId, blobText, git, isText, HOUSE_REF, importCommits, localCopies, revision, run, succeeded, tree, } from './git.js';
|
|
7
7
|
import { kitHome } from './home.js';
|
|
8
8
|
import { operationId } from './operation.js';
|
|
9
9
|
import { refusalOf } from './refusals.js';
|
|
@@ -29,6 +29,10 @@ const REBASED = new Set([
|
|
|
29
29
|
function rebaseFixes(refusal) {
|
|
30
30
|
return refusal.code === 'edit_conflict' && refusal.conflicts.some((code) => REBASED.has(code));
|
|
31
31
|
}
|
|
32
|
+
function textOnly(paths) {
|
|
33
|
+
const [named, them] = paths.length === 1 ? [`${paths[0]} is`, 'it'] : [`${paths.join(', ')} are`, 'them'];
|
|
34
|
+
return `${named} not text, and house push sends text only; remove ${them} from the commit and place ${them} with house upload`;
|
|
35
|
+
}
|
|
32
36
|
function short(commit) {
|
|
33
37
|
return commit.slice(0, 12);
|
|
34
38
|
}
|
|
@@ -572,7 +576,13 @@ export class LocalCopies {
|
|
|
572
576
|
const after = await tree(copy.repository, commit);
|
|
573
577
|
const moved = movedPaths(copy.moves, before, after);
|
|
574
578
|
const arrived = new Set(moved.values());
|
|
575
|
-
const
|
|
579
|
+
const binary = [];
|
|
580
|
+
for (const [path, entry] of after)
|
|
581
|
+
if (before.get(path) !== entry && !(await isText(copy.repository, entry)))
|
|
582
|
+
binary.push(path);
|
|
583
|
+
if (binary.length > 0)
|
|
584
|
+
throw new Error(textOnly(binary));
|
|
585
|
+
const text = (entry) => blobText(copy.repository, entry);
|
|
576
586
|
const changes = [];
|
|
577
587
|
for (const path of [...new Set([...before.keys(), ...after.keys()])].sort()) {
|
|
578
588
|
if (arrived.has(path))
|
|
@@ -585,7 +595,7 @@ export class LocalCopies {
|
|
|
585
595
|
changes.push({ op: 'rename', path: `${root}/${path}`, to: `${root}/${to}`, base: known });
|
|
586
596
|
const moving = after.get(to);
|
|
587
597
|
if (moving !== prior) {
|
|
588
|
-
changes.push({ op: 'replace', path: `${root}/${to}`, base: known, content: await text(moving
|
|
598
|
+
changes.push({ op: 'replace', path: `${root}/${to}`, base: known, content: await text(moving) });
|
|
589
599
|
}
|
|
590
600
|
continue;
|
|
591
601
|
}
|
|
@@ -594,9 +604,9 @@ export class LocalCopies {
|
|
|
594
604
|
if (next === undefined)
|
|
595
605
|
changes.push({ op: 'remove', path: `${root}/${path}`, base: known });
|
|
596
606
|
else if (prior === undefined)
|
|
597
|
-
changes.push({ op: 'create', path: `${root}/${path}`, content: await text(next
|
|
607
|
+
changes.push({ op: 'create', path: `${root}/${path}`, content: await text(next) });
|
|
598
608
|
else
|
|
599
|
-
changes.push(...changed(`${root}/${path}`, path, known, await text(prior
|
|
609
|
+
changes.push(...changed(`${root}/${path}`, path, known, await text(prior), await text(next)));
|
|
600
610
|
}
|
|
601
611
|
return changes;
|
|
602
612
|
}
|
|
@@ -663,7 +673,7 @@ export class LocalCopies {
|
|
|
663
673
|
written.push({
|
|
664
674
|
path: `${root}/${path}`,
|
|
665
675
|
revision: entry === undefined ? null : (revisionAt(current, current.house, path) ?? null),
|
|
666
|
-
content: entry === undefined ? null : await blobText(copy.repository, entry
|
|
676
|
+
content: entry === undefined ? null : await blobText(copy.repository, entry),
|
|
667
677
|
});
|
|
668
678
|
}
|
|
669
679
|
return this.finished(await this.save({ ...current, push: { ...push, state: 'accepted', written } }));
|
|
@@ -707,7 +717,7 @@ export class LocalCopies {
|
|
|
707
717
|
{
|
|
708
718
|
path: `${rootOf(copy.room_handle)}/${path}`,
|
|
709
719
|
revision: entry === undefined ? null : (revisionAt(copy, copy.house, path) ?? null),
|
|
710
|
-
content: entry === undefined ? null : await blobText(copy.repository, entry
|
|
720
|
+
content: entry === undefined ? null : await blobText(copy.repository, entry),
|
|
711
721
|
},
|
|
712
722
|
];
|
|
713
723
|
}
|
|
@@ -752,7 +762,7 @@ export class LocalCopies {
|
|
|
752
762
|
async landed(repository, changes, house, selected) {
|
|
753
763
|
const text = async (path) => {
|
|
754
764
|
const entry = house.get(relative(path));
|
|
755
|
-
return entry === undefined ? undefined : blobText(repository, entry
|
|
765
|
+
return entry === undefined ? undefined : blobText(repository, entry);
|
|
756
766
|
};
|
|
757
767
|
for (const change of changes) {
|
|
758
768
|
const current = await text(change.path);
|
package/dist/end.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { forgetRejected } from './home.js';
|
|
2
|
+
import { installCommand } from './placement.js';
|
|
2
3
|
import { killDescendants } from './scope.js';
|
|
3
4
|
export const REPLACED = 'another Kit started for this Environment';
|
|
4
5
|
function exit(reason, status) {
|
|
@@ -12,6 +13,9 @@ export function end(reason) {
|
|
|
12
13
|
export function restart(reason) {
|
|
13
14
|
exit(reason, 1);
|
|
14
15
|
}
|
|
16
|
+
export function updateRequired(house) {
|
|
17
|
+
end(`This Kit is too old for House. Update it: ${installCommand(house)}`);
|
|
18
|
+
}
|
|
15
19
|
export async function signInAgain(rejected) {
|
|
16
20
|
await forgetRejected(rejected);
|
|
17
21
|
restart('sign in again');
|
package/dist/files.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
1
2
|
import { mkdir, writeFile } from 'node:fs/promises';
|
|
2
3
|
import { join } from 'node:path';
|
|
3
4
|
import { HouseRefusal, retrying } from './api.js';
|
|
4
5
|
import { relayed } from './relay.js';
|
|
6
|
+
export function verified(bytes, sha256, name) {
|
|
7
|
+
if (createHash('sha256').update(bytes).digest('hex') !== sha256)
|
|
8
|
+
throw new Error(`${name} did not arrive whole; download it again`);
|
|
9
|
+
return bytes;
|
|
10
|
+
}
|
|
5
11
|
export async function placeFiles(house, directory, files, signal) {
|
|
6
12
|
const paths = [];
|
|
7
13
|
for (const file of files) {
|
|
@@ -16,7 +22,7 @@ export async function placeFiles(house, directory, files, signal) {
|
|
|
16
22
|
});
|
|
17
23
|
await mkdir(folder, { recursive: true });
|
|
18
24
|
const path = join(folder, file.name);
|
|
19
|
-
await writeFile(path, Buffer.from(await answer.arrayBuffer()));
|
|
25
|
+
await writeFile(path, verified(Buffer.from(await answer.arrayBuffer()), file.sha256, file.name));
|
|
20
26
|
paths.push(path);
|
|
21
27
|
}
|
|
22
28
|
return paths;
|
package/dist/git.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
|
+
import { isUtf8 } from 'node:buffer';
|
|
2
3
|
import { createHash } from 'node:crypto';
|
|
3
4
|
import { join } from 'node:path';
|
|
4
5
|
import { withoutProxy } from './clis.js';
|
|
@@ -48,14 +49,16 @@ export async function tree(repository, commit) {
|
|
|
48
49
|
}
|
|
49
50
|
return entries;
|
|
50
51
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
const TEXT_MAX_BYTES = 16 * 1024 * 1024;
|
|
53
|
+
async function blob(repository, object) {
|
|
54
|
+
return (await run(repository, ['cat-file', 'blob', object])).stdout;
|
|
55
|
+
}
|
|
56
|
+
export async function blobText(repository, object) {
|
|
57
|
+
return (await blob(repository, object)).toString('utf8');
|
|
58
|
+
}
|
|
59
|
+
export async function isText(repository, object) {
|
|
60
|
+
const bytes = await blob(repository, object);
|
|
61
|
+
return bytes.length <= TEXT_MAX_BYTES && isUtf8(bytes) && !bytes.includes(0);
|
|
59
62
|
}
|
|
60
63
|
export function blobId(content) {
|
|
61
64
|
const bytes = Buffer.from(content, 'utf8');
|
package/dist/home.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { accessSync, chmodSync, constants, existsSync, linkSync, lstatSync, mkdirSync, readFileSync, renameSync, rmSync } from 'node:fs';
|
|
2
3
|
import { mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises';
|
|
3
|
-
import { homedir } from 'node:os';
|
|
4
|
+
import { homedir, tmpdir } from 'node:os';
|
|
4
5
|
import { join } from 'node:path';
|
|
5
6
|
import { selectRelay } from './relay.js';
|
|
6
7
|
const ENROLMENT = 'credential.json';
|
|
@@ -8,8 +9,41 @@ const DISCONNECTED = 'disconnected.json';
|
|
|
8
9
|
const CONFIGURATION = 'kit.json';
|
|
9
10
|
const OWN_AGENT = 'own-agent.json';
|
|
10
11
|
const RESTART = 'restart';
|
|
12
|
+
let defaulted;
|
|
13
|
+
function writable(directory) {
|
|
14
|
+
try {
|
|
15
|
+
accessSync(directory, constants.W_OK | constants.X_OK);
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function ownTemporaryHome() {
|
|
23
|
+
const home = join(tmpdir(), `house-kit-${process.getuid()}`);
|
|
24
|
+
try {
|
|
25
|
+
mkdirSync(home, { mode: 0o700 });
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
if (error.code !== 'EEXIST')
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
const found = lstatSync(home);
|
|
32
|
+
if (found.isSymbolicLink())
|
|
33
|
+
throw new Error(`${home} is a symbolic link`);
|
|
34
|
+
if (!found.isDirectory())
|
|
35
|
+
throw new Error(`${home} is not a directory`);
|
|
36
|
+
if (found.uid !== process.getuid())
|
|
37
|
+
throw new Error(`${home} is not owned by this User`);
|
|
38
|
+
chmodSync(home, 0o700);
|
|
39
|
+
return home;
|
|
40
|
+
}
|
|
41
|
+
function defaultHome() {
|
|
42
|
+
const home = join(homedir(), '.house-kit');
|
|
43
|
+
return existsSync(home) || writable(homedir()) ? home : ownTemporaryHome();
|
|
44
|
+
}
|
|
11
45
|
export function kitHome() {
|
|
12
|
-
return process.env.HOUSE_KIT_HOME
|
|
46
|
+
return process.env.HOUSE_KIT_HOME || (defaulted ??= defaultHome());
|
|
13
47
|
}
|
|
14
48
|
export function workspaceRoot() {
|
|
15
49
|
return process.env.HOUSE_KIT_WORKSPACE ?? '/agents/house';
|
|
@@ -30,7 +64,7 @@ export async function readHome(name) {
|
|
|
30
64
|
export async function writeHome(name, value) {
|
|
31
65
|
const home = kitHome();
|
|
32
66
|
await mkdir(home, { recursive: true, mode: 0o700 });
|
|
33
|
-
const temporary = join(home, `${name}.${
|
|
67
|
+
const temporary = join(home, `${name}.${randomUUID()}`);
|
|
34
68
|
await writeFile(temporary, `${JSON.stringify(value)}\n`, { mode: 0o600 });
|
|
35
69
|
await rename(temporary, join(home, name));
|
|
36
70
|
}
|
|
@@ -47,6 +81,9 @@ export async function writeEnrolment(enrolment) {
|
|
|
47
81
|
export function readDisconnected() {
|
|
48
82
|
return readHome(DISCONNECTED);
|
|
49
83
|
}
|
|
84
|
+
export function forgetDisconnected() {
|
|
85
|
+
return rm(join(kitHome(), DISCONNECTED), { force: true });
|
|
86
|
+
}
|
|
50
87
|
export async function forgetEnrolment({ house, environment }) {
|
|
51
88
|
await writeHome(DISCONNECTED, { house, environment });
|
|
52
89
|
await rm(join(kitHome(), ENROLMENT), { force: true });
|