dal-code 1.0.44 → 1.0.45

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 (426) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/NOTICE +17 -0
  3. package/PRIVACY.md +159 -102
  4. package/dal-docs/README.md +1 -1
  5. package/dal-docs/keybindings.md +1 -0
  6. package/dal-docs/settings.md +5 -0
  7. package/dist/cli/credential-print.js +1 -1
  8. package/dist/config.d.ts +1 -0
  9. package/dist/config.js +1 -1
  10. package/dist/core/agent-session-runtime.js +1 -1
  11. package/dist/core/agent-session.d.ts +1 -1
  12. package/dist/core/agent-session.js +5 -5
  13. package/dist/core/auth-storage.js +1 -1
  14. package/dist/core/background-processes.js +7 -7
  15. package/dist/core/export-html/template.js +34 -34
  16. package/dist/core/extensions/runner.js +1 -1
  17. package/dist/core/extensions/types.d.ts +5 -1
  18. package/dist/core/key-id-schema.js +1 -0
  19. package/dist/core/keybindings-schema.js +1 -0
  20. package/dist/core/keybindings.d.ts +5 -0
  21. package/dist/core/keybindings.js +1 -1
  22. package/dist/core/model-config.d.ts +818 -99
  23. package/dist/core/model-config.js +5 -5
  24. package/dist/core/model-resolver.d.ts +30 -10
  25. package/dist/core/model-resolver.js +1 -1
  26. package/dist/core/model-runtime.d.ts +1 -0
  27. package/dist/core/model-runtime.js +2 -2
  28. package/dist/core/package-manager.d.ts +5 -0
  29. package/dist/core/package-manager.js +2 -2
  30. package/dist/core/permissions/shell-words.d.ts +26 -0
  31. package/dist/core/project-trust.js +2 -2
  32. package/dist/core/prompt-templates.js +2 -2
  33. package/dist/core/remote-catalog-provider.js +1 -1
  34. package/dist/core/resource-loader.js +1 -1
  35. package/dist/core/sandbox/libreoffice.js +1 -0
  36. package/dist/core/sandbox/runtime.d.ts +1 -0
  37. package/dist/core/sandbox/runtime.js +1 -1
  38. package/dist/core/sandbox/shell-sandbox.js +6 -6
  39. package/dist/core/sandbox/windows.js +4 -4
  40. package/dist/core/session-manager.d.ts +1 -0
  41. package/dist/core/session-manager.js +12 -12
  42. package/dist/core/settings-defaults.js +1 -0
  43. package/dist/core/settings-manager.d.ts +5 -0
  44. package/dist/core/settings-manager.js +1 -1
  45. package/dist/core/settings-schema.d.ts +229 -0
  46. package/dist/core/settings-schema.js +1 -0
  47. package/dist/core/tools/bash-read-only.d.ts +1 -0
  48. package/dist/core/tools/read.js +12 -12
  49. package/dist/core/tools/render-utils.d.ts +40 -0
  50. package/dist/core/tools/render-utils.js +7 -7
  51. package/dist/core/tools/renderers/read.js +8 -8
  52. package/dist/core/trust-manager.js +1 -1
  53. package/dist/core/workspace-lock.d.ts +6 -2
  54. package/dist/core/workspace-lock.js +3 -3
  55. package/dist/dal/extension-compat.js +4 -4
  56. package/dist/dal/hooks/config.d.ts +5 -1
  57. package/dist/dal/hooks/config.js +1 -1
  58. package/dist/dal/hooks/extension.js +3 -3
  59. package/dist/dal/hooks/index.d.ts +1 -1
  60. package/dist/dal/hooks/index.js +1 -1
  61. package/dist/dal/i18n.js +1 -1
  62. package/dist/dal/manifest.js +1 -1
  63. package/dist/extensions/codemode/execute.js +14 -13
  64. package/dist/extensions/codemode/index.js +1 -1
  65. package/dist/extensions/codemode/renderer.js +6 -6
  66. package/dist/extensions/codemode/tool.d.ts +2 -3
  67. package/dist/extensions/codemode/tool.js +9 -12
  68. package/dist/extensions/mcp/cli.js +4 -4
  69. package/dist/extensions/mcp/index.js +12 -12
  70. package/dist/extensions/mcp/resources.d.ts +0 -5
  71. package/dist/extensions/mcp/resources.js +1 -1
  72. package/dist/extensions/mcp/runtime.d.ts +1 -4
  73. package/dist/extensions/mcp/runtime.js +3 -3
  74. package/dist/extensions/mcp/tools.js +7 -7
  75. package/dist/extensions/tool-search/tool.js +3 -3
  76. package/dist/index.d.ts +5 -2
  77. package/dist/index.js +1 -1
  78. package/dist/main.js +3 -3
  79. package/dist/migrations.js +5 -5
  80. package/dist/modes/interactive/components/settings-selector.d.ts +3 -1
  81. package/dist/modes/interactive/components/settings-selector.js +1 -1
  82. package/dist/modes/interactive/components/status-indicator.d.ts +1 -1
  83. package/dist/modes/interactive/components/status-indicator.js +1 -1
  84. package/dist/modes/interactive/components/tree-selector.js +1 -1
  85. package/dist/modes/interactive/interactive-mode.js +17 -17
  86. package/dist/modes/interactive/session-share.js +2 -2
  87. package/dist/modes/interactive/theme/dark.json +1 -1
  88. package/dist/modes/interactive/theme/light.json +1 -1
  89. package/dist/modes/interactive/theme/theme-schema.d.ts +18 -0
  90. package/dist/modes/interactive/theme/theme-schema.js +12 -0
  91. package/dist/modes/interactive/theme/theme-tokens.d.ts +255 -0
  92. package/dist/modes/interactive/theme/theme-tokens.js +1 -0
  93. package/dist/modes/interactive/theme/theme.d.ts +7 -10
  94. package/dist/modes/interactive/theme/theme.js +5 -5
  95. package/dist/modes/rpc/rpc-client.d.ts +5 -1
  96. package/dist/modes/rpc/rpc-client.js +2 -2
  97. package/dist/modes/rpc/rpc-mode.js +1 -1
  98. package/dist/modes/rpc/rpc-types.d.ts +20 -0
  99. package/dist/node_modules/@dalcode/dal-advisor/package.json +3 -3
  100. package/dist/node_modules/@dalcode/dal-advisor/src/index.js +8 -8
  101. package/dist/node_modules/@dalcode/dal-awake/package.json +2 -2
  102. package/dist/node_modules/@dalcode/dal-bridge/package.json +2 -2
  103. package/dist/node_modules/@dalcode/dal-capabilities/package.json +4 -4
  104. package/dist/node_modules/@dalcode/dal-capabilities/src/index.js +10 -10
  105. package/dist/node_modules/@dalcode/dal-codeindex/package.json +34 -0
  106. package/dist/node_modules/@dalcode/dal-codeindex/src/extract.js +3 -0
  107. package/dist/node_modules/@dalcode/dal-codeindex/src/format.js +11 -0
  108. package/dist/node_modules/@dalcode/dal-codeindex/src/index.js +4 -0
  109. package/dist/node_modules/@dalcode/dal-codeindex/src/indexer.js +1 -0
  110. package/dist/node_modules/@dalcode/dal-codeindex/src/languages.js +176 -0
  111. package/dist/node_modules/@dalcode/dal-codeindex/src/project.js +1 -0
  112. package/dist/node_modules/@dalcode/dal-codeindex/src/query.js +2 -0
  113. package/dist/node_modules/@dalcode/dal-codeindex/src/runtime.js +1 -0
  114. package/dist/node_modules/@dalcode/dal-codeindex/src/scan.js +1 -0
  115. package/dist/node_modules/@dalcode/dal-codeindex/src/semantic.js +2 -0
  116. package/dist/node_modules/@dalcode/dal-codeindex/src/sqlite.js +1 -0
  117. package/dist/node_modules/@dalcode/dal-codeindex/src/store.js +33 -0
  118. package/dist/node_modules/@dalcode/dal-codeindex/src/worker.js +1 -0
  119. package/dist/node_modules/@dalcode/dal-compat/package.json +2 -2
  120. package/dist/node_modules/@dalcode/dal-dap/package.json +2 -2
  121. package/dist/node_modules/@dalcode/dal-gateway/package.json +2 -2
  122. package/dist/node_modules/@dalcode/dal-goal/package.json +3 -3
  123. package/dist/node_modules/@dalcode/dal-guard/package.json +4 -4
  124. package/dist/node_modules/@dalcode/dal-guard/src/index.js +4 -2
  125. package/dist/node_modules/@dalcode/dal-guard/src/mode.js +2 -2
  126. package/dist/node_modules/@dalcode/dal-guard/src/policy.js +1 -0
  127. package/dist/node_modules/@dalcode/dal-halo/package.json +1 -1
  128. package/dist/node_modules/@dalcode/dal-interactive/package.json +2 -2
  129. package/dist/node_modules/@dalcode/dal-lang/package.json +3 -3
  130. package/dist/node_modules/@dalcode/dal-learn/package.json +2 -2
  131. package/dist/node_modules/@dalcode/dal-lsp/package.json +3 -3
  132. package/dist/node_modules/@dalcode/dal-lsp/src/index.js +12 -10
  133. package/dist/node_modules/@dalcode/dal-mcp/package.json +7 -5
  134. package/dist/node_modules/@dalcode/dal-mcp/src/http-client.d.ts +9 -27
  135. package/dist/node_modules/@dalcode/dal-mcp/src/http-client.js +1 -2
  136. package/dist/node_modules/@dalcode/dal-mcp/src/index.js +17 -17
  137. package/dist/node_modules/@dalcode/dal-mcp/src/protocol-client.d.ts +38 -0
  138. package/dist/node_modules/@dalcode/dal-mcp/src/protocol-client.js +1 -0
  139. package/dist/node_modules/@dalcode/dal-mcp/src/proxy.js +6 -6
  140. package/dist/node_modules/@dalcode/dal-mcp/src/resources.js +1 -0
  141. package/dist/node_modules/@dalcode/dal-mcp/src/stdio-client.d.ts +9 -18
  142. package/dist/node_modules/@dalcode/dal-mcp/src/stdio-client.js +4 -5
  143. package/dist/node_modules/@dalcode/dal-mcp/src/types.d.ts +50 -5
  144. package/dist/node_modules/@dalcode/dal-mcp/src/types.js +1 -1
  145. package/dist/node_modules/@dalcode/dal-office/package.json +2 -2
  146. package/dist/node_modules/@dalcode/dal-office/src/index.d.ts +2 -2
  147. package/dist/node_modules/@dalcode/dal-office/src/index.js +1 -1
  148. package/dist/node_modules/@dalcode/dal-office/src/render/docx.js +1 -1
  149. package/dist/node_modules/@dalcode/dal-office/src/render/pptx.d.ts +8 -0
  150. package/dist/node_modules/@dalcode/dal-office/src/render/pptx.js +3 -3
  151. package/dist/node_modules/@dalcode/dal-office/src/render/xlsx.js +1 -1
  152. package/dist/node_modules/@dalcode/dal-office/src/themes.d.ts +2 -0
  153. package/dist/node_modules/@dalcode/dal-office/src/themes.js +1 -1
  154. package/dist/node_modules/@dalcode/dal-office/src/tools/ppt-generate.js +3 -2
  155. package/dist/node_modules/@dalcode/dal-office/src/tools/ppt-plan.js +2 -2
  156. package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.js +9 -3
  157. package/dist/node_modules/@dalcode/dal-pi-kit/dist/index.js +1 -1
  158. package/dist/node_modules/@dalcode/dal-pi-kit/dist/session-scope.js +1 -0
  159. package/dist/node_modules/@dalcode/dal-pi-kit/package.json +1 -1
  160. package/dist/node_modules/@dalcode/dal-pi-kit/src/i18n.js +9 -3
  161. package/dist/node_modules/@dalcode/dal-pi-kit/src/index.js +1 -1
  162. package/dist/node_modules/@dalcode/dal-pi-kit/src/session-scope.js +1 -0
  163. package/dist/node_modules/@dalcode/dal-plugins/package.json +4 -4
  164. package/dist/node_modules/@dalcode/dal-plugins/src/brand.js +1 -1
  165. package/dist/node_modules/@dalcode/dal-plugins/src/index.js +11 -11
  166. package/dist/node_modules/@dalcode/dal-recall/package.json +2 -2
  167. package/dist/node_modules/@dalcode/dal-remote/package.json +2 -2
  168. package/dist/node_modules/@dalcode/dal-review/package.json +3 -3
  169. package/dist/node_modules/@dalcode/dal-rewind/package.json +2 -2
  170. package/dist/node_modules/@dalcode/dal-rewind/src/core.d.ts +0 -1
  171. package/dist/node_modules/@dalcode/dal-rewind/src/core.js +8 -8
  172. package/dist/node_modules/@dalcode/dal-rewind/src/index.js +1 -1
  173. package/dist/node_modules/@dalcode/dal-router/package.json +9 -5
  174. package/dist/node_modules/@dalcode/dal-router/src/advisor.js +1 -1
  175. package/dist/node_modules/@dalcode/dal-router/src/commands.js +8 -7
  176. package/dist/node_modules/@dalcode/dal-router/src/config.d.ts +11 -0
  177. package/dist/node_modules/@dalcode/dal-router/src/config.js +2 -2
  178. package/dist/node_modules/@dalcode/dal-router/src/index.js +4 -4
  179. package/dist/node_modules/@dalcode/dal-router/src/roles/changes.js +5 -0
  180. package/dist/node_modules/@dalcode/dal-router/src/roles/index.js +13 -0
  181. package/dist/node_modules/@dalcode/dal-router/src/roles/models.d.ts +50 -0
  182. package/dist/node_modules/@dalcode/dal-router/src/roles/models.js +1 -0
  183. package/dist/node_modules/@dalcode/dal-router/src/roles/prompts.js +40 -0
  184. package/dist/node_modules/@dalcode/dal-router/src/roles/signals.js +2 -0
  185. package/dist/node_modules/@dalcode/dal-router/src/runtime.d.ts +3 -0
  186. package/dist/node_modules/@dalcode/dal-router/src/runtime.js +1 -1
  187. package/dist/node_modules/@dalcode/dal-router/src/subagent.js +1 -1
  188. package/dist/node_modules/@dalcode/dal-rtk/package.json +2 -2
  189. package/dist/node_modules/@dalcode/dal-skills/package.json +3 -3
  190. package/dist/node_modules/@dalcode/dal-skills/src/bundled/dal-slides/SKILL.md +74 -0
  191. package/dist/node_modules/@dalcode/dal-skills/src/bundled.js +1 -1
  192. package/dist/node_modules/@dalcode/dal-skills/src/client.js +1 -1
  193. package/dist/node_modules/@dalcode/dal-skills/src/index.js +14 -14
  194. package/dist/node_modules/@dalcode/dal-skills/src/packages.js +3 -3
  195. package/dist/node_modules/@dalcode/dal-skills/src/search.js +1 -1
  196. package/dist/node_modules/@dalcode/dal-statusline/package.json +2 -2
  197. package/dist/node_modules/@dalcode/dal-structured/package.json +2 -2
  198. package/dist/node_modules/@dalcode/dal-subagent/package.json +5 -5
  199. package/dist/node_modules/@dalcode/dal-telemetry/package.json +3 -3
  200. package/dist/node_modules/@dalcode/dal-terminal/package.json +2 -2
  201. package/dist/node_modules/@dalcode/dal-tool-catalog/package.json +2 -2
  202. package/dist/node_modules/@dalcode/dal-tool-catalog/src/index.js +4 -4
  203. package/dist/node_modules/@dalcode/dal-usage/package.json +2 -2
  204. package/dist/node_modules/@dalcode/dal-web/package.json +3 -3
  205. package/dist/node_modules/@dalcode/dal-workflow/LICENSE +27 -0
  206. package/dist/node_modules/@dalcode/dal-workflow/package.json +2 -2
  207. package/dist/node_modules/@dalcode/dal-workflow/src/index.js +4 -4
  208. package/dist/node_modules/@dalcode/dal-workflow/src/plan-mode.js +13 -13
  209. package/dist/node_modules/@dalcode/dal-workflow/src/todo-snapshot.js +2 -0
  210. package/dist/node_modules/@dalcode/dal-workflow/src/todo.js +4 -4
  211. package/dist/node_modules/@dalcode/deepailab/package.json +3 -3
  212. package/dist/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
  213. package/dist/node_modules/@earendil-works/pi-ai/README.md +5 -34
  214. package/dist/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +5 -5
  215. package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-shared.js +1 -1
  216. package/dist/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js +4 -4
  217. package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +1 -1
  218. package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js +6 -6
  219. package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +2 -2
  220. package/dist/node_modules/@earendil-works/pi-ai/dist/index.d.ts +0 -1
  221. package/dist/node_modules/@earendil-works/pi-ai/dist/index.js +1 -1
  222. package/dist/node_modules/@earendil-works/pi-ai/dist/models.d.ts +1 -0
  223. package/dist/node_modules/@earendil-works/pi-ai/dist/models.js +1 -1
  224. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/compat-schema.d.ts +359 -0
  225. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/compat-schema.js +1 -0
  226. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  227. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/amazon-bedrock.json +1 -1
  228. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/anthropic.json +1 -1
  229. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/azure.json +1 -1
  230. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/baseten.json +1 -1
  231. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/cerebras.json +1 -1
  232. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
  233. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-workers-ai.json +1 -1
  234. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -1
  235. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
  236. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/google.json +1 -1
  237. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/groq.json +1 -1
  238. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/huggingface.json +1 -1
  239. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/kimi-coding.json +1 -1
  240. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/minimax-cn.json +1 -1
  241. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/minimax.json +1 -1
  242. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/mistral.json +1 -1
  243. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/moonshotai-cn.json +1 -1
  244. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/nvidia.json +1 -1
  245. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openai-codex.json +1 -1
  246. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json +1 -1
  247. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
  248. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
  249. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  250. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan-cn.json +1 -1
  251. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan.json +1 -1
  252. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/radius.json +1 -1
  253. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/together.json +1 -1
  254. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
  255. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xai.json +1 -1
  256. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-ams.json +1 -1
  257. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-cn.json +1 -1
  258. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-sgp.json +1 -1
  259. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi.json +1 -1
  260. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.js +1 -1
  261. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/model-schema.d.ts +90 -0
  262. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/model-schema.js +1 -0
  263. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/openrouter-api.js +1 -0
  264. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.js +1 -1
  265. package/dist/node_modules/@earendil-works/pi-ai/dist/types.d.ts +5 -146
  266. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/retry.js +1 -1
  267. package/dist/node_modules/@earendil-works/pi-ai/package.json +2 -2
  268. package/dist/node_modules/@earendil-works/pi-codemode/README.md +195 -11
  269. package/dist/node_modules/@earendil-works/pi-codemode/dist/cloudflare.js +1 -0
  270. package/dist/node_modules/@earendil-works/pi-codemode/dist/declarations.d.ts +0 -2
  271. package/dist/node_modules/@earendil-works/pi-codemode/dist/declarations.js +9 -84
  272. package/dist/node_modules/@earendil-works/pi-codemode/dist/index.d.ts +5 -2
  273. package/dist/node_modules/@earendil-works/pi-codemode/dist/index.js +1 -1
  274. package/dist/node_modules/@earendil-works/pi-codemode/dist/portable.js +1 -0
  275. package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/execution.d.ts +29 -0
  276. package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/execution.js +1 -0
  277. package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/host.d.ts +3 -16
  278. package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/host.js +1 -1
  279. package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/inline.d.ts +13 -0
  280. package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/inline.js +1 -0
  281. package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/prelude-source.js +14 -6
  282. package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/protocol.d.ts +72 -0
  283. package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/protocol.js +1 -1
  284. package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/remote.d.ts +32 -0
  285. package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/remote.js +1 -0
  286. package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/vm.js +3 -0
  287. package/dist/node_modules/@earendil-works/pi-codemode/dist/runtime/worker.js +1 -3
  288. package/dist/node_modules/@earendil-works/pi-codemode/dist/source.js +4 -3
  289. package/dist/node_modules/@earendil-works/pi-codemode/dist/types.d.ts +51 -1
  290. package/dist/node_modules/@earendil-works/pi-codemode/package.json +14 -2
  291. package/dist/node_modules/@earendil-works/pi-coding-agent/package.json +1 -1
  292. package/dist/node_modules/@earendil-works/pi-mcp/CHANGELOG.md +13 -0
  293. package/dist/node_modules/@earendil-works/pi-mcp/dist/client.js +1 -1
  294. package/dist/node_modules/@earendil-works/pi-mcp/dist/index.d.ts +1 -1
  295. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/errors.d.ts +2 -2
  296. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/errors.js +1 -1
  297. package/dist/node_modules/@earendil-works/pi-mcp/dist/oauth/flow.js +1 -1
  298. package/dist/node_modules/@earendil-works/pi-mcp/dist/protocol/content.d.ts +1 -1
  299. package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/streamable-http.d.ts +2 -2
  300. package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/streamable-http.js +4 -4
  301. package/dist/node_modules/@earendil-works/pi-mcp/dist/transports/transport.d.ts +4 -1
  302. package/dist/node_modules/@earendil-works/pi-mcp/package.json +1 -1
  303. package/dist/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
  304. package/dist/node_modules/@earendil-works/pi-tui/README.md +5 -3
  305. package/dist/node_modules/@earendil-works/pi-tui/dist/components/editor.js +6 -6
  306. package/dist/node_modules/@earendil-works/pi-tui/dist/components/input.js +2 -2
  307. package/dist/node_modules/@earendil-works/pi-tui/dist/index.d.ts +1 -1
  308. package/dist/node_modules/@earendil-works/pi-tui/dist/index.js +1 -1
  309. package/dist/node_modules/@earendil-works/pi-tui/dist/keys.js +5 -5
  310. package/dist/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.js +1 -1
  311. package/dist/node_modules/@earendil-works/pi-tui/dist/terminal-image.js +1 -1
  312. package/dist/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.js +3 -3
  313. package/dist/node_modules/@earendil-works/pi-tui/dist/tui-main-screen.js +1 -1
  314. package/dist/node_modules/@earendil-works/pi-tui/dist/tui.d.ts +4 -0
  315. package/dist/node_modules/@earendil-works/pi-tui/dist/tui.js +2 -2
  316. package/dist/node_modules/@earendil-works/pi-tui/dist/utils.js +1 -1
  317. package/dist/node_modules/@earendil-works/pi-tui/package.json +1 -1
  318. package/dist/sdk/index.d.ts +3 -3
  319. package/dist/sdk/index.js +1 -1
  320. package/dist/sdk/rewind.d.ts +1 -1
  321. package/dist/sdk/rewind.js +1 -1
  322. package/dist/utils/clipboard.js +1 -1
  323. package/dist/utils/output-files.js +1 -1
  324. package/dist/utils/temp-files.js +1 -0
  325. package/docs/security.md +24 -7
  326. package/examples/README.md +0 -3
  327. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  328. package/examples/extensions/dynamic-resources/dynamic.json +1 -1
  329. package/examples/extensions/gondolin/package-lock.json +2 -2
  330. package/examples/extensions/gondolin/package.json +1 -1
  331. package/examples/extensions/minimal-mode.ts +4 -5
  332. package/examples/extensions/overlay-test.ts +2 -2
  333. package/examples/extensions/sandbox/package-lock.json +2 -2
  334. package/examples/extensions/sandbox/package.json +1 -1
  335. package/examples/extensions/subagent/index.ts +4 -6
  336. package/examples/extensions/with-deps/package-lock.json +2 -2
  337. package/examples/extensions/with-deps/package.json +1 -1
  338. package/npm-shrinkwrap.json +9 -460
  339. package/package.json +3 -12
  340. package/dist/modes/interactive/theme/theme-json.d.ts +0 -75
  341. package/dist/modes/interactive/theme/theme-json.js +0 -12
  342. package/dist/modes/interactive/theme/theme-schema.json +0 -361
  343. package/dist/node_modules/@earendil-works/chord/README.md +0 -264
  344. package/dist/node_modules/@earendil-works/chord/dist/api.js +0 -1
  345. package/dist/node_modules/@earendil-works/chord/dist/bundler.js +0 -1
  346. package/dist/node_modules/@earendil-works/chord/dist/context/index.js +0 -1
  347. package/dist/node_modules/@earendil-works/chord/dist/delta/apply-immutable-trusted.js +0 -1
  348. package/dist/node_modules/@earendil-works/chord/dist/delta/diff.js +0 -1
  349. package/dist/node_modules/@earendil-works/chord/dist/delta/draft.js +0 -0
  350. package/dist/node_modules/@earendil-works/chord/dist/delta/index.js +0 -1
  351. package/dist/node_modules/@earendil-works/chord/dist/delta/revision-validator.js +0 -1
  352. package/dist/node_modules/@earendil-works/chord/dist/delta/tracker.js +0 -1
  353. package/dist/node_modules/@earendil-works/chord/dist/facets/host.js +0 -1
  354. package/dist/node_modules/@earendil-works/chord/dist/facets/loader.js +0 -1
  355. package/dist/node_modules/@earendil-works/chord/dist/index.js +0 -1
  356. package/dist/node_modules/@earendil-works/chord/dist/json.js +0 -1
  357. package/dist/node_modules/@earendil-works/chord/dist/node/bundle-loader.js +0 -2
  358. package/dist/node_modules/@earendil-works/chord/dist/node/bundle.js +0 -4
  359. package/dist/node_modules/@earendil-works/chord/dist/node/manifest.js +0 -1
  360. package/dist/node_modules/@earendil-works/chord/dist/node/package.js +0 -1
  361. package/dist/node_modules/@earendil-works/chord/dist/node.js +0 -1
  362. package/dist/node_modules/@earendil-works/chord/dist/services/consumer.js +0 -1
  363. package/dist/node_modules/@earendil-works/chord/dist/services/errors.js +0 -1
  364. package/dist/node_modules/@earendil-works/chord/dist/services/handle.js +0 -1
  365. package/dist/node_modules/@earendil-works/chord/dist/services/instances.js +0 -1
  366. package/dist/node_modules/@earendil-works/chord/dist/services/loopback.js +0 -1
  367. package/dist/node_modules/@earendil-works/chord/dist/services/provider.js +0 -1
  368. package/dist/node_modules/@earendil-works/chord/dist/services/state-codec.js +0 -1
  369. package/dist/node_modules/@earendil-works/chord/dist/services/state-internals.js +0 -1
  370. package/dist/node_modules/@earendil-works/chord/dist/services/state.js +0 -1
  371. package/dist/node_modules/@earendil-works/chord/dist/services/wire.js +0 -1
  372. package/dist/node_modules/@earendil-works/chord/dist/types.js +0 -0
  373. package/dist/node_modules/@earendil-works/chord/package.json +0 -62
  374. package/dist/node_modules/@earendil-works/chord/src/delta/README.md +0 -191
  375. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/assistant-message-frame.d.ts +0 -63
  376. package/dist/node_modules/@earendil-works/pi-ai/dist/utils/assistant-message-frame.js +0 -1
  377. package/dist/node_modules/@earendil-works/pi-client/CHANGELOG.md +0 -45
  378. package/dist/node_modules/@earendil-works/pi-client/LICENSE +0 -21
  379. package/dist/node_modules/@earendil-works/pi-client/README.md +0 -72
  380. package/dist/node_modules/@earendil-works/pi-client/dist/client.js +0 -1
  381. package/dist/node_modules/@earendil-works/pi-client/dist/connection.js +0 -1
  382. package/dist/node_modules/@earendil-works/pi-client/dist/errors.js +0 -1
  383. package/dist/node_modules/@earendil-works/pi-client/dist/index.js +0 -1
  384. package/dist/node_modules/@earendil-works/pi-client/dist/promise.js +0 -1
  385. package/dist/node_modules/@earendil-works/pi-client/dist/transport.js +0 -0
  386. package/dist/node_modules/@earendil-works/pi-client/dist/types.js +0 -0
  387. package/dist/node_modules/@earendil-works/pi-client/dist/unix.js +0 -1
  388. package/dist/node_modules/@earendil-works/pi-client/package.json +0 -46
  389. package/dist/node_modules/@earendil-works/pi-protocol/LICENSE +0 -21
  390. package/dist/node_modules/@earendil-works/pi-protocol/README.md +0 -41
  391. package/dist/node_modules/@earendil-works/pi-protocol/dist/cbor/decoder.js +0 -1
  392. package/dist/node_modules/@earendil-works/pi-protocol/dist/cbor/encoder.js +0 -1
  393. package/dist/node_modules/@earendil-works/pi-protocol/dist/cbor/index.js +0 -1
  394. package/dist/node_modules/@earendil-works/pi-protocol/dist/cbor/options.js +0 -1
  395. package/dist/node_modules/@earendil-works/pi-protocol/dist/codec.js +0 -1
  396. package/dist/node_modules/@earendil-works/pi-protocol/dist/framing.js +0 -1
  397. package/dist/node_modules/@earendil-works/pi-protocol/dist/index.js +0 -1
  398. package/dist/node_modules/@earendil-works/pi-protocol/dist/protocol.js +0 -1
  399. package/dist/node_modules/@earendil-works/pi-protocol/dist/schemas.js +0 -1
  400. package/dist/node_modules/@earendil-works/pi-protocol/package.json +0 -39
  401. package/dist/node_modules/@earendil-works/pi-server/CHANGELOG.md +0 -81
  402. package/dist/node_modules/@earendil-works/pi-server/LICENSE +0 -21
  403. package/dist/node_modules/@earendil-works/pi-server/README.md +0 -63
  404. package/dist/node_modules/@earendil-works/pi-server/dist/connection.js +0 -1
  405. package/dist/node_modules/@earendil-works/pi-server/dist/errors.js +0 -1
  406. package/dist/node_modules/@earendil-works/pi-server/dist/index.js +0 -1
  407. package/dist/node_modules/@earendil-works/pi-server/dist/listener.js +0 -0
  408. package/dist/node_modules/@earendil-works/pi-server/dist/server.js +0 -1
  409. package/dist/node_modules/@earendil-works/pi-server/dist/session-router.js +0 -1
  410. package/dist/node_modules/@earendil-works/pi-server/dist/testing/client.js +0 -1
  411. package/dist/node_modules/@earendil-works/pi-server/dist/testing/host.js +0 -1
  412. package/dist/node_modules/@earendil-works/pi-server/dist/testing/index.js +0 -1
  413. package/dist/node_modules/@earendil-works/pi-server/dist/testing/server.js +0 -1
  414. package/dist/node_modules/@earendil-works/pi-server/dist/transports/unix/address.js +0 -1
  415. package/dist/node_modules/@earendil-works/pi-server/dist/transports/unix/index.js +0 -1
  416. package/dist/node_modules/@earendil-works/pi-server/dist/transports/unix/listener.js +0 -1
  417. package/dist/node_modules/@earendil-works/pi-server/dist/transports/unix/preset.js +0 -1
  418. package/dist/node_modules/@earendil-works/pi-server/dist/transports/unix/types.js +0 -0
  419. package/dist/node_modules/@earendil-works/pi-server/dist/types.js +0 -0
  420. package/dist/node_modules/@earendil-works/pi-server/package.json +0 -45
  421. package/examples/plugins/pi-example-plugin/README.md +0 -38
  422. package/examples/plugins/pi-example-plugin/package.json +0 -10
  423. package/examples/plugins/pi-example-plugin/src/contract.ts +0 -13
  424. package/examples/plugins/pi-example-plugin/src/session.ts +0 -24
  425. package/examples/plugins/pi-example-plugin/src/tui.ts +0 -31
  426. /package/dist/node_modules/{@earendil-works/chord → @dalcode/dal-codeindex}/LICENSE +0 -0
