castle-web-cli 0.4.193 → 0.4.195

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 (101) hide show
  1. package/dist/agent-prompts.d.ts +1 -0
  2. package/dist/agent-prompts.js +14 -5
  3. package/dist/agent.js +101 -4
  4. package/dist/api.d.ts +1 -0
  5. package/dist/api.js +5 -0
  6. package/dist/bundle.js +2 -1
  7. package/dist/castleJson.d.ts +1 -2
  8. package/dist/castleJson.js +0 -39
  9. package/dist/check.js +14 -6
  10. package/dist/devSessionFrameBudget.d.ts +14 -0
  11. package/dist/devSessionFrameBudget.js +64 -0
  12. package/dist/devSessionServer.d.ts +6 -0
  13. package/dist/devSessionServer.js +38 -1
  14. package/dist/editorConfig.d.ts +1 -1
  15. package/dist/editorConfig.js +12 -4
  16. package/dist/filesChanged.js +7 -3
  17. package/dist/ide.js +28 -59
  18. package/dist/importUpdateHook.d.ts +31 -0
  19. package/dist/importUpdateHook.js +135 -0
  20. package/dist/importUpdateHookRunner.d.ts +2 -0
  21. package/dist/importUpdateHookRunner.js +24 -0
  22. package/dist/imports.js +58 -10
  23. package/dist/index.js +58 -7
  24. package/dist/init.d.ts +1 -0
  25. package/dist/init.js +15 -9
  26. package/dist/multiplayerDoc.d.ts +1 -0
  27. package/dist/multiplayerDoc.js +228 -0
  28. package/dist/native/loop.js +29 -9
  29. package/dist/platformDoc.d.ts +1 -0
  30. package/dist/platformDoc.js +25 -6
  31. package/dist/remix.js +4 -1
  32. package/dist/scriptErrors.d.ts +23 -0
  33. package/dist/scriptErrors.js +147 -0
  34. package/dist/serve.js +366 -36
  35. package/dist/serverBundle.js +1 -1
  36. package/dist/shell/assets/index-kMH1qj6D.js +449 -0
  37. package/dist/shell/index.html +1 -1
  38. package/dist/versions.d.ts +14 -0
  39. package/dist/versions.js +21 -0
  40. package/dist/viteClientStub.d.ts +18 -0
  41. package/dist/viteClientStub.js +193 -0
  42. package/dist/vitePlugins.d.ts +1 -0
  43. package/dist/vitePlugins.js +18 -0
  44. package/kits/base/CLAUDE.md +3 -3
  45. package/kits/base/castle.json +1 -3
  46. package/kits/base/sdk/README.md +17 -0
  47. package/kits/multiplayer-2d/CLAUDE.md +9 -2
  48. package/kits/multiplayer-2d/blueprints/crate.scene +32 -4
  49. package/kits/multiplayer-2d/blueprints/other-player.scene +31 -4
  50. package/kits/multiplayer-2d/blueprints/player.scene +38 -6
  51. package/kits/multiplayer-2d/blueprints/wall.scene +25 -3
  52. package/kits/multiplayer-2d/castle.json +3 -12
  53. package/kits/multiplayer-2d/test/two-client-test.mjs +4 -4
  54. package/kits/multiplayer-3d/CLAUDE.md +5 -2
  55. package/kits/multiplayer-3d/castle.json +3 -11
  56. package/kits/multiplayer-3d/scenes/main.scene +128 -0
  57. package/kits/physics-2d/CLAUDE.md +16 -11
  58. package/kits/physics-2d/behaviors/Camera.jsx +5 -6
  59. package/kits/physics-2d/behaviors/Goal.jsx +5 -2
  60. package/kits/physics-2d/behaviors/Joints.jsx +4 -3
  61. package/kits/physics-2d/behaviors/Layout.jsx +120 -3
  62. package/kits/physics-2d/behaviors/Sprite.jsx +9 -9
  63. package/kits/physics-2d/behaviors/Style.jsx +22 -15
  64. package/kits/physics-2d/behaviors/Text.jsx +7 -6
  65. package/kits/physics-2d/blueprints/ball.scene +27 -5
  66. package/kits/physics-2d/blueprints/block.scene +16 -3
  67. package/kits/physics-2d/blueprints/cauldron.scene +3 -1
  68. package/kits/physics-2d/blueprints/crate.scene +23 -4
  69. package/kits/physics-2d/blueprints/goal.scene +12 -2
  70. package/kits/physics-2d/blueprints/text.scene +13 -3
  71. package/kits/physics-2d/castle.json +2 -11
  72. package/kits/physics-2d/editors/SceneEditor.jsx +68 -5
  73. package/kits/physics-2d/editors/SelectionOverlay.jsx +27 -20
  74. package/kits/physics-2d/editors/behaviorRegistry.js +8 -2
  75. package/kits/physics-2d/engine/ErrorOverlay.jsx +69 -0
  76. package/kits/physics-2d/engine/ScenePlayer.jsx +2 -67
  77. package/kits/physics-2d/engine/blueprint.js +111 -54
  78. package/kits/physics-2d/engine/blueprintCore.js +59 -0
  79. package/kits/physics-2d/engine/collider.js +28 -17
  80. package/kits/physics-2d/engine/layout.js +61 -0
  81. package/kits/physics-2d/engine/layoutOriginMigration.js +223 -0
  82. package/kits/physics-2d/engine/liveReload.js +5 -4
  83. package/kits/physics-2d/engine/physics/PhysicsSystem.js +11 -7
  84. package/kits/physics-2d/engine/physics/controls.js +4 -8
  85. package/kits/physics-2d/engine/physics/matterBridge.js +13 -8
  86. package/kits/physics-2d/engine/scene.js +38 -34
  87. package/kits/physics-2d/engine/spriteGeometry.js +17 -9
  88. package/kits/physics-2d/engine/tap.js +4 -3
  89. package/kits/physics-2d/scenes/main.scene +59 -6
  90. package/kits/physics-2d/scenes/sandbox.scene +69 -7
  91. package/kits/physics-2d/scripts/onUpdate.mjs +199 -0
  92. package/kits/physics-3d/castle.json +0 -11
  93. package/kits/real-time/castle.json +2 -8
  94. package/kits/real-time/code/server/persist.js +14 -0
  95. package/kits/turn-based/CLAUDE.md +18 -10
  96. package/kits/turn-based/blueprints/board.scene +3 -1
  97. package/kits/turn-based/blueprints/square.scene +3 -1
  98. package/kits/turn-based/castle.json +3 -14
  99. package/kits/turn-based/code/behaviors/Board.jsx +33 -21
  100. package/package.json +1 -1
  101. package/dist/shell/assets/index-ColHKJYj.js +0 -449
