@neuralnomads/codenomad-dev 1.1.0-dev-20261110-ac976439 → 1.1.0-dev-20261111-2f153e2e

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.
Files changed (56) hide show
  1. package/dist/opencode/design/register.test.js +1 -1
  2. package/dist/opencode/design/register.test.js.map +1 -1
  3. package/dist/opencode/desktop-plugin-readiness-ownership.test.js +71 -11
  4. package/dist/opencode/desktop-plugin-readiness-ownership.test.js.map +1 -1
  5. package/dist/opencode/desktop-plugin-readiness.js +24 -9
  6. package/dist/opencode/desktop-plugin-readiness.js.map +1 -1
  7. package/dist/plugins/automation/plugin.mjs +21 -7
  8. package/dist/plugins/memory/plugin.mjs +21 -7
  9. package/dist/plugins/missions/plugin.mjs +45 -31
  10. package/dist/plugins/session-pruning/plugin.mjs +21 -7
  11. package/package.json +2 -1
  12. package/public/assets/{App-QR8ba-y-.js → App-Dg0UAdVZ.js} +8 -8
  13. package/public/assets/{App-QR8ba-y-.js.map → App-Dg0UAdVZ.js.map} +1 -1
  14. package/public/assets/{FilesPanel-AYKPRMdg.js → FilesPanel-DsXM132G.js} +2 -2
  15. package/public/assets/{FilesPanel-AYKPRMdg.js.map → FilesPanel-DsXM132G.js.map} +1 -1
  16. package/public/assets/{StatusTab-CQJ3ee1d.js → StatusTab-DknJXs7j.js} +2 -2
  17. package/public/assets/{StatusTab-CQJ3ee1d.js.map → StatusTab-DknJXs7j.js.map} +1 -1
  18. package/public/assets/{agent-memory-cleanup-Crt6zw9B.js → agent-memory-cleanup-Boy48VOC.js} +2 -2
  19. package/public/assets/{agent-memory-cleanup-Crt6zw9B.js.map → agent-memory-cleanup-Boy48VOC.js.map} +1 -1
  20. package/public/assets/{app-tabs-6NZIUiUk.js → app-tabs-CnOLzRPp.js} +2 -2
  21. package/public/assets/{app-tabs-6NZIUiUk.js.map → app-tabs-CnOLzRPp.js.map} +1 -1
  22. package/public/assets/{client-state-DsQDz6MZ.js → client-state-BwT32pqz.js} +2 -2
  23. package/public/assets/{client-state-DsQDz6MZ.js.map → client-state-BwT32pqz.js.map} +1 -1
  24. package/public/assets/{client-state-O8K7Bczj.js → client-state-DlctTvkX.js} +2 -2
  25. package/public/assets/{client-state-O8K7Bczj.js.map → client-state-DlctTvkX.js.map} +1 -1
  26. package/public/assets/client-state-owner-commands-CrKtXVnv.js +2 -0
  27. package/public/assets/{client-state-owner-commands-DhYjQmdA.js.map → client-state-owner-commands-CrKtXVnv.js.map} +1 -1
  28. package/public/assets/{diff-viewer-B7k_JJ2j.js → diff-viewer-DvB6j-87.js} +2 -2
  29. package/public/assets/{diff-viewer-B7k_JJ2j.js.map → diff-viewer-DvB6j-87.js.map} +1 -1
  30. package/public/assets/{external-link-clicks-DT_KkgU8.js → external-link-clicks-BMqNLroa.js} +2 -2
  31. package/public/assets/{external-link-clicks-DT_KkgU8.js.map → external-link-clicks-BMqNLroa.js.map} +1 -1
  32. package/public/assets/{main-DlFS2W8Z.js → main-DiOHABRa.js} +80 -80
  33. package/public/assets/main-DiOHABRa.js.map +1 -0
  34. package/public/assets/{markdown-CW7_CYd7.js → markdown-CZbYG561.js} +2 -2
  35. package/public/assets/{markdown-CW7_CYd7.js.map → markdown-CZbYG561.js.map} +1 -1
  36. package/public/assets/{opener-startup-state-settings-card-DonzFV86.js → opener-startup-state-settings-card-DR79GQho.js} +2 -2
  37. package/public/assets/{opener-startup-state-settings-card-DonzFV86.js.map → opener-startup-state-settings-card-DR79GQho.js.map} +1 -1
  38. package/public/assets/{startup-state-settings-card-CL5Is8ZQ.js → startup-state-settings-card-Ds_zXNAi.js} +2 -2
  39. package/public/assets/{startup-state-settings-card-CL5Is8ZQ.js.map → startup-state-settings-card-Ds_zXNAi.js.map} +1 -1
  40. package/public/assets/{startup-state-settings-view-DJoV-Vg1.js → startup-state-settings-view-BARe0DnD.js} +2 -2
  41. package/public/assets/{startup-state-settings-view-DJoV-Vg1.js.map → startup-state-settings-view-BARe0DnD.js.map} +1 -1
  42. package/public/assets/{terminal-square-BhPTPJyU.js → terminal-square-Z3OtXFlS.js} +2 -2
  43. package/public/assets/{terminal-square-BhPTPJyU.js.map → terminal-square-Z3OtXFlS.js.map} +1 -1
  44. package/public/assets/{tool-call-BpcwGh7T.js → tool-call-DAz7ntjV.js} +4 -4
  45. package/public/assets/{tool-call-BpcwGh7T.js.map → tool-call-DAz7ntjV.js.map} +1 -1
  46. package/public/assets/{unified-picker-x3omUEsY.js → unified-picker-DYVgfOeS.js} +2 -2
  47. package/public/assets/{unified-picker-x3omUEsY.js.map → unified-picker-DYVgfOeS.js.map} +1 -1
  48. package/public/favicon.ico +0 -0
  49. package/public/index.html +1 -1
  50. package/public/pwa-64x64.png +0 -0
  51. package/public/sw.js +2 -1
  52. package/public/sw.js.map +1 -1
  53. package/public/{workbox-60d14903.js → workbox-49a728ca.js} +3 -2
  54. package/public/{workbox-60d14903.js.map → workbox-49a728ca.js.map} +1 -1
  55. package/public/assets/client-state-owner-commands-DhYjQmdA.js +0 -2
  56. package/public/assets/main-DlFS2W8Z.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"desktop-plugin-readiness.js","sourceRoot":"","sources":["../../src/opencode/desktop-plugin-readiness.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAmB,MAAM,kBAAkB,CAAA;AACrG,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAE1D,0EAA0E;AAC1E,mFAAmF;AACnF,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,CAAA;AACtC,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAA;AACxC,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,CAAA;AACvC,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AI,IAAI,EAAE,CAAC;gBACtC,KAAK,EAAE,CAAA;gBACP,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;oBAAE,SAAQ;gBAC3F,KAAK,EAAE,CAAA;gBACP,yEAAyE;gBACzE,IAAI,CAAC;oBACH,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,KAAK,EAAE,WAAW,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,CAAA;gBACtG,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBAAC,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ;wBAAE,MAAM,KAAK,CAAA;gBAAC,CAAC;gBACvF,KAAK,EAAE,CAAA;YACT,CAAC;QACH,CAAC;QACD,KAAK,CAAC,KAAK;YACT,MAAM,GAAG,IAAI,CAAA;YACb,uEAAuE;YACvE,IAAI,SAAS,EAAE,CAAC;gBAAC,MAAM,WAAW,CAAC,SAAS,CAAC,CAAC;gBAAC,SAAS,GAAG,SAAS,CAAA;YAAC,CAAC;YACtE,KAAK,MAAM,KAAK,IAAI,SAAS,CAAC,MAAM,EAAE;gBAAE,MAAM,WAAW,CAAC,KAAK,CAAC,CAAA;YAChE,SAAS,CAAC,KAAK,EAAE,CAAA;QACnB,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["import { randomUUID } from \"node:crypto\"\nimport { lstat, mkdir, open, opendir, rm, rmdir, writeFile, type FileHandle } from \"node:fs/promises\"\nimport path from \"node:path\"\nimport { setTimeout as delay } from \"node:timers/promises\"\n\n// Presence-owned pruning preparation v1. Uniform fresh challenges avoid a\n// first-activation cache: the native catalogue stays active across scope disposal.\nexport const READINESS_WAIT_MS = 5_000\nexport const READINESS_MAX_BYTES = 8_192\nexport const READINESS_MAX_PENDING = 32\nconst MAX_LEASES = 64\nconst MAX_RESPONSES = 64\n// Includes inert scopes after a crash; refuse admission without erasing foreign records.\nconst MAX_NAMESPACE_ENTRIES = 256\nconst UUID = /^[a-f\\d]{8}-[a-f\\d]{4}-[a-f\\d]{4}-[a-f\\d]{4}-[a-f\\d]{12}$/\nconst leaseName = (name: string) => name.endsWith(\".lease\") && UUID.test(name.slice(0, -6))\ntype Request = { version: 1; nonce: string; lease: string; directory: string; expires: number }\ntype Ack = Request & { incarnation: string }\nconst requestKeys = \"directory,expires,lease,nonce,version\"\n\nexport function isReadinessDirectory(directory: unknown): directory is string {\n return typeof directory === \"string\" && directory.length > 0 && Buffer.byteLength(directory) <= 4_096\n && !directory.includes(\"\\0\") && (path.posix.isAbsolute(directory) || path.win32.isAbsolute(directory))\n}\n\nfunction request(value: unknown): value is Request {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return false\n const v = value as Request\n return v.version === 1 && typeof v.nonce === \"string\" && UUID.test(v.nonce)\n && typeof v.lease === \"string\" && leaseName(v.lease)\n && isReadinessDirectory(v.directory)\n && Number.isSafeInteger(v.expires) && v.expires > Date.now() && v.expires <= Date.now() + READINESS_WAIT_MS\n}\n\nasync function plainDirectory(directory: string, check: () => void) {\n check()\n const info = await lstat(directory)\n check()\n if (!info.isDirectory() || info.isSymbolicLink()) throw new Error(\"Invalid readiness directory\")\n}\n\n// Open bounded regular single-link files; pathname/handle identity also rejects\n// a link swapped between lstat and open (Windows has no portable O_NOFOLLOW).\nasync function read(file: string, check: () => void): Promise<unknown> {\n check()\n const before = await lstat(file, { bigint: true }).catch(() => undefined)\n check()\n if (!before?.isFile() || before.isSymbolicLink() || before.nlink !== 1n || before.size > BigInt(READINESS_MAX_BYTES)) return\n const handle = await open(file, \"r\").catch(() => undefined)\n if (!handle) { check(); return }\n try {\n check()\n const info = await handle.stat({ bigint: true })\n check()\n if (!info.isFile() || info.nlink !== 1n || info.ino !== before.ino || info.dev !== before.dev) return\n const buffer = Buffer.alloc(READINESS_MAX_BYTES + 1)\n const { bytesRead } = await handle.read(buffer, 0, buffer.length, 0)\n check()\n if (bytesRead > READINESS_MAX_BYTES) return\n try { return JSON.parse(buffer.toString(\"utf8\", 0, bytesRead)) } catch { return }\n } finally { await handle.close() }\n}\n\nasync function liveLease(file: string, check: () => void) {\n check()\n const info = await lstat(file).catch(() => undefined)\n check()\n return Boolean(info?.isFile() && !info.isSymbolicLink() && info.nlink === 1\n && Date.now() - info.mtimeMs >= -1_000 && Date.now() - info.mtimeMs < 15_000)\n}\n\nasync function names(directory: string, max: number, check: () => void) {\n check()\n const stream = await opendir(directory).catch((error: NodeJS.ErrnoException) => {\n if (error.code !== \"ENOENT\") throw error\n return undefined\n })\n if (!stream) { check(); return [] }\n const result: string[] = []\n try {\n check()\n for (let i = 0; i <= max; i++) {\n check()\n const entry = await stream.read()\n check()\n if (!entry) return result\n result.push(entry.name)\n }\n throw new Error(\"Readiness directory exceeds limit\")\n } finally { await stream.close() }\n}\n\ntype OwnedFile = { file: string; handle: FileHandle }\nasync function removeOwned(owned: OwnedFile) {\n try {\n const expected = await owned.handle.stat({ bigint: true })\n const actual = await lstat(owned.file, { bigint: true }).catch(() => undefined)\n if (actual?.isFile() && !actual.isSymbolicLink() && actual.nlink === 1n\n && actual.dev === expected.dev && actual.ino === expected.ino) await rm(owned.file, { force: true })\n } finally { await owned.handle.close() }\n}\n\nasync function createOwned(file: string, content: string, check: () => void): Promise<OwnedFile> {\n // EEXIST acquires nothing. Retain the handle, including across partial writes,\n // so a replacement at the same name never acquires our cleanup ownership.\n const owned = { file, handle: await open(file, \"wx\") }\n try { check(); await writeFile(owned.handle, content); return owned }\n catch (error) { await removeOwned(owned); throw error }\n}\n\n/** One owner per backend lease; close drains requests before removing the lease. */\nexport function ownReadiness(lease: string) {\n let closed = false\n const pending = new Set<Promise<unknown>>()\n const directory = `${lease}.prepare`\n let directoryIdentity: { dev: bigint; ino: bigint } | undefined\n return {\n prepare(location: string, signal: AbortSignal, assertCurrent: () => void, deadlineAt = Date.now() + READINESS_WAIT_MS): Promise<Ack> {\n const expires = Math.min(deadlineAt, Date.now() + READINESS_WAIT_MS)\n const check = () => {\n signal.throwIfAborted()\n if (closed) throw new Error(\"Readiness lease closed\")\n if (Date.now() >= expires) throw new Error(\"Pruning Location readiness timed out or unsupported\")\n assertCurrent()\n }\n check()\n if (pending.size >= READINESS_MAX_PENDING) throw new Error(\"Too many readiness requests\")\n const run = (async () => {\n const value: Request = { version: 1, nonce: randomUUID(), lease: path.basename(lease), directory: location, expires }\n if (!request(value)) throw new Error(\"Invalid readiness Location\")\n const content = JSON.stringify(value)\n if (Buffer.byteLength(content) > READINESS_MAX_BYTES) throw new Error(\"Readiness Location exceeds limit\")\n const file = path.join(directory, `${value.nonce}.json`)\n const ackFile = path.join(directory, `${value.nonce}.ack`)\n let owned: OwnedFile | undefined\n try {\n check()\n await plainDirectory(path.dirname(lease), check)\n check()\n await mkdir(directory).then(async () => { directoryIdentity = await lstat(directory, { bigint: true }) })\n .catch((error: NodeJS.ErrnoException) => { if (error.code !== \"EEXIST\") throw error })\n check()\n await plainDirectory(directory, check)\n if (!await liveLease(lease, check)) throw new Error(\"Readiness lease expired\")\n check()\n owned = await createOwned(file, content, check)\n check()\n while (true) {\n check()\n if (!await liveLease(lease, check)) throw new Error(\"Readiness lease expired\")\n const ack = await read(ackFile, check) as Ack | undefined\n check()\n if (ack && Object.keys(ack).sort().join(\",\") === `${requestKeys},incarnation`.split(\",\").sort().join(\",\")\n && request(ack) && UUID.test(ack.incarnation)\n && Object.keys(value).every(key => ack[key as keyof Request] === value[key as keyof Request])) {\n const scope = await read(path.join(path.dirname(lease), `${ack.incarnation}.scope`), check) as Record<string, unknown> | undefined\n check()\n if (scope && Object.keys(scope).sort().join(\",\") === \"directory,incarnation,version\"\n && scope.version === 1 && scope.incarnation === ack.incarnation && scope.directory === location) return ack\n }\n check()\n if (Date.now() >= value.expires) throw new Error(\"Pruning Location readiness timed out or unsupported\")\n await delay(100, undefined, { signal })\n check()\n }\n } finally {\n if (owned) await removeOwned(owned)\n }\n })()\n pending.add(run)\n void run.finally(() => pending.delete(run)).catch(() => {})\n return run\n },\n async close() {\n closed = true\n await Promise.allSettled([...pending])\n const actual = await lstat(directory, { bigint: true }).catch(() => undefined)\n if (directoryIdentity && actual?.isDirectory() && !actual.isSymbolicLink()\n && actual.dev === directoryIdentity.dev && actual.ino === directoryIdentity.ino) {\n await rmdir(directory).catch((error: NodeJS.ErrnoException) => {\n if (error.code !== \"ENOENT\" && error.code !== \"ENOTEMPTY\" && error.code !== \"EEXIST\") throw error\n })\n }\n },\n }\n}\n\n/** Acquired only after actual RPC registration; renewed for each scope incarnation. */\nexport function registeredReadiness(directory: string, location: string, current: () => void) {\n const incarnation = randomUUID()\n const marker = path.join(directory, `${incarnation}.scope`)\n const responses = new Map<string, OwnedFile>()\n let published: OwnedFile | undefined\n let closed = false\n const check = () => { if (closed) throw new Error(\"Readiness scope closed\"); current() }\n return {\n async reconcile(leases: readonly string[]) {\n check()\n if (!published) {\n await plainDirectory(directory, check)\n check()\n const entries = await names(directory, MAX_NAMESPACE_ENTRIES, check)\n if (entries.length >= MAX_NAMESPACE_ENTRIES) throw new Error(\"Readiness namespace exceeds limit\")\n published = await createOwned(marker, JSON.stringify({ version: 1, directory: location, incarnation }), check)\n // Concurrent followers also validate after their exclusive creation.\n try { await names(directory, MAX_NAMESPACE_ENTRIES, check) }\n catch (error) { await removeOwned(published); published = undefined; throw error }\n check()\n }\n // Reclaim only our own responses whose request has gone; at most 64 held.\n for (const [file, owned] of responses) {\n check()\n const value = await read(file.slice(0, -4) + \".json\", check)\n check()\n if (request(value)) continue\n await removeOwned(owned)\n responses.delete(file)\n check()\n }\n if (leases.length > MAX_LEASES) throw new Error(\"Too many readiness leases\")\n const plan: Array<{ ackFile: string; value: Request }> = []\n for (const lease of leases) {\n check()\n if (!leaseName(lease) || !await liveLease(path.join(directory, lease), check)) continue\n const requests = path.join(directory, `${lease}.prepare`)\n const info = await lstat(requests).catch(() => undefined)\n check()\n if (!info) continue\n await plainDirectory(requests, check)\n const entries = await names(requests, READINESS_MAX_PENDING * 2, check)\n check()\n for (const entry of entries) {\n check()\n if (!entry.endsWith(\".json\") || !UUID.test(entry.slice(0, -5))) continue\n const file = path.join(requests, entry)\n const ackFile = file.slice(0, -5) + \".ack\"\n if (responses.has(ackFile)) continue\n const value = await read(file, check)\n check()\n if (!request(value) || Object.keys(value).sort().join(\",\") !== requestKeys\n || value.nonce !== entry.slice(0, -5) || value.lease !== lease || value.directory !== location) continue\n if (!await liveLease(path.join(directory, lease), check)) continue\n check()\n if (!request(value)) continue\n if (responses.size + plan.length >= MAX_RESPONSES) throw new Error(\"Too many readiness responses\")\n plan.push({ ackFile, value })\n }\n }\n // Validate the entire bounded snapshot before publishing consumable ACKs.\n for (const { ackFile, value } of plan) {\n check()\n if (!request(value) || !await liveLease(path.join(directory, value.lease), check)) continue\n check()\n // wx refuses a foreign or old scope's response rather than replacing it.\n try {\n responses.set(ackFile, await createOwned(ackFile, JSON.stringify({ ...value, incarnation }), check))\n } catch (error) { if ((error as NodeJS.ErrnoException).code !== \"EEXIST\") throw error }\n check()\n }\n },\n async close() {\n closed = true\n // Caller serializes reconciliation and joins any admitted write first.\n if (published) { await removeOwned(published); published = undefined }\n for (const owned of responses.values()) await removeOwned(owned)\n responses.clear()\n },\n }\n}\n"]}
