@agentshouse/kit 0.2.1-cde47fd72fe59 → 0.2.1-ce0af1aee9a57
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 +28 -29
- package/dist/acp.js +59 -8
- package/dist/afk.js +17 -0
- package/dist/agents.js +59 -33
- package/dist/api.js +5 -5
- package/dist/authority-main.js +3 -3
- package/dist/bridge.js +5 -5
- package/dist/building.js +50 -0
- package/dist/calls.js +71 -0
- package/dist/chunks.js +49 -0
- package/dist/clis.js +47 -45
- package/dist/{stream.js → connection.js} +46 -49
- package/dist/content.js +63 -0
- package/dist/conversations.js +614 -206
- package/dist/copies.js +308 -176
- package/dist/end.js +14 -4
- package/dist/events.js +742 -210
- package/dist/files.js +139 -37
- package/dist/git.js +47 -13
- package/dist/grok.js +39 -0
- package/dist/home.js +0 -7
- package/dist/house-cli.js +97 -89
- package/dist/house-main.js +3 -3
- package/dist/instructions.js +29 -11
- package/dist/kit-cli.js +5 -8
- package/dist/kit-main.js +3 -3
- package/dist/login.js +6 -6
- package/dist/logout.js +1 -1
- package/dist/mcp.js +6 -2
- package/dist/placement.js +21 -20
- package/dist/relay.js +21 -0
- package/dist/resident.js +69 -48
- package/dist/scope.js +15 -4
- package/dist/scripts.js +255 -0
- package/dist/secret-input.js +1 -1
- package/dist/service.js +1 -1
- package/dist/sign-in.js +22 -21
- package/dist/silence.js +28 -0
- package/dist/skills.js +42 -97
- package/dist/transcription.js +88 -45
- package/dist/translate.js +18 -9
- package/dist/update.js +113 -124
- package/dist/wire.js +37 -3
- package/dist/work.js +9 -2
- package/package.json +22 -21
- package/dist/bootstrap.json +0 -24
- package/dist/chatgpt.js +0 -32
- package/dist/clis-main.js +0 -23
- package/dist/inputs.js +0 -37
- package/dist/parts.js +0 -82
- package/how-we-work.md +0 -33
- package/skills/ask-matt/LICENSE +0 -21
- package/skills/ask-matt/PHASE-BOUNDARIES.md +0 -55
- package/skills/ask-matt/SKILL.md +0 -97
- package/skills/ask-matt/agents/openai.yaml +0 -5
- 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 -114
- package/skills/codebase-design/agents/openai.yaml +0 -3
- package/skills/diagnosing-bugs/LICENSE +0 -21
- package/skills/diagnosing-bugs/SKILL.md +0 -138
- 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/GLOSSARY-FORMAT.md +0 -60
- package/skills/domain-modeling/LICENSE +0 -21
- package/skills/domain-modeling/SKILL.md +0 -74
- package/skills/domain-modeling/agents/openai.yaml +0 -3
- package/skills/grill-me/LICENSE +0 -21
- package/skills/grill-me/SKILL.md +0 -7
- package/skills/grill-me/agents/openai.yaml +0 -5
- package/skills/grill-with-docs/LICENSE +0 -21
- package/skills/grill-with-docs/SKILL.md +0 -7
- package/skills/grill-with-docs/agents/openai.yaml +0 -5
- 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 -16
- package/skills/handoff/agents/openai.yaml +0 -5
- package/skills/implement/LICENSE +0 -21
- package/skills/implement/SKILL.md +0 -17
- package/skills/implement/agents/openai.yaml +0 -5
- package/skills/implement-spec/LICENSE +0 -21
- package/skills/implement-spec/SKILL.md +0 -40
- package/skills/implement-spec/agents/openai.yaml +0 -5
- 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 -71
- package/skills/improve-codebase-architecture/agents/openai.yaml +0 -5
- package/skills/pr/CREDITS.md +0 -3
- package/skills/pr/LICENSE +0 -21
- package/skills/pr/SKILL.md +0 -170
- package/skills/pr/agents/openai.yaml +0 -3
- package/skills/prototype/LICENSE +0 -21
- package/skills/prototype/LOGIC.md +0 -67
- package/skills/prototype/SKILL.md +0 -26
- 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 -12
- package/skills/research/agents/openai.yaml +0 -3
- package/skills/retro/LICENSE +0 -21
- package/skills/retro/SKILL.md +0 -44
- package/skills/retro/agents/openai.yaml +0 -5
- package/skills/tdd/LICENSE +0 -21
- package/skills/tdd/SKILL.md +0 -38
- 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 -140
- package/skills/teach/agents/openai.yaml +0 -5
- package/skills/to-questionnaire/LICENSE +0 -21
- package/skills/to-questionnaire/SKILL.md +0 -54
- package/skills/to-questionnaire/agents/openai.yaml +0 -5
- package/skills/to-spec/LICENSE +0 -21
- package/skills/to-spec/SKILL.md +0 -75
- package/skills/to-spec/agents/openai.yaml +0 -5
- package/skills/to-tickets/LICENSE +0 -21
- package/skills/to-tickets/SKILL.md +0 -105
- package/skills/to-tickets/agents/openai.yaml +0 -5
- package/skills/triage/AGENT-BRIEF.md +0 -207
- package/skills/triage/LICENSE +0 -21
- package/skills/triage/OUT-OF-SCOPE.md +0 -105
- package/skills/triage/SKILL.md +0 -112
- package/skills/triage/agents/openai.yaml +0 -5
- package/skills/wait-what/LICENSE +0 -21
- package/skills/wait-what/SKILL.md +0 -7
- package/skills/wait-what/agents/openai.yaml +0 -5
- package/skills/wayfinder/LICENSE +0 -21
- package/skills/wayfinder/SKILL.md +0 -128
- package/skills/wayfinder/agents/openai.yaml +0 -5
- package/skills/wizard/LICENSE +0 -21
- package/skills/wizard/SKILL.md +0 -44
- package/skills/wizard/agents/openai.yaml +0 -3
- package/skills/wizard/template.sh +0 -223
- 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 -81
- package/skills/writing-for-agents/agents/openai.yaml +0 -3
package/dist/instructions.js
CHANGED
|
@@ -1,12 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { agentInstructions } from '@agentshouse/skills';
|
|
2
|
+
const OWNER_RULES = '/rooms/private/owner-rules.md';
|
|
3
|
+
const UNREADABLE = /^(?:\S+: )?(?:path_not_found|room_not_found|operation_denied)\b/;
|
|
4
|
+
const FAILED = /^exit: [1-9]\d*$/;
|
|
5
|
+
const CUT = /^stderr: shell: output_cut (\d+) of \d+ bytes; continue with: (.+)$/;
|
|
6
|
+
function cutOf(lines) {
|
|
7
|
+
const cut = CUT.exec(lines[0] ?? '');
|
|
8
|
+
return cut !== null && Buffer.byteLength(lines.slice(1).join('\n')) === Number(cut[1]) ? cut : null;
|
|
9
|
+
}
|
|
10
|
+
async function readOwnerRules(bridge) {
|
|
11
|
+
let document = '';
|
|
12
|
+
for (let command = `cat ${OWNER_RULES}`; command !== undefined;) {
|
|
13
|
+
const read = await bridge.tool('shell', { command });
|
|
14
|
+
const text = read.content.map((content) => content.text).join('\n');
|
|
15
|
+
const lines = text.split('\n');
|
|
16
|
+
if (read.isError === true || (FAILED.test(lines[0] ?? '') && lines[1]?.startsWith('stderr: '))) {
|
|
17
|
+
const refusal = read.isError === true ? text : lines.slice(1).join('\n').replace(/^stderr: /gm, '');
|
|
18
|
+
if (UNREADABLE.test(refusal))
|
|
19
|
+
return '';
|
|
20
|
+
throw new Error(refusal);
|
|
21
|
+
}
|
|
22
|
+
const cut = cutOf(lines);
|
|
23
|
+
document += lines.slice(cut === null ? 0 : 1).join('\n');
|
|
24
|
+
command = cut?.[2];
|
|
25
|
+
}
|
|
26
|
+
return document;
|
|
27
|
+
}
|
|
28
|
+
export async function instructions(bridge, base) {
|
|
29
|
+
return [agentInstructions().join('\n'), base, (await readOwnerRules(bridge)).replace(/\n$/, '')].filter((part) => part !== '').join('\n\n');
|
|
12
30
|
}
|
package/dist/kit-cli.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { setGlobalProxyFromEnv } from 'node:http';
|
|
2
1
|
import { parseArgs } from 'node:util';
|
|
3
2
|
import { answerGitCredential } from './app-git.js';
|
|
4
|
-
import { chatgpt } from './chatgpt.js';
|
|
5
3
|
import { login } from './login.js';
|
|
6
4
|
import { logout } from './logout.js';
|
|
5
|
+
import { proxyUnlessRelayed } from './relay.js';
|
|
7
6
|
import { resident } from './resident.js';
|
|
8
|
-
const USAGE = 'usage: kit <login|logout|resident
|
|
7
|
+
const USAGE = 'usage: kit <login|logout|resident>\n';
|
|
9
8
|
const COMMANDS = new Map([
|
|
10
9
|
[
|
|
11
10
|
'logout',
|
|
12
11
|
{
|
|
13
12
|
usage: 'usage: kit logout',
|
|
14
|
-
about: "disconnects this computer, stops
|
|
13
|
+
about: "disconnects this computer, stops the Kit process and ends your own agent's connection",
|
|
15
14
|
operands: 0,
|
|
16
15
|
run: logout,
|
|
17
16
|
},
|
|
@@ -20,7 +19,7 @@ const COMMANDS = new Map([
|
|
|
20
19
|
'resident',
|
|
21
20
|
{
|
|
22
21
|
usage: 'usage: kit resident',
|
|
23
|
-
about: "keeps this Environment connected;
|
|
22
|
+
about: "keeps this Environment connected; Kit's service runs it",
|
|
24
23
|
operands: 0,
|
|
25
24
|
run: resident,
|
|
26
25
|
},
|
|
@@ -36,12 +35,10 @@ const COMMANDS = new Map([
|
|
|
36
35
|
],
|
|
37
36
|
]);
|
|
38
37
|
const [command, ...argv] = process.argv.slice(2);
|
|
39
|
-
|
|
38
|
+
proxyUnlessRelayed();
|
|
40
39
|
async function run() {
|
|
41
40
|
if (command === 'login')
|
|
42
41
|
return login(argv);
|
|
43
|
-
if (command === 'chatgpt')
|
|
44
|
-
return chatgpt(argv);
|
|
45
42
|
if (command === '--help') {
|
|
46
43
|
parseArgs({ args: argv });
|
|
47
44
|
process.stdout.write(USAGE);
|
package/dist/kit-main.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const [major = 0, minor = 0] = process.versions.node.split('.').map(Number);
|
|
3
|
-
if (major < 24 || (major === 24 && minor <
|
|
4
|
-
process.stderr.write(`kit: the Kit needs Node 24.
|
|
2
|
+
const [major = 0, minor = 0, patch = 0] = process.versions.node.split('.').map(Number);
|
|
3
|
+
if (major < 24 || (major === 24 && (minor < 22 || (minor === 22 && patch < 1)))) {
|
|
4
|
+
process.stderr.write(`kit: the Kit needs Node 24.22.1 or newer; this is ${process.versions.node}\n`);
|
|
5
5
|
process.exitCode = 1;
|
|
6
6
|
}
|
|
7
7
|
else {
|
package/dist/login.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
2
|
import { createHash, randomBytes } from 'node:crypto';
|
|
3
|
-
import { hostname } from 'node:os';
|
|
4
3
|
import { parseArgs } from 'node:util';
|
|
5
4
|
import { HouseRefusal, post, retrying } from './api.js';
|
|
6
5
|
import { placeAppGit } from './app-git.js';
|
|
@@ -11,7 +10,8 @@ import { refusalOf } from './refusals.js';
|
|
|
11
10
|
import { selectRelay } from './relay.js';
|
|
12
11
|
import { startService } from './service.js';
|
|
13
12
|
import { placeSkillSet } from './skills.js';
|
|
14
|
-
|
|
13
|
+
import { endUnserved } from './wire.js';
|
|
14
|
+
const DEFAULT_HOUSE = 'https://agents.house';
|
|
15
15
|
const OPENER = process.platform === 'darwin' ? 'open' : 'xdg-open';
|
|
16
16
|
// Polling every two seconds brings the User's confirmation to the waiting Kit moments after they give it.
|
|
17
17
|
const POLL_INTERVAL_MS = 2000;
|
|
@@ -20,12 +20,13 @@ function open(link) {
|
|
|
20
20
|
.on('error', () => undefined)
|
|
21
21
|
.unref();
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
async function accepted(house, credential) {
|
|
24
24
|
const checked = await callHouse(house, credential, rpc('tools/list', {}));
|
|
25
25
|
if (checked.status === 200)
|
|
26
26
|
return true;
|
|
27
27
|
if (checked.status === 401)
|
|
28
28
|
return false;
|
|
29
|
+
endUnserved(checked.text);
|
|
29
30
|
throw new Error(`House answered ${checked.status} when Kit checked this computer's own agent's connection: ${checked.text}`);
|
|
30
31
|
}
|
|
31
32
|
const USAGE = `usage: kit login [--house <origin>] [--environment <id>] [--rooms <ref>[,<ref>...] | --no-private]
|
|
@@ -91,13 +92,12 @@ export async function login(argv) {
|
|
|
91
92
|
let named = environment;
|
|
92
93
|
let exchanged;
|
|
93
94
|
if (values.code !== undefined) {
|
|
94
|
-
exchanged = await post(house, '/kit/token', { code: values.code
|
|
95
|
+
exchanged = await post(house, '/kit/token', { code: values.code });
|
|
95
96
|
}
|
|
96
97
|
else {
|
|
97
98
|
held = ownAgent !== null && ownAgent.house === house && (await accepted(house, ownAgent.credential));
|
|
98
99
|
const verifier = randomBytes(32).toString('base64url');
|
|
99
100
|
const start = () => retrying(() => post(house, '/kit', {
|
|
100
|
-
label: hostname(),
|
|
101
101
|
...(named === undefined
|
|
102
102
|
? { act: 'new_environment', ...(replaces === undefined ? {} : { replaces }) }
|
|
103
103
|
: { act: 'existing_environment', environment_id: named }),
|
|
@@ -121,7 +121,7 @@ export async function login(argv) {
|
|
|
121
121
|
open(started.start_url);
|
|
122
122
|
exchanged = await retrying(() => post(house, '/kit/token', { login: started.login, code_verifier: verifier }), undefined, () => POLL_INTERVAL_MS);
|
|
123
123
|
}
|
|
124
|
-
await placeSkillSet();
|
|
124
|
+
await placeSkillSet(house);
|
|
125
125
|
await writeCodexRule().catch((error) => process.stderr.write(`kit: ${error.message}\n`));
|
|
126
126
|
const relayRecord = relay === undefined ? {} : { relay };
|
|
127
127
|
await writeEnrolment({
|
package/dist/logout.js
CHANGED
|
@@ -4,7 +4,7 @@ export async function logout() {
|
|
|
4
4
|
const enrolled = await readEnrolment();
|
|
5
5
|
if (enrolled !== null) {
|
|
6
6
|
try {
|
|
7
|
-
await post(enrolled.house, '/kit/
|
|
7
|
+
await post(enrolled.house, '/kit/kits/log-out', {}, enrolled.credential);
|
|
8
8
|
}
|
|
9
9
|
catch (error) {
|
|
10
10
|
if (!(error instanceof HouseRefusal && error.status === 401))
|
package/dist/mcp.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
|
-
import {
|
|
2
|
+
import { KIT_RELEASE } from './clis.js';
|
|
3
3
|
import { relayed } from './relay.js';
|
|
4
|
+
import { KIT_WIRE, KIT_WIRE_HEADER } from './wire.js';
|
|
4
5
|
const MCP_PROTOCOL_VERSION = '2026-07-28';
|
|
5
6
|
export const UNREACHABLE = 'House is unreachable; call again in a minute';
|
|
7
|
+
export class Unsettled extends Error {
|
|
8
|
+
}
|
|
6
9
|
export function rpc(method, params) {
|
|
7
10
|
return { jsonrpc: '2.0', id: randomUUID(), method, params };
|
|
8
11
|
}
|
|
@@ -13,7 +16,7 @@ export function mcpBody(message, operation) {
|
|
|
13
16
|
...message.params,
|
|
14
17
|
_meta: {
|
|
15
18
|
'io.modelcontextprotocol/protocolVersion': MCP_PROTOCOL_VERSION,
|
|
16
|
-
'io.modelcontextprotocol/clientInfo': { name: '@agentshouse/kit', version:
|
|
19
|
+
'io.modelcontextprotocol/clientInfo': { name: '@agentshouse/kit', version: KIT_RELEASE },
|
|
17
20
|
'io.modelcontextprotocol/clientCapabilities': {},
|
|
18
21
|
...(operation === null ? {} : { 'agents.house/agent-operation': operation }),
|
|
19
22
|
},
|
|
@@ -31,6 +34,7 @@ export async function callHouse(origin, credential, message, operation = null, s
|
|
|
31
34
|
'mcp-protocol-version': MCP_PROTOCOL_VERSION,
|
|
32
35
|
'mcp-method': message.method,
|
|
33
36
|
...(tool === null ? {} : { 'mcp-name': tool }),
|
|
37
|
+
[KIT_WIRE_HEADER]: String(KIT_WIRE),
|
|
34
38
|
},
|
|
35
39
|
body: mcpBody(message, operation),
|
|
36
40
|
signal,
|
package/dist/placement.js
CHANGED
|
@@ -1,26 +1,9 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
import { run } from './clis.js';
|
|
2
|
+
import { join, resolve } from 'node:path';
|
|
4
3
|
import { kitHome } from './home.js';
|
|
5
|
-
|
|
6
|
-
if (process.platform !== 'linux' || !process.env.INVOCATION_ID)
|
|
7
|
-
return null;
|
|
8
|
-
return process.env.MANAGERPID ? 'user' : 'system';
|
|
9
|
-
}
|
|
10
|
-
export function throughSudo() {
|
|
11
|
-
return service() === 'system' && process.getuid() !== 0;
|
|
12
|
-
}
|
|
13
|
-
export async function updatesItself() {
|
|
14
|
-
if (service() === null)
|
|
15
|
-
return false;
|
|
16
|
-
if (!throughSudo())
|
|
17
|
-
return true;
|
|
18
|
-
// sudo answers at once, so ten seconds only bounds a stuck sudo.
|
|
19
|
-
return (await run('sudo', ['-n', 'true'], 10_000)).status === 0;
|
|
20
|
-
}
|
|
21
|
-
export function installCommand() {
|
|
4
|
+
function recorded(name) {
|
|
22
5
|
try {
|
|
23
|
-
return readFileSync(join(kitHome(),
|
|
6
|
+
return readFileSync(join(kitHome(), name), 'utf8').trim();
|
|
24
7
|
}
|
|
25
8
|
catch (error) {
|
|
26
9
|
if (error.code === 'ENOENT')
|
|
@@ -28,3 +11,21 @@ export function installCommand() {
|
|
|
28
11
|
throw error;
|
|
29
12
|
}
|
|
30
13
|
}
|
|
14
|
+
export function installCommand() {
|
|
15
|
+
return recorded('install-command');
|
|
16
|
+
}
|
|
17
|
+
export function machine() {
|
|
18
|
+
const placed = recorded('placement');
|
|
19
|
+
if (placed === 'container' || placed === 'server' || placed === 'windows')
|
|
20
|
+
return placed;
|
|
21
|
+
return process.platform === 'darwin' ? 'macos' : 'linux';
|
|
22
|
+
}
|
|
23
|
+
export function placedPrefix() {
|
|
24
|
+
const prefix = process.env.HOUSE_KIT_PREFIX;
|
|
25
|
+
if (prefix === undefined || prefix === '')
|
|
26
|
+
throw new Error('this Kit process was not started by a launcher its installer placed');
|
|
27
|
+
return resolve(prefix);
|
|
28
|
+
}
|
|
29
|
+
export function releaseDirectory(release) {
|
|
30
|
+
return join(placedPrefix(), 'releases', release);
|
|
31
|
+
}
|
package/dist/relay.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
import { setGlobalProxyFromEnv } from 'node:http';
|
|
2
|
+
const PROXY = /^https?_proxy$/i;
|
|
3
|
+
const LOOPBACK = ['127.0.0.1', 'localhost', '::1'];
|
|
1
4
|
let selected;
|
|
5
|
+
let restoreProxy;
|
|
2
6
|
export function selectRelay(relay) {
|
|
3
7
|
selected = relay === undefined || relay === '' ? null : relay;
|
|
8
|
+
proxyUnlessRelayed();
|
|
4
9
|
}
|
|
5
10
|
export function relayOrigin() {
|
|
6
11
|
if (selected !== undefined)
|
|
@@ -8,6 +13,22 @@ export function relayOrigin() {
|
|
|
8
13
|
const ambient = process.env.HOUSE_KIT_RELAY;
|
|
9
14
|
return ambient === undefined || ambient === '' ? undefined : ambient;
|
|
10
15
|
}
|
|
16
|
+
function unlessRelayed() {
|
|
17
|
+
if (relayOrigin() === undefined)
|
|
18
|
+
return { ...process.env };
|
|
19
|
+
return Object.fromEntries(Object.entries(process.env).filter(([name]) => !PROXY.test(name)));
|
|
20
|
+
}
|
|
21
|
+
export function proxyUnlessRelayed() {
|
|
22
|
+
restoreProxy?.();
|
|
23
|
+
restoreProxy = setGlobalProxyFromEnv(unlessRelayed());
|
|
24
|
+
}
|
|
25
|
+
export function childEnvironment() {
|
|
26
|
+
const environment = unlessRelayed();
|
|
27
|
+
if (!Object.keys(environment).some((name) => PROXY.test(name)))
|
|
28
|
+
return environment;
|
|
29
|
+
const bypassed = [environment.NO_PROXY ?? environment.no_proxy, ...LOOPBACK].filter((entry) => entry !== undefined && entry !== '').join(',');
|
|
30
|
+
return { ...environment, NO_PROXY: bypassed, no_proxy: bypassed };
|
|
31
|
+
}
|
|
11
32
|
export function relayed(target) {
|
|
12
33
|
const url = new URL(target);
|
|
13
34
|
const relay = relayOrigin();
|
package/dist/resident.js
CHANGED
|
@@ -8,17 +8,19 @@ import { fileURLToPath } from 'node:url';
|
|
|
8
8
|
import { Agents } from './agents.js';
|
|
9
9
|
import { house } from './api.js';
|
|
10
10
|
import { received } from './bridge.js';
|
|
11
|
-
import {
|
|
11
|
+
import { CONVERSATION_METHODS, Conversations } from './conversations.js';
|
|
12
12
|
import { LocalCopies } from './copies.js';
|
|
13
|
-
import { restart } from './end.js';
|
|
14
|
-
import { agentBase, enrolled,
|
|
15
|
-
import {
|
|
13
|
+
import { restart, unknownMethod } from './end.js';
|
|
14
|
+
import { agentBase, enrolled, kitHome, ownerLock, ownerSocket, readEnrolment } from './home.js';
|
|
15
|
+
import { Calls } from './calls.js';
|
|
16
16
|
import { killDescendants } from './scope.js';
|
|
17
|
+
import { removeInputs, Scripts } from './scripts.js';
|
|
17
18
|
import { quoted } from './shell.js';
|
|
18
19
|
import { SignIns } from './sign-in.js';
|
|
19
20
|
import { placeSkillSet } from './skills.js';
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
21
|
+
import { holdConnection } from './connection.js';
|
|
22
|
+
import { KitUpdate } from './update.js';
|
|
23
|
+
import { takeUnservedRelease } from './wire.js';
|
|
22
24
|
import { codexLauncher } from './work.js';
|
|
23
25
|
function report(error) {
|
|
24
26
|
process.stderr.write(`kit: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
@@ -47,7 +49,7 @@ async function serveOwner(copies) {
|
|
|
47
49
|
if (!claimed(lock)) {
|
|
48
50
|
lock.close();
|
|
49
51
|
const running = await runningResident();
|
|
50
|
-
throw new Error(`${running === null ? 'another Kit' : `Kit ${running}`} already runs this Environment from Kit home ${kitHome()}; stop it first to run another here`);
|
|
52
|
+
throw new Error(`${running === null ? 'another Kit process' : `Kit process ${running}`} already runs this Environment from Kit home ${kitHome()}; stop it first to run another Kit process here`);
|
|
51
53
|
}
|
|
52
54
|
const server = createServer(async (request, response) => {
|
|
53
55
|
try {
|
|
@@ -109,14 +111,7 @@ function connected() {
|
|
|
109
111
|
}
|
|
110
112
|
async function started() {
|
|
111
113
|
await connected();
|
|
112
|
-
await
|
|
113
|
-
watch(kitHome(), () => {
|
|
114
|
-
if (enrolled())
|
|
115
|
-
return;
|
|
116
|
-
killDescendants();
|
|
117
|
-
process.exit(1);
|
|
118
|
-
});
|
|
119
|
-
await placeSkillSet();
|
|
114
|
+
await placeSkillSet((await readEnrolment()).house);
|
|
120
115
|
await mkdir(agentBase(), { recursive: true });
|
|
121
116
|
await installShim(join(kitHome(), 'shim', 'git'), 'git-main');
|
|
122
117
|
await installShim(codexLauncher(), 'codex-main');
|
|
@@ -126,72 +121,98 @@ export async function resident() {
|
|
|
126
121
|
const copies = new LocalCopies(house);
|
|
127
122
|
await copies.load();
|
|
128
123
|
await serveOwner(copies);
|
|
124
|
+
await copies.swept();
|
|
129
125
|
await started().catch((error) => {
|
|
130
126
|
report(error);
|
|
131
127
|
process.exit(1);
|
|
132
128
|
});
|
|
133
129
|
process.env.HOUSE_KIT_RESIDENT = String(process.pid);
|
|
134
130
|
const agents = new Agents(house, () => changed());
|
|
135
|
-
let
|
|
131
|
+
let connection = null;
|
|
136
132
|
let reported = false;
|
|
137
|
-
|
|
133
|
+
let stopping = false;
|
|
134
|
+
const stop = async (then) => {
|
|
135
|
+
if (stopping)
|
|
136
|
+
return;
|
|
137
|
+
stopping = true;
|
|
138
|
+
conversations.stopped();
|
|
139
|
+
killDescendants();
|
|
140
|
+
await connection?.close();
|
|
141
|
+
then();
|
|
142
|
+
};
|
|
143
|
+
const idle = () => calls.idle() && conversations.idle() && agents.idle();
|
|
138
144
|
const changed = () => {
|
|
139
145
|
if (!idle()) {
|
|
140
146
|
reported = false;
|
|
141
147
|
}
|
|
142
|
-
else if (
|
|
143
|
-
|
|
148
|
+
else if (update.placedRelease() !== null && conversations.quiet()) {
|
|
149
|
+
const placed = update.placedRelease();
|
|
150
|
+
void stop(() => restart(`Kit ${placed} is placed; its supervisor starts it`));
|
|
144
151
|
}
|
|
145
152
|
else if (!reported) {
|
|
146
153
|
reported = true;
|
|
147
|
-
logged(house.deliver('/kit/idle', {}, idle));
|
|
154
|
+
logged(house.deliver('/kit/kits/report-idle', {}, idle));
|
|
148
155
|
}
|
|
149
156
|
};
|
|
150
|
-
const
|
|
157
|
+
const calls = new Calls(house, changed);
|
|
151
158
|
const conversations = new Conversations({
|
|
152
159
|
house,
|
|
153
160
|
agents,
|
|
154
161
|
copies,
|
|
155
|
-
|
|
156
|
-
send: (
|
|
162
|
+
calls,
|
|
163
|
+
send: (oneWayCall) => connection?.send(oneWayCall) ?? false,
|
|
157
164
|
changed,
|
|
158
165
|
});
|
|
159
|
-
const signIns = new SignIns(house, agents,
|
|
160
|
-
const
|
|
166
|
+
const signIns = new SignIns(house, agents, calls);
|
|
167
|
+
const update = new KitUpdate(calls);
|
|
168
|
+
if (process.env.HOUSE_KIT_SANDBOX !== '1')
|
|
169
|
+
takeUnservedRelease((release) => logged(update.takeRefused(release)));
|
|
170
|
+
removeInputs();
|
|
171
|
+
const scripts = new Scripts(calls, (oneWayCall) => connection?.send(oneWayCall) ?? false);
|
|
161
172
|
for (const signal of ['SIGTERM', 'SIGINT']) {
|
|
162
173
|
process.once(signal, () => {
|
|
163
|
-
|
|
164
|
-
|
|
174
|
+
void stop(() => {
|
|
175
|
+
removeInputs();
|
|
176
|
+
process.kill(process.pid, signal);
|
|
177
|
+
});
|
|
165
178
|
});
|
|
166
179
|
}
|
|
167
|
-
|
|
168
|
-
|
|
180
|
+
const unenrolled = () => {
|
|
181
|
+
if (!enrolled())
|
|
182
|
+
void stop(() => process.exit(1));
|
|
183
|
+
};
|
|
184
|
+
watch(kitHome(), unenrolled);
|
|
185
|
+
unenrolled();
|
|
186
|
+
await house.deliver('/kit/kits/report-restart', {}).catch(report);
|
|
169
187
|
logged(agents.refresh());
|
|
170
|
-
|
|
188
|
+
agents.keepCurrent(() => process.env.HOUSE_KIT_SANDBOX === '1' && reported);
|
|
189
|
+
connection = holdConnection({
|
|
171
190
|
opened: () => {
|
|
172
191
|
conversations.opened();
|
|
173
192
|
changed();
|
|
174
193
|
logged(copies.connected());
|
|
175
194
|
},
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
conversations.input(arrived);
|
|
190
|
-
else {
|
|
191
|
-
const refused = { refused: `This Kit does not know ${arrived.kind}; update the Kit` };
|
|
192
|
-
void inputs.carry(String(arrived.input_id), async () => ({ ack: refused }));
|
|
193
|
-
}
|
|
195
|
+
closed: () => scripts.disconnected(),
|
|
196
|
+
call: (call) => {
|
|
197
|
+
if (call.kind === 'sign_in')
|
|
198
|
+
signIns.start(call);
|
|
199
|
+
else if (call.kind === 'update')
|
|
200
|
+
update.take(call);
|
|
201
|
+
else if (call.kind === 'run_wizard' || call.kind === 'run_function')
|
|
202
|
+
scripts.start(call);
|
|
203
|
+
else if (CONVERSATION_METHODS.has(call.kind))
|
|
204
|
+
conversations.call(call);
|
|
205
|
+
else {
|
|
206
|
+
const refused = { refused: unknownMethod(call.kind) };
|
|
207
|
+
void calls.carry(call.input_id, async () => ({ result: refused }));
|
|
194
208
|
}
|
|
195
209
|
},
|
|
210
|
+
oneWayCall: (oneWayCall) => {
|
|
211
|
+
if (oneWayCall.type === 'watching')
|
|
212
|
+
conversations.watching(oneWayCall.watching === true);
|
|
213
|
+
if (oneWayCall.type === 'work_available' && oneWayCall.subject === 'agents')
|
|
214
|
+
logged(agents.refresh());
|
|
215
|
+
scripts.notified(oneWayCall);
|
|
216
|
+
},
|
|
196
217
|
});
|
|
197
218
|
}
|
package/dist/scope.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { execFileSync } from 'node:child_process';
|
|
2
|
-
import { mkdirSync, readdirSync, readFileSync, rmdirSync, statSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { mkdirSync, readdirSync, readFileSync, realpathSync, rmdirSync, statSync, writeFileSync } from 'node:fs';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
4
|
const LISTING_BYTES = 1 << 28;
|
|
5
5
|
const CGROUPS = '/sys/fs/cgroup';
|
|
6
6
|
const GONE = new Set(['ENOENT', 'ESRCH']);
|
|
7
|
+
const EXITED = new Set(['Z', 'X']);
|
|
7
8
|
function failure(error) {
|
|
8
9
|
return error.code ?? '';
|
|
9
10
|
}
|
|
@@ -24,6 +25,8 @@ function read(pid) {
|
|
|
24
25
|
try {
|
|
25
26
|
const stat = readFileSync(`/proc/${pid}/stat`, 'utf8');
|
|
26
27
|
const fields = stat.slice(stat.lastIndexOf(')') + 2).split(' ');
|
|
28
|
+
if (EXITED.has(fields[0]))
|
|
29
|
+
return null;
|
|
27
30
|
const command = readFileSync(`/proc/${pid}/cmdline`, 'utf8').replaceAll('\0', ' ');
|
|
28
31
|
return { parent: Number(fields[1]), session: fields[3], command };
|
|
29
32
|
}
|
|
@@ -119,15 +122,23 @@ function members(group) {
|
|
|
119
122
|
}
|
|
120
123
|
return pids;
|
|
121
124
|
}
|
|
125
|
+
function besideCli(cli) {
|
|
126
|
+
try {
|
|
127
|
+
return `${realpathSync(cli)}-`;
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
122
133
|
export class Scope {
|
|
123
134
|
marker;
|
|
124
|
-
|
|
135
|
+
helpers;
|
|
125
136
|
group;
|
|
126
137
|
session = null;
|
|
127
138
|
recorded = null;
|
|
128
139
|
constructor(marker, name, cli) {
|
|
129
140
|
this.marker = marker;
|
|
130
|
-
this.
|
|
141
|
+
this.helpers = besideCli(cli);
|
|
131
142
|
const own = ownGroup();
|
|
132
143
|
this.group = own === null ? null : join(own, name);
|
|
133
144
|
try {
|
|
@@ -165,7 +176,7 @@ export class Scope {
|
|
|
165
176
|
return true;
|
|
166
177
|
if (this.recorded === null)
|
|
167
178
|
return found.size > 0;
|
|
168
|
-
return [...found].some(([pid, { session, command }]) => session !== this.session || !(this.recorded.has(pid) || command.startsWith(
|
|
179
|
+
return [...found].some(([pid, { session, command }]) => session !== this.session || !(this.recorded.has(pid) || (this.helpers !== null && command.startsWith(this.helpers))));
|
|
169
180
|
}
|
|
170
181
|
empty() {
|
|
171
182
|
return this.found()?.size === 0;
|