crewbee 0.1.13 → 0.1.15
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 +1 -1
- package/README.zh-CN.md +1 -1
- package/dist/opencode-plugin.mjs +317 -125
- 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 +5 -7
- package/dist/src/adapters/opencode/delegation/tools.d.ts.map +1 -1
- package/dist/src/adapters/opencode/delegation/tools.js +61 -26
- package/dist/src/adapters/opencode/delegation/tools.js.map +1 -1
- package/dist/src/adapters/opencode/delegation/types.d.ts +5 -0
- package/dist/src/adapters/opencode/delegation/types.d.ts.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 +1 -1
- package/dist/src/adapters/opencode/permission-mapper.d.ts.map +1 -1
- package/dist/src/adapters/opencode/permission-mapper.js +12 -2
- 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 +88 -2
- 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 -6
- package/dist/src/adapters/opencode/tool-hooks.d.ts.map +1 -1
- package/dist/src/adapters/opencode/tool-hooks.js +20 -43
- package/dist/src/adapters/opencode/tool-hooks.js.map +1 -1
- package/dist/src/agent-teams/embedded/coding-team/agents/coding-executor.js +2 -2
- package/dist/src/agent-teams/embedded/coding-team/agents/coding-executor.js.map +1 -1
- package/dist/src/agent-teams/embedded/coding-team/agents/coding-leader.d.ts.map +1 -1
- package/dist/src/agent-teams/embedded/coding-team/agents/coding-leader.js +2 -3
- package/dist/src/agent-teams/embedded/coding-team/agents/coding-leader.js.map +1 -1
- package/dist/src/agent-teams/embedded/coding-team/agents/coordination-leader.d.ts.map +1 -1
- package/dist/src/agent-teams/embedded/coding-team/agents/coordination-leader.js +2 -3
- package/dist/src/agent-teams/embedded/coding-team/agents/coordination-leader.js.map +1 -1
- package/dist/src/agent-teams/embedded/coding-team/agents/principal-advisor.d.ts.map +1 -1
- package/dist/src/agent-teams/embedded/coding-team/agents/principal-advisor.js +0 -1
- package/dist/src/agent-teams/embedded/coding-team/agents/principal-advisor.js.map +1 -1
- package/dist/src/agent-teams/embedded/coding-team/agents/reviewer.d.ts.map +1 -1
- package/dist/src/agent-teams/embedded/coding-team/agents/reviewer.js +1 -2
- package/dist/src/agent-teams/embedded/coding-team/agents/reviewer.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/dist/src/runtime/registries/plugin-tools.js +3 -3
- package/dist/src/runtime/registries/plugin-tools.js.map +1 -1
- package/package.json +1 -1
package/dist/opencode-plugin.mjs
CHANGED
|
@@ -7676,14 +7676,13 @@ function createCoordinationLeaderAgent() {
|
|
|
7676
7676
|
]
|
|
7677
7677
|
},
|
|
7678
7678
|
runtimeConfig: {
|
|
7679
|
-
requestedTools: ["read", "glob", "grep", "skill", "
|
|
7679
|
+
requestedTools: ["read", "glob", "grep", "skill", "task", "delegate_status", "delegate_cancel", "edit", "write", "bash", "lsp_diagnostics"],
|
|
7680
7680
|
permission: [
|
|
7681
7681
|
{ permission: "read", pattern: "*", action: "allow" },
|
|
7682
7682
|
{ permission: "glob", pattern: "*", action: "allow" },
|
|
7683
7683
|
{ permission: "grep", pattern: "*", action: "allow" },
|
|
7684
7684
|
{ permission: "skill", pattern: "*", action: "allow" },
|
|
7685
|
-
|
|
7686
|
-
{ permission: "delegate_task", pattern: "*", action: "allow" },
|
|
7685
|
+
{ permission: "task", pattern: "*", action: "allow" },
|
|
7687
7686
|
{ permission: "delegate_status", pattern: "*", action: "allow" },
|
|
7688
7687
|
{ permission: "delegate_cancel", pattern: "*", action: "allow" },
|
|
7689
7688
|
{ permission: "edit", pattern: "*", action: "allow" },
|
|
@@ -8026,7 +8025,7 @@ function createCodingExecutorAgent() {
|
|
|
8026
8025
|
],
|
|
8027
8026
|
outOfScope: [
|
|
8028
8027
|
"\u591A\u4EE3\u7406\u5B9E\u73B0\u7C7B\u59D4\u6D3E",
|
|
8029
|
-
"task tool
|
|
8028
|
+
"task tool \u7C7B\u7F16\u6392",
|
|
8030
8029
|
"\u7EAF\u89C4\u5212\u5DE5\u4F5C",
|
|
8031
8030
|
"\u672A\u7ECF\u660E\u786E\u8BF7\u6C42\u7684\u63D0\u4EA4",
|
|
8032
8031
|
"\u7528\u7C7B\u578B\u538B\u5236\u3001\u8DF3\u8FC7\u9A8C\u8BC1\u6216\u5220\u9664\u6D4B\u8BD5\u6765\u4F2A\u9020\u5B8C\u6210"
|
|
@@ -8088,7 +8087,7 @@ function createCodingExecutorAgent() {
|
|
|
8088
8087
|
},
|
|
8089
8088
|
guardrails: {
|
|
8090
8089
|
critical: [
|
|
8091
|
-
"\u7981\u6B62 task tool
|
|
8090
|
+
"\u7981\u6B62 task tool \u7C7B\u5B9E\u73B0\u7F16\u6392\u3002",
|
|
8092
8091
|
"\u7814\u7A76\u53EF\u4EE5\u501F\u52A9\u5916\u90E8\u89D2\u8272\uFF0C\u6267\u884C\u4E0D\u53EF\u4EE5\u5916\u5305\u3002",
|
|
8093
8092
|
"\u591A\u6B65\u9AA4\u4EFB\u52A1\u6CA1\u6709 todo = \u672A\u5B8C\u6210\u3002",
|
|
8094
8093
|
"\u6CA1\u6709\u9A8C\u8BC1\u8BC1\u636E = \u672A\u5B8C\u6210\u3002",
|
|
@@ -8238,14 +8237,13 @@ function createCodingLeaderAgent() {
|
|
|
8238
8237
|
]
|
|
8239
8238
|
},
|
|
8240
8239
|
runtimeConfig: {
|
|
8241
|
-
requestedTools: ["read", "glob", "grep", "skill", "
|
|
8240
|
+
requestedTools: ["read", "glob", "grep", "skill", "task", "delegate_status", "delegate_cancel", "edit", "write", "bash", "lsp_diagnostics"],
|
|
8242
8241
|
permission: [
|
|
8243
8242
|
{ permission: "read", pattern: "*", action: "allow" },
|
|
8244
8243
|
{ permission: "glob", pattern: "*", action: "allow" },
|
|
8245
8244
|
{ permission: "grep", pattern: "*", action: "allow" },
|
|
8246
8245
|
{ permission: "skill", pattern: "*", action: "allow" },
|
|
8247
|
-
|
|
8248
|
-
{ permission: "delegate_task", pattern: "*", action: "allow" },
|
|
8246
|
+
{ permission: "task", pattern: "*", action: "allow" },
|
|
8249
8247
|
{ permission: "delegate_status", pattern: "*", action: "allow" },
|
|
8250
8248
|
{ permission: "delegate_cancel", pattern: "*", action: "allow" },
|
|
8251
8249
|
{ permission: "edit", pattern: "*", action: "allow" },
|
|
@@ -8752,7 +8750,6 @@ function createPrincipalAdvisorAgent() {
|
|
|
8752
8750
|
{ permission: "webfetch", pattern: "*", action: "allow" },
|
|
8753
8751
|
{ permission: "websearch", pattern: "*", action: "allow" },
|
|
8754
8752
|
{ permission: "task", pattern: "*", action: "allow" },
|
|
8755
|
-
{ permission: "delegate_task", pattern: "*", action: "deny" },
|
|
8756
8753
|
{ permission: "delegate_status", pattern: "*", action: "deny" },
|
|
8757
8754
|
{ permission: "delegate_cancel", pattern: "*", action: "deny" },
|
|
8758
8755
|
{ permission: "edit", pattern: "*", action: "deny" },
|
|
@@ -9034,8 +9031,7 @@ function createReviewerAgent() {
|
|
|
9034
9031
|
{ permission: "read", pattern: "*", action: "allow" },
|
|
9035
9032
|
{ permission: "glob", pattern: "*", action: "allow" },
|
|
9036
9033
|
{ permission: "grep", pattern: "*", action: "allow" },
|
|
9037
|
-
|
|
9038
|
-
{ permission: "delegate_task", pattern: "*", action: "deny" },
|
|
9034
|
+
{ permission: "task", pattern: "*", action: "deny" },
|
|
9039
9035
|
{ permission: "delegate_status", pattern: "*", action: "deny" },
|
|
9040
9036
|
{ permission: "delegate_cancel", pattern: "*", action: "deny" },
|
|
9041
9037
|
{ permission: "lsp_diagnostics", pattern: "*", action: "allow" },
|
|
@@ -9940,6 +9936,18 @@ function asStringArray(value, label) {
|
|
|
9940
9936
|
}
|
|
9941
9937
|
return value.map((entry, index) => asString(entry, `${label}[${index}]`));
|
|
9942
9938
|
}
|
|
9939
|
+
function mapProviderOptions(record2) {
|
|
9940
|
+
const options = { ...asOptionalRecord(record2.options) ?? {} };
|
|
9941
|
+
const thinkingLevel = asOptionalString(record2.thinking_level ?? record2.thinkingLevel);
|
|
9942
|
+
const reasoningEffort = asOptionalString(record2.reasoning_effort ?? record2.reasoningEffort);
|
|
9943
|
+
if (thinkingLevel) {
|
|
9944
|
+
options.thinkingLevel = thinkingLevel;
|
|
9945
|
+
}
|
|
9946
|
+
if (reasoningEffort) {
|
|
9947
|
+
options.reasoningEffort = reasoningEffort;
|
|
9948
|
+
}
|
|
9949
|
+
return Object.keys(options).length > 0 ? options : void 0;
|
|
9950
|
+
}
|
|
9943
9951
|
function readTextFile(filePath) {
|
|
9944
9952
|
return readFileSync(filePath, "utf8");
|
|
9945
9953
|
}
|
|
@@ -10264,14 +10272,14 @@ function mapAgentRuntime(raw) {
|
|
|
10264
10272
|
return Object.fromEntries(
|
|
10265
10273
|
Object.entries(raw).map(([agentId, value]) => {
|
|
10266
10274
|
const record2 = asRecord(value, `agent_runtime.${agentId}`);
|
|
10267
|
-
const options =
|
|
10275
|
+
const options = mapProviderOptions(record2);
|
|
10268
10276
|
const runtime = {
|
|
10269
10277
|
provider: record2.provider !== void 0 ? asString(record2.provider, `agent_runtime.${agentId}.provider`) : void 0,
|
|
10270
10278
|
model: asString(record2.model, `agent_runtime.${agentId}.model`),
|
|
10271
10279
|
temperature: record2.temperature !== void 0 ? Number(record2.temperature) : void 0,
|
|
10272
10280
|
topP: record2.top_p !== void 0 || record2.topP !== void 0 ? Number(record2.top_p ?? record2.topP) : void 0,
|
|
10273
10281
|
variant: asOptionalString(record2.variant),
|
|
10274
|
-
options
|
|
10282
|
+
options,
|
|
10275
10283
|
fallbackModels: record2.fallback_models || record2.fallbackModels ? asStringArray(record2.fallback_models ?? record2.fallbackModels, `agent_runtime.${agentId}.fallback_models`) : void 0,
|
|
10276
10284
|
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
10285
|
};
|
|
@@ -10532,6 +10540,21 @@ function getOptionalPriority(value, fallback) {
|
|
|
10532
10540
|
function getOptionalString(value) {
|
|
10533
10541
|
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
10534
10542
|
}
|
|
10543
|
+
function getOptionalRecord(value) {
|
|
10544
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
10545
|
+
}
|
|
10546
|
+
function createProviderOptionOverrides(raw) {
|
|
10547
|
+
const options = { ...getOptionalRecord(raw.options) ?? {} };
|
|
10548
|
+
const thinkingLevel = getOptionalString(raw.thinkingLevel ?? raw.thinking_level);
|
|
10549
|
+
const reasoningEffort = getOptionalString(raw.reasoningEffort ?? raw.reasoning_effort);
|
|
10550
|
+
if (thinkingLevel) {
|
|
10551
|
+
options.thinkingLevel = thinkingLevel;
|
|
10552
|
+
}
|
|
10553
|
+
if (reasoningEffort) {
|
|
10554
|
+
options.reasoningEffort = reasoningEffort;
|
|
10555
|
+
}
|
|
10556
|
+
return Object.keys(options).length > 0 ? options : void 0;
|
|
10557
|
+
}
|
|
10535
10558
|
function normalizeConfiguredTeamModelOverride(raw) {
|
|
10536
10559
|
const modelPreset = getOptionalString(raw.model_preset ?? raw.modelPreset);
|
|
10537
10560
|
const fallback = getOptionalString(raw.fallback);
|
|
@@ -10543,7 +10566,13 @@ function normalizeConfiguredTeamModelOverride(raw) {
|
|
|
10543
10566
|
return [];
|
|
10544
10567
|
}
|
|
10545
10568
|
const model = getOptionalString(value.model);
|
|
10546
|
-
|
|
10569
|
+
const variant = getOptionalString(value.variant);
|
|
10570
|
+
const options = createProviderOptionOverrides(value);
|
|
10571
|
+
return [[agentId, {
|
|
10572
|
+
...model ? { model } : {},
|
|
10573
|
+
...variant ? { variant } : {},
|
|
10574
|
+
...options ? { options } : {}
|
|
10575
|
+
}]];
|
|
10547
10576
|
})
|
|
10548
10577
|
) : void 0;
|
|
10549
10578
|
const normalizedAgents = agents && Object.keys(agents).length > 0 ? agents : void 0;
|
|
@@ -11803,12 +11832,12 @@ function pickDefaultUserSelectableAgent(team) {
|
|
|
11803
11832
|
|
|
11804
11833
|
// src/runtime/registries/plugin-tools.ts
|
|
11805
11834
|
var CREWBEE_PLUGIN_TOOLS = {
|
|
11806
|
-
|
|
11807
|
-
id: "
|
|
11835
|
+
task: {
|
|
11836
|
+
id: "task",
|
|
11808
11837
|
source: "crewbee-plugin",
|
|
11809
11838
|
status: "implemented",
|
|
11810
11839
|
visibility: "agent-addressable",
|
|
11811
|
-
description: "Delegate work to a CrewBee team member
|
|
11840
|
+
description: "Delegate work to a CrewBee team member through the OpenCode-compatible task tool.",
|
|
11812
11841
|
hostTargets: ["opencode"]
|
|
11813
11842
|
},
|
|
11814
11843
|
delegate_status: {
|
|
@@ -11929,6 +11958,7 @@ function createManagedCrewBeeAgentOptions(input) {
|
|
|
11929
11958
|
// src/adapters/opencode/config-merge.ts
|
|
11930
11959
|
function applyOpenCodeAgentConfigPatch(config2, patch) {
|
|
11931
11960
|
const patchKeys = new Set(Object.keys(patch.agent));
|
|
11961
|
+
const forceUpdateKeys = new Set(patch.forceUpdateAgentKeys ?? []);
|
|
11932
11962
|
const nextAgents = Object.fromEntries(
|
|
11933
11963
|
Object.entries(config2.agent ?? {}).filter(([key, definition]) => {
|
|
11934
11964
|
if (isManagedCrewBeeAgentDefinition(definition) && !patchKeys.has(key)) {
|
|
@@ -11947,7 +11977,7 @@ function applyOpenCodeAgentConfigPatch(config2, patch) {
|
|
|
11947
11977
|
continue;
|
|
11948
11978
|
}
|
|
11949
11979
|
const existingDefinition = nextAgents[key];
|
|
11950
|
-
if (isManagedCrewBeeAgentDefinition(existingDefinition)) {
|
|
11980
|
+
if (forceUpdateKeys.has(key) || isManagedCrewBeeAgentDefinition(existingDefinition)) {
|
|
11951
11981
|
nextAgents[key] = definition;
|
|
11952
11982
|
updatedAgentKeys.push(key);
|
|
11953
11983
|
continue;
|
|
@@ -11993,6 +12023,7 @@ var TOOL_MAP = {
|
|
|
11993
12023
|
patch: "edit",
|
|
11994
12024
|
multiedit: "edit",
|
|
11995
12025
|
lsp_diagnostics: "lsp",
|
|
12026
|
+
delegate_task: "task",
|
|
11996
12027
|
look_at: void 0
|
|
11997
12028
|
};
|
|
11998
12029
|
function mapOpenCodeToolName(toolId) {
|
|
@@ -12014,8 +12045,17 @@ function mapPermissionRulesWithAvailability(permissionRules, availableTools) {
|
|
|
12014
12045
|
};
|
|
12015
12046
|
}).filter((rule) => Boolean(rule)).filter((rule) => isAvailableTool(rule.permission, availableTools));
|
|
12016
12047
|
}
|
|
12017
|
-
function createOpenCodePermissionRules(agent, availableTools) {
|
|
12018
|
-
|
|
12048
|
+
function createOpenCodePermissionRules(agent, availableTools, allowedTaskTargets = []) {
|
|
12049
|
+
const mappedRules = mapPermissionRulesWithAvailability(agent.sourceAgent.runtimeConfig.permission, availableTools);
|
|
12050
|
+
const rules = mappedRules.filter((rule) => rule.permission !== "task");
|
|
12051
|
+
const taskAllowed = mappedRules.some((rule) => rule.permission === "task" && rule.action !== "deny");
|
|
12052
|
+
rules.push({ permission: "task", action: "deny", pattern: "*" });
|
|
12053
|
+
if (taskAllowed) {
|
|
12054
|
+
for (const target of allowedTaskTargets) {
|
|
12055
|
+
rules.push({ permission: "task", action: "allow", pattern: target });
|
|
12056
|
+
}
|
|
12057
|
+
}
|
|
12058
|
+
return rules;
|
|
12019
12059
|
}
|
|
12020
12060
|
function createOpenCodePermissionConfig(permissionRules) {
|
|
12021
12061
|
const permission = {};
|
|
@@ -12489,7 +12529,12 @@ function createCollaborationPromptValue(agent) {
|
|
|
12489
12529
|
};
|
|
12490
12530
|
return {
|
|
12491
12531
|
defaultConsults: agent.sourceAgent.collaboration.defaultConsults.map(mapBinding),
|
|
12492
|
-
defaultHandoffs: agent.sourceAgent.collaboration.defaultHandoffs.map(mapBinding)
|
|
12532
|
+
defaultHandoffs: agent.sourceAgent.collaboration.defaultHandoffs.map(mapBinding),
|
|
12533
|
+
delegationBoundary: [
|
|
12534
|
+
"Only delegate to agents explicitly listed in default_consults or default_handoffs for this Agent Profile.",
|
|
12535
|
+
"Do not delegate to host-provided agents, OpenCode built-in agents, agents from other Teams, or agents not listed here.",
|
|
12536
|
+
"Use the OpenCode-compatible CrewBee task tool for delegation; it is implemented by CrewBee and constrained by this Team boundary."
|
|
12537
|
+
]
|
|
12493
12538
|
};
|
|
12494
12539
|
}
|
|
12495
12540
|
function renderPart(title, body) {
|
|
@@ -12537,6 +12582,32 @@ function resolveRuntimeModelId(runtime) {
|
|
|
12537
12582
|
}
|
|
12538
12583
|
return runtime.provider ? `${runtime.provider}/${runtime.model}` : runtime.model;
|
|
12539
12584
|
}
|
|
12585
|
+
function mergeModelOptions(baseOptions, overrideOptions) {
|
|
12586
|
+
const merged = {
|
|
12587
|
+
...baseOptions ?? {},
|
|
12588
|
+
...overrideOptions ?? {}
|
|
12589
|
+
};
|
|
12590
|
+
return Object.keys(merged).length > 0 ? merged : void 0;
|
|
12591
|
+
}
|
|
12592
|
+
function applyAgentModelOverride(runtime, override) {
|
|
12593
|
+
if (!override) {
|
|
12594
|
+
return runtime;
|
|
12595
|
+
}
|
|
12596
|
+
const model = override.model ?? runtime?.model;
|
|
12597
|
+
if (!model) {
|
|
12598
|
+
return runtime;
|
|
12599
|
+
}
|
|
12600
|
+
return {
|
|
12601
|
+
provider: runtime?.provider,
|
|
12602
|
+
model,
|
|
12603
|
+
temperature: runtime?.temperature,
|
|
12604
|
+
topP: runtime?.topP,
|
|
12605
|
+
variant: override.variant ?? runtime?.variant,
|
|
12606
|
+
options: mergeModelOptions(runtime?.options, override.options),
|
|
12607
|
+
fallbackModels: runtime?.fallbackModels,
|
|
12608
|
+
fallbackToHostDefault: runtime?.fallbackToHostDefault
|
|
12609
|
+
};
|
|
12610
|
+
}
|
|
12540
12611
|
function parseProviderModel(model) {
|
|
12541
12612
|
const separator = model.indexOf("/");
|
|
12542
12613
|
if (separator <= 0 || separator >= model.length - 1) {
|
|
@@ -12573,16 +12644,28 @@ function createHostDefaultTrace(input) {
|
|
|
12573
12644
|
function appendConfiguredModelCandidate(input) {
|
|
12574
12645
|
const runtimeModel = resolveRuntimeModelId(input.runtime);
|
|
12575
12646
|
const defaultRuntimeModel = resolveRuntimeModelId(input.defaultRuntime);
|
|
12576
|
-
if (input.
|
|
12577
|
-
appendUniqueCandidate(input.candidates, {
|
|
12647
|
+
if (input.agentOverride?.model) {
|
|
12648
|
+
appendUniqueCandidate(input.candidates, {
|
|
12649
|
+
model: input.agentOverride.model,
|
|
12650
|
+
source: "crewbee-json",
|
|
12651
|
+
runtime: applyAgentModelOverride(input.runtime ?? input.defaultRuntime, input.agentOverride)
|
|
12652
|
+
});
|
|
12578
12653
|
return;
|
|
12579
12654
|
}
|
|
12580
12655
|
if (runtimeModel) {
|
|
12581
|
-
appendUniqueCandidate(input.candidates, {
|
|
12656
|
+
appendUniqueCandidate(input.candidates, {
|
|
12657
|
+
model: runtimeModel,
|
|
12658
|
+
source: "team-manifest",
|
|
12659
|
+
runtime: applyAgentModelOverride(input.runtime, input.agentOverride)
|
|
12660
|
+
});
|
|
12582
12661
|
return;
|
|
12583
12662
|
}
|
|
12584
12663
|
if (defaultRuntimeModel) {
|
|
12585
|
-
appendUniqueCandidate(input.candidates, {
|
|
12664
|
+
appendUniqueCandidate(input.candidates, {
|
|
12665
|
+
model: defaultRuntimeModel,
|
|
12666
|
+
source: "team-manifest-default",
|
|
12667
|
+
runtime: applyAgentModelOverride(input.defaultRuntime, input.agentOverride)
|
|
12668
|
+
});
|
|
12586
12669
|
}
|
|
12587
12670
|
}
|
|
12588
12671
|
function resolveAgentModel(input) {
|
|
@@ -12591,6 +12674,8 @@ function resolveAgentModel(input) {
|
|
|
12591
12674
|
const agentOverride = teamOverride?.agents?.[agent.canonicalAgentId];
|
|
12592
12675
|
const runtime = agent.sourceTeam.manifest.agentRuntime?.[agent.canonicalAgentId];
|
|
12593
12676
|
const defaultRuntime = agent.sourceTeam.manifest.agentRuntime?.$default;
|
|
12677
|
+
const runtimeWithOverride = applyAgentModelOverride(runtime, agentOverride);
|
|
12678
|
+
const defaultRuntimeWithOverride = applyAgentModelOverride(defaultRuntime, agentOverride);
|
|
12594
12679
|
const fallbackStrategy = teamOverride?.fallback ?? (agent.teamId === BUILTIN_CODING_TEAM_ID ? BUILTIN_CODING_TEAM_MODEL_FALLBACK : TEAM_MANIFEST_FALLBACK_STRATEGY);
|
|
12595
12680
|
const fallbackToHostDefault = teamOverride?.fallbackToHostDefault ?? runtime?.fallbackToHostDefault ?? defaultRuntime?.fallbackToHostDefault ?? true;
|
|
12596
12681
|
const runtimeModel = resolveRuntimeModelId(runtime);
|
|
@@ -12598,9 +12683,9 @@ function resolveAgentModel(input) {
|
|
|
12598
12683
|
const candidates = [];
|
|
12599
12684
|
appendConfiguredModelCandidate({
|
|
12600
12685
|
candidates,
|
|
12601
|
-
|
|
12602
|
-
runtime,
|
|
12603
|
-
defaultRuntime
|
|
12686
|
+
agentOverride,
|
|
12687
|
+
runtime: runtimeWithOverride,
|
|
12688
|
+
defaultRuntime: defaultRuntimeWithOverride
|
|
12604
12689
|
});
|
|
12605
12690
|
if (agentOverride?.model === HOST_DEFAULT_MODEL_ID || !agentOverride?.model && runtimeModel === HOST_DEFAULT_MODEL_ID) {
|
|
12606
12691
|
return {
|
|
@@ -12618,11 +12703,11 @@ function resolveAgentModel(input) {
|
|
|
12618
12703
|
const sourceAgentId = agent.sourceAgent.metadata.sourceId ?? agent.canonicalAgentId;
|
|
12619
12704
|
if (fallbackStrategy === BUILTIN_CODING_TEAM_MODEL_FALLBACK && agent.teamId === BUILTIN_CODING_TEAM_ID) {
|
|
12620
12705
|
for (const model of BUILTIN_ROLE_FALLBACKS[sourceAgentId] ?? BUILTIN_ROLE_FALLBACKS[agent.canonicalAgentId] ?? []) {
|
|
12621
|
-
appendUniqueCandidate(candidates, { model, source: "builtin-role-chain", runtime });
|
|
12706
|
+
appendUniqueCandidate(candidates, { model, source: "builtin-role-chain", runtime: runtimeWithOverride });
|
|
12622
12707
|
}
|
|
12623
12708
|
} else {
|
|
12624
|
-
for (const model of
|
|
12625
|
-
appendUniqueCandidate(candidates, { model, source: "team-manifest", runtime });
|
|
12709
|
+
for (const model of runtimeWithOverride?.fallbackModels ?? defaultRuntimeWithOverride?.fallbackModels ?? []) {
|
|
12710
|
+
appendUniqueCandidate(candidates, { model, source: "team-manifest", runtime: runtimeWithOverride ?? defaultRuntimeWithOverride });
|
|
12626
12711
|
}
|
|
12627
12712
|
}
|
|
12628
12713
|
const availableModels = input.availableModels ? new Set(input.availableModels) : void 0;
|
|
@@ -12690,6 +12775,40 @@ function resolveAgentModel(input) {
|
|
|
12690
12775
|
function createOpenCodeConfigKey(agent) {
|
|
12691
12776
|
return agent.canonicalAgentId;
|
|
12692
12777
|
}
|
|
12778
|
+
function resolveTeamAgentByRef(agent, agentRef) {
|
|
12779
|
+
return agent.sourceTeam.agents.find((candidate) => {
|
|
12780
|
+
return candidate.metadata.id === agentRef || candidate.canonicalAgentId === agentRef;
|
|
12781
|
+
});
|
|
12782
|
+
}
|
|
12783
|
+
function createDelegationPolicy(agent) {
|
|
12784
|
+
const createTarget = (binding2, via) => {
|
|
12785
|
+
const agentRef = typeof binding2 === "string" ? binding2 : binding2.agentRef;
|
|
12786
|
+
const targetAgent = resolveTeamAgentByRef(agent, agentRef);
|
|
12787
|
+
if (!targetAgent) {
|
|
12788
|
+
return void 0;
|
|
12789
|
+
}
|
|
12790
|
+
const canonicalAgentId = targetAgent.canonicalAgentId ?? targetAgent.metadata.id;
|
|
12791
|
+
const member = agent.sourceTeam.manifest.members[targetAgent.metadata.id] ?? agent.sourceTeam.manifest.members[agentRef];
|
|
12792
|
+
return {
|
|
12793
|
+
configKey: canonicalAgentId,
|
|
12794
|
+
canonicalAgentId,
|
|
12795
|
+
sourceAgentId: targetAgent.metadata.id,
|
|
12796
|
+
description: member?.responsibility ?? targetAgent.responsibilityCore.description,
|
|
12797
|
+
via
|
|
12798
|
+
};
|
|
12799
|
+
};
|
|
12800
|
+
const targets = [
|
|
12801
|
+
...agent.sourceAgent.collaboration.defaultConsults.map((binding2) => createTarget(binding2, "consult")),
|
|
12802
|
+
...agent.sourceAgent.collaboration.defaultHandoffs.map((binding2) => createTarget(binding2, "handoff"))
|
|
12803
|
+
].filter((target) => Boolean(target));
|
|
12804
|
+
const deduped = /* @__PURE__ */ new Map();
|
|
12805
|
+
for (const target of targets) {
|
|
12806
|
+
if (!deduped.has(target.configKey)) {
|
|
12807
|
+
deduped.set(target.configKey, target);
|
|
12808
|
+
}
|
|
12809
|
+
}
|
|
12810
|
+
return { allowedTargets: [...deduped.values()] };
|
|
12811
|
+
}
|
|
12693
12812
|
function createOpenCodeAgentConfig(agent, options = {}) {
|
|
12694
12813
|
const runtimeConfig = agent.sourceAgent.runtimeConfig;
|
|
12695
12814
|
const modelResolution = resolveAgentModel({
|
|
@@ -12708,7 +12827,11 @@ function createOpenCodeAgentConfig(agent, options = {}) {
|
|
|
12708
12827
|
hidden: agent.exposure !== "user-selectable",
|
|
12709
12828
|
description: agent.description,
|
|
12710
12829
|
prompt: createOpenCodeAgentPrompt(agent, requestedTools),
|
|
12711
|
-
permission: createOpenCodePermissionRules(
|
|
12830
|
+
permission: createOpenCodePermissionRules(
|
|
12831
|
+
agent,
|
|
12832
|
+
availableToolContext,
|
|
12833
|
+
createDelegationPolicy(agent).allowedTargets.map((target) => target.configKey)
|
|
12834
|
+
),
|
|
12712
12835
|
runtimeConfig: {
|
|
12713
12836
|
requestedTools,
|
|
12714
12837
|
permission: runtimeConfig.permission,
|
|
@@ -12727,6 +12850,7 @@ function createOpenCodeAgentConfig(agent, options = {}) {
|
|
|
12727
12850
|
availabilitySource: availableToolContext.source,
|
|
12728
12851
|
availabilityIsExplicit: availableToolContext.hasExplicitTools
|
|
12729
12852
|
},
|
|
12853
|
+
delegation: createDelegationPolicy(agent),
|
|
12730
12854
|
metadata: {
|
|
12731
12855
|
teamId: agent.teamId,
|
|
12732
12856
|
teamName: agent.teamName,
|
|
@@ -12765,11 +12889,62 @@ function createOpenCodeProjectedIdentities(agent) {
|
|
|
12765
12889
|
}];
|
|
12766
12890
|
}
|
|
12767
12891
|
function createOpenCodeAgentConfigPatch(input) {
|
|
12892
|
+
const disabledHostAgents = {
|
|
12893
|
+
build: {
|
|
12894
|
+
name: "build",
|
|
12895
|
+
description: "Disabled by CrewBee while a CrewBee Agent Team owns the session.",
|
|
12896
|
+
mode: "subagent",
|
|
12897
|
+
disable: true,
|
|
12898
|
+
tools: {},
|
|
12899
|
+
prompt: "",
|
|
12900
|
+
permission: {}
|
|
12901
|
+
},
|
|
12902
|
+
plan: {
|
|
12903
|
+
name: "plan",
|
|
12904
|
+
description: "Disabled by CrewBee while a CrewBee Agent Team owns the session.",
|
|
12905
|
+
mode: "subagent",
|
|
12906
|
+
disable: true,
|
|
12907
|
+
tools: {},
|
|
12908
|
+
prompt: "",
|
|
12909
|
+
permission: {}
|
|
12910
|
+
},
|
|
12911
|
+
general: {
|
|
12912
|
+
name: "general",
|
|
12913
|
+
description: "Disabled by CrewBee while a CrewBee Agent Team owns the session.",
|
|
12914
|
+
mode: "subagent",
|
|
12915
|
+
disable: true,
|
|
12916
|
+
tools: {},
|
|
12917
|
+
prompt: "",
|
|
12918
|
+
permission: {}
|
|
12919
|
+
},
|
|
12920
|
+
explore: {
|
|
12921
|
+
name: "explore",
|
|
12922
|
+
description: "Disabled by CrewBee while a CrewBee Agent Team owns the session.",
|
|
12923
|
+
mode: "subagent",
|
|
12924
|
+
disable: true,
|
|
12925
|
+
tools: {},
|
|
12926
|
+
prompt: "",
|
|
12927
|
+
permission: {}
|
|
12928
|
+
},
|
|
12929
|
+
scout: {
|
|
12930
|
+
name: "scout",
|
|
12931
|
+
description: "Disabled by CrewBee while a CrewBee Agent Team owns the session.",
|
|
12932
|
+
mode: "subagent",
|
|
12933
|
+
disable: true,
|
|
12934
|
+
tools: {},
|
|
12935
|
+
prompt: "",
|
|
12936
|
+
permission: {}
|
|
12937
|
+
}
|
|
12938
|
+
};
|
|
12768
12939
|
return {
|
|
12769
|
-
agent:
|
|
12770
|
-
|
|
12771
|
-
|
|
12772
|
-
|
|
12940
|
+
agent: {
|
|
12941
|
+
...Object.fromEntries(
|
|
12942
|
+
input.agents.map((agent) => [agent.configKey, createOpenCodeAgentDefinition(agent)])
|
|
12943
|
+
),
|
|
12944
|
+
...disabledHostAgents
|
|
12945
|
+
},
|
|
12946
|
+
defaultAgent: input.defaultAgentConfigKey,
|
|
12947
|
+
forceUpdateAgentKeys: Object.keys(disabledHostAgents)
|
|
12773
12948
|
};
|
|
12774
12949
|
}
|
|
12775
12950
|
function findProjectedAgentByConfigKey(agents, configKey) {
|
|
@@ -12809,11 +12984,6 @@ function resolveProjectedAgentAlias(index, alias) {
|
|
|
12809
12984
|
}
|
|
12810
12985
|
return index.get(normalizeAlias(alias));
|
|
12811
12986
|
}
|
|
12812
|
-
function createProjectedAgentTaskAliasHelpLines(agents) {
|
|
12813
|
-
return agents.map((agent) => {
|
|
12814
|
-
return `- ${agent.configKey}`;
|
|
12815
|
-
});
|
|
12816
|
-
}
|
|
12817
12987
|
|
|
12818
12988
|
// src/adapters/opencode/tool-domain.ts
|
|
12819
12989
|
function createOpenCodeToolDomainPlan() {
|
|
@@ -25897,7 +26067,7 @@ function resolveDelegateAgent(input) {
|
|
|
25897
26067
|
const bySelection = resolveProjectedAgentSelection(input.agents, {
|
|
25898
26068
|
configKey: input.agent
|
|
25899
26069
|
});
|
|
25900
|
-
if (bySelection) {
|
|
26070
|
+
if (bySelection && isAllowedDelegateTarget(input.sourceAgent, bySelection)) {
|
|
25901
26071
|
return {
|
|
25902
26072
|
agent: bySelection,
|
|
25903
26073
|
configKey: bySelection.configKey,
|
|
@@ -25905,7 +26075,7 @@ function resolveDelegateAgent(input) {
|
|
|
25905
26075
|
};
|
|
25906
26076
|
}
|
|
25907
26077
|
const byAlias = resolveProjectedAgentAlias(input.aliasIndex, input.agent);
|
|
25908
|
-
if (!byAlias) {
|
|
26078
|
+
if (!byAlias || !isAllowedDelegateTarget(input.sourceAgent, byAlias.agent)) {
|
|
25909
26079
|
return void 0;
|
|
25910
26080
|
}
|
|
25911
26081
|
return {
|
|
@@ -25914,6 +26084,12 @@ function resolveDelegateAgent(input) {
|
|
|
25914
26084
|
canonicalAgentId: byAlias.agent.canonicalAgentId
|
|
25915
26085
|
};
|
|
25916
26086
|
}
|
|
26087
|
+
function isAllowedDelegateTarget(sourceAgent, targetAgent) {
|
|
26088
|
+
if (!sourceAgent) {
|
|
26089
|
+
return false;
|
|
26090
|
+
}
|
|
26091
|
+
return sourceAgent.delegation.allowedTargets.some((target) => target.configKey === targetAgent.configKey);
|
|
26092
|
+
}
|
|
25917
26093
|
function isSelfDelegate(binding2, canonicalAgentId) {
|
|
25918
26094
|
if (!binding2) {
|
|
25919
26095
|
return false;
|
|
@@ -25961,8 +26137,21 @@ function createDescription(prompt) {
|
|
|
25961
26137
|
const trimmed = prompt.trim().replace(/\s+/g, " ");
|
|
25962
26138
|
return trimmed.length <= 60 ? trimmed : `${trimmed.slice(0, 57)}...`;
|
|
25963
26139
|
}
|
|
26140
|
+
function resolveRequestedAgent(args) {
|
|
26141
|
+
return args.subagent_type ?? args.agent;
|
|
26142
|
+
}
|
|
26143
|
+
function resolveRequestedSessionID(args) {
|
|
26144
|
+
return args.task_id ?? args.session_id;
|
|
26145
|
+
}
|
|
26146
|
+
function resolveRequestedMode(args) {
|
|
26147
|
+
if (args.run_in_background === true) {
|
|
26148
|
+
return "background";
|
|
26149
|
+
}
|
|
26150
|
+
return args.mode ?? "foreground";
|
|
26151
|
+
}
|
|
25964
26152
|
async function resolveChildSession(input) {
|
|
25965
|
-
|
|
26153
|
+
const requestedSessionID = resolveRequestedSessionID(input.args);
|
|
26154
|
+
if (!requestedSessionID) {
|
|
25966
26155
|
const created = unwrapSdkResponse(await input.client.session.create({
|
|
25967
26156
|
body: { parentID: input.parentSessionID, title: input.title }
|
|
25968
26157
|
}));
|
|
@@ -25975,20 +26164,20 @@ async function resolveChildSession(input) {
|
|
|
25975
26164
|
});
|
|
25976
26165
|
return { sessionID, existing: false };
|
|
25977
26166
|
}
|
|
25978
|
-
const known = input.store.getSession(
|
|
26167
|
+
const known = input.store.getSession(requestedSessionID);
|
|
25979
26168
|
if (!known) {
|
|
25980
|
-
return createFailedResult(
|
|
26169
|
+
return createFailedResult(requestedSessionID, "invalid_session_id", "Use an existing task_id/session_id returned by task.");
|
|
25981
26170
|
}
|
|
25982
26171
|
if (known.parentSessionID !== input.parentSessionID) {
|
|
25983
|
-
return createFailedResult(
|
|
26172
|
+
return createFailedResult(requestedSessionID, "invalid_session_id", "Use a delegated task_id/session_id created from the current parent session.");
|
|
25984
26173
|
}
|
|
25985
26174
|
if (known.canonicalAgentId !== input.canonicalAgentId) {
|
|
25986
|
-
return createFailedResult(
|
|
26175
|
+
return createFailedResult(requestedSessionID, "agent_session_mismatch", "The delegated session is already bound to a different agent.");
|
|
25987
26176
|
}
|
|
25988
|
-
await input.client.session.get({ path: { id:
|
|
25989
|
-
throw createFailedResult(
|
|
26177
|
+
await input.client.session.get({ path: { id: requestedSessionID } }).catch(() => {
|
|
26178
|
+
throw createFailedResult(requestedSessionID, "invalid_session_id", "Use an existing task_id/session_id returned by task.");
|
|
25990
26179
|
});
|
|
25991
|
-
return { sessionID:
|
|
26180
|
+
return { sessionID: requestedSessionID, existing: true };
|
|
25992
26181
|
}
|
|
25993
26182
|
async function runForeground(input) {
|
|
25994
26183
|
const anchor = await getSessionAnchor(input.client, input.sessionID);
|
|
@@ -26012,10 +26201,11 @@ async function runForeground(input) {
|
|
|
26012
26201
|
const result = {
|
|
26013
26202
|
status: "completed",
|
|
26014
26203
|
session_id: input.sessionID,
|
|
26204
|
+
task_id: input.sessionID,
|
|
26015
26205
|
message,
|
|
26016
26206
|
resume_supported: true
|
|
26017
26207
|
};
|
|
26018
|
-
input.ctx.metadata({ title: input.title, metadata: { sessionId: input.sessionID, agent: input.target.canonicalAgentId } });
|
|
26208
|
+
input.ctx.metadata({ title: input.title, metadata: { sessionId: input.sessionID, taskId: input.sessionID, agent: input.target.canonicalAgentId, mode: "foreground" } });
|
|
26019
26209
|
return result;
|
|
26020
26210
|
}
|
|
26021
26211
|
function createBackgroundRecord(input) {
|
|
@@ -26054,41 +26244,54 @@ function launchBackground(input) {
|
|
|
26054
26244
|
input.store.setTaskStatus(input.taskRef, "failed", { lastError: String(error45), message: String(error45) });
|
|
26055
26245
|
});
|
|
26056
26246
|
}
|
|
26247
|
+
function findBoundSourceAgent(input) {
|
|
26248
|
+
if (!input.binding) {
|
|
26249
|
+
return void 0;
|
|
26250
|
+
}
|
|
26251
|
+
return input.agents.find((agent) => {
|
|
26252
|
+
return agent.teamId === input.binding?.teamId && agent.canonicalAgentId === input.binding.selectedAgentId;
|
|
26253
|
+
});
|
|
26254
|
+
}
|
|
26057
26255
|
function createDelegateTools(input) {
|
|
26058
|
-
const
|
|
26059
|
-
description: "Delegate work to a CrewBee team member.",
|
|
26256
|
+
const task = createToolDefinition({
|
|
26257
|
+
description: "Delegate work to a CrewBee team member. This is CrewBee's OpenCode-compatible task implementation; use subagent_type to select an allowed Team member.",
|
|
26060
26258
|
args: {
|
|
26061
|
-
|
|
26062
|
-
prompt: zod_default.string().describe("
|
|
26063
|
-
|
|
26064
|
-
|
|
26259
|
+
description: zod_default.string().optional().describe("A short (3-5 words) description of the task"),
|
|
26260
|
+
prompt: zod_default.string().describe("The task for the CrewBee agent to perform"),
|
|
26261
|
+
subagent_type: zod_default.string().describe("CrewBee agent id or alias listed in the current Agent Profile collaboration section"),
|
|
26262
|
+
task_id: zod_default.string().optional().describe("Existing delegated session to continue"),
|
|
26263
|
+
run_in_background: zod_default.boolean().optional().describe("Launch the delegated task in background mode")
|
|
26065
26264
|
},
|
|
26066
26265
|
async execute(args, ctx) {
|
|
26067
|
-
|
|
26068
|
-
|
|
26266
|
+
const requestedAgent = resolveRequestedAgent(args);
|
|
26267
|
+
if (!requestedAgent) {
|
|
26268
|
+
return stringifyDelegateTaskResult(createFailedResult(ctx.sessionID, "missing_agent", "Provide subagent_type when delegating work."));
|
|
26069
26269
|
}
|
|
26070
26270
|
if (input.store.getSession(ctx.sessionID)) {
|
|
26071
26271
|
return stringifyDelegateTaskResult(
|
|
26072
26272
|
createFailedResult(ctx.sessionID, "nested_delegate_forbidden", "Nested CrewBee delegation is disabled for delegated subagent sessions.")
|
|
26073
26273
|
);
|
|
26074
26274
|
}
|
|
26075
|
-
const mode = args
|
|
26275
|
+
const mode = resolveRequestedMode(args);
|
|
26076
26276
|
if (mode !== "foreground" && mode !== "background") {
|
|
26077
26277
|
return stringifyDelegateTaskResult(createFailedResult(ctx.sessionID, "unsupported_mode", "Use mode=foreground or mode=background."));
|
|
26078
26278
|
}
|
|
26279
|
+
const projectedAgents = input.getProjectedAgents();
|
|
26280
|
+
const binding2 = input.bindings.get(ctx.sessionID);
|
|
26281
|
+
const sourceAgent = findBoundSourceAgent({ agents: projectedAgents, binding: binding2 });
|
|
26079
26282
|
const target = resolveDelegateAgent({
|
|
26080
|
-
agents:
|
|
26283
|
+
agents: projectedAgents,
|
|
26081
26284
|
aliasIndex: input.getAliasIndex(),
|
|
26082
|
-
agent:
|
|
26285
|
+
agent: requestedAgent,
|
|
26286
|
+
sourceAgent
|
|
26083
26287
|
});
|
|
26084
26288
|
if (!target) {
|
|
26085
|
-
return stringifyDelegateTaskResult(createFailedResult(ctx.sessionID, "unknown_agent", `Unknown CrewBee
|
|
26289
|
+
return stringifyDelegateTaskResult(createFailedResult(ctx.sessionID, "unknown_agent", `Unknown or disallowed CrewBee delegate target: ${requestedAgent}`));
|
|
26086
26290
|
}
|
|
26087
|
-
const binding2 = input.bindings.get(ctx.sessionID);
|
|
26088
26291
|
if (isSelfDelegate(binding2, target.canonicalAgentId)) {
|
|
26089
26292
|
return stringifyDelegateTaskResult(createFailedResult(ctx.sessionID, "self_delegate_forbidden", "Do not delegate a CrewBee session back to the same active agent."));
|
|
26090
26293
|
}
|
|
26091
|
-
const title = createDelegatedTitle(target.canonicalAgentId, args.prompt);
|
|
26294
|
+
const title = args.description ?? createDelegatedTitle(target.canonicalAgentId, args.prompt);
|
|
26092
26295
|
const child = await resolveChildSession({
|
|
26093
26296
|
args,
|
|
26094
26297
|
client: input.client,
|
|
@@ -26128,6 +26331,7 @@ function createDelegateTools(input) {
|
|
|
26128
26331
|
anchor
|
|
26129
26332
|
});
|
|
26130
26333
|
input.store.putTask(record2);
|
|
26334
|
+
input.store.setTaskStatus(record2.taskRef, "running");
|
|
26131
26335
|
launchBackground({
|
|
26132
26336
|
args,
|
|
26133
26337
|
client: input.client,
|
|
@@ -26137,10 +26341,11 @@ function createDelegateTools(input) {
|
|
|
26137
26341
|
sessionID,
|
|
26138
26342
|
taskRef: record2.taskRef
|
|
26139
26343
|
});
|
|
26140
|
-
ctx.metadata({ title, metadata: { sessionId: sessionID, taskRef: record2.taskRef, agent: target.canonicalAgentId } });
|
|
26344
|
+
ctx.metadata({ title, metadata: { sessionId: sessionID, taskId: sessionID, taskRef: record2.taskRef, agent: target.canonicalAgentId, mode: "background" } });
|
|
26141
26345
|
return stringifyDelegateTaskResult({
|
|
26142
26346
|
status: "running",
|
|
26143
26347
|
session_id: sessionID,
|
|
26348
|
+
task_id: sessionID,
|
|
26144
26349
|
task_ref: record2.taskRef,
|
|
26145
26350
|
message: "Delegated session launched in background.",
|
|
26146
26351
|
resume_supported: true
|
|
@@ -26153,15 +26358,21 @@ function createDelegateTools(input) {
|
|
|
26153
26358
|
task_ref: zod_default.string().describe("CrewBee background task reference")
|
|
26154
26359
|
},
|
|
26155
26360
|
async execute(args) {
|
|
26156
|
-
|
|
26157
|
-
if (!
|
|
26361
|
+
let task2 = input.store.getTask(args.task_ref);
|
|
26362
|
+
if (!task2) {
|
|
26158
26363
|
return stringifyDelegateStatusResult({ status: "failed", task_ref: args.task_ref, message: "Unknown background task reference." });
|
|
26159
26364
|
}
|
|
26365
|
+
if (task2.status === "queued" || task2.status === "running") {
|
|
26366
|
+
const message = await extractAssistantText(input.client, task2.sessionID, task2.anchor).catch(() => void 0);
|
|
26367
|
+
if (message) {
|
|
26368
|
+
task2 = input.store.setTaskStatus(task2.taskRef, "completed", { message }) ?? task2;
|
|
26369
|
+
}
|
|
26370
|
+
}
|
|
26160
26371
|
return stringifyDelegateStatusResult({
|
|
26161
|
-
status:
|
|
26162
|
-
session_id:
|
|
26163
|
-
task_ref:
|
|
26164
|
-
message:
|
|
26372
|
+
status: task2.status,
|
|
26373
|
+
session_id: task2.sessionID,
|
|
26374
|
+
task_ref: task2.taskRef,
|
|
26375
|
+
message: task2.message
|
|
26165
26376
|
});
|
|
26166
26377
|
}
|
|
26167
26378
|
});
|
|
@@ -26171,37 +26382,37 @@ function createDelegateTools(input) {
|
|
|
26171
26382
|
task_ref: zod_default.string().describe("CrewBee background task reference")
|
|
26172
26383
|
},
|
|
26173
26384
|
async execute(args) {
|
|
26174
|
-
const
|
|
26175
|
-
if (!
|
|
26385
|
+
const task2 = input.store.getTask(args.task_ref);
|
|
26386
|
+
if (!task2) {
|
|
26176
26387
|
return stringifyDelegateCancelResult({ ok: false, task_ref: args.task_ref, message: "Unknown background task reference." });
|
|
26177
26388
|
}
|
|
26178
|
-
if (
|
|
26389
|
+
if (task2.status === "completed" || task2.status === "failed" || task2.status === "cancelled") {
|
|
26179
26390
|
return stringifyDelegateCancelResult({
|
|
26180
26391
|
ok: false,
|
|
26181
|
-
task_ref:
|
|
26182
|
-
session_id:
|
|
26183
|
-
message: `Task is already ${
|
|
26392
|
+
task_ref: task2.taskRef,
|
|
26393
|
+
session_id: task2.sessionID,
|
|
26394
|
+
message: `Task is already ${task2.status}.`
|
|
26184
26395
|
});
|
|
26185
26396
|
}
|
|
26186
|
-
const aborted2 = await input.client.session.abort({ path: { id:
|
|
26397
|
+
const aborted2 = await input.client.session.abort({ path: { id: task2.sessionID } }).then(() => true).catch(() => false);
|
|
26187
26398
|
if (!aborted2) {
|
|
26188
26399
|
return stringifyDelegateCancelResult({
|
|
26189
26400
|
ok: false,
|
|
26190
|
-
task_ref:
|
|
26191
|
-
session_id:
|
|
26401
|
+
task_ref: task2.taskRef,
|
|
26402
|
+
session_id: task2.sessionID,
|
|
26192
26403
|
message: "Failed to cancel the delegated session."
|
|
26193
26404
|
});
|
|
26194
26405
|
}
|
|
26195
|
-
input.store.setTaskStatus(
|
|
26406
|
+
input.store.setTaskStatus(task2.taskRef, "cancelled", { message: "Delegated session cancelled." });
|
|
26196
26407
|
return stringifyDelegateCancelResult({
|
|
26197
26408
|
ok: true,
|
|
26198
|
-
task_ref:
|
|
26199
|
-
session_id:
|
|
26409
|
+
task_ref: task2.taskRef,
|
|
26410
|
+
session_id: task2.sessionID,
|
|
26200
26411
|
message: "Delegated session cancelled."
|
|
26201
26412
|
});
|
|
26202
26413
|
}
|
|
26203
26414
|
});
|
|
26204
|
-
return {
|
|
26415
|
+
return { task, delegate_status, delegate_cancel };
|
|
26205
26416
|
}
|
|
26206
26417
|
|
|
26207
26418
|
// src/adapters/opencode/system-transform-hook.ts
|
|
@@ -26242,27 +26453,14 @@ function createSystemTransformHook(bindings, getLoadIssues = () => []) {
|
|
|
26242
26453
|
}
|
|
26243
26454
|
|
|
26244
26455
|
// src/adapters/opencode/tool-hooks.ts
|
|
26245
|
-
function deduplicateTaskDescription(description) {
|
|
26246
|
-
const seen = /* @__PURE__ */ new Set();
|
|
26247
|
-
return description.split("\n").filter((line) => {
|
|
26248
|
-
if (!line.startsWith("- ")) {
|
|
26249
|
-
return true;
|
|
26250
|
-
}
|
|
26251
|
-
if (seen.has(line)) {
|
|
26252
|
-
return false;
|
|
26253
|
-
}
|
|
26254
|
-
seen.add(line);
|
|
26255
|
-
return true;
|
|
26256
|
-
}).join("\n");
|
|
26257
|
-
}
|
|
26258
26456
|
function buildRetryGuidance(result) {
|
|
26259
26457
|
if (!result.error_code) {
|
|
26260
26458
|
return void 0;
|
|
26261
26459
|
}
|
|
26262
26460
|
const fixes = {
|
|
26263
|
-
missing_agent: 'Fix: include `
|
|
26264
|
-
unknown_agent: "Fix: use a valid CrewBee member id or projected alias
|
|
26265
|
-
invalid_session_id: "Fix: use a delegated `
|
|
26461
|
+
missing_agent: 'Fix: include `subagent_type="reviewer"` or another CrewBee member id.',
|
|
26462
|
+
unknown_agent: "Fix: use a valid CrewBee member id or projected alias as `subagent_type`.",
|
|
26463
|
+
invalid_session_id: "Fix: use a delegated `task_id` previously returned by `task`.",
|
|
26266
26464
|
agent_session_mismatch: "Fix: resume with the same agent that created the delegated session.",
|
|
26267
26465
|
unsupported_mode: 'Fix: use `mode="foreground"` or `mode="background"`.',
|
|
26268
26466
|
nested_delegate_forbidden: "Fix: return the result to the parent session instead of delegating again from a delegated subagent.",
|
|
@@ -26273,17 +26471,17 @@ function buildRetryGuidance(result) {
|
|
|
26273
26471
|
return void 0;
|
|
26274
26472
|
}
|
|
26275
26473
|
return [
|
|
26276
|
-
"[
|
|
26474
|
+
"[task CALL FAILED - RETRY REQUIRED]",
|
|
26277
26475
|
`Error: ${result.error_code}`,
|
|
26278
26476
|
fix,
|
|
26279
|
-
'Example:
|
|
26477
|
+
'Example: task(subagent_type="reviewer", prompt="continue review")'
|
|
26280
26478
|
].join("\n");
|
|
26281
26479
|
}
|
|
26282
26480
|
function withResumeHint(result) {
|
|
26283
26481
|
if (result.status === "failed" || !result.session_id || result.resume_hint) {
|
|
26284
26482
|
return result;
|
|
26285
26483
|
}
|
|
26286
|
-
const hint = `to continue:
|
|
26484
|
+
const hint = `to continue: task(task_id="${result.session_id}", subagent_type="${result.session_id ? "..." : "reviewer"}", prompt="...")`;
|
|
26287
26485
|
return {
|
|
26288
26486
|
...result,
|
|
26289
26487
|
resume_hint: hint,
|
|
@@ -26316,24 +26514,8 @@ function withRetryGuidance(result) {
|
|
|
26316
26514
|
${guidance}` : guidance
|
|
26317
26515
|
};
|
|
26318
26516
|
}
|
|
26319
|
-
function createToolDefinitionHook(
|
|
26320
|
-
return async (
|
|
26321
|
-
if (input.toolID !== "task") {
|
|
26322
|
-
return;
|
|
26323
|
-
}
|
|
26324
|
-
const helpLines = createProjectedAgentTaskAliasHelpLines(getAgents());
|
|
26325
|
-
if (helpLines.length === 0) {
|
|
26326
|
-
return;
|
|
26327
|
-
}
|
|
26328
|
-
output.description = deduplicateTaskDescription(output.description);
|
|
26329
|
-
output.description = [
|
|
26330
|
-
output.description,
|
|
26331
|
-
"",
|
|
26332
|
-
"CrewBee subagent aliases:",
|
|
26333
|
-
...helpLines,
|
|
26334
|
-
"",
|
|
26335
|
-
"When delegating inside CrewBee, prefer the CrewBee source-agent alias shown on each line."
|
|
26336
|
-
].join("\n");
|
|
26517
|
+
function createToolDefinitionHook(_getAgents) {
|
|
26518
|
+
return async () => {
|
|
26337
26519
|
};
|
|
26338
26520
|
}
|
|
26339
26521
|
function createToolExecuteBeforeHook(input) {
|
|
@@ -26353,14 +26535,24 @@ function createToolExecuteBeforeHook(input) {
|
|
|
26353
26535
|
}
|
|
26354
26536
|
function createToolExecuteAfterHook() {
|
|
26355
26537
|
return async (input, output) => {
|
|
26356
|
-
if (input.tool !== "
|
|
26538
|
+
if (input.tool !== "task") {
|
|
26357
26539
|
return;
|
|
26358
26540
|
}
|
|
26359
26541
|
const parsed = parseDelegateTaskResult(output.output);
|
|
26360
26542
|
if (!parsed) {
|
|
26361
26543
|
return;
|
|
26362
26544
|
}
|
|
26363
|
-
|
|
26545
|
+
const result = withResumeHint(withRetryGuidance(withEmptyWarning(parsed)));
|
|
26546
|
+
output.output = stringifyDelegateTaskResult(result);
|
|
26547
|
+
if (result.status !== "failed" && result.session_id) {
|
|
26548
|
+
output.title = output.title || "CrewBee task";
|
|
26549
|
+
output.metadata = {
|
|
26550
|
+
...output.metadata,
|
|
26551
|
+
sessionId: result.session_id,
|
|
26552
|
+
taskId: result.task_id ?? result.session_id,
|
|
26553
|
+
taskRef: result.task_ref
|
|
26554
|
+
};
|
|
26555
|
+
}
|
|
26364
26556
|
};
|
|
26365
26557
|
}
|
|
26366
26558
|
|