@mnaimfaizy/agent-kit 1.0.0-beta.12 → 1.0.0-beta.14

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.
@@ -1,378 +1,48 @@
1
- // The scan phase's only route out (#370): a key-injecting reverse proxy that
2
- // runs in the launcher, on the host, outside the sandbox. The sandboxed
3
- // Claude Code holds only a placeholder key and reaches the model API through
4
- // this proxy, which forwards only to the model API, strips the placeholder
5
- // (`x-api-key`, `Authorization`) and inserts the real credential: as
6
- // `x-api-key` for an API key, or, on the subscription path (#375), as the
7
- // bearer value of `Authorization` and nothing else, so every other header
8
- // Claude Code sends (its OAuth beta header among them) passes on as it is
9
- // and need not be known here. The
10
- // credential lives only in this process's memory: it is never an argument,
11
- // an environment variable or a file of any command the launcher runs.
12
- // Node core only (ADR 0001).
13
- //
14
- // It also holds the run's token cap (#371): it counts the `usage` each
15
- // model API answer returns, and once the count reaches the cap it refuses
16
- // every further request and tells the launcher, which stops the agent step.
17
- // From the same answers it reads the `model` each one names, so the launcher
18
- // can say which model the API answered with, not only which was asked for.
19
-
20
- import { createServer, request as httpRequest } from "node:http";
21
- import { request as httpsRequest } from "node:https";
22
- import { createBrotliDecompress, createGunzip, createInflate } from "node:zlib";
23
-
24
- /** The model API every forwarded request goes to. */
25
- export const MODEL_API = "https://api.anthropic.com";
26
-
27
- /** Only the Messages API's paths are forwarded. */
28
- const MODEL_PATH = /^\/v1\//;
29
-
30
- /**
31
- * Paths whose spend an answer's `usage` would not show (a batch is billed
32
- * later, outside this run), so the token cap could not hold: refused.
33
- */
34
- const UNCOUNTED_PATH = /^\/v1\/(messages\/batches|complete)(\/|$)/i;
35
-
36
- /** The `usage` fields the cap counts: every kind of token billed. */
37
- export const COUNTED_USAGE = Object.freeze([
38
- "input_tokens",
39
- "cache_creation_input_tokens",
40
- "cache_read_input_tokens",
41
- "output_tokens",
42
- ]);
43
-
44
- /** How much of an answer the meter reads: a line of a stream, or a whole JSON body. */
45
- const MAX_LINE = 1024 * 1024;
46
- const MAX_BODY = 16 * 1024 * 1024;
47
-
48
- /**
49
- * A model id as Claude Code's --model takes it, and nothing more: the
50
- * launcher's check of --model, which goes into the agent step's command
51
- * line (so no space, quote or leading dash; the same pattern as the static
52
- * workflow's model input), and the only form of an answer's `model` the
53
- * summary names, so an answer cannot write a line of its own.
54
- */
55
- export const MODEL_ID = /^[A-Za-z0-9][A-Za-z0-9._:@/[\]-]*$/;
56
-
57
- /** How many distinct refused hosts, paths or answered models the summary keeps, and how long each. */
58
- const MAX_KEPT = 5;
59
- const MAX_ENTRY = 80;
60
-
61
- // Hop-by-hop headers (RFC 9110 7.6.1), the client's credentials, and the
62
- // Host, which is the model API's own.
63
- const DROPPED = new Set([
64
- "x-api-key",
65
- "authorization",
66
- "proxy-authorization",
67
- "proxy-authenticate",
68
- "proxy-connection",
69
- "connection",
70
- "keep-alive",
71
- "te",
72
- "trailer",
73
- "transfer-encoding",
74
- "upgrade",
75
- "host",
76
- "cookie",
77
- ]);
1
+ // The scan phase's only route out (#370): the model proxy's core
2
+ // (../model-proxy/core.mjs), which runs in the launcher, on the host, outside
3
+ // the sandbox, with the `anthropic` provider profile (ADR 0023). The core's
4
+ // header says what is forwarded and how the run's token cap (#371) holds; the
5
+ // profile's says what of the Messages API passes, and how the real credential
6
+ // goes in. Node core only (ADR 0001).
7
+
8
+ import { startProxy } from "../model-proxy/core.mjs";
9
+ import { anthropic } from "../model-proxy/profiles/anthropic.mjs";
10
+
11
+ export { MAX_IN_FLIGHT, MODEL_ID } from "../model-proxy/core.mjs";
12
+ export {
13
+ COUNTED_USAGE,
14
+ FORWARDED,
15
+ MAX_REQUEST,
16
+ MODEL_API,
17
+ requestRefusal,
18
+ } from "../model-proxy/profiles/anthropic.mjs";
78
19
 
