@alexkroman1/aai 0.8.1 → 0.8.3

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 (44) hide show
  1. package/dist/cli.js +181 -230
  2. package/dist/sdk/_render_check.d.ts.map +1 -1
  3. package/dist/sdk/_render_check.js +3 -0
  4. package/dist/sdk/_render_check.js.map +1 -1
  5. package/dist/sdk/server.d.ts.map +1 -1
  6. package/dist/sdk/server.js +30 -87
  7. package/dist/sdk/server.js.map +1 -1
  8. package/dist/sdk/winterc_server.d.ts +1 -0
  9. package/dist/sdk/winterc_server.d.ts.map +1 -1
  10. package/dist/sdk/winterc_server.js +11 -15
  11. package/dist/sdk/winterc_server.js.map +1 -1
  12. package/dist/sdk/ws_handler.d.ts +2 -0
  13. package/dist/sdk/ws_handler.d.ts.map +1 -1
  14. package/dist/sdk/ws_handler.js +3 -1
  15. package/dist/sdk/ws_handler.js.map +1 -1
  16. package/dist/ui/_components/app.d.ts.map +1 -1
  17. package/dist/ui/_components/app.js +3 -4
  18. package/dist/ui/_components/app.js.map +1 -1
  19. package/dist/ui/_components/chat_view.d.ts.map +1 -1
  20. package/dist/ui/_components/chat_view.js +1 -2
  21. package/dist/ui/_components/chat_view.js.map +1 -1
  22. package/dist/ui/_components/start_screen.js +1 -1
  23. package/dist/ui/_components/start_screen.js.map +1 -1
  24. package/dist/ui/components_mod.d.ts +2 -2
  25. package/dist/ui/components_mod.d.ts.map +1 -1
  26. package/dist/ui/components_mod.js.map +1 -1
  27. package/dist/ui/mod.d.ts +2 -2
  28. package/dist/ui/mod.d.ts.map +1 -1
  29. package/dist/ui/mount.d.ts +1 -13
  30. package/dist/ui/mount.d.ts.map +1 -1
  31. package/dist/ui/mount.js.map +1 -1
  32. package/dist/ui/mount_context.d.ts +13 -1
  33. package/dist/ui/mount_context.d.ts.map +1 -1
  34. package/dist/ui/mount_context.js.map +1 -1
  35. package/dist/ui/session.d.ts.map +1 -1
  36. package/dist/ui/session.js +12 -0
  37. package/dist/ui/session.js.map +1 -1
  38. package/package.json +4 -1
  39. package/templates/_shared/CLAUDE.md +52 -29
  40. package/templates/_shared/global.d.ts +1 -0
  41. package/templates/_shared/package.json +2 -1
  42. package/templates/night-owl/client.tsx +1 -1
  43. package/templates/solo-rpg/agent.ts +1240 -0
  44. package/templates/solo-rpg/client.tsx +698 -0
package/dist/cli.js CHANGED
@@ -133,111 +133,6 @@ var init_help = __esm({
133
133
  }
134
134
  });
135
135
 
