@indigoai-us/hq-cli 5.345.203 → 5.345.205

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 (95) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/command-catalog.generated.d.ts +51 -1
  3. package/dist/command-catalog.generated.js +63 -1
  4. package/dist/commands/bot.d.ts +67 -0
  5. package/dist/commands/bot.js +308 -41
  6. package/dist/commands/cloud-off-gate.d.ts +9 -2
  7. package/dist/commands/cloud-off-gate.js +49 -13
  8. package/dist/commands/cloud.d.ts +14 -2
  9. package/dist/commands/cloud.js +25 -16
  10. package/dist/commands/feedback.d.ts +26 -0
  11. package/dist/commands/feedback.js +91 -5
  12. package/dist/commands/install-global.d.ts +3 -1
  13. package/dist/commands/install-global.js +15 -4
  14. package/dist/commands/lanes.d.ts +2 -0
  15. package/dist/commands/lanes.js +9 -3
  16. package/dist/commands/mcp-serve.d.ts +5 -2
  17. package/dist/commands/mcp-serve.js +45 -3
  18. package/dist/commands/mcp-status.d.ts +3 -1
  19. package/dist/commands/mcp-status.js +24 -14
  20. package/dist/commands/secrets.js +11 -1
  21. package/dist/commands/sources.js +10 -15
  22. package/dist/commands/sync-core.js +2 -0
  23. package/dist/index.js +7 -2
  24. package/dist/lib/bot/claude-login.d.ts +7 -1
  25. package/dist/lib/bot/claude-login.js +56 -16
  26. package/dist/lib/bot/executive-settings.d.ts +13 -0
  27. package/dist/lib/bot/executive-settings.js +20 -17
  28. package/dist/lib/bot/executive-sync.d.ts +12 -0
  29. package/dist/lib/bot/executive-sync.js +36 -0
  30. package/dist/lib/bot/executive.d.ts +51 -0
  31. package/dist/lib/bot/executive.js +144 -0
  32. package/dist/lib/bot/fleet-cron.d.ts +7 -0
  33. package/dist/lib/bot/fleet-cron.js +2 -1
  34. package/dist/lib/bot/jobs/executive-handover.d.ts +6 -0
  35. package/dist/lib/bot/jobs/executive-handover.js +33 -0
  36. package/dist/lib/bot/jobs/hot-signal-sync.d.ts +22 -0
  37. package/dist/lib/bot/jobs/hot-signal-sync.js +47 -0
  38. package/dist/lib/bot/listed-running.d.ts +16 -0
  39. package/dist/lib/bot/listed-running.js +16 -0
  40. package/dist/lib/bot/pending-switch.d.ts +51 -0
  41. package/dist/lib/bot/pending-switch.js +103 -0
  42. package/dist/lib/bot/run.js +27 -3
  43. package/dist/lib/bot/runtime-failure.js +19 -3
  44. package/dist/lib/bot/status.d.ts +20 -0
  45. package/dist/lib/capacity/collectors/claude-oauth.d.ts +53 -5
  46. package/dist/lib/capacity/collectors/claude-oauth.js +251 -71
  47. package/dist/lib/company-skill-wrapper.js +29 -0
  48. package/dist/lib/daemon/catalog.js +2 -2
  49. package/dist/lib/daemon/hq-child-bootstrap.mjs +197 -2
  50. package/dist/lib/daemon/resolver.d.ts +14 -0
  51. package/dist/lib/daemon/resolver.js +96 -0
  52. package/dist/lib/daemon/run.d.ts +11 -0
  53. package/dist/lib/daemon/run.js +60 -8
  54. package/dist/lib/daemon/server.d.ts +2 -9
  55. package/dist/lib/daemon/server.js +3 -89
  56. package/dist/lib/doctor/checks/claude-wiring.js +41 -0
  57. package/dist/lib/doctor/checks/sync-health.d.ts +8 -0
  58. package/dist/lib/doctor/checks/sync-health.js +34 -2
  59. package/dist/lib/doctor/duplicate-hook-registrations.d.ts +34 -0
  60. package/dist/lib/doctor/duplicate-hook-registrations.js +130 -0
  61. package/dist/lib/doctor/fix/apply.js +79 -3
  62. package/dist/lib/doctor/fix/remediation.d.ts +1 -1
  63. package/dist/lib/doctor/fix/remediation.js +15 -0
  64. package/dist/lib/doctor/types.d.ts +1 -1
  65. package/dist/lib/doctor/types.js +1 -0
  66. package/dist/lib/lanes/config.js +13 -0
  67. package/dist/lib/lanes/throttle.d.ts +12 -1
  68. package/dist/lib/lanes/throttle.js +27 -8
  69. package/dist/lib/lanes/types.d.ts +5 -0
  70. package/dist/lib/mcp/local-native-tools.d.ts +40 -0
  71. package/dist/lib/mcp/local-native-tools.js +111 -0
  72. package/dist/lib/mcp/tools.d.ts +2 -0
  73. package/dist/lib/mcp/tools.js +2 -0
  74. package/dist/lib/signals/steps/extract.d.ts +111 -5
  75. package/dist/lib/signals/steps/extract.js +524 -55
  76. package/dist/lib/sync-core/engine-home.d.ts +2 -1
  77. package/dist/lib/sync-core/engine-home.js +25 -8
  78. package/dist/lib/sync-core/reconcile.d.ts +3 -1
  79. package/dist/lib/sync-core/reconcile.js +21 -8
  80. package/dist/lib/sync-core/release.d.ts +14 -5
  81. package/dist/lib/sync-core/release.js +58 -14
  82. package/dist/sentry-init.js +6 -0
  83. package/dist/utils/cli-network-lifecycle.d.ts +11 -1
  84. package/dist/utils/cli-network-lifecycle.js +36 -2
  85. package/dist/utils/daemon-helper-lifetime.d.ts +39 -0
  86. package/dist/utils/daemon-helper-lifetime.js +209 -0
  87. package/dist/utils/daemon-helper-markers.d.ts +24 -0
  88. package/dist/utils/daemon-helper-markers.js +53 -0
  89. package/dist/utils/mcp-launcher.d.ts +28 -0
  90. package/dist/utils/mcp-launcher.js +117 -0
  91. package/dist/utils/package-use-lease.d.ts +10 -0
  92. package/dist/utils/package-use-lease.js +31 -0
  93. package/dist/utils/resident-package-preload.js +4 -1
  94. package/docs/anywhere-runtime.md +7 -0
  95. package/package.json +7 -7