79
20
  /**
80
- * Start the proxy on `bind` (an address the relay reaches, never all
81
- * interfaces; on Docker Sandboxes, 127.0.0.1, which its policy lets the
82
- * sandbox reach). `refused` collects every host or path it turned away.
83
- * With `maxTokens`, the first request once the counted tokens reach it is
84
- * refused, as is every one after, and `onCap` is called once. The answer
85
- * that crosses the cap is delivered: a request in flight is never cut.
86
- * @param {{ credential: string, kind?: "api-key" | "subscription", bind: string, upstream?: string, maxTokens?: number, onCap?: () => void }} opts
21
+ * Start the Deep scan's model proxy on `bind`. See startProxy in the core for
22
+ * every option and for what it returns.
23
+ * @param {{ credential: string, kind?: "api-key" | "subscription", bind: string, upstream?: string, maxTokens?: number, onCap?: () => void, callerKey?: string }} opts
87
24
  * `kind` is the credential's (default an API key). `upstream` is the
88
- * model API; only tests pass another.
89
- * @returns {Promise<{ port: number, refused: string[], tokens: () => number, models: () => string[], credentialRefused: () => boolean, summary: () => string, close: () => Promise<void> }>}
90
- * `models` is each distinct model id the answers named, in the order first
91
- * seen, at most MAX_KEPT of them, and only plain ids of MAX_ENTRY or fewer.
92
- * `credentialRefused` is true when at least one request was forwarded and
93
- * the model API answered every one with 401 or 403: it refused the
94
- * credential (a request that got no answer, or still waits for one, is not
95
- * a refusal). The proxy's own refusals (a path, a host, the cap) are not
96
- * answers of the model API, so they never count.
25
+ * model API; only tests pass another. `callerKey`, when given, is the
26
+ * only value accepted as the caller's `x-api-key` or `Authorization`
27
+ * bearer value; the launcher always gives one.
97
28
  */
