@mnaimfaizy/agent-kit 1.0.0-beta.14 → 1.0.0-beta.15
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/README.md +22 -4
- package/custom-harness.schema.json +243 -0
- package/harnesses.json +244 -6
- package/package.json +3 -2
- package/src/checks/ci-workflow.mjs +105 -0
- package/src/checks/claude-app.mjs +11 -2
- package/src/checks/custom-harness.mjs +157 -0
- package/src/checks/github-app.mjs +214 -0
- package/src/checks/rulesets.mjs +9 -8
- package/src/checks/secrets-and-variables.mjs +27 -8
- package/src/checks/stages.mjs +705 -0
- package/src/cli.mjs +270 -33
- package/src/deep-scan/agent.mjs +88 -21
- package/src/deep-scan/credential.mjs +81 -32
- package/src/deep-scan/docker-driver.mjs +105 -42
- package/src/deep-scan/harness-text.mjs +99 -0
- package/src/deep-scan/lifecycle.mjs +68 -178
- package/src/deep-scan/limits.mjs +13 -7
- package/src/deep-scan/model-proxy.mjs +21 -10
- package/src/deep-scan/preflight.mjs +19 -6
- package/src/deep-scan/recipe.mjs +4 -0
- package/src/deep-scan/runtime.mjs +54 -6
- package/src/deep-scan/sandbox-run.mjs +232 -0
- package/src/deep-scan/sbx-driver.mjs +224 -39
- package/src/deep-scan/tar.mjs +69 -22
- package/src/deep-scan/verify.mjs +6 -1
- package/src/deep-scan.mjs +73 -13
- package/src/doctor.mjs +113 -4
- package/src/harness/adapters.mjs +30 -0
- package/src/harness/antigravity.mjs +187 -0
- package/src/harness/claude-code.mjs +8 -1
- package/src/harness/codex.mjs +219 -0
- package/src/harness/cursor.mjs +199 -0
- package/src/harness/custom/registry.mjs +21 -0
- package/src/harness/custom/schema.mjs +90 -0
- package/src/harness/custom.mjs +299 -0
- package/src/harness/facts.mjs +44 -7
- package/src/harness/gemini.mjs +164 -0
- package/src/harness/install-layer.mjs +86 -3
- package/src/harness/opencode.mjs +289 -0
- package/src/harness/resolve.mjs +156 -0
- package/src/harness/support-levels.mjs +151 -3
- package/src/harness-live/assess.mjs +29 -6
- package/src/harness-live/cursor-real.mjs +146 -0
- package/src/harness-live/cursor-version.mjs +70 -0
- package/src/harness-live/cursor.mjs +80 -0
- package/src/harness-live/custom.mjs +91 -0
- package/src/harness-live/fixture-harness.mjs +45 -0
- package/src/harness-live/harnesses.mjs +263 -0
- package/src/harness-live/host.mjs +113 -4
- package/src/harness-live/opencode.mjs +289 -0
- package/src/harness-live/probes.mjs +87 -7
- package/src/harness-live/run.mjs +101 -20
- package/src/harness-live/setup.mjs +126 -0
- package/src/harness-live/stage.mjs +25 -15
- package/src/harness-live/suite.mjs +276 -95
- package/src/harness-test.mjs +116 -0
- package/src/init.mjs +313 -13
- package/src/model-proxy/core.mjs +128 -20
- package/src/model-proxy/profiles/anthropic.mjs +54 -10
- package/src/model-proxy/profiles/gemini-api.mjs +311 -0
- package/src/model-proxy/profiles/openai.mjs +327 -0
- package/src/model-proxy/stub-dialects/gemini-api.mjs +178 -0
- package/src/model-proxy/stub-dialects/openai.mjs +173 -0
- package/src/model-proxy/stub.mjs +9 -1
- package/src/stage/audit.mjs +79 -0
- package/src/stage/egress-route.mjs +207 -0
- package/src/stage/implement/carry.mjs +308 -0
- package/src/stage/implement/sandbox.mjs +271 -0
- package/src/stage/implement/verify.mjs +70 -0
- package/src/stage/implement.mjs +218 -0
- package/src/stage/plan.mjs +115 -0
- package/src/stage/review-response.mjs +172 -0
- package/src/stage/review.mjs +185 -0
- package/src/stage/workspace.mjs +274 -0
- package/src/stage.mjs +1068 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
// The Antigravity CLI Harness adapter (ADR 0027): one function that takes a
|
|
2
|
+
// Stage request and returns a launch plan, as plain data. The Launcher does
|
|
3
|
+
// everything with the plan; this module starts nothing and imports nothing.
|
|
4
|
+
//
|
|
5
|
+
// The CLI (`agy`): one pinned version, in `/opt/agent-kit` of the kit's Harness
|
|
6
|
+
// image (ADR 0029, docker/harness-images/), which is pinned by digest. The
|
|
7
|
+
// updater is off in the image and in the run's environment. Nothing is
|
|
8
|
+
// installed at run time.
|
|
9
|
+
//
|
|
10
|
+
// The launch: headless, the brief on stdin (with no `-p`, which takes the
|
|
11
|
+
// prompt on the command line), every tool call approved, since the Launcher's
|
|
12
|
+
// sandbox reaches the Guards. Everything the CLI reads and writes of its own is
|
|
13
|
+
// under `--gemini_dir`, in a folder of the Launcher's that it empties first, so
|
|
14
|
+
// nothing in the sandbox's home is read. There the Launcher writes the
|
|
15
|
+
// settings (`modelProvider: "gemini"`, which makes the CLI use the key in
|
|
16
|
+
// `GEMINI_API_KEY` with no sign-in) and one agent of its own, which the run is
|
|
17
|
+
// made as. No setting of the pinned version turns its web search off, and a
|
|
18
|
+
// permission rule naming it is dropped, so that agent lists the local tools it
|
|
19
|
+
// has and no other: no web search and no subagent, which could have its own.
|
|
20
|
+
//
|
|
21
|
+
// `agy` loads `.agents/`, `.agent/`, `_agents/` and `_agent/` (hooks, MCP
|
|
22
|
+
// servers, plugins, skills, agents) from the working directory with no trust
|
|
23
|
+
// asked, so the Launcher removes each from the copy, and `.gemini/` with them.
|
|
24
|
+
// `AGENTS.md` and `GEMINI.md` are instruction files it loads by itself.
|
|
25
|
+
//
|
|
26
|
+
// The model API's base URL is the model proxy, over plain HTTP, which the
|
|
27
|
+
// pinned version accepts; the live suite names that cause if a bump does not.
|
|
28
|
+
//
|
|
29
|
+
// The agent holds only the run's caller key as its `GEMINI_API_KEY`. It has no
|
|
30
|
+
// turn limit: the wall clock and the proxy's token cap bound the run. A CLI
|
|
31
|
+
// that asks for a sign-in was not given a credential it reads.
|
|
32
|
+
//
|
|
33
|
+
// The only credential is a Gemini API key. A Google sign-in is not accepted:
|
|
34
|
+
// the CLI's signed-in calls include one to a fixed Google host that no setting
|
|
35
|
+
// points at the model proxy (#578).
|
|
36
|
+
|
|
37
|
+
/** The Antigravity CLI version every sandbox runs, pinned. */
|
|
38
|
+
const VERSION = "1.5.20";
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The Harness image that holds that version. The `harness-images` workflow
|
|
42
|
+
* builds it in the pull request that changes the pin or its Dockerfile, and
|
|
43
|
+
* fails until this holds the digest it pushed
|
|
44
|
+
* (`node docker/harness-images/image.mjs record antigravity`).
|
|
45
|
+
*/
|
|
46
|
+
const IMAGE = "ghcr.io/mnaimfaizy/agent-kit-sandbox-antigravity";
|
|
47
|
+
const IMAGE_DIGEST = "sha256:db9e91a505fb28977a0d1a13af747060eba9facdf16385c0461a5a08726c06be"; // inputs-7f6aaef296738b4eb2ed3d0e2588a7b3
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* What a Consumer needs to know about Antigravity CLI, which
|
|
51
|
+
* `cli/harnesses.json` publishes per tag (ADR 0030): the kit secret it accepts,
|
|
52
|
+
* with where to get it; the values its `--effort` takes (each model offers some
|
|
53
|
+
* of them, and the CLI refuses one its model does not); and the model a Stage
|
|
54
|
+
* gets when none is named, which is the pinned version's own default.
|
|
55
|
+
*/
|
|
56
|
+
export const FACTS = Object.freeze({
|
|
57
|
+
displayName: "Antigravity CLI",
|
|
58
|
+
secrets: Object.freeze([
|
|
59
|
+
{
|
|
60
|
+
name: "gemini_api_key",
|
|
61
|
+
whereToGet:
|
|
62
|
+
"Create an API key in Google AI Studio, in a project with its own budget: https://aistudio.google.com/apikey.",
|
|
63
|
+
},
|
|
64
|
+
]),
|
|
65
|
+
effortValues: Object.freeze(["low", "medium", "high", "xhigh", "max"]),
|
|
66
|
+
defaultModel: "gemini-3.1-pro",
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
/** The CLI's own tools the run's agent has: all local. */
|
|
70
|
+
export const TOOLS = Object.freeze([
|
|
71
|
+
"run_command",
|
|
72
|
+
"read_file",
|
|
73
|
+
"write_file",
|
|
74
|
+
"edit_file",
|
|
75
|
+
"manage_task",
|
|
76
|
+
"update_steps",
|
|
77
|
+
]);
|
|
78
|
+
|
|
79
|
+
/** The agent the run is made as, which only the Launcher's folder holds. */
|
|
80
|
+
const AGENT = "agent-kit";
|
|
81
|
+
|
|
82
|
+
const AGENT_FILE = [
|
|
83
|
+
"---",
|
|
84
|
+
`name: ${AGENT}`,
|
|
85
|
+
"description: The agent of an Agent-kit run.",
|
|
86
|
+
"mainAgent: true",
|
|
87
|
+
"subagent: false",
|
|
88
|
+
"tools:",
|
|
89
|
+
...TOOLS.map((tool) => ` - ${tool}`),
|
|
90
|
+
"---",
|
|
91
|
+
"You are the agent of an Agent-kit run, working alone with no human to ask.",
|
|
92
|
+
"Do what the request says, with the tools you have, until it is done.",
|
|
93
|
+
"",
|
|
94
|
+
].join("\n");
|
|
95
|
+
|
|
96
|
+
/** The credential Antigravity CLI accepts, and the placeholder the model proxy swaps. */
|
|
97
|
+
const CREDENTIALS = {
|
|
98
|
+
"api-key": {
|
|
99
|
+
secret: "gemini_api_key",
|
|
100
|
+
env: "GEMINI_API_KEY",
|
|
101
|
+
placeholder: "agent-kit-deep-scan-placeholder",
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
/** The settings every run holds. */
|
|
106
|
+
const SETTINGS = {
|
|
107
|
+
modelProvider: "gemini",
|
|
108
|
+
enableTelemetry: false,
|
|
109
|
+
permissions: { deny: ["read_url(*)"] },
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const UPDATER_OFF = "AGY_CLI_DISABLE_AUTO_UPDATE=true";
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* The launch plan for `request`.
|
|
116
|
+
* @param {object} [request] a Stage request, as the Claude Code adapter
|
|
117
|
+
* describes it. `maxTurns` is ignored: Antigravity CLI has no turn limit.
|
|
118
|
+
* The only `credentialKind` is `api-key`.
|
|
119
|
+
* @returns the nine-part launch plan, in the same shape as Claude Code's.
|
|
120
|
+
*/
|
|
121
|
+
export function antigravity({
|
|
122
|
+
model,
|
|
123
|
+
effort,
|
|
124
|
+
credentialKind = "api-key",
|
|
125
|
+
proxyUrl,
|
|
126
|
+
briefPath,
|
|
127
|
+
kitDir,
|
|
128
|
+
callerKey,
|
|
129
|
+
} = {}) {
|
|
130
|
+
if (!Object.hasOwn(CREDENTIALS, credentialKind)) {
|
|
131
|
+
throw new Error(`Antigravity CLI has no credential kind ${JSON.stringify(credentialKind)}`);
|
|
132
|
+
}
|
|
133
|
+
const accepted = structuredClone(CREDENTIALS);
|
|
134
|
+
const credential = accepted[credentialKind];
|
|
135
|
+
if (callerKey !== undefined) credential.placeholder = callerKey;
|
|
136
|
+
const home = kitDir ?? "/agent-kit";
|
|
137
|
+
const own = `${home}/agy`;
|
|
138
|
+
return {
|
|
139
|
+
identity: { name: "antigravity", displayName: "Antigravity CLI", version: VERSION, major: 1 },
|
|
140
|
+
installLayer: {
|
|
141
|
+
image: `${IMAGE}@${IMAGE_DIGEST}`,
|
|
142
|
+
env: [UPDATER_OFF],
|
|
143
|
+
run: ["ln -sf /opt/agent-kit/bin/agy /usr/local/bin/agy"],
|
|
144
|
+
},
|
|
145
|
+
modelRoute: { profile: "gemini-api" },
|
|
146
|
+
credentials: { accepted, scrub: ["GEMINI_API_KEY", "GOOGLE_API_KEY"] },
|
|
147
|
+
launch: {
|
|
148
|
+
argv: [
|
|
149
|
+
"agy",
|
|
150
|
+
`--gemini_dir=${own}`,
|
|
151
|
+
"--dangerously-skip-permissions",
|
|
152
|
+
// The brief is text to follow, never one of the CLI's own commands.
|
|
153
|
+
"--disable-slash-commands",
|
|
154
|
+
// Its answer goes to stdout, the transcript.
|
|
155
|
+
"--output-format",
|
|
156
|
+
"text",
|
|
157
|
+
"--agent",
|
|
158
|
+
AGENT,
|
|
159
|
+
...(model !== undefined ? ["--model", model] : []),
|
|
160
|
+
...(effort !== undefined ? ["--effort", effort] : []),
|
|
161
|
+
],
|
|
162
|
+
stdin: briefPath !== undefined ? { file: briefPath } : null,
|
|
163
|
+
files: [
|
|
164
|
+
{ path: `${own}/antigravity-cli/settings.json`, text: JSON.stringify(SETTINGS, null, 2) },
|
|
165
|
+
{ path: `${own}/config/agents/${AGENT}.md`, text: AGENT_FILE },
|
|
166
|
+
],
|
|
167
|
+
env: [
|
|
168
|
+
`${credential.env}=${credential.placeholder}`,
|
|
169
|
+
UPDATER_OFF,
|
|
170
|
+
...(proxyUrl !== undefined ? [`GOOGLE_GEMINI_BASE_URL=${proxyUrl}`] : []),
|
|
171
|
+
],
|
|
172
|
+
// The Launcher removes `checkoutConfig` from the copy before the launch.
|
|
173
|
+
removeCheckoutConfig: true,
|
|
174
|
+
},
|
|
175
|
+
checkoutConfig: [".agents", ".agent", "_agents", "_agent", ".gemini"],
|
|
176
|
+
instructionFiles: ["GEMINI.md", "AGENTS.md"],
|
|
177
|
+
stops: {
|
|
178
|
+
turnCap: null,
|
|
179
|
+
// What it says on its error output when it has no credential it reads.
|
|
180
|
+
credentialMissing: {
|
|
181
|
+
stderrPattern:
|
|
182
|
+
"^(error: )?authentication required|GEMINI_API_KEY environment variable is not set",
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
transcript: { path: `${home}/logs/agent.log` },
|
|
186
|
+
};
|
|
187
|
+
}
|
|
@@ -220,7 +220,14 @@ export function claudeCode({
|
|
|
220
220
|
// itself. Declared for the Launcher; the Deep scan keeps the config from
|
|
221
221
|
// loading by the flags above, and removes nothing from the copy.
|
|
222
222
|
checkoutConfig: [".claude/settings.json", ".claude/settings.local.json", ".mcp.json"],
|
|
223
|
-
instructionFiles: [
|
|
223
|
+
instructionFiles: [
|
|
224
|
+
"CLAUDE.md",
|
|
225
|
+
"CLAUDE.local.md",
|
|
226
|
+
".claude/rules",
|
|
227
|
+
".claude/skills",
|
|
228
|
+
".claude/agents",
|
|
229
|
+
".claude/commands",
|
|
230
|
+
],
|
|
224
231
|
// Print mode says "Error: Reached max turns" on its error output.
|
|
225
232
|
stops: { turnCap: { stderrPattern: "^Error: Reached max turns" } },
|
|
226
233
|
// Where the Launcher keeps Claude Code's own output.
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
// The Codex CLI Harness adapter (ADR 0027): one function that takes a Stage
|
|
2
|
+
// request and returns a launch plan, as plain data. The Launcher does
|
|
3
|
+
// everything with the plan; this module starts nothing and imports nothing.
|
|
4
|
+
//
|
|
5
|
+
// The CLI: one pinned version, in `/opt/agent-kit` of the kit's Harness image
|
|
6
|
+
// (ADR 0029, docker/harness-images/), which is pinned by digest, with the
|
|
7
|
+
// update check off both in the Launcher's own config and in /etc/codex.
|
|
8
|
+
// Nothing is installed at run time.
|
|
9
|
+
//
|
|
10
|
+
// The launch: `codex exec`, the brief on stdin, with approvals and Codex's
|
|
11
|
+
// own sandbox off, since the Launcher's sandbox reaches the Guards. Codex
|
|
12
|
+
// reads one config file, the Launcher's, from a `CODEX_HOME` of the
|
|
13
|
+
// Launcher's own outside the workspace. It names a model provider of the
|
|
14
|
+
// kit's whose base URL is the model proxy, with WebSockets off, so every
|
|
15
|
+
// model request is one the `openai` provider profile judges. Web search and
|
|
16
|
+
// every feature that reaches outside the sandbox (apps, plugins, image
|
|
17
|
+
// generation, browsers), hooks, analytics, feedback and the update check are
|
|
18
|
+
// off. The checkout's own Codex config is removed from the copy and its
|
|
19
|
+
// project is marked untrusted, and no `AGENTS.md` is loaded
|
|
20
|
+
// (`project_doc_max_bytes = 0`): as on the Claude Code path, the brief hands
|
|
21
|
+
// the agent everything. `--strict-config` fails a pin that no longer knows
|
|
22
|
+
// one of these settings.
|
|
23
|
+
//
|
|
24
|
+
// The agent holds only the run's caller key as its `OPENAI_API_KEY`. Codex
|
|
25
|
+
// CLI has no turn limit, so the wall clock and the proxy's token cap bound it.
|
|
26
|
+
|
|
27
|
+
/** The Codex CLI version every sandbox runs, pinned. */
|
|
28
|
+
const VERSION = "0.172.0";
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The Harness image that holds that version. The `harness-images` workflow
|
|
32
|
+
* builds it in the pull request that changes the pin or its Dockerfile, and
|
|
33
|
+
* fails until this holds the digest it pushed
|
|
34
|
+
* (`node docker/harness-images/image.mjs record codex`).
|
|
35
|
+
*/
|
|
36
|
+
const IMAGE = "ghcr.io/mnaimfaizy/agent-kit-sandbox-codex";
|
|
37
|
+
const IMAGE_DIGEST = "sha256:987c3c106226b35afdce2c9ce983253718623c56843c7b362196516ac966a2e3"; // inputs-070b8818f9d8f4a50bd20b9db465686c
|
|
38
|
+
|
|
39
|
+
/** The system config line that keeps the update check off on any image. */
|
|
40
|
+
const UPDATE_CHECK_OFF = "check_for_update_on_startup = false";
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* What a Consumer needs to know about Codex CLI, which `cli/harnesses.json`
|
|
44
|
+
* publishes per tag (ADR 0030): the kit secret it accepts, with where to get
|
|
45
|
+
* it; the reasoning efforts its default model takes at the pinned version
|
|
46
|
+
* (`codex debug models --bundled`); and the model a Stage gets when none is
|
|
47
|
+
* named, which is the pinned version's own default.
|
|
48
|
+
*/
|
|
49
|
+
export const FACTS = Object.freeze({
|
|
50
|
+
displayName: "Codex CLI",
|
|
51
|
+
secrets: Object.freeze([
|
|
52
|
+
{
|
|
53
|
+
name: "openai_api_key",
|
|
54
|
+
whereToGet:
|
|
55
|
+
"Create an API key in the OpenAI platform, in a project with its own budget: https://platform.openai.com/api-keys.",
|
|
56
|
+
},
|
|
57
|
+
]),
|
|
58
|
+
effortValues: Object.freeze(["low", "medium", "high", "xhigh", "max", "ultra"]),
|
|
59
|
+
defaultModel: "gpt-6.2-sol",
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
/** The name of the kit's model provider in Codex's config. */
|
|
63
|
+
const PROVIDER = "agent-kit";
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Every Codex feature switched off: what reaches outside the sandbox, what
|
|
67
|
+
* runs a config's own commands, and what the model proxy would refuse (a
|
|
68
|
+
* compressed request, a connection retried without end).
|
|
69
|
+
*/
|
|
70
|
+
export const FEATURES_OFF = Object.freeze([
|
|
71
|
+
"apps",
|
|
72
|
+
"browser_use",
|
|
73
|
+
"browser_use_external",
|
|
74
|
+
"browser_use_full_cdp_access",
|
|
75
|
+
"computer_use",
|
|
76
|
+
"daemon_auto_start",
|
|
77
|
+
"enable_request_compression",
|
|
78
|
+
"hooks",
|
|
79
|
+
"image_generation",
|
|
80
|
+
"in_app_browser",
|
|
81
|
+
"plugin_sharing",
|
|
82
|
+
"plugins",
|
|
83
|
+
"remote_plugin",
|
|
84
|
+
"shell_snapshot",
|
|
85
|
+
"skill_mcp_dependency_install",
|
|
86
|
+
"tool_suggest",
|
|
87
|
+
"unbounded_connection_retries",
|
|
88
|
+
"workspace_dependencies",
|
|
89
|
+
]);
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The credential Codex CLI accepts: the kit secret, the variable it reads in
|
|
93
|
+
* the sandbox, and the placeholder it holds there, which the model proxy swaps.
|
|
94
|
+
*/
|
|
95
|
+
const CREDENTIALS = {
|
|
96
|
+
"api-key": {
|
|
97
|
+
secret: "openai_api_key",
|
|
98
|
+
env: "OPENAI_API_KEY",
|
|
99
|
+
placeholder: "sk-agent-kit-deep-scan-placeholder",
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/** The Launcher's config file, as TOML. Without a proxy address, no base URL. */
|
|
104
|
+
function configToml({ proxyUrl, workspace }) {
|
|
105
|
+
// A TOML basic string takes JSON's escapes.
|
|
106
|
+
const quoted = (s) => JSON.stringify(s);
|
|
107
|
+
return [
|
|
108
|
+
"# Written by the agent-kit Launcher for this run.",
|
|
109
|
+
`model_provider = ${quoted(PROVIDER)}`,
|
|
110
|
+
'approval_policy = "never"',
|
|
111
|
+
'sandbox_mode = "danger-full-access"',
|
|
112
|
+
'web_search = "disabled"',
|
|
113
|
+
UPDATE_CHECK_OFF,
|
|
114
|
+
"project_doc_max_bytes = 0",
|
|
115
|
+
"",
|
|
116
|
+
"[analytics]",
|
|
117
|
+
"enabled = false",
|
|
118
|
+
"",
|
|
119
|
+
"[feedback]",
|
|
120
|
+
"enabled = false",
|
|
121
|
+
"",
|
|
122
|
+
"[history]",
|
|
123
|
+
'persistence = "none"',
|
|
124
|
+
"",
|
|
125
|
+
`[projects.${quoted(workspace)}]`,
|
|
126
|
+
'trust_level = "untrusted"',
|
|
127
|
+
"",
|
|
128
|
+
"[features]",
|
|
129
|
+
...FEATURES_OFF.map((feature) => `${feature} = false`),
|
|
130
|
+
"",
|
|
131
|
+
`[model_providers.${PROVIDER}]`,
|
|
132
|
+
`name = ${quoted(PROVIDER)}`,
|
|
133
|
+
...(proxyUrl !== undefined ? [`base_url = ${quoted(`${proxyUrl}/v1`)}`] : []),
|
|
134
|
+
'env_key = "OPENAI_API_KEY"',
|
|
135
|
+
'wire_api = "responses"',
|
|
136
|
+
"supports_websockets = false",
|
|
137
|
+
"",
|
|
138
|
+
`[model_providers.${PROVIDER}.capabilities]`,
|
|
139
|
+
'remote_compaction = "unsupported"',
|
|
140
|
+
"external_web_access = false",
|
|
141
|
+
"",
|
|
142
|
+
].join("\n");
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* The launch plan for `request`.
|
|
147
|
+
* @param {object} [request] a Stage request, as the Claude Code adapter
|
|
148
|
+
* describes it, with `workspace`, the repository's folder in the sandbox.
|
|
149
|
+
* `maxTurns` is ignored: Codex CLI has no turn limit. The only
|
|
150
|
+
* `credentialKind` is `api-key`.
|
|
151
|
+
* @returns the nine-part launch plan, in the same shape as Claude Code's.
|
|
152
|
+
*/
|
|
153
|
+
export function codex({
|
|
154
|
+
model,
|
|
155
|
+
effort,
|
|
156
|
+
credentialKind = "api-key",
|
|
157
|
+
proxyUrl,
|
|
158
|
+
briefPath,
|
|
159
|
+
kitDir = "/agent-kit",
|
|
160
|
+
workspace = "/workspace",
|
|
161
|
+
callerKey,
|
|
162
|
+
} = {}) {
|
|
163
|
+
if (!Object.hasOwn(CREDENTIALS, credentialKind)) {
|
|
164
|
+
throw new Error(`Codex CLI has no credential kind ${JSON.stringify(credentialKind)}`);
|
|
165
|
+
}
|
|
166
|
+
const accepted = structuredClone(CREDENTIALS);
|
|
167
|
+
const credential = accepted[credentialKind];
|
|
168
|
+
if (callerKey !== undefined) credential.placeholder = callerKey;
|
|
169
|
+
const home = `${kitDir}/codex`;
|
|
170
|
+
return {
|
|
171
|
+
identity: { name: "codex", displayName: "Codex CLI", version: VERSION, major: 0 },
|
|
172
|
+
installLayer: {
|
|
173
|
+
image: `${IMAGE}@${IMAGE_DIGEST}`,
|
|
174
|
+
env: [],
|
|
175
|
+
run: [
|
|
176
|
+
"ln -sf /opt/agent-kit/bin/codex /usr/local/bin/codex \\",
|
|
177
|
+
" && mkdir -p /etc/codex \\",
|
|
178
|
+
` && printf '%s\\n' '${UPDATE_CHECK_OFF}' > /etc/codex/config.toml`,
|
|
179
|
+
],
|
|
180
|
+
},
|
|
181
|
+
modelRoute: { profile: "openai" },
|
|
182
|
+
credentials: {
|
|
183
|
+
accepted,
|
|
184
|
+
scrub: ["OPENAI_API_KEY", "CODEX_API_KEY", "CODEX_ACCESS_TOKEN"],
|
|
185
|
+
},
|
|
186
|
+
launch: {
|
|
187
|
+
argv: [
|
|
188
|
+
"codex",
|
|
189
|
+
"exec",
|
|
190
|
+
// Its events go to stdout, the transcript, and not to its error output.
|
|
191
|
+
"--json",
|
|
192
|
+
"--strict-config",
|
|
193
|
+
"--skip-git-repo-check",
|
|
194
|
+
"--ephemeral",
|
|
195
|
+
"--ignore-rules",
|
|
196
|
+
"--dangerously-bypass-approvals-and-sandbox",
|
|
197
|
+
...(model !== undefined ? ["--model", model] : []),
|
|
198
|
+
...(effort !== undefined ? ["--config", `model_reasoning_effort="${effort}"`] : []),
|
|
199
|
+
// The prompt is read from stdin.
|
|
200
|
+
"-",
|
|
201
|
+
],
|
|
202
|
+
stdin: briefPath !== undefined ? { file: briefPath } : null,
|
|
203
|
+
files: [{ path: `${home}/config.toml`, text: configToml({ proxyUrl, workspace }) }],
|
|
204
|
+
env: [
|
|
205
|
+
`${credential.env}=${credential.placeholder}`,
|
|
206
|
+
`CODEX_HOME=${home}`,
|
|
207
|
+
// Codex takes its base URL from the config; the shell is told it too,
|
|
208
|
+
// as OpenAI's own clients read it: the API's base, `/v1` included.
|
|
209
|
+
...(proxyUrl !== undefined ? [`OPENAI_BASE_URL=${proxyUrl}/v1`] : []),
|
|
210
|
+
],
|
|
211
|
+
// The Launcher removes `checkoutConfig` from the copy before the launch.
|
|
212
|
+
removeCheckoutConfig: true,
|
|
213
|
+
},
|
|
214
|
+
checkoutConfig: [".codex", ".agents/plugins", ".agents/skills"],
|
|
215
|
+
instructionFiles: ["AGENTS.md", "AGENTS.override.md"],
|
|
216
|
+
stops: { turnCap: null },
|
|
217
|
+
transcript: { path: `${kitDir}/logs/agent.log` },
|
|
218
|
+
};
|
|
219
|
+
}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
// The Cursor CLI Harness adapter (ADR 0027): one function that takes a Stage
|
|
2
|
+
// request and returns a launch plan, as plain data. The Launcher does
|
|
3
|
+
// everything with the plan; this module starts nothing and imports nothing.
|
|
4
|
+
//
|
|
5
|
+
// Cursor CLI is the one harness the model proxy cannot front: every model
|
|
6
|
+
// request goes through Cursor's own backend. Its key and network Guards take
|
|
7
|
+
// the fixed weaker form of ADR 0025, on plan, implement and review only:
|
|
8
|
+
//
|
|
9
|
+
// - egress: the sandbox reaches Cursor's hosts (HOSTS, below) and nothing
|
|
10
|
+
// else, through the Launcher's allowlist proxy (`modelRoute.egress`);
|
|
11
|
+
// - key: `CURSOR_API_KEY` itself sits in the sandbox, the one secret passed
|
|
12
|
+
// in; there is no placeholder;
|
|
13
|
+
// - result: the Launcher refuses a Stage result, or an agent's commit
|
|
14
|
+
// (binary files included), that holds the key (`refuseHeldKey`, in
|
|
15
|
+
// cli/src/stage/egress-route.mjs). The commits are scanned on the host,
|
|
16
|
+
// from the bundle that came out, never by the sandbox's git. The transcript and error output stay
|
|
17
|
+
// private on the runner and are not checked. The key reaches the sandbox
|
|
18
|
+
// through the runtime CLI's environment, never its command line.
|
|
19
|
+
//
|
|
20
|
+
// It is refused for Review response, the static security audit and the Deep
|
|
21
|
+
// scan (harness/resolve.mjs and the reusable workflows), and capped at `tried`
|
|
22
|
+
// (ADR 0028): Cursor's backend changes behind the pinned binary.
|
|
23
|
+
//
|
|
24
|
+
// The CLI: one pinned version, in `/opt/agent-kit` of the kit's Harness image
|
|
25
|
+
// (ADR 0029), pinned by digest. Cursor became Grok Build on 2026-11-30; this
|
|
26
|
+
// is the legacy Cursor CLI (`cursor-agent`, dated versions like
|
|
27
|
+
// `2026.12.02-8b70b6c`), not xAI's `grok` 2.x CLI (versions `2.…`), which
|
|
28
|
+
// takes other flags, another key and other hosts
|
|
29
|
+
// (docs/research/cursor-grok-build.md). `cursor-agent update --channel grok`
|
|
30
|
+
// would replace it with `grok`, recorded in `grok-switch.json` in
|
|
31
|
+
// `CURSOR_CONFIG_DIR`. None of that can happen here: the image is
|
|
32
|
+
// root-owned, no update host (`downloads.cursor.com`, `x.ai`,
|
|
33
|
+
// `storage.googleapis.com`) is allowed, `CURSOR_CONFIG_DIR` is the run's own
|
|
34
|
+
// fresh directory with no switch record, and the image build and the live
|
|
35
|
+
// workflow fail unless `--version` prints this dated pin (VERSION_FORM). The launch: headless
|
|
36
|
+
// (`-p`), every tool approved (`--force`) since the Launcher's sandbox reaches
|
|
37
|
+
// the Guards, the prompt as the one argument (the brief is a file it names).
|
|
38
|
+
// The checkout's Cursor config (`.cursor/`, `.cursorrules`, `.agents/skills`,
|
|
39
|
+
// `.env`) is removed from the copy; the run's own `cli-config.json`, under a
|
|
40
|
+
// `CURSOR_CONFIG_DIR` of the Launcher's, denies Cursor's web tools where its
|
|
41
|
+
// permission rules allow it.
|
|
42
|
+
|
|
43
|
+
/** The Cursor CLI version every sandbox runs, pinned (a `lab/<version>` package). */
|
|
44
|
+
const VERSION = "2026.12.02-8b70b6c";
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The legacy Cursor CLI's version form. The image build checks its pin with
|
|
48
|
+
* the same pattern (a test holds docker/harness-images/cursor.Dockerfile to it).
|
|
49
|
+
*/
|
|
50
|
+
export const VERSION_FORM = /^[0-9]{4}\.[0-9]{2}\.[0-9]{2}-[0-9a-f]{7,}$/;
|
|
51
|
+
|
|
52
|
+
/** What `grok` 2.x prints for `--version` (versions `2.…`), in the image build too. */
|
|
53
|
+
export const GROK_VERSION = /^(grok[^ ]* +)?v?2\.[0-9]/i;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The Harness image that holds that version. The `harness-images` workflow
|
|
57
|
+
* builds it in the pull request that changes the pin or its Dockerfile, and
|
|
58
|
+
* fails until this holds the digest it pushed
|
|
59
|
+
* (`node docker/harness-images/image.mjs record cursor`).
|
|
60
|
+
*/
|
|
61
|
+
const IMAGE = "ghcr.io/mnaimfaizy/agent-kit-sandbox-cursor";
|
|
62
|
+
const IMAGE_DIGEST = "sha256:557d45d4952ad836b3df9005a2f7768ca16861f2d9a104c54da17bcbab206aa8"; // inputs-e5fe4cda6fcdda6920a56a7acdb51e73
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* What a Consumer needs to know about Cursor CLI, which `cli/harnesses.json`
|
|
66
|
+
* publishes per tag (ADR 0030): the kit secret it accepts, with where to get
|
|
67
|
+
* it; no effort values (the pinned version has no effort setting); and the
|
|
68
|
+
* model a Stage gets when none is named, Cursor's own `auto`.
|
|
69
|
+
*/
|
|
70
|
+
export const FACTS = Object.freeze({
|
|
71
|
+
displayName: "Cursor CLI",
|
|
72
|
+
secrets: Object.freeze([
|
|
73
|
+
{
|
|
74
|
+
name: "cursor_api_key",
|
|
75
|
+
whereToGet:
|
|
76
|
+
'Create an API key with the permission "Sign in to the Cursor CLI and SDK" in the Grok Build dashboard (Cursor is now Grok Build): https://grok.com/dashboard/api-keys. An existing Cursor (legacy) key keeps working. It sits in the sandbox for the run, so use one from an account with its own spend limit.',
|
|
77
|
+
},
|
|
78
|
+
]),
|
|
79
|
+
effortValues: Object.freeze([]),
|
|
80
|
+
defaultModel: "auto",
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* The hosts the sandbox may reach, each on port 443: the ones Cursor's
|
|
85
|
+
* network configuration page lists for agent requests (`api2` for most API
|
|
86
|
+
* requests, `api5` for agent requests, `api3`, `api4` and `repo42` for tab
|
|
87
|
+
* and codebase search). Exact names, no wildcard: the allowlist proxy takes
|
|
88
|
+
* none, and `downloads.cursor.com` (updates) is left out on purpose.
|
|
89
|
+
* Of the page's `agent*.api5.cursor.sh` subdomains, which it gives only for
|
|
90
|
+
* "network access layer (NAL) requests" and ties to no client, one is on the
|
|
91
|
+
* list: a live probe on 2026-12-04 (Cursor CLI 2026.12.02-8b70b6c) was refused
|
|
92
|
+
* on `agentn.global.api5.cursor.sh` with an HTTPS proxy CONNECT 403. The other
|
|
93
|
+
* `agent*.api5.cursor.sh` names stay out until a run shows the CLI needs one.
|
|
94
|
+
* Left out too: its sign-in hosts (an API key opens no sign-in page); and
|
|
95
|
+
* every `x.ai`, `grok.com` or `spacexsi.com` host, which serve `grok` 2.x or
|
|
96
|
+
* browser sign-in, not this CLI.
|
|
97
|
+
* Source: https://docs.grok.com/build/agents-window/enterprise/network-configuration
|
|
98
|
+
*/
|
|
99
|
+
export const HOSTS = Object.freeze([
|
|
100
|
+
"api2.cursor.sh",
|
|
101
|
+
"api3.cursor.sh",
|
|
102
|
+
"api4.cursor.sh",
|
|
103
|
+
"api5.cursor.sh",
|
|
104
|
+
"repo42.cursor.sh",
|
|
105
|
+
"agentn.global.api5.cursor.sh",
|
|
106
|
+
]);
|
|
107
|
+
|
|
108
|
+
/** The credential Cursor CLI accepts: the key itself, held in the sandbox. */
|
|
109
|
+
const CREDENTIALS = {
|
|
110
|
+
"api-key": { secret: "cursor_api_key", env: "CURSOR_API_KEY", placeholder: "" },
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
/** The run's own CLI config: no web tools, and the permissions a headless run needs. */
|
|
114
|
+
const CONFIG = {
|
|
115
|
+
version: 1,
|
|
116
|
+
permissions: {
|
|
117
|
+
allow: ["Read(**)", "Write(**)", "Shell(*)"],
|
|
118
|
+
deny: ["WebFetch(*)", "WebSearch(*)"],
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* The launch plan for `request`.
|
|
124
|
+
* @param {object} [request] a Stage request, as the Claude Code adapter
|
|
125
|
+
* describes it, with these differences. `proxyUrl` is the Launcher's
|
|
126
|
+
* allowlist proxy, not a model proxy. `callerKey` is the Cursor API key
|
|
127
|
+
* itself, which the sandbox holds; without it the plan holds none. `effort`
|
|
128
|
+
* and `maxTurns` are ignored: Cursor CLI has neither.
|
|
129
|
+
* @returns the nine-part launch plan, in the same shape as Claude Code's.
|
|
130
|
+
*/
|
|
131
|
+
export function cursor({
|
|
132
|
+
model,
|
|
133
|
+
credentialKind = "api-key",
|
|
134
|
+
proxyUrl,
|
|
135
|
+
briefPath,
|
|
136
|
+
kitDir,
|
|
137
|
+
callerKey,
|
|
138
|
+
} = {}) {
|
|
139
|
+
if (!Object.hasOwn(CREDENTIALS, credentialKind)) {
|
|
140
|
+
throw new Error(`Cursor CLI has no credential kind ${JSON.stringify(credentialKind)}`);
|
|
141
|
+
}
|
|
142
|
+
const accepted = structuredClone(CREDENTIALS);
|
|
143
|
+
const credential = accepted[credentialKind];
|
|
144
|
+
if (callerKey !== undefined) credential.placeholder = callerKey;
|
|
145
|
+
const home = kitDir ?? "/agent-kit";
|
|
146
|
+
const config = `${home}/cursor`;
|
|
147
|
+
return {
|
|
148
|
+
identity: { name: "cursor", displayName: "Cursor CLI", version: VERSION, major: 2026 },
|
|
149
|
+
installLayer: {
|
|
150
|
+
image: `${IMAGE}@${IMAGE_DIGEST}`,
|
|
151
|
+
env: [],
|
|
152
|
+
run: ["ln -sf /opt/agent-kit/bin/cursor-agent /usr/local/bin/cursor-agent"],
|
|
153
|
+
},
|
|
154
|
+
// No model proxy: the egress allowlist, to the hosts above, is the route.
|
|
155
|
+
modelRoute: { profile: null, egress: { hosts: [...HOSTS] } },
|
|
156
|
+
credentials: { accepted, scrub: ["CURSOR_API_KEY"] },
|
|
157
|
+
launch: {
|
|
158
|
+
argv: [
|
|
159
|
+
"sh",
|
|
160
|
+
"-c",
|
|
161
|
+
// The prompt is the one argument, read from the file the Launcher wrote.
|
|
162
|
+
`exec cursor-agent -p --force --trust --output-format text${model !== undefined ? ` --model '${model.replace(/'/g, "")}'` : ""} "$(cat ${briefPath ?? `${home}/in/prompt.md`})"`,
|
|
163
|
+
],
|
|
164
|
+
stdin: null,
|
|
165
|
+
files: [{ path: `${config}/cli-config.json`, text: JSON.stringify(CONFIG, null, 2) }],
|
|
166
|
+
env: [
|
|
167
|
+
...(credential.placeholder !== "" ? [`${credential.env}=${credential.placeholder}`] : []),
|
|
168
|
+
`CURSOR_CONFIG_DIR=${config}`,
|
|
169
|
+
"NO_COLOR=1",
|
|
170
|
+
...(proxyUrl !== undefined
|
|
171
|
+
? [
|
|
172
|
+
`HTTPS_PROXY=${proxyUrl}`,
|
|
173
|
+
`HTTP_PROXY=${proxyUrl}`,
|
|
174
|
+
`ALL_PROXY=${proxyUrl}`,
|
|
175
|
+
"NODE_USE_ENV_PROXY=1",
|
|
176
|
+
]
|
|
177
|
+
: []),
|
|
178
|
+
],
|
|
179
|
+
// The Launcher removes `checkoutConfig` from the copy before the launch.
|
|
180
|
+
// The runtime CLI is given the name alone; the value goes in its environment.
|
|
181
|
+
secretEnv: ["CURSOR_API_KEY"],
|
|
182
|
+
removeCheckoutConfig: true,
|
|
183
|
+
},
|
|
184
|
+
checkoutConfig: [".cursor", ".cursorrules", ".agents/skills", ".env"],
|
|
185
|
+
instructionFiles: ["AGENTS.md", "CLAUDE.md"],
|
|
186
|
+
stops: { turnCap: null },
|
|
187
|
+
transcript: { path: `${home}/logs/agent.log` },
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** What a Stage says that differs by harness (cli/src/deep-scan/harness-text.mjs). */
|
|
192
|
+
export const TEXT = Object.freeze({
|
|
193
|
+
webOff: "Cursor CLI's web fetch and web search are denied in its run config",
|
|
194
|
+
agentStep: () =>
|
|
195
|
+
"the API key in the sandbox, egress to Cursor's hosts alone, web tools denied, the checkout's Cursor config removed",
|
|
196
|
+
turnLimit: false,
|
|
197
|
+
needsKey: "Cursor CLI needs a Cursor API key",
|
|
198
|
+
keyRefused: "Check that the key is current and its Cursor account is active",
|
|
199
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// The Custom harnesses this process has loaded from a trusted commit, by their
|
|
2
|
+
// `custom:<name>`. Whatever looks a harness up by name finds a loaded one here
|
|
3
|
+
// beside the kit's own. It imports nothing, so anything may import it.
|
|
4
|
+
|
|
5
|
+
/** @type {Map<string, { adapter: Function, facts: object, text: object }>} */
|
|
6
|
+
const loaded = new Map();
|
|
7
|
+
|
|
8
|
+
/** Whether `harness` names a Custom harness. */
|
|
9
|
+
export const isCustom = (harness) => typeof harness === "string" && harness.startsWith("custom:");
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @param {string} harness `custom:<name>`
|
|
13
|
+
* @param {{ adapter: Function, facts: object, text: object }} entry
|
|
14
|
+
*/
|
|
15
|
+
export function registerCustom(harness, entry) {
|
|
16
|
+
if (!isCustom(harness)) throw new Error(`not a Custom harness: ${JSON.stringify(harness)}`);
|
|
17
|
+
loaded.set(harness, entry);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** The loaded Custom harness `harness`, or undefined. */
|
|
21
|
+
export const loadedCustom = (harness) => loaded.get(harness);
|