@@ -0,0 +1,40 @@
1
+ /**
2
+ * In-process answers for the hqd-native MCP tools that only touch the local HQ
3
+ * checkout: hq_resolve_company, hq_policy_check and hq_journal_append.
4
+ *
5
+ * `hq mcp serve` forwards every call to hqd. The HQ desktop app registers the
6
+ * `hq` connector whenever HQ Anywhere is on, but it runs hqd only when its
7
+ * `desktop.hq-daemon` flag is on, and a terminal install can register the
8
+ * connector before `hq daemon install`. Without this fallback those sessions
9
+ * got `hqd_unreachable` for a journal line (feedback_31380021). The hooks
10
+ * already work the same way: they route through hqd when it is running and use
11
+ * the direct engine when it is stopped.
12
+ *
13
+ * The checks match hqd's `mcp.call`: the server's cwd binds the company, an
14
+ * explicit company must match it, the HQ Anywhere gate is read before the call
15
+ * and again before the journal write, and the write runs only after the policy
16
+ * engine allows it. hq_run_worker and the hosted hq-mcp tools still need hqd.
17
+ */
18
+ import { type ResolveResult } from "../registry/registry.js";
19
+ import { type JournalAppendResult } from "../daemon/ops/journal.js";
20
+ import { type PolicyCheckResult } from "../daemon/ops/policy.js";
21
+ export declare const LOCAL_NATIVE_TOOL_NAMES: ReadonlySet<string>;
22
+ export declare class LocalToolError extends Error {
23
+ readonly code: string;
24
+ constructor(code: string, message: string);
25
+ }
26
+ /** Error classes whose code and message reach the MCP client unchanged, as they do through hqd. */
27
+ export declare function localToolErrorCode(err: unknown): string | null;
28
+ export interface LocalNativeContext {
29
+ hqRoot: string;
30
+ home: string;
31
+ env: NodeJS.ProcessEnv;
32
+ /** The server's working directory; it binds the company, as the caller cwd does in hqd. */
33
+ cwd: string;
34
+ /** HQ Anywhere gate (runtime flag and person setting). */
35
+ runtimeEnabled: () => boolean | Promise<boolean>;
36
+ now?: () => Date;
37
+ }
38
+ /** Run one native tool without hqd. Returns the value hqd would wrap as the tool result. */
39
+ export declare function callLocalNativeTool(name: string, raw: Record<string, unknown>, ctx: LocalNativeContext): Promise<ResolveResult | PolicyCheckResult | JournalAppendResult>;
40
+ //# sourceMappingURL=local-native-tools.d.ts.map
@@ -0,0 +1,111 @@
1
+ /**
2
+ * In-process answers for the hqd-native MCP tools that only touch the local HQ
3
+ * checkout: hq_resolve_company, hq_policy_check and hq_journal_append.
4
+ *
5
+ * `hq mcp serve` forwards every call to hqd. The HQ desktop app registers the
6
+ * `hq` connector whenever HQ Anywhere is on, but it runs hqd only when its
7
+ * `desktop.hq-daemon` flag is on, and a terminal install can register the
8
+ * connector before `hq daemon install`. Without this fallback those sessions
9
+ * got `hqd_unreachable` for a journal line (feedback_31380021). The hooks
10
+ * already work the same way: they route through hqd when it is running and use
11
+ * the direct engine when it is stopped.
12
+ *
13
+ * The checks match hqd's `mcp.call`: the server's cwd binds the company, an
14
+ * explicit company must match it, the HQ Anywhere gate is read before the call
15
+ * and again before the journal write, and the write runs only after the policy
16
+ * engine allows it. hq_run_worker and the hosted hq-mcp tools still need hqd.
17
+ */
18
+ import { registryDir, registryFile } from "../registry/registry.js";
19
+ import { createResolver } from "../daemon/resolver.js";
20
+ import { journalAppend, JournalOpError } from "../daemon/ops/journal.js";
21
+ import { PolicyIndex, PolicyOpError, policyCheck } from "../daemon/ops/policy.js";
22
+ import { HQ_ANYWHERE_RUNTIME_FLAG } from "../anywhere-runtime-flag-key.js";
23
+ export const LOCAL_NATIVE_TOOL_NAMES = new Set(["hq_resolve_company", "hq_policy_check", "hq_journal_append"]);
24
+ export class LocalToolError extends Error {
25
+ code;
26
+ constructor(code, message) {
27
+ super(message);
28
+ this.code = code;
29
+ this.name = "LocalToolError";
30
+ }
31
+ }
32
+ /** Error classes whose code and message reach the MCP client unchanged, as they do through hqd. */
33
+ export function localToolErrorCode(err) {
34
+ return err instanceof LocalToolError || err instanceof JournalOpError || err instanceof PolicyOpError ? err.code : null;
35
+ }
36
+ function stringArg(args, name, required = true) {
37
+ const value = args[name];
38
+ if (typeof value === "string" && value.trim())
39
+ return value;
40
+ if (value === undefined && !required)
41
+ return undefined;
42
+ throw new LocalToolError("bad_args", `${name} must be a non-empty string`);
43
+ }
44
+ async function requireEnabled(ctx) {
45
+ if (!(await ctx.runtimeEnabled())) {
46
+ throw new LocalToolError("anywhere_disabled", `HQ Anywhere is disabled by the ${HQ_ANYWHERE_RUNTIME_FLAG} flag.`);
47
+ }
48
+ }
49
+ /** Run one native tool without hqd. Returns the value hqd would wrap as the tool result. */
50
+ export async function callLocalNativeTool(name, raw, ctx) {
51
+ if (!LOCAL_NATIVE_TOOL_NAMES.has(name))
52
+ throw new LocalToolError("unknown_tool", `unknown tool ${name}`);
53
+ await requireEnabled(ctx);
54
+ const clock = ctx.now ?? (() => new Date());
55
+ const resolve = createResolver(registryFile(registryDir(ctx.home, ctx.env)), { hqRoot: ctx.hqRoot });
56
+ const toolArgs = { cwd: ctx.cwd, ...raw };
57
+ const companyArgs = { ...toolArgs, cwd: ctx.cwd };
58
+ delete companyArgs.runtime;
59
+ delete companyArgs.sessionId;
60
+ const companyFor = (args) => {
61
+ const explicit = stringArg(args, "company", false);
62
+ const cwd = stringArg(args, "cwd", false);
63
+ const bound = cwd ? (resolve(cwd).company ?? undefined) : undefined;
64
+ if (explicit && bound && explicit !== bound) {
65
+ throw new LocalToolError("company_mismatch", `explicit company ${explicit} conflicts with bound company ${bound}`);
66
+ }
67
+ return explicit ?? bound;
68
+ };
69
+ const index = new PolicyIndex(ctx.hqRoot);
70
+ const check = (args) => {
71
+ const company = companyFor(args);
72
+ if (!company)
73
+ throw new LocalToolError("bad_args", "company is required (or a cwd linked to a company)");
74
+ const input = args.input;
75
+ if (input !== undefined && (input === null || typeof input !== "object" || Array.isArray(input))) {
76
+ throw new LocalToolError("bad_args", "input must be an object");
77
+ }
78
+ return policyCheck({
79
+ company,
80
+ event: stringArg(args, "event", false),
81
+ tool: stringArg(args, "tool"),
82
+ input: input,
83
+ sessionId: stringArg(args, "sessionId", false),
84
+ cwd: stringArg(args, "cwd", false),
85
+ }, { hqRoot: ctx.hqRoot, index, env: ctx.env, now: clock });
86
+ };
87
+ try {
88
+ switch (name) {
89
+ case "hq_resolve_company":
90
+ return resolve(stringArg(toolArgs, "cwd"));
91
+ case "hq_policy_check":
92
+ return await check(companyArgs);
93
+ default: {
94
+ // hq_journal_append: policy first, then the gate again, then the write.
95
+ const company = companyFor(companyArgs);
96
+ if (!company)
97
+ throw new LocalToolError("bad_args", "company is required for a write-capable MCP tool");
98
+ const verdict = await check({ company, cwd: typeof toolArgs.cwd === "string" ? toolArgs.cwd : ctx.cwd, tool: name, input: raw });
99
+ if (verdict.decision !== "allow") {
100
+ throw new LocalToolError("policy_blocked", verdict.reasons.join("; ") || "policy check did not allow this tool");
101
+ }
102
+ await requireEnabled(ctx);
103
+ return journalAppend({ company, project: stringArg(companyArgs, "project"), section: stringArg(companyArgs, "section"), text: stringArg(companyArgs, "text") }, ctx.hqRoot, clock());
104
+ }
105
+ }
106
+ }
107
+ finally {
108
+ index.close();
109
+ }
110
+ }
111
+ //# sourceMappingURL=local-native-tools.js.map
@@ -10,6 +10,8 @@
10
10
  * hqd answers every one of these through the `mcp.call` op, so a subagent