@@ -1,46 +0,0 @@
1
- {
2
- "name": "@earendil-works/pi-client",
3
- "version": "1.0.44",
4
- "description": "Transport-neutral client for remote pi sessions over framed CBOR bytes",
5
- "type": "module",
6
- "main": "./dist/index.js",
7
- "types": "./dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/index.d.ts",
11
- "import": "./dist/index.js"
12
- },
13
- "./unix": {
14
- "types": "./dist/unix.d.ts",
15
- "import": "./dist/unix.js"
16
- },
17
- "./package.json": "./package.json"
18
- },
19
- "sideEffects": false,
20
- "files": [
21
- "dist",
22
- "README.md",
23
- "CHANGELOG.md"
24
- ],
25
- "keywords": [
26
- "pi",
27
- "client",
28
- "protocol",
29
- "cbor",
30
- "binary"
31
- ],
32
- "author": "Earendil Works",
33
- "license": "MIT",
34
- "repository": {
35
- "type": "git",
36
- "url": "git+https://github.com/earendil-works/pi.git",
37
- "directory": "packages/client"
38
- },
39
- "engines": {
40
- "node": ">=22.19.0"
41
- },
42
- "dependencies": {
43
- "@earendil-works/chord": "^1.0.44",
44
- "@earendil-works/pi-protocol": "^1.0.44"
45
- }
46
- }
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Mario Zechner
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,41 +0,0 @@
1
- # @earendil-works/pi-protocol
2
-
3
- Runtime-neutral routed envelopes, CBOR encoding, and byte-stream framing for the experimental Pi protocol.
4
-
5
- Protocol version `8` defines:
6
-
7
- - a version handshake that identifies the logical `serverId`;
8
- - explicit server and Session request targets;
9
- - correlated requests and responses with opaque strict-JSON payloads;
10
- - request cancellation, opaque subscription updates, and out-of-band attachment changes;
11
- - non-empty opaque error codes and bounded transport messages.
12
-
13
- A server target contains `{ serverId }`; a Session target contains `{ serverId, sessionId, attachmentId }`. The combined route fences calls to one logical server, durable Session, and live presentation attachment. Management `attach()` and `detach()` return no routing identifiers; the server publishes the selected live route in an out-of-band `attachment` message. Disconnecting releases only that presentation's attachment after admitted calls settle.
14
-
15
- Chord owns the payload semantics carried inside these envelopes: `{ serviceId, instance?, member, args }` calls, the `$chord.service` control vocabulary, service catalogues, subscription snapshots and updates, service error codes, and the independent Delta path codecs for replicated states. `pi-protocol` validates that each opaque payload is strict JSON but does not validate or export its Chord grammar. Clients and servers parse those values through `@earendil-works/chord` at the service adapter boundary.
16
-
17
- Session-directory state, management results, transcripts, models, plugins, and all other application values remain opaque service data. The durable Session and its Harness remain local to the Session worker process. Server and Session calls route opaquely to their owning providers, where Chord and the application validate and invoke them.
18
-
19
- Server and worker lifecycle is intentionally outside this public protocol. The experimental local coordinator is only an opaque message router; each replaceable server process owns the private lifecycle protocol.
20
-
21
- Each wire frame consists of a four-byte unsigned big-endian payload length followed by one definite-length CBOR item. `encodeClientMessage()` and `encodeServerMessage()` validate and encode complete frames. `ClientMessageDecoder` and `ServerMessageDecoder` accept arbitrary stream fragmentation and coalescing.
22
-
23
- ```ts
24
- import {
25
- PROTOCOL_VERSION,
26
- encodeClientMessage,
27
- ServerMessageDecoder,
28
- type ClientHello,
29
- } from "@earendil-works/pi-protocol";
30
-
31
- const hello: ClientHello = { type: "hello", version: PROTOCOL_VERSION };
32
- transport.send(encodeClientMessage(hello));
33
-
34
- const decoder = new ServerMessageDecoder({ maxFrameLength: 1024 * 1024 });
35
- for (const message of decoder.push(incomingChunk)) handleServerMessage(message);
36
- decoder.end();
37
- ```
38
-
39
- All envelope schemas reject unknown object properties, and codecs recursively reject non-JSON opaque payloads, including non-finite numbers, byte arrays, `undefined`, prototypes, and cycles. Envelope violations, malformed CBOR, and invalid framing throw `ProtocolValidationError`. Payload-specific adapters must perform their own semantic validation after decoding. Transports must preserve byte order. Peer authentication and authenticated service contexts are not implemented by the experimental transport.
40
-
41
- Default limits are 16 MiB per CBOR payload/frame, 1,000,000 array elements or map entries, and 64 nested item levels. The protocol is experimental and has no compatibility guarantees.
@@ -1 +0,0 @@
1
- var f=Object.defineProperty;var c=(a,t)=>f(a,"name",{value:t,configurable:!0});import{CborError as r,resolveOptions as g,textDecoder as w,UINT32_BASE as l}from"./options.js";class y{static{c(this,"CborReader")}bytes;offset=0;options;constructor(t,e){this.bytes=t,this.options=e}decode(){const t=this.readItem(0);if(this.offset!==this.bytes.byteLength)throw new r("CBOR payload contains trailing data");return t}readItem(t){if(t>this.options.maxDepth)throw new r(`CBOR nesting depth exceeds configured limit of ${this.options.maxDepth}`);const e=this.readByte(),s=e>>>5,n=e&31;switch(s){case 0:return this.readArgument(n);case 1:{const i=-1-this.readArgument(n);if(!Number.isSafeInteger(i))throw new r("Decoded CBOR integer is outside the safe range");return i}case 2:{const i=this.readLength(n,"byte string",this.options.maxByteLength);return new Uint8Array(this.readBytes(i))}case 3:{const i=this.readLength(n,"text string",this.options.maxByteLength),o=this.readBytes(i);try{return w.decode(o)}catch{throw new r("CBOR text string contains invalid UTF-8")}}case 4:{const i=this.readLength(n,"array",this.options.maxContainerLength),o=[];for(let h=0;h<i;h++)o.push(this.readItem(t+1));return o}case 5:{const i=this.readLength(n,"map",this.options.maxContainerLength),o={},h=new Set;for(let u=0;u<i;u++){const d=this.readItem(t+1);if(typeof d!="string")throw new r("CBOR map keys must be strings");if(h.has(d))throw new r("CBOR map contains a duplicate key");h.add(d),Object.defineProperty(o,d,{configurable:!0,enumerable:!0,value:this.readItem(t+1),writable:!0})}return o}case 6:throw new r("CBOR tags are not supported");case 7:return this.readSimple(n);default:throw new r("Malformed CBOR major type")}}readSimple(t){switch(t){case 20:return!1;case 21:return!0;case 22:return null;case 27:{const e=this.readBytes(8),s=new DataView(e.buffer,e.byteOffset,e.byteLength).getFloat64(0,!1);if(!Number.isFinite(s))throw new r("Decoded CBOR number must be finite");if(Number.isInteger(s)&&!Number.isSafeInteger(s))throw new r("Decoded CBOR integer is outside the safe range");return s}case 31:throw new r("CBOR break marker is not supported");default:throw new r("Unsupported CBOR simple value or floating-point width")}}readLength(t,e,s){if(t===31)throw new r(`Indefinite-length CBOR ${e}s are not supported`);const n=this.readArgument(t);if(n>s)throw new r(`CBOR ${e} length exceeds configured limit of ${s}`);return n}readArgument(t){if(t<24)return t;switch(t){case 24:return this.readByte();case 25:{const e=this.readBytes(2);return e[0]*256+e[1]}case 26:{const e=this.readBytes(4);return e[0]*16777216+e[1]*65536+e[2]*256+e[3]}case 27:{const e=this.readArgument(26),s=this.readArgument(26);if(e>2097151)throw new r("Decoded CBOR integer or length is outside the safe range");return e*l+s}case 31:throw new r("Indefinite-length CBOR items are not supported");default:throw new r("Malformed CBOR additional information")}}readByte(){if(this.offset>=this.bytes.byteLength)throw new r("Truncated CBOR payload");const t=this.bytes[this.offset];return this.offset++,t}readBytes(t){if(t>this.bytes.byteLength-this.offset)throw new r("Truncated CBOR payload");const e=this.bytes.subarray(this.offset,this.offset+t);return this.offset+=t,e}}function b(a,t){if(!(a instanceof Uint8Array))throw new TypeError("CBOR input must be a Uint8Array");const e=g(t);if(a.byteLength>e.maxByteLength)throw new r(`CBOR byte length exceeds configured limit of ${e.maxByteLength}`);return new y(a,e).decode()}c(b,"decodeCbor");export{b as decodeCbor};
@@ -1 +0,0 @@
1
- var w=Object.defineProperty;var h=(n,t)=>w(n,"name",{value:t,configurable:!0});import{CborError as f,MAX_UINT32 as d,resolveOptions as x,textDecoder as B,textEncoder as a,UINT32_BASE as g}from"./options.js";class u{static{h(this,"CborWriter")}buffer;offset=0;maxByteLength;constructor(t){this.maxByteLength=t,this.buffer=new Uint8Array(Math.min(256,t))}writeByte(t){this.ensureCapacity(1),this.buffer[this.offset]=t,this.offset++}writeBytes(t){this.ensureCapacity(t.byteLength),this.buffer.set(t,this.offset),this.offset+=t.byteLength}writeUint16(t){this.ensureCapacity(2),this.buffer[this.offset]=t>>>8,this.buffer[this.offset+1]=t,this.offset+=2}writeUint32(t){this.ensureCapacity(4),this.buffer[this.offset]=t>>>24,this.buffer[this.offset+1]=t>>>16,this.buffer[this.offset+2]=t>>>8,this.buffer[this.offset+3]=t,this.offset+=4}writeUint64(t){const e=Math.floor(t/g),i=t-e*g;this.writeUint32(e),this.writeUint32(i)}writeFloat64(t){this.ensureCapacity(9),this.buffer[this.offset]=251,new DataView(this.buffer.buffer).setFloat64(this.offset+1,t,!1),this.offset+=9}finish(){return this.buffer.slice(0,this.offset)}ensureCapacity(t){const e=this.offset+t;if(e>this.maxByteLength)throw new f(`CBOR byte length exceeds configured limit of ${this.maxByteLength}`);if(e<=this.buffer.byteLength)return;let i=Math.max(1,this.buffer.byteLength);for(;i<e;)i=Math.min(this.maxByteLength,Math.max(e,i*2));const s=new Uint8Array(i);s.set(this.buffer),this.buffer=s}}function y(n,t,e){const i=t<<5;e<24?n.writeByte(i|e):e<=255?(n.writeByte(i|24),n.writeByte(e)):e<=65535?(n.writeByte(i|25),n.writeUint16(e)):e<=d?(n.writeByte(i|26),n.writeUint32(e)):(n.writeByte(i|27),n.writeUint64(e))}h(y,"writeArgument");function C(n){if(typeof n!="object"||n===null)return!1;const t=Object.getPrototypeOf(n);return t===Object.prototype||t===null}h(C,"isPlainObject");function m(n,t,e){const i=a.encode(t);if(i.byteLength>e.maxByteLength)throw new f(`CBOR text string length exceeds configured limit of ${e.maxByteLength}`);if(B.decode(i)!==t)throw new f("CBOR text strings must contain valid Unicode scalar values");y(n,3,i.byteLength),n.writeBytes(i)}h(m,"encodeText");function b(n,t,e,i,s){if(i>e.maxDepth)throw new f(`CBOR nesting depth exceeds configured limit of ${e.maxDepth}`);if(t===null){n.writeByte(246);return}if(typeof t=="boolean"){n.writeByte(t?245:244);return}if(typeof t=="number"){if(!Number.isFinite(t))throw new f("CBOR numbers must be finite");if(Number.isInteger(t)&&!Object.is(t,-0)){if(!Number.isSafeInteger(t))throw new f("CBOR integers must be safe JavaScript integers");t>=0?y(n,0,t):y(n,1,-1-t)}else n.writeFloat64(t);return}if(typeof t=="string"){m(n,t,e);return}if(t instanceof Uint8Array){if(t.byteLength>e.maxByteLength)throw new f(`CBOR byte string length exceeds configured limit of ${e.maxByteLength}`);y(n,2,t.byteLength),n.writeBytes(t);return}if(Array.isArray(t)){if(s.has(t))throw new f("CBOR values must not contain cycles");if(t.length>e.maxContainerLength)throw new f(`CBOR array length exceeds configured limit of ${e.maxContainerLength}`);s.add(t);try{y(n,4,t.length);for(let r=0;r<t.length;r++){if(!Object.hasOwn(t,r)||t[r]===void 0)throw new f("CBOR arrays must not contain holes or undefined values");b(n,t[r],e,i+1,s)}}finally{s.delete(t)}return}if(C(t)){if(s.has(t))throw new f("CBOR values must not contain cycles");for(const o of Object.getOwnPropertySymbols(t))if(Object.prototype.propertyIsEnumerable.call(t,o))throw new f("CBOR map keys must be strings");const r=[];for(const o of Object.keys(t)){const c=t[o];c!==void 0&&r.push([o,c])}if(r.length>e.maxContainerLength)throw new f(`CBOR map length exceeds configured limit of ${e.maxContainerLength}`);s.add(t);try{y(n,5,r.length);for(const[o,c]of r)m(n,o,e),b(n,c,e,i+1,s)}finally{s.delete(t)}return}throw new f(`Unsupported CBOR value type: ${typeof t}`)}h(b,"encodeValue");function L(n,t){const e=x(t),i=new u(e.maxByteLength);return b(i,n,e,0,new Set),i.finish()}h(L,"encodeCbor");export{L as encodeCbor};
@@ -1 +0,0 @@
1
- import{decodeCbor as _}from"./decoder.js";import{encodeCbor as T}from"./encoder.js";import{CborError as A,DEFAULT_MAX_CBOR_BYTE_LENGTH as C,DEFAULT_MAX_CBOR_CONTAINER_LENGTH as L,DEFAULT_MAX_CBOR_DEPTH as B}from"./options.js";export{A as CborError,C as DEFAULT_MAX_CBOR_BYTE_LENGTH,L as DEFAULT_MAX_CBOR_CONTAINER_LENGTH,B as DEFAULT_MAX_CBOR_DEPTH,_ as decodeCbor,T as encodeCbor};
@@ -1 +0,0 @@
1
- var _=Object.defineProperty;var r=(e,t)=>_(e,"name",{value:t,configurable:!0});const x=4294967296,T=4294967295,A=512,c=16777216,s=1e6,D=64;class L extends Error{static{r(this,"CborError")}constructor(t){super(t),this.name="CborError"}}const a=new TextEncoder,C=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});function n(e,t,o){if(!Number.isSafeInteger(t)||t<0||t>o)throw new RangeError(`${e} must be an integer between 0 and ${o}`);return t}r(n,"resolveLimit");function N(e){return{maxByteLength:n("maxByteLength",e?.maxByteLength??16777216,4294967295),maxContainerLength:n("maxContainerLength",e?.maxContainerLength??1e6,4294967295),maxDepth:n("maxDepth",e?.maxDepth??64,512)}}r(N,"resolveOptions");export{L as CborError,c as DEFAULT_MAX_CBOR_BYTE_LENGTH,s as DEFAULT_MAX_CBOR_CONTAINER_LENGTH,D as DEFAULT_MAX_CBOR_DEPTH,T as MAX_UINT32,x as UINT32_BASE,N as resolveOptions,C as textDecoder,a as textEncoder};
@@ -1 +0,0 @@
1
- var g=Object.defineProperty;var t=(e,r)=>g(e,"name",{value:r,configurable:!0});import{isJsonValue as c}from"@earendil-works/chord";import{Check as d}from"typebox/value";import{decodeCbor as w,encodeCbor as x}from"./cbor/index.js";import{DEFAULT_MAX_FRAME_LENGTH as h,encodeFrame as M,FrameDecoder as L}from"./framing.js";import{ClientMessageSchema as F,PROTOCOL_VERSION as E,ServerMessageSchema as $}from"./protocol.js";class s extends Error{static{t(this,"ProtocolValidationError")}constructor(r){super(r),this.name="ProtocolValidationError"}}function m(e){if(!d(F,e)||!c(e))throw new s("Invalid client protocol message");return e}t(m,"parseClientMessage");function f(e){if(!d($,e)||!c(e))throw new s("Invalid server protocol message");return e}t(f,"parseServerMessage");function i(e){return e instanceof Error?e.message.length<=500?e.message:`${e.message.slice(0,497)}...`:"Unknown codec error"}t(i,"boundedErrorMessage");function l(e,r,o,n){const u=r(e);try{const a=n?.maxFrameLength??h;return M(x(u,{maxByteLength:a}))}catch(a){throw a instanceof s?a:new s(`Unable to encode ${o} protocol message: ${i(a)}`)}}t(l,"encodeProtocolMessage");function b(e,r){return l(e,m,"client",r)}t(b,"encodeClientMessage");function y(e,r){return l(e,f,"server",r)}t(y,"encodeServerMessage");class p{static{t(this,"ValidatedMessageDecoder")}failed=!1;frames;kind;maxFrameLength;parse;constructor(r,o,n){this.frames=new L(n),this.kind=r,this.maxFrameLength=n?.maxFrameLength??h,this.parse=o}push(r){if(this.failed)throw new s(`${this.kind} message decoder has failed`);try{const o=[];for(const n of this.frames.push(r))o.push(this.parse(w(n,{maxByteLength:this.maxFrameLength})));return o}catch(o){throw this.failed=!0,o instanceof s?o:new s(`Invalid ${this.kind} protocol frame: ${i(o)}`)}}end(){if(this.failed)throw new s(`${this.kind} message decoder has failed`);try{this.frames.end()}catch(r){throw this.failed=!0,new s(`Invalid ${this.kind} protocol framing: ${i(r)}`)}}}class D{static{t(this,"ClientMessageDecoder")}decoder;constructor(r){this.decoder=new p("client",m,r)}push(r){return this.decoder.push(r)}end(){this.decoder.end()}}class P{static{t(this,"ServerMessageDecoder")}decoder;constructor(r){this.decoder=new p("server",f,r)}push(r){return this.decoder.push(r)}end(){this.decoder.end()}}function O(e){return Number.isInteger(e)&&e===E}t(O,"isSupportedProtocolVersion");export{D as ClientMessageDecoder,s as ProtocolValidationError,P as ServerMessageDecoder,b as encodeClientMessage,y as encodeServerMessage,O as isSupportedProtocolVersion,m as parseClientMessage,f as parseServerMessage};
@@ -1 +0,0 @@
1
- var l=Object.defineProperty;var o=(n,e)=>l(n,"name",{value:e,configurable:!0});const L=4,g=4294967295,f=65536,u=16777216;class i extends Error{static{o(this,"FrameError")}constructor(e){super(e),this.name="FrameError"}}function c(n){const e=n?.maxFrameLength??16777216;if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw new RangeError(`maxFrameLength must be an integer between 0 and ${4294967295}`);return e}o(c,"resolveMaxFrameLength");function m(n){if(!(n instanceof Uint8Array))throw new TypeError("Frame payload must be a Uint8Array");if(n.byteLength>4294967295)throw new RangeError("Frame payload exceeds the unsigned 32-bit length limit");const e=new Uint8Array(4+n.byteLength),h=n.byteLength;return e[0]=h>>>24,e[1]=h>>>16,e[2]=h>>>8,e[3]=h,e.set(n,4),e}o(m,"encodeFrame");class E{static{o(this,"FrameDecoder")}header=new Uint8Array(4);headerLength=0;maxFrameLength;payloadBlocks=[];currentPayloadBlock;currentPayloadBlockLength=0;expectedPayloadLength;payloadLength=0;state="open";constructor(e){this.maxFrameLength=c(e)}push(e){if(this.state==="ended")throw new i("Frame decoder has ended");if(this.state==="failed")throw new i("Frame decoder has failed");if(!(e instanceof Uint8Array))throw new TypeError("Frame chunk must be a Uint8Array");const h=[];let r=0;for(;r<e.byteLength;){if(this.expectedPayloadLength===void 0){const t=Math.min(4-this.headerLength,e.byteLength-r);if(this.header.set(e.subarray(r,r+t),this.headerLength),this.headerLength+=t,r+=t,this.headerLength<4)continue;const a=this.header[0]*16777216+this.header[1]*65536+this.header[2]*256+this.header[3];if(this.headerLength=0,a>this.maxFrameLength&&this.fail(`Frame length ${a} exceeds configured limit of ${this.maxFrameLength}`),a===0){h.push(new Uint8Array);continue}this.expectedPayloadLength=a,this.payloadBlocks=[],this.currentPayloadBlock=void 0,this.currentPayloadBlockLength=0,this.payloadLength=0}const s=this.expectedPayloadLength;if(s!==void 0){for(;r<e.byteLength&&this.payloadLength<s;){let t=this.currentPayloadBlock;(!t||this.currentPayloadBlockLength===t.byteLength)&&(t=new Uint8Array(Math.min(65536,s-this.payloadLength)),this.payloadBlocks.push(t),this.currentPayloadBlock=t,this.currentPayloadBlockLength=0);const a=Math.min(t.byteLength-this.currentPayloadBlockLength,e.byteLength-r);t.set(e.subarray(r,r+a),this.currentPayloadBlockLength),this.currentPayloadBlockLength+=a,this.payloadLength+=a,r+=a}if(this.payloadLength===s){if(this.payloadBlocks.length===1)h.push(this.payloadBlocks[0]);else{const t=new Uint8Array(s);let a=0;for(const d of this.payloadBlocks)t.set(d,a),a+=d.byteLength;h.push(t)}this.payloadBlocks=[],this.currentPayloadBlock=void 0,this.currentPayloadBlockLength=0,this.expectedPayloadLength=void 0,this.payloadLength=0}}}return h}end(){if(this.state==="ended")throw new i("Frame decoder has ended");if(this.state==="failed")throw new i("Frame decoder has failed");(this.headerLength!==0||this.expectedPayloadLength!==void 0)&&this.fail("Truncated frame at end of stream"),this.state="ended"}fail(e){throw this.state="failed",this.headerLength=0,this.payloadBlocks=[],this.currentPayloadBlock=void 0,this.currentPayloadBlockLength=0,this.expectedPayloadLength=void 0,this.payloadLength=0,new i(e)}}export{u as DEFAULT_MAX_FRAME_LENGTH,E as FrameDecoder,i as FrameError,m as encodeFrame};
@@ -1 +0,0 @@
1
- export*from"./cbor/index.js";export*from"./codec.js";export*from"./framing.js";import{isServerId as p,PROTOCOL_VERSION as t}from"./protocol.js";export{t as PROTOCOL_VERSION,p as isServerId};
@@ -1 +0,0 @@
1
- var m=Object.defineProperty;var a=(n,p)=>m(n,"name",{value:p,configurable:!0});import e from"typebox";import{Check as S}from"typebox/value";const h=8,r=e.String({minLength:1}),c=e.Unsafe(e.Unknown()),t=a(n=>e.Object(n,{additionalProperties:!1}),"StrictObject"),o=e.String({pattern:"^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"});function R(n){return S(o,n)}a(R,"isServerId");const s=t({code:r,message:e.String()}),v=t({type:e.Literal("hello"),version:e.Integer({minimum:0})}),d=t({serverId:o}),i=t({serverId:o,sessionId:r,attachmentId:r}),l=e.Union([d,i]),L=t({type:e.Literal("request"),id:r,target:l,call:c}),g=t({type:e.Literal("cancel"),id:r,target:l}),T=e.Union([v,L,g]),u=t({type:e.Literal("hello"),version:e.Literal(h),serverId:o}),f=t({type:e.Literal("hello_error"),error:s}),I=e.Union([t({type:e.Literal("response"),id:r,ok:e.Literal(!0),result:e.Optional(c)}),t({type:e.Literal("response"),id:r,ok:e.Literal(!1),error:s})]),y=t({type:e.Literal("service_update"),subscriptionId:r,update:c}),E=t({type:e.Literal("attachment"),attachment:e.Union([i,e.Null()])}),b=e.Union([u,f,I,y,E]);export{T as ClientMessageSchema,h as PROTOCOL_VERSION,b as ServerMessageSchema,R as isServerId};
@@ -1 +0,0 @@
1
- var k=Object.defineProperty;var d=(l,R)=>k(l,"name",{value:R,configurable:!0});import e from"typebox";const h=1,n=e.String({minLength:1}),i=e.Integer({minimum:0}),t=d(l=>e.Object(l,{additionalProperties:!1}),"StrictObject"),E=e.Cyclic({JsonValue:e.Union([e.Null(),e.Boolean(),e.Number(),e.String(),e.Array(e.Ref("JsonValue")),e.Record(e.String(),e.Ref("JsonValue"))])},"JsonValue"),r=e.Unsafe(E),a=e.Union([e.Literal("off"),e.Literal("minimal"),e.Literal("low"),e.Literal("medium"),e.Literal("high"),e.Literal("xhigh"),e.Literal("max")]),P=e.Union([e.Literal("idle"),e.Literal("turn"),e.Literal("compaction"),e.Literal("branch_summary"),e.Literal("retry")]),s=t({provider:n,id:n}),f=t({input:e.Number({minimum:0}),output:e.Number({minimum:0}),cacheRead:e.Number({minimum:0}),cacheWrite:e.Number({minimum:0})}),N=t({provider:n,id:n,name:e.String({minLength:1}),api:n,reasoning:e.Boolean(),input:e.Array(e.Union([e.Literal("text"),e.Literal("image")])),contextWindow:e.Integer({minimum:1}),maxTokens:e.Integer({minimum:1}),cost:f,supportedThinkingLevels:e.Array(a,{minItems:1}),authenticated:e.Boolean()}),c=t({type:e.Literal("text"),text:e.String()}),w=t({type:e.Literal("thinking"),thinking:e.String(),redacted:e.Optional(e.Boolean())}),S=t({type:e.Literal("image"),data:e.String(),mimeType:e.String({minLength:1})}),M=t({type:e.Literal("toolCall"),toolCallId:n,toolName:n,input:r}),q=e.Union([c,S]),V=e.Union([c,w,M]),B=e.Union([c,S]),u=t({input:e.Integer({minimum:0}),output:e.Integer({minimum:0}),cacheRead:e.Integer({minimum:0}),cacheWrite:e.Integer({minimum:0}),reasoning:e.Optional(e.Integer({minimum:0})),totalTokens:e.Integer({minimum:0}),cost:t({input:e.Number({minimum:0}),output:e.Number({minimum:0}),cacheRead:e.Number({minimum:0}),cacheWrite:e.Number({minimum:0}),total:e.Number({minimum:0})})}),L=t({id:n,role:e.Literal("user"),content:e.Array(q),timestamp:i}),m={id:n,role:e.Literal("assistant"),content:e.Array(V),model:s,responseModel:e.Optional(e.String({minLength:1})),usage:e.Optional(u),timestamp:i},J=t({...m,status:e.Literal("streaming")}),x=t({...m,status:e.Literal("complete"),stopReason:e.Union([e.Literal("stop"),e.Literal("length"),e.Literal("toolUse")])}),g=t({...m,status:e.Literal("error"),stopReason:e.Literal("error"),errorMessage:e.Optional(e.String({minLength:1}))}),I=t({...m,status:e.Literal("aborted"),stopReason:e.Literal("aborted"),errorMessage:e.Optional(e.String())}),y=e.Union([J,x,g,I]),p={id:n,role:e.Literal("tool"),toolCallId:n,toolName:n,input:r,content:e.Array(B),details:e.Optional(r),usage:e.Optional(u),timestamp:i},W=t({...p,status:e.Literal("running"),isError:e.Literal(!1)}),U=t({...p,status:e.Literal("complete"),isError:e.Literal(!1)}),C=t({...p,status:e.Literal("error"),isError:e.Literal(!0)}),v=e.Union([W,U,C]),T=e.Union([L,y,v]),H=e.Union([t({type:e.Literal("item_started"),item:T}),t({type:e.Literal("assistant_delta"),messageId:n,contentIndex:e.Integer({minimum:0}),kind:e.Union([e.Literal("text"),e.Literal("thinking"),e.Literal("toolCall")]),delta:e.String()}),t({type:e.Literal("item_updated"),item:e.Union([y,v])}),t({type:e.Literal("item_finished"),item:e.Union([x,g,I,U,C])})]),A=t({id:n,createdAt:i,updatedAt:e.Optional(i),parentSessionId:e.Optional(n),sessionName:e.Optional(e.String()),cwd:e.Optional(e.String({minLength:1}))}),o=t({id:n,name:e.Optional(e.String()),cwd:e.String({minLength:1}),createdAt:i,updatedAt:i,phase:P,model:s,thinkingLevel:a,attached:e.Boolean(),locked:e.Boolean(),revision:e.Integer({minimum:0}),transcript:e.Array(T),queuedSteer:e.Array(L),queuedSteerCount:e.Integer({minimum:0})}),O=t({serverId:n,protocolVersion:e.Literal(h),revision:e.Integer({minimum:0}),sessions:e.Array(A),models:e.Array(N)}),j=e.Union([e.Literal("version"),e.Literal("busy"),e.Literal("session_locked"),e.Literal("not_found"),e.Literal("invalid_request"),e.Literal("not_implemented"),e.Literal("internal_error")]),b=t({code:j,message:e.String(),details:e.Optional(r)}),_={sessionId:n,text:e.String()},D=t({command:e.Literal("list")}),z=t({command:e.Literal("create"),cwd:e.Optional(e.String({minLength:1})),name:e.Optional(e.String()),model:e.Optional(s),thinkingLevel:e.Optional(a)}),F=t({command:e.Literal("attach"),sessionId:n}),G=t({command:e.Literal("detach"),sessionId:n}),K=t({command:e.Literal("prompt"),..._}),Q=t({command:e.Literal("steer"),..._}),X=t({command:e.Literal("abort"),sessionId:n}),Y=t({command:e.Literal("set_model"),sessionId:n,model:s}),Z=t({command:e.Literal("set_thinking"),sessionId:n,thinkingLevel:a}),$=e.Union([e.Literal("info"),e.Literal("warning"),e.Literal("error")]),ee=e.Union([e.Literal("aux"),e.Literal("status")]),te=t({title:e.Optional(e.String()),lines:e.Optional(e.Array(e.String())),placement:e.Optional(ee)}),ne=t({id:n,label:e.String(),description:e.Optional(e.String())}),oe=e.Union([t({kind:e.Literal("input"),title:e.String(),placeholder:e.Optional(e.String())}),t({kind:e.Literal("choice"),title:e.String(),items:e.Array(ne,{minItems:1})})]),ie=e.Union([t({kind:e.Literal("panel"),id:n,panel:e.Optional(te)}),t({kind:e.Literal("status"),key:n,text:e.Optional(e.String())}),t({kind:e.Literal("notify"),level:$,message:e.String()}),t({kind:e.Literal("request"),requestId:n,request:oe})]),re=e.Union([t({type:e.Literal("value"),value:e.String()}),t({type:e.Literal("cancelled")})]),ae=t({command:e.Literal("subscribe_extension_ui"),sessionId:n}),se=t({command:e.Literal("extension_ui_answer"),sessionId:n,requestId:n,answer:re}),me=e.Union([D,z,F,G,K,Q,X,Y,Z,ae,se]),le=t({command:e.Literal("create"),session:o}),ce=t({command:e.Literal("attach"),session:o}),pe=t({command:e.Literal("prompt"),session:o}),de=t({command:e.Literal("steer"),session:o}),he=t({command:e.Literal("abort"),session:o}),Se=t({command:e.Literal("set_model"),session:o}),ue=t({command:e.Literal("set_thinking"),session:o}),Le=t({command:e.Literal("subscribe_extension_ui"),sessionId:n}),xe=t({command:e.Literal("extension_ui_answer"),sessionId:n,requestId:n}),ge=t({command:e.Literal("list"),sessions:e.Array(A)}),Ie=t({command:e.Literal("detach"),sessionId:n}),ye=e.Union([ge,le,ce,Ie,pe,de,he,Se,ue,Le,xe]),Ue=t({type:e.Literal("hello"),version:e.Integer({minimum:0})}),Ce=t({type:e.Literal("request"),id:n,request:me}),ke=e.Union([Ue,Ce]),ve=e.Union([t({type:e.Literal("server_snapshot"),snapshot:O}),t({type:e.Literal("session_snapshot"),snapshot:o}),t({type:e.Literal("session_progress"),sessionId:n,progress:H}),t({type:e.Literal("session_removed"),sessionId:n}),t({type:e.Literal("extension_ui"),sessionId:n,payload:ie})]),Te=t({type:e.Literal("hello"),version:e.Literal(h),connectionId:n,snapshot:O}),Ae=t({type:e.Literal("hello_error"),error:b}),Oe=e.Union([t({type:e.Literal("response"),id:n,ok:e.Literal(!0),result:ye}),t({type:e.Literal("response"),id:n,ok:e.Literal(!1),error:b})]),be=t({type:e.Literal("event"),event:ve}),Ee=e.Union([Te,Ae,Oe,be]);export{X as AbortCommandSchema,he as AbortResultSchema,V as AssistantContentSchema,y as AssistantTranscriptItemSchema,F as AttachCommandSchema,ce as AttachResultSchema,Ue as ClientHelloSchema,ke as ClientMessageSchema,ye as CommandResultSchema,me as CommandSchema,z as CreateCommandSchema,le as CreateResultSchema,G as DetachCommandSchema,Ie as DetachResultSchema,be as EventEnvelopeSchema,se as ExtensionUiAnswerCommandSchema,xe as ExtensionUiAnswerResultSchema,re as ExtensionUiAnswerSchema,ne as ExtensionUiChoiceItemSchema,$ as ExtensionUiLevelSchema,te as ExtensionUiPanelSchema,ie as ExtensionUiPayloadSchema,ee as ExtensionUiPlacementSchema,oe as ExtensionUiPromptSchema,S as ImageContentSchema,r as JsonValueSchema,D as ListCommandSchema,ge as ListResultSchema,f as ModelCostSchema,N as ModelMetadataSchema,s as ModelRefSchema,h as PROTOCOL_VERSION,K as PromptCommandSchema,pe as PromptResultSchema,j as ProtocolErrorCodeSchema,b as ProtocolErrorSchema,Ce as RequestEnvelopeSchema,Oe as ResponseEnvelopeSchema,ve as ServerEventSchema,Ae as ServerHelloErrorSchema,Te as ServerHelloSchema,Ee as ServerMessageSchema,O as ServerSnapshotSchema,A as SessionMetadataSchema,P as SessionPhaseSchema,o as SessionSnapshotSchema,Y as SetModelCommandSchema,Se as SetModelResultSchema,Z as SetThinkingCommandSchema,ue as SetThinkingResultSchema,Q as SteerCommandSchema,de as SteerResultSchema,ae as SubscribeExtensionUiCommandSchema,Le as SubscribeExtensionUiResultSchema,c as TextContentSchema,w as ThinkingContentSchema,a as ThinkingLevelSchema,M as ToolCallContentSchema,B as ToolContentSchema,v as ToolTranscriptItemSchema,T as TranscriptItemSchema,H as TranscriptProgressSchema,u as UsageSchema,q as UserContentSchema,L as UserTranscriptItemSchema};
@@ -1,39 +0,0 @@
1
- {
2
- "name": "@earendil-works/pi-protocol",
3
- "version": "1.0.44",
4
- "description": "Transport-neutral CBOR protocol for remote pi sessions",
5
- "type": "module",
6
- "main": "./dist/index.js",
7
- "types": "./dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/index.d.ts",
11
- "import": "./dist/index.js"
12
- }
13
- },
14
- "files": [
15
- "dist",
16
- "README.md"
17
- ],
18
- "keywords": [
19
- "pi",
20
- "protocol",
21
- "cbor",
22
- "binary",
23
- "framing"
24
- ],
25
- "author": "Earendil Works",
26
- "license": "MIT",
27
- "repository": {
28
- "type": "git",
29
- "url": "git+https://github.com/earendil-works/pi.git",
30
- "directory": "packages/protocol"
31
- },
32
- "engines": {
33
- "node": ">=22.19.0"
34
- },
35
- "dependencies": {
36
- "@earendil-works/chord": "^1.0.44",
37
- "typebox": "1.3.27"
38
- }
39
- }
@@ -1,81 +0,0 @@
1
- # Changelog
2
-
3
- `0.84.x` headings are inherited Pi history. DAL Code product version is `0.1.0`.
4
-
5
- ## [1.1.0] - 2026-10-07
6
-
7
- ## [1.0.4] - 2026-10-05
8
-
9
- ## [1.0.3] - 2026-10-05
10
-
11
- ## [1.0.2] - 2026-10-04
12
-
13
- ## [1.0.1] - 2026-10-03
14
-
15
- ## [1.0.0] - 2026-10-01
16
-
17
- ### Breaking Changes
18
-
19
- - `SessionMetadata` is now exported by `@earendil-works/pi-server` and requires only `id`; the package no longer depends on `@earendil-works/pi-agent-core`. The testing `TestServerHost` keeps an in-memory session map instead of a `MemorySessionRepo`, and `TestHarness` exposes `metadata` instead of `session`.
20
-
21
- ## [0.99.2] - 2026-09-30
22
-
23
- ## [0.99.1] - 2026-09-29
24
-
25
- ## [0.99.0] - 2026-09-29
26
-
27
- ## [0.87.1] - 2026-09-22
28
-
29
- ## [Unreleased]
30
-
31
- ### Added
32
-
33
- - Forwards `extension_ui` runtime events only to connections that called `subscribe_extension_ui`. `extension_ui_answer` is delivered to `PiSessionRuntime.answerExtensionUi`.
34
-
35
- ## [0.84.3] - 2026-08-24
36
-
37
- ## [0.84.2] - 2026-08-14
38
-
39
- ## [0.84.1] - 2026-08-07
40
-
41
- ## [0.84.0] - 2026-08-06
42
-
43
- ### Breaking Changes
44
-
45
- - Changed `toProtocolToolResultMessage()` to require the original `ToolCall` and verify tool result association.
46
- - Changed `PiServerService.listSessions()` to return durable `SessionMetadata` instead of runtime `SessionSummary` values ([#7708](https://github.com/earendil-works/pi/pull/7708)).
47
-
48
- ### Fixed
49
-
50
- - Hardened protocol adapters against contradictory lifecycle states, invalid identifiers and timestamps, sparse execution arrays, and additive `pi-ai` contract drift.
51
- - Sanitized service and runtime failures into stable `not_implemented` and `internal_error` responses without exposing private error details ([#7644](https://github.com/earendil-works/pi/pull/7644)).
52
-
53
- ## [0.83.0] - 2026-07-29
54
-
55
- ## [0.82.1] - 2026-07-25
56
-
57
- ## [0.82.0] - 2026-07-24
58
-
59
- ## [0.81.1] - 2026-07-21
60
-
61
- ## [0.81.0] - 2026-07-21
62
-
63
- ### Changed
64
-
65
- - Renamed the orchestrator workspace package and internal server references to server ([#6898](https://github.com/earendil-works/pi/pull/6898) by [@cristinaponcela](https://github.com/cristinaponcela)).
66
-
67
- ## [0.80.10] - 2026-07-16
68
-
69
- ## [0.80.9] - 2026-07-16
70
-
71
- ## [0.80.8] - 2026-07-16
72
-
73
- ## [0.80.7] - 2026-07-14
74
-
75
- ## [0.80.6] - 2026-07-09
76
-
77
- ## [0.80.5] - 2026-07-09
78
-
79
- ## [0.80.4] - 2026-07-09
80
-
81
- ## [0.80.3] - 2026-06-30
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Mario Zechner
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,63 +0,0 @@
1
- # @earendil-works/pi-server
2
-
3
- Experimental local server that routes clients to application-hosted durable Sessions.
4
-
5
- The current slice supports server- and Session-scoped facet-service routing and multi-presentation attachment. `RoutedServerServiceHost.attachClient()` creates one connection-scoped server service endpoint with narrow attachment-management capabilities. `RoutedSessionHandle.attachClient()` returns a presentation-scoped Session capability. Its `invokeService()` forwards an opaque service/member envelope to the selected Session endpoint; the server validates the attachment route but does not load the facet contract.
6
-
7
- - server service calls and subscriptions route opaquely through the connection's `RoutedServerServiceAttachment`;
8
- - the application-owned `SessionDirectory` projects the private catalog into replicated presentation-safe state;
9
- - the application-owned `SessionManagement` creates, removes, attaches, and detaches Sessions without exposing route IDs in business results;
10
- - attachment changes are published out of band after the router installs or clears the live route;
11
- - Session service calls route through `invokeService` without server-side business-payload decoding;
12
- - service subscription updates remain scoped to the requesting attachment;
13
- - application observations such as transcripts route as ordinary service state without server-owned business schemas.
14
-
15
- A Session may have multiple presentation attachments. Repeating `attach` from one connection is idempotent; every successful attachment has a server-generated `attachmentId` delivered only as routing control data. Session requests carry `{ serverId, sessionId, attachmentId }`, and the server rejects stale or mismatched routes. Losing a connection rejects its local responses but releases its attachment only after admitted service calls settle. The host decides when zero presentation demand and worker-local Harness activity permit worker retirement. Server shutdown closes every routed Session handle, releasing its worker and Session writer ownership.
16
-
17
- ```ts
18
- import { randomUUID } from "node:crypto";
19
- import {
20
- type RoutedServerServiceHost,
21
- type RoutedSessionHandle,
22
- type ServerHost,
23
- type SessionMetadata,
24
- SessionNotFoundError,
25
- } from "@earendil-works/pi-server";
26
- import { createUnixServer, getUnixSocketPath } from "@earendil-works/pi-server/unix";
27
-
28
- interface StoredSession extends SessionMetadata {
29
- path: string;
30
- }
31
-
32
- async function startServer(
33
- serverServices: RoutedServerServiceHost,
34
- sessions: Map<string, StoredSession>,
35
- openRoutedSession: (session: StoredSession) => Promise<RoutedSessionHandle>,
36
- ) {
37
- const host: ServerHost<StoredSession> = {
38
- serverServices,
39
- async resolveSession(sessionId) {
40
- const metadata = sessions.get(sessionId);
41
- if (!metadata) throw new SessionNotFoundError(`Unknown session: ${sessionId}`);
42
- return metadata;
43
- },
44
- openSession: (metadata) => openRoutedSession(metadata),
45
- };
46
-
47
- const serverId = randomUUID();
48
- const server = createUnixServer(host, {
49
- serverId,
50
- path: getUnixSocketPath(serverId, "/run/user/1000/pi"),
51
- });
52
- await server.start();
53
- return server;
54
- }
55
- ```
56
-
57
- Applications supply a required server service host, a bounded Session resolver, and a routed Session factory. `SessionMetadata` only requires an `id`; applications may extend it with their own storage fields. Session discovery and management are application-owned services; the protocol server only asks the resolver for metadata when routing an attachment. The host owns acquiring the worker-local Session and Harness. Failures are cleaned up in that worker. Neither an open JavaScript Session nor a Harness crosses the process boundary.
58
-
59
- `serverId` is a logical identity supplied by the launcher, not a socket address. The Unix preset requires an explicit physical `path`; `getUnixSocketPath()` derives one from a caller-selected directory. Choose a short, private runtime directory rather than deriving the route from an unbounded home-directory path. A long-lived launcher can reuse the same ID and path when replacing a server process.
60
-
61
- `Server` composes transports through `ServerListener`; peer authentication remains application policy and is not implemented by the experimental Unix transport. The Unix submodule provides `createUnixListener()` and `createUnixServer()`. Low-level routed-envelope validation, CBOR, and framing come from `@earendil-works/pi-protocol`; Chord owns service-control parsing, error codes, snapshots and updates, and each subscription's replicated-state encoder.
62
-
63
- Server and worker lifecycle is managed outside the public Pi protocol. The replaceable application server converts connection attachments into private demand updates; the worker combines generation-tagged demand with authoritative Harness activity. The experimental coordinator only supplies stable routing and reports generic server-generation connection changes.
@@ -1 +0,0 @@
1
- var c=Object.defineProperty;var e=(n,o)=>c(n,"name",{value:o,configurable:!0});function r(n){return n.disconnected||n.stage==="closing"||n.stage==="closed"}e(r,"isTerminalConnection");export{r as isTerminalConnection};
@@ -1 +0,0 @@
1
- var n=Object.defineProperty;var s=(r,e)=>n(r,"name",{value:e,configurable:!0});const a="Internal server error";class o extends Error{static{s(this,"ServerError")}code;constructor(e,t){super(t),this.name="ServerError",this.code=e}}class c extends o{static{s(this,"WrongServerError")}constructor(){super("wrong_server","Request was addressed to another server"),this.name="WrongServerError"}}class u extends o{static{s(this,"SessionNotFoundError")}constructor(e="Session was not found"){super("session_not_found",e),this.name="SessionNotFoundError"}}class d extends o{static{s(this,"SessionAmbiguousError")}constructor(){super("session_ambiguous","Session ID matches more than one session"),this.name="SessionAmbiguousError"}}class E extends o{static{s(this,"SessionNotAttachedError")}constructor(){super("session_not_attached","Session is not attached to this client"),this.name="SessionNotAttachedError"}}class S extends o{static{s(this,"ServerDrainingError")}constructor(){super("server_draining","Server is draining"),this.name="ServerDrainingError"}}export{a as INTERNAL_SERVER_ERROR_MESSAGE,S as ServerDrainingError,o as ServerError,d as SessionAmbiguousError,E as SessionNotAttachedError,u as SessionNotFoundError,c as WrongServerError};
@@ -1 +0,0 @@
1
- export*from"./errors.js";export*from"./listener.js";export*from"./server.js";export*from"./types.js";
@@ -1 +0,0 @@
1
- var T=Object.defineProperty;var n=(o,e)=>T(o,"name",{value:e,configurable:!0});import{createServiceStateEncoder as b,decodeServiceControlCall as P,parseServiceCall as M,parseServiceSubscriptionSnapshot as R,RemoteServiceError as k}from"@earendil-works/chord";import{BACKGROUND_CONTEXT as _,TODO_CONTEXT as h,withAbortSignal as A}from"@earendil-works/chord/context";import{ClientMessageDecoder as q,DEFAULT_MAX_FRAME_LENGTH as x,encodeServerMessage as w,isServerId as L,isSupportedProtocolVersion as F,PROTOCOL_VERSION as E,ProtocolValidationError as f}from"@earendil-works/pi-protocol";import{isTerminalConnection as C}from"./connection.js";import{INTERNAL_SERVER_ERROR_MESSAGE as U,ServerError as D,WrongServerError as O}from"./errors.js";import{SessionRouter as N}from"./session-router.js";const j=5e3,y=4294967295,I=2147483647;class Y{static{n(this,"Server")}serverId;closed;host;listeners;maxFrameLength;handshakeTimeoutMs;onConnectionCountChanged;onError;connections=new Set;sessions;closing=!1;closePromise;closedSettled=!1;rejectClosed;resolveClosed;startPromise;started=!1;constructor(e,s){const t=$(s);this.host=e,this.listeners=s.listeners,this.serverId=s.serverId,this.maxFrameLength=t.maxFrameLength,this.handshakeTimeoutMs=t.handshakeTimeoutMs,this.onConnectionCountChanged=s.onConnectionCountChanged,this.onError=s.onError,this.sessions=new N({host:e,serverId:this.serverId,isClosing:n(()=>this.closing,"isClosing"),publishAttachment:n(async(r,i)=>{await this.sendMessage(r,{type:"attachment",attachment:i??null})},"publishAttachment"),reportError:n(r=>this.reportError(r),"reportError")}),this.closed=new Promise((r,i)=>{this.resolveClosed=r,this.rejectClosed=i}),this.closed.catch(()=>{})}start(){return this.started?Promise.reject(new Error("Server is already started")):this.startPromise?Promise.reject(new Error("Server is already starting")):this.closing?Promise.reject(new Error("Server is closing or closed")):(this.startPromise=this.startInternal(),this.startPromise)}async startInternal(){const e=[];try{for(const s of this.listeners)await s.start(t=>this.accept(t)),e.push(s);return this.started=!0,this}catch(s){this.closing=!0;const t=[],r=await Promise.allSettled(e.map(i=>i.close()));for(const i of r)i.status==="rejected"&&t.push(i.reason);try{await this.closeServerState()}catch(i){t.push(i)}if(t.length>0){const i=new AggregateError([s,...t],"Server startup and cleanup failed");throw this.settleClosed(i),i}throw this.settleClosed(),s}finally{this.startPromise=void 0}}accept(e){if(this.closing)return this.closeConnection(e),{onData:n(()=>{},"onData"),onClose:n(()=>{},"onClose"),onError:n(r=>this.reportError(r),"onError")};let s;const t=setTimeout(()=>{this.failProtocol(s,{code:"invalid_request",message:"Handshake timeout"})},this.handshakeTimeoutMs);return t.unref(),s={connection:e,decoder:new q({maxFrameLength:this.maxFrameLength}),serviceStateEncoders:new Map,sessionIds:new Set,extensionUiSessions:new Set,stage:"awaitingHello",disconnected:!1,handshakeTimeout:t,activeRequests:new Map},this.connections.add(s),this.notifyConnectionCountChanged(),{onData:n(r=>this.receive(s,r),"onData"),onClose:n(()=>this.transportClosed(s),"onClose"),onError:n(r=>{this.reportError(r),this.closeConnection(e).then(()=>this.disconnect(s))},"onError")}}async close(){return this.closePromise?this.closePromise:(this.closing=!0,this.closePromise=this.closeInternal(),this.closePromise)}async closeInternal(){const e=this.startPromise;e&&await e.catch(()=>{});const s=[],t=await Promise.allSettled(this.listeners.map(r=>r.close()));for(const r of t)r.status==="rejected"&&s.push(r.reason);try{await this.closeServerState()}catch(r){s.push(r)}if(this.started=!1,s.length>0){const r=s.length===1&&s[0]instanceof Error?s[0]:new AggregateError(s,"Server shutdown failed");throw this.settleClosed(r),r}this.settleClosed()}receive(e,s){if(C(e))return;let t;try{t=e.decoder.push(s)}catch(r){this.failProtocol(e,this.toProtocolError(r));return}for(const r of t){if(C(e))return;this.dispatchMessage(e,r)}}dispatchMessage(e,s){if(e.stage==="awaitingHello"){if(s.type!=="hello"){this.failProtocol(e,{code:"invalid_request",message:"The first client message must be hello"});return}e.stage="handshaking",e.handshake=this.finishHandshake(e,s).catch(r=>this.failProtocol(e,this.toProtocolError(r)));return}if(s.type==="hello"){this.failProtocol(e,{code:"invalid_request",message:"hello may only be sent as the first message"});return}if(e.stage==="ready"){s.type==="cancel"?this.handleCancel(e,s):this.handleRequest(e,s);return}if(e.stage!=="handshaking")return;const t=e.handshake;t&&t.then(()=>{e.stage!=="ready"||e.disconnected||(s.type==="cancel"?this.handleCancel(e,s):this.handleRequest(e,s))})}async finishHandshake(e,s){if(!F(s.version)){await this.failProtocol(e,{code:"version",message:`Unsupported protocol version ${s.version}; expected ${E}`});return}if(this.closing||e.disconnected||e.stage!=="handshaking"||e.connection.closed)return;const t=await this.host.serverServices.attachClient({attachSession:n(async(i,l)=>{await this.sessions.attachClient(e,i,l)},"attachSession"),detachSession:n(i=>this.sessions.detachClient(e,i),"detachSession"),prepareSessionRemoval:n((i,l)=>this.sessions.removeSession(i,l),"prepareSessionRemoval")},h);if(this.closing||e.disconnected||e.stage!=="handshaking"||e.connection.closed){await t.release(h);return}e.serverServices=t,await this.sendMessage(e,{type:"hello",version:E,serverId:this.serverId})&&!e.disconnected&&e.stage==="handshaking"&&(e.stage="ready",clearTimeout(e.handshakeTimeout))}handleCancel(e,s){if(s.target.serverId!==this.serverId)return;const t=e.activeRequests.get(s.id);t!==void 0&&H(t.target,s.target)&&t.controller.abort(new DOMException("RPC request cancelled","AbortError"))}async handleRequest(e,s){if(e.activeRequests.has(s.id)){await this.sendMessage(e,{type:"response",id:s.id,ok:!1,error:{code:"invalid_request",message:"Request ID is already active"}});return}let t;try{t=M(s.call)}catch{await this.sendMessage(e,{type:"response",id:s.id,ok:!1,error:{code:"invalid_request",message:"Invalid service call"}});return}const r=new AbortController,i={controller:r,target:s.target};e.activeRequests.set(s.id,i);const l=A(r.signal,h),u=P(t),c=u?.type==="subscribe"?u:void 0,g=[];let v=c===void 0,p=!1,m=!1;const S=n(async(a,d)=>{if(c!==void 0&&a===c.subscriptionId&&!v){g.push({update:d});return}await this.sendServiceUpdate(e,a,d)},"publish");try{if(s.target.serverId!==this.serverId)throw new O;if(c!==void 0&&e.serviceStateEncoders.has(c.subscriptionId))throw new f(`Duplicate service subscription ${c.subscriptionId}`);let a;if("sessionId"in s.target)a=await this.sessions.executeServiceCall(t,s.target,e,S,l);else if(e.serverServices!==void 0)a=await e.serverServices.invokeService(t,S,l);else throw new f(`Unknown service member ${t.serviceId}.${t.member}`);if(c!==void 0){if(a===void 0)throw new f("Service subscription did not return a snapshot");const d=b();a=d.encodeSnapshot(R(a)),e.serviceStateEncoders.set(c.subscriptionId,d),p=!0}else u?.type==="unsubscribe"&&e.serviceStateEncoders.delete(u.subscriptionId);if(await this.sendMessage(e,a===void 0?{type:"response",id:s.id,ok:!0}:{type:"response",id:s.id,ok:!0,result:a}),m=!0,c!==void 0){for(;g.length>0;){const d=g.shift();d!==void 0&&await this.sendServiceUpdate(e,c.subscriptionId,d.update)}v=!0}}catch(a){c!==void 0&&p&&!m&&e.serviceStateEncoders.delete(c.subscriptionId),m?(this.reportError(a),await this.closeConnection(e.connection),this.disconnect(e)):await this.sendMessage(e,{type:"response",id:s.id,ok:!1,error:r.signal.aborted?{code:"cancelled",message:"RPC request cancelled"}:this.toProtocolError(a)})}finally{e.activeRequests.get(s.id)===i&&e.activeRequests.delete(s.id)}}transportClosed(e){if(!e.disconnected&&e.stage!=="closing")try{e.decoder.end()}catch(s){this.reportError(s)}this.disconnect(e)}disconnect(e){if(e.disconnected)return;e.disconnected=!0,e.stage="closed",clearTimeout(e.handshakeTimeout);for(const{controller:t}of e.activeRequests.values())t.abort(new Error("Client disconnected"));e.activeRequests.clear(),e.serviceStateEncoders.clear(),this.connections.delete(e)&&this.notifyConnectionCountChanged();const s=e.serverServices;delete e.serverServices,Promise.allSettled([this.sessions.disconnect(e,h),s?.release(h)]).then(t=>{for(const r of t)r.status==="rejected"&&this.reportError(r.reason)})}async sendServiceUpdate(e,s,t){const r=e.serviceStateEncoders.get(s);r!==void 0&&await this.sendMessage(e,{type:"service_update",subscriptionId:s,update:r.encodeUpdate(t)})}async sendMessage(e,s){if(e.disconnected||e.connection.closed)return!1;let t;try{t=w(s,{maxFrameLength:this.maxFrameLength})}catch(r){return this.reportError(r),await this.closeConnection(e.connection),this.disconnect(e),!1}try{return await e.connection.send(t),!0}catch(r){return this.reportError(r),await this.closeConnection(e.connection),this.disconnect(e),!1}}async failProtocol(e,s){if(e.disconnected||e.stage==="closing"||e.stage==="closed")return;e.stage="closing",clearTimeout(e.handshakeTimeout);const t={type:"hello_error",error:s};let r;try{r=w(t,{maxFrameLength:this.maxFrameLength})}catch(i){this.reportError(i)}await this.closeConnection(e.connection,r),this.disconnect(e)}async closeServerState(){const e=[...this.connections];for(const r of e)r.stage="closing",clearTimeout(r.handshakeTimeout);await Promise.all(e.map(r=>this.closeConnection(r.connection)));for(const r of e)this.disconnect(r);const s=await Promise.allSettled([this.sessions.close(_)]);this.connections.clear();const t=s.flatMap(r=>r.status==="rejected"?[r.reason]:[]);if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Failed to close server Sessions")}async closeConnection(e,s){try{await e.close(s)}catch(t){this.reportError(t)}}toProtocolError(e){return e instanceof D||e instanceof k?{code:e.code,message:e.message}:e instanceof f?{code:"invalid_request",message:e.message}:(this.reportError(e),{code:"internal_error",message:U})}notifyConnectionCountChanged(){try{this.onConnectionCountChanged?.(this.connections.size)}catch(e){this.reportError(e)}}reportError(e){try{this.onError?.(e instanceof Error?e:new Error(String(e)))}catch{}}settleClosed(e){this.closedSettled||(this.closedSettled=!0,e===void 0?this.resolveClosed():this.rejectClosed(e))}}function H(o,e){return o.serverId!==e.serverId?!1:!("sessionId"in o)||!("sessionId"in e)?!("sessionId"in o)&&!("sessionId"in e):o.sessionId===e.sessionId&&o.attachmentId===e.attachmentId}n(H,"sameTarget");function $(o){if(!Array.isArray(o.listeners))throw new TypeError("Server listeners must be an array");if(!L(o.serverId))throw new TypeError("serverId must be a canonical lowercase UUIDv4");const e=o.maxFrameLength??x;if(!Number.isSafeInteger(e)||e<=0||e>y)throw new TypeError(`Server maxFrameLength must be an integer between 1 and ${y}`);const s=o.handshakeTimeoutMs??j;if(!Number.isSafeInteger(s)||s<=0||s>I)throw new TypeError(`Server handshakeTimeoutMs must be an integer between 1 and ${I}`);return{maxFrameLength:e,handshakeTimeoutMs:s}}n($,"resolveOptions");export{Y as Server};
@@ -1 +0,0 @@
1
- var g=Object.defineProperty;var p=(u,t)=>g(u,"name",{value:t,configurable:!0});import{randomUUID as S}from"node:crypto";import{BACKGROUND_CONTEXT as C}from"@earendil-works/chord/context";import{ServerDrainingError as h,SessionNotAttachedError as w}from"./errors.js";class m extends AggregateError{static{p(this,"SessionCleanupError")}}class P{static{p(this,"SessionRouter")}options;hostedSessions=new Map;openingSessions=new Map;attachmentsByClient=new Map;disconnectedClients=new Set;clientOperations=new Map;closePromise;constructor(t){this.options=t}async executeServiceCall(t,s,e,i,n){return(await this.runForClient(e,()=>this.startServiceCall(e,s,t,i,n))).result}attachClient(t,s,e){return this.options.isClosing()?Promise.reject(new h):this.runForClient(t,()=>this.attachClientNow(t,s,e))}detachClient(t,s){return this.runForClient(t,async()=>{const e=this.attachmentsByClient.get(t);e&&await this.releaseAttachment(e,s)})}async removeSession(t,s){if(this.options.isClosing())throw new h;const e=this.hostedSessions.get(t);if(e===void 0)return;const i=[],n=await Promise.allSettled([...e.attachments].map(o=>this.releaseAttachment(o,s)));for(const o of n)o.status==="rejected"&&i.push(o.reason);try{await e.handle.close(s)}catch(o){i.push(o)}if(this.hostedSessions.get(t)===e&&this.hostedSessions.delete(t),i.length===1)throw i[0];if(i.length>1)throw new AggregateError(i,`Failed to close Session ${t}`)}async disconnect(t,s){this.disconnectedClients.add(t);try{await this.runForClient(t,async()=>{const e=this.attachmentsByClient.get(t);e&&await this.releaseAttachment(e,s,!1)})}finally{this.disconnectedClients.delete(t)}}close(t){return this.closePromise??=this.closeInternal(t),this.closePromise}async closeInternal(t){const s=[...this.clientOperations.values()],e=[...this.openingSessions.values()],[i,n]=await Promise.all([Promise.allSettled(s),Promise.allSettled(e)]),o=[];for(const r of[...i,...n])r.status==="rejected"&&(this.options.reportError(r.reason),r.reason instanceof m&&o.push(r.reason));const a=await Promise.allSettled([...this.hostedSessions.values()].flatMap(r=>[...r.attachments].map(l=>this.releaseAttachment(l,t))));for(const r of a)r.status==="rejected"&&o.push(r.reason);const c=[...this.hostedSessions.values()],d=await Promise.allSettled(c.map(({handle:r})=>r.close(t)));for(let r=0;r<d.length;r++){const l=d[r],f=c[r];if(l.status==="fulfilled"){this.hostedSessions.get(f.id)===f&&this.hostedSessions.delete(f.id);continue}this.options.reportError(l.reason),o.push(l.reason)}if(this.attachmentsByClient.clear(),this.clientOperations.clear(),o.length>0)throw new AggregateError(o,"Failed to close routed Sessions")}runForClient(t,s){const i=(this.clientOperations.get(t)??Promise.resolve()).catch(()=>{}).then(s),n=i.then(()=>{},()=>{});return this.clientOperations.set(t,n),n.finally(()=>{this.clientOperations.get(t)===n&&this.clientOperations.delete(t)}),i}async attachClientNow(t,s,e){if(this.options.isClosing()||this.disconnectedClients.has(t))throw new h;const i=this.attachmentsByClient.get(t);if(i?.session.id===s)return;const n=await this.acquire(s,e);if(this.options.isClosing()||this.disconnectedClients.has(t))throw new h;i&&await this.releaseAttachment(i,e,!1);const o={id:S(),client:t,session:n,operations:new Set};n.attachments.add(o);try{const a=Promise.resolve(n.handle.attachClient(e));o.acquiring=a,o.lease=await a}catch(a){throw n.attachments.delete(o),a}if(this.hostedSessions.get(n.id)!==n||!n.attachments.has(o)||this.disconnectedClients.has(t)||this.options.isClosing())throw await this.releaseAttachment(o,e),new h;this.attachmentsByClient.set(t,o),await this.options.publishAttachment(t,{serverId:this.options.serverId,sessionId:s,attachmentId:o.id},e)}async startServiceCall(t,s,e,i,n){const o=this.requireAttachment(t,s),a=o.lease.invokeService(e,(c,d,r)=>i(c,d,r),n);return this.trackOperation(o,a),{result:a}}trackOperation(t,s){t.operations.add(s);const e=p(()=>{t.operations.delete(s)},"remove");s.then(e,e)}requireAttachment(t,s){if(this.options.isClosing()||this.disconnectedClients.has(t))throw new h;if(!("sessionId"in s))throw new w;const e=this.attachmentsByClient.get(t);if(!e||e.session.id!==s.sessionId||e.id!==s.attachmentId)throw new w;return e}releaseAttachment(t,s,e=!0){return t.releasing??=(async()=>{const i=[];try{await Promise.allSettled(t.operations);try{const n=t.lease??await t.acquiring;n&&await n.release(s)}catch(n){i.push(n)}if(i.length===1)throw i[0];if(i.length>1)throw new AggregateError(i,"Failed to release Session attachment")}finally{await this.clearAttachment(t,s,e)}})(),t.releasing}async clearAttachment(t,s,e){t.session.attachments.delete(t),this.attachmentsByClient.get(t.client)===t&&(this.attachmentsByClient.delete(t.client),e&&await this.options.publishAttachment(t.client,void 0,s))}async acquire(t,s){const e=this.hostedSessions.get(t);if(e)return e;const i=this.openingSessions.get(t);if(i)return i;const n=this.open(t,s);this.openingSessions.set(t,n);try{return await n}finally{this.openingSessions.get(t)===n&&this.openingSessions.delete(t)}}async open(t,s){const e=await this.options.host.resolveSession(t,s),i=await this.options.host.openSession(e,s);if(this.options.isClosing()){try{await i.close(s)}catch(o){throw this.options.reportError(o),new m([new h,o],"Failed to close routed Session acquired while draining")}throw new h}const n={id:e.id,handle:i,attachments:new Set};return this.hostedSessions.set(n.id,n),i.terminated&&i.terminated.then(o=>this.invalidate(n,o),o=>this.invalidate(n,o instanceof Error?o:new Error(String(o)))),n}invalidate(t,s){if(this.hostedSessions.get(t.id)===t){this.hostedSessions.delete(t.id);for(const e of t.attachments)this.releaseAttachment(e,C).catch(i=>this.options.reportError(i));s&&this.options.reportError(s)}}}export{P as SessionRouter};
@@ -1 +0,0 @@
1
- var h=Object.defineProperty;var o=(i,e)=>h(i,"name",{value:e,configurable:!0});import{once as c}from"node:events";import{createConnection as u}from"node:net";import{encodeClientMessage as l,PROTOCOL_VERSION as m,ServerMessageDecoder as f}from"@earendil-works/pi-protocol";import{Deferred as w}from"./host.js";class g{static{o(this,"ProtocolTestClient")}messages=[];channel;decoder=new f;waiters=new Set;closedDeferred=new w;requestSequence=0;attachment;closedValue=!1;constructor(e){this.channel=e}get closed(){return this.closedValue}hello(e=m){const t=this.next(s=>s.type==="hello"||s.type==="hello_error");return this.sendMessage({type:"hello",version:e}),t}async requestService(e,t,s=`request-${++this.requestSequence}`){const r=this.next(n=>n.type==="response"&&n.id===s);return await this.sendMessage({type:"request",id:s,target:e,call:t}),await r}attach(e,t){return this.requestService({serverId:e},{serviceId:"pi.session-management",member:"attach",args:[t]})}requestSessionService(e,t,s,r){const n=this.attachment,d=n===void 0||n.sessionId!==t?{serverId:e,sessionId:t,attachmentId:"missing-attachment"}:{serverId:e,...n};return this.requestService(d,s,r)}sendMessage(e){return this.channel.send(l(e))}sendBytes(e){return this.channel.send(e)}sendFragmentedMessage(e,t){return this.channel.sendFragmented(l(e),t)}next(e){return this.nextFrom(0,e)}nextFrom(e,t){const s=this.messages.slice(e).find(t);return s?Promise.resolve(s):this.closedValue?Promise.reject(new Error("Wire client is closed")):new Promise((r,n)=>this.waiters.add({predicate:t,resolve:r,reject:n}))}waitForClose(){return this.closedValue?Promise.resolve():this.closedDeferred.promise}close(){return this.channel.close()}receive(e){try{for(const t of this.decoder.push(e)){t.type==="attachment"&&(this.attachment=t.attachment===null?void 0:{sessionId:t.attachment.sessionId,attachmentId:t.attachment.attachmentId}),this.messages.push(t);for(const s of this.waiters)s.predicate(t)&&(this.waiters.delete(s),s.resolve(t))}}catch(t){this.fail(t instanceof Error?t:new Error(String(t)))}}markClosed(){this.closedValue||(this.closedValue=!0,this.closedDeferred.resolve(void 0),this.fail(new Error("Wire connection closed")))}fail(e){for(const t of this.waiters)t.reject(e);this.waiters.clear()}}async function x(i){const e=u(i);await c(e,"connect");const t=new g({send:o(s=>a(e,s),"send"),async sendFragmented(s,r){await a(e,s.subarray(0,r)),await a(e,s.subarray(r))},async close(){if(e.destroyed)return;const s=c(e,"close");e.destroy(),await s}});return e.on("data",s=>{t.receive(new Uint8Array(s.buffer,s.byteOffset,s.byteLength))}),e.on("error",s=>t.fail(s)),e.once("close",()=>t.markClosed()),t}o(x,"connectUnixTestClient");function a(i,e){return new Promise((t,s)=>{i.write(e,r=>{r?s(r):t()})})}o(a,"writeSocket");export{g as ProtocolTestClient,x as connectUnixTestClient};
@@ -1 +0,0 @@
1
- var l=Object.defineProperty;var i=(r,e)=>l(r,"name",{value:e,configurable:!0});import{SessionNotFoundError as h}from"../errors.js";class n{static{i(this,"Deferred")}promise;resolvePromise;constructor(){this.promise=new Promise(e=>{this.resolvePromise=e})}resolve(e){this.resolvePromise(e)}}class d{static{i(this,"TestHarness")}metadata;closed=new n;#e=new n;terminated=this.#e.promise;attachedClients=0;attachmentReleaseCount=0;closeCount=0;serviceCalls=[];failAttachmentRelease;failClose;nextServiceError;nextServiceResult={ok:!0};nextCloseGate;nextServiceGate;constructor(e){this.metadata=e}attachClient(e){this.attachedClients+=1;let s=!1;return{invokeService:i(t=>this.invokeService(t),"invokeService"),release:i(t=>{if(!s){if(this.attachmentReleaseCount+=1,this.failAttachmentRelease)throw this.failAttachmentRelease;s=!0,this.attachedClients-=1}},"release")}}async invokeService(e){if(this.serviceCalls.push(e),this.nextServiceError){const o=this.nextServiceError;throw this.nextServiceError=void 0,o}const s=this.nextServiceGate;s&&(this.nextServiceGate=void 0,s.entered.resolve(void 0),await s.release.promise);const t=this.nextServiceResult;return this.nextServiceResult={ok:!0},t}async close(e){this.closeCount+=1;const s=this.nextCloseGate;if(s&&(this.nextCloseGate=void 0,s.entered.resolve(void 0),await s.release.promise),this.failClose){const t=this.failClose;throw this.failClose=void 0,t}this.closed.resolve(void 0),this.#e.resolve(void 0)}async terminate(e){this.#e.resolve(e)}gateNextClose(){const e={entered:new n,release:new n};return this.nextCloseGate=e,e}gateNextServiceCall(){const e={entered:new n,release:new n};return this.nextServiceGate=e,e}}function u(){return{attachClient(r){return{async invokeService(e,s,t){if(e.instance===void 0&&e.serviceId==="pi.session-management"&&e.member==="attach"&&e.args.length===1&&typeof e.args[0]=="string")return await r.attachSession(e.args[0],t),null;if(e.instance===void 0&&e.serviceId==="pi.session-management"&&e.member==="detach"&&e.args.length===0)return await r.detachSession(t),null;throw new Error(`Unsupported test server service ${e.serviceId}.${e.member}`)},release(){}}}}}i(u,"createTestServerServices");class x{static{i(this,"TestServerHost")}serverServices=u();sessions=new Map;harnesses=new Map;openSessionCount=0;nextOpenSessionError;nextHarnessCloseError;nextOpenSessionGate;async resolveSession(e,s){const t=this.sessions.get(e);if(!t)throw new h(`Unknown session: ${e}`);return t}async openSession(e,s){this.openSessionCount+=1;const t=this.nextOpenSessionGate;if(t&&(this.nextOpenSessionGate=void 0,t.entered.resolve(void 0),await t.release.promise),!this.sessions.has(e.id))throw new h(`Unknown session: ${e.id}`);if(this.nextOpenSessionError){const c=this.nextOpenSessionError;throw this.nextOpenSessionError=void 0,c}const o=new d(e);this.nextHarnessCloseError&&(o.failClose=this.nextHarnessCloseError,this.nextHarnessCloseError=void 0);const a=this.harnesses.get(e.id)??[];return a.push(o),this.harnesses.set(e.id,a),o}async seed(e="session-1"){const s={id:e};return this.sessions.set(e,s),s}gateNextOpenSession(){const e={entered:new n,release:new n};return this.nextOpenSessionGate=e,e}latestHarness(e){const s=this.harnesses.get(e);if(!s?.length)throw new Error(`No harness for ${e}`);return s.at(-1)}}export{n as Deferred,d as TestHarness,x as TestServerHost,u as createTestServerServices};
@@ -1 +0,0 @@
1
- import{connectUnixTestClient as t,ProtocolTestClient as o}from"./client.js";import{createTestServerServices as c,Deferred as n,TestHarness as T,TestServerHost as f}from"./host.js";import{createTestServer as v}from"./server.js";export{n as Deferred,o as ProtocolTestClient,T as TestHarness,f as TestServerHost,t as connectUnixTestClient,v as createTestServer,c as createTestServerServices};
@@ -1 +0,0 @@
1
- var s=Object.defineProperty;var t=(e,r)=>s(e,"name",{value:r,configurable:!0});import{Server as m}from"../server.js";import{TestServerHost as a}from"./host.js";function v(e){const r=e.host??new a;return{server:new m(r,{listeners:e.listeners,maxFrameLength:e.maxFrameLength,handshakeTimeoutMs:e.handshakeTimeoutMs,serverId:e.serverId??"00000000-0000-4000-8000-000000000001",onError:e.onError}),host:r}}t(v,"createTestServer");export{v as createTestServer};
@@ -1 +0,0 @@
1
- var e=Object.defineProperty;var t=(a,o)=>e(a,"name",{value:o,configurable:!0});import{join as r}from"node:path";function i(a,o){if(!/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(a))throw new TypeError("Unix serverId must be a canonical lowercase UUIDv4");return r(o,`${a}.sock`)}t(i,"getUnixSocketPath");export{i as getUnixSocketPath};
@@ -1 +0,0 @@
1
- import{getUnixSocketPath as t}from"./address.js";import{createUnixListener as x}from"./listener.js";import{createUnixServer as n}from"./preset.js";export{x as createUnixListener,n as createUnixServer,t as getUnixSocketPath};
@@ -1 +0,0 @@
1
- var v=Object.defineProperty;var o=(n,e)=>v(n,"name",{value:e,configurable:!0});import{createHash as T,randomUUID as E}from"node:crypto";import{chmod as S,link as k,lstat as l,mkdir as x,rename as u,unlink as U}from"node:fs/promises";import{createConnection as C,createServer as N}from"node:net";import{dirname as w,join as m}from"node:path";import{DEFAULT_MAX_FRAME_LENGTH as B}from"@earendil-works/pi-protocol";const O=384,b=5e3,y=4294967295,g=2147483647,_=1e3;class L{static{o(this,"UnixListener")}options;path;mode;connections=new Set;server;socketIdentity;ownedBindPath;closing=!1;closePromise;accept;constructor(e){this.options=D(e),this.path=this.options.path,this.mode=this.options.mode}async start(e){if(this.server)throw new Error("Unix listener is already started");if(this.closing)throw new Error("Unix listener is closing or closed");this.accept=e;const t=A(this.path);await x(w(this.path),{recursive:!0,mode:448}),await p(this.path),await p(t),this.ownedBindPath=t;const i=N(r=>this.acceptSocket(r));i.on("error",r=>this.reportError(r)),this.server=i;try{await new Promise((s,a)=>{const c=o(P=>{i.off("listening",d),a(P)},"onError"),d=o(()=>{i.off("error",c),s()},"onListening");i.once("error",c),i.once("listening",d),i.listen(t)});const r=await l(t);if(!r.isSocket())throw new Error(`Unix listener path is not a socket after binding: ${t}`);this.socketIdentity={dev:r.dev,ino:r.ino},await k(t,this.path),await F(this.path,this.mode),await f(t),this.ownedBindPath=void 0}catch(r){throw await this.closeServerAndCleanup(i),this.server=void 0,r}}async close(){return this.closePromise?this.closePromise:(this.closing=!0,this.closePromise=this.closeInternal(),this.closePromise)}acceptSocket(e){if(this.closing){e.destroy();return}const t=new M(e,this.options.gracefulCloseTimeoutMs,this.options.maxPendingBytes);this.connections.add(t);const i=this.accept;if(!i){e.destroy();return}const r=i(t);e.on("data",s=>{r.onData(new Uint8Array(s.buffer,s.byteOffset,s.byteLength))}),e.on("error",s=>{r.onError(s),e.destroy()}),e.once("close",()=>{t.markClosed(),this.connections.delete(t),r.onClose()})}async closeInternal(){const e=this.server?this.closeServerAndCleanup(this.server):this.cleanupOwnedSocket();await Promise.all([...this.connections].map(t=>t.close())),await e,this.ownedBindPath&&await f(this.ownedBindPath),this.ownedBindPath=void 0,this.connections.clear(),this.server=void 0}async closeServerAndCleanup(e){try{await $(e,t=>this.reportError(t))}finally{this.ownedBindPath&&await f(this.ownedBindPath),this.ownedBindPath=void 0,await this.cleanupOwnedSocket()}}async cleanupOwnedSocket(){const e=this.socketIdentity;if(this.socketIdentity=void 0,!e)return;let t;try{t=await l(this.path)}catch(s){if(h(s,"ENOENT"))return;throw s}if(!t.isSocket()||t.dev!==e.dev||t.ino!==e.ino)return;const i=m(w(this.path),`cleanup-${E().slice(0,6)}`);try{await u(this.path,i)}catch(s){if(h(s,"ENOENT"))return;throw s}const r=await l(i);if(r.isSocket()&&r.dev===e.dev&&r.ino===e.ino){await f(i);return}try{await l(this.path)}catch(s){if(h(s,"ENOENT"))await u(i,this.path);else throw s}throw new Error(`Unix listener path changed during cleanup; preserved replacement at ${i}`)}reportError(e){try{this.options.onError?.(e instanceof Error?e:new Error(String(e)))}catch{}}}class M{static{o(this,"UnixByteConnection")}socket;gracefulCloseTimeoutMs;maxPendingBytes;pendingBytes=0;closedValue=!1;closing=!1;writeTail=Promise.resolve();closePromise;resolveClose;constructor(e,t,i){this.socket=e,this.gracefulCloseTimeoutMs=t,this.maxPendingBytes=i}get closed(){return this.closedValue}send(e){if(!(e instanceof Uint8Array))return Promise.reject(new TypeError("Unix connection chunks must be Uint8Array"));if(this.closedValue||this.closing)return Promise.reject(new Error("Unix connection is closed"));if(this.pendingBytes+e.byteLength>this.maxPendingBytes)return Promise.reject(new Error("Unix connection exceeded its pending byte limit"));this.pendingBytes+=e.byteLength;const t=e.slice(),r=this.writeTail.then(()=>this.write(t)).finally(()=>{this.pendingBytes-=t.byteLength});return this.writeTail=r.catch(()=>{}),r}close(e){if(this.closedValue||this.socket.destroyed)return this.markClosed(),Promise.resolve();if(this.closePromise)return this.closePromise;this.closing=!0;const t=e?.slice();return this.closePromise=new Promise(i=>{this.resolveClose=i;const r=setTimeout(()=>{this.socket.destroyed||this.socket.destroy(),this.markClosed()},this.gracefulCloseTimeoutMs);r.unref(),this.socket.once("close",()=>clearTimeout(r)),this.writeTail.then(()=>{if(this.socket.destroyed){this.markClosed();return}try{t?this.socket.end(t):this.socket.end()}catch{this.socket.destroy()}})}),this.closePromise}markClosed(){this.closedValue||(this.closedValue=!0,this.closing=!0,this.resolveClose?.(),this.resolveClose=void 0)}write(e){return this.closedValue||this.closing||!this.socket.writable?Promise.reject(new Error("Unix connection is closed")):new Promise((t,i)=>{let r=!1;const s=o(()=>a(new Error("Unix connection closed during write")),"onClose"),a=o(c=>{r||(r=!0,this.socket.off("close",s),c?i(c):t())},"finish");this.socket.once("close",s);try{this.socket.write(e,a)}catch(c){a(c instanceof Error?c:new Error(String(c)))}})}}function A(n){const e=T("sha256").update(n).digest("hex").slice(0,8);return m(w(n),`bind-${e}`)}o(A,"getOwnedBindPath");async function p(n){let e;try{e=await l(n)}catch(r){if(h(r,"ENOENT"))return;throw r}if(!e.isSocket())throw new Error(`Refusing to remove non-socket Unix listener path: ${n}`);if(await I(n))throw new Error(`Unix listener is already running: ${n}`);const t=m(w(n),`stale-${E().slice(0,6)}`);try{await u(n,t)}catch(r){if(h(r,"ENOENT"))return;throw r}const i=await l(t);if(!i.isSocket()||i.dev!==e.dev||i.ino!==e.ino){try{await l(n)}catch(r){if(h(r,"ENOENT"))await u(t,n);else throw r}throw new Error(`Unix listener path changed while checking for a stale socket: ${n}`)}await f(t)}o(p,"removeStaleSocket");async function f(n){try{await U(n)}catch(e){if(!h(e,"ENOENT"))throw e}}o(f,"removePath");function I(n){return new Promise((e,t)=>{const i=C(n);let r=!1,s;const a=o((c,d)=>{r||(r=!0,s&&clearTimeout(s),i.removeAllListeners(),i.destroy(),d?t(d):e(c))},"finish");i.once("connect",()=>a(!0)),i.once("error",c=>{if(["ECONNREFUSED","ENOENT","EPIPE","ECONNRESET"].includes(c.code??"")){a(!1);return}a(!1,c)}),s=setTimeout(()=>a(!0),_),s.unref()})}o(I,"isSocketLive");async function F(n,e){if(process.platform!=="win32")try{await S(n,e)}catch(t){if(!h(t,"ENOSYS")&&!h(t,"ENOTSUP"))throw t}}o(F,"setSocketMode");function $(n,e){return n.listening?new Promise(t=>{n.close(i=>{i&&e(i),t()})}):Promise.resolve()}o($,"closeNetServer");function h(n,e){return n instanceof Error&&"code"in n&&n.code===e}o(h,"isErrorCode");function K(n){return new L(n)}o(K,"createUnixListener");function D(n){if(!n.path)throw new TypeError("Server Unix socket path must not be empty");const e=n.mode??O;if(!Number.isInteger(e)||e<0||e>511)throw new TypeError("Server Unix socket mode must be an integer between 0 and 0o777");const t=n.maxFrameLength??B;if(!Number.isSafeInteger(t)||t<=0||t>y)throw new TypeError(`Server maxFrameLength must be an integer between 1 and ${y}`);const i=n.maxPendingBytes??t*4;if(!Number.isSafeInteger(i)||i<t+4)throw new TypeError("Server maxPendingBytes must be a safe integer at least maxFrameLength + 4");const r=n.gracefulCloseTimeoutMs??b;if(!Number.isSafeInteger(r)||r<=0||r>g)throw new TypeError(`Server gracefulCloseTimeoutMs must be an integer between 1 and ${g}`);return{path:n.path,mode:e,maxPendingBytes:i,gracefulCloseTimeoutMs:r,onError:n.onError}}o(D,"resolveUnixListenerOptions");export{M as UnixByteConnection,K as createUnixListener};
@@ -1 +0,0 @@
1
- var m=Object.defineProperty;var n=(r,e)=>m(r,"name",{value:e,configurable:!0});import{Server as t}from"../../server.js";import{createUnixListener as h}from"./listener.js";function u(r,e){const a=h({path:e.path,mode:e.mode,maxFrameLength:e.maxFrameLength,maxPendingBytes:e.maxPendingBytes,gracefulCloseTimeoutMs:e.gracefulCloseTimeoutMs,onError:e.onError});return new t(r,{listeners:[a],maxFrameLength:e.maxFrameLength,handshakeTimeoutMs:e.handshakeTimeoutMs,onConnectionCountChanged:e.onConnectionCountChanged,serverId:e.serverId,onError:e.onError})}n(u,"createUnixServer");export{u as createUnixServer};
@@ -1,45 +0,0 @@
1
- {
2
- "name": "@earendil-works/pi-server",
3
- "version": "1.0.44",
4
- "description": "experimental server package for pi",
5
- "type": "module",
6
- "main": "./dist/index.js",
7
- "types": "./dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/index.d.ts",
11
- "import": "./dist/index.js"
12
- },
13
- "./testing": {
14
- "types": "./dist/testing/index.d.ts",
15
- "import": "./dist/testing/index.js"
16
- },
17
- "./unix": {
18
- "types": "./dist/transports/unix/index.d.ts",
19
- "import": "./dist/transports/unix/index.js"
20
- }
21
- },
22
- "files": [
23
- "dist",
24
- "README.md",
25
- "CHANGELOG.md"
26
- ],
27
- "keywords": [
28
- "pi",
29
- "server"
30
- ],
31
- "author": "Earendil Works",
32
- "license": "MIT",
33
- "repository": {
34
- "type": "git",
35
- "url": "git+https://github.com/earendil-works/pi.git",
36
- "directory": "packages/server"
37
- },
38
- "engines": {
39
- "node": ">=22.19.0"
40
- },
41
- "dependencies": {
42
- "@earendil-works/chord": "^1.0.44",
43
- "@earendil-works/pi-protocol": "^1.0.44"
44
- }
45
- }
@@ -1,38 +0,0 @@
1
- # `@earendil-works/pi-example-plugin`
2
-
3
- This package provides conventional `session` and `tui` Chord facets. The Session-worker facet provides a remote greeting service. The TUI facet contributes `/hello` and calls that service.
4
-
5
- The package needs no build script. Pi asks Chord to discover `src/session.ts` and `src/tui.ts`, builds both entries into its server-owned plugin cache, and sends the TUI artifact to clients.
6
-
7
- From the repository root:
8
-
9
- ```bash
10
- PI_EXPERIMENTAL=1 ./pi-test.sh server \
11
- -e "$PWD/packages/coding-agent/examples/plugins/pi-example-plugin"
12
- ```
13
-
14
- Alternatively, a client can select the plugin for the Session it creates or resumes on one local server:
15
-
16
- ```bash
17
- PI_EXPERIMENTAL=1 ./pi-test.sh client \
18
- -e "$PWD/packages/coding-agent/examples/plugins/pi-example-plugin"
19
- ```
20
-
21
- Repeat `-e` to select multiple plugin packages. Client paths are resolved locally and sent only to a Unix server; Radius clients cannot select server filesystem paths. The Session and matching TUI facets are stored with that Session, so later server generations and clients can resume it without plugin arguments. Other Sessions and their workers are unaffected. An active Session rejects a different package selection instead of being restarted.
22
-
23
- `server -e` establishes the server profile's default Session and TUI facets. Starting an explicit foreground server without `-e` clears that default. Client selection never changes the server's root facet generation.
24
-
25
- Run `/hello Armin` in the TUI. After editing a facet, run `/reload`. The server atomically rebuilds the package, reloads the attached Session-worker generation, updates the current TUI generation, and serves the new artifact to future clients.
26
-
27
- Package metadata can override or disable conventional entries:
28
-
29
- ```json
30
- {
31
- "chord": {
32
- "facets": {
33
- "session": "./src/worker.ts",
34
- "tui": false
35
- }
36
- }
37
- }
38
- ```