crewbee 0.1.11 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +175 -269
- package/README.zh-CN.md +157 -271
- package/dist/opencode-plugin.mjs +690 -354
- package/dist/src/adapters/opencode/bootstrap.d.ts +1 -0
- package/dist/src/adapters/opencode/bootstrap.d.ts.map +1 -1
- package/dist/src/adapters/opencode/bootstrap.js +1 -0
- package/dist/src/adapters/opencode/bootstrap.js.map +1 -1
- package/dist/src/adapters/opencode/model-resolution.d.ts +33 -0
- package/dist/src/adapters/opencode/model-resolution.d.ts.map +1 -0
- package/dist/src/adapters/opencode/model-resolution.js +180 -0
- package/dist/src/adapters/opencode/model-resolution.js.map +1 -0
- package/dist/src/adapters/opencode/projection.d.ts +4 -1
- package/dist/src/adapters/opencode/projection.d.ts.map +1 -1
- package/dist/src/adapters/opencode/projection.js +7 -12
- package/dist/src/adapters/opencode/projection.js.map +1 -1
- package/dist/src/adapters/opencode/prompt-builder.js +7 -7
- package/dist/src/adapters/opencode/prompt-builder.js.map +1 -1
- package/dist/src/agent-teams/canonical-agent-id.d.ts.map +1 -1
- package/dist/src/agent-teams/canonical-agent-id.js +11 -0
- package/dist/src/agent-teams/canonical-agent-id.js.map +1 -1
- package/dist/src/agent-teams/constants.d.ts +9 -0
- package/dist/src/agent-teams/constants.d.ts.map +1 -1
- package/dist/src/agent-teams/constants.js +19 -1
- package/dist/src/agent-teams/constants.js.map +1 -1
- package/dist/src/agent-teams/embedded/coding-team.d.ts.map +1 -1
- package/dist/src/agent-teams/embedded/coding-team.js +20 -10
- package/dist/src/agent-teams/embedded/coding-team.js.map +1 -1
- package/dist/src/agent-teams/filesystem.d.ts +12 -1
- package/dist/src/agent-teams/filesystem.d.ts.map +1 -1
- package/dist/src/agent-teams/filesystem.js +126 -5
- package/dist/src/agent-teams/filesystem.js.map +1 -1
- package/dist/src/agent-teams/library.d.ts.map +1 -1
- package/dist/src/agent-teams/library.js +7 -2
- package/dist/src/agent-teams/library.js.map +1 -1
- package/dist/src/agent-teams/parsers.d.ts.map +1 -1
- package/dist/src/agent-teams/parsers.js +7 -1
- package/dist/src/agent-teams/parsers.js.map +1 -1
- package/dist/src/agent-teams/validation.d.ts.map +1 -1
- package/dist/src/agent-teams/validation.js +14 -0
- package/dist/src/agent-teams/validation.js.map +1 -1
- package/dist/src/cli/doctor.d.ts.map +1 -1
- package/dist/src/cli/doctor.js +14 -1
- package/dist/src/cli/doctor.js.map +1 -1
- package/dist/src/cli/package-version.d.ts.map +1 -0
- package/dist/src/cli/package-version.js.map +1 -0
- package/dist/src/cli/version.js +1 -1
- package/dist/src/cli/version.js.map +1 -1
- package/dist/src/core/index.d.ts +13 -1
- package/dist/src/core/index.d.ts.map +1 -1
- package/dist/src/install/doctor.d.ts.map +1 -1
- package/dist/src/install/doctor.js +7 -0
- package/dist/src/install/doctor.js.map +1 -1
- package/dist/src/install/types.d.ts +3 -1
- package/dist/src/install/types.d.ts.map +1 -1
- package/dist/src/normalize/build-agent-prompt-document.d.ts +6 -0
- package/dist/src/normalize/build-agent-prompt-document.d.ts.map +1 -0
- package/dist/src/normalize/{build-agent-prompt-source.js → build-agent-prompt-document.js} +6 -6
- package/dist/src/normalize/build-agent-prompt-document.js.map +1 -0
- package/dist/src/normalize/{build-team-prompt-source.d.ts → build-team-prompt-document.d.ts} +2 -2
- package/dist/src/normalize/build-team-prompt-document.d.ts.map +1 -0
- package/dist/src/normalize/{build-team-prompt-source.js → build-team-prompt-document.js} +3 -3
- package/dist/src/normalize/build-team-prompt-document.js.map +1 -0
- package/dist/src/render/apply-prompt-projection.d.ts.map +1 -0
- package/dist/src/render/apply-prompt-projection.js.map +1 -0
- package/dist/src/render/build-prompt-catalog.d.ts.map +1 -0
- package/dist/src/render/build-prompt-catalog.js.map +1 -0
- package/dist/src/render/build-prompt-plan.d.ts.map +1 -0
- package/dist/src/render/build-prompt-plan.js.map +1 -0
- package/dist/src/render/prompt-document-renderer.js +3 -3
- package/dist/src/render/prompt-document-renderer.js.map +1 -1
- package/dist/src/render/structural-renderer.js +1 -1
- package/dist/src/render/structural-renderer.js.map +1 -1
- package/package.json +2 -2
- package/templates/crewbee.json +31 -1
- package/dist/src/catalog/build-prompt-catalog.d.ts.map +0 -1
- package/dist/src/catalog/build-prompt-catalog.js.map +0 -1
- package/dist/src/manager/index.d.ts +0 -24
- package/dist/src/manager/index.d.ts.map +0 -1
- package/dist/src/manager/index.js +0 -68
- package/dist/src/manager/index.js.map +0 -1
- package/dist/src/normalize/build-agent-prompt-source.d.ts +0 -6
- package/dist/src/normalize/build-agent-prompt-source.d.ts.map +0 -1
- package/dist/src/normalize/build-agent-prompt-source.js.map +0 -1
- package/dist/src/normalize/build-team-prompt-source.d.ts.map +0 -1
- package/dist/src/normalize/build-team-prompt-source.js.map +0 -1
- package/dist/src/plan/build-prompt-plan.d.ts.map +0 -1
- package/dist/src/plan/build-prompt-plan.js.map +0 -1
- package/dist/src/projection/apply-prompt-projection.d.ts.map +0 -1
- package/dist/src/projection/apply-prompt-projection.js.map +0 -1
- package/dist/src/version/package-version.d.ts.map +0 -1
- package/dist/src/version/package-version.js.map +0 -1
- /package/dist/src/{version → cli}/package-version.d.ts +0 -0
- /package/dist/src/{version → cli}/package-version.js +0 -0
- /package/dist/src/{projection → render}/apply-prompt-projection.d.ts +0 -0
- /package/dist/src/{projection → render}/apply-prompt-projection.js +0 -0
- /package/dist/src/{catalog → render}/build-prompt-catalog.d.ts +0 -0
- /package/dist/src/{catalog → render}/build-prompt-catalog.js +0 -0
- /package/dist/src/{plan → render}/build-prompt-plan.d.ts +0 -0
- /package/dist/src/{plan → render}/build-prompt-plan.js +0 -0
package/dist/opencode-plugin.mjs
CHANGED
|
@@ -1435,6 +1435,7 @@ var require_stringify = __commonJS({
|
|
|
1435
1435
|
nullStr: "null",
|
|
1436
1436
|
simpleKeys: false,
|
|
1437
1437
|
singleQuote: null,
|
|
1438
|
+
trailingComma: false,
|
|
1438
1439
|
trueStr: "true",
|
|
1439
1440
|
verifyAliasOrder: true
|
|
1440
1441
|
}, doc.schema.toStringOptions, options);
|
|
@@ -1952,12 +1953,19 @@ ${indent}${line}` : "\n";
|
|
|
1952
1953
|
if (comment)
|
|
1953
1954
|
reqNewline = true;
|
|
1954
1955
|
let str = stringify.stringify(item, itemCtx, () => comment = null);
|
|
1955
|
-
|
|
1956
|
+
reqNewline || (reqNewline = lines.length > linesAtValue || str.includes("\n"));
|
|
1957
|
+
if (i < items.length - 1) {
|
|
1956
1958
|
str += ",";
|
|
1959
|
+
} else if (ctx.options.trailingComma) {
|
|
1960
|
+
if (ctx.options.lineWidth > 0) {
|
|
1961
|
+
reqNewline || (reqNewline = lines.reduce((sum, line) => sum + line.length + 2, 2) + (str.length + 2) > ctx.options.lineWidth);
|
|
1962
|
+
}
|
|
1963
|
+
if (reqNewline) {
|
|
1964
|
+
str += ",";
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1957
1967
|
if (comment)
|
|
1958
1968
|
str += stringifyComment.lineComment(str, itemIndent, commentString(comment));
|
|
1959
|
-
if (!reqNewline && (lines.length > linesAtValue || str.includes("\n")))
|
|
1960
|
-
reqNewline = true;
|
|
1961
1969
|
lines.push(str);
|
|
1962
1970
|
linesAtValue = lines.length;
|
|
1963
1971
|
}
|
|
@@ -4971,17 +4979,22 @@ var require_compose_node = __commonJS({
|
|
|
4971
4979
|
case "block-map":
|
|
4972
4980
|
case "block-seq":
|
|
4973
4981
|
case "flow-collection":
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4982
|
+
try {
|
|
4983
|
+
node = composeCollection.composeCollection(CN, ctx, token, props, onError);
|
|
4984
|
+
if (anchor)
|
|
4985
|
+
node.anchor = anchor.source.substring(1);
|
|
4986
|
+
} catch (error45) {
|
|
4987
|
+
const message = error45 instanceof Error ? error45.message : String(error45);
|
|
4988
|
+
onError(token, "RESOURCE_EXHAUSTION", message);
|
|
4989
|
+
}
|
|
4977
4990
|
break;
|
|
4978
4991
|
default: {
|
|
4979
4992
|
const message = token.type === "error" ? token.message : `Unsupported token (type: ${token.type})`;
|
|
4980
4993
|
onError(token, "UNEXPECTED_TOKEN", message);
|
|
4981
|
-
node = composeEmptyNode(ctx, token.offset, void 0, null, props, onError);
|
|
4982
4994
|
isSrcToken = false;
|
|
4983
4995
|
}
|
|
4984
4996
|
}
|
|
4997
|
+
node ?? (node = composeEmptyNode(ctx, token.offset, void 0, null, props, onError));
|
|
4985
4998
|
if (anchor && node.anchor === "")
|
|
4986
4999
|
onError(anchor, "BAD_ALIAS", "Anchor cannot be an empty string");
|
|
4987
5000
|
if (atKey && ctx.options.stringKeys && (!identity.isScalar(node) || typeof node.value !== "string" || node.tag && node.tag !== "tag:yaml.org,2002:str")) {
|
|
@@ -7331,6 +7344,20 @@ var BUILTIN_CODING_TEAM_ID = "coding-team";
|
|
|
7331
7344
|
var DEFAULT_EMBEDDED_TEAM_PRIORITY = 0;
|
|
7332
7345
|
var DEFAULT_FILE_TEAM_PRIORITY = 1;
|
|
7333
7346
|
var EMBEDDED_TEAM_IDS = [BUILTIN_CODING_TEAM_ID];
|
|
7347
|
+
var BUILTIN_CODING_TEAM_MODEL_PRESET = "sota-2026-05";
|
|
7348
|
+
var BUILTIN_CODING_TEAM_MODEL_FALLBACK = "builtin-role-chain";
|
|
7349
|
+
var BUILTIN_CODING_TEAM_FALLBACK_TO_HOST_DEFAULT = true;
|
|
7350
|
+
var CREWBEE_CONFIG_VERSION = 2;
|
|
7351
|
+
var BUILTIN_CODING_TEAM_AGENT_MODELS = {
|
|
7352
|
+
"coding-leader": "openai/gpt-5.5",
|
|
7353
|
+
"coordination-leader": "openai/gpt-5.5",
|
|
7354
|
+
"coding-executor": "openai/gpt-5.5",
|
|
7355
|
+
"codebase-explorer": "openai/gpt-5.4-mini",
|
|
7356
|
+
"web-researcher": "google/gemini-3.1-pro-preview",
|
|
7357
|
+
reviewer: "anthropic/claude-opus-4-7",
|
|
7358
|
+
"principal-advisor": "anthropic/claude-opus-4-7",
|
|
7359
|
+
"multimodal-looker": "google/gemini-3.1-pro-preview"
|
|
7360
|
+
};
|
|
7334
7361
|
|
|
7335
7362
|
// src/agent-teams/documentation.ts
|
|
7336
7363
|
import { existsSync, readdirSync } from "node:fs";
|
|
@@ -9492,7 +9519,27 @@ function createCodingTeamAgents() {
|
|
|
9492
9519
|
}
|
|
9493
9520
|
|
|
9494
9521
|
// src/agent-teams/embedded/coding-team.ts
|
|
9522
|
+
var CODING_TEAM_RUNTIME_PROFILES = {
|
|
9523
|
+
"coding-leader": { temperature: 0.2, topP: 0.85, variant: "long-context" },
|
|
9524
|
+
"coordination-leader": { temperature: 0.15, topP: 0.75 },
|
|
9525
|
+
"coding-executor": { temperature: 0.25, topP: 0.9 },
|
|
9526
|
+
"codebase-explorer": { temperature: 0.1, topP: 0.8 },
|
|
9527
|
+
"web-researcher": { temperature: 0.2, topP: 0.85 },
|
|
9528
|
+
reviewer: { temperature: 0.15, topP: 0.75 },
|
|
9529
|
+
"principal-advisor": { temperature: 0.15, topP: 0.75 },
|
|
9530
|
+
"multimodal-looker": { temperature: 0.2, topP: 0.85 }
|
|
9531
|
+
};
|
|
9495
9532
|
function createEmbeddedCodingTeam() {
|
|
9533
|
+
const runtime = Object.fromEntries(
|
|
9534
|
+
Object.entries(BUILTIN_CODING_TEAM_AGENT_MODELS).map(([agentId, model]) => [
|
|
9535
|
+
agentId,
|
|
9536
|
+
{
|
|
9537
|
+
model,
|
|
9538
|
+
...CODING_TEAM_RUNTIME_PROFILES[agentId],
|
|
9539
|
+
fallbackToHostDefault: BUILTIN_CODING_TEAM_FALLBACK_TO_HOST_DEFAULT
|
|
9540
|
+
}
|
|
9541
|
+
])
|
|
9542
|
+
);
|
|
9496
9543
|
const manifest = {
|
|
9497
9544
|
id: "coding-team",
|
|
9498
9545
|
version: "1.0.0",
|
|
@@ -9601,16 +9648,7 @@ function createEmbeddedCodingTeam() {
|
|
|
9601
9648
|
"\u4ED3\u5E93\u5185\u7814\u7A76\u4E0E\u5916\u90E8\u7814\u7A76\u5FC5\u987B\u5206\u79BB"
|
|
9602
9649
|
]
|
|
9603
9650
|
},
|
|
9604
|
-
agentRuntime:
|
|
9605
|
-
"coding-leader": { provider: "openai", model: "gpt-5.5", temperature: 0.2, topP: 0.85, variant: "long-context" },
|
|
9606
|
-
"coordination-leader": { provider: "openai", model: "gpt-5.5", temperature: 0.15, topP: 0.75 },
|
|
9607
|
-
"coding-executor": { provider: "openai", model: "gpt-5.5", temperature: 0.25, topP: 0.9 },
|
|
9608
|
-
"codebase-explorer": { provider: "openai", model: "gpt-5.5", temperature: 0.1, topP: 0.8 },
|
|
9609
|
-
"web-researcher": { provider: "openai", model: "gpt-5.5", temperature: 0.2, topP: 0.85 },
|
|
9610
|
-
reviewer: { provider: "openai", model: "gpt-5.5", temperature: 0.15, topP: 0.75 },
|
|
9611
|
-
"principal-advisor": { provider: "openai", model: "gpt-5.5", temperature: 0.15, topP: 0.75 },
|
|
9612
|
-
"multimodal-looker": { provider: "openai", model: "gpt-5.5", temperature: 0.2, topP: 0.85 }
|
|
9613
|
-
},
|
|
9651
|
+
agentRuntime: runtime,
|
|
9614
9652
|
tags: ["\u4EE3\u7801", "leader\u9A71\u52A8", "\u4E0A\u4E0B\u6587\u8FDE\u7EED\u6027", "\u4E3B\u6267\u884C\u8005\u4E2D\u5FC3", "\u8BC4\u5BA1\u4E2D\u5FC3", "\u8BC1\u636E\u9A71\u52A8"]
|
|
9615
9653
|
};
|
|
9616
9654
|
const agents = createCodingTeamAgents();
|
|
@@ -10228,12 +10266,14 @@ function mapAgentRuntime(raw) {
|
|
|
10228
10266
|
const record2 = asRecord(value, `agent_runtime.${agentId}`);
|
|
10229
10267
|
const options = asOptionalRecord(record2.options);
|
|
10230
10268
|
const runtime = {
|
|
10231
|
-
provider: asString(record2.provider, `agent_runtime.${agentId}.provider`),
|
|
10269
|
+
provider: record2.provider !== void 0 ? asString(record2.provider, `agent_runtime.${agentId}.provider`) : void 0,
|
|
10232
10270
|
model: asString(record2.model, `agent_runtime.${agentId}.model`),
|
|
10233
10271
|
temperature: record2.temperature !== void 0 ? Number(record2.temperature) : void 0,
|
|
10234
10272
|
topP: record2.top_p !== void 0 || record2.topP !== void 0 ? Number(record2.top_p ?? record2.topP) : void 0,
|
|
10235
10273
|
variant: asOptionalString(record2.variant),
|
|
10236
|
-
options: options ? { ...options } : void 0
|
|
10274
|
+
options: options ? { ...options } : void 0,
|
|
10275
|
+
fallbackModels: record2.fallback_models || record2.fallbackModels ? asStringArray(record2.fallback_models ?? record2.fallbackModels, `agent_runtime.${agentId}.fallback_models`) : void 0,
|
|
10276
|
+
fallbackToHostDefault: record2.fallback_to_host_default !== void 0 || record2.fallbackToHostDefault !== void 0 ? asBoolean(record2.fallback_to_host_default ?? record2.fallbackToHostDefault, `agent_runtime.${agentId}.fallback_to_host_default`) : void 0
|
|
10237
10277
|
};
|
|
10238
10278
|
return [agentId, runtime];
|
|
10239
10279
|
})
|
|
@@ -10492,6 +10532,31 @@ function getOptionalPriority(value, fallback) {
|
|
|
10492
10532
|
function getOptionalString(value) {
|
|
10493
10533
|
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
10494
10534
|
}
|
|
10535
|
+
function normalizeConfiguredTeamModelOverride(raw) {
|
|
10536
|
+
const modelPreset = getOptionalString(raw.model_preset ?? raw.modelPreset);
|
|
10537
|
+
const fallback = getOptionalString(raw.fallback);
|
|
10538
|
+
const fallbackToHostDefaultValue = raw.fallback_to_host_default ?? raw.fallbackToHostDefault;
|
|
10539
|
+
const fallbackToHostDefault = typeof fallbackToHostDefaultValue === "boolean" ? fallbackToHostDefaultValue : void 0;
|
|
10540
|
+
const agents = isRecord3(raw.agents) ? Object.fromEntries(
|
|
10541
|
+
Object.entries(raw.agents).flatMap(([agentId, value]) => {
|
|
10542
|
+
if (!isRecord3(value)) {
|
|
10543
|
+
return [];
|
|
10544
|
+
}
|
|
10545
|
+
const model = getOptionalString(value.model);
|
|
10546
|
+
return [[agentId, { ...model ? { model } : {} }]];
|
|
10547
|
+
})
|
|
10548
|
+
) : void 0;
|
|
10549
|
+
const normalizedAgents = agents && Object.keys(agents).length > 0 ? agents : void 0;
|
|
10550
|
+
if (!modelPreset && !fallback && fallbackToHostDefault === void 0 && !normalizedAgents) {
|
|
10551
|
+
return void 0;
|
|
10552
|
+
}
|
|
10553
|
+
return {
|
|
10554
|
+
modelPreset,
|
|
10555
|
+
fallback,
|
|
10556
|
+
fallbackToHostDefault,
|
|
10557
|
+
agents: normalizedAgents
|
|
10558
|
+
};
|
|
10559
|
+
}
|
|
10495
10560
|
function createDefaultCodingTeamSource(input) {
|
|
10496
10561
|
return {
|
|
10497
10562
|
kind: "embedded",
|
|
@@ -10501,14 +10566,21 @@ function createDefaultCodingTeamSource(input) {
|
|
|
10501
10566
|
order: -1,
|
|
10502
10567
|
sourceScope: input.sourceScope,
|
|
10503
10568
|
sourcePrecedence: input.sourcePrecedence,
|
|
10504
|
-
configPath: input.configPath
|
|
10569
|
+
configPath: input.configPath,
|
|
10570
|
+
modelConfigOverride: normalizeConfiguredTeamModelOverride(createDefaultCodingTeamConfigEntry())
|
|
10505
10571
|
};
|
|
10506
10572
|
}
|
|
10507
10573
|
function createDefaultCodingTeamConfigEntry() {
|
|
10508
10574
|
return {
|
|
10509
10575
|
id: BUILTIN_CODING_TEAM_ID,
|
|
10510
10576
|
enabled: true,
|
|
10511
|
-
priority: DEFAULT_EMBEDDED_TEAM_PRIORITY
|
|
10577
|
+
priority: DEFAULT_EMBEDDED_TEAM_PRIORITY,
|
|
10578
|
+
model_preset: BUILTIN_CODING_TEAM_MODEL_PRESET,
|
|
10579
|
+
fallback: BUILTIN_CODING_TEAM_MODEL_FALLBACK,
|
|
10580
|
+
fallback_to_host_default: BUILTIN_CODING_TEAM_FALLBACK_TO_HOST_DEFAULT,
|
|
10581
|
+
agents: Object.fromEntries(
|
|
10582
|
+
Object.entries(BUILTIN_CODING_TEAM_AGENT_MODELS).map(([agentId, model]) => [agentId, { model }])
|
|
10583
|
+
)
|
|
10512
10584
|
};
|
|
10513
10585
|
}
|
|
10514
10586
|
function getPackagedTemplateRootPath() {
|
|
@@ -10555,6 +10627,7 @@ function createDefaultCrewBeeConfig() {
|
|
|
10555
10627
|
}
|
|
10556
10628
|
}
|
|
10557
10629
|
return {
|
|
10630
|
+
config_version: CREWBEE_CONFIG_VERSION,
|
|
10558
10631
|
teams: [createDefaultCodingTeamConfigEntry()]
|
|
10559
10632
|
};
|
|
10560
10633
|
}
|
|
@@ -10613,6 +10686,65 @@ function createUpdatedCrewBeeConfigWithDefaultTeam(config2) {
|
|
|
10613
10686
|
}
|
|
10614
10687
|
};
|
|
10615
10688
|
}
|
|
10689
|
+
function migrateCrewBeeConfig(existing) {
|
|
10690
|
+
const currentVersion = typeof existing.config_version === "number" ? existing.config_version : 1;
|
|
10691
|
+
if (currentVersion >= CREWBEE_CONFIG_VERSION) {
|
|
10692
|
+
return { changed: false, config: existing };
|
|
10693
|
+
}
|
|
10694
|
+
const defaults = createDefaultCrewBeeConfig();
|
|
10695
|
+
const migrated = { ...existing };
|
|
10696
|
+
migrated.config_version = CREWBEE_CONFIG_VERSION;
|
|
10697
|
+
for (const key of Object.keys(defaults)) {
|
|
10698
|
+
if (!(key in migrated)) {
|
|
10699
|
+
migrated[key] = defaults[key];
|
|
10700
|
+
}
|
|
10701
|
+
}
|
|
10702
|
+
const existingTeams = Array.isArray(migrated.teams) ? migrated.teams : [];
|
|
10703
|
+
const defaultTeams = defaults.teams ?? [];
|
|
10704
|
+
const mergedTeams = existingTeams.map((entry) => {
|
|
10705
|
+
if (!isRecord3(entry)) return entry;
|
|
10706
|
+
const teamId = getOptionalString(entry.id);
|
|
10707
|
+
if (!teamId) return entry;
|
|
10708
|
+
const defaultEntry = defaultTeams.find(
|
|
10709
|
+
(d) => isRecord3(d) && d.id === teamId
|
|
10710
|
+
);
|
|
10711
|
+
if (!defaultEntry || !isRecord3(defaultEntry)) return entry;
|
|
10712
|
+
const merged = { ...entry };
|
|
10713
|
+
for (const key of Object.keys(defaultEntry)) {
|
|
10714
|
+
if (!(key in merged)) {
|
|
10715
|
+
merged[key] = defaultEntry[key];
|
|
10716
|
+
}
|
|
10717
|
+
}
|
|
10718
|
+
if (isRecord3(defaultEntry.agents)) {
|
|
10719
|
+
const existingAgents = isRecord3(merged.agents) ? { ...merged.agents } : {};
|
|
10720
|
+
for (const [agentId, agentConfig] of Object.entries(defaultEntry.agents)) {
|
|
10721
|
+
if (!(agentId in existingAgents)) {
|
|
10722
|
+
existingAgents[agentId] = agentConfig;
|
|
10723
|
+
}
|
|
10724
|
+
}
|
|
10725
|
+
merged.agents = existingAgents;
|
|
10726
|
+
}
|
|
10727
|
+
return merged;
|
|
10728
|
+
});
|
|
10729
|
+
for (const defaultEntry of defaultTeams) {
|
|
10730
|
+
if (!isRecord3(defaultEntry)) continue;
|
|
10731
|
+
const defaultId = getOptionalString(defaultEntry.id);
|
|
10732
|
+
const defaultPath = getOptionalString(defaultEntry.path);
|
|
10733
|
+
const key = defaultId ?? defaultPath;
|
|
10734
|
+
if (!key) continue;
|
|
10735
|
+
const alreadyExists = mergedTeams.some((entry) => {
|
|
10736
|
+
if (!isRecord3(entry)) return false;
|
|
10737
|
+
if (defaultId) return entry.id === defaultId;
|
|
10738
|
+
if (defaultPath) return entry.path === defaultPath;
|
|
10739
|
+
return false;
|
|
10740
|
+
});
|
|
10741
|
+
if (!alreadyExists) {
|
|
10742
|
+
mergedTeams.push(defaultEntry);
|
|
10743
|
+
}
|
|
10744
|
+
}
|
|
10745
|
+
migrated.teams = mergedTeams;
|
|
10746
|
+
return { changed: true, config: migrated };
|
|
10747
|
+
}
|
|
10616
10748
|
function ensureCrewBeeConfigFile(input) {
|
|
10617
10749
|
const configRoot = input.configRoot ?? resolveOpenCodeConfigRoot();
|
|
10618
10750
|
const configPath = resolveCrewBeeConfigPath(configRoot);
|
|
@@ -10642,14 +10774,21 @@ function ensureCrewBeeConfigFile(input) {
|
|
|
10642
10774
|
};
|
|
10643
10775
|
}
|
|
10644
10776
|
if (input.mode === "startup") {
|
|
10777
|
+
const migration2 = migrateCrewBeeConfig(parsed.config);
|
|
10778
|
+
if (migration2.changed && !input.dryRun) {
|
|
10779
|
+
writeCrewBeeConfig(configPath, migration2.config);
|
|
10780
|
+
}
|
|
10645
10781
|
return {
|
|
10646
|
-
changed:
|
|
10782
|
+
changed: migration2.changed,
|
|
10647
10783
|
configPath,
|
|
10648
|
-
reason: "unchanged"
|
|
10784
|
+
reason: migration2.changed ? "migrated-config-version" : "unchanged"
|
|
10649
10785
|
};
|
|
10650
10786
|
}
|
|
10651
10787
|
const updated = createUpdatedCrewBeeConfigWithDefaultTeam(parsed.config);
|
|
10652
|
-
|
|
10788
|
+
const migration = migrateCrewBeeConfig(updated.next);
|
|
10789
|
+
const finalConfig = migration.config;
|
|
10790
|
+
const changed = updated.changed || migration.changed;
|
|
10791
|
+
if (!changed) {
|
|
10653
10792
|
return {
|
|
10654
10793
|
changed: false,
|
|
10655
10794
|
configPath,
|
|
@@ -10657,12 +10796,12 @@ function ensureCrewBeeConfigFile(input) {
|
|
|
10657
10796
|
};
|
|
10658
10797
|
}
|
|
10659
10798
|
if (!input.dryRun) {
|
|
10660
|
-
writeCrewBeeConfig(configPath,
|
|
10799
|
+
writeCrewBeeConfig(configPath, finalConfig);
|
|
10661
10800
|
}
|
|
10662
10801
|
return {
|
|
10663
10802
|
changed: true,
|
|
10664
10803
|
configPath,
|
|
10665
|
-
reason: "added-default-coding-team"
|
|
10804
|
+
reason: updated.changed ? "added-default-coding-team" : "migrated-config-version"
|
|
10666
10805
|
};
|
|
10667
10806
|
}
|
|
10668
10807
|
function resolveConfiguredTeamPath(teamPath, configRoot) {
|
|
@@ -10752,7 +10891,8 @@ function normalizeConfiguredTeamEntry(input) {
|
|
|
10752
10891
|
order: input.index,
|
|
10753
10892
|
sourceScope: input.sourceScope,
|
|
10754
10893
|
sourcePrecedence: input.sourcePrecedence,
|
|
10755
|
-
configPath: input.configPath
|
|
10894
|
+
configPath: input.configPath,
|
|
10895
|
+
modelConfigOverride: normalizeConfiguredTeamModelOverride(raw)
|
|
10756
10896
|
},
|
|
10757
10897
|
issues: []
|
|
10758
10898
|
};
|
|
@@ -10767,7 +10907,8 @@ function normalizeConfiguredTeamEntry(input) {
|
|
|
10767
10907
|
order: input.index,
|
|
10768
10908
|
sourceScope: input.sourceScope,
|
|
10769
10909
|
sourcePrecedence: input.sourcePrecedence,
|
|
10770
|
-
configPath: input.configPath
|
|
10910
|
+
configPath: input.configPath,
|
|
10911
|
+
modelConfigOverride: normalizeConfiguredTeamModelOverride(raw)
|
|
10771
10912
|
},
|
|
10772
10913
|
issues: []
|
|
10773
10914
|
};
|
|
@@ -11068,6 +11209,15 @@ function normalizeTeamAgentIds(input) {
|
|
|
11068
11209
|
])
|
|
11069
11210
|
) : void 0
|
|
11070
11211
|
},
|
|
11212
|
+
modelConfigOverride: input.team.modelConfigOverride ? {
|
|
11213
|
+
...input.team.modelConfigOverride,
|
|
11214
|
+
agents: input.team.modelConfigOverride.agents ? Object.fromEntries(
|
|
11215
|
+
Object.entries(input.team.modelConfigOverride.agents).map(([agentId, override]) => [
|
|
11216
|
+
agentIdMap.get(agentId) ?? agentId,
|
|
11217
|
+
override
|
|
11218
|
+
])
|
|
11219
|
+
) : void 0
|
|
11220
|
+
} : void 0,
|
|
11071
11221
|
agents: input.team.agents.map((agent) => {
|
|
11072
11222
|
const canonicalAgentId = agentIdMap.get(agent.metadata.id) ?? agent.metadata.id;
|
|
11073
11223
|
return {
|
|
@@ -11148,6 +11298,9 @@ function validateTeamDefinition(team) {
|
|
|
11148
11298
|
return issues;
|
|
11149
11299
|
}
|
|
11150
11300
|
for (const [agentId] of Object.entries(manifest.agentRuntime ?? {})) {
|
|
11301
|
+
if (agentId === "$default") {
|
|
11302
|
+
continue;
|
|
11303
|
+
}
|
|
11151
11304
|
if (!agentIds.has(agentId)) {
|
|
11152
11305
|
issues.push({
|
|
11153
11306
|
level: "warning",
|
|
@@ -11158,6 +11311,17 @@ function validateTeamDefinition(team) {
|
|
|
11158
11311
|
});
|
|
11159
11312
|
}
|
|
11160
11313
|
}
|
|
11314
|
+
for (const [agentId] of Object.entries(team.modelConfigOverride?.agents ?? {})) {
|
|
11315
|
+
if (!agentIds.has(agentId)) {
|
|
11316
|
+
issues.push({
|
|
11317
|
+
level: "warning",
|
|
11318
|
+
code: "team_agent_model_override_target_missing",
|
|
11319
|
+
path: `teams.${manifest.id}.agents.${agentId}`,
|
|
11320
|
+
message: `Agent model override '${agentId}' is not defined in Team '${manifest.id}'.`,
|
|
11321
|
+
suggestion: "Remove this model override or add the target Agent profile."
|
|
11322
|
+
});
|
|
11323
|
+
}
|
|
11324
|
+
}
|
|
11161
11325
|
for (const agent of team.agents) {
|
|
11162
11326
|
const requestedTools = new Set(agent.runtimeConfig.requestedTools);
|
|
11163
11327
|
const collaborationTargets = [
|
|
@@ -11299,7 +11463,10 @@ function loadDefaultTeamLibrary(input = process.cwd()) {
|
|
|
11299
11463
|
continue;
|
|
11300
11464
|
}
|
|
11301
11465
|
pendingTeams.push({
|
|
11302
|
-
loader: () => ({
|
|
11466
|
+
loader: () => ({
|
|
11467
|
+
team: embeddedTeam.team ? { ...embeddedTeam.team, modelConfigOverride: source.modelConfigOverride } : void 0,
|
|
11468
|
+
issues: []
|
|
11469
|
+
}),
|
|
11303
11470
|
priority: source.priority,
|
|
11304
11471
|
order: source.order,
|
|
11305
11472
|
sourcePrecedence: source.sourcePrecedence,
|
|
@@ -11313,7 +11480,7 @@ function loadDefaultTeamLibrary(input = process.cwd()) {
|
|
|
11313
11480
|
try {
|
|
11314
11481
|
const loaded = loadTeamDefinitionFromDirectoryWithIssues(source.teamDir, baseDir);
|
|
11315
11482
|
return {
|
|
11316
|
-
team: loaded.team,
|
|
11483
|
+
team: { ...loaded.team, modelConfigOverride: source.modelConfigOverride },
|
|
11317
11484
|
issues: loaded.issues
|
|
11318
11485
|
};
|
|
11319
11486
|
} catch (error45) {
|
|
@@ -11717,56 +11884,108 @@ function shouldEmitCrewBeeLog(level = "info") {
|
|
|
11717
11884
|
return level === "error" || level === "warn" || isCrewBeeLoggingEnabled();
|
|
11718
11885
|
}
|
|
11719
11886
|
|
|
11720
|
-
// src/adapters/opencode/
|
|
11721
|
-
function
|
|
11722
|
-
|
|
11723
|
-
|
|
11887
|
+
// src/adapters/opencode/capabilities.ts
|
|
11888
|
+
function createOpenCodeCapabilityContract() {
|
|
11889
|
+
return {
|
|
11890
|
+
supportsAgentRegistration: true,
|
|
11891
|
+
supportsAgentSwitching: true,
|
|
11892
|
+
supportsNativeAgentSelection: true,
|
|
11893
|
+
supportsNativeModelSelection: true,
|
|
11894
|
+
supportsCliOverrides: true,
|
|
11895
|
+
supportsSingleExecutorMode: true,
|
|
11896
|
+
supportsTeamCollaboration: false,
|
|
11897
|
+
supportsRuntimeEvents: true,
|
|
11898
|
+
supportsToolDomainInjection: false,
|
|
11899
|
+
supportsSessionLogExport: false
|
|
11900
|
+
};
|
|
11724
11901
|
}
|
|
11725
|
-
|
|
11726
|
-
|
|
11902
|
+
|
|
11903
|
+
// src/adapters/opencode/ownership.ts
|
|
11904
|
+
function isRecord4(value) {
|
|
11905
|
+
return typeof value === "object" && value !== null;
|
|
11727
11906
|
}
|
|
11728
|
-
function
|
|
11729
|
-
if (
|
|
11730
|
-
return
|
|
11731
|
-
providerID: target.resolvedModel.providerID,
|
|
11732
|
-
modelID: target.resolvedModel.modelID
|
|
11733
|
-
};
|
|
11907
|
+
function isManagedCrewBeeAgentDefinition(value) {
|
|
11908
|
+
if (!isRecord4(value)) {
|
|
11909
|
+
return false;
|
|
11734
11910
|
}
|
|
11735
|
-
|
|
11911
|
+
const options = value.options;
|
|
11912
|
+
if (!isRecord4(options)) {
|
|
11913
|
+
return false;
|
|
11914
|
+
}
|
|
11915
|
+
const crewbee = options.crewbee;
|
|
11916
|
+
return isRecord4(crewbee) && crewbee.managed === true;
|
|
11736
11917
|
}
|
|
11737
|
-
function
|
|
11738
|
-
return
|
|
11739
|
-
|
|
11740
|
-
|
|
11741
|
-
|
|
11742
|
-
|
|
11743
|
-
|
|
11744
|
-
|
|
11745
|
-
|
|
11746
|
-
"",
|
|
11747
|
-
"Execution rules:",
|
|
11748
|
-
"- Work only on this delegated objective",
|
|
11749
|
-
"- Do not broaden scope",
|
|
11750
|
-
"- If you need a skill, decide and load it yourself based on the task",
|
|
11751
|
-
"- Prefer a compact result focused on outcome, files changed, blockers, and next step",
|
|
11752
|
-
"",
|
|
11753
|
-
"Return:",
|
|
11754
|
-
"1. Result / conclusion",
|
|
11755
|
-
"2. Files changed or inspected",
|
|
11756
|
-
"3. Remaining risk or blocker",
|
|
11757
|
-
"4. Recommended next step"
|
|
11758
|
-
].join("\n");
|
|
11918
|
+
function createManagedCrewBeeAgentOptions(input) {
|
|
11919
|
+
return {
|
|
11920
|
+
...input.existingOptions ?? {},
|
|
11921
|
+
crewbee: {
|
|
11922
|
+
managed: true,
|
|
11923
|
+
teamId: input.teamId,
|
|
11924
|
+
canonicalAgentId: input.canonicalAgentId
|
|
11925
|
+
}
|
|
11926
|
+
};
|
|
11759
11927
|
}
|
|
11760
|
-
|
|
11928
|
+
|
|
11929
|
+
// src/adapters/opencode/config-merge.ts
|
|
11930
|
+
function applyOpenCodeAgentConfigPatch(config2, patch) {
|
|
11931
|
+
const patchKeys = new Set(Object.keys(patch.agent));
|
|
11932
|
+
const nextAgents = Object.fromEntries(
|
|
11933
|
+
Object.entries(config2.agent ?? {}).filter(([key, definition]) => {
|
|
11934
|
+
if (isManagedCrewBeeAgentDefinition(definition) && !patchKeys.has(key)) {
|
|
11935
|
+
return false;
|
|
11936
|
+
}
|
|
11937
|
+
return true;
|
|
11938
|
+
})
|
|
11939
|
+
);
|
|
11940
|
+
const insertedAgentKeys = [];
|
|
11941
|
+
const updatedAgentKeys = [];
|
|
11942
|
+
const skippedAgentKeys = [];
|
|
11943
|
+
for (const [key, definition] of Object.entries(patch.agent)) {
|
|
11944
|
+
if (!(key in nextAgents)) {
|
|
11945
|
+
nextAgents[key] = definition;
|
|
11946
|
+
insertedAgentKeys.push(key);
|
|
11947
|
+
continue;
|
|
11948
|
+
}
|
|
11949
|
+
const existingDefinition = nextAgents[key];
|
|
11950
|
+
if (isManagedCrewBeeAgentDefinition(existingDefinition)) {
|
|
11951
|
+
nextAgents[key] = definition;
|
|
11952
|
+
updatedAgentKeys.push(key);
|
|
11953
|
+
continue;
|
|
11954
|
+
}
|
|
11955
|
+
skippedAgentKeys.push(key);
|
|
11956
|
+
}
|
|
11957
|
+
const nextConfig = {
|
|
11958
|
+
...config2,
|
|
11959
|
+
agent: nextAgents
|
|
11960
|
+
};
|
|
11961
|
+
if (patch.defaultAgent) {
|
|
11962
|
+
nextConfig.default_agent = patch.defaultAgent;
|
|
11963
|
+
}
|
|
11761
11964
|
return {
|
|
11762
|
-
|
|
11763
|
-
|
|
11764
|
-
|
|
11965
|
+
config: nextConfig,
|
|
11966
|
+
insertedAgentKeys,
|
|
11967
|
+
updatedAgentKeys,
|
|
11968
|
+
skippedAgentKeys
|
|
11765
11969
|
};
|
|
11766
11970
|
}
|
|
11767
11971
|
|
|
11768
|
-
// src/adapters/opencode/
|
|
11769
|
-
|
|
11972
|
+
// src/adapters/opencode/coexistence.ts
|
|
11973
|
+
function createOpenCodeCoexistencePolicy() {
|
|
11974
|
+
return {
|
|
11975
|
+
pluginId: "crewbee",
|
|
11976
|
+
dependsOnOhMyOpenCode: false,
|
|
11977
|
+
featureDevelopmentMode: "mutually-exclusive",
|
|
11978
|
+
safeWhenCoInstalled: true,
|
|
11979
|
+
reservedConfigKeyPrefix: "",
|
|
11980
|
+
neverMutateForeignAgents: true
|
|
11981
|
+
};
|
|
11982
|
+
}
|
|
11983
|
+
function detectOpenCodeProjectionCollisions(input) {
|
|
11984
|
+
const existingConfigKeys = new Set(input.existingConfigKeys ?? []);
|
|
11985
|
+
return {
|
|
11986
|
+
configKeyCollisions: input.projectedAgents.filter((agent) => existingConfigKeys.has(agent.configKey)).map((agent) => agent.configKey)
|
|
11987
|
+
};
|
|
11988
|
+
}
|
|
11770
11989
|
|
|
11771
11990
|
// src/adapters/opencode/permission-mapper.ts
|
|
11772
11991
|
var TOOL_MAP = {
|
|
@@ -11818,33 +12037,7 @@ function createOpenCodePermissionConfig(permissionRules) {
|
|
|
11818
12037
|
return permission;
|
|
11819
12038
|
}
|
|
11820
12039
|
|
|
11821
|
-
// src/
|
|
11822
|
-
function isRecord4(value) {
|
|
11823
|
-
return typeof value === "object" && value !== null;
|
|
11824
|
-
}
|
|
11825
|
-
function isManagedCrewBeeAgentDefinition(value) {
|
|
11826
|
-
if (!isRecord4(value)) {
|
|
11827
|
-
return false;
|
|
11828
|
-
}
|
|
11829
|
-
const options = value.options;
|
|
11830
|
-
if (!isRecord4(options)) {
|
|
11831
|
-
return false;
|
|
11832
|
-
}
|
|
11833
|
-
const crewbee = options.crewbee;
|
|
11834
|
-
return isRecord4(crewbee) && crewbee.managed === true;
|
|
11835
|
-
}
|
|
11836
|
-
function createManagedCrewBeeAgentOptions(input) {
|
|
11837
|
-
return {
|
|
11838
|
-
...input.existingOptions ?? {},
|
|
11839
|
-
crewbee: {
|
|
11840
|
-
managed: true,
|
|
11841
|
-
teamId: input.teamId,
|
|
11842
|
-
canonicalAgentId: input.canonicalAgentId
|
|
11843
|
-
}
|
|
11844
|
-
};
|
|
11845
|
-
}
|
|
11846
|
-
|
|
11847
|
-
// src/normalize/build-agent-prompt-source.ts
|
|
12040
|
+
// src/normalize/build-agent-prompt-document.ts
|
|
11848
12041
|
function isRecord5(value) {
|
|
11849
12042
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
11850
12043
|
}
|
|
@@ -11882,7 +12075,7 @@ function pushBlock(blocks, key, value, order) {
|
|
|
11882
12075
|
});
|
|
11883
12076
|
return order + 1;
|
|
11884
12077
|
}
|
|
11885
|
-
function
|
|
12078
|
+
function buildAgentPromptDocumentWithOverrides(agent, overrides) {
|
|
11886
12079
|
const blocks = [];
|
|
11887
12080
|
let order = 0;
|
|
11888
12081
|
order = pushBlock(blocks, "persona_core", agent.personaCore, order);
|
|
@@ -11917,7 +12110,7 @@ function buildAgentPromptSourceWithOverrides(agent, overrides) {
|
|
|
11917
12110
|
};
|
|
11918
12111
|
}
|
|
11919
12112
|
|
|
11920
|
-
// src/normalize/build-team-prompt-
|
|
12113
|
+
// src/normalize/build-team-prompt-document.ts
|
|
11921
12114
|
function asRecord2(value) {
|
|
11922
12115
|
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
11923
12116
|
}
|
|
@@ -11927,7 +12120,7 @@ function asMetadataRecord2(value) {
|
|
|
11927
12120
|
}
|
|
11928
12121
|
return value;
|
|
11929
12122
|
}
|
|
11930
|
-
function
|
|
12123
|
+
function buildTeamPromptDocument(manifest, policy, bodySections = []) {
|
|
11931
12124
|
const qualityFloor = asRecord2(policy.qualityFloor);
|
|
11932
12125
|
const approvalPolicy = asRecord2(policy.approvalPolicy);
|
|
11933
12126
|
const workingRulesValue = normalizeValue({
|
|
@@ -11993,7 +12186,39 @@ function buildTeamPromptSource(manifest, policy, bodySections = []) {
|
|
|
11993
12186
|
};
|
|
11994
12187
|
}
|
|
11995
12188
|
|
|
11996
|
-
// src/
|
|
12189
|
+
// src/render/apply-prompt-projection.ts
|
|
12190
|
+
function matchesPath(selected, path10) {
|
|
12191
|
+
return selected === path10 || path10.startsWith(`${selected}.`);
|
|
12192
|
+
}
|
|
12193
|
+
function isAncestorPath(ancestor, descendant) {
|
|
12194
|
+
return descendant === ancestor || descendant.startsWith(`${ancestor}.`);
|
|
12195
|
+
}
|
|
12196
|
+
function projectNode(node, projection) {
|
|
12197
|
+
const include = projection?.include ?? [];
|
|
12198
|
+
const exclude = projection?.exclude ?? [];
|
|
12199
|
+
const labels = projection?.labels ?? {};
|
|
12200
|
+
const projectedChildren = node.children?.map((child) => projectNode(child, projection)).filter((child) => Boolean(child));
|
|
12201
|
+
const explicitlyIncluded = include.length === 0 || include.some((selected) => matchesPath(selected, node.path));
|
|
12202
|
+
const descendantIncluded = include.length > 0 && include.some((selected) => isAncestorPath(node.path, selected));
|
|
12203
|
+
const explicitlyExcluded = exclude.some((selected) => matchesPath(selected, node.path));
|
|
12204
|
+
const shouldKeep = include.length === 0 ? !explicitlyExcluded && (node.visibleByDefault || (projectedChildren?.length ?? 0) > 0) : (explicitlyIncluded || descendantIncluded || (projectedChildren?.length ?? 0) > 0) && !explicitlyExcluded;
|
|
12205
|
+
if (!shouldKeep) {
|
|
12206
|
+
return void 0;
|
|
12207
|
+
}
|
|
12208
|
+
return {
|
|
12209
|
+
...node,
|
|
12210
|
+
label: labels[node.path] ?? node.label,
|
|
12211
|
+
...projectedChildren ? { children: projectedChildren } : {}
|
|
12212
|
+
};
|
|
12213
|
+
}
|
|
12214
|
+
function applyPromptProjection(catalog, projection) {
|
|
12215
|
+
return {
|
|
12216
|
+
kind: catalog.kind,
|
|
12217
|
+
nodes: catalog.nodes.map((node) => projectNode(node, projection)).filter((node) => Boolean(node))
|
|
12218
|
+
};
|
|
12219
|
+
}
|
|
12220
|
+
|
|
12221
|
+
// src/render/build-prompt-catalog.ts
|
|
11997
12222
|
function formatDisplayLabel(key) {
|
|
11998
12223
|
return key.replace(/_/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/\b\w/g, (char) => char.toUpperCase());
|
|
11999
12224
|
}
|
|
@@ -12066,7 +12291,7 @@ function buildPromptCatalog(doc) {
|
|
|
12066
12291
|
};
|
|
12067
12292
|
}
|
|
12068
12293
|
|
|
12069
|
-
// src/
|
|
12294
|
+
// src/render/build-prompt-plan.ts
|
|
12070
12295
|
var CANONICAL_SECTION_TITLES = {
|
|
12071
12296
|
working_rules: "Working Rules",
|
|
12072
12297
|
approval_safety: "Approval & Safety",
|
|
@@ -12137,38 +12362,6 @@ function buildPromptPlan(catalog) {
|
|
|
12137
12362
|
};
|
|
12138
12363
|
}
|
|
12139
12364
|
|
|
12140
|
-
// src/projection/apply-prompt-projection.ts
|
|
12141
|
-
function matchesPath(selected, path10) {
|
|
12142
|
-
return selected === path10 || path10.startsWith(`${selected}.`);
|
|
12143
|
-
}
|
|
12144
|
-
function isAncestorPath(ancestor, descendant) {
|
|
12145
|
-
return descendant === ancestor || descendant.startsWith(`${ancestor}.`);
|
|
12146
|
-
}
|
|
12147
|
-
function projectNode(node, projection) {
|
|
12148
|
-
const include = projection?.include ?? [];
|
|
12149
|
-
const exclude = projection?.exclude ?? [];
|
|
12150
|
-
const labels = projection?.labels ?? {};
|
|
12151
|
-
const projectedChildren = node.children?.map((child) => projectNode(child, projection)).filter((child) => Boolean(child));
|
|
12152
|
-
const explicitlyIncluded = include.length === 0 || include.some((selected) => matchesPath(selected, node.path));
|
|
12153
|
-
const descendantIncluded = include.length > 0 && include.some((selected) => isAncestorPath(node.path, selected));
|
|
12154
|
-
const explicitlyExcluded = exclude.some((selected) => matchesPath(selected, node.path));
|
|
12155
|
-
const shouldKeep = include.length === 0 ? !explicitlyExcluded && (node.visibleByDefault || (projectedChildren?.length ?? 0) > 0) : (explicitlyIncluded || descendantIncluded || (projectedChildren?.length ?? 0) > 0) && !explicitlyExcluded;
|
|
12156
|
-
if (!shouldKeep) {
|
|
12157
|
-
return void 0;
|
|
12158
|
-
}
|
|
12159
|
-
return {
|
|
12160
|
-
...node,
|
|
12161
|
-
label: labels[node.path] ?? node.label,
|
|
12162
|
-
...projectedChildren ? { children: projectedChildren } : {}
|
|
12163
|
-
};
|
|
12164
|
-
}
|
|
12165
|
-
function applyPromptProjection(catalog, projection) {
|
|
12166
|
-
return {
|
|
12167
|
-
kind: catalog.kind,
|
|
12168
|
-
nodes: catalog.nodes.map((node) => projectNode(node, projection)).filter((node) => Boolean(node))
|
|
12169
|
-
};
|
|
12170
|
-
}
|
|
12171
|
-
|
|
12172
12365
|
// src/render/structural-renderer.ts
|
|
12173
12366
|
var defaultRenderContext = {
|
|
12174
12367
|
indentUnit: " "
|
|
@@ -12305,7 +12498,7 @@ function renderPart(title, body) {
|
|
|
12305
12498
|
${body}` : void 0;
|
|
12306
12499
|
}
|
|
12307
12500
|
function createOpenCodeAgentPrompt(agent, _requestedTools) {
|
|
12308
|
-
const
|
|
12501
|
+
const teamDocument = buildTeamPromptDocument(
|
|
12309
12502
|
{
|
|
12310
12503
|
id: agent.sourceTeam.manifest.id,
|
|
12311
12504
|
name: agent.sourceTeam.manifest.name,
|
|
@@ -12313,21 +12506,196 @@ function createOpenCodeAgentPrompt(agent, _requestedTools) {
|
|
|
12313
12506
|
},
|
|
12314
12507
|
agent.sourceTeam.policy
|
|
12315
12508
|
);
|
|
12316
|
-
const teamPart = renderNormalizedPromptDocument(
|
|
12317
|
-
const normalizedAgent =
|
|
12509
|
+
const teamPart = renderNormalizedPromptDocument(teamDocument);
|
|
12510
|
+
const normalizedAgent = buildAgentPromptDocumentWithOverrides(agent.sourceAgent, {
|
|
12318
12511
|
collaborationValue: createCollaborationPromptValue(agent)
|
|
12319
12512
|
});
|
|
12320
12513
|
const agentPart = renderNormalizedPromptDocument(normalizedAgent);
|
|
12321
12514
|
return [renderPart("Team Contract", teamPart), renderPart("Agent Contract", agentPart)].filter((block) => Boolean(block)).join("\n\n");
|
|
12322
12515
|
}
|
|
12323
12516
|
|
|
12517
|
+
// src/adapters/opencode/model-resolution.ts
|
|
12518
|
+
var HOST_DEFAULT_MODEL_ID = "host-default";
|
|
12519
|
+
var TEAM_MANIFEST_FALLBACK_STRATEGY = "team-manifest";
|
|
12520
|
+
var BUILTIN_ROLE_FALLBACKS = {
|
|
12521
|
+
"coding-leader": ["openai/gpt-5.5-pro", "anthropic/claude-opus-4-7", "google/gemini-3.1-pro-preview"],
|
|
12522
|
+
"coordination-leader": ["anthropic/claude-opus-4-7", "google/gemini-3.1-pro-preview", "openai/gpt-5.4-mini"],
|
|
12523
|
+
"coding-executor": ["openai/gpt-5.5-pro", "anthropic/claude-opus-4-7", "google/gemini-3.1-pro-preview"],
|
|
12524
|
+
"codebase-explorer": ["google/gemini-3.1-flash-lite-preview", "openai/gpt-5.5", "google/gemini-3.1-pro-preview"],
|
|
12525
|
+
"web-researcher": ["openai/gpt-5.5", "anthropic/claude-opus-4-7", "google/gemini-3.1-flash-lite-preview"],
|
|
12526
|
+
reviewer: ["openai/gpt-5.5-pro", "openai/gpt-5.5", "google/gemini-3.1-pro-preview"],
|
|
12527
|
+
"principal-advisor": ["openai/gpt-5.5-pro", "openai/gpt-5.5", "google/gemini-3.1-pro-preview"],
|
|
12528
|
+
"multimodal-looker": ["openai/gpt-5.5", "anthropic/claude-opus-4-7"],
|
|
12529
|
+
"task-orchestrator": ["anthropic/claude-opus-4-7", "google/gemini-3.1-pro-preview", "openai/gpt-5.4-mini"]
|
|
12530
|
+
};
|
|
12531
|
+
function resolveRuntimeModelId(runtime) {
|
|
12532
|
+
if (!runtime?.model) {
|
|
12533
|
+
return void 0;
|
|
12534
|
+
}
|
|
12535
|
+
if (runtime.model === HOST_DEFAULT_MODEL_ID || runtime.model.includes("/")) {
|
|
12536
|
+
return runtime.model;
|
|
12537
|
+
}
|
|
12538
|
+
return runtime.provider ? `${runtime.provider}/${runtime.model}` : runtime.model;
|
|
12539
|
+
}
|
|
12540
|
+
function parseProviderModel(model) {
|
|
12541
|
+
const separator = model.indexOf("/");
|
|
12542
|
+
if (separator <= 0 || separator >= model.length - 1) {
|
|
12543
|
+
return void 0;
|
|
12544
|
+
}
|
|
12545
|
+
return {
|
|
12546
|
+
providerID: model.slice(0, separator),
|
|
12547
|
+
modelID: model.slice(separator + 1)
|
|
12548
|
+
};
|
|
12549
|
+
}
|
|
12550
|
+
function appendUniqueCandidate(candidates, candidate) {
|
|
12551
|
+
if (candidates.some((entry) => entry.model === candidate.model)) {
|
|
12552
|
+
return;
|
|
12553
|
+
}
|
|
12554
|
+
candidates.push(candidate);
|
|
12555
|
+
}
|
|
12556
|
+
function getCandidateModelIds(candidates) {
|
|
12557
|
+
return candidates.map((candidate) => candidate.model);
|
|
12558
|
+
}
|
|
12559
|
+
function createHostDefaultTrace(input) {
|
|
12560
|
+
return {
|
|
12561
|
+
teamId: input.agent.teamId,
|
|
12562
|
+
agentId: input.agent.canonicalAgentId,
|
|
12563
|
+
configuredModel: input.configuredModel,
|
|
12564
|
+
resolvedModel: HOST_DEFAULT_MODEL_ID,
|
|
12565
|
+
source: "host-default",
|
|
12566
|
+
fallback: input.fallbackStrategy,
|
|
12567
|
+
fallbackToHostDefault: input.fallbackToHostDefault,
|
|
12568
|
+
candidates: getCandidateModelIds(input.candidates),
|
|
12569
|
+
skipped: input.skipped,
|
|
12570
|
+
reason: input.reason
|
|
12571
|
+
};
|
|
12572
|
+
}
|
|
12573
|
+
function appendConfiguredModelCandidate(input) {
|
|
12574
|
+
const runtimeModel = resolveRuntimeModelId(input.runtime);
|
|
12575
|
+
const defaultRuntimeModel = resolveRuntimeModelId(input.defaultRuntime);
|
|
12576
|
+
if (input.agentOverrideModel) {
|
|
12577
|
+
appendUniqueCandidate(input.candidates, { model: input.agentOverrideModel, source: "crewbee-json", runtime: input.runtime });
|
|
12578
|
+
return;
|
|
12579
|
+
}
|
|
12580
|
+
if (runtimeModel) {
|
|
12581
|
+
appendUniqueCandidate(input.candidates, { model: runtimeModel, source: "team-manifest", runtime: input.runtime });
|
|
12582
|
+
return;
|
|
12583
|
+
}
|
|
12584
|
+
if (defaultRuntimeModel) {
|
|
12585
|
+
appendUniqueCandidate(input.candidates, { model: defaultRuntimeModel, source: "team-manifest-default", runtime: input.defaultRuntime });
|
|
12586
|
+
}
|
|
12587
|
+
}
|
|
12588
|
+
function resolveAgentModel(input) {
|
|
12589
|
+
const { agent } = input;
|
|
12590
|
+
const teamOverride = agent.sourceTeam.modelConfigOverride;
|
|
12591
|
+
const agentOverride = teamOverride?.agents?.[agent.canonicalAgentId];
|
|
12592
|
+
const runtime = agent.sourceTeam.manifest.agentRuntime?.[agent.canonicalAgentId];
|
|
12593
|
+
const defaultRuntime = agent.sourceTeam.manifest.agentRuntime?.$default;
|
|
12594
|
+
const fallbackStrategy = teamOverride?.fallback ?? (agent.teamId === BUILTIN_CODING_TEAM_ID ? BUILTIN_CODING_TEAM_MODEL_FALLBACK : TEAM_MANIFEST_FALLBACK_STRATEGY);
|
|
12595
|
+
const fallbackToHostDefault = teamOverride?.fallbackToHostDefault ?? runtime?.fallbackToHostDefault ?? defaultRuntime?.fallbackToHostDefault ?? true;
|
|
12596
|
+
const runtimeModel = resolveRuntimeModelId(runtime);
|
|
12597
|
+
const configuredModel = agentOverride?.model ?? runtimeModel ?? resolveRuntimeModelId(defaultRuntime);
|
|
12598
|
+
const candidates = [];
|
|
12599
|
+
appendConfiguredModelCandidate({
|
|
12600
|
+
candidates,
|
|
12601
|
+
agentOverrideModel: agentOverride?.model,
|
|
12602
|
+
runtime,
|
|
12603
|
+
defaultRuntime
|
|
12604
|
+
});
|
|
12605
|
+
if (agentOverride?.model === HOST_DEFAULT_MODEL_ID || !agentOverride?.model && runtimeModel === HOST_DEFAULT_MODEL_ID) {
|
|
12606
|
+
return {
|
|
12607
|
+
trace: createHostDefaultTrace({
|
|
12608
|
+
agent,
|
|
12609
|
+
configuredModel,
|
|
12610
|
+
fallbackStrategy,
|
|
12611
|
+
fallbackToHostDefault,
|
|
12612
|
+
candidates,
|
|
12613
|
+
skipped: [],
|
|
12614
|
+
reason: "host-default selected explicitly"
|
|
12615
|
+
})
|
|
12616
|
+
};
|
|
12617
|
+
}
|
|
12618
|
+
const sourceAgentId = agent.sourceAgent.metadata.sourceId ?? agent.canonicalAgentId;
|
|
12619
|
+
if (fallbackStrategy === BUILTIN_CODING_TEAM_MODEL_FALLBACK && agent.teamId === BUILTIN_CODING_TEAM_ID) {
|
|
12620
|
+
for (const model of BUILTIN_ROLE_FALLBACKS[sourceAgentId] ?? BUILTIN_ROLE_FALLBACKS[agent.canonicalAgentId] ?? []) {
|
|
12621
|
+
appendUniqueCandidate(candidates, { model, source: "builtin-role-chain", runtime });
|
|
12622
|
+
}
|
|
12623
|
+
} else {
|
|
12624
|
+
for (const model of runtime?.fallbackModels ?? defaultRuntime?.fallbackModels ?? []) {
|
|
12625
|
+
appendUniqueCandidate(candidates, { model, source: "team-manifest", runtime });
|
|
12626
|
+
}
|
|
12627
|
+
}
|
|
12628
|
+
const availableModels = input.availableModels ? new Set(input.availableModels) : void 0;
|
|
12629
|
+
const skipped = [];
|
|
12630
|
+
for (const candidate of candidates) {
|
|
12631
|
+
if (candidate.model === HOST_DEFAULT_MODEL_ID) {
|
|
12632
|
+
return {
|
|
12633
|
+
trace: createHostDefaultTrace({
|
|
12634
|
+
agent,
|
|
12635
|
+
configuredModel,
|
|
12636
|
+
fallbackStrategy,
|
|
12637
|
+
fallbackToHostDefault,
|
|
12638
|
+
candidates,
|
|
12639
|
+
skipped,
|
|
12640
|
+
reason: "host-default selected from candidate chain"
|
|
12641
|
+
})
|
|
12642
|
+
};
|
|
12643
|
+
}
|
|
12644
|
+
const parsed = parseProviderModel(candidate.model);
|
|
12645
|
+
if (!parsed) {
|
|
12646
|
+
skipped.push({ model: candidate.model, reason: "model must use provider/model format" });
|
|
12647
|
+
continue;
|
|
12648
|
+
}
|
|
12649
|
+
if (availableModels && !availableModels.has(candidate.model)) {
|
|
12650
|
+
skipped.push({ model: candidate.model, reason: "model not available in current OpenCode environment" });
|
|
12651
|
+
continue;
|
|
12652
|
+
}
|
|
12653
|
+
return {
|
|
12654
|
+
model: {
|
|
12655
|
+
providerID: parsed.providerID,
|
|
12656
|
+
modelID: parsed.modelID,
|
|
12657
|
+
temperature: candidate.runtime?.temperature,
|
|
12658
|
+
topP: candidate.runtime?.topP,
|
|
12659
|
+
variant: candidate.runtime?.variant,
|
|
12660
|
+
options: candidate.runtime?.options,
|
|
12661
|
+
source: candidate.source
|
|
12662
|
+
},
|
|
12663
|
+
trace: {
|
|
12664
|
+
teamId: agent.teamId,
|
|
12665
|
+
agentId: agent.canonicalAgentId,
|
|
12666
|
+
configuredModel,
|
|
12667
|
+
resolvedModel: candidate.model,
|
|
12668
|
+
source: candidate.source,
|
|
12669
|
+
fallback: fallbackStrategy,
|
|
12670
|
+
fallbackToHostDefault,
|
|
12671
|
+
candidates: getCandidateModelIds(candidates),
|
|
12672
|
+
skipped
|
|
12673
|
+
}
|
|
12674
|
+
};
|
|
12675
|
+
}
|
|
12676
|
+
return {
|
|
12677
|
+
trace: createHostDefaultTrace({
|
|
12678
|
+
agent,
|
|
12679
|
+
configuredModel,
|
|
12680
|
+
fallbackStrategy,
|
|
12681
|
+
fallbackToHostDefault,
|
|
12682
|
+
candidates,
|
|
12683
|
+
skipped,
|
|
12684
|
+
reason: fallbackToHostDefault ? "no usable model candidate; fallback_to_host_default enabled" : "no usable model candidate"
|
|
12685
|
+
})
|
|
12686
|
+
};
|
|
12687
|
+
}
|
|
12688
|
+
|
|
12324
12689
|
// src/adapters/opencode/projection.ts
|
|
12325
12690
|
function createOpenCodeConfigKey(agent) {
|
|
12326
12691
|
return agent.canonicalAgentId;
|
|
12327
12692
|
}
|
|
12328
12693
|
function createOpenCodeAgentConfig(agent, options = {}) {
|
|
12329
12694
|
const runtimeConfig = agent.sourceAgent.runtimeConfig;
|
|
12330
|
-
const
|
|
12695
|
+
const modelResolution = resolveAgentModel({
|
|
12696
|
+
agent,
|
|
12697
|
+
availableModels: options.availableModels
|
|
12698
|
+
});
|
|
12331
12699
|
const availableToolContext = createAvailableToolContext(options.availableTools);
|
|
12332
12700
|
const requestedTools = mapOpenCodeToolNames(runtimeConfig.requestedTools);
|
|
12333
12701
|
const availableTools = availableToolContext.hasExplicitTools ? requestedTools.filter((toolId) => isAvailableTool(toolId, availableToolContext)) : [...requestedTools];
|
|
@@ -12350,15 +12718,8 @@ function createOpenCodeAgentConfig(agent, options = {}) {
|
|
|
12350
12718
|
memory: runtimeConfig.memory,
|
|
12351
12719
|
hooks: runtimeConfig.hooks
|
|
12352
12720
|
},
|
|
12353
|
-
resolvedModel:
|
|
12354
|
-
|
|
12355
|
-
modelID: runtimeOverride.model,
|
|
12356
|
-
temperature: runtimeOverride.temperature,
|
|
12357
|
-
topP: runtimeOverride.topP,
|
|
12358
|
-
variant: runtimeOverride.variant,
|
|
12359
|
-
options: runtimeOverride.options,
|
|
12360
|
-
source: "team-manifest"
|
|
12361
|
-
} : void 0,
|
|
12721
|
+
resolvedModel: modelResolution.model,
|
|
12722
|
+
modelResolution: modelResolution.trace,
|
|
12362
12723
|
resolvedTooling: {
|
|
12363
12724
|
requestedTools,
|
|
12364
12725
|
availableTools,
|
|
@@ -12454,211 +12815,6 @@ function createProjectedAgentTaskAliasHelpLines(agents) {
|
|
|
12454
12815
|
});
|
|
12455
12816
|
}
|
|
12456
12817
|
|
|
12457
|
-
// src/adapters/opencode/chat-message-hook.ts
|
|
12458
|
-
function getDefaultAgent(boot) {
|
|
12459
|
-
return boot.mergedConfig?.default_agent ?? boot.configPatch.defaultAgent;
|
|
12460
|
-
}
|
|
12461
|
-
function resolveModel(agent, model) {
|
|
12462
|
-
if (model) {
|
|
12463
|
-
return model;
|
|
12464
|
-
}
|
|
12465
|
-
if (!agent.resolvedModel) {
|
|
12466
|
-
return void 0;
|
|
12467
|
-
}
|
|
12468
|
-
return {
|
|
12469
|
-
providerID: agent.resolvedModel.providerID,
|
|
12470
|
-
modelID: agent.resolvedModel.modelID
|
|
12471
|
-
};
|
|
12472
|
-
}
|
|
12473
|
-
function createChatMessageHook(input) {
|
|
12474
|
-
return async (message, _output) => {
|
|
12475
|
-
const boot = input.getBoot();
|
|
12476
|
-
const selected = message.agent ?? getDefaultAgent(boot);
|
|
12477
|
-
if (!selected) {
|
|
12478
|
-
return;
|
|
12479
|
-
}
|
|
12480
|
-
const agent = resolveProjectedAgentSelection(boot.projectedAgents, {
|
|
12481
|
-
configKey: selected
|
|
12482
|
-
});
|
|
12483
|
-
if (!agent) {
|
|
12484
|
-
return;
|
|
12485
|
-
}
|
|
12486
|
-
const binding2 = createSessionRuntimeBinding({
|
|
12487
|
-
projection: boot.projection,
|
|
12488
|
-
sessionID: message.sessionID,
|
|
12489
|
-
teamId: agent.teamId,
|
|
12490
|
-
canonicalAgentId: agent.canonicalAgentId,
|
|
12491
|
-
mode: DEFAULT_OPENCODE_EXECUTION_MODE,
|
|
12492
|
-
source: message.agent ? "host-agent-selection" : "plugin-default"
|
|
12493
|
-
});
|
|
12494
|
-
input.bindings.set(message.sessionID, binding2);
|
|
12495
|
-
input.store.setCheckpoint(message.sessionID, createCheckpoint(agent, resolveModel(agent, message.model)));
|
|
12496
|
-
};
|
|
12497
|
-
}
|
|
12498
|
-
|
|
12499
|
-
// src/adapters/opencode/delegation/sdk-response.ts
|
|
12500
|
-
function unwrapSdkResponse(value) {
|
|
12501
|
-
if (typeof value === "object" && value !== null && "data" in value) {
|
|
12502
|
-
return value.data;
|
|
12503
|
-
}
|
|
12504
|
-
return value;
|
|
12505
|
-
}
|
|
12506
|
-
|
|
12507
|
-
// src/adapters/opencode/delegation/continuity.ts
|
|
12508
|
-
function formatDelegatedSessions(store, sessionID) {
|
|
12509
|
-
const sessions = store.getSessionsByParent(sessionID);
|
|
12510
|
-
if (sessions.length === 0) {
|
|
12511
|
-
return "- None";
|
|
12512
|
-
}
|
|
12513
|
-
return sessions.map((session) => {
|
|
12514
|
-
const task = store.getTaskBySession(session.sessionID);
|
|
12515
|
-
return [
|
|
12516
|
-
`- ${session.canonicalAgentId}`,
|
|
12517
|
-
task?.status ?? "completed",
|
|
12518
|
-
task?.description ?? "foreground delegation",
|
|
12519
|
-
`session_id=${session.sessionID}`,
|
|
12520
|
-
"resume, don't restart"
|
|
12521
|
-
].join(" | ");
|
|
12522
|
-
}).join("\n");
|
|
12523
|
-
}
|
|
12524
|
-
function formatTodoSnapshot(store, sessionID) {
|
|
12525
|
-
const todos = store.getTodos(sessionID);
|
|
12526
|
-
if (todos.length === 0) {
|
|
12527
|
-
return "- None";
|
|
12528
|
-
}
|
|
12529
|
-
return todos.map((todo) => `- [${todo.status}][${todo.priority ?? "medium"}] ${todo.content}`).join("\n");
|
|
12530
|
-
}
|
|
12531
|
-
function formatCheckpointSummary(store, sessionID) {
|
|
12532
|
-
const checkpoint = store.getCheckpoint(sessionID);
|
|
12533
|
-
if (!checkpoint) {
|
|
12534
|
-
return "- None";
|
|
12535
|
-
}
|
|
12536
|
-
return [
|
|
12537
|
-
`- agent=${checkpoint.agent}`,
|
|
12538
|
-
checkpoint.model ? `- model=${checkpoint.model.providerID}/${checkpoint.model.modelID}` : void 0,
|
|
12539
|
-
checkpoint.tools.length > 0 ? `- tools=${checkpoint.tools.join(", ")}` : "- tools=None"
|
|
12540
|
-
].filter(Boolean).join("\n");
|
|
12541
|
-
}
|
|
12542
|
-
async function captureTodoSnapshot(ctx, store, sessionID) {
|
|
12543
|
-
const result = unwrapSdkResponse(await ctx.client.session.todo({ path: { id: sessionID } }).catch(() => []));
|
|
12544
|
-
store.setTodos(sessionID, Array.isArray(result) ? result : []);
|
|
12545
|
-
}
|
|
12546
|
-
function buildCompactionContext(store, sessionID) {
|
|
12547
|
-
return [
|
|
12548
|
-
"[CrewBee Continuity Context]",
|
|
12549
|
-
"",
|
|
12550
|
-
"When summarizing this session, preserve the sections below in the compacted summary.",
|
|
12551
|
-
"",
|
|
12552
|
-
"1. User Requests / Final Goal",
|
|
12553
|
-
"2. Work Completed",
|
|
12554
|
-
"3. Remaining Tasks",
|
|
12555
|
-
"4. Active Working Context",
|
|
12556
|
-
"5. Explicit Constraints",
|
|
12557
|
-
"6. Agent Verification State",
|
|
12558
|
-
"7. Checkpointed Agent Configuration",
|
|
12559
|
-
" - include current agent / source agent / model / enabled tools when known",
|
|
12560
|
-
"8. Todo Snapshot",
|
|
12561
|
-
" - preserve outstanding todos and their status/priority",
|
|
12562
|
-
"9. Delegated Agent Sessions",
|
|
12563
|
-
" - include agent, status, description, session_id",
|
|
12564
|
-
" - instruction: resume, don't restart",
|
|
12565
|
-
"",
|
|
12566
|
-
"[Checkpointed agent configuration]",
|
|
12567
|
-
formatCheckpointSummary(store, sessionID),
|
|
12568
|
-
"",
|
|
12569
|
-
"[Todo snapshot]",
|
|
12570
|
-
formatTodoSnapshot(store, sessionID),
|
|
12571
|
-
"",
|
|
12572
|
-
"[Runtime-carried delegated sessions]",
|
|
12573
|
-
formatDelegatedSessions(store, sessionID)
|
|
12574
|
-
].join("\n");
|
|
12575
|
-
}
|
|
12576
|
-
|
|
12577
|
-
// src/adapters/opencode/compaction-hook.ts
|
|
12578
|
-
function createCompactionHook(ctx, store) {
|
|
12579
|
-
return async (input, output) => {
|
|
12580
|
-
await captureTodoSnapshot(ctx, store, input.sessionID);
|
|
12581
|
-
output.context.push(buildCompactionContext(store, input.sessionID));
|
|
12582
|
-
};
|
|
12583
|
-
}
|
|
12584
|
-
|
|
12585
|
-
// src/adapters/opencode/capabilities.ts
|
|
12586
|
-
function createOpenCodeCapabilityContract() {
|
|
12587
|
-
return {
|
|
12588
|
-
supportsAgentRegistration: true,
|
|
12589
|
-
supportsAgentSwitching: true,
|
|
12590
|
-
supportsNativeAgentSelection: true,
|
|
12591
|
-
supportsNativeModelSelection: true,
|
|
12592
|
-
supportsCliOverrides: true,
|
|
12593
|
-
supportsSingleExecutorMode: true,
|
|
12594
|
-
supportsTeamCollaboration: false,
|
|
12595
|
-
supportsRuntimeEvents: true,
|
|
12596
|
-
supportsToolDomainInjection: false,
|
|
12597
|
-
supportsSessionLogExport: false
|
|
12598
|
-
};
|
|
12599
|
-
}
|
|
12600
|
-
|
|
12601
|
-
// src/adapters/opencode/config-merge.ts
|
|
12602
|
-
function applyOpenCodeAgentConfigPatch(config2, patch) {
|
|
12603
|
-
const patchKeys = new Set(Object.keys(patch.agent));
|
|
12604
|
-
const nextAgents = Object.fromEntries(
|
|
12605
|
-
Object.entries(config2.agent ?? {}).filter(([key, definition]) => {
|
|
12606
|
-
if (isManagedCrewBeeAgentDefinition(definition) && !patchKeys.has(key)) {
|
|
12607
|
-
return false;
|
|
12608
|
-
}
|
|
12609
|
-
return true;
|
|
12610
|
-
})
|
|
12611
|
-
);
|
|
12612
|
-
const insertedAgentKeys = [];
|
|
12613
|
-
const updatedAgentKeys = [];
|
|
12614
|
-
const skippedAgentKeys = [];
|
|
12615
|
-
for (const [key, definition] of Object.entries(patch.agent)) {
|
|
12616
|
-
if (!(key in nextAgents)) {
|
|
12617
|
-
nextAgents[key] = definition;
|
|
12618
|
-
insertedAgentKeys.push(key);
|
|
12619
|
-
continue;
|
|
12620
|
-
}
|
|
12621
|
-
const existingDefinition = nextAgents[key];
|
|
12622
|
-
if (isManagedCrewBeeAgentDefinition(existingDefinition)) {
|
|
12623
|
-
nextAgents[key] = definition;
|
|
12624
|
-
updatedAgentKeys.push(key);
|
|
12625
|
-
continue;
|
|
12626
|
-
}
|
|
12627
|
-
skippedAgentKeys.push(key);
|
|
12628
|
-
}
|
|
12629
|
-
const nextConfig = {
|
|
12630
|
-
...config2,
|
|
12631
|
-
agent: nextAgents
|
|
12632
|
-
};
|
|
12633
|
-
if (patch.defaultAgent) {
|
|
12634
|
-
nextConfig.default_agent = patch.defaultAgent;
|
|
12635
|
-
}
|
|
12636
|
-
return {
|
|
12637
|
-
config: nextConfig,
|
|
12638
|
-
insertedAgentKeys,
|
|
12639
|
-
updatedAgentKeys,
|
|
12640
|
-
skippedAgentKeys
|
|
12641
|
-
};
|
|
12642
|
-
}
|
|
12643
|
-
|
|
12644
|
-
// src/adapters/opencode/coexistence.ts
|
|
12645
|
-
function createOpenCodeCoexistencePolicy() {
|
|
12646
|
-
return {
|
|
12647
|
-
pluginId: "crewbee",
|
|
12648
|
-
dependsOnOhMyOpenCode: false,
|
|
12649
|
-
featureDevelopmentMode: "mutually-exclusive",
|
|
12650
|
-
safeWhenCoInstalled: true,
|
|
12651
|
-
reservedConfigKeyPrefix: "",
|
|
12652
|
-
neverMutateForeignAgents: true
|
|
12653
|
-
};
|
|
12654
|
-
}
|
|
12655
|
-
function detectOpenCodeProjectionCollisions(input) {
|
|
12656
|
-
const existingConfigKeys = new Set(input.existingConfigKeys ?? []);
|
|
12657
|
-
return {
|
|
12658
|
-
configKeyCollisions: input.projectedAgents.filter((agent) => existingConfigKeys.has(agent.configKey)).map((agent) => agent.configKey)
|
|
12659
|
-
};
|
|
12660
|
-
}
|
|
12661
|
-
|
|
12662
12818
|
// src/adapters/opencode/tool-domain.ts
|
|
12663
12819
|
function createOpenCodeToolDomainPlan() {
|
|
12664
12820
|
const implementedTools = listImplementedCrewBeePluginTools().filter((tool) => tool.hostTargets.includes("opencode"));
|
|
@@ -12764,7 +12920,8 @@ function createOpenCodeBootstrap(input) {
|
|
|
12764
12920
|
const projection = createTeamLibraryProjection(input.teamLibrary);
|
|
12765
12921
|
const toolDomainPlan = createOpenCodeToolDomainPlan();
|
|
12766
12922
|
const projectedAgents = createOpenCodeAgentConfigs(projection, {
|
|
12767
|
-
availableTools: input.availableTools
|
|
12923
|
+
availableTools: input.availableTools,
|
|
12924
|
+
availableModels: input.availableModels
|
|
12768
12925
|
});
|
|
12769
12926
|
const foreignCollisions = getForeignCollisionInputs({
|
|
12770
12927
|
existingConfig: input.existingConfig,
|
|
@@ -12815,6 +12972,185 @@ function createOpenCodeBootstrap(input) {
|
|
|
12815
12972
|
};
|
|
12816
12973
|
}
|
|
12817
12974
|
|
|
12975
|
+
// src/adapters/opencode/defaults.ts
|
|
12976
|
+
var DEFAULT_OPENCODE_EXECUTION_MODE = "single-executor";
|
|
12977
|
+
|
|
12978
|
+
// src/adapters/opencode/delegation/prompt.ts
|
|
12979
|
+
function truncatePrompt(value) {
|
|
12980
|
+
const trimmed = value.trim().replace(/\s+/g, " ");
|
|
12981
|
+
return trimmed.length <= 80 ? trimmed : `${trimmed.slice(0, 77)}...`;
|
|
12982
|
+
}
|
|
12983
|
+
function createDelegatedTitle(agent, prompt) {
|
|
12984
|
+
return `${agent}: ${truncatePrompt(prompt)}`;
|
|
12985
|
+
}
|
|
12986
|
+
function resolveDelegateModel(target, fallback) {
|
|
12987
|
+
if (target.resolvedModel) {
|
|
12988
|
+
return {
|
|
12989
|
+
providerID: target.resolvedModel.providerID,
|
|
12990
|
+
modelID: target.resolvedModel.modelID
|
|
12991
|
+
};
|
|
12992
|
+
}
|
|
12993
|
+
return fallback;
|
|
12994
|
+
}
|
|
12995
|
+
function createDelegationEnvelope(input) {
|
|
12996
|
+
return [
|
|
12997
|
+
`You are continuing work as CrewBee team member: ${input.agent}.`,
|
|
12998
|
+
"",
|
|
12999
|
+
`Parent session: ${input.parentSessionID}`,
|
|
13000
|
+
`Delegated session: ${input.sessionID}`,
|
|
13001
|
+
"",
|
|
13002
|
+
"Your delegated objective:",
|
|
13003
|
+
input.prompt.trim(),
|
|
13004
|
+
"",
|
|
13005
|
+
"Execution rules:",
|
|
13006
|
+
"- Work only on this delegated objective",
|
|
13007
|
+
"- Do not broaden scope",
|
|
13008
|
+
"- If you need a skill, decide and load it yourself based on the task",
|
|
13009
|
+
"- Prefer a compact result focused on outcome, files changed, blockers, and next step",
|
|
13010
|
+
"",
|
|
13011
|
+
"Return:",
|
|
13012
|
+
"1. Result / conclusion",
|
|
13013
|
+
"2. Files changed or inspected",
|
|
13014
|
+
"3. Remaining risk or blocker",
|
|
13015
|
+
"4. Recommended next step"
|
|
13016
|
+
].join("\n");
|
|
13017
|
+
}
|
|
13018
|
+
function createCheckpoint(agent, model) {
|
|
13019
|
+
return {
|
|
13020
|
+
agent: agent.configKey,
|
|
13021
|
+
model,
|
|
13022
|
+
tools: [...agent.runtimeConfig.requestedTools]
|
|
13023
|
+
};
|
|
13024
|
+
}
|
|
13025
|
+
|
|
13026
|
+
// src/adapters/opencode/chat-message-hook.ts
|
|
13027
|
+
function getDefaultAgent(boot) {
|
|
13028
|
+
return boot.mergedConfig?.default_agent ?? boot.configPatch.defaultAgent;
|
|
13029
|
+
}
|
|
13030
|
+
function resolveModel(agent, model) {
|
|
13031
|
+
if (model) {
|
|
13032
|
+
return model;
|
|
13033
|
+
}
|
|
13034
|
+
if (!agent.resolvedModel) {
|
|
13035
|
+
return void 0;
|
|
13036
|
+
}
|
|
13037
|
+
return {
|
|
13038
|
+
providerID: agent.resolvedModel.providerID,
|
|
13039
|
+
modelID: agent.resolvedModel.modelID
|
|
13040
|
+
};
|
|
13041
|
+
}
|
|
13042
|
+
function createChatMessageHook(input) {
|
|
13043
|
+
return async (message, _output) => {
|
|
13044
|
+
const boot = input.getBoot();
|
|
13045
|
+
const selected = message.agent ?? getDefaultAgent(boot);
|
|
13046
|
+
if (!selected) {
|
|
13047
|
+
return;
|
|
13048
|
+
}
|
|
13049
|
+
const agent = resolveProjectedAgentSelection(boot.projectedAgents, {
|
|
13050
|
+
configKey: selected
|
|
13051
|
+
});
|
|
13052
|
+
if (!agent) {
|
|
13053
|
+
return;
|
|
13054
|
+
}
|
|
13055
|
+
const binding2 = createSessionRuntimeBinding({
|
|
13056
|
+
projection: boot.projection,
|
|
13057
|
+
sessionID: message.sessionID,
|
|
13058
|
+
teamId: agent.teamId,
|
|
13059
|
+
canonicalAgentId: agent.canonicalAgentId,
|
|
13060
|
+
mode: DEFAULT_OPENCODE_EXECUTION_MODE,
|
|
13061
|
+
source: message.agent ? "host-agent-selection" : "plugin-default"
|
|
13062
|
+
});
|
|
13063
|
+
input.bindings.set(message.sessionID, binding2);
|
|
13064
|
+
input.store.setCheckpoint(message.sessionID, createCheckpoint(agent, resolveModel(agent, message.model)));
|
|
13065
|
+
};
|
|
13066
|
+
}
|
|
13067
|
+
|
|
13068
|
+
// src/adapters/opencode/delegation/sdk-response.ts
|
|
13069
|
+
function unwrapSdkResponse(value) {
|
|
13070
|
+
if (typeof value === "object" && value !== null && "data" in value) {
|
|
13071
|
+
return value.data;
|
|
13072
|
+
}
|
|
13073
|
+
return value;
|
|
13074
|
+
}
|
|
13075
|
+
|
|
13076
|
+
// src/adapters/opencode/delegation/continuity.ts
|
|
13077
|
+
function formatDelegatedSessions(store, sessionID) {
|
|
13078
|
+
const sessions = store.getSessionsByParent(sessionID);
|
|
13079
|
+
if (sessions.length === 0) {
|
|
13080
|
+
return "- None";
|
|
13081
|
+
}
|
|
13082
|
+
return sessions.map((session) => {
|
|
13083
|
+
const task = store.getTaskBySession(session.sessionID);
|
|
13084
|
+
return [
|
|
13085
|
+
`- ${session.canonicalAgentId}`,
|
|
13086
|
+
task?.status ?? "completed",
|
|
13087
|
+
task?.description ?? "foreground delegation",
|
|
13088
|
+
`session_id=${session.sessionID}`,
|
|
13089
|
+
"resume, don't restart"
|
|
13090
|
+
].join(" | ");
|
|
13091
|
+
}).join("\n");
|
|
13092
|
+
}
|
|
13093
|
+
function formatTodoSnapshot(store, sessionID) {
|
|
13094
|
+
const todos = store.getTodos(sessionID);
|
|
13095
|
+
if (todos.length === 0) {
|
|
13096
|
+
return "- None";
|
|
13097
|
+
}
|
|
13098
|
+
return todos.map((todo) => `- [${todo.status}][${todo.priority ?? "medium"}] ${todo.content}`).join("\n");
|
|
13099
|
+
}
|
|
13100
|
+
function formatCheckpointSummary(store, sessionID) {
|
|
13101
|
+
const checkpoint = store.getCheckpoint(sessionID);
|
|
13102
|
+
if (!checkpoint) {
|
|
13103
|
+
return "- None";
|
|
13104
|
+
}
|
|
13105
|
+
return [
|
|
13106
|
+
`- agent=${checkpoint.agent}`,
|
|
13107
|
+
checkpoint.model ? `- model=${checkpoint.model.providerID}/${checkpoint.model.modelID}` : void 0,
|
|
13108
|
+
checkpoint.tools.length > 0 ? `- tools=${checkpoint.tools.join(", ")}` : "- tools=None"
|
|
13109
|
+
].filter(Boolean).join("\n");
|
|
13110
|
+
}
|
|
13111
|
+
async function captureTodoSnapshot(ctx, store, sessionID) {
|
|
13112
|
+
const result = unwrapSdkResponse(await ctx.client.session.todo({ path: { id: sessionID } }).catch(() => []));
|
|
13113
|
+
store.setTodos(sessionID, Array.isArray(result) ? result : []);
|
|
13114
|
+
}
|
|
13115
|
+
function buildCompactionContext(store, sessionID) {
|
|
13116
|
+
return [
|
|
13117
|
+
"[CrewBee Continuity Context]",
|
|
13118
|
+
"",
|
|
13119
|
+
"When summarizing this session, preserve the sections below in the compacted summary.",
|
|
13120
|
+
"",
|
|
13121
|
+
"1. User Requests / Final Goal",
|
|
13122
|
+
"2. Work Completed",
|
|
13123
|
+
"3. Remaining Tasks",
|
|
13124
|
+
"4. Active Working Context",
|
|
13125
|
+
"5. Explicit Constraints",
|
|
13126
|
+
"6. Agent Verification State",
|
|
13127
|
+
"7. Checkpointed Agent Configuration",
|
|
13128
|
+
" - include current agent / source agent / model / enabled tools when known",
|
|
13129
|
+
"8. Todo Snapshot",
|
|
13130
|
+
" - preserve outstanding todos and their status/priority",
|
|
13131
|
+
"9. Delegated Agent Sessions",
|
|
13132
|
+
" - include agent, status, description, session_id",
|
|
13133
|
+
" - instruction: resume, don't restart",
|
|
13134
|
+
"",
|
|
13135
|
+
"[Checkpointed agent configuration]",
|
|
13136
|
+
formatCheckpointSummary(store, sessionID),
|
|
13137
|
+
"",
|
|
13138
|
+
"[Todo snapshot]",
|
|
13139
|
+
formatTodoSnapshot(store, sessionID),
|
|
13140
|
+
"",
|
|
13141
|
+
"[Runtime-carried delegated sessions]",
|
|
13142
|
+
formatDelegatedSessions(store, sessionID)
|
|
13143
|
+
].join("\n");
|
|
13144
|
+
}
|
|
13145
|
+
|
|
13146
|
+
// src/adapters/opencode/compaction-hook.ts
|
|
13147
|
+
function createCompactionHook(ctx, store) {
|
|
13148
|
+
return async (input, output) => {
|
|
13149
|
+
await captureTodoSnapshot(ctx, store, input.sessionID);
|
|
13150
|
+
output.context.push(buildCompactionContext(store, input.sessionID));
|
|
13151
|
+
};
|
|
13152
|
+
}
|
|
13153
|
+
|
|
12818
13154
|
// src/adapters/opencode/logging.ts
|
|
12819
13155
|
async function logCrewBee(ctx, message, extra, level = "info") {
|
|
12820
13156
|
if (!shouldEmitCrewBeeLog(level)) {
|