This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

superconfig / 2configs / omp-collab-autostart.patch
4.0 kB 91 lines
1diff --git a/packages/coding-agent/src/collab/host.ts b/packages/coding-agent/src/collab/host.ts 2index 74a021a..45df271 100644 3--- a/packages/coding-agent/src/collab/host.ts 4+++ b/packages/coding-agent/src/collab/host.ts 5@@ -21,6 +21,7 @@ import type { 6 AgentEvent as WireAgentEvent, 7 SessionEntry as WireSessionEntry, 8 } from "@oh-my-pi/pi-wire"; 9+import { ROOM_KEY_BYTES, WRITE_TOKEN_BYTES } from "@oh-my-pi/pi-wire"; 10 import type { InteractiveModeContext } from "../modes/types"; 11 import { AgentLifecycleManager } from "../registry/agent-lifecycle"; 12 import { type AgentRef, AgentRegistry } from "../registry/agent-registry"; 13@@ -207,10 +208,14 @@ export class CollabHost { 14 } 15 } 16 17- async start(relayUrl: string, webUrl = ""): Promise<void> { 18- const rawKey = generateRoomKey(); 19- const writeToken = generateWriteToken(); 20- const roomId = generateRoomId(); 21+ async start( 22+ relayUrl: string, 23+ webUrl = "", 24+ preset?: { roomId: string; key: Uint8Array; writeToken: Uint8Array }, 25+ ): Promise<void> { 26+ const rawKey = preset?.key ?? generateRoomKey(); 27+ const writeToken = preset?.writeToken ?? generateWriteToken(); 28+ const roomId = preset?.roomId ?? generateRoomId(); 29 this.#writeToken = writeToken; 30 this.#link = formatCollabLink(relayUrl, roomId, rawKey, writeToken); 31 this.#webLink = formatCollabWebLink(relayUrl, roomId, rawKey, writeToken, webUrl); 32@@ -688,3 +693,32 @@ export class CollabHost { 33 this.#ctx.ui.requestRender(); 34 } 35 } 36+ 37+/** 38+ * covibe integration: when OMP_COLLAB_RELAY is set, start hosting headlessly on 39+ * boot using a caller-provided room id + key (OMP_COLLAB_ROOM / OMP_COLLAB_KEY, 40+ * base64url of key‖writeToken) so the orchestrator owns a stable, enumerable 41+ * link with no minting or scraping. Returns the live host, or undefined when no 42+ * relay is configured. 43+ */ 44+export async function maybeAutostartCollab(ctx: InteractiveModeContext): Promise<CollabHost | undefined> { 45+ const relay = process.env.OMP_COLLAB_RELAY; 46+ if (!relay) return undefined; 47+ const webUrl = process.env.OMP_COLLAB_WEB ?? ""; 48+ const roomId = process.env.OMP_COLLAB_ROOM; 49+ const keyB64 = process.env.OMP_COLLAB_KEY; 50+ let preset: { roomId: string; key: Uint8Array; writeToken: Uint8Array } | undefined; 51+ if (roomId && keyB64) { 52+ const secret = new Uint8Array(Buffer.from(keyB64, "base64url")); 53+ if (secret.byteLength === ROOM_KEY_BYTES + WRITE_TOKEN_BYTES) { 54+ preset = { 55+ roomId, 56+ key: secret.subarray(0, ROOM_KEY_BYTES), 57+ writeToken: secret.subarray(ROOM_KEY_BYTES), 58+ }; 59+ } 60+ } 61+ const host = new CollabHost(ctx); 62+ await host.start(relay, webUrl, preset); 63+ return host; 64+} 65diff --git a/packages/coding-agent/src/modes/interactive-mode.ts b/packages/coding-agent/src/modes/interactive-mode.ts 66index c2008d5..447f69b 100644 67--- a/packages/coding-agent/src/modes/interactive-mode.ts 68+++ b/packages/coding-agent/src/modes/interactive-mode.ts 69@@ -54,6 +54,7 @@ import chalk from "chalk"; 70 import { reset as resetCapabilities } from "../capability"; 71 import type { CollabGuestLink } from "../collab/guest"; 72 import type { CollabHost } from "../collab/host"; 73+import { maybeAutostartCollab } from "../collab/host"; 74 import { KeybindingsManager } from "../config/keybindings"; 75 import type { ResolvedModelRoleValue } from "../config/model-resolver"; 76 import { applyProviderGlobalsFromSettings } from "../config/provider-globals"; 77@@ -1091,6 +1092,14 @@ export class InteractiveMode implements InteractiveModeContext { 78 this.statusLine.watchBranch(() => { 79 this.ui.requestRender(); 80 }); 81+ 82+ // covibe: headless collab autostart from env (OMP_COLLAB_*). Fire-and-forget 83+ // so the TUI is not blocked on the relay connect; attaches when it opens. 84+ void maybeAutostartCollab(this) 85+ .then(host => { 86+ if (host) this.collabHost = host; 87+ }) 88+ .catch((err: unknown) => logger.warn(`collab autostart failed: ${String(err)}`)); 89 } 90 91 /** Reload the title-generation system prompt override for the provided working