@agentshouse/kit 0.1.0-alpha.23 → 0.1.0-alpha.25

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
@@ -6,13 +6,33 @@ this repository contains only the package source and its operator documentation.
6
6
 
7
7
  ## Connect a Linux computer
8
8
 
9
- On Linux `amd64` or `arm64` with a working Docker Engine, run the published,
10
- versioned bootstrap once:
9
+ On Linux `amd64` or `arm64`, run the published, versioned bootstrap once:
11
10
 
12
11
  ```sh
13
- bash <(curl -fsSL https://github.com/agentshouse/kit/releases/download/v0.1.0-alpha.23/connect-linux.sh)
12
+ bash <(curl -fsSL https://github.com/agentshouse/kit/releases/download/v0.1.0-alpha.25/connect-linux.sh)
14
13
  ```
15
14
 
15
+ The bootstrap first establishes Docker Engine from what it observes on the
16
+ computer. A Docker Engine that already answers is used as it is, on any
17
+ distribution. On Ubuntu 22.04, 24.04 or 26.04 LTS it follows Docker's
18
+ [apt repository recipe](https://docs.docker.com/engine/install/ubuntu/) for
19
+ whatever is missing: it installs `docker-ce`, `docker-ce-cli`,
20
+ `containerd.io`, `docker-buildx-plugin` and `docker-compose-plugin` from
21
+ `download.docker.com`, starts the `docker` service when it is stopped and adds
22
+ the account to the `docker` group. Every such step runs through `sudo`, which
23
+ asks for the password as it ordinarily does. A new group membership applies
24
+ from the account's next sign-in, so the invocation that grants it reaches
25
+ Docker Engine through `sudo` for the rest of its own run; a later invocation
26
+ from a session older than the membership is refused until the account signs
27
+ out and back in. The bootstrap refuses an Ubuntu computer whose installed
28
+ `docker.io`, `docker-compose`, `docker-compose-v2`, `docker-doc`,
29
+ `docker-buildx`, `podman-docker`, `containerd` or `runc` package conflicts with
30
+ that recipe rather than removing it. Any other distribution needs a working
31
+ Docker Engine supplied by its owner, and without one the bootstrap stops with
32
+ that missing prerequisite. A step that fails names its cause and changes
33
+ nothing further; running the same bootstrap again continues from the state it
34
+ left, including after a restart.
35
+
16
36
  The release asset pins one immutable multi-architecture image digest. It creates
17
37
  owner-protected `~/.house-kit` and `~/AgentsHouse`, mounts those as the complete
18
38
  Kit home and `/agents/house`, enrolls through House Login in the host browser,
@@ -781,7 +801,18 @@ Kit reads what the Session was started for from House's
781
801
  its input, references, requester and the pinned revision's instruction, or the
782
802
  sealed conversation turn. It sends that as the first prompt block, followed by
783
803
  current House guidance fetched through the Run connection, so the Agent calls
784
- nothing to learn it. An unreadable request or guidance refuses the turn. It forwards only adapter-classified User-visible assistant
804
+ nothing to learn it. An unreadable request or guidance refuses the turn.
805
+ A session opened with `session/new` gets one more text block ahead of those,
806
+ the same for every adapter kind: the line
807
+ `The agents.house house CLI is available: run house --help.`, the base
808
+ instructions of the Execution attempt plan House acquired, and the current text
809
+ of the owner's How-we-work document `/private/library/how-we-work.md`, which the
810
+ launcher reads with the `shell` tool over the Session's own bridge, following
811
+ House's cursor to the whole text. An absent document, one the Session's ceiling
812
+ cannot read, and empty base instructions add nothing. Any other failed read
813
+ refuses the attempt as `kit_how_we_work_unreadable` with the bridge's cause
814
+ before a prompt is sent. A session reloaded with `session/load` already holds
815
+ the block and gets none. It forwards only adapter-classified User-visible assistant
785
816
  text back over the local channel, and leaves reasoning, tool traces, and
786
817
  terminal output where they are. The supervised process's own House calls travel
787
818
  that same channel through the `house` CLI. The Kit holds the WorkerRunToken, replaces it in place when
@@ -11,6 +11,10 @@ HOUSE_SELECTED=0
11
11
  FORWARDING=0
12
12
  FORWARDED=kit
13
13
  FORWARD=()
14
+ UBUNTU_RELEASES=(jammy noble resolute)
15
+ DOCKER_PACKAGES=(docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin)
16
+ CONFLICTING_PACKAGES=(docker.io docker-compose docker-compose-v2 docker-doc docker-buildx podman-docker containerd runc)
17
+ DOCKER_GROUP=0
14
18
 
15
19
  refuse() {
16
20
  printf 'kit_bootstrap_refused: %s\n' "$1" >&2
@@ -42,6 +46,94 @@ start_resident() {
42
46
  docker run -d --name "$NAME" --restart unless-stopped --user "$(id -u):$(id -g)" --mount "$KIT_HOME_MOUNT" --mount "$WORKSPACE_MOUNT" --label "agentshouse.house=$HOUSE" --env HOME=/kit-home --env HOUSE_KIT_HOME=/kit-home --env HOUSE_KIT_CONTAINER=1 "$IMAGE" resident >/dev/null
43
47
  }
44
48
 
49
+ docker() {
50
+ if ((DOCKER_GROUP)); then
51
+ sudo -u "$(id -un)" docker "$@"
52
+ else
53
+ command docker "$@"
54
+ fi
55
+ }
56
+
57
+ elevated() {
58
+ if ((EUID == 0)); then
59
+ "$@"
60
+ else
61
+ sudo "$@"
62
+ fi
63
+ }
64
+
65
+ docker_member() {
66
+ [[ " $(id -nG "$@") " == *' docker '* ]]
67
+ }
68
+
69
+ docker_answers() {
70
+ DOCKER_PLATFORM=$(docker info --format '{{.OSType}}/{{.Architecture}}' 2>/dev/null)
71
+ }
72
+
73
+ docker_cause() {
74
+ docker info 2>&1 >/dev/null | tail -n 1
75
+ }
76
+
77
+ unanswered() {
78
+ type -P docker >/dev/null || return 0
79
+ printf '; Docker Engine does not answer: %s' "$(docker_cause)"
80
+ }
81
+
82
+ installed_packages() {
83
+ { dpkg-query -W -f='${db:Status-Status} ${Package}\n' "$@" 2>/dev/null || true; } | awk '$1 == "installed" { print $2 }'
84
+ }
85
+
86
+ install_docker_engine() {
87
+ printf 'Installing Docker Engine from Docker'\''s apt repository for %s; sudo may ask for your password.\n' "$1"
88
+ elevated apt-get update -qq >/dev/null || refuse 'apt could not refresh its package lists'
89
+ elevated apt-get install -y -qq ca-certificates curl >/dev/null || refuse 'apt could not install ca-certificates and curl'
90
+ elevated install -m 0755 -d /etc/apt/keyrings || refuse '/etc/apt/keyrings could not be created'
91
+ elevated curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc || refuse 'the Docker apt repository key could not be downloaded'
92
+ elevated chmod a+r /etc/apt/keyrings/docker.asc || refuse 'the Docker apt repository key could not be made readable'
93
+ printf 'Types: deb\nURIs: https://download.docker.com/linux/ubuntu\nSuites: %s\nComponents: stable\nArchitectures: %s\nSigned-By: /etc/apt/keyrings/docker.asc\n' "$2" "$(dpkg --print-architecture)" \
94
+ | elevated tee /etc/apt/sources.list.d/docker.sources >/dev/null || refuse 'the Docker apt repository could not be configured'
95
+ elevated apt-get update -qq >/dev/null || refuse 'apt could not read the Docker apt repository'
96
+ elevated apt-get install -y -qq "${DOCKER_PACKAGES[@]}" >/dev/null || refuse 'apt could not install Docker Engine'
97
+ }
98
+
99
+ establish_docker_engine() {
100
+ docker_answers && return
101
+ if ((EUID != 0)) && ! docker_member && docker_member "$(id -un)"; then
102
+ refuse "$(id -un) joined the docker group after this session began; sign out and back in, then rerun this bootstrap"
103
+ fi
104
+ local distribution='' release='' described='this Linux distribution' conflicting present
105
+ if [[ -r /etc/os-release ]]; then
106
+ distribution=$(. /etc/os-release && printf '%s' "${ID:-}")
107
+ release=$(. /etc/os-release && printf '%s' "${UBUNTU_CODENAME:-${VERSION_CODENAME:-}}")
108
+ described=$(. /etc/os-release && printf '%s' "${PRETTY_NAME:-$described}")
109
+ fi
110
+ if ((FORWARDING)); then
111
+ type -P docker >/dev/null || refuse 'House Kit is not installed; run this bootstrap without arguments first'
112
+ refuse "Docker Engine does not answer: $(docker_cause)"
113
+ fi
114
+ if [[ "$distribution" != ubuntu ]]; then
115
+ type -P docker >/dev/null || refuse "Docker Engine is not installed on $described; install a working Docker Engine, then rerun this bootstrap"
116
+ refuse "Docker Engine does not answer on $described: $(docker_cause)"
117
+ fi
118
+ [[ " ${UBUNTU_RELEASES[*]} " == *" $release "* ]] || refuse "this bootstrap installs Docker Engine only on Ubuntu 22.04, 24.04 and 26.04 LTS, not $described; install a working Docker Engine, then rerun this bootstrap$(unanswered)"
119
+ conflicting=$(installed_packages "${CONFLICTING_PACKAGES[@]}" | paste -sd ' ' -)
120
+ [[ -z "$conflicting" ]] || refuse "the installed packages $conflicting conflict with Docker Engine; remove them or make their Docker Engine work, then rerun this bootstrap$(unanswered)"
121
+ present=$(installed_packages "${DOCKER_PACKAGES[@]}" | wc -l)
122
+ ((present == ${#DOCKER_PACKAGES[@]})) || install_docker_engine "$described" "$release"
123
+ if ! systemctl is-active --quiet docker.service; then
124
+ printf 'Starting Docker Engine; sudo may ask for your password.\n'
125
+ elevated systemctl start docker.service || refuse 'Docker Engine could not be started'
126
+ fi
127
+ if ((EUID != 0)); then
128
+ if ! docker_member "$(id -un)"; then
129
+ printf 'Adding %s to the docker group; it applies from your next sign-in, so this run reaches Docker Engine through sudo.\n' "$(id -un)"
130
+ elevated usermod -aG docker "$(id -un)" || refuse "$(id -un) could not be added to the docker group"
131
+ fi
132
+ docker_member || DOCKER_GROUP=1
133
+ fi
134
+ docker_answers || refuse "Docker Engine does not answer: $(docker_cause)"
135
+ }
136
+
45
137
  if [[ "${1:-}" == kit || "${1:-}" == house ]]; then
46
138
  FORWARDING=1
47
139
  FORWARDED="$1"
@@ -80,8 +172,7 @@ case "$(uname -m)" in
80
172
  *) refuse "unsupported Linux architecture $(uname -m)" ;;
81
173
  esac
82
174
  [[ "$WORKSPACE" == /* ]] || refuse 'workspace root must be an absolute path'
83
- command -v docker >/dev/null || refuse 'Docker Engine client is unavailable'
84
- DOCKER_PLATFORM=$(docker info --format '{{.OSType}}/{{.Architecture}}' 2>/dev/null) || refuse 'Docker Engine is unavailable'
175
+ establish_docker_engine
85
176
  case "$DOCKER_PLATFORM" in
86
177
  linux/x86_64|linux/amd64) DOCKER_ARCH=amd64 ;;
87
178
  linux/aarch64|linux/arm64) DOCKER_ARCH=arm64 ;;
package/bootstrap.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "version": "0.1.0-alpha.23",
3
+ "version": "0.1.0-alpha.25",
4
4
  "hosts": {
5
5
  "linux": {
6
- "command": "bash <(curl -fsSL https://github.com/agentshouse/kit/releases/download/v0.1.0-alpha.23/connect-linux.sh)",
6
+ "command": "bash <(curl -fsSL https://github.com/agentshouse/kit/releases/download/v0.1.0-alpha.25/connect-linux.sh)",
7
7
  "asset": {
8
8
  "name": "connect-linux.sh",
9
- "url": "https://github.com/agentshouse/kit/releases/download/v0.1.0-alpha.23/connect-linux.sh"
9
+ "url": "https://github.com/agentshouse/kit/releases/download/v0.1.0-alpha.25/connect-linux.sh"
10
10
  },
11
11
  "workspace": {
12
12
  "argument": "--workspace",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentshouse/kit",
3
- "version": "0.1.0-alpha.23",
3
+ "version": "0.1.0-alpha.25",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,5 +1,10 @@
1
- import { COMMAND_ADAPTER_INITIALIZE_TIMEOUT_MS, MCP_PROTOCOL_VERSION } from "./contract.js";
2
- import { bridgeCall } from "./mcp.js";
1
+ import {
2
+ COMMAND_ADAPTER_INITIALIZE_TIMEOUT_MS,
3
+ HOW_WE_WORK_PATH,
4
+ MCP_PROTOCOL_VERSION,
5
+ SHELL_RENDER,
6
+ } from "./contract.js";
7
+ import { answerText, bridgeCall } from "./mcp.js";
3
8
  import { KitRefusal } from "./refusal.js";
4
9
 
5
10
  function readableDiscovery(discovery) {
@@ -29,3 +34,53 @@ export async function commandHouseInstructions(bridge) {
29
34
  }
30
35
  return frame.result.instructions;
31
36
  }
37
+
38
+ function shellAnswer(text) {
39
+ const lines = text.split("\n");
40
+ if (!lines[0].startsWith(`protocol: render=${SHELL_RENDER} `)) return null;
41
+ const exit = Number(lines[2].slice("exit: ".length));
42
+ let at = lines[5]?.startsWith("authority: ") ? 6 : 5;
43
+ if (exit === 0) return { exit, stderr: [], stdout: lines.slice(at).join("\n"), cursor: null };
44
+ const stderr = [];
45
+ while (lines[at]?.startsWith("stderr: ")) stderr.push(lines[at++].slice("stderr: ".length));
46
+ const stdout = lines.slice(at);
47
+ const cursor = stdout.at(-1)?.startsWith("cursor: ") ? stdout.pop().slice("cursor: ".length) : null;
48
+ return { exit, stderr, stdout: stdout.join("\n"), cursor };
49
+ }
50
+
51
+ async function howWeWorkPage(bridge, cursor) {
52
+ const frame = await bridgeCall(bridge, {
53
+ method: "tools/call",
54
+ params: {
55
+ name: "shell",
56
+ arguments: { command: `cat ${HOW_WE_WORK_PATH}`, ...(cursor === null ? {} : { cursor }) },
57
+ },
58
+ });
59
+ if (frame.error !== undefined) {
60
+ throw new KitRefusal("kit_how_we_work_unreadable", frame.error.message ?? null);
61
+ }
62
+ const text = answerText(frame.result);
63
+ if (frame.result?.isError === true) {
64
+ if (text.split(":")[0] === "room_not_found") return null;
65
+ throw new KitRefusal("kit_how_we_work_unreadable", text);
66
+ }
67
+ const page = shellAnswer(text);
68
+ if (page === null) throw new KitRefusal("kit_how_we_work_unreadable", text);
69
+ if (page.cursor === null && page.exit !== 0) {
70
+ if (page.stderr.length === 1 && page.stderr[0].split(" ")[1] === "path_not_found") return null;
71
+ throw new KitRefusal("kit_how_we_work_unreadable", page.stderr.join("\n"));
72
+ }
73
+ return page;
74
+ }
75
+
76
+ export async function commandHouseHowWeWork(bridge) {
77
+ const pages = [];
78
+ let cursor = null;
79
+ do {
80
+ const page = await howWeWorkPage(bridge, cursor);
81
+ if (page === null) return "";
82
+ pages.push(page.stdout);
83
+ cursor = page.cursor;
84
+ } while (cursor !== null);
85
+ return pages.join("\n");
86
+ }
package/src/contract.js CHANGED
@@ -118,6 +118,10 @@ export const BRIDGE_NONCE_ENVIRONMENT = "HOUSE_KIT_BRIDGE_NONCE";
118
118
  export const BRIDGE_RECONNECT_MS = 200;
119
119
  export const BRIDGE_RECONNECT_MAX_MS = 5_000;
120
120
 
121
+ export const HOUSE_CLI_LINE = "The agents.house house CLI is available: run house --help.";
122
+ export const HOW_WE_WORK_PATH = "/private/library/how-we-work.md";
123
+ export const SHELL_RENDER = "shell/1";
124
+
121
125
  export const ACP_PROTOCOL = 1;
122
126
  export const ACP_AUTH_REQUIRED = -32000;
123
127
  export const ADAPTER_EXIT_GRACE_MS = 2_000;
package/src/house.js CHANGED
@@ -855,9 +855,13 @@ function acquiredAssignment(value, declaration) {
855
855
  if (Number.isNaN(Date.parse(expiresAt))) {
856
856
  envelope.refuse(`${declaration}.session.bridge_token_expires_at`);
857
857
  }
858
+ if (typeof plan.base_instructions !== "string") {
859
+ envelope.refuse(`${declaration}.plan.base_instructions`);
860
+ }
858
861
  return {
859
862
  run: envelope.text(acquired.run, `${declaration}.run`, 128),
860
863
  agentId: envelope.text(plan.agent_id, `${declaration}.plan.agent_id`, 128),
864
+ baseInstructions: plan.base_instructions,
861
865
  workingDirectory: envelope.text(
862
866
  plan.working_directory,
863
867
  `${declaration}.plan.working_directory`,
package/src/launcher.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { randomUUID } from "node:crypto";
2
- import { commandHouseInstructions } from "./adapter-mcp.js";
2
+ import { commandHouseHowWeWork, commandHouseInstructions } from "./adapter-mcp.js";
3
3
  import {
4
4
  compiledContract,
5
5
  initializeCommandAdapter,
@@ -7,7 +7,7 @@ import {
7
7
  startCommandAdapter,
8
8
  stopCommandAdapter,
9
9
  } from "./adapter.js";
10
- import { PERMISSION_OPTION_KINDS, SESSION_SET_CONFIG_OPTION } from "./contract.js";
10
+ import { HOUSE_CLI_LINE, PERMISSION_OPTION_KINDS, SESSION_SET_CONFIG_OPTION } from "./contract.js";
11
11
  import { observedAssistantDrafts } from "./draft.js";
12
12
  import { observedPlans } from "./plan.js";
13
13
  import { bridgePeer } from "./peer.js";
@@ -129,6 +129,11 @@ async function configureSession(acp, contract, sessionId, adapter) {
129
129
  }
130
130
  }
131
131
 
132
+ async function sessionOpening(bridge, baseInstructions) {
133
+ const parts = [HOUSE_CLI_LINE, baseInstructions, await commandHouseHowWeWork(bridge)];
134
+ return [{ type: "text", text: parts.filter((part) => part.trim() !== "").join("\n\n") }];
135
+ }
136
+
132
137
  function workingCopyContext(copies) {
133
138
  if (!Array.isArray(copies) || copies.length === 0) return [];
134
139
  const lines = copies.map((copy) => `${copy.path}: ${copy.repository}`);
@@ -179,6 +184,8 @@ async function runTurn(channel, start, bridge, turn) {
179
184
  const { acp } = await initializeCommandAdapter(adapter, contract, handlers);
180
185
  const instructions = await commandHouseInstructions(bridge);
181
186
  let providerSessionId = start.provider_session ?? null;
187
+ const opening =
188
+ providerSessionId === null ? await sessionOpening(bridge, start.base_instructions) : [];
182
189
  const setup = { cwd: start.working_directory, mcpServers: [] };
183
190
  if (providerSessionId === null) {
184
191
  providerSessionId = openedSession(await acp.request("session/new", setup));
@@ -196,6 +203,7 @@ async function runTurn(channel, start, bridge, turn) {
196
203
  const prompted = await acp.request("session/prompt", {
197
204
  sessionId: providerSessionId,
198
205
  prompt: [
206
+ ...opening,
199
207
  { type: "text", text: JSON.stringify(start.request) },
200
208
  { type: "text", text: instructions },
201
209
  ...workingCopyContext(start.working_copies),
package/src/worker.js CHANGED
@@ -575,6 +575,7 @@ async function prepareAssignment(context, assignment, resumed) {
575
575
  };
576
576
  const authority = { token: assignment.session.token, expiresAt: assignment.session.expiresAt };
577
577
  const start = {
578
+ base_instructions: assignment.baseInstructions,
578
579
  working_directory: assignment.workingDirectory,
579
580
  working_copies: await appliedWorkingCopies(context),
580
581
  execution_authority: context.configuration.executionAuthority,