136
- // cli/_bundler.ts
137
- import fs from "node:fs/promises";
138
- import path from "node:path";
139
- import preact from "@preact/preset-vite";
140
- import tailwindcss from "@tailwindcss/vite";
141
- import { build } from "vite";
142
- async function readDirRecursive(dir, base = dir) {
143
- const files = {};
144
- let names;
145
- try {
146
- names = await fs.readdir(dir);
147
- } catch {
148
- return files;
149
- }
150
- for (const name of names) {
151
- const full = path.join(dir, name);
152
- const stat = await fs.stat(full);
153
- const entry = { name, isDirectory: () => stat.isDirectory() };
154
- if (entry.isDirectory()) {
155
- Object.assign(files, await readDirRecursive(full, base));
156
- } else {
157
- const rel = path.relative(base, full);
158
- files[rel] = await fs.readFile(full, "utf-8");
159
- }
160
- }
161
- return files;
162
- }
163
- async function bundleAgent(agent, opts) {
164
- const aaiDir = path.join(agent.dir, ".aai");
165
- const buildDir = path.join(aaiDir, "build");
166
- const clientDir = path.join(aaiDir, "client");
167
- await fs.mkdir(aaiDir, { recursive: true });
168
- const workerEntry = path.join(aaiDir, "_worker_entry.ts");
169
- await fs.writeFile(
170
- workerEntry,
171
- [
172
- `import agent from "../agent.ts";`,
173
- `import { initWorker } from "@alexkroman1/aai/worker-shim";`,
174
- `initWorker(agent);`
175
- ].join("\n")
176
- );
177
- try {
178
- await build({
179
- configFile: false,
180
- root: agent.dir,
181
- logLevel: "warn",
182
- build: {
183
- outDir: buildDir,
184
- emptyOutDir: true,
185
- minify: true,
186
- target: "es2022",
187
- rollupOptions: {
188
- input: workerEntry,
189
- output: {
190
- format: "es",
191
- entryFileNames: "worker.js",
192
- inlineDynamicImports: true
193
- }
194
- }
195
- }
196
- });
197
- } catch (err) {
198
- throw new BundleError(err instanceof Error ? err.message : String(err));
199
- }
200
- const skipClient = opts?.skipClient || !agent.clientEntry;
201
- if (!skipClient) {
202
- try {
203
- await build({
204
- root: agent.dir,
205
- base: "./",
206
- logLevel: "warn",
207
- plugins: [preact(), tailwindcss()],
208
- build: {
209
- outDir: clientDir,
210
- emptyOutDir: true,
211
- minify: true,
212
- target: "es2022"
213
- }
214
- });
215
- } catch (err) {
216
- throw new BundleError(err instanceof Error ? err.message : String(err));
217
- }
218
- }
219
- const worker = await fs.readFile(path.join(buildDir, "worker.js"), "utf-8");
220
- const clientFiles = await readDirRecursive(clientDir);
221
- return {
222
- worker,
223
- clientFiles,
224
- clientDir,
225
- workerBytes: Buffer.byteLength(worker)
226
- };
227
- }
228
- var BundleError;
229
- var init_bundler = __esm({
230
- "cli/_bundler.ts"() {
231
- "use strict";
232
- BundleError = class extends Error {
233
- constructor(message) {
234
- super(message);
235
- this.name = "BundleError";
236
- }
237
- };
238
- }
239
- });
240
-
241
136
  // cli/_prompts.tsx
242
137
  import { ConfirmInput, PasswordInput, Select, TextInput } from "@inkjs/ui";
243
138
  import { Box, render, Text } from "ink";
@@ -325,17 +220,17 @@ __export(discover_exports, {
325
220
  writeProjectConfig: () => writeProjectConfig
326
221
  });
327
222
  import { accessSync } from "node:fs";
328
- import fs2 from "node:fs/promises";
329
- import path2 from "node:path";
223
+ import fs from "node:fs/promises";
224
+ import path from "node:path";
330
225
  import { humanId } from "human-id";
