@agentshouse/kit 0.2.1-alpha.11 → 0.2.1-alpha.13

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 CHANGED
@@ -8,10 +8,15 @@ through the agent CLIs you chose and gives each Agent the `house` command.
8
8
 
9
9
  Connect a computer from agents.house. It gives you the one command that
10
10
  installs House Kit on that computer and updates it when you run it again. On
11
- Linux, macOS and Windows 11 it runs House Kit in one Docker container with
12
- your workspace, `~/AgentsHouse` unless you pass `--workspace <path>`, mounted
13
- at `/agents/house`. Append a `kit` or `house` command to the same command to
14
- run it in that container.
11
+ macOS and Linux it installs House Kit natively under your own account, without
12
+ an admin password, as a service that runs while you are logged in. `kit` and
13
+ `house` are then on your login shell's `PATH`, and your workspace is
14
+ `~/AgentsHouse` unless you pass `--workspace <path>`.
15
+
16
+ Add `--container` to run House Kit in one Docker container instead, with your
17
+ workspace mounted at `/agents/house`; your Agents then reach only that
18
+ workspace. On Windows 11 the container is the one choice. Append a `kit` or
19
+ `house` command to the container's command to run it in that container.
15
20
 
16
21
  On your own Ubuntu 26.04 server, run the Linux command with `--linux` to
17
22
  install House Kit natively, with its workspace at `/agents/house`; `kit` and
@@ -29,10 +34,10 @@ set. Pass `--manual` to paste the code by hand on a machine without a browser,
29
34
  and `--environment <id>` to reconnect an Environment you already have.
30
35
 
31
36
  `kit resident` keeps the Environment connected, and keeps the Rooms you chose
32
- for this Environment as Git repositories under `/agents/house/working-copies`.
33
- Commit in one and run `house git push --owner` there to send the commit to
34
- House; on a computer, run it through the install command from the copy's
35
- directory. Inside an Agent conversation the Agent runs `house git push`.
37
+ for this Environment as Git repositories under `working-copies` in the
38
+ workspace. Commit in one and run `house git push --owner` there to send the
39
+ commit to House; in the container, run it through the install command from the
40
+ copy's directory. Inside an Agent conversation the Agent runs `house git push`.
36
41
 
37
42
  ## License
38
43
 
package/dist/acp.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ndJsonStream, PROTOCOL_VERSION, } from '@agentclientprotocol/sdk';
2
- import { spawn } from 'node:child_process';
2
+ import { execFileSync, spawn } from 'node:child_process';
3
3
  import { readdirSync, readFileSync } from 'node:fs';
4
4
  import { Readable, Writable } from 'node:stream';
5
5
  import { CLIS, KIT_VERSION, cliCommand, withoutProxy } from './clis.js';
@@ -60,15 +60,29 @@ export async function startAdapter(kind, cwd, app, jobs = () => undefined, added
60
60
  throw error;
61
61
  }
62
62
  }
63
+ const LISTING_BYTES = 1 << 28;
64
+ function listed(options) {
65
+ return execFileSync('ps', [options, '-o', 'pid=,ppid=,command='], { encoding: 'utf8', maxBuffer: LISTING_BYTES })
66
+ .split('\n')
67
+ .flatMap((line) => {
68
+ const fields = /^\s*(\d+)\s+(\d+)\s?(.*)$/.exec(line);
69
+ return fields === null ? [] : [[Number(fields[1]), Number(fields[2]), fields[3]]];
70
+ });
71
+ }
63
72
  function parents() {
64
73
  const children = new Map();
74
+ const adopt = (pid, parent) => children.set(parent, [...(children.get(parent) ?? []), pid]);
75
+ if (process.platform === 'darwin') {
76
+ for (const [pid, parent] of listed('-Aww'))
77
+ adopt(pid, parent);
78
+ return children;
79
+ }
65
80
  for (const entry of readdirSync('/proc')) {
66
81
  if (!/^\d+$/.test(entry))
67
82
  continue;
68
83
  try {
69
84
  const stat = readFileSync(`/proc/${entry}/stat`, 'utf8');
70
- const parent = Number(stat.slice(stat.lastIndexOf(')') + 2).split(' ')[1]);
71
- children.set(parent, [...(children.get(parent) ?? []), Number(entry)]);
85
+ adopt(Number(entry), Number(stat.slice(stat.lastIndexOf(')') + 2).split(' ')[1]));
72
86
  }
73
87
  catch { }
74
88
  }
@@ -96,6 +110,11 @@ function killAll(pids) {
96
110
  }
97
111
  }
