crewbee 0.1.14 → 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 +128 -98
- 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 +48 -24
- 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/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 +10 -3
- package/dist/src/adapters/opencode/permission-mapper.js.map +1 -1
- package/dist/src/adapters/opencode/projection.d.ts.map +1 -1
- package/dist/src/adapters/opencode/projection.js +19 -2
- package/dist/src/adapters/opencode/projection.js.map +1 -1
- package/dist/src/adapters/opencode/prompt-builder.js +1 -1
- 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 +19 -37
- 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/runtime/registries/plugin-tools.js +3 -3
- package/dist/src/runtime/registries/plugin-tools.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
package/README.zh-CN.md
CHANGED
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" },
|
|
@@ -11836,12 +11832,12 @@ function pickDefaultUserSelectableAgent(team) {
|
|
|
11836
11832
|
|
|
11837
11833
|
// src/runtime/registries/plugin-tools.ts
|
|
11838
11834
|
var CREWBEE_PLUGIN_TOOLS = {
|
|
11839
|
-
|
|
11840
|
-
id: "
|
|
11835
|
+
task: {
|
|
11836
|
+
id: "task",
|
|
11841
11837
|
source: "crewbee-plugin",
|
|
11842
11838
|
status: "implemented",
|
|
11843
11839
|
visibility: "agent-addressable",
|
|
11844
|
-
description: "Delegate work to a CrewBee team member
|
|
11840
|
+
description: "Delegate work to a CrewBee team member through the OpenCode-compatible task tool.",
|
|
11845
11841
|
hostTargets: ["opencode"]
|
|
11846
11842
|
},
|
|
11847
11843
|
delegate_status: {
|
|
@@ -12027,6 +12023,7 @@ var TOOL_MAP = {
|
|
|
12027
12023
|
patch: "edit",
|
|
12028
12024
|
multiedit: "edit",
|
|
12029
12025
|
lsp_diagnostics: "lsp",
|
|
12026
|
+
delegate_task: "task",
|
|
12030
12027
|
look_at: void 0
|
|
12031
12028
|
};
|
|
12032
12029
|
function mapOpenCodeToolName(toolId) {
|
|
@@ -12048,9 +12045,16 @@ function mapPermissionRulesWithAvailability(permissionRules, availableTools) {
|
|
|
12048
12045
|
};
|
|
12049
12046
|
}).filter((rule) => Boolean(rule)).filter((rule) => isAvailableTool(rule.permission, availableTools));
|
|
12050
12047
|
}
|
|
12051
|
-
function createOpenCodePermissionRules(agent, availableTools) {
|
|
12052
|
-
const
|
|
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");
|
|
12053
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
|
+
}
|
|
12054
12058
|
return rules;
|
|
12055
12059
|
}
|
|
12056
12060
|
function createOpenCodePermissionConfig(permissionRules) {
|
|
@@ -12529,7 +12533,7 @@ function createCollaborationPromptValue(agent) {
|
|
|
12529
12533
|
delegationBoundary: [
|
|
12530
12534
|
"Only delegate to agents explicitly listed in default_consults or default_handoffs for this Agent Profile.",
|
|
12531
12535
|
"Do not delegate to host-provided agents, OpenCode built-in agents, agents from other Teams, or agents not listed here.",
|
|
12532
|
-
"Use CrewBee
|
|
12536
|
+
"Use the OpenCode-compatible CrewBee task tool for delegation; it is implemented by CrewBee and constrained by this Team boundary."
|
|
12533
12537
|
]
|
|
12534
12538
|
};
|
|
12535
12539
|
}
|
|
@@ -12823,7 +12827,11 @@ function createOpenCodeAgentConfig(agent, options = {}) {
|
|
|
12823
12827
|
hidden: agent.exposure !== "user-selectable",
|
|
12824
12828
|
description: agent.description,
|
|
12825
12829
|
prompt: createOpenCodeAgentPrompt(agent, requestedTools),
|
|
12826
|
-
permission: createOpenCodePermissionRules(
|
|
12830
|
+
permission: createOpenCodePermissionRules(
|
|
12831
|
+
agent,
|
|
12832
|
+
availableToolContext,
|
|
12833
|
+
createDelegationPolicy(agent).allowedTargets.map((target) => target.configKey)
|
|
12834
|
+
),
|
|
12827
12835
|
runtimeConfig: {
|
|
12828
12836
|
requestedTools,
|
|
12829
12837
|
permission: runtimeConfig.permission,
|
|
@@ -12862,7 +12870,6 @@ function createOpenCodeAgentDefinition(agent) {
|
|
|
12862
12870
|
description: agent.description,
|
|
12863
12871
|
mode: agent.mode,
|
|
12864
12872
|
hidden: agent.hidden || void 0,
|
|
12865
|
-
tools: { task: false },
|
|
12866
12873
|
model: agent.resolvedModel ? `${agent.resolvedModel.providerID}/${agent.resolvedModel.modelID}` : void 0,
|
|
12867
12874
|
temperature: agent.resolvedModel?.temperature,
|
|
12868
12875
|
top_p: agent.resolvedModel?.topP,
|
|
@@ -12909,6 +12916,24 @@ function createOpenCodeAgentConfigPatch(input) {
|
|
|
12909
12916
|
tools: {},
|
|
12910
12917
|
prompt: "",
|
|
12911
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: {}
|
|
12912
12937
|
}
|
|
12913
12938
|
};
|
|
12914
12939
|
return {
|
|
@@ -26112,8 +26137,21 @@ function createDescription(prompt) {
|
|
|
26112
26137
|
const trimmed = prompt.trim().replace(/\s+/g, " ");
|
|
26113
26138
|
return trimmed.length <= 60 ? trimmed : `${trimmed.slice(0, 57)}...`;
|
|
26114
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
|
+
}
|
|
26115
26152
|
async function resolveChildSession(input) {
|
|
26116
|
-
|
|
26153
|
+
const requestedSessionID = resolveRequestedSessionID(input.args);
|
|
26154
|
+
if (!requestedSessionID) {
|
|
26117
26155
|
const created = unwrapSdkResponse(await input.client.session.create({
|
|
26118
26156
|
body: { parentID: input.parentSessionID, title: input.title }
|
|
26119
26157
|
}));
|
|
@@ -26126,20 +26164,20 @@ async function resolveChildSession(input) {
|
|
|
26126
26164
|
});
|
|
26127
26165
|
return { sessionID, existing: false };
|
|
26128
26166
|
}
|
|
26129
|
-
const known = input.store.getSession(
|
|
26167
|
+
const known = input.store.getSession(requestedSessionID);
|
|
26130
26168
|
if (!known) {
|
|
26131
|
-
return createFailedResult(
|
|
26169
|
+
return createFailedResult(requestedSessionID, "invalid_session_id", "Use an existing task_id/session_id returned by task.");
|
|
26132
26170
|
}
|
|
26133
26171
|
if (known.parentSessionID !== input.parentSessionID) {
|
|
26134
|
-
return createFailedResult(
|
|
26172
|
+
return createFailedResult(requestedSessionID, "invalid_session_id", "Use a delegated task_id/session_id created from the current parent session.");
|
|
26135
26173
|
}
|
|
26136
26174
|
if (known.canonicalAgentId !== input.canonicalAgentId) {
|
|
26137
|
-
return createFailedResult(
|
|
26175
|
+
return createFailedResult(requestedSessionID, "agent_session_mismatch", "The delegated session is already bound to a different agent.");
|
|
26138
26176
|
}
|
|
26139
|
-
await input.client.session.get({ path: { id:
|
|
26140
|
-
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.");
|
|
26141
26179
|
});
|
|
26142
|
-
return { sessionID:
|
|
26180
|
+
return { sessionID: requestedSessionID, existing: true };
|
|
26143
26181
|
}
|
|
26144
26182
|
async function runForeground(input) {
|
|
26145
26183
|
const anchor = await getSessionAnchor(input.client, input.sessionID);
|
|
@@ -26163,10 +26201,11 @@ async function runForeground(input) {
|
|
|
26163
26201
|
const result = {
|
|
26164
26202
|
status: "completed",
|
|
26165
26203
|
session_id: input.sessionID,
|
|
26204
|
+
task_id: input.sessionID,
|
|
26166
26205
|
message,
|
|
26167
26206
|
resume_supported: true
|
|
26168
26207
|
};
|
|
26169
|
-
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" } });
|
|
26170
26209
|
return result;
|
|
26171
26210
|
}
|
|
26172
26211
|
function createBackgroundRecord(input) {
|
|
@@ -26214,24 +26253,26 @@ function findBoundSourceAgent(input) {
|
|
|
26214
26253
|
});
|
|
26215
26254
|
}
|
|
26216
26255
|
function createDelegateTools(input) {
|
|
26217
|
-
const
|
|
26218
|
-
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.",
|
|
26219
26258
|
args: {
|
|
26220
|
-
|
|
26221
|
-
prompt: zod_default.string().describe("
|
|
26222
|
-
|
|
26223
|
-
|
|
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")
|
|
26224
26264
|
},
|
|
26225
26265
|
async execute(args, ctx) {
|
|
26226
|
-
|
|
26227
|
-
|
|
26266
|
+
const requestedAgent = resolveRequestedAgent(args);
|
|
26267
|
+
if (!requestedAgent) {
|
|
26268
|
+
return stringifyDelegateTaskResult(createFailedResult(ctx.sessionID, "missing_agent", "Provide subagent_type when delegating work."));
|
|
26228
26269
|
}
|
|
26229
26270
|
if (input.store.getSession(ctx.sessionID)) {
|
|
26230
26271
|
return stringifyDelegateTaskResult(
|
|
26231
26272
|
createFailedResult(ctx.sessionID, "nested_delegate_forbidden", "Nested CrewBee delegation is disabled for delegated subagent sessions.")
|
|
26232
26273
|
);
|
|
26233
26274
|
}
|
|
26234
|
-
const mode = args
|
|
26275
|
+
const mode = resolveRequestedMode(args);
|
|
26235
26276
|
if (mode !== "foreground" && mode !== "background") {
|
|
26236
26277
|
return stringifyDelegateTaskResult(createFailedResult(ctx.sessionID, "unsupported_mode", "Use mode=foreground or mode=background."));
|
|
26237
26278
|
}
|
|
@@ -26241,16 +26282,16 @@ function createDelegateTools(input) {
|
|
|
26241
26282
|
const target = resolveDelegateAgent({
|
|
26242
26283
|
agents: projectedAgents,
|
|
26243
26284
|
aliasIndex: input.getAliasIndex(),
|
|
26244
|
-
agent:
|
|
26285
|
+
agent: requestedAgent,
|
|
26245
26286
|
sourceAgent
|
|
26246
26287
|
});
|
|
26247
26288
|
if (!target) {
|
|
26248
|
-
return stringifyDelegateTaskResult(createFailedResult(ctx.sessionID, "unknown_agent", `Unknown or disallowed CrewBee delegate target: ${
|
|
26289
|
+
return stringifyDelegateTaskResult(createFailedResult(ctx.sessionID, "unknown_agent", `Unknown or disallowed CrewBee delegate target: ${requestedAgent}`));
|
|
26249
26290
|
}
|
|
26250
26291
|
if (isSelfDelegate(binding2, target.canonicalAgentId)) {
|
|
26251
26292
|
return stringifyDelegateTaskResult(createFailedResult(ctx.sessionID, "self_delegate_forbidden", "Do not delegate a CrewBee session back to the same active agent."));
|
|
26252
26293
|
}
|
|
26253
|
-
const title = createDelegatedTitle(target.canonicalAgentId, args.prompt);
|
|
26294
|
+
const title = args.description ?? createDelegatedTitle(target.canonicalAgentId, args.prompt);
|
|
26254
26295
|
const child = await resolveChildSession({
|
|
26255
26296
|
args,
|
|
26256
26297
|
client: input.client,
|
|
@@ -26290,6 +26331,7 @@ function createDelegateTools(input) {
|
|
|
26290
26331
|
anchor
|
|
26291
26332
|
});
|
|
26292
26333
|
input.store.putTask(record2);
|
|
26334
|
+
input.store.setTaskStatus(record2.taskRef, "running");
|
|
26293
26335
|
launchBackground({
|
|
26294
26336
|
args,
|
|
26295
26337
|
client: input.client,
|
|
@@ -26299,10 +26341,11 @@ function createDelegateTools(input) {
|
|
|
26299
26341
|
sessionID,
|
|
26300
26342
|
taskRef: record2.taskRef
|
|
26301
26343
|
});
|
|
26302
|
-
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" } });
|
|
26303
26345
|
return stringifyDelegateTaskResult({
|
|
26304
26346
|
status: "running",
|
|
26305
26347
|
session_id: sessionID,
|
|
26348
|
+
task_id: sessionID,
|
|
26306
26349
|
task_ref: record2.taskRef,
|
|
26307
26350
|
message: "Delegated session launched in background.",
|
|
26308
26351
|
resume_supported: true
|
|
@@ -26315,15 +26358,21 @@ function createDelegateTools(input) {
|
|
|
26315
26358
|
task_ref: zod_default.string().describe("CrewBee background task reference")
|
|
26316
26359
|
},
|
|
26317
26360
|
async execute(args) {
|
|
26318
|
-
|
|
26319
|
-
if (!
|
|
26361
|
+
let task2 = input.store.getTask(args.task_ref);
|
|
26362
|
+
if (!task2) {
|
|
26320
26363
|
return stringifyDelegateStatusResult({ status: "failed", task_ref: args.task_ref, message: "Unknown background task reference." });
|
|
26321
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
|
+
}
|
|
26322
26371
|
return stringifyDelegateStatusResult({
|
|
26323
|
-
status:
|
|
26324
|
-
session_id:
|
|
26325
|
-
task_ref:
|
|
26326
|
-
message:
|
|
26372
|
+
status: task2.status,
|
|
26373
|
+
session_id: task2.sessionID,
|
|
26374
|
+
task_ref: task2.taskRef,
|
|
26375
|
+
message: task2.message
|
|
26327
26376
|
});
|
|
26328
26377
|
}
|
|
26329
26378
|
});
|
|
@@ -26333,37 +26382,37 @@ function createDelegateTools(input) {
|
|
|
26333
26382
|
task_ref: zod_default.string().describe("CrewBee background task reference")
|
|
26334
26383
|
},
|
|
26335
26384
|
async execute(args) {
|
|
26336
|
-
const
|
|
26337
|
-
if (!
|
|
26385
|
+
const task2 = input.store.getTask(args.task_ref);
|
|
26386
|
+
if (!task2) {
|
|
26338
26387
|
return stringifyDelegateCancelResult({ ok: false, task_ref: args.task_ref, message: "Unknown background task reference." });
|
|
26339
26388
|
}
|
|
26340
|
-
if (
|
|
26389
|
+
if (task2.status === "completed" || task2.status === "failed" || task2.status === "cancelled") {
|
|
26341
26390
|
return stringifyDelegateCancelResult({
|
|
26342
26391
|
ok: false,
|
|
26343
|
-
task_ref:
|
|
26344
|
-
session_id:
|
|
26345
|
-
message: `Task is already ${
|
|
26392
|
+
task_ref: task2.taskRef,
|
|
26393
|
+
session_id: task2.sessionID,
|
|
26394
|
+
message: `Task is already ${task2.status}.`
|
|
26346
26395
|
});
|
|
26347
26396
|
}
|
|
26348
|
-
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);
|
|
26349
26398
|
if (!aborted2) {
|
|
26350
26399
|
return stringifyDelegateCancelResult({
|
|
26351
26400
|
ok: false,
|
|
26352
|
-
task_ref:
|
|
26353
|
-
session_id:
|
|
26401
|
+
task_ref: task2.taskRef,
|
|
26402
|
+
session_id: task2.sessionID,
|
|
26354
26403
|
message: "Failed to cancel the delegated session."
|
|
26355
26404
|
});
|
|
26356
26405
|
}
|
|
26357
|
-
input.store.setTaskStatus(
|
|
26406
|
+
input.store.setTaskStatus(task2.taskRef, "cancelled", { message: "Delegated session cancelled." });
|
|
26358
26407
|
return stringifyDelegateCancelResult({
|
|
26359
26408
|
ok: true,
|
|
26360
|
-
task_ref:
|
|
26361
|
-
session_id:
|
|
26409
|
+
task_ref: task2.taskRef,
|
|
26410
|
+
session_id: task2.sessionID,
|
|
26362
26411
|
message: "Delegated session cancelled."
|
|
26363
26412
|
});
|
|
26364
26413
|
}
|
|
26365
26414
|
});
|
|
26366
|
-
return {
|
|
26415
|
+
return { task, delegate_status, delegate_cancel };
|
|
26367
26416
|
}
|
|
26368
26417
|
|
|
26369
26418
|
// src/adapters/opencode/system-transform-hook.ts
|
|
@@ -26404,36 +26453,14 @@ function createSystemTransformHook(bindings, getLoadIssues = () => []) {
|
|
|
26404
26453
|
}
|
|
26405
26454
|
|
|
26406
26455
|
// src/adapters/opencode/tool-hooks.ts
|
|
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;
|
|
26428
|
-
}
|
|
26429
26456
|
function buildRetryGuidance(result) {
|
|
26430
26457
|
if (!result.error_code) {
|
|
26431
26458
|
return void 0;
|
|
26432
26459
|
}
|
|
26433
26460
|
const fixes = {
|
|
26434
|
-
missing_agent: 'Fix: include `
|
|
26435
|
-
unknown_agent: "Fix: use a valid CrewBee member id or projected alias
|
|
26436
|
-
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`.",
|
|
26437
26464
|
agent_session_mismatch: "Fix: resume with the same agent that created the delegated session.",
|
|
26438
26465
|
unsupported_mode: 'Fix: use `mode="foreground"` or `mode="background"`.',
|
|
26439
26466
|
nested_delegate_forbidden: "Fix: return the result to the parent session instead of delegating again from a delegated subagent.",
|
|
@@ -26444,17 +26471,17 @@ function buildRetryGuidance(result) {
|
|
|
26444
26471
|
return void 0;
|
|
26445
26472
|
}
|
|
26446
26473
|
return [
|
|
26447
|
-
"[
|
|
26474
|
+
"[task CALL FAILED - RETRY REQUIRED]",
|
|
26448
26475
|
`Error: ${result.error_code}`,
|
|
26449
26476
|
fix,
|
|
26450
|
-
'Example:
|
|
26477
|
+
'Example: task(subagent_type="reviewer", prompt="continue review")'
|
|
26451
26478
|
].join("\n");
|
|
26452
26479
|
}
|
|
26453
26480
|
function withResumeHint(result) {
|
|
26454
26481
|
if (result.status === "failed" || !result.session_id || result.resume_hint) {
|
|
26455
26482
|
return result;
|
|
26456
26483
|
}
|
|
26457
|
-
const hint = `to continue:
|
|
26484
|
+
const hint = `to continue: task(task_id="${result.session_id}", subagent_type="${result.session_id ? "..." : "reviewer"}", prompt="...")`;
|
|
26458
26485
|
return {
|
|
26459
26486
|
...result,
|
|
26460
26487
|
resume_hint: hint,
|
|
@@ -26488,14 +26515,7 @@ ${guidance}` : guidance
|
|
|
26488
26515
|
};
|
|
26489
26516
|
}
|
|
26490
26517
|
function createToolDefinitionHook(_getAgents) {
|
|
26491
|
-
return async (
|
|
26492
|
-
if (input.toolID !== "task") {
|
|
26493
|
-
return;
|
|
26494
|
-
}
|
|
26495
|
-
output.description = [
|
|
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."
|
|
26497
|
-
].join("\n");
|
|
26498
|
-
output.parameters = sanitizeNativeTaskParameters(output.parameters);
|
|
26518
|
+
return async () => {
|
|
26499
26519
|
};
|
|
26500
26520
|
}
|
|
26501
26521
|
function createToolExecuteBeforeHook(input) {
|
|
@@ -26515,14 +26535,24 @@ function createToolExecuteBeforeHook(input) {
|
|
|
26515
26535
|
}
|
|
26516
26536
|
function createToolExecuteAfterHook() {
|
|
26517
26537
|
return async (input, output) => {
|
|
26518
|
-
if (input.tool !== "
|
|
26538
|
+
if (input.tool !== "task") {
|
|
26519
26539
|
return;
|
|
26520
26540
|
}
|
|
26521
26541
|
const parsed = parseDelegateTaskResult(output.output);
|
|
26522
26542
|
if (!parsed) {
|
|
26523
26543
|
return;
|
|
26524
26544
|
}
|
|
26525
|
-
|
|
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
|
+
}
|
|
26526
26556
|
};
|
|
26527
26557
|
}
|
|
26528
26558
|
|
|
@@ -91,14 +91,12 @@ interface CreateDelegateToolsInput {
|
|
|
91
91
|
bindings: Map<string, SessionRuntimeBinding>;
|
|
92
92
|
}
|
|
93
93
|
export declare function createDelegateTools(input: CreateDelegateToolsInput): {
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
task: CrewBeeToolDefinition<{
|
|
95
|
+
description: z.ZodOptional<z.ZodString>;
|
|
96
96
|
prompt: z.ZodString;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
background: "background";
|
|
101
|
-
}>>;
|
|
97
|
+
subagent_type: z.ZodString;
|
|
98
|
+
task_id: z.ZodOptional<z.ZodString>;
|
|
99
|
+
run_in_background: z.ZodOptional<z.ZodBoolean>;
|
|
102
100
|
}>;
|
|
103
101
|
delegate_status: CrewBeeToolDefinition<{
|
|
104
102
|
task_ref: z.ZodString;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../../../src/adapters/opencode/delegation/tools.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,KAAK,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAOlF,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAI7C,UAAU,kBAAkB;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,WAAW,CAAC;IACnB,QAAQ,CAAC,KAAK,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,GAAG,IAAI,CAAC;CAC/E;AAED,UAAU,qBAAqB,CAAC,IAAI,SAAS,CAAC,CAAC,WAAW;IACxD,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,EAAE,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC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