@agentshouse/kit 0.2.1-c7f53ff9eaf98 → 0.2.1-c845e172df1af
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 +17 -17
- package/dist/acp.js +36 -16
- package/dist/agents.js +36 -16
- package/dist/api.js +5 -5
- package/dist/bootstrap.json +4 -4
- package/dist/bridge.js +1 -1
- package/dist/calls.js +63 -0
- package/dist/clis.js +1 -1
- package/dist/{stream.js → connection.js} +32 -30
- package/dist/conversations.js +242 -116
- package/dist/copies.js +53 -51
- package/dist/end.js +6 -2
- package/dist/events.js +2 -2
- package/dist/files.js +116 -27
- package/dist/git.js +1 -1
- package/dist/house-cli.js +95 -59
- package/dist/instructions.js +2 -2
- package/dist/kit-cli.js +2 -2
- package/dist/mcp.js +4 -2
- package/dist/placement.js +11 -2
- package/dist/resident.js +32 -30
- package/dist/scope.js +3 -0
- package/dist/service.js +23 -1
- package/dist/sign-in.js +19 -37
- package/dist/skills.js +3 -3
- package/dist/translate.js +2 -8
- package/dist/update.js +42 -45
- package/dist/wire.js +19 -3
- package/package.json +3 -3
package/dist/skills.js
CHANGED
|
@@ -5,7 +5,7 @@ import { homedir } from 'node:os';
|
|
|
5
5
|
import { join, relative } from 'node:path';
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
7
7
|
import { parse } from 'yaml';
|
|
8
|
-
import {
|
|
8
|
+
import { KIT_RELEASE } from './clis.js';
|
|
9
9
|
import { kitHome, readConfiguration, readHome, writeHome } from './home.js';
|
|
10
10
|
import { refusalOf } from './refusals.js';
|
|
11
11
|
const HOW_WE_WORK = '/rooms/private/how-we-work.md';
|
|
@@ -60,7 +60,7 @@ async function install() {
|
|
|
60
60
|
if (claude !== skills)
|
|
61
61
|
await symlink(relative(claude, join(skills, name)), join(claudeDirectory(), name));
|
|
62
62
|
}
|
|
63
|
-
await writeHome(RECORD, { version:
|
|
63
|
+
await writeHome(RECORD, { version: KIT_RELEASE, names });
|
|
64
64
|
}
|
|
65
65
|
export async function placeSkillSet() {
|
|
66
66
|
try {
|
|
@@ -73,7 +73,7 @@ export async function placeSkillSet() {
|
|
|
73
73
|
async function replaceSkillSet() {
|
|
74
74
|
const accepted = (await readConfiguration()).skills;
|
|
75
75
|
const installed = await readHome(RECORD);
|
|
76
|
-
if (accepted && installed?.version ===
|
|
76
|
+
if (accepted && installed?.version === KIT_RELEASE)
|
|
77
77
|
return;
|
|
78
78
|
for (const name of installed?.names ?? []) {
|
|
79
79
|
await rm(join(claudeDirectory(), name), { recursive: true, force: true });
|
package/dist/translate.js
CHANGED
|
@@ -3,14 +3,8 @@ function same(left, right) {
|
|
|
3
3
|
return JSON.stringify(left) === JSON.stringify(right);
|
|
4
4
|
}
|
|
5
5
|
function applied(document, changes) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const result = apply(current, change);
|
|
9
|
-
if (result.outcome !== 'applied')
|
|
10
|
-
return null;
|
|
11
|
-
current = result.document;
|
|
12
|
-
}
|
|
13
|
-
return serialize(current);
|
|
6
|
+
const result = apply(document, changes);
|
|
7
|
+
return result.outcome === 'applied' ? serialize(result.document) : null;
|
|
14
8
|
}
|
|
15
9
|
function components(path, before, after, text) {
|
|
16
10
|
const edits = [];
|
package/dist/update.js
CHANGED
|
@@ -6,9 +6,6 @@ import { join } from 'node:path';
|
|
|
6
6
|
import { run } from './clis.js';
|
|
7
7
|
import { kitHome, workspaceRoot } from './home.js';
|
|
8
8
|
import { service, throughSudo } from './placement.js';
|
|
9
|
-
function logged(error) {
|
|
10
|
-
process.stderr.write(`kit: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
11
|
-
}
|
|
12
9
|
function directory() {
|
|
13
10
|
return join(kitHome(), 'update');
|
|
14
11
|
}
|
|
@@ -18,8 +15,8 @@ function pending() {
|
|
|
18
15
|
function outcome() {
|
|
19
16
|
return join(directory(), 'outcome');
|
|
20
17
|
}
|
|
21
|
-
function unit(
|
|
22
|
-
return `house-kit-update-${
|
|
18
|
+
function unit(callId) {
|
|
19
|
+
return `house-kit-update-${callId}`;
|
|
23
20
|
}
|
|
24
21
|
function manager() {
|
|
25
22
|
return service() === 'user' ? ['--user'] : [];
|
|
@@ -36,7 +33,7 @@ function placement() {
|
|
|
36
33
|
function record() {
|
|
37
34
|
return `outcome=$1; shift; bash "$0" "$@"; printf %s "$?" > "$outcome"; ${[...elevated(), 'systemctl', ...manager(), 'start', 'house-kit.service'].join(' ')}`;
|
|
38
35
|
}
|
|
39
|
-
async function
|
|
36
|
+
async function pendingCall() {
|
|
40
37
|
try {
|
|
41
38
|
return JSON.parse(await readFile(pending(), 'utf8')).input_id;
|
|
42
39
|
}
|
|
@@ -50,20 +47,26 @@ async function recorded() {
|
|
|
50
47
|
return null;
|
|
51
48
|
return status.trim() === '0' ? {} : { refused: `the Kit bootstrap exited with ${status.trim()}` };
|
|
52
49
|
}
|
|
53
|
-
async function
|
|
50
|
+
async function forget(callId) {
|
|
51
|
+
if ((await pendingCall()) !== callId)
|
|
52
|
+
return;
|
|
53
|
+
await rm(pending(), { force: true });
|
|
54
|
+
await rm(outcome(), { force: true });
|
|
55
|
+
}
|
|
56
|
+
async function finished(callId) {
|
|
54
57
|
for (;;) {
|
|
55
|
-
const
|
|
56
|
-
if (
|
|
57
|
-
return
|
|
58
|
+
const result = await recorded();
|
|
59
|
+
if (result !== null)
|
|
60
|
+
return result;
|
|
58
61
|
// systemctl answers at once, so ten seconds only bounds a stuck service manager.
|
|
59
|
-
if ((await run('systemctl', [...manager(), 'is-active', '--quiet', unit(
|
|
62
|
+
if ((await run('systemctl', [...manager(), 'is-active', '--quiet', unit(callId)], 10_000)).status !== 0) {
|
|
60
63
|
return (await recorded()) ?? { refused: 'the Kit bootstrap did not finish' };
|
|
61
64
|
}
|
|
62
65
|
// The bootstrap runs for minutes, so checking each second sees its outcome within a second at little cost.
|
|
63
66
|
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
64
67
|
}
|
|
65
68
|
}
|
|
66
|
-
function rerun(script,
|
|
69
|
+
function rerun(script, callId, flags) {
|
|
67
70
|
return new Promise((resolve) => {
|
|
68
71
|
const [command, ...args] = [
|
|
69
72
|
...elevated(),
|
|
@@ -73,7 +76,7 @@ function rerun(script, inputId, flags) {
|
|
|
73
76
|
'--wait',
|
|
74
77
|
'--collect',
|
|
75
78
|
'--quiet',
|
|
76
|
-
`--unit=${unit(
|
|
79
|
+
`--unit=${unit(callId)}`,
|
|
77
80
|
`--setenv=HOME=${homedir()}`,
|
|
78
81
|
`--setenv=HOUSE_KIT_HOME=${kitHome()}`,
|
|
79
82
|
'/bin/sh',
|
|
@@ -85,57 +88,51 @@ function rerun(script, inputId, flags) {
|
|
|
85
88
|
...flags,
|
|
86
89
|
];
|
|
87
90
|
const child = spawn(command, args, { stdio: ['ignore', 'ignore', 'inherit'] });
|
|
88
|
-
child.on('error', () => resolve({ refused: 'no service manager runs this Kit' }));
|
|
91
|
+
child.on('error', () => resolve({ refused: 'no service manager runs this Kit process' }));
|
|
89
92
|
child.on('close', () => resolve(null));
|
|
90
93
|
});
|
|
91
94
|
}
|
|
92
|
-
export class
|
|
93
|
-
|
|
94
|
-
held = new Set();
|
|
95
|
+
export class KitUpdate {
|
|
96
|
+
calls;
|
|
95
97
|
queue = Promise.resolve();
|
|
96
|
-
constructor(
|
|
97
|
-
this.
|
|
98
|
+
constructor(calls) {
|
|
99
|
+
this.calls = calls;
|
|
98
100
|
}
|
|
99
101
|
async resumed() {
|
|
100
|
-
const
|
|
101
|
-
if (
|
|
102
|
+
const callId = await pendingCall();
|
|
103
|
+
if (callId === null)
|
|
102
104
|
return;
|
|
103
|
-
await this.
|
|
105
|
+
await this.enqueue(callId, () => finished(callId));
|
|
104
106
|
}
|
|
105
|
-
start(
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
107
|
+
start(call) {
|
|
108
|
+
void this.enqueue(call.input_id, () => this.carry(call));
|
|
109
|
+
}
|
|
110
|
+
enqueue(callId, work) {
|
|
111
|
+
const before = this.queue;
|
|
112
|
+
const carried = this.calls.carry(callId, async () => {
|
|
113
|
+
await before;
|
|
114
|
+
return { result: await work(), returned: () => forget(callId) };
|
|
115
|
+
});
|
|
116
|
+
this.queue = before.then(() => carried);
|
|
117
|
+
return carried;
|
|
114
118
|
}
|
|
115
|
-
async carry(
|
|
116
|
-
if ((await
|
|
117
|
-
return finished(
|
|
118
|
-
const answer = await fetch(
|
|
119
|
+
async carry(call) {
|
|
120
|
+
if ((await pendingCall()) === call.input_id)
|
|
121
|
+
return finished(call.input_id);
|
|
122
|
+
const answer = await fetch(call.bootstrap);
|
|
119
123
|
if (!answer.ok)
|
|
120
124
|
return { refused: `the Kit bootstrap could not be downloaded: ${answer.status}` };
|
|
121
125
|
const script = Buffer.from(await answer.arrayBuffer());
|
|
122
|
-
if (createHash('sha256').update(script).digest('hex') !==
|
|
126
|
+
if (createHash('sha256').update(script).digest('hex') !== call.sha256) {
|
|
123
127
|
return { refused: 'the Kit bootstrap does not match its sha256' };
|
|
124
128
|
}
|
|
125
129
|
await mkdir(directory(), { recursive: true, mode: 0o700 });
|
|
126
130
|
const path = join(directory(), 'connect-linux.sh');
|
|
127
131
|
await writeFile(path, script, { mode: 0o700 });
|
|
128
132
|
await rm(outcome(), { force: true });
|
|
129
|
-
await writeFile(pending(), `${JSON.stringify({ input_id:
|
|
130
|
-
return (await rerun(path,
|
|
133
|
+
await writeFile(pending(), `${JSON.stringify({ input_id: call.input_id })}\n`, { mode: 0o600 });
|
|
134
|
+
return (await rerun(path, call.input_id, call.update_clis ? ['--update-clis'] : [])) ?? (await recorded()) ?? {
|
|
131
135
|
refused: 'the Kit bootstrap did not finish',
|
|
132
136
|
};
|
|
133
137
|
}
|
|
134
|
-
async acknowledge(inputId, ack) {
|
|
135
|
-
await this.house.deliver(`/kit/inputs/${inputId}/ack`, ack);
|
|
136
|
-
if ((await pendingInput()) !== inputId)
|
|
137
|
-
return;
|
|
138
|
-
await rm(pending(), { force: true });
|
|
139
|
-
await rm(outcome(), { force: true });
|
|
140
|
-
}
|
|
141
138
|
}
|
package/dist/wire.js
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
|
+
import { newerThanHouse, updateRequired } from './end.js';
|
|
2
|
+
import { machine } from './placement.js';
|
|
1
3
|
import { refusalOf } from './refusals.js';
|
|
2
|
-
export const KIT_WIRE =
|
|
4
|
+
export const KIT_WIRE = 3;
|
|
3
5
|
export const KIT_WIRE_HEADER = 'x-house-kit-wire';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
function newer(text) {
|
|
7
|
+
let body;
|
|
8
|
+
try {
|
|
9
|
+
body = JSON.parse(text);
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
return body?.error?.code === 'kit_newer_than_house' ? body.error : null;
|
|
15
|
+
}
|
|
16
|
+
export function endUnserved(text) {
|
|
17
|
+
if (refusalOf(text)?.code === 'kit_update_required')
|
|
18
|
+
updateRequired();
|
|
19
|
+
const refused = newer(text);
|
|
20
|
+
if (refused !== null)
|
|
21
|
+
newerThanHouse(refused.release, refused.commands[machine()]);
|
|
6
22
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentshouse/kit",
|
|
3
|
-
"version": "0.2.1-
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.2.1-c845e172df1af",
|
|
4
|
+
"description": "Kit connects an Environment to agents.house.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@agentclientprotocol/sdk": "1.7.0",
|
|
31
|
-
"@agentshouse/mdmodel": "0.1.0-
|
|
31
|
+
"@agentshouse/mdmodel": "0.1.0-cabd61587647f",
|
|
32
32
|
"yaml": "2.9.1"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|