@byok-sdk/keys 0.5.0 → 0.6.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.
@@ -1,9 +1,19 @@
1
+ import { type ChildProcess } from 'node:child_process';
2
+ import { type ImplementationSpawnBindingV1 } from '@byok-sdk/implementation-identity';
3
+ import { type CommandRunner } from './command-runner';
4
+ import { type PiLauncherRuntimeEntry } from './pi-provider-projection';
1
5
  import { type ExactProviderProfileBinding, type ModelProviderProfile, type ProviderProfileRef } from './provider-profile';
2
6
  import { type SecretStore } from './secret-store';
3
7
  export interface PiProviderLauncherOptions {
4
8
  piBin: string;
5
9
  /** Explicit script entry for the selected interpreter; never inferred from a filename. */
6
10
  piEntry?: string;
11
+ launchBinding?: ImplementationSpawnBindingV1;
12
+ piCwd?: string;
13
+ piFixedArgs?: readonly string[];
14
+ piConfigDigest?: string;
15
+ /** Which of this launcher's two child grammars applies; never defaulted. */
16
+ runtimeEntry: PiLauncherRuntimeEntry;
7
17
  profileDbPath: string;
8
18
  /** Carried by the `--provider` flag: the exact local profile to launch. */
9
19
  profileRef: ProviderProfileRef;
@@ -16,6 +26,23 @@ export interface PiProviderLauncherOptions {
16
26
  piArgs: string[];
17
27
  }
18
28
  export declare function parsePiProviderLauncherOptions(args: string[]): PiProviderLauncherOptions;
29
+ /**
30
+ * What a profile must declare before it may parent a prepared host.
31
+ *
32
+ * Both refusals are about the prepared lane's own compile support set, not
33
+ * about custody: a prepared artifact is `openai-completions` bytes compiled by
34
+ * the device, and the host resolves a key for the projected provider before it
35
+ * will consume one. An `anthropic` adapter projects `anthropic-messages`, which
36
+ * the prepared compiler never emits, and `auth_mode: 'none'` projects a
37
+ * provider with no `apiKey` reference at all, so the host would refuse with
38
+ * `prepared_provider_credential_unavailable` AFTER a child had already been
39
+ * spawned. Refusing here means the admission (`--validate-only true`) answers
40
+ * the same question the launch would, before any process exists.
41
+ *
42
+ * Deliberately NOT a silent narrowing of the profile: nothing here rewrites the
43
+ * adapter or invents a credential.
44
+ */
45
+ export declare function assertPiPreparedProviderProfile(profile: ModelProviderProfile): void;
19
46
  /**
20
47
  * Resolve only the credential the validated profile requires. In particular,
21
48
  * an auth-free local provider must remain usable on hosts without an OS
@@ -23,14 +50,35 @@ export declare function parsePiProviderLauncherOptions(args: string[]): PiProvid
23
50
  * dependency and turn an explicit `auth_mode: none` into a hidden fallback.
24
51
  */
25
52
  export declare function resolvePiProviderSecret(profile: ModelProviderProfile, createStore: () => SecretStore): Promise<string | undefined>;
26
- /** Build Pi's child environment from a closed platform baseline plus one exact key. */
53
+ /** The inherited inventory is shared with admission; controlled values come only from the binding. */
27
54
  export declare function buildPiProviderChildEnvironment(options: {
28
55
  ambient: NodeJS.ProcessEnv;
29
- projectionDir: string;
56
+ binding: ImplementationSpawnBindingV1;
30
57
  sessionDir: string;
31
58
  secret: string | undefined;
32
59
  platform?: NodeJS.Platform;
33
60
  }): Record<string, string>;
61
+ /** Read-only Windows equivalent of uid + 0700; never repairs host ACLs. */
62
+ export declare function assertWindowsPiProjectionAcl(directory: string, options?: {
63
+ systemRoot?: string;
64
+ run?: CommandRunner;
65
+ }): Promise<void>;
66
+ /** Validate the client-owned empty directory before any credential access. */
67
+ export declare function assertPiProjectionDirectory(projectionDir: string, expectedDir: string): Promise<void>;
68
+ export interface PiProviderLaunchDependencies {
69
+ ambient: NodeJS.ProcessEnv;
70
+ createSecretStore: () => SecretStore;
71
+ spawn?: (command: string, args: string[], options: {
72
+ cwd: string;
73
+ env: Record<string, string>;
74
+ stdio: 'inherit';
75
+ }) => ChildProcess;
76
+ }
77
+ /** Owns the credential-to-spawn sequence; the client retains directory ownership. */
78
+ export declare function startPiProvider(profile: ModelProviderProfile, options: PiProviderLauncherOptions, dependencies: PiProviderLaunchDependencies): Promise<{
79
+ child: ChildProcess;
80
+ cleanup: () => Promise<void>;
81
+ }>;
34
82
  /**
35
83
  * Create the configured session directory owner-only without mutating the
36
84
  * mode of an existing host-owned directory. The path is operator config, so
@@ -1,5 +1,22 @@
1
1
  import type { ModelProviderProfile } from './provider-profile';
2
2
  export declare const PI_PROJECTED_KEY_ENV = "PI_PROVIDER_API_KEY";
3
+ /**
4
+ * The runtime entries this launcher may parent, and the ONLY two.
5
+ *
6
+ * The entry is not a hint about which flags happen to be present: it selects
7
+ * which delegated-argv grammar below is applied, and the two grammars admit
8
+ * disjoint argument sets. A client that could omit it would be a client whose
9
+ * argv decides the grammar, so the flag is required at the parser rather than
10
+ * defaulted — a client/keys version skew then fails closed instead of
11
+ * silently launching a prepared host under the rpc grammar.
12
+ *
13
+ * `@byok-sdk/implementation-identity` declares four entries; the other two
14
+ * (`pi-subagent-print`, `pi-subagent-runner`) are descendants the launcher
15
+ * never parents, so restating the pair here is a narrowing, not a second
16
+ * vocabulary.
17
+ */
18
+ export declare const PI_LAUNCHER_RUNTIME_ENTRIES: readonly ['pi-rpc', 'pi-prepared'];
19
+ export type PiLauncherRuntimeEntry = (typeof PI_LAUNCHER_RUNTIME_ENTRIES)[number];
3
20
  /** Keep projected providers disjoint from Pi built-ins so composition can never fall back to one. */
4
21
  export declare function piProjectionProviderId(profileRef: string): string;
5
22
  /**
@@ -18,3 +35,17 @@ export declare function buildPiProviderProjection(profile: ModelProviderProfile)
18
35
  * the Pi child to the namespaced projection and exact configured model.
19
36
  */
20
37
  export declare function buildPiProviderArgs(profile: ModelProviderProfile, delegatedArgs: readonly string[]): string[];
38
+ /**
39
+ * The whole delegated argv a prepared host may be launched with: one
40
+ * `--config <absolute path>` pair, and nothing else.
41
+ *
42
+ * Nothing is APPENDED either. The rpc grammar ends by binding the child to the
43
+ * projected provider, the configured model and the configured thinking level,
44
+ * because the rpc child composes its session from `models.json`. A prepared
45
+ * host composes nothing: the request it consumes was already compiled and the
46
+ * model it verifies against is the one the durable record pinned, so a
47
+ * `--provider`/`--model`/`--thinking` appended here would be a second, silent
48
+ * authority over a request that was already decided — and the host's own
49
+ * argument parser refuses anything but `--config` regardless.
50
+ */
51
+ export declare function buildPiPreparedArgs(delegatedArgs: readonly string[]): string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@byok-sdk/keys",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "BYOK SDK key management: provider profiles, credential-backed auth headers, and direct provider transports",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -48,7 +48,8 @@
48
48
  "clean": "rm -rf dist"
49
49
  },
50
50
  "dependencies": {
51
- "@byok-sdk/core": "0.18.0",
52
- "zod": "^4.4.3"
51
+ "@byok-sdk/core": "0.19.0",
52
+ "zod": "^4.4.3",
53
+ "@byok-sdk/implementation-identity": "0.19.0"
53
54
  }
54
55
  }