@byok-sdk/client 0.6.0 → 0.6.1
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 +91 -1
- package/dist/adapters/index.js +183 -34
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/pi/events.d.ts +1 -1
- package/dist/adapters/pi/mcp-config.d.ts +1 -0
- package/dist/adapters/pi/mcp-extension.js +25 -0
- package/dist/adapters/pi/mcp-extension.js.map +1 -0
- package/dist/adapters/pi/permission-mapping.d.ts +1 -1
- package/dist/adapters/pi/pi-adapter.d.ts +5 -0
- package/dist/adapters/pi/resolve-extensions.d.ts +11 -0
- package/dist/agent-home.d.ts +106 -0
- package/dist/bin/byok-agent.js +12892 -9473
- package/dist/bin/byok-agent.js.map +1 -1
- package/dist/bin/byok-approval-mcp.js.map +1 -1
- package/dist/bin/commands/toolsets.d.ts +8 -0
- package/dist/bin/format.d.ts +3 -0
- package/dist/daemon/agent-content-audit-store.d.ts +35 -0
- package/dist/daemon/agent-content-read.d.ts +169 -0
- package/dist/daemon/agent-egress-controller.d.ts +76 -0
- package/dist/daemon/agent-egress-policy.d.ts +36 -0
- package/dist/daemon/agent-egress-sanitizer.d.ts +38 -0
- package/dist/daemon/agent-egress-spool.d.ts +116 -0
- package/dist/daemon/agent-session-handoff-store.d.ts +82 -0
- package/dist/daemon/blob-client.d.ts +6 -2
- package/dist/daemon/connection-manager.d.ts +2 -2
- package/dist/daemon/control-protocol.d.ts +9 -0
- package/dist/daemon/create-daemon.d.ts +78 -3
- package/dist/daemon/long-poll-transport.d.ts +60 -0
- package/dist/daemon/presence-publisher.d.ts +2 -2
- package/dist/daemon/task-runner.d.ts +53 -4
- package/dist/daemon/toolset-registry.d.ts +30 -0
- package/dist/daemon/url.d.ts +21 -0
- package/dist/daemon/ws-transport.d.ts +30 -5
- package/dist/index.d.ts +12 -2
- package/dist/index.js +8646 -5272
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +44 -0
- package/package.json +7 -5
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AgentEvent } from '@byok-sdk/protocol';
|
|
2
2
|
import type { PiRpcMessage } from './rpc-client';
|
|
3
3
|
/**
|
|
4
|
-
* Map pi 0.84.
|
|
4
|
+
* Map pi 0.84.2 RPC frames into BYOK's runtime-neutral event contract.
|
|
5
5
|
*
|
|
6
6
|
* `agent_settled` is the only whole-task completion authority. `agent_end`
|
|
7
7
|
* ends one low-level agent run, but pi may still perform retry/compaction or
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const BYOK_PI_MCP_CONFIG_PATH = "BYOK_PI_MCP_CONFIG_PATH";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { readFileSync } from 'fs';
|
|
2
|
+
import { createMcpAdapter } from 'pi-mcp-adapter';
|
|
3
|
+
|
|
4
|
+
// src/adapters/pi/mcp-extension.ts
|
|
5
|
+
|
|
6
|
+
// src/adapters/pi/mcp-config.ts
|
|
7
|
+
var BYOK_PI_MCP_CONFIG_PATH = "BYOK_PI_MCP_CONFIG_PATH";
|
|
8
|
+
|
|
9
|
+
// src/adapters/pi/mcp-extension.ts
|
|
10
|
+
function loadTaskScopedConfig() {
|
|
11
|
+
const configPath = process.env[BYOK_PI_MCP_CONFIG_PATH];
|
|
12
|
+
if (!configPath) {
|
|
13
|
+
throw new Error(`${BYOK_PI_MCP_CONFIG_PATH} is required for the BYOK Pi MCP extension`);
|
|
14
|
+
}
|
|
15
|
+
const parsed = JSON.parse(readFileSync(configPath, "utf8"));
|
|
16
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed) || !Object.prototype.hasOwnProperty.call(parsed, "mcpServers") || parsed.mcpServers === null || typeof parsed.mcpServers !== "object" || Array.isArray(parsed.mcpServers)) {
|
|
17
|
+
throw new Error("BYOK Pi MCP configuration must contain an mcpServers object");
|
|
18
|
+
}
|
|
19
|
+
return parsed;
|
|
20
|
+
}
|
|
21
|
+
var mcp_extension_default = createMcpAdapter({ config: loadTaskScopedConfig() });
|
|
22
|
+
|
|
23
|
+
export { mcp_extension_default as default };
|
|
24
|
+
//# sourceMappingURL=mcp-extension.js.map
|
|
25
|
+
//# sourceMappingURL=mcp-extension.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/adapters/pi/mcp-config.ts","../../../src/adapters/pi/mcp-extension.ts"],"names":[],"mappings":";;;;;;AAAO,IAAM,uBAAA,GAA0B,yBAAA;;;ACKvC,SAAS,oBAAA,GAAkC;AACzC,EAAA,MAAM,UAAA,GAAa,OAAA,CAAQ,GAAA,CAAI,uBAAuB,CAAA;AACtD,EAAA,IAAI,CAAC,UAAA,EAAY;AACf,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,EAAG,uBAAuB,CAAA,0CAAA,CAA4C,CAAA;AAAA,EACxF;AAEA,EAAA,MAAM,SAAS,IAAA,CAAK,KAAA,CAAM,YAAA,CAAa,UAAA,EAAY,MAAM,CAAC,CAAA;AAC1D,EAAA,IACE,MAAA,KAAW,IAAA,IACX,OAAO,MAAA,KAAW,QAAA,IAClB,KAAA,CAAM,OAAA,CAAQ,MAAM,CAAA,IACpB,CAAC,MAAA,CAAO,SAAA,CAAU,cAAA,CAAe,IAAA,CAAK,MAAA,EAAQ,YAAY,CAAA,IACzD,MAAA,CAAoC,UAAA,KAAe,IAAA,IACpD,OAAQ,MAAA,CAAoC,UAAA,KAAe,QAAA,IAC3D,KAAA,CAAM,OAAA,CAAS,MAAA,CAAoC,UAAU,CAAA,EAC7D;AACA,IAAA,MAAM,IAAI,MAAM,6DAA6D,CAAA;AAAA,EAC/E;AACA,EAAA,OAAO,MAAA;AACT;AAIA,IAAO,wBAAQ,gBAAA,CAAiB,EAAE,MAAA,EAAQ,oBAAA,IAAwB","file":"mcp-extension.js","sourcesContent":["export const BYOK_PI_MCP_CONFIG_PATH = 'BYOK_PI_MCP_CONFIG_PATH';\n","import { readFileSync } from 'node:fs';\nimport { createMcpAdapter } from 'pi-mcp-adapter';\nimport type { McpConfig } from 'pi-mcp-adapter/types';\nimport { BYOK_PI_MCP_CONFIG_PATH } from './mcp-config';\n\nfunction loadTaskScopedConfig(): McpConfig {\n const configPath = process.env[BYOK_PI_MCP_CONFIG_PATH];\n if (!configPath) {\n throw new Error(`${BYOK_PI_MCP_CONFIG_PATH} is required for the BYOK Pi MCP extension`);\n }\n\n const parsed = JSON.parse(readFileSync(configPath, 'utf8')) as unknown;\n if (\n parsed === null ||\n typeof parsed !== 'object' ||\n Array.isArray(parsed) ||\n !Object.prototype.hasOwnProperty.call(parsed, 'mcpServers') ||\n (parsed as { mcpServers?: unknown }).mcpServers === null ||\n typeof (parsed as { mcpServers?: unknown }).mcpServers !== 'object' ||\n Array.isArray((parsed as { mcpServers?: unknown }).mcpServers)\n ) {\n throw new Error('BYOK Pi MCP configuration must contain an mcpServers object');\n }\n return parsed as McpConfig;\n}\n\n// Supplying `config` is pi-mcp-adapter's isolated SDK mode: it deliberately\n// does not merge ~/.config/mcp, .mcp.json, Pi settings, imports, or argv.\nexport default createMcpAdapter({ config: loadTaskScopedConfig() });\n"]}
|
|
@@ -8,7 +8,7 @@ export interface PiPermissionMapping {
|
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* Map an effective {@link PermissionPolicy} to `pi --mode rpc` CLI args,
|
|
11
|
-
* fail-closed against the exact pi 0.84.
|
|
11
|
+
* fail-closed against the exact pi 0.84.2 CLI contract:
|
|
12
12
|
*
|
|
13
13
|
* - `auto` / `readonly` are expressible via `--tools` / `--no-tools`.
|
|
14
14
|
* - `confirm` and `plan` are NOT expressible: pi ships no built-in per-call
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type RuntimeAdapter, type RuntimeDetectResult, type RuntimeAdapterPrepareInput, type RuntimeAdapterPrepareResult } from '../../types';
|
|
2
2
|
import { type ResolvedBin } from './resolve-bin';
|
|
3
|
+
import { type ResolvedPiExtensions } from './resolve-extensions';
|
|
3
4
|
import { type SpawnFn } from './rpc-client';
|
|
4
5
|
/**
|
|
5
6
|
* Known provider credential env var *names* (never values) — see the
|
|
@@ -13,6 +14,8 @@ export interface PiAdapterOptions {
|
|
|
13
14
|
resolveBin?: () => ResolvedBin;
|
|
14
15
|
/** Override process spawning — tests substitute a fake spawn. */
|
|
15
16
|
spawnFn?: SpawnFn;
|
|
17
|
+
/** Override bundled extension resolution — tests use stable fixture paths. */
|
|
18
|
+
resolveExtensions?: () => ResolvedPiExtensions;
|
|
16
19
|
/**
|
|
17
20
|
* Separate-process BYOK credential boundary. The launcher receives only
|
|
18
21
|
* non-secret selection/config paths, resolves the OS credential itself,
|
|
@@ -26,8 +29,10 @@ export interface PiByokLauncherConfig {
|
|
|
26
29
|
args?: string[];
|
|
27
30
|
profileDbPath: string;
|
|
28
31
|
sessionDir: string;
|
|
32
|
+
macosKeychainPath?: string;
|
|
29
33
|
secretServicePrefix?: string;
|
|
30
34
|
}
|
|
35
|
+
export declare function validatePiByokLauncherConfig(launcher: PiByokLauncherConfig | undefined): void;
|
|
31
36
|
export declare class PiAdapter implements RuntimeAdapter {
|
|
32
37
|
private readonly options;
|
|
33
38
|
readonly descriptor: import("..").RuntimeAdapterDescriptor;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface ResolvedPiExtensions {
|
|
2
|
+
readonly webAccess: string;
|
|
3
|
+
readonly mcpAdapter: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Resolve the two Pi extensions shipped as required `@byok-sdk/client`
|
|
7
|
+
* dependencies. Pi receives explicit extension paths so runtime behavior is
|
|
8
|
+
* pinned to this package graph rather than a user's mutable global Pi package
|
|
9
|
+
* settings.
|
|
10
|
+
*/
|
|
11
|
+
export declare function resolvePiExtensions(): ResolvedPiExtensions;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { type AgentRef } from '@byok-sdk/protocol';
|
|
2
|
+
export type { AgentRef } from '@byok-sdk/protocol';
|
|
3
|
+
export declare const AGENT_HOME_DIRECTORY = "agents";
|
|
4
|
+
export declare const AGENT_HOME_INTERNAL_DIRECTORY = ".byok";
|
|
5
|
+
export declare class AgentHomeError extends Error {
|
|
6
|
+
constructor(message: string);
|
|
7
|
+
}
|
|
8
|
+
export declare class AgentRefValidationError extends AgentHomeError {
|
|
9
|
+
constructor(message: string);
|
|
10
|
+
}
|
|
11
|
+
export declare class AgentHomeResolutionError extends AgentHomeError {
|
|
12
|
+
constructor(message: string);
|
|
13
|
+
}
|
|
14
|
+
export declare class AgentHomeCollisionError extends AgentHomeResolutionError {
|
|
15
|
+
constructor(message: string);
|
|
16
|
+
}
|
|
17
|
+
export declare class AgentHomeBusyError extends AgentHomeError {
|
|
18
|
+
constructor(message: string);
|
|
19
|
+
}
|
|
20
|
+
/** A malformed persisted lease is integrity failure, never retryable contention. */
|
|
21
|
+
export declare class AgentHomeLeaseCorruptError extends AgentHomeResolutionError {
|
|
22
|
+
constructor(message: string);
|
|
23
|
+
}
|
|
24
|
+
export interface AgentHomeResolution {
|
|
25
|
+
readonly agentRef: AgentRef;
|
|
26
|
+
/** Absolute branded storage root supplied by the host, after realpath. */
|
|
27
|
+
readonly hostStorageRoot: string;
|
|
28
|
+
/** SDK-owned `<hostStorageRoot>/agents` authority, after realpath. */
|
|
29
|
+
readonly agentsRoot: string;
|
|
30
|
+
/** Canonical absolute Agent home. This is also the runtime cwd. */
|
|
31
|
+
readonly homeDir: string;
|
|
32
|
+
readonly canonicalHome: string;
|
|
33
|
+
}
|
|
34
|
+
export interface AgentHomeProjectionInput extends AgentHomeResolution {
|
|
35
|
+
readonly cwd: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Optional downstream projection hook. The SDK supplies the canonical home;
|
|
39
|
+
* the host supplies opaque, redacted product content and never joins
|
|
40
|
+
* `agents/<agentId>` itself. The SDK does not parse the projected content.
|
|
41
|
+
*/
|
|
42
|
+
export interface AgentHomeProjection {
|
|
43
|
+
prepare(input: AgentHomeProjectionInput): void | Promise<void>;
|
|
44
|
+
}
|
|
45
|
+
export type AgentHomeProjectionFunction = (input: AgentHomeProjectionInput) => void | Promise<void>;
|
|
46
|
+
export interface AgentHomeLease {
|
|
47
|
+
readonly leaseId: string;
|
|
48
|
+
readonly agentRef: AgentRef;
|
|
49
|
+
readonly canonicalHome: string;
|
|
50
|
+
readonly cwd: string;
|
|
51
|
+
release(): Promise<void>;
|
|
52
|
+
}
|
|
53
|
+
export interface AgentHomeBinding {
|
|
54
|
+
readonly resolution: AgentHomeResolution;
|
|
55
|
+
readonly lease: AgentHomeLease;
|
|
56
|
+
}
|
|
57
|
+
export declare function validateAgentRef(value: unknown): AgentRef;
|
|
58
|
+
/**
|
|
59
|
+
* SDK-owned deterministic Agent-home layout. The downstream supplies exactly
|
|
60
|
+
* one absolute branded storage root; there is deliberately no host path
|
|
61
|
+
* resolver and no second workspace authority.
|
|
62
|
+
*/
|
|
63
|
+
export declare class AgentHomeLayout {
|
|
64
|
+
private readonly hostStorageRootInput;
|
|
65
|
+
private readonly agentIdByCanonicalHome;
|
|
66
|
+
private canonicalRoot?;
|
|
67
|
+
constructor(hostStorageRoot: string);
|
|
68
|
+
resolve(agentRefInput: AgentRef): Promise<AgentHomeResolution>;
|
|
69
|
+
/**
|
|
70
|
+
* Prove the canonical root is materializable and writable before the daemon
|
|
71
|
+
* advertises Agent-home capability. No Agent identity or persistent Agent
|
|
72
|
+
* file is created by this preflight.
|
|
73
|
+
*/
|
|
74
|
+
preflight(): Promise<void>;
|
|
75
|
+
private resolveRoot;
|
|
76
|
+
}
|
|
77
|
+
export declare function stableAgentHomeOwnerId(storeDir: string, productId: string): string;
|
|
78
|
+
/** One-writer lease backed by both a process registry and an exclusive marker. */
|
|
79
|
+
export declare class AgentHomeLeaseManager {
|
|
80
|
+
private static readonly held;
|
|
81
|
+
private readonly ownerId;
|
|
82
|
+
constructor(options?: {
|
|
83
|
+
ownerId?: string;
|
|
84
|
+
});
|
|
85
|
+
acquire(resolution: AgentHomeResolution): Promise<AgentHomeLease>;
|
|
86
|
+
private openLeaseMarker;
|
|
87
|
+
}
|
|
88
|
+
/** Coordinates SDK-owned initialization, optional projection, and the lease. */
|
|
89
|
+
export declare class AgentHomeManager {
|
|
90
|
+
readonly layout: AgentHomeLayout;
|
|
91
|
+
readonly projection?: AgentHomeProjection;
|
|
92
|
+
readonly leaseManager: AgentHomeLeaseManager;
|
|
93
|
+
constructor(options: {
|
|
94
|
+
hostStorageRoot: string;
|
|
95
|
+
projection?: AgentHomeProjection;
|
|
96
|
+
leaseManager?: AgentHomeLeaseManager;
|
|
97
|
+
});
|
|
98
|
+
prepare(agentRef: AgentRef): Promise<AgentHomeBinding>;
|
|
99
|
+
/** Validate the configured root before capability publication. */
|
|
100
|
+
preflight(): Promise<void>;
|
|
101
|
+
/** Resolve and lease without applying downstream projection side effects. */
|
|
102
|
+
acquire(agentRef: AgentRef): Promise<AgentHomeBinding>;
|
|
103
|
+
/** Initialize only after any requested session exact-match has succeeded. */
|
|
104
|
+
initialize(binding: AgentHomeBinding): Promise<void>;
|
|
105
|
+
}
|
|
106
|
+
export declare function createAgentHomeProjection(prepare: AgentHomeProjectionFunction): AgentHomeProjection;
|