castle-web-cli 0.4.78 → 0.4.80
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.
- package/dist/agent-prompts.d.ts +4 -1
- package/dist/agent-prompts.js +28 -7
- package/dist/agent.d.ts +7 -2
- package/dist/agent.js +655 -51
- package/dist/native/loop.d.ts +2 -0
- package/dist/native/loop.js +698 -0
- package/dist/native/openrouter.d.ts +55 -0
- package/dist/native/openrouter.js +354 -0
- package/dist/native/playtest-browser.d.ts +34 -0
- package/dist/native/playtest-browser.js +354 -0
- package/dist/native/playtest-executor.d.ts +3 -0
- package/dist/native/playtest-executor.js +156 -0
- package/dist/native/playtest.d.ts +131 -0
- package/dist/native/playtest.js +314 -0
- package/dist/native/tools.d.ts +38 -0
- package/dist/native/tools.js +690 -0
- package/dist/native/types.d.ts +40 -0
- package/dist/native/types.js +41 -0
- package/dist/serve.js +12 -0
- package/dist/shell/assets/{index-yGdKhgfZ.js → index-D3unT7do.js} +37 -37
- package/dist/shell/assets/{index-WE24qX3d.css → index-RZrw5gQ2.css} +1 -1
- package/dist/shell/index.html +2 -2
- package/kits/basic-2d/CLAUDE.md +29 -3
- package/kits/basic-2d/behaviors/Layout.jsx +10 -0
- package/kits/basic-2d/behaviors/Sprite.jsx +1 -1
- package/kits/basic-2d/blueprints/cauldron.scene +22 -0
- package/kits/basic-2d/castle.json +5 -7
- package/kits/basic-2d/docs/pxart-format.md +4 -3
- package/kits/basic-2d/drawings/cauldron.pxart +113 -0
- package/kits/basic-2d/editors/BlueprintLibrary.jsx +247 -0
- package/kits/basic-2d/editors/PlayOnly.jsx +1 -0
- package/kits/basic-2d/editors/SceneEditor.jsx +399 -411
- package/kits/basic-2d/editors/SelectionOverlay.jsx +125 -63
- package/kits/basic-2d/editors/SingleEditor.jsx +11 -2
- package/kits/basic-2d/editors/editorHistory.js +8 -2
- package/kits/basic-2d/editors/inspectorSheet.js +5 -19
- package/kits/basic-2d/engine/ScenePlayer.jsx +2 -2
- package/kits/basic-2d/engine/blueprint.js +423 -0
- package/kits/basic-2d/engine/files.js +1 -1
- package/kits/basic-2d/engine/scene.js +29 -29
- package/kits/basic-2d/engine/ui.jsx +160 -21
- package/kits/basic-2d/engine/ui.module.css +155 -13
- package/kits/basic-2d/pnpm-workspace.yaml +3 -0
- package/kits/basic-2d/scenes/main.scene +3 -13
- package/package.json +2 -1
- package/kits/basic-2d/drawings/pig.pxart +0 -26
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { PlaytestExecutor } from "./playtest.js";
|
|
2
|
+
export type NativeRole = "router" | "task";
|
|
3
|
+
export interface NativePlaytestOpts {
|
|
4
|
+
executor: PlaytestExecutor;
|
|
5
|
+
serveUrl: string;
|
|
6
|
+
framesDir: string;
|
|
7
|
+
}
|
|
8
|
+
export interface NativeUsage {
|
|
9
|
+
input_tokens?: number;
|
|
10
|
+
output_tokens?: number;
|
|
11
|
+
cache_creation_input_tokens?: number;
|
|
12
|
+
cache_read_input_tokens?: number;
|
|
13
|
+
}
|
|
14
|
+
export interface NativeRunOpts {
|
|
15
|
+
cwd: string;
|
|
16
|
+
role: NativeRole;
|
|
17
|
+
model: string;
|
|
18
|
+
apiKey: string;
|
|
19
|
+
prompt: string;
|
|
20
|
+
systemReminder?: string;
|
|
21
|
+
attachments?: string[];
|
|
22
|
+
playtest?: NativePlaytestOpts;
|
|
23
|
+
restart?: () => void;
|
|
24
|
+
logPath?: string;
|
|
25
|
+
timeoutMs: number;
|
|
26
|
+
signal?: AbortSignal;
|
|
27
|
+
onDelta?: (delta: string) => void;
|
|
28
|
+
onActivity?: (activity: string | null) => void;
|
|
29
|
+
onThinking?: (delta: string) => void;
|
|
30
|
+
onSpawn?: (pid: number | undefined) => void;
|
|
31
|
+
labelUnknownTools?: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface NativeRunResult {
|
|
34
|
+
text: string;
|
|
35
|
+
error?: string;
|
|
36
|
+
usage?: NativeUsage;
|
|
37
|
+
filesTouched?: string[];
|
|
38
|
+
playtestFrames?: string[];
|
|
39
|
+
crashed?: boolean;
|
|
40
|
+
}
|
|
@@ -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({
|