1
+ {"version":3,"file":"desktop-plugin-readiness.js","sourceRoot":"","sources":["../../src/opencode/desktop-plugin-readiness.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAmB,MAAM,kBAAkB,CAAA;AACrG,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,UAAU,IAAI,KAAK,EA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AAS,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,KAAK,EAAE,WAAW,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,CAAA;gBACtG,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBAAC,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ;wBAAE,MAAM,KAAK,CAAA;gBAAC,CAAC;gBACvF,KAAK,EAAE,CAAA;YACT,CAAC;QACH,CAAC;QACD,KAAK,CAAC,KAAK;YACT,MAAM,GAAG,IAAI,CAAA;YACb,uEAAuE;YACvE,IAAI,SAAS,EAAE,CAAC;gBAAC,MAAM,WAAW,CAAC,SAAS,CAAC,CAAC;gBAAC,SAAS,GAAG,SAAS,CAAA;YAAC,CAAC;YACtE,IAAI,WAAW,EAAE,CAAC;gBAAC,MAAM,WAAW,CAAC,WAAW,CAAC,CAAC;gBAAC,WAAW,GAAG,SAAS,CAAA;YAAC,CAAC;YAC5E,KAAK,MAAM,KAAK,IAAI,SAAS,CAAC,MAAM,EAAE;gBAAE,MAAM,WAAW,CAAC,KAAK,CAAC,CAAA;YAChE,SAAS,CAAC,KAAK,EAAE,CAAA;QACnB,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["import { createHash, randomUUID } from \"node:crypto\"\nimport { lstat, mkdir, open, opendir, rm, rmdir, writeFile, type FileHandle } from \"node:fs/promises\"\nimport path from \"node:path\"\nimport { setTimeout as delay } from \"node:timers/promises\"\n\n// Presence-owned pruning preparation v1. Uniform fresh challenges avoid a\n// first-activation cache: the native catalogue stays active across scope disposal.\nexport const READINESS_WAIT_MS = 5_000\nexport const READINESS_MAX_BYTES = 8_192\nexport const READINESS_MAX_PENDING = 32\nconst MAX_LEASES = 64\nconst MAX_RESPONSES = 64\n// Per-Location reservations include crash residues; preserve foreign records.\nconst MAX_NAMESPACE_ENTRIES = 256\nconst UUID = /^[a-f\\d]{8}-[a-f\\d]{4}-[a-f\\d]{4}-[a-f\\d]{4}-[a-f\\d]{12}$/\nconst leaseName = (name: string) => name.endsWith(\".lease\") && UUID.test(name.slice(0, -6))\ntype Request = { version: 1; nonce: string; lease: string; directory: string; expires: number }\ntype Ack = Request & { incarnation: string }\nconst requestKeys = \"directory,expires,lease,nonce,version\"\n\nexport function isReadinessDirectory(directory: unknown): directory is string {\n return typeof directory === \"string\" && directory.length > 0 && Buffer.byteLength(directory) <= 4_096\n && !directory.includes(\"\\0\") && (path.posix.isAbsolute(directory) || path.win32.isAbsolute(directory))\n}\n\nfunction request(value: unknown): value is Request {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return false\n const v = value as Request\n return v.version === 1 && typeof v.nonce === \"string\" && UUID.test(v.nonce)\n && typeof v.lease === \"string\" && leaseName(v.lease)\n && isReadinessDirectory(v.directory)\n && Number.isSafeInteger(v.expires) && v.expires > Date.now() && v.expires <= Date.now() + READINESS_WAIT_MS\n}\n\nasync function plainDirectory(directory: string, check: () => void) {\n check()\n const info = await lstat(directory)\n check()\n if (!info.isDirectory() || info.isSymbolicLink()) throw new Error(\"Invalid readiness directory\")\n}\n\n// Open bounded regular single-link files; pathname/handle identity also rejects\n// a link swapped between lstat and open (Windows has no portable O_NOFOLLOW).\nasync function read(file: string, check: () => void): Promise<unknown> {\n check()\n const before = await lstat(file, { bigint: true }).catch(() => undefined)\n check()\n if (!before?.isFile() || before.isSymbolicLink() || before.nlink !== 1n || before.size > BigInt(READINESS_MAX_BYTES)) return\n const handle = await open(file, \"r\").catch(() => undefined)\n if (!handle) { check(); return }\n try {\n check()\n const info = await handle.stat({ bigint: true })\n check()\n if (!info.isFile() || info.nlink !== 1n || info.ino !== before.ino || info.dev !== before.dev) return\n const buffer = Buffer.alloc(READINESS_MAX_BYTES + 1)\n const { bytesRead } = await handle.read(buffer, 0, buffer.length, 0)\n check()\n if (bytesRead > READINESS_MAX_BYTES) return\n try { return JSON.parse(buffer.toString(\"utf8\", 0, bytesRead)) } catch { return }\n } finally { await handle.close() }\n}\n\nasync function liveLease(file: string, check: () => void) {\n check()\n const info = await lstat(file).catch(() => undefined)\n check()\n return Boolean(info?.isFile() && !info.isSymbolicLink() && info.nlink === 1\n && Date.now() - info.mtimeMs >= -1_000 && Date.now() - info.mtimeMs < 15_000)\n}\n\nasync function names(directory: string, max: number, check: () => void) {\n check()\n const stream = await opendir(directory).catch((error: NodeJS.ErrnoException) => {\n if (error.code !== \"ENOENT\") throw error\n return undefined\n })\n if (!stream) { check(); return [] }\n const result: string[] = []\n try {\n check()\n for (let i = 0; i <= max; i++) {\n check()\n const entry = await stream.read()\n check()\n if (!entry) return result\n result.push(entry.name)\n }\n throw new Error(\"Readiness directory exceeds limit\")\n } finally { await stream.close() }\n}\n\ntype OwnedFile = { file: string; handle: FileHandle }\nasync function removeOwned(owned: OwnedFile) {\n try {\n const expected = await owned.handle.stat({ bigint: true })\n const actual = await lstat(owned.file, { bigint: true }).catch(() => undefined)\n if (actual?.isFile() && !actual.isSymbolicLink() && actual.nlink === 1n\n && actual.dev === expected.dev && actual.ino === expected.ino) await rm(owned.file, { force: true })\n } finally { await owned.handle.close() }\n}\n\nasync function createOwned(file: string, content: string, check: () => void): Promise<OwnedFile> {\n // EEXIST acquires nothing. Retain the handle, including across partial writes,\n // so a replacement at the same name never acquires our cleanup ownership.\n const owned = { file, handle: await open(file, \"wx\") }\n try { check(); await writeFile(owned.handle, content); return owned }\n catch (error) { await removeOwned(owned); throw error }\n}\n\n/** One owner per backend lease; close drains requests before removing the lease. */\nexport function ownReadiness(lease: string) {\n let closed = false\n const pending = new Set<Promise<unknown>>()\n const directory = `${lease}.prepare`\n let directoryIdentity: { dev: bigint; ino: bigint } | undefined\n return {\n prepare(location: string, signal: AbortSignal, assertCurrent: () => void, deadlineAt = Date.now() + READINESS_WAIT_MS): Promise<Ack> {\n const expires = Math.min(deadlineAt, Date.now() + READINESS_WAIT_MS)\n const check = () => {\n signal.throwIfAborted()\n if (closed) throw new Error(\"Readiness lease closed\")\n if (Date.now() >= expires) throw new Error(\"Pruning Location readiness timed out or unsupported\")\n assertCurrent()\n }\n check()\n if (pending.size >= READINESS_MAX_PENDING) throw new Error(\"Too many readiness requests\")\n const run = (async () => {\n const value: Request = { version: 1, nonce: randomUUID(), lease: path.basename(lease), directory: location, expires }\n if (!request(value)) throw new Error(\"Invalid readiness Location\")\n const content = JSON.stringify(value)\n if (Buffer.byteLength(content) > READINESS_MAX_BYTES) throw new Error(\"Readiness Location exceeds limit\")\n const file = path.join(directory, `${value.nonce}.json`)\n const ackFile = path.join(directory, `${value.nonce}.ack`)\n let owned: OwnedFile | undefined\n try {\n check()\n await plainDirectory(path.dirname(lease), check)\n check()\n await mkdir(directory).then(async () => { directoryIdentity = await lstat(directory, { bigint: true }) })\n .catch((error: NodeJS.ErrnoException) => { if (error.code !== \"EEXIST\") throw error })\n check()\n await plainDirectory(directory, check)\n if (!await liveLease(lease, check)) throw new Error(\"Readiness lease expired\")\n check()\n owned = await createOwned(file, content, check)\n check()\n while (true) {\n check()\n if (!await liveLease(lease, check)) throw new Error(\"Readiness lease expired\")\n const ack = await read(ackFile, check) as Ack | undefined\n check()\n if (ack && Object.keys(ack).sort().join(\",\") === `${requestKeys},incarnation`.split(\",\").sort().join(\",\")\n && request(ack) && UUID.test(ack.incarnation)\n && Object.keys(value).every(key => ack[key as keyof Request] === value[key as keyof Request])) {\n const scope = await read(path.join(path.dirname(lease), `${ack.incarnation}.scope`), check) as Record<string, unknown> | undefined\n check()\n if (scope && Object.keys(scope).sort().join(\",\") === \"directory,incarnation,version\"\n && scope.version === 1 && scope.incarnation === ack.incarnation && scope.directory === location) return ack\n }\n check()\n if (Date.now() >= value.expires) throw new Error(\"Pruning Location readiness timed out or unsupported\")\n await delay(100, undefined, { signal })\n check()\n }\n } finally {\n if (owned) await removeOwned(owned)\n }\n })()\n pending.add(run)\n void run.finally(() => pending.delete(run)).catch(() => {})\n return run\n },\n async close() {\n closed = true\n await Promise.allSettled([...pending])\n const actual = await lstat(directory, { bigint: true }).catch(() => undefined)\n if (directoryIdentity && actual?.isDirectory() && !actual.isSymbolicLink()\n && actual.dev === directoryIdentity.dev && actual.ino === directoryIdentity.ino) {\n await rmdir(directory).catch((error: NodeJS.ErrnoException) => {\n if (error.code !== \"ENOENT\" && error.code !== \"ENOTEMPTY\" && error.code !== \"EEXIST\") throw error\n })\n }\n },\n }\n}\n\n/** Acquired only after actual RPC registration; renewed for each scope incarnation. */\nexport function registeredReadiness(directory: string, location: string, current: () => void) {\n const incarnation = randomUUID()\n const marker = path.join(directory, `${incarnation}.scope`)\n // Presence includes leases from other backends and scopes from other Locations.\n // Bound only this Location's registrations; retain the root marker's wire path.\n const namespaces = path.join(directory, \"readiness\")\n const namespace = path.join(namespaces, createHash(\"sha256\").update(location).digest(\"hex\"))\n const responses = new Map<string, OwnedFile>()\n let published: OwnedFile | undefined\n let reservation: OwnedFile | undefined\n let closed = false\n const check = () => { if (closed) throw new Error(\"Readiness scope closed\"); current() }\n return {\n async reconcile(leases: readonly string[]) {\n check()\n if (!published) {\n await plainDirectory(directory, check)\n for (const folder of [namespaces, namespace]) {\n check()\n await mkdir(folder).catch((error: NodeJS.ErrnoException) => { if (error.code !== \"EEXIST\") throw error })\n await plainDirectory(folder, check)\n }\n const entries = await names(namespace, MAX_NAMESPACE_ENTRIES, check)\n if (entries.length >= MAX_NAMESPACE_ENTRIES) throw new Error(\"Readiness namespace exceeds limit\")\n reservation = await createOwned(path.join(namespace, `${incarnation}.claim`), \"\", check)\n try {\n // Concurrent followers validate their bounded Location before publishing proof.\n await names(namespace, MAX_NAMESPACE_ENTRIES, check)\n published = await createOwned(marker, JSON.stringify({ version: 1, directory: location, incarnation }), check)\n } catch (error) { await removeOwned(reservation); reservation = undefined; throw error }\n check()\n }\n // Reclaim only our own responses whose request has gone; at most 64 held.\n for (const [file, owned] of responses) {\n check()\n const value = await read(file.slice(0, -4) + \".json\", check)\n check()\n if (request(value)) continue\n await removeOwned(owned)\n responses.delete(file)\n check()\n }\n if (leases.length > MAX_LEASES) throw new Error(\"Too many readiness leases\")\n const plan: Array<{ ackFile: string; value: Request }> = []\n for (const lease of leases) {\n check()\n if (!leaseName(lease) || !await liveLease(path.join(directory, lease), check)) continue\n const requests = path.join(directory, `${lease}.prepare`)\n const info = await lstat(requests).catch(() => undefined)\n check()\n if (!info) continue\n await plainDirectory(requests, check)\n const entries = await names(requests, READINESS_MAX_PENDING * 2, check)\n check()\n for (const entry of entries) {\n check()\n if (!entry.endsWith(\".json\") || !UUID.test(entry.slice(0, -5))) continue\n const file = path.join(requests, entry)\n const ackFile = file.slice(0, -5) + \".ack\"\n if (responses.has(ackFile)) continue\n const value = await read(file, check)\n check()\n if (!request(value) || Object.keys(value).sort().join(\",\") !== requestKeys\n || value.nonce !== entry.slice(0, -5) || value.lease !== lease || value.directory !== location) continue\n if (!await liveLease(path.join(directory, lease), check)) continue\n check()\n if (!request(value)) continue\n if (responses.size + plan.length >= MAX_RESPONSES) throw new Error(\"Too many readiness responses\")\n plan.push({ ackFile, value })\n }\n }\n // Validate the entire bounded snapshot before publishing consumable ACKs.\n for (const { ackFile, value } of plan) {\n check()\n if (!request(value) || !await liveLease(path.join(directory, value.lease), check)) continue\n check()\n // wx refuses a foreign or old scope's response rather than replacing it.\n try {\n responses.set(ackFile, await createOwned(ackFile, JSON.stringify({ ...value, incarnation }), check))\n } catch (error) { if ((error as NodeJS.ErrnoException).code !== \"EEXIST\") throw error }\n check()\n }\n },\n async close() {\n closed = true\n // Caller serializes reconciliation and joins any admitted write first.\n if (published) { await removeOwned(published); published = undefined }\n if (reservation) { await removeOwned(reservation); reservation = undefined }\n for (const owned of responses.values()) await removeOwned(owned)\n responses.clear()\n },\n }\n}\n"]}
@@ -21755,7 +21755,7 @@ import path3 from "node:path";
21755
21755
  var DESIGN_REQUEST = JSON.stringify({ version: 1, design: true });
