@anhlp/alp-daemon 0.0.1-beta.8 → 0.0.1-beta.9

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.
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.1-beta.8",
2
+ "version": "0.0.1-beta.9",
3
3
  "entries": {
4
4
  "packages/daemon/dist/alpd.js": {
5
5
  "inputs": [
package/dist/main.js CHANGED
@@ -22,7 +22,7 @@ import { migrateState } from "@anhlp/alp-core/migrations";
22
22
  import { createLogger } from "@anhlp/alp-core/log";
23
23
  import { createModelCatalog } from "./model-catalog.js";
24
24
  import { selfCommand, selfEntry } from "@anhlp/alp-core/packaged";
25
- var VERSION = true ? "0.0.1-beta.8" : "0.0.0-dev";
25
+ var VERSION = true ? "0.0.1-beta.9" : "0.0.0-dev";
26
26
  var LOG_BYTES = 10 * 1024 * 1024;
27
27
  var LOG_FILES = 3;
28
28
  var log = createLogger({ component: "alpd" });
@@ -0,0 +1,2 @@
1
+ import './native-register.js';
2
+ import './main.js';
@@ -0,0 +1,3 @@
1
+ // packages/daemon/src/native-entry.ts
2
+ import "./native-register.js";
3
+ import "./main.js";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ // packages/daemon/src/native-register.ts
2
+ import { bundleDist, bundleInfo, registerNativeDaemon } from "@anhlp/alp-core/packaged";
3
+ if (process.argv.length === 3 && process.argv[2] === "--version") {
4
+ process.stdout.write(`${true ? "0.0.1-beta.9" : "0.0.0-dev"}
5
+ `);
6
+ process.exit(0);
7
+ }
8
+ var bundle = bundleInfo();
9
+ registerNativeDaemon({
10
+ modules: { claudeAgentSdk: () => import("@anthropic-ai/claude-agent-sdk") },
11
+ // The terminal helper (native-terminal.ts) lies in the bundle's @anhlp/alp-cli dist, not beside alpd.
12
+ distDir: () => bundle ? bundleDist(bundle) : void 0
13
+ });
@@ -9,8 +9,12 @@ var sha = (value) => createHash("sha256").update(value).digest("hex");
9
9
  function binary() {
10
10
  const libc = process.platform === "linux" ? process.report?.getReport()?.header?.glibcVersionRuntime ? "glibc" : "musl" : void 0;
11
11
  const slot = [process.platform, process.arch, libc].filter(Boolean).join("-");
12
- const adjacent = path.join(path.dirname(fileURLToPath(import.meta.url)), "terminal-native");
13
- const dir = existsSync(adjacent) ? adjacent : path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../native");
12
+ const native = globalThis[Symbol.for("alp.nativeDaemon")];
13
+ const bundled = native?.distDir?.();
14
+ if (native && !bundled) throw new Error("The native alpd runs outside an ALP bundle: no terminal helper");
15
+ const here = bundled ?? path.dirname(fileURLToPath(import.meta.url));
16
+ const adjacent = path.join(here, "terminal-native");
17
+ const dir = existsSync(adjacent) || bundled ? adjacent : path.resolve(here, "../native");
14
18
  const file = path.join(dir, "prebuilt", slot, "terminal-owner");
15
19
  const manifest = JSON.parse(readFileSync(path.join(path.dirname(file), "manifest.json"), "utf8"));
16
20
  if (!statSync(file).isFile() || manifest.protocol !== 1 || manifest.slot !== slot || manifest.source !== sha(readFileSync(path.join(dir, "terminal-owner.c"))) || manifest.sha256 !== sha(readFileSync(file))) throw new Error("Native helper manifest mismatch");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anhlp/alp-daemon",
3
- "version": "0.0.1-beta.8",
3
+ "version": "0.0.1-beta.9",
4
4
  "type": "module",
5
5
  "description": "ALP daemon module",
6
6
  "files": [
@@ -129,10 +129,10 @@
129
129
  "node": ">=22.12"
130
130
  },
131
131
  "dependencies": {
132
- "@anhlp/alp-core": "0.0.1-beta.8",
133
- "@anhlp/alp-runtime": "0.0.1-beta.8",
134
- "@anhlp/alp-client": "0.0.1-beta.8",
135
- "@anhlp/alp-protocol": "0.0.1-beta.8",
132
+ "@anhlp/alp-core": "0.0.1-beta.9",
133
+ "@anhlp/alp-runtime": "0.0.1-beta.9",
134
+ "@anhlp/alp-client": "0.0.1-beta.9",
135
+ "@anhlp/alp-protocol": "0.0.1-beta.9",
136
136
  "@anthropic-ai/sdk": "^0.131.0",
137
137
  "ws": "^8.22.0",
138
138
  "zod": "4.6.7",
@@ -0,0 +1,5 @@
1
+ // Entry of the native alpd (t-81b0.9): `bun build --compile` of this file is `<bundle>/bin/alpd`
2
+ // (scripts/build-alpd-native.mjs). The registration must load before alpd: ES modules evaluate in
3
+ // import order.
4
+ import './native-register.js';
5
+ import './main.js';
@@ -0,0 +1,21 @@
1
+ // The native alpd (t-81b0.9, scripts/build-alpd-native.mjs): registers this process as the native
2
+ // alpd before alpd's own modules load (native-entry.ts imports this first). The Claude Agent SDK is
3
+ // imported here by its literal name so the build embeds it in the executable; claude-transport.ts
4
+ // reaches it through this registration instead of its computed import.
5
+ import { bundleDist, bundleInfo, registerNativeDaemon } from '@anhlp/alp-core/packaged';
6
+
7
+ declare const __ALP_VERSION__: string;
8
+ // `alpd --version` answers before alpd loads, so install.sh, alp update and the build can check that this
9
+ // executable runs on the machine without starting a daemon.
10
+ if (process.argv.length === 3 && process.argv[2] === '--version') {
11
+ process.stdout.write(`${typeof __ALP_VERSION__ === 'string' ? __ALP_VERSION__ : '0.0.0-dev'}\n`);
12
+ process.exit(0);
13
+ }
14
+ // The bundle is read once at start: a later reinstall of the same version moves this directory aside.
15
+ const bundle = bundleInfo();
16
+
17
+ registerNativeDaemon({
18
+ modules: { claudeAgentSdk: () => import('@anthropic-ai/claude-agent-sdk') },
19
+ // The terminal helper (native-terminal.ts) lies in the bundle's @anhlp/alp-cli dist, not beside alpd.
20
+ distDir: () => bundle ? bundleDist(bundle) : undefined,
21
+ });
@@ -12,8 +12,16 @@ const sha = (value: Buffer) => createHash('sha256').update(value).digest('hex');
12
12
  function binary() {
13
13
  const libc = process.platform === 'linux' ? (process.report?.getReport() as { header?: { glibcVersionRuntime?: string } })?.header?.glibcVersionRuntime ? 'glibc' : 'musl' : undefined;
14
14
  const slot = [process.platform, process.arch, libc].filter(Boolean).join('-');
15
- const adjacent = path.join(path.dirname(fileURLToPath(import.meta.url)), 'terminal-native');
16
- const dir = existsSync(adjacent) ? adjacent : path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../native');
15
+ // The native alpd (t-81b0.9) has no directory of its own (import.meta.url is inside its executable):
16
+ // it uses the helper in its bundle's @anhlp/alp-cli dist; outside a bundle it has none.
17
+ // This file stays self-contained (it is shipped and tested on its own), so it reads the native alpd's
18
+ // registration (@anhlp/alp-core/packaged, native-register.ts) from its global directly.
19
+ const native = (globalThis as { [key: symbol]: { distDir?: () => string | undefined } | undefined })[Symbol.for('alp.nativeDaemon')];
20
+ const bundled = native?.distDir?.();
21
+ if (native && !bundled) throw new Error('The native alpd runs outside an ALP bundle: no terminal helper');
22
+ const here = bundled ?? path.dirname(fileURLToPath(import.meta.url));
23
+ const adjacent = path.join(here, 'terminal-native');
24
+ const dir = existsSync(adjacent) || bundled ? adjacent : path.resolve(here, '../native');
17
25
  const file = path.join(dir, 'prebuilt', slot, 'terminal-owner');
18
26
  const manifest = JSON.parse(readFileSync(path.join(path.dirname(file), 'manifest.json'), 'utf8'));
19
27
  if (!statSync(file).isFile() || manifest.protocol !== 1 || manifest.slot !== slot || manifest.source !== sha(readFileSync(path.join(dir, 'terminal-owner.c'))) || manifest.sha256 !== sha(readFileSync(file))) throw new Error('Native helper manifest mismatch');