11
11
  * without MCP can call the same tool with
12
12
  * `hq daemon call mcp.call --json '{"name":"hq_journal_append","arguments":{...}}'`.
13
+ * When hqd is not running, `hq mcp serve` answers the three local-only tools
14
+ * itself (local-native-tools.ts).
13
15
  */
14
16
  import type { McpToolDefinition } from "./types.js";
15
17
  export type { McpToolDefinition } from "./types.js";
@@ -10,6 +10,8 @@
10
10
  * hqd answers every one of these through the `mcp.call` op, so a subagent
11
11
  * without MCP can call the same tool with
12
12
  * `hq daemon call mcp.call --json '{"name":"hq_journal_append","arguments":{...}}'`.
13
+ * When hqd is not running, `hq mcp serve` answers the three local-only tools
14
+ * itself (local-native-tools.ts).
13
15
  */
14
16
  import { HQ_MCP_TOOLS } from "./hq-mcp-tools.generated.js";
15
17
  import { HOSTED_SEARCH_FETCH_TOOLS } from "./hosted-search-tools.js";
@@ -1,6 +1,6 @@
1
1
  import { type StoredPriorSignal } from "../prior-signals.js";
2
2
  import { type BotRuntimeId } from "../../bot/config.js";
3
- import type { SignalsStep, StepContext, StepResult } from "./types.js";
3
+ import type { SignalsStep, SpawnSyncFn, StepContext, StepResult } from "./types.js";
4
4
  export declare const EXTRACT_SIGNAL_TYPES: readonly ["action_item", "commitment", "decision", "risk", "question", "key_point", "participant_contribution", "summary"];
