@byok-sdk/client 0.12.0 → 0.14.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.
Files changed (48) hide show
  1. package/README.md +93 -0
  2. package/dist/adapters/claude/process-client.d.ts +24 -0
  3. package/dist/adapters/codex/process-runner.d.ts +46 -1
  4. package/dist/adapters/index.js +433 -33
  5. package/dist/adapters/index.js.map +1 -1
  6. package/dist/adapters/pi/events.d.ts +1 -1
  7. package/dist/adapters/pi/pi-adapter.d.ts +3 -0
  8. package/dist/adapters/pi/rpc-client.d.ts +47 -1
  9. package/dist/adapters/pi/subagents-policy-extension.js +1 -1
  10. package/dist/adapters/pi/subagents-policy-extension.js.map +1 -1
  11. package/dist/adapters/pi/team-interaction-extension.d.ts +24 -0
  12. package/dist/adapters/pi/team-interaction-extension.js +81 -0
  13. package/dist/adapters/pi/team-interaction-extension.js.map +1 -0
  14. package/dist/adapters/process-tree.d.ts +74 -4
  15. package/dist/adapters/provider-credential-environment.d.ts +1 -1
  16. package/dist/adapters/win32-job-object.d.ts +101 -0
  17. package/dist/agent-home.d.ts +74 -0
  18. package/dist/agent-memory/index.d.ts +1 -1
  19. package/dist/agent-memory/index.js.map +1 -1
  20. package/dist/bin/byok-agent-memory-mcp.js.map +1 -1
  21. package/dist/bin/byok-agent-message-mcp.js.map +1 -1
  22. package/dist/bin/byok-agent-team-mcp.js.map +1 -1
  23. package/dist/bin/byok-agent.js +9571 -8272
  24. package/dist/bin/byok-agent.js.map +1 -1
  25. package/dist/bin/byok-approval-mcp.js.map +1 -1
  26. package/dist/bin/commands/team-pi-relay.d.ts +24 -0
  27. package/dist/bin/commands/team-relay.d.ts +11 -0
  28. package/dist/bin/team-codex-relay.d.ts +32 -0
  29. package/dist/bin/team-notification-relay.d.ts +40 -0
  30. package/dist/bin/team-pi-session.d.ts +59 -0
  31. package/dist/daemon/agent-egress-policy.d.ts +8 -0
  32. package/dist/daemon/connection-manager.d.ts +66 -224
  33. package/dist/daemon/control-protocol.d.ts +10 -1
  34. package/dist/daemon/create-daemon.d.ts +58 -13
  35. package/dist/daemon/event-spill.d.ts +90 -0
  36. package/dist/daemon/journal/journal.d.ts +15 -3
  37. package/dist/daemon/journal/sqlite-journal.d.ts +7 -2
  38. package/dist/daemon/long-poll-transport.d.ts +28 -70
  39. package/dist/daemon/observer.d.ts +1 -1
  40. package/dist/daemon/task-runner.d.ts +31 -0
  41. package/dist/daemon/team-workspace.d.ts +9 -0
  42. package/dist/daemon/url.d.ts +10 -12
  43. package/dist/diagnostics/support-bundle.d.ts +1 -1
  44. package/dist/index.d.ts +2 -2
  45. package/dist/index.js +1334 -696
  46. package/dist/index.js.map +1 -1
  47. package/package.json +9 -8
  48. package/dist/daemon/ws-transport.d.ts +0 -139
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@byok-sdk/client",
3
- "version": "0.12.0",
3
+ "version": "0.14.0",
4
4
  "description": "BYOK SDK client daemon: runs on the end user's machine, pairs with a SaaS server, and drives a local coding-agent runtime",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -63,19 +63,20 @@
63
63
  "audit:credentials": "node scripts/linux-credential-audit.mjs",
64
64
  "clean": "rm -rf dist"
65
65
  },
