@quantiya/codevibe-core 2.0.81 → 2.0.83

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.
@@ -951,7 +951,7 @@ function companionPreferenceFilePath() {
951
951
  async function readCompanionPreference() {
952
952
  let filePath = companionPreferenceFilePath(), raw, st;
953
953
  try {
954
- st = await fs64.stat(filePath);
954
+ st = await fs65.stat(filePath);
955
955
  } catch (err) {
956
956
  return err?.code !== "ENOENT" && logger.debug("[companion-preference] stat error \u2014 treating as missing", {
957
957
  filePath,
@@ -964,7 +964,7 @@ async function readCompanionPreference() {
964
964
  `
965
965
  ), null;
966
966
  try {
967
- raw = await fs64.readFile(filePath, "utf8");
967
+ raw = await fs65.readFile(filePath, "utf8");
968
968
  } catch (err) {
969
969
  return logger.debug("[companion-preference] read error \u2014 treating as missing", {
970
970
  filePath,
@@ -982,19 +982,19 @@ async function readCompanionPreference() {
982
982
  }
983
983
  async function persistCompanionPreference(pref) {
984
984
  let filePath = companionPreferenceFilePath(), dir = path85.dirname(filePath);
985
- await fs64.mkdir(dir, { recursive: !0 }), await fs64.writeFile(filePath, JSON.stringify(pref, null, 2), {
985
+ await fs65.mkdir(dir, { recursive: !0 }), await fs65.writeFile(filePath, JSON.stringify(pref, null, 2), {
986
986
  encoding: "utf8",
987
987
  mode: 384
988
988
  });
989
989
  try {
990
- await fs64.chmod(filePath, 384);
990
+ await fs65.chmod(filePath, 384);
991
991
  } catch {
992
992
  }
993
993
  }
994
- var fs64, path85, os52, import_zod16, CompanionPreferenceSchema, init_persist_preference = __esm({
994
+ var fs65, path85, os52, import_zod16, CompanionPreferenceSchema, init_persist_preference = __esm({
995
995
  "src/companion-mode/persist-preference.ts"() {
996
996
  "use strict";
997
- fs64 = __toESM(require("fs/promises")), path85 = __toESM(require("path")), os52 = __toESM(require("os")), import_zod16 = require("zod");
997
+ fs65 = __toESM(require("fs/promises")), path85 = __toESM(require("path")), os52 = __toESM(require("os")), import_zod16 = require("zod");
998
998
  init_logger2();
999
999
  CompanionPreferenceSchema = import_zod16.z.object({
1000
1000
  lastAgent: import_zod16.z.union([
@@ -1059,13 +1059,13 @@ function isContainedPath(parent, candidate) {
1059
1059
  }
1060
1060
  function resolveDeclaredCompanionLauncher(packageJsonPath) {
1061
1061
  try {
1062
- let packageRoot = fs65.realpathSync(path86.dirname(packageJsonPath)), declared = JSON.parse(
1063
- fs65.readFileSync(packageJsonPath, "utf8")
1062
+ let packageRoot = fs66.realpathSync(path86.dirname(packageJsonPath)), declared = JSON.parse(
1063
+ fs66.readFileSync(packageJsonPath, "utf8")
1064
1064
  ).codevibe?.companionLauncher;
1065
1065
  if (typeof declared != "string" || declared.trim().length === 0)
1066
1066
  return null;
1067
- let launcherPath = fs65.realpathSync(path86.resolve(packageRoot, declared));
1068
- return !isContainedPath(packageRoot, launcherPath) || !fs65.statSync(launcherPath).isFile() ? null : (fs65.accessSync(launcherPath, fs65.constants.X_OK), launcherPath);
1067
+ let launcherPath = fs66.realpathSync(path86.resolve(packageRoot, declared));
1068
+ return !isContainedPath(packageRoot, launcherPath) || !fs66.statSync(launcherPath).isFile() ? null : (fs66.accessSync(launcherPath, fs66.constants.X_OK), launcherPath);
1069
1069
  } catch {
1070
1070
  return null;
1071
1071
  }
@@ -1175,10 +1175,10 @@ async function runCompanionMode(args) {
1175
1175
  process.kill(process.pid, signal);
1176
1176
  }))(child.signal), 1) : child.status ?? 1;
1177
1177
  }
1178
- var import_child_process10, import_module, path86, fs65, NoAgentInstalledError, COMPANION_PLUGIN, ACTIVE_COMPANION_AGENTS, ACTIVATION_AGENT, init_companion_mode = __esm({
1178
+ var import_child_process10, import_module, path86, fs66, NoAgentInstalledError, COMPANION_PLUGIN, ACTIVE_COMPANION_AGENTS, ACTIVATION_AGENT, init_companion_mode = __esm({
1179
1179
  "src/companion-mode/index.ts"() {
1180
1180
  "use strict";
1181
- import_child_process10 = require("child_process"), import_module = require("module"), path86 = __toESM(require("path")), fs65 = __toESM(require("fs"));
1181
+ import_child_process10 = require("child_process"), import_module = require("module"), path86 = __toESM(require("path")), fs66 = __toESM(require("fs"));
1182
1182
  init_env_scrub();
1183
1183
  init_logger2();
1184
1184
  init_detect_agents();
@@ -21826,7 +21826,7 @@ async function clearRetiredPlannerCache(userId, cacheRoot = process.env.CODEVIBE
21826
21826
  }
21827
21827
 
21828
21828
  // src/orchestration-shell/index.ts
21829
- var path79 = __toESM(require("path")), os48 = __toESM(require("os")), import_promises = require("node:fs/promises"), import_node_fs37 = require("node:fs"), import_node_child_process10 = require("node:child_process"), import_node_util3 = require("node:util"), import_node_async_hooks = require("node:async_hooks");
21829
+ var path79 = __toESM(require("path")), os48 = __toESM(require("os")), import_promises = require("node:fs/promises"), fs59 = __toESM(require("node:fs")), import_node_fs37 = require("node:fs"), import_node_child_process10 = require("node:child_process"), import_node_util3 = require("node:util"), import_node_async_hooks = require("node:async_hooks");
21830
21830
 
21831
21831
  // src/orchestration-shell/web/sanitize.ts
21832
21832
  function sanitizeForTerminal(input) {
@@ -33981,8 +33981,12 @@ function InputBar(props) {
33981
33981
  let completed = pick2.name + " ";
33982
33982
  return commit(completed, completed.length), setDism(!0), setHl(0), !0;
33983
33983
  }, [liveSuggestions, commit, setDism, setHl]), doSubmit = React18.useCallback(() => {
33984
- if (gatePromptMode?.kind === "submitting") return;
33985
33984
  let text2 = valueRef.current;
33985
+ if (gatePromptMode?.kind === "submitting") {
33986
+ let exit = text2.trim() === "/exit";
33987
+ commit("", 0), setErrorHint(exit ? null : "Decision pending \u2014 only /exit is available"), exit && props.onSubmit("/exit");
33988
+ return;
33989
+ }
33986
33990
  if (gatePromptMode?.kind === "awaiting-number") {
33987
33991
  let trimmed = text2.trim();
33988
33992
  if (trimmed.startsWith("/")) {
@@ -34058,7 +34062,7 @@ function InputBar(props) {
34058
34062
  [gatePromptMode, commit, setHl, setDism]
34059
34063
  ), handleKey = React18.useCallback(
34060
34064
  (input, key) => {
34061
- if (key.ctrl) return;
34065
+ if (key.ctrl || gatePromptMode?.kind === "submitting" && key.escape) return;
34062
34066
  let live = liveSuggestions();
34063
34067
  if (live.length > 0) {
34064
34068
  let n = live.length;
@@ -34104,13 +34108,11 @@ function InputBar(props) {
34104
34108
  }
34105
34109
  input && input.length > 0 && applyPaste(input);
34106
34110
  },
34107
- [liveSuggestions, completeToHighlighted, doSubmit, commit, applyPaste, setHl, setDism]
34108
- ), latestRef = React18.useRef({ handleKey, applyPaste, gatePromptMode });
34109
- latestRef.current = { handleKey, applyPaste, gatePromptMode };
34111
+ [liveSuggestions, completeToHighlighted, doSubmit, commit, applyPaste, setHl, setDism, gatePromptMode]
34112
+ ), latestRef = React18.useRef({ handleKey, applyPaste });
34113
+ latestRef.current = { handleKey, applyPaste };
34110
34114
  let onRawChunk = React18.useCallback((chunk) => {
34111
- let { handleKey: hk, applyPaste: fp, gatePromptMode: mode } = latestRef.current;
34112
- if (mode?.kind === "submitting") return;
34113
- let buf = endTailRef.current + chunk;
34115
+ let { handleKey: hk, applyPaste: fp } = latestRef.current, buf = endTailRef.current + chunk;
34114
34116
  endTailRef.current = "";
34115
34117
  let i = 0;
34116
34118
  for (; i < buf.length; )
@@ -34146,7 +34148,7 @@ function InputBar(props) {
34146
34148
  pasteActiveRef.current = !0, pasteBufRef.current = "", i = s + PASTE_START.length;
34147
34149
  }
34148
34150
  }, []);
34149
- if (React18.useEffect(() => {
34151
+ React18.useEffect(() => {
34150
34152
  let emitter = internal_eventEmitter;
34151
34153
  if (emitter)
34152
34154
  return emitter.on("input", onRawChunk), () => {
@@ -34157,24 +34159,9 @@ function InputBar(props) {
34157
34159
  origin2 && setRowOrigin(
34158
34160
  (prev) => prev && prev.left === origin2.left && prev.top === origin2.top ? prev : origin2
34159
34161
  );
34160
- }), gatePromptMode?.kind === "submitting")
34161
- return setCursorPosition(void 0), React18.createElement(
34162
- Box,
34163
- {
34164
- flexDirection: "row",
34165
- borderStyle: "round",
34166
- borderColor: getAccent(),
34167
- paddingX: 1
34168
- },
34169
- React18.createElement(Text, { color: getAccent() }, "\u276F "),
34170
- React18.createElement(
34171
- Text,
34172
- { dimColor: !0, italic: !0 },
34173
- "submitting\u2026"
34174
- )
34175
- );
34162
+ });
34176
34163
  let placeholder = props.placeholder ?? "";
34177
- gatePromptMode?.kind === "awaiting-number" ? placeholder = gatePromptMode.taskLabel ? `Type a number 1..${gatePromptMode.maxOption} \xB7 ${gatePromptMode.taskLabel}` : `Type a number 1..${gatePromptMode.maxOption}` : gatePromptMode?.kind === "awaiting-notes" && (placeholder = "Type your notes + Enter");
34164
+ gatePromptMode?.kind === "awaiting-number" ? placeholder = gatePromptMode.taskLabel ? `Type a number 1..${gatePromptMode.maxOption} \xB7 ${gatePromptMode.taskLabel}` : `Type a number 1..${gatePromptMode.maxOption}` : gatePromptMode?.kind === "awaiting-notes" ? placeholder = "Type your notes + Enter" : gatePromptMode?.kind === "submitting" && (placeholder = "submitting\u2026 \xB7 /exit to leave");
34178
34165
  let shown = displayValue(value), cur = clampCursor2(cursor, shown.length), valueWidth = Math.max(1, columns - 6), win = computeInputWindow(shown, cur, valueWidth, scrollRef.current);
34179
34166
  scrollRef.current = win.scroll;
34180
34167
  let origin = rowOrigin ?? { left: 0, top: 0 };
@@ -61160,6 +61147,9 @@ function resolveTeamExecution(_override, _env = process.env) {
61160
61147
  return DEFAULT_TEAM_EXECUTION;
61161
61148
  }
61162
61149
 
61150
+ // src/local-executor/spawn-sweep.ts
61151
+ init_logger2();
61152
+
61163
61153
  // src/orchestration-shell/quorum-loop.ts
61164
61154
  init_env_scrub();
61165
61155
 
@@ -62549,6 +62539,7 @@ var ChildProcessCommandRunner = class {
62549
62539
  let spawnOptions = {
62550
62540
  stdio: opts.stdinTty ? ["pipe", "pipe", "pipe"] : ["ignore", "pipe", "pipe"],
62551
62541
  windowsHide: !0,
62542
+ detached: opts.detached ?? !1,
62552
62543
  signal: opts.signal,
62553
62544
  env: opts.env !== void 0 ? scrubSearchApiKeys({ ...opts.env }) : scrubSearchApiKeys({ ...process.env }),
62554
62545
  ...opts.cwd !== void 0 ? { cwd: opts.cwd } : {}
@@ -63081,7 +63072,17 @@ function buildSeatbeltProfile(workdir, execPath = process.execPath, extraReadDir
63081
63072
  '(allow file-read* (subpath "/Library"))',
63082
63073
  '(allow file-read* (subpath "/private/var/db"))',
63083
63074
  '(allow file-read* (subpath "/private/var/select"))',
63084
- '(allow file-read* (subpath "/dev"))',
63075
+ // PD-MAC-DEV (§6.1): grant only literal reads of the device nodes agents
63076
+ // use, plus `/dev/fd`. Replaces the broad `/dev` subpath read so a confined
63077
+ // agent cannot open another terminal session's tty or its own controlling
63078
+ // terminal (/dev/tty, /dev/ttys*).
63079
+ '(allow file-read* (literal "/dev/null"))',
63080
+ '(allow file-read* (literal "/dev/zero"))',
63081
+ '(allow file-read* (literal "/dev/random"))',
63082
+ '(allow file-read* (literal "/dev/urandom"))',
63083
+ '(allow file-read* (literal "/dev/dtracehelper"))',
63084
+ '(allow file-read* (literal "/dev/autofs_nowait"))',
63085
+ '(allow file-read* (subpath "/dev/fd"))',
63085
63086
  // Ordinary POSIX tooling opens `/dev/null` rw. Grant only that literal
63086
63087
  // device (the `/dev` read above does not cover writes).
63087
63088
  '(allow file-write* (literal "/dev/null"))'
@@ -63124,11 +63125,13 @@ function buildSeatbeltProfile(workdir, execPath = process.execPath, extraReadDir
63124
63125
  );
63125
63126
  }
63126
63127
  return networkPosture === "open" ? lines.push(
63127
- // A1d resolver-confinement row: deny all network, then re-allow ALL
63128
- // OUTBOUND (external inbound stays denied). Loopback bind/inbound is permitted
63128
+ // A1d resolver-confinement row (§6.1, SP-A5, SP-A5b): deny all network,
63129
+ // then allow IP outbound + only mDNSResponder Unix socket for name resolution
63130
+ // (external inbound stays denied). Loopback bind/inbound is permitted
63129
63131
  // for local IPC (e.g. Antigravity local RPC daemon on 127.0.0.1).
63130
63132
  "(deny network*)",
63131
- "(allow network-outbound)",
63133
+ '(allow network-outbound (remote ip "*:*"))',
63134
+ '(allow network-outbound (remote unix-socket (path-literal "/private/var/run/mDNSResponder")))',
63132
63135
  '(allow network-bind (local ip "localhost:*"))',
63133
63136
  '(allow network-inbound (local ip "localhost:*"))',
63134
63137
  ""
@@ -83086,7 +83089,14 @@ async function runOrchestrationShellSession(args) {
83086
83089
  {
83087
83090
  receiveDesktopEvents: !0,
83088
83091
  onSupervisionEvent: (event) => {
83089
- classifyDurableGateResolution(event, args.session.sessionId) && subscribedEventDispatcher(event);
83092
+ if (event.sessionId === args.session.sessionId) {
83093
+ if (event.type === "INTERACTIVE_PROMPT") {
83094
+ if (event.source !== "DESKTOP" || event.emittedBy !== "SYSTEM" || event.writerAuthenticated !== !1) return;
83095
+ subscribedEventDispatcher(event);
83096
+ return;
83097
+ }
83098
+ classifyDurableGateResolution(event, args.session.sessionId) && subscribedEventDispatcher(event);
83099
+ }
83090
83100
  },
83091
83101
  onSubscribed: (isReconnect) => {
83092
83102
  initialCatchUpStarted = !0, catchUpDurableGateTimeline(isReconnect).then(() => settleInitialSubscription()).catch((error) => {
@@ -84900,14 +84910,138 @@ function uniqueDetectedAgents(detected) {
84900
84910
  item2 !== "CLAUDE" && item2 !== "CODEX" && item2 !== "ANTIGRAVITY" || out.includes(item2) || out.push(item2);
84901
84911
  return out;
84902
84912
  }
84903
- function agyReadOnlyWorkdirPreamble(workdir) {
84904
- return [
84913
+ var AGY_ADVISORY_LISTING_MAX_ENTRIES = 500, AGY_ADVISORY_LISTING_MAX_BYTES = 16384, AGY_ADVISORY_IGNORED_DIRS = /* @__PURE__ */ new Set([
84914
+ ".git",
84915
+ "node_modules",
84916
+ "dist",
84917
+ "build",
84918
+ "coverage",
84919
+ "target",
84920
+ "venv",
84921
+ ".venv",
84922
+ "__pycache__",
84923
+ "Pods",
84924
+ "DerivedData",
84925
+ ".gradle",
84926
+ ".idea",
84927
+ ".next",
84928
+ ".turbo",
84929
+ ".cache",
84930
+ ".gemini",
84931
+ ".codevibe",
84932
+ ".codevibe-audit",
84933
+ ".codevibe-attachments",
84934
+ ".agent-worktrees",
84935
+ ".review-worktrees",
84936
+ ".hard-gate",
84937
+ ".dev-marketplace",
84938
+ ".dev-marketplace-next"
84939
+ ]), AGY_COMMAND_TOOL_SEATBELT_WARNING = "Your command tool cannot run in this sandbox: do not call it. CodeVibe listed the folder for you below (relative paths with '/' separator; literal backslashes escaped as \\\\, control characters escaped as \\xNN or \\uNNNN; a trailing / marks a folder). Read files with your file-reading tool, using absolute paths under the folder.";
84940
+ function sanitizeListingPath(relPath) {
84941
+ return relPath.replace(/\\/g, "\\\\").replace(/[\x00-\x1f\x7f]/g, (c) => `\\x${c.charCodeAt(0).toString(16).padStart(2, "0")}`).replace(/[\u0080-\u009f\u061c\u200e\u200f\u2028\u2029\u202a-\u202e\u2066-\u2069\ufeff]/g, (c) => `\\u${c.charCodeAt(0).toString(16).padStart(4, "0")}`);
84942
+ }
84943
+ function formatAgyWorkspaceListing(workdir, maxEntries = AGY_ADVISORY_LISTING_MAX_ENTRIES, maxBytes = AGY_ADVISORY_LISTING_MAX_BYTES) {
84944
+ try {
84945
+ if (!fs59.existsSync(workdir))
84946
+ return "Folder listing unavailable (directory does not exist)";
84947
+ if (!fs59.statSync(workdir).isDirectory())
84948
+ return "Folder listing unavailable (not a directory)";
84949
+ if (maxBytes <= 0 || maxEntries <= 0)
84950
+ return "Folder listing (listing omitted \u2014 prompt budget exhausted)";
84951
+ let entries = [], skippedTopLevel = [], totalBytes = 0, truncated = !1, hasUnreadableDirs = !1, queue = [""];
84952
+ for (; queue.length > 0 && !truncated; ) {
84953
+ let relDir = queue.shift(), absDir = relDir === "" ? workdir : path79.join(workdir, relDir), dir;
84954
+ try {
84955
+ dir = fs59.opendirSync(absDir);
84956
+ } catch (err) {
84957
+ if (relDir === "")
84958
+ return `Folder listing unavailable (directory unreadable: ${err?.code || (err instanceof Error ? err.message : String(err))})`;
84959
+ hasUnreadableDirs = !0;
84960
+ continue;
84961
+ }
84962
+ let dirEntries = [], dirScanLimit = maxEntries * 2;
84963
+ try {
84964
+ let entry5;
84965
+ for (; (entry5 = dir.readSync()) !== null; )
84966
+ if (dirEntries.push(entry5), dirEntries.length > dirScanLimit) {
84967
+ truncated = !0;
84968
+ break;
84969
+ }
84970
+ } catch (err) {
84971
+ if (relDir === "" && dirEntries.length === 0)
84972
+ return `Folder listing unavailable (directory unreadable: ${err?.code || (err instanceof Error ? err.message : String(err))})`;
84973
+ hasUnreadableDirs = !0;
84974
+ } finally {
84975
+ try {
84976
+ dir.closeSync();
84977
+ } catch {
84978
+ }
84979
+ }
84980
+ dirEntries.sort((a, b) => a.name.localeCompare(b.name));
84981
+ for (let entry5 of dirEntries) {
84982
+ let isDir = entry5.isDirectory(), isSymlinkToDir = !1;
84983
+ if (!isDir && entry5.isSymbolicLink())
84984
+ try {
84985
+ fs59.statSync(path79.join(absDir, entry5.name)).isDirectory() && (isSymlinkToDir = !0, isDir = !0);
84986
+ } catch {
84987
+ }
84988
+ if (entry5.name === ".git") {
84989
+ relDir === "" && skippedTopLevel.push(isDir ? ".git/" : ".git");
84990
+ continue;
84991
+ }
84992
+ if (isDir && AGY_ADVISORY_IGNORED_DIRS.has(entry5.name)) {
84993
+ relDir === "" && skippedTopLevel.push(`${entry5.name}/`);
84994
+ continue;
84995
+ }
84996
+ let rawRelPath = relDir === "" ? entry5.name : `${relDir}/${entry5.name}`, sanitizedRel = sanitizeListingPath(rawRelPath);
84997
+ if (entry5.isDirectory()) {
84998
+ let entryStr = `${sanitizedRel}/`, entryBytes = Buffer.byteLength(entryStr, "utf8") + 1;
84999
+ if (entries.length >= maxEntries || totalBytes + entryBytes > maxBytes) {
85000
+ truncated = !0;
85001
+ break;
85002
+ }
85003
+ entries.push(entryStr), totalBytes += entryBytes, queue.push(rawRelPath);
85004
+ } else if (isSymlinkToDir) {
85005
+ let entryStr = `${sanitizedRel}/`, entryBytes = Buffer.byteLength(entryStr, "utf8") + 1;
85006
+ if (entries.length >= maxEntries || totalBytes + entryBytes > maxBytes) {
85007
+ truncated = !0;
85008
+ break;
85009
+ }
85010
+ entries.push(entryStr), totalBytes += entryBytes;
85011
+ } else {
85012
+ let entryStr = sanitizedRel, entryBytes = Buffer.byteLength(entryStr, "utf8") + 1;
85013
+ if (entries.length >= maxEntries || totalBytes + entryBytes > maxBytes) {
85014
+ truncated = !0;
85015
+ break;
85016
+ }
85017
+ entries.push(entryStr), totalBytes += entryBytes;
85018
+ }
85019
+ }
85020
+ }
85021
+ if (entries.length === 0)
85022
+ return truncated ? "Folder listing (listing omitted \u2014 prompt budget exhausted)" : hasUnreadableDirs ? "Folder listing unavailable (directory unreadable)" : skippedTopLevel.length > 0 ? `Folder listing (0 entries listed, complete; not listed: ${skippedTopLevel.join(", ")}):
85023
+ (no other files found)` : `Folder listing (0 entries, complete):
85024
+ (no files found)`;
85025
+ let status = truncated ? "truncated" : hasUnreadableDirs ? "partial, some subdirectories unreadable" : "complete", notListedPart = skippedTopLevel.length > 0 ? `; not listed: ${skippedTopLevel.join(", ")}` : "";
85026
+ return `${`Folder listing (${entries.length} entries, ${status}${notListedPart}):`}
85027
+ ${entries.join(`
85028
+ `)}`;
85029
+ } catch (err) {
85030
+ return `Folder listing unavailable (${err?.code || (err instanceof Error ? err.message : String(err))})`;
85031
+ }
85032
+ }
85033
+ function agyReadOnlyWorkdirPreamble(workdir, listing) {
85034
+ let parts = [
84905
85035
  `You are reading the directory \`${workdir}\` (added to your workspace via --add-dir).`,
84906
85036
  `Use absolute paths under \`${workdir}\` when you reference files.`,
84907
85037
  "Do NOT use a relative 'current directory' \u2014 your process cwd is NOT the workspace.",
84908
- "This is read-only advisory work: do not create, edit, delete, or move files.",
84909
- ""
84910
- ].join(`
85038
+ "This is read-only advisory work: do not create, edit, delete, or move files."
85039
+ ];
85040
+ return listing !== void 0 && listing.length > 0 && parts.push(
85041
+ AGY_COMMAND_TOOL_SEATBELT_WARNING,
85042
+ "",
85043
+ listing
85044
+ ), parts.push(""), parts.join(`
84911
85045
  `);
84912
85046
  }
84913
85047
  function readOnlyAgentPrompt(args) {
@@ -84928,8 +85062,17 @@ function readOnlyAgentPrompt(args) {
84928
85062
  args.advisoryBrief || args.intent.promptForPlanning || args.intent.rawMention,
84929
85063
  ""
84930
85064
  ].join(`
84931
- `);
84932
- return args.agent === "ANTIGRAVITY" && args.allowRepositoryTools ? `${agyReadOnlyWorkdirPreamble(args.workingDir)}${body}` : body;
85065
+ `), fullPrompt;
85066
+ if (args.agent === "ANTIGRAVITY" && args.allowRepositoryTools) {
85067
+ let basePreamble = agyReadOnlyWorkdirPreamble(args.workingDir), bodyBytes = Buffer.byteLength(body, "utf8"), basePreambleBytes = Buffer.byteLength(basePreamble, "utf8"), instructionPreambleText = `${AGY_COMMAND_TOOL_SEATBELT_WARNING}
85068
+
85069
+ `, instructionBytes = Buffer.byteLength(instructionPreambleText, "utf8"), totalScaffoldBytes = bodyBytes + basePreambleBytes + instructionBytes + 128 + 512, availableListingBytes = Math.max(0, 122880 - totalScaffoldBytes), maxListingBytes = Math.min(AGY_ADVISORY_LISTING_MAX_BYTES, availableListingBytes), listing;
85070
+ args.folderListing !== void 0 ? (listing = args.folderListing, Buffer.byteLength(listing, "utf8") > availableListingBytes && (listing = "Folder listing (listing omitted \u2014 prompt budget exhausted)")) : maxListingBytes >= 64 ? listing = formatAgyWorkspaceListing(args.workingDir, AGY_ADVISORY_LISTING_MAX_ENTRIES, maxListingBytes) : listing = "Folder listing (listing omitted \u2014 prompt budget exhausted)";
85071
+ let candidatePrompt = `${agyReadOnlyWorkdirPreamble(args.workingDir, listing)}${body}`;
85072
+ Buffer.byteLength(candidatePrompt, "utf8") <= 122880 ? fullPrompt = candidatePrompt : fullPrompt = `${basePreamble}${body}`;
85073
+ } else
85074
+ fullPrompt = body;
85075
+ return fullPrompt;
84933
85076
  }
84934
85077
  function readOnlyAdvisoryAllowsRepositoryTools(_input) {
84935
85078
  return !0;
@@ -89300,14 +89443,14 @@ var OllamaGemmaRunner = class {
89300
89443
  };
89301
89444
 
89302
89445
  // src/orchestration-shell/cli.ts
89303
- var import_uuid18 = require("uuid"), fs66 = __toESM(require("fs"));
89446
+ var import_uuid18 = require("uuid"), fs67 = __toESM(require("fs"));
89304
89447
 
89305
89448
  // src/orchestration-shell/doctor-cli.ts
89306
- var fs60 = __toESM(require("fs")), path80 = __toESM(require("path")), crypto32 = __toESM(require("crypto")), import_child_process7 = require("child_process");
89449
+ var fs61 = __toESM(require("fs")), path80 = __toESM(require("path")), crypto32 = __toESM(require("crypto")), import_child_process7 = require("child_process");
89307
89450
  init_detect_agents();
89308
89451
 
89309
89452
  // src/auth/auth-service.ts
89310
- var crypto31 = __toESM(require("crypto")), fs59 = __toESM(require("fs")), http3 = __toESM(require("http")), import_child_process6 = require("child_process");
89453
+ var crypto31 = __toESM(require("crypto")), fs60 = __toESM(require("fs")), http3 = __toESM(require("http")), import_child_process6 = require("child_process");
89311
89454
  init_env_scrub();
89312
89455
  init_logger2();
89313
89456
  init_auth_telemetry();
@@ -89389,7 +89532,7 @@ var AuthService = class _AuthService {
89389
89532
  isRunningInWSL() {
89390
89533
  if (process.platform !== "linux") return !1;
89391
89534
  try {
89392
- let osRelease = fs59.readFileSync("/proc/sys/kernel/osrelease", "utf8");
89535
+ let osRelease = fs60.readFileSync("/proc/sys/kernel/osrelease", "utf8");
89393
89536
  return /microsoft|wsl/i.test(osRelease);
89394
89537
  } catch {
89395
89538
  return !1;
@@ -89883,9 +90026,9 @@ var colors = {
89883
90026
  function probeAgentClis(env = process.env) {
89884
90027
  return AGENT_SPECS.map(({ agent, command, name }) => {
89885
90028
  let binPath;
89886
- if (agent === "ANTIGRAVITY" && env.AGY_PATH && fs60.existsSync(env.AGY_PATH))
90029
+ if (agent === "ANTIGRAVITY" && env.AGY_PATH && fs61.existsSync(env.AGY_PATH))
89887
90030
  try {
89888
- fs60.statSync(env.AGY_PATH).isFile() && (binPath = env.AGY_PATH);
90031
+ fs61.statSync(env.AGY_PATH).isFile() && (binPath = env.AGY_PATH);
89889
90032
  } catch {
89890
90033
  binPath = void 0;
89891
90034
  }
@@ -90013,19 +90156,19 @@ async function probeBackendConnectivity(appsyncUrl) {
90013
90156
  function readBoundedUtf8File(filePath, maxBytes) {
90014
90157
  let fd;
90015
90158
  try {
90016
- let stat14 = fs60.statSync(filePath);
90159
+ let stat14 = fs61.statSync(filePath);
90017
90160
  if (!stat14.isFile()) return { ok: !1, error: "not a regular file" };
90018
90161
  if (stat14.size > maxBytes) return { ok: !1, error: `file exceeds ${maxBytes} byte limit (${stat14.size} bytes)` };
90019
90162
  if (stat14.size === 0) return { ok: !1, error: "empty file (0 bytes)" };
90020
- fd = fs60.openSync(filePath, "r");
90021
- let buf = Buffer.alloc(stat14.size), bytesRead = fs60.readSync(fd, buf, 0, stat14.size, 0);
90163
+ fd = fs61.openSync(filePath, "r");
90164
+ let buf = Buffer.alloc(stat14.size), bytesRead = fs61.readSync(fd, buf, 0, stat14.size, 0);
90022
90165
  return { ok: !0, content: buf.subarray(0, bytesRead).toString("utf8") };
90023
90166
  } catch (err) {
90024
90167
  return { ok: !1, error: err.message };
90025
90168
  } finally {
90026
90169
  if (fd !== void 0)
90027
90170
  try {
90028
- fs60.closeSync(fd);
90171
+ fs61.closeSync(fd);
90029
90172
  } catch {
90030
90173
  }
90031
90174
  }
@@ -90151,8 +90294,8 @@ async function probeOrphanStatus(stateRoot, ownerRootOverride, shadowRootOverrid
90151
90294
  scanErrors.push(`Exposure retention ${record2.marker.taskId}: ${err.message}`);
90152
90295
  }
90153
90296
  let ownerRoot = ownerRootOverride ?? resolveOwnerRoot({}, stateRoot), deadProcessOwnersCount = 0;
90154
- if (fs60.existsSync(ownerRoot)) {
90155
- let entries = fs60.readdirSync(ownerRoot, { withFileTypes: !0 });
90297
+ if (fs61.existsSync(ownerRoot)) {
90298
+ let entries = fs61.readdirSync(ownerRoot, { withFileTypes: !0 });
90156
90299
  for (let entry5 of entries) {
90157
90300
  if (!entry5.isFile() || !/^owner-[0-9a-f-]{36}\.json$/i.test(entry5.name)) continue;
90158
90301
  let readResult = readBoundedUtf8File(path80.join(ownerRoot, entry5.name), 4096);
@@ -90210,7 +90353,7 @@ function shadowStateRoot() {
90210
90353
  function readRegistry(stateRoot) {
90211
90354
  let file = path80.join(stateRoot, SHADOW_ROOT_REGISTRY_FILE), raw;
90212
90355
  try {
90213
- raw = fs60.readFileSync(file, "utf8");
90356
+ raw = fs61.readFileSync(file, "utf8");
90214
90357
  } catch {
90215
90358
  return null;
90216
90359
  }
@@ -90222,7 +90365,7 @@ function readRegistry(stateRoot) {
90222
90365
  function collectMarkers(stateRoot) {
90223
90366
  let index = /* @__PURE__ */ new Map(), taskDirs;
90224
90367
  try {
90225
- taskDirs = fs60.readdirSync(stateRoot, { withFileTypes: !0 });
90368
+ taskDirs = fs61.readdirSync(stateRoot, { withFileTypes: !0 });
90226
90369
  } catch {
90227
90370
  return index;
90228
90371
  }
@@ -90230,7 +90373,7 @@ function collectMarkers(stateRoot) {
90230
90373
  if (!taskDir.isDirectory() || taskDir.name.startsWith(".")) continue;
90231
90374
  let dir = path80.join(stateRoot, taskDir.name), files;
90232
90375
  try {
90233
- files = fs60.readdirSync(dir);
90376
+ files = fs61.readdirSync(dir);
90234
90377
  } catch {
90235
90378
  continue;
90236
90379
  }
@@ -90238,8 +90381,8 @@ function collectMarkers(stateRoot) {
90238
90381
  if (!SHADOW_STATE_FILE_RE.test(name) && !SHADOW_EXPOSURE_RETENTION_FILE_RE.test(name)) continue;
90239
90382
  let file = path80.join(dir, name), marker;
90240
90383
  try {
90241
- if (fs60.statSync(file).size > MAX_STATE_MARKER_BYTES) continue;
90242
- marker = JSON.parse(fs60.readFileSync(file, "utf8"));
90384
+ if (fs61.statSync(file).size > MAX_STATE_MARKER_BYTES) continue;
90385
+ marker = JSON.parse(fs61.readFileSync(file, "utf8"));
90243
90386
  } catch {
90244
90387
  continue;
90245
90388
  }
@@ -90255,19 +90398,19 @@ function inodeSurvivesInParent(root) {
90255
90398
  if (!root.ino) return;
90256
90399
  let parent = path80.dirname(root.path);
90257
90400
  try {
90258
- fs60.lstatSync(parent);
90401
+ fs61.lstatSync(parent);
90259
90402
  } catch (err) {
90260
90403
  return err.code === "ENOENT" ? !1 : void 0;
90261
90404
  }
90262
90405
  let entries;
90263
90406
  try {
90264
- entries = fs60.readdirSync(parent);
90407
+ entries = fs61.readdirSync(parent);
90265
90408
  } catch {
90266
90409
  return;
90267
90410
  }
90268
90411
  for (let name of entries)
90269
90412
  try {
90270
- if (fs60.lstatSync(path80.join(parent, name), { bigint: !0 }).ino.toString() === root.ino) return !0;
90413
+ if (fs61.lstatSync(path80.join(parent, name), { bigint: !0 }).ino.toString() === root.ino) return !0;
90271
90414
  } catch {
90272
90415
  continue;
90273
90416
  }
@@ -90278,7 +90421,7 @@ function diagnose(stateRoot, roots) {
90278
90421
  return roots.map((root) => {
90279
90422
  let markers = markerIndex.get(root.path) ?? [], present = !1;
90280
90423
  try {
90281
- present = fs60.lstatSync(root.path).isDirectory();
90424
+ present = fs61.lstatSync(root.path).isDirectory();
90282
90425
  } catch {
90283
90426
  present = !1;
90284
90427
  }
@@ -90436,29 +90579,29 @@ ${colors.red}\u2717${colors.reset} ${withheld.length} entr${withheld.length ===
90436
90579
  Nothing was written. Re-run with ${colors.bold}--yes${colors.reset} to apply${withheld.length ? " the entries listed first" : ""}.`), 0;
90437
90580
  let locks = path80.join(stateRoot, SHADOW_QUOTA_LOCK_DIR), held = [];
90438
90581
  try {
90439
- held = fs60.readdirSync(locks);
90582
+ held = fs61.readdirSync(locks);
90440
90583
  } catch {
90441
90584
  held = [];
90442
90585
  }
90443
90586
  if (held.length)
90444
90587
  return console.error(`${colors.red}\u2717${colors.reset} A CodeVibe session is registering a root right now. Try again once it is idle.`), 1;
90445
- let file = path80.join(stateRoot, SHADOW_ROOT_REGISTRY_FILE), current = fs60.readFileSync(file, "utf8");
90588
+ let file = path80.join(stateRoot, SHADOW_ROOT_REGISTRY_FILE), current = fs61.readFileSync(file, "utf8");
90446
90589
  if (crypto32.createHash("sha256").update(current).digest("hex") !== crypto32.createHash("sha256").update(registry.raw).digest("hex"))
90447
90590
  return console.error(`${colors.red}\u2717${colors.reset} The registry changed while this ran. Nothing was written; re-run.`), 1;
90448
90591
  let stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-"), backupDir = path80.join(path80.dirname(stateRoot), "shadow-root-backups", stamp), backup = path80.join(backupDir, "shadow-roots.json");
90449
90592
  try {
90450
- fs60.mkdirSync(backupDir, { recursive: !0, mode: 448 }), fs60.copyFileSync(file, backup);
90593
+ fs61.mkdirSync(backupDir, { recursive: !0, mode: 448 }), fs61.copyFileSync(file, backup);
90451
90594
  } catch (err) {
90452
90595
  return console.error(`${colors.red}\u2717${colors.reset} Could not write the backup at ${backupDir} (${err.code ?? "unknown error"}). Nothing was changed \u2014 this command will not clear an entry it cannot restore.`), 1;
90453
90596
  }
90454
90597
  let removed = new Set(clearable.map((d) => d.root.path)), kept = registry.roots.filter((r) => !removed.has(r.path)), tmp = path80.join(backupDir, `.registry.next.${process.pid}`);
90455
90598
  try {
90456
- fs60.writeFileSync(tmp, JSON.stringify({ version: 2, roots: kept }), { mode: 384 }), fs60.renameSync(tmp, file);
90599
+ fs61.writeFileSync(tmp, JSON.stringify({ version: 2, roots: kept }), { mode: 384 }), fs61.renameSync(tmp, file);
90457
90600
  } catch (err) {
90458
90601
  return console.error(`${colors.red}\u2717${colors.reset} Could not replace the registry (${err.code ?? "unknown error"}). Nothing was changed; a copy of it is at ${backup}.`), 1;
90459
90602
  } finally {
90460
90603
  try {
90461
- fs60.unlinkSync(tmp);
90604
+ fs61.unlinkSync(tmp);
90462
90605
  } catch {
90463
90606
  }
90464
90607
  }
@@ -90467,7 +90610,7 @@ ${colors.red}\u2717${colors.reset} ${withheld.length} entr${withheld.length ===
90467
90610
  for (let marker of d.markers) {
90468
90611
  let copy = path80.join(backupDir, `marker-${savedMarkers.length}-${path80.basename(marker)}`);
90469
90612
  try {
90470
- fs60.copyFileSync(marker, copy), savedMarkers.push({ copy: path80.basename(copy), original: marker });
90613
+ fs61.copyFileSync(marker, copy), savedMarkers.push({ copy: path80.basename(copy), original: marker });
90471
90614
  } catch (err) {
90472
90615
  if (err.code !== "ENOENT") {
90473
90616
  unbackedMarkers.push(marker);
@@ -90475,16 +90618,16 @@ ${colors.red}\u2717${colors.reset} ${withheld.length} entr${withheld.length ===
90475
90618
  }
90476
90619
  }
90477
90620
  try {
90478
- fs60.unlinkSync(marker);
90621
+ fs61.unlinkSync(marker);
90479
90622
  } catch {
90480
90623
  }
90481
90624
  try {
90482
- fs60.rmdirSync(path80.dirname(marker));
90625
+ fs61.rmdirSync(path80.dirname(marker));
90483
90626
  } catch {
90484
90627
  }
90485
90628
  }
90486
90629
  try {
90487
- fs60.writeFileSync(path80.join(backupDir, "manifest.json"), `${JSON.stringify({
90630
+ fs61.writeFileSync(path80.join(backupDir, "manifest.json"), `${JSON.stringify({
90488
90631
  clearedAtUtc: (/* @__PURE__ */ new Date()).toISOString(),
90489
90632
  registry: file,
90490
90633
  registryBackup: path80.basename(backup),
@@ -90504,7 +90647,7 @@ ${colors.green}\u2713${colors.reset} Cleared ${clearable.length} entr${clearable
90504
90647
  }
90505
90648
 
90506
90649
  // src/substrate-launch/engage-substrate.ts
90507
- var import_node_fs38 = require("node:fs"), os49 = __toESM(require("node:os")), path81 = __toESM(require("node:path"));
90650
+ var import_node_fs38 = require("node:fs"), os49 = __toESM(require("node:os")), path81 = __toESM(require("node:path")), crypto33 = __toESM(require("node:crypto"));
90508
90651
 
90509
90652
  // src/credential-broker/types.ts
90510
90653
  var BROKER_ROUTES = [
@@ -92795,8 +92938,7 @@ async function engageSubstrate(input) {
92795
92938
  }
92796
92939
  }
92797
92940
  var RESOLVER_AGENT_STATE_DIR_SEGMENTS = {
92798
- GEMINI: [".gemini"],
92799
- ANTIGRAVITY: [".gemini"]
92941
+ GEMINI: [".gemini"]
92800
92942
  };
92801
92943
  async function engageWriteConfinedResolverSandbox(input) {
92802
92944
  let agentKind = input.agentKind;
@@ -92821,36 +92963,94 @@ async function engageWriteConfinedResolverSandbox(input) {
92821
92963
  teardown: async () => {
92822
92964
  }
92823
92965
  };
92824
- let homedir41 = os49.homedir(), stateDir = path81.join(
92825
- homedir41,
92826
- ...RESOLVER_AGENT_STATE_DIR_SEGMENTS[agentKind]
92827
- );
92828
- await import_node_fs38.promises.mkdir(stateDir, { recursive: !0 }).catch(() => {
92829
- });
92830
- let env = {}, nodeDir = process.execPath.slice(0, process.execPath.lastIndexOf("/"));
92831
- env.PATH = `${SANDBOX_DEFAULT_PATH}:${nodeDir}`, env.HOME = homedir41;
92832
- let safeSource = input.localeSource ?? {};
92833
- for (let key of SAFE_ENV_ALLOWLIST) {
92834
- let v = safeSource[key];
92835
- typeof v == "string" && v.length > 0 && (env[key] = v);
92966
+ let homedir41 = input.homedir ?? os49.homedir(), stateDir, privateHomeDir = null, spawnParentDir = null, spawnParentDirCreated = !1, env = {}, handle, finalEnv;
92967
+ if (agentKind === "ANTIGRAVITY") {
92968
+ let spawnId = input.spawnId ?? crypto33.randomUUID().slice(0, 8), taskSegment = input.taskId || "advisory";
92969
+ if (process.platform === "darwin")
92970
+ input.taskId ? (spawnParentDir = path81.join(homedir41, "Library", "Caches", "CodeVibe", "shadows", taskSegment, "agy-home", spawnId), privateHomeDir = spawnParentDir) : (spawnParentDir = path81.join(homedir41, "Library", "Caches", "CodeVibe", "shadows", `advisory-${spawnId}`), privateHomeDir = path81.join(spawnParentDir, "agy-home"));
92971
+ else {
92972
+ let cacheBase = process.env.XDG_CACHE_HOME || path81.join(homedir41, ".cache");
92973
+ input.taskId ? (spawnParentDir = path81.join(cacheBase, "codevibe", "shadows", taskSegment, "spawn", spawnId), privateHomeDir = path81.join(spawnParentDir, "home")) : (spawnParentDir = path81.join(cacheBase, "codevibe", "shadows", `advisory-${spawnId}`), privateHomeDir = path81.join(spawnParentDir, "home"));
92974
+ }
92975
+ stateDir = privateHomeDir, await import_node_fs38.promises.mkdir(path81.dirname(spawnParentDir), { recursive: !0 }), await import_node_fs38.promises.mkdir(spawnParentDir), spawnParentDirCreated = !0;
92976
+ try {
92977
+ let agyCliDir = path81.join(privateHomeDir, ".gemini", "antigravity-cli");
92978
+ await import_node_fs38.promises.mkdir(agyCliDir, { recursive: !0 });
92979
+ let hostAgyDir = path81.join(homedir41, ".gemini", "antigravity-cli"), tokenFile = path81.join(hostAgyDir, "antigravity-oauth-token"), idFile = path81.join(hostAgyDir, "installation_id");
92980
+ try {
92981
+ await import_node_fs38.promises.copyFile(tokenFile, path81.join(agyCliDir, "antigravity-oauth-token")), await import_node_fs38.promises.chmod(path81.join(agyCliDir, "antigravity-oauth-token"), 384);
92982
+ } catch {
92983
+ }
92984
+ try {
92985
+ await import_node_fs38.promises.copyFile(idFile, path81.join(agyCliDir, "installation_id")), await import_node_fs38.promises.chmod(path81.join(agyCliDir, "installation_id"), 384);
92986
+ } catch {
92987
+ }
92988
+ env.HOME = privateHomeDir;
92989
+ let nodeDir = process.execPath.slice(0, process.execPath.lastIndexOf("/"));
92990
+ env.PATH = `${SANDBOX_DEFAULT_PATH}:${nodeDir}`;
92991
+ let safeSource = input.localeSource ?? {};
92992
+ for (let key of SAFE_ENV_ALLOWLIST) {
92993
+ let v = safeSource[key];
92994
+ typeof v == "string" && v.length > 0 && (env[key] = v);
92995
+ }
92996
+ assertNoAmbientCreds(env), finalEnv = buildSubstrateImplementorEnv(input.role, env, input.processTreeId);
92997
+ let spec = {
92998
+ isolationTech: "sandbox_exec",
92999
+ workdir: input.workdir,
93000
+ ...input.workdirAuthority ? { workdirAuthority: input.workdirAuthority } : {},
93001
+ hostBrokerAddr: "",
93002
+ sandboxBrokerUrl: "",
93003
+ taskId: input.taskId,
93004
+ sanitizedEnv: finalEnv,
93005
+ agentConfig: { hostDir: stateDir, sandboxDir: stateDir },
93006
+ networkPosture: "open",
93007
+ writableWorkdir: input.writableWorkdir !== !1
93008
+ };
93009
+ handle = await selection.substrate.launch(spec);
93010
+ } catch (launchErr) {
93011
+ let rollbackErrors = [];
93012
+ if (spawnParentDirCreated && spawnParentDir !== null)
93013
+ try {
93014
+ await import_node_fs38.promises.rm(spawnParentDir, { recursive: !0, force: !0 });
93015
+ } catch (rmErr) {
93016
+ rollbackErrors.push(rmErr);
93017
+ }
93018
+ if (rollbackErrors.length > 0) {
93019
+ let combinedError = new Error(
93020
+ `engageSubstrate initialization or launch failed and rollback failed: ${launchErr instanceof Error ? launchErr.message : String(launchErr)} (rollback: ${rollbackErrors.map((e) => e instanceof Error ? e.message : String(e)).join("; ")})`
93021
+ );
93022
+ throw combinedError.cause = launchErr, combinedError;
93023
+ }
93024
+ throw launchErr;
93025
+ }
93026
+ } else {
93027
+ stateDir = path81.join(
93028
+ homedir41,
93029
+ ...RESOLVER_AGENT_STATE_DIR_SEGMENTS[agentKind]
93030
+ ), await import_node_fs38.promises.mkdir(stateDir, { recursive: !0 }).catch(() => {
93031
+ }), env.HOME = homedir41;
93032
+ let nodeDir = process.execPath.slice(0, process.execPath.lastIndexOf("/"));
93033
+ env.PATH = `${SANDBOX_DEFAULT_PATH}:${nodeDir}`;
93034
+ let safeSource = input.localeSource ?? {};
93035
+ for (let key of SAFE_ENV_ALLOWLIST) {
93036
+ let v = safeSource[key];
93037
+ typeof v == "string" && v.length > 0 && (env[key] = v);
93038
+ }
93039
+ assertNoAmbientCreds(env), finalEnv = buildSubstrateImplementorEnv(input.role, env, input.processTreeId);
93040
+ let spec = {
93041
+ isolationTech: "sandbox_exec",
93042
+ workdir: input.workdir,
93043
+ ...input.workdirAuthority ? { workdirAuthority: input.workdirAuthority } : {},
93044
+ hostBrokerAddr: "",
93045
+ sandboxBrokerUrl: "",
93046
+ taskId: input.taskId,
93047
+ sanitizedEnv: finalEnv,
93048
+ agentConfig: { hostDir: stateDir, sandboxDir: stateDir },
93049
+ networkPosture: "open",
93050
+ writableWorkdir: input.writableWorkdir !== !1
93051
+ };
93052
+ handle = await selection.substrate.launch(spec);
92836
93053
  }
92837
- assertNoAmbientCreds(env);
92838
- let finalEnv = buildSubstrateImplementorEnv(input.role, env, input.processTreeId), spec = {
92839
- isolationTech: "sandbox_exec",
92840
- workdir: input.workdir,
92841
- ...input.workdirAuthority ? { workdirAuthority: input.workdirAuthority } : {},
92842
- // No broker on this row — the addr/url fields are informational for A5
92843
- // (the profile, not these strings, governs egress) and deliberately empty.
92844
- hostBrokerAddr: "",
92845
- sandboxBrokerUrl: "",
92846
- taskId: input.taskId,
92847
- sanitizedEnv: finalEnv,
92848
- // The agent's own auth/state home — writable, read-granted (A5: sandbox fs
92849
- // == host fs, so sandboxDir == hostDir).
92850
- agentConfig: { hostDir: stateDir, sandboxDir: stateDir },
92851
- networkPosture: "open",
92852
- writableWorkdir: input.writableWorkdir !== !1
92853
- }, handle = await selection.substrate.launch(spec);
92854
93054
  return logger.info(
92855
93055
  `[A1d] Resolver-confinement row engaged (tier=sandbox_exec, egress=open) \u2014 writes fenced to the disposable workspace; ${agentKind} runs on its own file-based auth (no broker)`,
92856
93056
  { taskId: input.taskId, agent: agentKind }
@@ -92868,8 +93068,18 @@ async function engageWriteConfinedResolverSandbox(input) {
92868
93068
  refreshBrokerToken: async () => {
92869
93069
  },
92870
93070
  teardown: async () => {
92871
- await handle.teardown().catch(() => {
92872
- });
93071
+ try {
93072
+ await handle.teardown();
93073
+ } catch (err) {
93074
+ throw logger.warn(
93075
+ "[engageSubstrate] resolver sandbox handle teardown failed, retaining state for recovery",
93076
+ {
93077
+ err,
93078
+ spawnParentDir
93079
+ }
93080
+ ), err;
93081
+ }
93082
+ spawnParentDirCreated && spawnParentDir !== null && await import_node_fs38.promises.rm(spawnParentDir, { recursive: !0, force: !0 });
92873
93083
  }
92874
93084
  };
92875
93085
  }
@@ -94760,7 +94970,7 @@ Note: --export will overwrite any existing file at <path>.
94760
94970
  offset: parsed.offset
94761
94971
  });
94762
94972
  if (result.kind === "ok" && parsed.exportPath) {
94763
- let writeFile4 = deps?.writeFileFn ?? ((p, c) => fs66.writeFileSync(p, c, "utf8"));
94973
+ let writeFile4 = deps?.writeFileFn ?? ((p, c) => fs67.writeFileSync(p, c, "utf8"));
94764
94974
  try {
94765
94975
  let formatted = formatAuditExport(
94766
94976
  result.model,