5
5
  export declare const DEFAULT_WORKLIST_LIMIT = 20;
6
6
  export declare const DEFAULT_TURN_TIMEOUT_MS: number;
@@ -13,6 +13,20 @@ export declare const WORKLIST_ITEM_TIMEOUT_MS = 10000;
13
13
  export declare function worklistTimeoutMs(limit: number): number;
14
14
  export declare const CODEX_PERMISSION_PROFILE = "hq_signals_extract";
15
15
  export declare const CANDIDATE_WRAPPER_NAME = "write-candidate.sh";
16
+ /** The sandbox profile the step writes to <turn dir>/.grok/sandbox.toml for a grok turn. */
17
+ export declare const GROK_SANDBOX_PROFILE = "hq_signals_extract";
18
+ export declare const GROK_SANDBOX_FILE: string;
19
+ /** The oldest grok whose `--help` lists every flag in GROK_EXTRACT_FLAGS. */
20
+ export declare const GROK_MIN_VERSION = "1.0.70";
21
+ /** Flags a grok turn needs; one missing from `--help` means the installed grok cannot be locked down. */
22
+ export declare const GROK_EXTRACT_FLAGS: readonly ["--permission-mode", "--tools", "--disallowed-tools", "--allow", "--deny", "--sandbox", "--disable-web-search", "--no-subagents", "--max-turns", "--cwd", "--output-format"];
23
+ /**
24
+ * grok's built-in read-only shell list (its permissions guide, "Read-Only
25
+ * Shell Commands"): auto-approved even under dontAsk, so each is denied by
26
+ * name. A Bash rule without `*` is a prefix match, so `Bash(cat)` also covers
27
+ * `cat` with any arguments.
28
+ */
29
+ export declare const GROK_READ_ONLY_COMMANDS: readonly ["ls", "cat", "pwd", "date", "whoami", "hostname", "uptime", "ps", "head", "tail", "wc", "sort", "uniq", "tr", "cut", "mkdir", "touch", "git", "grep", "rg", "kubectl"];
16
30
  /** The only tools a claude turn may use: Read inside the channel folder and the pinned wrapper. */