21756
21756
 
21757
21757
  // src/opencode/desktop-plugin-readiness.ts
21758
- import { randomUUID } from "node:crypto";
21758
+ import { createHash, randomUUID } from "node:crypto";
21759
21759
  import { lstat, mkdir as mkdir2, open as open3, opendir as opendir2, rm as rm2, rmdir, writeFile as writeFile2 } from "node:fs/promises";
21760
21760
  import path2 from "node:path";
21761
21761
  var READINESS_WAIT_MS = 5e3;
@@ -21863,8 +21863,11 @@ async function createOwned(file2, content2, check2) {
21863
21863
  function registeredReadiness(directory, location, current) {
21864
21864
  const incarnation = randomUUID();
21865
21865
  const marker = path2.join(directory, `${incarnation}.scope`);
21866
+ const namespaces = path2.join(directory, "readiness");
21867
+ const namespace = path2.join(namespaces, createHash("sha256").update(location).digest("hex"));
21866
21868
  const responses = /* @__PURE__ */ new Map();
21867
21869
  let published;
21870
+ let reservation;
21868
21871
  let closed = false;
21869
21872
  const check2 = () => {
21870
21873
  if (closed) throw new Error("Readiness scope closed");
@@ -21875,15 +21878,22 @@ function registeredReadiness(directory, location, current) {
21875
21878
  check2();
21876
21879
  if (!published) {
21877
21880
  await plainDirectory(directory, check2);
21878
- check2();
21879
- const entries = await names(directory, MAX_NAMESPACE_ENTRIES, check2);
21881
+ for (const folder of [namespaces, namespace]) {
21882
+ check2();
21883
+ await mkdir2(folder).catch((error62) => {
21884
+ if (error62.code !== "EEXIST") throw error62;
21885
+ });
21886
+ await plainDirectory(folder, check2);
21887
+ }
21888
+ const entries = await names(namespace, MAX_NAMESPACE_ENTRIES, check2);
21880
21889
  if (entries.length >= MAX_NAMESPACE_ENTRIES) throw new Error("Readiness namespace exceeds limit");
21881
- published = await createOwned(marker, JSON.stringify({ version: 1, directory: location, incarnation }), check2);
21890
+ reservation = await createOwned(path2.join(namespace, `${incarnation}.claim`), "", check2);
21882
21891
  try {
21883
- await names(directory, MAX_NAMESPACE_ENTRIES, check2);
21892
+ await names(namespace, MAX_NAMESPACE_ENTRIES, check2);
21893
+ published = await createOwned(marker, JSON.stringify({ version: 1, directory: location, incarnation }), check2);
21884
21894
  } catch (error62) {
21885
- await removeOwned(published);
21886
- published = void 0;
21895
+ await removeOwned(reservation);
21896
+ reservation = void 0;
21887
21897
  throw error62;
21888
21898
  }
21889
21899
  check2();
@@ -21943,6 +21953,10 @@ function registeredReadiness(directory, location, current) {
21943
21953
  await removeOwned(published);
21944
21954
  published = void 0;
21945
21955
  }
21956
+ if (reservation) {
21957
+ await removeOwned(reservation);
21958
+ reservation = void 0;
21959
+ }
21946
21960
  for (const owned of responses.values()) await removeOwned(owned);
21947
21961
  responses.clear();
21948
21962
  }
@@ -21343,7 +21343,7 @@ import path3 from "node:path";
21343
21343
  var DESIGN_REQUEST = JSON.stringify({ version: 1, design: true });
21344
21344
 
21345
21345
  // src/opencode/desktop-plugin-readiness.ts
21346
- import { randomUUID } from "node:crypto";
21346
+ import { createHash, randomUUID } from "node:crypto";
21347
21347
  import { lstat, mkdir as mkdir2, open as open3, opendir as opendir2, rm as rm2, rmdir, writeFile as writeFile2 } from "node:fs/promises";
21348
21348
  import path2 from "node:path";
21349
21349
  var READINESS_WAIT_MS = 5e3;
@@ -21451,8 +21451,11 @@ async function createOwned(file2, content2, check2) {
21451
21451
  function registeredReadiness(directory, location, current) {
21452
21452
  const incarnation = randomUUID();
21453
21453
  const marker = path2.join(directory, `${incarnation}.scope`);
21454
+ const namespaces = path2.join(directory, "readiness");
21455
+ const namespace = path2.join(namespaces, createHash("sha256").update(location).digest("hex"));
21454
21456
  const responses = /* @__PURE__ */ new Map();
21455
21457
  let published;
21458
+ let reservation;
21456
21459
  let closed = false;
21457
21460
  const check2 = () => {
21458
21461
  if (closed) throw new Error("Readiness scope closed");
@@ -21463,15 +21466,22 @@ function registeredReadiness(directory, location, current) {
21463
21466
  check2();
21464
21467
  if (!published) {
21465
21468
  await plainDirectory(directory, check2);
21466
- check2();
21467
- const entries = await names(directory, MAX_NAMESPACE_ENTRIES, check2);
21469
+ for (const folder of [namespaces, namespace]) {
21470
+ check2();
21471
+ await mkdir2(folder).catch((error62) => {
21472
+ if (error62.code !== "EEXIST") throw error62;
21473
+ });
21474
+ await plainDirectory(folder, check2);
21475
+ }
21476
+ const entries = await names(namespace, MAX_NAMESPACE_ENTRIES, check2);
21468
21477
  if (entries.length >= MAX_NAMESPACE_ENTRIES) throw new Error("Readiness namespace exceeds limit");
21469
- published = await createOwned(marker, JSON.stringify({ version: 1, directory: location, incarnation }), check2);
21478
+ reservation = await createOwned(path2.join(namespace, `${incarnation}.claim`), "", check2);
21470
21479
  try {
21471
- await names(directory, MAX_NAMESPACE_ENTRIES, check2);
21480
+ await names(namespace, MAX_NAMESPACE_ENTRIES, check2);
21481
+ published = await createOwned(marker, JSON.stringify({ version: 1, directory: location, incarnation }), check2);
21472
21482
  } catch (error62) {
21473
- await removeOwned(published);
21474
- published = void 0;
21483
+ await removeOwned(reservation);
21484
+ reservation = void 0;
21475
21485
  throw error62;
21476
21486
  }
21477
21487
  check2();
@@ -21531,6 +21541,10 @@ function registeredReadiness(directory, location, current) {
21531
21541
  await removeOwned(published);
21532
21542
  published = void 0;
21533
21543
  }
21544
+ if (reservation) {
21545
+ await removeOwned(reservation);
21546
+ reservation = void 0;
21547
+ }
21534
21548
  for (const owned of responses.values()) await removeOwned(owned);
21535
21549
  responses.clear();
21536
21550
  }
@@ -21035,9 +21035,9 @@ var init_lifecycle_schema = __esm({
21035
21035
  });
21036
21036
 
21037
21037
  // src/missions/receipt-identity.ts
21038
- import { createHash } from "node:crypto";
21038
+ import { createHash as createHash2 } from "node:crypto";
21039
21039
  function stableToken(value, length2 = 26) {
21040
- return createHash("sha256").update(value).digest("hex").slice(0, length2);
21040
+ return createHash2("sha256").update(value).digest("hex").slice(0, length2);
21041
21041
  }
21042
21042
  function recurrenceMessageID(passageID) {
21043
21043
  return `msg_${stableToken(passageID, 28)}`;
@@ -21359,7 +21359,7 @@ var init_mission_title = __esm({
21359
21359
  });
21360
21360
 
21361
21361
  // src/missions/authority-protocol.ts
21362
- import { createHash as createHash4, createPublicKey, verify } from "node:crypto";
21362
+ import { createHash as createHash5, createPublicKey, verify } from "node:crypto";
21363
21363
  function rejectAuthority(code) {
21364
21364
  throw new MissionAuthorityError(code);
21365
21365
  }
@@ -21404,7 +21404,7 @@ function canonicalAuthority(value, maxBytes = AUTHORITY_MAX_BYTES) {
21404
21404
  return visit2(value, 0);
21405
21405
  }
21406
21406
  function authorityDigest(value) {
21407
- return createHash4("sha256").update(canonicalAuthority(value)).digest("hex");
21407
+ return createHash5("sha256").update(canonicalAuthority(value)).digest("hex");
21408
21408
  }
21409
21409
  var MISSION_AUTHORITY_POLICY, AUTHORITY_MAX_BYTES, AUTHORITY_ID_MAX_LENGTH, AUTHORITY_REQUEST_MAX_LENGTH, id3, requestID, revision, authorityRootSchema, authorityBindingSchema, header, authorityIntentSchema, signedAuthorityIntentSchema, authorityEffectResultSchema, MissionAuthorityError;
21410
21410
  var init_authority_protocol = __esm({
@@ -31210,7 +31210,7 @@ import path2 from "node:path";
31210
31210
  var DESIGN_REQUEST = JSON.stringify({ version: 1, design: true });
31211
31211
 
31212
31212
  // src/opencode/desktop-plugin-readiness.ts
31213
- import { randomUUID } from "node:crypto";
31213
+ import { createHash, randomUUID } from "node:crypto";
31214
31214
  import { lstat, mkdir, open, opendir, rm, rmdir, writeFile } from "node:fs/promises";
31215
31215
  import path from "node:path";
31216
31216
  var READINESS_WAIT_MS = 5e3;
@@ -31318,8 +31318,11 @@ async function createOwned(file2, content2, check2) {
31318
31318
  function registeredReadiness(directory, location5, current) {
31319
31319
  const incarnation2 = randomUUID();
31320
31320
  const marker5 = path.join(directory, `${incarnation2}.scope`);
31321
+ const namespaces = path.join(directory, "readiness");
31322
+ const namespace = path.join(namespaces, createHash("sha256").update(location5).digest("hex"));
31321
31323
  const responses = /* @__PURE__ */ new Map();
31322
31324
  let published;
31325
+ let reservation;
31323
31326
  let closed = false;
31324
31327
  const check2 = () => {
31325
31328
  if (closed) throw new Error("Readiness scope closed");
@@ -31330,15 +31333,22 @@ function registeredReadiness(directory, location5, current) {
31330
31333
  check2();
31331
31334
  if (!published) {
31332
31335
  await plainDirectory(directory, check2);
31333
- check2();
31334
- const entries = await names(directory, MAX_NAMESPACE_ENTRIES, check2);
31336
+ for (const folder of [namespaces, namespace]) {
31337
+ check2();
31338
+ await mkdir(folder).catch((error62) => {
31339
+ if (error62.code !== "EEXIST") throw error62;
31340
+ });
31341
+ await plainDirectory(folder, check2);
31342
+ }
31343
+ const entries = await names(namespace, MAX_NAMESPACE_ENTRIES, check2);
31335
31344
  if (entries.length >= MAX_NAMESPACE_ENTRIES) throw new Error("Readiness namespace exceeds limit");
31336
- published = await createOwned(marker5, JSON.stringify({ version: 1, directory: location5, incarnation: incarnation2 }), check2);
31345
+ reservation = await createOwned(path.join(namespace, `${incarnation2}.claim`), "", check2);
31337
31346
  try {
31338
- await names(directory, MAX_NAMESPACE_ENTRIES, check2);
31347
+ await names(namespace, MAX_NAMESPACE_ENTRIES, check2);
31348
+ published = await createOwned(marker5, JSON.stringify({ version: 1, directory: location5, incarnation: incarnation2 }), check2);
31339
31349
  } catch (error62) {
31340
- await removeOwned(published);
31341
- published = void 0;
31350
+ await removeOwned(reservation);
31351
+ reservation = void 0;
31342
31352
  throw error62;
31343
31353
  }
31344
31354
  check2();
@@ -31398,6 +31408,10 @@ function registeredReadiness(directory, location5, current) {
31398
31408
  await removeOwned(published);
31399
31409
  published = void 0;
31400
31410
  }
31411
+ if (reservation) {
31412
+ await removeOwned(reservation);
31413
+ reservation = void 0;
31414
+ }
31401
31415
  for (const owned of responses.values()) await removeOwned(owned);
31402
31416
  responses.clear();
31403
31417
  }
@@ -32542,7 +32556,7 @@ init_mission_title();
32542
32556
  init_task_execution_mode();
32543
32557
 
32544
32558
  // src/missions/cleanup-projection.ts
32545
- import { createHash as createHash2 } from "node:crypto";
32559
+ import { createHash as createHash3 } from "node:crypto";
32546
32560
  var SETTLED_CLEANUP_HISTORY = 20;
32547
32561
  var MAX_PROJECTED_CLEANUPS = 2e3;
32548
32562
  function cleanupReference(event) {
@@ -32552,9 +32566,9 @@ function pendingCleanupTargets(deletion, events2) {
32552
32566
  return (deletion.cleanupTargets ?? []).filter((target3) => !events2.some((event) => isCleanupReceipt(event, deletion, target3.sessionID))).map((target3) => target3.sessionID);
32553
32567
  }
32554
32568
  function cleanupReceiptID(deletionID, sessionID3) {
32555
- return `evt_${createHash2("sha256").update(`${deletionID}\0cleanup\0${sessionID3}`).digest("hex").slice(0, 28)}`;
32569
+ return `evt_${createHash3("sha256").update(`${deletionID}\0cleanup\0${sessionID3}`).digest("hex").slice(0, 28)}`;
32556
32570
  }
32557
- var documentCleanupReceiptID = (deletionID) => `evt_${createHash2("sha256").update(`${deletionID}\0document-cleaned`).digest("hex").slice(0, 28)}`;
32571
+ var documentCleanupReceiptID = (deletionID) => `evt_${createHash3("sha256").update(`${deletionID}\0document-cleaned`).digest("hex").slice(0, 28)}`;
32558
32572
  function isDocumentCleanupReceipt(event, deletion) {
32559
32573
  return deletion.documentCleanup === true && event.type === "mission.document-cleaned" && event.missionID === deletion.missionID && event.projectID === deletion.projectID && event.deletionID === deletion.id && event.id === documentCleanupReceiptID(deletion.id);
32560
32574
  }
@@ -32945,9 +32959,9 @@ function missionFamilyTaskContexts(tasks) {
32945
32959
  }
32946
32960
 
32947
32961
  // src/missions/content-digest.ts
32948
- import { createHash as createHash3 } from "node:crypto";
32962
+ import { createHash as createHash4 } from "node:crypto";
32949
32963
  function contentDigest(text13) {
32950
- return createHash3("sha256").update(text13, "utf16le").digest("base64url");
32964
+ return createHash4("sha256").update(text13, "utf16le").digest("base64url");
32951
32965
  }
32952
32966
 
32953
32967
  // src/missions/mission-task-marks.ts
@@ -33806,7 +33820,7 @@ function missionCalendarPlans(doc, now, principalAnchorAt = now) {
33806
33820
 
33807
33821
  // src/missions/mission-calendar-placement.ts
33808
33822
  init_zod();
33809
- import { createHash as createHash5 } from "node:crypto";
33823
+ import { createHash as createHash6 } from "node:crypto";
33810
33824
  import { closeSync, constants, fstatSync, lstatSync, openSync, readSync, realpathSync, statSync } from "node:fs";
33811
33825
  import path4 from "node:path";
33812
33826
 
@@ -33829,7 +33843,7 @@ var missionCalendarPlacementSchema = external_exports.object({
33829
33843
  routing: external_exports.array(external_exports.object({ file: external_exports.string().min(1).max(4096), digest: external_exports.string().regex(/^[a-f0-9]{64}$/).nullable() }).strict()).max(128),
33830
33844
  gitEnvironmentDigest: external_exports.string().regex(/^[a-f0-9]{64}$/)
33831
33845
  }).strict();
33832
- var hash2 = (value) => createHash5("sha256").update(value).digest("hex");
33846
+ var hash2 = (value) => createHash6("sha256").update(value).digest("hex");
33833
33847
  var environment = () => hash2(JSON.stringify(Object.entries(process.env).filter(([key4]) => key4.startsWith("GIT_")).sort(([a], [b]) => a.localeCompare(b))));
33834
33848
  var capture = (directory) => {
33835
33849
  const named = lstatSync(directory, { bigint: true }), physical2 = realpathSync(directory), stat3 = statSync(physical2, { bigint: true });
@@ -45653,7 +45667,7 @@ import { Context as Context7, Effect as Effect12, Option as Option11, Predicate
45653
45667
 
45654
45668
  // src/opencode/missions/native-service-adapter.ts
45655
45669
  import { isDeepStrictEqual as isDeepStrictEqual8 } from "node:util";
45656
- import { createHash as createHash6 } from "node:crypto";
45670
+ import { createHash as createHash7 } from "node:crypto";
45657
45671
  import { Context as Context4, DateTime as DateTime2, Effect as Effect9, Option as Option8, Predicate as Predicate4, Schema as Schema42 } from "effect";
45658
45672
 
45659
45673
  // ../../node_modules/@opencode/schema/dist/session.js
@@ -47863,7 +47877,7 @@ init_execution();
47863
47877
  var sessionTag2 = Context4.Service("@opencode/Session");
47864
47878
  var locationTag3 = Context4.Service("@opencode/Location");
47865
47879
  function nativePassageMessageDigest(value) {
47866
- return createHash6("sha256").update(canonicalAuthority(Schema42.encodeSync(session_message_exports.Info)(value), 256 * 1024)).digest("hex");
47880
+ return createHash7("sha256").update(canonicalAuthority(Schema42.encodeSync(session_message_exports.Info)(value), 256 * 1024)).digest("hex");
47867
47881
  }
47868
47882
  var method2 = Schema42.declare((value) => Predicate4.isFunction(value));
47869
47883
  var serviceShape = Schema42.Struct({ get: method2, create: method2, environment: method2, prompt: method2, synthetic: method2, inbox: method2 });
@@ -47981,7 +47995,7 @@ var acquireMissionNativeService = Effect9.fn("missions.acquireNativeService")(fu
47981
47995
  const anchor2 = yield* message({ sessionID: request2.sessionID, messageID: request2.afterMessageID });
47982
47996
  if (!anchor2 || !Predicate4.hasProperty(anchor2, "id") || anchor2.id !== request2.afterMessageID) rejectAuthority("observation-unavailable");
47983
47997
  anchorBytes = nativeBytes(anchor2);
47984
- if (request2.afterNativeDigest !== void 0 && createHash6("sha256").update(anchorBytes).digest("hex") !== request2.afterNativeDigest)
47998
+ if (request2.afterNativeDigest !== void 0 && createHash7("sha256").update(anchorBytes).digest("hex") !== request2.afterNativeDigest)
47985
47999
  rejectAuthority("observation-unavailable");
47986
48000
  }
47987
48001
  const prepared = messages({
@@ -48014,7 +48028,7 @@ var acquireMissionNativeService = Effect9.fn("missions.acquireNativeService")(fu
48014
48028
  const reference2 = {
48015
48029
  id: String(item.id),
48016
48030
  type: technical ? "technical" : item.type,
48017
- nativeDigest: createHash6("sha256").update(bytes2).digest("hex"),
48031
+ nativeDigest: createHash7("sha256").update(bytes2).digest("hex"),
48018
48032
  ...item.type === "assistant" && item.time.completed ? { completedAt: DateTime2.toEpochMillis(item.time.completed) } : {}
48019
48033
  };
48020
48034
  const complete = { ...reference2, text: text13 };
@@ -50233,7 +50247,7 @@ var controlNativeRecurrence = Effect19.fn("missions.controlNativeRecurrence")(fu
50233
50247
  // src/opencode/missions/native-recurrence-create.ts
50234
50248
  init_authority_protocol();
50235
50249
  import { Context as Context12, Effect as Effect20, Option as Option14, Schema as Schema48 } from "effect";
50236
- import { createHash as createHash7 } from "node:crypto";
50250
+ import { createHash as createHash8 } from "node:crypto";
50237
50251
  import { realpath as realpath4 } from "node:fs/promises";
50238
50252
  init_zod();
50239
50253
  var locationTag9 = Context12.Service("@opencode/Location");
@@ -50253,11 +50267,11 @@ var profileScope = external_exports.object({
50253
50267
  key: external_exports.string().regex(/^[a-f0-9]{64}$/)
50254
50268
  }).strict();
50255
50269
  var recurrenceScheduleID = (projectID, canonical, requestID4) => `rcs_${stableToken(`${projectID}\0${canonical}\0${requestID4}`, 40)}`;
50256
- var recurrenceConfigDigest = (config2) => createHash7("sha256").update(canonicalAuthority(config2, 64 * 1024)).digest("hex");
50270
+ var recurrenceConfigDigest = (config2) => createHash8("sha256").update(canonicalAuthority(config2, 64 * 1024)).digest("hex");
50257
50271
  async function assertNativeRecurrenceCreateScope(directory, config2, rawScope, executionHost) {
50258
50272
  const scope = profileScope.parse(rawScope);
50259
50273
  const nativeHost = process.platform === "linux" && process.env.WSL_DISTRO_NAME ? `wsl:${process.env.WSL_DISTRO_NAME}` : "local";
50260
- if (scope.key !== createHash7("sha256").update(`${scope.channel}\0${scope.configIdentity}`).digest("hex") || config2.profileID !== scope.key || config2.executionHost !== executionHost || executionHost !== nativeHost) {
50274
+ if (scope.key !== createHash8("sha256").update(`${scope.channel}\0${scope.configIdentity}`).digest("hex") || config2.profileID !== scope.key || config2.executionHost !== executionHost || executionHost !== nativeHost) {
50261
50275
  throw new Error("Recurrence profile or host differs from its selected scope");
50262
50276
  }
50263
50277
  const checkout = await resolveRepoRoot(directory);
@@ -50920,7 +50934,7 @@ init_receipt_identity();
50920
50934
  var MISSION_SCHEDULE_CARRIER_SESSION_PREFIX = "ses_cn_schedule_";
50921
50935
 
50922
50936
  // src/opencode/missions/native-schedule-carrier-binding.ts
50923
- import { createHash as createHash8 } from "node:crypto";
50937
+ import { createHash as createHash9 } from "node:crypto";
50924
50938
  import { closeSync as closeSync4, fstatSync as fstatSync4, openSync as openSync4, readSync as readSync4 } from "node:fs";
50925
50939
  import path16 from "node:path";
50926
50940
  import { Effect as Effect26 } from "effect";
@@ -51124,7 +51138,7 @@ function assertNativeScheduleCarrierArtifacts(installation) {
51124
51138
  if (!count4) break;
51125
51139
  size2 += count4;
51126
51140
  }
51127
- if (size2 !== stat3.size || createHash8("sha256").update(bytes2.subarray(0, size2)).digest("hex") !== artifact.sha256)
51141
+ if (size2 !== stat3.size || createHash9("sha256").update(bytes2.subarray(0, size2)).digest("hex") !== artifact.sha256)
51128
51142
  throw new Error("schedule-carrier-artifact");
51129
51143
  } finally {
51130
51144
  closeSync4(fd);
@@ -52342,7 +52356,7 @@ function nativeScheduleOwnerBindings(ctx, run) {
52342
52356
  }
52343
52357
 
52344
52358
  // src/opencode/missions/native-schedule-provider-registration.ts
52345
- import { createHash as createHash9 } from "node:crypto";
52359
+ import { createHash as createHash10 } from "node:crypto";
52346
52360
  import { closeSync as closeSync5, constants as constants4, fstatSync as fstatSync5, lstatSync as lstatSync4, openSync as openSync5, readSync as readSync5 } from "node:fs";
52347
52361
  import path17 from "node:path";
52348
52362
  import { pathToFileURL } from "node:url";
@@ -52370,7 +52384,7 @@ function assertArtifacts(artifacts) {
52370
52384
  if (!read4) break;
52371
52385
  size2 += read4;
52372
52386
  }
52373
- if (size2 !== info2.size || createHash9("sha256").update(bytes2.subarray(0, size2)).digest("hex") !== artifact.sha256) throw unavailable();
52387
+ if (size2 !== info2.size || createHash10("sha256").update(bytes2.subarray(0, size2)).digest("hex") !== artifact.sha256) throw unavailable();
52374
52388
  } finally {
52375
52389
  closeSync5(fd);
52376
52390
  }
@@ -52439,13 +52453,13 @@ import { Effect as Effect32 } from "effect";
52439
52453
  // src/missions/mission-local-sources.ts
52440
52454
  init_zod();
52441
52455
  init_authority_protocol();
52442
- import { createHash as createHash10 } from "node:crypto";
52456
+ import { createHash as createHash11 } from "node:crypto";
52443
52457
  import { execFile as execFile3 } from "node:child_process";
52444
52458
  import { constants as constants5 } from "node:fs";
52445
52459
  import fs2 from "node:fs/promises";
52446
52460
  import path18 from "node:path";
52447
52461
  import { promisify as promisify2 } from "node:util";
52448
- var hash3 = (value) => createHash10("sha256").update(value).digest("hex");
52462
+ var hash3 = (value) => createHash11("sha256").update(value).digest("hex");
52449
52463
  var same4 = (a, b) => canonicalAuthority(a) === canonicalAuthority(b);
52450
52464
  var fileProof = external_exports.object({ files: external_exports.array(external_exports.object({
52451
52465
  path: external_exports.string().min(1).max(4096),
@@ -22592,7 +22592,7 @@ function leaseRequestsDesign(content2) {
22592
22592
  }
22593
22593
 
22594
22594
  // src/opencode/desktop-plugin-readiness.ts
22595
- import { randomUUID as randomUUID3 } from "node:crypto";
22595
+ import { createHash as createHash9, randomUUID as randomUUID3 } from "node:crypto";
22596
22596
  import { lstat as lstat2, mkdir, open as open2, opendir, rm, rmdir, writeFile } from "node:fs/promises";
22597
22597
  import path8 from "node:path";
22598
22598
  var READINESS_WAIT_MS = 5e3;
@@ -22700,8 +22700,11 @@ async function createOwned(file2, content2, check2) {
22700
22700
  function registeredReadiness(directory2, location, current) {
22701
22701
  const incarnation = randomUUID3();
22702
22702
  const marker = path8.join(directory2, `${incarnation}.scope`);
22703
+ const namespaces = path8.join(directory2, "readiness");
22704
+ const namespace = path8.join(namespaces, createHash9("sha256").update(location).digest("hex"));
22703
22705
  const responses = /* @__PURE__ */ new Map();
22704
22706
  let published;
22707
+ let reservation;
22705
22708
  let closed = false;
22706
22709
  const check2 = () => {
22707
22710
  if (closed) throw new Error("Readiness scope closed");
@@ -22712,15 +22715,22 @@ function registeredReadiness(directory2, location, current) {
22712
22715
  check2();
22713
22716
  if (!published) {
22714
22717
  await plainDirectory(directory2, check2);
22715
- check2();
22716
- const entries = await names(directory2, MAX_NAMESPACE_ENTRIES, check2);
22718
+ for (const folder of [namespaces, namespace]) {
22719
+ check2();
22720
+ await mkdir(folder).catch((error62) => {
22721
+ if (error62.code !== "EEXIST") throw error62;
22722
+ });
22723
+ await plainDirectory(folder, check2);
22724
+ }
22725
+ const entries = await names(namespace, MAX_NAMESPACE_ENTRIES, check2);
22717
22726
  if (entries.length >= MAX_NAMESPACE_ENTRIES) throw new Error("Readiness namespace exceeds limit");
22718
- published = await createOwned(marker, JSON.stringify({ version: 1, directory: location, incarnation }), check2);
22727
+ reservation = await createOwned(path8.join(namespace, `${incarnation}.claim`), "", check2);
22719
22728
  try {
22720
- await names(directory2, MAX_NAMESPACE_ENTRIES, check2);
22729
+ await names(namespace, MAX_NAMESPACE_ENTRIES, check2);
22730
+ published = await createOwned(marker, JSON.stringify({ version: 1, directory: location, incarnation }), check2);
22721
22731
  } catch (error62) {
22722
- await removeOwned(published);
22723
- published = void 0;
22732
+ await removeOwned(reservation);
22733
+ reservation = void 0;
22724
22734
  throw error62;
22725
22735
  }
22726
22736
  check2();
@@ -22780,6 +22790,10 @@ function registeredReadiness(directory2, location, current) {
22780
22790
  await removeOwned(published);
22781
22791
  published = void 0;
22782
22792
  }
22793
+ if (reservation) {
22794
+ await removeOwned(reservation);
22795
+ reservation = void 0;
22796
+ }
22783
22797
  for (const owned2 of responses.values()) await removeOwned(owned2);
22784
22798
  responses.clear();
22785
22799
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neuralnomads/codenomad-dev",
3
- "version": "1.1.0-dev-20261110-ac976439",
3
+ "version": "1.1.0-dev-20261111-2f153e2e",
4
4
  "description": "CodeNomad Server",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -57,6 +57,7 @@
57
57
  "@types/node-forge": "^1.3.14",
58
58
  "@types/npm-package-arg": "^6.1.4",
59
59
  "@types/yauzl": "^2.10.0",
60
+ "ajv": "^6.12.6",
60
61
  "ajv2020": "npm:ajv@^8.20.0",
61
62
  "cross-env": "^7.0.3",
62
63
  "esbuild": "^0.28.2",