@borgee/agents-host 0.1.7 → 0.1.8

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/dist/cli.d.ts CHANGED
@@ -10,5 +10,10 @@ export interface CliDeps {
10
10
  generateLocalConfig?: typeof generateLocalConfig;
11
11
  readStdin?: () => Promise<string>;
12
12
  }
13
+ interface CliEntrypointDeps {
14
+ realpath?: (path: string) => string;
15
+ }
13
16
  export declare function dispatchCli(argv: string[], deps?: Omit<CliDeps, 'logger'>): Promise<void>;
14
17
  export declare function main(argv?: string[], deps?: CliDeps): Promise<number>;
18
+ export declare function isCliEntrypoint(importMetaUrl: string, argv1?: string | undefined, deps?: CliEntrypointDeps): boolean;
19
+ export {};
package/dist/cli.js CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ import { realpathSync } from 'node:fs';
2
3
  import { resolve } from 'node:path';
3
4
  import { fileURLToPath } from 'node:url';
4
5
  import { CliUsageError, parseDescribeArgs, parseGenerateConfigArgs, parsePrintLayoutArgs, parseStartArgs, parseValidateArgs, USAGE, } from './cli-args.js';
@@ -87,11 +88,27 @@ export async function main(argv = process.argv.slice(2), deps = {}) {
87
88
  return 1;
88
89
  }
89
90
  }
90
- function isCliEntrypoint(importMetaUrl, argv1 = process.argv[1]) {
91
+ function safeRealpath(path, realpath) {
92
+ try {
93
+ return realpath(path);
94
+ }
95
+ catch {
96
+ return null;
97
+ }
98
+ }
99
+ export function isCliEntrypoint(importMetaUrl, argv1 = process.argv[1], deps = {}) {
91
100
  if (!argv1) {
92
101
  return false;
93
102
  }
94
- return fileURLToPath(importMetaUrl) === resolve(argv1);
103
+ const importMetaPath = fileURLToPath(importMetaUrl);
104
+ const argvPath = resolve(argv1);
105
+ if (importMetaPath === argvPath) {
106
+ return true;
107
+ }
108
+ const realpath = deps.realpath ?? realpathSync.native;
109
+ const importMetaRealpath = safeRealpath(importMetaPath, realpath);
110
+ const argvRealpath = safeRealpath(argvPath, realpath);
111
+ return importMetaRealpath !== null && importMetaRealpath === argvRealpath;
95
112
  }
96
113
  if (isCliEntrypoint(import.meta.url)) {
97
114
  void main().then((exitCode) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@borgee/agents-host",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"