@byok-sdk/client 0.16.0 → 0.18.0

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.
@@ -14,5 +14,5 @@ export declare function classifyDetectError(error: unknown): ProbeFailure;
14
14
  * not by itself timeout evidence (execFile also kills on output overflow).
15
15
  * Resolve only at execFile completion; SIGKILL bounds a TERM-ignoring probe.
16
16
  */
17
- export declare function probeRuntimeVersion(command: string, timeoutMs: number): Promise<VersionProbeResult>;
17
+ export declare function probeRuntimeVersion(command: string, timeoutMs: number, prefixArgs?: readonly string[]): Promise<VersionProbeResult>;
18
18
  export {};
@@ -198,13 +198,13 @@ function classifyDetectError(error) {
198
198
  if (code === "EACCES" || code === "EPERM" || code === "ENOEXEC") return { kind: "not-executable" };
199
199
  return { kind: "probe-failed" };
200
200
  }
201
- async function probeRuntimeVersion(command, timeoutMs) {
201
+ async function probeRuntimeVersion(command, timeoutMs, prefixArgs = []) {
202
202
  if (!Number.isSafeInteger(timeoutMs) || timeoutMs <= 0) throw new TypeError("invalid runtime probe timeout");
203
203
  return new Promise((resolve) => {
204
204
  let timer;
205
205
  let timedOut = false;
206
206
  try {
207
- const child = execFile(command, ["--version"], { encoding: "utf8" }, (error, stdout, stderr) => {
207
+ const child = execFile(command, [...prefixArgs, "--version"], { encoding: "utf8" }, (error, stdout, stderr) => {
208
208
  if (timer) clearTimeout(timer);
209
209
  if (error?.code === "ERR_CHILD_PROCESS_STDIO_MAXBUFFER") resolve({ kind: "probe-failed" });
210
210
  else if (timedOut) resolve({ kind: "timeout" });
@@ -1178,6 +1178,9 @@ function withoutProviderCredentials(env) {
1178
1178
  // src/adapters/pi/pi-adapter.ts
1179
1179
  var execFileAsync = promisify(execFile);
1180
1180
  var DETECT_TIMEOUT_MS = 5e3;
1181
+ function piInvocation(bin) {
1182
+ return bin.source === "package" ? { command: process.execPath, entry: bin.command } : { command: bin.command };
1183
+ }
1181
1184
  function errorMessage(err) {
1182
1185
  return err instanceof Error ? err.message : String(err);
1183
1186
  }
@@ -1226,6 +1229,7 @@ function validatePiByokLauncherConfig(launcher) {
1226
1229
  const reserved = /* @__PURE__ */ new Set([
1227
1230
  "--",
1228
1231
  "--pi-bin",
1232
+ "--pi-entry",
1229
1233
  "--profile-db",
1230
1234
  "--session-dir",
1231
1235
  "--macos-keychain-path",
@@ -1274,7 +1278,12 @@ var PiAdapter = class {
1274
1278
  async detect() {
1275
1279
  try {
1276
1280
  const bin = this.resolveBin();
1277
- const probe = await probeRuntimeVersion(bin.command, DETECT_TIMEOUT_MS);
1281
+ const invocation = piInvocation(bin);
1282
+ const probe = await probeRuntimeVersion(
1283
+ invocation.command,
1284
+ DETECT_TIMEOUT_MS,
1285
+ invocation.entry === void 0 ? [] : [invocation.entry]
1286
+ );
1278
1287
  if (probe.kind !== "available") return probe;
1279
1288
  const version = probe.stdout.trim() || probe.stderr.trim();
1280
1289
  const authPresent = PROVIDER_CREDENTIAL_ENV_NAMES.some((name) => process.env[name] !== void 0);
@@ -1305,7 +1314,8 @@ var PiAdapter = class {
1305
1314
  requiredCapabilities: Object.freeze([...selection.providerProfile.requiredCapabilities])
1306
1315
  })
1307
1316
  }) : Object.freeze({ ...selection });
1308
- let command = bin.command;
1317
+ const invocation = piInvocation(bin);
1318
+ let command = invocation.command;
1309
1319
  let launcherArgs;
1310
1320
  if (pinnedSelection !== void 0) {
1311
1321
  if (pinnedSelection.lane !== "byok" && pinnedSelection.lane !== "byok-profile" || pinnedSelection.runtimeId !== "pi") {
@@ -1334,7 +1344,8 @@ var PiAdapter = class {
1334
1344
  launcherArgs = [
1335
1345
  ...launcher.args ?? [],
1336
1346
  "--pi-bin",
1337
- bin.command,
1347
+ invocation.command,
1348
+ ...invocation.entry === void 0 ? [] : ["--pi-entry", invocation.entry],
1338
1349
  "--profile-db",
1339
1350
  launcher.profileDbPath,
1340
1351
  "--session-dir",
@@ -1428,7 +1439,7 @@ var PiAdapter = class {
1428
1439
  ...resumeSessionId ? ["--session", resumeSessionId] : [],
1429
1440
  ...mapping.args
1430
1441
  ];
1431
- const args = launcherArgs === void 0 ? piArgs : [...launcherArgs, "--", ...piArgs];
1442
+ const args = launcherArgs === void 0 ? [...invocation.entry === void 0 ? [] : [invocation.entry], ...piArgs] : [...launcherArgs, "--", ...piArgs];
1432
1443
  let rpc;
1433
1444
  try {
1434
1445
  rpc = new PiRpcClient({