98
29
  export async function startModelProxy({
99
30
  credential,
100
31
  kind = "api-key",
101
32
  bind,
102
- upstream = MODEL_API,
33
+ upstream,
103
34
  maxTokens,
104
- onCap = () => {},
35
+ onCap,
36
+ callerKey,
105
37
  }) {
106
- if (kind !== "api-key" && kind !== "subscription") {
107
- throw new Error(`the model proxy has no credential kind ${JSON.stringify(kind)}`);
108
- }
109
- // The one header the proxy writes: the sandbox's x-api-key and
110
- // Authorization are always dropped, so the placeholder never passes on.
111
- const auth =
112
- kind === "subscription" ? ["authorization", `Bearer ${credential}`] : ["x-api-key", credential];
113
- const target = new URL(upstream);
114
- const send = target.protocol === "https:" ? httpsRequest : httpRequest;
115
- const refused = [];
116
- let refusedCount = 0;
117
- // What the sandbox sends is untrusted: keep a few short entries, and a count.
118
- const refuse = (what) => {
119
- refusedCount += 1;
120
- const entry = what.slice(0, MAX_ENTRY);
121
- if (refused.length < MAX_KEPT && !refused.includes(entry)) refused.push(entry);
122
- };
123
- /** @type {Map<string, number>} upstream status (or "error") to count */
124
- const statuses = new Map();
125
- let forwarded = 0;
126
- let tokens = 0;
127
- /** @type {string[]} */
128
- const models = [];
129
- let moreModels = false;
130
- // What an answer names is kept only as a plain, short id.
131
- const answeredBy = (model) => {
132
- if (typeof model !== "string" || model.length > MAX_ENTRY || !MODEL_ID.test(model)) return;
133
- if (models.includes(model)) return;
134
- if (models.length < MAX_KEPT) models.push(model);
135
- else moreModels = true;
136
- };
137
- let pastCap = 0;
138
- const sockets = new Set();
139
- const count = (key) => statuses.set(key, (statuses.get(key) ?? 0) + 1);
140
-
141
- const server = createServer((req, res) => {
142
- const raw = req.url ?? "";
143
- if (!raw.startsWith("/")) {
144
- // An absolute URL: someone is using the proxy as a forward proxy.
145
- let host = raw;
146
- try {
147
- host = new URL(raw).host;
148
- } catch {
149
- host = raw;
150
- }
151
- refuse(host);
152
- res.writeHead(403).end("deep-scan model proxy: only the model API is reachable\n");
153
- return;
154
- }
155
- const path = raw.split("?")[0];
156
- // The checks run on the path as the API would route it, percent-decoded,
157
- // so `/v1/%6dessages/batches` is the batch path it names. A path that
158
- // does not decode, or still holds a `%` once decoded (encoded twice), is
159
- // refused. No dot segment, plain or encoded, may walk it out of /v1/.
160
- let decoded = null;
161
- try {
162
- decoded = decodeURIComponent(path);
163
- } catch {
164
- decoded = null;
165
- }
166
- if (
167
- decoded === null ||
168
- decoded.includes("%") ||
169
- !MODEL_PATH.test(path) ||
170
- !MODEL_PATH.test(decoded) ||
171
- UNCOUNTED_PATH.test(decoded) ||
172
- // An empty segment (`/v1//messages/batches`): a front end that merges
173
- // slashes would route it past the uncounted-path check.
174
- /\/\/|\/$/.test(decoded) ||
175
- /(^|\/)\.{1,2}(\/|$)|\\/.test(decoded) ||
176
- /(^|\/)(\.|%2e){1,2}(\/|$)|%2f|\\/i.test(path)
177
- ) {
178
- refuse(path);
179
- res.writeHead(403).end("deep-scan model proxy: only the model API's /v1/ paths\n");
180
- return;
181
- }
182
- if (maxTokens !== undefined && tokens >= maxTokens) {
183
- pastCap += 1;
184
- if (pastCap === 1) onCap();
185
- res.writeHead(403, { "content-type": "application/json" }).end(
186
- JSON.stringify({
187
- type: "error",
188
- error: {
189
- type: "permission_error",
190
- message: `deep-scan model proxy: this run's token cap (${maxTokens}) is reached`,
191
- },
192
- }),
193
- );
194
- return;
195
- }
196
- const headers = {};
197
- for (const [name, value] of Object.entries(req.headers)) {
198
- if (!DROPPED.has(name.toLowerCase()) && value !== undefined) headers[name] = value;
199
- }
200
- headers[auth[0]] = auth[1];
201
- // A plain body, so the meter can read its usage.
202
- headers["accept-encoding"] = "identity";
203
- forwarded += 1;
204
- const upstreamReq = send(
205
- {
206
- protocol: target.protocol,
207
- hostname: target.hostname,
208
- port: target.port || undefined,
209
- method: req.method,
210
- path: raw,
211
- headers,
212
- },
213
- (r) => {
214
- count(String(r.statusCode ?? "error"));
215
- const back = {};
216
- for (const [name, value] of Object.entries(r.headers)) {
217
- if (!DROPPED.has(name.toLowerCase()) && value !== undefined) back[name] = value;
218
- }
219
- res.writeHead(r.statusCode ?? 502, back);
220
- meter(
221
- r,
222
- (n) => {
223
- tokens += n;
224
- },
225
- answeredBy,
226
- );
227
- r.pipe(res);
228
- },
229
- );
230
- upstreamReq.on("error", () => {
231
- count("error");
232
- if (!res.headersSent) {
233
- res.writeHead(502).end("deep-scan model proxy: the model API could not be reached\n");
234
- } else {
235
- res.destroy();
236
- }
237
- });
238
- req.pipe(upstreamReq);
239
- });
240
-
241
- // A CONNECT tunnel would reach any host: refused.
242
- server.on("connect", (req, socket) => {
243
- socket.on("error", () => {});
244
- refuse(req.url ?? "");
245
- socket.end("HTTP/1.1 403 Forbidden\r\n\r\n");
246
- });
247
- server.on("connection", (socket) => {
248
- sockets.add(socket);
249
- socket.on("close", () => sockets.delete(socket));
250
- });
251
-
252
- await new Promise((resolve, reject) => {
253
- server.once("error", reject);
254
- server.listen(0, bind, () => resolve(undefined));
255
- });
256
- const address = server.address();
257
- return {
258
- port: typeof address === "object" && address ? address.port : 0,
259
- refused,
260
- tokens: () => tokens,
261
- models: () => [...models],
262
- // Every forwarded request answered, and each answer a 401 or 403.
263
- credentialRefused: () =>
264
- forwarded > 0 &&
265
- [...statuses].reduce(
266
- (sum, [status, n]) => (status === "401" || status === "403" ? sum + n : sum),
267
- 0,
268
- ) === forwarded,
269
- summary() {
270
- const byStatus = [...statuses].map(([s, n]) => `${s} x${n}`).join(", ");
271
- const parts = [
272
- `forwarded ${forwarded} request(s) to ${target.host}${byStatus ? ` (answers: ${byStatus})` : ""}`,
273
- ];
274
- if (forwarded) {
275
- parts.push(
276
- models.length
277
- ? `the model API answered with ${models.join(", ")}${moreModels ? ", ..." : ""}`
278
- : "no answer named a model",
279
- );
280
- }
281
- if (refusedCount) {
282
- const more = refusedCount > refused.length ? ", ..." : "";
283
- parts.push(`refused ${refusedCount} (${refused.join(", ")}${more})`);
284
- }
285
- if (maxTokens !== undefined) {
286
- parts.push(
287
- `counted ${tokens} of the ${maxTokens}-token cap${pastCap ? `, and refused ${pastCap} request(s) past it` : ""}`,
288
- );
289
- }
290
- return parts.join("; ");
291
- },
292
- close: () =>
293
- new Promise((resolve) => {
294
- for (const s of sockets) s.destroy();
295
- server.close(() => resolve(undefined));
296
- }),
297
- };
298
- }
299
-
300
- /**
301
- * Count the tokens an answer's `usage` reports, as the answer streams past:
302
- * each kind in COUNTED_USAGE, from a JSON body or from a stream's
303
- * `message_start` and `message_delta` events. A stream's usage is
304
- * cumulative, so each kind counts its highest value once. A compressed body
305
- * (sent although the proxy asked for none) is decoded for counting only.
306
- * The `model` the answer names (a JSON body's, or a stream's
307
- * `message_start`'s) goes to `named`, unchecked.
308
- * @param {import("node:http").IncomingMessage} r
309
- * @param {(n: number) => void} add called with each newly counted amount
310
- * @param {(model: unknown) => void} named called with each `model` an answer names
311
- */
312
- function meter(r, add, named) {
313
- const seen = Object.fromEntries(COUNTED_USAGE.map((k) => [k, 0]));
314
- const take = (obj) => {
315
- const model = obj?.model ?? obj?.message?.model;
316
- if (model !== undefined) named(model);
317
- const usage = obj?.usage ?? obj?.message?.usage;
318
- if (!usage || typeof usage !== "object") return;
319
- for (const key of COUNTED_USAGE) {
320
- const n = usage[key];
321
- if (typeof n === "number" && Number.isFinite(n) && n > seen[key]) {
322
- add(n - seen[key]);
323
- seen[key] = n;
324
- }
325
- }
326
- };
327
- const parse = (text) => {
328
- try {
329
- take(JSON.parse(text));
330
- } catch {
331
- // Not JSON: nothing to count.
332
- }
333
- };
334
- const stream = /text\/event-stream/i.test(String(r.headers["content-type"] ?? ""));
335
- const decoders = {
336
- gzip: createGunzip,
337
- "x-gzip": createGunzip,
338
- deflate: createInflate,
339
- br: createBrotliDecompress,
340
- };
341
- const encoding = String(r.headers["content-encoding"] ?? "identity")
342
- .trim()
343
- .toLowerCase();
344
- /** @type {import("node:stream").Readable} */
345
- let body = r;
346
- if (encoding !== "identity" && encoding !== "") {
347
- const make = decoders[encoding];
348
- if (!make) return;
349
- const decoder = make();
350
- decoder.on("error", () => {});
351
- r.on("data", (chunk) => decoder.write(chunk));
352
- r.on("end", () => decoder.end());
353
- body = decoder;
354
- }
355
- let pending = "";
356
- let size = 0;
357
- let overflow = false;
358
- body.on("data", (chunk) => {
359
- const text = chunk.toString("utf8");
360
- if (!stream) {
361
- size += text.length;
362
- if (size > MAX_BODY) overflow = true;
363
- if (!overflow) pending += text;
364
- return;
365
- }
366
- pending += text;
367
- const lines = pending.split(/\r?\n/);
368
- pending = lines.pop() ?? "";
369
- if (pending.length > MAX_LINE) pending = "";
370
- for (const line of lines) {
371
- if (line.startsWith("data:") && /"(usage|model)"/.test(line)) parse(line.slice(5).trim());
372
- }
373
- });
374
- body.on("end", () => {
375
- if (!stream && !overflow) parse(pending);
376
- else if (stream && pending.startsWith("data:")) parse(pending.slice(5).trim());
38
+ return startProxy(anthropic, {
39
+ credential,
40
+ kind,
41
+ bind,
42
+ upstream,
43
+ maxTokens,
44
+ onCap,
45
+ callerKey,
46
+ name: "deep-scan model proxy",
377
47
  });
378
48
  }
@@ -1,9 +1,76 @@
1
1
  // The Deep scan launcher's pre-flight refusals (#368): before any sandbox
2
2
  // runtime is touched, refuse a GitHub token that would reach the sandbox and
3
3
  // a .env that would be forwarded into it wholesale. Both checks read only the
4
- // launcher's own environment and the trusted ref's file list.
4
+ // launcher's own environment and the trusted ref's file list. A third
5
+ // refusal comes with the image, the first thing that can show it, and still
6
+ // before any sandbox: a musl recipe image, which cannot run the Harness
7
+ // image's glibc builds (ADR 0029). Before all of them, the Support Level
8
+ // (ADR 0028): a Deep scan runs on a pair below `tried` only as a Proving run.
5
9
 
10
+ import { appendFileSync } from "node:fs";
6
11
  import { firstLine } from "../exec.mjs";
12
+ import { readHarnesses, supportFor } from "../harness/facts.mjs";
13
+ import { MUSL_MARKER } from "../harness/install-layer.mjs";
14
+ import { ENDS_HERE, outputLines, StepFailed } from "./steps.mjs";
15
+
16
+ /**
17
+ * Throw the musl refusal when the layer build `r` failed on the musl check.
18
+ * @param {import("../exec.mjs").StartResult} r
19
+ * @param {{ image?: string, dockerfile?: string }} steps the recipe's
20
+ */
21
+ export function refuseMusl(r, { image, dockerfile }) {
22
+ if (r.status === 0) return;
23
+ if (!`${r.stdout.toString("utf8")}\n${r.stderr}`.includes(MUSL_MARKER)) return;
24
+ const what =
25
+ dockerfile !== undefined
26
+ ? `The image the recipe's ${dockerfile} builds`
27
+ : `The recipe's image ${image}`;
28
+ throw new StepFailed([
29
+ `REFUSED ${what} is musl Linux (such as Alpine), and the harness runs only on glibc Linux.`,
30
+ ...outputLines(r),
31
+ "Name a glibc image, such as a Debian or Ubuntu one, or leave image and dockerfile out to run on the Harness image.",
32
+ ENDS_HERE,
33
+ ]);
34
+ }
35
+
36
+ /**
37
+ * Whether a Deep scan may run on `harness` at the Support Level
38
+ * `cli/harnesses.json` holds for the pair, and what the run says about it:
39
+ * the line it prints and the line of the GitHub Actions run summary, for a
40
+ * refused run too, then the refusal, or the warning at `documented`. All of
41
+ * it comes from that file and the flag, nothing from the scan, so a public
42
+ * log may hold it.
43
+ * @param {{ harness?: string, provingRun?: boolean }} run
44
+ * @returns {{ line: string, summary: string, refused?: string, warning?: string }}
45
+ */
46
+ export function deepScanSupport({ harness = "claude-code", provingRun = false }) {
47
+ const facts = readHarnesses().harnesses[harness];
48
+ const found = supportFor(facts, { stage: "deep-scan", provingRun });
49
+ const level = facts.supportLevels["deep-scan"]?.level ?? "none";
50
+ const proving = provingRun ? "yes" : "no";
51
+ return {
52
+ line: `Harness: ${harness}; Support Level: ${level}; Proving run: ${proving}`,
53
+ summary: `Harness: \`${harness}\` · Support Level: \`${level}\` · Proving run: ${proving}`,
54
+ ...(found.refused !== undefined ? { refused: found.refused } : {}),
55
+ ...(found.warning !== undefined ? { warning: found.warning } : {}),
56
+ };
57
+ }
58
+
59
+ /**
60
+ * Add `line` to the GitHub Actions run summary, where `env` names one.
61
+ * @param {Record<string, string | undefined>} env
62
+ * @param {string} line
63
+ * @returns {string | null} why it could not be written, or null
64
+ */
65
+ export function writeRunSummary(env, line) {
66
+ if (!env.GITHUB_STEP_SUMMARY) return null;
67
+ try {
68
+ appendFileSync(env.GITHUB_STEP_SUMMARY, `${line}\n`);
69
+ return null;
70
+ } catch (e) {
71
+ return firstLine(e.message);
72
+ }
73
+ }
7
74
 
8
75
  /** The GitHub token variables that must never reach the sandbox. */
9
76
  export const GITHUB_TOKEN_VARS = Object.freeze(["GH_TOKEN", "GITHUB_TOKEN"]);
@@ -7,6 +7,7 @@
7
7
 
8
8
  import { CLI_VERSION } from "../tags.mjs";
9
9
  import { checkSafePath } from "../safe-paths.mjs";
10
+ import { groundingUrlProblem, isGroundingUrl } from "./grounding-url.mjs";
10
11
  import {
11
12
  isMapping,
12
13
  parseScalar,
@@ -92,6 +93,21 @@ export function readRecipeAtRef({ runner, root, ref, path }) {
92
93
  return { found: true, text: blob.stdout, oid };
93
94
  }
94
95
 
96
+ /**
97
+ * A note for a recipe `image` named by tag alone, or null when it carries a
98
+ * `@sha256:` digest. The image is trusted like the recipe, and is pulled and
99
+ * built on the host's Docker, outside the sandbox runtime, so what a tag
100
+ * names should not change between runs unseen. A warning, not a refusal, so
101
+ * existing recipes still run.
102
+ *
103
+ * @param {string} image
104
+ * @returns {string | null}
105
+ */
106
+ export function imageDigestNote(image) {
107
+ if (/@sha256:[0-9a-f]{64}$/.test(String(image))) return null;
108
+ return `Note: the recipe's image ${image} has no @sha256: digest, so what it names can change between runs. Pin it as ${String(image).split("@")[0]}@sha256:<digest>; the image is pulled and built on this machine's Docker, outside the sandbox runtime, and is trusted like the recipe.`;
109
+ }
110
+
95
111
  /**
96
112
  * Every problem with a recipe's text, each one line naming its field. An
97
113
  * empty list means the recipe is valid.
@@ -116,19 +132,15 @@ export function validateRecipe(text) {
116
132
  if (problem) say(key, problem);
117
133
  }
118
134
 
119
- // image or dockerfile, exactly one.
135
+ // image or dockerfile, at most one: without either, the scan runs on the
136
+ // Harness image (ADR 0029).
120
137
  const hasImage = "image" in recipe;
121
138
  const hasDockerfile = "dockerfile" in recipe;
122
- if (!hasImage && !hasDockerfile) {
123
- say(
124
- "image or dockerfile",
125
- "name a base image (image) or a Dockerfile (dockerfile); the recipe has neither.",
126
- );
127
- } else if (hasImage && hasDockerfile) {
139
+ if (hasImage && hasDockerfile) {
128
140
  say("image and dockerfile", "give one of them, not both.");
129
141
  }
130
142
  if (hasImage && !isWord(recipe.image)) {
131
- say("image", "must be one image reference, such as node:22-bookworm.");
143
+ say("image", "must be one image reference, such as node:22-bookworm@sha256:<digest>.");
132
144
  }
133
145
  if (hasDockerfile) {
134
146
  const file = recipe.dockerfile;
@@ -215,6 +227,11 @@ export function validateRecipe(text) {
215
227
  if ("grounding" in recipe) {
216
228
  asList(recipe.grounding, "grounding", say)?.forEach((g, i) => {
217
229
  if (!isWord(g)) say(`grounding[${i}]`, "must be one URL or repository path.");
230
+ else if (isGroundingUrl(g)) {
231
+ // Fetched on the host, so only a public https:// page (see grounding-url.mjs).
232
+ const problem = groundingUrlProblem(g);
233
+ if (problem) say(`grounding[${i}]`, `${problem}.`);
234
+ }
218
235
  });
219
236
  }
220
237