@comput/pi-intercom 0.12.0 → 0.13.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"worker-status.js","sourceRoot":"","sources":["../src/worker-status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAA4B,MAAM,eAAe,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAE9E,MAAM,MAAM,GAA2B;IACrC,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,kBAAkB;IAC9E,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,EAAE,iBAAiB;IAClG,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,wBAAwB,EAAE,OAAO,EAAE,cAAc;CAC9F,CAAC;AACF,MAAM,UAAU,iBAAiB,CAAC,QAA6B,EAAE,SAAiB,EAAE,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE;IAClG,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,SAAS;QAClE,CAAC,eAAe,EAAE,eAAe,EAAE,gBAAgB,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC;QACtE,CAAC,CAAC,CAAC,KAAK,KAAK,gBAAgB,IAAI,OAAO,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAC7G,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAsC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAC5E,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAA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AAE,CAAC,CAAC,CAAC,IAAI;YACzG,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC5F,UAAU,EAAE,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,SAAS,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI;gBAC9F,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAClC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpB,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC;YAAC,OAAO,CAAC,GAAG,EAAE,CAAC;YAAC,MAAM;QAAC,CAAC;IAC3F,CAAC;IACD,IAAI,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM;QAAE,MAAM,CAAC,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IACzF,gGAAgG;IAChG,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,EAAE,GAAG,uBAAuB,CAAC,OAAO,EAAE,QAAQ,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,CAAC;IAClG,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { type Agent } from './config.js';
2
+ export interface WorkerWorkspace {
3
+ worktree: string;
4
+ branch: string;
5
+ }
6
+ /** Compare the loaded contract, not transport ports or optional workflow metadata. */
7
+ export declare function sameResponsibility(a: Agent, b: Agent): boolean;
8
+ /** Read-only Git inspection. No shell, hooks, writes, retries, or inherited Git routing. */
9
+ export declare function validateWorkerWorkspace(root: string, agent: Pick<Agent, 'worktree' | 'branch'>): Promise<WorkerWorkspace>;
@@ -0,0 +1,61 @@
1
+ import { execFile } from 'node:child_process';
2
+ import { realpath, stat } from 'node:fs/promises';
3
+ import path from 'node:path';
4
+ import { promisify } from 'node:util';
5
+ import { fail, requireWorkspace } from './config.js';
6
+ const exec = promisify(execFile);
7
+ const CHECK_TIMEOUT_MS = 3000;
8
+ /** Compare the loaded contract, not transport ports or optional workflow metadata. */
9
+ export function sameResponsibility(a, b) {
10
+ return a.sessionId === b.sessionId && a.coordinator === b.coordinator && a.name === b.name &&
11
+ a.description === b.description && a.projectDirectory === b.projectDirectory &&
12
+ a.worktree === b.worktree && a.branch === b.branch;
13
+ }
14
+ /** Read-only Git inspection. No shell, hooks, writes, retries, or inherited Git routing. */
15
+ export async function validateWorkerWorkspace(root, agent) {
16
+ requireWorkspace(agent);
17
+ const deadline = Date.now() + CHECK_TIMEOUT_MS;
18
+ const env = Object.fromEntries(Object.entries(process.env).filter(([key]) => !key.toUpperCase().startsWith('GIT_')));
19
+ env.GIT_OPTIONAL_LOCKS = '0';
20
+ env.GIT_TERMINAL_PROMPT = '0';
21
+ const git = async (cwd, args) => {
22
+ const timeout = deadline - Date.now();
23
+ if (timeout <= 0)
24
+ fail('worker workspace validation timed out');
25
+ try {
26
+ const result = await exec('git', ['-C', cwd, ...args], { env, timeout, maxBuffer: 16384, windowsHide: true, encoding: 'utf8' });
27
+ return result.stdout.trimEnd();
28
+ }
29
+ catch {
30
+ return fail('worker workspace Git check failed (Git unavailable, invalid repository, detached HEAD, or timeout)');
31
+ }
32
+ };
33
+ let base, worktree;
34
+ try {
35
+ [base, worktree] = await Promise.all([realpath(root), realpath(path.resolve(root, agent.worktree))]);
36
+ if (!(await stat(worktree)).isDirectory())
37
+ fail('worker worktree is not a directory');
38
+ }
39
+ catch {
40
+ return fail('worker worktree directory is missing or inaccessible');
41
+ }
42
+ if (path.relative(base, worktree) === '')
43
+ fail('worker worktree must be separate from the project root');
44
+ const [rootCommon, metadata, ref] = await Promise.all([
45
+ git(base, ['rev-parse', '--path-format=absolute', '--git-common-dir']),
46
+ git(worktree, ['rev-parse', '--path-format=absolute', '--show-toplevel', '--git-common-dir']),
47
+ git(worktree, ['symbolic-ref', '--quiet', 'HEAD']),
48
+ ]);
49
+ const parts = metadata.split(/\r?\n/);
50
+ if (parts.length !== 2)
51
+ fail('invalid worker worktree metadata');
52
+ const [top, common, projectCommon] = await Promise.all([realpath(parts[0]), realpath(parts[1]), realpath(rootCommon)]);
53
+ if (path.relative(top, worktree) !== '')
54
+ fail('worker worktree must be the worktree root, not a subdirectory');
55
+ if (path.relative(common, projectCommon) !== '')
56
+ fail('worker worktree belongs to a different repository');
57
+ if (ref !== `refs/heads/${agent.branch}`)
58
+ fail('worker worktree is not on its configured branch');
59
+ return { worktree, branch: agent.branch };
60
+ }
61
+ //# sourceMappingURL=workspace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace.js","sourceRoot":"","sources":["../src/workspace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAc,MAAM,aAAa,CAAC;AAEjE,MAAM,IAAI,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AACjC,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAG9B,sFAAsF;AACtF,MAAM,UAAU,kBAAkB,CAAC,CAAQ,EAAE,CAAQ;IACnD,OAAO,CAAC,CAAC,SAAS,KAAK,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,WAAW,KAAK,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,I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AAE,MAAM,EAAE,aAAa,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IACvH,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,KAAK,EAAE;QAAE,IAAI,CAAC,+DAA+D,CAAC,CAAC;IAC/G,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,KAAK,EAAE;QAAE,IAAI,CAAC,mDAAmD,CAAC,CAAC;IAC3G,IAAI,GAAG,KAAK,cAAc,KAAK,CAAC,MAAM,EAAE;QAAE,IAAI,CAAC,iDAAiD,CAAC,CAAC;IAClG,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;AAC5C,CAAC"}
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "bugs": {
13
13
  "url": "https://github.com/mbundgaard/pi-intercom/issues"
14
14
  },
15
- "version": "0.12.0",
15
+ "version": "0.13.0",
16
16
  "description": "A coordinator-led workspace for Pi. Delegate to workers with separate contexts, evaluate their reports, and keep the main conversation focused—with the team visible alongside it.",
17
17
  "type": "module",
18
18
  "keywords": [
@@ -27,6 +27,7 @@
27
27
  "src",
28
28
  "dist",
29
29
  "README.md",
30
+ "rules.md",
30
31
  "references/observability.md",
31
32
  "references/releasing.md",
32
33
  "references/herdr-core.md",
@@ -51,7 +52,7 @@
51
52
  "build": "node -e \"require('node:fs').rmSync('dist', {recursive:true, force:true})\" && tsc",
52
53
  "prepack": "npm run build",
53
54
  "typecheck": "tsc --noEmit",
54
- "test": "npm run build && node --test tests/release.test.mjs tests/release-workflow.test.mjs tests/published-release.test.mjs tests/core.test.mjs tests/root-isolation.test.mjs tests/integration.test.mjs tests/launcher.test.mjs tests/linux-launcher.test.mjs tests/core-launcher.test.mjs tests/core-worker-layout.test.mjs tests/herdr-core.test.mjs tests/activity.test.mjs tests/reports.test.mjs tests/worker-status.test.mjs tests/connections.test.mjs tests/handoff.test.mjs tests/pane-close.test.mjs tests/core-pane-close.test.mjs tests/version.test.mjs tests/monitor.test.mjs tests/monitor-view.test.mjs tests/monitor-launcher.test.mjs tests/core-monitor.test.mjs tests/monitor-settings.test.mjs tests/extension.test.mjs tests/runtime-http.test.mjs tests/resume-storage.test.mjs tests/observability.test.mjs tests/snapshot.test.mjs tests/snapshot-security.test.mjs tests/observability-integration.test.mjs",
55
+ "test": "npm run build && node --test tests/release.test.mjs tests/release-workflow.test.mjs tests/published-release.test.mjs tests/core.test.mjs tests/workspace.test.mjs tests/root-isolation.test.mjs tests/integration.test.mjs tests/launcher.test.mjs tests/linux-launcher.test.mjs tests/core-launcher.test.mjs tests/core-worker-layout.test.mjs tests/herdr-core.test.mjs tests/activity.test.mjs tests/reports.test.mjs tests/worker-status.test.mjs tests/connections.test.mjs tests/handoff.test.mjs tests/pane-close.test.mjs tests/core-pane-close.test.mjs tests/version.test.mjs tests/monitor.test.mjs tests/monitor-view.test.mjs tests/monitor-launcher.test.mjs tests/core-monitor.test.mjs tests/monitor-settings.test.mjs tests/extension.test.mjs tests/runtime-http.test.mjs tests/resume-storage.test.mjs tests/observability.test.mjs tests/snapshot.test.mjs tests/snapshot-security.test.mjs tests/observability-integration.test.mjs",
55
56
  "test:host": "node --test tests/pi-cancellation-probe.test.mjs",
56
57
  "test:package": "node --test tests/packaged-monitor.test.mjs",
57
58
  "check:package": "npm run build && npm pack --dry-run --ignore-scripts && npm run test:package"
package/rules.md ADDED
@@ -0,0 +1,30 @@
1
+ # Pi Intercom operating rules
2
+
3
+ These are mandatory operating rules for sessions using Intercom. If an assignment conflicts with them, report the conflict and wait for clarification; do not silently make an exception. Intercom communicates and validates configuration; the agents decide and execute the work. These instructions are not a filesystem or shell sandbox.
4
+
5
+ ## Every session
6
+
7
+ - Start in the project folder. The project folder is the Intercom configuration root, not a worker's editing directory.
8
+ - Responsibility is not a work assignment. Anonymous or unloaded workers wait for configuration, successful reload, and a separate explicit assignment. Do not implement unrelated work from findings.
9
+ - Configuration supplied by the extension is authoritative for identity, responsibility, worktree, and branch. Old conversation messages do not override it.
10
+ - If the extension says a worker is not ready, report the problem and wait for the coordinator to correct and reload the configuration. Do not guess a directory or branch or fall back to the project root.
11
+
12
+ ## Workers
13
+
14
+ - Every worker has a real worktree and branch recorded in its configuration, including investigation-only and documentation workers.
15
+ - Change files only in your configured worktree, on your configured branch. Use absolute worktree paths for file operations and an explicit working directory for project commands (for example, `git -C <worktree> ...`). Your tools still start in the project root. A shell `cd` does not change later tool calls' working directories.
16
+ - Commit your changes to your configured branch, then report the commit to the coordinator. If no files changed, report that rather than inventing a commit.
17
+ - Never push and never modify the main branch.
18
+ - After coordinator-assigned work, file `intercom_report_work` or message the coordinator before ending the turn, then wait. Do not autonomously exit. Keep reports short; put long results in a file in your worktree and reference its path.
19
+ - Progress questions require reporting and continuing the current assignment unless explicitly redirected.
20
+
21
+ ## Coordinator
22
+
23
+ - Manage the main branch. Review workers' commits, merge accepted work into main, and push; this workflow does not require an additional user approval step. This does not authorize unrelated production-system changes.
24
+ - Check worker configuration before assigning work. When the extension lists incomplete entries, establish each worker's actual worktree and branch, write both with `intercom_configure_worker`, then call `intercom_reload_worker`. Do not guess missing values; ask the user if they cannot be established. Do not assign work until configuration is successfully loaded.
25
+ - Configuration writes do not load the worker or assign work. Changes to an existing worker's worktree or branch require an idle worker and a separate successful reload.
26
+ - Worker reports are self-reported claims, not verified completion or approval.
27
+
28
+ ## Lifecycle
29
+
30
+ `stop_worker` remains disabled due to the host cancellation blocker. `close_worker` is a separate supported Linux Herdr background handoff-and-pane-close workflow. Do not self-exit, remove registration, force-kill, or infer completion from job acceptance. A status receipt is not task completion or proof of process termination.
package/src/config.ts CHANGED
@@ -12,6 +12,9 @@ export interface Agent {
12
12
  /** Legacy browser dashboard field, accepted for migration only; removed at coordinator startup. */
13
13
  dashboardPort?: number;
14
14
  projectDirectory: string;
15
+ /** Worker-only. Optional on disk solely so legacy entries can be migrated. */
16
+ worktree?: string;
17
+ branch?: string;
15
18
  handoff?: Handoff;
16
19
  closeJob?: CloseJob;
17
20
  }
@@ -46,6 +49,15 @@ export function text(value: unknown, field: string, max = 4096): asserts value i
46
49
  export function port(value: unknown): asserts value is number {
47
50
  if (!Number.isInteger(value) || Number(value) < 1 || Number(value) > 65535) fail('invalid port');
48
51
  }
52
+ export function workspaceField(value: unknown, field: 'worktree' | 'branch'): asserts value is string {
53
+ text(value, field);
54
+ if (value !== value.trim() || /^none$/i.test(value) || /[\x00-\x1f\x7f]/.test(value)) fail(`invalid ${field}`);
55
+ if (field === 'branch' && value === 'main') fail('workers must not use the main branch');
56
+ }
57
+ export function requireWorkspace(agent: Pick<Agent, 'worktree' | 'branch'>): asserts agent is { worktree: string; branch: string } {
58
+ if (agent.worktree === undefined || agent.branch === undefined) fail('worker requires worktree and branch; reconfigure before reload or resume');
59
+ workspaceField(agent.worktree, 'worktree'); workspaceField(agent.branch, 'branch');
60
+ }
49
61
  export function relativeDirectory(value: unknown): asserts value is string {
50
62
  text(value, 'projectDirectory');
51
63
  if (path.isAbsolute(value) || path.win32.isAbsolute(value) || value.split(/[\\/]/).includes('..')) fail('projectDirectory must be root-relative, without ..');
@@ -61,6 +73,10 @@ export function validateConfig(value: unknown): Config {
61
73
  text(a.sessionId, 'sessionId', 256); text(a.name, 'name', 128); text(a.description, 'description');
62
74
  if (a.name !== a.name.trim() || /[\r\n\x00-\x1f]/.test(a.name)) fail('invalid name');
63
75
  port(a.port); relativeDirectory(a.projectDirectory);
76
+ if (a.coordinator && (a.worktree !== undefined || a.branch !== undefined)) fail('worktree and branch are worker-only');
77
+ // Missing fields are migration state, not defaults. Present fields must be valid.
78
+ if (a.worktree !== undefined) workspaceField(a.worktree, 'worktree');
79
+ if (a.branch !== undefined) workspaceField(a.branch, 'branch');
64
80
  if (a.handoff !== undefined) { if (a.coordinator) fail('handoff is worker-only'); validateHandoff(a.handoff); }
65
81
  if (a.closeJob !== undefined) { if (a.coordinator) fail('closeJob is worker-only'); validateCloseJob(a.closeJob); }
66
82
  if (a.dashboardPort !== undefined) {
@@ -231,11 +247,16 @@ export class ConfigStore {
231
247
  });
232
248
  this.tail = operation.catch(() => {}); return operation;
233
249
  }
234
- async configure(id: string, values: Omit<Agent, 'coordinator'>, assertValid: () => void = () => {}): Promise<Config> {
250
+ async configure(id: string, values: Omit<Agent, 'coordinator'>, assertValid: () => void = () => {}, checkPrevious?: (previous: Agent | undefined) => void): Promise<Config> {
235
251
  return this.update(id, async c => {
236
252
  if (values.sessionId === coordinator(c).sessionId) fail('cannot configure coordinator as worker');
253
+ checkPrevious?.(c.agents.find(a => a.sessionId === values.sessionId));
254
+ for (const field of ['sessionId', 'name', 'description', 'projectDirectory'] as const) {
255
+ if (typeof values[field] === 'string' && /^none$/i.test(values[field].trim())) fail(`invalid ${field}`);
256
+ }
257
+ requireWorkspace(values);
237
258
  const projectDirectory = await directory(this.root, values.projectDirectory);
238
- const a: Agent = { sessionId: values.sessionId, name: values.name, description: values.description, port: values.port, projectDirectory, coordinator: false };
259
+ const a: Agent = { sessionId: values.sessionId, name: values.name, description: values.description, port: values.port, projectDirectory, worktree: values.worktree, branch: values.branch, coordinator: false };
239
260
  const index = c.agents.findIndex(old => old.sessionId === a.sessionId);
240
261
  if (index < 0) c.agents.push(a);
241
262
  else {
@@ -7,6 +7,8 @@ export interface WorkerConnection {
7
7
  state: 'connected' | 'disconnected' | 'unknown';
8
8
  checkedAt: string | null;
9
9
  reason: ConnectionReason;
10
+ /** Present only when a verified endpoint supplied a boolean activity snapshot. */
11
+ busy?: boolean;
10
12
  }
11
13
  export interface ConnectionAgent { sessionId: string; port: number }
12
14
  export interface ProbeOptions { signal?: AbortSignal; timeoutMs?: number }
@@ -34,7 +36,7 @@ export function probeWorker(agent: ConnectionAgent, options: ProbeOptions = {}):
34
36
  let request: http.ClientRequest | undefined;
35
37
  let response: http.IncomingMessage | undefined;
36
38
  let timer: ReturnType<typeof setTimeout> | undefined;
37
- const finish = (state: WorkerConnection['state'], reason: ConnectionReason) => {
39
+ const finish = (state: WorkerConnection['state'], reason: ConnectionReason, busy?: boolean) => {
38
40
  if (settled) return;
39
41
  settled = true;
40
42
  clearTimeout(timer);
@@ -43,7 +45,7 @@ export function probeWorker(agent: ConnectionAgent, options: ProbeOptions = {}):
43
45
  request?.destroy();
44
46
  resolve(options.signal?.aborted
45
47
  ? unknown(agent.sessionId, 'aborted', new Date().toISOString())
46
- : { sessionId: agent.sessionId, state, reason, checkedAt: new Date().toISOString() });
48
+ : { sessionId: agent.sessionId, state, reason, checkedAt: new Date().toISOString(), ...(typeof busy === 'boolean' ? { busy } : {}) });
47
49
  };
48
50
  const abort = () => finish('unknown', 'aborted');
49
51
  const error = (error: NodeJS.ErrnoException) => {
@@ -83,10 +85,10 @@ export function probeWorker(agent: ConnectionAgent, options: ProbeOptions = {}):
83
85
  !(body as { sessionId: string }).sessionId.trim() || (body as { sessionId: string }).sessionId.length > 256) {
84
86
  finish('unknown', 'malformed'); return;
85
87
  }
86
- const identity = body as { version: number; sessionId: string };
88
+ const identity = body as { version: number; sessionId: string; busy?: unknown };
87
89
  if (identity.version !== 1) finish('unknown', 'unsupported_version');
88
90
  else if (identity.sessionId !== agent.sessionId) finish('disconnected', 'identity_mismatch');
89
- else finish('connected', 'verified');
91
+ else finish('connected', 'verified', typeof identity.busy === 'boolean' ? identity.busy : undefined);
90
92
  });
91
93
  });
92
94
  request.on('error', error);
package/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { fileURLToPath } from 'node:url';
2
+ import { readFile } from 'node:fs/promises';
2
3
  import path from 'node:path';
3
4
  import { Type, type TSchema } from 'typebox';
4
5
  import { getAgentDir, SessionManager, SettingsManager, truncateHead, withFileMutationQueue, type ExtensionAPI, type ExtensionContext } from '@earendil-works/pi-coding-agent';
@@ -14,11 +15,11 @@ const modelSelection = Type.Union([Type.Null(), Type.Object({ provider: Type.Str
14
15
  const tools: [string, string, TSchema][] = [
15
16
  ['configure_models', 'Coordinator only. Save coordinator and/or worker provider/model defaults in project config. Null removes a default. Applies on startup or idle responsibility reload, not immediately. Manual model changes remain allowed; unavailable models produce an error without fallback.', Type.Object({ coordinator: Type.Optional(modelSelection), worker: Type.Optional(modelSelection) }, { minProperties: 1, additionalProperties: false })],
16
17
  ['create_worker', 'Coordinator only. Launch one anonymous worker at the coordinator root. projectDirectory defaults to root and must resolve to that same directory; subfolder launches cannot use a parent config and are refused. No assignment, configuration, or registration wait.', Type.Object({ projectDirectory: Type.Optional(Type.String()) })],
17
- ['configure_worker', 'Coordinator only. Write explicit reported connection details and responsibility to config. Does not notify, reload, or start work. Use reload_worker separately.', Type.Object({ sessionId: Type.String(), port: Type.Integer({ minimum: 1, maximum: 65535 }), projectDirectory: Type.String(), name: Type.String({ minLength: 1, maxLength: 128 }), description: Type.String({ minLength: 1, maxLength: 4096 }) })],
18
- ['reload_worker', 'Coordinator only. Ask worker to reread responsibility and synchronize names. NOT Pi extension reload, cancellation, restart, or work assignment.', to],
18
+ ['configure_worker', 'Coordinator only. Write reported connection details, responsibility, and required worktree/branch to config. All seven fields are required; blank/none worktree or branch refused. Worktree may be absolute or project-root-relative, including siblings. Changing an existing workspace requires a verified idle worker. Does not notify, reload, or start work. Use reload_worker separately.', Type.Object({ sessionId: Type.String(), port: Type.Integer({ minimum: 1, maximum: 65535 }), projectDirectory: Type.String(), name: Type.String({ minLength: 1, maxLength: 128 }), description: Type.String({ minLength: 1, maxLength: 4096 }), worktree: Type.String({ minLength: 1, maxLength: 4096 }), branch: Type.String({ minLength: 1, maxLength: 4096 }) })],
19
+ ['reload_worker', 'Coordinator only. Ask idle worker to validate its worktree/branch, load its configuration and synchronize names. Missing legacy workspace fields require reconfiguration first. NOT Pi extension reload, cancellation, restart, or work assignment.', to],
19
20
  ['send', 'Configured sessions only. Send an explicit work/progress/findings message by recipient name. Idle delivery starts a turn; busy delivery steers at supported boundaries. Receipt is not an agent reply. Progress questions do not cancel assignments.', Type.Object({ to: Type.String(), message: Type.String({ minLength: 1, maxLength: 48000 }) })],
20
21
  ['worker_status', 'Configured sessions only. Read paginated JSON worker observations and public reports from local files, optionally by worker name. Last-observed status is not live liveness or task completion; reports are self-reported, not approval. Local-only by default; probe:true performs bounded loopback identity checks for this page only, without worker prompts or Telegram dependency. Disconnected means endpoint unreachable, not process termination. Follow nextOffset for further pages; null report means no readable active report.', Type.Object({ name: Type.Optional(Type.String({ minLength: 1, maxLength: 128 })), offset: Type.Optional(Type.Integer({ minimum: 0 })), limit: Type.Optional(Type.Integer({ minimum: 1, maximum: 20 })), probe: Type.Optional(Type.Boolean()) })],
21
- ['list', 'Configured sessions only. Read current saved names, responsibilities, session IDs, roles and ports. No live probing. Output limited to 50 KiB/2000 lines; full data remains in config.json.', Type.Object({})],
22
+ ['list', 'Configured sessions only. Read current saved names, responsibilities, worktrees, branches, session IDs, roles and ports. No live probing. Output limited to 50 KiB/2000 lines; full data remains in config.json.', Type.Object({})],
22
23
  ['request_status', 'Coordinator only. Ask worker extension to send an independent sessionId/port/busy report without a model turn on worker. No synchronous status reply.', to],
23
24
  ['report_work', 'Configured, responsibility-loaded workers only. Store one public report (blocked, needs_decision, ready_for_review) and notify the coordinator; clear retires it silently. Put long details in a file and reference its path. Summary required except clear (omit or empty). Never include private reasoning, credentials, raw tool payloads, or secrets. Receipt is not approval, verified completion, or permission for follow-up work.', Type.Object({ status: Type.String({ enum: ['blocked', 'needs_decision', 'ready_for_review', 'clear'] }), summary: Type.Optional(Type.String({ maxLength: 2000 })) })],
24
25
  ['report_status', 'Worker only (including anonymous). Send runtime sessionId/port/busy report to coordinator. This is NOT registration and creates no config entry.', Type.Object({})],
@@ -252,9 +253,16 @@ export default function intercomExtension(pi: ExtensionAPI): void {
252
253
  pi.on('before_agent_start', async (event, ctx) => {
253
254
  context = ctx;
254
255
  if (!runtime) return;
255
- const { me } = await runtime.state();
256
- const loaded = runtime.responsibility;
257
- return { systemPrompt: event.systemPrompt + '\n\nPiIntercom: communicates; Pi decides orchestration. Responsibility is not a work assignment. Do not implement unrelated work from findings. After coordinator-assigned work, file intercom_report_work (or message the coordinator) before ending the turn, then wait; do not autonomously exit. Keep reports short: put long results in a file and reference its path. Worker reports are self-reported, not verified completion or approval. Progress questions require reporting and continuing unless explicitly redirected. stop_worker remains disabled due to the host cancellation blocker. close_worker is a separate Linux Herdr background handoff-and-pane-close workflow: do not self-exit, remove registration, force kill or infer completion from job acceptance.\n' + (me && loaded ? `Identity: ${loaded.name} (${me.sessionId}). Responsibility: ${loaded.description}.` : 'Anonymous/unloaded worker: wait for coordinator configuration and separate reload; do not treat registration as authorization to work.') };
256
+ const current = runtime, started = generation;
257
+ // Package-owned rules, not a project file or a skill the model must discover.
258
+ // Pi keeps these instructions for the run; tools/messages do not repeat them.
259
+ let rules: string;
260
+ try { rules = await readFile(new URL('../rules.md', import.meta.url), 'utf8'); }
261
+ catch { return { systemPrompt: event.systemPrompt + '\n\nIntercom NOT READY: packaged rules.md is unavailable. Report the problem and do not continue assigned work until the installation is repaired.' }; }
262
+ if (runtime !== current || generation !== started) return;
263
+ const instructions = await current.beforeRunInstructions();
264
+ if (runtime !== current || generation !== started) return;
265
+ return { systemPrompt: event.systemPrompt + '\n\n' + rules + '\n' + instructions };
258
266
  });
259
267
  for (const [operation, description, parameters] of tools) {
260
268
  pi.registerTool({
@@ -93,6 +93,10 @@ export function renderMonitor(snapshot: ObservationSnapshot | undefined, width:
93
93
  line(` Connection: ${connection.state} · ${connection.reason}`),
94
94
  line(` Checked: ${connection.checkedAt ?? 'never'} · ${Number.isFinite(checkedAge) && checkedAge >= 0 ? ageLabel(checkedAge) : 'age unknown'}`),
95
95
  ];
96
+ const workspaceDetails = [
97
+ line(` Worktree: ${worker.worktree || 'Missing — reconfigure worker'}`),
98
+ line(` Branch: ${worker.branch || 'Missing — reconfigure worker'}`),
99
+ ];
96
100
  const selected = start + offset === selectedIndex;
97
101
  const report = snapshot.reports?.find(report => report.sessionId === worker.sessionId && reportLabels[report.status]);
98
102
  lines.push(table(worker.name, connection.state, activity, age, evidence, report ? reportLabels[report.status] : '—', tone, selected));
@@ -117,6 +121,7 @@ export function renderMonitor(snapshot: ObservationSnapshot | undefined, width:
117
121
  ] : []),
118
122
  ...connectionDetails,
119
123
  line(` Responsibility: ${worker.description || 'Not specified'}`),
124
+ ...workspaceDetails,
120
125
  line(` Observed status: ${activity} · ${age}`),
121
126
  line(` Last activity: ${evidence}`),
122
127
  ...(closeJob ? [line(` Close updated: ${closeJob.updatedAt}`), line(' Workflow state is not proof all child processes terminated')] : []),
@@ -124,12 +129,13 @@ export function renderMonitor(snapshot: ObservationSnapshot | undefined, width:
124
129
  } else if (selected && showDetails && report) {
125
130
  const elapsed = now - Date.parse(report.updatedAt);
126
131
  const reportAge = !Number.isFinite(elapsed) || elapsed < 0 ? 'clock uncertain' : ageLabel(elapsed) + (elapsed > snapshot.staleAfterMs ? ' (old)' : '');
127
- const contextRows = detailBudget >= 8 ? [
132
+ const contextRows = detailBudget >= 11 ? [
128
133
  paint('1', line(` ${worker.name}`)),
129
134
  ...connectionDetails,
130
135
  line(` Responsibility: ${worker.description || 'Not specified'}`),
136
+ ...workspaceDetails,
131
137
  line(` Observed status: ${activity} · ${age}`),
132
- ...(detailBudget >= 10 ? [line(` Last activity: ${evidence}`)] : []),
138
+ ...(detailBudget >= 12 ? [line(` Last activity: ${evidence}`)] : []),
133
139
  ] : [];
134
140
  selectedDetail = [
135
141
  ...contextRows,
@@ -140,6 +146,7 @@ export function renderMonitor(snapshot: ObservationSnapshot | undefined, width:
140
146
  } else if (selected && showDetails) selectedDetail = [
141
147
  ...connectionDetails,
142
148
  line(` Responsibility: ${worker.description || 'Not specified'}`),
149
+ ...workspaceDetails,
143
150
  line(` Observed status: ${activity} · ${age}`),
144
151
  line(` Last activity: ${evidence}`),
145
152
  ];
package/src/runtime.ts CHANGED
@@ -2,7 +2,7 @@ import path from 'node:path';
2
2
  import { randomUUID } from 'node:crypto';
3
3
  import { realpath } from 'node:fs/promises';
4
4
  import { LocalObserver, LOG_LIMITS, observationError, type Observer, type EventType, type EventMetadata } from './observability.js';
5
- import { ConfigStore, coordinator, directory, fail, named, port, requireCoordinator, text, validateConfig, monitorSettings, validateMonitorSettings, validateModels, type ModelSelection, type ModelSettings, type MonitorSettings, type Agent, type Config } from './config.js';
5
+ import { ConfigStore, coordinator, directory, fail, named, port, requireCoordinator, requireWorkspace, text, validateConfig, monitorSettings, validateMonitorSettings, validateModels, type ModelSelection, type ModelSettings, type MonitorSettings, type Agent, type Config } from './config.js';
6
6
  import { listen, send, reportPayload, type Endpoint, type Envelope, type Kind } from './transport.js';
7
7
  import { saveWorkerReport } from './reports.js';
8
8
  import { readObservationSnapshot } from './snapshot.js';
@@ -10,6 +10,8 @@ import { workerStatusPage } from './worker-status.js';
10
10
  import { probeWorker, probeWorkers } from './connections.js';
11
11
  import { HandoffWorkflow, HANDOFF_KINDS, fencedClose, type CloseProvider, type HandoffKind } from './handoff.js';
12
12
 
13
+ import { sameResponsibility, validateWorkerWorkspace, type WorkerWorkspace } from './workspace.js';
14
+
13
15
  export const UNSUPPORTED_CANCELLATION = 'Unsupported Pi host: stop_worker and legacy graceful-close control are disabled. Pi 0.84.4 extension abort does not cancel retry backoff/continuations; graceful shutdown cannot guarantee no queued work restarts. No cancellation or shutdown was performed. close_worker uses a separate supported-provider owned-pane closure contract, not graceful cancellation. See references/implementation-blocker.md. A verified supported host API is required for graceful cancellation (no version-only override).';
14
16
  export interface Host {
15
17
  sessionId(): string;
@@ -41,6 +43,8 @@ export interface RuntimeOptions {
41
43
  workspaceRoot?: string;
42
44
  /** Adapter startup must not recreate a config removed after discovery. */
43
45
  requireExistingConfig?: boolean;
46
+ /** Read-only validation seam for isolated runtime tests. */
47
+ validateWorkspace?: typeof validateWorkerWorkspace;
44
48
  }
45
49
  export class Intercom {
46
50
  store!: ConfigStore;
@@ -51,6 +55,8 @@ export class Intercom {
51
55
  private configuredRoot?: string;
52
56
  private configuredFile?: string;
53
57
  responsibility?: Agent;
58
+ private loadedWorkspace?: WorkerWorkspace;
59
+ private workspaceIssue?: string;
54
60
  private observer?: Observer;
55
61
  private closing?: Promise<void>;
56
62
  private reportWrites: Promise<void> = Promise.resolve();
@@ -127,7 +133,7 @@ export class Intercom {
127
133
  const own = previous?.agents.find(a => a.sessionId === this.id());
128
134
  const endpoint = await (this.options.listen ?? listen)(own?.port, m => { assertValid(); return this.receive(m); }, () => {
129
135
  assertValid();
130
- return { version: 1, sessionId: this.initialId };
136
+ return { version: 1, sessionId: this.initialId, busy: this.host.busy() };
131
137
  });
132
138
  try { assertValid(); } catch (error) { await endpoint.close(); throw error; }
133
139
  this.endpoint = endpoint;
@@ -177,7 +183,7 @@ export class Intercom {
177
183
  }
178
184
  } catch (e) { assertValid(); this.host.notify(`Coordinator unreachable/registration failed; worker remains reachable: ${String(e)}. No retry. Anonymous registration repeat is an unresolved contract; use explicit Pi /reload to restart this extension, not report_status.`); }
179
185
  assertValid();
180
- this.host.notify(`Intercom worker ready at 127.0.0.1:${this.endpoint.port}; waiting for explicit work.`);
186
+ this.host.notify(`Intercom worker listening at 127.0.0.1:${this.endpoint.port}; ${this.responsibility ? 'configuration loaded; waiting for explicit work' : 'not ready; configuration and successful reload required'}.`);
181
187
  }
182
188
  record('runtime.ready', { port: this.endpoint.port, role: me?.coordinator ? 'coordinator' : me ? 'worker' : 'anonymous', busy: this.host.busy(), outcome: 'ready' });
183
189
  } catch (e) {
@@ -198,6 +204,8 @@ export class Intercom {
198
204
  this.owesCoordinator = false;
199
205
  const endpoint = this.endpoint; this.endpoint = undefined;
200
206
  this.responsibility = undefined;
207
+ this.loadedWorkspace = undefined;
208
+ this.workspaceIssue = undefined;
201
209
  const closing = (async () => {
202
210
  try { if (endpoint) await endpoint.close(); }
203
211
  finally {
@@ -263,21 +271,79 @@ export class Intercom {
263
271
  if (!this.host.applyModel) fail('model selection unavailable in this host');
264
272
  await this.host.applyModel(selection);
265
273
  }
274
+ private invalidateWorkspace(reason: string): void {
275
+ this.responsibility = undefined;
276
+ this.loadedWorkspace = undefined;
277
+ this.workspaceIssue = reason;
278
+ }
279
+ private validateWorkspace(agent: Agent): Promise<WorkerWorkspace> {
280
+ requireWorkspace(agent);
281
+ return (this.options.validateWorkspace ?? validateWorkerWorkspace)(this.store.root, agent);
282
+ }
283
+ /** Supplies instructions once per agent run, never once per tool operation. */
284
+ async beforeRunInstructions(): Promise<string> {
285
+ const generation = this.generation;
286
+ try {
287
+ const assertValid = this.validity();
288
+ const { me, config } = await this.state();
289
+ assertValid();
290
+ if (!me) {
291
+ this.invalidateWorkspace('worker is not configured');
292
+ return 'Anonymous/unloaded worker: wait for coordinator configuration and separate reload; do not treat registration as authorization to work.';
293
+ }
294
+ if (me.coordinator) {
295
+ const missing = config.agents.filter(a => !a.coordinator && (!a.worktree || !a.branch)).map(a => a.name);
296
+ return `Identity: ${me.name} (${me.sessionId}). Responsibility: ${me.description}.\nProject/configuration root: ${this.store.root}.` +
297
+ (missing.length ? `\nWorkers with incomplete configuration: ${JSON.stringify(missing)}. Check their actual worktrees and branches, update each with intercom_configure_worker, then call intercom_reload_worker. Do not assign work until configuration is successfully loaded. Do not guess missing values; ask the user if they cannot be established.` : '');
298
+ }
299
+ requireWorkspace(me);
300
+ if (!this.responsibility) throw new Error(this.workspaceIssue ?? 'worker configuration is not loaded; successful reload required');
301
+ if (!sameResponsibility(me, this.responsibility)) fail('worker configuration changed; successful reload required');
302
+ const workspace = await this.validateWorkspace(me);
303
+ const fresh = await this.state();
304
+ assertValid();
305
+ if (!fresh.me || !sameResponsibility(me, fresh.me)) fail('worker configuration changed during validation; successful reload required');
306
+ this.loadedWorkspace = workspace;
307
+ this.workspaceIssue = undefined;
308
+ return `Identity: ${me.name} (${me.sessionId}). Responsibility: ${me.description}.\nProject/configuration root: ${this.store.root}.\nWorktree: ${workspace.worktree}. Branch: ${workspace.branch}.\nChange files only in that worktree, on that branch. Your tools still start in the project root; use explicit worktree paths.`;
309
+ } catch (error) {
310
+ // Hook exceptions are not an execution gate in Pi: always return explicit
311
+ // not-ready instructions instead of silently dropping the operating rules.
312
+ const reason = error instanceof Error ? error.message : 'worker configuration validation failed';
313
+ if (generation === this.generation) this.invalidateWorkspace(reason);
314
+ return `Intercom NOT READY: ${reason}\nDo not continue assigned work. Report the configuration problem to the coordinator and wait for correction and successful reload. Do not guess a workspace or fall back to the project root.`;
315
+ }
316
+ }
266
317
  async reload(): Promise<void> {
318
+ const generation = this.generation;
267
319
  const record = this.captureObserver();
268
320
  const assertValid = this.validity();
269
- const { me, config } = await this.state();
270
- assertValid();
271
- if (!me) fail('worker not configured; configure_worker must run before reload_worker');
272
- const selection = config.models?.[me.coordinator ? 'coordinator' : 'worker'];
273
- await this.applyConfiguredModel(selection);
274
- assertValid();
275
- this.responsibility = { ...me };
276
- // Coordinator is a routing identity, not ownership of the user's Pi/tab title.
277
- if (!me.coordinator) await this.host.setName(me.name);
278
- assertValid();
279
- record('config.reloaded', { role: me.coordinator ? 'coordinator' : 'worker' });
280
- this.host.notify(`Intercom responsibility loaded for ${me.name}; no work turn started.`);
321
+ try {
322
+ const { me, config } = await this.state();
323
+ assertValid();
324
+ if (!me) fail('worker not configured; configure_worker must run before reload_worker');
325
+ if (!me.coordinator && this.host.busy()) fail('worker configuration reload requires an idle worker');
326
+ this.invalidateWorkspace('configuration reload has not completed');
327
+ const workspace = me.coordinator ? undefined : await this.validateWorkspace(me);
328
+ assertValid();
329
+ const selection = config.models?.[me.coordinator ? 'coordinator' : 'worker'];
330
+ await this.applyConfiguredModel(selection);
331
+ assertValid();
332
+ // Coordinator is a routing identity, not ownership of the user's Pi/tab title.
333
+ if (!me.coordinator) await this.host.setName(me.name);
334
+ const fresh = await this.state();
335
+ assertValid();
336
+ if (!fresh.me || !sameResponsibility(me, fresh.me)) fail('configuration changed during reload; reload again when idle');
337
+ if (!me.coordinator && this.host.busy()) fail('worker became busy during reload; reload again when idle');
338
+ this.responsibility = { ...me };
339
+ this.loadedWorkspace = workspace;
340
+ this.workspaceIssue = undefined;
341
+ record('config.reloaded', { role: me.coordinator ? 'coordinator' : 'worker' });
342
+ this.host.notify(`Intercom responsibility loaded for ${me.name}; no work turn started.`);
343
+ } catch (error) {
344
+ if (generation === this.generation) this.invalidateWorkspace(error instanceof Error ? error.message : 'configuration reload failed');
345
+ throw error;
346
+ }
281
347
  }
282
348
  async transmit(to: string, kind: Kind, payload: Record<string, unknown> = {}): Promise<void> {
283
349
  const record = this.captureObserver();
@@ -302,7 +368,9 @@ export class Intercom {
302
368
  assertValid();
303
369
  if (me?.coordinator) fail('report_status is worker-only');
304
370
  if (!this.endpoint) fail('endpoint unavailable');
305
- await this.transmit(coordinator(config).name, 'status', { port: this.endpoint.port, busy: this.host.busy() });
371
+ await this.transmit(coordinator(config).name, 'status', { port: this.endpoint.port, busy: this.host.busy(),
372
+ worktree: me?.worktree, branch: me?.branch,
373
+ workspaceState: this.responsibility && this.loadedWorkspace && me && sameResponsibility(me, this.responsibility) ? 'loaded' : 'not_ready' });
306
374
  }
307
375
  async receive(message: Envelope): Promise<void> {
308
376
  const record = this.captureObserver();
@@ -362,7 +430,10 @@ export class Intercom {
362
430
  }
363
431
  record('status.received', { ...metadata, busy: message.payload.busy as boolean, port: message.payload.port as number });
364
432
  if (sender) record('config.changed', { operation: 'port_update', peerSessionId: message.from, port: message.payload.port as number, outcome: 'written' });
365
- notify('status', JSON.stringify({ sessionId: message.from, port: message.payload.port, busy: message.payload.busy, configured: !!sender }));
433
+ notify('status', JSON.stringify({ sessionId: message.from, port: message.payload.port, busy: message.payload.busy, configured: !!sender,
434
+ worktree: sender?.worktree, branch: sender?.branch,
435
+ workspaceState: sender?.worktree && sender.branch && message.payload.workspaceState === 'loaded' &&
436
+ message.payload.worktree === sender.worktree && message.payload.branch === sender.branch ? 'loaded' : 'not_ready' }));
366
437
  }
367
438
  return;
368
439
  }
@@ -396,6 +467,7 @@ export class Intercom {
396
467
  if (message.kind === 'message') {
397
468
  if (!sender || !me) fail('agent messaging requires configured sender and recipient; anonymous permissions TODO');
398
469
  if (!this.responsibility) fail('worker must load responsibility before receiving work');
470
+ if (!me.coordinator && !sameResponsibility(me, this.responsibility)) fail('worker configuration changed; successful reload required before receiving work');
399
471
  if (this.handoff?.workerClosing || fencedClose(me.closeJob)) fail('worker close is active or uncertain; new Intercom work is fenced');
400
472
  notify('agent message', message.payload.message as string);
401
473
  if (sender.coordinator && !me.coordinator) this.owesCoordinator = true;
@@ -449,15 +521,16 @@ export class Intercom {
449
521
  }
450
522
  if (operation === 'report_status') { await this.report(); return { accepted: true }; }
451
523
  if (operation === 'report_work') {
452
- if (!me || me.coordinator || !this.responsibility) fail('report_work requires a configured, responsibility-loaded worker');
524
+ if (!me || me.coordinator || (!this.responsibility && !(this.workspaceIssue && args.status === 'blocked'))) fail('report_work requires a configured, responsibility-loaded worker (or blocked configuration report)');
453
525
  const payload = reportPayload(args);
454
526
  await this.transmit(coordinator(config).name, 'report', payload);
455
527
  if (payload.status !== 'clear') this.owesCoordinator = false;
456
528
  return { accepted: true, coordinatorEvaluation: 'not awaited' };
457
529
  }
458
530
  if (operation === 'send') {
459
- if (!me || !this.responsibility) fail('anonymous/unloaded worker cannot send agent messages (permissions TODO)');
531
+ if (!me) fail('anonymous/unloaded worker cannot send agent messages (permissions TODO)');
460
532
  const recipient = named(config, args.to as string);
533
+ if (!this.responsibility && !(this.workspaceIssue && recipient.coordinator)) fail('anonymous/unloaded worker cannot send agent messages (permissions TODO)');
461
534
  text(args.message, 'message', 48000);
462
535
  if (this.handoff?.workerClosing || fencedClose(me.closeJob) || this.handoff?.isClosing(recipient.sessionId) || fencedClose(recipient.closeJob)) fail('worker close is active or uncertain; new Intercom work is fenced');
463
536
  await this.transmit(args.to as string, 'message', { message: args.message });
@@ -506,12 +579,22 @@ export class Intercom {
506
579
  const relative = await directory(this.store.root, args.projectDirectory as string);
507
580
  assertConfigurable();
508
581
  const candidate: Agent = { sessionId: args.sessionId as string, name: args.name as string, description: args.description as string,
509
- port: args.port as number, projectDirectory: relative, coordinator: false };
582
+ port: args.port as number, projectDirectory: relative, worktree: args.worktree as string, branch: args.branch as string, coordinator: false };
510
583
  if (candidate.sessionId === id) fail('cannot configure coordinator as worker');
511
584
  const previous = config.agents.find(a => a.sessionId === candidate.sessionId);
512
585
  if (fencedClose(previous?.closeJob)) fail('worker close is active or uncertain; configuration is fenced');
586
+ requireWorkspace(candidate);
513
587
  validateConfig({ ...config, agents: [...config.agents.filter(a => a.sessionId !== candidate.sessionId), candidate] });
514
- await this.store.configure(id, args as unknown as Omit<Agent, 'coordinator'>, assertConfigurable);
588
+ if (previous?.worktree && previous.branch && (previous.worktree !== candidate.worktree || previous.branch !== candidate.branch)) {
589
+ // A last-observed activity log is not a live idle check. Unknown or
590
+ // unreachable workers cannot authorize changing an existing workspace.
591
+ const connection = await (this.options.probe ?? probeWorker)(previous, { signal: this.probeController.signal });
592
+ assertConfigurable();
593
+ if (connection.state !== 'connected' || connection.busy !== false) fail('worktree/branch changes require a verified idle worker; busy or unknown worker refused');
594
+ }
595
+ await this.store.configure(id, args as unknown as Omit<Agent, 'coordinator'>, assertConfigurable, current => {
596
+ if (JSON.stringify(current ?? null) !== JSON.stringify(previous ?? null)) fail('worker configuration changed during configure check; no update written');
597
+ });
515
598
  record('config.changed', { operation: 'configure_worker', peerSessionId: args.sessionId as string, peerName: args.name as string, outcome: 'written' });
516
599
  return { written: true, reloaded: false };
517
600
  }
@@ -539,6 +622,9 @@ export class Intercom {
539
622
  return { accepted: true, completion: 'not awaited' };
540
623
  }
541
624
  if (operation === 'resume_worker') {
625
+ requireWorkspace(target);
626
+ await this.validateWorkspace(target);
627
+ assertValid();
542
628
  if (args.confirmClosed !== true) fail('Resume requires explicit user confirmation that the previous worker session is closed (confirmClosed:true). Disconnected alone is not proof of closure.');
543
629
  if (this.resumeFences.has(target.sessionId)) fail('Resume already in flight or awaiting worker status; outcome may be uncertain. Inspect the worker before any retry; no automatic relaunch.');
544
630
  const relative = await directory(this.store.root, target.projectDirectory);
@@ -559,7 +645,7 @@ export class Intercom {
559
645
  assertValid();
560
646
  requireCoordinator(fresh.config, id);
561
647
  const current = fresh.config.agents.find(agent => agent.sessionId === target.sessionId && !agent.coordinator);
562
- if (!current || current.port !== target.port || current.projectDirectory !== target.projectDirectory) fail('Worker configuration changed during resume check; no launch submitted.');
648
+ if (!current || current.port !== target.port || !sameResponsibility(current, target)) fail('Worker configuration changed during resume check; no launch submitted.');
563
649
  if (this.handoff?.isClosing(target.sessionId) || fencedClose(current.closeJob)) fail('worker close is active or uncertain; resume is fenced');
564
650
  fence.submitted = true;
565
651
  const result = await this.launchObserved({ multiplexer: fresh.config.multiplexer, cwd, workspaceRoot: this.store.root, sessionId: current.sessionId });