@paybond/kit 0.9.5 → 0.9.6

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/init.js CHANGED
@@ -281,15 +281,41 @@ export async function main(argv = process.argv.slice(2)) {
281
281
  function normalizeFileURL(url) {
282
282
  return url.startsWith("file:///var/") ? url.replace("file:///var/", "file:///private/var/") : url;
283
283
  }
284
- function invokedFromCLI() {
285
- const invokedPath = process.argv[1] ? normalizeFileURL(new URL("file://" + process.argv[1]).href) : "";
286
- return Boolean(invokedPath && normalizeFileURL(import.meta.url) === invokedPath);
284
+ async function invokedFromCLI() {
285
+ const scriptPath = process.argv[1];
286
+ if (!scriptPath) {
287
+ return false;
288
+ }
289
+ // @ts-ignore Node builtins are available in the published CLI runtime.
290
+ const fs = (await import("node:fs/promises"));
291
+ // @ts-ignore Node builtins are available in the published CLI runtime.
292
+ const path = (await import("node:path"));
293
+ // @ts-ignore Node builtins are available in the published CLI runtime.
294
+ const url = (await import("node:url"));
295
+ async function realFileURL(filePath) {
296
+ let resolved = path.resolve(filePath);
297
+ try {
298
+ resolved = await fs.realpath(resolved);
299
+ }
300
+ catch {
301
+ // If realpath fails, compare the absolute path. This keeps direct execution
302
+ // working even when the script path disappears during process startup.
303
+ }
304
+ return normalizeFileURL(url.pathToFileURL(resolved).href);
305
+ }
306
+ return (await realFileURL(scriptPath)) === (await realFileURL(url.fileURLToPath(import.meta.url)));
287
307
  }
288
- if (invokedFromCLI()) {
308
+ invokedFromCLI().then((invoked) => {
309
+ if (!invoked) {
310
+ return;
311
+ }
289
312
  main().then((code) => {
290
313
  process.exitCode = code;
291
314
  }, (err) => {
292
315
  process.stderr.write(`${err instanceof Error ? err.message : String(err)}\n`);
293
316
  process.exitCode = 1;
294
317
  });
295
- }
318
+ }, (err) => {
319
+ process.stderr.write(`${err instanceof Error ? err.message : String(err)}\n`);
320
+ process.exitCode = 1;
321
+ });
package/dist/login.js CHANGED
@@ -440,15 +440,41 @@ export async function main(argv = process.argv.slice(2), deps = {}) {
440
440
  function normalizeFileURL(url) {
441
441
  return url.startsWith("file:///var/") ? url.replace("file:///var/", "file:///private/var/") : url;
442
442
  }
443
- function invokedFromCLI() {
444
- const invokedPath = process.argv[1] ? normalizeFileURL(new URL("file://" + process.argv[1]).href) : "";
445
- return Boolean(invokedPath && normalizeFileURL(import.meta.url) === invokedPath);
443
+ async function invokedFromCLI() {
444
+ const scriptPath = process.argv[1];
445
+ if (!scriptPath) {
446
+ return false;
447
+ }
448
+ // @ts-ignore Node builtins are available in the published CLI runtime.
449
+ const fs = (await import("node:fs/promises"));
450
+ // @ts-ignore Node builtins are available in the published CLI runtime.
451
+ const path = (await import("node:path"));
452
+ // @ts-ignore Node builtins are available in the published CLI runtime.
453
+ const url = (await import("node:url"));
454
+ async function realFileURL(filePath) {
455
+ let resolved = path.resolve(filePath);
456
+ try {
457
+ resolved = await fs.realpath(resolved);
458
+ }
459
+ catch {
460
+ // If realpath fails, compare the absolute path. This keeps direct execution
461
+ // working even when the script path disappears during process startup.
462
+ }
463
+ return normalizeFileURL(url.pathToFileURL(resolved).href);
464
+ }
465
+ return (await realFileURL(scriptPath)) === (await realFileURL(url.fileURLToPath(import.meta.url)));
446
466
  }
447
- if (invokedFromCLI()) {
467
+ invokedFromCLI().then((invoked) => {
468
+ if (!invoked) {
469
+ return;
470
+ }
448
471
  main().then((code) => {
449
472
  process.exitCode = code;
450
473
  }, (err) => {
451
474
  process.stderr.write(`${err instanceof Error ? err.message : String(err)}\n`);
452
475
  process.exitCode = 1;
453
476
  });
454
- }
477
+ }, (err) => {
478
+ process.stderr.write(`${err instanceof Error ? err.message : String(err)}\n`);
479
+ process.exitCode = 1;
480
+ });
@@ -1049,18 +1049,35 @@ function formatError(err) {
1049
1049
  function normalizeFileURL(url) {
1050
1050
  return url.startsWith("file:///var/") ? url.replace("file:///var/", "file:///private/var/") : url;
1051
1051
  }
1052
- const isMainModule = (() => {
1052
+ async function invokedFromCLI() {
1053
1053
  const scriptPath = process.argv[1];
1054
1054
  if (!scriptPath) {
1055
1055
  return false;
1056
1056
  }
1057
- try {
1058
- return normalizeFileURL(import.meta.url) === normalizeFileURL(new URL("file://" + scriptPath).href);
1057
+ // @ts-ignore Node builtins are available in the published CLI runtime.
1058
+ const fs = (await import("node:fs/promises"));
1059
+ // @ts-ignore Node builtins are available in the published CLI runtime.
1060
+ const path = (await import("node:path"));
1061
+ // @ts-ignore Node builtins are available in the published CLI runtime.
1062
+ const url = (await import("node:url"));
1063
+ async function realFileURL(filePath) {
1064
+ let resolved = path.resolve(filePath);
1065
+ try {
1066
+ resolved = await fs.realpath(resolved);
1067
+ }
1068
+ catch {
1069
+ // If realpath fails, compare the absolute path. This keeps direct execution
1070
+ // working even when the script path disappears during process startup.
1071
+ }
1072
+ return normalizeFileURL(url.pathToFileURL(resolved).href);
1059
1073
  }
1060
- catch {
1061
- return import.meta.url.endsWith(scriptPath);
1074
+ return (await realFileURL(scriptPath)) === (await realFileURL(url.fileURLToPath(import.meta.url)));
1075
+ }
1076
+ invokedFromCLI().then((invoked) => {
1077
+ if (invoked && main() !== 0) {
1078
+ process.exitCode = 1;
1062
1079
  }
1063
- })();
1064
- if (isMainModule && main() !== 0) {
1080
+ }, (err) => {
1081
+ process.stderr.write(`${formatError(err)}\n`);
1065
1082
  process.exitCode = 1;
1066
- }
1083
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paybond/kit",
3
- "version": "0.9.5",
3
+ "version": "0.9.6",
4
4
  "description": "Paybond Kit for TypeScript: agent spend governance for paid tool calls with spend authorization, evidence receipts, refunds, disputes, hosted Gateway sessions, and settlement.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",