akm-cli 0.9.24 → 0.9.25-alpha.1
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 +294 -0
- package/dist/commands/health/checks.js +10 -11
- package/dist/commands/improve/consolidate/pair-pass.js +3 -2
- package/dist/commands/improve/consolidate.js +3 -2
- package/dist/commands/improve/execution.js +4 -10
- package/dist/commands/improve/extract-prompt.js +4 -4
- package/dist/commands/improve/extract.js +10 -13
- package/dist/commands/improve/improve-cli.js +32 -33
- package/dist/commands/improve/improve-strategies.js +49 -43
- package/dist/commands/improve/improve-usage-report.js +8 -17
- package/dist/commands/improve/preparation.js +3 -1
- package/dist/commands/improve/reflect.js +108 -172
- package/dist/commands/improve/stage.js +69 -18
- package/dist/commands/proposal/drain.js +14 -2
- package/dist/commands/proposal/proposal-cli.js +1 -5
- package/dist/commands/proposal/propose-cli.js +2 -2
- package/dist/commands/proposal/propose.js +80 -83
- package/dist/commands/remember.js +3 -3
- package/dist/commands/sources/schema-repair.js +1 -1
- package/dist/core/config/config-schema.js +37 -60
- package/dist/core/config/engine-semantics.js +15 -11
- package/dist/core/config/schema/engines.js +33 -15
- package/dist/core/config/schema/improve-processes.js +2 -2
- package/dist/core/improve-result.js +3 -3
- package/dist/core/structured.js +10 -0
- package/dist/execution/source.js +14 -0
- package/dist/indexer/passes/memory-inference.js +2 -1
- package/dist/integrations/agent/builder-shared.js +15 -0
- package/dist/integrations/agent/config.js +2 -0
- package/dist/integrations/agent/engine-resolution.js +16 -31
- package/dist/integrations/agent/execution.js +46 -21
- package/dist/integrations/agent/index.js +1 -1
- package/dist/integrations/agent/model-map.js +16 -15
- package/dist/integrations/agent/prompts.js +53 -76
- package/dist/integrations/agent/request-lowering.js +20 -9
- package/dist/integrations/agent/runner-dispatch.js +103 -4
- package/dist/integrations/agent/runner.js +8 -2
- package/dist/integrations/harnesses/aider/agent-builder.js +11 -23
- package/dist/integrations/harnesses/aider/index.js +0 -5
- package/dist/integrations/harnesses/amazonq/agent-builder.js +10 -21
- package/dist/integrations/harnesses/amazonq/index.js +0 -5
- package/dist/integrations/harnesses/claude/agent-builder.js +61 -38
- package/dist/integrations/harnesses/claude/index.js +0 -14
- package/dist/integrations/harnesses/codex/agent-builder.js +4 -4
- package/dist/integrations/harnesses/codex/index.js +0 -4
- package/dist/integrations/harnesses/copilot/agent-builder.js +4 -13
- package/dist/integrations/harnesses/copilot/index.js +2 -7
- package/dist/integrations/harnesses/gemini/agent-builder.js +4 -13
- package/dist/integrations/harnesses/gemini/index.js +0 -5
- package/dist/integrations/harnesses/ids.js +18 -10
- package/dist/integrations/harnesses/opencode/agent-builder.js +52 -10
- package/dist/integrations/harnesses/opencode/index.js +0 -8
- package/dist/integrations/harnesses/opencode/model-config.js +80 -0
- package/dist/integrations/harnesses/opencode/model-work-agent.js +80 -0
- package/dist/integrations/harnesses/opencode-sdk/harness.js +6 -7
- package/dist/integrations/harnesses/opencode-sdk/sdk-runner.js +168 -24
- package/dist/integrations/harnesses/openhands/agent-builder.js +8 -21
- package/dist/integrations/harnesses/openhands/index.js +0 -5
- package/dist/integrations/harnesses/pi/agent-builder.js +8 -21
- package/dist/integrations/harnesses/pi/index.js +0 -5
- package/dist/llm/client.js +5 -0
- package/dist/llm/feature-gate.js +10 -4
- package/dist/llm/index-passes.js +3 -6
- package/dist/llm/memory-infer.js +6 -5
- package/dist/llm/structured-call.js +33 -11
- package/dist/scripts/akm-migrate-node.js +298 -204
- package/dist/scripts/akm-migrate.js +298 -204
- package/dist/workflows/exec/step-work.js +6 -5
- package/dist/workflows/freeze/step-values.js +1 -1
- package/docs/reference/cli.md +29 -11
- package/docs/reference/configuration.md +168 -11
- package/docs/reference/workflow-schema.md +13 -9
- package/package.json +1 -1
- package/schemas/akm-config.json +36 -0
|
@@ -28236,16 +28236,16 @@ var BUILTIN_IMPROVE_STRATEGY_NAMES = [
|
|
|
28236
28236
|
"reflect-distill",
|
|
28237
28237
|
"proactive-maintenance"
|
|
28238
28238
|
];
|
|
28239
|
-
var
|
|
28240
|
-
reflect
|
|
28241
|
-
distill
|
|
28242
|
-
consolidate
|
|
28243
|
-
memoryInference
|
|
28244
|
-
extract
|
|
28245
|
-
validation
|
|
28246
|
-
triage
|
|
28247
|
-
|
|
28248
|
-
|
|
28239
|
+
var IMPROVE_ENGINE_PROCESSES = [
|
|
28240
|
+
"reflect",
|
|
28241
|
+
"distill",
|
|
28242
|
+
"consolidate",
|
|
28243
|
+
"memoryInference",
|
|
28244
|
+
"extract",
|
|
28245
|
+
"validation",
|
|
28246
|
+
"triage"
|
|
28247
|
+
];
|
|
28248
|
+
var IMPROVE_PROCESS_NAMES = [...IMPROVE_ENGINE_PROCESSES, "proactiveMaintenance"];
|
|
28249
28249
|
|
|
28250
28250
|
// src/core/improve-result.ts
|
|
28251
28251
|
var COMMON_FIELDS = [
|
|
@@ -35453,6 +35453,27 @@ var coerce = {
|
|
|
35453
35453
|
date: (arg) => ZodDate.create({ ...arg, coerce: true })
|
|
35454
35454
|
};
|
|
35455
35455
|
var NEVER = INVALID;
|
|
35456
|
+
// src/integrations/harnesses/ids.ts
|
|
35457
|
+
var OPENCODE_INFERENCE = ["temperature", "maxTokens", "contextLength", "enableThinking", "reasoningEffort"];
|
|
35458
|
+
var HARNESS_ID_TABLE = [
|
|
35459
|
+
{ id: "opencode", agentDispatch: true, enforcesModelWorkTools: true, inference: OPENCODE_INFERENCE },
|
|
35460
|
+
{ id: "claude", agentDispatch: true, enforcesModelWorkTools: true, inference: ["reasoningEffort"] },
|
|
35461
|
+
{ id: "opencode-sdk", agentDispatch: true, enforcesModelWorkTools: true, inference: OPENCODE_INFERENCE },
|
|
35462
|
+
{ id: "codex", agentDispatch: true, enforcesModelWorkTools: false, inference: [] },
|
|
35463
|
+
{ id: "copilot", agentDispatch: true, enforcesModelWorkTools: false, inference: [] },
|
|
35464
|
+
{ id: "pi", agentDispatch: true, enforcesModelWorkTools: false, inference: [] },
|
|
35465
|
+
{ id: "gemini", agentDispatch: true, enforcesModelWorkTools: false, inference: [] },
|
|
35466
|
+
{ id: "aider", agentDispatch: true, enforcesModelWorkTools: false, inference: [] },
|
|
35467
|
+
{ id: "amazonq", agentDispatch: true, enforcesModelWorkTools: false, inference: [] },
|
|
35468
|
+
{ id: "openhands", agentDispatch: true, enforcesModelWorkTools: false, inference: [] }
|
|
35469
|
+
];
|
|
35470
|
+
var VALID_HARNESS_IDS = Object.freeze(HARNESS_ID_TABLE.map((h) => h.id));
|
|
35471
|
+
var HARNESS_AGENT_DISPATCH_IDS = new Set(HARNESS_ID_TABLE.filter((h) => h.agentDispatch).map((h) => h.id));
|
|
35472
|
+
var HARNESS_MODEL_WORK_IDS = new Set(HARNESS_ID_TABLE.filter((h) => h.enforcesModelWorkTools).map((h) => h.id));
|
|
35473
|
+
function harnessInferenceKeys(platform) {
|
|
35474
|
+
return HARNESS_ID_TABLE.find((h) => h.id === platform)?.inference ?? [];
|
|
35475
|
+
}
|
|
35476
|
+
|
|
35456
35477
|
// src/core/extra-params.ts
|
|
35457
35478
|
var EXTRA_PARAMS_PROTECTED_TOP_LEVEL_KEYS = [
|
|
35458
35479
|
"model",
|
|
@@ -35682,22 +35703,6 @@ var EmbeddingConnectionConfigSchema = exports_external.object({
|
|
|
35682
35703
|
concurrency: positiveInt.max(16).optional()
|
|
35683
35704
|
}).passthrough();
|
|
35684
35705
|
|
|
35685
|
-
// src/integrations/harnesses/ids.ts
|
|
35686
|
-
var HARNESS_ID_TABLE = [
|
|
35687
|
-
{ id: "opencode", agentDispatch: true },
|
|
35688
|
-
{ id: "claude", agentDispatch: true },
|
|
35689
|
-
{ id: "opencode-sdk", agentDispatch: true },
|
|
35690
|
-
{ id: "codex", agentDispatch: true },
|
|
35691
|
-
{ id: "copilot", agentDispatch: true },
|
|
35692
|
-
{ id: "pi", agentDispatch: true },
|
|
35693
|
-
{ id: "gemini", agentDispatch: true },
|
|
35694
|
-
{ id: "aider", agentDispatch: true },
|
|
35695
|
-
{ id: "amazonq", agentDispatch: true },
|
|
35696
|
-
{ id: "openhands", agentDispatch: true }
|
|
35697
|
-
];
|
|
35698
|
-
var VALID_HARNESS_IDS = Object.freeze(HARNESS_ID_TABLE.map((h) => h.id));
|
|
35699
|
-
var HARNESS_AGENT_DISPATCH_IDS = new Set(HARNESS_ID_TABLE.filter((h) => h.agentDispatch).map((h) => h.id));
|
|
35700
|
-
|
|
35701
35706
|
// src/execution/limits.ts
|
|
35702
35707
|
var EXECUTION_MAX_TIMEOUT_MS = 2 ** 31 - 1;
|
|
35703
35708
|
|
|
@@ -35772,6 +35777,13 @@ var LlmEngineSchema = exports_external.object({
|
|
|
35772
35777
|
});
|
|
35773
35778
|
}
|
|
35774
35779
|
});
|
|
35780
|
+
var AGENT_INFERENCE_KEYS = [
|
|
35781
|
+
"temperature",
|
|
35782
|
+
"maxTokens",
|
|
35783
|
+
"contextLength",
|
|
35784
|
+
"enableThinking",
|
|
35785
|
+
"reasoningEffort"
|
|
35786
|
+
];
|
|
35775
35787
|
var AgentEngineSchema = exports_external.object({
|
|
35776
35788
|
kind: exports_external.literal("agent"),
|
|
35777
35789
|
platform: AgentPlatformSchema.refine((platform) => HARNESS_AGENT_DISPATCH_IDS.has(platform), {
|
|
@@ -35782,25 +35794,27 @@ var AgentEngineSchema = exports_external.object({
|
|
|
35782
35794
|
workspace: nonEmptyString.optional(),
|
|
35783
35795
|
model: nonEmptyString.optional(),
|
|
35784
35796
|
timeoutMs: timeoutMsField,
|
|
35785
|
-
llmEngine: engineName.optional()
|
|
35797
|
+
llmEngine: engineName.optional(),
|
|
35798
|
+
temperature: exports_external.number().finite().optional(),
|
|
35799
|
+
maxTokens: positiveInt.optional(),
|
|
35800
|
+
contextLength: positiveInt.optional(),
|
|
35801
|
+
enableThinking: exports_external.boolean().optional(),
|
|
35802
|
+
reasoningEffort: nonEmptyString.optional()
|
|
35786
35803
|
}).passthrough().superRefine((value, ctx) => {
|
|
35787
|
-
for (const key of [
|
|
35788
|
-
"provider",
|
|
35789
|
-
"endpoint",
|
|
35790
|
-
"apiKey",
|
|
35791
|
-
"apiKeyFile",
|
|
35792
|
-
"temperature",
|
|
35793
|
-
"maxTokens",
|
|
35794
|
-
"concurrency",
|
|
35795
|
-
"extraParams",
|
|
35796
|
-
"contextLength",
|
|
35797
|
-
"enableThinking",
|
|
35798
|
-
"reasoningEffort",
|
|
35799
|
-
"modelAliases"
|
|
35800
|
-
]) {
|
|
35804
|
+
for (const key of ["provider", "endpoint", "apiKey", "apiKeyFile", "concurrency", "extraParams", "modelAliases"]) {
|
|
35801
35805
|
if (key in value)
|
|
35802
35806
|
ctx.addIssue({ code: exports_external.ZodIssueCode.custom, path: [key], message: `${key} is not valid on an agent engine` });
|
|
35803
35807
|
}
|
|
35808
|
+
const translated = harnessInferenceKeys(value.platform);
|
|
35809
|
+
for (const key of AGENT_INFERENCE_KEYS) {
|
|
35810
|
+
if (key in value && !translated.includes(key)) {
|
|
35811
|
+
ctx.addIssue({
|
|
35812
|
+
code: exports_external.ZodIssueCode.custom,
|
|
35813
|
+
path: [key],
|
|
35814
|
+
message: `${key} is not valid on a ${value.platform} engine: ${translated.length > 0 ? `the platform translates only ${translated.join(", ")}` : "the platform translates no inference fields"}`
|
|
35815
|
+
});
|
|
35816
|
+
}
|
|
35817
|
+
}
|
|
35804
35818
|
if (value.platform !== "opencode-sdk" && value.llmEngine !== undefined) {
|
|
35805
35819
|
ctx.addIssue({
|
|
35806
35820
|
code: exports_external.ZodIssueCode.custom,
|
|
@@ -35973,7 +35987,7 @@ var ImproveProfileProcessesSchema = exports_external.object({
|
|
|
35973
35987
|
});
|
|
35974
35988
|
}
|
|
35975
35989
|
for (const [name, process2] of Object.entries(val)) {
|
|
35976
|
-
if (!(name
|
|
35990
|
+
if (!IMPROVE_PROCESS_NAMES.includes(name) && !RETIRED_PROCESS_NAMES.has(name) && process2 !== null && typeof process2 === "object" && process2.enabled === true) {
|
|
35977
35991
|
ctx.addIssue({
|
|
35978
35992
|
code: exports_external.ZodIssueCode.custom,
|
|
35979
35993
|
path: [name],
|
|
@@ -36399,13 +36413,27 @@ var AkmConfigSchema = AkmConfigBaseSchema.superRefine((config, ctx) => {
|
|
|
36399
36413
|
message: "engine does not name a configured engine"
|
|
36400
36414
|
});
|
|
36401
36415
|
}
|
|
36402
|
-
const
|
|
36403
|
-
|
|
36404
|
-
|
|
36405
|
-
|
|
36406
|
-
|
|
36407
|
-
|
|
36408
|
-
|
|
36416
|
+
const confining = [...HARNESS_MODEL_WORK_IDS];
|
|
36417
|
+
const confiningPlatforms = `${confining.slice(0, -1).join(", ")} or ${confining.at(-1)}`;
|
|
36418
|
+
const modelWorkEngine = (name, path12) => {
|
|
36419
|
+
if (!name)
|
|
36420
|
+
return;
|
|
36421
|
+
const engine = config.engines?.[name];
|
|
36422
|
+
if (!engine) {
|
|
36423
|
+
ctx.addIssue({ code: exports_external.ZodIssueCode.custom, path: path12, message: "engine does not name a configured engine" });
|
|
36424
|
+
} else if (engine.kind !== "llm" && !HARNESS_MODEL_WORK_IDS.has(engine.platform)) {
|
|
36425
|
+
ctx.addIssue({
|
|
36426
|
+
code: exports_external.ZodIssueCode.custom,
|
|
36427
|
+
path: path12,
|
|
36428
|
+
message: `engine "${name}" (platform ${engine.platform}) cannot confine the model-work tool policy, which unattended model work requires. Use an LLM engine, or an agent engine on ${confiningPlatforms}.`
|
|
36429
|
+
});
|
|
36430
|
+
}
|
|
36431
|
+
};
|
|
36432
|
+
modelWorkEngine(config.defaults?.llmEngine, ["defaults", "llmEngine"]);
|
|
36433
|
+
for (const [passName, pass] of Object.entries(config.index ?? {})) {
|
|
36434
|
+
const engine = pass?.engine;
|
|
36435
|
+
if (typeof engine === "string")
|
|
36436
|
+
modelWorkEngine(engine, ["index", passName, "engine"]);
|
|
36409
36437
|
}
|
|
36410
36438
|
const workflowJudge = config.workflow?.judgeEngine;
|
|
36411
36439
|
if (workflowJudge && !config.engines?.[workflowJudge]) {
|
|
@@ -36424,64 +36452,24 @@ var AkmConfigSchema = AkmConfigBaseSchema.superRefine((config, ctx) => {
|
|
|
36424
36452
|
});
|
|
36425
36453
|
}
|
|
36426
36454
|
for (const [strategyName, strategy] of Object.entries(config.improve?.strategies ?? {})) {
|
|
36427
|
-
const
|
|
36428
|
-
|
|
36429
|
-
const engine = config.engines?.[strategyEngine];
|
|
36430
|
-
if (!engine || engine.kind !== "llm") {
|
|
36431
|
-
ctx.addIssue({
|
|
36432
|
-
code: exports_external.ZodIssueCode.custom,
|
|
36433
|
-
path: ["improve", "strategies", strategyName, "engine"],
|
|
36434
|
-
message: engine ? "strategy engine must be an LLM engine" : "engine does not name a configured engine"
|
|
36435
|
-
});
|
|
36436
|
-
}
|
|
36437
|
-
}
|
|
36455
|
+
const strategyPath = ["improve", "strategies", strategyName];
|
|
36456
|
+
modelWorkEngine(strategy.engine, [...strategyPath, "engine"]);
|
|
36438
36457
|
for (const [processName, process2] of Object.entries(strategy.processes ?? {})) {
|
|
36439
36458
|
const processConfig = process2;
|
|
36440
|
-
const
|
|
36441
|
-
if (processConfig.engine &&
|
|
36459
|
+
const processPath = [...strategyPath, "processes", processName];
|
|
36460
|
+
if (processConfig.engine && !IMPROVE_ENGINE_PROCESSES.includes(processName)) {
|
|
36442
36461
|
ctx.addIssue({
|
|
36443
36462
|
code: exports_external.ZodIssueCode.custom,
|
|
36444
|
-
path: [
|
|
36463
|
+
path: [...processPath, "engine"],
|
|
36445
36464
|
message: `${processName} does not dispatch an engine`
|
|
36446
36465
|
});
|
|
36447
36466
|
} else {
|
|
36448
|
-
|
|
36449
|
-
if (processEngine && capability === "llm") {
|
|
36450
|
-
const engine = config.engines?.[processEngine];
|
|
36451
|
-
if (!engine || engine.kind !== "llm") {
|
|
36452
|
-
ctx.addIssue({
|
|
36453
|
-
code: exports_external.ZodIssueCode.custom,
|
|
36454
|
-
path: ["improve", "strategies", strategyName, "processes", processName, "engine"],
|
|
36455
|
-
message: engine ? `${processName} requires an LLM engine` : "engine does not name a configured engine"
|
|
36456
|
-
});
|
|
36457
|
-
}
|
|
36458
|
-
} else if (processConfig.engine && capability === "runner" && !config.engines?.[processConfig.engine]) {
|
|
36459
|
-
ctx.addIssue({
|
|
36460
|
-
code: exports_external.ZodIssueCode.custom,
|
|
36461
|
-
path: ["improve", "strategies", strategyName, "processes", processName, "engine"],
|
|
36462
|
-
message: "engine does not name a configured engine"
|
|
36463
|
-
});
|
|
36464
|
-
}
|
|
36467
|
+
modelWorkEngine(processConfig.engine, [...processPath, "engine"]);
|
|
36465
36468
|
}
|
|
36466
|
-
|
|
36467
|
-
|
|
36468
|
-
const engine = config.engines?.[judgmentEngine];
|
|
36469
|
-
if (!engine) {
|
|
36470
|
-
ctx.addIssue({
|
|
36471
|
-
code: exports_external.ZodIssueCode.custom,
|
|
36472
|
-
path: ["improve", "strategies", strategyName, "processes", processName, "judgment", "engine"],
|
|
36473
|
-
message: "engine does not name a configured engine"
|
|
36474
|
-
});
|
|
36475
|
-
}
|
|
36476
|
-
}
|
|
36477
|
-
const gateEngine = processConfig.qualityGate?.engine;
|
|
36478
|
-
if (gateEngine && config.engines?.[gateEngine]?.kind !== "llm") {
|
|
36479
|
-
ctx.addIssue({
|
|
36480
|
-
code: exports_external.ZodIssueCode.custom,
|
|
36481
|
-
path: ["improve", "strategies", strategyName, "processes", processName, "qualityGate", "engine"],
|
|
36482
|
-
message: config.engines?.[gateEngine] ? "a quality-gate judge must be an LLM engine" : "engine does not name a configured engine"
|
|
36483
|
-
});
|
|
36469
|
+
if (processConfig.judgment?.enabled === true) {
|
|
36470
|
+
modelWorkEngine(processConfig.judgment.engine, [...processPath, "judgment", "engine"]);
|
|
36484
36471
|
}
|
|
36472
|
+
modelWorkEngine(processConfig.qualityGate?.engine, [...processPath, "qualityGate", "engine"]);
|
|
36485
36473
|
}
|
|
36486
36474
|
}
|
|
36487
36475
|
if (config.defaultWriteTarget !== undefined) {
|
|
@@ -39686,6 +39674,10 @@ import { createHash as createHash3 } from "node:crypto";
|
|
|
39686
39674
|
|
|
39687
39675
|
// src/execution/source.ts
|
|
39688
39676
|
var EXECUTION_SOURCE_SCHEMA_VERSION = 1;
|
|
39677
|
+
var MODEL_WORK_TOOLS = Object.freeze(["read", "edit", "akm search", "akm show"]);
|
|
39678
|
+
function isModelWorkTools(tools) {
|
|
39679
|
+
return Array.isArray(tools) && tools.length === MODEL_WORK_TOOLS.length && tools.every((tool, index) => tool === MODEL_WORK_TOOLS[index]);
|
|
39680
|
+
}
|
|
39689
39681
|
function requireRecord(value, path18) {
|
|
39690
39682
|
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
39691
39683
|
throw new TypeError(`${path18} must be an object`);
|
|
@@ -50946,6 +50938,17 @@ class BaseHarness {
|
|
|
50946
50938
|
function resolveDispatchModel(request, _profile, _platform) {
|
|
50947
50939
|
return request.model;
|
|
50948
50940
|
}
|
|
50941
|
+
function modelFromArgs(args) {
|
|
50942
|
+
let model;
|
|
50943
|
+
for (let index = 0;index < args.length; index += 1) {
|
|
50944
|
+
const arg = args[index];
|
|
50945
|
+
if (arg === "--model")
|
|
50946
|
+
model = args[index + 1];
|
|
50947
|
+
else if (arg?.startsWith("--model="))
|
|
50948
|
+
model = arg.slice("--model=".length);
|
|
50949
|
+
}
|
|
50950
|
+
return model;
|
|
50951
|
+
}
|
|
50949
50952
|
function normalizeTools(tools) {
|
|
50950
50953
|
if (typeof tools === "string")
|
|
50951
50954
|
return tools;
|
|
@@ -50954,6 +50957,14 @@ function normalizeTools(tools) {
|
|
|
50954
50957
|
return JSON.stringify(tools);
|
|
50955
50958
|
}
|
|
50956
50959
|
|
|
50960
|
+
// src/core/structured.ts
|
|
50961
|
+
function withSchemaInstruction(prompt, schema) {
|
|
50962
|
+
return `${prompt}
|
|
50963
|
+
|
|
50964
|
+
Respond with ONLY a JSON value matching this JSON Schema (no prose, no code fences):
|
|
50965
|
+
${JSON.stringify(schema)}`;
|
|
50966
|
+
}
|
|
50967
|
+
|
|
50957
50968
|
// src/integrations/agent/conversation-fallback.ts
|
|
50958
50969
|
var CONVERSATION_FALLBACK_BEGIN = "<AKM_CONVERSATION_JSON>";
|
|
50959
50970
|
var CONVERSATION_FALLBACK_END = "</AKM_CONVERSATION_JSON>";
|
|
@@ -51034,8 +51045,8 @@ function extensionFields(request) {
|
|
|
51034
51045
|
];
|
|
51035
51046
|
}
|
|
51036
51047
|
function createAgentRequestLowerer(options) {
|
|
51037
|
-
|
|
51038
|
-
|
|
51048
|
+
return (profile, request) => {
|
|
51049
|
+
const supportedInference = new Set(typeof options.inference === "function" ? options.inference(profile, request) : options.inference ?? []);
|
|
51039
51050
|
const notices = [];
|
|
51040
51051
|
const skip = (field) => {
|
|
51041
51052
|
notices.push(untranslated(options.adapter, field));
|
|
@@ -51066,6 +51077,10 @@ function createAgentRequestLowerer(options) {
|
|
|
51066
51077
|
}
|
|
51067
51078
|
dispatch.agent = request.agent;
|
|
51068
51079
|
}
|
|
51080
|
+
if (request.outputSchema) {
|
|
51081
|
+
prompt = withSchemaInstruction(prompt, request.outputSchema);
|
|
51082
|
+
dispatch.schema = request.outputSchema;
|
|
51083
|
+
}
|
|
51069
51084
|
dispatch.prompt = prompt;
|
|
51070
51085
|
if (request.model)
|
|
51071
51086
|
dispatch.model = request.model.resolved;
|
|
@@ -51075,15 +51090,16 @@ function createAgentRequestLowerer(options) {
|
|
|
51075
51090
|
if (!supportedInference.has(key))
|
|
51076
51091
|
skip(`inference.${key}`);
|
|
51077
51092
|
}
|
|
51078
|
-
if (typeof request.inference?.effort === "string")
|
|
51079
|
-
dispatch.effort = request.inference.effort;
|
|
51080
51093
|
}
|
|
51081
|
-
if (request.
|
|
51082
|
-
if (!options.
|
|
51083
|
-
|
|
51084
|
-
|
|
51085
|
-
|
|
51086
|
-
|
|
51094
|
+
if (isModelWorkTools(request.tools)) {
|
|
51095
|
+
if (!options.modelWorkTools) {
|
|
51096
|
+
throw new ConfigError(`The ${options.adapter} transport cannot enforce the model-work tool policy.`, "INVALID_CONFIG_FILE");
|
|
51097
|
+
}
|
|
51098
|
+
if (dispatch.agent) {
|
|
51099
|
+
throw new ConfigError(`The ${options.adapter} transport cannot run native agent ${JSON.stringify(dispatch.agent)} under the model-work tool policy.`, "INVALID_CONFIG_FILE");
|
|
51100
|
+
}
|
|
51101
|
+
dispatch.tools = request.tools;
|
|
51102
|
+
} else if (request.tools !== undefined) {
|
|
51087
51103
|
if (hasToolSelection(request.tools) && !translatesTools(options.tools, request.tools)) {
|
|
51088
51104
|
throw new ConfigError(`The ${options.adapter} transport cannot enforce the resolved tool policy.`, "INVALID_CONFIG_FILE");
|
|
51089
51105
|
}
|
|
@@ -51105,10 +51121,6 @@ function buildMessagePayload(req) {
|
|
|
51105
51121
|
if (req.systemPrompt)
|
|
51106
51122
|
sections.push(req.systemPrompt);
|
|
51107
51123
|
sections.push(req.prompt);
|
|
51108
|
-
if (req.schema) {
|
|
51109
|
-
sections.push(`Respond with ONLY a JSON value matching this JSON Schema (no prose, no code fences):
|
|
51110
|
-
${JSON.stringify(req.schema)}`);
|
|
51111
|
-
}
|
|
51112
51124
|
return sections.join(`
|
|
51113
51125
|
|
|
51114
51126
|
`);
|
|
@@ -51119,8 +51131,7 @@ var aiderBuilder = {
|
|
|
51119
51131
|
lower: createAgentRequestLowerer({
|
|
51120
51132
|
adapter: AIDER_PLATFORM,
|
|
51121
51133
|
personaChannel: "prompt",
|
|
51122
|
-
tools: "none"
|
|
51123
|
-
outputSchema: true
|
|
51134
|
+
tools: "none"
|
|
51124
51135
|
}),
|
|
51125
51136
|
build(profile, req) {
|
|
51126
51137
|
const args = [...profile.args];
|
|
@@ -51170,8 +51181,6 @@ class AiderHarness extends BaseHarness {
|
|
|
51170
51181
|
displayName = "Aider";
|
|
51171
51182
|
agentBuilder = aiderBuilder;
|
|
51172
51183
|
resultExtractor = aiderResultExtractor;
|
|
51173
|
-
pattern = "local-runner";
|
|
51174
|
-
structuredOutput = "none";
|
|
51175
51184
|
capabilities = caps({
|
|
51176
51185
|
agentDispatch: true,
|
|
51177
51186
|
detection: true
|
|
@@ -51194,10 +51203,6 @@ function buildPromptPayload(req) {
|
|
|
51194
51203
|
if (req.systemPrompt)
|
|
51195
51204
|
sections.push(req.systemPrompt);
|
|
51196
51205
|
sections.push(req.prompt);
|
|
51197
|
-
if (req.schema) {
|
|
51198
|
-
sections.push(`Respond with ONLY a JSON value matching this JSON Schema (no prose, no code fences):
|
|
51199
|
-
${JSON.stringify(req.schema)}`);
|
|
51200
|
-
}
|
|
51201
51206
|
return sections.join(`
|
|
51202
51207
|
|
|
51203
51208
|
`);
|
|
@@ -51208,8 +51213,7 @@ var amazonqBuilder = {
|
|
|
51208
51213
|
lower: createAgentRequestLowerer({
|
|
51209
51214
|
adapter: AMAZONQ_PLATFORM,
|
|
51210
51215
|
personaChannel: "prompt",
|
|
51211
|
-
tools: "flat"
|
|
51212
|
-
outputSchema: true
|
|
51216
|
+
tools: "flat"
|
|
51213
51217
|
}),
|
|
51214
51218
|
build(profile, req) {
|
|
51215
51219
|
const extra = profile.args[0] === "chat" ? profile.args.slice(1) : [...profile.args];
|
|
@@ -51266,8 +51270,6 @@ class AmazonqHarness extends BaseHarness {
|
|
|
51266
51270
|
displayName = "Amazon Q Developer CLI";
|
|
51267
51271
|
agentBuilder = amazonqBuilder;
|
|
51268
51272
|
resultExtractor = amazonqResultExtractor;
|
|
51269
|
-
pattern = "local-runner";
|
|
51270
|
-
structuredOutput = "none";
|
|
51271
51273
|
capabilities = caps({
|
|
51272
51274
|
agentDispatch: true,
|
|
51273
51275
|
detection: true
|
|
@@ -51275,14 +51277,16 @@ class AmazonqHarness extends BaseHarness {
|
|
|
51275
51277
|
}
|
|
51276
51278
|
|
|
51277
51279
|
// src/integrations/harnesses/claude/agent-builder.ts
|
|
51278
|
-
|
|
51279
|
-
|
|
51280
|
-
|
|
51281
|
-
|
|
51282
|
-
|
|
51283
|
-
|
|
51284
|
-
|
|
51285
|
-
|
|
51280
|
+
var MODEL_WORK_CLAUDE_FLAGS = Object.freeze([
|
|
51281
|
+
"--restricted",
|
|
51282
|
+
"--strict-mcp-config",
|
|
51283
|
+
"--tools",
|
|
51284
|
+
"Read,Edit,Bash",
|
|
51285
|
+
"--allowedTools",
|
|
51286
|
+
"Read,Edit,Bash(akm search *),Bash(akm show *)",
|
|
51287
|
+
"--permission-mode",
|
|
51288
|
+
"dontAsk"
|
|
51289
|
+
]);
|
|
51286
51290
|
var claudeBuilder = {
|
|
51287
51291
|
platform: "claude",
|
|
51288
51292
|
personaChannel: "native",
|
|
@@ -51291,10 +51295,12 @@ var claudeBuilder = {
|
|
|
51291
51295
|
personaChannel: "native",
|
|
51292
51296
|
nativeAgentSelector: true,
|
|
51293
51297
|
tools: "all",
|
|
51294
|
-
|
|
51298
|
+
modelWorkTools: true,
|
|
51299
|
+
inference: ["reasoningEffort"]
|
|
51295
51300
|
}),
|
|
51296
51301
|
build(profile, req) {
|
|
51297
|
-
const
|
|
51302
|
+
const modelWork = isModelWorkTools(req.tools);
|
|
51303
|
+
const args = modelWork ? [...MODEL_WORK_CLAUDE_FLAGS] : [...profile.args];
|
|
51298
51304
|
if (req.agent) {
|
|
51299
51305
|
args.push("--agent", req.agent);
|
|
51300
51306
|
}
|
|
@@ -51304,8 +51310,15 @@ var claudeBuilder = {
|
|
|
51304
51310
|
if (req.model) {
|
|
51305
51311
|
const resolved = resolveDispatchModel(req, profile, "claude");
|
|
51306
51312
|
args.push("--model", resolved);
|
|
51307
|
-
}
|
|
51308
|
-
|
|
51313
|
+
} else if (modelWork) {
|
|
51314
|
+
const model = modelFromArgs(profile.args);
|
|
51315
|
+
if (model)
|
|
51316
|
+
args.push("--model", model);
|
|
51317
|
+
}
|
|
51318
|
+
const effort = req.inference?.reasoningEffort;
|
|
51319
|
+
if (typeof effort === "string" && effort.length > 0)
|
|
51320
|
+
args.push("--effort", effort);
|
|
51321
|
+
if (req.tools && !modelWork) {
|
|
51309
51322
|
args.push("--allowedTools", normalizeTools(req.tools));
|
|
51310
51323
|
}
|
|
51311
51324
|
if (req.schema) {
|
|
@@ -51313,7 +51326,7 @@ var claudeBuilder = {
|
|
|
51313
51326
|
}
|
|
51314
51327
|
args.push("--print");
|
|
51315
51328
|
args.push("--");
|
|
51316
|
-
args.push(
|
|
51329
|
+
args.push(req.prompt);
|
|
51317
51330
|
return { argv: [profile.bin, ...args] };
|
|
51318
51331
|
}
|
|
51319
51332
|
};
|
|
@@ -51648,8 +51661,6 @@ class ClaudeHarness extends BaseHarness {
|
|
|
51648
51661
|
setupDetectionDir = ".claude";
|
|
51649
51662
|
agentBuilder = claudeBuilder;
|
|
51650
51663
|
resultExtractor = claudeResultExtractor;
|
|
51651
|
-
pattern = "in-harness";
|
|
51652
|
-
structuredOutput = "native-json";
|
|
51653
51664
|
identityEnv = ["CLAUDE_SESSION_ID"];
|
|
51654
51665
|
sessionLogProvider = () => new ClaudeCodeProvider;
|
|
51655
51666
|
capabilities = caps({
|
|
@@ -51684,8 +51695,7 @@ var codexBuilder = {
|
|
|
51684
51695
|
lower: createAgentRequestLowerer({
|
|
51685
51696
|
adapter: "codex",
|
|
51686
51697
|
personaChannel: "prompt",
|
|
51687
|
-
tools: "none"
|
|
51688
|
-
outputSchema: true
|
|
51698
|
+
tools: "none"
|
|
51689
51699
|
}),
|
|
51690
51700
|
build(profile, req) {
|
|
51691
51701
|
const extra = profile.args[0] === "exec" ? profile.args.slice(1) : [...profile.args];
|
|
@@ -51772,8 +51782,6 @@ class CodexHarness extends BaseHarness {
|
|
|
51772
51782
|
displayName = "OpenAI Codex CLI";
|
|
51773
51783
|
agentBuilder = codexBuilder;
|
|
51774
51784
|
resultExtractor = codexResultExtractor;
|
|
51775
|
-
pattern = "local-runner";
|
|
51776
|
-
structuredOutput = "native-schema";
|
|
51777
51785
|
presenceEnv = ["CODEX_SANDBOX"];
|
|
51778
51786
|
capabilities = caps({
|
|
51779
51787
|
agentDispatch: true,
|
|
@@ -51792,15 +51800,11 @@ function toolPolicyEntries2(tools) {
|
|
|
51792
51800
|
}
|
|
51793
51801
|
return;
|
|
51794
51802
|
}
|
|
51795
|
-
function
|
|
51803
|
+
function buildPromptPayload2(req) {
|
|
51796
51804
|
const sections = [];
|
|
51797
51805
|
if (req.systemPrompt)
|
|
51798
51806
|
sections.push(req.systemPrompt);
|
|
51799
51807
|
sections.push(req.prompt);
|
|
51800
|
-
if (req.schema) {
|
|
51801
|
-
sections.push(`Respond with ONLY a JSON value matching this JSON Schema (no prose, no code fences):
|
|
51802
|
-
${JSON.stringify(req.schema)}`);
|
|
51803
|
-
}
|
|
51804
51808
|
return sections.join(`
|
|
51805
51809
|
|
|
51806
51810
|
`);
|
|
@@ -51811,8 +51815,7 @@ var copilotBuilder = {
|
|
|
51811
51815
|
lower: createAgentRequestLowerer({
|
|
51812
51816
|
adapter: COPILOT_PLATFORM,
|
|
51813
51817
|
personaChannel: "prompt",
|
|
51814
|
-
tools: "flat"
|
|
51815
|
-
outputSchema: true
|
|
51818
|
+
tools: "flat"
|
|
51816
51819
|
}),
|
|
51817
51820
|
build(profile, req) {
|
|
51818
51821
|
const args = [...profile.args];
|
|
@@ -51831,7 +51834,7 @@ var copilotBuilder = {
|
|
|
51831
51834
|
if (req.schema) {
|
|
51832
51835
|
args.push("--output-format", "json");
|
|
51833
51836
|
}
|
|
51834
|
-
args.push("-p",
|
|
51837
|
+
args.push("-p", buildPromptPayload2(req));
|
|
51835
51838
|
return { argv: [profile.bin, ...args] };
|
|
51836
51839
|
}
|
|
51837
51840
|
};
|
|
@@ -51929,8 +51932,6 @@ class CopilotHarness extends BaseHarness {
|
|
|
51929
51932
|
displayName = "GitHub Copilot CLI";
|
|
51930
51933
|
agentBuilder = copilotBuilder;
|
|
51931
51934
|
resultExtractor = copilotResultExtractor;
|
|
51932
|
-
pattern = "local-runner";
|
|
51933
|
-
structuredOutput = "native-json";
|
|
51934
51935
|
identityEnv = ["COPILOT_SESSION_ID"];
|
|
51935
51936
|
capabilities = caps({
|
|
51936
51937
|
agentDispatch: true,
|
|
@@ -51949,15 +51950,11 @@ function toolPolicyEntries3(tools) {
|
|
|
51949
51950
|
}
|
|
51950
51951
|
return;
|
|
51951
51952
|
}
|
|
51952
|
-
function
|
|
51953
|
+
function buildPromptPayload3(req) {
|
|
51953
51954
|
const sections = [];
|
|
51954
51955
|
if (req.systemPrompt)
|
|
51955
51956
|
sections.push(req.systemPrompt);
|
|
51956
51957
|
sections.push(req.prompt);
|
|
51957
|
-
if (req.schema) {
|
|
51958
|
-
sections.push(`Respond with ONLY a JSON value matching this JSON Schema (no prose, no code fences):
|
|
51959
|
-
${JSON.stringify(req.schema)}`);
|
|
51960
|
-
}
|
|
51961
51958
|
return sections.join(`
|
|
51962
51959
|
|
|
51963
51960
|
`);
|
|
@@ -51968,8 +51965,7 @@ var geminiBuilder = {
|
|
|
51968
51965
|
lower: createAgentRequestLowerer({
|
|
51969
51966
|
adapter: GEMINI_PLATFORM,
|
|
51970
51967
|
personaChannel: "prompt",
|
|
51971
|
-
tools: "flat"
|
|
51972
|
-
outputSchema: true
|
|
51968
|
+
tools: "flat"
|
|
51973
51969
|
}),
|
|
51974
51970
|
build(profile, req) {
|
|
51975
51971
|
const args = [...profile.args];
|
|
@@ -51985,7 +51981,7 @@ var geminiBuilder = {
|
|
|
51985
51981
|
if (req.schema) {
|
|
51986
51982
|
args.push("--output-format", "json");
|
|
51987
51983
|
}
|
|
51988
|
-
args.push("-p",
|
|
51984
|
+
args.push("-p", buildPromptPayload3(req));
|
|
51989
51985
|
return { argv: [profile.bin, ...args] };
|
|
51990
51986
|
}
|
|
51991
51987
|
};
|
|
@@ -52076,8 +52072,6 @@ class GeminiHarness extends BaseHarness {
|
|
|
52076
52072
|
displayName = "Gemini CLI";
|
|
52077
52073
|
agentBuilder = geminiBuilder;
|
|
52078
52074
|
resultExtractor = geminiResultExtractor;
|
|
52079
|
-
pattern = "local-runner";
|
|
52080
|
-
structuredOutput = "native-json";
|
|
52081
52075
|
presenceEnv = ["GEMINI_CLI"];
|
|
52082
52076
|
capabilities = caps({
|
|
52083
52077
|
agentDispatch: true,
|
|
@@ -52085,18 +52079,141 @@ class GeminiHarness extends BaseHarness {
|
|
|
52085
52079
|
});
|
|
52086
52080
|
}
|
|
52087
52081
|
|
|
52082
|
+
// src/integrations/harnesses/opencode/model-config.ts
|
|
52083
|
+
var isPositiveInteger = (value) => typeof value === "number" && Number.isInteger(value) && value > 0;
|
|
52084
|
+
function carriedInference(inference) {
|
|
52085
|
+
const carried = {};
|
|
52086
|
+
const { temperature, reasoningEffort, enableThinking, maxTokens, contextLength } = inference ?? {};
|
|
52087
|
+
if (typeof temperature === "number" && Number.isFinite(temperature))
|
|
52088
|
+
carried.temperature = temperature;
|
|
52089
|
+
if (typeof reasoningEffort === "string" && reasoningEffort.length > 0)
|
|
52090
|
+
carried.reasoningEffort = reasoningEffort;
|
|
52091
|
+
if (typeof enableThinking === "boolean")
|
|
52092
|
+
carried.enableThinking = enableThinking;
|
|
52093
|
+
const limit = isPositiveInteger(maxTokens) && isPositiveInteger(contextLength);
|
|
52094
|
+
if (limit)
|
|
52095
|
+
carried.limit = { context: contextLength, output: maxTokens };
|
|
52096
|
+
const keys = [
|
|
52097
|
+
["temperature", carried.temperature !== undefined, temperature],
|
|
52098
|
+
["reasoningEffort", carried.reasoningEffort !== undefined, reasoningEffort],
|
|
52099
|
+
["enableThinking", carried.enableThinking !== undefined, enableThinking],
|
|
52100
|
+
["maxTokens", limit, maxTokens],
|
|
52101
|
+
["contextLength", limit, contextLength]
|
|
52102
|
+
].filter(([, isCarried, value]) => isCarried || value === null).map(([key]) => key);
|
|
52103
|
+
return { carried, keys };
|
|
52104
|
+
}
|
|
52105
|
+
function splitOpencodeModel(model) {
|
|
52106
|
+
const slash = model.indexOf("/");
|
|
52107
|
+
if (slash <= 0 || slash === model.length - 1)
|
|
52108
|
+
return;
|
|
52109
|
+
return { providerID: model.slice(0, slash), modelID: model.slice(slash + 1) };
|
|
52110
|
+
}
|
|
52111
|
+
function opencodeCarriedKeys(attachable, inference, modelWork) {
|
|
52112
|
+
const { keys } = carriedInference(inference);
|
|
52113
|
+
if (attachable)
|
|
52114
|
+
return keys;
|
|
52115
|
+
return modelWork ? keys.filter((key) => key !== "maxTokens" && key !== "contextLength") : [];
|
|
52116
|
+
}
|
|
52117
|
+
function opencodeInferenceConfig(inference, modelWork) {
|
|
52118
|
+
const { carried } = carriedInference(inference);
|
|
52119
|
+
const options = {};
|
|
52120
|
+
if (carried.temperature !== undefined)
|
|
52121
|
+
options.temperature = carried.temperature;
|
|
52122
|
+
if (carried.reasoningEffort !== undefined)
|
|
52123
|
+
options.reasoningEffort = carried.reasoningEffort;
|
|
52124
|
+
if (carried.enableThinking !== undefined) {
|
|
52125
|
+
options.chat_template_kwargs = { enable_thinking: carried.enableThinking };
|
|
52126
|
+
options.enable_thinking = carried.enableThinking;
|
|
52127
|
+
}
|
|
52128
|
+
const hasOptions = Object.keys(options).length > 0;
|
|
52129
|
+
return {
|
|
52130
|
+
entry: {
|
|
52131
|
+
...hasOptions && !modelWork ? { options } : {},
|
|
52132
|
+
...carried.limit ? { limit: { ...carried.limit } } : {}
|
|
52133
|
+
},
|
|
52134
|
+
...hasOptions && modelWork ? { agentOptions: options } : {}
|
|
52135
|
+
};
|
|
52136
|
+
}
|
|
52137
|
+
function opencodeModelConfig(model, entry) {
|
|
52138
|
+
const target = model === undefined ? undefined : splitOpencodeModel(model);
|
|
52139
|
+
if (!target || Object.keys(entry).length === 0)
|
|
52140
|
+
return;
|
|
52141
|
+
return { provider: { [target.providerID]: { models: { [target.modelID]: entry } } } };
|
|
52142
|
+
}
|
|
52143
|
+
|
|
52144
|
+
// src/integrations/harnesses/opencode/model-work-agent.ts
|
|
52145
|
+
var MODEL_WORK_OPENCODE_AGENT = "akm-model-work";
|
|
52146
|
+
var MODEL_WORK_STEPS = 8;
|
|
52147
|
+
var MODEL_WORK_PROMPT = "You do one bounded task for akm. Use tools only to check what the task needs, never repeat a tool call, and reply with exactly what the task asks for.";
|
|
52148
|
+
var MODEL_WORK_PERMISSION = {
|
|
52149
|
+
"*": "deny",
|
|
52150
|
+
read: "allow",
|
|
52151
|
+
edit: "allow",
|
|
52152
|
+
external_directory: "deny",
|
|
52153
|
+
bash: "deny",
|
|
52154
|
+
doom_loop: "deny",
|
|
52155
|
+
glob: "deny",
|
|
52156
|
+
grep: "deny",
|
|
52157
|
+
list: "deny",
|
|
52158
|
+
lsp: "deny",
|
|
52159
|
+
question: "deny",
|
|
52160
|
+
skill: "deny",
|
|
52161
|
+
task: "deny",
|
|
52162
|
+
todowrite: "deny",
|
|
52163
|
+
webfetch: "deny",
|
|
52164
|
+
websearch: "deny"
|
|
52165
|
+
};
|
|
52166
|
+
function modelWorkOpencodeConfig(options) {
|
|
52167
|
+
return {
|
|
52168
|
+
permission: { ...MODEL_WORK_PERMISSION },
|
|
52169
|
+
compaction: { auto: false },
|
|
52170
|
+
agent: {
|
|
52171
|
+
[MODEL_WORK_OPENCODE_AGENT]: {
|
|
52172
|
+
mode: "primary",
|
|
52173
|
+
description: "akm unattended model work: read and edit inside its working directory only.",
|
|
52174
|
+
prompt: MODEL_WORK_PROMPT,
|
|
52175
|
+
steps: MODEL_WORK_STEPS,
|
|
52176
|
+
...options ? { options } : {},
|
|
52177
|
+
permission: { ...MODEL_WORK_PERMISSION }
|
|
52178
|
+
}
|
|
52179
|
+
}
|
|
52180
|
+
};
|
|
52181
|
+
}
|
|
52182
|
+
|
|
52088
52183
|
// src/integrations/harnesses/opencode/agent-builder.ts
|
|
52089
52184
|
var opencodeBuilder = {
|
|
52090
52185
|
platform: "opencode",
|
|
52091
|
-
personaChannel: "
|
|
52186
|
+
personaChannel: "prompt",
|
|
52092
52187
|
lower: createAgentRequestLowerer({
|
|
52093
52188
|
adapter: "opencode",
|
|
52094
|
-
personaChannel: "
|
|
52189
|
+
personaChannel: "prompt",
|
|
52095
52190
|
nativeAgentSelector: true,
|
|
52096
52191
|
tools: "none",
|
|
52097
|
-
|
|
52192
|
+
modelWorkTools: true,
|
|
52193
|
+
inference: (profile, request) => {
|
|
52194
|
+
const model = request.model?.resolved ?? modelFromArgs(profile.args);
|
|
52195
|
+
return opencodeCarriedKeys(model !== undefined && splitOpencodeModel(model) !== undefined, request.inference, isModelWorkTools(request.tools));
|
|
52196
|
+
}
|
|
52098
52197
|
}),
|
|
52099
52198
|
build(profile, req) {
|
|
52199
|
+
const model = req.model ?? modelFromArgs(profile.args);
|
|
52200
|
+
const modelWork = isModelWorkTools(req.tools);
|
|
52201
|
+
const { entry, agentOptions } = opencodeInferenceConfig(req.inference, modelWork);
|
|
52202
|
+
const modelConfig = opencodeModelConfig(model, entry);
|
|
52203
|
+
if (modelWork) {
|
|
52204
|
+
return {
|
|
52205
|
+
argv: [
|
|
52206
|
+
profile.bin,
|
|
52207
|
+
"run",
|
|
52208
|
+
"--agent",
|
|
52209
|
+
MODEL_WORK_OPENCODE_AGENT,
|
|
52210
|
+
...model ? ["--model", model] : [],
|
|
52211
|
+
"--",
|
|
52212
|
+
req.prompt
|
|
52213
|
+
],
|
|
52214
|
+
env: { OPENCODE_CONFIG_CONTENT: JSON.stringify({ ...modelWorkOpencodeConfig(agentOptions), ...modelConfig }) }
|
|
52215
|
+
};
|
|
52216
|
+
}
|
|
52100
52217
|
const args = req.model ? [] : [...profile.args];
|
|
52101
52218
|
if (req.model) {
|
|
52102
52219
|
for (let index = 0;index < profile.args.length; index += 1) {
|
|
@@ -52110,9 +52227,6 @@ var opencodeBuilder = {
|
|
|
52110
52227
|
}
|
|
52111
52228
|
}
|
|
52112
52229
|
}
|
|
52113
|
-
if (req.systemPrompt) {
|
|
52114
|
-
args.push("--system-prompt", req.systemPrompt);
|
|
52115
|
-
}
|
|
52116
52230
|
if (req.agent) {
|
|
52117
52231
|
args.push("--agent", req.agent);
|
|
52118
52232
|
}
|
|
@@ -52122,7 +52236,10 @@ var opencodeBuilder = {
|
|
|
52122
52236
|
}
|
|
52123
52237
|
args.push("--");
|
|
52124
52238
|
args.push(req.prompt);
|
|
52125
|
-
return {
|
|
52239
|
+
return {
|
|
52240
|
+
argv: [profile.bin, ...args],
|
|
52241
|
+
...modelConfig ? { env: { OPENCODE_CONFIG_CONTENT: JSON.stringify(modelConfig) } } : {}
|
|
52242
|
+
};
|
|
52126
52243
|
}
|
|
52127
52244
|
};
|
|
52128
52245
|
|
|
@@ -52400,8 +52517,6 @@ class OpencodeHarness extends BaseHarness {
|
|
|
52400
52517
|
displayName = "OpenCode";
|
|
52401
52518
|
setupDetectionDir = ".config/opencode";
|
|
52402
52519
|
agentBuilder = opencodeBuilder;
|
|
52403
|
-
pattern = "local-runner";
|
|
52404
|
-
structuredOutput = "none";
|
|
52405
52520
|
identityEnv = ["OPENCODE_SESSION_ID"];
|
|
52406
52521
|
sessionLogProvider = () => new OpenCodeProvider;
|
|
52407
52522
|
capabilities = caps({
|
|
@@ -52416,8 +52531,6 @@ class OpencodeHarness extends BaseHarness {
|
|
|
52416
52531
|
class OpencodeSdkHarness extends BaseHarness {
|
|
52417
52532
|
id = "opencode-sdk";
|
|
52418
52533
|
displayName = "OpenCode SDK";
|
|
52419
|
-
pattern = "local-runner";
|
|
52420
|
-
structuredOutput = "native-json";
|
|
52421
52534
|
executionLowerer = {
|
|
52422
52535
|
platform: "opencode-sdk",
|
|
52423
52536
|
personaChannel: "native",
|
|
@@ -52426,7 +52539,8 @@ class OpencodeSdkHarness extends BaseHarness {
|
|
|
52426
52539
|
personaChannel: "native",
|
|
52427
52540
|
nativeAgentSelector: true,
|
|
52428
52541
|
tools: "sdk",
|
|
52429
|
-
|
|
52542
|
+
modelWorkTools: true,
|
|
52543
|
+
inference: (_profile, request) => opencodeCarriedKeys(Boolean(request.model?.resolved), request.inference, isModelWorkTools(request.tools))
|
|
52430
52544
|
})
|
|
52431
52545
|
};
|
|
52432
52546
|
capabilities = caps({
|
|
@@ -52443,10 +52557,6 @@ function buildTaskPayload(req) {
|
|
|
52443
52557
|
if (req.systemPrompt)
|
|
52444
52558
|
sections.push(req.systemPrompt);
|
|
52445
52559
|
sections.push(req.prompt);
|
|
52446
|
-
if (req.schema) {
|
|
52447
|
-
sections.push(`Respond with ONLY a JSON value matching this JSON Schema (no prose, no code fences):
|
|
52448
|
-
${JSON.stringify(req.schema)}`);
|
|
52449
|
-
}
|
|
52450
52560
|
return sections.join(`
|
|
52451
52561
|
|
|
52452
52562
|
`);
|
|
@@ -52457,8 +52567,7 @@ var openhandsBuilder = {
|
|
|
52457
52567
|
lower: createAgentRequestLowerer({
|
|
52458
52568
|
adapter: OPENHANDS_PLATFORM,
|
|
52459
52569
|
personaChannel: "prompt",
|
|
52460
|
-
tools: "none"
|
|
52461
|
-
outputSchema: true
|
|
52570
|
+
tools: "none"
|
|
52462
52571
|
}),
|
|
52463
52572
|
build(profile, req) {
|
|
52464
52573
|
const args = [...profile.args];
|
|
@@ -52542,8 +52651,6 @@ class OpenhandsHarness extends BaseHarness {
|
|
|
52542
52651
|
displayName = "OpenHands";
|
|
52543
52652
|
agentBuilder = openhandsBuilder;
|
|
52544
52653
|
resultExtractor = openhandsResultExtractor;
|
|
52545
|
-
pattern = "local-runner";
|
|
52546
|
-
structuredOutput = "native-json";
|
|
52547
52654
|
capabilities = caps({
|
|
52548
52655
|
agentDispatch: true,
|
|
52549
52656
|
detection: true
|
|
@@ -52552,24 +52659,13 @@ class OpenhandsHarness extends BaseHarness {
|
|
|
52552
52659
|
|
|
52553
52660
|
// src/integrations/harnesses/pi/agent-builder.ts
|
|
52554
52661
|
var PI_PLATFORM = "pi";
|
|
52555
|
-
function buildPromptPayload5(req) {
|
|
52556
|
-
const sections = [req.prompt];
|
|
52557
|
-
if (req.schema) {
|
|
52558
|
-
sections.push(`Respond with ONLY a JSON value matching this JSON Schema (no prose, no code fences):
|
|
52559
|
-
${JSON.stringify(req.schema)}`);
|
|
52560
|
-
}
|
|
52561
|
-
return sections.join(`
|
|
52562
|
-
|
|
52563
|
-
`);
|
|
52564
|
-
}
|
|
52565
52662
|
var piBuilder = {
|
|
52566
52663
|
platform: PI_PLATFORM,
|
|
52567
52664
|
personaChannel: "native",
|
|
52568
52665
|
lower: createAgentRequestLowerer({
|
|
52569
52666
|
adapter: PI_PLATFORM,
|
|
52570
52667
|
personaChannel: "native",
|
|
52571
|
-
tools: "none"
|
|
52572
|
-
outputSchema: true
|
|
52668
|
+
tools: "none"
|
|
52573
52669
|
}),
|
|
52574
52670
|
build(profile, req) {
|
|
52575
52671
|
const args = [...profile.args];
|
|
@@ -52585,7 +52681,7 @@ var piBuilder = {
|
|
|
52585
52681
|
}
|
|
52586
52682
|
args.push("-p");
|
|
52587
52683
|
args.push("--");
|
|
52588
|
-
args.push(
|
|
52684
|
+
args.push(req.prompt);
|
|
52589
52685
|
return { argv: [profile.bin, ...args] };
|
|
52590
52686
|
}
|
|
52591
52687
|
};
|
|
@@ -52687,8 +52783,6 @@ class PiHarness extends BaseHarness {
|
|
|
52687
52783
|
displayName = "Pi";
|
|
52688
52784
|
agentBuilder = piBuilder;
|
|
52689
52785
|
resultExtractor = piResultExtractor;
|
|
52690
|
-
pattern = "local-runner";
|
|
52691
|
-
structuredOutput = "native-json";
|
|
52692
52786
|
identityEnv = ["PI_SESSION_ID"];
|
|
52693
52787
|
capabilities = caps({
|
|
52694
52788
|
agentDispatch: true,
|
|
@@ -52723,6 +52817,11 @@ var VALID_HARNESS_IDS2 = Object.freeze(HARNESS_REGISTRY.map((h) => h.id));
|
|
|
52723
52817
|
var SESSION_LOG_HARNESSES = HARNESS_REGISTRY.filter(isSessionLogHarness);
|
|
52724
52818
|
var AGENT_DISPATCH_HARNESSES = HARNESS_REGISTRY.filter((h) => h.capabilities.agentDispatch);
|
|
52725
52819
|
|
|
52820
|
+
// src/integrations/agent/model-map.ts
|
|
52821
|
+
var ENGINE_KEY_PATTERN = new RegExp(ENGINE_NAME_PATTERN_SOURCE);
|
|
52822
|
+
var RESERVED_MAP_KEYS = new Set(["__proto__", "constructor", "prototype", "tostring"]);
|
|
52823
|
+
var PROFILE_FIELD_KEYS = new Set(["model", "inference", "engine"]);
|
|
52824
|
+
|
|
52726
52825
|
// src/core/spawn-env.ts
|
|
52727
52826
|
var COMMON_SPAWN_ENV_PASSTHROUGH = [
|
|
52728
52827
|
"HOME",
|
|
@@ -52824,11 +52923,6 @@ var FALLBACK_ANNOUNCEMENT = `No engine is configured; falling back to \`${FALLBA
|
|
|
52824
52923
|
var NO_ENGINE_MESSAGE_SUFFIX = `has no selected engine, and no usable \`${OPENCODE_SDK_SERVER_BIN}\` binary was found to fall back to.`;
|
|
52825
52924
|
var NO_ENGINE_REMEDY = "Run `akm setup` to detect an installed agent, or set one explicitly: " + '`akm config set engines.claude \'{"kind":"agent","platform":"claude"}\'` ' + "then `akm config set defaults.engine claude`. " + `Installing the \`${OPENCODE_SDK_SERVER_BIN}\` binary also works ` + "(`npm i -g opencode-ai`) — akm falls back to it automatically.";
|
|
52826
52925
|
|
|
52827
|
-
// src/integrations/agent/model-map.ts
|
|
52828
|
-
var ENGINE_KEY_PATTERN = new RegExp(ENGINE_NAME_PATTERN_SOURCE);
|
|
52829
|
-
var RESERVED_MAP_KEYS = new Set(["__proto__", "constructor", "prototype", "tostring"]);
|
|
52830
|
-
var PROFILE_FIELD_KEYS = new Set(["model", "inference", "engine"]);
|
|
52831
|
-
|
|
52832
52926
|
// src/storage/repositories/improve-ledger-repository.ts
|
|
52833
52927
|
var LEDGER_REJECTION_WINDOW_DAYS = Object.freeze({
|
|
52834
52928
|
reflect: 14,
|
|
@@ -52855,9 +52949,9 @@ var BUILTIN_STRATEGIES = {
|
|
|
52855
52949
|
if (BUILTIN_IMPROVE_STRATEGY_NAMES.some((name) => !(name in BUILTIN_STRATEGIES))) {
|
|
52856
52950
|
throw new Error("Built-in improve strategy names are out of sync with their assets");
|
|
52857
52951
|
}
|
|
52952
|
+
var MODEL_CALLING_PROCESSES = new Set(IMPROVE_ENGINE_PROCESSES.filter((name) => name !== "triage"));
|
|
52858
52953
|
|
|
52859
52954
|
// src/commands/improve/improve-usage-report.ts
|
|
52860
|
-
var LLM_BACKED_PROCESSES = new Set(Object.keys(IMPROVE_PROCESS_ENGINE_CAPABILITIES).filter((name) => IMPROVE_PROCESS_ENGINE_CAPABILITIES[name] === "llm"));
|
|
52861
52955
|
function renderFixedWidthTable(headers, rows) {
|
|
52862
52956
|
const widths = headers.map((header, index) => Math.max(header.length, ...rows.map((row) => row[index]?.length ?? 0)));
|
|
52863
52957
|
const renderRow = (cells) => cells.map((cell, index) => cell.padEnd(widths[index] ?? 0)).join(" ").trimEnd();
|