glimmervoid 0.34.1 → 0.35.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.
Files changed (52) hide show
  1. package/dist/bin/glimmervoid.js +31 -19
  2. package/dist/chunks/adapters-B37wqNti.js +1 -0
  3. package/dist/chunks/{adapters-D-cRFZ_Q.js → adapters-CADejSpq.js} +219 -9
  4. package/dist/chunks/agent-api-cli-CRj_FYbz.js +1 -0
  5. package/dist/chunks/{agent-api-cli-DuT7437B.js → agent-api-cli-vGwstJ1j.js} +57 -17
  6. package/dist/chunks/{agent-api-core-Ddg15j2j.js → agent-api-core-D1233u1U.js} +35 -9
  7. package/dist/chunks/{agent-setup-cli-CFielF2o.js → agent-setup-cli-BTAFcckd.js} +2 -2
  8. package/dist/chunks/child-process-safe-ChRmWAJP.js +1 -0
  9. package/dist/chunks/{config-DTwMFUjx.js → config-rPbbL4nW.js} +12 -21
  10. package/dist/chunks/config-store-BeIxAZNn.js +1 -0
  11. package/dist/chunks/{config-store-D0lRWsAM.js → config-store-BtsYbNC3.js} +44 -14
  12. package/dist/chunks/{contracts-DZV9H8px.js → contracts-DjIgIuDk.js} +27 -27
  13. package/dist/chunks/{git-version-CrLW4a6r.js → git-version-CUcDtF5k.js} +3 -3
  14. package/dist/chunks/{grok-BYKnBgdr.js → grok-KKgdSe-7.js} +7 -3
  15. package/dist/chunks/{ingest-editor-core-vR6Wv6bP.js → ingest-editor-core-B2tycW_m.js} +4 -4
  16. package/dist/chunks/{json-file-oEH9vt-0.js → json-file-BaxGcB2R.js} +1 -1
  17. package/dist/chunks/{knowledge-graph-cli-BBE3R9DJ.js → knowledge-graph-cli-Rj5nj87L.js} +4 -4
  18. package/dist/chunks/{main-VMWdsGC6.js → main-C-T2Uk20.js} +337 -426
  19. package/dist/chunks/{pair-cli-CI848omy.js → pair-cli-Dcyzv3In.js} +2 -2
  20. package/dist/chunks/paths-Bu4eH1Yd.js +27 -0
  21. package/dist/chunks/{remote-config-Y6YtqoiO.js → remote-config-Dd1T-VJA.js} +3 -3
  22. package/dist/chunks/{rtk-resolver-jJxy_Mrt.js → rtk-resolver-B9pzjLsM.js} +1 -1
  23. package/dist/chunks/rtk-resolver-SWU5VVM7.js +1 -0
  24. package/dist/chunks/{runtime-paths-BPoxENmK.js → runtime-paths-BkeftE60.js} +3 -4
  25. package/dist/chunks/runtime-paths-DSmormp7.js +1 -0
  26. package/dist/chunks/{sandbox-deps-C63o3mZs.js → sandbox-deps-CWiH1d1w.js} +3 -3
  27. package/dist/chunks/{session-C7rstCmA.js → session-D6xXN0UU.js} +26 -4
  28. package/dist/chunks/session-routes-BYy3am9m.js +127 -0
  29. package/dist/chunks/{ssh-sign-cli-SWtTF00D.js → ssh-sign-cli-DPHpT22B.js} +11 -7
  30. package/dist/chunks/{visions-cli-BhFdym5n.js → visions-cli-CYujESdJ.js} +2 -2
  31. package/dist/chunks/{visions-setup-CfgNHiG3.js → visions-setup-B-ZeRdsi.js} +9 -9
  32. package/dist/client/assets/index-CUxRHbCS.js +254 -0
  33. package/dist/client/assets/index-DE2GUmqs.css +1 -0
  34. package/dist/client/index.html +2 -2
  35. package/dist/scripts/postinstall-path-check.js +1 -1
  36. package/dist/server/index.js +2 -2
  37. package/dist/session/hook-tool-relay.js +2 -2
  38. package/dist/session/sandbox-open-launcher.js +1 -1
  39. package/dist/session/statusline-relay.js +1 -1
  40. package/dist/session/visions-relay.js +3 -3
  41. package/dist/tools/vscode-visions/visions-lsp-core.js +1 -1
  42. package/package.json +8 -8
  43. package/dist/chunks/adapters-CgbcceU3.js +0 -2
  44. package/dist/chunks/agent-api-cli-CRJYxzVU.js +0 -2
  45. package/dist/chunks/child-process-safe-B3zcPdFM.js +0 -2
  46. package/dist/chunks/config-store-DwTxLe8Y.js +0 -2
  47. package/dist/chunks/paths-CeJl2Vcg.js +0 -55
  48. package/dist/chunks/rtk-resolver-CIVLE_xk.js +0 -2
  49. package/dist/chunks/runtime-paths-DU5jBEEO.js +0 -2
  50. package/dist/client/assets/index-BxU3Ww0L.css +0 -1
  51. package/dist/client/assets/index-b9goyXSa.js +0 -254
  52. package/dist/chunks/{child-process-safe-DDELk9XC.js → child-process-safe-CbQnyh7D.js} +1 -1
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
  import { o as nodePtyRebuildHint, r as firstLine, t as probeNodePty } from "../chunks/node-pty-preflight-C8QIlrtU.js";
3
3
  import { i as errorText } from "../chunks/text-DoirglWV.js";
4
- import { a as packageRoot } from "../chunks/runtime-paths-BPoxENmK.js";
5
- import { t as AGENT_API_VERBS } from "../chunks/session-C7rstCmA.js";
6
- import { i as execSync } from "../chunks/child-process-safe-DDELk9XC.js";
4
+ import { a as packageRoot } from "../chunks/runtime-paths-BkeftE60.js";
5
+ import { t as AGENT_API_VERBS } from "../chunks/session-D6xXN0UU.js";
6
+ import { i as execSync } from "../chunks/child-process-safe-CbQnyh7D.js";
7
7
  import { t as renderTable } from "../chunks/ascii-figure-core-pDAwtlKO.js";
