@playcraft/cli 0.1.23 → 0.1.24

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 (278) hide show
  1. package/README.md +3 -38
  2. package/dist/agent/local-backend.js +1 -1
  3. package/dist/cli-root-help.js +0 -1
  4. package/dist/commands/build.js +4 -9
  5. package/dist/commands/create.js +33 -26
  6. package/dist/commands/image.js +6 -2
  7. package/dist/commands/login.js +42 -84
  8. package/dist/commands/skills.js +0 -2
  9. package/dist/commands/tools-generation.js +4 -2
  10. package/dist/commands/tools.js +0 -2
  11. package/dist/config.js +4 -59
  12. package/dist/index.js +1 -6
  13. package/dist/remix/clone.js +0 -2
  14. package/dist/remix/init-template.js +0 -2
  15. package/dist/remix/pull.js +0 -2
  16. package/dist/remix/push.js +1 -21
  17. package/dist/utils/agent-api-client.js +29 -148
  18. package/dist/utils/playcraft-http-client.js +4 -6
  19. package/package.json +2 -8
  20. package/project-template/.claude/skills/playcraft-image-generation/SKILL.md +61 -23
  21. package/project-templates/phaser/.claude/skills/playcraft-image-generation/SKILL.md +61 -23
  22. package/project-templates/threejs/.claude/skills/playcraft-image-generation/SKILL.md +61 -23
  23. package/dist/auth/account-activation.js +0 -157
  24. package/dist/auth/messages.js +0 -30
  25. package/dist/commands/platform-skills.generated.js +0 -19
  26. package/dist/commands/tools-batch.js +0 -59
  27. package/dist/commands/workspace-runtime.js +0 -54
  28. package/dist/project-skills/commands.js +0 -72
  29. package/dist/project-skills/lifecycle.js +0 -28
  30. package/dist/project-skills/local-run.js +0 -112
  31. package/dist/project-skills/local-store.js +0 -149
  32. package/dist/project-skills/messages.js +0 -72
  33. package/dist/project-skills/reconcile.js +0 -62
  34. package/dist/project-skills/remote-cache.js +0 -51
  35. package/dist/project-skills/validation.js +0 -19
  36. package/dist/utils/environment-endpoints.js +0 -17
  37. package/dist/utils/tool-operation-journal.js +0 -124
  38. package/dist/workspace-runtime/codex/app-server.js +0 -574
  39. package/dist/workspace-runtime/codex/config-toml.js +0 -108
  40. package/dist/workspace-runtime/codex/jsonrpc-stdio.js +0 -123
  41. package/dist/workspace-runtime/codex/launcher-client.js +0 -163
  42. package/dist/workspace-runtime/codex/loopback.js +0 -143
  43. package/dist/workspace-runtime/codex/model-broker.js +0 -239
  44. package/dist/workspace-runtime/codex/native-adapter.js +0 -9
  45. package/dist/workspace-runtime/main.js +0 -10
  46. package/dist/workspace-runtime/persistence/journal.js +0 -355
  47. package/dist/workspace-runtime/persistence/sqlite-client.js +0 -61
  48. package/dist/workspace-runtime/persistence/sqlite-worker.js +0 -1015
  49. package/dist/workspace-runtime/previews/publish.js +0 -259
  50. package/dist/workspace-runtime/previews/single-file.js +0 -43
  51. package/dist/workspace-runtime/processes/managed-writes.js +0 -69
  52. package/dist/workspace-runtime/production/contracts.js +0 -17
  53. package/dist/workspace-runtime/production/controller.js +0 -207
  54. package/dist/workspace-runtime/production/dependencies.js +0 -60
  55. package/dist/workspace-runtime/production/native.js +0 -70
  56. package/dist/workspace-runtime/production/processes.js +0 -86
  57. package/dist/workspace-runtime/production/save-command.js +0 -20
  58. package/dist/workspace-runtime/production/stages.js +0 -175
  59. package/dist/workspace-runtime/production/storage.js +0 -32
  60. package/dist/workspace-runtime/serve.js +0 -199
  61. package/dist/workspace-runtime/server/auth.js +0 -21
  62. package/dist/workspace-runtime/server/connectivity.js +0 -201
  63. package/dist/workspace-runtime/server/desktop-host.js +0 -429
  64. package/dist/workspace-runtime/server/desktop-preview-config.js +0 -81
  65. package/dist/workspace-runtime/server/desktop-preview-service.js +0 -157
  66. package/dist/workspace-runtime/server/desktop-preview-static.js +0 -53
  67. package/dist/workspace-runtime/server/desktop-preview.js +0 -189
  68. package/dist/workspace-runtime/server/dispatch.js +0 -848
  69. package/dist/workspace-runtime/server/endpoints.js +0 -19
  70. package/dist/workspace-runtime/server/execution-group.js +0 -85
  71. package/dist/workspace-runtime/server/http.js +0 -919
  72. package/dist/workspace-runtime/server/lock.js +0 -53
  73. package/dist/workspace-runtime/server/rfb-watch-gate.js +0 -168
  74. package/dist/workspace-runtime/server/terminal-host.js +0 -294
  75. package/dist/workspace-runtime/server/types.js +0 -1
  76. package/dist/workspace-runtime/workspaces/attachments.js +0 -109
  77. package/dist/workspace-runtime/workspaces/batch-commit.js +0 -142
  78. package/dist/workspace-runtime/workspaces/cli-credentials.js +0 -111
  79. package/dist/workspace-runtime/workspaces/context-error.js +0 -2
  80. package/dist/workspace-runtime/workspaces/dependencies.js +0 -264
  81. package/dist/workspace-runtime/workspaces/developer-command.js +0 -64
  82. package/dist/workspace-runtime/workspaces/directories.js +0 -106
  83. package/dist/workspace-runtime/workspaces/directory-access.js +0 -20
  84. package/dist/workspace-runtime/workspaces/directory-maintenance.js +0 -111
  85. package/dist/workspace-runtime/workspaces/directory-stats.js +0 -49
  86. package/dist/workspace-runtime/workspaces/empty-template.js +0 -32
  87. package/dist/workspace-runtime/workspaces/files.js +0 -113
  88. package/dist/workspace-runtime/workspaces/git-credential-broker.js +0 -312
  89. package/dist/workspace-runtime/workspaces/git-credential-helper.js +0 -68
  90. package/dist/workspace-runtime/workspaces/git-direct-store.js +0 -155
  91. package/dist/workspace-runtime/workspaces/git.js +0 -471
  92. package/dist/workspace-runtime/workspaces/json5-edit.js +0 -170
  93. package/dist/workspace-runtime/workspaces/parameters.js +0 -272
  94. package/dist/workspace-runtime/workspaces/prepare.js +0 -263
  95. package/dist/workspace-runtime/workspaces/registry.js +0 -192
  96. package/dist/workspace-runtime/workspaces/revisions.js +0 -31
  97. package/dist/workspace-runtime/workspaces/skill-artifact-loader.js +0 -46
  98. package/dist/workspace-runtime/workspaces/skills.js +0 -179
  99. package/project-template-v2/.claude/agents/artist.md +0 -82
  100. package/project-template-v2/.claude/agents/developer.md +0 -153
  101. package/project-template-v2/.claude/agents/game-designer.md +0 -264
  102. package/project-template-v2/.claude/agents/refs/artist-art-style-catalog.md +0 -533
  103. package/project-template-v2/.claude/agents/refs/artist-color-audio-recipes.md +0 -153
  104. package/project-template-v2/.claude/agents/refs/artist-dimension-axis.md +0 -27
  105. package/project-template-v2/.claude/agents/refs/artist-master-composite-recipes.md +0 -208
  106. package/project-template-v2/.claude/agents/refs/atom-skill-library.md +0 -81
  107. package/project-template-v2/.claude/agents/refs/developer-impl-cookbook.md +0 -432
  108. package/project-template-v2/.claude/agents/refs/framework-5-component-filter.md +0 -252
  109. package/project-template-v2/.claude/agents/refs/framework-game-feel-juice.md +0 -266
  110. package/project-template-v2/.claude/agents/refs/framework-mda.md +0 -147
  111. package/project-template-v2/.claude/agents/refs/game-designer-gameplay-sufficiency.md +0 -123
  112. package/project-template-v2/.claude/agents/refs/ta-3d-flip-recipe.md +0 -88
  113. package/project-template-v2/.claude/agents/refs/ta-atlas-deliverable-standard.md +0 -67
  114. package/project-template-v2/.claude/agents/refs/ta-batch-pipeline-recipes.md +0 -120
  115. package/project-template-v2/.claude/agents/refs/ta-image-generation-detail.md +0 -300
  116. package/project-template-v2/.claude/agents/refs/ta-image-ops-reference.md +0 -495
  117. package/project-template-v2/.claude/agents/refs/ta-pipeline-cookbook.md +0 -1141
  118. package/project-template-v2/.claude/agents/refs/ta-tools-reference.md +0 -111
  119. package/project-template-v2/.claude/agents/refs/ta-vfx-preset-catalog.md +0 -365
  120. package/project-template-v2/.claude/agents/refs/threejs-cannon-pitfalls.md +0 -412
  121. package/project-template-v2/.claude/agents/reviewer.md +0 -75
  122. package/project-template-v2/.claude/agents/technical-artist.md +0 -86
  123. package/project-template-v2/.claude/hooks/snapshot-milestone.mjs +0 -243
  124. package/project-template-v2/.claude/hooks/user-prompt.mjs +0 -133
  125. package/project-template-v2/.claude/settings.json +0 -33
  126. package/project-template-v2/.claude/skills/brainstorming/SKILL.md +0 -161
  127. package/project-template-v2/.claude/skills/brainstorming/scripts/frame-template.html +0 -270
  128. package/project-template-v2/.claude/skills/brainstorming/scripts/helper.js +0 -177
  129. package/project-template-v2/.claude/skills/brainstorming/scripts/server.cjs +0 -354
  130. package/project-template-v2/.claude/skills/brainstorming/scripts/start-server.sh +0 -148
  131. package/project-template-v2/.claude/skills/brainstorming/scripts/stop-server.sh +0 -56
  132. package/project-template-v2/.claude/skills/brainstorming/scripts/wait-for-selection.sh +0 -62
  133. package/project-template-v2/.claude/skills/brainstorming/spec-document-reviewer-prompt.md +0 -49
  134. package/project-template-v2/.claude/skills/brainstorming/visual-companion.md +0 -309
  135. package/project-template-v2/.claude/skills/playcraft-ad-psychology/SKILL.md +0 -182
  136. package/project-template-v2/.claude/skills/playcraft-art-style-guide/SKILL.md +0 -123
  137. package/project-template-v2/.claude/skills/playcraft-asset-state-sheet/SKILL.md +0 -205
  138. package/project-template-v2/.claude/skills/playcraft-audio-generation/SKILL.md +0 -280
  139. package/project-template-v2/.claude/skills/playcraft-batch-pipeline/SKILL.md +0 -184
  140. package/project-template-v2/.claude/skills/playcraft-build-optimizer/SKILL.md +0 -306
  141. package/project-template-v2/.claude/skills/playcraft-image-generation/SKILL.md +0 -298
  142. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/build-sprite-sheet.template.mjs +0 -123
  143. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/compare-style.template.mjs +0 -254
  144. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/gen-batch-sprite.template.mjs +0 -324
  145. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/gen-batch.template.mjs +0 -97
  146. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/gen-edit-variants.template.mjs +0 -118
  147. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/process-batch.template.mjs +0 -137
  148. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/prompt-cookbook.md +0 -397
  149. package/project-template-v2/.claude/skills/playcraft-image-generation/reference/validate-sprite-sheet.template.mjs +0 -296
  150. package/project-template-v2/.claude/skills/playcraft-image-ops/SKILL.md +0 -122
  151. package/project-template-v2/.claude/skills/playcraft-image-processing/SKILL.md +0 -219
  152. package/project-template-v2/.claude/skills/playcraft-masking/SKILL.md +0 -373
  153. package/project-template-v2/.claude/skills/playcraft-playable-optimization/SKILL.md +0 -161
  154. package/project-template-v2/.claude/skills/playcraft-research/SKILL.md +0 -215
  155. package/project-template-v2/.claude/skills/playcraft-skill-recommender/SKILL.md +0 -382
  156. package/project-template-v2/.claude/skills/playcraft-sprite-generation/SKILL.md +0 -423
  157. package/project-template-v2/.claude/skills/playcraft-sprite-remix/SKILL.md +0 -158
  158. package/project-template-v2/.claude/skills/playcraft-sprite-sheet/SKILL.md +0 -100
  159. package/project-template-v2/.claude/skills/playcraft-storyboard/SKILL.md +0 -167
  160. package/project-template-v2/.claude/skills/playcraft-style-qa/SKILL.md +0 -270
  161. package/project-template-v2/.claude/skills/playcraft-text-rendering/SKILL.md +0 -236
  162. package/project-template-v2/.claude/skills/playcraft-vfx-animation/SKILL.md +0 -130
  163. package/project-template-v2/.claude/skills/playwright-cli/SKILL.md +0 -390
  164. package/project-template-v2/.claude/skills/playwright-cli/references/element-attributes.md +0 -23
  165. package/project-template-v2/.claude/skills/playwright-cli/references/playwright-tests.md +0 -39
  166. package/project-template-v2/.claude/skills/playwright-cli/references/request-mocking.md +0 -87
  167. package/project-template-v2/.claude/skills/playwright-cli/references/running-code.md +0 -240
  168. package/project-template-v2/.claude/skills/playwright-cli/references/session-management.md +0 -226
  169. package/project-template-v2/.claude/skills/playwright-cli/references/spec-driven-testing.md +0 -308
  170. package/project-template-v2/.claude/skills/playwright-cli/references/storage-state.md +0 -275
  171. package/project-template-v2/.claude/skills/playwright-cli/references/test-generation.md +0 -134
  172. package/project-template-v2/.claude/skills/playwright-cli/references/tracing.md +0 -142
  173. package/project-template-v2/.claude/skills/playwright-cli/references/video-recording.md +0 -153
  174. package/project-template-v2/.claude/skills/session-analyzer/SKILL.md +0 -386
  175. package/project-template-v2/.claude/skills/session-analyzer/scripts/execution-breakdown.mjs +0 -182
  176. package/project-template-v2/.claude/skills/session-analyzer/scripts/find-turns.mjs +0 -72
  177. package/project-template-v2/.claude/skills/session-analyzer/scripts/heavy-output.mjs +0 -121
  178. package/project-template-v2/.claude/skills/session-analyzer/scripts/resolve-session.mjs +0 -102
  179. package/project-template-v2/.claude/skills/session-analyzer/scripts/subagent-stats.mjs +0 -127
  180. package/project-template-v2/.claude/skills/session-analyzer/scripts/subagent-tool-timeline.mjs +0 -106
  181. package/project-template-v2/.claude/skills/session-analyzer/scripts/time-gaps.mjs +0 -128
  182. package/project-template-v2/.claude/skills/session-analyzer/scripts/turn-timeline.mjs +0 -67
  183. package/project-template-v2/.claude/snapshot.mjs +0 -263
  184. package/project-template-v2/.playcraft/skills.lock.json +0 -152
  185. package/project-template-v2/CLAUDE.md +0 -146
  186. package/project-template-v2/assets/audio/bgm/.gitkeep +0 -0
  187. package/project-template-v2/assets/audio/sfx/.gitkeep +0 -0
  188. package/project-template-v2/assets/bundles/.gitkeep +0 -0
  189. package/project-template-v2/assets/images/bg/.gitkeep +0 -0
  190. package/project-template-v2/assets/images/reference/.gitkeep +0 -0
  191. package/project-template-v2/assets/images/storyboard/.gitkeep +0 -0
  192. package/project-template-v2/assets/images/tiles/.gitkeep +0 -0
  193. package/project-template-v2/assets/images/ui/.gitkeep +0 -0
  194. package/project-template-v2/assets/images/vfx/.gitkeep +0 -0
  195. package/project-template-v2/assets/models/.gitkeep +0 -0
  196. package/project-template-v2/docs/harness/iteration-1/context-flow.md +0 -254
  197. package/project-template-v2/docs/harness/iteration-1/generate-flow.md +0 -91
  198. package/project-template-v2/docs/harness/iteration-1/ideate-flow.md +0 -214
  199. package/project-template-v2/docs/harness/iteration-1/optimize-flow.md +0 -75
  200. package/project-template-v2/docs/harness/iteration-1/wrapup-flow.md +0 -63
  201. package/project-template-v2/docs/harness/iteration-2/context-flow.md +0 -223
  202. package/project-template-v2/docs/harness/iteration-2/generate-flow.md +0 -129
  203. package/project-template-v2/docs/harness/iteration-2/ideate-flow.md +0 -267
  204. package/project-template-v2/docs/harness/iteration-2/optimize-flow.md +0 -164
  205. package/project-template-v2/docs/harness/iteration-2/wrapup-flow.md +0 -115
  206. package/project-template-v2/docs/harness/orchestrator-flow.md +0 -364
  207. package/project-template-v2/docs/project-state.json +0 -60
  208. package/project-template-v2/docs/project-state.md +0 -72
  209. package/project-template-v2/docs/standards/README.md +0 -225
  210. package/project-template-v2/docs/standards/agent-behavior-standards.md +0 -174
  211. package/project-template-v2/docs/standards/artifacts/design-brief.md +0 -19
  212. package/project-template-v2/docs/standards/artifacts/design.md +0 -22
  213. package/project-template-v2/docs/standards/artifacts/game-code.md +0 -41
  214. package/project-template-v2/docs/standards/artifacts/todo-list.md +0 -41
  215. package/project-template-v2/docs/standards/iter1-agent-behavior-standards.md +0 -343
  216. package/project-template-v2/game/index.ts +0 -18
  217. package/project-template-v2/globals.d.ts +0 -51
  218. package/project-template-v2/index.css +0 -34
  219. package/project-template-v2/index.html +0 -18
  220. package/project-template-v2/main.ts +0 -9
  221. package/project-template-v2/package.json +0 -46
  222. package/project-template-v2/skills/_shared/scripts/dispatch-clear.mjs +0 -31
  223. package/project-template-v2/skills/_shared/scripts/dispatch-set.mjs +0 -86
  224. package/project-template-v2/skills/_shared/scripts/dod-check.mjs +0 -153
  225. package/project-template-v2/skills/_shared/scripts/handoff-append.mjs +0 -70
  226. package/project-template-v2/skills/_shared/scripts/lib/validator-artifacts.mjs +0 -91
  227. package/project-template-v2/skills/_shared/scripts/pipeline/dod-config.mjs +0 -131
  228. package/project-template-v2/skills/_shared/scripts/pipeline/index.mjs +0 -80
  229. package/project-template-v2/skills/_shared/scripts/pipeline/iteration-1-core.mjs +0 -90
  230. package/project-template-v2/skills/_shared/scripts/pipeline/iteration-2-wrap.mjs +0 -93
  231. package/project-template-v2/skills/_shared/scripts/pipeline/iteration-3-visual.mjs +0 -23
  232. package/project-template-v2/skills/_shared/scripts/render-project-state.mjs +0 -230
  233. package/project-template-v2/skills/_shared/scripts/state-advance-stage.mjs +0 -58
  234. package/project-template-v2/skills/_shared/scripts/state-get.mjs +0 -339
  235. package/project-template-v2/skills/_shared/scripts/state-handoff.mjs +0 -39
  236. package/project-template-v2/skills/_shared/scripts/state-set.mjs +0 -94
  237. package/project-template-v2/skills/_shared/scripts/state-store.mjs +0 -783
  238. package/project-template-v2/skills/_shared/scripts/todo-add.mjs +0 -88
  239. package/project-template-v2/skills/_shared/scripts/todo-get.mjs +0 -130
  240. package/project-template-v2/skills/_shared/scripts/todo-remove.mjs +0 -33
  241. package/project-template-v2/skills/_shared/scripts/todo-set.mjs +0 -47
  242. package/project-template-v2/skills/_shared/scripts/verify-asset-code-sync.mjs +0 -268
  243. package/project-template-v2/skills/_shared/scripts/verify-env.mjs +0 -285
  244. package/project-template-v2/skills/_shared/scripts/verify-placeholders.mjs +0 -161
  245. package/project-template-v2/skills/playable-autoplay/SKILL.md +0 -176
  246. package/project-template-v2/skills/playable-autoplay/agents/openai.yaml +0 -4
  247. package/project-template-v2/skills/playable-debug/SKILL.md +0 -116
  248. package/project-template-v2/skills/playable-debug/agents/openai.yaml +0 -4
  249. package/project-template-v2/skills/playable-debug/references/debug-config.md +0 -40
  250. package/project-template-v2/skills/playable-record/SKILL.md +0 -140
  251. package/project-template-v2/skills/playable-record/scripts/lib/dev-server.mjs +0 -104
  252. package/project-template-v2/skills/playable-record/scripts/lib/record-audio-bridge.js +0 -141
  253. package/project-template-v2/skills/playable-record/scripts/record-playable.mjs +0 -425
  254. package/project-template-v2/skills/playable-record/scripts/verify-contract.mjs +0 -261
  255. package/project-template-v2/skills/playable-record/scripts/verify-firstwin.mjs +0 -398
  256. package/project-template-v2/skills/playable-record/scripts/verify-fusion.mjs +0 -322
  257. package/project-template-v2/skills/playable-record/scripts/verify-lifecycle.mjs +0 -105
  258. package/project-template-v2/skills/playable-record/scripts/verify-vlm-video.mjs +0 -230
  259. package/project-template-v2/skills/playable-validate/SKILL.md +0 -61
  260. package/project-template-v2/skills/playable-validate/validation-rules.md +0 -14
  261. package/project-template-v2/skills/playable-verify-ui/SKILL.md +0 -63
  262. package/project-template-v2/skills/playable-verify-ui/scripts/lib/__init__.py +0 -1
  263. package/project-template-v2/skills/playable-verify-ui/scripts/lib/config_expr.js +0 -218
  264. package/project-template-v2/skills/playable-verify-ui/scripts/lib/node_utils.js +0 -51
  265. package/project-template-v2/skills/playable-verify-ui/scripts/lib/profile_loader.py +0 -59
  266. package/project-template-v2/skills/playable-verify-ui/scripts/lib/report.py +0 -106
  267. package/project-template-v2/skills/playable-verify-ui/scripts/lib/runtime_contract.js +0 -116
  268. package/project-template-v2/skills/playable-verify-ui/scripts/verify_fetch_antipatterns.py +0 -59
  269. package/project-template-v2/skills/playable-verify-ui/scripts/verify_hardcoded_layout.js +0 -64
  270. package/project-template-v2/skills/playable-verify-ui/scripts/verify_runtime_contract.js +0 -58
  271. package/project-template-v2/skills/playable-verify-ui/scripts/verify_text_overlap.py +0 -333
  272. package/project-template-v2/ta-workspace/scripts/.gitkeep +0 -0
  273. package/project-template-v2/tsconfig.json +0 -20
  274. package/project-template-v2/vite.config.ts +0 -27
  275. package/project-templates/batch-locks/phaser.yaml +0 -922
  276. package/project-templates/batch-locks/threejs.yaml +0 -978
  277. package/project-templates/empty/AGENTS.md +0 -23
  278. package/project-templates/empty/gitignore +0 -31
