@agentshouse/kit 0.2.1-ceeaf32286734 → 0.2.1-ceffdba88db37
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 +14 -15
- package/dist/acp.js +1 -1
- package/dist/afk.js +17 -0
- package/dist/agents.js +54 -25
- package/dist/api.js +11 -6
- package/dist/authority-main.js +2 -2
- package/dist/bridge.js +4 -4
- package/dist/building.js +7 -3
- package/dist/calls.js +1 -1
- package/dist/chunks.js +49 -0
- package/dist/clis.js +35 -57
- package/dist/connection.js +24 -20
- package/dist/content.js +63 -0
- package/dist/conversations.js +236 -115
- package/dist/copies.js +293 -148
- package/dist/end.js +2 -9
- package/dist/events.js +729 -218
- package/dist/files.js +2 -2
- package/dist/git.js +44 -10
- package/dist/grok.js +39 -0
- package/dist/home.js +0 -7
- package/dist/house-cli.js +81 -21
- package/dist/instructions.js +2 -4
- package/dist/kit-cli.js +1 -4
- package/dist/login.js +12 -5
- package/dist/logout.js +2 -2
- package/dist/mcp.js +2 -2
- package/dist/placement.js +9 -23
- package/dist/resident.js +44 -37
- package/dist/scope.js +12 -4
- package/dist/scripts.js +59 -11
- package/dist/secret-input.js +1 -1
- package/dist/transcription.js +5 -2
- package/dist/translate.js +18 -9
- package/dist/update.js +105 -159
- package/dist/wire.js +19 -9
- package/dist/work.js +9 -2
- package/package.json +12 -8
- package/dist/chatgpt.js +0 -32
- package/dist/clis-main.js +0 -23
- package/dist/parts.js +0 -82
package/README.md
CHANGED
|
@@ -9,25 +9,25 @@ Run `sh -c 'kit=$(curl -fsSL "$0") || { echo "Kit could not be downloaded; run t
|
|
|
9
9
|
or `& { try { $kit = irm agents.house/kit.ps1 } catch { throw 'Kit could not be downloaded; run this command again.' }; & ([scriptblock]::Create($kit)) @args }` on Windows, which run nothing of a failed download, and again to update; options follow `agents.house/kit`.
|
|
10
10
|
On macOS and Linux it installs Kit natively under your own account, without an admin password, as a service that runs
|
|
11
11
|
while you are logged in. `kit` and `house` are then on your login shell's `PATH`, and your workspace is `~/AgentsHouse` unless you
|
|
12
|
-
pass `--workspace <path>`.
|
|
12
|
+
pass `--workspace <path>`. Every run places the Kit release your Building serves, with the Node.js and agent adapters it runs on, in a directory of its own beside the one that runs, then starts it; the earlier one stays until the next release. Kit also updates itself: when your Building takes another release, Kit places it the same way and, once no turn is open, ends so its service, or the container's restart policy, starts it. When House no longer serves the wire of the Kit that runs, Kit places your Building's release at once, ending any running turn, and ends the same way; while it cannot, it stays offline, prints why with the command that installs it again, and tries again regularly.
|
|
13
13
|
|
|
14
|
-
Add `--container` to run Kit in one Docker container instead, with your
|
|
15
|
-
workspace
|
|
16
|
-
|
|
14
|
+
Add `--container` to run Kit in one Docker container instead, with your workspace mounted at `/agents/house`; your Agents then reach only that
|
|
15
|
+
workspace. The container's image holds no Kit release and no Node.js: every run places them in Kit home's `kit` folder, which a container created again keeps. On Windows,
|
|
16
|
+
Kit home is the Docker volume `house-kit-home` and the container is the one choice. Append a `kit` or `house` command to the container's options to run it in that container.
|
|
17
17
|
Running the command for the other choice on a connected computer asks you to
|
|
18
18
|
confirm, then replaces its Environment, whose Agents end, with a new one. Running it with a different `HOUSE_KIT_HOME`
|
|
19
19
|
from the running Kit process asks you to confirm before it replaces that process, and leaves the earlier Kit home as it was.
|
|
20
20
|
|
|
21
|
-
On your own Linux server, run the Linux command with `--linux` to
|
|
22
|
-
install Kit natively, with its workspace at `/agents/house`; `kit` and
|
|
23
|
-
`house` are then on the server's `PATH`.
|
|
21
|
+
On your own Linux server, run the Linux command with `--linux` to install Kit natively, with its workspace at `/agents/house` and a missing `ca-certificates`, `curl` or `git` installed through apt; `kit` and `house` are then on the server's `PATH`.
|
|
24
22
|
|
|
25
|
-
Kit runs the
|
|
26
|
-
|
|
27
|
-
each CLI
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
Kit is built for macOS 27 on Apple silicon, Ubuntu 26.04 LTS on amd64 and Windows 11 on amd64. On another release, distribution or architecture the command prints one warning line, such as `Warning: macOS 26.7.1 is outdated; update to macOS 27.`, and installs anyway. It refuses only an architecture other than amd64 and arm64, a native install on a macOS older than 13.5, and one on a Linux without glibc 2.28 or newer, where `--container` still runs Kit. On a Linux without systemd it installs and connects Kit but starts nothing: run the `kit resident` command it prints under your own service manager, restarting it whenever it ends with a failure. `--container` installs Docker Engine on Ubuntu and Debian; another Linux needs a working Docker Engine first.
|
|
24
|
+
|
|
25
|
+
Kit runs each agent CLI through the link your login shell finds and installs a missing one through that CLI's own
|
|
26
|
+
installer. When it starts and regularly after, Kit runs each CLI's own update command, such as `claude update`, beside
|
|
27
|
+
your conversations: a running conversation keeps its version and the next one runs the new release. A CLI older than
|
|
28
|
+
the oldest release Kit is built for still runs, though its conversations may fail: Kit tells House its version, that
|
|
29
|
+
oldest release and its update command. Kit also gives every Agent on the Environment the agent skills of
|
|
30
|
+
`@agentshouse/skills`, at the version each Kit release installs. Add `--no-skills` to the command to leave them out; running it again without the flag brings them back.
|
|
31
31
|
|
|
32
32
|
## Commands
|
|
33
33
|
|
|
@@ -38,12 +38,11 @@ reconnects an Environment you already have; `--rooms <ref>[,<ref>...]` gives it
|
|
|
38
38
|
only those Rooms and `--no-private` every Room but your Private Room; `--code <code>` connects immediately without a link.
|
|
39
39
|
A login also connects your own agent: outside an Agent conversation, `house <tool>` calls
|
|
40
40
|
House as you and `git` clones and pushes your Apps at `<house>/app/` as you, each through the Kit
|
|
41
|
-
home `$HOUSE_KIT_HOME` names where it runs, until you revoke that connection on Connections. `house help` lists the Tools. Codex sessions started after a
|
|
41
|
+
home `$HOUSE_KIT_HOME` names where it runs, until you revoke that connection on Connections. `house help` lists the Tools and `house help <tool>` one Tool's arguments. Codex sessions started after a
|
|
42
42
|
login run a lone `house` command outside their sandbox. `kit logout` disconnects this
|
|
43
43
|
computer, stops the Kit process and ends your own agent's connection, so `house` and `git` no
|
|
44
44
|
longer act as you here; a later `kit login` reconnects the same Environment, or connects
|
|
45
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.
|
|
47
46
|
|
|
48
47
|
`kit resident` keeps the Environment connected and, as it connects, copies the text of each Room you chose for it as a
|
|
49
48
|
Git repository in the workspace's `local-copies`, and keeps a Room's copy as it is, no longer refreshing it, once the
|
package/dist/acp.js
CHANGED
|
@@ -116,7 +116,7 @@ export async function startAdapter(kind, cli, cwd, app, events = () => undefined
|
|
|
116
116
|
terminal: false,
|
|
117
117
|
elicitation: { form: {} },
|
|
118
118
|
session: { compaction: {}, notices: {} },
|
|
119
|
-
_meta: { jetbrains: { air: { version: 1, capabilities: CLIS[kind].air } } },
|
|
119
|
+
_meta: { terminal_output: true, jetbrains: { air: { version: 1, capabilities: CLIS[kind].air } } },
|
|
120
120
|
},
|
|
121
121
|
clientInfo: { name: '@agentshouse/kit', version: KIT_RELEASE },
|
|
122
122
|
});
|
package/dist/afk.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CLIS } from './clis.js';
|
|
2
|
+
const NOBODY_THERE = 'Nobody is there to answer. Decide for yourself and go on.';
|
|
3
|
+
export const PLAN_APPROVED = { outcome: 'approved' };
|
|
4
|
+
function told(fields) {
|
|
5
|
+
return Object.fromEntries(fields.map((field) => [field, NOBODY_THERE]));
|
|
6
|
+
}
|
|
7
|
+
export function permissionAllowed({ options }) {
|
|
8
|
+
const option = options.find(({ kind }) => kind === 'allow_once') ?? options.find(({ kind }) => kind === 'allow_always');
|
|
9
|
+
return { outcome: { outcome: 'selected', optionId: option.optionId } };
|
|
10
|
+
}
|
|
11
|
+
export function formAnswered(kind, request) {
|
|
12
|
+
const fields = CLIS[kind].questionFields(request);
|
|
13
|
+
return fields.length === 0 ? { action: 'decline' } : { action: 'accept', content: told(fields) };
|
|
14
|
+
}
|
|
15
|
+
export function grokQuestionAnswered({ questions }) {
|
|
16
|
+
return { outcome: 'accepted', answers: told(questions.map(({ question }) => question)) };
|
|
17
|
+
}
|
package/dist/agents.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { client } from '@agentclientprotocol/sdk';
|
|
2
|
-
import {
|
|
2
|
+
import { KIT_WIRE } from '@agentshouse/kit-wire';
|
|
3
|
+
import { readFile } from 'node:fs/promises';
|
|
3
4
|
import { setTimeout as delay } from 'node:timers/promises';
|
|
4
5
|
import { signedOut, startAdapter } from './acp.js';
|
|
5
|
-
import { CLIS, KIT_RELEASE, below,
|
|
6
|
+
import { CLIS, KIT_RELEASE, below, installCli, locate, run, updateCli, versionOf } from './clis.js';
|
|
6
7
|
import { agentBase, kitHome } from './home.js';
|
|
7
|
-
import { updatesItself } from './placement.js';
|
|
8
8
|
import { holdTranscription, transcriptionReport } from './transcription.js';
|
|
9
|
-
import { KIT_WIRE } from './wire.js';
|
|
10
9
|
// Two quiet seconds let a fresh conversation start before background model discovery competes for its CPU.
|
|
11
10
|
const MODEL_PROBE_QUIET_MS = 2_000;
|
|
11
|
+
// A CLI's maker can publish several releases a day, so running each chosen CLI's update command hourly brings a new one to the next conversation within the hour for one small check.
|
|
12
|
+
export const CLI_UPDATE_MS = 60 * 60_000;
|
|
12
13
|
// A sign-in's model read that has not answered in ten seconds leaves its sign-in to the status check, so a hung CLI never holds the sign-in's result.
|
|
13
14
|
const SIGNED_IN_READ_MS = 10_000;
|
|
14
15
|
const SIGNED_OUT = { signed_in: false, models: [], modes: [] };
|
|
@@ -110,10 +111,11 @@ async function offer(kind, cli, known, signal) {
|
|
|
110
111
|
}
|
|
111
112
|
}
|
|
112
113
|
function reported(kind, reading) {
|
|
114
|
+
const { minimum, update } = CLIS[kind];
|
|
113
115
|
return {
|
|
114
116
|
kind,
|
|
115
117
|
release: reading.release,
|
|
116
|
-
...(reading.
|
|
118
|
+
...(reading.release !== null && below(reading.release, minimum) ? { minimum, update } : {}),
|
|
117
119
|
failure: reading.failure,
|
|
118
120
|
...(reading.installing === undefined ? {} : { installing: reading.installing }),
|
|
119
121
|
signed_in: reading.signed_in,
|
|
@@ -123,10 +125,6 @@ function reported(kind, reading) {
|
|
|
123
125
|
};
|
|
124
126
|
}
|
|
125
127
|
const NOT_READY = "the Agent's CLI is not ready on this computer";
|
|
126
|
-
function tooOld(kind, release) {
|
|
127
|
-
const cli = CLIS[kind];
|
|
128
|
-
return `${cli.bin} ${release} is older than ${cli.minimum}, the oldest this Kit runs`;
|
|
129
|
-
}
|
|
130
128
|
async function sshHostKey() {
|
|
131
129
|
// Listing a local host key takes a moment, so ten seconds only bounds a stuck ssh-keygen.
|
|
132
130
|
const listed = await run('ssh-keygen', ['-l', '-E', 'sha256', '-f', '/etc/ssh/ssh_host_ed25519_key.pub'], 10_000);
|
|
@@ -168,13 +166,15 @@ export class Agents {
|
|
|
168
166
|
sending = Promise.resolve();
|
|
169
167
|
sent = null;
|
|
170
168
|
refreshing = 0;
|
|
169
|
+
loaded = Promise.resolve();
|
|
170
|
+
updating = null;
|
|
171
171
|
changed;
|
|
172
172
|
constructor(house, changed = () => undefined) {
|
|
173
173
|
this.house = house;
|
|
174
174
|
this.changed = changed;
|
|
175
175
|
}
|
|
176
176
|
idle() {
|
|
177
|
-
return this.refreshing === 0;
|
|
177
|
+
return this.refreshing === 0 && this.updating === null;
|
|
178
178
|
}
|
|
179
179
|
read() {
|
|
180
180
|
return this.reading.then(() => undefined, () => undefined);
|
|
@@ -186,11 +186,11 @@ export class Agents {
|
|
|
186
186
|
this.refreshing++;
|
|
187
187
|
this.changed();
|
|
188
188
|
const reading = this.read().then(async () => {
|
|
189
|
-
this.desired = await this.house.deliver('
|
|
189
|
+
this.desired = await this.house.deliver('agents/desired/list', {});
|
|
190
190
|
return this.desired;
|
|
191
191
|
});
|
|
192
192
|
this.reading = reading;
|
|
193
|
-
reading
|
|
193
|
+
this.loaded = reading
|
|
194
194
|
.then(({ agents, transcribe }) => Promise.all([
|
|
195
195
|
holdTranscription(transcribe)
|
|
196
196
|
.then((changed) => (changed ? this.report() : undefined))
|
|
@@ -206,18 +206,25 @@ export class Agents {
|
|
|
206
206
|
});
|
|
207
207
|
return reading.then(() => undefined);
|
|
208
208
|
}
|
|
209
|
+
keepCurrent(stopping) {
|
|
210
|
+
this.updateAll(this.loaded);
|
|
211
|
+
setInterval(() => {
|
|
212
|
+
if (!stopping())
|
|
213
|
+
this.updateAll(Promise.resolve());
|
|
214
|
+
}, CLI_UPDATE_MS);
|
|
215
|
+
}
|
|
209
216
|
cli(kind) {
|
|
210
217
|
this.starts += 1;
|
|
211
218
|
return this.queue(kind, async () => {
|
|
212
219
|
const resolved = await this.resolve(kind);
|
|
213
220
|
if (!('cli' in resolved)) {
|
|
214
221
|
this.update(kind, resolved);
|
|
215
|
-
throw new Error(
|
|
222
|
+
throw new Error(NOT_READY);
|
|
216
223
|
}
|
|
217
224
|
const { cli, release } = resolved;
|
|
218
225
|
const known = this.readings.get(kind);
|
|
219
|
-
const kept = known?.release === null
|
|
220
|
-
if (known?.release !== release ||
|
|
226
|
+
const kept = known?.release === null ? SIGNED_OUT : (known ?? SIGNED_OUT);
|
|
227
|
+
if (known?.release !== release || this.installs.has(kind)) {
|
|
221
228
|
this.update(kind, { release, failure: null, signed_in: kept.signed_in, models: kept.models, modes: kept.modes });
|
|
222
229
|
}
|
|
223
230
|
const read = this.nextRead(kind);
|
|
@@ -284,9 +291,6 @@ export class Agents {
|
|
|
284
291
|
return signal === undefined ? queued : Promise.race([queued, ended(signal)]);
|
|
285
292
|
}
|
|
286
293
|
async ensure(kind, signal, owner = {}) {
|
|
287
|
-
const failed = await installAdapter(kind, signal);
|
|
288
|
-
if (failed !== null)
|
|
289
|
-
throw new Error(failed);
|
|
290
294
|
const found = await locate(kind, signal);
|
|
291
295
|
if (found !== null)
|
|
292
296
|
return found;
|
|
@@ -305,7 +309,7 @@ export class Agents {
|
|
|
305
309
|
async resolve(kind, signal, owner) {
|
|
306
310
|
let cli;
|
|
307
311
|
try {
|
|
308
|
-
cli = await
|
|
312
|
+
cli = await this.ensure(kind, signal, owner);
|
|
309
313
|
}
|
|
310
314
|
catch (error) {
|
|
311
315
|
const failure = causeOf(error);
|
|
@@ -315,9 +319,6 @@ export class Agents {
|
|
|
315
319
|
const release = await versionOf(cli, signal);
|
|
316
320
|
if (release === null)
|
|
317
321
|
return { release: null, failure: `${cli} --version names no version`, ...SIGNED_OUT };
|
|
318
|
-
const minimum = CLIS[kind].minimum;
|
|
319
|
-
if (below(release, minimum))
|
|
320
|
-
return { release, minimum, failure: null, ...SIGNED_OUT };
|
|
321
322
|
return { cli, release };
|
|
322
323
|
}
|
|
323
324
|
async examine(kind, known, read, signal, owner) {
|
|
@@ -327,6 +328,35 @@ export class Agents {
|
|
|
327
328
|
if (this.reads.get(kind) === current && !signal?.aborted)
|
|
328
329
|
this.hold(kind, reading);
|
|
329
330
|
}
|
|
331
|
+
updateAll(after) {
|
|
332
|
+
if (this.updating !== null)
|
|
333
|
+
return;
|
|
334
|
+
this.updating = after
|
|
335
|
+
.then(async () => {
|
|
336
|
+
for (const kind of this.desired.agents) {
|
|
337
|
+
if (this.installs.has(kind) || !this.readings.get(kind)?.release)
|
|
338
|
+
continue;
|
|
339
|
+
const failure = await updateCli(kind);
|
|
340
|
+
if (failure !== null)
|
|
341
|
+
process.stderr.write(`kit: ${kind} did not update: ${failure}\n`);
|
|
342
|
+
await this.readVersion(kind);
|
|
343
|
+
}
|
|
344
|
+
})
|
|
345
|
+
.catch(logged)
|
|
346
|
+
.finally(() => {
|
|
347
|
+
this.updating = null;
|
|
348
|
+
this.changed();
|
|
349
|
+
});
|
|
350
|
+
this.changed();
|
|
351
|
+
}
|
|
352
|
+
async readVersion(kind) {
|
|
353
|
+
const cli = await locate(kind);
|
|
354
|
+
const release = cli === null ? null : await versionOf(cli);
|
|
355
|
+
const current = this.readings.get(kind);
|
|
356
|
+
if (release === null || !current?.release || current.release === release)
|
|
357
|
+
return;
|
|
358
|
+
this.update(kind, { ...current, release });
|
|
359
|
+
}
|
|
330
360
|
async quietOffer(kind, cli, known) {
|
|
331
361
|
for (let seen = -1; seen !== this.starts;) {
|
|
332
362
|
seen = this.starts;
|
|
@@ -336,7 +366,7 @@ export class Agents {
|
|
|
336
366
|
}
|
|
337
367
|
async load(kind) {
|
|
338
368
|
const known = this.readings.get(kind);
|
|
339
|
-
if (known !== undefined && known.failure === null
|
|
369
|
+
if (known !== undefined && known.failure === null)
|
|
340
370
|
return;
|
|
341
371
|
await this.examine(kind, SIGNED_OUT, (kind, cli, known) => this.quietOffer(kind, cli, known));
|
|
342
372
|
await this.report();
|
|
@@ -353,7 +383,6 @@ export class Agents {
|
|
|
353
383
|
...(form === undefined ? {} : { form }),
|
|
354
384
|
kit_release: KIT_RELEASE,
|
|
355
385
|
wire: KIT_WIRE,
|
|
356
|
-
updates_itself: await updatesItself(),
|
|
357
386
|
agent_base: agentBase(),
|
|
358
387
|
agents,
|
|
359
388
|
transcription: transcriptionReport(),
|
|
@@ -362,7 +391,7 @@ export class Agents {
|
|
|
362
391
|
const state = JSON.stringify(body);
|
|
363
392
|
if (state === this.sent)
|
|
364
393
|
return;
|
|
365
|
-
await this.house.deliver('
|
|
394
|
+
await this.house.deliver('agents/report', body);
|
|
366
395
|
this.sent = state;
|
|
367
396
|
}
|
|
368
397
|
}
|
package/dist/api.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { KIT_WIRE, KIT_WIRE_HEADER, } from '@agentshouse/kit-wire';
|
|
1
2
|
import { setTimeout as delay } from 'node:timers/promises';
|
|
2
3
|
import { signInAgain } from './end.js';
|
|
3
4
|
import { readEnrolment } from './home.js';
|
|
4
5
|
import { retryable } from './refusals.js';
|
|
5
6
|
import { relayed } from './relay.js';
|
|
6
|
-
import { endUnserved
|
|
7
|
+
import { endUnserved } from './wire.js';
|
|
7
8
|
export class HouseRefusal extends Error {
|
|
8
9
|
status;
|
|
9
10
|
text;
|
|
@@ -38,7 +39,7 @@ export async function post(house, path, body, credential, signal) {
|
|
|
38
39
|
method: 'POST',
|
|
39
40
|
headers: {
|
|
40
41
|
'content-type': 'application/json',
|
|
41
|
-
[KIT_WIRE_HEADER]:
|
|
42
|
+
[KIT_WIRE_HEADER]: KIT_WIRE,
|
|
42
43
|
...(credential === undefined ? {} : { authorization: `Bearer ${credential}` }),
|
|
43
44
|
},
|
|
44
45
|
body: JSON.stringify(body),
|
|
@@ -51,6 +52,9 @@ export async function post(house, path, body, credential, signal) {
|
|
|
51
52
|
throw new HouseRefusal(path, answer.status, text);
|
|
52
53
|
return JSON.parse(text);
|
|
53
54
|
}
|
|
55
|
+
export function kitAct(house, act, request, credential, signal) {
|
|
56
|
+
return post(house, `/kit/${act}`, request, credential, signal);
|
|
57
|
+
}
|
|
54
58
|
async function enrolledPost(path, body, signal) {
|
|
55
59
|
const { house, credential } = (await readEnrolment());
|
|
56
60
|
try {
|
|
@@ -63,16 +67,17 @@ async function enrolledPost(path, body, signal) {
|
|
|
63
67
|
}
|
|
64
68
|
}
|
|
65
69
|
export const house = {
|
|
66
|
-
|
|
67
|
-
|
|
70
|
+
act: (act, request, signal) => enrolledPost(`/kit/${act}`, request, signal),
|
|
71
|
+
door: (act, body, signal) => enrolledPost(`/kit/door/${act}`, body, signal),
|
|
72
|
+
deliver: async (act, request, current = () => true) => {
|
|
68
73
|
for (let attempt = 0;; attempt++) {
|
|
69
74
|
try {
|
|
70
|
-
return await enrolledPost(
|
|
75
|
+
return await enrolledPost(`/kit/${act}`, request);
|
|
71
76
|
}
|
|
72
77
|
catch (error) {
|
|
73
78
|
if (finalRefusal(error))
|
|
74
79
|
throw error;
|
|
75
|
-
process.stderr.write(`kit:
|
|
80
|
+
process.stderr.write(`kit: /kit/${act} did not reach House: ${error.message}\n`);
|
|
76
81
|
// A delivery House did not take is sent again on the jittered curve for as long as it is still current.
|
|
77
82
|
await new Promise((resolve) => setTimeout(resolve, retryDelay(attempt)));
|
|
78
83
|
if (!current())
|
package/dist/authority-main.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HouseRefusal,
|
|
1
|
+
import { HouseRefusal, kitAct } from './api.js';
|
|
2
2
|
import { readEnrolment } from './home.js';
|
|
3
3
|
import { proxyUnlessRelayed } from './relay.js';
|
|
4
4
|
function unanswered(error) {
|
|
@@ -8,7 +8,7 @@ proxyUnlessRelayed();
|
|
|
8
8
|
try {
|
|
9
9
|
const { house, credential } = (await readEnrolment());
|
|
10
10
|
try {
|
|
11
|
-
await
|
|
11
|
+
await kitAct(house, 'agents/desired/list', {}, credential);
|
|
12
12
|
}
|
|
13
13
|
catch (error) {
|
|
14
14
|
if (!unanswered(error))
|
package/dist/bridge.js
CHANGED
|
@@ -81,7 +81,7 @@ function editAnswer(forwarded) {
|
|
|
81
81
|
export async function openBridge(house, copies, conversationId, signal) {
|
|
82
82
|
const path = [join(kitHome(), 'shim'), dirname(process.execPath), await loginPath()].join(delimiter);
|
|
83
83
|
const origin = (await readEnrolment()).house;
|
|
84
|
-
const { credential } = await retrying(() => house.
|
|
84
|
+
const { credential } = await retrying(() => house.act('conversations/credentials/issue', { conversation: conversationId }, signal), signal);
|
|
85
85
|
const closed = new AbortController();
|
|
86
86
|
const sent = (message, operation) => callHouse(origin, credential, message, operation, closed.signal);
|
|
87
87
|
const send = async (message, operation) => {
|
|
@@ -105,7 +105,7 @@ export async function openBridge(house, copies, conversationId, signal) {
|
|
|
105
105
|
const bytes = Buffer.from(JSON.stringify({ changes }));
|
|
106
106
|
const sha256 = createHash('sha256').update(bytes).digest('hex');
|
|
107
107
|
const prepared = answered(await send(call('run_command', {
|
|
108
|
-
command: '
|
|
108
|
+
command: 'files/batch-upload',
|
|
109
109
|
arguments: { paths: changedPaths(changes), bytes: bytes.length, sha256 },
|
|
110
110
|
}), operation));
|
|
111
111
|
if ('refused' in prepared)
|
|
@@ -141,7 +141,7 @@ export async function openBridge(house, copies, conversationId, signal) {
|
|
|
141
141
|
const caller = {
|
|
142
142
|
key: `conversation:${conversationId}`,
|
|
143
143
|
submit: async (operation, changes, held, retain) => {
|
|
144
|
-
const inline = call('
|
|
144
|
+
const inline = call('files_batch', { changes });
|
|
145
145
|
let upload = held;
|
|
146
146
|
if (upload === undefined && Buffer.byteLength(mcpBody(inline, operation)) > MCP_REQUEST_BYTES) {
|
|
147
147
|
const prepared = await staged(operation, changes);
|
|
@@ -150,7 +150,7 @@ export async function openBridge(house, copies, conversationId, signal) {
|
|
|
150
150
|
upload = prepared;
|
|
151
151
|
await retain(upload);
|
|
152
152
|
}
|
|
153
|
-
return editAnswer(await send(upload === undefined ? inline : call('
|
|
153
|
+
return editAnswer(await send(upload === undefined ? inline : call('files_batch', { paths: changedPaths(changes), upload }), operation));
|
|
154
154
|
},
|
|
155
155
|
};
|
|
156
156
|
const local = async (path, text) => {
|
package/dist/building.js
CHANGED
|
@@ -16,10 +16,14 @@ async function served(name, signal) {
|
|
|
16
16
|
await answer.body?.cancel();
|
|
17
17
|
throw new Error(`House answered ${answer.status} for ${name}`);
|
|
18
18
|
}
|
|
19
|
-
export async function
|
|
19
|
+
export async function servedRelease(signal) {
|
|
20
20
|
const manifest = (await (await served(MANIFEST, signal)).json());
|
|
21
|
-
const
|
|
22
|
-
|
|
21
|
+
const installer = manifest.hosts?.linux;
|
|
22
|
+
const sha256 = typeof installer === 'string' ? manifest.files?.[installer]?.sha256 : undefined;
|
|
23
|
+
if (typeof manifest.version !== 'string' || typeof installer !== 'string' || typeof sha256 !== 'string') {
|
|
24
|
+
throw new Error(`House serves no Kit release in ${MANIFEST}`);
|
|
25
|
+
}
|
|
26
|
+
return { version: manifest.version, installer, sha256 };
|
|
23
27
|
}
|
|
24
28
|
export async function downloadServed(name, sha256, destination, signal, most = Infinity) {
|
|
25
29
|
const answer = await served(name, signal);
|
package/dist/calls.js
CHANGED
|
@@ -42,7 +42,7 @@ export class Calls {
|
|
|
42
42
|
return carried
|
|
43
43
|
.then(async ({ result, returned, release }) => {
|
|
44
44
|
try {
|
|
45
|
-
await this.house.deliver(
|
|
45
|
+
await this.house.deliver('kit-calls/results/return', { call: callId, ...result });
|
|
46
46
|
}
|
|
47
47
|
finally {
|
|
48
48
|
this.returned.add(callId);
|
package/dist/chunks.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { readFile, rm } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { downloaded, fetched } from './files.js';
|
|
4
|
+
const DOWNLOADS_AT_ONCE = 6;
|
|
5
|
+
// A chunk is about one megabyte, so a download still unfinished after two minutes holds every Room behind it on a dead connection.
|
|
6
|
+
const CHUNK_DOWNLOAD_MS = 120_000;
|
|
7
|
+
class AddressExpired extends Error {
|
|
8
|
+
constructor() {
|
|
9
|
+
super("House's store refused every chunk it asked for");
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function once(chunk) {
|
|
13
|
+
let asked = false;
|
|
14
|
+
return async () => {
|
|
15
|
+
if (asked)
|
|
16
|
+
throw new AddressExpired();
|
|
17
|
+
asked = true;
|
|
18
|
+
return { download: chunk.download, sha256: chunk.hash };
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export async function stagedChunks(directory, chunks) {
|
|
22
|
+
let next = 0;
|
|
23
|
+
let failure;
|
|
24
|
+
const downloading = async () => {
|
|
25
|
+
while (next < chunks.length && failure === undefined) {
|
|
26
|
+
const chunk = chunks[next++];
|
|
27
|
+
const reading = (url) => fetched(url, AbortSignal.timeout(CHUNK_DOWNLOAD_MS));
|
|
28
|
+
await downloaded(once(chunk), reading, join(directory, chunk.hash), 'A Room chunk').catch((error) => {
|
|
29
|
+
failure ??= error;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
await Promise.all(Array.from({ length: DOWNLOADS_AT_ONCE }, downloading));
|
|
34
|
+
return failure;
|
|
35
|
+
}
|
|
36
|
+
export async function* chunkTexts(directory, chunks, models) {
|
|
37
|
+
yield* models;
|
|
38
|
+
for (const { hash } of chunks) {
|
|
39
|
+
const file = join(directory, hash);
|
|
40
|
+
for (const line of (await readFile(file, 'utf8')).split('\n')) {
|
|
41
|
+
if (line === '')
|
|
42
|
+
continue;
|
|
43
|
+
const entry = JSON.parse(line);
|
|
44
|
+
if (entry.content !== undefined)
|
|
45
|
+
yield entry;
|
|
46
|
+
}
|
|
47
|
+
await rm(file);
|
|
48
|
+
}
|
|
49
|
+
}
|