8
8
  import { n as glimmervoidHomeDir, t as decideConfigPath } from "../chunks/config-path-core-DFt-TemS.js";
9
- import { i as sandboxDoctorRows, r as probeSandboxDependencies } from "../chunks/sandbox-deps-C63o3mZs.js";
10
- import { r as gitDoctorRows, t as probeGitVersion } from "../chunks/git-version-CrLW4a6r.js";
9
+ import { i as sandboxDoctorRows, r as probeSandboxDependencies } from "../chunks/sandbox-deps-CWiH1d1w.js";
10
+ import { r as gitDoctorRows, t as probeGitVersion } from "../chunks/git-version-CUcDtF5k.js";
11
11
  import { i as pnpmGlobalBinDir, n as npmGlobalBinDir, r as onPath, t as formatPathNotice } from "../chunks/path-doctor-C23VAqeu.js";
12
12
  import fs from "node:fs";
13
13
  import path from "node:path";
@@ -109,6 +109,7 @@ Commands:
109
109
  board From inside a Glimmervoid session, list the live sessions
110
110
  push From inside a Glimmervoid session, land its commits on the integration branch and push it
111
111
  edit <path> From inside a Glimmervoid session, surface a text file for the operator to edit in the dashboard
112
+ limits From inside a Glimmervoid session, list which of these commands answer and what its guardrails block
112
113
  ssh-sign What git runs inside a Glimmervoid session to sign a commit with the operator's forwarded ssh agent
113
114
  kg [command] Experimental typed knowledge and task graph (Settings > Lanes > Knowledge graph)
114
115
 
@@ -121,6 +122,8 @@ Options:
121
122
  var commandLine = parseCommandLine(args);
122
123
  if (commandLine.kind === "help") {
123
124
  console.log(USAGE);
125
+ await printSessionLimits();
126
+ await drainOutput();
124
127
  process.exit(0);
125
128
  }
126
129
  if (commandLine.kind === "version") {
@@ -135,38 +138,47 @@ var SUBCOMMAND_RUNNERS = new Map([
135
138
  return 0;
136
139
  }],
137
140
  ["pair", async (subcommandArgs) => {
138
- const { runPairCli } = await import("../chunks/pair-cli-CI848omy.js");
141
+ const { runPairCli } = await import("../chunks/pair-cli-Dcyzv3In.js");
139
142
  return runPairCli(subcommandArgs);
140
143
  }],
141
144
  ["agent", async (subcommandArgs) => {
142
- const { runAgentSetupCli } = await import("../chunks/agent-setup-cli-CFielF2o.js");
145
+ const { runAgentSetupCli } = await import("../chunks/agent-setup-cli-BTAFcckd.js");
143
146
  return runAgentSetupCli(subcommandArgs);
144
147
  }],
145
148
  ["kg", async (subcommandArgs) => {
146
- const { runKnowledgeGraphCommand } = await import("../chunks/knowledge-graph-cli-BBE3R9DJ.js");
149
+ const { runKnowledgeGraphCommand } = await import("../chunks/knowledge-graph-cli-Rj5nj87L.js");
147
150
  return runKnowledgeGraphCommand(subcommandArgs);
148
151
  }],
149
152
  ["visions", async (subcommandArgs) => {
150
- const { runVisionsCli } = await import("../chunks/visions-cli-BhFdym5n.js");
153
+ const { runVisionsCli } = await import("../chunks/visions-cli-CYujESdJ.js");
151
154
  return runVisionsCli(subcommandArgs);
152
155
  }],
153
156
  ["ssh-sign", async (subcommandArgs) => {
154
- const { runSshSignCli } = await import("../chunks/ssh-sign-cli-SWtTF00D.js");
157
+ const { runSshSignCli } = await import("../chunks/ssh-sign-cli-DPHpT22B.js");
155
158
  return runSshSignCli(subcommandArgs);
156
159
  }],
157
160
  ...AGENT_API_VERBS.map((verb) => [verb, async (subcommandArgs, subcommandName) => {
158
- const { runAgentApiCli } = await import("../chunks/agent-api-cli-CRJYxzVU.js");
161
+ const { runAgentApiCli } = await import("../chunks/agent-api-cli-CRj_FYbz.js");
159
162
  return runAgentApiCli([subcommandName, ...subcommandArgs]);
160
163
  }])
161
164
  ]);
165
+ async function printSessionLimits() {
166
+ if (!process.env["GLIMMERVOID_AGENT_URL"]) return;
167
+ const { sessionLimitsHelpLines } = await import("../chunks/agent-api-cli-CRj_FYbz.js");
168
+ const limitsLines = await sessionLimitsHelpLines();
169
+ console.log(`\n${limitsLines.join("\n")}`);
170
+ }
162
171
  function flushStream(stream) {
163
172
  return new Promise((resolve) => {
164
173
  stream.once("error", () => resolve());
165
174
  stream.write("", () => resolve());
166
175
  });
167
176
  }
