@hasna/switcher 0.2.13 → 0.2.15

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.
@@ -0,0 +1,84 @@
1
+ import { type GatewayHost, type RoutingEvent } from "./inference-gateway";
2
+ import { type CommandRunner } from "./gateway-supervisor";
3
+ export type GatewayStatus = {
4
+ service: "switcher-gateway";
5
+ protocol: number;
6
+ version: string;
7
+ pid: number;
8
+ port: number;
9
+ baseUrl: string;
10
+ launches: number;
11
+ supervisor: string;
12
+ };
13
+ type Registration = {
14
+ id: string;
15
+ token: string;
16
+ baseUrl: string;
17
+ };
18
+ type Release = {
19
+ retained: boolean;
20
+ holders: number;
21
+ events?: RoutingEvent[];
22
+ eventsDropped?: number;
23
+ };
24
+ /** HTTP over the owner-only Unix socket of the gateway service. */
25
+ export declare class GatewayControlClient {
26
+ readonly socket: string;
27
+ readonly timeoutMs: number;
28
+ constructor(socket: string, timeoutMs?: number);
29
+ private request;
30
+ status(): Promise<GatewayStatus>;
31
+ launches(): Promise<{
32
+ data: unknown[];
33
+ }>;
34
+ register(body: unknown): Promise<Registration>;
35
+ attach(id: string, pid: number): Promise<{
36
+ holders: number;
37
+ }>;
38
+ release(id: string): Promise<Release>;
39
+ revoke(id: string): Promise<{
40
+ revoked: boolean;
41
+ }>;
42
+ stop(): Promise<{
43
+ stopping: boolean;
44
+ }>;
45
+ }
46
+ /** The running gateway's status, or undefined when none runs. An untrusted socket is an error, never "stopped". */
47
+ export declare function gatewayStatus(env?: NodeJS.ProcessEnv): Promise<GatewayStatus | undefined>;
48
+ /** True when the running gateway is not this CLI's version or protocol, so `switcher gateway install` should restart it. */
49
+ export declare const gatewayOutdated: (status: GatewayStatus) => boolean;
50
+ /**
51
+ * supervise: false never installs a login item (for example when this CLI is not the
52
+ * PATH-linked switcher, such as a development checkout); a detached service is used.
53
+ */
54
+ export type EnsureGatewayOptions = {
55
+ env?: NodeJS.ProcessEnv;
56
+ command: string[];
57
+ runner?: CommandRunner;
58
+ waitMs?: number;
59
+ supervise?: boolean;
60
+ warn?: (message: string) => void;
61
+ };
62
+ export type EnsuredGateway = {
63
+ client: GatewayControlClient;
64
+ status: GatewayStatus;
65
+ started: "existing" | "launchd" | "systemd" | "detached";
66
+ };
67
+ /** Reuse the running gateway or start it: under launchd/systemd for the default home, otherwise detached. */
68
+ export declare function ensureGatewayService(options: EnsureGatewayOptions): Promise<EnsuredGateway>;
69
+ export type ServiceGatewayHost = GatewayHost & {
70
+ attach: (pid: number) => void;
71
+ retainedState: () => boolean;
72
+ };
73
+ /**
74
+ * Register each launch gateway with the persistent service. If registration fails,
75
+ * the launch still runs on a per-launch gateway and says so.
76
+ */
77
+ export declare function createServiceGatewayHost(client: GatewayControlClient, context: {
78
+ holderPid: number;
79
+ stateDir?: string;
80
+ credentialEnv?: string;
81
+ onRoutingEvent?: (event: RoutingEvent) => void;
82
+ warn?: (message: string) => void;
83
+ }): ServiceGatewayHost;
84
+ export {};
@@ -0,0 +1,60 @@
1
+ import { type ProviderInput } from "./domain";
2
+ import type { ProviderRequestTiming } from "./provider-request";
3
+ import { type EnvironmentDigestProbe, type ProcessReader } from "./process-table";
4
+ /** Version of the control protocol between `switcher launch` and the gateway service. */
5
+ export declare const GATEWAY_PROTOCOL = 1;
6
+ export type GatewayPaths = {
7
+ root: string;
8
+ socket: string;
9
+ launches: string;
10
+ config: string;
11
+ log: string;
12
+ };
13
+ /** Every path the gateway service owns for one Switcher home. */
14
+ export declare function gatewayPaths(env?: NodeJS.ProcessEnv): GatewayPaths;
15
+ /**
16
+ * Check the control socket before a client sends anything to it: launches carry the
17
+ * provider credential. Its directory must be a private directory owned by this user,
18
+ * and the socket itself a socket owned by this user. A missing socket means the
19
+ * gateway is not running.
20
+ */
21
+ export declare function assertTrustedControlSocket(socket: string): Promise<void>;
22
+ /** The default home gets one stable, per-user loopback port. */
23
+ export declare function defaultGatewayPort(uid?: number): number;
24
+ /**
25
+ * The account's home from the passwd database. Bun's os.userInfo().homedir follows
26
+ * $HOME, so it cannot tell a synthetic test home from the real one.
27
+ */
28
+ export declare function accountHome(): string | undefined;
29
+ /** True only for the account's real home and its default ~/.hasna/switcher; unknown means no. */
30
+ export declare function isDefaultSwitcherHome(env?: NodeJS.ProcessEnv, home?: string | undefined): boolean;
31
+ export declare function gatewaySettings(env?: NodeJS.ProcessEnv): {
32
+ port: number | undefined;
33
+ graceMs: number;
34
+ scanMs: number;
35
+ exitIdleMs: number;
36
+ };
37
+ export type GatewayServiceOptions = {
38
+ env?: NodeJS.ProcessEnv;
39
+ port?: number;
40
+ graceMs?: number;
41
+ scanMs?: number;
42
+ exitWhenIdleMs?: number;
43
+ supervisor?: string;
44
+ processTable?: ProcessReader;
45
+ environmentProbe?: EnvironmentDigestProbe;
46
+ now?: () => number;
47
+ timing?: ProviderRequestTiming;
48
+ log?: (line: string) => void;
49
+ resolveCredential?: (provider: ProviderInput) => Promise<string | undefined>;
50
+ };
51
+ export type GatewayService = {
52
+ url: string;
53
+ port: number;
54
+ socket: string;
55
+ pid: number;
56
+ close: () => Promise<void>;
57
+ closed: Promise<void>;
58
+ scan: () => Promise<void>;
59
+ };
60
+ export declare function startGatewayService(options?: GatewayServiceOptions): Promise<GatewayService>;
@@ -0,0 +1,73 @@
1
+ export declare const LAUNCHD_LABEL = "com.hasna.switcher.gateway";
2
+ export declare const SYSTEMD_UNIT = "switcher-gateway.service";
3
+ export type Supervisor = "launchd" | "systemd" | "none";
4
+ export type CommandResult = {
5
+ code: number;
6
+ stdout: string;
7
+ stderr: string;
8
+ };
9
+ export type CommandRunner = (argv: string[]) => Promise<CommandResult>;
10
+ export declare function serviceEnvironment(env?: NodeJS.ProcessEnv): Record<string, string>;
11
+ /** A login unit outlives the installing shell: its temporary directory comes from launchd or systemd, not that shell. */
12
+ export declare function unitEnvironment(env?: NodeJS.ProcessEnv): Record<string, string>;
13
+ /**
14
+ * A login unit runs its command at every login and after every crash, so each file it
15
+ * runs must be one only this user (or root) can change: the file, its real path and
16
+ * every parent directory owned by this user or root and not writable by group or
17
+ * others, and nothing under a temporary directory.
18
+ */
19
+ export declare function assertSafeServiceCommand(command: string[], temporaryRoots?: string[]): Promise<void>;
20
+ /**
21
+ * The OS supervisor that keeps the gateway running across logins and crashes.
22
+ * Only the user's real default home is supervised; tests and custom homes use a
23
+ * detached service that exits when idle, so they never register a login item.
24
+ */
25
+ export declare function supervisorFor(env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform, home?: string | undefined): Supervisor;
26
+ /** launchd creates missing log directories itself, so its log stays outside the private Switcher home. */
27
+ export declare function launchdLogPath(home: string): string;
28
+ export declare function unitPath(supervisor: Exclude<Supervisor, "none">, env?: NodeJS.ProcessEnv, home?: string): string;
29
+ /** A per-user LaunchAgent: started at login, restarted if it crashes, stopped only on purpose. */
30
+ export declare function renderLaunchdPlist(command: string[], env?: NodeJS.ProcessEnv, home?: string): string;
31
+ /** A systemd user unit with the same semantics. Starting at boot without a login needs `loginctl enable-linger`. */
32
+ export declare function renderSystemdUnit(command: string[], env?: NodeJS.ProcessEnv): string;
33
+ export declare const defaultRunner: CommandRunner;
34
+ export type InstallResult = {
35
+ supervisor: Exclude<Supervisor, "none">;
36
+ path: string;
37
+ changed: boolean;
38
+ domain?: string;
39
+ };
40
+ /**
41
+ * Install (or refresh) and start the gateway under the user's supervisor.
42
+ * verifyCommand checks the files the unit will run (assertSafeServiceCommand); tests with
43
+ * fixture paths replace it.
44
+ */
45
+ export declare function installGatewayService(options: {
46
+ command: string[];
47
+ env?: NodeJS.ProcessEnv;
48
+ supervisor?: Supervisor;
49
+ runner?: CommandRunner;
50
+ home?: string;
51
+ verifyCommand?: (command: string[]) => Promise<void>;
52
+ }): Promise<InstallResult>;
53
+ /** Stop the supervised gateway and remove its unit. Persisted launches stay for a later start. */
54
+ export declare function uninstallGatewayService(options?: {
55
+ env?: NodeJS.ProcessEnv;
56
+ supervisor?: Supervisor;
57
+ runner?: CommandRunner;
58
+ home?: string;
59
+ }): Promise<{
60
+ removed: boolean;
61
+ supervisor: "none";
62
+ path?: undefined;
63
+ } | {
64
+ removed: boolean;
65
+ supervisor: "systemd" | "launchd";
66
+ path: string;
67
+ }>;
68
+ export declare function unitInstalled(env?: NodeJS.ProcessEnv, home?: string | undefined): Promise<{
69
+ supervisor: Supervisor;
70
+ path?: string;
71
+ log?: string;
72
+ installed: boolean;
73
+ }>;
@@ -6,6 +6,7 @@ export declare function runHarnessProcess(options: {
6
6
  env: NodeJS.ProcessEnv;
7
7
  timeoutMs?: number;
8
8
  silent?: boolean;
9
+ onSpawn?: (pid: number) => void;
9
10
  }): Promise<{
10
11
  code: number;
11
12
  interrupted: boolean;
@@ -1,7 +1,7 @@
1
1
  import type { Model, Provider, Profile } from "./domain";
2
2
  import type { CompiledModelPolicy, ModelPolicy } from "./model-policy";
3
3
  import type { NativeModelPolicy } from "./native-model-policy";
4
- import type { RoutingEvent } from "./inference-gateway";
4
+ import type { GatewayHost, RoutingEvent } from "./inference-gateway";
5
5
  import type { ReasoningEffort } from "./reasoning";
6
6
  import type { NativeState } from "./native-state";
7
7
  export type HarnessId = Profile["harness"];
@@ -28,6 +28,8 @@ export type HarnessLaunchInput = {
28
28
  reasoning?: ReasoningEffort;
29
29
  dangerouslyBypassApprovalsAndSandbox?: boolean;
30
30
  sharedState?: NativeState;
31
+ /** Hosts the launch's inference gateway; a per-launch listener when absent. */
32
+ gatewayHost?: GatewayHost;
31
33
  };
32
34
  export type PreparedLaunch = {
33
35
  executable: string;
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ var __export = (target, all) => {
13
13
  });
14
14
  };
