alchemylab-opencode 1.0.16 → 1.0.17
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/serve.js +4 -0
- package/dist/serve.js.map +2 -2
- package/package.json +1 -1
package/dist/serve.js
CHANGED
|
@@ -11,8 +11,12 @@ if (typeof globalThis.__export === 'undefined') { globalThis.__export = (t, a) =
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
// packages/opencode/src/serve.ts
|
|
14
|
+
import { Agent, setGlobalDispatcher } from "undici";
|
|
14
15
|
import { homedir } from "node:os";
|
|
15
16
|
import { join } from "node:path";
|
|
17
|
+
setGlobalDispatcher(new Agent({
|
|
18
|
+
connect: { keepAlive: true, keepAliveInitialDelay: 5e3 }
|
|
19
|
+
}));
|
|
16
20
|
function arg(name, fallback) {
|
|
17
21
|
const idx = process.argv.indexOf(`--${name}`);
|
|
18
22
|
return idx !== -1 && process.argv[idx + 1] ? process.argv[idx + 1] : fallback;
|
package/dist/serve.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../packages/opencode/src/serve.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Minimal Node.js-compatible entry point for `opencode serve`.\n * Only imports the serve path \u2014 avoids TUI/CLI dependencies that require Bun.\n *\n * Usage:\n * node --experimental-strip-types --experimental-transform-types \\\n * --import ./src/node-preload.mjs \\\n * src/serve.ts --port 4096 [--hostname 127.0.0.1] [--data-dir /path/to/.alchemy_lab]\n */\n\nfunction arg(name: string, fallback: string): string {\n const idx = process.argv.indexOf(`--${name}`)\n return idx !== -1 && process.argv[idx + 1] ? process.argv[idx + 1] : fallback\n}\n\n// Set data directory before any module imports Global.Path\nimport { homedir } from 'node:os'\nimport { join } from 'node:path'\nconst defaultDataDir = join(homedir(), '.alchemy_lab', 'opencode')\nconst dataDir = arg('data-dir', defaultDataDir)\nprocess.env.OPENCODE_DATA_DIR = dataDir\n\n// Now safe to import the server\nconst { Server } = await import(\"./server/server\")\n\nconst port = parseInt(arg('port', '4096'), 10)\nconst hostname = arg('hostname', '127.0.0.1')\n\ntry {\n const server = await Server.listen({ port, hostname })\n console.log(`opencode server listening on http://${server.hostname}:${server.port}`)\n\n const shutdown = async () => {\n await server.stop(true)\n process.exit(0)\n }\n process.on('SIGINT', shutdown)\n process.on('SIGTERM', shutdown)\n\n // Keep process alive\n await new Promise(() => {})\n} catch (err) {\n console.error('Failed to start server:', err)\n process.exit(1)\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;AAgBA,SAAS,eAAe;AACxB,SAAS,YAAY;
|
|
4
|
+
"sourcesContent": ["/**\n * Minimal Node.js-compatible entry point for `opencode serve`.\n * Only imports the serve path \u2014 avoids TUI/CLI dependencies that require Bun.\n *\n * Usage:\n * node --experimental-strip-types --experimental-transform-types \\\n * --import ./src/node-preload.mjs \\\n * src/serve.ts --port 4096 [--hostname 127.0.0.1] [--data-dir /path/to/.alchemy_lab]\n */\n\n// Enable TCP keepalive on every outgoing fetch so reasoning-model silences\n// don't let NAT / provider-edge / ISP equipment quietly drop the socket\n// (see req009613/req009614: 'agents stop writing' after 60-90s of think-phase silence).\n// Done in serve.ts (not just node-preload.mjs) because build.mjs bundles polyfills\n// from a banner string and never reads node-preload.mjs \u2014 dist/serve.js needs the\n// dispatcher inside the bundled source.\nimport { Agent, setGlobalDispatcher } from 'undici'\nsetGlobalDispatcher(new Agent({\n connect: { keepAlive: true, keepAliveInitialDelay: 5000 },\n}))\n\nfunction arg(name: string, fallback: string): string {\n const idx = process.argv.indexOf(`--${name}`)\n return idx !== -1 && process.argv[idx + 1] ? process.argv[idx + 1] : fallback\n}\n\n// Set data directory before any module imports Global.Path\nimport { homedir } from 'node:os'\nimport { join } from 'node:path'\nconst defaultDataDir = join(homedir(), '.alchemy_lab', 'opencode')\nconst dataDir = arg('data-dir', defaultDataDir)\nprocess.env.OPENCODE_DATA_DIR = dataDir\n\n// Now safe to import the server\nconst { Server } = await import(\"./server/server\")\n\nconst port = parseInt(arg('port', '4096'), 10)\nconst hostname = arg('hostname', '127.0.0.1')\n\ntry {\n const server = await Server.listen({ port, hostname })\n console.log(`opencode server listening on http://${server.hostname}:${server.port}`)\n\n const shutdown = async () => {\n await server.stop(true)\n process.exit(0)\n }\n process.on('SIGINT', shutdown)\n process.on('SIGTERM', shutdown)\n\n // Keep process alive\n await new Promise(() => {})\n} catch (err) {\n console.error('Failed to start server:', err)\n process.exit(1)\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;AAgBA,SAAS,OAAO,2BAA2B;AAW3C,SAAS,eAAe;AACxB,SAAS,YAAY;AAXrB,oBAAoB,IAAI,MAAM;AAAA,EAC5B,SAAS,EAAE,WAAW,MAAM,uBAAuB,IAAK;AAC1D,CAAC,CAAC;AAEF,SAAS,IAAI,MAAc,UAA0B;AACnD,QAAM,MAAM,QAAQ,KAAK,QAAQ,KAAK,IAAI,EAAE;AAC5C,SAAO,QAAQ,MAAM,QAAQ,KAAK,MAAM,CAAC,IAAI,QAAQ,KAAK,MAAM,CAAC,IAAI;AACvE;AAKA,IAAM,iBAAiB,KAAK,QAAQ,GAAG,gBAAgB,UAAU;AACjE,IAAM,UAAU,IAAI,YAAY,cAAc;AAC9C,QAAQ,IAAI,oBAAoB;AAGhC,IAAM,EAAE,OAAO,IAAI,MAAM,OAAO,sBAAiB;AAEjD,IAAM,OAAO,SAAS,IAAI,QAAQ,MAAM,GAAG,EAAE;AAC7C,IAAM,WAAW,IAAI,YAAY,WAAW;AAE5C,IAAI;AACF,QAAM,SAAS,MAAM,OAAO,OAAO,EAAE,MAAM,SAAS,CAAC;AACrD,UAAQ,IAAI,uCAAuC,OAAO,QAAQ,IAAI,OAAO,IAAI,EAAE;AAEnF,QAAM,WAAW,YAAY;AAC3B,UAAM,OAAO,KAAK,IAAI;AACtB,YAAQ,KAAK,CAAC;AAAA,EAChB;AACA,UAAQ,GAAG,UAAU,QAAQ;AAC7B,UAAQ,GAAG,WAAW,QAAQ;AAG9B,QAAM,IAAI,QAAQ,MAAM;AAAA,EAAC,CAAC;AAC5B,SAAS,KAAK;AACZ,UAAQ,MAAM,2BAA2B,GAAG;AAC5C,UAAQ,KAAK,CAAC;AAChB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|