castle-web-cli 0.4.78 → 0.4.79

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 (46) hide show
  1. package/dist/agent-prompts.d.ts +4 -1
  2. package/dist/agent-prompts.js +28 -7
  3. package/dist/agent.d.ts +7 -2
  4. package/dist/agent.js +655 -51
  5. package/dist/native/loop.d.ts +2 -0
  6. package/dist/native/loop.js +698 -0
  7. package/dist/native/openrouter.d.ts +55 -0
  8. package/dist/native/openrouter.js +354 -0
  9. package/dist/native/playtest-browser.d.ts +34 -0
  10. package/dist/native/playtest-browser.js +354 -0
  11. package/dist/native/playtest-executor.d.ts +3 -0
  12. package/dist/native/playtest-executor.js +156 -0
  13. package/dist/native/playtest.d.ts +131 -0
  14. package/dist/native/playtest.js +314 -0
  15. package/dist/native/tools.d.ts +38 -0
  16. package/dist/native/tools.js +630 -0
  17. package/dist/native/types.d.ts +40 -0
  18. package/dist/native/types.js +41 -0
  19. package/dist/serve.js +12 -0
  20. package/dist/shell/assets/{index-yGdKhgfZ.js → index-CNT3KxJb.js} +37 -37
  21. package/dist/shell/assets/{index-WE24qX3d.css → index-RZrw5gQ2.css} +1 -1
  22. package/dist/shell/index.html +2 -2
  23. package/kits/basic-2d/CLAUDE.md +29 -3
  24. package/kits/basic-2d/behaviors/Layout.jsx +10 -0
  25. package/kits/basic-2d/behaviors/Sprite.jsx +1 -1
  26. package/kits/basic-2d/blueprints/cauldron.scene +22 -0
  27. package/kits/basic-2d/castle.json +5 -7
  28. package/kits/basic-2d/docs/pxart-format.md +4 -3
  29. package/kits/basic-2d/drawings/cauldron.pxart +113 -0
  30. package/kits/basic-2d/editors/BlueprintLibrary.jsx +247 -0
  31. package/kits/basic-2d/editors/PlayOnly.jsx +1 -0
  32. package/kits/basic-2d/editors/SceneEditor.jsx +399 -411
  33. package/kits/basic-2d/editors/SelectionOverlay.jsx +125 -63
  34. package/kits/basic-2d/editors/SingleEditor.jsx +11 -2
  35. package/kits/basic-2d/editors/editorHistory.js +8 -2
  36. package/kits/basic-2d/editors/inspectorSheet.js +5 -19
  37. package/kits/basic-2d/engine/ScenePlayer.jsx +2 -2
  38. package/kits/basic-2d/engine/blueprint.js +423 -0
  39. package/kits/basic-2d/engine/files.js +1 -1
  40. package/kits/basic-2d/engine/scene.js +29 -29
  41. package/kits/basic-2d/engine/ui.jsx +160 -21
  42. package/kits/basic-2d/engine/ui.module.css +155 -13
  43. package/kits/basic-2d/pnpm-workspace.yaml +3 -0
  44. package/kits/basic-2d/scenes/main.scene +3 -13
  45. package/package.json +2 -1
  46. package/kits/basic-2d/drawings/pig.pxart +0 -26
@@ -0,0 +1,41 @@
1
+ // Shapes for the native (in-process, OpenRouter-backed) agent backend --
2
+ // see the plan at native_openrouter_agent_loop_fd7d9b3e.plan.md, "Path B".
3
+ //
4
+ // These MIRROR the non-exported CliRunOpts / CliRunResult / CliUsage
5
+ // interfaces in cli/src/agent.ts (see runAgentCli there), which normalize
6
+ // the headless `claude` / `cursor-agent` CLI backends into onDelta/onActivity/
7
+ // onThinking hooks plus a { finalText, error, usage, filesTouched, crashed }
8
+ // result. This file is a SEPARATE set of types for now (new-files-only
9
+ // constraint -- agent.ts is being edited concurrently by a sibling change),
10
+ // not a re-export, so field names differ in a few places. When the native
11
+ // backend is wired into agent.ts, expect one of these two outcomes:
12
+ //
13
+ // 1. CliRunOpts/CliRunResult are widened to a shape both backends share
14
+ // (command/args/parser and children become backend-specific extras), or
15
+ // 2. the call site maps between the two shapes directly:
16
+ // - NativeRunResult.text -> CliRunResult.finalText
17
+ // - NativeRunResult.error/usage/filesTouched/crashed -> same names
18
+ // - CliRunResult.ok <- derived as
19
+ // `!result.error && !result.crashed` (no native equivalent of
20
+ // a process exit code -- "ok" always follows from the other
21
+ // two fields)
22
+ // - CliRunOpts.children (Set<ChildProcess>) has no native
23
+ // equivalent -- runAgentNative takes `signal` (AbortSignal)
24
+ // instead, so a caller cancels a run the same way it would abort
25
+ // any other fetch-based operation. The wiring step would create one
26
+ // AbortController per run and adapt it to whatever cancellation
27
+ // registry agent.ts uses for CLI children.
28
+ // - CliRunOpts.command/args/parser have no native equivalent --
29
+ // replaced by `model` (the free-form OpenRouter model id) and
30
+ // `apiKey`.
31
+ // - CliRunOpts.logPath maps to NativeRunOpts.logPath: same file
32
+ // locations (tasks/<id>/log.jsonl, .castle/agent/router-log.jsonl),
33
+ // same append-JSONL discipline, but the native lines are STRUCTURED
34
+ // run events (init/assistant/tool_result/eviction/retry/result --
35
+ // see createRunLogger in loop.ts) rather than raw CLI stream-json.
36
+ //
37
+ // Turns stay stateless exactly as they are today: the caller rebuilds one big
38
+ // prompt string per turn (buildRouterPrompt/buildTaskPrompt) and passes it as
39
+ // `prompt`; runAgentNative holds the resulting message array only for the
40
+ // lifetime of that one call.
41
+ export {};
package/dist/serve.js CHANGED
@@ -255,6 +255,18 @@ export async function serve(dir, options = {}) {
255
255
  const agentServer = createAgentServer({
256
256
  deckDir: projectDir,
257
257
  deckLabel: path.basename(projectDir),
258
+ port,
259
+ // Same effect as the WS server's own 'restart' branch below (invalidate
260
+ // then tell every connected tab to reload), called directly in-process
261
+ // instead of round-tripping through a WebSocket message -- this is what
262
+ // backs the native `restart` tool (see native/tools.ts) so a smith task
263
+ // agent doesn't have to spawn `npm run restart` (node + castle-web CLI +
264
+ // its own WS client) just to send one message to a serve it's already
265
+ // running inside of.
266
+ restart: () => {
267
+ invalidateModuleCaches(viteHolder.vite);
268
+ broadcast({ type: 'restart' });
269
+ },
258
270
  });
259
271
  process.on('exit', () => agentServer.shutdown());
260
272
  const vite = await createServer({