@agentshouse/kit 0.2.1-ce145e9aadbf6 → 0.2.1-ce47f621f90e1
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 +47 -46
- package/dist/acp.js +102 -108
- package/dist/agents.js +189 -56
- package/dist/api.js +34 -2
- package/dist/app-git.js +48 -0
- package/dist/authority-main.js +2 -2
- package/dist/bridge.js +37 -58
- package/dist/building.js +50 -0
- package/dist/calls.js +71 -0
- package/dist/chatgpt.js +32 -0
- package/dist/clis.js +150 -99
- package/dist/codex-main.js +58 -0
- package/dist/connection.js +105 -0
- package/dist/conversations.js +731 -332
- package/dist/copies.js +188 -128
- package/dist/end.js +33 -0
- package/dist/enrol-main.js +7 -1
- package/dist/events.js +546 -0
- package/dist/files.js +139 -17
- package/dist/git.js +13 -11
- package/dist/home.js +89 -7
- package/dist/house-cli.js +299 -0
- package/dist/house-main.js +7 -159
- package/dist/instructions.js +8 -10
- package/dist/kit-cli.js +68 -0
- package/dist/kit-main.js +8 -19
- package/dist/login.js +119 -104
- package/dist/logout.js +14 -13
- package/dist/mcp.js +6 -2
- package/dist/parts.js +82 -0
- package/dist/placement.js +31 -0
- package/dist/refusals.js +12 -0
- package/dist/relay.js +33 -2
- package/dist/resident.js +117 -51
- package/dist/scope.js +214 -0
- package/dist/scripts.js +255 -0
- package/dist/secret-input.js +3 -2
- package/dist/service-main.js +9 -0
- package/dist/service.js +55 -0
- package/dist/shell.js +3 -0
- package/dist/sign-in.js +40 -33
- package/dist/silence.js +28 -0
- package/dist/skills.js +49 -35
- package/dist/transcription.js +129 -41
- package/dist/translate.js +2 -8
- package/dist/update.js +113 -103
- package/dist/wire.js +40 -0
- package/dist/work.js +346 -0
- package/package.json +20 -20
- package/dist/blocks.js +0 -51
- package/dist/bootstrap.json +0 -24
- package/dist/clis-main.js +0 -23
- package/dist/stream.js +0 -47
- package/how-we-work.md +0 -23
- package/skills/ask-matt/LICENSE +0 -21
- package/skills/ask-matt/PHASE-BOUNDARIES.md +0 -55
- package/skills/ask-matt/SKILL.md +0 -91
- package/skills/ask-matt/agents/openai.yaml +0 -4
- package/skills/code-review/LICENSE +0 -21
- package/skills/code-review/SKILL.md +0 -89
- package/skills/code-review/agents/openai.yaml +0 -3
- package/skills/codebase-design/DEEPENING.md +0 -37
- package/skills/codebase-design/DESIGN-IT-TWICE.md +0 -44
- package/skills/codebase-design/LICENSE +0 -21
- package/skills/codebase-design/SKILL.md +0 -116
- package/skills/codebase-design/agents/openai.yaml +0 -3
- package/skills/diagnosing-bugs/LICENSE +0 -21
- package/skills/diagnosing-bugs/SKILL.md +0 -140
- package/skills/diagnosing-bugs/agents/openai.yaml +0 -3
- package/skills/diagnosing-bugs/scripts/hitl-loop.template.sh +0 -44
- package/skills/domain-modeling/ADR-FORMAT.md +0 -47
- package/skills/domain-modeling/CONTEXT-FORMAT.md +0 -60
- package/skills/domain-modeling/LICENSE +0 -21
- package/skills/domain-modeling/SKILL.md +0 -76
- package/skills/domain-modeling/agents/openai.yaml +0 -3
- package/skills/grill-me/LICENSE +0 -21
- package/skills/grill-me/SKILL.md +0 -8
- package/skills/grill-me/agents/openai.yaml +0 -4
- package/skills/grill-with-docs/LICENSE +0 -21
- package/skills/grill-with-docs/SKILL.md +0 -8
- package/skills/grill-with-docs/agents/openai.yaml +0 -4
- package/skills/grilling/LICENSE +0 -21
- package/skills/grilling/SKILL.md +0 -30
- package/skills/grilling/agents/openai.yaml +0 -3
- package/skills/handoff/LICENSE +0 -21
- package/skills/handoff/SKILL.md +0 -17
- package/skills/handoff/agents/openai.yaml +0 -4
- package/skills/implement/LICENSE +0 -21
- package/skills/implement/SKILL.md +0 -16
- package/skills/implement/agents/openai.yaml +0 -4
- package/skills/improve-codebase-architecture/HTML-REPORT.md +0 -123
- package/skills/improve-codebase-architecture/LICENSE +0 -21
- package/skills/improve-codebase-architecture/SKILL.md +0 -72
- package/skills/improve-codebase-architecture/agents/openai.yaml +0 -4
- package/skills/prototype/LICENSE +0 -21
- package/skills/prototype/LOGIC.md +0 -67
- package/skills/prototype/SKILL.md +0 -28
- package/skills/prototype/UI.md +0 -112
- package/skills/prototype/agents/openai.yaml +0 -3
- package/skills/research/LICENSE +0 -21
- package/skills/research/SKILL.md +0 -14
- package/skills/research/agents/openai.yaml +0 -3
- package/skills/resolving-merge-conflicts/LICENSE +0 -21
- package/skills/resolving-merge-conflicts/SKILL.md +0 -16
- package/skills/resolving-merge-conflicts/agents/openai.yaml +0 -3
- package/skills/tdd/LICENSE +0 -21
- package/skills/tdd/SKILL.md +0 -40
- package/skills/tdd/agents/openai.yaml +0 -3
- package/skills/tdd/mocking.md +0 -59
- package/skills/tdd/tests.md +0 -77
- package/skills/teach/GLOSSARY-FORMAT.md +0 -35
- package/skills/teach/LEARNING-RECORD-FORMAT.md +0 -46
- package/skills/teach/LICENSE +0 -21
- package/skills/teach/MISSION-FORMAT.md +0 -31
- package/skills/teach/RESOURCES-FORMAT.md +0 -32
- package/skills/teach/SKILL.md +0 -141
- package/skills/teach/agents/openai.yaml +0 -4
- package/skills/to-questionnaire/LICENSE +0 -21
- package/skills/to-questionnaire/SKILL.md +0 -55
- package/skills/to-questionnaire/agents/openai.yaml +0 -4
- package/skills/to-spec/LICENSE +0 -21
- package/skills/to-spec/SKILL.md +0 -76
- package/skills/to-spec/agents/openai.yaml +0 -4
- package/skills/to-tickets/LICENSE +0 -21
- package/skills/to-tickets/SKILL.md +0 -106
- package/skills/to-tickets/agents/openai.yaml +0 -4
- package/skills/wait-what/LICENSE +0 -21
- package/skills/wait-what/SKILL.md +0 -8
- package/skills/wait-what/agents/openai.yaml +0 -4
- package/skills/wayfinder/LICENSE +0 -21
- package/skills/wayfinder/SKILL.md +0 -129
- package/skills/wayfinder/agents/openai.yaml +0 -4
- package/skills/writing-for-agents/LICENSE +0 -21
- package/skills/writing-for-agents/SKILL-MECHANICS.md +0 -22
- package/skills/writing-for-agents/SKILL.md +0 -83
- package/skills/writing-for-agents/agents/openai.yaml +0 -3
package/README.md
CHANGED
|
@@ -1,59 +1,60 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Kit
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
through the agent CLIs you chose and gives each Agent the `house` command.
|
|
3
|
+
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
|
|
10
|
-
Windows, and again to update; options follow `
|
|
11
|
-
installs
|
|
12
|
-
|
|
13
|
-
your
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
workspace. On Windows 11 the container is the one choice. Append a `kit` or
|
|
19
|
-
`house` command to the container's options to run it in that container.
|
|
8
|
+
Run `sh -c 'kit=$(curl -fsSL "$0") || { echo "Kit could not be downloaded; run this command again." >&2; exit 1; }; eval "$kit"' agents.house/kit`,
|
|
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
|
+
On macOS and Linux it installs Kit natively under your own account, without an admin password, as a service that runs
|
|
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>`. 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 refuses the Kit that runs as too old or too new, 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
|
+
|
|
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.
|
|
20
17
|
Running the command for the other choice on a connected computer asks you to
|
|
21
|
-
confirm, then replaces its Environment, whose Agents end, with a new one.
|
|
18
|
+
confirm, then replaces its Environment, whose Agents end, with a new one. Running it with a different `HOUSE_KIT_HOME`
|
|
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
|
+
|
|
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`.
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
install House Kit natively, with its workspace at `/agents/house`; `kit` and
|
|
25
|
-
`house` are then on the server's `PATH`.
|
|
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, and a native install on a Linux without glibc, 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.
|
|
26
24
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
them out; running it again without the flag brings them back.
|
|
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.
|
|
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
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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, 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
|
|
42
|
+
login run a lone `house` command outside their sandbox. `kit logout` disconnects this
|
|
43
|
+
computer, stops the Kit process 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, or connects
|
|
45
|
+
this computer as a new one when House no longer holds it.
|
|
46
|
+
In a container you do not control, such as ChatGPT's, `npm i -g @agentshouse/kit` and `kit chatgpt --key <key>` with a key made on Connections let `house <tool>` act as you, starting and configuring nothing else.
|
|
47
|
+
|
|
48
|
+
`kit resident` keeps the Environment connected and, as it connects, copies the text of each Room you chose for it as a
|
|
49
|
+
Git repository in the workspace's `local-copies`, and keeps a Room's copy as it is, no longer refreshing it, once the
|
|
50
|
+
Room may no longer be copied here. `house fetch` does the same and records House's changes on each copy's
|
|
51
|
+
`refs/house/received`; rebase onto it, commit and run `house push --owner` in the copy, through the install command in
|
|
52
|
+
the container. An Agent runs both, without `--owner`. `house upload` and `house download` move a Room's other files straight between disk and House's store, and a broken upload resumes on its own.
|
|
53
|
+
|
|
54
|
+
Kit turns each audio file your message to an Agent links into text on this computer before the Agent reads it, and keeps a message whose audio it cannot turn into text from starting. While transcription is on, the speech engine and model use about 425 MB beside the Environment's credential; turning it off deletes them.
|
|
55
|
+
|
|
56
|
+
When you press Run on a Web Wizard's page, Kit runs its script with `bash` in a terminal on this computer, as you, in the home and directory it runs agent CLIs from, with your login shell's `PATH`; the page shows that terminal and takes your typing, and closing the page, or Kit losing its connection to House, ends the script and its child processes. Kit keeps nothing the script prints or you type. A script you keep as a function from a Web Wizard runs as you, from the same home, directory and `PATH`, when a Trigger of your Private Room or your agent runs it, with no terminal and nothing on its standard input, and when you press Run now on its page, in a terminal you can type into. Kit writes the run's input as JSON to a file only you can read, whose path is in `HOUSE_INPUT`, and deletes it when the run ends; it ends the script and its child processes at the run's time limit or when it loses its connection to House, and sends House the end of what the script printed, up to the run's output limit, without any line that holds a line you typed.
|
|
54
57
|
|
|
55
58
|
## License
|
|
56
59
|
|
|
57
|
-
MIT
|
|
58
|
-
|
|
59
|
-
The skills come from [mattpocock/skills](https://github.com/mattpocock/skills); thank you, Matt Pocock.
|
|
60
|
+
MIT.
|
package/dist/acp.js
CHANGED
|
@@ -1,48 +1,113 @@
|
|
|
1
|
-
import { ndJsonStream, PROTOCOL_VERSION, } from '@agentclientprotocol/sdk';
|
|
2
|
-
import {
|
|
3
|
-
import { readdirSync, readFileSync } from 'node:fs';
|
|
1
|
+
import { ndJsonStream, PROTOCOL_VERSION, RequestError, } from '@agentclientprotocol/sdk';
|
|
2
|
+
import { spawn } from 'node:child_process';
|
|
4
3
|
import { Readable, Writable } from 'node:stream';
|
|
5
|
-
import { CLIS,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
import { CLIS, KIT_RELEASE, adapterCommand } from './clis.js';
|
|
5
|
+
import { childEnvironment } from './relay.js';
|
|
6
|
+
import { killTree } from './scope.js';
|
|
7
|
+
import { Silence } from './silence.js';
|
|
8
|
+
const RETIRED = 'the CLI was retired';
|
|
9
|
+
const SIGNED_OUT = RequestError.authRequired().code;
|
|
10
|
+
export function signedOut(error) {
|
|
11
|
+
return typeof error === 'object' && error !== null && error.code === SIGNED_OUT;
|
|
12
|
+
}
|
|
13
|
+
// Claude Code ends a shell command or a model request after ten minutes, so a CLI that owes the Kit an answer and sends nothing for half an hour has hung.
|
|
14
|
+
export const CLI_SILENCE_MS = 30 * 60_000;
|
|
15
|
+
const SILENT = `the CLI sent nothing for ${CLI_SILENCE_MS / 60_000} minutes`;
|
|
16
|
+
export async function startAdapter(kind, cli, cwd, app, events = () => undefined, added = {}, signal, scope = null) {
|
|
9
17
|
const adapter = CLIS[kind].adapter;
|
|
10
|
-
const
|
|
18
|
+
const started = [adapter === null ? cli : adapterCommand(kind), CLIS[kind].args];
|
|
19
|
+
const [command, args] = scope?.command(...started) ?? started;
|
|
20
|
+
const child = spawn(command, args, {
|
|
11
21
|
cwd,
|
|
12
|
-
env: { ...
|
|
22
|
+
env: { ...childEnvironment(), ...(adapter === null ? {} : { ...adapter.env, [adapter.executable]: cli }), ...added },
|
|
13
23
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
14
24
|
detached: true,
|
|
15
25
|
});
|
|
26
|
+
let owned = true;
|
|
27
|
+
let retired = false;
|
|
28
|
+
let silent = false;
|
|
29
|
+
let over = false;
|
|
30
|
+
let open = false;
|
|
16
31
|
let stderr = '';
|
|
32
|
+
const owed = new Set();
|
|
33
|
+
const asked = new Set();
|
|
34
|
+
const silence = new Silence(CLI_SILENCE_MS, () => {
|
|
35
|
+
silent = true;
|
|
36
|
+
connection.close(new Error(SILENT));
|
|
37
|
+
if (child.pid !== undefined)
|
|
38
|
+
killTree(child);
|
|
39
|
+
});
|
|
40
|
+
const watch = () => (!over && (owed.size > 0 || open) && asked.size === 0 ? silence.heard() : silence.stop());
|
|
17
41
|
child.stderr.on('data', (chunk) => {
|
|
18
42
|
stderr = (stderr + chunk.toString('utf8')).slice(-4000);
|
|
19
43
|
});
|
|
20
|
-
const exited = new Promise((resolve) => {
|
|
21
|
-
child.on('error', (error) => resolve(`the CLI did not start: ${error.message}`));
|
|
22
|
-
child.on('exit', (code, signal) => {
|
|
23
|
-
const last = stderr.trim().split('\n').at(-1);
|
|
24
|
-
resolve(`the CLI exited with ${code ?? signal}${last ? `: ${last}` : ''}`);
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
44
|
const stream = ndJsonStream(Writable.toWeb(child.stdin), Readable.toWeb(child.stdout));
|
|
45
|
+
const output = stream.writable.getWriter();
|
|
28
46
|
const connection = app.connect({
|
|
29
|
-
writable:
|
|
47
|
+
writable: new WritableStream({
|
|
48
|
+
write(message) {
|
|
49
|
+
const sent = message;
|
|
50
|
+
if (sent.id !== undefined) {
|
|
51
|
+
if (sent.method === undefined)
|
|
52
|
+
asked.delete(sent.id);
|
|
53
|
+
else
|
|
54
|
+
owed.add(sent.id);
|
|
55
|
+
watch();
|
|
56
|
+
}
|
|
57
|
+
return output.write(message);
|
|
58
|
+
},
|
|
59
|
+
close: () => output.close(),
|
|
60
|
+
abort: (reason) => output.abort(reason),
|
|
61
|
+
}),
|
|
30
62
|
readable: stream.readable.pipeThrough(new TransformStream({
|
|
31
63
|
transform(message, controller) {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
64
|
+
const read = message;
|
|
65
|
+
if (read.id !== undefined) {
|
|
66
|
+
if (read.method === undefined)
|
|
67
|
+
owed.delete(read.id);
|
|
68
|
+
else
|
|
69
|
+
asked.add(read.id);
|
|
70
|
+
}
|
|
71
|
+
watch();
|
|
72
|
+
if (owned)
|
|
73
|
+
events(read);
|
|
74
|
+
if (read.id !== undefined || (read.method !== 'session/update' && !read.method.startsWith('_'))) {
|
|
37
75
|
controller.enqueue(message);
|
|
38
|
-
|
|
39
|
-
controller.enqueue({ jsonrpc: '2.0', method: TURN_STARTED });
|
|
40
|
-
if (CLIS[kind].turnEnded(notice))
|
|
41
|
-
controller.enqueue({ jsonrpc: '2.0', method: TURN_ENDED });
|
|
76
|
+
}
|
|
42
77
|
},
|
|
43
78
|
})),
|
|
44
79
|
});
|
|
45
|
-
|
|
80
|
+
const { promise: lost, resolve: lose } = Promise.withResolvers();
|
|
81
|
+
const exited = new Promise((resolve) => {
|
|
82
|
+
const end = (cause) => {
|
|
83
|
+
over = true;
|
|
84
|
+
silence.stop();
|
|
85
|
+
if (owned)
|
|
86
|
+
lose(cause);
|
|
87
|
+
owned = false;
|
|
88
|
+
connection.close(new Error(cause));
|
|
89
|
+
resolve(cause);
|
|
90
|
+
};
|
|
91
|
+
child.on('error', (error) => end(`the CLI did not start: ${error.message}`));
|
|
92
|
+
child.on('exit', (code, signal) => {
|
|
93
|
+
const last = stderr.trim().split('\n').at(-1);
|
|
94
|
+
end(silent ? SILENT : `the CLI exited with ${code ?? signal}${last ? `: ${last}` : ''}`);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
const retire = () => {
|
|
98
|
+
owned = false;
|
|
99
|
+
over = true;
|
|
100
|
+
silence.stop();
|
|
101
|
+
if (retired)
|
|
102
|
+
return;
|
|
103
|
+
retired = true;
|
|
104
|
+
if (child.pid !== undefined)
|
|
105
|
+
killTree(child);
|
|
106
|
+
scope?.kill();
|
|
107
|
+
connection.close(new Error(RETIRED));
|
|
108
|
+
};
|
|
109
|
+
signal?.addEventListener('abort', retire, { once: true });
|
|
110
|
+
child.on('exit', () => signal?.removeEventListener('abort', retire));
|
|
46
111
|
try {
|
|
47
112
|
const initialized = await connection.agent.request('initialize', {
|
|
48
113
|
protocolVersion: PROTOCOL_VERSION,
|
|
@@ -50,91 +115,20 @@ export async function startAdapter(kind, cli, cwd, app, jobs = () => undefined,
|
|
|
50
115
|
fs: { readTextFile: false, writeTextFile: false },
|
|
51
116
|
terminal: false,
|
|
52
117
|
elicitation: { form: {} },
|
|
53
|
-
|
|
118
|
+
session: { compaction: {}, notices: {} },
|
|
119
|
+
_meta: { jetbrains: { air: { version: 1, capabilities: CLIS[kind].air } } },
|
|
54
120
|
},
|
|
55
|
-
clientInfo: { name: '@agentshouse/kit', version:
|
|
121
|
+
clientInfo: { name: '@agentshouse/kit', version: KIT_RELEASE },
|
|
56
122
|
});
|
|
57
|
-
|
|
123
|
+
scope?.entered(child.pid);
|
|
124
|
+
const turn = (opened) => {
|
|
125
|
+
open = opened;
|
|
126
|
+
watch();
|
|
127
|
+
};
|
|
128
|
+
return { connection, initialized, exited, lost, silent: () => silent, turn, retire };
|
|
58
129
|
}
|
|
59
130
|
catch (error) {
|
|
60
|
-
|
|
131
|
+
retire();
|
|
61
132
|
throw error;
|
|
62
133
|
}
|
|
63
134
|
}
|
|
64
|
-
const LISTING_BYTES = 1 << 28;
|
|
65
|
-
function listed(options) {
|
|
66
|
-
return execFileSync('ps', [options, '-o', 'pid=,ppid=,command='], { encoding: 'utf8', maxBuffer: LISTING_BYTES })
|
|
67
|
-
.split('\n')
|
|
68
|
-
.flatMap((line) => {
|
|
69
|
-
const fields = /^\s*(\d+)\s+(\d+)\s?(.*)$/.exec(line);
|
|
70
|
-
return fields === null ? [] : [[Number(fields[1]), Number(fields[2]), fields[3]]];
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
function parents() {
|
|
74
|
-
const children = new Map();
|
|
75
|
-
const adopt = (pid, parent) => children.set(parent, [...(children.get(parent) ?? []), pid]);
|
|
76
|
-
if (process.platform === 'darwin') {
|
|
77
|
-
for (const [pid, parent] of listed('-Aww'))
|
|
78
|
-
adopt(pid, parent);
|
|
79
|
-
return children;
|
|
80
|
-
}
|
|
81
|
-
for (const entry of readdirSync('/proc')) {
|
|
82
|
-
if (!/^\d+$/.test(entry))
|
|
83
|
-
continue;
|
|
84
|
-
try {
|
|
85
|
-
const stat = readFileSync(`/proc/${entry}/stat`, 'utf8');
|
|
86
|
-
adopt(Number(entry), Number(stat.slice(stat.lastIndexOf(')') + 2).split(' ')[1]));
|
|
87
|
-
}
|
|
88
|
-
catch { }
|
|
89
|
-
}
|
|
90
|
-
return children;
|
|
91
|
-
}
|
|
92
|
-
function descendants(roots) {
|
|
93
|
-
const children = parents();
|
|
94
|
-
const tree = [];
|
|
95
|
-
const pending = roots.flatMap((root) => children.get(root) ?? []);
|
|
96
|
-
while (pending.length > 0) {
|
|
97
|
-
const pid = pending.pop();
|
|
98
|
-
tree.push(pid);
|
|
99
|
-
pending.push(...(children.get(pid) ?? []));
|
|
100
|
-
}
|
|
101
|
-
return tree;
|
|
102
|
-
}
|
|
103
|
-
function killAll(pids) {
|
|
104
|
-
for (const pid of pids) {
|
|
105
|
-
for (const target of [-pid, pid]) {
|
|
106
|
-
try {
|
|
107
|
-
process.kill(target, 'SIGKILL');
|
|
108
|
-
}
|
|
109
|
-
catch { }
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
function marked(marker) {
|
|
114
|
-
if (process.platform === 'darwin') {
|
|
115
|
-
return listed('-AEww')
|
|
116
|
-
.filter(([, , command]) => ` ${command} `.includes(` ${marker} `))
|
|
117
|
-
.map(([pid]) => pid);
|
|
118
|
-
}
|
|
119
|
-
return readdirSync('/proc')
|
|
120
|
-
.filter((entry) => {
|
|
121
|
-
try {
|
|
122
|
-
return /^\d+$/.test(entry) && readFileSync(`/proc/${entry}/environ`, 'utf8').split('\0').includes(marker);
|
|
123
|
-
}
|
|
124
|
-
catch {
|
|
125
|
-
return false;
|
|
126
|
-
}
|
|
127
|
-
})
|
|
128
|
-
.map(Number);
|
|
129
|
-
}
|
|
130
|
-
export function killTree(child) {
|
|
131
|
-
killAll([child.pid, ...descendants([child.pid])]);
|
|
132
|
-
}
|
|
133
|
-
export function killMarked(marker) {
|
|
134
|
-
const pids = marked(marker);
|
|
135
|
-
killAll([...pids, ...descendants(pids)]);
|
|
136
|
-
}
|
|
137
|
-
export function killDescendants() {
|
|
138
|
-
const pids = marked(`HOUSE_KIT_RESIDENT=${process.pid}`);
|
|
139
|
-
killAll([...pids, ...descendants([process.pid, ...pids])]);
|
|
140
|
-
}
|