@@ -87,6 +87,7 @@ export interface RouterPromptOpts {
87
87
  tasks: PromptTask[];
88
88
  plan?: RouterPlanOpts;
89
89
  playtest?: boolean;
90
+ editorTabs?: string[];
90
91
  instruction: string;
91
92
  }
92
93
  export declare function buildRouterPromptParts(opts: RouterPromptOpts): RouterPromptParts;
@@ -29,11 +29,13 @@ function baseRouterRules(playtest) {
29
29
 
30
30
  What a deck is: a normal web project served by vite -- index.html plus plain JS/JSX modules, with real npm dependencies (more can be installed), the castle-web-sdk package, and usually a kit framework whose engine, behaviors, scenes, editors, and drawings are ordinary files in this directory. The web platform is fully available (DOM, canvas, npm libraries like react, three, etc.). The deck's Quick reference and file list below describe its setup; the full CLAUDE.md / AGENTS.md has deeper detail. NEVER claim something is impossible or unsupported on the platform without checking that context (or, for specifics it doesn't cover, the deck's files) first.
31
31
 
32
+ What the user sees beside this chat: Castle's own panels -- Play, Files, Parameters, Terminal, and this chat -- plus a tab for each file they open. Those panels belong to Castle, and nothing in the deck can change them. A file's tab is different: unless it is the plain code view, it is an EDITOR, an ordinary module that comes from the deck or its kit (this deck's are listed under == editor tabs ==). Users name one by its label ("the <label> tab") or just say "this tab", and they mean that editor, not Castle. When they ask whether a tab can do something it doesn't do yet, or whether it can be changed at all, the answer is yes: a task forks the kit's editor into the deck and changes that copy (see the imports rule below), or gives a new file type an editor of its own. Never tell the user a file's tab is part of Castle.
33
+
32
34
  Hard rules:
33
35
  - You NEVER edit files or run state-changing commands. All building and fixing happens through background task agents -- always hand the longer work to them.
34
36
  - IMPORTS ARE YOURS, and they are the one exception to the rule above. Run \`castle-web list-decks --kind kits\` (also \`mine\` and \`saved\`) to see what this deck can import, and \`castle-web add-import <deckIdOrUrl>\` to add one -- both directly, not through a task. Do NOT claim you can list or import anything until you have actually run these; do not describe imports you have not looked at. \`list-decks\` prints one deck per line starting with the id \`add-import\` takes, and marks the ones this deck already has. A pasted castle.xyz deck link works in place of an id. Everything else about a deck's files still goes to task agents.
35
- - Imported files are READ-ONLY, which is what to say when the user asks whether they can change something a kit or another import gave them, or why an edit to one did not stick: the deck takes its own version of that one file -- a fork, stored beside the import and used in its place -- and that version is what runs. Forking is how their own data and code changes override an import's, and a task agent does it; the tradeoff, worth saying plainly, is that a file done this way stops picking up changes when the import itself is updated, so it stays to the few files the change actually needs. Often it does not come to a fork at all, which is the better thing to say first: a kit picks up the deck's own behaviors and systems, so new logic is usually just a new file in the deck.
36
- - You are the fast lane: get to your final reply as quickly as possible. When the user reports something broken, do NOT dig into the code to diagnose it first -- spawn a task whose job is to investigate AND fix it. Only read deck files when your reply itself needs them (answering a question about the deck, grounding a claim -- never make things up); never read as pre-work before spawning a task, and never read files just to learn conventions already covered by the Quick reference.${playtest ? `\n${PLAYTEST_ROUTER_RULE}` : ""}
37
+ - Imported files are READ-ONLY, which is what to say when the user asks whether they can change something a kit or another import gave them (an editor tab included), or why an edit to one did not stick: the deck takes its own version of that one file -- a fork, stored beside the import and used in its place -- and that version is what runs. Forking is how their own data and code changes override an import's, and a task agent does it; the tradeoff, worth saying plainly, is that a file done this way stops picking up changes when the import itself is updated, so it stays to the few files the change actually needs. Often it does not come to a fork at all, which is the better thing to say first: a kit picks up the deck's own behaviors and systems, so new logic is usually just a new file in the deck.
38
+ - You are the fast lane: get to your final reply as quickly as possible. When the user reports something broken, do NOT dig into the code to diagnose it first -- spawn a task whose job is to investigate AND fix it. A QUESTION is not a fix request: "why is X happening?" gets a task told explicitly to diagnose and CHANGE NOTHING, and your reply says that it will only look and report back. Only read deck files when your reply itself needs them (answering a question about the deck, grounding a claim -- never make things up); never read as pre-work before spawning a task, and never read files just to learn conventions already covered by the Quick reference.${playtest ? `\n${PLAYTEST_ROUTER_RULE}` : ""}
37
39
  - When you point the user at a file, a line, or a tunable value, write it as a link they can tap: \`[label](game.js)\` for a file, \`[label](game.js#L108)\` for a line, \`[label](game.js#params)\` for a file's tunable values and \`[label](game.js#params:enemySpeed)\` for ONE of them (the key exactly as it is written in that file's \`PARAMS\` object -- \`player.speed\` for a nested one). The label is your own words for the thing; the path must be exact and must be a file this deck actually has, or it renders as plain text. A bare \`game.js#108\` in a sentence links too. Cite a line number ONLY when you have read that file with numbered lines -- any deck contents in this prompt carry none, so never count them yourself; link the file or its params instead when you are unsure.
38
40
  - Launch a SET of small steps the user tests one by one -- a pipeline, never one big task they wait on, never untestable fragments. One interacting mechanic = one task (paddle + ball + bricks = one playable core, not three). First step = the smallest genuinely playable thing; later steps build it out. Match breadth to ambition ("basic" = a few steps; "go wild" = many). You're optimizing the user's taste and feedback -- more small testable steps = more points where they steer it into something theirs.
39
41
  - The whole goal: every piece of work TESTABLE in actual gameplay ASAP. Start every task as early as possible and run them in PARALLEL. Do NOT break tasks down by which files they touch, and never add \`after:\` just to avoid two tasks editing the same file -- tasks make surgical edits and overlap fine. The only real dependency between tasks is INFORMATION: a task is blocked only when it needs a fact it does not yet have.
@@ -70,7 +72,7 @@ comma-separated active-task titles or ids, or \`all\`
70
72
  - Never claim the board is cleared without actually emitting the fence.
71
73
  - Tasks are one-and-done -- when the user gives feedback on a finished task, spawn a new fix task (and \`castle-done\` the old row) rather than reopening it.
72
74
  - Task agents are capable coding agents working in this same deck directory, but they know nothing about this conversation beyond your prompt.
73
- - The deck keeps its own version history, and you may READ it: \`castle-web list-versions\` shows the versions newest first, and \`castle-web show-version <id>\` shows what one changed, as diffs of just those files. Use them to answer "what changed" or to ground a claim about recent work. You NEVER run \`save-version\` -- you did not make the changes, so a version of yours would not correspond to a unit of work -- and you NEVER run \`restore-version\`: going back is the user's own decision, not something you do on their behalf.
75
+ - The deck keeps its own version history, and you may READ it: \`castle-web list-versions\` shows the versions newest first, and \`castle-web show-version <id>\` shows what one changed, as diffs of just those files. Use them to answer "what changed" or to ground a claim about recent work. You NEVER run \`save-version\` -- you did not make the changes, so a version of yours would not correspond to a unit of work -- and you NEVER run \`restore-version\`: going back is the user's own decision, not something you do on their behalf. For the same reason, no task you spawn may ever revert, replace, or re-scaffold the deck's scenes, scripts, or behaviors back to kit or starter content -- a fix is always a targeted edit, and every task prompt you write has to be readable that way.
74
76
 
75
77
  Asking with options (the \`\`\`ask block). When you need the user to settle a few choices at once, emit ONE fenced block tagged \`ask\` containing JSON -- it renders inline in the chat as grouped options they tap and submit together (far better than stacking questions they can only half-answer). Reach for it to pin a direction fast when their ask is vague ("make me a game" -> ask what kind), NOT to interrogate.
76
78
 
@@ -87,6 +89,7 @@ Conversation style:
87
89
  - As short and focused as possible -- a few tight sentences. Concrete, energetic.
88
90
  - Plain, everyday language for a CREATOR who may not be a programmer. No dev or game-industry jargon -- not "greybox", "scaffold", "refactor", "wire up", "placeholder art", "core loop", etc. -- in ANYTHING the user sees, including task TITLES. Say what's happening simply ("a rough playable version first, then the real art"; "Player movement", "Enemies you can fight", "Real artwork"). Task titles read like plain to-do items a non-coder understands.
89
91
  - After spawning tasks, less is more -- but NEVER reply with only task directives: always include at least one short line of plain text saying what is being spun up. One tight sentence is plenty; the board shows the rest. Do NOT tack a follow-up question onto your replies by default; ask a question (at most one) only when you genuinely need the answer to proceed.
92
+ - When the user asks HOW to do something or to see an example, answer it yourself -- a couple of sentences, plus a short standalone snippet if it helps -- and do not spawn a task that drops a demo behavior or actor into their scene. Build it only when they want it in their game; if a task did add files, name each one and what it attached to so they can find and remove them.
90
93
  - Do not narrate before tool calls ("Checking the deck...") -- that reads as noise in the chat. Read silently, then give one reply after your final tool call.
91
94
  - The user sees a live task board above the chat -- never re-announce task status yourself.
92
95
  - Spawning a task does NOT apply the change -- tasks run for minutes and finish on the board. Talk about spawned work in future tense ("this will dial the shake back"), and NEVER ask how a change feels right after spawning it -- the user cannot have tried it yet. Save "how is it?" for things whose task already finished.
@@ -833,6 +836,9 @@ export function buildRouterPromptParts(opts) {
833
836
  const quickReference = opts.quickReference?.trim()
834
837
  ? `\n\n== how this deck works ==\n${opts.quickReference.trim()}`
835
838
  : `\n\n== how this deck works ==\n${NO_DECK_DOCS}`;
839
+ const editorTabs = opts.editorTabs?.length
840
+ ? `\n\n== editor tabs ==\n${opts.editorTabs.map((tab) => `- ${tab}`).join("\n")}`
841
+ : "";
836
842
  const deckFiles = opts.deckTree?.trim()
837
843
  ? `\n\n== deck files ==\n${opts.deckTree.trim()}`
838
844
  : "";
@@ -852,7 +858,7 @@ export function buildRouterPromptParts(opts) {
852
858
  system: `${routerRules(opts.plan !== undefined, opts.playtest === true)}
853
859
 
854
860
  == deck ==
855
- ${opts.deckLabel}${quickReference}${deckFiles}`,
861
+ ${opts.deckLabel}${quickReference}${editorTabs}${deckFiles}`,
856
862
  user: `== conversation so far ==
857
863
  ${renderTranscript(opts.messages)}${plan}
858
864
 
@@ -958,7 +964,8 @@ Operating rules:
958
964
  - Speed is of the essence -- go for the quickest viable, testable change, unless this prompt explicitly tells you to take longer and dive deep. It must still amount to at least one meaningful step up (one or a few features, pieces of art, etc.), never a token gesture.
959
965
  - The USER is the verifier -- the whole tasks system exists so the user playtests every change themselves. Your first priority is to finish as soon as possible with the change genuinely in place and reachable in the running deck, so the user can test it right away. Do NOT run verification (screenshots especially) unless ${opts.playtest ? "this task's brief asks for it or " : ""}you are really sure it will catch something a re-read of your own change cannot -- and even then at most one cheap check, never a retry loop. Time spent verifying is time the user is left waiting.
960
966
  - The moment implementation is complete and you switch to verifying, write 90 to the progress file -- verification time must not read as stalled progress.
961
- - Do this one task completely, then stop. Do not expand scope.${planRules}
967
+ - Do this one task completely, then stop. Do not expand scope.
968
+ - If the task is to SHOW HOW something is done or to give an example, answer it -- in your streamed output and notes, with a standalone snippet if that helps -- and do NOT insert a demo behavior, blueprint, or actor into their scene; that only happens when the user asked for it in their game. Anything you did add to a scene must be named in your notes by file path and by the actor or blueprint it attached to, so they can find it and take it out.${planRules}
962
969
  - SAVE A VERSION when your change is done, so the user can see and undo it: \`castle-web save-version -m "<short description of what you changed>" <each path you touched>\`. Name those paths explicitly -- a bare \`save-version\` with no paths records the WHOLE deck, including files a sibling agent is still working on. One version for the whole task, at the end; not one per file.
963
970
  - Overlap with the other agents working in this deck is fine and expected -- do not try to avoid it or wait for them. Saving only your own paths is all that is asked of you; nothing anyone has written is lost by your save.
964
971
  - NEVER run \`restore-version\`. Going back to an earlier version is the user's decision alone -- not yours, not even to undo your own work. If your change is wrong, fix it forward.
@@ -977,6 +984,8 @@ Operating rules:
977
984
  - When a fork IS the way, prefer forking to open a SEAM: put a hook, registration, or override point in the forked file and keep the logic it calls in an ordinary deck file. Later changes then land in the deck instead of forcing more forks. Size that to the change though -- a one- or two-line tweak is just a direct edit to the fork; do not build an override system for it.
978
985
  - A forked file exists on disk TWICE, and reading or grepping finds both copies. \`forks/<alias>/<path>\` is the live one -- edit that one. \`imports/<alias>/<path>\` is the version the fork was taken from; it is what the deck used to run, not what it runs now, and writing to it just fails.
979
986
  - Other task agents may be editing this same deck IN PARALLEL. When you change an existing file, READ it first and make a targeted edit to just the part you need -- never overwrite a whole file you have not read. A blind full-file rewrite clobbers other agents' in-flight changes. Being a bit slower and careful here is the right tradeoff.
987
+ - NEVER revert, replace, or re-scaffold the deck's scenes, scripts, or behaviors back to kit, starter, or imported content, and never delete or rewrite a whole scene as a way to diagnose a problem -- that file IS the person's game, and a rewrite destroys work no one asked you to touch. A brief that asks you to investigate, diagnose, or explain is READ-ONLY: report what you found and change nothing unless the user asked for a fix.
988
+ - Before any change that overwrites or deletes MORE THAN ONE existing file of theirs, save a version first so they can restore: \`castle-web save-version -m "<what is about to change>" <those paths>\`. That is on top of the end-of-task version below, not instead of it.
980
989
  - How the code should read: decks get opened by strangers copying the pattern, so write for a first-time reader. Name things in words -- \`connection\`, not \`conn\`; \`runtime\`, not \`rt\`. A name that needs a comment to decode is the wrong name.
981
990
  - Order a file: data shapes first, then classes, then the functions over that data, so the reader meets the shape before the code that moves it.
982
991
  - Comments say what a thing IS and how the system works, declaratively. Not the case for a choice, not what the next line does -- and nothing at all when the code already says it.
package/dist/agent.js CHANGED
@@ -15,6 +15,7 @@
15
15
  // runAgentCli.
16
16
  import { execFileSync, spawn } from 'child_process';
17
17
  import { claudeContextEnv, quickReferenceFor } from './platformDoc.js';
18
+ import { resolveFileTypes } from './editorConfig.js';
18
19
  import { IMPORTS_DIR } from './imports.js';
19
20
  import { isSameOriginUpgrade } from './wsOrigin.js';
20
21
  import { resolveDeckPath } from './ide.js';
@@ -402,6 +403,8 @@ systemPrompt) {
402
403
  const direct = viaOpenrouter ? orAuth.mode === 'user-key' : anAuth.mode !== 'proxy';
403
404
  return {
404
405
  command: 'claude',
406
+ model: spawnModel,
407
+ systemText,
405
408
  args: [
406
409
  '-p',
407
410
  '--verbose',
@@ -1237,6 +1240,11 @@ function makeAgentEventHandler(opts, state) {
1237
1240
  };
1238
1241
  return handleClaudeEvent;
1239
1242
  }
1243
+ // How long a settled run waits for its log stream to flush before resolving
1244
+ // anyway. Long enough that an ordinary append always lands first (so a retry's
1245
+ // next attempt cannot interleave with it), short enough that a wedged disk
1246
+ // never becomes a stuck turn.
1247
+ const LOG_FLUSH_TIMEOUT_MS = 2_000;
1240
1248
  // One headless claude CLI run, normalized to delta/activity/result hooks:
1241
1249
  // stream_event wraps anthropic SSE deltas, and a result event carries the
1242
1250
  // canonical final text.
@@ -1271,7 +1279,42 @@ function runAgentCli(opts) {
1271
1279
  }
1272
1280
  opts.children.add(child);
1273
1281
  opts.onSpawn?.(child.pid);
1274
- const log = opts.logPath ? fs.createWriteStream(opts.logPath, { flags: 'a' }) : null;
1282
+ // The run log is strictly best-effort -- it must never take the run, or
1283
+ // the serve, down with it. A write stream reports ENOSPC, EACCES and a
1284
+ // removed directory as an ASYNC 'error' event, and an unhandled 'error'
1285
+ // on a stream is FATAL to the process: without this listener the whole
1286
+ // serve dies because logging failed. So the stream lives in a nullable
1287
+ // the handler clears, and every use goes through writeLog, which quietly
1288
+ // becomes a no-op once the stream is gone. (Same discipline as
1289
+ // createRunLogger in native/loop.ts.)
1290
+ let logStream = null;
1291
+ if (opts.logPath) {
1292
+ try {
1293
+ logStream = fs.createWriteStream(opts.logPath, { flags: 'a' });
1294
+ logStream.on('error', () => {
1295
+ logStream = null;
1296
+ });
1297
+ }
1298
+ catch {
1299
+ logStream = null;
1300
+ }
1301
+ }
1302
+ const writeLog = (line) => {
1303
+ try {
1304
+ logStream?.write(line);
1305
+ }
1306
+ catch {
1307
+ /* never fail a run over logging */
1308
+ }
1309
+ };
1310
+ // Ahead of every stream line: what this turn was asked (see logHeader).
1311
+ if (opts.logHeader) {
1312
+ writeLog(JSON.stringify({
1313
+ type: 'castle_prompt',
1314
+ at: new Date().toISOString(),
1315
+ ...opts.logHeader,
1316
+ }) + '\n');
1317
+ }
1275
1318
  let settled = false;
1276
1319
  let stderrTail = '';
1277
1320
  let lineBuffer = '';
@@ -1282,8 +1325,36 @@ function runAgentCli(opts) {
1282
1325
  settled = true;
1283
1326
  clearTimeout(timeout);
1284
1327
  opts.children.delete(child);
1285
- log?.end();
1286
- resolve(result);
1328
+ // Resolve only once the log's buffered lines have actually reached disk.
1329
+ // A task's retry loop opens a NEW append stream on this SAME file for
1330
+ // the next attempt, so resolving before the flush let attempt 2's
1331
+ // castle_prompt header land in the middle of attempt 1's lines -- two
1332
+ // runs interleaved in one file, which a corpus reader cannot untangle.
1333
+ // The timer is the escape hatch: a hung disk delays the log, never the
1334
+ // run, and a flush callback that arrives after it is ignored.
1335
+ const stream = logStream;
1336
+ if (!stream) {
1337
+ resolve(result);
1338
+ return;
1339
+ }
1340
+ let flushed = false;
1341
+ // Declared before the timer it clears: nothing calls this until after
1342
+ // the timer below exists (end's callback and the timer itself are both
1343
+ // async, and the catch path runs after the assignment).
1344
+ const finishFlush = () => {
1345
+ if (flushed)
1346
+ return;
1347
+ flushed = true;
1348
+ clearTimeout(flushTimer);
1349
+ resolve(result);
1350
+ };
1351
+ const flushTimer = setTimeout(finishFlush, LOG_FLUSH_TIMEOUT_MS);
1352
+ try {
1353
+ stream.end(finishFlush);
1354
+ }
1355
+ catch {
1356
+ finishFlush();
1357
+ }
1287
1358
  };
1288
1359
  const timeout = setTimeout(() => {
1289
1360
  try {
@@ -1307,7 +1378,7 @@ function runAgentCli(opts) {
1307
1378
  const line = lineBuffer.slice(0, nl);
1308
1379
  lineBuffer = lineBuffer.slice(nl + 1);
1309
1380
  if (line.trim()) {
1310
- log?.write(line + '\n');
1381
+ writeLog(line + '\n');
1311
1382
  try {
1312
1383
  handleEvent(JSON.parse(line));
1313
1384
  }
@@ -1703,6 +1774,19 @@ async function runAgentTurn(opts) {
1703
1774
  env: invocation.env,
1704
1775
  timeoutMs: opts.timeoutMs,
1705
1776
  logPath: opts.logPath,
1777
+ // The question this run was asked, recorded once at the top of the run log
1778
+ // -- the stream-json lines that follow carry only the answer. `model` and
1779
+ // `systemText` come back from buildAgentInvocation so they are literally
1780
+ // what was spawned, not a recomputation of it.
1781
+ logHeader: {
1782
+ role: opts.role,
1783
+ sessionId,
1784
+ backend: 'claude',
1785
+ model: invocation.model,
1786
+ effort: opts.effort,
1787
+ systemPrompt: invocation.systemText || undefined,
1788
+ prompt: opts.prompt,
1789
+ },
1706
1790
  children: opts.children,
1707
1791
  onDelta: opts.onDelta,
1708
1792
  onActivity: opts.onActivity,
@@ -2807,6 +2891,18 @@ function resolveFailure(result) {
2807
2891
  : 'exit';
2808
2892
  return { kind, detail: error ?? 'unknown failure' };
2809
2893
  }
2894
+ // Only a type with an editor opens in a tab of its own (editorClassInfo in the
2895
+ // shell), so that is the filter; types sharing a label share the tab.
2896
+ function editorTabsFor(deckDir) {
2897
+ const extsByLabel = new Map();
2898
+ for (const type of resolveFileTypes(deckDir) ?? []) {
2899
+ if (!type.editor || type.unsupported)
2900
+ continue;
2901
+ const label = type.label?.trim() || type.ext;
2902
+ extsByLabel.set(label, [...(extsByLabel.get(label) ?? []), type.ext]);
2903
+ }
2904
+ return [...extsByLabel].map(([label, exts]) => `${label} (${exts.join(', ')})`);
2905
+ }
2810
2906
  // Assemble the full stateless prompt for one router turn: rules + deck
2811
2907
  // context + transcript replay (minus log lines and the in-flight reply) +
2812
2908
  // the live board + this turn's instruction.
@@ -2814,6 +2910,7 @@ function routerTurnPrompt(ctx, instruction, selfMessageId, plan) {
2814
2910
  return buildRouterPromptParts({
2815
2911
  deckLabel: ctx.deckLabel,
2816
2912
  quickReference: quickReferenceFor(ctx.deckDir, ctx.quickReference, 'router'),
2913
+ editorTabs: editorTabsFor(ctx.deckDir),
2817
2914
  deckTree: buildDeckTree(ctx.deckDir),
2818
2915
  playtest: playtestSteering(),
2819
2916
  messages: ctx.log.messages
package/dist/api.d.ts CHANGED
@@ -69,6 +69,7 @@ export interface MeProfile {
69
69
  } | null;
70
70
  }
71
71
  export declare function me(): Promise<MeProfile | null>;
72
+ export declare function whoAmI(): Promise<Pick<MeProfile, 'userId' | 'username'> | null>;
72
73
  export interface DeckRow {
73
74
  deckId: string;
74
75
  title: string | null;
package/dist/api.js CHANGED
@@ -98,6 +98,11 @@ export async function me() {
98
98
  return null;
99
99
  }
100
100
  }
101
+ export async function whoAmI() {
102
+ const data = await graphql(`query { me { userId username } }`);
103
+ handleAPIError(data);
104
+ return pickData(data, 'me');
105
+ }
101
106
  // Everything an import-picker row shows for one deck: what it is, whose it is,
102
107
  // what it looks like, and who it was remixed from. One fragment, so the three
103
108
  // list queries below can't drift apart.
package/dist/bundle.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as path from 'path';
2
2
  import { build } from 'vite';
3
3
  import { viteSingleFile } from 'vite-plugin-singlefile';
4
- import { sceneFilesPlugin, importsAliasPlugin, forksOverlayPlugin, sdkAliasPlugin, } from './vitePlugins.js';
4
+ import { sceneFilesPlugin, importsAliasPlugin, forksOverlayPlugin, sdkAliasPlugin, singleFileBuildCompatPlugin, } from './vitePlugins.js';
5
5
  export async function bundleProject(dir) {
6
6
  const result = await build({
7
7
  root: dir,
@@ -10,6 +10,7 @@ export async function bundleProject(dir) {
10
10
  importsAliasPlugin(),
11
11
  sdkAliasPlugin(),
12
12
  viteSingleFile(),
13
+ singleFileBuildCompatPlugin(),
13
14
  sceneFilesPlugin(),
14
15
  ],
15
16
  build: {
@@ -16,6 +16,7 @@ export interface CastleJson {
16
16
  cardId?: string;
17
17
  imports?: Record<string, DeckImport>;
18
18
  autoUpdateWhenImported?: boolean;
19
+ onUpdate?: string;
19
20
  main?: string;
20
21
  agent?: {
21
22
  plan?: 'on' | 'off';
@@ -45,5 +46,3 @@ export declare const DEFAULT_MAIN = "main.jsx";
45
46
  export declare function deckMainFile(dir: string): string;
46
47
  export declare function readCastleJson(dir: string): CastleJson | null;
47
48
  export declare function readCastleJsonOrThrow(dir: string): CastleJson | null;
48
- export declare function ensureVisiblePath(deckDir: string, rel: string): boolean;
49
- export declare function ensureVisibleGlob(deckDir: string, glob: string, probe: string): boolean;
@@ -1,6 +1,5 @@
1
1
  import * as fs from 'fs';
2
2
  import * as path from 'path';
3
- import picomatch from 'picomatch';
4
3
  // Where a deck's dependencies live, relative to its root. Defined here, in a
5
4
  // module with no imports of its own, because both the import machinery and the
6
5
  // fork overlay need it and importing it from either of those would close a
@@ -99,41 +98,3 @@ export function readCastleJsonOrThrow(dir) {
99
98
  throw new Error(`Could not read ${file}: ${e instanceof Error ? e.message : String(e)}`);
100
99
  });
101
100
  }
102
- // Add `<rel>/**` to the deck's editor.visiblePaths so files created in a
103
- // newly-made folder show in the curated Files tree.
104
- export function ensureVisiblePath(deckDir, rel) {
105
- return ensureVisibleGlob(deckDir, `${rel}/**`, `${rel}/__probe__`);
106
- }
107
- // Add `glob` to the deck's editor.visiblePaths. Only touches a deck that is
108
- // ALREADY curated (non-empty visiblePaths) -- when visiblePaths is empty
109
- // everything is visible, and adding a glob would wrongly start hiding things.
110
- // No-op if an existing glob already covers `probe`, a path the new glob would
111
- // match. Returns whether it wrote.
112
- export function ensureVisibleGlob(deckDir, glob, probe) {
113
- const file = path.join(deckDir, 'castle.json');
114
- let data;
115
- try {
116
- data = JSON.parse(fs.readFileSync(file, 'utf8'));
117
- }
118
- catch {
119
- return false; // no castle.json yet (deck never saved) -> treat as not curated
120
- }
121
- const visible = data.editor && Array.isArray(data.editor.visiblePaths)
122
- ? data.editor.visiblePaths.filter((v) => typeof v === 'string')
123
- : null;
124
- if (!visible || visible.length === 0)
125
- return false; // not curated -> all visible
126
- if (visible.includes(glob))
127
- return false;
128
- if (picomatch(visible)(probe))
129
- return false; // already covered
130
- visible.push(glob);
131
- data.editor.visiblePaths = visible;
132
- try {
133
- fs.writeFileSync(file, `${JSON.stringify(data, null, 2)}\n`, 'utf8');
134
- return true;
135
- }
136
- catch {
137
- return false;
138
- }
139
- }
package/dist/check.js CHANGED
@@ -1,13 +1,15 @@
1
1
  import * as fs from 'fs';
2
2
  import * as path from 'path';
3
3
  import { bundleProject } from './bundle.js';
4
- // `castle-web check` -- does this deck still build?
4
+ import { resolveServerConfig } from './castleJson.js';
5
+ import { buildServerBundle } from './serverBundle.js';
6
+ // `castle-web check` -- do this deck and its authoritative server still build?
5
7
  //
6
- // The bundle is the gate that matters wherever a deck came from: it is the same
7
- // build `save-deck` runs, so anything it refuses is a deck that would publish
8
+ // These are the gates that matter wherever a deck came from: they are the same
9
+ // builds `save-deck` runs, so anything they refuse is a deck that would publish
8
10
  // broken. A kit adds its own lint and duplicate gates on top through its own
9
- // `check` script; a deck built on nothing has no lint config to run, and used
10
- // to have no way to answer the question at all.
11
+ // `check` script; a deck built on nothing has no lint config to run, and used to
12
+ // have no way to answer the question at all.
11
13
  export async function check(dir) {
12
14
  const deckDir = path.resolve(dir);
13
15
  if (!fs.existsSync(path.join(deckDir, 'index.html'))) {
@@ -16,10 +18,16 @@ export async function check(dir) {
16
18
  }
17
19
  try {
18
20
  await bundleProject(deckDir);
21
+ console.log('Bundle OK.');
22
+ if (resolveServerConfig(deckDir)) {
23
+ const serverBundle = await buildServerBundle(deckDir);
24
+ if (!serverBundle)
25
+ throw new Error('Server entry disappeared while bundling.');
26
+ console.log('Server bundle OK.');
27
+ }
19
28
  }
20
29
  catch (e) {
21
30
  console.error(e instanceof Error ? e.message : String(e));
22
31
  process.exit(1);
23
32
  }
24
- console.log('Bundle OK.');
25
33
  }
@@ -0,0 +1,14 @@
1
+ export declare const FRAMES_PER_SECOND_BASE = 40;
2
+ export declare const FRAMES_PER_SECOND_PER_PLAYER = 40;
3
+ /** Frames per second a session with this many players connected may send. */
4
+ export declare function frameBudget(players: number): number;
5
+ export declare class OutboundFrameMeter {
6
+ private readonly now;
7
+ private windowStart;
8
+ private frames;
9
+ private players;
10
+ private warnedAt;
11
+ constructor(now: () => number);
12
+ record(connectedPlayers: number): string | null;
13
+ }
14
+ export declare function frameBudgetWarning(frames: number, players: number, budget: number): string;
@@ -0,0 +1,64 @@
1
+ import { MULTIPLAYER_DOC_REL } from './platformDoc.js';
2
+ // Warn-only metering of what the author's server sends, so the budget a
3
+ // published session is held to is visible while the deck is still being built.
4
+ //
5
+ // Production (cauldron-game-server) charges one frame per `sendTo`/`sendBinary`
6
+ // and one per `broadcast`/`broadcastBinary`, and DROPS what is over budget. The
7
+ // dev serve charges the same way and drops nothing: a local serve that silently
8
+ // lost frames would be a worse lie than one that is merely more generous.
9
+ //
10
+ // The numbers mirror cauldron-game-server's `shared/src/constants.ts`
11
+ // (`RUNTIME_FRAMES_PER_SECOND_BASE`, `RUNTIME_FRAMES_PER_SECOND_PER_PLAYER`);
12
+ // its burst allowance and byte budget are deliberately not modelled here --
13
+ // this is a nudge toward one broadcast per tick, not an emulator.
14
+ export const FRAMES_PER_SECOND_BASE = 40;
15
+ export const FRAMES_PER_SECOND_PER_PLAYER = 40;
16
+ const WINDOW_MS = 1_000;
17
+ const WARN_INTERVAL_MS = 10_000;
18
+ /** Frames per second a session with this many players connected may send. */
19
+ export function frameBudget(players) {
20
+ return FRAMES_PER_SECOND_BASE + FRAMES_PER_SECOND_PER_PLAYER * Math.max(1, players);
21
+ }
22
+ // Counts frames in one-second windows and warns the moment a window goes over
23
+ // budget, at most once every 10s. It warns on the crossing frame rather than
24
+ // when the window closes, because the window only closes when a LATER frame
25
+ // arrives: a burst that ends in silence -- a server that floods and then wedges
26
+ // -- would otherwise never be reported at all. `now` is injected so this is
27
+ // testable without a clock.
28
+ export class OutboundFrameMeter {
29
+ now;
30
+ windowStart = null;
31
+ frames = 0;
32
+ players = 0;
33
+ warnedAt = null;
34
+ constructor(now) {
35
+ this.now = now;
36
+ }
37
+ // Charges one frame against the current window and returns a warning line if
38
+ // that frame is the one that took the window past its budget, or null. The
39
+ // player count is the largest seen during the window, which is the most
40
+ // generous budget the window could have had.
41
+ record(connectedPlayers) {
42
+ const now = this.now();
43
+ if (this.windowStart === null || now - this.windowStart >= WINDOW_MS) {
44
+ this.windowStart = now;
45
+ this.frames = 0;
46
+ this.players = 0;
47
+ }
48
+ this.frames += 1;
49
+ this.players = Math.max(this.players, connectedPlayers);
50
+ const budget = frameBudget(this.players);
51
+ if (this.frames <= budget)
52
+ return null;
53
+ if (this.warnedAt !== null && now - this.warnedAt < WARN_INTERVAL_MS)
54
+ return null;
55
+ this.warnedAt = now;
56
+ return frameBudgetWarning(this.frames, this.players, budget);
57
+ }
58
+ }
59
+ export function frameBudgetWarning(frames, players, budget) {
60
+ const who = `${players} player${players === 1 ? '' : 's'}`;
61
+ return (`[multiplayer] server sent ${frames} frames in under a second to ${who}; production sustains ` +
62
+ `~${budget}/s here (about two seconds of burst) and drops what stays over it. One broadcast per tick costs 1 frame; a send per player ` +
63
+ `costs one each. See ${MULTIPLAYER_DOC_REL}`);
64
+ }
@@ -17,3 +17,9 @@ export declare function startDevSessionServer(opts: {
17
17
  projectDir: string;
18
18
  log: (level: 'log' | 'error', text: string) => void;
19
19
  }): Promise<DevSessionServer>;
20
+ export declare function serverRestartNeeded(changes: ReadonlyArray<{
21
+ path: string;
22
+ }>, opts: {
23
+ serverEntry: string;
24
+ serverDir: string;
25
+ }): boolean;
@@ -7,6 +7,7 @@ import * as path from 'path';
7
7
  import { fileURLToPath } from 'url';
8
8
  import { WebSocketServer, WebSocket } from 'ws';
9
9
  import { readCastleJson, resolveServerConfig } from './castleJson.js';
10
+ import { OutboundFrameMeter } from './devSessionFrameBudget.js';
10
11
  import { runDevStorageOperation } from './devSessionStorage.js';
11
12
  import { rawDataToString } from './rawData.js';
12
13
  import { bundleServerModule } from './serverBundle.js';
@@ -33,6 +34,27 @@ function serverDirOf(entry) {
33
34
  const slash = entry.lastIndexOf('/');
34
35
  return slash < 0 ? '' : entry.slice(0, slash + 1);
35
36
  }
37
+ export function serverRestartNeeded(changes, opts) {
38
+ const forkEntry = opts.serverEntry.startsWith('imports/')
39
+ ? `forks/${opts.serverEntry.slice('imports/'.length)}`
40
+ : null;
41
+ const forkDir = opts.serverDir.startsWith('imports/')
42
+ ? `forks/${opts.serverDir.slice('imports/'.length)}`
43
+ : null;
44
+ return changes.some((change) => change.path === opts.serverEntry ||
45
+ (!!opts.serverDir && change.path.startsWith(opts.serverDir)) ||
46
+ change.path.startsWith('server/') ||
47
+ change.path.startsWith('code/server/') ||
48
+ change.path === forkEntry ||
49
+ (!!forkDir && change.path.startsWith(forkDir)) ||
50
+ // The server bundle pulls in every import's server code (a multiplayer-2d
51
+ // entry imports castle.real-time's), so a sibling import's server file,
52
+ // or a fork of one, restarts it too.
53
+ IMPORTED_SERVER_PATH.test(change.path));
54
+ }
55
+ const IMPORTED_SERVER_PATH = /^(imports|forks)\/[^/]+\/(code\/)?server\//;
56
+ // The runtime frames that cost the session a frame of its outbound budget.
57
+ const OUTBOUND_FRAME_TYPES = new Set(['sendTo', 'sendBinary', 'broadcast', 'broadcastBinary']);
36
58
  class DevSessionServerImpl {
37
59
  projectDir;
38
60
  log;
@@ -51,6 +73,9 @@ class DevSessionServerImpl {
51
73
  nonces = new Map();
52
74
  reconnects = new Map();
53
75
  players = new Map();
76
+ // Warn-only: the dev serve never drops a frame for being over budget, it just
77
+ // says what a published session would have done (devSessionFrameBudget.ts).
78
+ frameMeter = new OutboundFrameMeter(() => Date.now());
54
79
  child = null;
55
80
  platformSocket = null;
56
81
  bootToken = '';
@@ -103,7 +128,10 @@ class DevSessionServerImpl {
103
128
  nextSettings !== this.serverSettings;
104
129
  this.serverSettings = nextSettings;
105
130
  if (!serverSettingsChanged &&
106
- !message.changes.some((change) => change.path === this.serverEntry || change.path.startsWith(this.serverDir)))
131
+ !serverRestartNeeded(message.changes, {
132
+ serverEntry: this.serverEntry,
133
+ serverDir: this.serverDir,
134
+ }))
107
135
  return;
108
136
  if (this.restartTimer)
109
137
  clearTimeout(this.restartTimer);
@@ -337,6 +365,8 @@ class DevSessionServerImpl {
337
365
  }
338
366
  if (!this.runtimeReady)
339
367
  return;
368
+ if (typeof frame.t === 'string' && OUTBOUND_FRAME_TYPES.has(frame.t))
369
+ this.meterOutbound();
340
370
  if (frame.t === 'sendTo' && typeof frame.playerId === 'string') {
341
371
  const socket = this.players.get(frame.playerId)?.socket;
342
372
  const payload = parseAuthorPayload(frame.d);
@@ -369,6 +399,13 @@ class DevSessionServerImpl {
369
399
  this.kick(frame.playerId, typeof frame.reason === 'string' ? frame.reason : undefined);
370
400
  }
371
401
  }
402
+ // One frame per send and one per broadcast, exactly as a published session is
403
+ // charged -- a broadcast to eight players is one frame there and one here.
404
+ meterOutbound() {
405
+ const warning = this.frameMeter.record(this.connectedPlayers().length);
406
+ if (warning)
407
+ this.log('log', warning);
408
+ }
372
409
  async handleStorageRequest(reqId, op, args) {
373
410
  const deckId = readCastleJson(this.projectDir)?.deckId;
374
411
  const result = await runDevStorageOperation(deckId, op, args);
@@ -30,11 +30,11 @@ export interface ResolvedFileType extends FileTypeConfig {
30
30
  export interface EditorConfig {
31
31
  initialPanels?: InitialPanel[];
32
32
  hiddenPaths?: string[];
33
- visiblePaths?: string[];
34
33
  fileTypes?: FileTypeConfig[];
35
34
  extensions?: string[];
36
35
  defaultPlayFile?: string;
37
36
  }
38
37
  export declare function readEditorConfig(deckDir: string): EditorConfig;
38
+ export declare function deckHidesFiles(deckDir: string): boolean;
39
39
  export declare function resolveFileTypes(deckDir: string): ResolvedFileType[] | null;
40
40
  export {};
@@ -10,9 +10,9 @@
10
10
  // sits there like any other), so resolving is a read of each import's own
11
11
  // castle.json -- there is no graph to walk.
12
12
  //
13
- // `initialPanels` and `visiblePaths`/`hiddenPaths` stay the deck's own, read from
14
- // the deck root only. `defaultPlayFile` falls back to an import's when the deck
15
- // names none -- see `importedDefaultPlayFile`.
13
+ // `initialPanels` and `hiddenPaths` stay the deck's own, read from the deck root
14
+ // only. `defaultPlayFile` falls back to an import's when the deck names none --
15
+ // see `importedDefaultPlayFile`.
16
16
  import * as fs from 'fs';
17
17
  import * as path from 'path';
18
18
  import { readCastleJson } from './castleJson.js';
@@ -53,7 +53,6 @@ export function readEditorConfig(deckDir) {
53
53
  return {
54
54
  initialPanels: Array.isArray(editor.initialPanels) ? editor.initialPanels : undefined,
55
55
  hiddenPaths: asStringArray(editor.hiddenPaths),
56
- visiblePaths: asStringArray(editor.visiblePaths),
57
56
  fileTypes: asFileTypes(editor.fileTypes),
58
57
  extensions: asStringArray(editor.extensions) ?? asStringArray(data.editorExtensions),
59
58
  defaultPlayFile: typeof editor.defaultPlayFile === 'string'
@@ -101,6 +100,15 @@ function importAliases(deckDir) {
101
100
  const pinned = Object.keys(readCastleJson(deckDir)?.imports ?? {}).filter((alias) => onDisk.includes(alias));
102
101
  return [...pinned, ...onDisk.filter((alias) => !pinned.includes(alias))];
103
102
  }
103
+ // Whether anything can be hidden from the Files tree: this deck's own denylist,
104
+ // or an import's -- an import is filtered by its own castle.json, so a kit that
105
+ // hides its internals hides files the importing deck never listed.
106
+ export function deckHidesFiles(deckDir) {
107
+ const hides = (dir) => (readEditorConfig(dir).hiddenPaths ?? []).length > 0;
108
+ if (hides(deckDir))
109
+ return true;
110
+ return importAliases(deckDir).some((alias) => hides(path.join(deckDir, IMPORTS_DIR, alias)));
111
+ }
104
112
  // Every file type this deck understands: its own, plus every import's. Keyed by
105
113
  // extension, first declaration wins -- so the deck overrides what it imports,
106
114
  // and among imports the one it pinned first does (the same order
@@ -57,9 +57,13 @@ export function installFilesChangedWatcher(opts) {
57
57
  affected.add(p);
58
58
  }
59
59
  const affectedList = [...affected].sort();
60
- log?.(`[watch] ${changes
61
- .map((c) => `${c.event} ${c.path}${c.affected.length ? ` (+${c.affected.length})` : ''}`)
62
- .join(', ')} | affected ${affectedList.length}\n`);
60
+ const loggedChanges = changes
61
+ .slice(0, 5)
62
+ .map((c) => `${c.event} ${c.path}${c.affected.length ? ` (+${c.affected.length})` : ''}`);
63
+ if (changes.length > loggedChanges.length) {
64
+ loggedChanges.push(`and ${changes.length - loggedChanges.length} more`);
65
+ }
66
+ log?.(`[watch] ${loggedChanges.join(', ')} | affected ${affectedList.length}\n`);
63
67
  broadcast({ type: 'files_changed', changes, affected: affectedList });
64
68
  };
65
69
  const schedule = () => {