@tempad-dev/mcp 1.0.4 → 2.0.0

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 (107) hide show
  1. package/README.md +28 -10
  2. package/README.zh-Hans.md +24 -9
  3. package/dist/{acquire-DHwsqq0j.mjs → acquire-CCPjn86-.mjs} +4 -4
  4. package/dist/acquire-CCPjn86-.mjs.map +1 -0
  5. package/dist/{acquire-BtKFZ9Lz.mjs → acquire-C_qsbxdV.mjs} +1 -1
  6. package/dist/{bootstrap-B9-RyWlM.mjs → bootstrap-BkZ1dGkI.mjs} +33 -27
  7. package/dist/bootstrap-BkZ1dGkI.mjs.map +1 -0
  8. package/dist/cli.mjs +6 -6
  9. package/dist/cli.mjs.map +1 -1
  10. package/dist/client-binding-CvSSv9JC.mjs.map +1 -1
  11. package/dist/{cold-start-U3cW0q9T.mjs → cold-start-Cv4OAoez.mjs} +1 -1
  12. package/dist/{cold-start-DOy9JsIQ.mjs → cold-start-qMVT1cNu.mjs} +94 -47
  13. package/dist/cold-start-qMVT1cNu.mjs.map +1 -0
  14. package/dist/{config-Busa_Dqv.mjs → config-Qvh73WBD.mjs} +20 -73
  15. package/dist/config-Qvh73WBD.mjs.map +1 -0
  16. package/dist/{design-task-store-BHR54v8-.mjs → design-task-store-BQy2SO7l.mjs} +4 -3
  17. package/dist/design-task-store-BQy2SO7l.mjs.map +1 -0
  18. package/dist/durable-json-_WKesGDj.mjs.map +1 -1
  19. package/dist/{edge-BUf7gs4J.mjs → edge-DO3aAdn1.mjs} +9 -9
  20. package/dist/edge-DO3aAdn1.mjs.map +1 -0
  21. package/dist/{edge-CHzaTUFt.mjs → edge-DdEimtG9.mjs} +1 -1
  22. package/dist/{hook-receipts-QJU3AMoY.mjs → hook-receipts-BIUk86RJ.mjs} +2 -2
  23. package/dist/hook-receipts-BIUk86RJ.mjs.map +1 -0
  24. package/dist/host-context-9TVtjsSm.mjs.map +1 -1
  25. package/dist/{hub-control-UlA4Fncg.mjs → hub-control-C2jNTi3G.mjs} +3 -3
  26. package/dist/hub-control-C2jNTi3G.mjs.map +1 -0
  27. package/dist/{hub-runtime-DsEO9zvX.mjs → hub-runtime-ApgbrLQI.mjs} +500 -454
  28. package/dist/hub-runtime-ApgbrLQI.mjs.map +1 -0
  29. package/dist/{hub-runtime-DjdqIgGl.mjs → hub-runtime-BZ6Nrold.mjs} +1 -1
  30. package/dist/hub.mjs +2 -2
  31. package/dist/hub.mjs.map +1 -1
  32. package/dist/{identity-CCaDEwgc.mjs → identity-C80lcT6j.mjs} +2 -2
  33. package/dist/identity-C80lcT6j.mjs.map +1 -0
  34. package/dist/indexes-zYqwqnU6.mjs.map +1 -1
  35. package/dist/log-transport.mjs.map +1 -1
  36. package/dist/managed-runtime.mjs +12 -12
  37. package/dist/managed-runtime.mjs.map +1 -1
  38. package/dist/on-exit-leak-free-By20-eFK.mjs.map +1 -1
  39. package/dist/pino-BiEyUxFF.mjs.map +1 -1
  40. package/dist/pino-abstract-transport-BBwCGDga.mjs.map +1 -1
  41. package/dist/pino-file.mjs.map +1 -1
  42. package/dist/pino-worker.mjs.map +1 -1
  43. package/dist/{probe-BeWkMbzQ.mjs → probe-BBGkIAHT.mjs} +7 -15
  44. package/dist/probe-BBGkIAHT.mjs.map +1 -0
  45. package/dist/process-environment-DRRIdoL8.mjs.map +1 -1
  46. package/dist/{processes-CBoalzSk.mjs → processes-BL7g1Hvw.mjs} +1 -1
  47. package/dist/{processes-BCCE8As7.mjs → processes-BX-yLfvZ.mjs} +67 -36
  48. package/dist/processes-BX-yLfvZ.mjs.map +1 -0
  49. package/dist/proper-lockfile-BgKrOq5D.mjs.map +1 -1
  50. package/dist/{protocol-7m-E_iFu.mjs → protocol-DlkrVyMK.mjs} +2 -2
  51. package/dist/protocol-DlkrVyMK.mjs.map +1 -0
  52. package/dist/{protocol-COK3rM6m.mjs → protocol-G4tyEGD3.mjs} +1 -1
  53. package/dist/runtime-identity-D9V-g5M-.mjs.map +1 -1
  54. package/dist/runtime-installer.mjs +3 -3
  55. package/dist/runtime-installer.mjs.map +1 -1
  56. package/dist/runtime-manifest.json +96 -97
  57. package/dist/{runtime-platform-C-Yk9F3L.mjs → runtime-platform-CpunJOI4.mjs} +143 -43
  58. package/dist/runtime-platform-CpunJOI4.mjs.map +1 -0
  59. package/dist/{runtime-recovery-DaRaQ8qY.mjs → runtime-recovery-CPfCb3rY.mjs} +2 -2
  60. package/dist/runtime-recovery-CPfCb3rY.mjs.map +1 -0
  61. package/dist/{runtime-recovery-DAYSaVV2.mjs → runtime-recovery-CexhaHl_.mjs} +1 -1
  62. package/dist/runtime-verification.mjs +5 -5
  63. package/dist/schemas-ZDdPV7RQ.mjs.map +1 -1
  64. package/dist/{server-CsCpY0Ft.mjs → server-CyzfkzoZ.mjs} +2 -2
  65. package/dist/server-CyzfkzoZ.mjs.map +1 -0
  66. package/dist/{shared-S0dtOYq8.mjs → shared-BRxN9qqm.mjs} +1 -1
  67. package/dist/{shared--othnF1c.mjs → shared-avqQD-kX.mjs} +10 -7
  68. package/dist/shared-avqQD-kX.mjs.map +1 -0
  69. package/dist/src-BSnzZMvK.mjs.map +1 -1
  70. package/dist/{stable-edge-VAAxSYSS.mjs → stable-edge-C5C0Rx5t.mjs} +3 -3
  71. package/dist/stable-edge-C5C0Rx5t.mjs.map +1 -0
  72. package/dist/{startup-log-CYlFgdy5.mjs → startup-log-CVOxFwjV.mjs} +2 -2
  73. package/dist/startup-log-CVOxFwjV.mjs.map +1 -0
  74. package/dist/{startup-log-DqK2uwBd.mjs → startup-log-DUPFFTwJ.mjs} +1 -1
  75. package/dist/{state-6qFcvi-I.mjs → state-4Dz7r-_n.mjs} +2 -2
  76. package/dist/state-4Dz7r-_n.mjs.map +1 -0
  77. package/dist/{state-BrWBtYNG.mjs → state-DDpxeTVd.mjs} +1 -1
  78. package/dist/stdio-20SBFdww.mjs.map +1 -1
  79. package/dist/{supervisor-CesT-H5_.mjs → supervisor-IWbA-VOB.mjs} +40 -42
  80. package/dist/supervisor-IWbA-VOB.mjs.map +1 -0
  81. package/dist/{task-storage-recovery-I9lpYYX6.mjs → task-storage-recovery-CabVFMUg.mjs} +3 -3
  82. package/dist/task-storage-recovery-CabVFMUg.mjs.map +1 -0
  83. package/dist/thread-stream-worker.mjs.map +1 -1
  84. package/dist/types-kNTSQOnR.mjs.map +1 -1
  85. package/package.json +1 -1
  86. package/dist/acquire-DHwsqq0j.mjs.map +0 -1
  87. package/dist/bootstrap-B9-RyWlM.mjs.map +0 -1
  88. package/dist/cold-start-DOy9JsIQ.mjs.map +0 -1
  89. package/dist/config-Busa_Dqv.mjs.map +0 -1
  90. package/dist/design-task-store-BHR54v8-.mjs.map +0 -1
  91. package/dist/edge-BUf7gs4J.mjs.map +0 -1
  92. package/dist/hook-receipts-QJU3AMoY.mjs.map +0 -1
  93. package/dist/hub-control-UlA4Fncg.mjs.map +0 -1
  94. package/dist/hub-runtime-DsEO9zvX.mjs.map +0 -1
  95. package/dist/identity-CCaDEwgc.mjs.map +0 -1
  96. package/dist/probe-BeWkMbzQ.mjs.map +0 -1
  97. package/dist/processes-BCCE8As7.mjs.map +0 -1
  98. package/dist/protocol-7m-E_iFu.mjs.map +0 -1
  99. package/dist/runtime-platform-C-Yk9F3L.mjs.map +0 -1
  100. package/dist/runtime-recovery-DaRaQ8qY.mjs.map +0 -1
  101. package/dist/server-CsCpY0Ft.mjs.map +0 -1
  102. package/dist/shared--othnF1c.mjs.map +0 -1
  103. package/dist/stable-edge-VAAxSYSS.mjs.map +0 -1
  104. package/dist/startup-log-CYlFgdy5.mjs.map +0 -1
  105. package/dist/state-6qFcvi-I.mjs.map +0 -1
  106. package/dist/supervisor-CesT-H5_.mjs.map +0 -1
  107. package/dist/task-storage-recovery-I9lpYYX6.mjs.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"identity-CCaDEwgc.mjs","names":["z.object","z.literal","z\n .object","z.enum","z.string"],"sources":["../src/agent-clients/identity.ts"],"sourcesContent":["import type { AgentClient } from '@tempad-dev/shared'\n\nimport {\n AGENT_CLIENTS,\n AgentClientKindSchema,\n AgentClientSchema,\n DesignTaskIdSchema\n} from '@tempad-dev/shared'\nimport { z } from 'zod'\n\nimport type { ClientBinding } from './types'\n\nexport const ClientEventSchema = z.object({\n method: z.literal('notifications/tempad/client-event'),\n params: z\n .object({\n event: z.enum([\n 'connect',\n 'taskBound',\n 'Interrupt',\n 'Stop',\n 'SessionEnd',\n 'UserPromptSubmit'\n ]),\n kind: AgentClientKindSchema,\n sessionId: AgentClientSchema.shape.sessionId,\n taskId: DesignTaskIdSchema.optional(),\n turnId: z.string().min(1).max(256).optional()\n })\n .strict()\n})\n\nexport function runtimeIdentity(env: NodeJS.ProcessEnv): ClientBinding {\n const kind = env.CODEX_APP_TOOLS_PIPE_PATH\n ? 'codex-app'\n : env.CODEX_THREAD_ID || env.CODEX_SESSION_ID\n ? 'codex-cli'\n : env.CLAUDECODE || env.CLAUDE_CODE\n ? 'claude'\n : 'other'\n return {\n client: clientDescriptor(kind, env.CODEX_THREAD_ID || env.CODEX_SESSION_ID)\n }\n}\n\nexport function clientDescriptor(kind: AgentClient['kind'], sessionId?: string): AgentClient {\n return { kind, name: AGENT_CLIENTS[kind].name, ...(sessionId ? { sessionId } : {}) }\n}\n\nfunction object(value: unknown): Record<string, unknown> {\n return value && typeof value === 'object' && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : {}\n}\n\n/** Read host-supplied MCP metadata, never agent-authored tool arguments. */\nexport function bindRequestMetadata(binding: ClientBinding, meta: unknown): ClientBinding {\n const source = object(meta)\n let codex = source['x-codex-turn-metadata']\n if (typeof codex === 'string') {\n try {\n codex = JSON.parse(codex)\n } catch {\n codex = undefined\n }\n }\n const metadata = object(codex)\n const sessionId = metadata.thread_id\n const turnId = metadata.turn_id\n if (typeof sessionId !== 'string' || !sessionId || sessionId.length > 256) return binding\n // One MCP process can serve multiple conversations: identity is captured per request.\n const next: ClientBinding = {\n ...binding,\n client: clientDescriptor(\n ['other', 'unknown'].includes(binding.client.kind) ? 'codex' : binding.client.kind,\n sessionId\n )\n }\n if (typeof turnId === 'string' && turnId && turnId.length <= 256) next.turnId = turnId\n else if (sessionId !== binding.client.sessionId) delete next.turnId\n return next\n}\n"],"mappings":";;;;;;;;;AAYA,MAAa,oBAAoBA,SAAS;CACxC,QAAQC,QAAU,mCAAmC;CACrD,QAAQC,SACE;EACN,OAAOC,MAAO;GACZ;GACA;GACA;GACA;GACA;GACA;EACF,CAAC;EACD,MAAM;EACN,WAAW,kBAAkB,MAAM;EACnC,QAAQ,mBAAmB,SAAS;EACpC,QAAQC,OAAS,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,SAAS;CAC9C,CAAC,CAAC,CACD,OAAO;AACZ,CAAC;AAED,SAAgB,gBAAgB,KAAuC;CAQrE,OAAO,EACL,QAAQ,iBARG,IAAI,4BACb,cACA,IAAI,mBAAmB,IAAI,mBACzB,cACA,IAAI,cAAc,IAAI,cACpB,WACA,SAEyB,IAAI,mBAAmB,IAAI,gBAAgB,EAC5E;AACF;AAEA,SAAgB,iBAAiB,MAA2B,WAAiC;CAC3F,OAAO;EAAE;EAAM,MAAM,cAAc,KAAK,CAAC;EAAM,GAAI,YAAY,EAAE,UAAU,IAAI,CAAC;CAAG;AACrF;AAEA,SAAS,OAAO,OAAyC;CACvD,OAAO,SAAS,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,IAC5D,QACD,CAAC;AACP;;AAGA,SAAgB,oBAAoB,SAAwB,MAA8B;CAExF,IAAI,QADW,OAAO,IACL,CAAC,CAAC;CACnB,IAAI,OAAO,UAAU,UACnB,IAAI;EACF,QAAQ,KAAK,MAAM,KAAK;CAC1B,QAAQ;EACN,QAAQ,KAAA;CACV;CAEF,MAAM,WAAW,OAAO,KAAK;CAC7B,MAAM,YAAY,SAAS;CAC3B,MAAM,SAAS,SAAS;CACxB,IAAI,OAAO,cAAc,YAAY,CAAC,aAAa,UAAU,SAAS,KAAK,OAAO;CAElF,MAAM,OAAsB;EAC1B,GAAG;EACH,QAAQ,iBACN,CAAC,SAAS,SAAS,CAAC,CAAC,SAAS,QAAQ,OAAO,IAAI,IAAI,UAAU,QAAQ,OAAO,MAC9E,SACF;CACF;CACA,IAAI,OAAO,WAAW,YAAY,UAAU,OAAO,UAAU,KAAK,KAAK,SAAS;MAC3E,IAAI,cAAc,QAAQ,OAAO,WAAW,OAAO,KAAK;CAC7D,OAAO;AACT"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"probe-BeWkMbzQ.mjs","names":["z.object","z.literal","z.string","z\n .object","z.record","z.unknown","process","spawn","z.literal","z.number","delay"],"sources":["../src/runtime-update/registry.ts","../../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js","../../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js","../../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js","../../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js","../../../node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.js","../../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js","../../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.js","../../../node_modules/.pnpm/shebang-regex@3.0.0/node_modules/shebang-regex/index.js","../../../node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.js","../../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js","../../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js","../../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.js","../../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js","../../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.2_supports-color@7.2.0_zod@4.6.7/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js","../src/runtime-prototype/probe.ts"],"sourcesContent":["import { z } from 'zod'\n\nimport { MAX_ARCHIVE_BYTES } from './archive'\nimport { compareVersions, IntegritySchema, PACKAGE_NAME, VersionSchema } from './manifest'\nimport { sha256 } from './package'\n\nconst REGISTRY = 'https://registry.npmjs.org'\nconst MetadataSchema = z.object({\n name: z.literal(PACKAGE_NAME),\n version: VersionSchema,\n deprecated: z.string().optional(),\n dist: z.object({ integrity: IntegritySchema, tarball: z.string() })\n})\nexport type Release = { version: string; integrity: string; url: string; deprecated?: string }\n\nfunction releaseMetadata(value: unknown, version?: string): Release {\n const metadata = MetadataSchema.parse(value)\n const url = `${REGISTRY}/@tempad-dev/mcp/-/mcp-${metadata.version}.tgz`\n if (metadata.dist.tarball !== url || (version && version !== metadata.version))\n throw new Error('Registry metadata does not identify the requested official release.')\n return {\n version: metadata.version,\n integrity: metadata.dist.integrity,\n url,\n ...(metadata.deprecated ? { deprecated: metadata.deprecated } : {})\n }\n}\n\nasync function bytes(url: string, limit: number, timeout: number, fetcher: typeof fetch) {\n const controller = new AbortController()\n const timer = setTimeout(() => controller.abort(), timeout)\n let reader: ReadableStreamDefaultReader<Uint8Array> | undefined\n try {\n const response = await fetcher(url, {\n signal: controller.signal,\n redirect: 'error',\n credentials: 'omit',\n headers: { accept: 'application/json, application/octet-stream' }\n })\n if (!response.ok || !response.body)\n throw new Error(`Runtime registry returned HTTP ${response.status}.`)\n reader = response.body.getReader()\n const chunks: Buffer[] = []\n let size = 0\n while (true) {\n const next = await reader.read()\n if (next.done) break\n size += next.value.byteLength\n if (size > limit) throw new Error('Runtime registry response exceeds its byte limit.')\n chunks.push(Buffer.from(next.value))\n }\n return Buffer.concat(chunks)\n } finally {\n clearTimeout(timer)\n await reader?.cancel().catch(() => {})\n controller.abort()\n }\n}\n\nexport async function resolveRelease(\n selector: string,\n fetcher: typeof fetch = fetch\n): Promise<Release> {\n if (selector !== 'latest') VersionSchema.parse(selector)\n const body = await bytes(\n `${REGISTRY}/@tempad-dev%2fmcp/${selector}`,\n 2 * 1024 * 1024,\n 10_000,\n fetcher\n )\n return releaseMetadata(\n JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(body)),\n selector === 'latest' ? undefined : selector\n )\n}\n\n/** The stable tag is an upper bound, including when its publisher rolls it back. */\nexport async function releaseCatalog(current: string, fetcher: typeof fetch = fetch) {\n VersionSchema.parse(current)\n const body = await bytes(`${REGISTRY}/@tempad-dev%2fmcp`, 8 * 1024 * 1024, 10_000, fetcher)\n const catalog = z\n .object({\n name: z.literal(PACKAGE_NAME),\n 'dist-tags': z.object({ latest: VersionSchema }),\n versions: z.record(z.string(), z.unknown())\n })\n .parse(JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(body)))\n const latest = catalog['dist-tags'].latest\n releaseMetadata(catalog.versions[latest], latest)\n const releases = Object.keys(catalog.versions)\n .filter(\n (version) =>\n VersionSchema.safeParse(version).success &&\n compareVersions(version, current) > 0 &&\n compareVersions(version, latest) <= 0\n )\n .sort((a, b) => compareVersions(b, a))\n .map((version) => releaseMetadata(catalog.versions[version], version))\n return { latest, releases, fingerprint: sha256(JSON.stringify({ latest, releases })) }\n}\n\nexport function downloadRelease(release: Release, fetcher: typeof fetch = fetch) {\n VersionSchema.parse(release.version)\n IntegritySchema.parse(release.integrity)\n if (release.url !== `${REGISTRY}/@tempad-dev/mcp/-/mcp-${release.version}.tgz`)\n throw new Error('Runtime download must use the official npm artifact URL.')\n return bytes(release.url, MAX_ARCHIVE_BYTES, 120_000, fetcher)\n}\n","module.exports = isexe\nisexe.sync = sync\n\nvar fs = require('fs')\n\nfunction checkPathExt (path, options) {\n var pathext = options.pathExt !== undefined ?\n options.pathExt : process.env.PATHEXT\n\n if (!pathext) {\n return true\n }\n\n pathext = pathext.split(';')\n if (pathext.indexOf('') !== -1) {\n return true\n }\n for (var i = 0; i < pathext.length; i++) {\n var p = pathext[i].toLowerCase()\n if (p && path.substr(-p.length).toLowerCase() === p) {\n return true\n }\n }\n return false\n}\n\nfunction checkStat (stat, path, options) {\n if (!stat.isSymbolicLink() && !stat.isFile()) {\n return false\n }\n return checkPathExt(path, options)\n}\n\nfunction isexe (path, options, cb) {\n fs.stat(path, function (er, stat) {\n cb(er, er ? false : checkStat(stat, path, options))\n })\n}\n\nfunction sync (path, options) {\n return checkStat(fs.statSync(path), path, options)\n}\n","module.exports = isexe\nisexe.sync = sync\n\nvar fs = require('fs')\n\nfunction isexe (path, options, cb) {\n fs.stat(path, function (er, stat) {\n cb(er, er ? false : checkStat(stat, options))\n })\n}\n\nfunction sync (path, options) {\n return checkStat(fs.statSync(path), options)\n}\n\nfunction checkStat (stat, options) {\n return stat.isFile() && checkMode(stat, options)\n}\n\nfunction checkMode (stat, options) {\n var mod = stat.mode\n var uid = stat.uid\n var gid = stat.gid\n\n var myUid = options.uid !== undefined ?\n options.uid : process.getuid && process.getuid()\n var myGid = options.gid !== undefined ?\n options.gid : process.getgid && process.getgid()\n\n var u = parseInt('100', 8)\n var g = parseInt('010', 8)\n var o = parseInt('001', 8)\n var ug = u | g\n\n var ret = (mod & o) ||\n (mod & g) && gid === myGid ||\n (mod & u) && uid === myUid ||\n (mod & ug) && myUid === 0\n\n return ret\n}\n","var fs = require('fs')\nvar core\nif (process.platform === 'win32' || global.TESTING_WINDOWS) {\n core = require('./windows.js')\n} else {\n core = require('./mode.js')\n}\n\nmodule.exports = isexe\nisexe.sync = sync\n\nfunction isexe (path, options, cb) {\n if (typeof options === 'function') {\n cb = options\n options = {}\n }\n\n if (!cb) {\n if (typeof Promise !== 'function') {\n throw new TypeError('callback not provided')\n }\n\n return new Promise(function (resolve, reject) {\n isexe(path, options || {}, function (er, is) {\n if (er) {\n reject(er)\n } else {\n resolve(is)\n }\n })\n })\n }\n\n core(path, options || {}, function (er, is) {\n // ignore EACCES because that just means we aren't allowed to run it\n if (er) {\n if (er.code === 'EACCES' || options && options.ignoreErrors) {\n er = null\n is = false\n }\n }\n cb(er, is)\n })\n}\n\nfunction sync (path, options) {\n // my kingdom for a filtered catch\n try {\n return core.sync(path, options || {})\n } catch (er) {\n if (options && options.ignoreErrors || er.code === 'EACCES') {\n return false\n } else {\n throw er\n }\n }\n}\n","const isWindows = process.platform === 'win32' ||\n process.env.OSTYPE === 'cygwin' ||\n process.env.OSTYPE === 'msys'\n\nconst path = require('path')\nconst COLON = isWindows ? ';' : ':'\nconst isexe = require('isexe')\n\nconst getNotFoundError = (cmd) =>\n Object.assign(new Error(`not found: ${cmd}`), { code: 'ENOENT' })\n\nconst getPathInfo = (cmd, opt) => {\n const colon = opt.colon || COLON\n\n // If it has a slash, then we don't bother searching the pathenv.\n // just check the file itself, and that's it.\n const pathEnv = cmd.match(/\\//) || isWindows && cmd.match(/\\\\/) ? ['']\n : (\n [\n // windows always checks the cwd first\n ...(isWindows ? [process.cwd()] : []),\n ...(opt.path || process.env.PATH ||\n /* istanbul ignore next: very unusual */ '').split(colon),\n ]\n )\n const pathExtExe = isWindows\n ? opt.pathExt || process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM'\n : ''\n const pathExt = isWindows ? pathExtExe.split(colon) : ['']\n\n if (isWindows) {\n if (cmd.indexOf('.') !== -1 && pathExt[0] !== '')\n pathExt.unshift('')\n }\n\n return {\n pathEnv,\n pathExt,\n pathExtExe,\n }\n}\n\nconst which = (cmd, opt, cb) => {\n if (typeof opt === 'function') {\n cb = opt\n opt = {}\n }\n if (!opt)\n opt = {}\n\n const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt)\n const found = []\n\n const step = i => new Promise((resolve, reject) => {\n if (i === pathEnv.length)\n return opt.all && found.length ? resolve(found)\n : reject(getNotFoundError(cmd))\n\n const ppRaw = pathEnv[i]\n const pathPart = /^\".*\"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw\n\n const pCmd = path.join(pathPart, cmd)\n const p = !pathPart && /^\\.[\\\\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd\n : pCmd\n\n resolve(subStep(p, i, 0))\n })\n\n const subStep = (p, i, ii) => new Promise((resolve, reject) => {\n if (ii === pathExt.length)\n return resolve(step(i + 1))\n const ext = pathExt[ii]\n isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {\n if (!er && is) {\n if (opt.all)\n found.push(p + ext)\n else\n return resolve(p + ext)\n }\n return resolve(subStep(p, i, ii + 1))\n })\n })\n\n return cb ? step(0).then(res => cb(null, res), cb) : step(0)\n}\n\nconst whichSync = (cmd, opt) => {\n opt = opt || {}\n\n const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt)\n const found = []\n\n for (let i = 0; i < pathEnv.length; i ++) {\n const ppRaw = pathEnv[i]\n const pathPart = /^\".*\"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw\n\n const pCmd = path.join(pathPart, cmd)\n const p = !pathPart && /^\\.[\\\\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd\n : pCmd\n\n for (let j = 0; j < pathExt.length; j ++) {\n const cur = p + pathExt[j]\n try {\n const is = isexe.sync(cur, { pathExt: pathExtExe })\n if (is) {\n if (opt.all)\n found.push(cur)\n else\n return cur\n }\n } catch (ex) {}\n }\n }\n\n if (opt.all && found.length)\n return found\n\n if (opt.nothrow)\n return null\n\n throw getNotFoundError(cmd)\n}\n\nmodule.exports = which\nwhich.sync = whichSync\n","'use strict';\n\nconst pathKey = (options = {}) => {\n\tconst environment = options.env || process.env;\n\tconst platform = options.platform || process.platform;\n\n\tif (platform !== 'win32') {\n\t\treturn 'PATH';\n\t}\n\n\treturn Object.keys(environment).reverse().find(key => key.toUpperCase() === 'PATH') || 'Path';\n};\n\nmodule.exports = pathKey;\n// TODO: Remove this for the next major release\nmodule.exports.default = pathKey;\n","'use strict';\n\nconst path = require('path');\nconst which = require('which');\nconst getPathKey = require('path-key');\n\nfunction resolveCommandAttempt(parsed, withoutPathExt) {\n const env = parsed.options.env || process.env;\n const cwd = process.cwd();\n const hasCustomCwd = parsed.options.cwd != null;\n // Worker threads do not have process.chdir()\n const shouldSwitchCwd = hasCustomCwd && process.chdir !== undefined && !process.chdir.disabled;\n\n // If a custom `cwd` was specified, we need to change the process cwd\n // because `which` will do stat calls but does not support a custom cwd\n if (shouldSwitchCwd) {\n try {\n process.chdir(parsed.options.cwd);\n } catch (err) {\n /* Empty */\n }\n }\n\n let resolved;\n\n try {\n resolved = which.sync(parsed.command, {\n path: env[getPathKey({ env })],\n pathExt: withoutPathExt ? path.delimiter : undefined,\n });\n } catch (e) {\n /* Empty */\n } finally {\n if (shouldSwitchCwd) {\n process.chdir(cwd);\n }\n }\n\n // If we successfully resolved, ensure that an absolute path is returned\n // Note that when a custom `cwd` was used, we need to resolve to an absolute path based on it\n if (resolved) {\n resolved = path.resolve(hasCustomCwd ? parsed.options.cwd : '', resolved);\n }\n\n return resolved;\n}\n\nfunction resolveCommand(parsed) {\n return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);\n}\n\nmodule.exports = resolveCommand;\n","'use strict';\n\n// See http://www.robvanderwoude.com/escapechars.php\nconst metaCharsRegExp = /([()\\][%!^\"`<>&|;, *?])/g;\n\nfunction escapeCommand(arg) {\n // Escape meta chars\n arg = arg.replace(metaCharsRegExp, '^$1');\n\n return arg;\n}\n\nfunction escapeArgument(arg, doubleEscapeMetaChars) {\n // Convert to string\n arg = `${arg}`;\n\n // Algorithm below is based on https://qntm.org/cmd\n // It's slightly altered to disable JS backtracking to avoid hanging on specially crafted input\n // Please see https://github.com/moxystudio/node-cross-spawn/pull/160 for more information\n\n // Sequence of backslashes followed by a double quote:\n // double up all the backslashes and escape the double quote\n arg = arg.replace(/(?=(\\\\+?)?)\\1\"/g, '$1$1\\\\\"');\n\n // Sequence of backslashes followed by the end of the string\n // (which will become a double quote later):\n // double up all the backslashes\n arg = arg.replace(/(?=(\\\\+?)?)\\1$/, '$1$1');\n\n // All other backslashes occur literally\n\n // Quote the whole thing:\n arg = `\"${arg}\"`;\n\n // Escape meta chars\n arg = arg.replace(metaCharsRegExp, '^$1');\n\n // Double escape meta chars if necessary\n if (doubleEscapeMetaChars) {\n arg = arg.replace(metaCharsRegExp, '^$1');\n }\n\n return arg;\n}\n\nmodule.exports.command = escapeCommand;\nmodule.exports.argument = escapeArgument;\n","'use strict';\nmodule.exports = /^#!(.*)/;\n","'use strict';\nconst shebangRegex = require('shebang-regex');\n\nmodule.exports = (string = '') => {\n\tconst match = string.match(shebangRegex);\n\n\tif (!match) {\n\t\treturn null;\n\t}\n\n\tconst [path, argument] = match[0].replace(/#! ?/, '').split(' ');\n\tconst binary = path.split('/').pop();\n\n\tif (binary === 'env') {\n\t\treturn argument;\n\t}\n\n\treturn argument ? `${binary} ${argument}` : binary;\n};\n","'use strict';\n\nconst fs = require('fs');\nconst shebangCommand = require('shebang-command');\n\nfunction readShebang(command) {\n // Read the first 150 bytes from the file\n const size = 150;\n const buffer = Buffer.alloc(size);\n\n let fd;\n\n try {\n fd = fs.openSync(command, 'r');\n fs.readSync(fd, buffer, 0, size, 0);\n fs.closeSync(fd);\n } catch (e) { /* Empty */ }\n\n // Attempt to extract shebang (null is returned if not a shebang)\n return shebangCommand(buffer.toString());\n}\n\nmodule.exports = readShebang;\n","'use strict';\n\nconst path = require('path');\nconst resolveCommand = require('./util/resolveCommand');\nconst escape = require('./util/escape');\nconst readShebang = require('./util/readShebang');\n\nconst isWin = process.platform === 'win32';\nconst isExecutableRegExp = /\\.(?:com|exe)$/i;\nconst isCmdShimRegExp = /node_modules[\\\\/].bin[\\\\/][^\\\\/]+\\.cmd$/i;\n\nfunction detectShebang(parsed) {\n parsed.file = resolveCommand(parsed);\n\n const shebang = parsed.file && readShebang(parsed.file);\n\n if (shebang) {\n parsed.args.unshift(parsed.file);\n parsed.command = shebang;\n\n return resolveCommand(parsed);\n }\n\n return parsed.file;\n}\n\nfunction parseNonShell(parsed) {\n if (!isWin) {\n return parsed;\n }\n\n // Detect & add support for shebangs\n const commandFile = detectShebang(parsed);\n\n // We don't need a shell if the command filename is an executable\n const needsShell = !isExecutableRegExp.test(commandFile);\n\n // If a shell is required, use cmd.exe and take care of escaping everything correctly\n // Note that `forceShell` is an hidden option used only in tests\n if (parsed.options.forceShell || needsShell) {\n // Need to double escape meta chars if the command is a cmd-shim located in `node_modules/.bin/`\n // The cmd-shim simply calls execute the package bin file with NodeJS, proxying any argument\n // Because the escape of metachars with ^ gets interpreted when the cmd.exe is first called,\n // we need to double escape them\n const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);\n\n // Normalize posix paths into OS compatible paths (e.g.: foo/bar -> foo\\bar)\n // This is necessary otherwise it will always fail with ENOENT in those cases\n parsed.command = path.normalize(parsed.command);\n\n // Escape command & arguments\n parsed.command = escape.command(parsed.command);\n parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));\n\n const shellCommand = [parsed.command].concat(parsed.args).join(' ');\n\n parsed.args = ['/d', '/s', '/c', `\"${shellCommand}\"`];\n parsed.command = process.env.comspec || 'cmd.exe';\n parsed.options.windowsVerbatimArguments = true; // Tell node's spawn that the arguments are already escaped\n }\n\n return parsed;\n}\n\nfunction parse(command, args, options) {\n // Normalize arguments, similar to nodejs\n if (args && !Array.isArray(args)) {\n options = args;\n args = null;\n }\n\n args = args ? args.slice(0) : []; // Clone array to avoid changing the original\n options = Object.assign({}, options); // Clone object to avoid changing the original\n\n // Build our parsed object\n const parsed = {\n command,\n args,\n options,\n file: undefined,\n original: {\n command,\n args,\n },\n };\n\n // Delegate further parsing to shell or non-shell\n return options.shell ? parsed : parseNonShell(parsed);\n}\n\nmodule.exports = parse;\n","'use strict';\n\nconst isWin = process.platform === 'win32';\n\nfunction notFoundError(original, syscall) {\n return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {\n code: 'ENOENT',\n errno: 'ENOENT',\n syscall: `${syscall} ${original.command}`,\n path: original.command,\n spawnargs: original.args,\n });\n}\n\nfunction hookChildProcess(cp, parsed) {\n if (!isWin) {\n return;\n }\n\n const originalEmit = cp.emit;\n\n cp.emit = function (name, arg1) {\n // If emitting \"exit\" event and exit code is 1, we need to check if\n // the command exists and emit an \"error\" instead\n // See https://github.com/IndigoUnited/node-cross-spawn/issues/16\n if (name === 'exit') {\n const err = verifyENOENT(arg1, parsed);\n\n if (err) {\n return originalEmit.call(cp, 'error', err);\n }\n }\n\n return originalEmit.apply(cp, arguments); // eslint-disable-line prefer-rest-params\n };\n}\n\nfunction verifyENOENT(status, parsed) {\n if (isWin && status === 1 && !parsed.file) {\n return notFoundError(parsed.original, 'spawn');\n }\n\n return null;\n}\n\nfunction verifyENOENTSync(status, parsed) {\n if (isWin && status === 1 && !parsed.file) {\n return notFoundError(parsed.original, 'spawnSync');\n }\n\n return null;\n}\n\nmodule.exports = {\n hookChildProcess,\n verifyENOENT,\n verifyENOENTSync,\n notFoundError,\n};\n","'use strict';\n\nconst cp = require('child_process');\nconst parse = require('./lib/parse');\nconst enoent = require('./lib/enoent');\n\nfunction spawn(command, args, options) {\n // Parse the arguments\n const parsed = parse(command, args, options);\n\n // Spawn the child process\n const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);\n\n // Hook into child process \"exit\" event to emit an error if the command\n // does not exists, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16\n enoent.hookChildProcess(spawned, parsed);\n\n return spawned;\n}\n\nfunction spawnSync(command, args, options) {\n // Parse the arguments\n const parsed = parse(command, args, options);\n\n // Spawn the child process\n const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);\n\n // Analyze if the command does not exist, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16\n result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);\n\n return result;\n}\n\nmodule.exports = spawn;\nmodule.exports.spawn = spawn;\nmodule.exports.sync = spawnSync;\n\nmodule.exports._parse = parse;\nmodule.exports._enoent = enoent;\n","import spawn from 'cross-spawn';\nimport process from 'node:process';\nimport { PassThrough } from 'node:stream';\nimport { ReadBuffer, serializeMessage } from '../shared/stdio.js';\n/**\n * Environment variables to inherit by default, if an environment is not explicitly given.\n */\nexport const DEFAULT_INHERITED_ENV_VARS = process.platform === 'win32'\n ? [\n 'APPDATA',\n 'HOMEDRIVE',\n 'HOMEPATH',\n 'LOCALAPPDATA',\n 'PATH',\n 'PROCESSOR_ARCHITECTURE',\n 'SYSTEMDRIVE',\n 'SYSTEMROOT',\n 'TEMP',\n 'USERNAME',\n 'USERPROFILE',\n 'PROGRAMFILES'\n ]\n : /* list inspired by the default env inheritance of sudo */\n ['HOME', 'LOGNAME', 'PATH', 'SHELL', 'TERM', 'USER'];\n/**\n * Returns a default environment object including only environment variables deemed safe to inherit.\n */\nexport function getDefaultEnvironment() {\n const env = {};\n for (const key of DEFAULT_INHERITED_ENV_VARS) {\n const value = process.env[key];\n if (value === undefined) {\n continue;\n }\n if (value.startsWith('()')) {\n // Skip functions, which are a security risk.\n continue;\n }\n env[key] = value;\n }\n return env;\n}\n/**\n * Client transport for stdio: this will connect to a server by spawning a process and communicating with it over stdin/stdout.\n *\n * This transport is only available in Node.js environments.\n */\nexport class StdioClientTransport {\n constructor(server) {\n this._stderrStream = null;\n this._serverParams = server;\n this._readBuffer = new ReadBuffer({ maxBufferSize: server.maxBufferSize });\n if (server.stderr === 'pipe' || server.stderr === 'overlapped') {\n this._stderrStream = new PassThrough();\n }\n }\n /**\n * Starts the server process and prepares to communicate with it.\n */\n async start() {\n if (this._process) {\n throw new Error('StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.');\n }\n return new Promise((resolve, reject) => {\n this._process = spawn(this._serverParams.command, this._serverParams.args ?? [], {\n // merge default env with server env because mcp server needs some env vars\n env: {\n ...getDefaultEnvironment(),\n ...this._serverParams.env\n },\n stdio: ['pipe', 'pipe', this._serverParams.stderr ?? 'inherit'],\n shell: false,\n windowsHide: process.platform === 'win32',\n cwd: this._serverParams.cwd\n });\n this._process.on('error', error => {\n reject(error);\n this.onerror?.(error);\n });\n this._process.on('spawn', () => {\n resolve();\n });\n this._process.on('close', _code => {\n this._process = undefined;\n this.onclose?.();\n });\n this._process.stdin?.on('error', error => {\n this.onerror?.(error);\n });\n this._process.stdout?.on('data', chunk => {\n try {\n this._readBuffer.append(chunk);\n this.processReadBuffer();\n }\n catch (error) {\n this.onerror?.(error);\n this.close().catch(() => { });\n }\n });\n this._process.stdout?.on('error', error => {\n this.onerror?.(error);\n });\n if (this._stderrStream && this._process.stderr) {\n this._process.stderr.pipe(this._stderrStream);\n }\n });\n }\n /**\n * The stderr stream of the child process, if `StdioServerParameters.stderr` was set to \"pipe\" or \"overlapped\".\n *\n * If stderr piping was requested, a PassThrough stream is returned _immediately_, allowing callers to\n * attach listeners before the start method is invoked. This prevents loss of any early\n * error output emitted by the child process.\n */\n get stderr() {\n if (this._stderrStream) {\n return this._stderrStream;\n }\n return this._process?.stderr ?? null;\n }\n /**\n * The child process pid spawned by this transport.\n *\n * This is only available after the transport has been started.\n */\n get pid() {\n return this._process?.pid ?? null;\n }\n processReadBuffer() {\n while (true) {\n try {\n const message = this._readBuffer.readMessage();\n if (message === null) {\n break;\n }\n this.onmessage?.(message);\n }\n catch (error) {\n this.onerror?.(error);\n }\n }\n }\n async close() {\n if (this._process) {\n const processToClose = this._process;\n this._process = undefined;\n const closePromise = new Promise(resolve => {\n processToClose.once('close', () => {\n resolve();\n });\n });\n try {\n processToClose.stdin?.end();\n }\n catch {\n // ignore\n }\n await Promise.race([closePromise, new Promise(resolve => setTimeout(resolve, 2000).unref())]);\n if (processToClose.exitCode === null) {\n try {\n processToClose.kill('SIGTERM');\n }\n catch {\n // ignore\n }\n await Promise.race([closePromise, new Promise(resolve => setTimeout(resolve, 2000).unref())]);\n }\n if (processToClose.exitCode === null) {\n try {\n processToClose.kill('SIGKILL');\n }\n catch {\n // ignore\n }\n }\n }\n this._readBuffer.clear();\n }\n send(message) {\n return new Promise(resolve => {\n if (!this._process?.stdin) {\n throw new Error('Not connected');\n }\n const json = serializeMessage(message);\n if (this._process.stdin.write(json)) {\n resolve();\n }\n else {\n this._process.stdin.once('drain', resolve);\n }\n });\n }\n}\n//# sourceMappingURL=stdio.js.map","import { Client } from '@modelcontextprotocol/sdk/client/index.js'\nimport { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js'\nimport { ResultSchema } from '@modelcontextprotocol/sdk/types.js'\nimport { createHash } from 'node:crypto'\nimport { realpathSync, rmSync, writeFileSync } from 'node:fs'\nimport { join } from 'node:path'\nimport { setTimeout as delay } from 'node:timers/promises'\nimport { z } from 'zod'\n\nimport { hubEnvironment } from '../process-environment'\nimport { createPrivateTempDirectory, runtimeEndpoint } from '../runtime-platform'\nimport { contractHashes, readRuntimeContract } from '../stable-edge'\nimport { connectSocket, fingerprintBundle } from './processes'\nimport { ControlPeer, RECOVER_MS, SocketTransport } from './protocol'\nimport { ArtifactSchema } from './state'\n\n/** Run only an explicitly offered local entry, with private stores and no user host identity. */\nexport async function probeArtifact(entry: string) {\n entry = realpathSync(entry)\n const bundle = fingerprintBundle(entry)\n const root = createPrivateTempDirectory('tp-probe-')\n const transport = new StdioClientTransport({\n command: process.execPath,\n args: [entry, '--root', root],\n stderr: 'pipe',\n env: Object.fromEntries(\n Object.entries(hubEnvironment(process.env)).filter(\n (value): value is [string, string] => typeof value[1] === 'string'\n )\n )\n })\n let stderr = Buffer.alloc(0)\n transport.stderr?.on('data', (chunk: Buffer) => {\n stderr = Buffer.concat([stderr, chunk.subarray(-16_384)]).subarray(-16_384)\n })\n const client = new Client({ name: 'tempad-artifact-probe', version: '1' })\n const control = new ControlPeer()\n let pids: number[] | undefined\n let result:\n | {\n artifact: z.infer<typeof ArtifactSchema>\n contract: string\n wireHash: string\n presentationHash: string\n }\n | undefined\n let failure: unknown\n let phase = 'initialize'\n const started = performance.now()\n try {\n // Initial attachment can use the edge's full recovery budget. Allow the\n // following SDK exchange without extending any business-request deadline.\n await client.connect(transport, { timeout: RECOVER_MS + 5000 })\n phase = 'runtime-status'\n await control.connect(\n new SocketTransport(await connectSocket(runtimeEndpoint(root, 'supervisor.sock')))\n )\n const state = await control.request(\n { method: 'tempad/runtime-status' },\n ResultSchema.extend({\n handoffVersion: z.literal(1),\n hubPid: z.number().int().positive(),\n supervisorPid: z.number().int().positive()\n }),\n { timeout: 5000 }\n )\n pids = [state.hubPid, state.supervisorPid]\n phase = 'contract'\n const contract = await readRuntimeContract(client, AbortSignal.timeout(10_000), 5000)\n const artifact = ArtifactSchema.parse({\n entry,\n bundle,\n version: client.getServerVersion()!.version\n })\n if (fingerprintBundle(entry) !== bundle)\n throw new Error('Local runtime changed during verification.')\n result = {\n artifact,\n ...contractHashes(contract),\n contract: createHash('sha256')\n .update(JSON.stringify({ ...contract, pages: [...contract.pages] }))\n .digest('hex')\n }\n phase = 'shutdown'\n } catch (error) {\n failure = error\n } finally {\n await control.close()\n await client.close()\n await transport.close()\n }\n // No forced PID kill: an uncertain probe retains its private evidence and\n // cannot authorize activation. The prototype's idle-owner rule stops children.\n let exited = false\n for (let attempt = 0; pids && attempt < 60; attempt++) {\n exited = pids.every((pid) => {\n try {\n process.kill(pid, 0)\n return false\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ESRCH') return true\n throw error\n }\n })\n if (exited) break\n await delay(100)\n }\n if (!exited) {\n const diagnostic = {\n phase,\n elapsedMs: Math.round(performance.now() - started),\n pids,\n failure:\n failure instanceof Error ? (failure.stack ?? failure.message).slice(-16_384) : undefined,\n stderr: stderr.toString('utf8')\n }\n try {\n writeFileSync(join(root, 'probe-failure.json'), JSON.stringify(diagnostic), { mode: 0o600 })\n } catch {\n // Evidence collection must not replace the original failure or permit cleanup.\n }\n const reason = pids ? 'did not stop' : `ownership is unknown after ${phase} failed`\n // Release preparation runs this probe in a subprocess. Include its bounded\n // private diagnostic so an uncaught failure retains the evidence in stderr.\n throw Object.assign(\n new Error(`Local runtime probe ${reason}; preserve ${root} for diagnosis.`, {\n cause: failure\n }),\n { diagnostic }\n )\n }\n rmSync(root, { recursive: true, force: true })\n if (failure) throw failure\n return result!\n}\n"],"ignoreList":[1,2,3,4,5,6,7,8,9,10,11,12,13,14],"mappings":";;;;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AAY,IAAI,IAAI,OAAO;GACjD;GACA,SACE,mBAAmB,SAAS,QAAQ,SAAS,QAAQ,QAAA,CAAS,MAAM,MAAO,IAAI,KAAA;GACjF,QAAQ,OAAO,SAAS,MAAM;EAChC;EACA,IAAI;GACF,cAAc,KAAK,MAAM,oBAAoB,GAAG,KAAK,UAAU,UAAU,GAAG,EAAE,MAAM,IAAM,CAAC;EAC7F,QAAQ,CAER;EACA,MAAM,SAAS,OAAO,iBAAiB,8BAA8B,MAAM;EAG3E,MAAM,OAAO,OACX,IAAI,MAAM,uBAAuB,OAAO,aAAa,KAAK,kBAAkB,EAC1E,OAAO,QACT,CAAC,GACD,EAAE,WAAW,CACf;CACF;CACA,OAAO,MAAM;EAAE,WAAW;EAAM,OAAO;CAAK,CAAC;CAC7C,IAAI,SAAS,MAAM;CACnB,OAAO;AACT"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"processes-BCCE8As7.mjs","names":["z\n .string","z.string","z\n .object","z.literal","z.number","z\n .object","z.enum","z.object","z.array","z.boolean","z.record","z.object","z.literal","z.string","z.record","z.array","z\n .object","delay","lockfile"],"sources":["../src/runtime-update/manifest.ts","../src/runtime-update/archive.ts","../src/runtime-update/package.ts","../src/runtime-update/cache.ts","../src/runtime-update/artifact.ts","../src/runtime-prototype/processes.ts"],"sourcesContent":["import { z } from 'zod'\n\nexport const PACKAGE_NAME = '@tempad-dev/mcp'\nexport const MANIFEST_PATH = 'dist/runtime-manifest.json'\nexport const VersionSchema = z\n .string()\n .regex(/^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$/)\n .refine((value) => value.split('.').every((part) => Number.isSafeInteger(Number(part))))\nconst HashSchema = z.string().regex(/^[a-f0-9]{64}$/)\nexport const IntegritySchema = z.string().regex(/^sha512-[A-Za-z0-9+/]{86}==$/)\n\nexport function safePath(path: string): boolean {\n return (\n path.length > 0 &&\n path.length <= 1024 &&\n !/[\\\\:*?\"<>|]/.test(path) &&\n [...path].every((character) => character.charCodeAt(0) >= 32 && character !== '\\x7f') &&\n path\n .split('/')\n .every(\n (part) =>\n part.length > 0 &&\n !/[. ]$/.test(part) &&\n !/^(?:con|prn|aux|nul|com[1-9¹²³]|lpt[1-9¹²³])(?:\\.|$)/i.test(part)\n )\n )\n}\n\nexport const PolicySchema = z\n .object({\n version: z.literal(1),\n guidanceEpoch: z.number().int().positive(),\n guidanceReview: z\n .object({\n version: VersionSchema,\n sourceHash: HashSchema,\n decision: z.enum(['initial', 'compatible', 'new-epoch']),\n baseline: z.object({ version: VersionSchema, integrity: IntegritySchema }),\n rationale: z.string().min(24).max(4000)\n })\n .strict(),\n controlProtocols: z.array(z.number().int().positive()).min(1).max(16),\n state: z\n .object({\n family: z.string().min(1),\n reads: z.array(z.number().int().positive()).min(1),\n writes: z.number().int().positive()\n })\n .strict(),\n extension: z\n .object({ protocols: z.array(z.number().int().positive()).min(1), legacy: z.boolean() })\n .strict(),\n hookProtocol: z.literal(2)\n })\n .strict()\nexport type RuntimePolicy = z.infer<typeof PolicySchema>\n\nexport const ManifestSchema = PolicySchema.extend({\n name: z.literal(PACKAGE_NAME),\n packageVersion: VersionSchema,\n entry: z.literal('dist/managed-runtime.mjs'),\n node: z.string().min(1),\n platforms: z.array(z.enum(['darwin', 'linux', 'win32'])).min(1),\n wireHash: HashSchema,\n presentationHash: HashSchema,\n lockHash: HashSchema,\n files: z.record(z.string().refine(safePath), HashSchema)\n}).refine(\n (value) => value.packageVersion === value.guidanceReview.version,\n 'Guidance review belongs to another release.'\n)\nexport type RuntimeManifest = z.infer<typeof ManifestSchema>\n\nexport function compareVersions(a: string, b: string) {\n const left = VersionSchema.parse(a).split('.').map(Number)\n const right = VersionSchema.parse(b).split('.').map(Number)\n for (let index = 0; index < 3; index++) {\n if (left[index] !== right[index]) return Math.sign(left[index]! - right[index]!)\n }\n return 0\n}\n\n/** Fail closed on an engine expression this release's checker cannot interpret. */\nexport function supportsNode(range: string, version = process.versions.node) {\n const [major] = VersionSchema.parse(version).split('.').map(Number)\n const clauses = range.split('||').map((value) => value.trim())\n if (!clauses.every((value) => /^(?:\\^|>=)(?:0|[1-9]\\d*)$/.test(value)))\n throw new Error('Unsupported Node engine policy; update the release checker first.')\n return clauses.some((value) =>\n value.startsWith('^') ? major === Number(value.slice(1)) : major! >= Number(value.slice(2))\n )\n}\n\nfunction runtimeCompatibilityReasons(next: RuntimeManifest): string[] {\n const reasons: string[] = []\n try {\n if (!supportsNode(next.node)) reasons.push('Node restart/upgrade required')\n } catch {\n reasons.push('Node engine policy requires a newer runtime checker')\n }\n if (!next.platforms.includes(process.platform as 'darwin' | 'linux' | 'win32'))\n reasons.push('Unsupported platform')\n return reasons\n}\n\n/** Integrity alone never authorizes execution on an incompatible launcher. */\nexport function assertRunnable(manifest: RuntimeManifest) {\n const reasons = runtimeCompatibilityReasons(manifest)\n if (reasons.length) throw new Error(`This runtime cannot run: ${reasons.join('; ')}.`)\n}\n\nfunction stateCompatibilityReasons(active: RuntimeManifest, next: RuntimeManifest) {\n const reasons: string[] = []\n if (\n active.state.family !== next.state.family ||\n !next.state.reads.includes(active.state.writes) ||\n !active.state.reads.includes(next.state.writes)\n )\n reasons.push('State rollback compatibility is missing')\n if (\n (active.extension.legacy && !next.extension.legacy) ||\n !active.extension.protocols.every((value) => next.extension.protocols.includes(value))\n )\n reasons.push('Released extension compatibility is missing')\n return reasons\n}\n\nexport function compatibilityReasons(active: RuntimeManifest, next: RuntimeManifest): string[] {\n const reasons = runtimeCompatibilityReasons(next)\n if (active.wireHash !== next.wireHash) reasons.push('MCP contract changed; restart MCP')\n if (active.guidanceEpoch !== next.guidanceEpoch)\n reasons.push('Guidance epoch changed; restart MCP')\n if (!active.controlProtocols.every((value) => next.controlProtocols.includes(value)))\n reasons.push('Control component restart required')\n return [...reasons, ...stateCompatibilityReasons(active, next)]\n}\n\n/** Automatic consent never crosses a breaking-release boundary. */\nexport function crossesBreakingBoundary(active: string, next: string) {\n const [major, minor] = VersionSchema.parse(active).split('.').map(Number)\n const [nextMajor, nextMinor] = VersionSchema.parse(next).split('.').map(Number)\n return major !== nextMajor || (major === 0 && minor !== nextMinor)\n}\n\nexport function automaticCompatibilityReasons(active: RuntimeManifest, next: RuntimeManifest) {\n const reasons = compatibilityReasons(active, next)\n if (crossesBreakingBoundary(active.packageVersion, next.packageVersion))\n reasons.push('Breaking release boundary; explicit update required')\n return reasons\n}\n\n/** Cold replacement has no frozen MCP sessions, but must retain safe state/rollback access. */\nexport function coldCompatibilityReasons(active: RuntimeManifest, next: RuntimeManifest) {\n const reasons = [...runtimeCompatibilityReasons(next), ...stateCompatibilityReasons(active, next)]\n if (!active.controlProtocols.some((value) => next.controlProtocols.includes(value)))\n reasons.push('No common control protocol for binary rollback')\n return reasons\n}\n\nexport function validatePolicyBaseline(current: RuntimeManifest, baseline?: RuntimeManifest) {\n const review = current.guidanceReview\n if (compareVersions(current.packageVersion, review.baseline.version) <= 0)\n throw new Error('A release must be newer than its reviewed baseline.')\n if (!baseline) {\n if (review.decision !== 'initial' || current.guidanceEpoch !== 1)\n throw new Error('Missing historical guidance evidence.')\n return\n }\n if (baseline.packageVersion !== review.baseline.version)\n throw new Error('Wrong release baseline.')\n if (current.guidanceEpoch < baseline.guidanceEpoch)\n throw new Error('Guidance epochs cannot decrease.')\n if (\n review.decision === 'initial' ||\n (review.decision === 'compatible') !== (current.guidanceEpoch === baseline.guidanceEpoch)\n )\n throw new Error('Guidance decision and epoch disagree.')\n if (!baseline.controlProtocols.every((value) => current.controlProtocols.includes(value)))\n throw new Error('Control protocol retirement requires a separate migration review.')\n}\n","import { createHash } from 'node:crypto'\nimport { gunzipSync } from 'node:zlib'\n\nimport { IntegritySchema, safePath } from './manifest'\n\nexport const MAX_ARCHIVE_BYTES = 32 * 1024 * 1024\nexport const MAX_EXTRACTED_BYTES = 256 * 1024 * 1024\nconst MAX_FILE_BYTES = 16 * 1024 * 1024\nconst MAX_FILES = 20_000\n\nexport function verifyIntegrity(bytes: Uint8Array, integrity: string) {\n IntegritySchema.parse(integrity)\n if (\n bytes.byteLength > MAX_ARCHIVE_BYTES ||\n `sha512-${createHash('sha512').update(bytes).digest('base64')}` !== integrity\n )\n throw new Error('Runtime archive integrity or size check failed.')\n}\n\nfunction field(bytes: Buffer) {\n const end = bytes.indexOf(0)\n return new TextDecoder('utf-8', { fatal: true }).decode(\n bytes.subarray(0, end < 0 ? bytes.length : end)\n )\n}\nfunction octal(bytes: Buffer) {\n const text = field(bytes).trim()\n if (!/^[0-7]+$/.test(text)) throw new Error('Invalid tar numeric field.')\n const number = Number.parseInt(text, 8)\n if (!Number.isSafeInteger(number)) throw new Error('Oversized tar numeric field.')\n return number\n}\nfunction pax(bytes: Buffer) {\n const result: Record<string, string> = Object.create(null)\n let offset = 0\n while (offset < bytes.length) {\n const space = bytes.indexOf(32, offset)\n const length = Number(bytes.subarray(offset, space).toString('ascii'))\n if (\n space < offset ||\n !Number.isSafeInteger(length) ||\n length <= space - offset + 1 ||\n offset + length > bytes.length ||\n bytes[offset + length - 1] !== 10\n )\n throw new Error('Invalid tar extended header.')\n const record = new TextDecoder('utf-8', { fatal: true }).decode(\n bytes.subarray(space + 1, offset + length - 1)\n )\n const equals = record.indexOf('=')\n if (equals < 1) throw new Error('Invalid tar extended field.')\n const key = record.slice(0, equals)\n if (key in result || key === 'linkpath' || key.startsWith('GNU.sparse'))\n throw new Error('Unsafe tar extended field.')\n result[key] = record.slice(equals + 1)\n offset += length\n }\n return result\n}\n\n/** Parse before writing anything. Links, devices, traversal and duplicate files are forbidden. */\nexport function readArchive(compressed: Buffer): Map<string, Buffer> {\n if (compressed.length > MAX_ARCHIVE_BYTES) throw new Error('Runtime archive is too large.')\n const bytes = gunzipSync(compressed, { maxOutputLength: MAX_EXTRACTED_BYTES })\n const files = new Map<string, Buffer>()\n const directories = new Set<string>()\n let extended: Record<string, string> | undefined\n let offset = 0\n let ended = false\n while (offset + 512 <= bytes.length) {\n const header = bytes.subarray(offset, offset + 512)\n offset += 512\n if (header.every((value) => value === 0)) {\n if (extended || bytes.subarray(offset).some((value) => value !== 0))\n throw new Error('Trailing tar content.')\n ended = true\n break\n }\n const checksum = header.reduce(\n (sum, byte, index) => sum + (index >= 148 && index < 156 ? 32 : byte),\n 0\n )\n if (octal(header.subarray(148, 156)) !== checksum) throw new Error('Invalid tar checksum.')\n const prefix = field(header.subarray(345, 500))\n const name = (prefix ? `${prefix}/` : '') + field(header.subarray(0, 100))\n const size = octal(header.subarray(124, 136))\n const type = String.fromCharCode(header[156]!)\n if (size > MAX_FILE_BYTES || offset + size > bytes.length)\n throw new Error('Invalid tar file size.')\n const data = bytes.subarray(offset, offset + size)\n offset += Math.ceil(size / 512) * 512\n if (type === 'x') {\n if (extended) throw new Error('Repeated tar extended header.')\n extended = pax(data)\n continue\n }\n const path = extended?.path ?? name\n if (extended?.size !== undefined && Number(extended.size) !== size)\n throw new Error('Conflicting tar sizes.')\n extended = undefined\n if (!['0', '\\0', '5'].includes(type))\n throw new Error('Runtime archives may contain only regular files and directories.')\n if (!path.startsWith('package/')) throw new Error('Unexpected package archive root.')\n if (type !== '5' && path.endsWith('/')) throw new Error('Invalid regular file path.')\n const relative = path.slice(8).replace(/\\/$/, '')\n if (type === '5' && !relative && size === 0) continue\n if (!safePath(relative) || files.has(relative))\n throw new Error('Unsafe or duplicate package path.')\n if (type === '5') {\n if (size !== 0) throw new Error('Nonempty tar directory.')\n directories.add(relative)\n } else {\n if (directories.has(relative)) throw new Error('Package file conflicts with directory.')\n files.set(relative, data)\n }\n if (files.size + directories.size > MAX_FILES) throw new Error('Too many package entries.')\n }\n if (!ended || !files.size) throw new Error('Incomplete package archive.')\n for (const path of [...files.keys(), ...directories]) {\n const parts = path.split('/')\n parts.pop()\n while (parts.length) {\n if (files.has(parts.join('/')))\n throw new Error('Package file is an ancestor of another entry.')\n parts.pop()\n }\n }\n return files\n}\n","import { createHash } from 'node:crypto'\nimport { lstatSync, readFileSync, readdirSync, realpathSync } from 'node:fs'\nimport { join, posix, relative, resolve } from 'node:path'\nimport { z } from 'zod'\n\nimport { readArchive, verifyIntegrity } from './archive'\nimport { MANIFEST_PATH, ManifestSchema, PACKAGE_NAME, VersionSchema } from './manifest'\n\nconst PackageSchema = z.object({\n name: z.literal(PACKAGE_NAME),\n version: VersionSchema,\n bin: z.literal('dist/cli.mjs'),\n engines: z.object({ node: z.string() }),\n dependencies: z.record(z.string(), z.string()),\n bundleDependencies: z.array(z.string())\n})\n\nexport const sha256 = (bytes: Uint8Array | string) =>\n createHash('sha256').update(bytes).digest('hex')\n\n/** Validate identity and complete payload integrity independently of this launcher. */\nexport function verifyPackage(files: ReadonlyMap<string, Buffer>, expectedVersion: string) {\n const json = (path: string) => {\n const bytes = files.get(path)\n if (!bytes || bytes.length > 4 * 1024 * 1024) throw new Error(`Missing or oversized ${path}.`)\n return JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(bytes)) as unknown\n }\n const pkg = PackageSchema.parse(json('package.json'))\n const manifest = ManifestSchema.parse(json(MANIFEST_PATH))\n if (\n pkg.version !== expectedVersion ||\n manifest.packageVersion !== expectedVersion ||\n manifest.node !== pkg.engines.node\n )\n throw new Error('Runtime package identity disagrees with its manifest.')\n if (Object.keys(manifest.files).length !== files.size - 1 || manifest.files[MANIFEST_PATH])\n throw new Error('The manifest must inventory every payload file exactly once.')\n for (const [path, bytes] of files) {\n if (path !== MANIFEST_PATH && manifest.files[path] !== sha256(bytes))\n throw new Error(`Runtime payload hash mismatch: ${path}`)\n }\n if (!files.has(manifest.entry) || !files.has(pkg.bin) || !files.has('dist/log-transport.mjs'))\n throw new Error('The runtime payload is incomplete.')\n if (Object.keys(pkg.dependencies).some((name) => !pkg.bundleDependencies.includes(name)))\n throw new Error('All runtime dependencies must be bundled.')\n\n // Node resolution must terminate inside this package, including transitive\n // worker dependencies. The release build supplies them from the frozen lock.\n for (const path of files.keys()) {\n if (\n path !== 'package.json' &&\n !/^node_modules\\/(?:@[^/]+\\/)?[^/]+\\/(?:node_modules\\/(?:@[^/]+\\/)?[^/]+\\/)*package\\.json$/.test(\n path\n )\n )\n continue\n const dependencyPackage = z\n .object({\n dependencies: z.record(z.string(), z.string()).optional(),\n optionalDependencies: z.record(z.string(), z.string()).optional()\n })\n .parse(json(path))\n for (const name of Object.keys(dependencyPackage.dependencies ?? {})) {\n if (Object.hasOwn(dependencyPackage.optionalDependencies ?? {}, name)) continue\n if (!/^(?:@[a-z0-9._-]+\\/)?[a-z0-9._-]+$/i.test(name))\n throw new Error('Invalid dependency name.')\n let directory = posix.dirname(path)\n let found = false\n while (true) {\n const candidate =\n directory === '.'\n ? `node_modules/${name}/package.json`\n : `${directory}/node_modules/${name}/package.json`\n if (files.has(candidate)) {\n found = true\n break\n }\n if (directory === '.') break\n directory = posix.dirname(directory)\n }\n if (!found) throw new Error(`Unbundled runtime dependency ${name} from ${path}.`)\n }\n }\n return manifest\n}\n\nexport function verifyArchive(bytes: Buffer, version: string, integrity: string) {\n verifyIntegrity(bytes, integrity)\n const files = readArchive(bytes)\n return { files, manifest: verifyPackage(files, version) }\n}\n\n/** Revalidate cached bytes, never trust a marker left by an earlier installer. */\nexport function readInstalledPackage(directory: string) {\n directory = resolve(directory)\n if (realpathSync(directory) !== directory)\n throw new Error('Runtime package path must be canonical.')\n const files = new Map<string, Buffer>()\n let size = 0\n function walk(path: string) {\n const stat = lstatSync(path)\n if (stat.isSymbolicLink() || (!stat.isDirectory() && !stat.isFile()))\n throw new Error('Runtime packages cannot contain links or special files.')\n if (stat.isDirectory()) {\n for (const name of readdirSync(path)) walk(join(path, name))\n } else {\n size += stat.size\n if (size > 256 * 1024 * 1024 || files.size >= 20_000)\n throw new Error('Runtime package exceeds its limits.')\n files.set(relative(directory, path).split('\\\\').join('/'), readFileSync(path))\n }\n }\n walk(directory)\n return files\n}\n","import {\n closeSync,\n fsyncSync,\n lstatSync,\n mkdtempSync,\n openSync,\n readFileSync,\n readdirSync,\n renameSync,\n rmSync,\n writeFileSync\n} from 'node:fs'\nimport { mkdir, writeFile } from 'node:fs/promises'\nimport { dirname, join, sep } from 'node:path'\n\nimport type { Artifact } from '../runtime-prototype/state'\n\nimport { ensurePrivateDirectory, ensurePrivateDirectoryAsync } from '../runtime-platform'\nimport { IntegritySchema, MANIFEST_PATH } from './manifest'\nimport { readInstalledPackage, sha256, verifyArchive, verifyPackage } from './package'\n\nexport function privateDirectory(path: string) {\n ensurePrivateDirectory(path)\n}\n\nexport function cacheDirectory(cache: string, integrity: string) {\n IntegritySchema.parse(integrity)\n return join(cache, sha256(integrity))\n}\n\nfunction retainedDirectory(path: string, retained: (Artifact | undefined)[]) {\n return retained.some(\n (artifact) =>\n artifact?.release &&\n (artifact.release.directory === path || artifact.release.directory.startsWith(path + sep))\n )\n}\n\n/** Download caches are replaceable; the running, control and rollback closures are not. */\nexport function discardUnusedCache(\n cache: string,\n integrity: string,\n retained: (Artifact | undefined)[]\n) {\n privateDirectory(cache)\n const directory = cacheDirectory(cache, integrity)\n if (retainedDirectory(directory, retained))\n throw new Error('A retained runtime cache is damaged; automatic replacement was refused.')\n try {\n lstatSync(directory)\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return false\n throw error\n }\n privateDirectory(directory)\n rmSync(directory, { recursive: true })\n return true\n}\n\n/** Called by the sole owner after an acquisition worker has exited. */\nexport async function pruneCache(\n cache: string,\n retained: (Artifact | undefined)[],\n signal?: AbortSignal\n) {\n await ensurePrivateDirectoryAsync(cache)\n signal?.throwIfAborted()\n for (const entry of readdirSync(cache, { withFileTypes: true })) {\n if (!entry.isDirectory()) continue\n const path = join(cache, entry.name)\n if (/^(?:bundled-)?[a-f0-9]{64}$/.test(entry.name)) {\n if (retainedDirectory(path, retained)) continue\n rmSync(path, { recursive: true, force: true })\n } else if (\n /^\\.(?:install|bundled)-/.test(entry.name) &&\n Date.now() - lstatSync(path).mtimeMs > 24 * 60 * 60 * 1000\n ) {\n rmSync(path, { recursive: true, force: true })\n }\n }\n}\n\nexport function verifyCached(cache: string, version: string, integrity: string) {\n privateDirectory(cache)\n const directory = cacheDirectory(cache, integrity)\n lstatSync(directory)\n privateDirectory(directory)\n const archivePath = join(directory, 'archive.tgz')\n const stat = lstatSync(archivePath)\n if (!stat.isFile() || stat.isSymbolicLink() || stat.size > 32 * 1024 * 1024)\n throw new Error('Invalid cached archive.')\n const expected = verifyArchive(readFileSync(archivePath), version, integrity)\n return verifyInstalled(join(directory, 'package'), version, expected.files.get(MANIFEST_PATH)!)\n}\n\nfunction verifyInstalled(directory: string, version: string, expectedManifest: Buffer) {\n const installed = readInstalledPackage(directory)\n const manifest = verifyPackage(installed, version)\n if (!installed.get(MANIFEST_PATH)!.equals(expectedManifest))\n throw new Error('Cached manifest differs from the verified release.')\n return { directory, manifest }\n}\n\n/** Bound file-system concurrency while durably writing every verified payload file. */\nexport async function writePackageFiles(directory: string, files: ReadonlyMap<string, Buffer>) {\n const entries = [...files]\n let next = 0\n const results = await Promise.allSettled(\n Array.from({ length: 8 }, async () => {\n while (next < entries.length) {\n const [path, data] = entries[next++]!\n const target = join(directory, path)\n await mkdir(dirname(target), { recursive: true, mode: 0o700 })\n await writeFile(target, data, { flag: 'wx', mode: 0o600, flush: true })\n }\n })\n )\n for (const result of results) if (result.status === 'rejected') throw result.reason\n}\n\nexport function publishDirectory(staging: string, destination: string) {\n renameSync(staging, destination)\n // Windows cannot open directories for fsync; payload files were flushed above,\n // and every startup revalidates the complete published closure.\n if (process.platform === 'win32') return\n const fd = openSync(dirname(destination), 'r')\n try {\n fsyncSync(fd)\n } finally {\n closeSync(fd)\n }\n}\n\nexport async function installArchive(\n cache: string,\n version: string,\n integrity: string,\n bytes: Buffer\n) {\n const { files } = verifyArchive(bytes, version, integrity)\n privateDirectory(cache)\n const destination = cacheDirectory(cache, integrity)\n try {\n lstatSync(destination)\n return verifyCached(cache, version, integrity)\n } catch (error) {\n // A corrupt existing cache is evidence, never silently replaced or executed.\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error\n }\n const staging = mkdtempSync(join(cache, '.install-'))\n try {\n writeFileSync(join(staging, 'archive.tgz'), bytes, { flag: 'wx', mode: 0o600, flush: true })\n await writePackageFiles(join(staging, 'package'), files)\n // Publish only a complete closure. A crash before rename leaves an unused\n // staging directory; a crash afterward is caught by full revalidation.\n publishDirectory(staging, destination)\n // The archive was verified above; recheck the installed bytes before probing\n // without decompressing that same immutable download a second time.\n return verifyInstalled(join(destination, 'package'), version, files.get(MANIFEST_PATH)!)\n } finally {\n rmSync(staging, { recursive: true, force: true })\n }\n}\n","import { lstatSync, mkdtempSync, readFileSync, realpathSync, rmSync } from 'node:fs'\nimport { join } from 'node:path'\n\nimport type { Artifact } from '../runtime-prototype/state'\n\nimport { startupPhase } from '../startup-log'\nimport { privateDirectory, publishDirectory, writePackageFiles } from './cache'\nimport { assertRunnable, MANIFEST_PATH, ManifestSchema } from './manifest'\nimport { readInstalledPackage, sha256, verifyPackage } from './package'\n\nexport function releaseManifest(artifact: Artifact) {\n if (!artifact.release) throw new Error('The runtime has no verified release payload.')\n const bytes = readFileSync(join(artifact.release.directory, MANIFEST_PATH))\n if (bytes.length > 4 * 1024 * 1024 || sha256(bytes) !== artifact.release.manifestHash)\n throw new Error('Runtime manifest changed.')\n const manifest = ManifestSchema.parse(JSON.parse(bytes.toString('utf8')))\n if (\n manifest.packageVersion !== artifact.version ||\n artifact.entry !== join(artifact.release.directory, manifest.entry)\n )\n throw new Error('Runtime release identity changed.')\n return manifest\n}\n\nexport function verifyReleaseArtifact(artifact: Artifact) {\n return startupPhase('verify-retained-package', () => {\n if (!artifact.release) throw new Error('The runtime has no verified release payload.')\n const { directory, manifestHash } = artifact.release\n const files = readInstalledPackage(directory)\n if (sha256(files.get(MANIFEST_PATH) ?? '') !== manifestHash)\n throw new Error('Runtime manifest changed.')\n const manifest = verifyPackage(files, artifact.version)\n assertRunnable(manifest)\n if (artifact.entry !== join(directory, manifest.entry))\n throw new Error('Runtime entry differs from its manifest.')\n return manifest\n })\n}\n\n/** The installed bootstrap is already trusted. Copy only its inventoried closure\n * so npm cache cleanup and subsequent npm installs cannot change the running owner. */\nexport async function retainBundledPackage(source: string, cache: string) {\n source = realpathSync(source)\n const manifestBytes = readFileSync(join(source, MANIFEST_PATH))\n const manifest = ManifestSchema.parse(JSON.parse(manifestBytes.toString('utf8')))\n const manifestHash = sha256(manifestBytes)\n const files = startupPhase('read-bundled-package', () => {\n const files = new Map([[MANIFEST_PATH, manifestBytes]])\n for (const path of Object.keys(manifest.files)) {\n const fullPath = join(source, path)\n const stat = lstatSync(fullPath)\n if (!stat.isFile() || realpathSync(fullPath) !== fullPath || stat.size > 16 * 1024 * 1024)\n throw new Error(`Invalid bundled runtime file: ${path}`)\n files.set(path, readFileSync(fullPath))\n }\n return files\n })\n startupPhase('verify-bundled-package', () => {\n verifyPackage(files, manifest.packageVersion)\n assertRunnable(manifest)\n })\n privateDirectory(cache)\n const directory = join(cache, `bundled-${manifestHash}`)\n let exists = false\n try {\n lstatSync(directory)\n exists = true\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error\n }\n if (!exists) {\n const staging = mkdtempSync(join(cache, '.bundled-'))\n try {\n await startupPhase('write-runtime-cache', () => writePackageFiles(staging, files))\n startupPhase('publish-runtime-cache', () => publishDirectory(staging, directory))\n } finally {\n rmSync(staging, { force: true, recursive: true })\n }\n }\n const artifact = {\n entry: join(directory, manifest.entry),\n version: manifest.packageVersion,\n bundle: '',\n release: { directory, manifestHash }\n }\n verifyReleaseArtifact(artifact)\n return artifact\n}\n","import type { Socket } from 'node:net'\n\nimport { spawn, type ChildProcess } from 'node:child_process'\nimport { createHash, randomUUID } from 'node:crypto'\nimport { existsSync, readFileSync, readdirSync, writeFileSync, realpathSync } from 'node:fs'\nimport { connect, type Server } from 'node:net'\nimport { dirname, join } from 'node:path'\nimport { setTimeout as delay } from 'node:timers/promises'\nimport lockfile from 'proper-lockfile'\n\nimport { hubEnvironment } from '../process-environment'\nimport {\n assertPrivateEndpointAsync,\n assertPrivatePath,\n ensurePrivateDirectory,\n isPipe,\n protectPipeAsync,\n runtimeEndpoint\n} from '../runtime-platform'\nimport { verifyReleaseArtifact } from '../runtime-update/artifact'\nimport { assertTrustedSocket, ensureFile } from '../shared'\nimport { startupPhase } from '../startup-log'\nimport { isRuntimeUnavailable, RECOVER_MS, unavailable } from './protocol'\nimport { ConfigSchema, readJournal, type Artifact, type PrototypeConfig } from './state'\nexport type { PrototypeConfig } from './state'\n\nexport function fingerprintBundle(entry: string): string {\n return startupPhase('fingerprint-bundle', () => {\n const directory = dirname(entry)\n const hash = createHash('sha256')\n for (const name of readdirSync(directory)\n .filter((name) => name.endsWith('.mjs'))\n .sort())\n hash\n .update(name)\n .update('\\0')\n .update(readFileSync(join(directory, name)))\n return hash.digest('hex')\n })\n}\n\nexport function runtimePaths(config: PrototypeConfig) {\n return (\n config.directories ?? {\n runtime: join(config.root, 'run'),\n state: join(config.root, 'state'),\n assets: join(config.root, 'assets'),\n log: join(config.root, 'log')\n }\n )\n}\n\nexport function hubSocketPath(root: string, runtime = join(root, 'run')) {\n return runtimeEndpoint(runtime, 'runtime-hub.sock')\n}\n\nexport function supervisorSocketPath(config: PrototypeConfig) {\n return runtimeEndpoint(config.directories?.runtime ?? config.root, 'supervisor.sock')\n}\n\nexport function prototypeConfig(root: string, entry: string, role = 'edge'): PrototypeConfig {\n root = realpathSync(root)\n ensurePrivateDirectory(root)\n const bundle = fingerprintBundle(entry)\n const path = join(root, 'prototype.json')\n try {\n writeFileSync(path, JSON.stringify({ version: 1, entry, bundle, secret: randomUUID() }), {\n flag: 'wx',\n mode: 0o600\n })\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'EEXIST') throw error\n }\n assertPrivatePath(path, 'file')\n const config = ConfigSchema.parse(JSON.parse(readFileSync(path, 'utf8')))\n if (config.entry !== entry || config.bundle !== bundle) {\n const journal = readJournal(root)\n const known = [journal?.active, journal?.candidate, journal?.previous].some(\n (artifact) => artifact?.entry === entry && artifact.bundle === bundle\n )\n if (role === 'supervisor' || !known)\n throw new Error(\n 'Runtime prototype bundle changed. Stop the isolated run and use a fresh root.'\n )\n }\n return { ...config, root }\n}\n\nexport function launch(config: PrototypeConfig, role: 'supervisor' | 'hub', artifact?: Artifact) {\n return startupPhase(`launch-${role}`, () => {\n const entry = artifact?.entry ?? config.entry\n if (artifact?.release) verifyReleaseArtifact(artifact)\n else if (config.release && !artifact)\n verifyReleaseArtifact({\n entry,\n bundle: config.bundle,\n version: JSON.parse(readFileSync(join(config.release.directory, 'package.json'), 'utf8'))\n .version,\n release: config.release\n })\n if (fingerprintBundle(entry) !== (artifact?.bundle ?? config.bundle))\n throw new Error('Verified runtime bundle changed before launch.')\n const child = spawn(process.execPath, [entry, '--root', config.root, '--role', role], {\n detached: true,\n windowsHide: true,\n stdio: 'ignore',\n env: hubEnvironment(process.env)\n })\n child.on('error', () => {})\n child.unref()\n return child\n })\n}\n\nexport function connectSocket(path: string, signal?: AbortSignal): Promise<Socket> {\n if (!isPipe(path)) assertTrustedSocket(path)\n return new Promise((resolve, reject) => {\n const socket = connect(path)\n let settled = false\n let deadline = performance.now() + 1000\n const inspection = new AbortController()\n const inspectionSignal = signal\n ? AbortSignal.any([signal, inspection.signal])\n : inspection.signal\n let pendingInspection: Error | undefined\n const cleanup = () => {\n clearTimeout(timer)\n signal?.removeEventListener('abort', abort)\n socket.off('error', fail)\n socket.off('close', closed)\n socket.off('connect', connected)\n }\n const fail = (error: Error) => {\n if (settled) return\n settled = true\n cleanup()\n inspection.abort()\n socket.destroy()\n reject(error)\n }\n const abort = () => fail(new Error('Runtime connection cancelled.'))\n const closed = () =>\n fail(\n Object.assign(new Error('Runtime connection closed before permission verification.'), {\n code: 'ECONNRESET'\n })\n )\n const timedOut = () =>\n fail(\n pendingInspection ??\n Object.assign(new Error('Runtime connection timed out.'), { code: 'ETIMEDOUT' })\n )\n let timer = setTimeout(timedOut, 1000)\n const verify = async () => {\n while (!settled && !socket.destroyed) {\n try {\n if (isPipe(path)) await assertPrivateEndpointAsync(path, inspectionSignal)\n return\n } catch (error) {\n if (\n !['EPIPEUNPROTECTED', 'EBUSY'].includes((error as NodeJS.ErrnoException).code ?? '') ||\n performance.now() >= deadline\n )\n throw error\n pendingInspection = error instanceof Error ? error : new Error(String(error))\n await delay(25, undefined, { signal: inspectionSignal })\n }\n }\n }\n const connected = () => {\n if (settled) return\n if (isPipe(path)) {\n // Connection acquisition and ACL inspection have separate bounds. The\n // helper may take 15s, but must not block the Hub's 10s control lease.\n clearTimeout(timer)\n deadline = performance.now() + 15_000\n timer = setTimeout(timedOut, 15_000)\n }\n // Keep the connection open while inspecting: a connected pipe cannot be replaced by\n // a different owner between this check and the caller's first authenticated frame.\n void verify().then(\n () => {\n if (settled) return\n if (socket.destroyed) return closed()\n settled = true\n cleanup()\n resolve(socket)\n },\n (error) => fail(error instanceof Error ? error : new Error(String(error)))\n )\n }\n socket.once('error', fail)\n socket.once('close', closed)\n socket.once('connect', connected)\n signal?.addEventListener('abort', abort, { once: true })\n if (signal?.aborted) abort()\n })\n}\n\nexport async function waitForSocket(\n path: string,\n signal?: AbortSignal,\n timeoutMs = 5000,\n processId?: number\n) {\n if (timeoutMs <= 0) throw unavailable('Runtime process has not published its endpoint yet.')\n const until = performance.now() + timeoutMs\n const deadline = AbortSignal.timeout(Math.ceil(timeoutMs))\n const bounded = signal ? AbortSignal.any([signal, deadline]) : deadline\n try {\n do {\n if (processId !== undefined) {\n try {\n process.kill(processId, 0)\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ESRCH') throw error\n throw new Error('Runtime process exited before endpoint publication.', { cause: error })\n }\n }\n try {\n const socket = await connectSocket(path, bounded)\n if (bounded.aborted) {\n socket.destroy()\n bounded.throwIfAborted()\n }\n return socket\n } catch (error) {\n bounded.throwIfAborted()\n if (!unavailableSocket(error) && !isSocketPending(error)) throw error\n await delay(100, undefined, { signal: bounded })\n }\n } while (performance.now() < until)\n } catch (error) {\n signal?.throwIfAborted()\n if (!deadline.aborted) throw error\n }\n throw unavailable('Runtime process has not published its endpoint yet.')\n}\n\nexport async function waitForLaunchedSocket(\n path: string,\n child: ChildProcess,\n signal: AbortSignal,\n timeoutMs = RECOVER_MS\n) {\n const ended = new AbortController()\n const failed = (error: Error) => ended.abort(error)\n const exited = (code: number | null, exitSignal: NodeJS.Signals | null) =>\n failed(new Error(`Runtime process exited before endpoint publication (${exitSignal ?? code}).`))\n child.once('error', failed)\n child.once('exit', exited)\n if (child.exitCode != null || child.signalCode != null) exited(child.exitCode, child.signalCode)\n try {\n return await waitForSocket(path, AbortSignal.any([signal, ended.signal]), timeoutMs)\n } catch (error) {\n signal.throwIfAborted()\n ended.signal.throwIfAborted()\n throw error\n } finally {\n child.off('error', failed)\n child.off('exit', exited)\n }\n}\n\nexport function unavailableSocket(error: unknown) {\n return ['ENOENT', 'ECONNREFUSED', 'EBUSY'].includes((error as NodeJS.ErrnoException).code ?? '')\n}\n\nexport function isSocketPending(error: unknown) {\n // A protecting listener rejects early connections. Closure or slow acquisition\n // cannot prove that its owner is absent and authorize a competing launch.\n return ['EPIPEUNPROTECTED', 'ETIMEDOUT', 'ECONNRESET', 'EPIPE'].includes(\n (error as NodeJS.ErrnoException).code ?? ''\n )\n}\n\nexport async function supervisorConnection(config: PrototypeConfig, signal: AbortSignal) {\n const deadline = AbortSignal.timeout(RECOVER_MS)\n const attemptSignal = AbortSignal.any([signal, deadline])\n for (;;) {\n signal.throwIfAborted()\n if (deadline.aborted) throw unavailable('Runtime supervisor startup timed out.')\n try {\n return await supervisorConnectionAttempt(config, attemptSignal)\n } catch (error) {\n signal.throwIfAborted()\n if (!deadline.aborted && !isRuntimeUnavailable(error) && !isSocketPending(error)) throw error\n await delay(200, undefined, { signal: attemptSignal }).catch(() => {})\n }\n }\n}\n\n// Retry only endpoint acquisition, before a control request can be dispatched.\nasync function supervisorConnectionAttempt(config: PrototypeConfig, signal: AbortSignal) {\n const path = supervisorSocketPath(config)\n try {\n return await connectSocket(path, signal)\n } catch (error) {\n if (!unavailableSocket(error)) throw error\n }\n try {\n return await withStartupLock(config.root, async () => {\n try {\n return await connectSocket(path, signal)\n } catch (error) {\n if (!unavailableSocket(error)) throw error\n }\n signal.throwIfAborted()\n // Another cold launch may have promoted the retained control artifact while\n // this edge waited. Never launch the stale snapshot supplied by the caller.\n if (config.release) {\n const { resumeColdStart } = await import('../runtime-update/cold-start')\n config = await resumeColdStart(config)\n }\n const owner = join(config.root, 'supervisor.lock')\n // A supervisor may be waiting for a crashed Hub's writer lease before it can\n // publish its endpoint. Repeated edge retries must not spawn losing owners.\n if (!existsSync(owner) || !(await lockfile.check(owner, { stale: 5000 })))\n launch(config, 'supervisor')\n return await waitForSocket(path, signal)\n })\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ELOCKED') throw error\n return waitForSocket(path, signal)\n }\n}\n\nexport async function withStartupLock<T>(root: string, action: () => Promise<T>, wait = false) {\n const path = join(root, 'startup.lock')\n ensureFile(path)\n const unlock = await lockfile.lock(path, {\n retries: wait ? { retries: 900, factor: 1, minTimeout: 100, maxTimeout: 100 } : 0,\n stale: 10_000\n })\n try {\n return await action()\n } finally {\n await unlock()\n }\n}\n\nexport async function listenPrivate(server: Server, path: string, signal?: AbortSignal) {\n signal?.throwIfAborted()\n const connectionListeners = isPipe(path) ? server.rawListeners('connection') : undefined\n const rejectUnprotected = (socket: Socket) => socket.destroy()\n if (connectionListeners) {\n server.removeAllListeners('connection')\n server.on('connection', rejectUnprotected)\n }\n await new Promise<void>((resolve, reject) => {\n const inspection = new AbortController()\n let settled = false\n const cleanup = () => {\n clearTimeout(timer)\n server.off('error', fail)\n server.off('close', closed)\n signal?.removeEventListener('abort', abort)\n }\n const fail = (error: Error) => {\n if (settled) return\n settled = true\n inspection.abort()\n cleanup()\n server.close()\n reject(error)\n }\n const closed = () => fail(new Error('Runtime listener closed during startup.'))\n const abort = () => fail(signal?.reason ?? new Error('Runtime listener startup cancelled.'))\n let timer = setTimeout(() => fail(new Error('Runtime listener startup timed out.')), 5000)\n server.once('error', fail)\n server.once('close', closed)\n signal?.addEventListener('abort', abort, { once: true })\n const mask = process.umask(0o177)\n try {\n server.listen(path, () => {\n clearTimeout(timer)\n timer = setTimeout(() => fail(new Error('Runtime listener protection timed out.')), 15_000)\n void (async () => {\n // Reject connections until the real ACL is installed and verified.\n if (isPipe(path)) await protectPipeAsync(path, inspection.signal)\n if (settled) return\n if (connectionListeners) {\n server.off('connection', rejectUnprotected)\n for (const listener of connectionListeners)\n server.on('connection', listener as (socket: Socket) => void)\n }\n cleanup()\n settled = true\n resolve()\n })().catch((error: unknown) => {\n fail(error instanceof Error ? error : new Error(String(error)))\n })\n })\n } catch (error) {\n fail(error instanceof Error ? error : new Error(String(error)))\n } finally {\n process.umask(mask)\n }\n })\n if (signal?.aborted) {\n server.close()\n signal.throwIfAborted()\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAa,eAAe;AAC5B,MAAa,gBAAgB;AAC7B,MAAa,gBAAgBA,OACnB,CAAC,CACR,MAAM,4CAA4C,CAAC,CACnD,QAAQ,UAAU,MAAM,MAAM,GAAG,CAAC,CAAC,OAAO,SAAS,OAAO,cAAc,OAAO,IAAI,CAAC,CAAC,CAAC;AACzF,MAAM,aAAaC,OAAS,CAAC,CAAC,MAAM,gBAAgB;AACpD,MAAa,kBAAkBA,OAAS,CAAC,CAAC,MAAM,8BAA8B;AAE9E,SAAgB,SAAS,MAAuB;CAC9C,OACE,KAAK,SAAS,KACd,KAAK,UAAU,QACf,CAAC,cAAc,KAAK,IAAI,KACxB,CAAC,GAAG,IAAI,CAAC,CAAC,OAAO,cAAc,UAAU,WAAW,CAAC,KAAK,MAAM,cAAc,GAAM,KACpF,KACG,MAAM,GAAG,CAAC,CACV,OACE,SACC,KAAK,SAAS,KACd,CAAC,QAAQ,KAAK,IAAI,KAClB,CAAC,wDAAwD,KAAK,IAAI,CACtE;AAEN;AAEA,MAAa,eAAeC,OAClB;CACN,SAASC,QAAU,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