linkzero 0.1.0 → 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.
Files changed (2) hide show
  1. package/dist/cli.js +24 -12
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -30,33 +30,45 @@ async function dispatchHandler(command, payload, timeout) {
30
30
  stdio: ["pipe", "pipe", "pipe"],
31
31
  shell: true
32
32
  });
33
- let stdout = "";
33
+ const chunks = [];
34
34
  let stderr = "";
35
+ let stdoutDone = false;
36
+ let exitCode = null;
35
37
  const timer = setTimeout(() => {
36
38
  child.kill("SIGKILL");
37
39
  reject(new Error(`Handler timed out after ${timeout}ms`));
38
40
  }, timeout);
41
+ function tryFinish() {
42
+ if (!stdoutDone || exitCode === null) return;
43
+ clearTimeout(timer);
44
+ const stdout = Buffer.concat(chunks).toString();
45
+ if (exitCode !== 0) {
46
+ reject(new Error(`Handler exited with code ${exitCode}: ${stderr.trim()}`));
47
+ return;
48
+ }
49
+ try {
50
+ resolve(JSON.parse(stdout));
51
+ } catch {
52
+ reject(new Error(`Handler returned invalid JSON: ${stdout.slice(0, 200)}`));
53
+ }
54
+ }
39
55
  child.stdout.on("data", (data) => {
40
- stdout += data.toString();
56
+ chunks.push(data);
41
57
  });
42
58
  child.stderr.on("data", (data) => {
43
59
  stderr += data.toString();
44
60
  });
61
+ child.stdout.on("end", () => {
62
+ stdoutDone = true;
63
+ tryFinish();
64
+ });
45
65
  child.on("error", (err) => {
46
66
  clearTimeout(timer);
47
67
  reject(new Error(`Handler failed to start: ${err.message}`));
48
68
  });
49
69
  child.on("close", (code) => {
50
- clearTimeout(timer);
51
- if (code !== 0) {
52
- reject(new Error(`Handler exited with code ${code}: ${stderr.trim()}`));
53
- return;
54
- }
55
- try {
56
- resolve(JSON.parse(stdout));
57
- } catch {
58
- reject(new Error(`Handler returned invalid JSON: ${stdout.slice(0, 200)}`));
59
- }
70
+ exitCode = code;
71
+ tryFinish();
60
72
  });
61
73
  child.stdin.write(JSON.stringify(payload));
62
74
  child.stdin.end();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "linkzero",
3
- "version": "0.1.0",
4
- "description": "CLI for LinkZero - the professional network for AI agents",
3
+ "version": "0.1.2",
4
+ "description": "CLI for LinkZero - real-time marketplace for AI agent capabilities",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "linkzero": "./dist/cli.js",