brainchain-worker-phala 0.1.1 → 0.1.2

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/agent.mjs CHANGED
@@ -12,7 +12,8 @@ import { answerOf, DEFAULT_BASE, DEFAULT_MODEL, unmet } from "./lib.mjs";
12
12
 
13
13
  const base = process.env.PHALA_AI_BASE || DEFAULT_BASE;
14
14
  const model = process.env.MODEL || DEFAULT_MODEL;
15
- const maxTokens = Number(process.env.MAX_TOKENS || 8000);
15
+ const asked = Number(process.env.MAX_TOKENS);
16
+ const maxTokens = Number.isInteger(asked) && asked > 0 ? asked : 8000;
16
17
 
17
18
  const prompt = await text(process.stdin);
18
19
  const aci = await connectAci({ baseURL: base });
@@ -22,7 +22,7 @@ services:
22
22
  command:
23
23
  - sh
24
24
  - -c
25
- - npm install --prefix /app --no-audit --no-fund --omit=dev --no-package-lock brainchain-worker-phala@0.1.1 && exec node /app/node_modules/brainchain-worker-phala/start.mjs
25
+ - npm install --prefix /app --no-audit --no-fund --omit=dev --no-package-lock brainchain-worker-phala@0.1.2 && exec node /app/node_modules/brainchain-worker-phala/start.mjs
26
26
 
27
27
  volumes:
28
28
  worker-data:
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "brainchain-worker-phala",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "brainchain-worker-phala",
9
- "version": "0.1.1",
9
+ "version": "0.1.2",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@phala/aci-verifier": "0.11.1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brainchain-worker-phala",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Run a BrainChain worker in a Phala Cloud enclave: a key that never leaves the enclave, and every task answered through Phala's confidential AI with its enclave receipt checked.",
5
5
  "license": "MIT",
6
6
  "author": "BrainChain",
@@ -32,7 +32,7 @@
32
32
  "node": ">=22.12"
33
33
  },
34
34
  "scripts": {
35
- "test": "node --test"
35
+ "test": "node --test lib-tests.mjs"
36
36
  },
37
37
  "dependencies": {
38
38
  "@phala/aci-verifier": "0.11.1",
package/start.mjs CHANGED
@@ -55,7 +55,8 @@ function run(args) {
55
55
  stdio: ["ignore", "inherit", "inherit"],
56
56
  env: { ...process.env, BRAINCHAIN_NETWORK: s.network, BRAINCHAIN_WORKER_KEY_FILE: fifo },
57
57
  });
58
- const exited = new Promise((resolve) => child.on("exit", (code, signal) => resolve(code ?? (signal ? 1 : 0))));
58
+ // A stop forwarded to the worker is a clean end, not a failure for the container's restart policy.
59
+ const exited = new Promise((resolve) => child.on("exit", (code, signal) => resolve(code ?? (signal === "SIGTERM" || signal === "SIGINT" ? 0 : 1))));
59
60
  // Opening the write end waits for the worker to open the read end. A worker that exits first never will, so the
60
61
  // read end is opened here, which lets the write go into a pipe nobody reads, and the FIFO is removed either way.
61
62
  const handed = open(fifo, "w").then(async (fd) => {