17
31
  export declare function claudeAllowedTools(channelDir: string, wrapperPath: string): string[];
18
32
  export interface PriorSignal {
@@ -36,10 +50,13 @@ export interface ExtractStepOptions {
36
50
  resolveBotRuntime?: () => BotRuntimeId | null;
37
51
  claudeBin?: string;
38
52
  codexBin?: string;
53
+ grokBin?: string;
39
54
  worklistLimit?: number;
40
55
  turnTimeoutMs?: number;
41
56
  /** Run channels whose source.yaml says run: cloud too (passes --force). */
42
57
  force?: boolean;
58
+ /** OS used to decide whether grok's child-process network block exists. Default: this process. */
59
+ platform?: NodeJS.Platform;
43
60
  }
44
61
  interface SourceChannel {
45
62
  channel: string;
@@ -51,7 +68,7 @@ interface WorkItem {
51
68
  audience?: string[];
52
69
  skip?: string;
53
70
  }
54
- /** First personal bot under ~/.hq/bots (by name) with a readable config. */
71
+ /** The Executive bot's runtime (lib/bot/executive.ts), or null when there is no personal bot. */
55
72
  export declare function defaultResolveBotRuntime(root?: string): BotRuntimeId | null;
56
73
  /**
57
74
  * The channel of a `--redo` item, which must be written `sources/<channel>/<file>.md`,
@@ -77,8 +94,11 @@ export declare function buildExtractPrompt(input: {
77
94
  item: WorkItem;
78
95
  itemPath: string;
79
96
  wrapperPath: string;
80
- /** codex has no Read tool; it reads with shell commands inside its sandbox. */
81
- runtime?: "claude" | "codex";
97
+ /**
98
+ * codex has no Read tool; it reads with shell commands inside its sandbox.
99
+ * grok reads with read_file and returns candidate commands as JSON data.
100
+ */
101
+ runtime?: "claude" | "codex" | "grok";
82
102
  }): string;
