crewbee 0.1.12 → 0.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +175 -269
- package/README.zh-CN.md +157 -271
- package/dist/opencode-plugin.mjs +351 -108
- package/dist/src/adapters/opencode/config-merge.d.ts.map +1 -1
- package/dist/src/adapters/opencode/config-merge.js +2 -1
- package/dist/src/adapters/opencode/config-merge.js.map +1 -1
- package/dist/src/adapters/opencode/delegation/resolve-agent.d.ts +1 -0
- package/dist/src/adapters/opencode/delegation/resolve-agent.d.ts.map +1 -1
- package/dist/src/adapters/opencode/delegation/resolve-agent.js +8 -2
- package/dist/src/adapters/opencode/delegation/resolve-agent.js.map +1 -1
- package/dist/src/adapters/opencode/delegation/tools.d.ts.map +1 -1
- package/dist/src/adapters/opencode/delegation/tools.js +14 -3
- package/dist/src/adapters/opencode/delegation/tools.js.map +1 -1
- package/dist/src/adapters/opencode/model-resolution.d.ts.map +1 -1
- package/dist/src/adapters/opencode/model-resolution.js +50 -10
- package/dist/src/adapters/opencode/model-resolution.js.map +1 -1
- package/dist/src/adapters/opencode/permission-mapper.d.ts.map +1 -1
- package/dist/src/adapters/opencode/permission-mapper.js +4 -1
- package/dist/src/adapters/opencode/permission-mapper.js.map +1 -1
- package/dist/src/adapters/opencode/projection.d.ts +14 -0
- package/dist/src/adapters/opencode/projection.d.ts.map +1 -1
- package/dist/src/adapters/opencode/projection.js +70 -1
- package/dist/src/adapters/opencode/projection.js.map +1 -1
- package/dist/src/adapters/opencode/prompt-builder.d.ts.map +1 -1
- package/dist/src/adapters/opencode/prompt-builder.js +12 -7
- package/dist/src/adapters/opencode/prompt-builder.js.map +1 -1
- package/dist/src/adapters/opencode/tool-hooks.d.ts +1 -1
- package/dist/src/adapters/opencode/tool-hooks.d.ts.map +1 -1
- package/dist/src/adapters/opencode/tool-hooks.js +22 -27
- package/dist/src/adapters/opencode/tool-hooks.js.map +1 -1
- package/dist/src/agent-teams/constants.d.ts +5 -0
- package/dist/src/agent-teams/constants.d.ts.map +1 -1
- package/dist/src/agent-teams/constants.js +6 -1
- package/dist/src/agent-teams/constants.js.map +1 -1
- package/dist/src/agent-teams/filesystem.d.ts +4 -1
- package/dist/src/agent-teams/filesystem.d.ts.map +1 -1
- package/dist/src/agent-teams/filesystem.js +116 -6
- package/dist/src/agent-teams/filesystem.js.map +1 -1
- package/dist/src/agent-teams/parsers.d.ts.map +1 -1
- package/dist/src/agent-teams/parsers.js +14 -2
- package/dist/src/agent-teams/parsers.js.map +1 -1
- package/dist/src/cli/doctor.js +1 -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 +2 -0
- package/dist/src/core/index.d.ts.map +1 -1
- package/dist/src/install/types.d.ts +1 -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 +1 -0
- 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")) {
|
|
@@ -7334,6 +7347,7 @@ var EMBEDDED_TEAM_IDS = [BUILTIN_CODING_TEAM_ID];
|
|
|
7334
7347
|
var BUILTIN_CODING_TEAM_MODEL_PRESET = "sota-2026-05";
|
|
7335
7348
|
var BUILTIN_CODING_TEAM_MODEL_FALLBACK = "builtin-role-chain";
|
|
7336
7349
|
var BUILTIN_CODING_TEAM_FALLBACK_TO_HOST_DEFAULT = true;
|
|
7350
|
+
var CREWBEE_CONFIG_VERSION = 2;
|
|
7337
7351
|
var BUILTIN_CODING_TEAM_AGENT_MODELS = {
|
|
7338
7352
|
"coding-leader": "openai/gpt-5.5",
|
|
7339
7353
|
"coordination-leader": "openai/gpt-5.5",
|
|
@@ -9926,6 +9940,18 @@ function asStringArray(value, label) {
|
|
|
9926
9940
|
}
|
|
9927
9941
|
return value.map((entry, index) => asString(entry, `${label}[${index}]`));
|
|
9928
9942
|
}
|
|
9943
|
+
function mapProviderOptions(record2) {
|
|
9944
|
+
const options = { ...asOptionalRecord(record2.options) ?? {} };
|
|
9945
|
+
const thinkingLevel = asOptionalString(record2.thinking_level ?? record2.thinkingLevel);
|
|
9946
|
+
const reasoningEffort = asOptionalString(record2.reasoning_effort ?? record2.reasoningEffort);
|
|
9947
|
+
if (thinkingLevel) {
|
|
9948
|
+
options.thinkingLevel = thinkingLevel;
|
|
9949
|
+
}
|
|
9950
|
+
if (reasoningEffort) {
|
|
9951
|
+
options.reasoningEffort = reasoningEffort;
|
|
9952
|
+
}
|
|
9953
|
+
return Object.keys(options).length > 0 ? options : void 0;
|
|
9954
|
+
}
|
|
9929
9955
|
function readTextFile(filePath) {
|
|
9930
9956
|
return readFileSync(filePath, "utf8");
|
|
9931
9957
|
}
|
|
@@ -10250,14 +10276,14 @@ function mapAgentRuntime(raw) {
|
|
|
10250
10276
|
return Object.fromEntries(
|
|
10251
10277
|
Object.entries(raw).map(([agentId, value]) => {
|
|
10252
10278
|
const record2 = asRecord(value, `agent_runtime.${agentId}`);
|
|
10253
|
-
const options =
|
|
10279
|
+
const options = mapProviderOptions(record2);
|
|
10254
10280
|
const runtime = {
|
|
10255
10281
|
provider: record2.provider !== void 0 ? asString(record2.provider, `agent_runtime.${agentId}.provider`) : void 0,
|
|
10256
10282
|
model: asString(record2.model, `agent_runtime.${agentId}.model`),
|
|
10257
10283
|
temperature: record2.temperature !== void 0 ? Number(record2.temperature) : void 0,
|
|
10258
10284
|
topP: record2.top_p !== void 0 || record2.topP !== void 0 ? Number(record2.top_p ?? record2.topP) : void 0,
|
|
10259
10285
|
variant: asOptionalString(record2.variant),
|
|
10260
|
-
options
|
|
10286
|
+
options,
|
|
10261
10287
|
fallbackModels: record2.fallback_models || record2.fallbackModels ? asStringArray(record2.fallback_models ?? record2.fallbackModels, `agent_runtime.${agentId}.fallback_models`) : void 0,
|
|
10262
10288
|
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
|
|
10263
10289
|
};
|
|
@@ -10518,6 +10544,21 @@ function getOptionalPriority(value, fallback) {
|
|
|
10518
10544
|
function getOptionalString(value) {
|
|
10519
10545
|
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
10520
10546
|
}
|
|
10547
|
+
function getOptionalRecord(value) {
|
|
10548
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
10549
|
+
}
|
|
10550
|
+
function createProviderOptionOverrides(raw) {
|
|
10551
|
+
const options = { ...getOptionalRecord(raw.options) ?? {} };
|
|
10552
|
+
const thinkingLevel = getOptionalString(raw.thinkingLevel ?? raw.thinking_level);
|
|
10553
|
+
const reasoningEffort = getOptionalString(raw.reasoningEffort ?? raw.reasoning_effort);
|
|
10554
|
+
if (thinkingLevel) {
|
|
10555
|
+
options.thinkingLevel = thinkingLevel;
|
|
10556
|
+
}
|
|
10557
|
+
if (reasoningEffort) {
|
|
10558
|
+
options.reasoningEffort = reasoningEffort;
|
|
10559
|
+
}
|
|
10560
|
+
return Object.keys(options).length > 0 ? options : void 0;
|
|
10561
|
+
}
|
|
10521
10562
|
function normalizeConfiguredTeamModelOverride(raw) {
|
|
10522
10563
|
const modelPreset = getOptionalString(raw.model_preset ?? raw.modelPreset);
|
|
10523
10564
|
const fallback = getOptionalString(raw.fallback);
|
|
@@ -10529,7 +10570,13 @@ function normalizeConfiguredTeamModelOverride(raw) {
|
|
|
10529
10570
|
return [];
|
|
10530
10571
|
}
|
|
10531
10572
|
const model = getOptionalString(value.model);
|
|
10532
|
-
|
|
10573
|
+
const variant = getOptionalString(value.variant);
|
|
10574
|
+
const options = createProviderOptionOverrides(value);
|
|
10575
|
+
return [[agentId, {
|
|
10576
|
+
...model ? { model } : {},
|
|
10577
|
+
...variant ? { variant } : {},
|
|
10578
|
+
...options ? { options } : {}
|
|
10579
|
+
}]];
|
|
10533
10580
|
})
|
|
10534
10581
|
) : void 0;
|
|
10535
10582
|
const normalizedAgents = agents && Object.keys(agents).length > 0 ? agents : void 0;
|
|
@@ -10613,6 +10660,7 @@ function createDefaultCrewBeeConfig() {
|
|
|
10613
10660
|
}
|
|
10614
10661
|
}
|
|
10615
10662
|
return {
|
|
10663
|
+
config_version: CREWBEE_CONFIG_VERSION,
|
|
10616
10664
|
teams: [createDefaultCodingTeamConfigEntry()]
|
|
10617
10665
|
};
|
|
10618
10666
|
}
|
|
@@ -10671,6 +10719,65 @@ function createUpdatedCrewBeeConfigWithDefaultTeam(config2) {
|
|
|
10671
10719
|
}
|
|
10672
10720
|
};
|
|
10673
10721
|
}
|
|
10722
|
+
function migrateCrewBeeConfig(existing) {
|
|
10723
|
+
const currentVersion = typeof existing.config_version === "number" ? existing.config_version : 1;
|
|
10724
|
+
if (currentVersion >= CREWBEE_CONFIG_VERSION) {
|
|
10725
|
+
return { changed: false, config: existing };
|
|
10726
|
+
}
|
|
10727
|
+
const defaults = createDefaultCrewBeeConfig();
|
|
10728
|
+
const migrated = { ...existing };
|
|
10729
|
+
migrated.config_version = CREWBEE_CONFIG_VERSION;
|
|
10730
|
+
for (const key of Object.keys(defaults)) {
|
|
10731
|
+
if (!(key in migrated)) {
|
|
10732
|
+
migrated[key] = defaults[key];
|
|
10733
|
+
}
|
|
10734
|
+
}
|
|
10735
|
+
const existingTeams = Array.isArray(migrated.teams) ? migrated.teams : [];
|
|
10736
|
+
const defaultTeams = defaults.teams ?? [];
|
|
10737
|
+
const mergedTeams = existingTeams.map((entry) => {
|
|
10738
|
+
if (!isRecord3(entry)) return entry;
|
|
10739
|
+
const teamId = getOptionalString(entry.id);
|
|
10740
|
+
if (!teamId) return entry;
|
|
10741
|
+
const defaultEntry = defaultTeams.find(
|
|
10742
|
+
(d) => isRecord3(d) && d.id === teamId
|
|
10743
|
+
);
|
|
10744
|
+
if (!defaultEntry || !isRecord3(defaultEntry)) return entry;
|
|
10745
|
+
const merged = { ...entry };
|
|
10746
|
+
for (const key of Object.keys(defaultEntry)) {
|
|
10747
|
+
if (!(key in merged)) {
|
|
10748
|
+
merged[key] = defaultEntry[key];
|
|
10749
|
+
}
|
|
10750
|
+
}
|
|
10751
|
+
if (isRecord3(defaultEntry.agents)) {
|
|
10752
|
+
const existingAgents = isRecord3(merged.agents) ? { ...merged.agents } : {};
|
|
10753
|
+
for (const [agentId, agentConfig] of Object.entries(defaultEntry.agents)) {
|
|
10754
|
+
if (!(agentId in existingAgents)) {
|
|
10755
|
+
existingAgents[agentId] = agentConfig;
|
|
10756
|
+
}
|
|
10757
|
+
}
|
|
10758
|
+
merged.agents = existingAgents;
|
|
10759
|
+
}
|
|
10760
|
+
return merged;
|
|
10761
|
+
});
|
|
10762
|
+
for (const defaultEntry of defaultTeams) {
|
|
10763
|
+
if (!isRecord3(defaultEntry)) continue;
|
|
10764
|
+
const defaultId = getOptionalString(defaultEntry.id);
|
|
10765
|
+
const defaultPath = getOptionalString(defaultEntry.path);
|
|
10766
|
+
const key = defaultId ?? defaultPath;
|
|
10767
|
+
if (!key) continue;
|
|
10768
|
+
const alreadyExists = mergedTeams.some((entry) => {
|
|
10769
|
+
if (!isRecord3(entry)) return false;
|
|
10770
|
+
if (defaultId) return entry.id === defaultId;
|
|
10771
|
+
if (defaultPath) return entry.path === defaultPath;
|
|
10772
|
+
return false;
|
|
10773
|
+
});
|
|
10774
|
+
if (!alreadyExists) {
|
|
10775
|
+
mergedTeams.push(defaultEntry);
|
|
10776
|
+
}
|
|
10777
|
+
}
|
|
10778
|
+
migrated.teams = mergedTeams;
|
|
10779
|
+
return { changed: true, config: migrated };
|
|
10780
|
+
}
|
|
10674
10781
|
function ensureCrewBeeConfigFile(input) {
|
|
10675
10782
|
const configRoot = input.configRoot ?? resolveOpenCodeConfigRoot();
|
|
10676
10783
|
const configPath = resolveCrewBeeConfigPath(configRoot);
|
|
@@ -10700,14 +10807,21 @@ function ensureCrewBeeConfigFile(input) {
|
|
|
10700
10807
|
};
|
|
10701
10808
|
}
|
|
10702
10809
|
if (input.mode === "startup") {
|
|
10810
|
+
const migration2 = migrateCrewBeeConfig(parsed.config);
|
|
10811
|
+
if (migration2.changed && !input.dryRun) {
|
|
10812
|
+
writeCrewBeeConfig(configPath, migration2.config);
|
|
10813
|
+
}
|
|
10703
10814
|
return {
|
|
10704
|
-
changed:
|
|
10815
|
+
changed: migration2.changed,
|
|
10705
10816
|
configPath,
|
|
10706
|
-
reason: "unchanged"
|
|
10817
|
+
reason: migration2.changed ? "migrated-config-version" : "unchanged"
|
|
10707
10818
|
};
|
|
10708
10819
|
}
|
|
10709
10820
|
const updated = createUpdatedCrewBeeConfigWithDefaultTeam(parsed.config);
|
|
10710
|
-
|
|
10821
|
+
const migration = migrateCrewBeeConfig(updated.next);
|
|
10822
|
+
const finalConfig = migration.config;
|
|
10823
|
+
const changed = updated.changed || migration.changed;
|
|
10824
|
+
if (!changed) {
|
|
10711
10825
|
return {
|
|
10712
10826
|
changed: false,
|
|
10713
10827
|
configPath,
|
|
@@ -10715,12 +10829,12 @@ function ensureCrewBeeConfigFile(input) {
|
|
|
10715
10829
|
};
|
|
10716
10830
|
}
|
|
10717
10831
|
if (!input.dryRun) {
|
|
10718
|
-
writeCrewBeeConfig(configPath,
|
|
10832
|
+
writeCrewBeeConfig(configPath, finalConfig);
|
|
10719
10833
|
}
|
|
10720
10834
|
return {
|
|
10721
10835
|
changed: true,
|
|
10722
10836
|
configPath,
|
|
10723
|
-
reason: "added-default-coding-team"
|
|
10837
|
+
reason: updated.changed ? "added-default-coding-team" : "migrated-config-version"
|
|
10724
10838
|
};
|
|
10725
10839
|
}
|
|
10726
10840
|
function resolveConfiguredTeamPath(teamPath, configRoot) {
|
|
@@ -11848,6 +11962,7 @@ function createManagedCrewBeeAgentOptions(input) {
|
|
|
11848
11962
|
// src/adapters/opencode/config-merge.ts
|
|
11849
11963
|
function applyOpenCodeAgentConfigPatch(config2, patch) {
|
|
11850
11964
|
const patchKeys = new Set(Object.keys(patch.agent));
|
|
11965
|
+
const forceUpdateKeys = new Set(patch.forceUpdateAgentKeys ?? []);
|
|
11851
11966
|
const nextAgents = Object.fromEntries(
|
|
11852
11967
|
Object.entries(config2.agent ?? {}).filter(([key, definition]) => {
|
|
11853
11968
|
if (isManagedCrewBeeAgentDefinition(definition) && !patchKeys.has(key)) {
|
|
@@ -11866,7 +11981,7 @@ function applyOpenCodeAgentConfigPatch(config2, patch) {
|
|
|
11866
11981
|
continue;
|
|
11867
11982
|
}
|
|
11868
11983
|
const existingDefinition = nextAgents[key];
|
|
11869
|
-
if (isManagedCrewBeeAgentDefinition(existingDefinition)) {
|
|
11984
|
+
if (forceUpdateKeys.has(key) || isManagedCrewBeeAgentDefinition(existingDefinition)) {
|
|
11870
11985
|
nextAgents[key] = definition;
|
|
11871
11986
|
updatedAgentKeys.push(key);
|
|
11872
11987
|
continue;
|
|
@@ -11934,7 +12049,9 @@ function mapPermissionRulesWithAvailability(permissionRules, availableTools) {
|
|
|
11934
12049
|
}).filter((rule) => Boolean(rule)).filter((rule) => isAvailableTool(rule.permission, availableTools));
|
|
11935
12050
|
}
|
|
11936
12051
|
function createOpenCodePermissionRules(agent, availableTools) {
|
|
11937
|
-
|
|
12052
|
+
const rules = mapPermissionRulesWithAvailability(agent.sourceAgent.runtimeConfig.permission, availableTools).filter((rule) => rule.permission !== "task");
|
|
12053
|
+
rules.push({ permission: "task", action: "deny", pattern: "*" });
|
|
12054
|
+
return rules;
|
|
11938
12055
|
}
|
|
11939
12056
|
function createOpenCodePermissionConfig(permissionRules) {
|
|
11940
12057
|
const permission = {};
|
|
@@ -11956,7 +12073,7 @@ function createOpenCodePermissionConfig(permissionRules) {
|
|
|
11956
12073
|
return permission;
|
|
11957
12074
|
}
|
|
11958
12075
|
|
|
11959
|
-
// src/normalize/build-agent-prompt-
|
|
12076
|
+
// src/normalize/build-agent-prompt-document.ts
|
|
11960
12077
|
function isRecord5(value) {
|
|
11961
12078
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
11962
12079
|
}
|
|
@@ -11994,7 +12111,7 @@ function pushBlock(blocks, key, value, order) {
|
|
|
11994
12111
|
});
|
|
11995
12112
|
return order + 1;
|
|
11996
12113
|
}
|
|
11997
|
-
function
|
|
12114
|
+
function buildAgentPromptDocumentWithOverrides(agent, overrides) {
|
|
11998
12115
|
const blocks = [];
|
|
11999
12116
|
let order = 0;
|
|
12000
12117
|
order = pushBlock(blocks, "persona_core", agent.personaCore, order);
|
|
@@ -12029,7 +12146,7 @@ function buildAgentPromptSourceWithOverrides(agent, overrides) {
|
|
|
12029
12146
|
};
|
|
12030
12147
|
}
|
|
12031
12148
|
|
|
12032
|
-
// src/normalize/build-team-prompt-
|
|
12149
|
+
// src/normalize/build-team-prompt-document.ts
|
|
12033
12150
|
function asRecord2(value) {
|
|
12034
12151
|
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
12035
12152
|
}
|
|
@@ -12039,7 +12156,7 @@ function asMetadataRecord2(value) {
|
|
|
12039
12156
|
}
|
|
12040
12157
|
return value;
|
|
12041
12158
|
}
|
|
12042
|
-
function
|
|
12159
|
+
function buildTeamPromptDocument(manifest, policy, bodySections = []) {
|
|
12043
12160
|
const qualityFloor = asRecord2(policy.qualityFloor);
|
|
12044
12161
|
const approvalPolicy = asRecord2(policy.approvalPolicy);
|
|
12045
12162
|
const workingRulesValue = normalizeValue({
|
|
@@ -12105,7 +12222,39 @@ function buildTeamPromptSource(manifest, policy, bodySections = []) {
|
|
|
12105
12222
|
};
|
|
12106
12223
|
}
|
|
12107
12224
|
|
|
12108
|
-
// src/
|
|
12225
|
+
// src/render/apply-prompt-projection.ts
|
|
12226
|
+
function matchesPath(selected, path10) {
|
|
12227
|
+
return selected === path10 || path10.startsWith(`${selected}.`);
|
|
12228
|
+
}
|
|
12229
|
+
function isAncestorPath(ancestor, descendant) {
|
|
12230
|
+
return descendant === ancestor || descendant.startsWith(`${ancestor}.`);
|
|
12231
|
+
}
|
|
12232
|
+
function projectNode(node, projection) {
|
|
12233
|
+
const include = projection?.include ?? [];
|
|
12234
|
+
const exclude = projection?.exclude ?? [];
|
|
12235
|
+
const labels = projection?.labels ?? {};
|
|
12236
|
+
const projectedChildren = node.children?.map((child) => projectNode(child, projection)).filter((child) => Boolean(child));
|
|
12237
|
+
const explicitlyIncluded = include.length === 0 || include.some((selected) => matchesPath(selected, node.path));
|
|
12238
|
+
const descendantIncluded = include.length > 0 && include.some((selected) => isAncestorPath(node.path, selected));
|
|
12239
|
+
const explicitlyExcluded = exclude.some((selected) => matchesPath(selected, node.path));
|
|
12240
|
+
const shouldKeep = include.length === 0 ? !explicitlyExcluded && (node.visibleByDefault || (projectedChildren?.length ?? 0) > 0) : (explicitlyIncluded || descendantIncluded || (projectedChildren?.length ?? 0) > 0) && !explicitlyExcluded;
|
|
12241
|
+
if (!shouldKeep) {
|
|
12242
|
+
return void 0;
|
|
12243
|
+
}
|
|
12244
|
+
return {
|
|
12245
|
+
...node,
|
|
12246
|
+
label: labels[node.path] ?? node.label,
|
|
12247
|
+
...projectedChildren ? { children: projectedChildren } : {}
|
|
12248
|
+
};
|
|
12249
|
+
}
|
|
12250
|
+
function applyPromptProjection(catalog, projection) {
|
|
12251
|
+
return {
|
|
12252
|
+
kind: catalog.kind,
|
|
12253
|
+
nodes: catalog.nodes.map((node) => projectNode(node, projection)).filter((node) => Boolean(node))
|
|
12254
|
+
};
|
|
12255
|
+
}
|
|
12256
|
+
|
|
12257
|
+
// src/render/build-prompt-catalog.ts
|
|
12109
12258
|
function formatDisplayLabel(key) {
|
|
12110
12259
|
return key.replace(/_/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/\b\w/g, (char) => char.toUpperCase());
|
|
12111
12260
|
}
|
|
@@ -12178,7 +12327,7 @@ function buildPromptCatalog(doc) {
|
|
|
12178
12327
|
};
|
|
12179
12328
|
}
|
|
12180
12329
|
|
|
12181
|
-
// src/
|
|
12330
|
+
// src/render/build-prompt-plan.ts
|
|
12182
12331
|
var CANONICAL_SECTION_TITLES = {
|
|
12183
12332
|
working_rules: "Working Rules",
|
|
12184
12333
|
approval_safety: "Approval & Safety",
|
|
@@ -12249,38 +12398,6 @@ function buildPromptPlan(catalog) {
|
|
|
12249
12398
|
};
|
|
12250
12399
|
}
|
|
12251
12400
|
|
|
12252
|
-
// src/projection/apply-prompt-projection.ts
|
|
12253
|
-
function matchesPath(selected, path10) {
|
|
12254
|
-
return selected === path10 || path10.startsWith(`${selected}.`);
|
|
12255
|
-
}
|
|
12256
|
-
function isAncestorPath(ancestor, descendant) {
|
|
12257
|
-
return descendant === ancestor || descendant.startsWith(`${ancestor}.`);
|
|
12258
|
-
}
|
|
12259
|
-
function projectNode(node, projection) {
|
|
12260
|
-
const include = projection?.include ?? [];
|
|
12261
|
-
const exclude = projection?.exclude ?? [];
|
|
12262
|
-
const labels = projection?.labels ?? {};
|
|
12263
|
-
const projectedChildren = node.children?.map((child) => projectNode(child, projection)).filter((child) => Boolean(child));
|
|
12264
|
-
const explicitlyIncluded = include.length === 0 || include.some((selected) => matchesPath(selected, node.path));
|
|
12265
|
-
const descendantIncluded = include.length > 0 && include.some((selected) => isAncestorPath(node.path, selected));
|
|
12266
|
-
const explicitlyExcluded = exclude.some((selected) => matchesPath(selected, node.path));
|
|
12267
|
-
const shouldKeep = include.length === 0 ? !explicitlyExcluded && (node.visibleByDefault || (projectedChildren?.length ?? 0) > 0) : (explicitlyIncluded || descendantIncluded || (projectedChildren?.length ?? 0) > 0) && !explicitlyExcluded;
|
|
12268
|
-
if (!shouldKeep) {
|
|
12269
|
-
return void 0;
|
|
12270
|
-
}
|
|
12271
|
-
return {
|
|
12272
|
-
...node,
|
|
12273
|
-
label: labels[node.path] ?? node.label,
|
|
12274
|
-
...projectedChildren ? { children: projectedChildren } : {}
|
|
12275
|
-
};
|
|
12276
|
-
}
|
|
12277
|
-
function applyPromptProjection(catalog, projection) {
|
|
12278
|
-
return {
|
|
12279
|
-
kind: catalog.kind,
|
|
12280
|
-
nodes: catalog.nodes.map((node) => projectNode(node, projection)).filter((node) => Boolean(node))
|
|
12281
|
-
};
|
|
12282
|
-
}
|
|
12283
|
-
|
|
12284
12401
|
// src/render/structural-renderer.ts
|
|
12285
12402
|
var defaultRenderContext = {
|
|
12286
12403
|
indentUnit: " "
|
|
@@ -12408,7 +12525,12 @@ function createCollaborationPromptValue(agent) {
|
|
|
12408
12525
|
};
|
|
12409
12526
|
return {
|
|
12410
12527
|
defaultConsults: agent.sourceAgent.collaboration.defaultConsults.map(mapBinding),
|
|
12411
|
-
defaultHandoffs: agent.sourceAgent.collaboration.defaultHandoffs.map(mapBinding)
|
|
12528
|
+
defaultHandoffs: agent.sourceAgent.collaboration.defaultHandoffs.map(mapBinding),
|
|
12529
|
+
delegationBoundary: [
|
|
12530
|
+
"Only delegate to agents explicitly listed in default_consults or default_handoffs for this Agent Profile.",
|
|
12531
|
+
"Do not delegate to host-provided agents, OpenCode built-in agents, agents from other Teams, or agents not listed here.",
|
|
12532
|
+
"Use CrewBee delegate_task for delegation; do not use the host task tool for CrewBee Team delegation."
|
|
12533
|
+
]
|
|
12412
12534
|
};
|
|
12413
12535
|
}
|
|
12414
12536
|
function renderPart(title, body) {
|
|
@@ -12417,7 +12539,7 @@ function renderPart(title, body) {
|
|
|
12417
12539
|
${body}` : void 0;
|
|
12418
12540
|
}
|
|
12419
12541
|
function createOpenCodeAgentPrompt(agent, _requestedTools) {
|
|
12420
|
-
const
|
|
12542
|
+
const teamDocument = buildTeamPromptDocument(
|
|
12421
12543
|
{
|
|
12422
12544
|
id: agent.sourceTeam.manifest.id,
|
|
12423
12545
|
name: agent.sourceTeam.manifest.name,
|
|
@@ -12425,8 +12547,8 @@ function createOpenCodeAgentPrompt(agent, _requestedTools) {
|
|
|
12425
12547
|
},
|
|
12426
12548
|
agent.sourceTeam.policy
|
|
12427
12549
|
);
|
|
12428
|
-
const teamPart = renderNormalizedPromptDocument(
|
|
12429
|
-
const normalizedAgent =
|
|
12550
|
+
const teamPart = renderNormalizedPromptDocument(teamDocument);
|
|
12551
|
+
const normalizedAgent = buildAgentPromptDocumentWithOverrides(agent.sourceAgent, {
|
|
12430
12552
|
collaborationValue: createCollaborationPromptValue(agent)
|
|
12431
12553
|
});
|
|
12432
12554
|
const agentPart = renderNormalizedPromptDocument(normalizedAgent);
|
|
@@ -12456,6 +12578,32 @@ function resolveRuntimeModelId(runtime) {
|
|
|
12456
12578
|
}
|
|
12457
12579
|
return runtime.provider ? `${runtime.provider}/${runtime.model}` : runtime.model;
|
|
12458
12580
|
}
|
|
12581
|
+
function mergeModelOptions(baseOptions, overrideOptions) {
|
|
12582
|
+
const merged = {
|
|
12583
|
+
...baseOptions ?? {},
|
|
12584
|
+
...overrideOptions ?? {}
|
|
12585
|
+
};
|
|
12586
|
+
return Object.keys(merged).length > 0 ? merged : void 0;
|
|
12587
|
+
}
|
|
12588
|
+
function applyAgentModelOverride(runtime, override) {
|
|
12589
|
+
if (!override) {
|
|
12590
|
+
return runtime;
|
|
12591
|
+
}
|
|
12592
|
+
const model = override.model ?? runtime?.model;
|
|
12593
|
+
if (!model) {
|
|
12594
|
+
return runtime;
|
|
12595
|
+
}
|
|
12596
|
+
return {
|
|
12597
|
+
provider: runtime?.provider,
|
|
12598
|
+
model,
|
|
12599
|
+
temperature: runtime?.temperature,
|
|
12600
|
+
topP: runtime?.topP,
|
|
12601
|
+
variant: override.variant ?? runtime?.variant,
|
|
12602
|
+
options: mergeModelOptions(runtime?.options, override.options),
|
|
12603
|
+
fallbackModels: runtime?.fallbackModels,
|
|
12604
|
+
fallbackToHostDefault: runtime?.fallbackToHostDefault
|
|
12605
|
+
};
|
|
12606
|
+
}
|
|
12459
12607
|
function parseProviderModel(model) {
|
|
12460
12608
|
const separator = model.indexOf("/");
|
|
12461
12609
|
if (separator <= 0 || separator >= model.length - 1) {
|
|
@@ -12492,16 +12640,28 @@ function createHostDefaultTrace(input) {
|
|
|
12492
12640
|
function appendConfiguredModelCandidate(input) {
|
|
12493
12641
|
const runtimeModel = resolveRuntimeModelId(input.runtime);
|
|
12494
12642
|
const defaultRuntimeModel = resolveRuntimeModelId(input.defaultRuntime);
|
|
12495
|
-
if (input.
|
|
12496
|
-
appendUniqueCandidate(input.candidates, {
|
|
12643
|
+
if (input.agentOverride?.model) {
|
|
12644
|
+
appendUniqueCandidate(input.candidates, {
|
|
12645
|
+
model: input.agentOverride.model,
|
|
12646
|
+
source: "crewbee-json",
|
|
12647
|
+
runtime: applyAgentModelOverride(input.runtime ?? input.defaultRuntime, input.agentOverride)
|
|
12648
|
+
});
|
|
12497
12649
|
return;
|
|
12498
12650
|
}
|
|
12499
12651
|
if (runtimeModel) {
|
|
12500
|
-
appendUniqueCandidate(input.candidates, {
|
|
12652
|
+
appendUniqueCandidate(input.candidates, {
|
|
12653
|
+
model: runtimeModel,
|
|
12654
|
+
source: "team-manifest",
|
|
12655
|
+
runtime: applyAgentModelOverride(input.runtime, input.agentOverride)
|
|
12656
|
+
});
|
|
12501
12657
|
return;
|
|
12502
12658
|
}
|
|
12503
12659
|
if (defaultRuntimeModel) {
|
|
12504
|
-
appendUniqueCandidate(input.candidates, {
|
|
12660
|
+
appendUniqueCandidate(input.candidates, {
|
|
12661
|
+
model: defaultRuntimeModel,
|
|
12662
|
+
source: "team-manifest-default",
|
|
12663
|
+
runtime: applyAgentModelOverride(input.defaultRuntime, input.agentOverride)
|
|
12664
|
+
});
|
|
12505
12665
|
}
|
|
12506
12666
|
}
|
|
12507
12667
|
function resolveAgentModel(input) {
|
|
@@ -12510,6 +12670,8 @@ function resolveAgentModel(input) {
|
|
|
12510
12670
|
const agentOverride = teamOverride?.agents?.[agent.canonicalAgentId];
|
|
12511
12671
|
const runtime = agent.sourceTeam.manifest.agentRuntime?.[agent.canonicalAgentId];
|
|
12512
12672
|
const defaultRuntime = agent.sourceTeam.manifest.agentRuntime?.$default;
|
|
12673
|
+
const runtimeWithOverride = applyAgentModelOverride(runtime, agentOverride);
|
|
12674
|
+
const defaultRuntimeWithOverride = applyAgentModelOverride(defaultRuntime, agentOverride);
|
|
12513
12675
|
const fallbackStrategy = teamOverride?.fallback ?? (agent.teamId === BUILTIN_CODING_TEAM_ID ? BUILTIN_CODING_TEAM_MODEL_FALLBACK : TEAM_MANIFEST_FALLBACK_STRATEGY);
|
|
12514
12676
|
const fallbackToHostDefault = teamOverride?.fallbackToHostDefault ?? runtime?.fallbackToHostDefault ?? defaultRuntime?.fallbackToHostDefault ?? true;
|
|
12515
12677
|
const runtimeModel = resolveRuntimeModelId(runtime);
|
|
@@ -12517,9 +12679,9 @@ function resolveAgentModel(input) {
|
|
|
12517
12679
|
const candidates = [];
|
|
12518
12680
|
appendConfiguredModelCandidate({
|
|
12519
12681
|
candidates,
|
|
12520
|
-
|
|
12521
|
-
runtime,
|
|
12522
|
-
defaultRuntime
|
|
12682
|
+
agentOverride,
|
|
12683
|
+
runtime: runtimeWithOverride,
|
|
12684
|
+
defaultRuntime: defaultRuntimeWithOverride
|
|
12523
12685
|
});
|
|
12524
12686
|
if (agentOverride?.model === HOST_DEFAULT_MODEL_ID || !agentOverride?.model && runtimeModel === HOST_DEFAULT_MODEL_ID) {
|
|
12525
12687
|
return {
|
|
@@ -12537,11 +12699,11 @@ function resolveAgentModel(input) {
|
|
|
12537
12699
|
const sourceAgentId = agent.sourceAgent.metadata.sourceId ?? agent.canonicalAgentId;
|
|
12538
12700
|
if (fallbackStrategy === BUILTIN_CODING_TEAM_MODEL_FALLBACK && agent.teamId === BUILTIN_CODING_TEAM_ID) {
|
|
12539
12701
|
for (const model of BUILTIN_ROLE_FALLBACKS[sourceAgentId] ?? BUILTIN_ROLE_FALLBACKS[agent.canonicalAgentId] ?? []) {
|
|
12540
|
-
appendUniqueCandidate(candidates, { model, source: "builtin-role-chain", runtime });
|
|
12702
|
+
appendUniqueCandidate(candidates, { model, source: "builtin-role-chain", runtime: runtimeWithOverride });
|
|
12541
12703
|
}
|
|
12542
12704
|
} else {
|
|
12543
|
-
for (const model of
|
|
12544
|
-
appendUniqueCandidate(candidates, { model, source: "team-manifest", runtime });
|
|
12705
|
+
for (const model of runtimeWithOverride?.fallbackModels ?? defaultRuntimeWithOverride?.fallbackModels ?? []) {
|
|
12706
|
+
appendUniqueCandidate(candidates, { model, source: "team-manifest", runtime: runtimeWithOverride ?? defaultRuntimeWithOverride });
|
|
12545
12707
|
}
|
|
12546
12708
|
}
|
|
12547
12709
|
const availableModels = input.availableModels ? new Set(input.availableModels) : void 0;
|
|
@@ -12609,6 +12771,40 @@ function resolveAgentModel(input) {
|
|
|
12609
12771
|
function createOpenCodeConfigKey(agent) {
|
|
12610
12772
|
return agent.canonicalAgentId;
|
|
12611
12773
|
}
|
|
12774
|
+
function resolveTeamAgentByRef(agent, agentRef) {
|
|
12775
|
+
return agent.sourceTeam.agents.find((candidate) => {
|
|
12776
|
+
return candidate.metadata.id === agentRef || candidate.canonicalAgentId === agentRef;
|
|
12777
|
+
});
|
|
12778
|
+
}
|
|
12779
|
+
function createDelegationPolicy(agent) {
|
|
12780
|
+
const createTarget = (binding2, via) => {
|
|
12781
|
+
const agentRef = typeof binding2 === "string" ? binding2 : binding2.agentRef;
|
|
12782
|
+
const targetAgent = resolveTeamAgentByRef(agent, agentRef);
|
|
12783
|
+
if (!targetAgent) {
|
|
12784
|
+
return void 0;
|
|
12785
|
+
}
|
|
12786
|
+
const canonicalAgentId = targetAgent.canonicalAgentId ?? targetAgent.metadata.id;
|
|
12787
|
+
const member = agent.sourceTeam.manifest.members[targetAgent.metadata.id] ?? agent.sourceTeam.manifest.members[agentRef];
|
|
12788
|
+
return {
|
|
12789
|
+
configKey: canonicalAgentId,
|
|
12790
|
+
canonicalAgentId,
|
|
12791
|
+
sourceAgentId: targetAgent.metadata.id,
|
|
12792
|
+
description: member?.responsibility ?? targetAgent.responsibilityCore.description,
|
|
12793
|
+
via
|
|
12794
|
+
};
|
|
12795
|
+
};
|
|
12796
|
+
const targets = [
|
|
12797
|
+
...agent.sourceAgent.collaboration.defaultConsults.map((binding2) => createTarget(binding2, "consult")),
|
|
12798
|
+
...agent.sourceAgent.collaboration.defaultHandoffs.map((binding2) => createTarget(binding2, "handoff"))
|
|
12799
|
+
].filter((target) => Boolean(target));
|
|
12800
|
+
const deduped = /* @__PURE__ */ new Map();
|
|
12801
|
+
for (const target of targets) {
|
|
12802
|
+
if (!deduped.has(target.configKey)) {
|
|
12803
|
+
deduped.set(target.configKey, target);
|
|
12804
|
+
}
|
|
12805
|
+
}
|
|
12806
|
+
return { allowedTargets: [...deduped.values()] };
|
|
12807
|
+
}
|
|
12612
12808
|
function createOpenCodeAgentConfig(agent, options = {}) {
|
|
12613
12809
|
const runtimeConfig = agent.sourceAgent.runtimeConfig;
|
|
12614
12810
|
const modelResolution = resolveAgentModel({
|
|
@@ -12646,6 +12842,7 @@ function createOpenCodeAgentConfig(agent, options = {}) {
|
|
|
12646
12842
|
availabilitySource: availableToolContext.source,
|
|
12647
12843
|
availabilityIsExplicit: availableToolContext.hasExplicitTools
|
|
12648
12844
|
},
|
|
12845
|
+
delegation: createDelegationPolicy(agent),
|
|
12649
12846
|
metadata: {
|
|
12650
12847
|
teamId: agent.teamId,
|
|
12651
12848
|
teamName: agent.teamName,
|
|
@@ -12665,6 +12862,7 @@ function createOpenCodeAgentDefinition(agent) {
|
|
|
12665
12862
|
description: agent.description,
|
|
12666
12863
|
mode: agent.mode,
|
|
12667
12864
|
hidden: agent.hidden || void 0,
|
|
12865
|
+
tools: { task: false },
|
|
12668
12866
|
model: agent.resolvedModel ? `${agent.resolvedModel.providerID}/${agent.resolvedModel.modelID}` : void 0,
|
|
12669
12867
|
temperature: agent.resolvedModel?.temperature,
|
|
12670
12868
|
top_p: agent.resolvedModel?.topP,
|
|
@@ -12684,11 +12882,44 @@ function createOpenCodeProjectedIdentities(agent) {
|
|
|
12684
12882
|
}];
|
|
12685
12883
|
}
|
|
12686
12884
|
function createOpenCodeAgentConfigPatch(input) {
|
|
12885
|
+
const disabledHostAgents = {
|
|
12886
|
+
build: {
|
|
12887
|
+
name: "build",
|
|
12888
|
+
description: "Disabled by CrewBee while a CrewBee Agent Team owns the session.",
|
|
12889
|
+
mode: "subagent",
|
|
12890
|
+
disable: true,
|
|
12891
|
+
tools: {},
|
|
12892
|
+
prompt: "",
|
|
12893
|
+
permission: {}
|
|
12894
|
+
},
|
|
12895
|
+
plan: {
|
|
12896
|
+
name: "plan",
|
|
12897
|
+
description: "Disabled by CrewBee while a CrewBee Agent Team owns the session.",
|
|
12898
|
+
mode: "subagent",
|
|
12899
|
+
disable: true,
|
|
12900
|
+
tools: {},
|
|
12901
|
+
prompt: "",
|
|
12902
|
+
permission: {}
|
|
12903
|
+
},
|
|
12904
|
+
general: {
|
|
12905
|
+
name: "general",
|
|
12906
|
+
description: "Disabled by CrewBee while a CrewBee Agent Team owns the session.",
|
|
12907
|
+
mode: "subagent",
|
|
12908
|
+
disable: true,
|
|
12909
|
+
tools: {},
|
|
12910
|
+
prompt: "",
|
|
12911
|
+
permission: {}
|
|
12912
|
+
}
|
|
12913
|
+
};
|
|
12687
12914
|
return {
|
|
12688
|
-
agent:
|
|
12689
|
-
|
|
12690
|
-
|
|
12691
|
-
|
|
12915
|
+
agent: {
|
|
12916
|
+
...Object.fromEntries(
|
|
12917
|
+
input.agents.map((agent) => [agent.configKey, createOpenCodeAgentDefinition(agent)])
|
|
12918
|
+
),
|
|
12919
|
+
...disabledHostAgents
|
|
12920
|
+
},
|
|
12921
|
+
defaultAgent: input.defaultAgentConfigKey,
|
|
12922
|
+
forceUpdateAgentKeys: Object.keys(disabledHostAgents)
|
|
12692
12923
|
};
|
|
12693
12924
|
}
|
|
12694
12925
|
function findProjectedAgentByConfigKey(agents, configKey) {
|
|
@@ -12728,11 +12959,6 @@ function resolveProjectedAgentAlias(index, alias) {
|
|
|
12728
12959
|
}
|
|
12729
12960
|
return index.get(normalizeAlias(alias));
|
|
12730
12961
|
}
|
|
12731
|
-
function createProjectedAgentTaskAliasHelpLines(agents) {
|
|
12732
|
-
return agents.map((agent) => {
|
|
12733
|
-
return `- ${agent.configKey}`;
|
|
12734
|
-
});
|
|
12735
|
-
}
|
|
12736
12962
|
|
|
12737
12963
|
// src/adapters/opencode/tool-domain.ts
|
|
12738
12964
|
function createOpenCodeToolDomainPlan() {
|
|
@@ -25816,7 +26042,7 @@ function resolveDelegateAgent(input) {
|
|
|
25816
26042
|
const bySelection = resolveProjectedAgentSelection(input.agents, {
|
|
25817
26043
|
configKey: input.agent
|
|
25818
26044
|
});
|
|
25819
|
-
if (bySelection) {
|
|
26045
|
+
if (bySelection && isAllowedDelegateTarget(input.sourceAgent, bySelection)) {
|
|
25820
26046
|
return {
|
|
25821
26047
|
agent: bySelection,
|
|
25822
26048
|
configKey: bySelection.configKey,
|
|
@@ -25824,7 +26050,7 @@ function resolveDelegateAgent(input) {
|
|
|
25824
26050
|
};
|
|
25825
26051
|
}
|
|
25826
26052
|
const byAlias = resolveProjectedAgentAlias(input.aliasIndex, input.agent);
|
|
25827
|
-
if (!byAlias) {
|
|
26053
|
+
if (!byAlias || !isAllowedDelegateTarget(input.sourceAgent, byAlias.agent)) {
|
|
25828
26054
|
return void 0;
|
|
25829
26055
|
}
|
|
25830
26056
|
return {
|
|
@@ -25833,6 +26059,12 @@ function resolveDelegateAgent(input) {
|
|
|
25833
26059
|
canonicalAgentId: byAlias.agent.canonicalAgentId
|
|
25834
26060
|
};
|
|
25835
26061
|
}
|
|
26062
|
+
function isAllowedDelegateTarget(sourceAgent, targetAgent) {
|
|
26063
|
+
if (!sourceAgent) {
|
|
26064
|
+
return false;
|
|
26065
|
+
}
|
|
26066
|
+
return sourceAgent.delegation.allowedTargets.some((target) => target.configKey === targetAgent.configKey);
|
|
26067
|
+
}
|
|
25836
26068
|
function isSelfDelegate(binding2, canonicalAgentId) {
|
|
25837
26069
|
if (!binding2) {
|
|
25838
26070
|
return false;
|
|
@@ -25973,6 +26205,14 @@ function launchBackground(input) {
|
|
|
25973
26205
|
input.store.setTaskStatus(input.taskRef, "failed", { lastError: String(error45), message: String(error45) });
|
|
25974
26206
|
});
|
|
25975
26207
|
}
|
|
26208
|
+
function findBoundSourceAgent(input) {
|
|
26209
|
+
if (!input.binding) {
|
|
26210
|
+
return void 0;
|
|
26211
|
+
}
|
|
26212
|
+
return input.agents.find((agent) => {
|
|
26213
|
+
return agent.teamId === input.binding?.teamId && agent.canonicalAgentId === input.binding.selectedAgentId;
|
|
26214
|
+
});
|
|
26215
|
+
}
|
|
25976
26216
|
function createDelegateTools(input) {
|
|
25977
26217
|
const delegate_task = createToolDefinition({
|
|
25978
26218
|
description: "Delegate work to a CrewBee team member.",
|
|
@@ -25995,15 +26235,18 @@ function createDelegateTools(input) {
|
|
|
25995
26235
|
if (mode !== "foreground" && mode !== "background") {
|
|
25996
26236
|
return stringifyDelegateTaskResult(createFailedResult(ctx.sessionID, "unsupported_mode", "Use mode=foreground or mode=background."));
|
|
25997
26237
|
}
|
|
26238
|
+
const projectedAgents = input.getProjectedAgents();
|
|
26239
|
+
const binding2 = input.bindings.get(ctx.sessionID);
|
|
26240
|
+
const sourceAgent = findBoundSourceAgent({ agents: projectedAgents, binding: binding2 });
|
|
25998
26241
|
const target = resolveDelegateAgent({
|
|
25999
|
-
agents:
|
|
26242
|
+
agents: projectedAgents,
|
|
26000
26243
|
aliasIndex: input.getAliasIndex(),
|
|
26001
|
-
agent: args.agent
|
|
26244
|
+
agent: args.agent,
|
|
26245
|
+
sourceAgent
|
|
26002
26246
|
});
|
|
26003
26247
|
if (!target) {
|
|
26004
|
-
return stringifyDelegateTaskResult(createFailedResult(ctx.sessionID, "unknown_agent", `Unknown CrewBee
|
|
26248
|
+
return stringifyDelegateTaskResult(createFailedResult(ctx.sessionID, "unknown_agent", `Unknown or disallowed CrewBee delegate target: ${args.agent}`));
|
|
26005
26249
|
}
|
|
26006
|
-
const binding2 = input.bindings.get(ctx.sessionID);
|
|
26007
26250
|
if (isSelfDelegate(binding2, target.canonicalAgentId)) {
|
|
26008
26251
|
return stringifyDelegateTaskResult(createFailedResult(ctx.sessionID, "self_delegate_forbidden", "Do not delegate a CrewBee session back to the same active agent."));
|
|
26009
26252
|
}
|
|
@@ -26161,18 +26404,27 @@ function createSystemTransformHook(bindings, getLoadIssues = () => []) {
|
|
|
26161
26404
|
}
|
|
26162
26405
|
|
|
26163
26406
|
// src/adapters/opencode/tool-hooks.ts
|
|
26164
|
-
function
|
|
26165
|
-
|
|
26166
|
-
|
|
26167
|
-
|
|
26168
|
-
|
|
26169
|
-
|
|
26170
|
-
|
|
26171
|
-
|
|
26172
|
-
|
|
26173
|
-
|
|
26174
|
-
|
|
26175
|
-
|
|
26407
|
+
function isRecord6(value) {
|
|
26408
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
26409
|
+
}
|
|
26410
|
+
function sanitizeNativeTaskParameters(value) {
|
|
26411
|
+
if (Array.isArray(value)) {
|
|
26412
|
+
return value.map((entry) => sanitizeNativeTaskParameters(entry));
|
|
26413
|
+
}
|
|
26414
|
+
if (!isRecord6(value)) {
|
|
26415
|
+
return value;
|
|
26416
|
+
}
|
|
26417
|
+
const next = Object.fromEntries(
|
|
26418
|
+
Object.entries(value).map(([key, entry]) => [key, sanitizeNativeTaskParameters(entry)])
|
|
26419
|
+
);
|
|
26420
|
+
const properties = next.properties;
|
|
26421
|
+
if (isRecord6(properties) && isRecord6(properties.subagent_type)) {
|
|
26422
|
+
properties.subagent_type = {
|
|
26423
|
+
type: "string",
|
|
26424
|
+
description: "Disabled for CrewBee Agent Team sessions. Use delegate_task with an agent listed in the current Agent Profile collaboration section."
|
|
26425
|
+
};
|
|
26426
|
+
}
|
|
26427
|
+
return next;
|
|
26176
26428
|
}
|
|
26177
26429
|
function buildRetryGuidance(result) {
|
|
26178
26430
|
if (!result.error_code) {
|
|
@@ -26235,24 +26487,15 @@ function withRetryGuidance(result) {
|
|
|
26235
26487
|
${guidance}` : guidance
|
|
26236
26488
|
};
|
|
26237
26489
|
}
|
|
26238
|
-
function createToolDefinitionHook(
|
|
26490
|
+
function createToolDefinitionHook(_getAgents) {
|
|
26239
26491
|
return async (input, output) => {
|
|
26240
26492
|
if (input.toolID !== "task") {
|
|
26241
26493
|
return;
|
|
26242
26494
|
}
|
|
26243
|
-
const helpLines = createProjectedAgentTaskAliasHelpLines(getAgents());
|
|
26244
|
-
if (helpLines.length === 0) {
|
|
26245
|
-
return;
|
|
26246
|
-
}
|
|
26247
|
-
output.description = deduplicateTaskDescription(output.description);
|
|
26248
26495
|
output.description = [
|
|
26249
|
-
|
|
26250
|
-
"",
|
|
26251
|
-
"CrewBee subagent aliases:",
|
|
26252
|
-
...helpLines,
|
|
26253
|
-
"",
|
|
26254
|
-
"When delegating inside CrewBee, prefer the CrewBee source-agent alias shown on each line."
|
|
26496
|
+
"CrewBee Agent Team boundary: this native task tool is disabled for CrewBee Team agents. Use delegate_task, and only target agents listed in the current Agent Profile collaboration section."
|
|
26255
26497
|
].join("\n");
|
|
26498
|
+
output.parameters = sanitizeNativeTaskParameters(output.parameters);
|
|
26256
26499
|
};
|
|
26257
26500
|
}
|
|
26258
26501
|
function createToolExecuteBeforeHook(input) {
|