Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
refactor(core): neutralize canvas control primitives
freshjuicez79b409d0debe
diff --git a/scripts/uninstall.sh b/scripts/uninstall.shindex 336de8f24..8b468b2c4 100644--- a/scripts/uninstall.sh+++ b/scripts/uninstall.sh@@ -78,7 +78,7 @@ elsefi# Markers the installers wrote — the uninstall keys off the SAME strings (see-# src/core/agents/hooks/install-helper.ts and src/main/canvas-control-core.ts).+# src/core/agents/hooks/install-helper.ts and src/core/canvas-control-core.ts).HOOK_MARKERS='agent-hooks|claude-signals'CC_START='<!-- nodeterm:manage-canvas:start -->'CC_END='<!-- nodeterm:manage-canvas:end -->'diff --git a/src/main/agent-messaging.ts b/src/core/agents/agent-messaging.tssimilarity index 94%rename from src/main/agent-messaging.tsrename to src/core/agents/agent-messaging.tsindex 8d6919caa..3833c435f 100644--- a/src/main/agent-messaging.ts+++ b/src/core/agents/agent-messaging.ts@@ -12,46 +12,45 @@** ── THREE SURFACES ──────────────────────────────────────────────────────────────────────────────* - **Desktop (Electron):** wired in `src/main/index.ts` — the only surface with the verbs.- * - **Server Edition:** never wired; `/control/send` answers `control-unsupported-on-this-edition`- * (`src/server/control-unsupported.ts`) for a verified caller and the messaging refusal for an- * unverified one. Everything this file imports from `src/core` still ships on both shells.+ * - **Server Edition:** wired when its canvas-control config flag is enabled; otherwise+ * `/control/send` keeps the named edition refusal. Both shells inject their own stores and PTYs.* - **Mobile (phone):** never a sender (it drives canvas control over relay→IPC, not `/control/*`);* a phone-spawned node is a valid TARGET and resolves like any other store node.*/-import type { NormalizedAgentEvent } from '../shared/agents/normalize'-import { binariesFor, type PaneOwner } from '../shared/agents/pane-owner-predicate'-import type { BoardLogEntry } from '../shared/types'+import type { NormalizedAgentEvent } from '../../shared/agents/normalize'+import { binariesFor, type PaneOwner } from '../../shared/agents/pane-owner-predicate'+import type { BoardLogEntry } from '../../shared/types'import type {AgentMessageDeliverRequest,AgentMessageReply-} from '../shared/agents/agent-messaging'-import { AGENT_MESSAGE_VERBS, NOTIFY_BODY } from '../shared/agents/agent-messaging'+} from '../../shared/agents/agent-messaging'+import { AGENT_MESSAGE_VERBS, NOTIFY_BODY } from '../../shared/agents/agent-messaging'import {deliverAgentMessage,type DeliveryDeps,type ReceiptEvent-} from '../core/agents/agent-message'+} from './agent-message'import {RETRYABLE,type AgentMessageOutcome,type NotPermittedReason-} from '../core/agents/agent-message-decide'-import { noteNewTurn, noteSent, reserveFlow } from '../core/agents/agent-message-flow'-import { recordDelivery } from '../core/agents/agent-message-trace'-import { resolveDeliveryScope, scopeRefusal } from '../core/agents/agent-message-scope'+} from './agent-message-decide'+import { noteNewTurn, noteSent, reserveFlow } from './agent-message-flow'+import { recordDelivery } from './agent-message-trace'+import { resolveDeliveryScope, scopeRefusal } from './agent-message-scope'import {DeliveryQueue,type DeliveryQueueDeps,type QueuedDeliveryRequest-} from '../core/agents/delivery-queue'+} from './delivery-queue'import { randomUUID } from 'crypto'-import { nodeTokenFilePresent } from '../core/agents/node-token-files'-import { mirrorEntry as coreMirrorEntry, type MirrorEntry } from '../core/agent-status-mirror'+import { nodeTokenFilePresent } from './node-token-files'+import { mirrorEntry as coreMirrorEntry, type MirrorEntry } from '../agent-status-mirror'import {projectCapabilityGrantedFor,type CapabilityAckMap-} from '../core/project-capability-consent'-import type { ProjectCapability } from '../shared/project-capabilities'+} from '../project-capability-consent'+import type { ProjectCapability } from '../../shared/project-capabilities'/** The little the service needs to know about a stored node. */export interface MessagingStoredNode {@@ -150,11 +149,9 @@ function subscribeBus(cb: (e: ReceiptEvent) => void): () => void {/*** The process-lifetime deliver-on-idle queue (PR 7), wired once by the desktop shell. Held at module- * scope — not threaded through `AgentMessagingDeps` on the event path — because the flush trigger is- * the SAME normalized event stream `onMessagingAgentEvent` already taps, and a target going idle is- * what a flush waits for. Null on the Server Edition and until wired (messaging does not exist- * there). The verb path still takes the queue through `deps.queue` so a test can drive enqueue in- * isolation.+ * scope for the desktop shell. The Server Edition passes its own queue explicitly to+ * `onMessagingAgentEvent`, which avoids coupling two independently-constructed runtimes in tests.+ * The verb path also takes the queue through `deps.queue` so either shell can drive enqueue.*/let deliveryQueue: DeliveryQueue | null = null@@ -249,7 +246,8 @@ export function createDeliveryQueue(* designed direction) but can never confirm a delivery (fail-closed, the receipt's).*/export function onMessagingAgentEvent(- e: Pick<NormalizedAgentEvent, 'nodeId' | 'state' | 'newTurn' | 'verified'>+ e: Pick<NormalizedAgentEvent, 'nodeId' | 'state' | 'newTurn' | 'verified'>,+ queue: DeliveryQueue | null = deliveryQueue): void {if (!e?.nodeId) returnif (e.newTurn === true) noteNewTurn(e.nodeId)@@ -264,7 +262,7 @@ export function onMessagingAgentEvent(// re-runs the whole delivery per queued message (the flush-time re-validation), so a `done` that// is actually still-not-deliverable (an unverified or inferred idle) simply re-queues — this only// needs to be a cheap "maybe now" nudge, not a precise idle verdict.- if (e.state === 'done') void deliveryQueue?.onTargetIdle(e.nodeId)+ if (e.state === 'done') void queue?.onTargetIdle(e.nodeId)}// ── The per-node delivery lock ────────────────────────────────────────────────────────────────diff --git a/src/core/agents/hook-server.ts b/src/core/agents/hook-server.tsindex 25a6ebdf3..01c73ff61 100644--- a/src/core/agents/hook-server.ts+++ b/src/core/agents/hook-server.ts@@ -177,7 +177,7 @@ export interface HookEventMeta {* fail-closed from day one costs nobody anything.** `open-project` (issue #338) is here for the same class of reason as `sticky`: the main-side- * grant ledger (src/main/project-grants.ts) mints per-caller targeting rights off a successful+ * grant ledger (src/core/project-grants.ts) mints per-caller targeting rights off a successful* `open-project`, and a grant recorded for an unverifiable caller would authorize whoever can* name that caller's node id. NEW verb, so fail-closed from day one strands nobody.*diff --git a/src/core/agents/node-identity-policy.ts b/src/core/agents/node-identity-policy.tsindex 9a91ee5a1..cac0cb224 100644--- a/src/core/agents/node-identity-policy.ts+++ b/src/core/agents/node-identity-policy.ts@@ -197,7 +197,7 @@ export const TOLERANT_CONTROL_VERBS = new Set(['list'])* Control verbs that admit ONLY a `verified` caller — no window, no latch, no override.** ⚠ **PRE-POSITIONED, AND INERT TODAY.** `browser` is the whole bucket, and `browser` is **not a- * verb this app has**: `ControlVerb` (`src/main/canvas-control-core.ts`) lists 24 and the browser+ * verb this app has**: `ControlVerb` (`src/core/canvas-control-core.ts`) lists 24 and the browser* one is `open-browser`, which is deliberately NOT in here (see below). So measured over the real* verb list, this set changes nothing for anybody: no request that succeeds today starts failing,* and `hookIdentityStrict: false` releases exactly what it released before. What it does is makediff --git a/src/main/canvas-control-core.ts b/src/core/canvas-control-core.tssimilarity index 98%rename from src/main/canvas-control-core.tsrename to src/core/canvas-control-core.tsindex 0c9c83c46..be689a8e4 100644--- a/src/main/canvas-control-core.ts+++ b/src/core/canvas-control-core.ts@@ -1,16 +1,16 @@// Pure core for agent canvas control: the verb model, request validation, and the standalone// CLI source. No electron imports, so this module + CONTROL_CLI_SCRIPT are unit-testable.// Electron/ipc/server wiring lives in canvas-control.ts + index.ts + hook-server.ts.-import { HOOK_CURL_HEADERS_SH } from '../core/agents/hook-curl-config-sh'-import { CODEX_SANDBOX_HINT_SH } from '../core/agents/hook-sandbox-hint-sh'-import { HOOK_ENDPOINT_FALLBACK_SH, STALE_ENDPOINT_HINT } from '../core/agents/hook-endpoint-failover-sh'-import { codexSandboxGuidanceLines } from '../core/context-link-core'-import { NODE_TOKEN_READ_SH } from '../core/agents/node-token-sh'+import { HOOK_CURL_HEADERS_SH } from './agents/hook-curl-config-sh'+import { CODEX_SANDBOX_HINT_SH } from './agents/hook-sandbox-hint-sh'+import { HOOK_ENDPOINT_FALLBACK_SH, STALE_ENDPOINT_HINT } from './agents/hook-endpoint-failover-sh'+import { codexSandboxGuidanceLines } from './context-link-core'+import { NODE_TOKEN_READ_SH } from './agents/node-token-sh'import { AGENT_CONFIG, AGENT_HOOK_TARGETS, BUILTIN_AGENT_IDS } from '@shared/agents/config'-import { RETRYABLE } from '../core/agents/agent-message-decide'-import { FANOUT_PER_TURN, PAIR_MIN_INTERVAL_MS } from '../core/agents/agent-message-flow'-import { BROWSER_RETRYABLE, BROWSER_OUTCOME_LABEL } from '../core/browser-outcomes'-import { BROWSER_KEYS, BROWSER_TIMEOUT_DEFAULT_MS, BROWSER_TIMEOUT_MAX_MS } from '../core/browser-verb'+import { RETRYABLE } from './agents/agent-message-decide'+import { FANOUT_PER_TURN, PAIR_MIN_INTERVAL_MS } from './agents/agent-message-flow'+import { BROWSER_RETRYABLE, BROWSER_OUTCOME_LABEL } from './browser-outcomes'+import { BROWSER_KEYS, BROWSER_TIMEOUT_DEFAULT_MS, BROWSER_TIMEOUT_MAX_MS } from './browser-verb'/*** The messaging verbs' retry guidance, RENDERED from `RETRYABLE` — the table is the source, and@@ -238,7 +238,7 @@ export function parseControlRequest(if (v === 'browser' && !args.node) return { error: 'browser: --node <id> is required' }// `open-project` requires a cwd; everything else about the argument (absolute, exists, is a// directory, resolved once) is validated in MAIN by `validateOpenProjectCwd`- // (src/main/project-grants.ts) — the caller's path is hostile input and this presence check is+ // (src/core/project-grants.ts) — the caller's path is hostile input and this presence check is// only the polite half.if (v === 'open-project' && !args.cwd) return { error: 'open-project requires --cwd <abs-path>' }return { verb: v, args }diff --git a/src/main/project-grants.ts b/src/core/project-grants.tssimilarity index 96%rename from src/main/project-grants.tsrename to src/core/project-grants.tsindex 623cf5dc1..512dbdf60 100644--- a/src/main/project-grants.ts+++ b/src/core/project-grants.ts@@ -8,11 +8,11 @@* consent via the #213 mechanism, which would be a third disjunct in `gateProjectTarget`, not a* redesign).*- * IN MEMORY, IN MAIN, NEVER PERSISTED — the browser-ownership-ledger posture+ * IN MEMORY, IN THE CORE PROCESS, NEVER PERSISTED — the browser-ownership-ledger posture* (browser-control-ledger.ts), for the same reason: a grant is a record of consent given to a* RUNNING session, not a durable claim. An app restart clears every grant; a caller's node* teardown (pty destroy/recycle, wired in index.ts) clears that caller's. Recording happens ONLY- * in main's control-handler wrapper on `result.ok && verified` — main's own identity verdict for+ * in the desktop control-handler wrapper on `result.ok && verified` — the core's identity verdict for* that request, never anything off the wire or out of project.json.** PURE on purpose: no electron, no fs, no child_process (project-grants.test.ts asserts this@@ -73,7 +73,7 @@ export const PROJECT_TARGETABLE_VERBS: ReadonlySet<string> = new Set([export const PROJECT_TARGETING_REFUSAL = 'Project targeting refused.'/** The named refusal for an id that is neither the caller's own project nor granted. Also the- * answer for an id main's store does not know, AND for an ungranted id that happens to name an+ * answer for an id the core store does not know, AND for an ungranted id that happens to name an* SSH project: every id the caller has no relationship to refuses with these SAME BYTES, so the* gate is neither a project-existence oracle nor a project-KIND oracle (PR #362 review, I3 —* the earlier distinct SSH wording let a verified caller learn "this id is a real SSH project"@@ -100,7 +100,7 @@ export const OPEN_PROJECT_LOCAL_ONLY =export const OPEN_PROJECT_GRANT_CAP ='open-project-grant-cap: this session already holds the maximum number of project grants'-/** The wrapper could not resolve the caller's own project from main's persisted store (a node+/** The wrapper could not resolve the caller's own project from the persisted store (a node* saved seconds ago may still be inside the save debounce). Fail closed, but say it is* transient — this is the one refusal here that a short wait can clear. */export const OPEN_PROJECT_CALLER_UNRESOLVED =@@ -113,9 +113,9 @@ export const OPEN_PROJECT_CWD_INVALID =export type ProjectTargetGate = 'allow' | { refuse: string }/**- * The `--project` targeting gate (spec §3 "consumed" + §5 P1/P2/P8), run in main's control-handler+ * The `--project` targeting gate (spec §3 "consumed" + §5 P1/P2/P8), run in the shell's control-handler* wrapper BEFORE anything is forwarded to the renderer — the renderer never sees an unauthorized- * `--project`. Every input is main's own data: `verified` is the hook server's identity verdict+ * `--project`. Every input is core-owned data: `verified` is the hook server's identity verdict* for THIS request, `callerProjectId` comes from node membership in `persistedCanvases()`,* `targetIsSsh` from `projectMetaFor` (undefined = the store does not know the target), and* `granted` from this module's ledger. Nothing is read off the request except the target id@@ -127,7 +127,7 @@ export type ProjectTargetGate = 'allow' | { refuse: string }* mid-debounce ever let `persistedCanvases` resolve the caller one tick before* `projectMetaFor` finds the entry, the caller's legitimate `--project <own-id>` must not be* spuriously refused as unknown. Allowing OWN on the caller-resolution alone is still- * fail-closed — the id equals the caller's own project in main's own store;+ * fail-closed — the id equals the caller's own project in the core store;* - every id the caller has NO relationship to (unknown, local-ungranted, SSH-ungranted)* refuses with the byte-identical PROJECT_TARGET_REFUSED (review I3 — no kind oracle);* - the SSH refusal sits INSIDE the granted allow as pure belt: a granted SSH id cannot exist@@ -181,7 +181,7 @@ export function recordOpenProjectGrant(* The whole main-side pre-forward gate for an `open-project` request (issue #338 Task 1.4, made* pure in the PR #362 fix round — review I1/I2 proved the SSH-caller and unresolved-caller* branches had no red-capable coverage while they lived inline in index.ts's wrapper). The- * wrapper resolves the inputs from main's own stores (caller project by node membership in+ * wrapper resolves the inputs from core-owned stores (caller project by node membership in* `persistedCanvases`, SSH-ness via `projectMetaFor`, the cap from this module's ledger) and* routes EVERY open-project through here; a `refuse` answer is returned to the caller without* anything being forwarded to the renderer, so no dialog can be shown (PR 2) and no grant can bediff --git a/src/core/workspace-store.test.ts b/src/core/workspace-store.test.tsindex 58405a03a..8bb17e7d8 100644--- a/src/core/workspace-store.test.ts+++ b/src/core/workspace-store.test.ts@@ -1823,7 +1823,7 @@ describe('the shared project file carries content, not machine identity', () =>})describe('projectMetaFor (issue #338 PR 1) — target exists / is SSH, from the store alone', () => {- // The --project targeting gate (src/main/project-grants.ts) learns "does this project exist,+ // The --project targeting gate (src/core/project-grants.ts) learns "does this project exist,// and is it SSH" from main's OWN store — never from anything the caller sent. Same three// entry kinds as persistedCanvases: inline (e.project), ssh (e.ssh), local ref (e.cwd).it('answers for all three entry kinds and undefined for an unknown id', async () => {diff --git a/src/core/workspace-store.ts b/src/core/workspace-store.tsindex defa9ce9b..f26580d99 100644--- a/src/core/workspace-store.ts+++ b/src/core/workspace-store.ts@@ -1166,7 +1166,7 @@ export class WorkspaceStore {/*** Does this project exist on THIS machine, and is it SSH? The `--project` targeting gate- * (issue #338, src/main/project-grants.ts) asks main's own store — never the request — before+ * (issue #338, src/core/project-grants.ts) asks the core store — never the request — before* any targeted open is forwarded. Same three-entry-kind scan and same id semantics as* `persistedCanvases` (inline keyed by `e.project.id`, ssh/local refs by `e.id`), because the* projectId a grant names there must resolve to the same project here. `undefined` = unknowndiff --git a/src/main/agent-messaging-switch.test.ts b/src/main/agent-messaging-switch.test.tsindex 97d0c2321..4fea8ffef 100644--- a/src/main/agent-messaging-switch.test.ts+++ b/src/main/agent-messaging-switch.test.ts@@ -21,7 +21,7 @@ import {deliverFromControl,messagingEnabledVia,type AgentMessagingDeps-} from './agent-messaging'+} from '../core/agents/agent-messaging'import type { CapabilityAckMap } from '../core/project-capability-consent'import { resetMessageFlow } from '../core/agents/agent-message-flow'import {diff --git a/src/main/agent-messaging.test.ts b/src/main/agent-messaging.test.tsindex ed6fcebb7..04d84489a 100644--- a/src/main/agent-messaging.test.ts+++ b/src/main/agent-messaging.test.ts@@ -8,14 +8,14 @@* real tmux in `agent-message.realtty.test.ts` — this file assumes both and tests only what the* service adds.*/-import { describe, it, expect, beforeEach } from 'vitest'+import { describe, it, expect, beforeEach, vi } from 'vitest'import {deliverFromControl,renderMessageOutcome,onMessagingAgentEvent,createDeliveryQueue,type AgentMessagingDeps-} from './agent-messaging'+} from '../core/agents/agent-messaging'import type { BoardLogEntry } from '../shared/types'import { RETRYABLE, type AgentMessageOutcome } from '../core/agents/agent-message-decide'import { resetMessageFlow, FANOUT_PER_TURN } from '../core/agents/agent-message-flow'@@ -361,6 +361,38 @@ describe('deliver-on-idle wiring (PR 7)', () => {expect(deps.rec.sent).toEqual([]) // queued is NOT delivered — no bytes yet})+ it('the Server Edition explicit queue tap flushes a busy send on the target idle event', async () => {+ const flushed = vi.fn(async () => ({+ kind: 'delivered' as const,+ traceId: 'delivered-trace',+ traced: 'memory' as const,+ receipt: 'observed' as const,+ signal: 'newTurn' as const+ }))+ const queue = new DeliveryQueue({+ now: () => 0,+ deliver: flushed,+ trace: async () => ({ traceId: 'queue-trace', traced: 'memory' }),+ schedule: () => () => {}+ })+ const busy: MirrorEntry = {+ state: 'working',+ updatedAt: 1,+ stateVerified: true,+ clientRevision: MANAGED_SCRIPT_REVISION+ }+ const deps = fakeDeps({ mirrorEntry: () => busy, queue })+ expect((await deliverFromControl(req(), deps)).outcome.kind).toBe('queued')+ expect(queue.depth('b1')).toBe(1)++ onMessagingAgentEvent(+ { nodeId: 'b1', state: 'done', verified: true, newTurn: false },+ queue+ )+ await vi.waitFor(() => expect(queue.depth('b1')).toBe(0))+ expect(flushed).toHaveBeenCalledTimes(1)+ })+it('without a queue, the same busy target is refused `targetBusy` (old behaviour intact)', async () => {const busy: MirrorEntry = { state: 'working', updatedAt: 1, stateVerified: true, clientRevision: MANAGED_SCRIPT_REVISION }const deps = fakeDeps({ mirrorEntry: () => busy })diff --git a/src/main/canvas-control-core.test.ts b/src/main/canvas-control-core.test.tsindex 9b6e88d2b..b2f3d1aea 100644--- a/src/main/canvas-control-core.test.ts+++ b/src/main/canvas-control-core.test.ts@@ -7,13 +7,13 @@ import {buildCanvasSkillBody,CONTROL_SHIM_SCRIPT,CONTROL_UNREACHABLE_MSG-} from './canvas-control-core'+} from '../core/canvas-control-core'import {CODEX_SANDBOX_BLOCKED_LINE,CODEX_SANDBOX_RETRY_LINE} from '../core/agents/hook-sandbox-hint-sh'import { RETRYABLE } from '../core/agents/agent-message-decide'-import { PROJECT_TARGETABLE_VERBS } from './project-grants'+import { PROJECT_TARGETABLE_VERBS } from '../core/project-grants'import { STRICT_CONTROL_VERBS } from '../core/agents/node-identity-policy'import { BROWSER_ACTION_KEYS } from '../core/browser-verb'import { BROWSER_RETRYABLE, BROWSER_OUTCOME_LABEL } from '../core/browser-outcomes'@@ -500,7 +500,7 @@ describe('open-project + --project docs land with the dispatch (issue #338, spec})it('every --project-targetable verb line documents the flag — walked off the REAL set', () => {- // The drift alarm walks PROJECT_TARGETABLE_VERBS (src/main/project-grants.ts) rather than a+ // The drift alarm walks PROJECT_TARGETABLE_VERBS (src/core/project-grants.ts) rather than a// re-typed list: a fourth verb joining the set without its doc line goes red here, and a doc// line dropping the flag goes red too.for (const [name, body] of bodies) {diff --git a/src/main/canvas-control-shim.failover.test.ts b/src/main/canvas-control-shim.failover.test.tsindex e736a9e91..f8ed8c62a 100644--- a/src/main/canvas-control-shim.failover.test.ts+++ b/src/main/canvas-control-shim.failover.test.ts@@ -10,7 +10,7 @@ import fs from 'node:fs'import os from 'node:os'import path from 'node:path'import { promisify } from 'node:util'-import { CONTROL_SHIM_SCRIPT, CONTROL_UNREACHABLE_MSG } from './canvas-control-core'+import { CONTROL_SHIM_SCRIPT, CONTROL_UNREACHABLE_MSG } from '../core/canvas-control-core'import { STALE_ENDPOINT_HINT } from '../core/agents/hook-endpoint-failover-sh'import { hookServer } from '../core/agents/hook-server'import { nodeAuthToken } from '../core/agents/node-auth-token'diff --git a/src/main/canvas-control-shim.test.ts b/src/main/canvas-control-shim.test.tsindex cb0bea9d3..ac3fe80c7 100644--- a/src/main/canvas-control-shim.test.ts+++ b/src/main/canvas-control-shim.test.ts@@ -9,7 +9,7 @@ import fs from 'node:fs'import os from 'node:os'import path from 'node:path'import { promisify } from 'node:util'-import { CONTROL_SHIM_SCRIPT } from './canvas-control-core'+import { CONTROL_SHIM_SCRIPT } from '../core/canvas-control-core'import { hookServer, parseControlBody } from '../core/agents/hook-server'import { nodeAuthToken } from '../core/agents/node-auth-token'import { initPlatform, resetPlatformForTests } from '../core/platform'diff --git a/src/main/canvas-control.ts b/src/main/canvas-control.tsindex c00e2acaa..dc3fb8f25 100644--- a/src/main/canvas-control.ts+++ b/src/main/canvas-control.ts@@ -15,7 +15,7 @@ import {buildCanvasControlInstructions,buildCanvasSkillBody,mergeCanvasControlBlock-} from './canvas-control-core'+} from '../core/canvas-control-core'import { opencodeConfigDir } from '../core/agents/hooks/opencode'import { copilotHomeDir } from '../core/agents/hooks/copilot'diff --git a/src/main/control-shim-parse.test.ts b/src/main/control-shim-parse.test.tsindex 1d24345a0..028dafe86 100644--- a/src/main/control-shim-parse.test.ts+++ b/src/main/control-shim-parse.test.ts@@ -14,7 +14,7 @@ import { execFileSync } from 'node:child_process'import fs from 'node:fs'import os from 'node:os'import path from 'node:path'-import { CONTROL_SHIM_SCRIPT } from './canvas-control-core'+import { CONTROL_SHIM_SCRIPT } from '../core/canvas-control-core'let dir = ''diff --git a/src/main/index.ts b/src/main/index.tsindex 299049fcd..729478550 100644--- a/src/main/index.ts+++ b/src/main/index.ts@@ -26,7 +26,7 @@ import {gateOpenProject,PROJECT_TARGETABLE_VERBS,OPEN_PROJECT_GRANT_CAP-} from './project-grants'+} from '../core/project-grants'import { BrowserLeaseManager, BrowserSession } from './browser-lease'import { CdpEventBus, type Sendable } from './browser-actions'import { RefTable } from './browser-refs'@@ -63,7 +63,7 @@ import {onMessagingAgentEvent,setDeliveryQueue,type AgentMessagingDeps-} from './agent-messaging'+} from '../core/agents/agent-messaging'import type { RemoteLogExec } from '../core/board-log'import { boardLogRemotePath } from '../core/board-log'import { PtyManager } from '../core/pty-manager'@@ -1596,7 +1596,7 @@ app.whenReady().then(async () => {// Agent messaging (the `send`/`reply` control verbs). Canvas.tsx forwards the validated verb// here; everything that authorizes or performs the delivery reads MAIN's stores. See- // src/main/agent-messaging.ts for the whole map.+ // src/core/agents/agent-messaging.ts for the whole map.const messagingDeps: AgentMessagingDeps = {paneOwner: (id) => ptyManager.paneOwner(id),sendEnvelope: (id, envelope) => ptyManager.sendEnvelope(id, envelope),@@ -2329,8 +2329,8 @@ app.whenReady().then(async () => {// Managed accounts each carry their own settings.json AND skills/ (Claude Code resolves both// relative to CLAUDE_CONFIG_DIR) — re-install the hook + canvas skill there too (idempotent),// so an app update's new versions reach every account dir. The loop is shared with the Server- // Edition's boot (src/core/claude-accounts-service.ts); the canvas skill is the desktop's own- // addition, because canvas control is not wired on that shell at all.+ // Edition's boot (src/core/claude-accounts-service.ts); each shell supplies its own canvas-skill+ // installer when that control surface is enabled.installHooksIntoLocalAccounts(settingsStore.get().claudeAccounts ?? [], installCanvasSkillInto)// Fan a normalized agent event to BOTH consumers: the renderer's agentStatus store (canvas badge)// and the mobile-facing mirror. Named so the deterministic-approval answer handler below can reusediff --git a/src/main/project-grants.test.ts b/src/main/project-grants.test.tsindex e8c544472..d7844ada9 100644--- a/src/main/project-grants.test.ts+++ b/src/main/project-grants.test.ts@@ -31,7 +31,7 @@ import {OPEN_PROJECT_LOCAL_ONLY,OPEN_PROJECT_CALLER_UNRESOLVED,OPEN_PROJECT_GRANT_CAP-} from './project-grants'+} from '../core/project-grants'beforeEach(() => clearAll())@@ -72,7 +72,7 @@ describe('the grant ledger is session-scoped (P3)', () => {it('the module is pure: no fs, no electron, no persistence path to write through', () => {// Structural, in the no-electron.test.ts style: the P3 claim "never persisted" is a property// of the SOURCE — an in-memory Map with no import that could reach a disk or the shell.- const src = fs.readFileSync(path.join(__dirname, 'project-grants.ts'), 'utf8')+ const src = fs.readFileSync(path.join(__dirname, '../core/project-grants.ts'), 'utf8')expect(src).not.toMatch(/from ['"]electron(\/[^'"]*)?['"]|require\(['"]electron/)expect(src).not.toMatch(/from ['"](node:)?fs['"]|require\(['"](node:)?fs['"]\)/)expect(src).not.toMatch(/from ['"](node:)?child_process['"]/)diff --git a/src/main/remote-ssh/remote-hooks.ts b/src/main/remote-ssh/remote-hooks.tsindex 80d58d34f..59b5bf968 100644--- a/src/main/remote-ssh/remote-hooks.ts+++ b/src/main/remote-ssh/remote-hooks.ts@@ -41,7 +41,7 @@ import {buildCanvasControlInstructions,buildCanvasSkillBody,mergeCanvasControlBlock-} from '../canvas-control-core'+} from '../../core/canvas-control-core'import {CONTEXT_SHIM_SCRIPT,buildContextLinkSkillBody,diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex e1836b311..41e3b7548 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -228,7 +228,7 @@ import {answerBrowserResolve,type BrowserResolveProject} from '../lib/controlRouting'-import { applyStickyWrite, parseStickyArgs, resolveStickyRef } from '../lib/stickyWrite'+import { applyStickyWrite, parseStickyArgs, resolveStickyRef } from '@shared/sticky-write'import {unavailableRecovery,planOpenProject,diff --git a/src/renderer/lib/projectOpen.ts b/src/renderer/lib/projectOpen.tsindex 33975f0d4..05155ee3d 100644--- a/src/renderer/lib/projectOpen.ts+++ b/src/renderer/lib/projectOpen.ts@@ -34,7 +34,7 @@ export function findProjectByCwd<T extends { cwd?: string }>(* pairs have already passed a human decision — creating, adopting, or the lighter first-attach* "Allow?" — so an idempotent re-open by the SAME caller does not re-raise the dialog, while a* DIFFERENT caller naming the same cwd still asks. DIALOG DEDUPE ONLY: authorization is main's- * grant ledger (src/main/project-grants.ts), keyed to main's own verified identity verdict; this+ * grant ledger (src/core/project-grants.ts), keyed to the core's own verified identity verdict; this* map decides nothing but whether a dialog is shown. In-memory, per app run — the same lifetime* as the grants it mirrors.*/diff --git a/src/renderer/lib/stickyWrite.test.ts b/src/renderer/lib/stickyWrite.test.tsindex 1edb189d0..bfc7eb579 100644--- a/src/renderer/lib/stickyWrite.test.ts+++ b/src/renderer/lib/stickyWrite.test.ts@@ -1,5 +1,5 @@import { describe, it, expect } from 'vitest'-import { applyStickyWrite, parseStickyArgs, resolveStickyRef, STICKY_TEXT_MAX } from './stickyWrite'+import { applyStickyWrite, parseStickyArgs, resolveStickyRef, STICKY_TEXT_MAX } from '@shared/sticky-write'const nodes = [{ id: 'sticky-1', sticky: true, title: 'Linear: my tickets' },diff --git a/src/shared/control-verbs.ts b/src/shared/control-verbs.tsindex 7e3609248..7c3aa4820 100644--- a/src/shared/control-verbs.ts+++ b/src/shared/control-verbs.ts@@ -2,7 +2,7 @@// set. Read the second half of that sentence literally — see WHAT THIS SET DOES NOT DO below.//// IN `src/shared` BECAUSE IT HAS TWO SIDES, and that is the whole point of this file existing.-// The set was defined in `src/main/canvas-control-core.ts` and the gate it describes lives in the+// The set was defined in `src/core/canvas-control-core.ts` and the gate it describes lives in the// renderer (`Canvas.tsx`'s `switch (verb)`), which cannot import from `src/main` — `tsconfig.web`// includes only `src/renderer`, `src/shared` and the preload types. So the set stayed a// security-shaped constant imported by nothing but its own unit test, whilediff --git a/src/renderer/lib/stickyWrite.ts b/src/shared/sticky-write.tssimilarity index 95%rename from src/renderer/lib/stickyWrite.tsrename to src/shared/sticky-write.tsindex 612e6648d..ca4bdf5a7 100644--- a/src/renderer/lib/stickyWrite.ts+++ b/src/shared/sticky-write.ts@@ -1,9 +1,9 @@// Pure model for the canvas-control `sticky` verb (issue #144): argument validation, resolving// which note a `--node <id|title>` ref names, and composing the note's next body from-// --text/--append. In lib/ so it is unit-testable off the Canvas dispatch — same reasoning as-// controlRouting, and the id-then-title convention follows kanban's `resolveColumnRef` ("agents+// --text/--append. In shared so both renderer and Server Edition use the exact same model, and the+// id-then-title convention follows kanban's `resolveColumnRef` ("agents// naturally pass a title; ids come from `list`").-import { oneLine } from '@shared/one-line'+import { oneLine } from './one-line'/** What the resolver needs to know about one canvas node. */export interface StickyCandidate {diff --git a/test/acceptance/open-project-chain.test.ts b/test/acceptance/open-project-chain.test.tsindex f40b32bad..d5c19615e 100644--- a/test/acceptance/open-project-chain.test.ts+++ b/test/acceptance/open-project-chain.test.ts@@ -20,7 +20,7 @@ import {gateProjectTarget,gateOpenProject,PROJECT_TARGET_REFUSED-} from '../../src/main/project-grants'+} from '../../src/core/project-grants'/*** Issue #338 Task 2.5 — THE CHAIN, once, against real primitives on both sides of the boundary: