brass-runtime 1.19.2 → 1.21.0
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/CHANGELOG.md +88 -0
- package/dist/agent/cli/main.cjs +265 -43
- package/dist/agent/cli/main.d.ts +99 -0
- package/dist/agent/cli/main.js +238 -16
- package/dist/agent/cli/main.mjs +238 -16
- package/dist/agent/index.cjs +18 -2
- package/dist/agent/index.d.ts +60 -482
- package/dist/agent/index.js +17 -1
- package/dist/agent/index.mjs +17 -1
- package/dist/{chunk-QAHW7S3Q.cjs → chunk-62IBGQOU.cjs} +6 -6
- package/dist/{chunk-6AGAZD32.js → chunk-6LF3M4JC.js} +2 -2
- package/dist/{chunk-5X3MPWTR.mjs → chunk-6NXQL3IC.mjs} +370 -10
- package/dist/{chunk-J4F5KC3U.js → chunk-AI3M6624.js} +1260 -45
- package/dist/{chunk-TWEHIAUE.cjs → chunk-BDTBIYAM.cjs} +13 -13
- package/dist/{chunk-IA6BDGXW.mjs → chunk-D53GY2SZ.mjs} +2 -2
- package/dist/{chunk-IHY2EJTT.cjs → chunk-EX4VEKUF.cjs} +1340 -125
- package/dist/{chunk-UOKXJQAI.cjs → chunk-LA2PAO7J.cjs} +378 -18
- package/dist/{chunk-ZXXOXB3T.mjs → chunk-OS4F5HZE.mjs} +1 -1
- package/dist/{chunk-HKLZJ5UK.js → chunk-POH2WZBI.js} +370 -10
- package/dist/{chunk-6BNZS2A4.mjs → chunk-Q57ENQUW.mjs} +1260 -45
- package/dist/{chunk-BHX4MD35.js → chunk-VXZIP3IU.js} +1 -1
- package/dist/{defaultClient-hyVSNzSJ.d.ts → defaultClient-DLOa3gdw.d.ts} +101 -3
- package/dist/http/index.cjs +69 -33
- package/dist/http/index.d.ts +67 -4
- package/dist/http/index.js +37 -1
- package/dist/http/index.mjs +37 -1
- package/dist/http/testing.cjs +4 -4
- package/dist/http/testing.d.ts +1 -1
- package/dist/http/testing.js +1 -1
- package/dist/http/testing.mjs +1 -1
- package/dist/nodeWorkspaceDiscovery-Ami1UkMt.d.ts +631 -0
- package/dist/observability/index.cjs +3 -3
- package/dist/observability/index.d.ts +3 -3
- package/dist/observability/index.js +2 -2
- package/dist/observability/index.mjs +2 -2
- package/dist/perf/cli.cjs +18 -18
- package/dist/perf/cli.js +3 -3
- package/dist/perf/cli.mjs +3 -3
- package/dist/perf/index.cjs +5 -5
- package/dist/perf/index.js +3 -3
- package/dist/perf/index.mjs +3 -3
- package/dist/{server-BKKuzAW9.d.ts → server-BGXOabjo.d.ts} +1 -1
- package/package.json +1 -1
- package/wasm/pkg/package.json +1 -1
package/dist/agent/cli/main.mjs
CHANGED
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
import {
|
|
3
3
|
NodeShell,
|
|
4
4
|
autoApproveApprovals,
|
|
5
|
+
buildHostProfile,
|
|
5
6
|
discoverNodeWorkspaceRoot,
|
|
7
|
+
discoverValidationCommands,
|
|
8
|
+
extractSignals,
|
|
6
9
|
goalForAgentPreset,
|
|
7
10
|
isAgentPreset,
|
|
8
11
|
loadNodeAgentConfig,
|
|
@@ -14,10 +17,14 @@ import {
|
|
|
14
17
|
makeNodePatchService,
|
|
15
18
|
makeOpenAICompatibleLLM,
|
|
16
19
|
observationStatus,
|
|
20
|
+
patchQualitySummary,
|
|
21
|
+
patchValidationStatus,
|
|
17
22
|
runAgent,
|
|
23
|
+
sampleBeta,
|
|
24
|
+
selectStrategy,
|
|
18
25
|
summarizeAgentAction,
|
|
19
26
|
summarizeAgentObservation
|
|
20
|
-
} from "../../chunk-
|
|
27
|
+
} from "../../chunk-Q57ENQUW.mjs";
|
|
21
28
|
import "../../chunk-B5JD23U7.mjs";
|
|
22
29
|
import {
|
|
23
30
|
Runtime
|
|
@@ -28,7 +35,9 @@ import {
|
|
|
28
35
|
asyncEffect
|
|
29
36
|
} from "../../chunk-36I3M4UC.mjs";
|
|
30
37
|
import "../../chunk-UZQ3BB6W.mjs";
|
|
31
|
-
import
|
|
38
|
+
import {
|
|
39
|
+
__require
|
|
40
|
+
} from "../../chunk-Y6FXYEAI.mjs";
|
|
32
41
|
|
|
33
42
|
// src/agent/cli/approvals.ts
|
|
34
43
|
var dynamicImport = new Function("specifier", "return import(specifier)");
|
|
@@ -242,8 +251,8 @@ var llmCheck = (config) => {
|
|
|
242
251
|
return {
|
|
243
252
|
id: "llm",
|
|
244
253
|
label: "LLM provider",
|
|
245
|
-
status: keyPresent ? "ok" : "
|
|
246
|
-
message: keyPresent ? `Google/Gemini provider is configured (${provider}).` : "
|
|
254
|
+
status: keyPresent ? "ok" : "warn",
|
|
255
|
+
message: keyPresent ? `Google/Gemini provider is configured (${provider}).` : "No LLM provider configured. Tool-only workflows will work; planning requires LLM credentials."
|
|
247
256
|
};
|
|
248
257
|
}
|
|
249
258
|
if (provider === "openai" || provider === "openai-compatible") {
|
|
@@ -252,8 +261,8 @@ var llmCheck = (config) => {
|
|
|
252
261
|
return {
|
|
253
262
|
id: "llm",
|
|
254
263
|
label: "LLM provider",
|
|
255
|
-
status: endpointPresent && keyPresent ? "ok" : "
|
|
256
|
-
message: endpointPresent && keyPresent ? `OpenAI-compatible provider is configured (${provider}).` : "
|
|
264
|
+
status: endpointPresent && keyPresent ? "ok" : "warn",
|
|
265
|
+
message: endpointPresent && keyPresent ? `OpenAI-compatible provider is configured (${provider}).` : "No LLM provider configured. Tool-only workflows will work; planning requires LLM credentials."
|
|
257
266
|
};
|
|
258
267
|
}
|
|
259
268
|
if (hasEnv("BRASS_GOOGLE_API_KEY") || hasEnv("GOOGLE_API_KEY") || hasEnv("GEMINI_API_KEY")) {
|
|
@@ -276,7 +285,7 @@ var llmCheck = (config) => {
|
|
|
276
285
|
id: "llm",
|
|
277
286
|
label: "LLM provider",
|
|
278
287
|
status: "warn",
|
|
279
|
-
message: "No
|
|
288
|
+
message: "No LLM provider configured. Tool-only workflows will work; planning requires LLM credentials."
|
|
280
289
|
};
|
|
281
290
|
};
|
|
282
291
|
var workspaceSettingsCommand = (cwd) => {
|
|
@@ -967,6 +976,73 @@ var printAgentInitResult = (result) => {
|
|
|
967
976
|
}
|
|
968
977
|
};
|
|
969
978
|
|
|
979
|
+
// src/agent/core/patchStrategy/reward.ts
|
|
980
|
+
var observationsAfterPatch = (state) => {
|
|
981
|
+
const patchIndex = [...state.observations].map((obs) => obs.type).lastIndexOf("patch.applied");
|
|
982
|
+
return patchIndex < 0 ? [] : state.observations.slice(patchIndex + 1);
|
|
983
|
+
};
|
|
984
|
+
var hasPatchProduced = (state) => state.observations.some((obs) => obs.type === "patch.applied");
|
|
985
|
+
var computeReward = (state) => {
|
|
986
|
+
if (!hasPatchProduced(state)) {
|
|
987
|
+
return 0;
|
|
988
|
+
}
|
|
989
|
+
const commands = discoverValidationCommands(state).validationCommands;
|
|
990
|
+
const status = patchValidationStatus(commands, observationsAfterPatch(state));
|
|
991
|
+
const quality = patchQualitySummary(state);
|
|
992
|
+
if (status.type === "not-run") {
|
|
993
|
+
return 1;
|
|
994
|
+
}
|
|
995
|
+
if (status.type === "pending") {
|
|
996
|
+
return 0;
|
|
997
|
+
}
|
|
998
|
+
if (status.type === "passed") {
|
|
999
|
+
if (quality.repairAttemptsUsed > 0 && quality.maxRepairAttempts > 0) {
|
|
1000
|
+
const reward = 1 - quality.repairAttemptsUsed / quality.maxRepairAttempts;
|
|
1001
|
+
return Math.max(0, Math.min(1, reward));
|
|
1002
|
+
}
|
|
1003
|
+
return 1;
|
|
1004
|
+
}
|
|
1005
|
+
return 0;
|
|
1006
|
+
};
|
|
1007
|
+
|
|
1008
|
+
// src/agent/core/patchStrategy/store.ts
|
|
1009
|
+
import { readFile, writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
|
|
1010
|
+
import { join as join4, dirname as dirname2 } from "path";
|
|
1011
|
+
var STORE_PATH = ".brass/patch-strategy.json";
|
|
1012
|
+
var loadRewardStore = async (cwd) => {
|
|
1013
|
+
try {
|
|
1014
|
+
const filePath = join4(cwd, STORE_PATH);
|
|
1015
|
+
const raw = await readFile(filePath, "utf-8");
|
|
1016
|
+
const data = JSON.parse(raw);
|
|
1017
|
+
if (typeof data !== "object" || data === null || !("version" in data) || data.version !== 1) {
|
|
1018
|
+
return [];
|
|
1019
|
+
}
|
|
1020
|
+
const stored = data;
|
|
1021
|
+
if (!Array.isArray(stored.entries)) {
|
|
1022
|
+
return [];
|
|
1023
|
+
}
|
|
1024
|
+
return stored.entries;
|
|
1025
|
+
} catch (err) {
|
|
1026
|
+
return [];
|
|
1027
|
+
}
|
|
1028
|
+
};
|
|
1029
|
+
var flushRewardStore = async (cwd, entries) => {
|
|
1030
|
+
try {
|
|
1031
|
+
const filePath = join4(cwd, STORE_PATH);
|
|
1032
|
+
const data = {
|
|
1033
|
+
version: 1,
|
|
1034
|
+
entries
|
|
1035
|
+
};
|
|
1036
|
+
await mkdir2(dirname2(filePath), { recursive: true });
|
|
1037
|
+
await writeFile2(filePath, JSON.stringify(data, null, 2), "utf-8");
|
|
1038
|
+
} catch (err) {
|
|
1039
|
+
console.warn(
|
|
1040
|
+
"[patchStrategy] Failed to flush reward store:",
|
|
1041
|
+
err instanceof Error ? err.message : String(err)
|
|
1042
|
+
);
|
|
1043
|
+
}
|
|
1044
|
+
};
|
|
1045
|
+
|
|
970
1046
|
// src/agent/cli/main.ts
|
|
971
1047
|
var dynamicImport2 = new Function("specifier", "return import(specifier)");
|
|
972
1048
|
var readPatchFile = async (cwd, patchFile) => {
|
|
@@ -999,6 +1075,7 @@ var parseCliArgs = (argv) => {
|
|
|
999
1075
|
let modeSpecified = false;
|
|
1000
1076
|
let showHelp = false;
|
|
1001
1077
|
let output = "human";
|
|
1078
|
+
let outputSpecified = false;
|
|
1002
1079
|
let approval = "auto";
|
|
1003
1080
|
let approvalSpecified = false;
|
|
1004
1081
|
let configPath;
|
|
@@ -1020,6 +1097,7 @@ var parseCliArgs = (argv) => {
|
|
|
1020
1097
|
let initProfile = "default";
|
|
1021
1098
|
let initDryRun = false;
|
|
1022
1099
|
let language;
|
|
1100
|
+
let hostProfile = false;
|
|
1023
1101
|
const goalParts = [];
|
|
1024
1102
|
for (let index = 0; index < argv.length; index += 1) {
|
|
1025
1103
|
const arg = argv[index];
|
|
@@ -1035,6 +1113,10 @@ var parseCliArgs = (argv) => {
|
|
|
1035
1113
|
doctor = true;
|
|
1036
1114
|
continue;
|
|
1037
1115
|
}
|
|
1116
|
+
if (arg === "--host-profile") {
|
|
1117
|
+
hostProfile = true;
|
|
1118
|
+
continue;
|
|
1119
|
+
}
|
|
1038
1120
|
if (arg === "--where" || arg === "--print-workspace") {
|
|
1039
1121
|
where = true;
|
|
1040
1122
|
continue;
|
|
@@ -1087,14 +1169,17 @@ var parseCliArgs = (argv) => {
|
|
|
1087
1169
|
}
|
|
1088
1170
|
if (arg === "--json") {
|
|
1089
1171
|
output = "json";
|
|
1172
|
+
outputSpecified = true;
|
|
1090
1173
|
continue;
|
|
1091
1174
|
}
|
|
1092
1175
|
if (arg === "--events-json") {
|
|
1093
1176
|
output = "events-json";
|
|
1177
|
+
outputSpecified = true;
|
|
1094
1178
|
continue;
|
|
1095
1179
|
}
|
|
1096
1180
|
if (arg === "--protocol-json") {
|
|
1097
1181
|
output = "protocol-json";
|
|
1182
|
+
outputSpecified = true;
|
|
1098
1183
|
continue;
|
|
1099
1184
|
}
|
|
1100
1185
|
if (arg === "--protocol-full-patches") {
|
|
@@ -1241,6 +1326,7 @@ var parseCliArgs = (argv) => {
|
|
|
1241
1326
|
modeSpecified,
|
|
1242
1327
|
showHelp,
|
|
1243
1328
|
output,
|
|
1329
|
+
outputSpecified,
|
|
1244
1330
|
approval,
|
|
1245
1331
|
approvalSpecified,
|
|
1246
1332
|
...configPath ? { configPath } : {},
|
|
@@ -1259,6 +1345,7 @@ var parseCliArgs = (argv) => {
|
|
|
1259
1345
|
initForce,
|
|
1260
1346
|
initProfile,
|
|
1261
1347
|
initDryRun,
|
|
1348
|
+
hostProfile,
|
|
1262
1349
|
...language ? { language } : {},
|
|
1263
1350
|
...saveRunDir ? { saveRunDir } : {},
|
|
1264
1351
|
...patchFile ? { patchFile } : {}
|
|
@@ -1494,6 +1581,91 @@ var printHelp = () => {
|
|
|
1494
1581
|
" BRASS_LLM_PROVIDER=openai-compatible BRASS_LLM_ENDPOINT=... BRASS_LLM_API_KEY=..."
|
|
1495
1582
|
].join("\n"));
|
|
1496
1583
|
};
|
|
1584
|
+
var KNOWN_WORKSPACE_MARKERS = [".vscode", ".cursor", ".kiro", ".git", ".github", ".gitlab-ci.yml", "Jenkinsfile"];
|
|
1585
|
+
var scanWorkspaceMarkers = (cwd) => {
|
|
1586
|
+
try {
|
|
1587
|
+
const fs = __require("fs");
|
|
1588
|
+
const path = __require("path");
|
|
1589
|
+
const found = [];
|
|
1590
|
+
for (const marker of KNOWN_WORKSPACE_MARKERS) {
|
|
1591
|
+
if (fs.existsSync(path.join(cwd, marker))) {
|
|
1592
|
+
found.push(marker);
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
return found;
|
|
1596
|
+
} catch {
|
|
1597
|
+
return [];
|
|
1598
|
+
}
|
|
1599
|
+
};
|
|
1600
|
+
var buildHostProfileFromProcess = (resolved) => {
|
|
1601
|
+
const workspaceMarkers = scanWorkspaceMarkers(resolved.cwd);
|
|
1602
|
+
const configPaths = [];
|
|
1603
|
+
if (resolved.resolvedConfigPath) {
|
|
1604
|
+
configPaths.push(resolved.resolvedConfigPath);
|
|
1605
|
+
}
|
|
1606
|
+
const input = {
|
|
1607
|
+
argv: process.argv,
|
|
1608
|
+
env: process.env,
|
|
1609
|
+
stdoutIsTTY: process.stdout.isTTY ?? false,
|
|
1610
|
+
stdinIsTTY: process.stdin.isTTY ?? false,
|
|
1611
|
+
ttyColumns: process.stdout.columns,
|
|
1612
|
+
parentProcessName: void 0,
|
|
1613
|
+
workspaceMarkers,
|
|
1614
|
+
stdinFirstLine: void 0,
|
|
1615
|
+
configPaths
|
|
1616
|
+
};
|
|
1617
|
+
return buildHostProfile(input);
|
|
1618
|
+
};
|
|
1619
|
+
var printHostProfileHuman = (profile) => {
|
|
1620
|
+
console.log("Transport: " + profile.transport);
|
|
1621
|
+
console.log("");
|
|
1622
|
+
console.log("Capabilities:");
|
|
1623
|
+
const caps = profile.capabilities;
|
|
1624
|
+
console.log(" hasOwnLLM: " + caps.hasOwnLLM);
|
|
1625
|
+
console.log(" wantsJson: " + caps.wantsJson);
|
|
1626
|
+
console.log(" supportsStreamingEvents: " + caps.supportsStreamingEvents);
|
|
1627
|
+
console.log(" supportsMcp: " + caps.supportsMcp);
|
|
1628
|
+
console.log(" canAskApproval: " + caps.canAskApproval);
|
|
1629
|
+
console.log(" canRenderDiff: " + caps.canRenderDiff);
|
|
1630
|
+
console.log(" canApplyPatch: " + caps.canApplyPatch);
|
|
1631
|
+
console.log(" interactiveTty: " + caps.interactiveTty);
|
|
1632
|
+
console.log("");
|
|
1633
|
+
console.log("Constraints:");
|
|
1634
|
+
const con = profile.constraints;
|
|
1635
|
+
console.log(" readOnlyByDefault: " + con.readOnlyByDefault);
|
|
1636
|
+
console.log(" patchPreviewRequired: " + con.patchPreviewRequired);
|
|
1637
|
+
console.log(" requireNoNetwork: " + con.requireNoNetwork);
|
|
1638
|
+
console.log("");
|
|
1639
|
+
console.log("Identity:");
|
|
1640
|
+
if (profile.identity) {
|
|
1641
|
+
console.log(" name: " + profile.identity.name);
|
|
1642
|
+
console.log(" confidence: " + profile.identity.confidence);
|
|
1643
|
+
} else {
|
|
1644
|
+
console.log(" (none detected)");
|
|
1645
|
+
}
|
|
1646
|
+
};
|
|
1647
|
+
var applyCapabilityDefaults = (resolved) => {
|
|
1648
|
+
const profile = buildHostProfileFromProcess(resolved);
|
|
1649
|
+
const caps = profile.capabilities;
|
|
1650
|
+
let output = resolved.output;
|
|
1651
|
+
let approval = resolved.approval;
|
|
1652
|
+
if (!resolved.outputSpecified) {
|
|
1653
|
+
if (caps.supportsStreamingEvents) {
|
|
1654
|
+
output = "events-json";
|
|
1655
|
+
} else if (caps.wantsJson) {
|
|
1656
|
+
output = "json";
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
if (!resolved.approvalSpecified) {
|
|
1660
|
+
if (!caps.canAskApproval) {
|
|
1661
|
+
approval = "deny";
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
if (output === resolved.output && approval === resolved.approval) {
|
|
1665
|
+
return resolved;
|
|
1666
|
+
}
|
|
1667
|
+
return { ...resolved, output, approval };
|
|
1668
|
+
};
|
|
1497
1669
|
var envByName = (name) => name ? process.env[name] : void 0;
|
|
1498
1670
|
var makeGoogleLLMFromEnv = (config) => {
|
|
1499
1671
|
const apiKey = envByName(config?.apiKeyEnv) ?? process.env.BRASS_GOOGLE_API_KEY ?? process.env.GOOGLE_API_KEY ?? process.env.GEMINI_API_KEY;
|
|
@@ -1518,7 +1690,7 @@ var makeOpenAICompatibleLLMFromEnv = (config) => {
|
|
|
1518
1690
|
if (!endpoint || !apiKey) return void 0;
|
|
1519
1691
|
return makeOpenAICompatibleLLM({ endpoint, apiKey, model });
|
|
1520
1692
|
};
|
|
1521
|
-
var
|
|
1693
|
+
var makeLLMFromEnvOptional = (config) => {
|
|
1522
1694
|
const provider = (process.env.BRASS_LLM_PROVIDER ?? config?.provider)?.trim().toLowerCase();
|
|
1523
1695
|
const fakeResponse = process.env.BRASS_FAKE_LLM_RESPONSE ?? config?.fakeResponse;
|
|
1524
1696
|
if (provider === "fake") return makeFakeLLM({ content: fakeResponse });
|
|
@@ -1543,7 +1715,7 @@ var makeLLMFromEnv = (config) => {
|
|
|
1543
1715
|
if (provider) {
|
|
1544
1716
|
throw new Error(`Unsupported LLM provider: ${provider}`);
|
|
1545
1717
|
}
|
|
1546
|
-
return makeGoogleLLMFromEnv(config) ?? makeOpenAICompatibleLLMFromEnv(config)
|
|
1718
|
+
return makeGoogleLLMFromEnv(config) ?? makeOpenAICompatibleLLMFromEnv(config);
|
|
1547
1719
|
};
|
|
1548
1720
|
var parseApprovalModeFromEnv = () => {
|
|
1549
1721
|
const raw = process.env.BRASS_AGENT_APPROVAL?.trim().toLowerCase();
|
|
@@ -1831,11 +2003,12 @@ var printHumanFinalSummary = (state) => {
|
|
|
1831
2003
|
var makeEventsSink = (parsed, compactOptions) => parsed.output === "human" ? createHumanEventSink(parsed.resolvedConfigPath) : parsed.output === "events-json" ? createJsonEventSink(compactOptions) : parsed.output === "protocol-json" ? createProtocolEventSink(compactOptions) : void 0;
|
|
1832
2004
|
var makeAgentEnv = (parsed, events) => {
|
|
1833
2005
|
const shell = NodeShell;
|
|
2006
|
+
const llm = makeLLMFromEnvOptional(parsed.config.llm);
|
|
1834
2007
|
return {
|
|
1835
2008
|
shell,
|
|
1836
2009
|
fs: makeNodeFileSystem(shell),
|
|
1837
2010
|
patch: makeNodePatchService(shell),
|
|
1838
|
-
llm
|
|
2011
|
+
llm,
|
|
1839
2012
|
permissions: makeConfiguredPermissions(parsed.config.permissions),
|
|
1840
2013
|
approvals: makeApprovalServiceFromCli(parsed),
|
|
1841
2014
|
...events ? { events } : {},
|
|
@@ -1855,21 +2028,44 @@ var runCliAgent = async (parsed, run, compactOptions, events) => {
|
|
|
1855
2028
|
const env = makeAgentEnv(parsed, events);
|
|
1856
2029
|
const runtime = new Runtime({ env });
|
|
1857
2030
|
const initialPatch = run.patchFile ? await readPatchFile(run.cwd, run.patchFile) : void 0;
|
|
2031
|
+
const rewardHistory = await loadRewardStore(run.cwd);
|
|
1858
2032
|
const state = await runtime.toPromise(
|
|
1859
2033
|
runAgent(runtime, {
|
|
1860
2034
|
id: `agent-${Date.now()}-${run.index + 1}`,
|
|
1861
2035
|
cwd: run.cwd,
|
|
1862
2036
|
text: run.goalText,
|
|
1863
2037
|
mode: run.mode,
|
|
2038
|
+
llmAvailable: env.llm !== void 0,
|
|
1864
2039
|
...parsed.config.project ? { project: parsed.config.project } : {},
|
|
1865
2040
|
...parsed.config.context ? { context: parsed.config.context } : {},
|
|
1866
2041
|
...parsed.config.patchQuality ? { patchQuality: parsed.config.patchQuality } : {},
|
|
1867
2042
|
...parsed.config.rollback ? { rollback: parsed.config.rollback } : {},
|
|
1868
2043
|
...parsed.config.redaction ? { redaction: parsed.config.redaction } : {},
|
|
1869
2044
|
...parsed.language ? { language: { response: parsed.language } } : parsed.config.language ? { language: parsed.config.language } : {},
|
|
1870
|
-
...initialPatch ? { initialPatch, initialPatchMode: run.patchFileMode } : {}
|
|
2045
|
+
...initialPatch ? { initialPatch, initialPatchMode: run.patchFileMode } : {},
|
|
2046
|
+
...parsed.config.patchStrategy ? { patchStrategy: parsed.config.patchStrategy } : {},
|
|
2047
|
+
rewardHistory
|
|
1871
2048
|
})
|
|
1872
2049
|
);
|
|
2050
|
+
try {
|
|
2051
|
+
if (state.goal.patchStrategy?.enabled !== false) {
|
|
2052
|
+
const reward = computeReward(state);
|
|
2053
|
+
const signals = extractSignals(state);
|
|
2054
|
+
const selectedArm = selectStrategy(
|
|
2055
|
+
signals,
|
|
2056
|
+
state.goal.patchStrategy,
|
|
2057
|
+
rewardHistory,
|
|
2058
|
+
{ sampleBeta: (a, b) => sampleBeta(a, b, Math.random), random: Math.random }
|
|
2059
|
+
);
|
|
2060
|
+
const newEntry = {
|
|
2061
|
+
arm: selectedArm,
|
|
2062
|
+
reward,
|
|
2063
|
+
timestamp: Date.now()
|
|
2064
|
+
};
|
|
2065
|
+
await flushRewardStore(run.cwd, [...rewardHistory, newEntry]);
|
|
2066
|
+
}
|
|
2067
|
+
} catch {
|
|
2068
|
+
}
|
|
1873
2069
|
if (run.saveRunDir) {
|
|
1874
2070
|
await writeRunArtifacts(state, run.saveRunDir, compactOptions);
|
|
1875
2071
|
}
|
|
@@ -1925,7 +2121,8 @@ var printWorkspaceWhere = (parsed) => {
|
|
|
1925
2121
|
if (result.envFiles.length > 0) console.log(`env: ${result.envFiles.join(", ")}`);
|
|
1926
2122
|
};
|
|
1927
2123
|
var main = async () => {
|
|
1928
|
-
const
|
|
2124
|
+
const rawParsed = await resolveParsedConfig(parseCliArgs(process.argv.slice(2)));
|
|
2125
|
+
const parsed = applyCapabilityDefaults(rawParsed);
|
|
1929
2126
|
const isBatch = parsed.batchRuns.length > 0;
|
|
1930
2127
|
if (parsed.showHelp) {
|
|
1931
2128
|
printHelp();
|
|
@@ -1965,6 +2162,22 @@ var main = async () => {
|
|
|
1965
2162
|
process.exitCode = report.status === "fail" ? 1 : 0;
|
|
1966
2163
|
return;
|
|
1967
2164
|
}
|
|
2165
|
+
if (parsed.hostProfile) {
|
|
2166
|
+
try {
|
|
2167
|
+
const profile = buildHostProfileFromProcess(parsed);
|
|
2168
|
+
if (parsed.output === "json") {
|
|
2169
|
+
console.log(JSON.stringify(profile, null, 2));
|
|
2170
|
+
} else {
|
|
2171
|
+
printHostProfileHuman(profile);
|
|
2172
|
+
}
|
|
2173
|
+
process.exit(0);
|
|
2174
|
+
} catch (err) {
|
|
2175
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
2176
|
+
process.stderr.write(`Error: host profile detection failed: ${message}
|
|
2177
|
+
`);
|
|
2178
|
+
process.exit(1);
|
|
2179
|
+
}
|
|
2180
|
+
}
|
|
1968
2181
|
if (!parsed.goalText && !isBatch) {
|
|
1969
2182
|
printHelp();
|
|
1970
2183
|
process.exit(1);
|
|
@@ -2021,7 +2234,16 @@ var main = async () => {
|
|
|
2021
2234
|
process.exitCode = result.exitCode;
|
|
2022
2235
|
}
|
|
2023
2236
|
};
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2237
|
+
if (typeof process !== "undefined" && !process.env.VITEST) {
|
|
2238
|
+
main().catch((error) => {
|
|
2239
|
+
console.error(error);
|
|
2240
|
+
process.exit(1);
|
|
2241
|
+
});
|
|
2242
|
+
}
|
|
2243
|
+
export {
|
|
2244
|
+
applyCapabilityDefaults,
|
|
2245
|
+
buildHostProfileFromProcess,
|
|
2246
|
+
makeLLMFromEnvOptional,
|
|
2247
|
+
parseCliArgs,
|
|
2248
|
+
printHostProfileHuman
|
|
2249
|
+
};
|
package/dist/agent/index.cjs
CHANGED
|
@@ -73,7 +73,15 @@
|
|
|
73
73
|
|
|
74
74
|
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
var _chunkEX4VEKUFcjs = require('../chunk-EX4VEKUF.cjs');
|
|
77
85
|
require('../chunk-SA6HUJVI.cjs');
|
|
78
86
|
require('../chunk-JKHBEWQA.cjs');
|
|
79
87
|
require('../chunk-MVGUEJ5Z.cjs');
|
|
@@ -154,4 +162,12 @@ require('../chunk-OBGZSXTJ.cjs');
|
|
|
154
162
|
|
|
155
163
|
|
|
156
164
|
|
|
157
|
-
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
exports.AGENT_CONFIG_FILE_NAMES = _chunkEX4VEKUFcjs.AGENT_CONFIG_FILE_NAMES; exports.CI_INDICATORS = _chunkEX4VEKUFcjs.CI_INDICATORS; exports.NodeShell = _chunkEX4VEKUFcjs.NodeShell; exports.PROJECT_LOCKFILE_PROBES = _chunkEX4VEKUFcjs.PROJECT_LOCKFILE_PROBES; exports.PROJECT_PROFILE_PROBES = _chunkEX4VEKUFcjs.PROJECT_PROFILE_PROBES; exports.autoApproveApprovals = _chunkEX4VEKUFcjs.autoApproveApprovals; exports.buildHostProfile = _chunkEX4VEKUFcjs.buildHostProfile; exports.canAutoRollback = _chunkEX4VEKUFcjs.canAutoRollback; exports.canRequestPatchRepair = _chunkEX4VEKUFcjs.canRequestPatchRepair; exports.collectHostSignals = _chunkEX4VEKUFcjs.collectHostSignals; exports.commandForScript = _chunkEX4VEKUFcjs.commandForScript; exports.decideNextAction = _chunkEX4VEKUFcjs.decideNextAction; exports.deepFreeze = _chunkEX4VEKUFcjs.deepFreeze; exports.defaultPermissions = _chunkEX4VEKUFcjs.defaultPermissions; exports.deriveContextSearchQueries = _chunkEX4VEKUFcjs.deriveContextSearchQueries; exports.describeCommandDiscovery = _chunkEX4VEKUFcjs.describeCommandDiscovery; exports.describeContextDiscovery = _chunkEX4VEKUFcjs.describeContextDiscovery; exports.describeLanguagePolicy = _chunkEX4VEKUFcjs.describeLanguagePolicy; exports.describePatchQuality = _chunkEX4VEKUFcjs.describePatchQuality; exports.describeProjectProfile = _chunkEX4VEKUFcjs.describeProjectProfile; exports.describeRollbackSafety = _chunkEX4VEKUFcjs.describeRollbackSafety; exports.discoverNodeWorkspaceRoot = _chunkEX4VEKUFcjs.discoverNodeWorkspaceRoot; exports.discoverPackageManager = _chunkEX4VEKUFcjs.discoverPackageManager; exports.discoverProjectProfile = _chunkEX4VEKUFcjs.discoverProjectProfile; exports.discoverValidationCommands = _chunkEX4VEKUFcjs.discoverValidationCommands; exports.emitAgentEvent = _chunkEX4VEKUFcjs.emitAgentEvent; exports.emitAgentEvents = _chunkEX4VEKUFcjs.emitAgentEvents; exports.errorEventFor = _chunkEX4VEKUFcjs.errorEventFor; exports.extractLikelyFilePaths = _chunkEX4VEKUFcjs.extractLikelyFilePaths; exports.extractPatchPaths = _chunkEX4VEKUFcjs.extractPatchPaths; exports.extractUnifiedDiff = _chunkEX4VEKUFcjs.extractUnifiedDiff; exports.goalForAgentPreset = _chunkEX4VEKUFcjs.goalForAgentPreset; exports.inferCapabilities = _chunkEX4VEKUFcjs.inferCapabilities; exports.inferConstraints = _chunkEX4VEKUFcjs.inferConstraints; exports.inferOptionalIdentity = _chunkEX4VEKUFcjs.inferOptionalIdentity; exports.inferTransport = _chunkEX4VEKUFcjs.inferTransport; exports.inferUserLanguage = _chunkEX4VEKUFcjs.inferUserLanguage; exports.initialAgentState = _chunkEX4VEKUFcjs.initialAgentState; exports.invokeAction = _chunkEX4VEKUFcjs.invokeAction; exports.isAgentConfigApprovalMode = _chunkEX4VEKUFcjs.isAgentConfigApprovalMode; exports.isAgentConfigLLMProvider = _chunkEX4VEKUFcjs.isAgentConfigLLMProvider; exports.isAgentConfigMode = _chunkEX4VEKUFcjs.isAgentConfigMode; exports.isAgentPreset = _chunkEX4VEKUFcjs.isAgentPreset; exports.isRedactionEnabled = _chunkEX4VEKUFcjs.isRedactionEnabled; exports.isTerminal = _chunkEX4VEKUFcjs.isTerminal; exports.latestUnappliedPatch = _chunkEX4VEKUFcjs.latestUnappliedPatch; exports.loadNodeAgentConfig = _chunkEX4VEKUFcjs.loadNodeAgentConfig; exports.makeAutoDenyApprovals = _chunkEX4VEKUFcjs.makeAutoDenyApprovals; exports.makeConfiguredPermissions = _chunkEX4VEKUFcjs.makeConfiguredPermissions; exports.makeFakeLLM = _chunkEX4VEKUFcjs.makeFakeLLM; exports.makeGoogleGenerativeAILLM = _chunkEX4VEKUFcjs.makeGoogleGenerativeAILLM; exports.makeNodeFileSystem = _chunkEX4VEKUFcjs.makeNodeFileSystem; exports.makeNodePatchService = _chunkEX4VEKUFcjs.makeNodePatchService; exports.makeOpenAICompatibleLLM = _chunkEX4VEKUFcjs.makeOpenAICompatibleLLM; exports.nextContextDiscoveryAction = _chunkEX4VEKUFcjs.nextContextDiscoveryAction; exports.nextProjectProbeAction = _chunkEX4VEKUFcjs.nextProjectProbeAction; exports.nextUnrunValidationCommand = _chunkEX4VEKUFcjs.nextUnrunValidationCommand; exports.nowMillis = _chunkEX4VEKUFcjs.nowMillis; exports.observationEventFor = _chunkEX4VEKUFcjs.observationEventFor; exports.observationStatus = _chunkEX4VEKUFcjs.observationStatus; exports.parseProjectPackageJson = _chunkEX4VEKUFcjs.parseProjectPackageJson; exports.patchQualitySummary = _chunkEX4VEKUFcjs.patchQualitySummary; exports.patchRepairAttemptsUsed = _chunkEX4VEKUFcjs.patchRepairAttemptsUsed; exports.patchValidationStatus = _chunkEX4VEKUFcjs.patchValidationStatus; exports.projectProfileProbePending = _chunkEX4VEKUFcjs.projectProfileProbePending; exports.redactText = _chunkEX4VEKUFcjs.redactText; exports.reduceAgentState = _chunkEX4VEKUFcjs.reduceAgentState; exports.responseLanguageName = _chunkEX4VEKUFcjs.responseLanguageName; exports.retry = _chunkEX4VEKUFcjs.retry; exports.rollbackSafetySummary = _chunkEX4VEKUFcjs.rollbackSafetySummary; exports.runAgent = _chunkEX4VEKUFcjs.runAgent; exports.runStatusFor = _chunkEX4VEKUFcjs.runStatusFor; exports.shouldContinueRollbackStack = _chunkEX4VEKUFcjs.shouldContinueRollbackStack; exports.sleep = _chunkEX4VEKUFcjs.sleep; exports.spanishLike = _chunkEX4VEKUFcjs.spanishLike; exports.splitCommand = _chunkEX4VEKUFcjs.splitCommand; exports.summarizeAgentAction = _chunkEX4VEKUFcjs.summarizeAgentAction; exports.summarizeAgentObservation = _chunkEX4VEKUFcjs.summarizeAgentObservation; exports.summarizeContextDiscovery = _chunkEX4VEKUFcjs.summarizeContextDiscovery; exports.timeout = _chunkEX4VEKUFcjs.timeout; exports.unappliedPatchStack = _chunkEX4VEKUFcjs.unappliedPatchStack; exports.workspaceValidationStatus = _chunkEX4VEKUFcjs.workspaceValidationStatus;
|