@agfpd/iapeer 0.2.66 → 0.2.67

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": "@agfpd/iapeer",
3
- "version": "0.2.66",
3
+ "version": "0.2.67",
4
4
  "description": "Foundation core for the iapeer multi-agent ecosystem: identity, registry, storage, codec.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -76,13 +76,15 @@ export interface StartDaemonResult {
76
76
  * re-invoke the installed binary through its `supervisor` verb instead. The caller appends
77
77
  * `daemon <session> <runtime> --run-dir <dir>`, so runSupervisorCli is reached either way.
78
78
  */
79
- export function resolveDaemonSelfArgv(execPath: string, selfPath: string, selfOnDisk: boolean): string[] {
80
- return selfOnDisk ? [execPath, selfPath] : [execPath, 'supervisor']
81
- }
82
- const selfArgv = (): string[] => {
83
- const self = fileURLToPath(import.meta.url)
84
- return resolveDaemonSelfArgv(process.execPath, self, existsSync(self))
79
+ export function resolveDaemonSelfArgv(execPath: string, selfPath: string): string[] {
80
+ // A `bun build --compile` standalone embeds this module at a `/$bunfs/root/…` virtual path
81
+ // (verified: import.meta.url → file:///$bunfs/root/…). `existsSync` is NO discriminator — Bun
82
+ // intercepts bunfs reads so it is true for BOTH src and compiled. The `$bunfs` marker in the self
83
+ // path IS the discriminator: compiled → re-invoke the installed binary through its `supervisor` verb
84
+ // (the caller appends `daemon …`); source → a real on-disk file, run it directly via the runtime.
85
+ return selfPath.includes('$bunfs') ? [execPath, 'supervisor'] : [execPath, selfPath]
85
86
  }
87
+ const selfArgv = (): string[] => resolveDaemonSelfArgv(process.execPath, fileURLToPath(import.meta.url))
86
88
 
87
89
  /** Start a detached supervisor daemon and wait until its socket is live. Idempotent. */
88
90
  export function startSupervisorDaemon(opts: StartDaemonOptions): StartDaemonResult {
@@ -7,15 +7,16 @@ import { describe, expect, test } from 'bun:test'
7
7
  import { resolveDaemonSelfArgv } from './index.ts'
8
8
 
9
9
  describe('resolveDaemonSelfArgv', () => {
10
- test('source (self on disk) → re-run the module directly with the runtime (bun)', () => {
11
- expect(resolveDaemonSelfArgv('/opt/homebrew/bin/bun', '/Users/x/iapeer/src/supervisor/index.ts', true))
12
- .toEqual(['/opt/homebrew/bin/bun', '/Users/x/iapeer/src/supervisor/index.ts'])
10
+ // Paths are the EMPIRICALLY-verified shapes: bun → real /private/... file; compiled → /$bunfs/root/...
11
+ test('source (real on-disk module) → re-run the module directly via the runtime (bun)', () => {
12
+ expect(resolveDaemonSelfArgv('/Users/x/.bun/bin/bun', '/Users/x/iapeer/src/supervisor/index.ts'))
13
+ .toEqual(['/Users/x/.bun/bin/bun', '/Users/x/iapeer/src/supervisor/index.ts'])
13
14
  })
14
15
 
15
- test('compiled standalone (self NOT on disk = embedded /$bunfs) → installed binary + `supervisor` verb', () => {
16
- expect(resolveDaemonSelfArgv('/Users/x/.local/bin/iapeer', '/$bunfs/root/src/supervisor/index.ts', false))
16
+ test('compiled standalone (embedded /$bunfs path) → installed binary + `supervisor` verb', () => {
17
+ expect(resolveDaemonSelfArgv('/Users/x/.local/bin/iapeer', '/$bunfs/root/src/supervisor/index.ts'))
17
18
  .toEqual(['/Users/x/.local/bin/iapeer', 'supervisor'])
18
19
  // The caller appends `daemon <session> <runtime> --run-dir <dir>` → `iapeer supervisor daemon …`,
19
- // which the CLI routes to runSupervisorCli('daemon', …). NOT a bare bunfs-path (→ usage).
20
+ // which the CLI routes to runSupervisorCli('daemon', …). NOT a bare bunfs-path (→ usage dump).
20
21
  })
21
22
  })