15
15
 
16
- // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/external.js
16
+ // node_modules/zod/v3/external.js
17
17
  var exports_external = {};
18
18
  __export(exports_external, {
19
19
  void: () => voidType,
@@ -125,7 +125,7 @@ __export(exports_external, {
125
125
  BRAND: () => BRAND
126
126
  });
127
127
 
128
- // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/helpers/util.js
128
+ // node_modules/zod/v3/helpers/util.js
129
129
  var util;
130
130
  (function(util2) {
131
131
  util2.assertEqual = (_) => {};
@@ -256,7 +256,7 @@ var getParsedType = (data) => {
256
256
  }
257
257
  };
258
258
 
259
- // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/ZodError.js
259
+ // node_modules/zod/v3/ZodError.js
260
260
  var ZodIssueCode = util.arrayToEnum([
261
261
  "invalid_type",
262
262
  "invalid_literal",
@@ -375,7 +375,7 @@ ZodError.create = (issues) => {
375
375
  return error;
376
376
  };
377
377
 
378
- // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/locales/en.js
378
+ // node_modules/zod/v3/locales/en.js
379
379
  var errorMap = (issue, _ctx) => {
380
380
  let message;
381
381
  switch (issue.code) {
@@ -478,7 +478,7 @@ var errorMap = (issue, _ctx) => {
478
478
  };
479
479
  var en_default = errorMap;
480
480
 
481
- // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/errors.js
481
+ // node_modules/zod/v3/errors.js
482
482
  var overrideErrorMap = en_default;
483
483
  function setErrorMap(map) {
484
484
  overrideErrorMap = map;
@@ -486,7 +486,7 @@ function setErrorMap(map) {
486
486
  function getErrorMap() {
487
487
  return overrideErrorMap;
488
488
  }
489
- // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
489
+ // node_modules/zod/v3/helpers/parseUtil.js
490
490
  var makeIssue = (params) => {
491
491
  const { data, path, errorMaps, issueData } = params;
492
492
  const fullPath = [...path, ...issueData.path || []];
@@ -592,14 +592,14 @@ var isAborted = (x) => x.status === "aborted";
592
592
  var isDirty = (x) => x.status === "dirty";
593
593
  var isValid = (x) => x.status === "valid";
594
594
  var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
595
- // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js
595
+ // node_modules/zod/v3/helpers/errorUtil.js
596
596
  var errorUtil;
597
597
  (function(errorUtil2) {
598
598
  errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
599
599
  errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
600
600
  })(errorUtil || (errorUtil = {}));
601
601
 
602
- // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/types.js
602
+ // node_modules/zod/v3/types.js
603
603
  class ParseInputLazyPath {
604
604
  constructor(parent, value, path, key) {
605
605
  this._cachedPath = [];
@@ -4200,7 +4200,7 @@ async function boundedJson(response, maxBytes = MAX_BYTES) {
4200
4200
  }
4201
4201
  }
4202
4202
 
4203
- // ../contracts/dist/client/transport.js
4203
+ // node_modules/@hasna/contracts/dist/client/transport.js
4204
4204
  import { isIP } from "net";
4205
4205
  import { spawnSync } from "child_process";
4206
4206
  import { closeSync as closeSync2, fstatSync as fstatSync2, openSync as openSync2, readFileSync as readFileSync2 } from "fs";
@@ -13,15 +13,38 @@ export type RoutingEvent = {
13
13
  reason?: string;
14
14
  upstreamStatus?: number;
15
15
  };
16
- type GatewayInput = HarnessLaunchInput & {
16
+ export type GatewayInput = HarnessLaunchInput & {
17
17
  compiledPolicy: CompiledModelPolicy;
18
18
  catalogPath: string;
19
19
  onRoutingEvent?: (event: RoutingEvent) => void;
20
20
  };
21
+ /** A started gateway endpoint as a native harness sees it. */
22
+ export type GatewayLease = {
23
+ baseUrl: string;
24
+ token: string;
25
+ cleanup: () => Promise<void>;
26
+ retainsState?: () => boolean;
27
+ };
28
+ /** Where a launch's inference gateway runs: its own listener, or a persistent service. */
29
+ export type GatewayHost = {
30
+ open: (input: GatewayInput) => Promise<GatewayLease>;
31
+ };
32
+ export type InferenceHandlerOptions = {
33
+ /** Resolve the provider credential when a request needs it; replaces input.credential. */
34
+ credential?: () => Promise<string | undefined>;
35
+ };
36
+ export type InferenceHandler = {
37
+ bodyLimit: number;
38
+ closing: () => boolean;
39
+ handle: (request: Request, server: Bun.Server<unknown>) => Promise<Response>;
40
+ close: () => Promise<void>;
41
+ };
42
+ export declare const MAX_REQUEST_BODY_BYTES: number;
43
+ /** A launch's credential boundary and model policy, independent of the listener that serves it. */
44
+ export declare function createInferenceHandler(input: GatewayInput, timing?: ProviderRequestTiming, options?: InferenceHandlerOptions): InferenceHandler;
21
45
  /** A per-launch credential boundary: the native client never receives the provider key. */
22
46
  export declare function createInferenceGateway(input: GatewayInput, timing?: ProviderRequestTiming): {
23
47
  baseUrl: string;
24
48
  token: string;
25
49
  cleanup: () => Promise<void>;
26
50
  };
27
- export {};
@@ -6,9 +6,19 @@ import type { ChatGPTInstallation, ClaudeDesktopInstallation } from "./desktop-a
6
6
  import type { ReasoningEffort } from "./reasoning";
7
7
  import { type NativeState } from "./native-state";
8
8
  import type { RoutingEvent } from "./inference-gateway";
9
+ import { type GatewayControlClient } from "./gateway-client";
9
10
  export { childEnvironment } from "./harness-environment";
10
11
  export type LaunchBackend = "direct" | "ori";
11
- export type LaunchOptions = {
12
+ export type GatewayMode = "local" | "service";
13
+ /** service: register with the persistent per-user gateway so detached descendants keep working. */
14
+ /** gatewaySupervise: false keeps a non-PATH switcher (a development checkout) from installing the login service. */
15
+ export type LaunchGatewayOptions = {
16
+ gateway?: GatewayMode;
17
+ gatewayCommand?: string[];
18
+ gatewaySupervise?: boolean;
19
+ connectGateway?: () => Promise<GatewayControlClient>;
20
+ };
21
+ export type LaunchOptions = LaunchGatewayOptions & {
12
22
  desktop?: ChatGPTInstallation;
13
23
  claudeDesktop?: ClaudeDesktopInstallation;
14
24
  shareNativeState?: boolean;
package/dist/mcp/index.js CHANGED
@@ -19,7 +19,7 @@ var __export = (target, all) => {
19
19
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
20
20
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
21
21
 
22
- // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/external.js
22
+ // node_modules/zod/v3/external.js
23
23
  var exports_external = {};
24
24
  __export(exports_external, {
25
25
  void: () => voidType,
@@ -131,7 +131,7 @@ __export(exports_external, {
131
131
  BRAND: () => BRAND
132
132
  });
133
133
 
134
- // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/helpers/util.js
134
+ // node_modules/zod/v3/helpers/util.js
135
135
  var util;
136
136
  (function(util2) {
137
137
  util2.assertEqual = (_) => {};
@@ -262,7 +262,7 @@ var getParsedType = (data) => {
262
262
  }
263
263
  };
264
264
 
265
- // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/ZodError.js
265
+ // node_modules/zod/v3/ZodError.js
266
266
  var ZodIssueCode = util.arrayToEnum([
267
267
  "invalid_type",
268
268
  "invalid_literal",
@@ -381,7 +381,7 @@ ZodError.create = (issues) => {
381
381
  return error;
382
382
  };
383
383
 
384
- // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/locales/en.js
384
+ // node_modules/zod/v3/locales/en.js
385
385
  var errorMap = (issue, _ctx) => {
386
386
  let message;
387
387
  switch (issue.code) {
@@ -484,7 +484,7 @@ var errorMap = (issue, _ctx) => {
484
484
  };
485
485
  var en_default = errorMap;
486
486
 
487
- // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/errors.js
487
+ // node_modules/zod/v3/errors.js
488
488
  var overrideErrorMap = en_default;
489
489
  function setErrorMap(map) {
490
490
  overrideErrorMap = map;
@@ -492,7 +492,7 @@ function setErrorMap(map) {
492
492
  function getErrorMap() {
493
493
  return overrideErrorMap;
494
494
  }
495
- // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
495
+ // node_modules/zod/v3/helpers/parseUtil.js
496
496
  var makeIssue = (params) => {
497
497
  const { data, path, errorMaps, issueData } = params;
498
498
  const fullPath = [...path, ...issueData.path || []];
@@ -598,14 +598,14 @@ var isAborted = (x) => x.status === "aborted";
598
598
  var isDirty = (x) => x.status === "dirty";
599
599
  var isValid = (x) => x.status === "valid";
600
600
  var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
601
- // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js
601
+ // node_modules/zod/v3/helpers/errorUtil.js
602
602
  var errorUtil;
603
603
  (function(errorUtil2) {
604
604
  errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
605
605
  errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
606
606
  })(errorUtil || (errorUtil = {}));
607
607
 
608
- // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/types.js
608
+ // node_modules/zod/v3/types.js
609
609
  class ParseInputLazyPath {
610
610
  constructor(parent, value, path, key) {
611
611
  this._cachedPath = [];
@@ -4049,7 +4049,7 @@ function canonicalPolicyJSON(value) {
4049
4049
  return JSON.stringify(value, (_key, item) => item && typeof item === "object" && !Array.isArray(item) ? Object.fromEntries(Object.entries(item).sort(([a], [b]) => a.localeCompare(b))) : item);
4050
4050
  }
4051
4051
  // package.json
4052
- var version = "0.2.13";
4052
+ var version = "0.2.15";
4053
4053
 
4054
4054
  // src/version.ts
4055
4055
  var VERSION = version;
@@ -4243,7 +4243,7 @@ async function boundedJson(response, maxBytes = MAX_BYTES) {
4243
4243
  }
4244
4244
  }
4245
4245
 
4246
- // ../contracts/dist/client/transport.js
4246
+ // node_modules/@hasna/contracts/dist/client/transport.js
4247
4247
  import { isIP } from "net";
4248
4248
  import { spawnSync } from "child_process";
4249
4249
  import { closeSync as closeSync2, fstatSync as fstatSync2, openSync as openSync2, readFileSync as readFileSync2 } from "fs";
@@ -5919,7 +5919,7 @@ import { chmod, mkdir } from "fs/promises";
5919
5919
  import { dirname as dirname2, resolve } from "path";
5920
5920
  import { createHash as createHash2 } from "crypto";
5921
5921
 
5922
- // ../contracts/dist/auth/index.js
5922
+ // node_modules/@hasna/contracts/dist/auth/index.js
5923
5923
  import { createHash, createHmac, randomBytes, timingSafeEqual } from "crypto";
5924
5924
  var MAX_TENANT_ID_LENGTH = 64;
5925
5925
  var TENANT_ID_PATTERN = new RegExp(`^[A-Za-z0-9][A-Za-z0-9._-]{0,${MAX_TENANT_ID_LENGTH - 1}}$`);
@@ -7080,7 +7080,7 @@ var openapi_default = {
7080
7080
  openapi: "3.0.3",
7081
7081
  info: {
7082
7082
  title: "Switcher API",
7083
- version: "0.2.13",
7083
+ version: "0.2.15",
7084
7084
  description: "Authenticated provider/profile/catalog control plane. Launches run locally; the API never returns provider credentials."
7085
7085
  },
7086
7086
  security: [
@@ -11693,7 +11693,7 @@ async function openCliRuntime(env = process.env, resolveCredential2) {
11693
11693
  return { client: new SwitcherClient({ baseUrl: service.url, apiKey }), mode: "local", providerEnv, close: service.close };
11694
11694
  }
11695
11695
 
11696
- // ../contracts/dist/executable-trust.js
11696
+ // node_modules/@hasna/contracts/dist/executable-trust.js
11697
11697
  import { constants as constants2 } from "fs";
11698
11698
  import { access as access2, lstat as lstat2, open, readlink, realpath, rename, unlink } from "fs/promises";
11699
11699
  import { dirname as dirname3, isAbsolute as isAbsolute3, join as join5, parse as parse2, sep as sep2 } from "path";
@@ -0,0 +1,28 @@
1
+ /**
2
+ * A process identity that survives PID reuse: the PID plus its start time.
3
+ * `comm` is read on Linux only, to recognise a `systemd --user` subreaper.
4
+ */
5
+ export type ProcessEntry = {
6
+ pid: number;
7
+ ppid: number;
8
+ start: string;
9
+ comm?: string;
10
+ };
11
+ export type ProcessTable = Map<number, ProcessEntry>;
12
+ export type ProcessReader = () => Promise<ProcessTable>;
13
+ /** Read every visible process's parent and start time. Unsupported platforms fail closed. */
14
+ export declare function readProcessTable(): Promise<ProcessTable>;
15
+ /** Every live process descended from one of the roots, excluding the excluded subtrees. */
16
+ export declare function descendants(table: ProcessTable, roots: Iterable<number>, exclude?: Iterable<number>): ProcessEntry[];
17
+ /**
18
+ * True for a process that was reparented away from its creator: to init or launchd
19
+ * (PID 1), or on Linux to a `systemd --user` subreaper.
20
+ */
21
+ export declare function isOrphan(entry: ProcessEntry, table: ProcessTable): boolean;
22
+ export type EnvironmentDigestProbe = (pids: number[], digest: string) => Promise<number[]>;
23
+ /**
24
+ * The PIDs among `pids` whose environment carries a launch token with this SHA-256
25
+ * digest. Token-shaped values are hashed and dropped; no value is returned or kept.
26
+ * Only the user's own processes are readable. Unsupported platforms find nothing.
27
+ */
28
+ export declare function processesHoldingTokenDigest(pids: number[], digest: string): Promise<number[]>;
package/dist/sdk.js CHANGED
@@ -13,7 +13,7 @@ var __export = (target, all) => {
13
13
  });
14
14
  };
15
15
 
16
- // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/external.js
16
+ // node_modules/zod/v3/external.js
17
17
  var exports_external = {};
18
18
  __export(exports_external, {
19
19
  void: () => voidType,
@@ -125,7 +125,7 @@ __export(exports_external, {
125
125
  BRAND: () => BRAND
126
126
  });
127
127
 
128
- // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/helpers/util.js
128
+ // node_modules/zod/v3/helpers/util.js
129
129
  var util;
130
130
  (function(util2) {
131
131
  util2.assertEqual = (_) => {};
@@ -256,7 +256,7 @@ var getParsedType = (data) => {
256
256
  }
257
257
  };
258
258
 
259
- // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/ZodError.js
259
+ // node_modules/zod/v3/ZodError.js
260
260
  var ZodIssueCode = util.arrayToEnum([
261
261
  "invalid_type",
262
262
  "invalid_literal",
@@ -375,7 +375,7 @@ ZodError.create = (issues) => {
375
375
  return error;
376
376
  };
377
377
 
378
- // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/locales/en.js
378
+ // node_modules/zod/v3/locales/en.js
379
379
  var errorMap = (issue, _ctx) => {
380
380
  let message;
381
381
  switch (issue.code) {
@@ -478,7 +478,7 @@ var errorMap = (issue, _ctx) => {
478
478
  };
479
479
  var en_default = errorMap;
480
480
 
481
- // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/errors.js
481
+ // node_modules/zod/v3/errors.js
482
482
  var overrideErrorMap = en_default;
483
483
  function setErrorMap(map) {
484
484
  overrideErrorMap = map;
@@ -486,7 +486,7 @@ function setErrorMap(map) {
486
486
  function getErrorMap() {
487
487
  return overrideErrorMap;
488
488
  }
489
- // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
489
+ // node_modules/zod/v3/helpers/parseUtil.js
490
490
  var makeIssue = (params) => {
491
491
  const { data, path, errorMaps, issueData } = params;
492
492
  const fullPath = [...path, ...issueData.path || []];
@@ -592,14 +592,14 @@ var isAborted = (x) => x.status === "aborted";
592
592
  var isDirty = (x) => x.status === "dirty";
593
593
  var isValid = (x) => x.status === "valid";
594
594
  var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
595
- // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js
595
+ // node_modules/zod/v3/helpers/errorUtil.js
596
596
  var errorUtil;
597
597
  (function(errorUtil2) {
598
598
  errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
599
599
  errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
600
600
  })(errorUtil || (errorUtil = {}));
601
601
 
602
- // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/types.js
602
+ // node_modules/zod/v3/types.js
603
603
  class ParseInputLazyPath {
604
604
  constructor(parent, value, path, key) {
605
605
  this._cachedPath = [];
@@ -4200,7 +4200,7 @@ async function boundedJson(response, maxBytes = MAX_BYTES) {
4200
4200
  }
4201
4201
  }
4202
4202
 
4203
- // ../contracts/dist/client/transport.js
4203
+ // node_modules/@hasna/contracts/dist/client/transport.js
4204
4204
  import { isIP } from "net";
4205
4205
  import { spawnSync } from "child_process";
4206
4206
  import { closeSync as closeSync2, fstatSync as fstatSync2, openSync as openSync2, readFileSync as readFileSync2 } from "fs";
@@ -68,7 +68,7 @@ function canonicalPolicyJSON(value) {
68
68
  return JSON.stringify(value, (_key, item) => item && typeof item === "object" && !Array.isArray(item) ? Object.fromEntries(Object.entries(item).sort(([a], [b]) => a.localeCompare(b))) : item);
69
69
  }
70
70
  // package.json
71
- var version = "0.2.13";
71
+ var version = "0.2.15";
72
72
 
73
73
  // src/version.ts
74
74
  var VERSION = version;
@@ -922,7 +922,7 @@ var openapi_default = {
922
922
  openapi: "3.0.3",
923
923
  info: {
924
924
  title: "Switcher API",
925
- version: "0.2.13",
925
+ version: "0.2.15",
926
926
  description: "Authenticated provider/profile/catalog control plane. Launches run locally; the API never returns provider credentials."
927
927
  },
928
928
  security: [