orkestrator 2.35.5-beta → 2.36.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.
- package/dist/client.js +964 -486
- package/dist/main.js +50800 -44088
- package/package.json +3 -3
- package/resources/acp-bridge/dist/index.js +325 -242
- package/resources/claude-bridge/dist/index.js +187 -22
- package/resources/codex-bridge/dist/index.js +537 -113
- package/resources/cursor-bridge/dist/index.js +34 -6
- package/resources/cursor-bridge/runtime/install.json +1 -1
- package/resources/pi-bridge/dist/index.js +69 -12
- package/resources/pi-bridge/runtime/install.json +1 -1
|
@@ -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:
|
|
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.",
|
|
@@ -1108,6 +1114,7 @@ var BUILD_PIPELINE_LOG_AREAS = defineLogAreas({
|
|
|
1108
1114
|
"usage.read-failed": "Reading a stage session's token usage failed.",
|
|
1109
1115
|
"checkpoint.deferred": "A stage transcript checkpoint could not be written yet; the provider's history stands.",
|
|
1110
1116
|
"checkpoint.not-committed": "A stage transcript checkpoint was reverted in the commit that should have kept it.",
|
|
1117
|
+
"worker-mail.claim-failed": "Mail queued for a worker could not be claimed at its turn end; it stays queued.",
|
|
1111
1118
|
"legacy-transcript.deferred": "Moving a legacy inline transcript failed; the inline body stays readable."
|
|
1112
1119
|
}
|
|
1113
1120
|
}
|
|
@@ -1170,18 +1177,27 @@ var COORDINATOR_LOG_AREAS = defineLogAreas({
|
|
|
1170
1177
|
"work.move-failed": "Work could not move to the main coordinator.",
|
|
1171
1178
|
"wake.observe-remote-workflow-failed": "A remote workflow could not be observed for status wakes.",
|
|
1172
1179
|
"wake.observe-pull-request-failed": "A pull request could not be observed for status wakes.",
|
|
1180
|
+
"wake.observe-feature-plan-failed": "A feature plan could not be observed for status wakes.",
|
|
1173
1181
|
"wake.observe-workflow-failed": "A workflow could not be observed for status wakes.",
|
|
1174
1182
|
"wake.deliver-failed": "A workflow status wake could not be delivered; the next pass retries.",
|
|
1175
1183
|
"wake.waiting-check-failed": "A waiting worker could not be checked; the next pass retries.",
|
|
1176
1184
|
"wake.resolve-report-failed": "A finished Resolve tab could not be reported.",
|
|
1177
1185
|
"wake.waiting-report-failed": "A waiting worker could not be reported.",
|
|
1178
1186
|
"wake.worker-outcomes-failed": "Coordinator-owned workers' merges and deletions could not be checked; the next sweep retries.",
|
|
1187
|
+
"pr-watch.added": "A pull request a coordinator conversation showed joined the project's watch; `source` says how.",
|
|
1188
|
+
"pr-watch.observe-failed": "A watched pull request could not be observed; the next sweep retries.",
|
|
1189
|
+
"pr-watch.read-failed": "GitHub could not be read for a watched pull request; `code` is the error category.",
|
|
1190
|
+
"pr-watch.removed": "A watched pull request stopped being watched without a reading; `reason` is `deleted` (GitHub confirmed it is gone) or `unreadable` (not found for the give-up period).",
|
|
1179
1191
|
"store.malformed": "The coordinator store was malformed and is treated as empty.",
|
|
1180
1192
|
"store.unsupported-version": "The coordinator store has an unsupported version and is treated as empty.",
|
|
1181
1193
|
"store.invalid-workspace": "An invalid coordinator workspace record was ignored.",
|
|
1182
1194
|
"store.workflows-cleared": "The workflow store was full, so a batch of its oldest finished records was removed.",
|
|
1183
1195
|
"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."
|
|
1196
|
+
"remote-worker.settle-failed": "A remote worker could not be settled.",
|
|
1197
|
+
"checkout.merge-followed": "After an environment's PR merged, the project checkout was fast-forwarded, or `outcome` says why not.",
|
|
1198
|
+
"checkout.merge-follow-failed": "Fast-forwarding the project checkout failed, after an environment's PR merged or before mail woke the main coordinator.",
|
|
1199
|
+
"checkout.mail-follow": "Before mail woke the main coordinator, the project checkout was fast-forwarded, or `outcome` says why not (`timed-out`, `failed`).",
|
|
1200
|
+
"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
1201
|
}
|
|
1186
1202
|
}
|
|
1187
1203
|
});
|
|
@@ -1213,6 +1229,7 @@ var REVIEW_LOG_AREAS = defineLogAreas({
|
|
|
1213
1229
|
"gh.pr-list-unparseable": "`gh pr list` returned nothing that parses. Sizes only, never the output.",
|
|
1214
1230
|
"monitor.start-failed": "Monitoring could not start for a newly opened pull request.",
|
|
1215
1231
|
"cleanup-scheduler.missing": "A merged pull request was seen, but this runtime has no merge cleanup scheduler.",
|
|
1232
|
+
"checkout.follow-merge-lookup-failed": "A merged pull request's project could not be read, so its checkout was not fast-forwarded.",
|
|
1216
1233
|
"auto-merge.evaluation-failed": "Evaluating an environment for auto-merge failed.",
|
|
1217
1234
|
"auto-merge.merge-failed": "Auto-merge could not merge a pull request; the attempt is held and retried.",
|
|
1218
1235
|
"auto-merge.resolve-failed": "Auto-merge could not launch Resolve for a pull request; the attempt is held and retried.",
|
|
@@ -1256,6 +1273,8 @@ var AGENT_ACCOUNTS_LOG_AREAS = defineLogAreas({
|
|
|
1256
1273
|
"container-sync.failed": "Handing a login or account to a container failed; `step` says which part.",
|
|
1257
1274
|
"last-usage.save-failed": "The last plan usage reading could not be saved; the next save retries.",
|
|
1258
1275
|
"login-cleanup.failed": "A temporary login could not be cleaned up.",
|
|
1276
|
+
"login-renewal.failed": "Renewing an idle account's sign-in to read its usage failed; it is retried after a backoff.",
|
|
1277
|
+
"login-renewal.not-extended": "Claude Code ran to renew an idle account's sign-in, but its token is still lapsed.",
|
|
1259
1278
|
"login-refresh.deferred": "Containers were not told to refresh their login now; they reconcile from its durable generation."
|
|
1260
1279
|
}
|
|
1261
1280
|
}
|
|
@@ -1269,6 +1288,7 @@ var DOCKER_LOG_AREAS = defineLogAreas({
|
|
|
1269
1288
|
"portable-inputs.relay-missing": "Docker is rootless and the image predates the staged-input relay, so the container cannot read them until rebuilt.",
|
|
1270
1289
|
"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
1290
|
"opencode.warm-incomplete": "OpenCode did not finish loading /workspace in a container.",
|
|
1291
|
+
"lifecycle-event.reconcile-failed": "Reconciling an environment after a container start or stop event failed; the next status read retries.",
|
|
1272
1292
|
"login-keeper.pass-failed": "A Claude login keeper pass failed; the next interval retries.",
|
|
1273
1293
|
"login-keeper.refresh-failed": "Refreshing the host Claude login failed. Fixed text: CLI output can hold credentials.",
|
|
1274
1294
|
"login-keeper.refresh-not-extended": "Refreshing the host Claude login did not extend its expiry.",
|
|
@@ -1392,7 +1412,7 @@ var GRAPH_LOG_AREAS = defineLogAreas({
|
|
|
1392
1412
|
// ../protocol/src/log-vocabulary/nodes.ts
|
|
1393
1413
|
var NODES_LOG_AREAS = defineLogAreas({
|
|
1394
1414
|
nodes: {
|
|
1395
|
-
description: "Command nodes: links, handovers, leaf mail and project copies.",
|
|
1415
|
+
description: "Command nodes: links, handovers, leaf mail, ticket sync and project copies.",
|
|
1396
1416
|
events: {
|
|
1397
1417
|
"actions.resume-failed": "Approved actions could not be resumed; a later pass retries.",
|
|
1398
1418
|
"project-copy.notify-failed": "The coordinator could not be told a project copy finished.",
|
|
@@ -1404,7 +1424,11 @@ var NODES_LOG_AREAS = defineLogAreas({
|
|
|
1404
1424
|
"verification.record-failed": "A node verification could not be recorded.",
|
|
1405
1425
|
"profile.record-failed": "A node profile could not be recorded.",
|
|
1406
1426
|
"detach.unconfirmed": "A forgotten node has not confirmed the detach yet.",
|
|
1407
|
-
"handover.recovery-pending": "Command handover recovery is still pending."
|
|
1427
|
+
"handover.recovery-pending": "Command handover recovery is still pending.",
|
|
1428
|
+
"ticket-sync.work-record-failed": "A remote build started but its ticket work location could not be saved.",
|
|
1429
|
+
"ticket-sync.failed": "A Kanban sync with a node failed; it is retried.",
|
|
1430
|
+
"ticket-sync.unknown-project": "A node sent ticket changes for a project that no longer exists here.",
|
|
1431
|
+
"ticket-sync.forget-failed": "A detached command node's ticket copies could not be released."
|
|
1408
1432
|
}
|
|
1409
1433
|
}
|
|
1410
1434
|
});
|
|
@@ -11401,6 +11425,9 @@ function agentMailCapabilities(tabType, agent, locked = true) {
|
|
|
11401
11425
|
}
|
|
11402
11426
|
if (tabType === "claude-tmux")
|
|
11403
11427
|
return { canPull: true, canSend: true, canInject: true };
|
|
11428
|
+
if (tabType === "pipeline-worker") {
|
|
11429
|
+
return agent ? { canPull: true, canSend: true, canInject: true } : { canPull: false, canSend: false, canInject: false };
|
|
11430
|
+
}
|
|
11404
11431
|
if (["claude", "codex", "opencode"].includes(tabType)) {
|
|
11405
11432
|
return { canPull: true, canSend: true, canInject: false };
|
|
11406
11433
|
}
|
|
@@ -11638,6 +11665,272 @@ import { constants } from "node:fs";
|
|
|
11638
11665
|
import { lstat, open as open2, realpath } from "node:fs/promises";
|
|
11639
11666
|
import { dirname, isAbsolute, join as join2, relative, resolve, sep } from "node:path";
|
|
11640
11667
|
import { randomBytes } from "node:crypto";
|
|
11668
|
+
|
|
11669
|
+
// ../protocol/src/coordinator-web-research.ts
|
|
11670
|
+
var DEFAULT_COORDINATOR_RESEARCH_MCP_SERVERS = Object.freeze([{ name: "context7", url: "https://mcp.context7.com/mcp" }]);
|
|
11671
|
+
var COORDINATOR_DENIED = Object.freeze([
|
|
11672
|
+
"file.write",
|
|
11673
|
+
"file.patch",
|
|
11674
|
+
"shell.mutate",
|
|
11675
|
+
"network"
|
|
11676
|
+
]);
|
|
11677
|
+
function coordinatorCapabilityPolicy(mode) {
|
|
11678
|
+
return {
|
|
11679
|
+
deny: [...COORDINATOR_DENIED],
|
|
11680
|
+
...mode === "off" ? {} : { allow: ["web.search"] }
|
|
11681
|
+
};
|
|
11682
|
+
}
|
|
11683
|
+
|
|
11684
|
+
// ../../bridges/acp-bridge/src/acp-policy.ts
|
|
11685
|
+
var BRIDGE_EXECUTION_POLICY_ENV = "ORKESTRATOR_BRIDGE_EXECUTION_POLICY";
|
|
11686
|
+
function processExecutionPolicyIsCoordinator(env = process.env) {
|
|
11687
|
+
return env[BRIDGE_EXECUTION_POLICY_ENV] === "coordinator-read-only";
|
|
11688
|
+
}
|
|
11689
|
+
function coordinatorProcessPolicy() {
|
|
11690
|
+
return {
|
|
11691
|
+
id: "coordinator-read-only",
|
|
11692
|
+
sandbox: "provider",
|
|
11693
|
+
approvals: "deny",
|
|
11694
|
+
projectResources: false,
|
|
11695
|
+
capabilityPolicy: coordinatorCapabilityPolicy("off"),
|
|
11696
|
+
networkAccess: "restricted",
|
|
11697
|
+
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."
|
|
11698
|
+
};
|
|
11699
|
+
}
|
|
11700
|
+
function effectiveExecutionPolicy(requested, env = process.env) {
|
|
11701
|
+
if (!processExecutionPolicyIsCoordinator(env))
|
|
11702
|
+
return requested;
|
|
11703
|
+
return coordinatorProcessPolicy();
|
|
11704
|
+
}
|
|
11705
|
+
function effectiveTurnExecutionPolicy(input) {
|
|
11706
|
+
return input.readOnly ? coordinatorProcessPolicy() : effectiveExecutionPolicy(input.policy);
|
|
11707
|
+
}
|
|
11708
|
+
function acpReportedPolicy(policy, agent) {
|
|
11709
|
+
const applied = withoutProviderSandbox(policy, { agent, toolsetBlocksNetwork: false });
|
|
11710
|
+
if (applied.projectResources)
|
|
11711
|
+
return applied;
|
|
11712
|
+
return appendNativeAgentPolicyNote({ ...applied, projectResources: true }, `${agent} loads a project's own configuration by its own folder trust, whatever this session's policy says.`);
|
|
11713
|
+
}
|
|
11714
|
+
function acpSessionReportedPolicy(state, agent) {
|
|
11715
|
+
if (state.readOnly) {
|
|
11716
|
+
return readOnlyTurnReportedPolicy(acpReportedPolicy(coordinatorProcessPolicy(), agent));
|
|
11717
|
+
}
|
|
11718
|
+
return state.policy ? acpReportedPolicy(state.policy, agent) : undefined;
|
|
11719
|
+
}
|
|
11720
|
+
var ACP_FILE_MUTATION_DENIALS = Object.freeze([
|
|
11721
|
+
"file.write",
|
|
11722
|
+
"file.patch",
|
|
11723
|
+
"write",
|
|
11724
|
+
"edit",
|
|
11725
|
+
"apply_patch"
|
|
11726
|
+
]);
|
|
11727
|
+
var ACP_SHELL_DENIALS = Object.freeze(["shell", "shell.mutate"]);
|
|
11728
|
+
var FULL_ACP_CLIENT_METHOD_GRANT = Object.freeze({
|
|
11729
|
+
writeTextFile: true,
|
|
11730
|
+
terminal: true
|
|
11731
|
+
});
|
|
11732
|
+
function acpClientMethodGrant(policy) {
|
|
11733
|
+
if (!policy)
|
|
11734
|
+
return FULL_ACP_CLIENT_METHOD_GRANT;
|
|
11735
|
+
if (policy.approvals === "deny")
|
|
11736
|
+
return { writeTextFile: false, terminal: false };
|
|
11737
|
+
const denied = new Set([
|
|
11738
|
+
...nativeAgentDeniedCapabilities(policy),
|
|
11739
|
+
...policy.toolPolicy?.deny ?? []
|
|
11740
|
+
]);
|
|
11741
|
+
return {
|
|
11742
|
+
writeTextFile: !ACP_FILE_MUTATION_DENIALS.some((name) => denied.has(name)),
|
|
11743
|
+
terminal: !ACP_SHELL_DENIALS.some((name) => denied.has(name))
|
|
11744
|
+
};
|
|
11745
|
+
}
|
|
11746
|
+
|
|
11747
|
+
// ../../bridges/acp-bridge/src/acp-provider-config.ts
|
|
11748
|
+
import { mkdtempSync } from "node:fs";
|
|
11749
|
+
import { tmpdir } from "node:os";
|
|
11750
|
+
import path from "node:path";
|
|
11751
|
+
var GROK_PROVIDER = {
|
|
11752
|
+
id: "grok",
|
|
11753
|
+
name: "Grok",
|
|
11754
|
+
executable: "grok",
|
|
11755
|
+
argv: ["--always-approve", "agent", "{{model}}", "{{effort}}", "stdio"],
|
|
11756
|
+
env: {},
|
|
11757
|
+
requiresAuthenticate: true,
|
|
11758
|
+
authMethodEnv: "GROK_AUTH_METHOD_ID",
|
|
11759
|
+
modeMap: {
|
|
11760
|
+
agent: "build",
|
|
11761
|
+
code: "build",
|
|
11762
|
+
build: "build",
|
|
11763
|
+
agentic: "build",
|
|
11764
|
+
plan: "plan",
|
|
11765
|
+
architect: "plan",
|
|
11766
|
+
ask: "plan"
|
|
11767
|
+
},
|
|
11768
|
+
extensionPrefixes: ["x.ai/", "_x.ai/"],
|
|
11769
|
+
acknowledgedExtensionMethods: [],
|
|
11770
|
+
modelUpdateMethods: ["x.ai/models/update", "_x.ai/models/update"],
|
|
11771
|
+
sessionUpdateMethods: ["x.ai/session/update", "_x.ai/session/update"]
|
|
11772
|
+
};
|
|
11773
|
+
var UNDECLARED_PROMPT_CAPABILITIES = {};
|
|
11774
|
+
function undeclaredPromptCapabilities(providerId) {
|
|
11775
|
+
return Object.hasOwn(UNDECLARED_PROMPT_CAPABILITIES, providerId) ? UNDECLARED_PROMPT_CAPABILITIES[providerId] : {};
|
|
11776
|
+
}
|
|
11777
|
+
var SESSION_FORK_METHODS = {
|
|
11778
|
+
grok: { fork: "_x.ai/session/fork", promptPoints: "_x.ai/rewind/points" }
|
|
11779
|
+
};
|
|
11780
|
+
function sessionForkMethods(providerId) {
|
|
11781
|
+
return Object.hasOwn(SESSION_FORK_METHODS, providerId) ? SESSION_FORK_METHODS[providerId] : undefined;
|
|
11782
|
+
}
|
|
11783
|
+
function loadAcpProviderConfig(environment = process.env) {
|
|
11784
|
+
const serialized = environment.ACP_PROVIDER_CONFIG?.trim();
|
|
11785
|
+
if (serialized)
|
|
11786
|
+
return parseProviderConfig(serialized);
|
|
11787
|
+
const id = environment.ACP_PROVIDER?.trim();
|
|
11788
|
+
if (id && id !== "grok") {
|
|
11789
|
+
throw new Error("ACP_PROVIDER_CONFIG is required for ACP providers other than grok (ACP_PROVIDER=grok is built in)");
|
|
11790
|
+
}
|
|
11791
|
+
return {
|
|
11792
|
+
...GROK_PROVIDER,
|
|
11793
|
+
executable: environment.ACP_AGENT_PATH?.trim() || GROK_PROVIDER.executable
|
|
11794
|
+
};
|
|
11795
|
+
}
|
|
11796
|
+
var NETWORK_DENIED_ARGUMENTS = {
|
|
11797
|
+
grok: {
|
|
11798
|
+
leading: ["--disable-web-search"],
|
|
11799
|
+
subcommand: "agent",
|
|
11800
|
+
afterSubcommand: ["--no-leader"]
|
|
11801
|
+
}
|
|
11802
|
+
};
|
|
11803
|
+
var PROJECT_TRUST = {
|
|
11804
|
+
grok: {
|
|
11805
|
+
env: { GROK_FOLDER_TRUST: "0" },
|
|
11806
|
+
subcommand: "agent",
|
|
11807
|
+
afterSubcommand: ["--no-leader"]
|
|
11808
|
+
}
|
|
11809
|
+
};
|
|
11810
|
+
var SESSION_RULES_META_FIELD = {
|
|
11811
|
+
grok: "rules"
|
|
11812
|
+
};
|
|
11813
|
+
function sessionInstructionsMeta(config, instructions) {
|
|
11814
|
+
if (!instructions || !Object.hasOwn(SESSION_RULES_META_FIELD, config.id))
|
|
11815
|
+
return {};
|
|
11816
|
+
return { _meta: { [SESSION_RULES_META_FIELD[config.id]]: instructions } };
|
|
11817
|
+
}
|
|
11818
|
+
var POLICY_ENV = {
|
|
11819
|
+
grok: { GROK_WORKTREE_INHERITS_MAIN_APPROVALS: "false" }
|
|
11820
|
+
};
|
|
11821
|
+
function projectTrust(config, trustProject) {
|
|
11822
|
+
return trustProject && Object.hasOwn(PROJECT_TRUST, config.id) ? PROJECT_TRUST[config.id] : undefined;
|
|
11823
|
+
}
|
|
11824
|
+
var withheldGhConfigDir;
|
|
11825
|
+
function emptyGhConfigDir() {
|
|
11826
|
+
withheldGhConfigDir ??= mkdtempSync(path.join(tmpdir(), "orkestrator-gh-withheld-"));
|
|
11827
|
+
return withheldGhConfigDir;
|
|
11828
|
+
}
|
|
11829
|
+
var BRIDGE_CONTROL_ENV_VARS = Object.freeze([
|
|
11830
|
+
"ACP_BRIDGE_TOKEN",
|
|
11831
|
+
"ORKESTRATOR_AGENT_MCP_TOKEN",
|
|
11832
|
+
"ORKESTRATOR_AGENT_MCP_URL"
|
|
11833
|
+
]);
|
|
11834
|
+
function withoutBridgeControlEnvironment(env) {
|
|
11835
|
+
const scrubbed = { ...env };
|
|
11836
|
+
for (const name of Object.keys(scrubbed)) {
|
|
11837
|
+
if (BRIDGE_CONTROL_ENV_VARS.includes(name) || name.endsWith("_BRIDGE_TOKEN")) {
|
|
11838
|
+
delete scrubbed[name];
|
|
11839
|
+
}
|
|
11840
|
+
}
|
|
11841
|
+
return scrubbed;
|
|
11842
|
+
}
|
|
11843
|
+
function providerEnv(config, options, base = process.env) {
|
|
11844
|
+
const env = {
|
|
11845
|
+
...withoutBridgeControlEnvironment(base),
|
|
11846
|
+
...config.env,
|
|
11847
|
+
...Object.hasOwn(POLICY_ENV, config.id) ? POLICY_ENV[config.id] : {},
|
|
11848
|
+
...projectTrust(config, options.trustProject)?.env
|
|
11849
|
+
};
|
|
11850
|
+
return options.withholdGitHub ? withheldGitHubCredentialEnvironment(env, options.withholdGitHub) : env;
|
|
11851
|
+
}
|
|
11852
|
+
function providerArgv(config, options) {
|
|
11853
|
+
if (options.readOnlyProfilePath && !config.argv.includes("agent")) {
|
|
11854
|
+
throw new Error("Grok read-only profile requires a local agent launcher");
|
|
11855
|
+
}
|
|
11856
|
+
const network = options.denyNetwork && Object.hasOwn(NETWORK_DENIED_ARGUMENTS, config.id) ? NETWORK_DENIED_ARGUMENTS[config.id] : undefined;
|
|
11857
|
+
const trust = projectTrust(config, options.trustProject);
|
|
11858
|
+
const argv = config.argv.flatMap((argument) => {
|
|
11859
|
+
if (argument === "--always-approve" && options.approvals && options.approvals !== "auto-approve") {
|
|
11860
|
+
return [];
|
|
11861
|
+
}
|
|
11862
|
+
if (argument === "{{model}}")
|
|
11863
|
+
return options.model ? ["--model", options.model] : [];
|
|
11864
|
+
if (argument === "{{effort}}") {
|
|
11865
|
+
return options.effort ? ["--reasoning-effort", options.effort] : [];
|
|
11866
|
+
}
|
|
11867
|
+
const after = [
|
|
11868
|
+
...network && argument === network.subcommand ? network.afterSubcommand : [],
|
|
11869
|
+
...trust && argument === trust.subcommand ? trust.afterSubcommand : [],
|
|
11870
|
+
...argument === "agent" && options.readOnlyProfilePath ? ["--no-leader"] : []
|
|
11871
|
+
];
|
|
11872
|
+
return [
|
|
11873
|
+
argument,
|
|
11874
|
+
...new Set(after),
|
|
11875
|
+
...argument === "agent" && options.readOnlyProfilePath ? ["--agent-profile", options.readOnlyProfilePath] : []
|
|
11876
|
+
];
|
|
11877
|
+
});
|
|
11878
|
+
return network ? [...network.leading, ...argv] : argv;
|
|
11879
|
+
}
|
|
11880
|
+
function parseProviderConfig(serialized) {
|
|
11881
|
+
let value;
|
|
11882
|
+
try {
|
|
11883
|
+
value = JSON.parse(serialized);
|
|
11884
|
+
} catch {
|
|
11885
|
+
throw new Error("ACP_PROVIDER_CONFIG must be valid JSON");
|
|
11886
|
+
}
|
|
11887
|
+
if (!isRecord2(value))
|
|
11888
|
+
throw new Error("ACP_PROVIDER_CONFIG must be a JSON object");
|
|
11889
|
+
const id = requiredString(value.id, "id");
|
|
11890
|
+
const executable = requiredString(value.executable, "executable");
|
|
11891
|
+
const argv = stringArray(value.argv, "argv", 128);
|
|
11892
|
+
const modeMap = isRecord2(value.modeMap) ? Object.fromEntries(Object.entries(value.modeMap).flatMap(([agentMode, normalized]) => normalized === "build" || normalized === "plan" ? [[agentMode, normalized]] : [])) : {};
|
|
11893
|
+
const env = isRecord2(value.env) ? Object.fromEntries(Object.entries(value.env).flatMap(([key, entry]) => typeof entry === "string" ? [[key, entry]] : [])) : {};
|
|
11894
|
+
return {
|
|
11895
|
+
id,
|
|
11896
|
+
name: optionalString(value.name) ?? id,
|
|
11897
|
+
executable,
|
|
11898
|
+
argv,
|
|
11899
|
+
env,
|
|
11900
|
+
requiresAuthenticate: value.requiresAuthenticate === true,
|
|
11901
|
+
...optionalString(value.authMethodEnv) ? { authMethodEnv: optionalString(value.authMethodEnv) } : {},
|
|
11902
|
+
modeMap,
|
|
11903
|
+
extensionPrefixes: stringArray(value.extensionPrefixes, "extensionPrefixes", 64, true),
|
|
11904
|
+
acknowledgedExtensionMethods: stringArray(value.acknowledgedExtensionMethods, "acknowledgedExtensionMethods", 64, true),
|
|
11905
|
+
modelUpdateMethods: stringArray(value.modelUpdateMethods, "modelUpdateMethods", 64, true),
|
|
11906
|
+
sessionUpdateMethods: stringArray(value.sessionUpdateMethods, "sessionUpdateMethods", 64, true)
|
|
11907
|
+
};
|
|
11908
|
+
}
|
|
11909
|
+
function stringArray(value, field, maximum, optional = false) {
|
|
11910
|
+
if (value === undefined && optional)
|
|
11911
|
+
return [];
|
|
11912
|
+
if (!Array.isArray(value) || value.length > maximum || value.some((entry) => !optionalString(entry))) {
|
|
11913
|
+
throw new Error(`ACP_PROVIDER_CONFIG.${field} must be an array of non-empty strings`);
|
|
11914
|
+
}
|
|
11915
|
+
return value;
|
|
11916
|
+
}
|
|
11917
|
+
function requiredString(value, field) {
|
|
11918
|
+
const parsed = optionalString(value);
|
|
11919
|
+
if (!parsed)
|
|
11920
|
+
throw new Error(`ACP_PROVIDER_CONFIG.${field} must be a non-empty string`);
|
|
11921
|
+
return parsed;
|
|
11922
|
+
}
|
|
11923
|
+
function optionalString(value) {
|
|
11924
|
+
if (typeof value !== "string")
|
|
11925
|
+
return;
|
|
11926
|
+
const trimmed = value.trim();
|
|
11927
|
+
return trimmed && Buffer.byteLength(trimmed) <= 4096 ? trimmed : undefined;
|
|
11928
|
+
}
|
|
11929
|
+
function isRecord2(value) {
|
|
11930
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
11931
|
+
}
|
|
11932
|
+
|
|
11933
|
+
// ../../bridges/acp-bridge/src/acp-client-methods.ts
|
|
11641
11934
|
var MAX_FILE_BYTES = 2 * 1024 * 1024;
|
|
11642
11935
|
var MAX_READ_LINES = 1e5;
|
|
11643
11936
|
var DEFAULT_TERMINAL_OUTPUT_BYTES = 1024 * 1024;
|
|
@@ -11703,12 +11996,17 @@ class BoundedTerminalOutput {
|
|
|
11703
11996
|
class AcpClientMethods {
|
|
11704
11997
|
workspaceRoot;
|
|
11705
11998
|
spawnTerminalImpl;
|
|
11999
|
+
grant;
|
|
11706
12000
|
#terminals = new Map;
|
|
11707
|
-
constructor(workspaceRoot, spawnTerminalImpl = spawnTerminal) {
|
|
12001
|
+
constructor(workspaceRoot, spawnTerminalImpl = spawnTerminal, grant = FULL_ACP_CLIENT_METHOD_GRANT) {
|
|
11708
12002
|
this.workspaceRoot = workspaceRoot;
|
|
11709
12003
|
this.spawnTerminalImpl = spawnTerminalImpl;
|
|
12004
|
+
this.grant = grant;
|
|
11710
12005
|
}
|
|
11711
12006
|
async handle(method, params) {
|
|
12007
|
+
if (method === "fs/write_text_file" && !this.grant.writeTextFile || method.startsWith("terminal/") && !this.grant.terminal) {
|
|
12008
|
+
throw new ClientMethodRefusedError(method);
|
|
12009
|
+
}
|
|
11712
12010
|
switch (method) {
|
|
11713
12011
|
case "fs/read_text_file":
|
|
11714
12012
|
return this.readTextFile(assertReadRequest(params));
|
|
@@ -11782,10 +12080,10 @@ class AcpClientMethods {
|
|
|
11782
12080
|
const terminalId = randomBytes(16).toString("hex");
|
|
11783
12081
|
const child = this.spawnTerminalImpl(request.command, request.args ?? [], {
|
|
11784
12082
|
cwd,
|
|
11785
|
-
env: {
|
|
12083
|
+
env: withoutBridgeControlEnvironment({
|
|
11786
12084
|
...process.env,
|
|
11787
12085
|
...Object.fromEntries((request.env ?? []).map((entry) => [entry.name, entry.value]))
|
|
11788
|
-
}
|
|
12086
|
+
})
|
|
11789
12087
|
});
|
|
11790
12088
|
let resolveExit;
|
|
11791
12089
|
const exited = new Promise((resolve) => {
|
|
@@ -11853,6 +12151,12 @@ class AcpClientMethods {
|
|
|
11853
12151
|
|
|
11854
12152
|
class UnsupportedClientMethodError extends Error {
|
|
11855
12153
|
}
|
|
12154
|
+
|
|
12155
|
+
class ClientMethodRefusedError extends Error {
|
|
12156
|
+
constructor(method) {
|
|
12157
|
+
super(`ACP ${method} is refused by this session's execution policy`);
|
|
12158
|
+
}
|
|
12159
|
+
}
|
|
11856
12160
|
async function secureExistingFile(requestedPath, workspaceRoot) {
|
|
11857
12161
|
const path = await securePath(requestedPath, workspaceRoot, false);
|
|
11858
12162
|
const stats = await lstat(path);
|
|
@@ -12061,178 +12365,6 @@ function isString(value) {
|
|
|
12061
12365
|
return typeof value === "string" && value.length > 0 && Buffer.byteLength(value) <= 16 * 1024;
|
|
12062
12366
|
}
|
|
12063
12367
|
|
|
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
12368
|
// ../../bridges/acp-bridge/src/acp-readonly-profile.ts
|
|
12237
12369
|
import { mkdtempSync as mkdtempSync2, writeFileSync, rmSync } from "node:fs";
|
|
12238
12370
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
@@ -12342,58 +12474,6 @@ function grokQuestionTimeoutFromEnv(env) {
|
|
|
12342
12474
|
return layer.secs !== undefined ? layer.secs * 1000 : GROK_QUESTION_DEFAULT_TIMEOUT_MS;
|
|
12343
12475
|
}
|
|
12344
12476
|
|
|
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
12477
|
// ../../bridges/acp-bridge/src/acp-mcp-inventory.ts
|
|
12398
12478
|
import { createHash as createHash2 } from "node:crypto";
|
|
12399
12479
|
import { readFile, stat } from "node:fs/promises";
|
|
@@ -12560,6 +12640,7 @@ var port = parsePort(process.env.PORT);
|
|
|
12560
12640
|
var hostname = process.env.HOSTNAME?.trim() || "127.0.0.1";
|
|
12561
12641
|
var workingDirectory = resolve3(process.env.CWD?.trim() || process.cwd());
|
|
12562
12642
|
var authToken = process.env.ACP_BRIDGE_TOKEN?.trim() || randomBytes2(32).toString("base64url");
|
|
12643
|
+
delete process.env.ACP_BRIDGE_TOKEN;
|
|
12563
12644
|
var executable = providerConfig.executable;
|
|
12564
12645
|
var stateDirectory = process.env.ACP_STATE_DIR?.trim();
|
|
12565
12646
|
var stateFile = stateDirectory ? resolve3(stateDirectory, "state.json") : null;
|
|
@@ -12718,7 +12799,8 @@ class AcpProcess {
|
|
|
12718
12799
|
child;
|
|
12719
12800
|
mcpConfigAtSpawn;
|
|
12720
12801
|
questionTimeout;
|
|
12721
|
-
clientMethods
|
|
12802
|
+
clientMethods;
|
|
12803
|
+
clientMethodGrant;
|
|
12722
12804
|
#diagnostics;
|
|
12723
12805
|
#nextId = 1;
|
|
12724
12806
|
#pending = new Map;
|
|
@@ -12744,6 +12826,8 @@ class AcpProcess {
|
|
|
12744
12826
|
throw new Error(`${provider} ACP provider config has no executable`);
|
|
12745
12827
|
}
|
|
12746
12828
|
const policy = spawnOptions.policy ?? effectiveExecutionPolicy(undefined);
|
|
12829
|
+
this.clientMethodGrant = acpClientMethodGrant(policy);
|
|
12830
|
+
this.clientMethods = new AcpClientMethods(workingDirectory, undefined, this.clientMethodGrant);
|
|
12747
12831
|
const trustProject = policy?.projectResources === true;
|
|
12748
12832
|
if (providerConfig.id === "grok" && policy?.approvals === "deny") {
|
|
12749
12833
|
this.#readOnlyProfile = createReadOnlyProfile();
|
|
@@ -12800,8 +12884,8 @@ class AcpProcess {
|
|
|
12800
12884
|
const initializeRequest = {
|
|
12801
12885
|
protocolVersion: PROTOCOL_VERSION,
|
|
12802
12886
|
clientCapabilities: {
|
|
12803
|
-
fs: { readTextFile: true, writeTextFile:
|
|
12804
|
-
terminal:
|
|
12887
|
+
fs: { readTextFile: true, writeTextFile: this.clientMethodGrant.writeTextFile },
|
|
12888
|
+
terminal: this.clientMethodGrant.terminal,
|
|
12805
12889
|
session: { configOptions: { boolean: {} }, notices: {} },
|
|
12806
12890
|
_meta: { parameterizedModelPicker: true }
|
|
12807
12891
|
},
|
|
@@ -12986,7 +13070,7 @@ class AcpProcess {
|
|
|
12986
13070
|
jsonrpc: "2.0",
|
|
12987
13071
|
id: message.id,
|
|
12988
13072
|
error: {
|
|
12989
|
-
code: error instanceof UnsupportedClientMethodError ? -32601 : -32602,
|
|
13073
|
+
code: error instanceof UnsupportedClientMethodError || error instanceof ClientMethodRefusedError ? -32601 : -32602,
|
|
12990
13074
|
message: error instanceof Error ? error.message : "ACP client request failed"
|
|
12991
13075
|
}
|
|
12992
13076
|
}));
|
|
@@ -21495,15 +21579,14 @@ function permissionToolNames(params, recorded) {
|
|
|
21495
21579
|
function explicitlyDeniedPermissionTool(params, policy, recorded) {
|
|
21496
21580
|
return permissionToolNames(params, recorded).some((name) => policy?.toolPolicy?.deny?.includes(name));
|
|
21497
21581
|
}
|
|
21498
|
-
var FILE_MUTATION_DENIALS = ["file.write", "file.patch", "write", "edit", "apply_patch"];
|
|
21499
21582
|
var AUTO_APPROVE_DENIALS_BY_KIND = {
|
|
21500
21583
|
read: [],
|
|
21501
21584
|
search: [],
|
|
21502
21585
|
think: [],
|
|
21503
|
-
edit:
|
|
21504
|
-
delete:
|
|
21505
|
-
move:
|
|
21506
|
-
execute:
|
|
21586
|
+
edit: ACP_FILE_MUTATION_DENIALS,
|
|
21587
|
+
delete: ACP_FILE_MUTATION_DENIALS,
|
|
21588
|
+
move: ACP_FILE_MUTATION_DENIALS,
|
|
21589
|
+
execute: ACP_SHELL_DENIALS,
|
|
21507
21590
|
fetch: ["network"]
|
|
21508
21591
|
};
|
|
21509
21592
|
var PERMISSION_KIND_BY_TOOL = {
|