@counterfact-labs/cli 0.2.3 → 0.2.4

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.
Files changed (58) hide show
  1. package/bundle/client-release.json +1 -1
  2. package/dist/adapters/files.js +5 -1
  3. package/dist/adapters/relay-plan.js +2 -2
  4. package/dist/adapters/release.js +8 -3
  5. package/dist/adapters/settings.js +2 -1
  6. package/dist/analysis-core/analysis/finding-quality/config.js +1 -1
  7. package/dist/analysis-core/analysis/finding-quality/policy.js +1 -1
  8. package/dist/analysis-core/analysis/headlines/attachment.js +1 -1
  9. package/dist/analysis-core/analysis/headlines/input.js +1 -1
  10. package/dist/analysis-core/analysis/schemas.js +1 -1
  11. package/dist/analysis-core/chunks/3CKW5JIF.js +1 -0
  12. package/dist/analysis-core/chunks/3GUKUEEJ.js +1 -0
  13. package/dist/analysis-core/chunks/7OYIBWX3.js +1 -0
  14. package/dist/analysis-core/chunks/{Y5AUKKYG.js → D6AWHLRI.js} +1 -1
  15. package/dist/analysis-core/chunks/{G322LST6.js → DRGDIIFA.js} +1 -1
  16. package/dist/analysis-core/chunks/{ZMUBMYWN.js → FTODBFQW.js} +1 -1
  17. package/dist/analysis-core/chunks/{EQTIRIMU.js → HPIAEQHE.js} +25 -25
  18. package/dist/analysis-core/chunks/{YVDCJN7D.js → IVDDV6CU.js} +1 -1
  19. package/dist/analysis-core/chunks/JKWTHRUR.js +1 -0
  20. package/dist/analysis-core/chunks/K5OTWBTT.js +22 -0
  21. package/dist/analysis-core/chunks/{VFENG4MR.js → MJGB25S5.js} +1 -1
  22. package/dist/analysis-core/chunks/{DTMHXKP6.js → MXXNED6N.js} +1 -1
  23. package/dist/analysis-core/chunks/NCWEOJVJ.js +6 -0
  24. package/dist/analysis-core/chunks/{M7MMAUAK.js → O652FQQH.js} +1 -1
  25. package/dist/analysis-core/chunks/{QPXNXMLC.js → QMIXCT62.js} +1 -1
  26. package/dist/analysis-core/chunks/QV2EOS7U.js +1 -0
  27. package/dist/analysis-core/chunks/T2SAP7OV.js +60 -0
  28. package/dist/analysis-core/chunks/{VER355VN.js → T66VDFXF.js} +1 -1
  29. package/dist/analysis-core/chunks/{IL2KRP3T.js → V7BFUTM7.js} +1 -1
  30. package/dist/analysis-core/contracts/requests.js +1 -1
  31. package/dist/analysis-core/conventions/analysis-fit.js +1 -0
  32. package/dist/analysis-core/conventions/file-admission.js +1 -1
  33. package/dist/analysis-core/errors.js +1 -1
  34. package/dist/analysis-core/import/outside-loader-sources.js +1 -1
  35. package/dist/analysis-core/index.js +3 -3
  36. package/dist/analysis-core/llm/cache-policy.js +1 -1
  37. package/dist/analysis-core/llm/cost.js +1 -1
  38. package/dist/analysis-core/requests/local-plan.js +1 -1
  39. package/dist/analysis-core/requests/registry.js +1 -1
  40. package/dist/analysis-core/requests/template-version.js +1 -1
  41. package/dist/analysis-core/requests/tools.js +1 -1
  42. package/dist/analysis-core/settings.js +1 -1
  43. package/dist/bundle/seal/signature.js +2 -2
  44. package/dist/cli/commands/analyze.js +4 -2
  45. package/dist/cli/development-relay.js +34 -0
  46. package/dist/cli/relay-check.js +2 -2
  47. package/dist/cli/relay-preparation.js +3 -1
  48. package/dist/contract/cli-refusals.js +2 -0
  49. package/dist/contract/cli-version.js +1 -1
  50. package/dist/contract/console.js +20 -0
  51. package/dist/gatekeeper/connection-exchange.js +2 -1
  52. package/dist/gatekeeper/console.js +11 -4
  53. package/package.json +2 -2
  54. package/dist/analysis-core/chunks/7QDOHWSY.js +0 -27
  55. package/dist/analysis-core/chunks/BZNHHLNP.js +0 -1
  56. package/dist/analysis-core/chunks/KEKTZDIK.js +0 -1
  57. package/dist/analysis-core/chunks/ORCYIIHB.js +0 -60
  58. package/dist/analysis-core/chunks/PVPEY7NF.js +0 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "verificationKey": "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEAbBab1PYdmBKXxCvoJ47toJhQvxPevo9nlZnb0zbDWoc=\n-----END PUBLIC KEY-----\n",
3
3
  "relayVersion": "relay-1.0.1",
4
- "localVersion": "0.2.3",
4
+ "localVersion": "0.2.4",
5
5
  "relayUrl": "https://relay.counterfactlabs.com:8443",
6
6
  "projectContext": "checks"
7
7
  }
@@ -1,6 +1,7 @@
1
1
  import { opendir, realpath, stat, readFile } from "node:fs/promises";
2
2
  import { dirname, join, posix } from "node:path";
3
3
  import { admitFile, fileRefusalWarning, localSymlinkGuardEnabled, respectGitignore, readRepoFile, resolveLocalExclusions } from "../analysis-core/conventions/file-admission.js";
4
+ import { assessAnalysisSize, measureAnalysisSize } from "../analysis-core/conventions/analysis-fit.js";
4
5
  import { localRepoKeyFor } from "../analysis-core/github/repo-key.js";
5
6
  import { fetchLocalSources } from "../analysis-core/index.js";
6
7
  import { repoPathFrom } from "../analysis-core/import/outside-loader-sources.js";
