@link-assistant/agent 0.8.19 → 0.8.20

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@link-assistant/agent",
3
- "version": "0.8.19",
3
+ "version": "0.8.20",
4
4
  "description": "A minimal, public domain AI CLI agent compatible with OpenCode's JSON interface. Bun-only runtime.",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -0,0 +1,41 @@
1
+ import { platform } from 'os';
2
+ import { dlopen, FFIType, ptr } from 'bun:ffi';
3
+
4
+ /**
5
+ * Set the process name visible in system monitoring tools (top, ps, htop, etc.).
6
+ *
7
+ * Bun does not implement the process.title setter (unlike Node.js), so we use
8
+ * platform-specific system calls via Bun's FFI:
9
+ * - Linux: prctl(PR_SET_NAME, name) sets /proc/<pid>/comm
10
+ * - macOS: relies on the binary/symlink name (set by `bun install -g`)
11
+ * - Windows: no-op (Task Manager shows the executable name)
12
+ */
13
+ export function setProcessName(name: string): void {
14
+ // Set in-process values for any JS code that checks them
15
+ process.title = name;
16
+ process.argv0 = name;
17
+
18
+ const os = platform();
19
+
20
+ if (os === 'linux') {
21
+ try {
22
+ const PR_SET_NAME = 15;
23
+ const libc = dlopen('libc.so.6', {
24
+ prctl: {
25
+ args: [FFIType.i32, FFIType.ptr],
26
+ returns: FFIType.i32,
27
+ },
28
+ });
29
+ // PR_SET_NAME accepts up to 16 bytes including the null terminator
30
+ const buf = Buffer.from(name.slice(0, 15) + '\0');
31
+ libc.symbols.prctl(PR_SET_NAME, ptr(buf));
32
+ libc.close();
33
+ } catch (_e) {
34
+ // Silently ignore - process name is cosmetic
35
+ }
36
+ }
37
+ // macOS: no userspace API changes the process comm shown in ps/top.
38
+ // When installed via `bun install -g`, the symlink is named 'agent',
39
+ // so macOS will already show 'agent' in ps/top.
40
+ // Windows: Task Manager always shows the executable name.
41
+ }
package/src/index.js CHANGED
@@ -1,9 +1,8 @@
1
1
  #!/usr/bin/env bun
2
2
 
3
- // Set process title to 'agent' so it appears correctly in process monitoring tools like top/ps
4
- // Both process.title and process.argv0 need to be set for maximum compatibility
5
- process.title = 'agent';
6
- process.argv0 = 'agent';
3
+ import { setProcessName } from './cli/process-name.ts';
4
+
5
+ setProcessName('agent');
7
6
 
8
7
  import { Server } from './server/server.ts';
9
8
  import { Instance } from './project/instance.ts';