orkestrator 2.35.5-beta → 2.36.0

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.
@@ -4,7 +4,7 @@ import { createHash } from "node:crypto";
4
4
  // ../protocol/src/secret-redaction.ts
5
5
  var TEXT_RULES = [
6
6
  {
7
- pattern: /([a-z][a-z0-9+.-]*:\/\/)[^/\s:@]+(?::[^/\s@]*)?@/gi,
7
+ pattern: /(?<![a-z0-9+.-])([a-z][a-z0-9+.-]*:\/\/)[^/\s:@]+(?::[^/\s@]*)?@/gi,
8
8
  replacement: "$1[redacted]@"
9
9
  },
10
10
  {
@@ -24,7 +24,7 @@ var TEXT_RULES = [
24
24
  { pattern: /\bAKIA[0-9A-Z]{12,}/g, replacement: "[redacted]" },
25
25
  { pattern: /\bAIza[0-9A-Za-z_-]{20,}/g, replacement: "[redacted]" },
26
26
  {
27
- pattern: /\b((?:[A-Za-z0-9]+[_-])*(?:api[_-]?key|apikey|access[_-]?token|refresh[_-]?token|auth[_-]?token|token|secret|client[_-]?secret|password|passwd|passphrase|authorization))("?\s*[:=]\s*)("?)(?!Bearer\b|Basic\b|\[redacted\])[^\s"',;)&]{6,}\3/gi,
27
+ pattern: /(?<![A-Za-z0-9_-])(-*\b(?:[A-Za-z0-9]+[_-])*(?:api[_-]?key|apikey|access[_-]?token|refresh[_-]?token|auth[_-]?token|token|secret|client[_-]?secret|password|passwd|passphrase|authorization))("?\s*[:=]\s*)("?)(?!Bearer\b|Basic\b|\[redacted\])[^\s"',;)&]{6,}\3/gi,
28
28
  replacement: "$1$2[redacted]"
29
29
  }
30
30
  ];
@@ -342,6 +342,7 @@ var BRIDGE_LOG_AREAS = defineLogAreas({
342
342
  "session.created": "A session was created or recovered.",
343
343
  "session.delete-failed": "Deleting a session failed.",
344
344
  "session.fork-failed": "Forking a session failed.",
345
+ "session.policy-widening-refused": "A config request tried to widen a live session's execution policy and was refused; widened names the axes.",
345
346
  "session.rename-failed": "Renaming a session failed.",
346
347
  "session.resolve-failed": "A session could not be found or loaded for a request; action names the request.",
347
348
  "session.rewind-failed": "Rewinding session files failed.",
@@ -474,6 +475,7 @@ var DESKTOP_LOG_AREAS = defineLogAreas({
474
475
  "backend.keychain-link-remove-failed": "An agent-test profile kept a legacy link to the host keychain.",
475
476
  "backend.start-failed": "The Local backend did not start; continuing with remote machines.",
476
477
  "clipboard.write-failed": "Writing text to the system clipboard failed.",
478
+ "dev-mode.ignored-packaged": "A packaged app was launched with ELECTRON_DEV=1 and ignored it; it loads its bundled renderer.",
477
479
  "instance.already-running": "Another instance holds this data directory; this one will quit.",
478
480
  "main-thread.stalled": "A timer fired late, so windows, IPC and the stdout reader waited.",
479
481
  "quit.stopping-backend": "The app is quitting and has asked the Local backend to stop.",
@@ -546,7 +548,8 @@ var DESKTOP_LOG_AREAS = defineLogAreas({
546
548
  description: "Preparing the pinned agent toolchain at desktop startup.",
547
549
  events: {
548
550
  "bootstrap-progress.show-failed": "The toolchain progress window could not be shown.",
549
- "prepare.failed": "Preparing the pinned agent tools failed."
551
+ "prepare.failed": "Preparing the pinned agent tools failed.",
552
+ "prepare.ready": "The pinned agent tools were verified and activated; durationMs is how long startup waited."
550
553
  }
551
554
  },
552
555
  "artifact-host": {
@@ -734,6 +737,7 @@ var NATIVE_AGENT_LOG_AREAS = defineLogAreas({
734
737
  description: "Native agent sessions and what the backend reads from their bridges.",
735
738
  events: {
736
739
  "catalogue.outdated-bridge": "A bridge predates the command catalogue, so its commands stay unavailable.",
740
+ "compact.instructions-ignored": "A bridge compacted without confirming the instructions sent with /compact: it predates them.",
737
741
  "handoff.summary-read-failed": "Change summaries could not be read for a handoff, so the carrier says they are unmeasured.",
738
742
  "handoff.consume-failed": "A delivered handoff could not be marked consumed.",
739
743
  "job.pr-refresh-rollback-failed": "Rolling back a pull request refresh for a job failed.",
@@ -989,6 +993,8 @@ var TMUX_LOG_AREAS = defineLogAreas({
989
993
  "interactive.snapshot-failed": "An interactive snapshot failed; expected while a pane is closing.",
990
994
  "signal.arm-failed": "The Claude state signal could not be armed.",
991
995
  "signal.degraded": "The Claude state signal missed a change or rang too often, so polling stays at one second until it is re-armed.",
996
+ "hook-signal.arm-failed": "The tmux hook doorbell could not be armed.",
997
+ "hook-signal.degraded": "The tmux hook doorbell missed a hook, so idle tabs poll every second until it is re-armed.",
992
998
  "pr-refresh.schedule-failed": "A pull request refresh after a turn could not be scheduled.",
993
999
  "pr-probe.failed": "Probing for a pull request an agent created failed.",
994
1000
  "activity.persist-failed": "Tmux tab activity could not be saved.",
@@ -1170,6 +1176,7 @@ var COORDINATOR_LOG_AREAS = defineLogAreas({
1170
1176
  "work.move-failed": "Work could not move to the main coordinator.",
1171
1177
  "wake.observe-remote-workflow-failed": "A remote workflow could not be observed for status wakes.",
1172
1178
  "wake.observe-pull-request-failed": "A pull request could not be observed for status wakes.",
1179
+ "wake.observe-feature-plan-failed": "A feature plan could not be observed for status wakes.",
1173
1180
  "wake.observe-workflow-failed": "A workflow could not be observed for status wakes.",
1174
1181
  "wake.deliver-failed": "A workflow status wake could not be delivered; the next pass retries.",
1175
1182
  "wake.waiting-check-failed": "A waiting worker could not be checked; the next pass retries.",
@@ -1181,7 +1188,11 @@ var COORDINATOR_LOG_AREAS = defineLogAreas({
1181
1188
  "store.invalid-workspace": "An invalid coordinator workspace record was ignored.",
1182
1189
  "store.workflows-cleared": "The workflow store was full, so a batch of its oldest finished records was removed.",
1183
1190
  "store.workflows-in-use": "The workflow store was full and every record was still in use, so new work was refused.",
1184
- "remote-worker.settle-failed": "A remote worker could not be settled."
1191
+ "remote-worker.settle-failed": "A remote worker could not be settled.",
1192
+ "checkout.merge-followed": "After an environment's PR merged, the project checkout was fast-forwarded, or `outcome` says why not.",
1193
+ "checkout.merge-follow-failed": "Fast-forwarding the project checkout failed, after an environment's PR merged or before mail woke the main coordinator.",
1194
+ "checkout.mail-follow": "Before mail woke the main coordinator, the project checkout was fast-forwarded, or `outcome` says why not (`timed-out`, `failed`).",
1195
+ "checkout.mail-follow-failed": "Before mail woke the main coordinator, checking whether to fast-forward the project checkout failed; the mail was delivered anyway."
1185
1196
  }
1186
1197
  }
1187
1198
  });
@@ -1213,6 +1224,7 @@ var REVIEW_LOG_AREAS = defineLogAreas({
1213
1224
  "gh.pr-list-unparseable": "`gh pr list` returned nothing that parses. Sizes only, never the output.",
1214
1225
  "monitor.start-failed": "Monitoring could not start for a newly opened pull request.",
1215
1226
  "cleanup-scheduler.missing": "A merged pull request was seen, but this runtime has no merge cleanup scheduler.",
1227
+ "checkout.follow-merge-lookup-failed": "A merged pull request's project could not be read, so its checkout was not fast-forwarded.",
1216
1228
  "auto-merge.evaluation-failed": "Evaluating an environment for auto-merge failed.",
1217
1229
  "auto-merge.merge-failed": "Auto-merge could not merge a pull request; the attempt is held and retried.",
1218
1230
  "auto-merge.resolve-failed": "Auto-merge could not launch Resolve for a pull request; the attempt is held and retried.",
@@ -1256,6 +1268,8 @@ var AGENT_ACCOUNTS_LOG_AREAS = defineLogAreas({
1256
1268
  "container-sync.failed": "Handing a login or account to a container failed; `step` says which part.",
1257
1269
  "last-usage.save-failed": "The last plan usage reading could not be saved; the next save retries.",
1258
1270
  "login-cleanup.failed": "A temporary login could not be cleaned up.",
1271
+ "login-renewal.failed": "Renewing an idle account's sign-in to read its usage failed; it is retried after a backoff.",
1272
+ "login-renewal.not-extended": "Claude Code ran to renew an idle account's sign-in, but its token is still lapsed.",
1259
1273
  "login-refresh.deferred": "Containers were not told to refresh their login now; they reconcile from its durable generation."
1260
1274
  }
1261
1275
  }
@@ -1269,6 +1283,7 @@ var DOCKER_LOG_AREAS = defineLogAreas({
1269
1283
  "portable-inputs.relay-missing": "Docker is rootless and the image predates the staged-input relay, so the container cannot read them until rebuilt.",
1270
1284
  "project-seed.refused": "A project .env, .env.local or opencode.json was not copied into a new container: a link, not a regular file, outside the project, too large or unreadable.",
1271
1285
  "opencode.warm-incomplete": "OpenCode did not finish loading /workspace in a container.",
1286
+ "lifecycle-event.reconcile-failed": "Reconciling an environment after a container start or stop event failed; the next status read retries.",
1272
1287
  "login-keeper.pass-failed": "A Claude login keeper pass failed; the next interval retries.",
1273
1288
  "login-keeper.refresh-failed": "Refreshing the host Claude login failed. Fixed text: CLI output can hold credentials.",
1274
1289
  "login-keeper.refresh-not-extended": "Refreshing the host Claude login did not extend its expiry.",
@@ -1392,7 +1407,7 @@ var GRAPH_LOG_AREAS = defineLogAreas({
1392
1407
  // ../protocol/src/log-vocabulary/nodes.ts
1393
1408
  var NODES_LOG_AREAS = defineLogAreas({
1394
1409
  nodes: {
1395
- description: "Command nodes: links, handovers, leaf mail and project copies.",
1410
+ description: "Command nodes: links, handovers, leaf mail, ticket sync and project copies.",
1396
1411
  events: {
1397
1412
  "actions.resume-failed": "Approved actions could not be resumed; a later pass retries.",
1398
1413
  "project-copy.notify-failed": "The coordinator could not be told a project copy finished.",
@@ -1404,7 +1419,11 @@ var NODES_LOG_AREAS = defineLogAreas({
1404
1419
  "verification.record-failed": "A node verification could not be recorded.",
1405
1420
  "profile.record-failed": "A node profile could not be recorded.",
1406
1421
  "detach.unconfirmed": "A forgotten node has not confirmed the detach yet.",
1407
- "handover.recovery-pending": "Command handover recovery is still pending."
1422
+ "handover.recovery-pending": "Command handover recovery is still pending.",
1423
+ "ticket-sync.work-record-failed": "A remote build started but its ticket work location could not be saved.",
1424
+ "ticket-sync.failed": "A Kanban sync with a node failed; it is retried.",
1425
+ "ticket-sync.unknown-project": "A node sent ticket changes for a project that no longer exists here.",
1426
+ "ticket-sync.forget-failed": "A detached command node's ticket copies could not be released."
1408
1427
  }
1409
1428
  }
1410
1429
  });
@@ -11638,6 +11657,272 @@ import { constants } from "node:fs";
11638
11657
  import { lstat, open as open2, realpath } from "node:fs/promises";
11639
11658
  import { dirname, isAbsolute, join as join2, relative, resolve, sep } from "node:path";
11640
11659
  import { randomBytes } from "node:crypto";
11660
+
11661
+ // ../protocol/src/coordinator-web-research.ts
11662
+ var DEFAULT_COORDINATOR_RESEARCH_MCP_SERVERS = Object.freeze([{ name: "context7", url: "https://mcp.context7.com/mcp" }]);
11663
+ var COORDINATOR_DENIED = Object.freeze([
11664
+ "file.write",
11665
+ "file.patch",
11666
+ "shell.mutate",
11667
+ "network"
11668
+ ]);
11669
+ function coordinatorCapabilityPolicy(mode) {
11670
+ return {
11671
+ deny: [...COORDINATOR_DENIED],
11672
+ ...mode === "off" ? {} : { allow: ["web.search"] }
11673
+ };
11674
+ }
11675
+
11676
+ // ../../bridges/acp-bridge/src/acp-policy.ts
11677
+ var BRIDGE_EXECUTION_POLICY_ENV = "ORKESTRATOR_BRIDGE_EXECUTION_POLICY";
11678
+ function processExecutionPolicyIsCoordinator(env = process.env) {
11679
+ return env[BRIDGE_EXECUTION_POLICY_ENV] === "coordinator-read-only";
11680
+ }
11681
+ function coordinatorProcessPolicy() {
11682
+ return {
11683
+ id: "coordinator-read-only",
11684
+ sandbox: "provider",
11685
+ approvals: "deny",
11686
+ projectResources: false,
11687
+ capabilityPolicy: coordinatorCapabilityPolicy("off"),
11688
+ networkAccess: "restricted",
11689
+ note: "Grok's write, search_replace, shell, subagent, web search and web fetch tools are removed. Remaining permission requests are denied; other tools that do not ask, including xAI's hosted X search tools, remain advisory."
11690
+ };
11691
+ }
11692
+ function effectiveExecutionPolicy(requested, env = process.env) {
11693
+ if (!processExecutionPolicyIsCoordinator(env))
11694
+ return requested;
11695
+ return coordinatorProcessPolicy();
11696
+ }
11697
+ function effectiveTurnExecutionPolicy(input) {
11698
+ return input.readOnly ? coordinatorProcessPolicy() : effectiveExecutionPolicy(input.policy);
11699
+ }
11700
+ function acpReportedPolicy(policy, agent) {
11701
+ const applied = withoutProviderSandbox(policy, { agent, toolsetBlocksNetwork: false });
11702
+ if (applied.projectResources)
11703
+ return applied;
11704
+ return appendNativeAgentPolicyNote({ ...applied, projectResources: true }, `${agent} loads a project's own configuration by its own folder trust, whatever this session's policy says.`);
11705
+ }
11706
+ function acpSessionReportedPolicy(state, agent) {
11707
+ if (state.readOnly) {
11708
+ return readOnlyTurnReportedPolicy(acpReportedPolicy(coordinatorProcessPolicy(), agent));
11709
+ }
11710
+ return state.policy ? acpReportedPolicy(state.policy, agent) : undefined;
11711
+ }
11712
+ var ACP_FILE_MUTATION_DENIALS = Object.freeze([
11713
+ "file.write",
11714
+ "file.patch",
11715
+ "write",
11716
+ "edit",
11717
+ "apply_patch"
11718
+ ]);
11719
+ var ACP_SHELL_DENIALS = Object.freeze(["shell", "shell.mutate"]);
11720
+ var FULL_ACP_CLIENT_METHOD_GRANT = Object.freeze({
11721
+ writeTextFile: true,
11722
+ terminal: true
11723
+ });
11724
+ function acpClientMethodGrant(policy) {
11725
+ if (!policy)
11726
+ return FULL_ACP_CLIENT_METHOD_GRANT;
11727
+ if (policy.approvals === "deny")
11728
+ return { writeTextFile: false, terminal: false };
11729
+ const denied = new Set([
11730
+ ...nativeAgentDeniedCapabilities(policy),
11731
+ ...policy.toolPolicy?.deny ?? []
11732
+ ]);
11733
+ return {
11734
+ writeTextFile: !ACP_FILE_MUTATION_DENIALS.some((name) => denied.has(name)),
11735
+ terminal: !ACP_SHELL_DENIALS.some((name) => denied.has(name))
11736
+ };
11737
+ }
11738
+
11739
+ // ../../bridges/acp-bridge/src/acp-provider-config.ts
11740
+ import { mkdtempSync } from "node:fs";
11741
+ import { tmpdir } from "node:os";
11742
+ import path from "node:path";
11743
+ var GROK_PROVIDER = {
11744
+ id: "grok",
11745
+ name: "Grok",
11746
+ executable: "grok",
11747
+ argv: ["--always-approve", "agent", "{{model}}", "{{effort}}", "stdio"],
11748
+ env: {},
11749
+ requiresAuthenticate: true,
11750
+ authMethodEnv: "GROK_AUTH_METHOD_ID",
11751
+ modeMap: {
11752
+ agent: "build",
11753
+ code: "build",
11754
+ build: "build",
11755
+ agentic: "build",
11756
+ plan: "plan",
11757
+ architect: "plan",
11758
+ ask: "plan"
11759
+ },
11760
+ extensionPrefixes: ["x.ai/", "_x.ai/"],
11761
+ acknowledgedExtensionMethods: [],
11762
+ modelUpdateMethods: ["x.ai/models/update", "_x.ai/models/update"],
11763
+ sessionUpdateMethods: ["x.ai/session/update", "_x.ai/session/update"]
11764
+ };
11765
+ var UNDECLARED_PROMPT_CAPABILITIES = {};
11766
+ function undeclaredPromptCapabilities(providerId) {
11767
+ return Object.hasOwn(UNDECLARED_PROMPT_CAPABILITIES, providerId) ? UNDECLARED_PROMPT_CAPABILITIES[providerId] : {};
11768
+ }
11769
+ var SESSION_FORK_METHODS = {
11770
+ grok: { fork: "_x.ai/session/fork", promptPoints: "_x.ai/rewind/points" }
11771
+ };
11772
+ function sessionForkMethods(providerId) {
11773
+ return Object.hasOwn(SESSION_FORK_METHODS, providerId) ? SESSION_FORK_METHODS[providerId] : undefined;
11774
+ }
11775
+ function loadAcpProviderConfig(environment = process.env) {
11776
+ const serialized = environment.ACP_PROVIDER_CONFIG?.trim();
11777
+ if (serialized)
11778
+ return parseProviderConfig(serialized);
11779
+ const id = environment.ACP_PROVIDER?.trim();
11780
+ if (id && id !== "grok") {
11781
+ throw new Error("ACP_PROVIDER_CONFIG is required for ACP providers other than grok (ACP_PROVIDER=grok is built in)");
11782
+ }
11783
+ return {
11784
+ ...GROK_PROVIDER,
11785
+ executable: environment.ACP_AGENT_PATH?.trim() || GROK_PROVIDER.executable
11786
+ };
11787
+ }
11788
+ var NETWORK_DENIED_ARGUMENTS = {
11789
+ grok: {
11790
+ leading: ["--disable-web-search"],
11791
+ subcommand: "agent",
11792
+ afterSubcommand: ["--no-leader"]
11793
+ }
11794
+ };
11795
+ var PROJECT_TRUST = {
11796
+ grok: {
11797
+ env: { GROK_FOLDER_TRUST: "0" },
11798
+ subcommand: "agent",
11799
+ afterSubcommand: ["--no-leader"]
11800
+ }
11801
+ };
11802
+ var SESSION_RULES_META_FIELD = {
11803
+ grok: "rules"
11804
+ };
11805
+ function sessionInstructionsMeta(config, instructions) {
11806
+ if (!instructions || !Object.hasOwn(SESSION_RULES_META_FIELD, config.id))
11807
+ return {};
11808
+ return { _meta: { [SESSION_RULES_META_FIELD[config.id]]: instructions } };
11809
+ }
11810
+ var POLICY_ENV = {
11811
+ grok: { GROK_WORKTREE_INHERITS_MAIN_APPROVALS: "false" }
11812
+ };
11813
+ function projectTrust(config, trustProject) {
11814
+ return trustProject && Object.hasOwn(PROJECT_TRUST, config.id) ? PROJECT_TRUST[config.id] : undefined;
11815
+ }
11816
+ var withheldGhConfigDir;
11817
+ function emptyGhConfigDir() {
11818
+ withheldGhConfigDir ??= mkdtempSync(path.join(tmpdir(), "orkestrator-gh-withheld-"));
11819
+ return withheldGhConfigDir;
11820
+ }
11821
+ var BRIDGE_CONTROL_ENV_VARS = Object.freeze([
11822
+ "ACP_BRIDGE_TOKEN",
11823
+ "ORKESTRATOR_AGENT_MCP_TOKEN",
11824
+ "ORKESTRATOR_AGENT_MCP_URL"
11825
+ ]);
11826
+ function withoutBridgeControlEnvironment(env) {
11827
+ const scrubbed = { ...env };
11828
+ for (const name of Object.keys(scrubbed)) {
11829
+ if (BRIDGE_CONTROL_ENV_VARS.includes(name) || name.endsWith("_BRIDGE_TOKEN")) {
11830
+ delete scrubbed[name];
11831
+ }
11832
+ }
11833
+ return scrubbed;
11834
+ }
11835
+ function providerEnv(config, options, base = process.env) {
11836
+ const env = {
11837
+ ...withoutBridgeControlEnvironment(base),
11838
+ ...config.env,
11839
+ ...Object.hasOwn(POLICY_ENV, config.id) ? POLICY_ENV[config.id] : {},
11840
+ ...projectTrust(config, options.trustProject)?.env
11841
+ };
11842
+ return options.withholdGitHub ? withheldGitHubCredentialEnvironment(env, options.withholdGitHub) : env;
11843
+ }
11844
+ function providerArgv(config, options) {
11845
+ if (options.readOnlyProfilePath && !config.argv.includes("agent")) {
11846
+ throw new Error("Grok read-only profile requires a local agent launcher");
11847
+ }
11848
+ const network = options.denyNetwork && Object.hasOwn(NETWORK_DENIED_ARGUMENTS, config.id) ? NETWORK_DENIED_ARGUMENTS[config.id] : undefined;
11849
+ const trust = projectTrust(config, options.trustProject);
11850
+ const argv = config.argv.flatMap((argument) => {
11851
+ if (argument === "--always-approve" && options.approvals && options.approvals !== "auto-approve") {
11852
+ return [];
11853
+ }
11854
+ if (argument === "{{model}}")
11855
+ return options.model ? ["--model", options.model] : [];
11856
+ if (argument === "{{effort}}") {
11857
+ return options.effort ? ["--reasoning-effort", options.effort] : [];
11858
+ }
11859
+ const after = [
11860
+ ...network && argument === network.subcommand ? network.afterSubcommand : [],
11861
+ ...trust && argument === trust.subcommand ? trust.afterSubcommand : [],
11862
+ ...argument === "agent" && options.readOnlyProfilePath ? ["--no-leader"] : []
11863
+ ];
11864
+ return [
11865
+ argument,
11866
+ ...new Set(after),
11867
+ ...argument === "agent" && options.readOnlyProfilePath ? ["--agent-profile", options.readOnlyProfilePath] : []
11868
+ ];
11869
+ });
11870
+ return network ? [...network.leading, ...argv] : argv;
11871
+ }
11872
+ function parseProviderConfig(serialized) {
11873
+ let value;
11874
+ try {
11875
+ value = JSON.parse(serialized);
11876
+ } catch {
11877
+ throw new Error("ACP_PROVIDER_CONFIG must be valid JSON");
11878
+ }
11879
+ if (!isRecord2(value))
11880
+ throw new Error("ACP_PROVIDER_CONFIG must be a JSON object");
11881
+ const id = requiredString(value.id, "id");
11882
+ const executable = requiredString(value.executable, "executable");
11883
+ const argv = stringArray(value.argv, "argv", 128);
11884
+ const modeMap = isRecord2(value.modeMap) ? Object.fromEntries(Object.entries(value.modeMap).flatMap(([agentMode, normalized]) => normalized === "build" || normalized === "plan" ? [[agentMode, normalized]] : [])) : {};
11885
+ const env = isRecord2(value.env) ? Object.fromEntries(Object.entries(value.env).flatMap(([key, entry]) => typeof entry === "string" ? [[key, entry]] : [])) : {};
11886
+ return {
11887
+ id,
11888
+ name: optionalString(value.name) ?? id,
11889
+ executable,
11890
+ argv,
11891
+ env,
11892
+ requiresAuthenticate: value.requiresAuthenticate === true,
11893
+ ...optionalString(value.authMethodEnv) ? { authMethodEnv: optionalString(value.authMethodEnv) } : {},
11894
+ modeMap,
11895
+ extensionPrefixes: stringArray(value.extensionPrefixes, "extensionPrefixes", 64, true),
11896
+ acknowledgedExtensionMethods: stringArray(value.acknowledgedExtensionMethods, "acknowledgedExtensionMethods", 64, true),
11897
+ modelUpdateMethods: stringArray(value.modelUpdateMethods, "modelUpdateMethods", 64, true),
11898
+ sessionUpdateMethods: stringArray(value.sessionUpdateMethods, "sessionUpdateMethods", 64, true)
11899
+ };
11900
+ }
11901
+ function stringArray(value, field, maximum, optional = false) {
11902
+ if (value === undefined && optional)
11903
+ return [];
11904
+ if (!Array.isArray(value) || value.length > maximum || value.some((entry) => !optionalString(entry))) {
11905
+ throw new Error(`ACP_PROVIDER_CONFIG.${field} must be an array of non-empty strings`);
11906
+ }
11907
+ return value;
11908
+ }
11909
+ function requiredString(value, field) {
11910
+ const parsed = optionalString(value);
11911
+ if (!parsed)
11912
+ throw new Error(`ACP_PROVIDER_CONFIG.${field} must be a non-empty string`);
11913
+ return parsed;
11914
+ }
11915
+ function optionalString(value) {
11916
+ if (typeof value !== "string")
11917
+ return;
11918
+ const trimmed = value.trim();
11919
+ return trimmed && Buffer.byteLength(trimmed) <= 4096 ? trimmed : undefined;
11920
+ }
11921
+ function isRecord2(value) {
11922
+ return value !== null && typeof value === "object" && !Array.isArray(value);
11923
+ }
11924
+
11925
+ // ../../bridges/acp-bridge/src/acp-client-methods.ts
11641
11926
  var MAX_FILE_BYTES = 2 * 1024 * 1024;
11642
11927
  var MAX_READ_LINES = 1e5;
11643
11928
  var DEFAULT_TERMINAL_OUTPUT_BYTES = 1024 * 1024;
@@ -11703,12 +11988,17 @@ class BoundedTerminalOutput {
11703
11988
  class AcpClientMethods {
11704
11989
  workspaceRoot;
11705
11990
  spawnTerminalImpl;
11991
+ grant;
11706
11992
  #terminals = new Map;
11707
- constructor(workspaceRoot, spawnTerminalImpl = spawnTerminal) {
11993
+ constructor(workspaceRoot, spawnTerminalImpl = spawnTerminal, grant = FULL_ACP_CLIENT_METHOD_GRANT) {
11708
11994
  this.workspaceRoot = workspaceRoot;
11709
11995
  this.spawnTerminalImpl = spawnTerminalImpl;
11996
+ this.grant = grant;
11710
11997
  }
11711
11998
  async handle(method, params) {
11999
+ if (method === "fs/write_text_file" && !this.grant.writeTextFile || method.startsWith("terminal/") && !this.grant.terminal) {
12000
+ throw new ClientMethodRefusedError(method);
12001
+ }
11712
12002
  switch (method) {
11713
12003
  case "fs/read_text_file":
11714
12004
  return this.readTextFile(assertReadRequest(params));
@@ -11782,10 +12072,10 @@ class AcpClientMethods {
11782
12072
  const terminalId = randomBytes(16).toString("hex");
11783
12073
  const child = this.spawnTerminalImpl(request.command, request.args ?? [], {
11784
12074
  cwd,
11785
- env: {
12075
+ env: withoutBridgeControlEnvironment({
11786
12076
  ...process.env,
11787
12077
  ...Object.fromEntries((request.env ?? []).map((entry) => [entry.name, entry.value]))
11788
- }
12078
+ })
11789
12079
  });
11790
12080
  let resolveExit;
11791
12081
  const exited = new Promise((resolve) => {
@@ -11853,6 +12143,12 @@ class AcpClientMethods {
11853
12143
 
11854
12144
  class UnsupportedClientMethodError extends Error {
11855
12145
  }
12146
+
12147
+ class ClientMethodRefusedError extends Error {
12148
+ constructor(method) {
12149
+ super(`ACP ${method} is refused by this session's execution policy`);
12150
+ }
12151
+ }
11856
12152
  async function secureExistingFile(requestedPath, workspaceRoot) {
11857
12153
  const path = await securePath(requestedPath, workspaceRoot, false);
11858
12154
  const stats = await lstat(path);
@@ -12061,178 +12357,6 @@ function isString(value) {
12061
12357
  return typeof value === "string" && value.length > 0 && Buffer.byteLength(value) <= 16 * 1024;
12062
12358
  }
12063
12359
 
12064
- // ../../bridges/acp-bridge/src/acp-provider-config.ts
12065
- import { mkdtempSync } from "node:fs";
12066
- import { tmpdir } from "node:os";
12067
- import path from "node:path";
12068
- var GROK_PROVIDER = {
12069
- id: "grok",
12070
- name: "Grok",
12071
- executable: "grok",
12072
- argv: ["--always-approve", "agent", "{{model}}", "{{effort}}", "stdio"],
12073
- env: {},
12074
- requiresAuthenticate: true,
12075
- authMethodEnv: "GROK_AUTH_METHOD_ID",
12076
- modeMap: {
12077
- agent: "build",
12078
- code: "build",
12079
- build: "build",
12080
- agentic: "build",
12081
- plan: "plan",
12082
- architect: "plan",
12083
- ask: "plan"
12084
- },
12085
- extensionPrefixes: ["x.ai/", "_x.ai/"],
12086
- acknowledgedExtensionMethods: [],
12087
- modelUpdateMethods: ["x.ai/models/update", "_x.ai/models/update"],
12088
- sessionUpdateMethods: ["x.ai/session/update", "_x.ai/session/update"]
12089
- };
12090
- var UNDECLARED_PROMPT_CAPABILITIES = {};
12091
- function undeclaredPromptCapabilities(providerId) {
12092
- return Object.hasOwn(UNDECLARED_PROMPT_CAPABILITIES, providerId) ? UNDECLARED_PROMPT_CAPABILITIES[providerId] : {};
12093
- }
12094
- var SESSION_FORK_METHODS = {
12095
- grok: { fork: "_x.ai/session/fork", promptPoints: "_x.ai/rewind/points" }
12096
- };
12097
- function sessionForkMethods(providerId) {
12098
- return Object.hasOwn(SESSION_FORK_METHODS, providerId) ? SESSION_FORK_METHODS[providerId] : undefined;
12099
- }
12100
- function loadAcpProviderConfig(environment = process.env) {
12101
- const serialized = environment.ACP_PROVIDER_CONFIG?.trim();
12102
- if (serialized)
12103
- return parseProviderConfig(serialized);
12104
- const id = environment.ACP_PROVIDER?.trim();
12105
- if (id && id !== "grok") {
12106
- throw new Error("ACP_PROVIDER_CONFIG is required for ACP providers other than grok (ACP_PROVIDER=grok is built in)");
12107
- }
12108
- return {
12109
- ...GROK_PROVIDER,
12110
- executable: environment.ACP_AGENT_PATH?.trim() || GROK_PROVIDER.executable
12111
- };
12112
- }
12113
- var NETWORK_DENIED_ARGUMENTS = {
12114
- grok: {
12115
- leading: ["--disable-web-search"],
12116
- subcommand: "agent",
12117
- afterSubcommand: ["--no-leader"]
12118
- }
12119
- };
12120
- var PROJECT_TRUST = {
12121
- grok: {
12122
- env: { GROK_FOLDER_TRUST: "0" },
12123
- subcommand: "agent",
12124
- afterSubcommand: ["--no-leader"]
12125
- }
12126
- };
12127
- var SESSION_RULES_META_FIELD = {
12128
- grok: "rules"
12129
- };
12130
- function sessionInstructionsMeta(config, instructions) {
12131
- if (!instructions || !Object.hasOwn(SESSION_RULES_META_FIELD, config.id))
12132
- return {};
12133
- return { _meta: { [SESSION_RULES_META_FIELD[config.id]]: instructions } };
12134
- }
12135
- var POLICY_ENV = {
12136
- grok: { GROK_WORKTREE_INHERITS_MAIN_APPROVALS: "false" }
12137
- };
12138
- function projectTrust(config, trustProject) {
12139
- return trustProject && Object.hasOwn(PROJECT_TRUST, config.id) ? PROJECT_TRUST[config.id] : undefined;
12140
- }
12141
- var withheldGhConfigDir;
12142
- function emptyGhConfigDir() {
12143
- withheldGhConfigDir ??= mkdtempSync(path.join(tmpdir(), "orkestrator-gh-withheld-"));
12144
- return withheldGhConfigDir;
12145
- }
12146
- function providerEnv(config, options, base = process.env) {
12147
- const env = {
12148
- ...base,
12149
- ...config.env,
12150
- ...Object.hasOwn(POLICY_ENV, config.id) ? POLICY_ENV[config.id] : {},
12151
- ...projectTrust(config, options.trustProject)?.env
12152
- };
12153
- return options.withholdGitHub ? withheldGitHubCredentialEnvironment(env, options.withholdGitHub) : env;
12154
- }
12155
- function providerArgv(config, options) {
12156
- if (options.readOnlyProfilePath && !config.argv.includes("agent")) {
12157
- throw new Error("Grok read-only profile requires a local agent launcher");
12158
- }
12159
- const network = options.denyNetwork && Object.hasOwn(NETWORK_DENIED_ARGUMENTS, config.id) ? NETWORK_DENIED_ARGUMENTS[config.id] : undefined;
12160
- const trust = projectTrust(config, options.trustProject);
12161
- const argv = config.argv.flatMap((argument) => {
12162
- if (argument === "--always-approve" && options.approvals && options.approvals !== "auto-approve") {
12163
- return [];
12164
- }
12165
- if (argument === "{{model}}")
12166
- return options.model ? ["--model", options.model] : [];
12167
- if (argument === "{{effort}}") {
12168
- return options.effort ? ["--reasoning-effort", options.effort] : [];
12169
- }
12170
- const after = [
12171
- ...network && argument === network.subcommand ? network.afterSubcommand : [],
12172
- ...trust && argument === trust.subcommand ? trust.afterSubcommand : [],
12173
- ...argument === "agent" && options.readOnlyProfilePath ? ["--no-leader"] : []
12174
- ];
12175
- return [
12176
- argument,
12177
- ...new Set(after),
12178
- ...argument === "agent" && options.readOnlyProfilePath ? ["--agent-profile", options.readOnlyProfilePath] : []
12179
- ];
12180
- });
12181
- return network ? [...network.leading, ...argv] : argv;
12182
- }
12183
- function parseProviderConfig(serialized) {
12184
- let value;
12185
- try {
12186
- value = JSON.parse(serialized);
12187
- } catch {
12188
- throw new Error("ACP_PROVIDER_CONFIG must be valid JSON");
12189
- }
12190
- if (!isRecord2(value))
12191
- throw new Error("ACP_PROVIDER_CONFIG must be a JSON object");
12192
- const id = requiredString(value.id, "id");
12193
- const executable = requiredString(value.executable, "executable");
12194
- const argv = stringArray(value.argv, "argv", 128);
12195
- const modeMap = isRecord2(value.modeMap) ? Object.fromEntries(Object.entries(value.modeMap).flatMap(([agentMode, normalized]) => normalized === "build" || normalized === "plan" ? [[agentMode, normalized]] : [])) : {};
12196
- const env = isRecord2(value.env) ? Object.fromEntries(Object.entries(value.env).flatMap(([key, entry]) => typeof entry === "string" ? [[key, entry]] : [])) : {};
12197
- return {
12198
- id,
12199
- name: optionalString(value.name) ?? id,
12200
- executable,
12201
- argv,
12202
- env,
12203
- requiresAuthenticate: value.requiresAuthenticate === true,
12204
- ...optionalString(value.authMethodEnv) ? { authMethodEnv: optionalString(value.authMethodEnv) } : {},
12205
- modeMap,
12206
- extensionPrefixes: stringArray(value.extensionPrefixes, "extensionPrefixes", 64, true),
12207
- acknowledgedExtensionMethods: stringArray(value.acknowledgedExtensionMethods, "acknowledgedExtensionMethods", 64, true),
12208
- modelUpdateMethods: stringArray(value.modelUpdateMethods, "modelUpdateMethods", 64, true),
12209
- sessionUpdateMethods: stringArray(value.sessionUpdateMethods, "sessionUpdateMethods", 64, true)
12210
- };
12211
- }
12212
- function stringArray(value, field, maximum, optional = false) {
12213
- if (value === undefined && optional)
12214
- return [];
12215
- if (!Array.isArray(value) || value.length > maximum || value.some((entry) => !optionalString(entry))) {
12216
- throw new Error(`ACP_PROVIDER_CONFIG.${field} must be an array of non-empty strings`);
12217
- }
12218
- return value;
12219
- }
12220
- function requiredString(value, field) {
12221
- const parsed = optionalString(value);
12222
- if (!parsed)
12223
- throw new Error(`ACP_PROVIDER_CONFIG.${field} must be a non-empty string`);
12224
- return parsed;
12225
- }
12226
- function optionalString(value) {
12227
- if (typeof value !== "string")
12228
- return;
12229
- const trimmed = value.trim();
12230
- return trimmed && Buffer.byteLength(trimmed) <= 4096 ? trimmed : undefined;
12231
- }
12232
- function isRecord2(value) {
12233
- return value !== null && typeof value === "object" && !Array.isArray(value);
12234
- }
12235
-
12236
12360
  // ../../bridges/acp-bridge/src/acp-readonly-profile.ts
12237
12361
  import { mkdtempSync as mkdtempSync2, writeFileSync, rmSync } from "node:fs";
12238
12362
  import { tmpdir as tmpdir2 } from "node:os";
@@ -12342,58 +12466,6 @@ function grokQuestionTimeoutFromEnv(env) {
12342
12466
  return layer.secs !== undefined ? layer.secs * 1000 : GROK_QUESTION_DEFAULT_TIMEOUT_MS;
12343
12467
  }
12344
12468
 
12345
- // ../protocol/src/coordinator-web-research.ts
12346
- var DEFAULT_COORDINATOR_RESEARCH_MCP_SERVERS = Object.freeze([{ name: "context7", url: "https://mcp.context7.com/mcp" }]);
12347
- var COORDINATOR_DENIED = Object.freeze([
12348
- "file.write",
12349
- "file.patch",
12350
- "shell.mutate",
12351
- "network"
12352
- ]);
12353
- function coordinatorCapabilityPolicy(mode) {
12354
- return {
12355
- deny: [...COORDINATOR_DENIED],
12356
- ...mode === "off" ? {} : { allow: ["web.search"] }
12357
- };
12358
- }
12359
-
12360
- // ../../bridges/acp-bridge/src/acp-policy.ts
12361
- var BRIDGE_EXECUTION_POLICY_ENV = "ORKESTRATOR_BRIDGE_EXECUTION_POLICY";
12362
- function processExecutionPolicyIsCoordinator(env = process.env) {
12363
- return env[BRIDGE_EXECUTION_POLICY_ENV] === "coordinator-read-only";
12364
- }
12365
- function coordinatorProcessPolicy() {
12366
- return {
12367
- id: "coordinator-read-only",
12368
- sandbox: "provider",
12369
- approvals: "deny",
12370
- projectResources: false,
12371
- capabilityPolicy: coordinatorCapabilityPolicy("off"),
12372
- networkAccess: "restricted",
12373
- note: "Grok's write, search_replace, shell, subagent, web search and web fetch tools are removed. Remaining permission requests are denied; other tools that do not ask, including xAI's hosted X search tools, remain advisory."
12374
- };
12375
- }
12376
- function effectiveExecutionPolicy(requested, env = process.env) {
12377
- if (!processExecutionPolicyIsCoordinator(env))
12378
- return requested;
12379
- return coordinatorProcessPolicy();
12380
- }
12381
- function effectiveTurnExecutionPolicy(input) {
12382
- return input.readOnly ? coordinatorProcessPolicy() : effectiveExecutionPolicy(input.policy);
12383
- }
12384
- function acpReportedPolicy(policy, agent) {
12385
- const applied = withoutProviderSandbox(policy, { agent, toolsetBlocksNetwork: false });
12386
- if (applied.projectResources)
12387
- return applied;
12388
- return appendNativeAgentPolicyNote({ ...applied, projectResources: true }, `${agent} loads a project's own configuration by its own folder trust, whatever this session's policy says.`);
12389
- }
12390
- function acpSessionReportedPolicy(state, agent) {
12391
- if (state.readOnly) {
12392
- return readOnlyTurnReportedPolicy(acpReportedPolicy(coordinatorProcessPolicy(), agent));
12393
- }
12394
- return state.policy ? acpReportedPolicy(state.policy, agent) : undefined;
12395
- }
12396
-
12397
12469
  // ../../bridges/acp-bridge/src/acp-mcp-inventory.ts
12398
12470
  import { createHash as createHash2 } from "node:crypto";
12399
12471
  import { readFile, stat } from "node:fs/promises";
@@ -12560,6 +12632,7 @@ var port = parsePort(process.env.PORT);
12560
12632
  var hostname = process.env.HOSTNAME?.trim() || "127.0.0.1";
12561
12633
  var workingDirectory = resolve3(process.env.CWD?.trim() || process.cwd());
12562
12634
  var authToken = process.env.ACP_BRIDGE_TOKEN?.trim() || randomBytes2(32).toString("base64url");
12635
+ delete process.env.ACP_BRIDGE_TOKEN;
12563
12636
  var executable = providerConfig.executable;
12564
12637
  var stateDirectory = process.env.ACP_STATE_DIR?.trim();
12565
12638
  var stateFile = stateDirectory ? resolve3(stateDirectory, "state.json") : null;
@@ -12718,7 +12791,8 @@ class AcpProcess {
12718
12791
  child;
12719
12792
  mcpConfigAtSpawn;
12720
12793
  questionTimeout;
12721
- clientMethods = new AcpClientMethods(workingDirectory);
12794
+ clientMethods;
12795
+ clientMethodGrant;
12722
12796
  #diagnostics;
12723
12797
  #nextId = 1;
12724
12798
  #pending = new Map;
@@ -12744,6 +12818,8 @@ class AcpProcess {
12744
12818
  throw new Error(`${provider} ACP provider config has no executable`);
12745
12819
  }
12746
12820
  const policy = spawnOptions.policy ?? effectiveExecutionPolicy(undefined);
12821
+ this.clientMethodGrant = acpClientMethodGrant(policy);
12822
+ this.clientMethods = new AcpClientMethods(workingDirectory, undefined, this.clientMethodGrant);
12747
12823
  const trustProject = policy?.projectResources === true;
12748
12824
  if (providerConfig.id === "grok" && policy?.approvals === "deny") {
12749
12825
  this.#readOnlyProfile = createReadOnlyProfile();
@@ -12800,8 +12876,8 @@ class AcpProcess {
12800
12876
  const initializeRequest = {
12801
12877
  protocolVersion: PROTOCOL_VERSION,
12802
12878
  clientCapabilities: {
12803
- fs: { readTextFile: true, writeTextFile: true },
12804
- terminal: true,
12879
+ fs: { readTextFile: true, writeTextFile: this.clientMethodGrant.writeTextFile },
12880
+ terminal: this.clientMethodGrant.terminal,
12805
12881
  session: { configOptions: { boolean: {} }, notices: {} },
12806
12882
  _meta: { parameterizedModelPicker: true }
12807
12883
  },
@@ -12986,7 +13062,7 @@ class AcpProcess {
12986
13062
  jsonrpc: "2.0",
12987
13063
  id: message.id,
12988
13064
  error: {
12989
- code: error instanceof UnsupportedClientMethodError ? -32601 : -32602,
13065
+ code: error instanceof UnsupportedClientMethodError || error instanceof ClientMethodRefusedError ? -32601 : -32602,
12990
13066
  message: error instanceof Error ? error.message : "ACP client request failed"
12991
13067
  }
12992
13068
  }));
@@ -21495,15 +21571,14 @@ function permissionToolNames(params, recorded) {
21495
21571
  function explicitlyDeniedPermissionTool(params, policy, recorded) {
21496
21572
  return permissionToolNames(params, recorded).some((name) => policy?.toolPolicy?.deny?.includes(name));
21497
21573
  }
21498
- var FILE_MUTATION_DENIALS = ["file.write", "file.patch", "write", "edit", "apply_patch"];
21499
21574
  var AUTO_APPROVE_DENIALS_BY_KIND = {
21500
21575
  read: [],
21501
21576
  search: [],
21502
21577
  think: [],
21503
- edit: FILE_MUTATION_DENIALS,
21504
- delete: FILE_MUTATION_DENIALS,
21505
- move: FILE_MUTATION_DENIALS,
21506
- execute: ["shell", "shell.mutate"],
21578
+ edit: ACP_FILE_MUTATION_DENIALS,
21579
+ delete: ACP_FILE_MUTATION_DENIALS,
21580
+ move: ACP_FILE_MUTATION_DENIALS,
21581
+ execute: ACP_SHELL_DENIALS,
21507
21582
  fetch: ["network"]
21508
21583
  };
21509
21584
  var PERMISSION_KIND_BY_TOOL = {