gencow 0.1.51 → 0.1.53

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/bin/gencow.mjs CHANGED
@@ -296,8 +296,16 @@ process.exit(0);
296
296
  info("Generating api.ts...");
297
297
  try {
298
298
  writeFileSync(extractTsPath, script);
299
- // Run bun to evaluate it and get the JSON out
300
- const outStr = execSync(`bun .gencow-extract.ts`, {
299
+
300
+ // Detect available TypeScript runtime: bun npx tsx
301
+ let tsRunner = "bun";
302
+ try { execSync("bun --version", { stdio: "ignore" }); }
303
+ catch {
304
+ try { execSync("npx tsx --version", { stdio: "ignore" }); tsRunner = "npx tsx"; }
305
+ catch { throw new Error("bun 또는 tsx가 필요합니다. npm i -g tsx 로 설치하세요."); }
306
+ }
307
+
308
+ const outStr = execSync(`${tsRunner} .gencow-extract.ts`, {
301
309
  cwd: serverRoot,
302
310
  stdio: ["pipe", "pipe", "ignore"]
303
311
  }).toString();
@@ -2797,7 +2805,7 @@ process.exit(0);
2797
2805
 
2798
2806
  async function connectLogStream() {
2799
2807
  const { WebSocket: WS } = await import("ws");
2800
- const wsUrl = `wss://${appName}.gencow.app/_admin/ws`;
2808
+ const wsUrl = `wss://${appName}.gencow.app/ws`;
2801
2809
 
2802
2810
  try {
2803
2811
  logWs = new WS(wsUrl);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gencow",
3
- "version": "0.1.51",
3
+ "version": "0.1.53",
4
4
  "description": "Gencow — AI Backend Engine",
5
5
  "type": "module",
6
6
  "bin": {
package/server/index.js CHANGED
@@ -71810,8 +71810,70 @@ var RuntimeBuffer = class {
71810
71810
  };
71811
71811
  var runtimeBuffer = new RuntimeBuffer();
71812
71812
  var wsTimers = /* @__PURE__ */ new WeakMap();
71813
+ var wsProxyBackends = /* @__PURE__ */ new WeakMap();
71814
+ var bunServer = null;
71813
71815
  var app = new Hono2();
71814
- var { upgradeWebSocket: upgradeWebSocket2, websocket: websocket2 } = createBunWebSocket();
71816
+ var { upgradeWebSocket: upgradeWebSocket2, websocket: baseWebsocket } = createBunWebSocket();
71817
+ var websocket2 = {
71818
+ ...baseWebsocket,
71819
+ open(ws) {
71820
+ if (ws.data?.proxyPort) {
71821
+ const targetUrl = `ws://127.0.0.1:${ws.data.proxyPort}${ws.data.proxyPath || "/ws"}`;
71822
+ try {
71823
+ const backend = new WebSocket(targetUrl);
71824
+ wsProxyBackends.set(ws, backend);
71825
+ backend.addEventListener("open", () => {
71826
+ });
71827
+ backend.addEventListener("message", (evt) => {
71828
+ try {
71829
+ ws.send(typeof evt.data === "string" ? evt.data : evt.data);
71830
+ } catch {
71831
+ }
71832
+ });
71833
+ backend.addEventListener("close", () => {
71834
+ try {
71835
+ ws.close();
71836
+ } catch {
71837
+ }
71838
+ wsProxyBackends.delete(ws);
71839
+ });
71840
+ backend.addEventListener("error", () => {
71841
+ try {
71842
+ ws.close();
71843
+ } catch {
71844
+ }
71845
+ wsProxyBackends.delete(ws);
71846
+ });
71847
+ } catch {
71848
+ ws.close();
71849
+ }
71850
+ return;
71851
+ }
71852
+ baseWebsocket.open?.(ws);
71853
+ },
71854
+ message(ws, msg) {
71855
+ const backend = wsProxyBackends.get(ws);
71856
+ if (backend) {
71857
+ if (backend.readyState === WebSocket.OPEN) {
71858
+ backend.send(typeof msg === "string" ? msg : msg);
71859
+ }
71860
+ return;
71861
+ }
71862
+ baseWebsocket.message?.(ws, msg);
71863
+ },
71864
+ close(ws, code, reason) {
71865
+ const backend = wsProxyBackends.get(ws);
71866
+ if (backend) {
71867
+ try {
71868
+ backend.close();
71869
+ } catch {
71870
+ }
71871
+ wsProxyBackends.delete(ws);
71872
+ return;
71873
+ }
71874
+ baseWebsocket.close?.(ws, code, reason);
71875
+ }
71876
+ };
71815
71877
  app.use("*", cors({
71816
71878
  origin: (origin) => {
71817
71879
  if (!origin || origin.startsWith("http://localhost")) return origin;
@@ -71927,6 +71989,16 @@ async function main() {
71927
71989
  const pathname = url3.pathname;
71928
71990
  const hasBackend = appRow.status === "running";
71929
71991
  const hasStatic = !!appRow.staticDeployedAt;
71992
+ const upgradeHeader = (c.req.header("upgrade") || "").toLowerCase();
71993
+ if (upgradeHeader === "websocket" && bunServer) {
71994
+ const upgraded = bunServer.upgrade(c.req.raw, {
71995
+ data: { proxyPort: appPort, proxyPath: pathname }
71996
+ });
71997
+ if (upgraded) {
71998
+ return new Response(null, { status: 101 });
71999
+ }
72000
+ return c.json({ error: "WebSocket upgrade failed" }, 500);
72001
+ }
71930
72002
  if (hasStatic && hasBackend) {
71931
72003
  const isApiRoute = /^\/(api|platform|internal|_admin|ws)\b/.test(pathname);
71932
72004
  if (isApiRoute) {
@@ -72387,6 +72459,7 @@ async function main() {
72387
72459
  fetch: app.fetch,
72388
72460
  websocket: websocket2
72389
72461
  });
72462
+ bunServer = server;
72390
72463
  const apiUrl = `http://localhost:${port}`;
72391
72464
  const wsUrl = `ws://localhost:${port}/ws`;
72392
72465
  const stackStr = `Bun + Hono + Drizzle + ${driver === "postgres" ? "PostgreSQL" : "PGlite"}`;