fix(worker): invert connector bypass default and gate on packaged build (S-01)

Previously `AGENTCOMPANY_ALLOW_UNSAFE_CONNECTOR_BYPASS !== "false"` meant
packaged builds defaulted to passing `dangerouslyBypassApprovalsAndSandbox`,
`dangerouslySkipPermissions`, `yolo`, and `--sandbox danger-full-access`
to CLI connectors, bypassing ApprovalService entirely.

Require both explicit opt-in (`AGENTCOMPANY_ALLOW_UNSAFE_CONNECTOR_BYPASS=true`)
and a non-packaged build. Packaged builds hard-refuse regardless of the env
var. Main process forks the worker with `AGENTCOMPANY_PACKAGED=<app.isPackaged>`
so the worker has an authoritative packaged signal.
This commit is contained in:
ZacharyZhang-NY committed 2026-04-16 21:48:10 -04:00
1 parent f8052c3741
commit a1f021ff4a
2 files changed
+13 -4

No files matched your search

+7 -1
View File
@@ -1,4 +1,4 @@
import { utilityProcess } from "electron"; import { app, utilityProcess } from "electron";
import { workerMessageSchema, type WorkerServiceDependencies } from "./worker/worker-types"; import { workerMessageSchema, type WorkerServiceDependencies } from "./worker/worker-types";
import { handleWorkerExit } from "./worker/worker-crash-recovery"; import { handleWorkerExit } from "./worker/worker-crash-recovery";
import { handleWorkerMessage } from "./worker/worker-message-handler"; import { handleWorkerMessage } from "./worker/worker-message-handler";
@@ -37,9 +37,15 @@ export function createWorkerService({
} }
function createWorker() { function createWorker() {
// S-01: Propagate packaged-build signal so the worker can hard-refuse
// connector bypass flags in production.
worker = utilityProcess.fork(workerPath, [], { worker = utilityProcess.fork(workerPath, [], {
stdio: "pipe", stdio: "pipe",
serviceName: "AgentCompany Orchestrator", serviceName: "AgentCompany Orchestrator",
env: {
...process.env,
AGENTCOMPANY_PACKAGED: app.isPackaged ? "true" : "false",
},
}); });
worker.stdout?.on("data", (chunk) => { worker.stdout?.on("data", (chunk) => {
+6 -3
View File
@@ -80,10 +80,13 @@ const activeByAgent = new Map<string, string>();
const activeByWorkspace = new Map<string, string>(); const activeByWorkspace = new Map<string, string>();
const queue: RunJob[] = []; const queue: RunJob[] = [];
const cancelledRuns = new Set<string>(); const cancelledRuns = new Set<string>();
// Agent runs are autonomous by design — they must execute commands without interactive approval. // S-01: Bypass is opt-in only. Packaged builds hard-refuse the dangerous CLI
// The env-var gate is retained as an emergency kill switch but defaults to enabled. // flags unless the operator sets BOTH `AGENTCOMPANY_ALLOW_UNSAFE_CONNECTOR_BYPASS=true`
// AND is running a dev/E2E build (AGENTCOMPANY_PACKAGED !== "true"). Main forks
// the worker with AGENTCOMPANY_PACKAGED=<app.isPackaged>.
const isPackaged = process.env.AGENTCOMPANY_PACKAGED === "true";
const allowUnsafeConnectorBypass = const allowUnsafeConnectorBypass =
process.env.AGENTCOMPANY_ALLOW_UNSAFE_CONNECTOR_BYPASS !== "false"; !isPackaged && process.env.AGENTCOMPANY_ALLOW_UNSAFE_CONNECTOR_BYPASS === "true";
function post(message: ChildMessage) { function post(message: ChildMessage) {
parentPort.postMessage(message); parentPort.postMessage(message);