/** * The Monomind Mesh half of the opencode hook-shim plugin (see generateHooksPlugin). * * opencode runs plugins inside its own process, so the mesh helpers (.claude/helpers/mesh-inbox.cjs * and mesh-title.cjs, unchanged) are started as its children: their ancestor walk finds the * credentials the MCP server left under opencode's pid. Both fragments are free of backticks and * dollar-brace sequences so they embed in a template literal without escaping. */ /** Module-scope helpers; the plugin imports execFile from node:child_process. */ export declare const MESH_PLUGIN_HELPERS = "\n// Locate a helper beside the Claude tree; absent -> the mesh hooks no-op.\nfunction findHelper(worktree, directory, name) {\n for (const base of [worktree || \"\", directory || \"\"]) {\n const c = path.join(base, \".claude\", \"helpers\", name);\n try { if (fs.existsSync(c)) return c; } catch (e) {}\n }\n return null;\n}\n\n// Run a mesh helper with node (process.execPath is opencode itself in a compiled build); \"\" on any failure.\nfunction meshRun(file, cwd, input) {\n return new Promise((resolve) => {\n if (!file) return resolve(\"\");\n try {\n const child = execFile(\"node\", [file], { cwd: cwd, encoding: \"utf-8\", timeout: 2500 }, (err, stdout) => {\n resolve(err ? \"\" : String(stdout || \"\").trim());\n });\n child.stdin.end(input || \"\");\n } catch (e) { resolve(\"\"); }\n });\n}\n"; /** Hook entries for the object the plugin returns (each ends with a comma). */ export declare const MESH_PLUGIN_HOOKS = "\n // Mesh inbox: unread messages from other agents ride along with the user's prompt.\n \"chat.message\": async (input, output) => {\n const text = await meshRun(findHelper(worktree, directory, \"mesh-inbox.cjs\"), worktree, \"\");\n if (!text || !output || !output.message || !Array.isArray(output.parts)) return;\n const id = \"prt_\" + (Date.now() * 4096).toString(16).padStart(12, \"0\") + Math.random().toString(36).slice(2, 16).padEnd(14, \"0\");\n output.parts.push({ id: id, sessionID: input.sessionID, messageID: output.message.id, type: \"text\", text: text, synthetic: true });\n },\n // Mesh name: title a new top-level session with the name it has on the mesh.\n event: async ({ event }) => {\n const info = event && event.type === \"session.created\" && event.properties && event.properties.info;\n if (!info || info.parentID || !ctx || !ctx.client) return;\n const out = await meshRun(findHelper(worktree, directory, \"mesh-title.cjs\"), worktree, JSON.stringify({ cwd: worktree }));\n try {\n const title = JSON.parse(out).hookSpecificOutput.sessionTitle;\n if (title) await ctx.client.session.update({ path: { id: info.id }, body: { title: title } });\n } catch (e) {}\n },\n"; export declare const KILO_MESH_PLUGIN_FILE = ".kilo/plugin/monomind-mesh.js"; /** * Kilo (`kilo`, an opencode fork) mesh plugin: `.kilo/plugin/monomind-mesh.js`. * Checked against @kilocode/plugin 7.8.17 and @kilocode/sdk 7.8.17: the `chat.message` and `event` * hooks, `session.created` (properties.info.parentID), `client.session.update({path, body: {title}})` * and a text part with `synthetic` have the shapes the opencode plugin uses, and a plugin file is a * default-exported `{ id, server }` module. The same two helpers run as its children. */ export declare function generateKiloMeshPlugin(): string; //# sourceMappingURL=opencode-mesh-plugin.d.ts.map