98
112
  function marked(marker) {
113
+ if (process.platform === 'darwin') {
114
+ return listed('-AEww')
115
+ .filter(([, , command]) => ` ${command} `.includes(` ${marker} `))
116
+ .map(([pid]) => pid);
117
+ }
99
118
  return readdirSync('/proc')
100
119
  .filter((entry) => {
101
120
  try {
package/dist/agents.js CHANGED
@@ -1,21 +1,64 @@
1
1
  import { client } from '@agentclientprotocol/sdk';
2
2
  import { readFile } from 'node:fs/promises';
3
- import { startAdapter } from './acp.js';
3
+ import { killTree, startAdapter } from './acp.js';
4
4
  import { CLIS, KIT_VERSION, cliCommand, install, run } from './clis.js';
5
- import { kitHome } from './home.js';
6
- async function signedIn(kind) {
7
- const probe = CLIS[kind].signedIn;
8
- if ('command' in probe) {
9
- return (await run(cliCommand(kind), probe.command, 30_000)).status === 0;
5
+ import { agentBase, kitHome } from './home.js';
6
+ const SIGNED_OUT = { signed_in: false, models: [] };
7
+ function select(options, category) {
8
+ const option = options.find((candidate) => candidate.category === category);
9
+ return option?.type === 'select' ? option : undefined;
10
+ }
11
+ function values(options) {
12
+ return options.flatMap((entry) => ('group' in entry ? entry.options : [entry])).map((entry) => entry.value);
13
+ }
14
+ function causeOf(error) {
15
+ return error instanceof Error ? error.message : String(error);
16
+ }
17
+ async function models(kind, adapter, known) {
18
+ const agent = adapter.connection.agent;
19
+ const opened = await agent.request('session/new', { cwd: kitHome(), mcpServers: [] });
20
+ let options = opened.configOptions ?? [];
21
+ const model = select(options, 'model');
22
+ if (model === undefined)
23
+ return [];
24
+ const offered = [];
25
+ for (const value of values(model.options)) {
26
+ if (select(options, 'model')?.currentValue !== value) {
27
+ try {
28
+ options = (await agent.request('session/set_config_option', { sessionId: opened.sessionId, configId: model.id, value })).configOptions;
29
+ }
30
+ catch (error) {
31
+ process.stderr.write(`kit: ${kind} refused its model ${value}: ${causeOf(error)}\n`);
32
+ offered.push({ model: value, efforts: known.find((entry) => entry.model === value)?.efforts ?? [] });
33
+ continue;
34
+ }
35
+ }
36
+ const effort = select(options, 'thought_level');
37
+ offered.push({ model: value, efforts: effort === undefined ? [] : values(effort.options) });
10
38
  }
39
+ return offered;
40
+ }
41
+ async function offer(kind, known) {
42
+ const probe = CLIS[kind].signedIn;
43
+ if ('command' in probe && (await run(cliCommand(kind), probe.command, 30_000)).status !== 0)
44
+ return SIGNED_OUT;
45
+ let adapter;
11
46
  try {
12
- const adapter = await startAdapter(kind, kitHome(), client({ name: '@agentshouse/kit' }));
13
- adapter.child.kill('SIGKILL');
14
- const method = adapter.initialized._meta?.[probe.initializeMeta];
15
- return typeof method === 'string' && method.length > 0;
47
+ adapter = await startAdapter(kind, kitHome(), client({ name: '@agentshouse/kit' }));
48
+ if ('initializeMeta' in probe) {
49
+ const method = adapter.initialized._meta?.[probe.initializeMeta];
50
+ if (typeof method !== 'string' || method.length === 0)
51
+ return SIGNED_OUT;
52
+ }
53
+ return { signed_in: true, models: await models(kind, adapter, known.models) };
54
+ }
55
+ catch (error) {
56
+ process.stderr.write(`kit: ${kind} did not offer its models: ${causeOf(error)}\n`);
57
+ return adapter === undefined && 'initializeMeta' in probe ? known : { signed_in: true, models: known.models };
16
58
  }
17
- catch {
18
- return false;
59
+ finally {
60
+ if (adapter !== undefined)
61
+ killTree(adapter.child);
19
62
  }
20
63
  }
21
64
  async function sshHostKey() {
@@ -23,6 +66,8 @@ async function sshHostKey() {
23
66
  return listed.status === 0 ? (/^\d+ (SHA256:\S+)/.exec(listed.output)?.[1] ?? null) : null;
24
67
  }
25
68
  async function operatingSystem() {
69
+ if (process.platform === 'darwin')
70
+ return `macOS ${(await run('sw_vers', ['-productVersion'], 10_000)).output.trim()}`;
26
71
  const release = await readFile('/etc/os-release', 'utf8');
27
72
  return /^PRETTY_NAME="?([^"\n]*)"?$/m.exec(release)?.[1] ?? release;
28
73
  }
@@ -31,9 +76,12 @@ export class Agents {
31
76
  house;
32
77
  reading = Promise.resolve();
33
78
  installing = Promise.resolve();
34
- releases = new Map();
79
+ installs = new Map();
80
+ offers = new Map();
35
81
  reporting = null;
36
82
  again = false;
83
+ sending = Promise.resolve();
84
+ sent = null;
37
85
  constructor(house) {
38
86
  this.house = house;
39
87
  }
@@ -62,24 +110,37 @@ export class Agents {
62
110
  this.again = true;
63
111
  return Promise.all([installing, this.reporting]).then(() => undefined);
64
112
  }
65
- async report() {
113
+ report() {
114
+ const sending = this.sending.catch(() => undefined).then(() => this.send());
115
+ this.sending = sending;
116
+ return sending;
117
+ }
118
+ async send() {
66
119
  const agents = [];
67
- for (const [kind, release] of this.releases) {
68
- agents.push({ kind, release, signed_in: release !== null && (await signedIn(kind)) });
120
+ for (const [kind, installed] of this.installs) {
121
+ const offered = installed.release === null ? SIGNED_OUT : await offer(kind, this.offers.get(kind) ?? SIGNED_OUT);
122
+ this.offers.set(kind, offered);
123
+ agents.push({ kind, ...installed, ...offered });
69
124
  }
70
125
  const hostKey = await sshHostKey();
71
- await this.house.deliver('/kit/agents/report', {
126
+ const body = {
72
127
  os: await operatingSystem(),
73
128
  kit_version: KIT_VERSION,
129
+ agent_base: agentBase(),
74
130
  agents,
75
131
  ...(hostKey === null ? {} : { ssh_host_key: hostKey }),
76
- });
132
+ };
133
+ const state = JSON.stringify(body);
134
+ if (state === this.sent)
135
+ return;
136
+ await this.house.deliver('/kit/agents/report', body);
137
+ this.sent = state;
77
138
  }
78
139
  async install(kinds) {
79
- const releases = new Map();
140
+ const installs = new Map();
80
141
  for (const kind of kinds)
81
- releases.set(kind, await install(kind));
82
- this.releases = releases;
142
+ installs.set(kind, await install(kind));
143
+ this.installs = installs;
83
144
  }
84
145
  async reports() {
85
146
  try {
@@ -1,23 +1,26 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "version": "0.2.1-alpha.11",
3
+ "version": "0.2.1-alpha.13",
4
4
  "hosts": {
5
5
  "linux": {
6
- "command": "bash <(curl -fsSL https://github.com/agentshouse/kit/releases/download/v0.2.1-alpha.11/connect-linux.sh)",
6
+ "command": "bash <(curl -fsSL https://github.com/agentshouse/kit/releases/download/v0.2.1-alpha.13/connect-linux.sh)",
7
7
  "asset": {
8
8
  "name": "connect-linux.sh",
9
- "url": "https://github.com/agentshouse/kit/releases/download/v0.2.1-alpha.11/connect-linux.sh"
9
+ "url": "https://github.com/agentshouse/kit/releases/download/v0.2.1-alpha.13/connect-linux.sh"
10
10
  },
11
11
  "workspace": {
12
12
  "argument": "--workspace",
13
13
  "quoting": "posix"
14
+ },
15
+ "container": {
16
+ "argument": "--container"
14
17
  }
15
18
  },
16
19
  "windows": {
17
- "command": "& ([scriptblock]::Create((irm https://github.com/agentshouse/kit/releases/download/v0.2.1-alpha.11/connect-windows.ps1)))",
20
+ "command": "& ([scriptblock]::Create((irm https://github.com/agentshouse/kit/releases/download/v0.2.1-alpha.13/connect-windows.ps1)))",
18
21
  "asset": {
19
22
  "name": "connect-windows.ps1",
20
- "url": "https://github.com/agentshouse/kit/releases/download/v0.2.1-alpha.11/connect-windows.ps1"
23
+ "url": "https://github.com/agentshouse/kit/releases/download/v0.2.1-alpha.13/connect-windows.ps1"
21
24
  },
22
25
  "workspace": {
23
26
  "argument": "--workspace",
package/dist/clis.js CHANGED
@@ -115,11 +115,12 @@ export function run(command, args, timeoutMs) {
115
115
  export async function install(kind) {
116
116
  const release = pinned(kind);
117
117
  if ((await installedRelease(kind)) === release)
118
- return release;
118
+ return { release, failure: null };
119
119
  const ran = await run('npm', ['install', '--prefix', prefix(kind), '--no-save', '--no-audit', '--no-fund', `${CLIS[kind].package}@${release}`], 15 * 60_000);
120
120
  if (ran.status !== 0) {
121
- process.stderr.write(`kit: ${kind} did not install: ${ran.output.trim()}\n`);
122
- return null;
121
+ const failure = ran.output.trim() || `npm exited with ${ran.status ?? 'a signal'}`;
122
+ process.stderr.write(`kit: ${kind} did not install: ${failure}\n`);
123
+ return { release: null, failure };
123
124
  }
124
- return installedRelease(kind);
125
+ return { release: await installedRelease(kind), failure: null };
125
126
  }
@@ -7,10 +7,10 @@ import { blocksOf, firstChange } from './blocks.js';
7
7
  import { openBridge } from './bridge.js';
8
8
  import { CLIS } from './clis.js';
9
9
  import { placeFiles } from './files.js';
10
+ import { agentBase } from './home.js';
10
11
  import { instructions } from './instructions.js';
11
12
  import { holdSecretInput } from './secret-input.js';
12
13
  import { createHowWeWork } from './skills.js';
13
- const LAUNCH_BASE = '/agents/house';
14
14
  const KILLED = 'the conversation was killed';
15
15
  function causeOf(error) {
16
16
  return error instanceof Error ? error.message : String(error);
@@ -241,7 +241,7 @@ export class Conversations {
241
241
  const route = this.kit.agents.route(agentId);
242
242
  if (route === undefined)
243
243
  throw new Error(`this Environment hosts no Agent ${agentId}`);
244
- if (route.working_directory === join(LAUNCH_BASE, route.agent_id)) {
244
+ if (route.working_directory === join(agentBase(), route.agent_id)) {
245
245
  await mkdir(route.working_directory, { recursive: true });
246
246
  }
247
247
  return route;
package/dist/copies.js CHANGED
@@ -3,7 +3,7 @@ import { randomUUID } from 'node:crypto';
3
3
  import { mkdir, readFile, readdir, realpath, rename, rm, rmdir, stat, writeFile } from 'node:fs/promises';
4
4
  import { dirname, join } from 'node:path';
5
5
  import { HouseRefusal } from './api.js';
6
- import { blobId, blobText, git, HOUSE_REF, importCommits, revision, run, succeeded, tree, WORKING_COPIES, } from './git.js';
6
+ import { blobId, blobText, git, HOUSE_REF, importCommits, revision, run, succeeded, tree, workingCopies, } from './git.js';
7
7
  import { kitHome } from './home.js';
8
8
  import { operationId } from './operation.js';
9
9
  import { refusalOf } from './refusals.js';
@@ -369,7 +369,7 @@ export class WorkingCopies {
369
369
  logged(`House serves nothing of ${rootOf({ private: scope.private, room_handle: scope.handle })} to copy`);
370
370
  return;
371
371
  }
372
- const repository = scope.private ? join(WORKING_COPIES, 'private') : join(WORKING_COPIES, 'rooms', read.anchor);
372
+ const repository = scope.private ? join(workingCopies(), 'private') : join(workingCopies(), 'rooms', read.anchor);
373
373
  if (await exists(repository)) {
374
374
  logged(`${repository} already exists and House Kit leaves it as it is`);
375
375
  return;
package/dist/git-main.js CHANGED
@@ -4,7 +4,7 @@ import { accessSync, constants, realpathSync, statSync } from 'node:fs';
4
4
  import { request } from 'node:http';
5
5
  import { constants as system } from 'node:os';
6
6
  import { delimiter, dirname, join } from 'node:path';
7
- import { WORKING_COPIES } from './git.js';
7
+ import { workingCopies } from './git.js';
8
8
  import { kitHome } from './home.js';
9
9
  const VALUED = new Set(['-C', '-c', '--git-dir', '--work-tree', '--namespace', '--config-env', '--attr-source', '--super-prefix']);
10
10
  const READS = new Set([
@@ -125,7 +125,7 @@ async function observed(git, args) {
125
125
  return delegated(git, args);
126
126
  const located = captured(git, [...globals, 'rev-parse', '--path-format=absolute', '--git-common-dir', '--show-toplevel']);
127
127
  const [common, worktree] = located?.split('\n') ?? [];
128
- if (common === undefined || worktree === undefined || !dirname(common).startsWith(`${WORKING_COPIES}/`)) {
128
+ if (common === undefined || worktree === undefined || !dirname(common).startsWith(`${workingCopies()}/`)) {
129
129
  return delegated(git, args);
130
130
  }
131
131
  const listing = [...globals, '-C', worktree, 'ls-files', '--stage', '-z'];
package/dist/git.js CHANGED
@@ -1,7 +1,11 @@
1
1
  import { spawn } from 'node:child_process';
2
2
  import { createHash } from 'node:crypto';
3
+ import { join } from 'node:path';
3
4
  import { withoutProxy } from './clis.js';
4
- export const WORKING_COPIES = '/agents/house/working-copies';
5
+ import { agentBase } from './home.js';
6
+ export function workingCopies() {
7
+ return join(agentBase(), 'working-copies');
8
+ }
5
9
  export const HOUSE_REF = 'refs/house/received';
6
10
  const COMMITTER = 'House Kit <house-kit@localhost>';
7
11
  export function run(cwd, args, input, env = {}) {
package/dist/home.js CHANGED
@@ -6,6 +6,9 @@ const CONFIGURATION = 'kit.json';
6
6
  export function kitHome() {
7
7
  return process.env.HOUSE_KIT_HOME ?? join(homedir(), '.house-kit');
8
8
  }
9
+ export function agentBase() {
10
+ return process.env.HOUSE_KIT_WORKSPACE ?? '/agents/house';
11
+ }
9
12
  export async function readHome(name) {
10
13
  try {
11
14
  return JSON.parse(await readFile(join(kitHome(), name), 'utf8'));
package/dist/resident.js CHANGED
@@ -14,6 +14,7 @@ import { SignIns } from './sign-in.js';
14
14
  import { placeSkillSet } from './skills.js';
15
15
  import { holdStream } from './stream.js';
16
16
  import { Updates } from './update.js';
17
+ const AGENTS_REREAD_MS = 60 * 60_000;
17
18
  function report(error) {
18
19
  process.stderr.write(`kit: ${error instanceof Error ? error.message : String(error)}\n`);
19
20
  }
@@ -93,6 +94,7 @@ export async function resident() {
93
94
  await house.deliver('/kit/restarted', {}).catch(report);
94
95
  await updates.resumed().catch(report);
95
96
  logged(agents.refresh());
97
+ setInterval(() => logged(agents.refresh()), AGENTS_REREAD_MS);
96
98
  stream = holdStream({
97
99
  opened: () => {
98
100
  conversations.opened();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentshouse/kit",
3
- "version": "0.2.1-alpha.11",
3
+ "version": "0.2.1-alpha.13",
4
4
  "description": "House Kit connects an Environment to agents.house.",
5
5
  "license": "MIT",
6
6
  "repository": {