@@ -1,123 +0,0 @@
1
- import { EventEmitter } from 'node:events';
2
- export function createJsonRpcStdioClient(child) {
3
- const stdin = child.stdin;
4
- const stdout = child.stdout;
5
- if (!stdin || !stdout)
6
- throw new Error('codex_stdio_missing');
7
- const emitter = new EventEmitter();
8
- const pending = new Map();
9
- let nextId = 1;
10
- let turnStarts = 0;
11
- let buffer = '';
12
- let closed = false;
13
- const onData = (chunk) => {
14
- buffer += typeof chunk === 'string' ? chunk : chunk.toString('utf8');
15
- let newline = buffer.indexOf('\n');
16
- while (newline >= 0) {
17
- const line = buffer.slice(0, newline).trim();
18
- buffer = buffer.slice(newline + 1);
19
- if (line)
20
- handleLine(line);
21
- newline = buffer.indexOf('\n');
22
- }
23
- };
24
- stdout.setEncoding('utf8');
25
- stdout.on('data', onData);
26
- function handleLine(line) {
27
- let message;
28
- try {
29
- message = JSON.parse(line);
30
- }
31
- catch {
32
- return;
33
- }
34
- if (message.id !== undefined && pending.has(Number(message.id))) {
35
- const waiter = pending.get(Number(message.id));
36
- if (!waiter)
37
- return;
38
- pending.delete(Number(message.id));
39
- clearTimeout(waiter.timer);
40
- if (message.error) {
41
- waiter.reject(new Error(message.error.message || 'jsonrpc_error'));
42
- return;
43
- }
44
- waiter.resolve(message.result);
45
- return;
46
- }
47
- if (message.method && message.id !== undefined) {
48
- emitter.emit('serverRequest', message.id, message.method, message.params ?? {});
49
- return;
50
- }
51
- if (message.method) {
52
- emitter.emit('notification', message.method, message.params ?? {});
53
- }
54
- }
55
- const send = (payload) => {
56
- if (closed)
57
- throw new Error('jsonrpc_closed');
58
- stdin.write(`${JSON.stringify(payload)}\n`);
59
- };
60
- return {
61
- notify(method, params) {
62
- send({ method, params: params ?? {} });
63
- },
64
- reserveRequest() {
65
- const id = nextId;
66
- nextId += 1;
67
- return id;
68
- },
69
- sendReserved(id, method, params, timeoutMs = 20_000) {
70
- if (pending.has(id))
71
- throw new Error('jsonrpc_request_in_use');
72
- if (method === 'turn/start')
73
- turnStarts += 1;
74
- return new Promise((resolve, reject) => {
75
- const timer = setTimeout(() => {
76
- pending.delete(id);
77
- reject(new Error(`jsonrpc_timeout:${method}`));
78
- }, timeoutMs);
79
- pending.set(id, { resolve: (value) => resolve(value), reject, timer });
80
- try {
81
- send({ method, id, params: params ?? {} });
82
- }
83
- catch (error) {
84
- pending.delete(id);
85
- clearTimeout(timer);
86
- reject(error instanceof Error ? error : new Error(String(error)));
87
- }
88
- });
89
- },
90
- request(method, params, timeoutMs = 20_000) {
91
- const id = nextId;
92
- nextId += 1;
93
- return this.sendReserved(id, method, params, timeoutMs);
94
- },
95
- turnStartSends() {
96
- return turnStarts;
97
- },
98
- onNotification(listener) {
99
- emitter.on('notification', listener);
100
- return () => emitter.off('notification', listener);
101
- },
102
- onServerRequest(listener) {
103
- emitter.on('serverRequest', listener);
104
- return () => emitter.off('serverRequest', listener);
105
- },
106
- respond(id, result) {
107
- send({ id, result });
108
- },
109
- async close() {
110
- if (closed)
111
- return;
112
- closed = true;
113
- stdout.off('data', onData);
114
- for (const [id, waiter] of pending) {
115
- clearTimeout(waiter.timer);
116
- waiter.reject(new Error('jsonrpc_closed'));
117
- pending.delete(id);
118
- }
119
- if (!stdin.destroyed)
120
- stdin.end();
121
- },
122
- };
123
- }
@@ -1,163 +0,0 @@
1
- import { EventEmitter } from 'node:events';
2
- import { createConnection } from 'node:net';
3
- import { PassThrough, Writable } from 'node:stream';
4
- import { setTimeout as delay } from 'node:timers/promises';
5
- function request(socketPath, message) {
6
- return new Promise((resolve, reject) => {
7
- const socket = createConnection(socketPath);
8
- let buffer = '';
9
- socket.setEncoding('utf8');
10
- const timer = setTimeout(() => socket.destroy(new Error('launcher_request_timeout')), 5000);
11
- socket.on('connect', () => socket.write(`${JSON.stringify(message)}\n`));
12
- socket.on('data', (chunk) => {
13
- buffer += chunk;
14
- if (buffer.length > 64 * 1024)
15
- return socket.destroy(new Error('launcher_reply_too_large'));
16
- if (!buffer.includes('\n'))
17
- return;
18
- try {
19
- const reply = JSON.parse(buffer.split('\n')[0]);
20
- if (!reply.ok)
21
- throw new Error(reply.error || 'launcher_request_failed');
22
- resolve(reply);
23
- }
24
- catch (error) {
25
- reject(error);
26
- }
27
- socket.destroy();
28
- });
29
- socket.on('error', reject);
30
- socket.on('close', () => {
31
- clearTimeout(timer);
32
- reject(new Error('launcher_connection_closed'));
33
- });
34
- });
35
- }
36
- export async function startLauncherProcess(input) {
37
- const socket = createConnection(input.socketPath);
38
- const stdout = new PassThrough();
39
- const stderr = new PassThrough();
40
- const events = new EventEmitter();
41
- let exited = false;
42
- let exitCode;
43
- let buffer = '';
44
- let identity;
45
- let stopPromise;
46
- const stdin = new Writable({
47
- write(chunk, _encoding, callback) {
48
- socket.write(`${JSON.stringify({ action: 'stdin', data: chunk.toString('base64') })}\n`, callback);
49
- },
50
- final(callback) {
51
- socket.write(`${JSON.stringify({ action: 'stdin-end' })}\n`, callback);
52
- },
53
- });
54
- // Transport loss is reported through onExit, never an unhandled stream error.
55
- stdin.on('error', () => socket.destroy());
56
- function exit() {
57
- if (exited)
58
- return;
59
- exited = true;
60
- events.emit('exit', exitCode);
61
- }
62
- socket.setEncoding('utf8');
63
- const pid = await new Promise((resolve, reject) => {
64
- const timer = setTimeout(() => socket.destroy(new Error('launcher_start_timeout')), 5000);
65
- let started = false;
66
- socket.on('connect', () => {
67
- const { socketPath: _socketPath, ...payload } = input;
68
- socket.write(`${JSON.stringify({ ...payload, action: input.terminal ? 'start-pty' : 'start-stdio' })}\n`);
69
- });
70
- socket.on('data', (chunk) => {
71
- buffer += chunk;
72
- if (buffer.length > 8 * 1024 * 1024)
73
- return socket.destroy(new Error('launcher_reply_too_large'));
74
- let newline;
75
- while ((newline = buffer.indexOf('\n')) >= 0) {
76
- const line = buffer.slice(0, newline);
77
- buffer = buffer.slice(newline + 1);
78
- try {
79
- const frame = JSON.parse(line);
80
- if (!started) {
81
- if (!frame.ok || !frame.pid || !frame.instanceId)
82
- throw new Error(frame.error || 'launcher_start_failed');
83
- identity = {
84
- processId: input.processId,
85
- runtimeEpoch: input.runtimeEpoch,
86
- instanceId: frame.instanceId,
87
- };
88
- started = true;
89
- clearTimeout(timer);
90
- resolve(frame.pid);
91
- }
92
- else if (frame.channel === 'stdout' || frame.channel === 'stderr') {
93
- if (typeof frame.data !== 'string')
94
- throw new Error('launcher_invalid_frame');
95
- const stream = frame.channel === 'stdout' ? stdout : stderr;
96
- if (!stream.write(Buffer.from(frame.data, 'base64'))) {
97
- socket.pause();
98
- stream.once('drain', () => socket.resume());
99
- }
100
- }
101
- else if (frame.event === 'exit') {
102
- exitCode = typeof frame.code === 'number' ? frame.code : null;
103
- exit();
104
- }
105
- else
106
- throw new Error('launcher_invalid_frame');
107
- }
108
- catch (error) {
109
- socket.destroy(error instanceof Error ? error : new Error('launcher_invalid_frame'));
110
- return;
111
- }
112
- }
113
- });
114
- socket.on('error', (error) => {
115
- clearTimeout(timer);
116
- reject(error);
117
- });
118
- socket.on('close', () => {
119
- clearTimeout(timer);
120
- reject(new Error('launcher_connection_closed'));
121
- stdout.end();
122
- stderr.end();
123
- stdin.destroy();
124
- exit();
125
- });
126
- });
127
- return {
128
- pid,
129
- stdin,
130
- stdout,
131
- stderr,
132
- onExit(listener) {
133
- if (exited)
134
- queueMicrotask(() => listener(exitCode));
135
- else
136
- events.once('exit', listener);
137
- },
138
- resize(cols, rows) {
139
- if (!input.terminal || exited)
140
- return;
141
- socket.write(`${JSON.stringify({ action: 'resize', cols, rows })}\n`);
142
- },
143
- stop() {
144
- stopPromise ??= (async () => {
145
- // A new launcher's empty registry cannot confirm an old group's exit.
146
- for (const signal of ['SIGTERM', 'SIGKILL']) {
147
- await request(input.socketPath, { ...identity, action: 'stop', signal });
148
- const deadline = Date.now() + 3000;
149
- while (Date.now() < deadline) {
150
- const status = await request(input.socketPath, { ...identity, action: 'status' });
151
- if (status.running === false) {
152
- socket.destroy();
153
- return;
154
- }
155
- await delay(50);
156
- }
157
- }
158
- throw new Error('codex_group_stop_unconfirmed');
159
- })();
160
- return stopPromise;
161
- },
162
- };
163
- }
@@ -1,143 +0,0 @@
1
- import { projectNativeThread } from '@playcraft/common/cloud-workspace/runtime';
2
- import { collectedEvent } from './native-adapter.js';
3
- /** In-process Codex stand-in. Not the App Server; used to prove the operation/event loop. */
4
- export function createLoopbackNativeAdapter() {
5
- const threads = new Map();
6
- const approvals = new Set();
7
- const collected = new Set();
8
- const sent = new Set();
9
- let turnStarts = 0;
10
- function emit(event) {
11
- for (const listener of collected)
12
- listener(event);
13
- }
14
- return {
15
- name: 'loopback',
16
- ready: () => true,
17
- onCollected(listener) {
18
- collected.add(listener);
19
- return () => collected.delete(listener);
20
- },
21
- turnStartSends() {
22
- return turnStarts;
23
- },
24
- async startThread(input) {
25
- const threadId = `thread_${input.sessionId}`;
26
- threads.set(threadId, { sessionId: input.sessionId, items: [] });
27
- return { threadId };
28
- },
29
- async resumeThread(input) {
30
- return threads.get(input.threadId)?.sessionId === input.sessionId ? {} : undefined;
31
- },
32
- async startTurn(input) {
33
- const thread = threads.get(input.threadId);
34
- if (!thread || thread.sessionId !== input.sessionId)
35
- return { outcome: 'failed', error: 'unknown_thread' };
36
- const nativeRequestId = `loopback:${input.sessionId}:${input.clientRequestId}`;
37
- const sentKey = `${input.sessionId}:${input.clientRequestId}`;
38
- await input.persistReservation({ nativeRequestId });
39
- if (input.simulateLostReceipt || sent.has(sentKey)) {
40
- sent.add(sentKey);
41
- return { outcome: 'uncertain', threadId: input.threadId };
42
- }
43
- sent.add(sentKey);
44
- turnStarts += 1;
45
- const turnId = `turn_${input.sessionId}_${input.clientRequestId}`;
46
- thread.turnId = turnId;
47
- thread.items.push({
48
- type: 'userMessage',
49
- id: `user_${turnId}`,
50
- content: [{ type: 'text', text: input.text }],
51
- });
52
- if (!input.text.includes('[approval]')) {
53
- thread.items.push({
54
- type: 'agentMessage',
55
- id: `agent_${turnId}`,
56
- text: `loopback:${input.text}`,
57
- });
58
- }
59
- queueMicrotask(() => {
60
- emit(collectedEvent('notification', 'item/agentMessage/delta', {
61
- threadId: input.threadId,
62
- turnId,
63
- text: `loopback:${input.text}`,
64
- delta: `loopback:${input.text}`,
65
- }));
66
- if (input.text.includes('[approval]')) {
67
- const approvalId = `approval_${input.clientRequestId}`;
68
- approvals.add(JSON.stringify([input.sessionId, approvalId]));
69
- emit(collectedEvent('approval_request', 'item/tool/requestUserInput', {
70
- threadId: input.threadId,
71
- turnId,
72
- approvalId,
73
- itemId: approvalId,
74
- }));
75
- return;
76
- }
77
- emit(collectedEvent('notification', 'turn/completed', {
78
- threadId: input.threadId,
79
- turnId,
80
- turn: { id: turnId, status: 'completed' },
81
- }));
82
- });
83
- return { outcome: 'accepted', threadId: input.threadId, turnId };
84
- },
85
- async interrupt(input) {
86
- const thread = threads.get(input.threadId);
87
- if (!thread || thread.sessionId !== input.sessionId)
88
- return { outcome: 'uncertain' };
89
- const turnId = thread.turnId;
90
- queueMicrotask(() => {
91
- emit(collectedEvent('notification', 'turn/completed', {
92
- threadId: input.threadId,
93
- turnId,
94
- turn: { id: turnId, status: 'interrupted' },
95
- }));
96
- });
97
- return { outcome: 'accepted', turnId };
98
- },
99
- async respondApproval(input) {
100
- const key = JSON.stringify([input.sessionId, input.approvalId]);
101
- if (!approvals.has(key))
102
- return { outcome: 'failed', approvalId: input.approvalId };
103
- approvals.delete(key);
104
- const thread = [...threads].find(([, value]) => value.sessionId === input.sessionId);
105
- queueMicrotask(() => {
106
- emit(collectedEvent('notification', 'approval.resolved', {
107
- approvalId: input.approvalId,
108
- accepted: input.accepted,
109
- threadId: thread?.[0],
110
- turnId: thread?.[1].turnId,
111
- }));
112
- emit(collectedEvent('notification', 'item/agentMessage/delta', {
113
- threadId: thread?.[0],
114
- turnId: thread?.[1].turnId,
115
- delta: 'after-approval',
116
- }));
117
- emit(collectedEvent('notification', 'turn/completed', {
118
- threadId: thread?.[0],
119
- turnId: thread?.[1].turnId,
120
- turn: { id: thread?.[1].turnId, status: 'completed' },
121
- }));
122
- });
123
- const found = thread?.[1];
124
- if (found) {
125
- found.items.push({
126
- type: 'agentMessage',
127
- id: `agent_${found.turnId ?? input.approvalId}`,
128
- text: 'after-approval',
129
- });
130
- }
131
- return { outcome: 'accepted', approvalId: input.approvalId, turnId: found?.turnId };
132
- },
133
- async readThread(input) {
134
- const thread = threads.get(input.threadId);
135
- if (!thread || thread.sessionId !== input.sessionId)
136
- return undefined;
137
- return projectNativeThread(input.threadId, {
138
- id: input.threadId,
139
- turns: [{ items: thread.items }],
140
- });
141
- },
142
- };
143
- }
@@ -1,239 +0,0 @@
1
- import { createHash, randomBytes, timingSafeEqual } from 'node:crypto';
2
- import { createServer } from 'node:http';
3
- import { Readable } from 'node:stream';
4
- import { pipeline } from 'node:stream/promises';
5
- import { basename, dirname } from 'node:path';
6
- import { z } from 'zod';
7
- import { workspaceContextFromRoot } from '../workspaces/registry.js';
8
- import { PLATFORM_ROUTES, modelResponsesPath, platformEndpoint } from '@playcraft/common/cloud-workspace/runtime';
9
- const credentialSchema = z.object({
10
- token: z.string().min(1), expiresAt: z.string().datetime(),
11
- configId: z.string().uuid(), model: z.string().min(1).max(128),
12
- claims: z.object({
13
- environment: z.string(), userId: z.string(), workspaceId: z.string(), runtimeId: z.string(),
14
- generation: z.number().int(), runtimeEpoch: z.number().int(),
15
- }),
16
- });
17
- /** Keeps renewable execution credentials in control memory, outside Codex and project files. */
18
- export class WorkspaceModelBroker {
19
- state;
20
- server;
21
- baseUrl = '';
22
- entries = new Map();
23
- routes = new Map();
24
- pending = new Map();
25
- requests = new Set();
26
- sessionRequests = new Map();
27
- constructor(state) {
28
- this.state = state;
29
- }
30
- async start() {
31
- if (this.server)
32
- return;
33
- const server = createServer({ maxHeaderSize: 8192 }, (request, response) => {
34
- void this.forward(request, response);
35
- });
36
- await new Promise((resolve, reject) => {
37
- server.once('error', reject);
38
- server.listen(0, '127.0.0.1', resolve);
39
- });
40
- this.server = server;
41
- const address = server.address();
42
- if (!address || typeof address === 'string')
43
- throw new Error('model_broker_unavailable');
44
- this.baseUrl = `http://127.0.0.1:${address.port}`;
45
- }
46
- async threadConfig(cwd, modelConfigId, sessionId) {
47
- const { activate, ...settings } = await this.prepareThreadConfig(cwd, modelConfigId, sessionId);
48
- activate();
49
- return settings;
50
- }
51
- async prepareThreadConfig(cwd, modelConfigId, sessionId) {
52
- if (!this.server)
53
- throw new Error('workspace_not_registered');
54
- const { workspaceId } = await workspaceContextFromRoot(this.state, cwd);
55
- if (modelConfigId !== undefined && !z.string().uuid().safeParse(modelConfigId).success)
56
- throw new Error('model_config_denied');
57
- const routeKey = sessionId ? `${workspaceId}/${createHash('sha256').update(sessionId).digest('hex').slice(0, 32)}` : workspaceId;
58
- let route = this.routes.get(routeKey);
59
- const selected = modelConfigId ?? (route?.epoch === this.state.runtimeEpoch ? route.selected?.entry.modelConfigId : undefined);
60
- const cacheKey = `${workspaceId}:${selected ?? 'default'}`;
61
- let entry = this.entries.get(cacheKey) ?? [...this.entries.values()].find(item => item.workspaceId === workspaceId && item.epoch === this.state.runtimeEpoch && item.modelConfigId === selected);
62
- if (!entry || entry.epoch !== this.state.runtimeEpoch) {
63
- entry = { workspaceId, epoch: this.state.runtimeEpoch, cacheKey, modelConfigId: selected };
64
- this.entries.set(cacheKey, entry);
65
- }
66
- // Resolve current model metadata and permission at every native turn boundary.
67
- const credential = await this.credential(entry, true);
68
- if (!route || route.epoch !== this.state.runtimeEpoch) {
69
- route = { workspaceId, epoch: this.state.runtimeEpoch, capability: randomBytes(32).toString('base64url') };
70
- this.routes.set(routeKey, route);
71
- }
72
- // Each session pins its prepared model; shared credential renewal cannot change an active turn.
73
- return {
74
- activate: () => {
75
- if (!this.valid(entry) || this.routes.get(routeKey) !== route)
76
- throw new Error('model_access_denied');
77
- route.selected = { entry, model: credential.model };
78
- },
79
- model: credential.model,
80
- modelConfigId: credential.configId,
81
- modelProvider: 'playcraft_workspace',
82
- config: {
83
- 'model_providers.playcraft_workspace': {
84
- name: 'PlayCraft Workspace', base_url: `${this.baseUrl}/${routeKey}`,
85
- wire_api: 'responses', requires_openai_auth: false,
86
- http_headers: { Authorization: `Bearer ${route.capability}` },
87
- },
88
- },
89
- };
90
- }
91
- valid(entry) {
92
- return Boolean(this.server && !this.state.journal.destroyed()
93
- && this.state.runtimeEpoch === entry.epoch && this.state.journal.getWorkspace(entry.workspaceId)
94
- && this.entries.get(entry.cacheKey) === entry);
95
- }
96
- async credential(entry, refresh = false) {
97
- if (!this.valid(entry))
98
- throw new Error('model_access_denied');
99
- if (!refresh && entry.credential && Date.parse(entry.credential.expiresAt) > Date.now() + 60_000)
100
- return entry.credential;
101
- let pending = this.pending.get(entry);
102
- if (!pending) {
103
- pending = this.renew(entry).finally(() => this.pending.delete(entry));
104
- this.pending.set(entry, pending);
105
- }
106
- return pending;
107
- }
108
- async renew(entry) {
109
- const config = this.state.config;
110
- const endpoint = platformEndpoint(config.publicBaseUrl, PLATFORM_ROUTES.modelCredentials);
111
- const response = await fetch(endpoint, {
112
- method: 'POST', redirect: 'error', signal: AbortSignal.timeout(10_000),
113
- headers: { authorization: `Bearer ${config.controlToken}`, 'content-type': 'application/json', 'playcraft-env': config.environment },
114
- body: JSON.stringify({ runtimeId: config.runtimeId, generation: config.generation,
115
- runtimeEpoch: entry.epoch, workspaceId: entry.workspaceId,
116
- ...(entry.modelConfigId ? { modelConfigId: entry.modelConfigId } : {}) }),
117
- });
118
- if (!response.ok) {
119
- const error = await response.json().catch(() => ({}));
120
- throw new Error(['model_config_required', 'model_config_denied'].includes(error.reason ?? '') ? error.reason : 'model_credential_unavailable');
121
- }
122
- const credential = credentialSchema.parse(await response.json());
123
- const claims = credential.claims;
124
- if (!this.valid(entry) || claims.workspaceId !== entry.workspaceId || claims.runtimeId !== config.runtimeId
125
- || claims.userId !== config.userId || claims.environment !== config.environment
126
- || claims.generation !== config.generation || claims.runtimeEpoch !== entry.epoch
127
- || (entry.modelConfigId !== undefined && credential.configId !== entry.modelConfigId)
128
- || Date.parse(credential.expiresAt) <= Date.now() + 1000)
129
- throw new Error('model_credential_scope_mismatch');
130
- entry.modelConfigId = credential.configId;
131
- entry.credential = credential;
132
- return credential;
133
- }
134
- async forward(request, response) {
135
- const abort = new AbortController();
136
- this.requests.add(abort);
137
- let activeRoute;
138
- const cancel = () => abort.abort();
139
- response.once('close', cancel);
140
- try {
141
- const match = /^\/([0-9a-f-]{36}(?:\/[0-9a-f]{32})?)\/responses$/.exec(request.url ?? '');
142
- const route = match ? this.routes.get(match[1]) : undefined;
143
- const selected = route?.selected;
144
- const entry = selected?.entry;
145
- const presented = Buffer.from(request.headers.authorization ?? '');
146
- const expected = Buffer.from(route ? `Bearer ${route.capability}` : '');
147
- if (request.method !== 'POST' || !entry || !expected.length || presented.length !== expected.length
148
- || !timingSafeEqual(presented, expected) || !this.valid(entry)) {
149
- response.writeHead(403);
150
- response.end();
151
- return;
152
- }
153
- activeRoute = route;
154
- const active = this.sessionRequests.get(route) ?? new Set();
155
- active.add(abort);
156
- this.sessionRequests.set(route, active);
157
- const credential = await this.credential(entry);
158
- const chunks = [];
159
- let size = 0;
160
- for await (const chunk of request) {
161
- size += chunk.length;
162
- if (size > 16 * 1024 * 1024) {
163
- response.writeHead(413);
164
- response.end();
165
- return;
166
- }
167
- chunks.push(Buffer.from(chunk));
168
- }
169
- if (!this.valid(entry))
170
- throw new Error('model_access_denied');
171
- const body = JSON.parse(Buffer.concat(chunks).toString('utf8'));
172
- if (!body || typeof body !== 'object' || Array.isArray(body)) {
173
- response.writeHead(400);
174
- response.end();
175
- return;
176
- }
177
- // The browser selects a configuration, never an arbitrary billable upstream model.
178
- body.model = selected.model;
179
- const expires = setTimeout(cancel, Math.max(0, Date.parse(credential.expiresAt) - Date.now()));
180
- try {
181
- const upstream = await fetch(platformEndpoint(this.state.config.publicBaseUrl, modelResponsesPath(credential.configId)), {
182
- method: 'POST', redirect: 'error', signal: abort.signal,
183
- headers: { authorization: `Bearer ${credential.token}`, 'content-type': 'application/json' },
184
- body: JSON.stringify(body),
185
- });
186
- if (upstream.status === 401 || upstream.status === 403)
187
- entry.credential = undefined;
188
- response.writeHead(upstream.status, {
189
- 'content-type': upstream.headers.get('content-type') ?? 'application/json', 'cache-control': 'no-store',
190
- });
191
- if (upstream.body)
192
- await pipeline(Readable.fromWeb(upstream.body), response);
193
- else
194
- response.end();
195
- }
196
- finally {
197
- clearTimeout(expires);
198
- }
199
- }
200
- catch {
201
- if (!response.headersSent) {
202
- response.writeHead(503, { 'content-type': 'application/json', 'cache-control': 'no-store' });
203
- response.end(JSON.stringify({ error: { message: 'model_credential_unavailable', type: 'server_error' } }));
204
- }
205
- else
206
- response.destroy();
207
- }
208
- finally {
209
- response.off('close', cancel);
210
- this.requests.delete(abort);
211
- if (activeRoute) {
212
- const active = this.sessionRequests.get(activeRoute);
213
- active?.delete(abort);
214
- if (!active?.size)
215
- this.sessionRequests.delete(activeRoute);
216
- }
217
- }
218
- }
219
- cancelSession(cwd, sessionId) {
220
- const routeKey = `${/^(basic|remix-)/.test(basename(cwd)) ? basename(dirname(cwd)) : basename(cwd)}/${createHash('sha256').update(sessionId).digest('hex').slice(0, 32)}`;
221
- const route = this.routes.get(routeKey);
222
- if (route)
223
- for (const request of this.sessionRequests.get(route) ?? [])
224
- request.abort();
225
- }
226
- async close() {
227
- const server = this.server;
228
- this.server = undefined;
229
- this.entries.clear();
230
- this.routes.clear();
231
- this.sessionRequests.clear();
232
- for (const request of this.requests)
233
- request.abort();
234
- if (server) {
235
- server.closeAllConnections();
236
- await new Promise(resolve => server.close(() => resolve()));
237
- }
238
- }
239
- }
@@ -1,9 +0,0 @@
1
- /** Failure before a native request was sent; safe to report as failed instead of uncertain. */
2
- export class NativePreparationError extends Error {
3
- }
4
- export function nativeEvent(type, payload) {
5
- return { type, payload, occurredAt: new Date().toISOString() };
6
- }
7
- export function collectedEvent(kind, method, params) {
8
- return { kind, method, params, occurredAt: new Date().toISOString() };
9
- }