168
- async function exitAfterOutputDrains(exitCode) {
177
+ async function drainOutput() {
169
178
  await Promise.all([flushStream(process.stdout), flushStream(process.stderr)]);
179
+ }
180
+ async function exitAfterOutputDrains(exitCode) {
181
+ await drainOutput();
170
182
  process.exit(exitCode);
171
183
  }
172
184
  async function runSubcommandToExitCode(runSubcommand, subcommandArgs, subcommandName) {
@@ -209,7 +221,7 @@ async function readDeclaredCustomAgents() {
209
221
  declared: [],
210
222
  error: null
211
223
  };
212
- const { loadConfigFile } = await import("../chunks/config-store-DwTxLe8Y.js");
224
+ const { loadConfigFile } = await import("../chunks/config-store-BeIxAZNn.js");
213
225
  try {
214
226
  const loaded = loadConfigFile(decided.path, { exitOnError: false });
215
227
  if (!loaded.config) return {
@@ -285,7 +297,7 @@ async function runDoctor() {
285
297
  }
286
298
  switchSection("Agents");
287
299
  try {
288
- const { listAgentIds, describeAgentResolvability, setCustomAgents } = await import("../chunks/adapters-CgbcceU3.js");
300
+ const { listAgentIds, describeAgentResolvability, setCustomAgents } = await import("../chunks/adapters-B37wqNti.js");
289
301
  const declaredCustomAgents = await readDeclaredCustomAgents();
290
302
  if (declaredCustomAgents.error) line("config", declaredCustomAgents.error);
291
303
  setCustomAgents(declaredCustomAgents.declared);
@@ -293,7 +305,7 @@ async function runDoctor() {
293
305
  const { label, path: resolvedPath } = describeAgentResolvability(id);
294
306
  line(`${id} (${label})`, resolvedPath ?? "not found on PATH");
295
307
  }
296
- const { inspectGrokAgentSetup } = await import("../chunks/agent-setup-cli-CFielF2o.js");
308
+ const { inspectGrokAgentSetup } = await import("../chunks/agent-setup-cli-BTAFcckd.js");
297
309
  const grokSetup = inspectGrokAgentSetup();
298
310
  line("grok hook setup", `${grokSetup.classification}: ${grokSetup.filePath}`);
299
311
  } catch (err) {
@@ -301,16 +313,16 @@ async function runDoctor() {
301
313
  }
302
314
  switchSection("rtk");
303
315
  try {
304
- const { getRtkPath } = await import("../chunks/rtk-resolver-CIVLE_xk.js");
316
+ const { getRtkPath } = await import("../chunks/rtk-resolver-SWU5VVM7.js");
305
317
  line("rtk", getRtkPath() || "not installed (Glimmervoid installs it when the rtk setting is on)");
306
318
  } catch (err) {
307
319
  line("rtk", `probe failed: ${firstLine(errorText(err))}`);
308
320
  }
309
321
  switchSection("Sane YOLO");
310
322
  try {
311
- const { resolvePackageBin } = await import("../chunks/runtime-paths-DU5jBEEO.js");
312
- const { execFileSync } = await import("../chunks/child-process-safe-B3zcPdFM.js");
313
- const { inspectGrokAgentSetup } = await import("../chunks/agent-setup-cli-CFielF2o.js");
323
+ const { resolvePackageBin } = await import("../chunks/runtime-paths-DSmormp7.js");
324
+ const { execFileSync } = await import("../chunks/child-process-safe-ChRmWAJP.js");
325
+ const { inspectGrokAgentSetup } = await import("../chunks/agent-setup-cli-BTAFcckd.js");
314
326
  const binPath = resolvePackageBin("cc-safety-net", "cc-safety-net");
315
327
  line("Sane YOLO", binPath || "not installed");
316
328
  if (binPath) line("cc-safety-net version", execFileSync(process.execPath, [binPath, "--version"], {
@@ -0,0 +1 @@
1
+ export { a as describeAgentResolvability, l as listAgentIds, d as setCustomAgents } from "./adapters-CADejSpq.js";
@@ -1,13 +1,16 @@
1
- import { o as relayPath } from "./runtime-paths-BPoxENmK.js";
2
- import { D as firstDetailLine, O as toolDetailFieldValue, f as PendingPromptQuestion, u as PROMPT_DETAIL_HIDDEN_CHARACTERS } from "./session-C7rstCmA.js";
3
- import { r as execFileSync } from "./child-process-safe-DDELk9XC.js";
1
+ import { o as relayPath } from "./runtime-paths-BkeftE60.js";
2
+ import { A as toolDetailFieldValue, d as PROMPT_DETAIL_HIDDEN_CHARACTERS, k as firstDetailLine, p as PendingPromptQuestion } from "./session-D6xXN0UU.js";
3
+ import { r as execFileSync } from "./child-process-safe-CbQnyh7D.js";
4
4
  import { n as resolveAgentCommand, t as buildAgentSpawnCommand } from "./spawn-command-Cc40FiZI.js";
5
- import { n as isRecord } from "./coerce-NSst8oRP.js";
6
- import { c as buildAgentEnv, i as isSpinnerChar, n as classifyAgentTitle, r as isBrailleChar, t as grok } from "./grok-BYKnBgdr.js";
5
+ import { n as isRecord, s as rawTextOr } from "./coerce-NSst8oRP.js";
6
+ import { r as nextBackoffMs } from "./backoff-DjVpfHk7.js";
7
+ import { l as supervisionLine } from "./session-routes-BYy3am9m.js";
8
+ import { c as buildAgentEnv, i as isSpinnerChar, n as classifyAgentTitle, r as isBrailleChar, t as grok } from "./grok-KKgdSe-7.js";
7
9
  import { t as buildHookCommand } from "./hook-command-core-DclEoE9e.js";
8
- import "./contracts-DZV9H8px.js";
10
+ import "./contracts-DjIgIuDk.js";
9
11
  import { n as mergeCodexPreToolUse, t as HOOK_TOOLS } from "./hook-tools-UX2fmt81.js";
10
12
  import fs from "node:fs";
13
+ import path from "node:path";
11
14
  //#region session/adapters/claude-code.ts
12
15
  var ID$1 = "claude-code";
13
16
  var COMMAND_NAME$1 = "claude";
@@ -183,9 +186,15 @@ function launchSessionId({ resumeSessionId, extraArgs, generatedId }) {
183
186
  ]
184
187
  };
185
188
  }
186
- function buildArgs$1({ dangerouslySkipPermissions = false, resumeSessionId = null, extraArgs = [], initialPrompt = null } = {}) {
189
+ var APPEND_SYSTEM_PROMPT_FLAG = "--append-system-prompt";
190
+ var APPENDED_SYSTEM_PROMPT_FLAGS = Object.freeze([APPEND_SYSTEM_PROMPT_FLAG, "--append-system-prompt-file"]);
191
+ function isAppendedSystemPromptArgument(launchArgument) {
192
+ return APPENDED_SYSTEM_PROMPT_FLAGS.some((flag) => launchArgument === flag || launchArgument.startsWith(`${flag}=`));
193
+ }
194
+ function buildArgs$1({ dangerouslySkipPermissions = false, resumeSessionId = null, extraArgs = [], initialPrompt = null, hasOuterSandbox = false, canRunHelpCommand = true } = {}) {
187
195
  const args = dangerouslySkipPermissions ? ["--dangerously-skip-permissions"] : [];
188
196
  if (resumeSessionId) args.push("--resume", resumeSessionId);
197
+ if (canRunHelpCommand && !extraArgs.some(isAppendedSystemPromptArgument)) args.push(APPEND_SYSTEM_PROMPT_FLAG, supervisionLine({ isSandboxed: hasOuterSandbox }));
189
198
  for (let index = 0; index < extraArgs.length; index += 1) {
190
199
  const argument = extraArgs[index];
191
200
  if (resumeSessionId && argument === "--session-id") {
@@ -233,6 +242,190 @@ var claudeCode = {
233
242
  mapHookPromptDetail
234
243
  };
235
244
  //#endregion
245
+ //#region server/usage/core/usage-scan-core.ts
246
+ function laneSpendStatus({ isTrackingEnabled, scan }) {
247
+ if (!isTrackingEnabled) return "tracking-off";
248
+ if (scan === null) return "scanner-missing";
249
+ if (scan.lastOutcome === "io-failed") return "read-failing";
250
+ if (!scan.isHistoryCaughtUp || scan.lastOutcome === null) return "catching-up";
251
+ return "known";
252
+ }
253
+ function decideFileRead(prior, stat) {
254
+ if (!prior) return {
255
+ action: "restart",
256
+ readFrom: 0
257
+ };
258
+ if (!stat || typeof stat.size !== "number") return {
259
+ action: "skip",
260
+ readFrom: prior.offset || 0
261
+ };
262
+ if (stat.size < (prior.size || 0)) return {
263
+ action: "restart",
264
+ readFrom: 0
265
+ };
266
+ if (stat.size < (prior.offset || 0)) return {
267
+ action: "restart",
268
+ readFrom: 0
269
+ };
270
+ if (stat.size === (prior.offset || 0) && stat.mtimeMs === prior.mtimeMs) return {
271
+ action: "skip",
272
+ readFrom: prior.offset || 0
273
+ };
274
+ return {
275
+ action: "append",
276
+ readFrom: prior.offset || 0
277
+ };
278
+ }
279
+ function splitLines(carry, chunkText) {
280
+ const text = `${carry || ""}${chunkText || ""}`;
281
+ const lines = text.split(/\r?\n/);
282
+ const nextCarry = text.endsWith("\n") || text.endsWith("\r\n") ? "" : lines.pop();
283
+ return {
284
+ lines: lines.filter((line) => line.length > 0),
285
+ carry: nextCarry || ""
286
+ };
287
+ }
288
+ function resolveProjectsDirs(env = process.env, extraDirs = [], isDirectory, homeDir = null) {
289
+ if (typeof isDirectory !== "function") throw new TypeError("resolveProjectsDirs requires an isDirectory function");
290
+ const surviving = projectDirCandidates(env, extraDirs, homeDir).filter(isDirectory);
291
+ if (!configDirOverride(env)) return surviving;
292
+ if (projectDirCandidates(env, [], homeDir).filter(isDirectory).length === 0) throw new Error("CLAUDE_CONFIG_DIR is set but no projects directory exists");
293
+ return surviving;
294
+ }
295
+ function projectDirCandidates(env = process.env, extraDirs = [], homeDir = null) {
296
+ const override = configDirOverride(env);
297
+ const extraHomes = normalizeHomeCandidates(extraDirs, env, homeDir);
298
+ if (override) return uniqueStrings([...projectsDirsFromHomes(normalizeHomeCandidates(override.split(","), env, homeDir)), ...projectsDirsFromHomes(extraHomes)]);
299
+ const resolvedHomeDir = resolveHomeDir(env, homeDir);
300
+ if (!resolvedHomeDir) return uniqueStrings(projectsDirsFromHomes(extraHomes));
301
+ const xdgConfigHome = rawTextOr(env.XDG_CONFIG_HOME, null) || path.join(resolvedHomeDir, ".config");
302
+ return uniqueStrings([...projectsDirsFromHomes([path.join(xdgConfigHome, "claude"), path.join(resolvedHomeDir, ".claude")]), ...projectsDirsFromHomes(extraHomes)]);
303
+ }
304
+ function configDirOverride(env) {
305
+ return (typeof env.CLAUDE_CONFIG_DIR === "string" ? env.CLAUDE_CONFIG_DIR : "").trim();
306
+ }
307
+ function projectsDirsFromHomes(homes) {
308
+ const projectsDirs = [];
309
+ for (const candidate of homes) {
310
+ const home = path.basename(candidate) === "projects" ? path.dirname(candidate) : candidate;
311
+ const projectsDir = path.join(home, "projects");
312
+ projectsDirs.push(projectsDir);
313
+ }
314
+ return projectsDirs;
315
+ }
316
+ function normalizeHomeCandidates(candidates, env, homeDir) {
317
+ if (!Array.isArray(candidates)) return [];
318
+ return candidates.map((candidate) => expandTilde(String(candidate || "").trim(), env, homeDir)).filter(Boolean);
319
+ }
320
+ function expandTilde(candidate, env, homeDir) {
321
+ if (!candidate.startsWith("~")) return candidate;
322
+ const home = resolveHomeDir(env, homeDir);
323
+ if (!home) return "";
324
+ if (candidate === "~") return home;
325
+ if (!candidate.startsWith(`~${path.sep}`) && !candidate.startsWith("~/")) return candidate;
326
+ return path.join(home, candidate.slice(2));
327
+ }
328
+ function resolveHomeDir(env, homeDir) {
329
+ return rawTextOr(env.HOME, null) || rawTextOr(env.USERPROFILE, null) || homeDir;
330
+ }
331
+ function uniqueStrings(values) {
332
+ return Array.from(new Set(values));
333
+ }
334
+ function passOutcome({ byteLimited, ioFailures }) {
335
+ if (ioFailures > 0) return "io-failed";
336
+ if (byteLimited) return "byte-limited";
337
+ return "complete";
338
+ }
339
+ function shouldPersistWarehouse({ outcome, storeReset }) {
340
+ if (outcome === "complete") return true;
341
+ if (outcome === "byte-limited") return false;
342
+ return !storeReset;
343
+ }
344
+ function continuationDelayMs({ outcome, ioFailureStreak, partialMs }) {
345
+ if (outcome === "complete") return null;
346
+ if (outcome === "byte-limited") return partialMs;
347
+ return nextBackoffMs({
348
+ attempt: ioFailureStreak,
349
+ baseMs: 3e4,
350
+ maxMs: 3e5
351
+ });
352
+ }
353
+ function shouldEvaluateDespiteIoFailures({ ioFailureStreak, limit }) {
354
+ if (!Number.isFinite(ioFailureStreak) || !Number.isFinite(limit)) return false;
355
+ if (limit <= 0) return false;
356
+ return ioFailureStreak >= limit;
357
+ }
358
+ function vendorHomes(env, varName, defaultDirName, homeDir) {
359
+ const rawOverride = env?.[varName];
360
+ const override = typeof rawOverride === "string" ? rawOverride.trim() : "";
361
+ if (override) return normalizeHomeCandidates(override.split(","), env, homeDir);
362
+ const home = resolveHomeDir(env, homeDir);
363
+ if (!home) return [];
364
+ return [path.join(home, defaultDirName)];
365
+ }
366
+ function codexHomes(env = process.env, homeDir = null) {
367
+ return vendorHomes(env, "CODEX_HOME", ".codex", homeDir);
368
+ }
369
+ function grokHomes(env = process.env, homeDir = null) {
370
+ return vendorHomes(env, "GROK_HOME", ".grok", homeDir);
371
+ }
372
+ function codexRootCandidates(homes) {
373
+ const candidates = [];
374
+ for (const home of homes) {
375
+ candidates.push({
376
+ dir: path.join(home, "sessions"),
377
+ kind: "active",
378
+ home
379
+ });
380
+ candidates.push({
381
+ dir: path.join(home, "archived_sessions"),
382
+ kind: "archived",
383
+ home
384
+ });
385
+ }
386
+ return candidates;
387
+ }
388
+ function codexFallbackRoots(homes, survivingRoots) {
389
+ const covered = new Set(survivingRoots.map((root) => root.home));
390
+ return homes.filter((home) => !covered.has(home)).map((home) => ({
391
+ dir: home,
392
+ kind: "flat",
393
+ home
394
+ }));
395
+ }
396
+ function grokRootCandidates(homes) {
397
+ return homes.map((home) => ({
398
+ dir: path.join(home, "sessions"),
399
+ kind: "active",
400
+ home
401
+ }));
402
+ }
403
+ var GROK_USAGE_FILENAME = "updates.jsonl";
404
+ function isUsageFile(vendor, fileName) {
405
+ if (typeof fileName !== "string") return false;
406
+ if (vendor === "grok") return fileName === GROK_USAGE_FILENAME;
407
+ return fileName.endsWith(".jsonl");
408
+ }
409
+ function dedupeCodexFiles(files) {
410
+ const byName = /* @__PURE__ */ new Map();
411
+ for (const file of files) {
412
+ const name = path.basename(file.file);
413
+ const existing = byName.get(name);
414
+ if (!existing) {
415
+ byName.set(name, file);
416
+ continue;
417
+ }
418
+ if (existing.kind === "archived" && file.kind !== "archived") byName.set(name, file);
419
+ }
420
+ return Array.from(byName.values());
421
+ }
422
+ function codexSessionIdFromPath(filePath) {
423
+ const base = path.basename(String(filePath || ""), ".jsonl");
424
+ const match = /([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/.exec(base);
425
+ if (match) return match[1];
426
+ return base || null;
427
+ }
428
+ //#endregion
236
429
  //#region session/adapters/codex.ts
237
430
  var ID = "codex";
238
431
  var COMMAND_NAME = "codex";
@@ -371,8 +564,23 @@ function permissionArgs(dangerouslySkipPermissions, hasOuterSandbox) {
371
564
  if (dangerouslySkipPermissions) return SKIP_PERMISSIONS_ARGS;
372
565
  return [];
373
566
  }
374
- function buildArgs({ dangerouslySkipPermissions = false, resumeSessionId = null, extraArgs = [], initialPrompt = null, hasOuterSandbox = false } = {}) {
567
+ var OPERATOR_CONFIG_FILE_NAME = "config.toml";
568
+ var DEVELOPER_INSTRUCTIONS_KEY = "developer_instructions";
569
+ var DEVELOPER_INSTRUCTIONS_DECLARATION_RE = /^[^\S\r\n]*["']?developer_instructions["']?[^\S\r\n]*=/m;
570
+ function operatorConfigPath(env) {
571
+ const [codexHome] = codexHomes(env, null);
572
+ if (!codexHome) return null;
573
+ return path.join(codexHome, OPERATOR_CONFIG_FILE_NAME);
574
+ }
575
+ function setsOperatorInstructions(operatorConfigText) {
576
+ return DEVELOPER_INSTRUCTIONS_DECLARATION_RE.test(operatorConfigText);
577
+ }
578
+ function isDeveloperInstructionsOverride(launchArgument) {
579
+ return launchArgument.startsWith(`${DEVELOPER_INSTRUCTIONS_KEY}=`);
580
+ }
581
+ function buildArgs({ dangerouslySkipPermissions = false, resumeSessionId = null, extraArgs = [], initialPrompt = null, hasOuterSandbox = false, hasOperatorInstructions = false, canRunHelpCommand = true } = {}) {
375
582
  const args = [...UPDATE_CHECK_ARGS];
583
+ if (canRunHelpCommand && !hasOperatorInstructions && !extraArgs.some(isDeveloperInstructionsOverride)) args.push("-c", `${DEVELOPER_INSTRUCTIONS_KEY}='''${supervisionLine({ isSandboxed: hasOuterSandbox })}'''`);
376
584
  if (resumeSessionId) args.push("resume", resumeSessionId);
377
585
  args.push(...permissionArgs(dangerouslySkipPermissions, hasOuterSandbox));
378
586
  if (extraArgs.length > 0) args.push(...extraArgs);
@@ -391,6 +599,8 @@ var codex = {
391
599
  buildSpawnCommand,
392
600
  buildEnv,
393
601
  buildArgs,
602
+ operatorConfigPath,
603
+ setsOperatorInstructions,
394
604
  buildHookArgs,
395
605
  buildHookCommand,
396
606
  mayContributeHooks,
@@ -597,4 +807,4 @@ function cachedAgentResolvability(agentId) {
597
807
  };
598
808
  }
599
809
  //#endregion
600
- export { describeAgentResolvability as a, isKnownAgentId as c, setCustomAgents as d, claudeCode as f, customAgentFingerprint as i, listAgentIds as l, cachedAgentResolvability as n, getAdapter as o, commandFor as r, hookProfileOf as s, DEFAULT_AGENT_ID as t, resolveAdapter as u };
810
+ export { claudeCode as A, laneSpendStatus as C, shouldEvaluateDespiteIoFailures as D, resolveProjectsDirs as E, shouldPersistWarehouse as O, isUsageFile as S, projectDirCandidates as T, decideFileRead as _, describeAgentResolvability as a, grokHomes as b, isKnownAgentId as c, setCustomAgents as d, codexFallbackRoots as f, continuationDelayMs as g, codexSessionIdFromPath as h, customAgentFingerprint as i, splitLines as k, listAgentIds as l, codexRootCandidates as m, cachedAgentResolvability as n, getAdapter as o, codexHomes as p, commandFor as r, hookProfileOf as s, DEFAULT_AGENT_ID as t, resolveAdapter as u, dedupeCodexFiles as v, passOutcome as w, grokRootCandidates as x, expandTilde as y };
@@ -0,0 +1 @@
1
+ export { n as runAgentApiCli, r as sessionLimitsHelpLines } from "./agent-api-cli-vGwstJ1j.js";
@@ -1,12 +1,16 @@
1
1
  import { t as errorCode } from "./text-DoirglWV.js";
2
- import { a as AgentDispatchRequest, c as AgentTicketRequest, n as AGENT_URL_ENV } from "./session-C7rstCmA.js";
2
+ import { a as AgentDispatchRequest, l as AgentTicketRequest, n as AGENT_URL_ENV, s as AgentLimitsReply } from "./session-D6xXN0UU.js";
3
3
  import { i as resolveHookTarget } from "./hook-relay-core-DA_bz2KA.js";
4
4
  import { n as decideSandboxProxy } from "./sandbox-proxy-core-hnQgKR0T.js";
5
- import { c as isAgentApiVerb, l as isOrchestratorAgentVerb } from "./agent-api-core-Ddg15j2j.js";
5
+ import { t as parseJsonOrNull } from "./json-core-dfa_7Fak.js";
6
+ import { a as formatSessionLimits } from "./session-routes-BYy3am9m.js";
7
+ import { d as isOrchestratorAgentVerb, u as isAgentApiVerb } from "./agent-api-core-D1233u1U.js";
6
8
  import path from "node:path";
7
9
  import http from "node:http";
8
10
  //#region server/agent-api-cli.ts
9
11
  var AGENT_PATH_PREFIX = "/agent/";
12
+ var HELP_LIMITS_TIMEOUT_MS = 2e3;
13
+ var HELP_LIMITS_UNKNOWN_LINE = "This session: Glimmervoid did not report its limits, so run glimmervoid limits to see why";
10
14
  function ticketBody(rest) {
11
15
  const parsed = AgentTicketRequest.safeParse({ workId: rest[0] });
12
16
  return parsed.success ? parsed.data : null;
@@ -26,6 +30,7 @@ var BODY_BUILDERS = {
26
30
  const docPath = rest.join(" ").trim();
27
31
  return docPath ? { path: path.resolve(docPath) } : null;
28
32
  },
33
+ limits: () => ({}),
29
34
  dispatch: (rest) => {
30
35
  const parsed = AgentDispatchRequest.safeParse(rest[0] === "--ready" ? { readyIntent: rest[1] } : { workId: rest[0] });
31
36
  return parsed.success ? parsed.data : null;
@@ -41,6 +46,15 @@ function bodySaysOk(text) {
41
46
  return false;
42
47
  }
43
48
  }
49
+ function limitsLines(replyText) {
50
+ const limits = AgentLimitsReply.safeParse(parseJsonOrNull(replyText));
51
+ if (!limits.success) return null;
52
+ return formatSessionLimits(limits.data);
53
+ }
54
+ function printableReply(verb, replyText) {
55
+ if (verb !== "limits") return replyText;
56
+ return limitsLines(replyText)?.join("\n") ?? replyText;
57
+ }
44
58
  function verbEndpoint(rawUrl, verb) {
45
59
  const target = resolveHookTarget(rawUrl, verb, AGENT_PATH_PREFIX);
46
60
  if (!target.url) return { ok: false };
@@ -53,18 +67,19 @@ function verbEndpoint(rawUrl, verb) {
53
67
  token
54
68
  };
55
69
  }
56
- async function postDirectly(endpoint, headers, bodyText) {
70
+ async function postDirectly({ endpoint, headers, bodyText, deadline }) {
57
71
  const response = await fetch(endpoint, {
58
72
  method: "POST",
59
73
  headers,
60
- body: bodyText
74
+ body: bodyText,
75
+ signal: deadline
61
76
  });
62
77
  return {
63
78
  hasSuccessStatus: response.ok,
64
79
  text: await response.text()
65
80
  };
66
81
  }
67
- function postThroughSandboxProxy(sandboxProxy, endpoint, headers, bodyText) {
82
+ function postThroughSandboxProxy(sandboxProxy, { endpoint, headers, bodyText, deadline }) {
68
83
  const proxyHeaders = sandboxProxy.authorization ? { "proxy-authorization": sandboxProxy.authorization } : {};
69
84
  return new Promise((resolve, reject) => {
70
85
  const request = http.request({
@@ -77,7 +92,8 @@ function postThroughSandboxProxy(sandboxProxy, endpoint, headers, bodyText) {
77
92
  ...proxyHeaders,
78
93
  host: endpoint.host,
79
94
  "content-length": String(Buffer.byteLength(bodyText))
80
- }
95
+ },
96
+ ...deadline ? { signal: deadline } : {}
81
97
  }, (response) => {
82
98
  const chunks = [];
83
99
  response.on("data", (chunk) => {
@@ -99,19 +115,39 @@ function postThroughSandboxProxy(sandboxProxy, endpoint, headers, bodyText) {
99
115
  function wasConnectionRefused(error) {
100
116
  return errorCode(error?.cause) === "ECONNREFUSED";
101
117
  }
102
- async function postToAgentIngress(endpoint, token, body) {
103
- const headers = {
104
- "content-type": "application/json",
105
- authorization: `Bearer ${token}`
118
+ async function postToAgentIngress({ endpoint, token, body, deadline = null }) {
119
+ const post = {
120
+ endpoint,
121
+ headers: {
122
+ "content-type": "application/json",
123
+ authorization: `Bearer ${token}`
124
+ },
125
+ bodyText: JSON.stringify(body),
126
+ deadline
106
127
  };
107
- const bodyText = JSON.stringify(body);
108
128
  try {
109
- return await postDirectly(endpoint, headers, bodyText);
129
+ return await postDirectly(post);
110
130
  } catch (error) {
111
131
  if (!wasConnectionRefused(error)) throw error;
112
132
  const sandboxProxy = decideSandboxProxy(process.env);
113
133
  if (!sandboxProxy) throw error;
114
- return postThroughSandboxProxy(sandboxProxy, endpoint, headers, bodyText);
134
+ return postThroughSandboxProxy(sandboxProxy, post);
135
+ }
136
+ }
137
+ async function sessionLimitsHelpLines({ timeoutMs = HELP_LIMITS_TIMEOUT_MS } = {}) {
138
+ const rawUrl = process.env[AGENT_URL_ENV];
139
+ if (!rawUrl) return [];
140
+ const target = verbEndpoint(rawUrl, "limits");
141
+ if (!target.ok) return [HELP_LIMITS_UNKNOWN_LINE];
142
+ try {
143
+ return limitsLines((await postToAgentIngress({
144
+ endpoint: target.endpoint,
145
+ token: target.token,
146
+ body: {},
147
+ deadline: AbortSignal.timeout(timeoutMs)
148
+ })).text) ?? [HELP_LIMITS_UNKNOWN_LINE];
149
+ } catch {
150
+ return [HELP_LIMITS_UNKNOWN_LINE];
115
151
  }
116
152
  }
117
153
  async function runAgentApiCli(args) {
@@ -135,7 +171,7 @@ async function runAgentApiCli(args) {
135
171
  }
136
172
  const rawUrl = process.env[AGENT_URL_ENV];
137
173
  if (!rawUrl) {
138
- console.error(`glimmervoid: ${AGENT_URL_ENV} is not set, so this is not a Glimmervoid session with the agent API turned on`);
174
+ console.error(`glimmervoid: ${AGENT_URL_ENV} is not set, so this is not a Glimmervoid session`);
139
175
  return 1;
140
176
  }
141
177
  const target = verbEndpoint(rawUrl, verb);
@@ -143,9 +179,13 @@ async function runAgentApiCli(args) {
143
179
  console.error(`glimmervoid: ${AGENT_URL_ENV} must be a loopback http url under ${AGENT_PATH_PREFIX}, so nothing was sent`);
144
180
  return 1;
145
181
  }
146
- const reply = await postToAgentIngress(target.endpoint, target.token, body);
147
- console.log(reply.text);
182
+ const reply = await postToAgentIngress({
183
+ endpoint: target.endpoint,
184
+ token: target.token,
185
+ body
186
+ });
187
+ console.log(printableReply(verb, reply.text));
148
188
  return reply.hasSuccessStatus && bodySaysOk(reply.text) ? 0 : 1;
149
189
  }
150
190
  //#endregion
151
- export { runAgentApiCli as n, postToAgentIngress as t };
191
+ export { runAgentApiCli as n, sessionLimitsHelpLines as r, postToAgentIngress as t };
@@ -1,14 +1,13 @@
1
- import { a as AgentDispatchRequest, i as AgentAttentionRequest, l as ORCHESTRATOR_AGENT_VERBS, o as AgentEditRequest, s as AgentSpawnRequest, t as AGENT_API_VERBS } from "./session-C7rstCmA.js";
1
+ import { a as AgentDispatchRequest, c as AgentSpawnRequest, i as AgentAttentionRequest, o as AgentEditRequest, t as AGENT_API_VERBS, u as ORCHESTRATOR_AGENT_VERBS } from "./session-D6xXN0UU.js";
2
+ import { c as spawnRoute, i as editRoute, n as attentionRoute, s as pushRoute, t as NO_OWN_WORKTREE_REASON } from "./session-routes-BYy3am9m.js";
2
3
  import crypto from "node:crypto";
3
4
  var MAX_SPAWNS_IN_FLIGHT = 1;
4
5
  var SPAWNABLE_DEPTH = 0;
5
6
  var REFUSAL_REASON = "unknown session";
6
7
  var INVALID_BODY_STATUS = 400;
7
8
  var PUSH_REFUSED_STATUS = 409;
8
- var PUSH_UNAVAILABLE_REASON = "not-operator-session";
9
9
  var PUSH_REFUSAL_COPY = Object.freeze({
10
- [PUSH_UNAVAILABLE_REASON]: () => "only an operator session or a session it spawned can push",
11
- "no-worktree": () => "this session has no worktree of its own, so there is nothing of its own to land",
10
+ "no-worktree": () => NO_OWN_WORKTREE_REASON,
12
11
  "merge-in-progress": () => "a merge for this session is already running, so try again when it ends",
13
12
  "not-continuable": () => "this session cannot be merged in its current state",
14
13
  destroyed: () => "this session is ending",
@@ -40,12 +39,21 @@ function decideAgentRequest({ sessionId, presentedToken, expectedToken, isLoopba
40
39
  if (!tokensMatch(presentedToken, expectedToken)) return refused();
41
40
  return { ok: true };
42
41
  }
43
- function decideSpawnAllowance({ liveChildren, lifetimeSpawns, inFlight, depth }) {
44
- if (depth !== SPAWNABLE_DEPTH) return {
42
+ function refuseByRole(route) {
43
+ if (route.answers) return { ok: true };
44
+ return {
45
45
  ok: false,
46
46
  status: 403,
47
- reason: "a spawned session may not spawn another"
47
+ reason: route.reason
48
48
  };
49
+ }
50
+ function decideSpawnAllowance({ liveChildren, lifetimeSpawns, inFlight, depth, isFactoryWorker, isEphemeral }) {
51
+ const role = refuseByRole(spawnRoute({
52
+ isEphemeral,
53
+ isSpawnedChild: depth !== SPAWNABLE_DEPTH,
54
+ factoryRole: isFactoryWorker ? "worker" : null
55
+ }));
56
+ if (!role.ok) return role;
49
57
  if (inFlight >= MAX_SPAWNS_IN_FLIGHT) return {
50
58
  ok: false,
51
59
  status: 429,
@@ -63,6 +71,24 @@ function decideSpawnAllowance({ liveChildren, lifetimeSpawns, inFlight, depth })
63
71
  };
64
72
  return { ok: true };
65
73
  }
74
+ function decideAttentionAllowance(caller) {
75
+ return refuseByRole(attentionRoute(caller));
76
+ }
77
+ function decideEditAllowance(caller) {
78
+ return refuseByRole(editRoute(caller));
79
+ }
80
+ function describePushRouteRefusal(caller) {
81
+ const route = pushRoute(caller);
82
+ if (route.answers) return null;
83
+ return {
84
+ status: PUSH_REFUSED_STATUS,
85
+ body: {
86
+ ok: false,
87
+ reason: route.code,
88
+ error: route.reason
89
+ }
90
+ };
91
+ }
66
92
  function isAgentApiVerb(verb) {
67
93
  return AGENT_API_VERBS.includes(verb);
68
94
  }
@@ -125,7 +151,7 @@ function parseAgentVerb(verb, payload) {
125
151
  status: 403,
126
152
  error: `${verb} requires a live factory orchestrator`
127
153
  };
128
- if (verb === "board" || verb === "push") return {
154
+ if (verb === "board" || verb === "push" || verb === "limits") return {
129
155
  ok: true,
130
156
  verb
131
157
  };
@@ -198,4 +224,4 @@ function deriveChildSessionName(parentName, existingNames) {
198
224
  return candidate;
199
225
  }
200
226
  //#endregion
201
- export { decideTicketAction as a, isAgentApiVerb as c, decideSpawnAllowance as i, isOrchestratorAgentVerb as l, REFUSAL_REASON as n, deriveChildSessionName as o, decideAgentRequest as r, describePushLanding as s, PUSH_UNAVAILABLE_REASON as t, parseAgentVerb as u };
227
+ export { decideSpawnAllowance as a, describePushLanding as c, isOrchestratorAgentVerb as d, parseAgentVerb as f, decideEditAllowance as i, describePushRouteRefusal as l, decideAgentRequest as n, decideTicketAction as o, decideAttentionAllowance as r, deriveChildSessionName as s, REFUSAL_REASON as t, isAgentApiVerb as u };
@@ -1,6 +1,6 @@
1
1
  import { a as isMissingFileError, r as errorMessage } from "./text-DoirglWV.js";
2
- import { a as classifyGrokHooksFile, o as renderGrokHooksFile, t as grok } from "./grok-BYKnBgdr.js";
3
- import { p as writeTextAtomicSync } from "./json-file-oEH9vt-0.js";
2
+ import { a as classifyGrokHooksFile, o as renderGrokHooksFile, t as grok } from "./grok-KKgdSe-7.js";
3
+ import { p as writeTextAtomicSync } from "./json-file-BaxGcB2R.js";
4
4
  import fs from "node:fs";
5
5
  import path from "node:path";
6
6
  //#region server/agent-setup-cli.ts
@@ -0,0 +1 @@
1
+ export { r as execFileSync } from "./child-process-safe-CbQnyh7D.js";