@@ -117,6 +118,9 @@ export async function readLocalFolder(settings, folder, admission = {}, options
117
118
  await walk(root, "", new Set());
118
119
  else
119
120
  gitSkipped.push(...await ignoredFiles(root, ""));
121
+ const analysisSize = measureAnalysisSize(settings, entries, admission);
122
+ // The service makes the final decision; local prediction never changes retained files.
123
+ const analysisFit = settings.CF_REFUSE_TOO_LARGE === "0" ? undefined : assessAnalysisSize(analysisSize);
120
124
  const listing = new Set(entries.map(entry => entry.path));
121
125
  const repoKey = localRepoKeyFor(root);
122
126
  const repository = createRepositoryFiles(settings, root, admission, options);
@@ -133,7 +137,7 @@ export async function readLocalFolder(settings, folder, admission = {}, options
133
137
  const expanded = discovered.root !== undefined;
134
138
  const ignored = mergeSkippedFiles(expanded ? gitSkipped.map(file => ({ ...file, path: repoPathFrom(file.path, discovered.root) })) : gitSkipped, repository.skippedFiles.map(file => ({ ...file, path: expanded ? file.path : posix.relative(repository.selectedRoot ?? "", file.path) })));
135
139
  const captured = { ...Object.fromEntries(Object.entries(snapshot).map(([path, bytes]) => [repoPathFrom(path, discovered.root), bytes])), ...repository.snapshot };
136
- return { repoKey, files: discovered.files, ...(expanded ? { root: discovered.root, sourceBase: repository.sourceBase } : {}),
140
+ return { repoKey, files: discovered.files, analysisSize, ...(analysisFit ? { analysisFit } : {}), ...(expanded ? { root: discovered.root, sourceBase: repository.sourceBase } : {}),
137
141
  ...(options.captureSnapshot ? { snapshot: Object.fromEntries(Object.keys(discovered.files).map(path => [path, captured[path]])) } : {}), fragment: discovered.fragment, selection: discovered.selection,
138
142
  skippedFiles: mergeSkippedFiles(discovered.skippedFiles, ignored, expanded ? refused.map(file => ({ ...file, path: repoPathFrom(file.path, discovered.root) })) : refused),
139
143
  warnings: [...new Set(mergeUnlistedFileWarnings([...warnings.map(file => fileRefusalWarning(repoPathFrom(file.path, discovered.root), file.reason)), ...discovered.warnings], ignored.length))] };
@@ -1,4 +1,4 @@
1
- import { sealedBundleHash } from "../bundle/seal/signature.js";
1
+ import { bundleContentHash } from "../bundle/seal/signature.js";
2
2
  import { checkPlannedCallsAgainstBundle } from "../bundle/seal/planned-calls.js";
3
3
  import { localCallPlan } from "../analysis-core/requests/local-plan.js";
4
4
  import { relayPlanSchema } from "../contract/console.js";
@@ -10,6 +10,6 @@ export function prepareRelayPlan({ bundle, tools, relayVersion, settings, source
10
10
  });
11
11
  checkPlannedCallsAgainstBundle(bundle, calls);
12
12
  return { files, plan: relayPlanSchema.parse({ bundleVersion: tools.bundleVersion,
13
- bundleHash: sealedBundleHash(bundle), relayVersion,
13
+ bundleHash: bundleContentHash(bundle.sealed), relayVersion,
14
14
  calls: calls.map(({ routeId, model, calls, maxInputBytes, maxInputTokens, maxOutputTokens }) => ({ routeId, model, calls, maxInputBytes, maxInputTokens, maxOutputTokens })) }) };
15
15
  }
@@ -1,4 +1,5 @@
1
1
  import { createHash, createPublicKey } from "node:crypto";
2
+ import { fileURLToPath } from "node:url";
2
3
  import { readFile } from "node:fs/promises";
3
4
  import { sealedBundle } from "../contract/messages.js";
4
5
  import { loadPublicRequestTools } from "./public-instructions.js";
@@ -28,6 +29,10 @@ export function readClientReleaseKey(pem) {
28
29
  throw new Error(cliRefusals.release_unavailable);
29
30
  return key;
30
31
  }
32
+ export function installedReleasePaths() {
33
+ const base = new URL(import.meta.url.endsWith(".ts") ? "../bundle/" : "../../bundle/", import.meta.url);
34
+ return { bundle: fileURLToPath(new URL("sealed.json", base)), metadata: fileURLToPath(new URL("client-release.json", base)) };
35
+ }
31
36
  /** Installed releases always use the separately reviewed signing key. */
32
37
  export function loadInstalledRelease(paths) {
33
38
  return loadRelease(paths, false);
@@ -38,14 +43,14 @@ export function loadDevelopmentRelease(paths) {
38
43
  }
39
44
  async function loadRelease(paths, development) {
40
45
  try {
41
- const base = new URL(import.meta.url.endsWith(".ts") ? "../bundle/" : "../../bundle/", import.meta.url);
42
- const metadata = JSON.parse(await readFile(paths?.metadata ?? new URL("client-release.json", base), "utf8"));
46
+ const location = paths ?? installedReleasePaths();
47
+ const metadata = JSON.parse(await readFile(location.metadata, "utf8"));
43
48
  const pins = paths ? metadata : readClientReleasePins(metadata);
44
49
  if (typeof pins.verificationKey !== "string" || typeof pins.relayVersion !== "string" || !pins.relayVersion ||
45
50
  typeof pins.localVersion !== "string" || !pins.localVersion)
46
51
  throw new Error();
47
52
  const verificationKey = development ? createPublicKey(pins.verificationKey) : readClientReleaseKey(pins.verificationKey);
48
- const bundle = JSON.parse(await readFile(paths?.bundle ?? new URL("sealed.json", base), "utf8"));
53
+ const bundle = JSON.parse(await readFile(location.bundle, "utf8"));
49
54
  const release = { bundle, verificationKey, relayVersion: pins.relayVersion, localVersion: pins.localVersion,
50
55
  relayUrl: pins.relayUrl, projectContext: pins.projectContext };
51
56
  validateClientRelease(release);
@@ -13,7 +13,8 @@ export function newRunSettings(caller, env = process.env) {
13
13
  if (choice !== "0" && choice !== "1")
14
14
  throw new Error("CF_FINDING_HEADLINES must be 0 or 1.");
15
15
  const outside = caller?.CF_IMPORT_OUTSIDE_LOADERS || env.CF_IMPORT_OUTSIDE_LOADERS || "0";
16
- return snapshotSettings({ ...(caller ?? env), CF_FINDING_HEADLINES: choice, CF_IMPORT_OUTSIDE_LOADERS: outside });
16
+ const refuseTooLarge = caller?.CF_REFUSE_TOO_LARGE ?? env.CF_REFUSE_TOO_LARGE ?? "1";
17
+ return snapshotSettings({ ...(caller ?? env), CF_FINDING_HEADLINES: choice, CF_IMPORT_OUTSIDE_LOADERS: outside, CF_REFUSE_TOO_LARGE: refuseTooLarge });
17
18
  }
18
19
  /** The installed command selects the relay; source-only switches remain on the development runner. */
19
20
  export function readCliSettings(env = process.env, emailSignIn) {
@@ -1 +1 @@
1
- import{n as a,o as b,p as c,q as d,r as e,s as f}from"../../chunks/G322LST6.js";import"../../chunks/6YCABS5T.js";import"../../chunks/SL27GMEN.js";import"../../chunks/PVPEY7NF.js";import"../../chunks/STZOC7LN.js";import"../../chunks/VFENG4MR.js";import"../../chunks/UEWL3GMQ.js";import"../../chunks/OFBJNHC6.js";import"../../chunks/3227KXHF.js";import"../../chunks/EQTIRIMU.js";import"../../chunks/74FPPPIG.js";import"../../chunks/EH3QQ3T4.js";import"../../chunks/KEKTZDIK.js";import"../../chunks/FSLWD2PE.js";import"../../chunks/JF4GYMOZ.js";import"../../chunks/BZNHHLNP.js";import"../../chunks/T5TREZCQ.js";import"../../chunks/724WZMYW.js";export{f as assertFindingQualityPrompts,b as findingAnalysisTemplate,e as findingQualityConfigOf,a as findingQualityPromptNames,c as plannedFindingQualityCalls,d as readFindingQualityConfig};
1
+ import{n as a,o as b,p as c,q as d,r as e,s as f}from"../../chunks/DRGDIIFA.js";import"../../chunks/6YCABS5T.js";import"../../chunks/SL27GMEN.js";import"../../chunks/3CKW5JIF.js";import"../../chunks/STZOC7LN.js";import"../../chunks/MJGB25S5.js";import"../../chunks/UEWL3GMQ.js";import"../../chunks/OFBJNHC6.js";import"../../chunks/3227KXHF.js";import"../../chunks/HPIAEQHE.js";import"../../chunks/74FPPPIG.js";import"../../chunks/EH3QQ3T4.js";import"../../chunks/JKWTHRUR.js";import"../../chunks/FSLWD2PE.js";import"../../chunks/JF4GYMOZ.js";import"../../chunks/3GUKUEEJ.js";import"../../chunks/T5TREZCQ.js";import"../../chunks/724WZMYW.js";export{f as assertFindingQualityPrompts,b as findingAnalysisTemplate,e as findingQualityConfigOf,a as findingQualityPromptNames,c as plannedFindingQualityCalls,d as readFindingQualityConfig};
@@ -1 +1 @@
1
- import{i as a,j as b}from"../../chunks/DTMHXKP6.js";import"../../chunks/U5HOEVPE.js";import"../../chunks/EQTIRIMU.js";import"../../chunks/74FPPPIG.js";import"../../chunks/EH3QQ3T4.js";import"../../chunks/KEKTZDIK.js";import"../../chunks/FSLWD2PE.js";import"../../chunks/JF4GYMOZ.js";import"../../chunks/BZNHHLNP.js";import"../../chunks/T5TREZCQ.js";import"../../chunks/724WZMYW.js";export{a as assessFindings,b as rankFindings};
1
+ import{i as a,j as b}from"../../chunks/MXXNED6N.js";import"../../chunks/U5HOEVPE.js";import"../../chunks/HPIAEQHE.js";import"../../chunks/74FPPPIG.js";import"../../chunks/EH3QQ3T4.js";import"../../chunks/JKWTHRUR.js";import"../../chunks/FSLWD2PE.js";import"../../chunks/JF4GYMOZ.js";import"../../chunks/3GUKUEEJ.js";import"../../chunks/T5TREZCQ.js";import"../../chunks/724WZMYW.js";export{a as assessFindings,b as rankFindings};
@@ -1 +1 @@
1
- import{a,b,c,d}from"../../chunks/M7MMAUAK.js";import"../../chunks/57M4OQJM.js";import"../../chunks/IBCFGUHI.js";import"../../chunks/EQTIRIMU.js";import"../../chunks/74FPPPIG.js";import"../../chunks/EH3QQ3T4.js";import"../../chunks/KEKTZDIK.js";import"../../chunks/FSLWD2PE.js";import"../../chunks/JF4GYMOZ.js";import"../../chunks/BZNHHLNP.js";import"../../chunks/T5TREZCQ.js";import"../../chunks/724WZMYW.js";export{d as attachHeadlineResults,c as attachHeadlineRows,a as headlineTargetFingerprint,b as headlineWordingAt};
1
+ import{a,b,c,d}from"../../chunks/O652FQQH.js";import"../../chunks/57M4OQJM.js";import"../../chunks/IBCFGUHI.js";import"../../chunks/HPIAEQHE.js";import"../../chunks/74FPPPIG.js";import"../../chunks/EH3QQ3T4.js";import"../../chunks/JKWTHRUR.js";import"../../chunks/FSLWD2PE.js";import"../../chunks/JF4GYMOZ.js";import"../../chunks/3GUKUEEJ.js";import"../../chunks/T5TREZCQ.js";import"../../chunks/724WZMYW.js";export{d as attachHeadlineResults,c as attachHeadlineRows,a as headlineTargetFingerprint,b as headlineWordingAt};
@@ -1 +1 @@
1
- import{a as b,b as c}from"../../chunks/ZMUBMYWN.js";import{c as a}from"../../chunks/ZAA44GPI.js";import"../../chunks/3227KXHF.js";import"../../chunks/M7MMAUAK.js";import"../../chunks/57M4OQJM.js";import"../../chunks/IBCFGUHI.js";import"../../chunks/EQTIRIMU.js";import"../../chunks/74FPPPIG.js";import"../../chunks/EH3QQ3T4.js";import"../../chunks/KEKTZDIK.js";import"../../chunks/FSLWD2PE.js";import"../../chunks/JF4GYMOZ.js";import"../../chunks/BZNHHLNP.js";import"../../chunks/T5TREZCQ.js";import"../../chunks/724WZMYW.js";export{b as buildHeadlineInput,c as headlineInputHash,a as headlineRequest};
1
+ import{a as b,b as c}from"../../chunks/FTODBFQW.js";import{c as a}from"../../chunks/ZAA44GPI.js";import"../../chunks/3227KXHF.js";import"../../chunks/O652FQQH.js";import"../../chunks/57M4OQJM.js";import"../../chunks/IBCFGUHI.js";import"../../chunks/HPIAEQHE.js";import"../../chunks/74FPPPIG.js";import"../../chunks/EH3QQ3T4.js";import"../../chunks/JKWTHRUR.js";import"../../chunks/FSLWD2PE.js";import"../../chunks/JF4GYMOZ.js";import"../../chunks/3GUKUEEJ.js";import"../../chunks/T5TREZCQ.js";import"../../chunks/724WZMYW.js";export{b as buildHeadlineInput,c as headlineInputHash,a as headlineRequest};
@@ -1 +1 @@
1
- import{Ab as o,mb as f,nb as g,ob as h,pb as i,vb as j,wb as k,xb as l,yb as m,zb as n}from"../chunks/EQTIRIMU.js";import"../chunks/74FPPPIG.js";import{c as a,d as b,e as c,f as d,g as e}from"../chunks/EH3QQ3T4.js";import"../chunks/KEKTZDIK.js";import"../chunks/FSLWD2PE.js";import"../chunks/JF4GYMOZ.js";import"../chunks/BZNHHLNP.js";import"../chunks/T5TREZCQ.js";import"../chunks/724WZMYW.js";export{j as MAX_FINDINGS,h as attachFiles,k as cleanFindings,m as cleanFixDelta,g as cleanFragment,d as findingsSchema,e as findingsSchemaFor,n as fingerprintOf,l as fixFingerprintOf,a as inspectFixSchema,i as mergeGraphs,f as normaliseBrand,o as numberLines,b as otherSiteSchema,c as rawFindingSchema};
1
+ import{lb as f,mb as g,nb as h,ob as i,ub as j,vb as k,wb as l,xb as m,yb as n,zb as o}from"../chunks/HPIAEQHE.js";import"../chunks/74FPPPIG.js";import{c as a,d as b,e as c,f as d,g as e}from"../chunks/EH3QQ3T4.js";import"../chunks/JKWTHRUR.js";import"../chunks/FSLWD2PE.js";import"../chunks/JF4GYMOZ.js";import"../chunks/3GUKUEEJ.js";import"../chunks/T5TREZCQ.js";import"../chunks/724WZMYW.js";export{j as MAX_FINDINGS,h as attachFiles,k as cleanFindings,m as cleanFixDelta,g as cleanFragment,d as findingsSchema,e as findingsSchemaFor,n as fingerprintOf,l as fixFingerprintOf,a as inspectFixSchema,i as mergeGraphs,f as normaliseBrand,o as numberLines,b as otherSiteSchema,c as rawFindingSchema};
@@ -0,0 +1 @@
1
+ import{a as C,b as F}from"./STZOC7LN.js";import{a as c}from"./MJGB25S5.js";import{z as t}from"zod";var O=Object.freeze(["CF_MULTI_PASS","CF_SPLIT_CHECK","CF_FINDING_CHECK","CF_SOURCE_NOTES","CF_PARALLEL_PASSES","CF_PASS_CONCURRENCY","CF_PARALLEL_SCOPE_CHECK","CF_FINDING_QUALITY","CF_FINDING_FULL_CONTEXT","CF_FINDING_PRECISION_RULES","CF_PROMPT_AGREE","CF_FINDING_SECOND_OPINION","CF_FINDING_RANKING","CF_FINDING_SEMANTIC_MATCHING","CF_FINDING_CODE_INPUTS","CF_FINDING_RECALL","CF_FINDING_RECALL_VARIANT","CF_FINDING_SECOND_OPINION_MODEL","CF_FINDING_SECOND_OPINION_PROVIDER","CF_FIX_EXPECTED_OUTCOME","CF_UNTRUSTED_CONTENT_CHECK","CF_FINDING_BETTER_AS_CODE","CF_CODE_AGENTS","CF_CODE_AGENTS_MODEL","CF_FINDING_DEDUPE","CF_ANALYSIS_IMPORTED_AGENTS","CF_RECALL_SIGNALS","CF_READING_NOTE_AGENT_ONLY","CF_SPLIT_HELPER_TOOLS","CF_CODE_PROMPT_LOADERS","CF_CODE_PROMPT_FUNCTIONS","CF_READING_PRIORITY","CF_LOCAL_SYMLINK_GUARD","CF_IMPORT_EXAMPLE_FILTER","CF_IMPORT_OUTSIDE_LOADERS","CF_SECRET_SCAN","CF_RESPECT_GITIGNORE","CF_IMPORT_COVERAGE","CF_IMPORT_MANIFEST","CF_IMPORT_SCOPED_SCAN","CF_IMPORT_INCLUDE_EXAMPLES","CF_IMPORT_WEAK_CODE_FALLBACK","CF_REFUSE_TOO_LARGE","CF_FINDING_HEADLINES","CF_IMPORT_LAYOUTS","CF_DISCOVERY_SKILLS","CF_IMPORT_CALLS","CF_PROMPT_CACHE","CF_MODEL_READER","CF_LEGACY_TOOL_LISTS"]),a=O.filter(e=>e!=="CF_IMPORT_OUTSIDE_LOADERS"&&e!=="CF_SECRET_SCAN"&&e!=="CF_RESPECT_GITIGNORE"&&e!=="CF_IMPORT_COVERAGE"&&e!=="CF_IMPORT_MANIFEST"&&e!=="CF_IMPORT_SCOPED_SCAN"&&e!=="CF_IMPORT_INCLUDE_EXAMPLES"&&e!=="CF_IMPORT_WEAK_CODE_FALLBACK"&&e!=="CF_REFUSE_TOO_LARGE");function N(e,_="request"){return Object.freeze(Object.fromEntries((_==="saved"?O:a).filter(i=>Object.hasOwn(e,i)).map(i=>[i,e[i]])))}var p=t.partialRecord(t.enum(a),t.string()),E=t.lazy(()=>t.union([t.string(),t.number(),t.boolean(),t.null(),t.array(E),t.record(t.string(),E)])),l=t.object({data:t.record(t.string(),E),settings:p,maxInputBytes:t.number().int().positive().optional()}).strict(),S=t.string().min(1).max(128).regex(/^[a-zA-Z0-9][a-zA-Z0-9._:-]*$/),T=t.object({maxTokens:t.number().int().positive().optional(),effort:t.enum(["low","medium","high","max"]).optional(),thinking:t.literal("disabled").optional(),promptCache:t.boolean().optional()}).strict(),R=t.object({template:t.string().min(1),inputs:l,answerFormat:t.string().min(1),model:S,limits:T.optional()}).strict();function P(e,_={},o){let i={data:e.inputs,settings:N(_),...o===void 0?{}:{maxInputBytes:o}};return R.parse({...e,answerFormat:Object.hasOwn(r,e.template)?A(e.template,e.answerFormat,_):e.answerFormat,limits:{...e.limits,promptCache:c(_,{template:e.template},e.model).enabled},inputs:JSON.parse(JSON.stringify(i))})}var n=(e,..._)=>Object.freeze({role:e,answerFormats:Object.freeze(_)}),s=F().map(e=>e.name),r=Object.freeze({"derive-findings":n("required",...s),"derive-findings-legacy":n("required",...s),"derive-findings-no-outcome":n("required",...s),"derive-findings-legacy-no-outcome":n("required",...s),"benchmark-judge":n("required","judge"),"judge-code-prompt":n("optional","codeJudge"),"derive-structure":n("optional","structures"),"structure-recheck":n("optional","recheck"),"derive-shape":n("optional","shape"),"scope-items":n("optional","structureScope"),"scope-findings":n("optional","scope"),"check-findings":n("optional","check"),"check-findings-precision-v1":n("optional","check"),"second-opinion":n("optional","opinion"),"explain-sources":n("optional","sourceNotes"),"finding-headlines":n("optional","findingHeadlines")});function D(){return r}function f(e,_,o){let i=o??(e==="derive"?"derive-findings":"check-findings");if(!Object.keys(r).filter(I=>r[I].answerFormats.includes(e==="derive"?"findings":"check")).includes(i))throw new Error("Unknown analysis template");return e==="derive"&&!C(_).switches.expectedOutcome&&!i.endsWith("-no-outcome")?`${i}-no-outcome`:i}function A(e,_,o){let i=_==="findings"?C(o).name:_;if(!Object.hasOwn(r,e)||!r[e].answerFormats.includes(i))throw new Error("Unsupported template answer format");return i}function g(e,_,o){if(o(_),!Object.hasOwn(r,e)||r[e].role!=="optional")throw _}export{O as a,N as b,l as c,S as d,T as e,R as f,P as g,D as h,f as i,A as j,g as k};
@@ -0,0 +1 @@
1
+ var l="This folder has more than one analysis can read. Choose a smaller folder, such as one agent's folder.",s=class extends Error{code;retryable;constructor(n,t,a){super(t),this.code=n,this.name="JobError",this.retryable=a?.retryable??!1}};function o(e){if(e instanceof s&&["org_spend_limit","lease_lost","cancelled","canceled","replay_miss"].includes(e.code)||e instanceof Error&&e.name==="AbortError"||e&&typeof e=="object"&&"kind"in e&&["spending_stop","lease_lost","cancelled"].includes(String(e.kind)))throw e}export{l as a,s as b,o as c};
@@ -0,0 +1 @@
1
+ import{h as G}from"./NCWEOJVJ.js";import{Aa as $,Ba as P,Ca as w,Fa as M,Ga as y,Ta as D,a as l,b as N,e as T,ga as E,o as C,qa as I,u as R,wa as F,za as _}from"./HPIAEQHE.js";import{a as b,c as x}from"./T5TREZCQ.js";var k="Some of this agent's files weren't read, so findings may be missing.";var B=r=>r.CF_READING_PRIORITY!=="0";var U=new Set(["system prompt","soul","knowledge","config","tools","mcp"]);function L(r){let t=new Set;for(let s of r.nodes)for(let f of s.files??[])U.has(f.role)&&t.add(f.path);let n=new Set(r.edges.filter(s=>s.kind==="delegates").map(s=>s.to));for(let s of r.nodes)n.has(s.id)&&s.sourceRef&&t.add(s.sourceRef.path);return t}function V(r){return new Set([...r.nodes,...r.edges].flatMap(t=>t.sourceRef?[t.sourceRef.path]:[]))}var p=6e4,j=r=>{if(r.length<=p)return r;let t=r.endsWith(E)?E:"";return(t?r.slice(0,-t.length):r).slice(0,p)+t};function Z(r,t){let n=[...r].filter(s=>t[s]!==void 0&&j(t[s])!==t[s]).sort();return n.length===0?null:`${n.length} core file${n.length===1?" was":"s were"} longer than ${p/1e3} KB, so only the first ${p/1e3} KB ${n.length===1?"was":"were"} read: ${n.join(", ")}`}var A=r=>r.split("/").slice(0,-1).join("/"),Y=/(agent|prompt|tool|llm|model)/i,z=2.5;function K(r,t){if(!B(r))return{enabled:!1,tierOf:()=>6};if(t.repos?.some(e=>e.kind==="github"&&b(e.root)))return v(r,t,t.repos);let n=t.scopes??(T(r)?G(r,t.paths):void 0),s=t.graph?L(t.graph):new Set,f=new Set(t.graph?.nodes.flatMap(e=>(e.files??[]).filter(o=>o.role==="code"&&l(o.path)).map(o=>o.path))??[]),i=new Set(t.graph?.nodes.flatMap(e=>(e.files??[]).filter(o=>o.role==="system prompt").map(o=>o.path))??[]),a=e=>N(e)&&(I.includes(e.split("/").pop().toLowerCase())||/(^|\/)system_prompt_[^/]+\.md$/i.test(e)||y.test(e)),c=e=>{if(s.has(e))return 1;if(f.has(e))return 2;let o=P(r,e,n),d=R(o,{nested:!0});if(d?.reference)return 5;if(d?.definition||F.test(o))return 4;if(d||/(^|\/)(docs?|references)\//i.test(o)||$.test(e.split("/").pop()))return 5;if(_(o)||w(r,e,n)&&_(e.split("/").pop())||a(e))return 1;if(l(e)){if(Y.test(e))return z;if(M.test(e))return 3}return 6};for(let e of t.paths)c(e)===1&&a(e)&&i.add(e);let m=[...i].flatMap(e=>{let o=A(e);return[o,...o?[A(o)]:[]]}),h=e=>l(e)&&m.some(o=>A(e)===o),u=new Map(t.paths.map(e=>{let o=c(e);return[e,o>2&&h(e)?2:o]})),g=[...u].filter(([e,o])=>o<=2&&l(e)).map(([e])=>e),O=D(Object.fromEntries(g.flatMap(e=>t.files?.[e]===void 0?[]:[[e,t.files[e]]])),t.paths);for(let e of O)l(e)&&!R(P(r,e,n),{nested:!0})&&(u.get(e)??6)>2&&u.set(e,2);return{enabled:!0,tierOf:e=>u.get(e)??c(e)}}function v(r,t,n){let s=new Map;for(let f of n){let i=f.kind==="github"?f.root:void 0,a=t.paths.filter(e=>f.files?.[e]!==void 0&&!s.has(e)),c=e=>x(e,i)??(f.files?.[e]!==void 0?e:null),m=e=>{let o=e?c(e.path):null;return o===null?null:{path:o}},h=t.graph&&{nodes:t.graph.nodes.map(e=>({...e,sourceRef:m(e.sourceRef),files:e.files?.flatMap(o=>{let d=c(o.path);return d===null?[]:[{...o,path:d}]})})),edges:t.graph.edges.map(e=>({...e,sourceRef:m(e.sourceRef)}))},u=a.flatMap(e=>{let o=c(e);return o===null?[]:[o]}),g=Object.fromEntries(a.flatMap(e=>{let o=c(e);return o===null||t.files?.[e]===void 0?[]:[[o,t.files[e]]]})),O=K(r,{paths:u,files:g,graph:h});for(let e of a)s.set(e,O.tierOf(c(e)??e))}return{enabled:!0,tierOf:f=>s.get(f)??6}}function H(r,t){return r.enabled?t.filter(n=>["too-large","total","allowance"].includes(n.reason)&&r.tierOf(n.path)<3).map(n=>n.path):[]}function W(r){return r.slice(0,3)}function q(r,t=!1){let n=W(r);if(!n.length)return;let s=t?". "+k:", so some findings may be missing";return`${n.join(", ")} ${n.length===1?"was":"were"} left out${s}`}function ue(r,t){return q(H(r,t))}function de(r,t){return r.enabled&&r.tierOf(t)<3}function me(r,t,n){let s=C.sourceFetch.codeFileBytes;return r.enabled&&r.tierOf(t)<3&&l(t)&&n>s?{size:s,readBytes:s}:{size:n}}function pe(r,t){return r.enabled&&r.tierOf(t)<3&&l(t)}function S(r){return r.split("/").length-1}function he(r,t,n){return w(r,t,n)?0:M.test(t)?1+Math.min(S(t),3)/10:S(t)<=2?2:S(t)<=4?3:4}function ge(r,t){return(r.tier??0)-(t.tier??0)||r.score-t.score||r.size-t.size}function Oe(r,t,n,s){return[...r].sort((f,i)=>(s?.enabled?s.tierOf(f)-s.tierOf(i):0)||Number(n.has(i))-Number(n.has(f))||t[f].length-t[i].length||(f<i?-1:1))}function Re(r,t,n,s){return[...r].sort((f,i)=>(s?.enabled?s.tierOf(f.path)-s.tierOf(i.path):0)||Number(t.has(i.path))-Number(t.has(f.path))||Number(n.has(i.path))-Number(n.has(f.path))||f.text.length-i.text.length)}export{B as a,L as b,V as c,j as d,Z as e,K as f,H as g,W as h,q as i,ue as j,de as k,me as l,pe as m,he as n,ge as o,Oe as p,Re as q};
@@ -1 +1 @@
1
- import{J as O}from"./7QDOHWSY.js";import{a as N}from"./326F4XNG.js";import{b as F}from"./2PSNOSJ2.js";import{q as x}from"./EQTIRIMU.js";import{e as P}from"./T5TREZCQ.js";async function H(S,t){let a={entriesVisited:0,filesRead:0,bytesRead:0,truncated:!1},d=[],R=()=>({files:t.selected.files,selection:t.selection,skippedFiles:F(d),search:a});if(O(S,{selected:t.selected,codeAgentsFound:t.codeAgentsFound}).kind==="none")return R();let h=await t.port.context();if(!h)return R();let E=[];try{let r=e=>P(e,h.selectedRoot),L=e=>Object.fromEntries(Object.entries(e).map(([c,I])=>[r(c),I])),A={...t.selected,files:L(t.selected.files),root:h.selectedRoot,...t.selected.listedPaths?{listedPaths:t.selected.listedPaths.map(r)}:{},...t.selected.pointerFiles?{pointerFiles:L(t.selected.pointerFiles)}:{},...typeof t.selected.explicitPrompt=="string"?{explicitPrompt:r(t.selected.explicitPrompt)}:{}},l=await t.port.list();a.entriesVisited=l.entriesVisited,a.truncated=l.truncated;let w=new Map(l.entries.map(e=>[e.path,e])),u=new Set,p={},m=x.codeScan,b=()=>O(S,{selected:A,codeAgentsFound:t.codeAgentsFound,entries:l.entries,bodies:p,attemptedPaths:[...u],completeListing:!l.truncated}),n=b();for(;n.kind==="search"&&n.paths.length;){let e=[],c=0;for(let s of n.paths){let i=w.get(s);if(i.size>m.fileBytes){d.push({path:s,reason:"too-large"}),u.add(s);continue}let o=i.size+1;if(e.length>=4||a.filesRead+e.length>=m.files||a.bytesRead+c+o>m.bytes)break;e.push({entry:i,allowance:o}),c+=o}if(!e.length){if(n=b(),n.kind==="none"||!n.paths.length)break;a.truncated=!0,d.push(...n.paths.map(s=>({path:s,reason:"scan-limit"})));break}(await N(e,4,async({entry:s,allowance:i})=>{u.add(s.path),a.filesRead++;try{return await t.port.read(s,i)}catch(o){if(o instanceof Error&&o.name==="AbortError")throw o;return{text:null,bytesRead:i,refusal:"unreadable"}}},{settleStartedOnError:!0})).forEach((s,i)=>{let{entry:o,allowance:k}=e[i],z=Number.isSafeInteger(s.bytesRead)&&s.bytesRead>=0&&s.bytesRead<=k;a.bytesRead+=z?s.bytesRead:k,z&&s.text!==null&&!s.refusal&&s.bytesRead<=m.fileBytes&&s.bytesRead<k&&Buffer.byteLength(s.text)===s.bytesRead?p[o.path]=s.text:d.push({path:o.path,reason:s.refusal??"unreadable"})}),n=b()}let g=b();if(g.kind==="none"||!g.ownedPaths.length)return R();let f={...A.files};for(let e of g.ownedPaths)Object.hasOwn(p,e)&&(f[e]=p[e]);let v=e=>({...e,path:r(e.path),...e.ref===e.path?{ref:r(e.ref)}:{}}),B=t.selection.selected.map(v),M=new Set(B.map(e=>e.path)),j=g.ownedPaths.filter(e=>!M.has(e)&&Object.hasOwn(f,e)).map(e=>({...w.get(e),path:e,size:Buffer.byteLength(f[e]),ref:w.get(e)?.ref??e})),y=t.selection.readingNotes,V={files:f,root:h.selectedRoot,search:a,skippedFiles:F(d),selection:{...t.selection,selected:[...B,...j],totalBytes:t.selection.totalBytes+j.reduce((e,c)=>e+c.size,0),refused:t.selection.refused.map(e=>({...e,path:r(e.path)})),...y?{readingNotes:{instruction:y.instruction.map(r),code:y.code.map(r),agents:y.agents.map(r)}}:{}}};return E=Object.keys(f),V}finally{t.port.finish?.(E)}}export{H as a};
1
+ import{D as O}from"./K5OTWBTT.js";import{a as N}from"./326F4XNG.js";import{b as F}from"./2PSNOSJ2.js";import{o as x}from"./HPIAEQHE.js";import{e as P}from"./T5TREZCQ.js";async function H(S,t){let a={entriesVisited:0,filesRead:0,bytesRead:0,truncated:!1},d=[],R=()=>({files:t.selected.files,selection:t.selection,skippedFiles:F(d),search:a});if(O(S,{selected:t.selected,codeAgentsFound:t.codeAgentsFound}).kind==="none")return R();let h=await t.port.context();if(!h)return R();let E=[];try{let r=e=>P(e,h.selectedRoot),L=e=>Object.fromEntries(Object.entries(e).map(([c,I])=>[r(c),I])),A={...t.selected,files:L(t.selected.files),root:h.selectedRoot,...t.selected.listedPaths?{listedPaths:t.selected.listedPaths.map(r)}:{},...t.selected.pointerFiles?{pointerFiles:L(t.selected.pointerFiles)}:{},...typeof t.selected.explicitPrompt=="string"?{explicitPrompt:r(t.selected.explicitPrompt)}:{}},l=await t.port.list();a.entriesVisited=l.entriesVisited,a.truncated=l.truncated;let w=new Map(l.entries.map(e=>[e.path,e])),u=new Set,p={},m=x.codeScan,b=()=>O(S,{selected:A,codeAgentsFound:t.codeAgentsFound,entries:l.entries,bodies:p,attemptedPaths:[...u],completeListing:!l.truncated}),n=b();for(;n.kind==="search"&&n.paths.length;){let e=[],c=0;for(let s of n.paths){let i=w.get(s);if(i.size>m.fileBytes){d.push({path:s,reason:"too-large"}),u.add(s);continue}let o=i.size+1;if(e.length>=4||a.filesRead+e.length>=m.files||a.bytesRead+c+o>m.bytes)break;e.push({entry:i,allowance:o}),c+=o}if(!e.length){if(n=b(),n.kind==="none"||!n.paths.length)break;a.truncated=!0,d.push(...n.paths.map(s=>({path:s,reason:"scan-limit"})));break}(await N(e,4,async({entry:s,allowance:i})=>{u.add(s.path),a.filesRead++;try{return await t.port.read(s,i)}catch(o){if(o instanceof Error&&o.name==="AbortError")throw o;return{text:null,bytesRead:i,refusal:"unreadable"}}},{settleStartedOnError:!0})).forEach((s,i)=>{let{entry:o,allowance:k}=e[i],z=Number.isSafeInteger(s.bytesRead)&&s.bytesRead>=0&&s.bytesRead<=k;a.bytesRead+=z?s.bytesRead:k,z&&s.text!==null&&!s.refusal&&s.bytesRead<=m.fileBytes&&s.bytesRead<k&&Buffer.byteLength(s.text)===s.bytesRead?p[o.path]=s.text:d.push({path:o.path,reason:s.refusal??"unreadable"})}),n=b()}let g=b();if(g.kind==="none"||!g.ownedPaths.length)return R();let f={...A.files};for(let e of g.ownedPaths)Object.hasOwn(p,e)&&(f[e]=p[e]);let v=e=>({...e,path:r(e.path),...e.ref===e.path?{ref:r(e.ref)}:{}}),B=t.selection.selected.map(v),M=new Set(B.map(e=>e.path)),j=g.ownedPaths.filter(e=>!M.has(e)&&Object.hasOwn(f,e)).map(e=>({...w.get(e),path:e,size:Buffer.byteLength(f[e]),ref:w.get(e)?.ref??e})),y=t.selection.readingNotes,V={files:f,root:h.selectedRoot,search:a,skippedFiles:F(d),selection:{...t.selection,selected:[...B,...j],totalBytes:t.selection.totalBytes+j.reduce((e,c)=>e+c.size,0),refused:t.selection.refused.map(e=>({...e,path:r(e.path)})),...y?{readingNotes:{instruction:y.instruction.map(r),code:y.code.map(r),agents:y.agents.map(r)}}:{}}};return E=Object.keys(f),V}finally{t.port.finish?.(E)}}export{H as a};
@@ -1 +1 @@
1
- import{a as U}from"./6YCABS5T.js";import{c as V}from"./SL27GMEN.js";import{i as b,j as v}from"./PVPEY7NF.js";import{c as y}from"./VFENG4MR.js";import{a as K}from"./OFBJNHC6.js";import{a as u,b as w}from"./3227KXHF.js";import{vb as Y}from"./EQTIRIMU.js";import{c as k,f as M}from"./KEKTZDIK.js";var l=u.chat,s=8,I=1,W=40,N=6e4,S=16e3,Q=8e4,f=4e3,q=1536,R=8192,B=1024;function h(e){return R+e*q+B}function A(e,t="legacy"){return t==="whole-file"?N+Q+f*e+4e3*4:N+(S+f)*e+4e3*2}function pe(e,t,o,n,c="legacy"){if(!o||t===0)return null;let r=Math.ceil(t/s),i=1+I,p=h(t)+(R+B)*(r-1),_={template:n};if(c==="whole-file"){let F=Math.floor(t/s),d=t%s,a=M(A(s,c))*F+(d?M(A(d,c)):0);return y(e,_,"Double-check findings",l,a*i,p*i)}let C=N*r+(S+f)*t;return y(e,_,"Double-check findings",l,(M(C)+4e3*r)*i,p*i)}var Ce=8e5;function L(e,t,o,n,c,r,i){return{routeId:U(t),templateId:t,answerFormatId:v(t,o,e),model:n,calls:c,maxInputBytes:r,maxInputTokens:2e5,maxOutputTokens:i??V({model:n})}}function X(e,t){let o=e.CF_FINDING_QUALITY==="1",n=o&&e.CF_FINDING_FULL_CONTEXT==="1",c=o&&e.CF_FINDING_PRECISION_RULES==="1",r=t?.check.name??(c?"check-findings-precision-v1":"check-findings");return{enabled:o,fullContext:n,precisionRules:c,prompts:{derive:t?.derive.name??"derive-findings-legacy",check:r==="check-findings-legacy"?"check-findings":r}}}function $(e){return X({},e.prompts).prompts}function G(e,t,{enabled:o,prompts:n}){return b(e,t,o?n[e]:void 0)}function Ae(e,t,o){return G(e,t,{enabled:o?.switches.enabled??!1,prompts:X({},o?.prompts).prompts})}function Fe(e,t,o,n){let c=K(e),r=X(e),{fullContext:i}=r,p=G("derive",e,r),_=G("check",e,r),C=i?"whole-file":"legacy";return{findings:o,derive:L(e,p,"findings",u.generate,t,n),check:c.findingCheck?L(e,_,"check",l,Math.ceil(o/s)*(I+1),Math.max(n,A(s,C)),h(s)):null}}function g(e){if(e&&typeof e=="object"){for(let t of Object.values(e))g(t);Object.freeze(e)}return e}function ee(e,t,o={}){let{enabled:n,fullContext:c,precisionRules:r,prompts:i}=X(e),p=m=>n&&e[m]==="1",_=p("CF_FINDING_SECOND_OPINION"),C=p("CF_FINDING_RANKING"),F=n&&e.CF_FINDING_SEMANTIC_MATCHING!=="0",d=o.codeInputs!==!1&&n&&e.CF_FINDING_CODE_INPUTS!=="0",a=[],x=e.CF_FINDING_RECALL_VARIANT,D=o.recall!==!1&&p("CF_FINDING_RECALL")&&(x==="request-18"||x==="two-sweeps")?x:"off";o.recall!==!1&&p("CF_FINDING_RECALL")&&D==="off"&&a.push("Recall was skipped: no supported variant was selected.");let P=null,H=null;if(o.recall===!1&&e.CF_FINDING_RECALL==="1"&&a.push("Recall isn't available in local checks yet, so CF_FINDING_RECALL has no effect."),o.codeInputs===!1&&e.CF_FINDING_CODE_INPUTS==="1"&&a.push("Code evidence isn't available in local checks yet, so CF_FINDING_CODE_INPUTS has no effect."),_&&o.secondOpinion===!1&&a.push("Second opinion was skipped: local analysis supports Anthropic only."),_&&o.secondOpinion!==!1){let m=e.CF_FINDING_SECOND_OPINION_MODEL??"",E=Object.hasOwn(k,m)?k[m]:void 0,O=k[l];E&&E.provider===e.CF_FINDING_SECOND_OPINION_PROVIDER&&E.provider!==O.provider&&E.input<=O.input&&E.output<=O.output&&(E.input<O.input||E.output<O.output)?(P=m,H=E.provider):a.push("Second opinion was skipped: configure a priced, cheaper model from a different provider.")}return g({ruleVersion:n?"precision-v1":"legacy",switches:{enabled:n,fullContext:c,precisionRules:r,secondOpinion:_,ranking:C,semanticMatching:F,codeInputs:d,recall:D!=="off"},prompts:{derive:t.promptVersion(i.derive,e),check:t.promptVersion(i.check,e)},models:{derive:u.generate,check:l,scope:u.mechanical,secondOpinion:P},caps:{coreBytes:N,siteBytes:S,findingTextBytes:f,siteWindowLines:W,citedBatchBytes:c?8e4:0,passBytes:15e4,passContextBytes:6e4,maxPasses:4,passFindings:D==="request-18"?18:Y,totalFindings:24,deriveOutputTokens:w,checkBatchSize:s,checkOutputTokens:h(s),checkMaxRetries:I,checkOverheadTokens:4e3,secondOpinionBatchSize:4,secondOpinionInputBytes:A(4)+(c?8e4:0),secondOpinionOutputTokens:2048,secondOpinionMaxRetries:I},recallVariant:D,displayPolicyVersion:C?"support-v1":"legacy",meaningMatchingVersion:F?"meaning-v1":"legacy",codeInputScopeVersion:d?"owned-code-v1":"legacy",secondOpinionProvider:H,diagnostics:a})}function De(e,t){return t?g(structuredClone(t)):ee({},e)}function ke(e,t,o={}){let n=$(e);e.switches.enabled&&t.assertPromptVersions([{...e.prompts.derive,name:n.derive},{...e.prompts.check,name:n.check}],o)}export{l as a,s as b,I as c,W as d,N as e,S as f,Q as g,f as h,h as i,A as j,pe as k,Ce as l,L as m,$ as n,Ae as o,Fe as p,ee as q,De as r,ke as s};
1
+ import{a as U}from"./6YCABS5T.js";import{c as V}from"./SL27GMEN.js";import{i as b,j as v}from"./3CKW5JIF.js";import{c as y}from"./MJGB25S5.js";import{a as K}from"./OFBJNHC6.js";import{a as u,b as w}from"./3227KXHF.js";import{ub as Y}from"./HPIAEQHE.js";import{c as k,f as M}from"./JKWTHRUR.js";var l=u.chat,s=8,I=1,W=40,N=6e4,S=16e3,Q=8e4,f=4e3,q=1536,R=8192,B=1024;function h(e){return R+e*q+B}function A(e,t="legacy"){return t==="whole-file"?N+Q+f*e+4e3*4:N+(S+f)*e+4e3*2}function pe(e,t,o,n,c="legacy"){if(!o||t===0)return null;let r=Math.ceil(t/s),i=1+I,p=h(t)+(R+B)*(r-1),_={template:n};if(c==="whole-file"){let F=Math.floor(t/s),d=t%s,a=M(A(s,c))*F+(d?M(A(d,c)):0);return y(e,_,"Double-check findings",l,a*i,p*i)}let C=N*r+(S+f)*t;return y(e,_,"Double-check findings",l,(M(C)+4e3*r)*i,p*i)}var Ce=8e5;function L(e,t,o,n,c,r,i){return{routeId:U(t),templateId:t,answerFormatId:v(t,o,e),model:n,calls:c,maxInputBytes:r,maxInputTokens:2e5,maxOutputTokens:i??V({model:n})}}function X(e,t){let o=e.CF_FINDING_QUALITY==="1",n=o&&e.CF_FINDING_FULL_CONTEXT==="1",c=o&&e.CF_FINDING_PRECISION_RULES==="1",r=t?.check.name??(c?"check-findings-precision-v1":"check-findings");return{enabled:o,fullContext:n,precisionRules:c,prompts:{derive:t?.derive.name??"derive-findings-legacy",check:r==="check-findings-legacy"?"check-findings":r}}}function $(e){return X({},e.prompts).prompts}function G(e,t,{enabled:o,prompts:n}){return b(e,t,o?n[e]:void 0)}function Ae(e,t,o){return G(e,t,{enabled:o?.switches.enabled??!1,prompts:X({},o?.prompts).prompts})}function Fe(e,t,o,n){let c=K(e),r=X(e),{fullContext:i}=r,p=G("derive",e,r),_=G("check",e,r),C=i?"whole-file":"legacy";return{findings:o,derive:L(e,p,"findings",u.generate,t,n),check:c.findingCheck?L(e,_,"check",l,Math.ceil(o/s)*(I+1),Math.max(n,A(s,C)),h(s)):null}}function g(e){if(e&&typeof e=="object"){for(let t of Object.values(e))g(t);Object.freeze(e)}return e}function ee(e,t,o={}){let{enabled:n,fullContext:c,precisionRules:r,prompts:i}=X(e),p=m=>n&&e[m]==="1",_=p("CF_FINDING_SECOND_OPINION"),C=p("CF_FINDING_RANKING"),F=n&&e.CF_FINDING_SEMANTIC_MATCHING!=="0",d=o.codeInputs!==!1&&n&&e.CF_FINDING_CODE_INPUTS!=="0",a=[],x=e.CF_FINDING_RECALL_VARIANT,D=o.recall!==!1&&p("CF_FINDING_RECALL")&&(x==="request-18"||x==="two-sweeps")?x:"off";o.recall!==!1&&p("CF_FINDING_RECALL")&&D==="off"&&a.push("Recall was skipped: no supported variant was selected.");let P=null,H=null;if(o.recall===!1&&e.CF_FINDING_RECALL==="1"&&a.push("Recall isn't available in local checks yet, so CF_FINDING_RECALL has no effect."),o.codeInputs===!1&&e.CF_FINDING_CODE_INPUTS==="1"&&a.push("Code evidence isn't available in local checks yet, so CF_FINDING_CODE_INPUTS has no effect."),_&&o.secondOpinion===!1&&a.push("Second opinion was skipped: local analysis supports Anthropic only."),_&&o.secondOpinion!==!1){let m=e.CF_FINDING_SECOND_OPINION_MODEL??"",E=Object.hasOwn(k,m)?k[m]:void 0,O=k[l];E&&E.provider===e.CF_FINDING_SECOND_OPINION_PROVIDER&&E.provider!==O.provider&&E.input<=O.input&&E.output<=O.output&&(E.input<O.input||E.output<O.output)?(P=m,H=E.provider):a.push("Second opinion was skipped: configure a priced, cheaper model from a different provider.")}return g({ruleVersion:n?"precision-v1":"legacy",switches:{enabled:n,fullContext:c,precisionRules:r,secondOpinion:_,ranking:C,semanticMatching:F,codeInputs:d,recall:D!=="off"},prompts:{derive:t.promptVersion(i.derive,e),check:t.promptVersion(i.check,e)},models:{derive:u.generate,check:l,scope:u.mechanical,secondOpinion:P},caps:{coreBytes:N,siteBytes:S,findingTextBytes:f,siteWindowLines:W,citedBatchBytes:c?8e4:0,passBytes:15e4,passContextBytes:6e4,maxPasses:4,passFindings:D==="request-18"?18:Y,totalFindings:24,deriveOutputTokens:w,checkBatchSize:s,checkOutputTokens:h(s),checkMaxRetries:I,checkOverheadTokens:4e3,secondOpinionBatchSize:4,secondOpinionInputBytes:A(4)+(c?8e4:0),secondOpinionOutputTokens:2048,secondOpinionMaxRetries:I},recallVariant:D,displayPolicyVersion:C?"support-v1":"legacy",meaningMatchingVersion:F?"meaning-v1":"legacy",codeInputScopeVersion:d?"owned-code-v1":"legacy",secondOpinionProvider:H,diagnostics:a})}function De(e,t){return t?g(structuredClone(t)):ee({},e)}function ke(e,t,o={}){let n=$(e);e.switches.enabled&&t.assertPromptVersions([{...e.prompts.derive,name:n.derive},{...e.prompts.check,name:n.check}],o)}export{l as a,s as b,I as c,W as d,N as e,S as f,Q as g,f as h,h as i,A as j,pe as k,Ce as l,L as m,$ as n,Ae as o,Fe as p,ee as q,De as r,ke as s};
@@ -1 +1 @@
1
- import{a as p}from"./M7MMAUAK.js";import{b as l}from"./57M4OQJM.js";import{createHash as d}from"node:crypto";function u({repo:o,body:r}){let[t,...i]=r.evidence,n=r.split,s=e=>e.map(a=>({path:a.path??null,startLine:a.startLine,endLine:a.endLine}));return{kind:"structure",impact:r.kind,cause:r.cause,category:null,question:null,fixSummaries:[],site:t?{repo:o,path:t.path,line:t.line}:null,excerpt:t?.excerpt??null,otherSites:i.map(e=>({repo:o,path:e.path,line:e.line,excerpt:e.excerpt})),structure:{title:r.title,subKind:r.subKind,files:r.files.map(e=>({path:e.path,action:e.action,role:e.role,unit:e.unit,loadMode:e.loadMode,loadVia:e.loadVia,purpose:e.purpose})),segments:r.segments.map(e=>({path:e.path,startLine:e.startLine,endLine:e.endLine,to:e.to,disposition:e.disposition,into:e.into?{path:e.into.path,line:e.into.line}:null,reason:e.reason})),reorder:r.reorder?{path:r.reorder.path,startLine:r.reorder.startLine,endLine:r.reorder.endLine,steps:r.reorder.steps.map(e=>({from:e.from,reason:e.reason}))}:null,toolMoves:r.toolMoves.map(e=>({tool:e.tool,fromUnit:e.fromUnit,toUnit:e.toUnit,reason:e.reason})),split:n?{frontDoor:{job:n.frontDoor.job,skills:[...n.frontDoor.skills]},subAgents:n.subAgents.map(e=>({job:e.job,description:e.description,path:e.path,handoff:e.handoff??null,skills:e.skills.map(a=>({from:a.from,to:a.to})),tools:[...e.tools],movedKnowledge:s(e.movedKnowledge),neededKnowledge:s(e.neededKnowledge)}))}:null}}}function x(o,r=[]){return{evidence:[...o.map((t,i)=>({key:`f${i}`,kind:"finding",impact:t.kind,structure:null,cause:t.cause,category:t.category??null,question:t.question,site:t.site?{repo:t.siteRepo,path:t.site.path,line:t.site.line}:null,excerpt:t.excerpt,otherSites:t.otherSites.map(n=>({repo:n.repo,path:n.path,line:n.line,excerpt:n.excerpt})),fixSummaries:t.fixes.flatMap(n=>typeof n.summary=="string"&&n.summary.trim()?[n.summary]:[])})),...r.map((t,i)=>({key:`s${i}`,...u(t)}))],positions:[...o.map((t,i)=>({key:`f${i}`,target:"finding",index:i,fingerprint:p("finding",t)})),...r.map((t,i)=>({key:`s${i}`,target:"structure",index:i,fingerprint:p("structure",t)}))]}}function L(o,r){return d("sha256").update(l({batch:o,requestIdentity:r})).digest("hex")}export{x as a,L as b};
1
+ import{a as p}from"./O652FQQH.js";import{b as l}from"./57M4OQJM.js";import{createHash as d}from"node:crypto";function u({repo:o,body:r}){let[t,...i]=r.evidence,n=r.split,s=e=>e.map(a=>({path:a.path??null,startLine:a.startLine,endLine:a.endLine}));return{kind:"structure",impact:r.kind,cause:r.cause,category:null,question:null,fixSummaries:[],site:t?{repo:o,path:t.path,line:t.line}:null,excerpt:t?.excerpt??null,otherSites:i.map(e=>({repo:o,path:e.path,line:e.line,excerpt:e.excerpt})),structure:{title:r.title,subKind:r.subKind,files:r.files.map(e=>({path:e.path,action:e.action,role:e.role,unit:e.unit,loadMode:e.loadMode,loadVia:e.loadVia,purpose:e.purpose})),segments:r.segments.map(e=>({path:e.path,startLine:e.startLine,endLine:e.endLine,to:e.to,disposition:e.disposition,into:e.into?{path:e.into.path,line:e.into.line}:null,reason:e.reason})),reorder:r.reorder?{path:r.reorder.path,startLine:r.reorder.startLine,endLine:r.reorder.endLine,steps:r.reorder.steps.map(e=>({from:e.from,reason:e.reason}))}:null,toolMoves:r.toolMoves.map(e=>({tool:e.tool,fromUnit:e.fromUnit,toUnit:e.toUnit,reason:e.reason})),split:n?{frontDoor:{job:n.frontDoor.job,skills:[...n.frontDoor.skills]},subAgents:n.subAgents.map(e=>({job:e.job,description:e.description,path:e.path,handoff:e.handoff??null,skills:e.skills.map(a=>({from:a.from,to:a.to})),tools:[...e.tools],movedKnowledge:s(e.movedKnowledge),neededKnowledge:s(e.neededKnowledge)}))}:null}}}function x(o,r=[]){return{evidence:[...o.map((t,i)=>({key:`f${i}`,kind:"finding",impact:t.kind,structure:null,cause:t.cause,category:t.category??null,question:t.question,site:t.site?{repo:t.siteRepo,path:t.site.path,line:t.site.line}:null,excerpt:t.excerpt,otherSites:t.otherSites.map(n=>({repo:n.repo,path:n.path,line:n.line,excerpt:n.excerpt})),fixSummaries:t.fixes.flatMap(n=>typeof n.summary=="string"&&n.summary.trim()?[n.summary]:[])})),...r.map((t,i)=>({key:`s${i}`,...u(t)}))],positions:[...o.map((t,i)=>({key:`f${i}`,target:"finding",index:i,fingerprint:p("finding",t)})),...r.map((t,i)=>({key:`s${i}`,target:"structure",index:i,fingerprint:p("structure",t)}))]}}function L(o,r){return d("sha256").update(l({batch:o,requestIdentity:r})).digest("hex")}export{x as a,L as b};