331
226
  function isDevMode() {
332
227
  const script = process.argv[1] ?? "";
333
228
  if (script.endsWith(".ts") || script.endsWith(".tsx")) return true;
334
229
  if (script.includes("/dist/") && !script.includes("node_modules")) {
335
- const dir = path2.dirname(path2.dirname(script));
230
+ const dir = path.dirname(path.dirname(script));
336
231
  try {
337
- accessSync(path2.join(dir, "sdk"));
338
- accessSync(path2.join(dir, "cli"));
232
+ accessSync(path.join(dir, "sdk"));
233
+ accessSync(path.join(dir, "cli"));
339
234
  return true;
340
235
  } catch {
341
236
  return false;
@@ -348,17 +243,17 @@ function generateSlug() {
348
243
  }
349
244
  async function readAuthConfig() {
350
245
  try {
351
- return JSON.parse(await fs2.readFile(CONFIG_FILE, "utf-8"));
246
+ return JSON.parse(await fs.readFile(CONFIG_FILE, "utf-8"));
352
247
  } catch {
353
248
  return {};
354
249
  }
355
250
  }
356
251
  async function writeAuthConfig(config) {
357
- await fs2.mkdir(CONFIG_DIR, { recursive: true });
358
- await fs2.writeFile(CONFIG_FILE, `${JSON.stringify(config, null, 2)}
252
+ await fs.mkdir(CONFIG_DIR, { recursive: true });
253
+ await fs.writeFile(CONFIG_FILE, `${JSON.stringify(config, null, 2)}
359
254
  `);
360
255
  if (process.platform !== "win32") {
361
- await fs2.chmod(CONFIG_FILE, 384);
256
+ await fs.chmod(CONFIG_FILE, 384);
362
257
  }
363
258
  }
364
259
  async function getApiKey() {
@@ -378,35 +273,35 @@ async function getApiKey() {
378
273
  }
379
274
  async function readProjectConfig(agentDir) {
380
275
  try {
381
- return JSON.parse(await fs2.readFile(path2.join(agentDir, ".aai", "project.json"), "utf-8"));
276
+ return JSON.parse(await fs.readFile(path.join(agentDir, ".aai", "project.json"), "utf-8"));
382
277
  } catch {
383
278
  return null;
384
279
  }
385
280
  }
386
281
  async function writeProjectConfig(agentDir, data) {
387
- const aaiDir = path2.join(agentDir, ".aai");
388
- await fs2.mkdir(aaiDir, { recursive: true });
389
- await fs2.writeFile(path2.join(aaiDir, "project.json"), `${JSON.stringify(data, null, 2)}
282
+ const aaiDir = path.join(agentDir, ".aai");
283
+ await fs.mkdir(aaiDir, { recursive: true });
284
+ await fs.writeFile(path.join(aaiDir, "project.json"), `${JSON.stringify(data, null, 2)}
390
285
  `);
391
286
  }
392
287
  async function fileExists(p) {
393
288
  try {
394
- await fs2.access(p);
289
+ await fs.access(p);
395
290
  return true;
396
291
  } catch {
397
292
  return false;
398
293
  }
399
294
  }
400
295
  async function loadAgent(dir) {
401
- const hasAgentTs = await fileExists(path2.join(dir, "agent.ts"));
296
+ const hasAgentTs = await fileExists(path.join(dir, "agent.ts"));
402
297
  if (!hasAgentTs) return null;
403
298
  const config = await readProjectConfig(dir);
404
299
  const slug = config?.slug ?? generateSlug();
405
- const clientEntry = await fileExists(path2.join(dir, "client.tsx")) ? path2.join(dir, "client.tsx") : "";
300
+ const clientEntry = await fileExists(path.join(dir, "client.tsx")) ? path.join(dir, "client.tsx") : "";
406
301
  return {
407
302
  slug,
408
303
  dir,
409
- entryPoint: path2.join(dir, "agent.ts"),
304
+ entryPoint: path.join(dir, "agent.ts"),
410
305
  clientEntry
411
306
  };
412
307
  }
@@ -415,12 +310,130 @@ var init_discover = __esm({
415
310
  "cli/_discover.ts"() {
416
311
  "use strict";
417
312
  init_prompts();
418
- CONFIG_DIR = path2.join(process.env.HOME ?? process.env.USERPROFILE ?? ".", ".config", "aai");
419
- CONFIG_FILE = path2.join(CONFIG_DIR, "config.json");
313
+ CONFIG_DIR = path.join(process.env.HOME ?? process.env.USERPROFILE ?? ".", ".config", "aai");
314
+ CONFIG_FILE = path.join(CONFIG_DIR, "config.json");
420
315
  DEFAULT_SERVER = "https://aai-agent.fly.dev";
421
316
  }
422
317
  });
423
318
 
319
+ // cli/_bundler.ts
320
+ import fs2 from "node:fs/promises";
321
+ import path2 from "node:path";
322
+ import preact from "@preact/preset-vite";
323
+ import tailwindcss from "@tailwindcss/vite";
324
+ import { build } from "vite";
325
+ async function readDirRecursive(dir, base = dir) {
326
+ const files = {};
327
+ let names;
328
+ try {
329
+ names = await fs2.readdir(dir);
330
+ } catch {
331
+ return files;
332
+ }
333
+ for (const name of names) {
334
+ const full = path2.join(dir, name);
335
+ const stat = await fs2.stat(full);
336
+ const entry = { name, isDirectory: () => stat.isDirectory() };
337
+ if (entry.isDirectory()) {
338
+ Object.assign(files, await readDirRecursive(full, base));
339
+ } else {
340
+ const rel = path2.relative(base, full);
341
+ files[rel] = await fs2.readFile(full, "utf-8");
342
+ }
343
+ }
344
+ return files;
345
+ }
346
+ async function bundleAgent(agent, opts) {
347
+ const aaiDir = path2.join(agent.dir, ".aai");
348
+ const buildDir = path2.join(aaiDir, "build");
349
+ const clientDir = path2.join(aaiDir, "client");
350
+ await fs2.mkdir(aaiDir, { recursive: true });
351
+ const workerEntry = path2.join(aaiDir, "_worker_entry.ts");
352
+ await fs2.writeFile(
353
+ workerEntry,
354
+ [
355
+ `import agent from "../agent.ts";`,
356
+ `import { initWorker } from "@alexkroman1/aai/worker-shim";`,
357
+ `initWorker(agent);`
358
+ ].join("\n")
359
+ );
360
+ try {
361
+ await build({
362
+ configFile: false,
363
+ root: agent.dir,
364
+ logLevel: "warn",
365
+ build: {
366
+ outDir: buildDir,
367
+ emptyOutDir: true,
368
+ minify: true,
369
+ target: "es2022",
370
+ rollupOptions: {
371
+ input: workerEntry,
372
+ output: {
373
+ format: "es",
374
+ entryFileNames: "worker.js",
375
+ inlineDynamicImports: true
376
+ }
377
+ }
378
+ }
379
+ });
380
+ } catch (err) {
381
+ throw new BundleError(err instanceof Error ? err.message : String(err));
382
+ }
383
+ const skipClient = opts?.skipClient || !agent.clientEntry;
384
+ if (!skipClient) {
385
+ const devAlias = {};
386
+ if (isDevMode()) {
387
+ const monorepoRoot = path2.resolve(import.meta.dirname ?? __dirname, "..");
388
+ devAlias["@alexkroman1/aai/ui/styles.css"] = path2.join(monorepoRoot, "ui/styles.css");
389
+ devAlias["@alexkroman1/aai/ui"] = path2.join(monorepoRoot, "ui/mod.ts");
390
+ devAlias["@alexkroman1/aai"] = path2.join(monorepoRoot, "sdk/mod.ts");
391
+ const userPreact = path2.join(agent.dir, "node_modules/preact");
392
+ const userSignals = path2.join(agent.dir, "node_modules/@preact/signals");
393
+ devAlias.preact = userPreact;
394
+ devAlias["@preact/signals"] = userSignals;
395
+ }
396
+ try {
397
+ await build({
398
+ root: agent.dir,
399
+ base: "./",
400
+ logLevel: "warn",
401
+ plugins: [preact(), tailwindcss()],
402
+ ...Object.keys(devAlias).length > 0 && { resolve: { alias: devAlias } },
403
+ build: {
404
+ outDir: clientDir,
405
+ emptyOutDir: true,
406
+ minify: true,
407
+ target: "es2022"
408
+ }
409
+ });
410
+ } catch (err) {
411
+ throw new BundleError(err instanceof Error ? err.message : String(err));
412
+ }
413
+ }
414
+ const worker = await fs2.readFile(path2.join(buildDir, "worker.js"), "utf-8");
415
+ const clientFiles = await readDirRecursive(clientDir);
416
+ return {
417
+ worker,
418
+ clientFiles,
419
+ clientDir,
420
+ workerBytes: Buffer.byteLength(worker)
421
+ };
422
+ }
423
+ var BundleError;
424
+ var init_bundler = __esm({
425
+ "cli/_bundler.ts"() {
426
+ "use strict";
427
+ init_discover();
428
+ BundleError = class extends Error {
429
+ constructor(message) {
430
+ super(message);
431
+ this.name = "BundleError";
432
+ }
433
+ };
434
+ }
435
+ });
436
+
424
437
  // cli/_ink.tsx
425
438
  import { Spinner } from "@inkjs/ui";
426
439
  import { Box as Box2, render as render2, Static, Text as Text2, useApp } from "ink";
@@ -559,7 +572,7 @@ var init_ink = __esm({
559
572
 
560
573
  // cli/_build.ts
561
574
  import React2 from "react";
562
- async function buildAgentBundle(cwd, log) {
575
+ async function buildAgentBundle(cwd, log, opts) {
563
576
  const agent = await loadAgent(cwd);
564
577
  if (!agent) {
565
578
  throw new Error("No agent found \u2014 run `aai init` first");
@@ -577,7 +590,7 @@ async function buildAgentBundle(cwd, log) {
577
590
  const kb = (bundle.workerBytes / 1024).toFixed(1);
578
591
  const clientCount = Object.keys(bundle.clientFiles).length;
579
592
  log(React2.createElement(Info, { msg: `worker: ${kb} KB, client: ${clientCount} file(s)` }));
580
- if (agent.clientEntry) {
593
+ if (agent.clientEntry && !opts?.skipRenderCheck) {
581
594
  try {
582
595
  const renderCheckPath = "../sdk/_render_check.ts";
583
596
  const { renderCheck } = await import(
@@ -2412,7 +2425,7 @@ function handleTextMessage(data, session, log, ctx, sid) {
2412
2425
  }
2413
2426
  function wireSessionSocket(ws, opts) {
2414
2427
  const { sessions, logger: log = consoleLogger } = opts;
2415
- const sessionId = crypto.randomUUID();
2428
+ const sessionId = opts.uid ?? crypto.randomUUID();
2416
2429
  const sid = sessionId.slice(0, 8);
2417
2430
  const ctx = opts.logContext ?? {};
2418
2431
  let session = null;
@@ -2462,6 +2475,7 @@ var init_ws_handler = __esm({
2462
2475
  });
2463
2476
 
2464
2477
  // sdk/winterc_server.ts
2478
+ import { Hono } from "hono";
2465
2479
  function createWintercServer(options) {
2466
2480
  const {
2467
2481
  agent,
@@ -2491,26 +2505,19 @@ function createWintercServer(options) {
2491
2505
  sampleRate: s2sConfig.inputSampleRate,
2492
2506
  ttsSampleRate: s2sConfig.outputSampleRate
2493
2507
  };
2508
+ const app = new Hono();
2509
+ app.get("/health", (c) => c.json({ status: "ok", name: agent.name }));
2510
+ app.get("/", (c) => {
2511
+ if (clientHtml) {
2512
+ return c.html(clientHtml);
2513
+ }
2514
+ return c.html(
2515
+ `<!DOCTYPE html><html><body><h1>${agent.name}</h1><p>Agent server running.</p></body></html>`
2516
+ );
2517
+ });
2494
2518
  return {
2495
2519
  async fetch(request) {
2496
- const url = new URL(request.url);
2497
- if (url.pathname === "/health") {
2498
- return new Response(JSON.stringify({ status: "ok", name: agent.name }), {
2499
- headers: { "Content-Type": "application/json" }
2500
- });
2501
- }
2502
- if (url.pathname === "/" && clientHtml) {
2503
- return new Response(clientHtml, {
2504
- headers: { "Content-Type": "text/html" }
2505
- });
2506
- }
2507
- if (url.pathname === "/") {
2508
- return new Response(
2509
- `<!DOCTYPE html><html><body><h1>${agent.name}</h1><p>Agent server running.</p></body></html>`,
2510
- { headers: { "Content-Type": "text/html" } }
2511
- );
2512
- }
2513
- return new Response("Not Found", { status: 404 });
2520
+ return app.fetch(request);
2514
2521
  },
2515
2522
  handleWebSocket(ws, wsOpts) {
2516
2523
  wireSessionSocket(ws, {
@@ -2522,7 +2529,8 @@ function createWintercServer(options) {
2522
2529
  skipGreeting: wsOpts?.skipGreeting ?? false
2523
2530
  }),
2524
2531
  readyConfig,
2525
- logger
2532
+ logger,
2533
+ uid: wsOpts?.uid
2526
2534
  });
2527
2535
  },
2528
2536
  async close() {
@@ -2550,6 +2558,9 @@ var server_exports = {};
2550
2558
  __export(server_exports, {
2551
2559
  createServer: () => createServer
2552
2560
  });
2561
+ import { serve } from "@hono/node-server";
2562
+ import { serveStatic } from "@hono/node-server/serve-static";
2563
+ import { Hono as Hono2 } from "hono";
2553
2564
  async function loadWsFactory() {
2554
2565
  try {
2555
2566
  const mod = await import("ws");
@@ -2611,18 +2622,31 @@ function createServer(options) {
2611
2622
  },
2612
2623
  async listen(port = 3e3) {
2613
2624
  await getWsFactory();
2614
- const http = await import("node:http");
2615
- const nodeServer = http.createServer(async (req, res) => {
2616
- if (clientDir && req.url) {
2617
- const served = await serveStaticFile(req.url, clientDir, res);
2618
- if (served) return;
2619
- }
2620
- await nodeHttpHandler(req, res, port, getWinterc);
2621
- });
2622
- attachWsUpgrade(nodeServer, port, getWinterc, logger);
2625
+ const wintercServer = getWinterc();
2626
+ const app = new Hono2();
2627
+ if (clientDir) {
2628
+ app.use("/*", serveStatic({ root: clientDir }));
2629
+ }
2630
+ app.all("/*", (c) => wintercServer.fetch(c.req.raw));
2631
+ const nodeServer = serve({ fetch: app.fetch, port });
2623
2632
  await new Promise((resolve) => {
2624
- nodeServer.listen(port, () => resolve());
2633
+ nodeServer.on("listening", resolve);
2625
2634
  });
2635
+ try {
2636
+ const wsMod = await import("ws");
2637
+ const wss = new wsMod.WebSocketServer({ noServer: true });
2638
+ nodeServer.on("upgrade", (req, socket, head) => {
2639
+ wss.handleUpgrade(req, socket, head, (ws) => {
2640
+ const reqUrl = new URL(req.url ?? "/", `http://localhost:${port}`);
2641
+ wintercServer.handleWebSocket(ws, {
2642
+ skipGreeting: reqUrl.searchParams.has("resume"),
2643
+ uid: reqUrl.searchParams.get("uid") ?? void 0
2644
+ });
2645
+ });
2646
+ });
2647
+ } catch {
2648
+ logger.warn("ws package not available for Node.js WebSocket upgrade");
2649
+ }
2626
2650
  serverHandle = {
2627
2651
  async shutdown() {
2628
2652
  await new Promise((resolve, reject) => {
@@ -2637,84 +2661,11 @@ function createServer(options) {
2637
2661
  }
2638
2662
  };
2639
2663
  }
2640
- async function serveStaticFile(reqUrl, clientDir, res) {
2641
- const { readFile } = await import("node:fs/promises");
2642
- const { join, extname, normalize } = await import("node:path");
2643
- const urlPath = new URL(reqUrl, "http://localhost").pathname;
2644
- const relPath = urlPath === "/" ? "index.html" : urlPath.slice(1);
2645
- const filePath = normalize(join(clientDir, relPath));
2646
- if (!filePath.startsWith(clientDir)) return false;
2647
- try {
2648
- const content = await readFile(filePath);
2649
- const ext = extname(filePath);
2650
- const contentType = MIME_TYPES[ext] ?? "application/octet-stream";
2651
- res.writeHead(200, { "Content-Type": contentType });
2652
- res.end(content);
2653
- return true;
2654
- } catch {
2655
- return false;
2656
- }
2657
- }
2658
- async function nodeHttpHandler(req, res, port, getWinterc) {
2659
- try {
2660
- const protocol = req.socket.encrypted ? "https" : "http";
2661
- const host = req.headers.host ?? `localhost:${port}`;
2662
- const url = new URL(req.url ?? "/", `${protocol}://${host}`);
2663
- const headers = new Headers();
2664
- for (const [key, val] of Object.entries(req.headers)) {
2665
- if (val) headers.set(key, Array.isArray(val) ? val[0] ?? "" : val);
2666
- }
2667
- const request = new Request(url, { method: req.method ?? "GET", headers });
2668
- const response = await getWinterc().fetch(request);
2669
- res.writeHead(response.status, Object.fromEntries(response.headers));
2670
- res.end(await response.text());
2671
- } catch (err) {
2672
- res.writeHead(500);
2673
- res.end(err instanceof Error ? err.message : "Internal Server Error");
2674
- }
2675
- }
2676
- function attachWsUpgrade(nodeServer, port, getWinterc, logger) {
2677
- import("ws").then((wsMod) => {
2678
- const WSServer = wsMod.WebSocketServer;
2679
- if (!WSServer) return;
2680
- const wss = new WSServer({ noServer: true });
2681
- nodeServer.on("upgrade", (req, socket, head) => {
2682
- wss.handleUpgrade(
2683
- req,
2684
- socket,
2685
- head,
2686
- (ws) => {
2687
- const reqUrl = new URL(
2688
- req.url ?? "/",
2689
- `http://localhost:${port}`
2690
- );
2691
- getWinterc().handleWebSocket(ws, {
2692
- skipGreeting: reqUrl.searchParams.has("resume")
2693
- });
2694
- }
2695
- );
2696
- });
2697
- }).catch(() => {
2698
- logger.warn("ws package not available for Node.js WebSocket upgrade");
2699
- });
2700
- }
2701
- var MIME_TYPES;
2702
2664
  var init_server = __esm({
2703
2665
  "sdk/server.ts"() {
2704
2666
  "use strict";
2705
2667
  init_runtime();
2706
2668
  init_winterc_server();
2707
- MIME_TYPES = {
2708
- ".html": "text/html",
2709
- ".js": "application/javascript",
2710
- ".css": "text/css",
2711
- ".json": "application/json",
2712
- ".svg": "image/svg+xml",
2713
- ".png": "image/png",
2714
- ".ico": "image/x-icon",
2715
- ".woff": "font/woff",
2716
- ".woff2": "font/woff2"
2717
- };
2718
2669
  }
2719
2670
  });
2720
2671
 
@@ -2820,7 +2771,7 @@ async function bootServer(agentDef, clientDir, env, port) {
2820
2771
 
2821
2772
  // cli/_dev.ts
2822
2773
  async function _startDevServer(cwd, port, log) {
2823
- const bundle = await buildAgentBundle(cwd, log);
2774
+ const bundle = await buildAgentBundle(cwd, log, { skipRenderCheck: true });
2824
2775
  const agentDef = await loadAgentDef(cwd);
2825
2776
  const env = await resolveServerEnv();
2826
2777
  await bootServer(agentDef, bundle.clientDir, env, port);
@@ -1 +1 @@
1
- {"version":3,"file":"_render_check.d.ts","sourceRoot":"","sources":["../../sdk/_render_check.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,wBAAsB,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAoCjF"}
1
+ {"version":3,"file":"_render_check.d.ts","sourceRoot":"","sources":["../../sdk/_render_check.ts"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AACH,wBAAsB,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAsCjF"}
@@ -1,4 +1,5 @@
1
1
  // Copyright 2025 the AAI authors. MIT license.
2
+ import preact from "@preact/preset-vite";
2
3
  import { createServer as createViteServer } from "vite";
3
4
  /**
4
5
  * Smoke-test a client.tsx by loading it via Vite SSR in a DOM-shimmed
@@ -23,6 +24,8 @@ export async function renderCheck(clientEntry, cwd) {
23
24
  const vite = await createViteServer({
24
25
  root: cwd,
25
26
  logLevel: "silent",
27
+ plugins: [preact()],
28
+ resolve: { dedupe: ["preact", "@preact/signals"] },
26
29
  server: { middlewareMode: true },
27
30
  });
28
31
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"_render_check.js","sourceRoot":"","sources":["../../sdk/_render_check.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAE/C,OAAO,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,MAAM,CAAC;AAExD;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,WAAmB,EAAE,GAAW;IAChE,wEAAwE;IACxE,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAC;IACzE,MAAM,EAAE,oBAAoB,EAAE,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,CAAC;IAE/D,cAAc,EAAE,CAAC;IAEjB,MAAM,CAAC,GAAG,UAAgD,CAAC;IAC3D,MAAM,GAAG,GAAG,IAAI,SAAS,EAAE,CAAC,eAAe,CACzC,8EAA8E,EAC9E,WAAW,CACZ,CAAC;IACF,MAAM,OAAO,GAAG,CAAC,CAAC,QAAQ,CAAC;IAC3B,MAAM,YAAY,GAAG,CAAC,CAAC,QAAQ,CAAC;IAChC,CAAC,CAAC,QAAQ,GAAG,GAAG,CAAC;IACjB,CAAC,CAAC,QAAQ,GAAG,EAAE,MAAM,EAAE,uBAAuB,EAAE,QAAQ,EAAE,GA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