crewbee 0.1.13 → 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/dist/opencode-plugin.mjs +217 -55
- 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 +5 -0
- 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/filesystem.d.ts +2 -0
- package/dist/src/agent-teams/filesystem.d.ts.map +1 -1
- package/dist/src/agent-teams/filesystem.js +22 -1
- 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/core/index.d.ts +2 -0
- package/dist/src/core/index.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/opencode-plugin.mjs
CHANGED
|
@@ -9940,6 +9940,18 @@ function asStringArray(value, label) {
|
|
|
9940
9940
|
}
|
|
9941
9941
|
return value.map((entry, index) => asString(entry, `${label}[${index}]`));
|
|
9942
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
|
+
}
|
|
9943
9955
|
function readTextFile(filePath) {
|
|
9944
9956
|
return readFileSync(filePath, "utf8");
|
|
9945
9957
|
}
|
|
@@ -10264,14 +10276,14 @@ function mapAgentRuntime(raw) {
|
|
|
10264
10276
|
return Object.fromEntries(
|
|
10265
10277
|
Object.entries(raw).map(([agentId, value]) => {
|
|
10266
10278
|
const record2 = asRecord(value, `agent_runtime.${agentId}`);
|
|
10267
|
-
const options =
|
|
10279
|
+
const options = mapProviderOptions(record2);
|
|
10268
10280
|
const runtime = {
|
|
10269
10281
|
provider: record2.provider !== void 0 ? asString(record2.provider, `agent_runtime.${agentId}.provider`) : void 0,
|
|
10270
10282
|
model: asString(record2.model, `agent_runtime.${agentId}.model`),
|
|
10271
10283
|
temperature: record2.temperature !== void 0 ? Number(record2.temperature) : void 0,
|
|
10272
10284
|
topP: record2.top_p !== void 0 || record2.topP !== void 0 ? Number(record2.top_p ?? record2.topP) : void 0,
|
|
10273
10285
|
variant: asOptionalString(record2.variant),
|
|
10274
|
-
options
|
|
10286
|
+
options,
|
|
10275
10287
|
fallbackModels: record2.fallback_models || record2.fallbackModels ? asStringArray(record2.fallback_models ?? record2.fallbackModels, `agent_runtime.${agentId}.fallback_models`) : void 0,
|
|
10276
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
|
|
10277
10289
|
};
|
|
@@ -10532,6 +10544,21 @@ function getOptionalPriority(value, fallback) {
|
|
|
10532
10544
|
function getOptionalString(value) {
|
|
10533
10545
|
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
10534
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
|
+
}
|
|
10535
10562
|
function normalizeConfiguredTeamModelOverride(raw) {
|
|
10536
10563
|
const modelPreset = getOptionalString(raw.model_preset ?? raw.modelPreset);
|
|
10537
10564
|
const fallback = getOptionalString(raw.fallback);
|
|
@@ -10543,7 +10570,13 @@ function normalizeConfiguredTeamModelOverride(raw) {
|
|
|
10543
10570
|
return [];
|
|
10544
10571
|
}
|
|
10545
10572
|
const model = getOptionalString(value.model);
|
|
10546
|
-
|
|
10573
|
+
const variant = getOptionalString(value.variant);
|
|
10574
|
+
const options = createProviderOptionOverrides(value);
|
|
10575
|
+
return [[agentId, {
|
|
10576
|
+
...model ? { model } : {},
|
|
10577
|
+
...variant ? { variant } : {},
|
|
10578
|
+
...options ? { options } : {}
|
|
10579
|
+
}]];
|
|
10547
10580
|
})
|
|
10548
10581
|
) : void 0;
|
|
10549
10582
|
const normalizedAgents = agents && Object.keys(agents).length > 0 ? agents : void 0;
|
|
@@ -11929,6 +11962,7 @@ function createManagedCrewBeeAgentOptions(input) {
|
|
|
11929
11962
|
// src/adapters/opencode/config-merge.ts
|
|
11930
11963
|
function applyOpenCodeAgentConfigPatch(config2, patch) {
|
|
11931
11964
|
const patchKeys = new Set(Object.keys(patch.agent));
|
|
11965
|
+
const forceUpdateKeys = new Set(patch.forceUpdateAgentKeys ?? []);
|
|
11932
11966
|
const nextAgents = Object.fromEntries(
|
|
11933
11967
|
Object.entries(config2.agent ?? {}).filter(([key, definition]) => {
|
|
11934
11968
|
if (isManagedCrewBeeAgentDefinition(definition) && !patchKeys.has(key)) {
|
|
@@ -11947,7 +11981,7 @@ function applyOpenCodeAgentConfigPatch(config2, patch) {
|
|
|
11947
11981
|
continue;
|
|
11948
11982
|
}
|
|
11949
11983
|
const existingDefinition = nextAgents[key];
|
|
11950
|
-
if (isManagedCrewBeeAgentDefinition(existingDefinition)) {
|
|
11984
|
+
if (forceUpdateKeys.has(key) || isManagedCrewBeeAgentDefinition(existingDefinition)) {
|
|
11951
11985
|
nextAgents[key] = definition;
|
|
11952
11986
|
updatedAgentKeys.push(key);
|
|
11953
11987
|
continue;
|
|
@@ -12015,7 +12049,9 @@ function mapPermissionRulesWithAvailability(permissionRules, availableTools) {
|
|
|
12015
12049
|
}).filter((rule) => Boolean(rule)).filter((rule) => isAvailableTool(rule.permission, availableTools));
|
|
12016
12050
|
}
|
|
12017
12051
|
function createOpenCodePermissionRules(agent, availableTools) {
|
|
12018
|
-
|
|
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;
|
|
12019
12055
|
}
|
|
12020
12056
|
function createOpenCodePermissionConfig(permissionRules) {
|
|
12021
12057
|
const permission = {};
|
|
@@ -12489,7 +12525,12 @@ function createCollaborationPromptValue(agent) {
|
|
|
12489
12525
|
};
|
|
12490
12526
|
return {
|
|
12491
12527
|
defaultConsults: agent.sourceAgent.collaboration.defaultConsults.map(mapBinding),
|
|
12492
|
-
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
|
+
]
|
|
12493
12534
|
};
|
|
12494
12535
|
}
|
|
12495
12536
|
function renderPart(title, body) {
|
|
@@ -12537,6 +12578,32 @@ function resolveRuntimeModelId(runtime) {
|
|
|
12537
12578
|
}
|
|
12538
12579
|
return runtime.provider ? `${runtime.provider}/${runtime.model}` : runtime.model;
|
|
12539
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
|
+
}
|
|
12540
12607
|
function parseProviderModel(model) {
|
|
12541
12608
|
const separator = model.indexOf("/");
|
|
12542
12609
|
if (separator <= 0 || separator >= model.length - 1) {
|
|
@@ -12573,16 +12640,28 @@ function createHostDefaultTrace(input) {
|
|
|
12573
12640
|
function appendConfiguredModelCandidate(input) {
|
|
12574
12641
|
const runtimeModel = resolveRuntimeModelId(input.runtime);
|
|
12575
12642
|
const defaultRuntimeModel = resolveRuntimeModelId(input.defaultRuntime);
|
|
12576
|
-
if (input.
|
|
12577
|
-
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
|
+
});
|
|
12578
12649
|
return;
|
|
12579
12650
|
}
|
|
12580
12651
|
if (runtimeModel) {
|
|
12581
|
-
appendUniqueCandidate(input.candidates, {
|
|
12652
|
+
appendUniqueCandidate(input.candidates, {
|
|
12653
|
+
model: runtimeModel,
|
|
12654
|
+
source: "team-manifest",
|
|
12655
|
+
runtime: applyAgentModelOverride(input.runtime, input.agentOverride)
|
|
12656
|
+
});
|
|
12582
12657
|
return;
|
|
12583
12658
|
}
|
|
12584
12659
|
if (defaultRuntimeModel) {
|
|
12585
|
-
appendUniqueCandidate(input.candidates, {
|
|
12660
|
+
appendUniqueCandidate(input.candidates, {
|
|
12661
|
+
model: defaultRuntimeModel,
|
|
12662
|
+
source: "team-manifest-default",
|
|
12663
|
+
runtime: applyAgentModelOverride(input.defaultRuntime, input.agentOverride)
|
|
12664
|
+
});
|
|
12586
12665
|
}
|
|
12587
12666
|
}
|
|
12588
12667
|
function resolveAgentModel(input) {
|
|
@@ -12591,6 +12670,8 @@ function resolveAgentModel(input) {
|
|
|
12591
12670
|
const agentOverride = teamOverride?.agents?.[agent.canonicalAgentId];
|
|
12592
12671
|
const runtime = agent.sourceTeam.manifest.agentRuntime?.[agent.canonicalAgentId];
|
|
12593
12672
|
const defaultRuntime = agent.sourceTeam.manifest.agentRuntime?.$default;
|
|
12673
|
+
const runtimeWithOverride = applyAgentModelOverride(runtime, agentOverride);
|
|
12674
|
+
const defaultRuntimeWithOverride = applyAgentModelOverride(defaultRuntime, agentOverride);
|
|
12594
12675
|
const fallbackStrategy = teamOverride?.fallback ?? (agent.teamId === BUILTIN_CODING_TEAM_ID ? BUILTIN_CODING_TEAM_MODEL_FALLBACK : TEAM_MANIFEST_FALLBACK_STRATEGY);
|
|
12595
12676
|
const fallbackToHostDefault = teamOverride?.fallbackToHostDefault ?? runtime?.fallbackToHostDefault ?? defaultRuntime?.fallbackToHostDefault ?? true;
|
|
12596
12677
|
const runtimeModel = resolveRuntimeModelId(runtime);
|
|
@@ -12598,9 +12679,9 @@ function resolveAgentModel(input) {
|
|
|
12598
12679
|
const candidates = [];
|
|
12599
12680
|
appendConfiguredModelCandidate({
|
|
12600
12681
|
candidates,
|
|
12601
|
-
|
|
12602
|
-
runtime,
|
|
12603
|
-
defaultRuntime
|
|
12682
|
+
agentOverride,
|
|
12683
|
+
runtime: runtimeWithOverride,
|
|
12684
|
+
defaultRuntime: defaultRuntimeWithOverride
|
|
12604
12685
|
});
|
|
12605
12686
|
if (agentOverride?.model === HOST_DEFAULT_MODEL_ID || !agentOverride?.model && runtimeModel === HOST_DEFAULT_MODEL_ID) {
|
|
12606
12687
|
return {
|
|
@@ -12618,11 +12699,11 @@ function resolveAgentModel(input) {
|
|
|
12618
12699
|
const sourceAgentId = agent.sourceAgent.metadata.sourceId ?? agent.canonicalAgentId;
|
|
12619
12700
|
if (fallbackStrategy === BUILTIN_CODING_TEAM_MODEL_FALLBACK && agent.teamId === BUILTIN_CODING_TEAM_ID) {
|
|
12620
12701
|
for (const model of BUILTIN_ROLE_FALLBACKS[sourceAgentId] ?? BUILTIN_ROLE_FALLBACKS[agent.canonicalAgentId] ?? []) {
|
|
12621
|
-
appendUniqueCandidate(candidates, { model, source: "builtin-role-chain", runtime });
|
|
12702
|
+
appendUniqueCandidate(candidates, { model, source: "builtin-role-chain", runtime: runtimeWithOverride });
|
|
12622
12703
|
}
|
|
12623
12704
|
} else {
|
|
12624
|
-
for (const model of
|
|
12625
|
-
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 });
|
|
12626
12707
|
}
|
|
12627
12708
|
}
|
|
12628
12709
|
const availableModels = input.availableModels ? new Set(input.availableModels) : void 0;
|
|
@@ -12690,6 +12771,40 @@ function resolveAgentModel(input) {
|
|
|
12690
12771
|
function createOpenCodeConfigKey(agent) {
|
|
12691
12772
|
return agent.canonicalAgentId;
|
|
12692
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
|
+
}
|
|
12693
12808
|
function createOpenCodeAgentConfig(agent, options = {}) {
|
|
12694
12809
|
const runtimeConfig = agent.sourceAgent.runtimeConfig;
|
|
12695
12810
|
const modelResolution = resolveAgentModel({
|
|
@@ -12727,6 +12842,7 @@ function createOpenCodeAgentConfig(agent, options = {}) {
|
|
|
12727
12842
|
availabilitySource: availableToolContext.source,
|
|
12728
12843
|
availabilityIsExplicit: availableToolContext.hasExplicitTools
|
|
12729
12844
|
},
|
|
12845
|
+
delegation: createDelegationPolicy(agent),
|
|
12730
12846
|
metadata: {
|
|
12731
12847
|
teamId: agent.teamId,
|
|
12732
12848
|
teamName: agent.teamName,
|
|
@@ -12746,6 +12862,7 @@ function createOpenCodeAgentDefinition(agent) {
|
|
|
12746
12862
|
description: agent.description,
|
|
12747
12863
|
mode: agent.mode,
|
|
12748
12864
|
hidden: agent.hidden || void 0,
|
|
12865
|
+
tools: { task: false },
|
|
12749
12866
|
model: agent.resolvedModel ? `${agent.resolvedModel.providerID}/${agent.resolvedModel.modelID}` : void 0,
|
|
12750
12867
|
temperature: agent.resolvedModel?.temperature,
|
|
12751
12868
|
top_p: agent.resolvedModel?.topP,
|
|
@@ -12765,11 +12882,44 @@ function createOpenCodeProjectedIdentities(agent) {
|
|
|
12765
12882
|
}];
|
|
12766
12883
|
}
|
|
12767
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
|
+
};
|
|
12768
12914
|
return {
|
|
12769
|
-
agent:
|
|
12770
|
-
|
|
12771
|
-
|
|
12772
|
-
|
|
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)
|
|
12773
12923
|
};
|
|
12774
12924
|
}
|
|
12775
12925
|
function findProjectedAgentByConfigKey(agents, configKey) {
|
|
@@ -12809,11 +12959,6 @@ function resolveProjectedAgentAlias(index, alias) {
|
|
|
12809
12959
|
}
|
|
12810
12960
|
return index.get(normalizeAlias(alias));
|
|
12811
12961
|
}
|
|
12812
|
-
function createProjectedAgentTaskAliasHelpLines(agents) {
|
|
12813
|
-
return agents.map((agent) => {
|
|
12814
|
-
return `- ${agent.configKey}`;
|
|
12815
|
-
});
|
|
12816
|
-
}
|
|
12817
12962
|
|
|
12818
12963
|
// src/adapters/opencode/tool-domain.ts
|
|
12819
12964
|
function createOpenCodeToolDomainPlan() {
|
|
@@ -25897,7 +26042,7 @@ function resolveDelegateAgent(input) {
|
|
|
25897
26042
|
const bySelection = resolveProjectedAgentSelection(input.agents, {
|
|
25898
26043
|
configKey: input.agent
|
|
25899
26044
|
});
|
|
25900
|
-
if (bySelection) {
|
|
26045
|
+
if (bySelection && isAllowedDelegateTarget(input.sourceAgent, bySelection)) {
|
|
25901
26046
|
return {
|
|
25902
26047
|
agent: bySelection,
|
|
25903
26048
|
configKey: bySelection.configKey,
|
|
@@ -25905,7 +26050,7 @@ function resolveDelegateAgent(input) {
|
|
|
25905
26050
|
};
|
|
25906
26051
|
}
|
|
25907
26052
|
const byAlias = resolveProjectedAgentAlias(input.aliasIndex, input.agent);
|
|
25908
|
-
if (!byAlias) {
|
|
26053
|
+
if (!byAlias || !isAllowedDelegateTarget(input.sourceAgent, byAlias.agent)) {
|
|
25909
26054
|
return void 0;
|
|
25910
26055
|
}
|
|
25911
26056
|
return {
|
|
@@ -25914,6 +26059,12 @@ function resolveDelegateAgent(input) {
|
|
|
25914
26059
|
canonicalAgentId: byAlias.agent.canonicalAgentId
|
|
25915
26060
|
};
|
|
25916
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
|
+
}
|
|
25917
26068
|
function isSelfDelegate(binding2, canonicalAgentId) {
|
|
25918
26069
|
if (!binding2) {
|
|
25919
26070
|
return false;
|
|
@@ -26054,6 +26205,14 @@ function launchBackground(input) {
|
|
|
26054
26205
|
input.store.setTaskStatus(input.taskRef, "failed", { lastError: String(error45), message: String(error45) });
|
|
26055
26206
|
});
|
|
26056
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
|
+
}
|
|
26057
26216
|
function createDelegateTools(input) {
|
|
26058
26217
|
const delegate_task = createToolDefinition({
|
|
26059
26218
|
description: "Delegate work to a CrewBee team member.",
|
|
@@ -26076,15 +26235,18 @@ function createDelegateTools(input) {
|
|
|
26076
26235
|
if (mode !== "foreground" && mode !== "background") {
|
|
26077
26236
|
return stringifyDelegateTaskResult(createFailedResult(ctx.sessionID, "unsupported_mode", "Use mode=foreground or mode=background."));
|
|
26078
26237
|
}
|
|
26238
|
+
const projectedAgents = input.getProjectedAgents();
|
|
26239
|
+
const binding2 = input.bindings.get(ctx.sessionID);
|
|
26240
|
+
const sourceAgent = findBoundSourceAgent({ agents: projectedAgents, binding: binding2 });
|
|
26079
26241
|
const target = resolveDelegateAgent({
|
|
26080
|
-
agents:
|
|
26242
|
+
agents: projectedAgents,
|
|
26081
26243
|
aliasIndex: input.getAliasIndex(),
|
|
26082
|
-
agent: args.agent
|
|
26244
|
+
agent: args.agent,
|
|
26245
|
+
sourceAgent
|
|
26083
26246
|
});
|
|
26084
26247
|
if (!target) {
|
|
26085
|
-
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}`));
|
|
26086
26249
|
}
|
|
26087
|
-
const binding2 = input.bindings.get(ctx.sessionID);
|
|
26088
26250
|
if (isSelfDelegate(binding2, target.canonicalAgentId)) {
|
|
26089
26251
|
return stringifyDelegateTaskResult(createFailedResult(ctx.sessionID, "self_delegate_forbidden", "Do not delegate a CrewBee session back to the same active agent."));
|
|
26090
26252
|
}
|
|
@@ -26242,18 +26404,27 @@ function createSystemTransformHook(bindings, getLoadIssues = () => []) {
|
|
|
26242
26404
|
}
|
|
26243
26405
|
|
|
26244
26406
|
// src/adapters/opencode/tool-hooks.ts
|
|
26245
|
-
function
|
|
26246
|
-
|
|
26247
|
-
|
|
26248
|
-
|
|
26249
|
-
|
|
26250
|
-
|
|
26251
|
-
|
|
26252
|
-
|
|
26253
|
-
|
|
26254
|
-
|
|
26255
|
-
|
|
26256
|
-
|
|
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;
|
|
26257
26428
|
}
|
|
26258
26429
|
function buildRetryGuidance(result) {
|
|
26259
26430
|
if (!result.error_code) {
|
|
@@ -26316,24 +26487,15 @@ function withRetryGuidance(result) {
|
|
|
26316
26487
|
${guidance}` : guidance
|
|
26317
26488
|
};
|
|
26318
26489
|
}
|
|
26319
|
-
function createToolDefinitionHook(
|
|
26490
|
+
function createToolDefinitionHook(_getAgents) {
|
|
26320
26491
|
return async (input, output) => {
|
|
26321
26492
|
if (input.toolID !== "task") {
|
|
26322
26493
|
return;
|
|
26323
26494
|
}
|
|
26324
|
-
const helpLines = createProjectedAgentTaskAliasHelpLines(getAgents());
|
|
26325
|
-
if (helpLines.length === 0) {
|
|
26326
|
-
return;
|
|
26327
|
-
}
|
|
26328
|
-
output.description = deduplicateTaskDescription(output.description);
|
|
26329
26495
|
output.description = [
|
|
26330
|
-
|
|
26331
|
-
"",
|
|
26332
|
-
"CrewBee subagent aliases:",
|
|
26333
|
-
...helpLines,
|
|
26334
|
-
"",
|
|
26335
|
-
"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."
|
|
26336
26497
|
].join("\n");
|
|
26498
|
+
output.parameters = sanitizeNativeTaskParameters(output.parameters);
|
|
26337
26499
|
};
|
|
26338
26500
|
}
|
|
26339
26501
|
function createToolExecuteBeforeHook(input) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-merge.d.ts","sourceRoot":"","sources":["../../../../src/adapters/opencode/config-merge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAG7D,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,kBAAkB,EAC1B,KAAK,EAAE,wBAAwB,GAC9B,yBAAyB,
|
|
1
|
+
{"version":3,"file":"config-merge.d.ts","sourceRoot":"","sources":["../../../../src/adapters/opencode/config-merge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAG7D,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,kBAAkB,EAC1B,KAAK,EAAE,wBAAwB,GAC9B,yBAAyB,CAiD3B"}
|
|
@@ -4,6 +4,7 @@ exports.applyOpenCodeAgentConfigPatch = applyOpenCodeAgentConfigPatch;
|
|
|
4
4
|
const ownership_1 = require("./ownership");
|
|
5
5
|
function applyOpenCodeAgentConfigPatch(config, patch) {
|
|
6
6
|
const patchKeys = new Set(Object.keys(patch.agent));
|
|
7
|
+
const forceUpdateKeys = new Set(patch.forceUpdateAgentKeys ?? []);
|
|
7
8
|
const nextAgents = Object.fromEntries(Object.entries(config.agent ?? {}).filter(([key, definition]) => {
|
|
8
9
|
if ((0, ownership_1.isManagedCrewBeeAgentDefinition)(definition) && !patchKeys.has(key)) {
|
|
9
10
|
return false;
|
|
@@ -20,7 +21,7 @@ function applyOpenCodeAgentConfigPatch(config, patch) {
|
|
|
20
21
|
continue;
|
|
21
22
|
}
|
|
22
23
|
const existingDefinition = nextAgents[key];
|
|
23
|
-
if ((0, ownership_1.isManagedCrewBeeAgentDefinition)(existingDefinition)) {
|
|
24
|
+
if (forceUpdateKeys.has(key) || (0, ownership_1.isManagedCrewBeeAgentDefinition)(existingDefinition)) {
|
|
24
25
|
nextAgents[key] = definition;
|
|
25
26
|
updatedAgentKeys.push(key);
|
|
26
27
|
continue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-merge.js","sourceRoot":"","sources":["../../../../src/adapters/opencode/config-merge.ts"],"names":[],"mappings":";;AAeA,
|
|
1
|
+
{"version":3,"file":"config-merge.js","sourceRoot":"","sources":["../../../../src/adapters/opencode/config-merge.ts"],"names":[],"mappings":";;AAeA,sEAoDC;AAlED,2CAA8D;AAc9D,SAAgB,6BAA6B,CAC3C,MAA0B,EAC1B,KAA+B;IAE/B,MAAM,SAAS,GAAG,IAAI,GAAG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AC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IAED,MAAM,UAAU,GAAuB;QACrC,GAAG,MAAM;QACT,KAAK,EAAE,UAAU;KAClB,CAAC;IAEF,IAAI,KAAK,CAAC,YAAY,EAAE,CAAC;QACvB,UAAU,CAAC,aAAa,GAAG,KAAK,CAAC,YAAY,CAAC;IAChD,CAAC;IAED,OAAO;QACL,MAAM,EAAE,UAAU;QAClB,iBAAiB;QACjB,gBAAgB;QAChB,gBAAgB;KACjB,CAAC;AACJ,CAAC"}
|
|
@@ -5,6 +5,7 @@ export declare function resolveDelegateAgent(input: {
|
|
|
5
5
|
agents: OpenCodeAgentConfig[];
|
|
6
6
|
aliasIndex: Map<string, OpenCodeAgentAliasEntry>;
|
|
7
7
|
agent: string;
|
|
8
|
+
sourceAgent?: OpenCodeAgentConfig;
|
|
8
9
|
}): ResolvedDelegateAgent | undefined;
|
|
9
10
|
export declare function isSelfDelegate(binding: SessionRuntimeBinding | undefined, canonicalAgentId: string): boolean;
|
|
10
11
|
//# sourceMappingURL=resolve-agent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-agent.d.ts","sourceRoot":"","sources":["../../../../../src/adapters/opencode/delegation/resolve-agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,KAAK,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAMlF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAErD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE;IAC1C,MAAM,EAAE,mBAAmB,EAAE,CAAC;IAC9B,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC;IACjD,KAAK,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"resolve-agent.d.ts","sourceRoot":"","sources":["../../../../../src/adapters/opencode/delegation/resolve-agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,KAAK,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAMlF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAErD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE;IAC1C,MAAM,EAAE,mBAAmB,EAAE,CAAC;IAC9B,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC;IACjD,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,mBAAmB,CAAC;CACnC,GAAG,qBAAqB,GAAG,SAAS,CAsBpC;AAUD,wBAAgB,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,SAAS,EAAE,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAM5G"}
|
|
@@ -7,7 +7,7 @@ function resolveDelegateAgent(input) {
|
|
|
7
7
|
const bySelection = (0, projection_1.resolveProjectedAgentSelection)(input.agents, {
|
|
8
8
|
configKey: input.agent,
|
|
9
9
|
});
|
|
10
|
-
if (bySelection) {
|
|
10
|
+
if (bySelection && isAllowedDelegateTarget(input.sourceAgent, bySelection)) {
|
|
11
11
|
return {
|
|
12
12
|
agent: bySelection,
|
|
13
13
|
configKey: bySelection.configKey,
|
|
@@ -15,7 +15,7 @@ function resolveDelegateAgent(input) {
|
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
const byAlias = (0, projection_1.resolveProjectedAgentAlias)(input.aliasIndex, input.agent);
|
|
18
|
-
if (!byAlias) {
|
|
18
|
+
if (!byAlias || !isAllowedDelegateTarget(input.sourceAgent, byAlias.agent)) {
|
|
19
19
|
return undefined;
|
|
20
20
|
}
|
|
21
21
|
return {
|
|
@@ -24,6 +24,12 @@ function resolveDelegateAgent(input) {
|
|
|
24
24
|
canonicalAgentId: byAlias.agent.canonicalAgentId,
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
+
function isAllowedDelegateTarget(sourceAgent, targetAgent) {
|
|
28
|
+
if (!sourceAgent) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
return sourceAgent.delegation.allowedTargets.some((target) => target.configKey === targetAgent.configKey);
|
|
32
|
+
}
|
|
27
33
|
function isSelfDelegate(binding, canonicalAgentId) {
|
|
28
34
|
if (!binding) {
|
|
29
35
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-agent.js","sourceRoot":"","sources":["../../../../../src/adapters/opencode/delegation/resolve-agent.ts"],"names":[],"mappings":";;AASA,
|
|
1
|
+
{"version":3,"file":"resolve-agent.js","sourceRoot":"","sources":["../../../../../src/adapters/opencode/delegation/resolve-agent.ts"],"names":[],"mappings":";;AASA,oDA2BC;AAUD,wCAMC;AAlDD,8CAGuB;AAIvB,SAAgB,oBAAoB,CAAC,KAKpC;IACC,MAAM,WAAW,GAAG,IAAA,2CAA8B,EAAC,KAAK,CAAC,MAAM,EAAE;QAC/D,SAAS,EAAE,KAAK,CAAC,KAAK;KACvB,CAAC,CAAC;IACH,IAAI,WAAW,IAAI,uBAAuB,CAAC,KAAK,CAAC,WAAW,EAAE,WAAW,CAAC,EAAE,CAAC;QAC3E,OAAO;YACL,KAAK,EAAE,WAAW;YAClB,SAAS,EAAE,WAAW,CAAC,SAAS;YAChC,gBAAgB,EAAE,WAAW,CAAC,gBAAgB;SAC/C,CAAC;IACJ,CAAC;IAED,MAAM,OAAO,GAAG,IAAA,uCAA0B,EAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IAC1E,IAAI,CAAC,OAAO,IAAI,CAAC,uBAAuB,CAAC,KAAK,CAAC,WAAW,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3E,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO;QACL,KAAK,EAAE,OAAO,CAAC,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AE,UAAU,CAAC;IACnB,KAAK,EAAE,kBAAkB,CAAC;IAC1B,kBAAkB,IAAI,mBAAmB,EAAE,CAAC;IAC5C,aAAa,IAAI,GAAG,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC;IACtD,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;CAC9C;AAyJD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB;;;;;;;;;;;;;;;;EAuKlE"}
|
|
@@ -110,6 +110,14 @@ function launchBackground(input) {
|
|
|
110
110
|
input.store.setTaskStatus(input.taskRef, "failed", { lastError: String(error), message: String(error) });
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
|
+
function findBoundSourceAgent(input) {
|
|
114
|
+
if (!input.binding) {
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
117
|
+
return input.agents.find((agent) => {
|
|
118
|
+
return agent.teamId === input.binding?.teamId && agent.canonicalAgentId === input.binding.selectedAgentId;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
113
121
|
function createDelegateTools(input) {
|
|
114
122
|
const delegate_task = createToolDefinition({
|
|
115
123
|
description: "Delegate work to a CrewBee team member.",
|
|
@@ -130,15 +138,18 @@ function createDelegateTools(input) {
|
|
|
130
138
|
if (mode !== "foreground" && mode !== "background") {
|
|
131
139
|
return (0, tool_result_1.stringifyDelegateTaskResult)((0, tool_result_1.createFailedResult)(ctx.sessionID, "unsupported_mode", "Use mode=foreground or mode=background."));
|
|
132
140
|
}
|
|
141
|
+
const projectedAgents = input.getProjectedAgents();
|
|
142
|
+
const binding = input.bindings.get(ctx.sessionID);
|
|
143
|
+
const sourceAgent = findBoundSourceAgent({ agents: projectedAgents, binding });
|
|
133
144
|
const target = (0, resolve_agent_1.resolveDelegateAgent)({
|
|
134
|
-
agents:
|
|
145
|
+
agents: projectedAgents,
|
|
135
146
|
aliasIndex: input.getAliasIndex(),
|
|
136
147
|
agent: args.agent,
|
|
148
|
+
sourceAgent,
|
|
137
149
|
});
|
|
138
150
|
if (!target) {
|
|
139
|
-
return (0, tool_result_1.stringifyDelegateTaskResult)((0, tool_result_1.createFailedResult)(ctx.sessionID, "unknown_agent", `Unknown CrewBee
|
|
151
|
+
return (0, tool_result_1.stringifyDelegateTaskResult)((0, tool_result_1.createFailedResult)(ctx.sessionID, "unknown_agent", `Unknown or disallowed CrewBee delegate target: ${args.agent}`));
|
|
140
152
|
}
|
|
141
|
-
const binding = input.bindings.get(ctx.sessionID);
|
|
142
153
|
if ((0, resolve_agent_1.isSelfDelegate)(binding, target.canonicalAgentId)) {
|
|
143
154
|
return (0, tool_result_1.stringifyDelegateTaskResult)((0, tool_result_1.createFailedResult)(ctx.sessionID, "self_delegate_forbidden", "Do not delegate a CrewBee session back to the same active agent."));
|
|
144
155
|
}
|