From 1def139db68e14db5b6b4a5d80e409bdbe7da322 Mon Sep 17 00:00:00 2001 From: RiriAgent <39219425+RiriAgent@users.noreply.github.com> Date: Tue, 1 Dec 2026 23:20:49 +0900 Subject: [PATCH] fix: narrowed registry session checks with isLocalAgentSession for omp 19.4.0 compatibility - Added `isLocalAgentSession` guard in `DispatchRuntime.start` before comparing `root.sessionManager`. - Added `isLocalAgentSession` guard in host port binding before comparing `ref.session.sessionManager`. Refs #267 --- CHANGELOG.md | 4 ++++ index.ts | 9 ++++++++- src/ports/host.ts | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7efbc44..736b707 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Fixed + +- Type-checks against omp 19.4.0, whose session handles gained `getForkBaseline()`: Main and seat identity checks now compare only this process's local sessions, so `bun run check` passes again with unchanged runtime behavior + ## [0.4.0] - 2026-11-28 ### Breaking Changes diff --git a/index.ts b/index.ts index 79429e7..71206c3 100644 --- a/index.ts +++ b/index.ts @@ -3,6 +3,7 @@ import { z } from "@oh-my-pi/omptype/zod"; import type { ExtensionAPI, ExtensionContext } from "@oh-my-pi/pi-coding-agent"; import { InternalUrlRouter } from "@oh-my-pi/pi-coding-agent/internal-urls"; import { AgentRegistry, MAIN_AGENT_ID } from "@oh-my-pi/pi-coding-agent/registry/agent-registry"; +import { isLocalAgentSession } from "@oh-my-pi/pi-coding-agent/session/agent-session-handle"; import { logger } from "@oh-my-pi/pi-utils"; import { applyActiveTools } from "./omomp-shared/active-tools.ts"; import { tr } from "./omomp-shared/i18n.ts"; @@ -95,7 +96,13 @@ class ProcessRuntime { async start(pi: ExtensionAPI, ctx: ExtensionContext, identity: CoordinatorIdentity): Promise { if (this.started) return; const root = AgentRegistry.global().get(MAIN_AGENT_ID)?.session; - if (ctx.agent.id !== MAIN_AGENT_ID || ctx.agent.kind !== "main" || !root || root.sessionManager !== ctx.sessionManager) + if ( + ctx.agent.id !== MAIN_AGENT_ID || + ctx.agent.kind !== "main" || + !root || + !isLocalAgentSession(root) || + root.sessionManager !== ctx.sessionManager + ) throw new Error("Dispatch requires the actual native Main"); this.started = true; this.binding = { pi, ctx }; diff --git a/src/ports/host.ts b/src/ports/host.ts index 202a883..27e967c 100644 --- a/src/ports/host.ts +++ b/src/ports/host.ts @@ -68,7 +68,7 @@ export function createHostPort(options: HostOptions): HostPort { return { bind(ctx) { const ref = registry.get(ctx.agent.id); - if (!ref?.session || ref.session.sessionManager !== ctx.sessionManager) + if (!ref?.session || !isLocalAgentSession(ref.session) || ref.session.sessionManager !== ctx.sessionManager) return { ok: false, error: { kind: "precondition", message: "Caller is not the current native session" } }; if (ref.id === MAIN_AGENT_ID && ref.kind === "main") return {