66
+ "optionalDependencies": {
67
+ "koffi": "3.2.0"
68
+ },
66
69
  "dependencies": {
67
- "@byok-sdk/core": "0.12.0",
68
- "@byok-sdk/protocol": "0.12.0",
69
- "@earendil-works/pi-coding-agent": "0.84.2",
70
+ "@byok-sdk/core": "0.14.0",
71
+ "@byok-sdk/protocol": "0.14.0",
72
+ "@earendil-works/pi-coding-agent": "0.85.1",
70
73
  "@juicesharp/rpiv-todo": "2.8.0",
71
74
  "pi-mcp-adapter": "2.27.0",
72
75
  "pi-subagents": "0.60.0",
73
- "pi-web-access": "0.24.1",
74
- "ws": "^8.21.1"
76
+ "pi-web-access": "0.24.1"
75
77
  },
76
78
  "devDependencies": {
77
- "@types/ws": "^8.18.1",
78
- "@byok-sdk/server": "0.12.0",
79
+ "@byok-sdk/server": "0.14.0",
79
80
  "@hono/node-server": "^2.0.10"
80
81
  }
81
82
  }
@@ -1,139 +0,0 @@
1
- import { type CapabilityFlag, type Envelope, type RuntimeInfo, type ToolsetId } from '@byok-sdk/protocol';
2
- import { type TransportEndpoint } from './url';
3
- export type ConnectionState = 'connecting' | 'open' | 'closed' | 'degraded' | 'revoked';
4
- /**
5
- * The WS upgrade itself was rejected with a non-101 HTTP status (e.g. 401 for
6
- * an expired/invalid bearer token). Surfaced via `onConnectOutcome` so
7
- * `ConnectionManager` can force a reactive token renewal before the next
8
- * attempt (protocol §6.2, "reactively on 401").
9
- *
10
- * Carries the {@link TransportEndpoint} the rejected upgrade was aimed at, so
11
- * a 401 in a log names WHICH server and path refused it instead of leaving
12
- * the reader to guess between a stale `serverUrl` and a genuinely expired
13
- * token. The endpoint's own construction is what keeps the bearer token out
14
- * of this message — see {@link describeEndpoint}.
15
- */
16
- export declare class WsUnexpectedStatusError extends Error {
17
- readonly status: number;
18
- readonly endpoint: TransportEndpoint;
19
- constructor(status: number, endpoint: TransportEndpoint);
20
- }
21
- export interface BackoffOptions {
22
- baseMs?: number;
23
- maxMs?: number;
24
- factor?: number;
25
- }
26
- export interface LivenessOptions {
27
- /** Terminate and reconnect if no data/ping arrives for this long. Default 75s (server pings every 30s per the pinned heartbeat convention). */
28
- timeoutMs?: number;
29
- /** How often to check for silence. Default: timeoutMs/3, floored at 1s. */
30
- checkIntervalMs?: number;
31
- }
32
- export interface WsTransportOptions {
33
- serverUrl: string;
34
- /** Resolves the current valid bearer token; called fresh before every connect attempt (initial and every reconnect) so a proactively-renewed token is always used. */
35
- getToken: () => Promise<string>;
36
- deviceId: string;
37
- productId: string;
38
- capabilities: CapabilityFlag[];
39
- /** U4a Local Agent release version; the sole client-version authority. */
40
- clientVersion?: string;
41
- /** Detected runtimes, sent on every `conn.hello` (protocol §10 gap #4/#11). */
42
- runtimes?: RuntimeInfo[];
43
- /** Reads current sorted logical IDs for every hello; no executable definition crosses the wire. */
44
- getConfiguredToolsets?: () => readonly ToolsetId[];
45
- /** The redelivery cursor to send as `conn.hello.cursor` (protocol §9) — read fresh on every connect so a value learned mid-connection is used on the next reconnect. */
46
- getCursor?: () => number | undefined;
47
- onEnvelope: (envelope: Envelope) => void;
48
- onStateChange?: (state: ConnectionState) => void;
49
- /**
50
- * Fired the moment `conn.ack` is processed and the connection becomes
51
- * usable — independent of `onConnectOutcome`, which only fires on close (a
52
- * healthy, still-open connection never reaches it). Carries the ack's own
53
- * `capabilities` (untyped `string[]` on the wire, forward-compat — a
54
- * server may advertise a flag this build doesn't recognize yet), so a
55
- * caller can learn what the CURRENTLY connected server understands (e.g.
56
- * the `approval_resolved` capability flag — see
57
- * `ConnectionManager.getServerCapabilities`) instead of it being silently
58
- * discarded after the handshake completes.
59
- */
60
- onAcked?: (capabilities: string[]) => void;
61
- /**
62
- * Fired once per connection attempt when the socket closes, reporting
63
- * whether that attempt ever reached `conn.ack` (`acked`) before closing,
64
- * and the causing error when the attempt failed before a socket even
65
- * opened (e.g. `getToken()` rejecting). Used by `ConnectionManager` to
66
- * count consecutive failures for the long-poll fallback (protocol §8).
67
- *
68
- * `endpoint` names the route this attempt was aimed at (computed once per
69
- * `openSocket()`, so every outcome site reports the same one) — a
70
- * consecutive-failure count in a log is only actionable once it says WHICH
71
- * server kept refusing.
72
- */
73
- onConnectOutcome?: (acked: boolean, err: unknown, endpoint: TransportEndpoint) => void;
74
- backoff?: BackoffOptions;
75
- liveness?: LivenessOptions;
76
- /** Deterministic automatic reconnect delay. Manual `connect({auto:false})` never reaches this scheduler. */
77
- reconnectDelayMs?: (attempt: number, baseDelayMs: number) => number;
78
- }
79
- /**
80
- * One canonical authenticated capability snapshot for both transports.
81
- * Long-poll sends this envelope through `POST /byok/messages`; WS sends the
82
- * same shape as its opening frame. Keeping construction here prevents one
83
- * transport from silently omitting a newly added daemon capability.
84
- */
85
- export declare function createConnectionHelloEnvelope(opts: Pick<WsTransportOptions, 'deviceId' | 'productId' | 'capabilities' | 'clientVersion' | 'runtimes' | 'getConfiguredToolsets' | 'getCursor'>): Envelope;
86
- /**
87
- * The daemon's outbound-only WS connection: opens, sends `conn.hello`, waits
88
- * for `conn.ack`, and reconnects with capped exponential backoff + jitter on
89
- * drop.
90
- *
91
- * Design B (finding N4): this transport is a stateless drainer — it holds no
92
- * outbound queue of its own. `ConnectionManager` owns the single shared
93
- * outbox both transports drain from (so a transport switch never strands a
94
- * queued envelope); `sendNow` just attempts to hand one envelope to the
95
- * live socket right now and reports back whether that actually happened,
96
- * leaving all queueing/retry policy to the caller.
97
- *
98
- * Auto-reconnect can be paused (`stopAutoReconnect`) and single attempts
99
- * made on demand (`connect({ auto: false })`) — used by `ConnectionManager`
100
- * to probe WS recovery every few minutes while long-polling, without this
101
- * transport's own backoff loop fighting that cadence.
102
- */
103
- export declare class WsTransport {
104
- private readonly opts;
105
- private socket;
106
- private closedByUser;
107
- private autoReconnect;
108
- private acked;
109
- private everAckedThisAttempt;
110
- private reconnectAttempt;
111
- private reconnectTimer;
112
- private livenessTimer;
113
- private lastActivity;
114
- private lastUnexpectedStatus;
115
- private ackWaiters;
116
- constructor(opts: WsTransportOptions);
117
- connect(opts?: {
118
- auto?: boolean;
119
- }): void;
120
- /** Stop scheduling further reconnect attempts (any pending one is cancelled too); the current socket, if any, is left alone. Used when handing retry ownership to a slower external cadence (e.g. the long-poll fallback's periodic WS probe). */
121
- stopAutoReconnect(): void;
122
- /** Resume normal auto-reconnect-on-close behavior (does not itself trigger a connect — only affects future closes). */
123
- resumeAutoReconnect(): void;
124
- get isOpen(): boolean;
125
- /**
126
- * Attempt to send ONE envelope right now; returns whether it actually went
127
- * out. `false` means the socket isn't currently open+acked — the caller
128
- * (`ConnectionManager.drainOutbox`, Design B/finding N4) owns re-queueing
129
- * and retrying later (e.g. on the next `onAcked`), since this transport no
130
- * longer buffers anything itself.
131
- */
132
- sendNow(envelope: Envelope): boolean;
133
- waitForAck(timeoutMs?: number): Promise<void>;
134
- close(): void;
135
- private openSocket;
136
- private scheduleReconnect;
137
- private startLivenessCheck;
138
- private stopLivenessCheck;
139
- }