@bivy/bivy 0.0.0 → 0.1.0-staging.3
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/LICENSE +105 -0
- package/README.md +265 -5
- package/bin/acp-shim.mjs +298 -0
- package/bin/agent-manifest.json +277 -0
- package/bin/bivy.mjs +4147 -0
- package/bin/codex-app-server-shim.mjs +447 -0
- package/bin/patch-pi-dependencies.mjs +44 -0
- package/bin/prune-sessions.mjs +52 -0
- package/bin/sessions-list.mjs +27 -0
- package/bin/shim-path.mjs +126 -0
- package/bin/uninstall-paths.mjs +48 -0
- package/dist/approval.js +87 -0
- package/dist/attach.js +248 -0
- package/dist/auth.js +258 -0
- package/dist/bivy-login.js +180 -0
- package/dist/browser-open.js +50 -0
- package/dist/control-plane-tasks.js +236 -0
- package/dist/data-dir.js +25 -0
- package/dist/device-registry.js +201 -0
- package/dist/e2e.js +70 -0
- package/dist/ephemeral-exec.js +109 -0
- package/dist/exec.js +209 -0
- package/dist/git-auth.js +155 -0
- package/dist/github-app-auth.js +107 -0
- package/dist/github-app-connect.js +235 -0
- package/dist/github-app-manifest.js +82 -0
- package/dist/github-app-sync-cli.js +93 -0
- package/dist/github-app-vault.js +106 -0
- package/dist/github-apps.js +121 -0
- package/dist/github-connect-repo.js +74 -0
- package/dist/github-device-auth.js +109 -0
- package/dist/github-tasks.js +650 -0
- package/dist/guard.js +109 -0
- package/dist/harness/cache-evict.js +88 -0
- package/dist/harness/checkpoint.js +0 -0
- package/dist/harness/cow-clone.js +84 -0
- package/dist/harness/dep-cache.js +78 -0
- package/dist/harness/disk-admission.js +46 -0
- package/dist/harness/egress.js +30 -0
- package/dist/harness/manager.js +97 -0
- package/dist/harness/mcp-config-formats.js +164 -0
- package/dist/harness/mcp-config.js +111 -0
- package/dist/harness/mcp-inject.js +134 -0
- package/dist/harness/mcp-proxy-cli.js +88 -0
- package/dist/harness/mcp-proxy.js +150 -0
- package/dist/harness/net-proxy.js +120 -0
- package/dist/harness/sandbox.js +96 -0
- package/dist/history-sync.js +26 -0
- package/dist/hosted-endpoints.d.mts +14 -0
- package/dist/hosted-endpoints.mjs +35 -0
- package/dist/identity.js +153 -0
- package/dist/integrations/index.js +4 -0
- package/dist/integrations/manager.js +279 -0
- package/dist/integrations/oauth.js +78 -0
- package/dist/integrations/registry.js +239 -0
- package/dist/integrations/store.js +54 -0
- package/dist/integrations/types.js +1 -0
- package/dist/linear-tasks.js +49 -0
- package/dist/metadata.js +226 -0
- package/dist/multiplexer.js +79 -0
- package/dist/native-pi.js +38 -0
- package/dist/node-stats.js +237 -0
- package/dist/pairing-crypto.js +105 -0
- package/dist/policy/conditions.js +103 -0
- package/dist/policy/policy-engine.js +20 -0
- package/dist/policy/risk.js +18 -0
- package/dist/policy/ruleset.js +113 -0
- package/dist/policy/run-policy.js +108 -0
- package/dist/policy/session-reroute.js +96 -0
- package/dist/pty-runner.py +95 -0
- package/dist/question.js +146 -0
- package/dist/redact.js +97 -0
- package/dist/relay-attach.js +345 -0
- package/dist/relay-chunk.js +73 -0
- package/dist/relay-cli-crypto.js +70 -0
- package/dist/relay-client.js +344 -0
- package/dist/relay-setup.js +262 -0
- package/dist/repo-workspace.js +208 -0
- package/dist/runtime/adoption.js +45 -0
- package/dist/runtime/agent-service-bin.js +149 -0
- package/dist/runtime/agent-service.js +439 -0
- package/dist/runtime/ansi.js +27 -0
- package/dist/runtime/anthropic-preflight.js +80 -0
- package/dist/runtime/claude-code.js +1364 -0
- package/dist/runtime/cli-parsers.js +647 -0
- package/dist/runtime/codex-auth.js +168 -0
- package/dist/runtime/codex-preflight.js +60 -0
- package/dist/runtime/codex-sessions.js +229 -0
- package/dist/runtime/control-plane-location.js +74 -0
- package/dist/runtime/credential-ingest.js +122 -0
- package/dist/runtime/credential-provisioning.js +79 -0
- package/dist/runtime/credential-store.js +435 -0
- package/dist/runtime/credentials.js +153 -0
- package/dist/runtime/host.js +153 -0
- package/dist/runtime/index.js +1548 -0
- package/dist/runtime/local-model-store.js +194 -0
- package/dist/runtime/location-registry.js +28 -0
- package/dist/runtime/model-catalog.js +97 -0
- package/dist/runtime/model-namer.js +85 -0
- package/dist/runtime/native-process-scan.js +102 -0
- package/dist/runtime/native-session-discovery.js +103 -0
- package/dist/runtime/normalize.js +75 -0
- package/dist/runtime/oauth/model-oauth-providers.js +75 -0
- package/dist/runtime/oauth/model-oauth.js +324 -0
- package/dist/runtime/opencode-preflight.js +55 -0
- package/dist/runtime/pi-auth.js +82 -0
- package/dist/runtime/pi-oauth.js +52 -0
- package/dist/runtime/pi-session-discovery.js +42 -0
- package/dist/runtime/pi.js +518 -0
- package/dist/runtime/process.js +499 -0
- package/dist/runtime/protocol.js +630 -0
- package/dist/runtime/remote.js +541 -0
- package/dist/runtime/rpc-protocol.js +56 -0
- package/dist/runtime/ruleset-store.js +117 -0
- package/dist/runtime/session-location.js +50 -0
- package/dist/runtime/types.js +17 -0
- package/dist/secrets-cli.js +134 -0
- package/dist/secrets.js +264 -0
- package/dist/server.js +9411 -0
- package/dist/session/bivy-session.js +1 -0
- package/dist/session/checkpoint-pack.js +133 -0
- package/dist/session/event-log.js +340 -0
- package/dist/session/fork-dirty.js +73 -0
- package/dist/session/fork-prereqs.js +61 -0
- package/dist/session/fork.js +57 -0
- package/dist/session/native-import.js +56 -0
- package/dist/session/reconnect.js +168 -0
- package/dist/session/replication-service.js +236 -0
- package/dist/session/replication.js +106 -0
- package/dist/session/replicator.js +140 -0
- package/dist/session/session-new-dedupe.js +42 -0
- package/dist/session/sibling-client.js +201 -0
- package/dist/session/transcript-merge.js +131 -0
- package/dist/session/transcript-normal.js +130 -0
- package/dist/session/workspace-context.js +1 -0
- package/dist/session-event-coalescer.js +50 -0
- package/dist/session-identity.js +34 -0
- package/dist/session-ref.js +65 -0
- package/dist/stt-cli.js +131 -0
- package/dist/stt.js +168 -0
- package/dist/terminal.js +409 -0
- package/dist/wire-format.js +67 -0
- package/dist/worktree-provision.js +118 -0
- package/dist/worktree.js +117 -0
- package/package.json +40 -6
- package/public/qr.js +464 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
// SPDX-License-Identifier: FSL-1.1-ALv2
|
|
2
|
+
// Copyright (c) 2026 Petter André Sjulstad
|
|
3
|
+
import { listRuntimes, makeRuntime } from "./index.js";
|
|
4
|
+
import { RemoteRuntime, connectSocketTransport } from "./remote.js";
|
|
5
|
+
function remoteRuntimeSelection() {
|
|
6
|
+
const flag = process.env.BIVY_REMOTE_RUNTIME?.trim();
|
|
7
|
+
if (!flag || flag === "0" || flag.toLowerCase() === "false")
|
|
8
|
+
return null;
|
|
9
|
+
const addr = process.env.BIVY_REMOTE_RUNTIME_ADDR?.trim();
|
|
10
|
+
if (!addr)
|
|
11
|
+
return null; // enabled but nowhere to connect — stay in-process
|
|
12
|
+
const all = ["1", "true", "all", "*"].includes(flag.toLowerCase());
|
|
13
|
+
const ids = all ? null : new Set(flag.split(",").map((s) => s.trim().toLowerCase()).filter(Boolean));
|
|
14
|
+
return { addr, enabled: (id) => all || Boolean(ids?.has(id)) };
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Whether the remote-runtime path is active at all (flag set AND an address to
|
|
18
|
+
* connect to). Stage 3 gates startup adoption and the control-plane location
|
|
19
|
+
* registry on this so those hooks are inert — and the daemon byte-identical —
|
|
20
|
+
* when the flag is off (docs/agent-node-decoupling.md).
|
|
21
|
+
*/
|
|
22
|
+
export function remoteRuntimeEnabled() {
|
|
23
|
+
return remoteRuntimeSelection() !== null;
|
|
24
|
+
}
|
|
25
|
+
/** Fill a RuntimeInfo's partial capabilities into a full, default-false surface. */
|
|
26
|
+
function fullCapabilities(partial) {
|
|
27
|
+
return { toolInterception: false, modelSelection: false, packages: false, resume: false, fork: false, ...partial };
|
|
28
|
+
}
|
|
29
|
+
export function enforcementLevelFor(capabilities, runtimeId) {
|
|
30
|
+
if (capabilities.toolInterception)
|
|
31
|
+
return "strong";
|
|
32
|
+
if (runtimeId === "generic-cli")
|
|
33
|
+
return "boundary";
|
|
34
|
+
return "observe_only";
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Small runtime host seam above concrete adapters. The node should talk to this
|
|
38
|
+
* for registry lookup, adapter caching, session create/open/list, and capability
|
|
39
|
+
* reporting instead of scattering runtime glue through server.ts.
|
|
40
|
+
*/
|
|
41
|
+
export class RuntimeHost {
|
|
42
|
+
options;
|
|
43
|
+
cache = new Map();
|
|
44
|
+
constructor(options) {
|
|
45
|
+
this.options = options;
|
|
46
|
+
}
|
|
47
|
+
list(currentId) {
|
|
48
|
+
return listRuntimes(currentId);
|
|
49
|
+
}
|
|
50
|
+
resolveRuntimeId(requested, fallback) {
|
|
51
|
+
const wantId = (requested || fallback).toLowerCase();
|
|
52
|
+
const info = this.list().find((candidate) => candidate.id === wantId);
|
|
53
|
+
if (!info)
|
|
54
|
+
throw new Error(`Unknown agent: ${wantId}`);
|
|
55
|
+
if (info.status !== "available")
|
|
56
|
+
throw new Error(`${info.displayName} is not available on this node yet.`);
|
|
57
|
+
return wantId;
|
|
58
|
+
}
|
|
59
|
+
get(requested, fallback, sandbox) {
|
|
60
|
+
// Remote path (opt-in, reversible): return a RemoteRuntime that drives the
|
|
61
|
+
// runtime in a separate agent service. Checked BEFORE resolveRuntimeId so a
|
|
62
|
+
// runtime the daemon can't run locally (e.g. the Claude SDK isn't installed
|
|
63
|
+
// here) is still offloadable — remote availability is the service's business.
|
|
64
|
+
const remote = remoteRuntimeSelection();
|
|
65
|
+
const wantId = (requested || fallback).toLowerCase();
|
|
66
|
+
if (remote && remote.enabled(wantId))
|
|
67
|
+
return this.getRemote(wantId, remote.addr, sandbox);
|
|
68
|
+
const id = this.resolveRuntimeId(requested, fallback);
|
|
69
|
+
// A per-session sandbox override bakes into the runtime's launch flags, so it
|
|
70
|
+
// must not share the cached instance built for the node default. Key such
|
|
71
|
+
// runtimes by tier; runtimes without an override keep the plain-id entry.
|
|
72
|
+
const key = sandbox ? `${id}::sandbox=${sandbox}` : id;
|
|
73
|
+
let rt = this.cache.get(key);
|
|
74
|
+
if (!rt) {
|
|
75
|
+
rt = makeRuntime({ ...this.options, runtime: id, sandbox });
|
|
76
|
+
this.cache.set(key, rt);
|
|
77
|
+
if (!sandbox && rt.id !== id)
|
|
78
|
+
this.cache.set(rt.id, rt);
|
|
79
|
+
}
|
|
80
|
+
return rt;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Per-session remote routing (Stage 3, docs/agent-node-decoupling.md): build (or
|
|
84
|
+
* reuse) a RemoteRuntime pointed at a SPECIFIC agent-service address, rather than
|
|
85
|
+
* the process-wide BIVY_REMOTE_RUNTIME_ADDR. An adopted session may live on a
|
|
86
|
+
* different service than the node default, so re-attach must target the address
|
|
87
|
+
* recorded for that session. Caching is keyed by address, so distinct services
|
|
88
|
+
* get distinct runtime facades.
|
|
89
|
+
*/
|
|
90
|
+
getRemoteAt(id, addr, sandbox) {
|
|
91
|
+
return this.getRemote(id, addr, sandbox);
|
|
92
|
+
}
|
|
93
|
+
/** Build (and cache) a RemoteRuntime facade for `id`, addressed at `addr`. */
|
|
94
|
+
getRemote(id, addr, sandbox) {
|
|
95
|
+
const key = `remote::${addr}::${id}${sandbox ? `::sandbox=${sandbox}` : ""}`;
|
|
96
|
+
let rt = this.cache.get(key);
|
|
97
|
+
if (!rt) {
|
|
98
|
+
// Passing `id` as currentId includes it even if it's hidden from the picker,
|
|
99
|
+
// so the capability/displayName lookup works for any known runtime.
|
|
100
|
+
const info = this.list(id).find((candidate) => candidate.id === id);
|
|
101
|
+
if (!info)
|
|
102
|
+
throw new Error(`Unknown agent: ${id}`);
|
|
103
|
+
rt = new RemoteRuntime({
|
|
104
|
+
targetRuntime: id,
|
|
105
|
+
displayName: info.displayName,
|
|
106
|
+
capabilities: fullCapabilities(info.capabilities),
|
|
107
|
+
sandbox,
|
|
108
|
+
agentServiceAddress: addr,
|
|
109
|
+
connect: () => connectSocketTransport(addr),
|
|
110
|
+
});
|
|
111
|
+
this.cache.set(key, rt);
|
|
112
|
+
}
|
|
113
|
+
return rt;
|
|
114
|
+
}
|
|
115
|
+
summary(runtime) {
|
|
116
|
+
return {
|
|
117
|
+
id: runtime.id,
|
|
118
|
+
displayName: runtime.displayName,
|
|
119
|
+
capabilities: runtime.capabilities,
|
|
120
|
+
enforcementLevel: enforcementLevelFor(runtime.capabilities, runtime.id),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
async createSession(runtime, options) {
|
|
124
|
+
return runtime.createSession(options);
|
|
125
|
+
}
|
|
126
|
+
async openSession(runtime, options) {
|
|
127
|
+
return runtime.openSession(options);
|
|
128
|
+
}
|
|
129
|
+
async listSessions(runtime) {
|
|
130
|
+
return runtime.listSessions();
|
|
131
|
+
}
|
|
132
|
+
/** Ask a runtime to forget a session from its own store (see
|
|
133
|
+
* AgentRuntime.deleteSession). No-ops to `false` for runtimes that keep no
|
|
134
|
+
* store of their own. */
|
|
135
|
+
async deleteSession(runtime, sessionId, sessionFile) {
|
|
136
|
+
return (await runtime.deleteSession?.(sessionId, sessionFile)) ?? false;
|
|
137
|
+
}
|
|
138
|
+
/** Fast, build-free transcript read for opening a session (see AgentRuntime.readMessages). */
|
|
139
|
+
readMessages(runtime, sessionFile) {
|
|
140
|
+
return runtime.readMessages?.(sessionFile);
|
|
141
|
+
}
|
|
142
|
+
/** Enumerate a runtime's own provider-native sessions this node didn't start
|
|
143
|
+
* (see AgentRuntime.discoverNativeSessions, issue #156). Empty for a runtime
|
|
144
|
+
* that doesn't support discovery, or on any adapter-level failure. */
|
|
145
|
+
async discoverNativeSessions(runtime) {
|
|
146
|
+
try {
|
|
147
|
+
return (await runtime.discoverNativeSessions?.()) ?? [];
|
|
148
|
+
}
|
|
149
|
+
catch {
|
|
150
|
+
return [];
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|