@agentshouse/kit 0.2.1-c5d36e97b0fea → 0.2.1-c681dfca497a8
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 +24 -24
- package/dist/agents.js +24 -5
- package/dist/api.js +6 -2
- package/dist/bootstrap.json +4 -4
- package/dist/chatgpt.js +26 -0
- package/dist/clis.js +41 -9
- package/dist/conversations.js +9 -5
- package/dist/copies.js +36 -26
- package/dist/end.js +17 -3
- package/dist/enrol-main.js +7 -1
- package/dist/files.js +7 -1
- package/dist/git.js +11 -8
- package/dist/home.js +76 -5
- package/dist/house-main.js +164 -63
- package/dist/instructions.js +5 -4
- package/dist/kit-main.js +53 -8
- package/dist/login.js +83 -18
- package/dist/parts.js +34 -16
- package/dist/placement.js +48 -0
- package/dist/relay.js +12 -2
- package/dist/resident.js +15 -6
- package/dist/service-main.js +9 -0
- package/dist/service.js +33 -0
- package/dist/skills.js +11 -1
- package/dist/stream.js +9 -4
- package/dist/update.js +28 -6
- package/dist/wire.js +6 -0
- package/how-we-work.md +11 -3
- package/package.json +3 -2
- 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
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
# House Kit
|
|
2
2
|
|
|
3
|
-
House Kit connects an Environment, a Linux computer or server, to
|
|
4
|
-
|
|
5
|
-
through the agent CLIs you chose and gives each Agent the `house` command.
|
|
3
|
+
House Kit connects an Environment, a Linux computer or server, to [agents.house](https://agents.house). It runs
|
|
4
|
+
your Agents' conversations through the agent CLIs you chose and gives each Agent the `house` command.
|
|
6
5
|
|
|
7
6
|
## Install
|
|
8
7
|
|
|
9
|
-
Run `curl -fsSL agents.house/kit | sh`, or `irm agents.house/kit.ps1 | iex` on
|
|
10
|
-
|
|
11
|
-
installs House Kit natively under your own account, without an admin password,
|
|
8
|
+
Run `curl -fsSL agents.house/kit | sh`, or `irm agents.house/kit.ps1 | iex` on Windows, and again to update;
|
|
9
|
+
options follow `sh -s --`. On macOS and Linux it installs House Kit natively under your own account, without an admin password,
|
|
12
10
|
as a service that runs while you are logged in. `kit` and `house` are then on
|
|
13
11
|
your login shell's `PATH`, and your workspace is `~/AgentsHouse` unless you
|
|
14
12
|
pass `--workspace <path>`.
|
|
@@ -20,7 +18,7 @@ workspace. On Windows 11 the container is the one choice. Append a `kit` or
|
|
|
20
18
|
Running the command for the other choice on a connected computer asks you to
|
|
21
19
|
confirm, then replaces its Environment, whose Agents end, with a new one.
|
|
22
20
|
|
|
23
|
-
On your own
|
|
21
|
+
On your own Linux server, run the Linux command with `--linux` to
|
|
24
22
|
install House Kit natively, with its workspace at `/agents/house`; `kit` and
|
|
25
23
|
`house` are then on the server's `PATH`.
|
|
26
24
|
|
|
@@ -33,26 +31,28 @@ them out; running it again without the flag brings them back.
|
|
|
33
31
|
|
|
34
32
|
## Commands
|
|
35
33
|
|
|
36
|
-
`kit login` opens or prints a link you confirm in any browser, on this
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
`
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
`kit
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
34
|
+
`kit login` opens or prints a link you confirm in any browser, on this computer
|
|
35
|
+
or another, continues on its own and keeps the Environment's credential 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
|
+
reconnects an Environment you already have; `--rooms <ref>[,<ref>...]` gives it
|
|
38
|
+
only those Rooms and `--no-private` every Room but your Private Room; `--code <code>` connects immediately without a link.
|
|
39
|
+
A login also connects your own agent: outside an Agent conversation, `house <tool>` calls
|
|
40
|
+
House as you and `git` clones and pushes your Apps at `<house>/app/` as you, until you revoke
|
|
41
|
+
that connection on Connections. `house help` lists the Tools. Codex sessions started after a
|
|
42
|
+
login run a lone `house` command outside their sandbox. `kit logout` disconnects this
|
|
43
|
+
computer, stops House Kit and ends your own agent's connection, so `house` and `git` no
|
|
44
|
+
longer act as you here; a later `kit login` reconnects the same Environment.
|
|
45
|
+
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
|
+
`kit resident` keeps the Environment connected and, as it connects, copies the text of each Room
|
|
48
|
+
you chose for it as a Git repository in the workspace's `local-copies`. `house fetch` records
|
|
49
|
+
House's changes on each copy's `refs/house/received`; rebase onto it, commit and run
|
|
50
|
+
`house push --owner` in the copy, through the install command in the container. An Agent runs
|
|
51
|
+
both, without `--owner`. `house upload` and `house download` move a Room's other files.
|
|
52
52
|
|
|
53
53
|
House Kit turns each audio file of your message to an Agent into text on this
|
|
54
54
|
computer before the Agent reads it. While transcription is on, the speech
|
|
55
|
-
engine and model use about 425 MB
|
|
55
|
+
engine and model use about 425 MB beside the Environment's credential; turning it off deletes them.
|
|
56
56
|
|
|
57
57
|
## License
|
|
58
58
|
|
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);
|
|
@@ -130,8 +132,14 @@ export class Agents {
|
|
|
130
132
|
reads = new Map();
|
|
131
133
|
sending = Promise.resolve();
|
|
132
134
|
sent = null;
|
|
133
|
-
|
|
135
|
+
refreshing = 0;
|
|
136
|
+
changed;
|
|
137
|
+
constructor(house, changed = () => undefined) {
|
|
134
138
|
this.house = house;
|
|
139
|
+
this.changed = changed;
|
|
140
|
+
}
|
|
141
|
+
idle() {
|
|
142
|
+
return this.refreshing === 0;
|
|
135
143
|
}
|
|
136
144
|
read() {
|
|
137
145
|
return this.reading.then(() => undefined, () => undefined);
|
|
@@ -140,19 +148,28 @@ export class Agents {
|
|
|
140
148
|
return this.desired.routes.find((route) => route.agent_id === agentId);
|
|
141
149
|
}
|
|
142
150
|
refresh() {
|
|
151
|
+
this.refreshing++;
|
|
152
|
+
this.changed();
|
|
143
153
|
const reading = this.read().then(async () => {
|
|
144
154
|
this.desired = await this.house.deliver('/kit/agents/desired', {});
|
|
145
155
|
return this.desired;
|
|
146
156
|
});
|
|
147
157
|
this.reading = reading;
|
|
148
|
-
|
|
158
|
+
reading
|
|
159
|
+
.then(({ agents, transcribe }) => Promise.all([
|
|
149
160
|
holdTranscription(transcribe)
|
|
150
161
|
.then((changed) => (changed ? this.report() : undefined))
|
|
151
|
-
.catch(logged)
|
|
162
|
+
.catch(logged),
|
|
152
163
|
Promise.all(agents.map((kind) => this.load(kind)))
|
|
153
164
|
.then(() => this.report())
|
|
154
|
-
.catch(logged)
|
|
165
|
+
.catch(logged),
|
|
166
|
+
]))
|
|
167
|
+
.catch(() => undefined)
|
|
168
|
+
.finally(() => {
|
|
169
|
+
this.refreshing--;
|
|
170
|
+
this.changed();
|
|
155
171
|
});
|
|
172
|
+
return reading.then(() => undefined);
|
|
156
173
|
}
|
|
157
174
|
cli(kind) {
|
|
158
175
|
return this.queue(kind, async () => {
|
|
@@ -257,7 +274,7 @@ export class Agents {
|
|
|
257
274
|
}
|
|
258
275
|
async load(kind) {
|
|
259
276
|
const known = this.readings.get(kind);
|
|
260
|
-
if (known !== undefined && known.failure === null)
|
|
277
|
+
if (known !== undefined && known.failure === null && known.minimum === undefined)
|
|
261
278
|
return;
|
|
262
279
|
await this.examine(kind, SIGNED_OUT, offer);
|
|
263
280
|
}
|
|
@@ -270,6 +287,8 @@ export class Agents {
|
|
|
270
287
|
const body = {
|
|
271
288
|
os: await operatingSystem(),
|
|
272
289
|
kit_version: KIT_VERSION,
|
|
290
|
+
wire: KIT_WIRE,
|
|
291
|
+
updates_itself: await updatesItself(),
|
|
273
292
|
agent_base: agentBase(),
|
|
274
293
|
agents,
|
|
275
294
|
transcription: transcriptionReport(),
|
package/dist/api.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { setTimeout as delay } from 'node:timers/promises';
|
|
2
|
-
import {
|
|
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);
|
|
@@ -54,7 +58,7 @@ async function enrolledPost(path, body, signal) {
|
|
|
54
58
|
}
|
|
55
59
|
catch (error) {
|
|
56
60
|
if (error instanceof HouseRefusal && error.status === 401)
|
|
57
|
-
|
|
61
|
+
await signInAgain(credential);
|
|
58
62
|
throw error;
|
|
59
63
|
}
|
|
60
64
|
}
|
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-c681dfca497a8",
|
|
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-c681dfca497a8/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-c681dfca497a8/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-c681dfca497a8/connect-windows.ps1"
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
}
|
package/dist/chatgpt.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { parseArgs } from 'node:util';
|
|
2
|
+
import { kitHome, readOwnAgent, writeOwnAgent } from './home.js';
|
|
3
|
+
import { accepted, DEFAULT_HOUSE } from './login.js';
|
|
4
|
+
const KEY_SOURCE = 'New key for a script on Connections';
|
|
5
|
+
const USAGE = `usage: kit chatgpt --key <key> [--house <origin>]
|
|
6
|
+
--key <key> a key from ${KEY_SOURCE}
|
|
7
|
+
--house <origin> the House of the key, ${DEFAULT_HOUSE} unless one is stored
|
|
8
|
+
`;
|
|
9
|
+
export async function chatgpt(argv) {
|
|
10
|
+
const { values } = parseArgs({
|
|
11
|
+
args: argv,
|
|
12
|
+
options: { key: { type: 'string' }, house: { type: 'string' }, help: { type: 'boolean', default: false } },
|
|
13
|
+
});
|
|
14
|
+
if (values.help) {
|
|
15
|
+
process.stdout.write(USAGE);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (values.key === undefined)
|
|
19
|
+
throw new Error(`pass --key with a key from ${KEY_SOURCE}`);
|
|
20
|
+
const house = values.house ?? (await readOwnAgent())?.house ?? DEFAULT_HOUSE;
|
|
21
|
+
if (!(await accepted(house, values.key)))
|
|
22
|
+
throw new Error(`${house} does not accept this key; pass one from ${KEY_SOURCE}`);
|
|
23
|
+
const relay = process.env.HOUSE_KIT_RELAY || undefined;
|
|
24
|
+
await writeOwnAgent({ house, ...(relay === undefined ? {} : { relay }), credential: values.key });
|
|
25
|
+
process.stdout.write(`house now calls ${house} as you, with the key kept in ${kitHome()}.\n`);
|
|
26
|
+
}
|
package/dist/clis.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
2
|
import { constants, readFileSync } from 'node:fs';
|
|
3
|
-
import { access, mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { access, mkdir, readFile, rename, writeFile } from 'node:fs/promises';
|
|
4
4
|
import { homedir, userInfo } from 'node:os';
|
|
5
|
-
import { delimiter, isAbsolute, join } from 'node:path';
|
|
5
|
+
import { delimiter, dirname, isAbsolute, join } from 'node:path';
|
|
6
6
|
import { kitHome } from './home.js';
|
|
7
|
+
const HOUSE_EXECUTABLES = /^host_executable\(name = "house", paths = (\[.*\])\)$/m;
|
|
8
|
+
function houseRule(houses) {
|
|
9
|
+
return `prefix_rule(pattern = ["house"], decision = "allow")\nhost_executable(name = "house", paths = ${JSON.stringify(houses)})\n`;
|
|
10
|
+
}
|
|
7
11
|
const RAW_SUBTYPES = [
|
|
8
12
|
'background_tasks_changed',
|
|
9
13
|
'task_started',
|
|
@@ -22,15 +26,37 @@ async function executable(path) {
|
|
|
22
26
|
return false;
|
|
23
27
|
}
|
|
24
28
|
}
|
|
25
|
-
async function
|
|
29
|
+
async function listedHouses(file) {
|
|
30
|
+
let text;
|
|
31
|
+
try {
|
|
32
|
+
text = await readFile(file, 'utf8');
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
if (error.code === 'ENOENT')
|
|
36
|
+
return [];
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
const listed = JSON.parse(HOUSE_EXECUTABLES.exec(text)?.[1] ?? '[]');
|
|
41
|
+
return Array.isArray(listed) ? listed.filter((house) => typeof house === 'string') : [];
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export async function allowHouseInCodex(path) {
|
|
26
48
|
const candidates = [...new Set(path.split(delimiter).filter((directory) => isAbsolute(directory)))].map((directory) => join(directory, 'house'));
|
|
27
|
-
const houses = [];
|
|
28
|
-
for (const candidate of candidates)
|
|
29
|
-
if (await executable(candidate))
|
|
30
|
-
houses.push(candidate);
|
|
31
49
|
const rules = join(process.env.CODEX_HOME || join(homedir(), '.codex'), 'rules');
|
|
50
|
+
const file = join(rules, 'house.rules');
|
|
51
|
+
const houses = [];
|
|
52
|
+
for (const house of [...(await listedHouses(file)), ...candidates]) {
|
|
53
|
+
if (!houses.includes(house) && (await executable(house)))
|
|
54
|
+
houses.push(house);
|
|
55
|
+
}
|
|
32
56
|
await mkdir(rules, { recursive: true });
|
|
33
|
-
|
|
57
|
+
const temporary = `${file}.${process.pid}`;
|
|
58
|
+
await writeFile(temporary, houseRule(houses));
|
|
59
|
+
await rename(temporary, file);
|
|
34
60
|
}
|
|
35
61
|
async function nothing() { }
|
|
36
62
|
function bridgeInClaudeSandbox(bridge) {
|
|
@@ -173,7 +199,7 @@ export async function installAdapter(kind, signal) {
|
|
|
173
199
|
const release = KIT_PACKAGE.peerDependencies[adapter.package];
|
|
174
200
|
if ((await installedAdapter(kind)) === release)
|
|
175
201
|
return null;
|
|
176
|
-
const ran = await run('npm', ['install', '--prefix', prefix(kind), '--no-save', '--no-audit', '--no-fund', '--omit=optional', `${adapter.package}@${release}`], INSTALL_MS, true, signal);
|
|
202
|
+
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);
|
|
177
203
|
return ran.status === 0 ? null : failureOf(ran, 'npm');
|
|
178
204
|
}
|
|
179
205
|
export async function installCli(kind, signal) {
|
|
@@ -198,6 +224,12 @@ export async function loginPath() {
|
|
|
198
224
|
const ran = await inLoginShell(`printf "${marker}%s\\n" "$PATH"`);
|
|
199
225
|
return ran.stdout.split('\n').findLast((line) => line.startsWith(marker)).slice(marker.length);
|
|
200
226
|
}
|
|
227
|
+
export async function writeCodexRule() {
|
|
228
|
+
const shell = await loginPath().catch(() => '');
|
|
229
|
+
await allowHouseInCodex([dirname(process.execPath), process.env.PATH ?? '', shell].join(delimiter)).catch((error) => {
|
|
230
|
+
throw new Error(`Codex's rule for house could not be written: ${error.message}`);
|
|
231
|
+
});
|
|
232
|
+
}
|
|
201
233
|
export async function versionOf(path, signal) {
|
|
202
234
|
return VERSION.exec((await run(path, ['--version'], READ_MS, false, signal)).stdout)?.[0] ?? null;
|
|
203
235
|
}
|
package/dist/conversations.js
CHANGED
|
@@ -17,6 +17,7 @@ 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
|
+
export const CONVERSATION_INPUTS = new Set(['open', 'message', 'interrupt', 'kill', 'option', 'answer']);
|
|
20
21
|
function causeOf(error) {
|
|
21
22
|
return error instanceof Error ? error.message : String(error);
|
|
22
23
|
}
|
|
@@ -132,6 +133,9 @@ export class Conversations {
|
|
|
132
133
|
return false;
|
|
133
134
|
return !conversations.some((conversation) => conversation.running?.scope.working() || [...conversation.leftovers].some((scope) => scope.working()));
|
|
134
135
|
}
|
|
136
|
+
quiet() {
|
|
137
|
+
return this.idle() && [...this.conversations.values()].every((conversation) => conversation.open === 0);
|
|
138
|
+
}
|
|
135
139
|
look() {
|
|
136
140
|
for (const conversation of this.conversations.values()) {
|
|
137
141
|
for (const scope of conversation.leftovers) {
|
|
@@ -499,7 +503,7 @@ export class Conversations {
|
|
|
499
503
|
if (conversation.turn === turn)
|
|
500
504
|
conversation.turn = null;
|
|
501
505
|
const body = Promise.allSettled(turn.uploads).then(() => ({
|
|
502
|
-
parts: turn.parts.
|
|
506
|
+
parts: turn.parts.saved(),
|
|
503
507
|
context: turn.parts.context,
|
|
504
508
|
...failed,
|
|
505
509
|
}));
|
|
@@ -644,7 +648,7 @@ export class Conversations {
|
|
|
644
648
|
turn.parts.plan(event.entries);
|
|
645
649
|
return;
|
|
646
650
|
case 'image':
|
|
647
|
-
turn.uploads.push(this.image(conversation, turn, event.data, event.mediaType));
|
|
651
|
+
turn.uploads.push(this.image(conversation, turn, turn.parts.reserve(), event.data, event.mediaType));
|
|
648
652
|
this.kit.changed();
|
|
649
653
|
return;
|
|
650
654
|
}
|
|
@@ -664,7 +668,7 @@ export class Conversations {
|
|
|
664
668
|
else
|
|
665
669
|
conversation.turn.parts.start(part);
|
|
666
670
|
}
|
|
667
|
-
async image(conversation, turn, data, mediaType) {
|
|
671
|
+
async image(conversation, turn, reserved, data, mediaType) {
|
|
668
672
|
const bytes = Buffer.from(data, 'base64');
|
|
669
673
|
const name = `image-${++turn.images}.${mediaType.split('/')[1]}`;
|
|
670
674
|
try {
|
|
@@ -677,10 +681,10 @@ export class Conversations {
|
|
|
677
681
|
const saved = declared.upload === undefined ? declared : await uploadBytes(declared.upload, bytes);
|
|
678
682
|
if (saved.save.status !== 'saved')
|
|
679
683
|
throw new Error(saved.save.failure ?? saved.save.status);
|
|
680
|
-
turn.parts.
|
|
684
|
+
turn.parts.arrive({ type: 'image', file: saved.version, name, media_type: mediaType }, reserved);
|
|
681
685
|
}
|
|
682
686
|
catch (error) {
|
|
683
|
-
turn.parts.
|
|
687
|
+
turn.parts.arrive({ type: 'marker', marker: 'retry', text: `${name} was not saved: ${causeOf(error)}` }, reserved);
|
|
684
688
|
}
|
|
685
689
|
}
|
|
686
690
|
}
|
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
|
}
|
|
@@ -42,7 +46,7 @@ function expiredAuthority(error) {
|
|
|
42
46
|
return undefined;
|
|
43
47
|
try {
|
|
44
48
|
const { error: refused } = JSON.parse(error.text);
|
|
45
|
-
return refused?.code === '
|
|
49
|
+
return refused?.code === 'expired' && typeof refused.authority === 'string' ? refused.authority : undefined;
|
|
46
50
|
}
|
|
47
51
|
catch {
|
|
48
52
|
return undefined;
|
|
@@ -168,7 +172,7 @@ export class LocalCopies {
|
|
|
168
172
|
house;
|
|
169
173
|
copies = new Map();
|
|
170
174
|
queues = new Map();
|
|
171
|
-
|
|
175
|
+
answering = Promise.resolve();
|
|
172
176
|
constructor(house) {
|
|
173
177
|
this.house = house;
|
|
174
178
|
this.owner = {
|
|
@@ -200,39 +204,39 @@ export class LocalCopies {
|
|
|
200
204
|
}
|
|
201
205
|
}
|
|
202
206
|
async mapping() {
|
|
203
|
-
await this.
|
|
207
|
+
await this.answering;
|
|
204
208
|
return [...this.copies.values()]
|
|
205
209
|
.filter((copy) => copy.active)
|
|
206
210
|
.map((copy) => `${rootOf(copy.room_handle)}: ${copy.repository}`)
|
|
207
211
|
.sort();
|
|
208
212
|
}
|
|
209
|
-
async
|
|
210
|
-
const
|
|
211
|
-
if (
|
|
212
|
-
logged(
|
|
213
|
+
async connected() {
|
|
214
|
+
const copied = await this.answered(() => this.fetched(false));
|
|
215
|
+
if (copied.refused)
|
|
216
|
+
logged(copied.text);
|
|
213
217
|
}
|
|
214
218
|
fetch() {
|
|
215
|
-
return this.
|
|
219
|
+
return this.answered(() => this.fetched(true));
|
|
216
220
|
}
|
|
217
|
-
|
|
218
|
-
const
|
|
219
|
-
this.
|
|
220
|
-
return
|
|
221
|
+
answered(work) {
|
|
222
|
+
const answered = this.answering.then(work);
|
|
223
|
+
this.answering = answered.catch(() => undefined);
|
|
224
|
+
return answered;
|
|
221
225
|
}
|
|
222
226
|
async fetched(refreshing) {
|
|
223
|
-
const { local_copy:
|
|
224
|
-
const
|
|
225
|
-
return this.holding([...new Set([...this.copies.keys(), ...
|
|
227
|
+
const { local_copy: answer } = await this.house.post('/kit/local-copy/selection', {});
|
|
228
|
+
const synced = new Map(answer.rooms.map((room) => [`rooms/${room.room_ref}`, room.room_handle]));
|
|
229
|
+
return this.holding([...new Set([...this.copies.keys(), ...synced.keys()])].sort(), async () => {
|
|
226
230
|
const said = [];
|
|
227
231
|
let refused = false;
|
|
228
232
|
for (const copy of this.copies.values()) {
|
|
229
|
-
if (
|
|
233
|
+
if (synced.has(copy.key) || !copy.active)
|
|
230
234
|
continue;
|
|
231
235
|
await this.save({ ...copy, active: false });
|
|
232
236
|
said.push(`${rootOf(copy.room_handle)}: no longer synced to this Environment; its files stay`);
|
|
233
237
|
}
|
|
234
238
|
const current = [];
|
|
235
|
-
for (const [key, handle] of
|
|
239
|
+
for (const [key, handle] of synced) {
|
|
236
240
|
try {
|
|
237
241
|
const held = this.copies.get(key);
|
|
238
242
|
if (held === undefined || !(await exists(held.repository))) {
|
|
@@ -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
|
}
|
|
@@ -623,7 +633,7 @@ export class LocalCopies {
|
|
|
623
633
|
const { upload, ...unstaged } = copy.push;
|
|
624
634
|
return this.settle(await this.save({ ...copy, push: unstaged }), caller, true);
|
|
625
635
|
}
|
|
626
|
-
if (outcome.refused.code === '
|
|
636
|
+
if (outcome.refused.code === 'expired')
|
|
627
637
|
return this.recovered(copy);
|
|
628
638
|
const rebased = rebaseFixes(outcome.refused);
|
|
629
639
|
let settled = await this.save(without(copy));
|
|
@@ -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,8 +1,22 @@
|
|
|
1
|
+
import { forgetRejected } from './home.js';
|
|
2
|
+
import { installCommand } from './placement.js';
|
|
1
3
|
import { killDescendants } from './scope.js';
|
|
2
4
|
export const REPLACED = 'another Kit started for this Environment';
|
|
3
|
-
|
|
4
|
-
export function end(reason) {
|
|
5
|
+
function exit(reason, status) {
|
|
5
6
|
process.stderr.write(`kit: ${reason}\n`);
|
|
6
7
|
killDescendants();
|
|
7
|
-
process.exit(
|
|
8
|
+
process.exit(status);
|
|
9
|
+
}
|
|
10
|
+
export function end(reason) {
|
|
11
|
+
exit(reason, 0);
|
|
12
|
+
}
|
|
13
|
+
export function restart(reason) {
|
|
14
|
+
exit(reason, 1);
|
|
15
|
+
}
|
|
16
|
+
export function updateRequired(house) {
|
|
17
|
+
end(`This Kit is too old for House. Update it: ${installCommand(house)}`);
|
|
18
|
+
}
|
|
19
|
+
export async function signInAgain(rejected) {
|
|
20
|
+
await forgetRejected(rejected);
|
|
21
|
+
restart('sign in again');
|
|
8
22
|
}
|
package/dist/enrol-main.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
2
|
import { writeEnrolment } from './home.js';
|
|
3
3
|
const [house, environment] = process.argv.slice(2);
|
|
4
|
-
|
|
4
|
+
const relay = process.env.HOUSE_KIT_RELAY || undefined;
|
|
5
|
+
await writeEnrolment({
|
|
6
|
+
house: house,
|
|
7
|
+
...(relay === undefined ? {} : { relay }),
|
|
8
|
+
environment: environment,
|
|
9
|
+
credential: readFileSync(0, 'utf8').trim(),
|
|
10
|
+
});
|
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');
|