83
103
  /**
84
104
  * The per-item candidate command. It pins --company, --audience and
@@ -91,7 +111,16 @@ export declare function buildCandidateWrapper(input: {
91
111
  audience: string;
92
112
  sourceRef: string;
93
113
  }): string;
94
- /** Parse a stream-json transcript (or a codex --json event stream). */
114
+ /**
115
+ * Parse a stream-json transcript (claude), a codex --json event stream, or a
116
+ * grok streaming-json event stream.
117
+ *
118
+ * grok writes `{"type":"text","data":…}` deltas and one terminal
119
+ * `{"type":"end","stopReason":…,"num_turns":n,"total_cost_usd":x}`; a refused
120
+ * tool call ends the turn with stopReason "cancelled", and an API failure is
121
+ * `{"type":"error","message":…}`. Both are mapped to an error result so the
122
+ * item fails and is retried; only "end_turn" is success.
123
+ */
95
124
  export declare function parseTurnOutput(stdout: string): {
96
125
  result: Record<string, unknown> | null;
97
126
  turns: number;
@@ -134,9 +163,86 @@ export interface TurnScope {
134
163
  wrapperPath: string;
135
164
  /** companies/{co}/{signals,ontology}/_candidates, realpath. */
136
165
  candidateDirs: string[];
166
+ /**
167
+ * Text of the pinned writer, when this turn generated one. A grok turn
168
+ * compares the file to this immediately before executing it.
169
+ */
170
+ wrapperBody?: string;
137
171
  }
138
172
  /** TOML inline table for the codex permission profile's filesystem entries. */
139
173
  export declare function codexFilesystemProfile(scope: TurnScope, codexBin: string, envPath: string | undefined): string;
174
+ /**
175
+ * The sandbox profile for a grok turn, written to <turn dir>/.grok/sandbox.toml.
176
+ * grok's `strict` already covers the turn dir (cwd), system paths and ~/.grok;
177
+ * the grants add bash's install prefix (Homebrew bash loads from it) and the
178
+ * read-only HQ paths of hqTurnGrants. Candidate folders are not granted:
179
+ * the host writes them after the turn, outside this sandbox.
180
+ */
181
+ export declare function grokSandboxProfile(scope: TurnScope, envPath: string | undefined): string;
182
+ /** Grok can read the source; candidate writing belongs to the host. */
183
+ export declare function grokAllowRules(channelDir: string): string[];
184
+ /** Parse literal arguments only. No shell ever interprets model output. */
185
+ export declare function grokCandidateArgv(command: string, wrapperPath: string): string[] | null;
186
+ /**
187
+ * Validate the whole batch before writing. Only the host executes the pinned
188
+ * writer. When `expectedWrapper` is set, the file is compared to that text
189
+ * immediately before each exec. Strict can write the turn directory, so a
190
+ * writer that no longer matches is not run.
191
+ */
192
+ export declare function executeGrokCandidates(text: string, wrapperPath: string, spawn: SpawnSyncFn, opts: Parameters<SpawnSyncFn>[2], expectedWrapper?: string): string | undefined;
193
+ /**
194
+ * Read denies for the grok login. Grok matches a `~` tool path literally and
195
+ * expands `~` only after that check, so the absolute temp home is not enough.
196
+ * `realHomes` is every home the original login might live under (the process
197
+ * HOME we copied from, and os.homedir() when that differs).
198
+ */
199
+ export declare function grokAuthReadDenies(tempHome: string, realHomes: readonly string[]): string[];
200
+ /** Deny rules of a grok turn: every other tool class, the login file, and the read-only shell list. */
201
+ export declare function grokDenyRules(tempHome: string, realHomes: readonly string[]): string[];
202
+ export declare function grokTurnArgs(prompt: string, scope: TurnScope, maxTurns: number, tempHome: string, realHomes: readonly string[]): string[];
203
+ /** Parent env keys copied into a grok turn. Everything else, including credentials, stays out. */
204
+ export declare const GROK_ENV_ALLOW: readonly ["PATH", "HOME", "TMPDIR", "TMP", "TEMP", "LANG", "LC_ALL", "LC_CTYPE", "USER", "LOGNAME", "SHELL", "SystemRoot", "COMSPEC", "PATHEXT", "WINDIR", "TERM", "TZ", "HQ_ROOT"];
205
+ /** The turn's environment for grok: an allowlist, no sandbox or config overrides, no Claude or Cursor configuration scans. */
206
+ export declare function grokTurnEnv(base: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
207
+ export type GrokExtractSupport = {
208
+ ok: true;
209
+ } | {
210
+ ok: false;
211
+ missing: string[];
212
+ };
213
+ /** Whether `grok --help` lists every flag a locked-down turn needs, and streaming-json output. */
214
+ export declare function grokExtractSupportFromHelp(helpText: string): GrokExtractSupport;
215
+ export declare function resetGrokExtractProbeCache(): void;
216
+ /** Probe `grok --help` once per grok binary path (empty or failed output counts as every flag missing). */
217
+ export declare function probeGrokExtractSupport(grokBin: string, readHelp: () => string): GrokExtractSupport;
218
+ export type GrokAvailability = {
219
+ installed: false;
220
+ } | {
221
+ installed: true;
222
+ support: GrokExtractSupport;
223
+ };
224
+ export interface ToolAvailability {
225
+ installed: boolean;
226
+ /** The tool's own answer; null when it did not say (then it is not used as a fallback). */
227
+ signedIn: boolean | null;
228
+ }
229
+ export type ExtractRuntimeChoice = {
230
+ runtime: BotRuntimeId;
231
+ fallback?: string;
232
+ } | {
233
+ error: string;
234
+ };
235
+ /**
236
+ * Which runtime runs the turns. The main bot's runtime, except that a grok
237
+ * that is missing or cannot be locked down is never run: the step uses
238
+ * claude, then codex, when that tool is installed and signed in, and
239
+ * otherwise fails. The claude and codex checks run only when needed.
240
+ */
241
+ export declare function chooseExtractRuntime(main: BotRuntimeId, avail: {
242
+ grok: () => GrokAvailability;
243
+ claude: () => ToolAvailability;
244
+ codex: () => ToolAvailability;
245
+ }, platform?: NodeJS.Platform): ExtractRuntimeChoice;
140
246
  export declare function claudeTurnArgs(prompt: string, scope: TurnScope, maxTurns: number, budgetUsd: number): string[];
141
247
  export declare function codexTurnArgs(prompt: string, scope: TurnScope, codexBin: string, envPath: string | undefined): string[];
142
248
  export declare function extractPartialDocument(ctx: StepContext, doc: PartialDocument, prior: readonly PriorSignal[]): Promise<StepResult>;