@agentshouse/kit 0.2.1-c3cf4b145dcda → 0.2.1-c3db1f18aed8f
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 -23
- package/dist/acp.js +7 -97
- package/dist/agents.js +27 -6
- package/dist/api.js +9 -5
- package/dist/bootstrap.json +4 -4
- package/dist/bridge.js +11 -37
- package/dist/chatgpt.js +26 -0
- package/dist/clis.js +86 -14
- package/dist/codex-main.js +58 -0
- package/dist/conversations.js +56 -55
- package/dist/copies.js +145 -110
- package/dist/end.js +18 -4
- package/dist/enrol-main.js +7 -1
- package/dist/events.js +10 -76
- package/dist/files.js +7 -1
- package/dist/git.js +11 -8
- package/dist/home.js +78 -6
- package/dist/house-main.js +183 -56
- package/dist/instructions.js +9 -32
- package/dist/kit-main.js +53 -8
- package/dist/login.js +93 -107
- package/dist/logout.js +14 -14
- package/dist/parts.js +34 -16
- package/dist/placement.js +48 -0
- package/dist/relay.js +12 -2
- package/dist/resident.js +35 -24
- package/dist/scope.js +203 -0
- package/dist/service-main.js +9 -0
- package/dist/service.js +33 -0
- package/dist/sign-in.js +1 -1
- package/dist/skills.js +80 -12
- package/dist/stream.js +9 -4
- package/dist/transcription.js +3 -3
- package/dist/update.js +28 -6
- package/dist/wire.js +6 -0
- package/dist/work.js +348 -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,25 +31,28 @@ them out; running it again without the flag brings them back.
|
|
|
33
31
|
|
|
34
32
|
## Commands
|
|
35
33
|
|
|
36
|
-
`kit login` opens a link you confirm in
|
|
37
|
-
|
|
38
|
-
set
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
`
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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.
|
|
51
52
|
|
|
52
53
|
House Kit turns each audio file of your message to an Agent into text on this
|
|
53
54
|
computer before the Agent reads it. While transcription is on, the speech
|
|
54
|
-
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.
|
|
55
56
|
|
|
56
57
|
## License
|
|
57
58
|
|
package/dist/acp.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { ndJsonStream, PROTOCOL_VERSION, } from '@agentclientprotocol/sdk';
|
|
2
|
-
import {
|
|
3
|
-
import { readdirSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { spawn } from 'node:child_process';
|
|
4
3
|
import { Readable, Writable } from 'node:stream';
|
|
5
4
|
import { CLIS, KIT_VERSION, adapterCommand, withoutProxy } from './clis.js';
|
|
6
|
-
|
|
5
|
+
import { killTree } from './scope.js';
|
|
6
|
+
export async function startAdapter(kind, cli, cwd, app, events = () => undefined, added = {}, signal, scope = null) {
|
|
7
7
|
const adapter = CLIS[kind].adapter;
|
|
8
|
-
const
|
|
8
|
+
const started = [adapter === null ? cli : adapterCommand(kind), CLIS[kind].args];
|
|
9
|
+
const [command, args] = scope?.command(...started) ?? started;
|
|
10
|
+
const child = spawn(command, args, {
|
|
9
11
|
cwd,
|
|
10
12
|
env: { ...withoutProxy(), ...(adapter === null ? {} : { ...adapter.env, [adapter.executable]: cli }), ...added },
|
|
11
13
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
@@ -51,6 +53,7 @@ export async function startAdapter(kind, cli, cwd, app, events = () => undefined
|
|
|
51
53
|
},
|
|
52
54
|
clientInfo: { name: '@agentshouse/kit', version: KIT_VERSION },
|
|
53
55
|
});
|
|
56
|
+
scope?.entered(child.pid);
|
|
54
57
|
return { child, connection, initialized, exited };
|
|
55
58
|
}
|
|
56
59
|
catch (error) {
|
|
@@ -58,96 +61,3 @@ export async function startAdapter(kind, cli, cwd, app, events = () => undefined
|
|
|
58
61
|
throw error;
|
|
59
62
|
}
|
|
60
63
|
}
|
|
61
|
-
const LISTING_BYTES = 1 << 28;
|
|
62
|
-
function listed(options) {
|
|
63
|
-
return execFileSync('ps', [options, '-o', 'pid=,ppid=,command='], { encoding: 'utf8', maxBuffer: LISTING_BYTES })
|
|
64
|
-
.split('\n')
|
|
65
|
-
.flatMap((line) => {
|
|
66
|
-
const fields = /^\s*(\d+)\s+(\d+)\s?(.*)$/.exec(line);
|
|
67
|
-
return fields === null ? [] : [[Number(fields[1]), Number(fields[2]), fields[3]]];
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
function parents() {
|
|
71
|
-
const children = new Map();
|
|
72
|
-
const adopt = (pid, parent) => children.set(parent, [...(children.get(parent) ?? []), pid]);
|
|
73
|
-
if (process.platform === 'darwin') {
|
|
74
|
-
for (const [pid, parent] of listed('-Aww'))
|
|
75
|
-
adopt(pid, parent);
|
|
76
|
-
return children;
|
|
77
|
-
}
|
|
78
|
-
for (const entry of readdirSync('/proc')) {
|
|
79
|
-
if (!/^\d+$/.test(entry))
|
|
80
|
-
continue;
|
|
81
|
-
try {
|
|
82
|
-
const stat = readFileSync(`/proc/${entry}/stat`, 'utf8');
|
|
83
|
-
adopt(Number(entry), Number(stat.slice(stat.lastIndexOf(')') + 2).split(' ')[1]));
|
|
84
|
-
}
|
|
85
|
-
catch { }
|
|
86
|
-
}
|
|
87
|
-
return children;
|
|
88
|
-
}
|
|
89
|
-
function descendants(roots) {
|
|
90
|
-
const children = parents();
|
|
91
|
-
const tree = [];
|
|
92
|
-
const pending = roots.flatMap((root) => children.get(root) ?? []);
|
|
93
|
-
while (pending.length > 0) {
|
|
94
|
-
const pid = pending.pop();
|
|
95
|
-
tree.push(pid);
|
|
96
|
-
pending.push(...(children.get(pid) ?? []));
|
|
97
|
-
}
|
|
98
|
-
return tree;
|
|
99
|
-
}
|
|
100
|
-
function killAll(pids) {
|
|
101
|
-
for (const pid of pids) {
|
|
102
|
-
for (const target of [-pid, pid]) {
|
|
103
|
-
try {
|
|
104
|
-
process.kill(target, 'SIGKILL');
|
|
105
|
-
}
|
|
106
|
-
catch { }
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
function marked(marker) {
|
|
111
|
-
if (process.platform === 'darwin') {
|
|
112
|
-
return listed('-AEww')
|
|
113
|
-
.filter(([, , command]) => ` ${command} `.includes(` ${marker} `))
|
|
114
|
-
.map(([pid]) => pid);
|
|
115
|
-
}
|
|
116
|
-
return readdirSync('/proc')
|
|
117
|
-
.filter((entry) => {
|
|
118
|
-
try {
|
|
119
|
-
return /^\d+$/.test(entry) && readFileSync(`/proc/${entry}/environ`, 'utf8').split('\0').includes(marker);
|
|
120
|
-
}
|
|
121
|
-
catch {
|
|
122
|
-
return false;
|
|
123
|
-
}
|
|
124
|
-
})
|
|
125
|
-
.map(Number);
|
|
126
|
-
}
|
|
127
|
-
function commandLine(pid) {
|
|
128
|
-
try {
|
|
129
|
-
return readFileSync(`/proc/${pid}/cmdline`, 'utf8').split('\0').join(' ').trim();
|
|
130
|
-
}
|
|
131
|
-
catch {
|
|
132
|
-
return '';
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
export function processes(marker) {
|
|
136
|
-
const pids = marked(marker);
|
|
137
|
-
const tree = [...pids, ...descendants(pids)];
|
|
138
|
-
const commands = process.platform === 'darwin'
|
|
139
|
-
? new Map(listed('-Aww').map(([pid, , command]) => [pid, command]))
|
|
140
|
-
: new Map(tree.map((pid) => [pid, commandLine(pid)]));
|
|
141
|
-
return new Set(tree.flatMap((pid) => (commands.get(pid) ? [`${pid} ${commands.get(pid)}`] : [])));
|
|
142
|
-
}
|
|
143
|
-
export function killTree(child) {
|
|
144
|
-
killAll([child.pid, ...descendants([child.pid])]);
|
|
145
|
-
}
|
|
146
|
-
export function killMarked(marker) {
|
|
147
|
-
const pids = marked(marker);
|
|
148
|
-
killAll([...pids, ...descendants(pids)]);
|
|
149
|
-
}
|
|
150
|
-
export function killDescendants() {
|
|
151
|
-
const pids = marked(`HOUSE_KIT_RESIDENT=${process.pid}`);
|
|
152
|
-
killAll([...pids, ...descendants([process.pid, ...pids])]);
|
|
153
|
-
}
|
package/dist/agents.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { client } from '@agentclientprotocol/sdk';
|
|
2
2
|
import { readFile, realpath } from 'node:fs/promises';
|
|
3
|
-
import {
|
|
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';
|
|
7
|
+
import { killTree } from './scope.js';
|
|
6
8
|
import { holdTranscription, transcriptionReport } from './transcription.js';
|
|
9
|
+
import { KIT_WIRE } from './wire.js';
|
|
7
10
|
const SIGNED_OUT = { signed_in: false, models: [], modes: [] };
|
|
8
11
|
function select(options, category) {
|
|
9
12
|
const option = options.find((candidate) => candidate.category === category);
|
|
@@ -129,8 +132,14 @@ export class Agents {
|
|
|
129
132
|
reads = new Map();
|
|
130
133
|
sending = Promise.resolve();
|
|
131
134
|
sent = null;
|
|
132
|
-
|
|
135
|
+
refreshing = 0;
|
|
136
|
+
changed;
|
|
137
|
+
constructor(house, changed = () => undefined) {
|
|
133
138
|
this.house = house;
|
|
139
|
+
this.changed = changed;
|
|
140
|
+
}
|
|
141
|
+
idle() {
|
|
142
|
+
return this.refreshing === 0;
|
|
134
143
|
}
|
|
135
144
|
read() {
|
|
136
145
|
return this.reading.then(() => undefined, () => undefined);
|
|
@@ -139,19 +148,28 @@ export class Agents {
|
|
|
139
148
|
return this.desired.routes.find((route) => route.agent_id === agentId);
|
|
140
149
|
}
|
|
141
150
|
refresh() {
|
|
151
|
+
this.refreshing++;
|
|
152
|
+
this.changed();
|
|
142
153
|
const reading = this.read().then(async () => {
|
|
143
154
|
this.desired = await this.house.deliver('/kit/agents/desired', {});
|
|
144
155
|
return this.desired;
|
|
145
156
|
});
|
|
146
157
|
this.reading = reading;
|
|
147
|
-
|
|
158
|
+
reading
|
|
159
|
+
.then(({ agents, transcribe }) => Promise.all([
|
|
148
160
|
holdTranscription(transcribe)
|
|
149
161
|
.then((changed) => (changed ? this.report() : undefined))
|
|
150
|
-
.catch(logged)
|
|
162
|
+
.catch(logged),
|
|
151
163
|
Promise.all(agents.map((kind) => this.load(kind)))
|
|
152
164
|
.then(() => this.report())
|
|
153
|
-
.catch(logged)
|
|
165
|
+
.catch(logged),
|
|
166
|
+
]))
|
|
167
|
+
.catch(() => undefined)
|
|
168
|
+
.finally(() => {
|
|
169
|
+
this.refreshing--;
|
|
170
|
+
this.changed();
|
|
154
171
|
});
|
|
172
|
+
return reading.then(() => undefined);
|
|
155
173
|
}
|
|
156
174
|
cli(kind) {
|
|
157
175
|
return this.queue(kind, async () => {
|
|
@@ -256,9 +274,10 @@ export class Agents {
|
|
|
256
274
|
}
|
|
257
275
|
async load(kind) {
|
|
258
276
|
const known = this.readings.get(kind);
|
|
259
|
-
if (known !== undefined && known.failure === null)
|
|
277
|
+
if (known !== undefined && known.failure === null && known.minimum === undefined)
|
|
260
278
|
return;
|
|
261
279
|
await this.examine(kind, SIGNED_OUT, offer);
|
|
280
|
+
await this.report();
|
|
262
281
|
}
|
|
263
282
|
async send() {
|
|
264
283
|
const agents = this.desired.agents.flatMap((kind) => {
|
|
@@ -269,6 +288,8 @@ export class Agents {
|
|
|
269
288
|
const body = {
|
|
270
289
|
os: await operatingSystem(),
|
|
271
290
|
kit_version: KIT_VERSION,
|
|
291
|
+
wire: KIT_WIRE,
|
|
292
|
+
updates_itself: await updatesItself(),
|
|
272
293
|
agent_base: agentBase(),
|
|
273
294
|
agents,
|
|
274
295
|
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;
|
|
@@ -19,7 +20,7 @@ export function retryDelay(attempt) {
|
|
|
19
20
|
// Full jitter, doubling from one second to a 30-second cap, spreads the Kits one outage dropped and retries within half a minute of House's return.
|
|
20
21
|
return Math.random() * Math.min(30_000, 1000 * 2 ** attempt);
|
|
21
22
|
}
|
|
22
|
-
export async function retrying(sent, signal) {
|
|
23
|
+
export async function retrying(sent, signal, pause = retryDelay) {
|
|
23
24
|
for (let attempt = 0;; attempt++) {
|
|
24
25
|
try {
|
|
25
26
|
return await sent();
|
|
@@ -28,8 +29,8 @@ export async function retrying(sent, signal) {
|
|
|
28
29
|
if (!(error instanceof HouseRefusal) || retryable(error.text) !== true)
|
|
29
30
|
throw error;
|
|
30
31
|
}
|
|
31
|
-
// A request House refused as retryable is sent again
|
|
32
|
-
await delay(
|
|
32
|
+
// A request House refused as retryable is sent again after the caller's pause, the jittered curve unless it names its own.
|
|
33
|
+
await delay(pause(attempt), undefined, { signal });
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
export async function post(house, path, body, credential, signal) {
|
|
@@ -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-c3db1f18aed8f",
|
|
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-c3db1f18aed8f/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-c3db1f18aed8f/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-c3db1f18aed8f/connect-windows.ps1"
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
}
|
package/dist/bridge.js
CHANGED
|
@@ -11,11 +11,10 @@ import { loginPath } from './clis.js';
|
|
|
11
11
|
import { changedPaths, } from './copies.js';
|
|
12
12
|
import { kitHome, readEnrolment } from './home.js';
|
|
13
13
|
import { callHouse, mcpBody, rpc, UNREACHABLE } from './mcp.js';
|
|
14
|
-
import { operationId
|
|
14
|
+
import { operationId } from './operation.js';
|
|
15
15
|
import { refusalOf, retryable } from './refusals.js';
|
|
16
16
|
import { relayed } from './relay.js';
|
|
17
17
|
const MCP_REQUEST_BYTES = 4 * 1024 * 1024;
|
|
18
|
-
const ATTACHMENTS = '/kit/attachments/upload';
|
|
19
18
|
export async function received(request) {
|
|
20
19
|
let text = '';
|
|
21
20
|
request.setEncoding('utf8');
|
|
@@ -68,11 +67,6 @@ function resendAfter(forwarded, attempt) {
|
|
|
68
67
|
const seconds = pendingSeconds(forwarded);
|
|
69
68
|
return seconds === null ? null : seconds * 1000;
|
|
70
69
|
}
|
|
71
|
-
function versioned(conversationId, text) {
|
|
72
|
-
const file = JSON.parse(text);
|
|
73
|
-
const identity = JSON.stringify([conversationId, file.room_ref ?? null, file.name, file.sha256]);
|
|
74
|
-
return JSON.stringify({ ...file, version: uuidOf(createHash('sha256').update(identity).digest(), 8) });
|
|
75
|
-
}
|
|
76
70
|
function editAnswer(forwarded) {
|
|
77
71
|
const answer = answered(forwarded);
|
|
78
72
|
if ('refused' in answer)
|
|
@@ -103,7 +97,7 @@ export async function openBridge(house, copies, conversationId, signal) {
|
|
|
103
97
|
const after = resendAfter(forwarded, attempt);
|
|
104
98
|
if (after === null)
|
|
105
99
|
return forwarded;
|
|
106
|
-
// A
|
|
100
|
+
// A Tool call House did not settle is sent again on the jittered curve, or after the wait House names for a pending one.
|
|
107
101
|
await delay(after, undefined, { signal: closed.signal });
|
|
108
102
|
}
|
|
109
103
|
};
|
|
@@ -141,32 +135,9 @@ export async function openBridge(house, copies, conversationId, signal) {
|
|
|
141
135
|
const held = JSON.parse(text).transfer;
|
|
142
136
|
return { url: held.url, operation: held.operation, bytes: bytes.length, sha256 };
|
|
143
137
|
};
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
.post('/kit/tools/mutations', {}, closed.signal)
|
|
148
|
-
.then(({ tools }) => new Set(tools.filter((listed) => listed.writes).map((listed) => listed.name)));
|
|
149
|
-
try {
|
|
150
|
-
return (await mutations).has(tool);
|
|
151
|
-
}
|
|
152
|
-
catch (error) {
|
|
153
|
-
mutations = null;
|
|
154
|
-
throw error;
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
const forward = async (path, text) => {
|
|
158
|
-
if (path === '/') {
|
|
159
|
-
const message = JSON.parse(text);
|
|
160
|
-
const tool = message.method === 'tools/call' ? String(message.params.name) : null;
|
|
161
|
-
return send(message, tool !== null && (await writes(tool)) ? operationId() : null);
|
|
162
|
-
}
|
|
163
|
-
const answer = await fetch(relayed(new URL(path, origin)), {
|
|
164
|
-
method: 'POST',
|
|
165
|
-
headers: { 'content-type': 'application/json', authorization: `Bearer ${credential}` },
|
|
166
|
-
body: versioned(conversationId, text),
|
|
167
|
-
signal: closed.signal,
|
|
168
|
-
});
|
|
169
|
-
return { status: answer.status, text: await answer.text() };
|
|
138
|
+
const forward = (text) => {
|
|
139
|
+
const message = JSON.parse(text);
|
|
140
|
+
return send(message, message.method === 'tools/call' ? operationId() : null);
|
|
170
141
|
};
|
|
171
142
|
const caller = {
|
|
172
143
|
key: `conversation:${conversationId}`,
|
|
@@ -188,11 +159,13 @@ export async function openBridge(house, copies, conversationId, signal) {
|
|
|
188
159
|
const { cwd, commit } = JSON.parse(text);
|
|
189
160
|
return { status: 200, text: JSON.stringify(await copies.push(cwd, commit, caller)) };
|
|
190
161
|
}
|
|
162
|
+
if (path === '/git/fetch')
|
|
163
|
+
return { status: 200, text: JSON.stringify(await copies.fetch()) };
|
|
191
164
|
if (path === '/git/observed') {
|
|
192
165
|
await copies.observed(JSON.parse(text));
|
|
193
166
|
return { status: 200, text: '{}' };
|
|
194
167
|
}
|
|
195
|
-
return path === '/'
|
|
168
|
+
return path === '/' ? forward(text) : { status: 404, text: '' };
|
|
196
169
|
};
|
|
197
170
|
const sockets = join(kitHome(), 'bridges');
|
|
198
171
|
await mkdir(sockets, { recursive: true, mode: 0o700 });
|
|
@@ -212,7 +185,8 @@ export async function openBridge(house, copies, conversationId, signal) {
|
|
|
212
185
|
response.writeHead(error.status, { 'content-type': 'application/json' }).end(error.text);
|
|
213
186
|
return;
|
|
214
187
|
}
|
|
215
|
-
|
|
188
|
+
const verb = request.url === '/git/push' || request.url === '/git/fetch';
|
|
189
|
+
response.writeHead(502).end(verb && error instanceof Error ? error.message : UNREACHABLE);
|
|
216
190
|
}
|
|
217
191
|
});
|
|
218
192
|
bridge.listen(socketPath);
|
|
@@ -239,7 +213,7 @@ export async function openBridge(house, copies, conversationId, signal) {
|
|
|
239
213
|
GIT_CONFIG_VALUE_0: app,
|
|
240
214
|
},
|
|
241
215
|
tool: async (name, args) => {
|
|
242
|
-
const forwarded = await forward(
|
|
216
|
+
const forwarded = await forward(JSON.stringify(call(name, args)));
|
|
243
217
|
if (forwarded.status !== 200)
|
|
244
218
|
throw new Error(`House refused ${name} with ${forwarded.status}: ${forwarded.text}`);
|
|
245
219
|
const answer = JSON.parse(forwarded.text);
|
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,24 +1,83 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { randomUUID } from 'node:crypto';
|
|
3
|
+
import { constants, readFileSync } from 'node:fs';
|
|
4
|
+
import { access, mkdir, readFile, rename, writeFile } from 'node:fs/promises';
|
|
4
5
|
import { homedir, userInfo } from 'node:os';
|
|
5
|
-
import { 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;
|
|
9
|
+
function houseRule(houses) {
|
|
10
|
+
return `prefix_rule(pattern = ["house"], decision = "allow")\nhost_executable(name = "house", paths = ${JSON.stringify(houses)})\n`;
|
|
11
|
+
}
|
|
12
|
+
const RAW_SUBTYPES = [
|
|
13
|
+
'background_tasks_changed',
|
|
14
|
+
'task_started',
|
|
15
|
+
'task_updated',
|
|
16
|
+
'task_notification',
|
|
17
|
+
'session_state_changed',
|
|
18
|
+
'hook_started',
|
|
19
|
+
'hook_response',
|
|
20
|
+
];
|
|
21
|
+
async function executable(path) {
|
|
22
|
+
try {
|
|
23
|
+
await access(path, constants.X_OK);
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
async function listedHouses(file) {
|
|
31
|
+
let text;
|
|
32
|
+
try {
|
|
33
|
+
text = await readFile(file, 'utf8');
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
if (error.code === 'ENOENT')
|
|
37
|
+
return [];
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
const listed = JSON.parse(HOUSE_EXECUTABLES.exec(text)?.[1] ?? '[]');
|
|
42
|
+
return Array.isArray(listed) ? listed.filter((house) => typeof house === 'string') : [];
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export async function allowHouseInCodex(path) {
|
|
49
|
+
const candidates = [...new Set(path.split(delimiter).filter((directory) => isAbsolute(directory)))].map((directory) => join(directory, 'house'));
|
|
8
50
|
const rules = join(process.env.CODEX_HOME || join(homedir(), '.codex'), 'rules');
|
|
51
|
+
const file = join(rules, 'house.rules');
|
|
52
|
+
const houses = [];
|
|
53
|
+
for (const house of [...(await listedHouses(file)), ...candidates]) {
|
|
54
|
+
if (!houses.includes(house) && (await executable(house)))
|
|
55
|
+
houses.push(house);
|
|
56
|
+
}
|
|
9
57
|
await mkdir(rules, { recursive: true });
|
|
10
|
-
|
|
58
|
+
const temporary = `${file}.${randomUUID()}`;
|
|
59
|
+
await writeFile(temporary, houseRule(houses));
|
|
60
|
+
await rename(temporary, file);
|
|
11
61
|
}
|
|
12
62
|
async function nothing() { }
|
|
63
|
+
function bridgeInClaudeSandbox(bridge) {
|
|
64
|
+
return process.platform === 'darwin' ? { allowUnixSockets: [bridge] } : { allowAllUnixSockets: true };
|
|
65
|
+
}
|
|
13
66
|
export const CLIS = {
|
|
14
67
|
'codex-acp': {
|
|
15
68
|
bin: 'codex',
|
|
16
69
|
minimum: '0.159.1',
|
|
17
70
|
install: 'curl -fsSL https://chatgpt.com/codex/install.sh | sh',
|
|
18
|
-
adapter: {
|
|
71
|
+
adapter: {
|
|
72
|
+
package: '@agentclientprotocol/codex-acp',
|
|
73
|
+
bin: 'codex-acp',
|
|
74
|
+
executable: 'CODEX_PATH',
|
|
75
|
+
env: { CODEX_CONFIG: JSON.stringify({ features: { shell_zsh_fork: true } }) },
|
|
76
|
+
},
|
|
19
77
|
args: [],
|
|
20
78
|
fullAccess: 'agent-full-access',
|
|
21
|
-
sessionMeta: {},
|
|
79
|
+
sessionMeta: () => ({}),
|
|
80
|
+
renames: true,
|
|
22
81
|
allowHouse: allowHouseInCodex,
|
|
23
82
|
signedIn: { command: ['login', 'status'] },
|
|
24
83
|
login: { args: ['login', '--device-auth'], code: 'show' },
|
|
@@ -36,12 +95,18 @@ export const CLIS = {
|
|
|
36
95
|
},
|
|
37
96
|
args: [],
|
|
38
97
|
fullAccess: 'bypassPermissions',
|
|
39
|
-
sessionMeta: {
|
|
98
|
+
sessionMeta: (bridge, title) => ({
|
|
40
99
|
claudeCode: {
|
|
41
|
-
options: {
|
|
42
|
-
|
|
100
|
+
options: {
|
|
101
|
+
allowedTools: ['Bash(house:*)'],
|
|
102
|
+
includeHookEvents: true,
|
|
103
|
+
title,
|
|
104
|
+
settings: { sandbox: { network: bridgeInClaudeSandbox(bridge) } },
|
|
105
|
+
},
|
|
106
|
+
emitRawSDKMessages: RAW_SUBTYPES.map((subtype) => ({ type: 'system', subtype })),
|
|
43
107
|
},
|
|
44
|
-
},
|
|
108
|
+
}),
|
|
109
|
+
renames: false,
|
|
45
110
|
allowHouse: nothing,
|
|
46
111
|
signedIn: { command: ['auth', 'status'] },
|
|
47
112
|
login: { args: ['auth', 'login', '--claudeai'], code: 'collect', rejected: 'Invalid code' },
|
|
@@ -52,9 +117,10 @@ export const CLIS = {
|
|
|
52
117
|
minimum: '1.0.46',
|
|
53
118
|
install: 'curl -fsSL https://x.ai/cli/install.sh | bash',
|
|
54
119
|
adapter: null,
|
|
55
|
-
args: ['agent', '--always-approve', '--no-leader', 'stdio'],
|
|
120
|
+
args: ['--sandbox', 'off', 'agent', '--always-approve', '--no-leader', 'stdio'],
|
|
56
121
|
fullAccess: null,
|
|
57
|
-
sessionMeta: {},
|
|
122
|
+
sessionMeta: () => ({}),
|
|
123
|
+
renames: false,
|
|
58
124
|
allowHouse: nothing,
|
|
59
125
|
signedIn: { initializeMeta: 'defaultAuthMethodId' },
|
|
60
126
|
login: { args: ['login', '--device-auth'], code: 'show' },
|
|
@@ -134,7 +200,7 @@ export async function installAdapter(kind, signal) {
|
|
|
134
200
|
const release = KIT_PACKAGE.peerDependencies[adapter.package];
|
|
135
201
|
if ((await installedAdapter(kind)) === release)
|
|
136
202
|
return null;
|
|
137
|
-
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);
|
|
138
204
|
return ran.status === 0 ? null : failureOf(ran, 'npm');
|
|
139
205
|
}
|
|
140
206
|
export async function installCli(kind, signal) {
|
|
@@ -159,6 +225,12 @@ export async function loginPath() {
|
|
|
159
225
|
const ran = await inLoginShell(`printf "${marker}%s\\n" "$PATH"`);
|
|
160
226
|
return ran.stdout.split('\n').findLast((line) => line.startsWith(marker)).slice(marker.length);
|
|
161
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
|
+
}
|
|
162
234
|
export async function versionOf(path, signal) {
|
|
163
235
|
return VERSION.exec((await run(path, ['--version'], READ_MS, false, signal)).stdout)?.[0] ?? null;
|
|
164
236
|
}
|