@byok-sdk/client 0.2.0 → 0.4.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.
- package/README.md +58 -5
- package/dist/adapters/claude/claude-adapter.d.ts +6 -19
- package/dist/adapters/claude/events.d.ts +3 -0
- package/dist/adapters/claude/process-client.d.ts +9 -1
- package/dist/adapters/codex/codex-adapter.d.ts +4 -15
- package/dist/adapters/codex/process-runner.d.ts +4 -1
- package/dist/adapters/index.d.ts +4 -2
- package/dist/adapters/index.js +1081 -258
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/pi/pi-adapter.d.ts +24 -15
- package/dist/adapters/pi/rpc-client.d.ts +9 -1
- package/dist/adapters/process-tree.d.ts +19 -0
- package/dist/adapters/provider-credential-environment.d.ts +18 -0
- package/dist/bin/audit-log.d.ts +12 -0
- package/dist/bin/byok-agent.js +2686 -912
- package/dist/bin/byok-agent.js.map +1 -1
- package/dist/bin/byok-approval-mcp.js +2 -2
- package/dist/bin/byok-approval-mcp.js.map +1 -1
- package/dist/bin/commands/workspaces.d.ts +11 -0
- package/dist/bin/format.d.ts +13 -0
- package/dist/bin/runtime-probe.d.ts +1 -1
- package/dist/bin/tasks-view.d.ts +13 -0
- package/dist/daemon/approvals.d.ts +2 -2
- package/dist/daemon/assertion-client.d.ts +68 -0
- package/dist/daemon/capabilities-client.d.ts +48 -0
- package/dist/daemon/connection-manager.d.ts +4 -2
- package/dist/daemon/control-protocol.d.ts +81 -4
- package/dist/daemon/control-server.d.ts +18 -1
- package/dist/daemon/create-daemon.d.ts +171 -3
- package/dist/daemon/daemon-owner.d.ts +37 -0
- package/dist/daemon/device-assertion-signer.d.ts +41 -0
- package/dist/daemon/device-keys.d.ts +15 -13
- package/dist/daemon/environment.d.ts +9 -9
- package/dist/daemon/git-workspace.d.ts +21 -0
- package/dist/daemon/observer.d.ts +81 -3
- package/dist/daemon/presence-publisher.d.ts +98 -0
- package/dist/daemon/runtime-capabilities.d.ts +1 -1
- package/dist/daemon/skill-pack-installer.d.ts +116 -0
- package/dist/daemon/task-runner.d.ts +156 -37
- package/dist/daemon/ws-transport.d.ts +3 -1
- package/dist/index.d.ts +25 -4
- package/dist/index.js +2972 -597
- package/dist/index.js.map +1 -1
- package/dist/runtime-failure.d.ts +64 -0
- package/dist/types.d.ts +114 -58
- package/package.json +4 -4
|
@@ -1,29 +1,38 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import { type RuntimeAdapter, type RuntimeCapabilities, type RuntimeDetectResult, type RuntimeEnvironmentRequirements, type Session, type TaskContext } from '../../types';
|
|
1
|
+
import { type RuntimeAdapter, type RuntimeDetectResult, type RuntimeAdapterPrepareInput, type RuntimeAdapterPrepareResult } from '../../types';
|
|
3
2
|
import { type ResolvedBin } from './resolve-bin';
|
|
4
3
|
import { type SpawnFn } from './rpc-client';
|
|
4
|
+
/**
|
|
5
|
+
* Known provider credential env var *names* (never values) — see the
|
|
6
|
+
* credential-isolation rule on `RuntimeAdapter`. `detect()` only checks
|
|
7
|
+
* whether one of these names is set; it never reads pi's own auth storage
|
|
8
|
+
* (`~/.pi/...`) or any file contents. Not exhaustive (pi supports ~30
|
|
9
|
+
* providers); covers the common ones for a useful `authPresent` signal.
|
|
10
|
+
*/
|
|
5
11
|
export interface PiAdapterOptions {
|
|
6
12
|
/** Override bin resolution — tests substitute the fake-pi fixture script. */
|
|
7
13
|
resolveBin?: () => ResolvedBin;
|
|
8
14
|
/** Override process spawning — tests substitute a fake spawn. */
|
|
9
15
|
spawnFn?: SpawnFn;
|
|
16
|
+
/**
|
|
17
|
+
* Separate-process BYOK credential boundary. The launcher receives only
|
|
18
|
+
* non-secret selection/config paths, resolves the OS credential itself,
|
|
19
|
+
* and transparently proxies the pinned Pi RPC process.
|
|
20
|
+
*/
|
|
21
|
+
byokLauncher?: PiByokLauncherConfig;
|
|
22
|
+
}
|
|
23
|
+
export interface PiByokLauncherConfig {
|
|
24
|
+
command: string;
|
|
25
|
+
/** Optional fixed launcher arguments, before BYOK's required arguments. */
|
|
26
|
+
args?: string[];
|
|
27
|
+
profileDbPath: string;
|
|
28
|
+
sessionDir: string;
|
|
29
|
+
secretServicePrefix?: string;
|
|
10
30
|
}
|
|
11
31
|
export declare class PiAdapter implements RuntimeAdapter {
|
|
12
32
|
private readonly options;
|
|
13
|
-
readonly
|
|
33
|
+
readonly descriptor: import("..").RuntimeAdapterDescriptor;
|
|
14
34
|
constructor(options?: PiAdapterOptions);
|
|
15
35
|
detect(): Promise<RuntimeDetectResult>;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* M5: pi authenticates to its ~30 supported providers via env-var API
|
|
19
|
-
* keys — `detect()`'s own `authPresent` probe above checks this identical
|
|
20
|
-
* list — so these MUST keep flowing into pi's spawned process or pi auth
|
|
21
|
-
* breaks entirely. `KNOWN_PROVIDER_ENV_VARS` above is the single source
|
|
22
|
-
* of truth, reused here rather than duplicated. No `baseNames`: nothing
|
|
23
|
-
* in this adapter or `rpc-client.ts` reads a pi-specific config-discovery
|
|
24
|
-
* variable beyond the platform baseline (`daemon/environment.ts`).
|
|
25
|
-
*/
|
|
26
|
-
environmentRequirements(): RuntimeEnvironmentRequirements;
|
|
27
|
-
start(task: TaskOfferPayload, ctx: TaskContext): Promise<Session>;
|
|
36
|
+
prepare(input: RuntimeAdapterPrepareInput): Promise<RuntimeAdapterPrepareResult>;
|
|
28
37
|
private resolveBin;
|
|
29
38
|
}
|
|
@@ -39,6 +39,9 @@ export declare class PiRpcClient {
|
|
|
39
39
|
private readonly eventQueue;
|
|
40
40
|
private closed;
|
|
41
41
|
private exitError;
|
|
42
|
+
private readonly closedPromise;
|
|
43
|
+
private resolveClosed;
|
|
44
|
+
private disposalAttempt;
|
|
42
45
|
/** Bounded tail of recent stderr lines — pi discarded this entirely before (nothing ever read `child.stderr`), which is exactly why finding #1 (`Error: Unknown option: --session-id`, exit 1) had to be root-caused by hand instead of reading it off a thrown error. See `buildExitError`. */
|
|
43
46
|
private readonly stderrRing;
|
|
44
47
|
/** Count of pi RPC message types `PiSession` (pi-adapter.ts) has told us have no `AgentEvent` mapping and aren't routine bookkeeping — see `recordUnmappedFrame`. */
|
|
@@ -51,6 +54,8 @@ export declare class PiRpcClient {
|
|
|
51
54
|
}): Promise<PiRpcMessage>;
|
|
52
55
|
/** Every non-response, non-`extension_ui_request` line — the latter is answered directly by this client (see `respondToExtensionUiRequest`) and never enqueued. */
|
|
53
56
|
get events(): AsyncIterable<PiRpcMessage>;
|
|
57
|
+
/** Local transport diagnostic retained when the process closes; consumers must classify it explicitly. */
|
|
58
|
+
get terminalError(): Error | undefined;
|
|
54
59
|
/**
|
|
55
60
|
* Record a pi RPC message `type` that `PiSession` (pi-adapter.ts) decided
|
|
56
61
|
* has no `AgentEvent` mapping and isn't routine bookkeeping (see
|
|
@@ -61,8 +66,11 @@ export declare class PiRpcClient {
|
|
|
61
66
|
* a post-mortem on a failed/hung task has it without separate log scraping.
|
|
62
67
|
*/
|
|
63
68
|
recordUnmappedFrame(type: string): void;
|
|
64
|
-
/**
|
|
69
|
+
/** Immediate process-tree termination request. `dispose()` is the settlement receipt. */
|
|
65
70
|
kill(): void;
|
|
71
|
+
waitClosed(): Promise<void>;
|
|
72
|
+
dispose(): Promise<void>;
|
|
73
|
+
private processTreeOptions;
|
|
66
74
|
private onData;
|
|
67
75
|
private onLine;
|
|
68
76
|
/**
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type ChildProcess, type SpawnOptions } from 'node:child_process';
|
|
2
|
+
export interface OwnedProcessTreeOptions {
|
|
3
|
+
child: ChildProcess;
|
|
4
|
+
waitClosed: () => Promise<void>;
|
|
5
|
+
isClosed: () => boolean;
|
|
6
|
+
label: string;
|
|
7
|
+
termGraceMs?: number;
|
|
8
|
+
killGraceMs?: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Every bundled runtime root is an owned process-group leader on POSIX. Pipes
|
|
12
|
+
* remain referenced, so `detached` changes ownership topology without making
|
|
13
|
+
* the runtime outlive the daemon. Windows uses taskkill's `/T` tree authority.
|
|
14
|
+
*/
|
|
15
|
+
export declare function withOwnedProcessTree<T extends SpawnOptions>(options: T): T;
|
|
16
|
+
/** Immediate termination request used by interrupt paths; close remains the receipt. */
|
|
17
|
+
export declare function requestOwnedProcessTreeTermination(options: OwnedProcessTreeOptions): void;
|
|
18
|
+
/** Resolve only after the adapter-owned root and descendants are quiescent. */
|
|
19
|
+
export declare function disposeOwnedProcessTree(options: OwnedProcessTreeOptions): Promise<void>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider credential names that the daemon may explicitly admit for the
|
|
3
|
+
* legacy direct-Pi path. Subscription runtimes and the BYOK custody launcher
|
|
4
|
+
* must not inherit them.
|
|
5
|
+
*
|
|
6
|
+
* This list contains names only. Credential values remain owned by the
|
|
7
|
+
* caller's environment or by the separate keys launcher.
|
|
8
|
+
*/
|
|
9
|
+
export declare const PROVIDER_CREDENTIAL_ENV_NAMES: readonly ['ANTHROPIC_API_KEY', 'ANTHROPIC_OAUTH_TOKEN', 'OPENAI_API_KEY', 'GEMINI_API_KEY', 'AZURE_OPENAI_API_KEY', 'DEEPSEEK_API_KEY', 'GROQ_API_KEY', 'MISTRAL_API_KEY', 'OPENROUTER_API_KEY', 'XAI_API_KEY', 'ZAI_API_KEY'];
|
|
10
|
+
/**
|
|
11
|
+
* Credential-shaped names stripped at subscription/BYOK custody boundaries.
|
|
12
|
+
* This is intentionally a superset of the small legacy-Pi allowlist above:
|
|
13
|
+
* denying a credential is safe, while allowing every cloud credential Pi
|
|
14
|
+
* could consume would regress the daemon's ambient-environment isolation.
|
|
15
|
+
*/
|
|
16
|
+
export declare const PROVIDER_CREDENTIAL_ENV_DENY_NAMES: readonly ["ANTHROPIC_API_KEY", "ANTHROPIC_OAUTH_TOKEN", "OPENAI_API_KEY", "GEMINI_API_KEY", "AZURE_OPENAI_API_KEY", "DEEPSEEK_API_KEY", "GROQ_API_KEY", "MISTRAL_API_KEY", "OPENROUTER_API_KEY", "XAI_API_KEY", "ZAI_API_KEY", "ANT_LING_API_KEY", "NVIDIA_API_KEY", "CEREBRAS_API_KEY", "CLOUDFLARE_API_KEY", "AI_GATEWAY_API_KEY", "ZAI_CODING_CN_API_KEY", "OPENCODE_API_KEY", "RADIUS_API_KEY", "FIREWORKS_API_KEY", "TOGETHER_API_KEY", "BASETEN_API_KEY", "KIMI_API_KEY", "MINIMAX_API_KEY", "MINIMAX_CN_API_KEY", "QWEN_TOKEN_PLAN_API_KEY", "QWEN_TOKEN_PLAN_CN_API_KEY", "XIAOMI_API_KEY", "XIAOMI_TOKEN_PLAN_CN_API_KEY", "XIAOMI_TOKEN_PLAN_AMS_API_KEY", "XIAOMI_TOKEN_PLAN_SGP_API_KEY", "AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN", "GOOGLE_APPLICATION_CREDENTIALS", "PI_PROVIDER_API_KEY"];
|
|
17
|
+
/** Return a copy that cannot pass ambient provider credentials to a child. */
|
|
18
|
+
export declare function withoutProviderCredentials(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
package/dist/bin/audit-log.d.ts
CHANGED
|
@@ -118,6 +118,18 @@ export declare const AUDIT_LOG_TRIM_TARGET_LINES = 5000;
|
|
|
118
118
|
* tail) rather than the file growing without bound.
|
|
119
119
|
*/
|
|
120
120
|
export declare const MAX_LIVE_TASK_ANCHORS = 500;
|
|
121
|
+
/**
|
|
122
|
+
* Git failures are serialized only as this closed, stable category set —
|
|
123
|
+
* never raw Git errors or command output. Projected from
|
|
124
|
+
* `daemon/git-workspace.ts`'s `GIT_ERROR_CATEGORIES` (the single source of
|
|
125
|
+
* truth for the `GitErrorCategory` union) rather than carrying a literal
|
|
126
|
+
* copy that could drift from it; the runtime half of that guarantee is
|
|
127
|
+
* `__tests__/git-category-drift.test.ts`.
|
|
128
|
+
*
|
|
129
|
+
* @internal Exported for the drift-guard test only (never re-exported from
|
|
130
|
+
* `index.ts`).
|
|
131
|
+
*/
|
|
132
|
+
export declare const STABLE_GIT_ERROR_CATEGORIES: Set<string>;
|
|
121
133
|
/**
|
|
122
134
|
* Appends one `DaemonEvent` as a single redacted JSON line (finding P1 #3 —
|
|
123
135
|
* see this file's module doc comment) at 0600, and rotates the file if it's
|