@mnaimfaizy/agent-kit 1.0.0-beta.14 → 1.0.0-beta.16
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 +583 -36
- 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 +166 -5
- package/src/exec.mjs +14 -5
- package/src/factory/budget/budget.mjs +259 -0
- package/src/factory/build/command.mjs +321 -0
- package/src/factory/build/factory.mjs +473 -0
- package/src/factory/build/findings.mjs +55 -0
- package/src/factory/build/host.mjs +230 -0
- package/src/factory/build/notes.mjs +191 -0
- package/src/factory/build/pull-request.mjs +74 -0
- package/src/factory/bundle.mjs +146 -0
- package/src/factory/checks/allowed-paths.mjs +50 -0
- package/src/factory/checks/plan-header.mjs +296 -0
- package/src/factory/checks/qa.mjs +85 -0
- package/src/factory/checks/review.mjs +73 -0
- package/src/factory/checks/security.mjs +50 -0
- package/src/factory/checks/stage-check.mjs +89 -0
- package/src/factory/claims/command.mjs +187 -0
- package/src/factory/claims/release.mjs +111 -0
- package/src/factory/decision/answers.mjs +103 -0
- package/src/factory/decision/command.mjs +64 -0
- package/src/factory/decision/plan.mjs +99 -0
- package/src/factory/decision/request.mjs +116 -0
- package/src/factory/doctor/files.mjs +329 -0
- package/src/factory/doctor/index.mjs +56 -0
- package/src/factory/doctor/local.mjs +497 -0
- package/src/factory/doctor/orchestrate.mjs +146 -0
- package/src/factory/engine/lease.mjs +146 -0
- package/src/factory/engine/local-engine.mjs +177 -0
- package/src/factory/engine/lockfile.mjs +64 -0
- package/src/factory/engine/workflow-engine.mjs +124 -0
- package/src/factory/gate/comment.mjs +88 -0
- package/src/factory/gate/config.mjs +57 -0
- package/src/factory/gate/gate-core.mjs +250 -0
- package/src/factory/gate/guarded.mjs +17 -0
- package/src/factory/gate/reads.mjs +105 -0
- package/src/factory/gate/task.mjs +193 -0
- package/src/factory/gate/trip-reads.mjs +82 -0
- package/src/factory/gate/trip.mjs +87 -0
- package/src/factory/init/blueprint.mjs +174 -0
- package/src/factory/init/index.mjs +337 -0
- package/src/factory/labels/evidence.mjs +162 -0
- package/src/factory/labels/moves.mjs +32 -0
- package/src/factory/labels/reconcile.mjs +267 -0
- package/src/factory/labels/revert.mjs +87 -0
- package/src/factory/labels/timeline.mjs +72 -0
- package/src/factory/labels/voided.mjs +59 -0
- package/src/factory/limits/harness.mjs +39 -0
- package/src/factory/limits/limits.mjs +123 -0
- package/src/factory/merge/command.mjs +172 -0
- package/src/factory/outbox/check.mjs +240 -0
- package/src/factory/outbox/rulings.mjs +195 -0
- package/src/factory/plan/command.mjs +66 -0
- package/src/factory/plan/comment.mjs +156 -0
- package/src/factory/plan/publish.mjs +149 -0
- package/src/factory/plan/risk.mjs +153 -0
- package/src/factory/qa/command.mjs +163 -0
- package/src/factory/records/engine-record.mjs +133 -0
- package/src/factory/records/main.mjs +96 -0
- package/src/factory/records/record.mjs +226 -0
- package/src/factory/records/sink.mjs +57 -0
- package/src/factory/report/build.mjs +92 -0
- package/src/factory/report/command.mjs +80 -0
- package/src/factory/report/facts.mjs +226 -0
- package/src/factory/report/gate-section.mjs +122 -0
- package/src/factory/report/metrics.mjs +111 -0
- package/src/factory/report/reads.mjs +246 -0
- package/src/factory/report/render.mjs +121 -0
- package/src/factory/report/rollout.mjs +154 -0
- package/src/factory/review/command.mjs +182 -0
- package/src/factory/run/awake.mjs +70 -0
- package/src/factory/run/collect.mjs +77 -0
- package/src/factory/run/command.mjs +490 -0
- package/src/factory/run/gh.mjs +46 -0
- package/src/factory/run/launch.mjs +47 -0
- package/src/factory/run/pipelines.mjs +261 -0
- package/src/factory/run/raw.mjs +96 -0
- package/src/factory/run/restart.mjs +83 -0
- package/src/factory/run/s3.mjs +193 -0
- package/src/factory/run/secrets.mjs +142 -0
- package/src/factory/run/teardown.mjs +242 -0
- package/src/factory/run/token.mjs +68 -0
- package/src/factory/security/command.mjs +157 -0
- package/src/factory/setup/app.mjs +122 -0
- package/src/factory/setup/command.mjs +409 -0
- package/src/factory/setup/labels.mjs +25 -0
- package/src/factory/setup/reads.mjs +129 -0
- package/src/factory/setup/writes.mjs +126 -0
- package/src/factory/snapshot/write.mjs +176 -0
- package/src/factory/stop/command.mjs +136 -0
- package/src/factory/sweep/actions-main.mjs +117 -0
- package/src/factory/sweep/command.mjs +65 -0
- package/src/factory/sweep/knobs.mjs +78 -0
- package/src/factory/sweep/marker-version.mjs +15 -0
- package/src/factory/sweep/markers.mjs +112 -0
- package/src/factory/sweep/overlap.mjs +24 -0
- package/src/factory/sweep/run.mjs +198 -0
- package/src/factory/sweep/shell.mjs +394 -0
- package/src/factory/sweep/split.mjs +104 -0
- package/src/factory/sweep/states.mjs +87 -0
- package/src/factory/sweep/sweep-core.mjs +1781 -0
- package/src/factory/tracker/github.mjs +674 -0
- package/src/factory/tracker/operations.mjs +153 -0
- package/src/factory/upgrade/index.mjs +83 -0
- 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 +374 -36
- package/src/kit-owned-paths.mjs +1 -1
- 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 +1087 -0
- package/src/upgrade.mjs +39 -7
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
// What the live suite knows about each harness it proves (ADR 0031): the stub
|
|
2
|
+
// model's dialect and the credential kinds it is run on, the header the proxy
|
|
3
|
+
// writes the real key in, the variable that names the model proxy in the
|
|
4
|
+
// sandbox, and the control for the checkout-config probe: the harness started
|
|
5
|
+
// again in the same sandbox with the checkout's config loaded on purpose, so a
|
|
6
|
+
// run in which none of it left a marker is known to have been able to.
|
|
7
|
+
|
|
8
|
+
import { antigravity } from "../harness/antigravity.mjs";
|
|
9
|
+
import { claudeCode, TOOLS } from "../harness/claude-code.mjs";
|
|
10
|
+
import { codex } from "../harness/codex.mjs";
|
|
11
|
+
import { gemini } from "../harness/gemini.mjs";
|
|
12
|
+
import { anthropicDialect } from "../model-proxy/stub-dialects/anthropic.mjs";
|
|
13
|
+
import { geminiApiDialect } from "../model-proxy/stub-dialects/gemini-api.mjs";
|
|
14
|
+
import { openaiDialect } from "../model-proxy/stub-dialects/openai.mjs";
|
|
15
|
+
import { canary, FAKE_CREDENTIAL, plantedConfig, plantedEnvFiles } from "./host.mjs";
|
|
16
|
+
import { liveOpencode } from "./opencode.mjs";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @typedef {{
|
|
20
|
+
* adapter: (request?: object) => import("../harness/claude-code.mjs").LaunchPlan,
|
|
21
|
+
* dialect: import("../model-proxy/stub.mjs").StubDialect,
|
|
22
|
+
* credential: (kind: string) => string,
|
|
23
|
+
* upstreamAuth: (kind: string, credential: string) => [string, string],
|
|
24
|
+
* baseUrlVariable: string,
|
|
25
|
+
* removed: readonly string[],
|
|
26
|
+
* harmlessVariables: readonly string[],
|
|
27
|
+
* configControl: readonly string[],
|
|
28
|
+
* assertions?: ReadonlyArray<NamedAssertion>,
|
|
29
|
+
* control: (launch: { plan: import("../harness/claude-code.mjs").LaunchPlan, url: string }) =>
|
|
30
|
+
* { argv: string[], stdin: string },
|
|
31
|
+
* model?: string,
|
|
32
|
+
* shellTool?: string,
|
|
33
|
+
* committed?: Record<string, string>,
|
|
34
|
+
* profiles?: Readonly<Record<string, Partial<LiveHarness>>>,
|
|
35
|
+
* before?: Function,
|
|
36
|
+
* after?: Function,
|
|
37
|
+
* }} LiveHarness `removed` are the checkout paths the Launcher must have
|
|
38
|
+
* removed from the sandbox's copy. `configControl` holds the start of each
|
|
39
|
+
* marker's name the control run must leave. `harmlessVariables` are the
|
|
40
|
+
* `NAME=value` pairs with a GitHub prefix that the harness itself sets.
|
|
41
|
+
* `assertions` are the harness's own, beside the Guards. `profiles` are the
|
|
42
|
+
* model providers a harness is proven on, one run of every scenario each,
|
|
43
|
+
* with what differs by provider (the `model` named among it). `before` and
|
|
44
|
+
* `after` run in a read-only Stage's sandbox around its agent step, and what
|
|
45
|
+
* `after` returns joins the evidence. `control` is missing for a Custom
|
|
46
|
+
* harness, whose own config the suite cannot know how to load; `shellTool`
|
|
47
|
+
* is its file's `probe_shell_tool`, and `committed` its file, planted on
|
|
48
|
+
* the fixture repository's default branch.
|
|
49
|
+
*
|
|
50
|
+
* @typedef {{
|
|
51
|
+
* name: string,
|
|
52
|
+
* check: (evidence: {
|
|
53
|
+
* requests: ReadonlyArray<{ method: string, path: string, body: string }>,
|
|
54
|
+
* transcript: string | null,
|
|
55
|
+
* launcherOutput: string,
|
|
56
|
+
* stage: boolean,
|
|
57
|
+
* decoy?: { registered: boolean, attachedByStage: boolean, attachedWithout: boolean },
|
|
58
|
+
* egress?: { logging: boolean, lines: string[] },
|
|
59
|
+
* }) => string | null,
|
|
60
|
+
* }} NamedAssertion What a run must show of one harness, by name, so that a pin
|
|
61
|
+
* bump that breaks it says why (ADR 0031): `check` gives why it failed, or
|
|
62
|
+
* null.
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
/** A word quoted for `sh`. */
|
|
66
|
+
const quote = (s) => `'${String(s).replace(/'/g, `'\\''`)}'`;
|
|
67
|
+
|
|
68
|
+
const DONE = "Say that you are done.";
|
|
69
|
+
|
|
70
|
+
/** The removed paths of a plan whose launch removes the checkout's config. */
|
|
71
|
+
const removedBy = ({ launch, checkoutConfig }) =>
|
|
72
|
+
launch.removeCheckoutConfig ? [...checkoutConfig] : [];
|
|
73
|
+
|
|
74
|
+
/** What a harness says when it will not send a model request over plain HTTP. */
|
|
75
|
+
const PLAIN_HTTP_REFUSED =
|
|
76
|
+
/(base[ _]?url.*\bhttps\b|\bmust use https\b|\bhttps is required\b|insecure.*\burl\b|plain[ -]http)/i;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Gemini CLI documents HTTPS for any base URL but a loopback one, and the
|
|
80
|
+
* pinned version does not enforce it (ADR 0023): the proxy is plain HTTP, and
|
|
81
|
+
* not loopback from the sandbox.
|
|
82
|
+
* @type {Readonly<NamedAssertion>}
|
|
83
|
+
*/
|
|
84
|
+
const PLAIN_HTTP = Object.freeze({
|
|
85
|
+
name: "gemini-plain-http-base-url",
|
|
86
|
+
check({ requests, transcript, launcherOutput }) {
|
|
87
|
+
if (requests.length > 0) return null;
|
|
88
|
+
const said = `${transcript ?? ""}\n${launcherOutput}`
|
|
89
|
+
.split("\n")
|
|
90
|
+
.find((line) => PLAIN_HTTP_REFUSED.test(line));
|
|
91
|
+
return said === undefined
|
|
92
|
+
? "no request of Gemini CLI's reached the model API, so the plain-HTTP base URL is not shown accepted: read the agent step's output."
|
|
93
|
+
: `Gemini CLI ${gemini().identity.version} refused the plain-HTTP base URL of the model proxy (ADR 0023), so it needs the in-sandbox loopback forwarder before this pin ships. It said: ${said.trim()}`;
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Antigravity CLI, in API-key mode, takes the model proxy's plain-HTTP base
|
|
99
|
+
* URL at the pinned version (ADR 0023, #578).
|
|
100
|
+
* @type {Readonly<NamedAssertion>}
|
|
101
|
+
*/
|
|
102
|
+
const ANTIGRAVITY_PLAIN_HTTP = Object.freeze({
|
|
103
|
+
name: "antigravity-plain-http-base-url",
|
|
104
|
+
check({ requests, transcript, launcherOutput }) {
|
|
105
|
+
if (requests.length > 0) return null;
|
|
106
|
+
const said = `${transcript ?? ""}\n${launcherOutput}`
|
|
107
|
+
.split("\n")
|
|
108
|
+
.find((line) => PLAIN_HTTP_REFUSED.test(line));
|
|
109
|
+
return said === undefined
|
|
110
|
+
? "no request of Antigravity CLI's reached the model API, so the plain-HTTP base URL is not shown accepted: read the agent step's output."
|
|
111
|
+
: `Antigravity CLI ${antigravity().identity.version} refused the plain-HTTP base URL of the model proxy (ADR 0023), so it needs an in-sandbox loopback forwarder before this pin ships. It said: ${said.trim()}`;
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* What the suite knows for one scenario: its harness's entry, with its
|
|
117
|
+
* provider's own over it.
|
|
118
|
+
* @param {{ harness: string, profile?: string }} scenario
|
|
119
|
+
* @returns {Readonly<LiveHarness>}
|
|
120
|
+
*/
|
|
121
|
+
export function liveFor({ harness, profile }) {
|
|
122
|
+
const entry = LIVE_HARNESSES[harness];
|
|
123
|
+
return profile === undefined ? entry : { ...entry, ...entry.profiles[profile] };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** @type {Readonly<Record<string, Readonly<LiveHarness>>>} */
|
|
127
|
+
export const LIVE_HARNESSES = Object.freeze({
|
|
128
|
+
"claude-code": Object.freeze({
|
|
129
|
+
adapter: claudeCode,
|
|
130
|
+
dialect: anthropicDialect,
|
|
131
|
+
credential: (kind) => FAKE_CREDENTIAL[kind](),
|
|
132
|
+
upstreamAuth: (kind, credential) =>
|
|
133
|
+
kind === "api-key" ? ["x-api-key", credential] : ["authorization", `Bearer ${credential}`],
|
|
134
|
+
baseUrlVariable: "ANTHROPIC_BASE_URL",
|
|
135
|
+
removed: removedBy(claudeCode()),
|
|
136
|
+
harmlessVariables: Object.freeze([]),
|
|
137
|
+
configControl: Object.freeze(["settings-", "local-", "mcp-server"]),
|
|
138
|
+
control: ({ url }) => ({
|
|
139
|
+
argv: [
|
|
140
|
+
"claude",
|
|
141
|
+
"--print",
|
|
142
|
+
"--setting-sources",
|
|
143
|
+
"user,project,local",
|
|
144
|
+
"--settings",
|
|
145
|
+
JSON.stringify({ env: { ANTHROPIC_BASE_URL: url } }),
|
|
146
|
+
"--tools",
|
|
147
|
+
TOOLS.join(","),
|
|
148
|
+
"--permission-mode",
|
|
149
|
+
"dontAsk",
|
|
150
|
+
"--no-session-persistence",
|
|
151
|
+
"--max-turns",
|
|
152
|
+
"2",
|
|
153
|
+
],
|
|
154
|
+
stdin: DONE,
|
|
155
|
+
}),
|
|
156
|
+
}),
|
|
157
|
+
codex: Object.freeze({
|
|
158
|
+
adapter: codex,
|
|
159
|
+
dialect: openaiDialect,
|
|
160
|
+
credential: () => `sk-proj-${canary()}`,
|
|
161
|
+
upstreamAuth: (_kind, credential) => ["authorization", `Bearer ${credential}`],
|
|
162
|
+
baseUrlVariable: "OPENAI_BASE_URL",
|
|
163
|
+
removed: removedBy(codex()),
|
|
164
|
+
// Codex CLI names `cat` as its shell's pager, GitHub's CLI's among them.
|
|
165
|
+
harmlessVariables: Object.freeze(["GH_PAGER=cat"]),
|
|
166
|
+
configControl: Object.freeze(["codex-hook-", "codex-mcp-server"]),
|
|
167
|
+
// The removed config is put back, the project marked trusted, hooks
|
|
168
|
+
// turned on and their trust check skipped, in the Launcher's own config.
|
|
169
|
+
control({ plan }) {
|
|
170
|
+
const planted = Object.entries(plantedConfig()).filter(([path]) =>
|
|
171
|
+
path.startsWith(".codex/"),
|
|
172
|
+
);
|
|
173
|
+
const [config] = plan.launch.files;
|
|
174
|
+
const loading = config.text
|
|
175
|
+
.replace('trust_level = "untrusted"', 'trust_level = "trusted"')
|
|
176
|
+
.replace("\nhooks = false\n", "\nhooks = true\n");
|
|
177
|
+
const argv = [...plan.launch.argv.slice(0, -1), "--dangerously-bypass-hook-trust", "-"];
|
|
178
|
+
const script = [
|
|
179
|
+
"set -eu",
|
|
180
|
+
"mkdir -p /workspace/.codex",
|
|
181
|
+
...planted.map(
|
|
182
|
+
([path, text]) => `printf '%s' ${quote(text)} > ${quote(`/workspace/${path}`)}`,
|
|
183
|
+
),
|
|
184
|
+
`printf '%s' ${quote(loading)} > ${quote(config.path)}`,
|
|
185
|
+
`exec ${argv.map(quote).join(" ")}`,
|
|
186
|
+
].join("\n");
|
|
187
|
+
return { argv: ["sh", "-c", script], stdin: DONE };
|
|
188
|
+
},
|
|
189
|
+
}),
|
|
190
|
+
gemini: Object.freeze({
|
|
191
|
+
adapter: gemini,
|
|
192
|
+
dialect: geminiApiDialect,
|
|
193
|
+
credential: () => `AIza-${canary()}`,
|
|
194
|
+
upstreamAuth: (_kind, credential) => ["x-goog-api-key", credential],
|
|
195
|
+
baseUrlVariable: "GOOGLE_GEMINI_BASE_URL",
|
|
196
|
+
removed: removedBy(gemini()),
|
|
197
|
+
// Gemini CLI tells GitHub's CLI in its shell not to prompt.
|
|
198
|
+
harmlessVariables: Object.freeze(["GH_PROMPT_DISABLED=1"]),
|
|
199
|
+
configControl: Object.freeze(["gemini-hook-", "gemini-mcp-server"]),
|
|
200
|
+
assertions: Object.freeze([PLAIN_HTTP]),
|
|
201
|
+
// The removed config is put back, hooks turned on and the checkout's
|
|
202
|
+
// `.env` read in the Launcher's own settings, the image's system settings
|
|
203
|
+
// left unread, and no limit on which MCP server may start.
|
|
204
|
+
control({ plan }) {
|
|
205
|
+
const planted = [
|
|
206
|
+
...Object.entries(plantedConfig()).filter(([path]) => path.startsWith(".gemini/")),
|
|
207
|
+
...Object.entries(plantedEnvFiles()),
|
|
208
|
+
];
|
|
209
|
+
const [config] = plan.launch.files;
|
|
210
|
+
const loading = JSON.stringify(
|
|
211
|
+
{
|
|
212
|
+
...JSON.parse(config.text),
|
|
213
|
+
hooksConfig: { enabled: true },
|
|
214
|
+
advanced: { ignoreLocalEnv: false },
|
|
215
|
+
},
|
|
216
|
+
null,
|
|
217
|
+
2,
|
|
218
|
+
);
|
|
219
|
+
const argv = [...plan.launch.argv];
|
|
220
|
+
argv.splice(argv.indexOf("--allowed-mcp-server-names"), 2);
|
|
221
|
+
const script = [
|
|
222
|
+
"set -eu",
|
|
223
|
+
"mkdir -p /workspace/.gemini",
|
|
224
|
+
...planted.map(
|
|
225
|
+
([path, text]) => `printf '%s' ${quote(text)} > ${quote(`/workspace/${path}`)}`,
|
|
226
|
+
),
|
|
227
|
+
`printf '%s' ${quote(loading)} > ${quote(config.path)}`,
|
|
228
|
+
"export GEMINI_CLI_SYSTEM_SETTINGS_PATH=/tmp/agent-kit-no-system-settings.json",
|
|
229
|
+
`exec ${argv.map(quote).join(" ")}`,
|
|
230
|
+
].join("\n");
|
|
231
|
+
return { argv: ["sh", "-c", script], stdin: DONE };
|
|
232
|
+
},
|
|
233
|
+
}),
|
|
234
|
+
antigravity: Object.freeze({
|
|
235
|
+
adapter: antigravity,
|
|
236
|
+
dialect: geminiApiDialect,
|
|
237
|
+
credential: () => `AIza-${canary()}`,
|
|
238
|
+
upstreamAuth: (_kind, credential) => ["x-goog-api-key", credential],
|
|
239
|
+
baseUrlVariable: "GOOGLE_GEMINI_BASE_URL",
|
|
240
|
+
removed: removedBy(antigravity()),
|
|
241
|
+
harmlessVariables: Object.freeze([]),
|
|
242
|
+
configControl: Object.freeze(["agy-hook-", "agy-mcp-server"]),
|
|
243
|
+
assertions: Object.freeze([ANTIGRAVITY_PLAIN_HTTP]),
|
|
244
|
+
// The removed config is put back: Antigravity CLI loads it from the
|
|
245
|
+
// working directory with no trust asked, so the Launcher's own launch is
|
|
246
|
+
// the one that loads it.
|
|
247
|
+
control({ plan }) {
|
|
248
|
+
const planted = Object.entries(plantedConfig()).filter(([path]) =>
|
|
249
|
+
/^[._]agents?\//.test(path),
|
|
250
|
+
);
|
|
251
|
+
const script = [
|
|
252
|
+
"set -eu",
|
|
253
|
+
...planted.flatMap(([path, text]) => [
|
|
254
|
+
`mkdir -p ${quote(`/workspace/${path.slice(0, path.lastIndexOf("/"))}`)}`,
|
|
255
|
+
`printf '%s' ${quote(text)} > ${quote(`/workspace/${path}`)}`,
|
|
256
|
+
]),
|
|
257
|
+
`exec ${plan.launch.argv.map(quote).join(" ")}`,
|
|
258
|
+
].join("\n");
|
|
259
|
+
return { argv: ["sh", "-c", script], stdin: DONE };
|
|
260
|
+
},
|
|
261
|
+
}),
|
|
262
|
+
opencode: liveOpencode,
|
|
263
|
+
});
|
|
@@ -44,7 +44,7 @@ export const FAKE_CREDENTIAL = Object.freeze({
|
|
|
44
44
|
/** A shell command that leaves the marker `name`, for a planted config to run. */
|
|
45
45
|
const mark = (name) => `mkdir -p ${MARKER_DIR} && touch ${MARKER_DIR}/${name}`;
|
|
46
46
|
|
|
47
|
-
/** Claude Code
|
|
47
|
+
/** Hooks, in the shape Claude Code and Codex CLI share, that each leave a marker, prefixed `from`. */
|
|
48
48
|
const hooks = (from) =>
|
|
49
49
|
Object.fromEntries(
|
|
50
50
|
["SessionStart", "UserPromptSubmit", "PreToolUse", "Stop"].map((event) => [
|
|
@@ -53,6 +53,31 @@ const hooks = (from) =>
|
|
|
53
53
|
]),
|
|
54
54
|
);
|
|
55
55
|
|
|
56
|
+
/** Hooks in Gemini CLI's own events, each leaving a marker. */
|
|
57
|
+
const geminiHooks = () =>
|
|
58
|
+
Object.fromEntries(
|
|
59
|
+
["SessionStart", "BeforeAgent", "BeforeTool", "AfterAgent"].map((event) => [
|
|
60
|
+
event,
|
|
61
|
+
[{ hooks: [{ type: "command", command: mark(`gemini-hook-${event}`) }] }],
|
|
62
|
+
]),
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Hooks in Antigravity CLI's shape, one folder's, each leaving a marker: a
|
|
67
|
+
* named hook with its events' commands.
|
|
68
|
+
*/
|
|
69
|
+
const antigravityHooks = (folder) => ({
|
|
70
|
+
planted: Object.fromEntries(
|
|
71
|
+
["SessionStart", "PreInvocation"].map((event) => [
|
|
72
|
+
event,
|
|
73
|
+
[{ type: "command", command: mark(`agy-hook-${folder}-${event}`) }],
|
|
74
|
+
]),
|
|
75
|
+
),
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
/** The folders of a checkout Antigravity CLI loads config from, beside `.gemini/`. */
|
|
79
|
+
const ANTIGRAVITY_FOLDERS = [".agents", ".agent", "_agents", "_agent"];
|
|
80
|
+
|
|
56
81
|
/**
|
|
57
82
|
* The executable harness config planted in the checkout, by path: each entry
|
|
58
83
|
* runs a command, or sets a variable, if the harness loads it.
|
|
@@ -69,9 +94,71 @@ export function plantedConfig() {
|
|
|
69
94
|
".mcp.json": JSON.stringify({
|
|
70
95
|
mcpServers: { planted: { command: "sh", args: ["-c", mark("mcp-server")] } },
|
|
71
96
|
}),
|
|
97
|
+
// Codex CLI's own: what it loads from a project it trusts.
|
|
98
|
+
".codex/config.toml": [
|
|
99
|
+
"[shell_environment_policy]",
|
|
100
|
+
`set = { ${PLANTED_ENV} = "1" }`,
|
|
101
|
+
"",
|
|
102
|
+
"[mcp_servers.planted]",
|
|
103
|
+
'command = "sh"',
|
|
104
|
+
`args = ["-c", ${JSON.stringify(mark("codex-mcp-server"))}]`,
|
|
105
|
+
"",
|
|
106
|
+
].join("\n"),
|
|
107
|
+
".codex/hooks.json": JSON.stringify({ hooks: hooks("codex-hook") }),
|
|
108
|
+
".agents/plugins/marketplace.json": JSON.stringify({ name: "planted", plugins: [] }),
|
|
109
|
+
".agents/skills/planted/SKILL.md":
|
|
110
|
+
"---\nname: planted\ndescription: A planted skill.\n---\n\nNothing here is real.\n",
|
|
111
|
+
// Antigravity CLI's own: hooks and MCP servers, from each of its folders,
|
|
112
|
+
// with no trust asked.
|
|
113
|
+
...Object.fromEntries(
|
|
114
|
+
ANTIGRAVITY_FOLDERS.flatMap((folder) => [
|
|
115
|
+
[`${folder}/hooks.json`, JSON.stringify(antigravityHooks(folder))],
|
|
116
|
+
[
|
|
117
|
+
`${folder}/mcp_config.json`,
|
|
118
|
+
JSON.stringify({
|
|
119
|
+
mcpServers: {
|
|
120
|
+
planted: { command: "sh", args: ["-c", mark(`agy-mcp-server-${folder}`)] },
|
|
121
|
+
},
|
|
122
|
+
}),
|
|
123
|
+
],
|
|
124
|
+
]),
|
|
125
|
+
),
|
|
126
|
+
// opencode's own: its project config, at the root and in `.opencode/`.
|
|
127
|
+
...Object.fromEntries(
|
|
128
|
+
[
|
|
129
|
+
["opencode.json", "opencode-mcp-server"],
|
|
130
|
+
["opencode.jsonc", "opencode-mcp-server-jsonc"],
|
|
131
|
+
[".opencode/opencode.json", "opencode-dir-mcp-server"],
|
|
132
|
+
].map(([path, name]) => [
|
|
133
|
+
path,
|
|
134
|
+
JSON.stringify({
|
|
135
|
+
mcp: {
|
|
136
|
+
servers: {
|
|
137
|
+
[name]: { type: "local", command: ["sh", "-c", mark(name)] },
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
}),
|
|
141
|
+
]),
|
|
142
|
+
),
|
|
143
|
+
// Gemini CLI's own: what it loads from a folder it trusts. A checkout can
|
|
144
|
+
// also turn a system hook off by name, since those lists merge.
|
|
145
|
+
".gemini/settings.json": JSON.stringify({
|
|
146
|
+
hooks: geminiHooks(),
|
|
147
|
+
hooksConfig: { disabled: ["planted-system-hook"] },
|
|
148
|
+
mcpServers: { planted: { command: "sh", args: ["-c", mark("gemini-mcp-server")] } },
|
|
149
|
+
}),
|
|
72
150
|
};
|
|
73
151
|
}
|
|
74
152
|
|
|
153
|
+
/**
|
|
154
|
+
* Environment files that set a variable if the harness loads them, by path.
|
|
155
|
+
* Apart from the rest of the planted config: a Deep scan refuses a repository
|
|
156
|
+
* with a committed `.env` before anything runs.
|
|
157
|
+
*/
|
|
158
|
+
export function plantedEnvFiles() {
|
|
159
|
+
return { ".env": `${PLANTED_ENV}=1\n`, ".gemini/.env": `${PLANTED_ENV}=1\n` };
|
|
160
|
+
}
|
|
161
|
+
|
|
75
162
|
/** The fixture repository's own files: what a Deep scan reads at the trusted ref. */
|
|
76
163
|
function fixtureFiles(control) {
|
|
77
164
|
const note = "A fixture for the live suite; nothing here is real.\n";
|
|
@@ -105,16 +192,38 @@ function fixtureFiles(control) {
|
|
|
105
192
|
* copy-in carries), canary files in the temporary and home folders, and
|
|
106
193
|
* canaries in the runner's GitHub variables. The launcher's own canary is on
|
|
107
194
|
* its process's command line, where the workflow puts it.
|
|
108
|
-
* @param {{ runner: import("../exec.mjs").Runner, launcherCanary: string
|
|
195
|
+
* @param {{ runner: import("../exec.mjs").Runner, launcherCanary: string, envFiles?: boolean,
|
|
196
|
+
* committed?: Record<string, string>, configPaths?: readonly string[] }} opts
|
|
197
|
+
* `envFiles` commits the planted environment files too. `committed` are files
|
|
198
|
+
* more to commit on `main`. Each of `configPaths`, a harness's checkout
|
|
199
|
+
* config, is planted unless a planted file already sits at it or under it,
|
|
200
|
+
* so its removal is seen.
|
|
109
201
|
*/
|
|
110
|
-
export function plant({
|
|
202
|
+
export function plant({
|
|
203
|
+
runner,
|
|
204
|
+
launcherCanary,
|
|
205
|
+
envFiles = false,
|
|
206
|
+
committed = {},
|
|
207
|
+
configPaths = [],
|
|
208
|
+
}) {
|
|
111
209
|
const root = mkdtempSync(join(tmpdir(), "agent-kit-live-repo-"));
|
|
112
210
|
const control = `AKCONTROL-${id()}`;
|
|
113
211
|
const write = (path, text) => {
|
|
114
212
|
mkdirSync(dirname(path), { recursive: true });
|
|
115
213
|
writeFileSync(path, text);
|
|
116
214
|
};
|
|
117
|
-
|
|
215
|
+
const files = {
|
|
216
|
+
...fixtureFiles(control),
|
|
217
|
+
...(envFiles ? plantedEnvFiles() : {}),
|
|
218
|
+
...committed,
|
|
219
|
+
};
|
|
220
|
+
const overlaps = (a, b) => a === b || a.startsWith(`${b}/`) || b.startsWith(`${a}/`);
|
|
221
|
+
for (const path of configPaths) {
|
|
222
|
+
if (!Object.keys(files).some((file) => overlaps(file, path))) {
|
|
223
|
+
files[path] = "# Planted by the live suite: the checkout's harness config.\n";
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
for (const [path, text] of Object.entries(files)) write(join(root, path), text);
|
|
118
227
|
const git = (...args) => {
|
|
119
228
|
const r = runner("git", [
|
|
120
229
|
"-C",
|