crewbee 0.1.4 → 0.1.5
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 +14 -2
- package/README.zh-CN.md +14 -2
- package/dist/opencode-plugin.mjs +210 -232
- package/dist/src/adapters/opencode/bootstrap.d.ts.map +1 -1
- package/dist/src/adapters/opencode/bootstrap.js +8 -51
- package/dist/src/adapters/opencode/bootstrap.js.map +1 -1
- package/dist/src/adapters/opencode/chat-message-hook.d.ts.map +1 -1
- package/dist/src/adapters/opencode/chat-message-hook.js +1 -2
- package/dist/src/adapters/opencode/chat-message-hook.js.map +1 -1
- package/dist/src/adapters/opencode/coexistence.d.ts +0 -4
- package/dist/src/adapters/opencode/coexistence.d.ts.map +1 -1
- package/dist/src/adapters/opencode/coexistence.js +0 -5
- package/dist/src/adapters/opencode/coexistence.js.map +1 -1
- package/dist/src/adapters/opencode/config-hook.d.ts.map +1 -1
- package/dist/src/adapters/opencode/config-hook.js +0 -1
- package/dist/src/adapters/opencode/config-hook.js.map +1 -1
- package/dist/src/adapters/opencode/config-merge.d.ts.map +1 -1
- package/dist/src/adapters/opencode/config-merge.js +2 -30
- package/dist/src/adapters/opencode/config-merge.js.map +1 -1
- package/dist/src/adapters/opencode/delegation/continuity.d.ts.map +1 -1
- package/dist/src/adapters/opencode/delegation/continuity.js +1 -2
- package/dist/src/adapters/opencode/delegation/continuity.js.map +1 -1
- package/dist/src/adapters/opencode/delegation/prompt.d.ts.map +1 -1
- package/dist/src/adapters/opencode/delegation/prompt.js +0 -1
- package/dist/src/adapters/opencode/delegation/prompt.js.map +1 -1
- package/dist/src/adapters/opencode/delegation/resolve-agent.d.ts +1 -1
- package/dist/src/adapters/opencode/delegation/resolve-agent.d.ts.map +1 -1
- package/dist/src/adapters/opencode/delegation/resolve-agent.js +4 -16
- package/dist/src/adapters/opencode/delegation/resolve-agent.js.map +1 -1
- package/dist/src/adapters/opencode/delegation/tools.js +10 -10
- package/dist/src/adapters/opencode/delegation/tools.js.map +1 -1
- package/dist/src/adapters/opencode/delegation/types.d.ts +3 -4
- package/dist/src/adapters/opencode/delegation/types.d.ts.map +1 -1
- package/dist/src/adapters/opencode/index.d.ts +2 -1
- package/dist/src/adapters/opencode/index.d.ts.map +1 -1
- package/dist/src/adapters/opencode/index.js +3 -5
- package/dist/src/adapters/opencode/index.js.map +1 -1
- package/dist/src/adapters/opencode/projection.d.ts +4 -11
- package/dist/src/adapters/opencode/projection.d.ts.map +1 -1
- package/dist/src/adapters/opencode/projection.js +11 -49
- 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 +1 -11
- package/dist/src/adapters/opencode/prompt-builder.js.map +1 -1
- package/dist/src/agent-teams/canonical-agent-id.d.ts +12 -0
- package/dist/src/agent-teams/canonical-agent-id.d.ts.map +1 -0
- package/dist/src/agent-teams/canonical-agent-id.js +117 -0
- package/dist/src/agent-teams/canonical-agent-id.js.map +1 -0
- package/dist/src/agent-teams/embedded/coding-team/agents/coding-executor.d.ts.map +1 -1
- package/dist/src/agent-teams/embedded/coding-team/agents/coding-executor.js +0 -1
- 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 +0 -1
- 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 +0 -1
- package/dist/src/agent-teams/embedded/coding-team/agents/coordination-leader.js.map +1 -1
- package/dist/src/agent-teams/library.d.ts.map +1 -1
- package/dist/src/agent-teams/library.js +63 -19
- package/dist/src/agent-teams/library.js.map +1 -1
- package/dist/src/agent-teams/parsers.d.ts.map +1 -1
- package/dist/src/agent-teams/parsers.js +0 -1
- package/dist/src/agent-teams/parsers.js.map +1 -1
- package/dist/src/cli/install.js +1 -1
- package/dist/src/cli/install.js.map +1 -1
- package/dist/src/core/index.d.ts +2 -1
- package/dist/src/core/index.d.ts.map +1 -1
- package/dist/src/runtime/team-library-projection.d.ts +2 -2
- package/dist/src/runtime/team-library-projection.d.ts.map +1 -1
- package/dist/src/runtime/team-library-projection.js +8 -12
- package/dist/src/runtime/team-library-projection.js.map +1 -1
- package/dist/src/runtime/types.d.ts +1 -3
- package/dist/src/runtime/types.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/opencode-plugin.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -7872,7 +7873,6 @@ function createCoordinationLeaderAgent() {
|
|
|
7872
7873
|
},
|
|
7873
7874
|
entryPoint: {
|
|
7874
7875
|
exposure: "user-selectable",
|
|
7875
|
-
selectionLabel: "coordination-leader",
|
|
7876
7876
|
selectionDescription: "CodingTeam \u7684\u534F\u8C03\u578B Leader \u6295\u5F71\uFF1B\u9002\u5408\u9AD8\u6A21\u7CCA\u3001\u8303\u56F4\u5F85\u6536\u675F\u3001\u591A\u5B50\u4EFB\u52A1\u7F16\u6392\u7684\u5F00\u5C40\u8DEF\u5F84\u3002",
|
|
7877
7877
|
selectionPriority: 1
|
|
7878
7878
|
},
|
|
@@ -8110,7 +8110,6 @@ function createCodingExecutorAgent() {
|
|
|
8110
8110
|
},
|
|
8111
8111
|
entryPoint: {
|
|
8112
8112
|
exposure: "user-selectable",
|
|
8113
|
-
selectionLabel: "executor",
|
|
8114
8113
|
selectionDescription: "CodingTeam \u7684\u76F4\u63A5\u6267\u884C\u5165\u53E3\uFF1B\u9002\u5408\u8FB9\u754C\u6E05\u6670\u3001\u5E0C\u671B\u76F4\u63A5\u8FDB\u5165\u5B9E\u73B0\u95ED\u73AF\u7684\u7528\u6237\u8DEF\u5F84\u3002",
|
|
8115
8114
|
selectionPriority: 2
|
|
8116
8115
|
}
|
|
@@ -8423,7 +8422,6 @@ function createCodingLeaderAgent() {
|
|
|
8423
8422
|
},
|
|
8424
8423
|
entryPoint: {
|
|
8425
8424
|
exposure: "user-selectable",
|
|
8426
|
-
selectionLabel: "leader",
|
|
8427
8425
|
selectionDescription: "CodingTeam \u7684\u9ED8\u8BA4\u4E3B\u6267\u884C Leader\uFF1B\u5728 OpenCode \u4E2D\u9009\u62E9\u5B83\uFF0C\u5C31\u8FDB\u5165\u4EE5 coding-leader \u4E3A\u4E3B owner \u7684 CodingTeam \u8DEF\u5F84\u3002",
|
|
8428
8426
|
selectionPriority: 0
|
|
8429
8427
|
},
|
|
@@ -10204,7 +10202,6 @@ function mapEntryPoint(raw) {
|
|
|
10204
10202
|
}
|
|
10205
10203
|
return {
|
|
10206
10204
|
exposure: asString(raw.exposure, "entry_point.exposure"),
|
|
10207
|
-
selectionLabel: asOptionalString(raw.selection_label ?? raw.selectionLabel),
|
|
10208
10205
|
selectionDescription: asOptionalString(raw.selection_description ?? raw.selectionDescription),
|
|
10209
10206
|
selectionPriority: asOptionalNumber(raw.selection_priority ?? raw.selectionPriority, "entry_point.selection_priority")
|
|
10210
10207
|
};
|
|
@@ -10765,6 +10762,114 @@ function loadTeamDefinitionFromDirectory(teamDir, workspaceRoot = process.cwd())
|
|
|
10765
10762
|
// src/agent-teams/library.ts
|
|
10766
10763
|
import path4 from "node:path";
|
|
10767
10764
|
|
|
10765
|
+
// src/agent-teams/canonical-agent-id.ts
|
|
10766
|
+
function sanitizeSegment(value) {
|
|
10767
|
+
return value.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").replace(/-{2,}/g, "-");
|
|
10768
|
+
}
|
|
10769
|
+
function resolveTeamStem(teamId) {
|
|
10770
|
+
const normalized = sanitizeSegment(teamId);
|
|
10771
|
+
return normalized.endsWith("-team") ? normalized.slice(0, -5) : normalized;
|
|
10772
|
+
}
|
|
10773
|
+
function resolveAgentSlug(agentId) {
|
|
10774
|
+
return sanitizeSegment(agentId);
|
|
10775
|
+
}
|
|
10776
|
+
function createCanonicalAgentId(teamId, agentId) {
|
|
10777
|
+
const teamStem = resolveTeamStem(teamId);
|
|
10778
|
+
const agentSlug = resolveAgentSlug(agentId);
|
|
10779
|
+
if (!teamStem) {
|
|
10780
|
+
return agentSlug;
|
|
10781
|
+
}
|
|
10782
|
+
return agentSlug === teamStem || agentSlug.startsWith(`${teamStem}-`) ? agentSlug : `${teamStem}-${agentSlug}`;
|
|
10783
|
+
}
|
|
10784
|
+
function createFallbackCanonicalAgentId(teamId, agentId) {
|
|
10785
|
+
return `${sanitizeSegment(teamId)}-${resolveAgentSlug(agentId)}`;
|
|
10786
|
+
}
|
|
10787
|
+
function rewriteBinding(binding3, agentIdMap) {
|
|
10788
|
+
if (typeof binding3 === "string") {
|
|
10789
|
+
return agentIdMap.get(binding3) ?? binding3;
|
|
10790
|
+
}
|
|
10791
|
+
return {
|
|
10792
|
+
...binding3,
|
|
10793
|
+
agentRef: agentIdMap.get(binding3.agentRef) ?? binding3.agentRef
|
|
10794
|
+
};
|
|
10795
|
+
}
|
|
10796
|
+
function normalizeTeamAgentIds(input) {
|
|
10797
|
+
const issues = [];
|
|
10798
|
+
const nextUsedIds = new Set(input.usedCanonicalIds);
|
|
10799
|
+
const localAssignedIds = /* @__PURE__ */ new Set();
|
|
10800
|
+
const agentIdMap = /* @__PURE__ */ new Map();
|
|
10801
|
+
for (const agent of input.team.agents) {
|
|
10802
|
+
const sourceId = agent.metadata.id;
|
|
10803
|
+
const candidate = createCanonicalAgentId(input.team.manifest.id, sourceId);
|
|
10804
|
+
const fallback = createFallbackCanonicalAgentId(input.team.manifest.id, sourceId);
|
|
10805
|
+
let assigned = candidate;
|
|
10806
|
+
if (nextUsedIds.has(assigned) || localAssignedIds.has(assigned)) {
|
|
10807
|
+
assigned = fallback;
|
|
10808
|
+
}
|
|
10809
|
+
if (nextUsedIds.has(assigned) || localAssignedIds.has(assigned)) {
|
|
10810
|
+
issues.push({
|
|
10811
|
+
level: "error",
|
|
10812
|
+
message: `Team '${input.team.manifest.id}' cannot assign a unique canonicalAgentId for source agent '${sourceId}'. Candidate '${candidate}' and fallback '${fallback}' both collide.`
|
|
10813
|
+
});
|
|
10814
|
+
return { issues };
|
|
10815
|
+
}
|
|
10816
|
+
agentIdMap.set(sourceId, assigned);
|
|
10817
|
+
localAssignedIds.add(assigned);
|
|
10818
|
+
nextUsedIds.add(assigned);
|
|
10819
|
+
}
|
|
10820
|
+
const normalizedTeam = {
|
|
10821
|
+
...input.team,
|
|
10822
|
+
manifest: {
|
|
10823
|
+
...input.team.manifest,
|
|
10824
|
+
leader: {
|
|
10825
|
+
...input.team.manifest.leader,
|
|
10826
|
+
agentRef: agentIdMap.get(input.team.manifest.leader.agentRef) ?? input.team.manifest.leader.agentRef
|
|
10827
|
+
},
|
|
10828
|
+
members: Object.fromEntries(
|
|
10829
|
+
Object.entries(input.team.manifest.members).map(([agentId, guidance]) => [
|
|
10830
|
+
agentIdMap.get(agentId) ?? agentId,
|
|
10831
|
+
guidance
|
|
10832
|
+
])
|
|
10833
|
+
),
|
|
10834
|
+
agentRuntime: input.team.manifest.agentRuntime ? Object.fromEntries(
|
|
10835
|
+
Object.entries(input.team.manifest.agentRuntime).map(([agentId, runtime]) => [
|
|
10836
|
+
agentIdMap.get(agentId) ?? agentId,
|
|
10837
|
+
runtime
|
|
10838
|
+
])
|
|
10839
|
+
) : void 0
|
|
10840
|
+
},
|
|
10841
|
+
agents: input.team.agents.map((agent) => {
|
|
10842
|
+
const canonicalAgentId = agentIdMap.get(agent.metadata.id) ?? agent.metadata.id;
|
|
10843
|
+
return {
|
|
10844
|
+
...agent,
|
|
10845
|
+
canonicalAgentId,
|
|
10846
|
+
metadata: {
|
|
10847
|
+
...agent.metadata,
|
|
10848
|
+
id: canonicalAgentId,
|
|
10849
|
+
sourceId: agent.metadata.sourceId ?? agent.metadata.id,
|
|
10850
|
+
name: canonicalAgentId
|
|
10851
|
+
},
|
|
10852
|
+
collaboration: {
|
|
10853
|
+
defaultConsults: agent.collaboration.defaultConsults.map((binding3) => rewriteBinding(binding3, agentIdMap)),
|
|
10854
|
+
defaultHandoffs: agent.collaboration.defaultHandoffs.map((binding3) => rewriteBinding(binding3, agentIdMap))
|
|
10855
|
+
},
|
|
10856
|
+
entryPoint: agent.entryPoint ? {
|
|
10857
|
+
...agent.entryPoint,
|
|
10858
|
+
selectionLabel: canonicalAgentId
|
|
10859
|
+
} : agent.entryPoint
|
|
10860
|
+
};
|
|
10861
|
+
})
|
|
10862
|
+
};
|
|
10863
|
+
input.usedCanonicalIds.clear();
|
|
10864
|
+
for (const usedId of nextUsedIds) {
|
|
10865
|
+
input.usedCanonicalIds.add(usedId);
|
|
10866
|
+
}
|
|
10867
|
+
return {
|
|
10868
|
+
team: normalizedTeam,
|
|
10869
|
+
issues
|
|
10870
|
+
};
|
|
10871
|
+
}
|
|
10872
|
+
|
|
10768
10873
|
// src/agent-teams/validation.ts
|
|
10769
10874
|
function getBindingAgentRef(binding3) {
|
|
10770
10875
|
return typeof binding3 === "string" ? binding3 : binding3.agentRef;
|
|
@@ -10898,30 +11003,9 @@ function createSkippedTeamIssue(teamDir, message) {
|
|
|
10898
11003
|
message: `Skipped Team '${path4.basename(teamDir)}': ${message}`
|
|
10899
11004
|
};
|
|
10900
11005
|
}
|
|
10901
|
-
function loadValidatedTeamDefinition(input) {
|
|
10902
|
-
try {
|
|
10903
|
-
const team = loadTeamDefinitionFromDirectory(input.teamDir, input.workspaceRoot);
|
|
10904
|
-
const issues = validateTeamDefinition(team);
|
|
10905
|
-
const errors = issues.filter((issue2) => issue2.level === "error");
|
|
10906
|
-
if (errors.length > 0) {
|
|
10907
|
-
return {
|
|
10908
|
-
issues: errors.map((issue2) => createSkippedTeamIssue(input.teamDir, issue2.message))
|
|
10909
|
-
};
|
|
10910
|
-
}
|
|
10911
|
-
return {
|
|
10912
|
-
team,
|
|
10913
|
-
issues: issues.filter((issue2) => issue2.level === "warning")
|
|
10914
|
-
};
|
|
10915
|
-
} catch (error45) {
|
|
10916
|
-
const message = error45 instanceof Error ? error45.message : String(error45);
|
|
10917
|
-
return {
|
|
10918
|
-
issues: [createSkippedTeamIssue(input.teamDir, message)]
|
|
10919
|
-
};
|
|
10920
|
-
}
|
|
10921
|
-
}
|
|
10922
11006
|
function loadDefaultTeamLibrary(baseDir = process.cwd()) {
|
|
10923
11007
|
const configured = listConfiguredTeamSources();
|
|
10924
|
-
const
|
|
11008
|
+
const pendingTeams = [];
|
|
10925
11009
|
for (const source of configured.sources) {
|
|
10926
11010
|
if (!source.enabled) {
|
|
10927
11011
|
continue;
|
|
@@ -10932,37 +11016,68 @@ function loadDefaultTeamLibrary(baseDir = process.cwd()) {
|
|
|
10932
11016
|
if (!embeddedTeam.team) {
|
|
10933
11017
|
continue;
|
|
10934
11018
|
}
|
|
10935
|
-
|
|
10936
|
-
team: embeddedTeam.team,
|
|
11019
|
+
pendingTeams.push({
|
|
11020
|
+
loader: () => ({ team: embeddedTeam.team, issues: [] }),
|
|
10937
11021
|
priority: source.priority,
|
|
10938
11022
|
order: source.order
|
|
10939
11023
|
});
|
|
10940
11024
|
continue;
|
|
10941
11025
|
}
|
|
10942
|
-
|
|
10943
|
-
|
|
10944
|
-
|
|
10945
|
-
|
|
10946
|
-
|
|
10947
|
-
|
|
10948
|
-
|
|
10949
|
-
|
|
10950
|
-
|
|
10951
|
-
|
|
11026
|
+
pendingTeams.push({
|
|
11027
|
+
loader: () => {
|
|
11028
|
+
try {
|
|
11029
|
+
return {
|
|
11030
|
+
team: loadTeamDefinitionFromDirectory(source.teamDir, baseDir),
|
|
11031
|
+
issues: []
|
|
11032
|
+
};
|
|
11033
|
+
} catch (error45) {
|
|
11034
|
+
const message = error45 instanceof Error ? error45.message : String(error45);
|
|
11035
|
+
return {
|
|
11036
|
+
issues: [createSkippedTeamIssue(source.teamDir, message)]
|
|
11037
|
+
};
|
|
11038
|
+
}
|
|
11039
|
+
},
|
|
10952
11040
|
priority: source.priority,
|
|
10953
11041
|
order: source.order
|
|
10954
11042
|
});
|
|
10955
11043
|
}
|
|
10956
|
-
|
|
11044
|
+
pendingTeams.sort((left, right) => {
|
|
10957
11045
|
const priorityOrder = left.priority - right.priority;
|
|
10958
11046
|
if (priorityOrder !== 0) {
|
|
10959
11047
|
return priorityOrder;
|
|
10960
11048
|
}
|
|
10961
11049
|
return left.order - right.order;
|
|
10962
11050
|
});
|
|
11051
|
+
const usedCanonicalIds = /* @__PURE__ */ new Set();
|
|
11052
|
+
const orderedTeams = [];
|
|
11053
|
+
for (const entry of pendingTeams) {
|
|
11054
|
+
const loaded = entry.loader();
|
|
11055
|
+
configured.issues.push(...loaded.issues);
|
|
11056
|
+
if (loaded.team) {
|
|
11057
|
+
const normalized = normalizeTeamAgentIds({
|
|
11058
|
+
team: loaded.team,
|
|
11059
|
+
usedCanonicalIds
|
|
11060
|
+
});
|
|
11061
|
+
configured.issues.push(...normalized.issues);
|
|
11062
|
+
if (normalized.team) {
|
|
11063
|
+
const validationIssues = validateTeamDefinition(normalized.team);
|
|
11064
|
+
const errors = validationIssues.filter((issue2) => issue2.level === "error");
|
|
11065
|
+
if (errors.length > 0) {
|
|
11066
|
+
configured.issues.push(...errors.map((issue2) => ({
|
|
11067
|
+
level: "warning",
|
|
11068
|
+
filePath: issue2.filePath,
|
|
11069
|
+
message: `Skipped Team '${normalized.team?.manifest.id ?? "unknown"}': ${issue2.message}`
|
|
11070
|
+
})));
|
|
11071
|
+
continue;
|
|
11072
|
+
}
|
|
11073
|
+
configured.issues.push(...validationIssues.filter((issue2) => issue2.level === "warning"));
|
|
11074
|
+
orderedTeams.push(normalized.team);
|
|
11075
|
+
}
|
|
11076
|
+
}
|
|
11077
|
+
}
|
|
10963
11078
|
return {
|
|
10964
11079
|
version: "config-driven-v1",
|
|
10965
|
-
teams: orderedTeams
|
|
11080
|
+
teams: orderedTeams,
|
|
10966
11081
|
loadIssues: configured.issues
|
|
10967
11082
|
};
|
|
10968
11083
|
}
|
|
@@ -10986,9 +11101,6 @@ function loadEmbeddedTeam(source) {
|
|
|
10986
11101
|
function isLeaderAgent(team, agent) {
|
|
10987
11102
|
return team.manifest.leader.agentRef === agent.metadata.id;
|
|
10988
11103
|
}
|
|
10989
|
-
function getSurfaceLabel(agent) {
|
|
10990
|
-
return agent.entryPoint?.selectionLabel ?? agent.metadata.id;
|
|
10991
|
-
}
|
|
10992
11104
|
function getExposure(agent) {
|
|
10993
11105
|
return agent.entryPoint?.exposure ?? "internal-only";
|
|
10994
11106
|
}
|
|
@@ -11016,15 +11128,15 @@ function sortTeamAgents(team) {
|
|
|
11016
11128
|
}
|
|
11017
11129
|
function createProjectedAgent(team, agent) {
|
|
11018
11130
|
const roleKind = isLeaderAgent(team, agent) ? "leader" : "member";
|
|
11131
|
+
const canonicalAgentId = agent.canonicalAgentId ?? agent.metadata.id;
|
|
11019
11132
|
return {
|
|
11020
11133
|
teamId: team.manifest.id,
|
|
11021
11134
|
teamName: team.manifest.name,
|
|
11022
11135
|
sourceTeam: team,
|
|
11023
|
-
|
|
11136
|
+
canonicalAgentId,
|
|
11024
11137
|
roleKind,
|
|
11025
11138
|
exposure: getExposure(agent),
|
|
11026
11139
|
selectionPriority: agent.entryPoint?.selectionPriority,
|
|
11027
|
-
surfaceLabel: getSurfaceLabel(agent),
|
|
11028
11140
|
description: getProjectionDescription(agent),
|
|
11029
11141
|
sourceAgent: agent
|
|
11030
11142
|
};
|
|
@@ -11046,21 +11158,20 @@ function createTeamLibraryProjection(library) {
|
|
|
11046
11158
|
agents: teams.flatMap((team) => team.agents)
|
|
11047
11159
|
};
|
|
11048
11160
|
}
|
|
11049
|
-
function findProjectedAgent(projection, teamId,
|
|
11050
|
-
return projection.agents.find((agent) => agent.teamId === teamId && agent.
|
|
11161
|
+
function findProjectedAgent(projection, teamId, canonicalAgentId) {
|
|
11162
|
+
return projection.agents.find((agent) => agent.teamId === teamId && agent.canonicalAgentId === canonicalAgentId);
|
|
11051
11163
|
}
|
|
11052
11164
|
function createSessionRuntimeBinding(input) {
|
|
11053
|
-
const selectedAgent = findProjectedAgent(input.projection, input.teamId, input.
|
|
11165
|
+
const selectedAgent = findProjectedAgent(input.projection, input.teamId, input.canonicalAgentId);
|
|
11054
11166
|
if (!selectedAgent) {
|
|
11055
|
-
throw new Error(`Unknown projected agent ${input.teamId}/${input.
|
|
11167
|
+
throw new Error(`Unknown projected agent ${input.teamId}/${input.canonicalAgentId}.`);
|
|
11056
11168
|
}
|
|
11057
11169
|
return {
|
|
11058
11170
|
sessionID: input.sessionID,
|
|
11059
11171
|
teamId: input.teamId,
|
|
11060
|
-
selectedAgentId: selectedAgent.
|
|
11061
|
-
selectedSurfaceLabel: selectedAgent.surfaceLabel,
|
|
11172
|
+
selectedAgentId: selectedAgent.canonicalAgentId,
|
|
11062
11173
|
mode: input.mode,
|
|
11063
|
-
activeOwnerId: selectedAgent.
|
|
11174
|
+
activeOwnerId: selectedAgent.canonicalAgentId,
|
|
11064
11175
|
source: input.source
|
|
11065
11176
|
};
|
|
11066
11177
|
}
|
|
@@ -11200,7 +11311,6 @@ function createDelegationEnvelope(input) {
|
|
|
11200
11311
|
function createCheckpoint(agent, model) {
|
|
11201
11312
|
return {
|
|
11202
11313
|
agent: agent.configKey,
|
|
11203
|
-
sourceAgentId: agent.sourceAgentId,
|
|
11204
11314
|
model,
|
|
11205
11315
|
tools: [...agent.runtimeConfig.requestedTools]
|
|
11206
11316
|
};
|
|
@@ -11682,12 +11792,6 @@ function renderPromptPlan(plan, ctx = defaultRenderContext) {
|
|
|
11682
11792
|
}
|
|
11683
11793
|
|
|
11684
11794
|
// src/adapters/opencode/prompt-builder.ts
|
|
11685
|
-
function sanitizeSegment(value) {
|
|
11686
|
-
return value.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
11687
|
-
}
|
|
11688
|
-
function createProjectedConfigKey(teamId, surfaceLabel) {
|
|
11689
|
-
return `crewbee.${sanitizeSegment(teamId)}.${sanitizeSegment(surfaceLabel)}`;
|
|
11690
|
-
}
|
|
11691
11795
|
function resolveTargetAgent(team, agentRef) {
|
|
11692
11796
|
return team.agents.find((candidate) => candidate.metadata.id === agentRef);
|
|
11693
11797
|
}
|
|
@@ -11699,7 +11803,7 @@ function createCollaborationPromptValue(agent) {
|
|
|
11699
11803
|
const member = team.manifest.members[agentRef];
|
|
11700
11804
|
const fallbackDescription = typeof binding3 === "string" ? void 0 : binding3.description;
|
|
11701
11805
|
return {
|
|
11702
|
-
id: targetAgent ?
|
|
11806
|
+
id: targetAgent ? targetAgent.canonicalAgentId ?? targetAgent.metadata.id : agentRef,
|
|
11703
11807
|
description: member?.responsibility ?? targetAgent?.responsibilityCore.description ?? fallbackDescription ?? agentRef,
|
|
11704
11808
|
...member?.delegateWhen ? { when_to_delegate: member.delegateWhen } : {}
|
|
11705
11809
|
};
|
|
@@ -11738,30 +11842,20 @@ function createOpenCodeAgentPrompt(agent, _requestedTools) {
|
|
|
11738
11842
|
}
|
|
11739
11843
|
|
|
11740
11844
|
// src/adapters/opencode/projection.ts
|
|
11741
|
-
function sanitizeSegment2(value) {
|
|
11742
|
-
return value.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
11743
|
-
}
|
|
11744
|
-
function createOpenCodePublicAgentName(agent) {
|
|
11745
|
-
return `[${agent.teamName}]${agent.surfaceLabel}`;
|
|
11746
|
-
}
|
|
11747
11845
|
function createOpenCodeConfigKey(agent) {
|
|
11748
|
-
return
|
|
11749
|
-
}
|
|
11750
|
-
function createOpenCodePublicNameAliasKey(agent) {
|
|
11751
|
-
return agent.publicName;
|
|
11846
|
+
return agent.canonicalAgentId;
|
|
11752
11847
|
}
|
|
11753
11848
|
function createOpenCodeAgentConfig(agent, options = {}) {
|
|
11754
11849
|
const runtimeConfig = agent.sourceAgent.runtimeConfig;
|
|
11755
|
-
const runtimeOverride = agent.sourceTeam.manifest.agentRuntime?.[agent.
|
|
11850
|
+
const runtimeOverride = agent.sourceTeam.manifest.agentRuntime?.[agent.canonicalAgentId];
|
|
11756
11851
|
const availableToolContext = createAvailableToolContext(options.availableTools);
|
|
11757
11852
|
const requestedTools = mapOpenCodeToolNames(runtimeConfig.requestedTools);
|
|
11758
11853
|
const availableTools = availableToolContext.hasExplicitTools ? requestedTools.filter((toolId) => isAvailableTool(toolId, availableToolContext)) : [...requestedTools];
|
|
11759
11854
|
const missingTools = availableToolContext.hasExplicitTools ? requestedTools.filter((toolId) => !isAvailableTool(toolId, availableToolContext)) : [];
|
|
11760
11855
|
return {
|
|
11761
11856
|
configKey: createOpenCodeConfigKey(agent),
|
|
11762
|
-
publicName: createOpenCodePublicAgentName(agent),
|
|
11763
11857
|
teamId: agent.teamId,
|
|
11764
|
-
|
|
11858
|
+
canonicalAgentId: agent.canonicalAgentId,
|
|
11765
11859
|
mode: agent.exposure === "user-selectable" ? "primary" : "subagent",
|
|
11766
11860
|
hidden: agent.exposure !== "user-selectable",
|
|
11767
11861
|
description: agent.description,
|
|
@@ -11795,8 +11889,8 @@ function createOpenCodeAgentConfig(agent, options = {}) {
|
|
|
11795
11889
|
metadata: {
|
|
11796
11890
|
teamId: agent.teamId,
|
|
11797
11891
|
teamName: agent.teamName,
|
|
11798
|
-
|
|
11799
|
-
|
|
11892
|
+
canonicalAgentId: agent.canonicalAgentId,
|
|
11893
|
+
sourceAgentId: agent.sourceAgent.metadata.sourceId,
|
|
11800
11894
|
roleKind: agent.roleKind,
|
|
11801
11895
|
exposure: agent.exposure
|
|
11802
11896
|
}
|
|
@@ -11807,7 +11901,7 @@ function createOpenCodeAgentConfigs(projection, options = {}) {
|
|
|
11807
11901
|
}
|
|
11808
11902
|
function createOpenCodeAgentDefinition(agent) {
|
|
11809
11903
|
return {
|
|
11810
|
-
name: agent.
|
|
11904
|
+
name: agent.configKey,
|
|
11811
11905
|
description: agent.description,
|
|
11812
11906
|
mode: agent.mode,
|
|
11813
11907
|
hidden: agent.hidden || void 0,
|
|
@@ -11820,31 +11914,15 @@ function createOpenCodeAgentDefinition(agent) {
|
|
|
11820
11914
|
options: agent.resolvedModel?.options
|
|
11821
11915
|
};
|
|
11822
11916
|
}
|
|
11823
|
-
function createOpenCodePublicNameAliasDefinition(agent) {
|
|
11824
|
-
return {
|
|
11825
|
-
...createOpenCodeAgentDefinition(agent),
|
|
11826
|
-
hidden: true
|
|
11827
|
-
};
|
|
11828
|
-
}
|
|
11829
11917
|
function createOpenCodeProjectedIdentities(agent) {
|
|
11830
|
-
return [
|
|
11831
|
-
|
|
11832
|
-
|
|
11833
|
-
publicName: agent.publicName
|
|
11834
|
-
},
|
|
11835
|
-
{
|
|
11836
|
-
configKey: createOpenCodePublicNameAliasKey(agent),
|
|
11837
|
-
publicName: agent.publicName
|
|
11838
|
-
}
|
|
11839
|
-
];
|
|
11918
|
+
return [{
|
|
11919
|
+
configKey: agent.configKey
|
|
11920
|
+
}];
|
|
11840
11921
|
}
|
|
11841
11922
|
function createOpenCodeAgentConfigPatch(input) {
|
|
11842
11923
|
return {
|
|
11843
11924
|
agent: Object.fromEntries(
|
|
11844
|
-
input.agents.
|
|
11845
|
-
[agent.configKey, createOpenCodeAgentDefinition(agent)],
|
|
11846
|
-
[createOpenCodePublicNameAliasKey(agent), createOpenCodePublicNameAliasDefinition(agent)]
|
|
11847
|
-
])
|
|
11925
|
+
input.agents.map((agent) => [agent.configKey, createOpenCodeAgentDefinition(agent)])
|
|
11848
11926
|
),
|
|
11849
11927
|
defaultAgent: input.defaultAgentConfigKey
|
|
11850
11928
|
};
|
|
@@ -11852,9 +11930,6 @@ function createOpenCodeAgentConfigPatch(input) {
|
|
|
11852
11930
|
function findProjectedAgentByConfigKey(agents, configKey) {
|
|
11853
11931
|
return agents.find((agent) => agent.configKey === configKey);
|
|
11854
11932
|
}
|
|
11855
|
-
function findProjectedAgentByPublicName(agents, publicName) {
|
|
11856
|
-
return agents.find((agent) => agent.publicName === publicName);
|
|
11857
|
-
}
|
|
11858
11933
|
function resolveProjectedAgentSelection(agents, selection) {
|
|
11859
11934
|
if (selection.configKey) {
|
|
11860
11935
|
const byConfigKey = findProjectedAgentByConfigKey(agents, selection.configKey);
|
|
@@ -11862,20 +11937,13 @@ function resolveProjectedAgentSelection(agents, selection) {
|
|
|
11862
11937
|
return byConfigKey;
|
|
11863
11938
|
}
|
|
11864
11939
|
}
|
|
11865
|
-
if (selection.publicName) {
|
|
11866
|
-
return findProjectedAgentByPublicName(agents, selection.publicName);
|
|
11867
|
-
}
|
|
11868
11940
|
return void 0;
|
|
11869
11941
|
}
|
|
11870
11942
|
function normalizeAlias(value) {
|
|
11871
11943
|
return value.trim().toLowerCase();
|
|
11872
11944
|
}
|
|
11873
11945
|
function createProjectedAgentAliasEntries(agent) {
|
|
11874
|
-
return [
|
|
11875
|
-
{ alias: agent.configKey, agent, kind: "config-key" },
|
|
11876
|
-
{ alias: agent.publicName, agent, kind: "public-name" },
|
|
11877
|
-
{ alias: agent.sourceAgentId, agent, kind: "source-agent-id" }
|
|
11878
|
-
];
|
|
11946
|
+
return [{ alias: agent.configKey, agent, kind: "config-key" }];
|
|
11879
11947
|
}
|
|
11880
11948
|
function createProjectedAgentAliasIndex(agents) {
|
|
11881
11949
|
const index = /* @__PURE__ */ new Map();
|
|
@@ -11898,8 +11966,7 @@ function resolveProjectedAgentAlias(index, alias) {
|
|
|
11898
11966
|
}
|
|
11899
11967
|
function createProjectedAgentTaskAliasHelpLines(agents) {
|
|
11900
11968
|
return agents.map((agent) => {
|
|
11901
|
-
|
|
11902
|
-
return `- ${agent.sourceAgentId} => ${agent.configKey} (${agent.publicName}; accepts: ${aliases.join(" | ")})`;
|
|
11969
|
+
return `- ${agent.configKey}`;
|
|
11903
11970
|
});
|
|
11904
11971
|
}
|
|
11905
11972
|
|
|
@@ -11927,8 +11994,7 @@ function createChatMessageHook(input) {
|
|
|
11927
11994
|
return;
|
|
11928
11995
|
}
|
|
11929
11996
|
const agent = resolveProjectedAgentSelection(boot.projectedAgents, {
|
|
11930
|
-
configKey: selected
|
|
11931
|
-
publicName: selected
|
|
11997
|
+
configKey: selected
|
|
11932
11998
|
});
|
|
11933
11999
|
if (!agent) {
|
|
11934
12000
|
return;
|
|
@@ -11937,7 +12003,7 @@ function createChatMessageHook(input) {
|
|
|
11937
12003
|
projection: boot.projection,
|
|
11938
12004
|
sessionID: message.sessionID,
|
|
11939
12005
|
teamId: agent.teamId,
|
|
11940
|
-
|
|
12006
|
+
canonicalAgentId: agent.canonicalAgentId,
|
|
11941
12007
|
mode: "single-executor",
|
|
11942
12008
|
source: message.agent ? "host-agent-selection" : "plugin-default"
|
|
11943
12009
|
});
|
|
@@ -11963,7 +12029,7 @@ function formatDelegatedSessions(store, sessionID) {
|
|
|
11963
12029
|
return sessions.map((session) => {
|
|
11964
12030
|
const task = store.getTaskBySession(session.sessionID);
|
|
11965
12031
|
return [
|
|
11966
|
-
`- ${session.
|
|
12032
|
+
`- ${session.canonicalAgentId}`,
|
|
11967
12033
|
task?.status ?? "completed",
|
|
11968
12034
|
task?.description ?? "foreground delegation",
|
|
11969
12035
|
`session_id=${session.sessionID}`,
|
|
@@ -11985,7 +12051,6 @@ function formatCheckpointSummary(store, sessionID) {
|
|
|
11985
12051
|
}
|
|
11986
12052
|
return [
|
|
11987
12053
|
`- agent=${checkpoint.agent}`,
|
|
11988
|
-
checkpoint.sourceAgentId ? `- source_agent=${checkpoint.sourceAgentId}` : void 0,
|
|
11989
12054
|
checkpoint.model ? `- model=${checkpoint.model.providerID}/${checkpoint.model.modelID}` : void 0,
|
|
11990
12055
|
checkpoint.tools.length > 0 ? `- tools=${checkpoint.tools.join(", ")}` : "- tools=None"
|
|
11991
12056
|
].filter(Boolean).join("\n");
|
|
@@ -12061,39 +12126,11 @@ function isCrewBeeOwnedKey(key) {
|
|
|
12061
12126
|
function isCompatibleCrewBeeOwnedKey(key) {
|
|
12062
12127
|
return isCrewBeeOwnedKey(key) || isLegacyCrewBeeOwnedKey(key);
|
|
12063
12128
|
}
|
|
12064
|
-
function getConfiguredAgentName(definition) {
|
|
12065
|
-
if (typeof definition !== "object" || definition === null || !("name" in definition)) {
|
|
12066
|
-
return void 0;
|
|
12067
|
-
}
|
|
12068
|
-
const candidate = definition.name;
|
|
12069
|
-
return typeof candidate === "string" ? candidate : void 0;
|
|
12070
|
-
}
|
|
12071
|
-
function isCrewBeePublicNameAliasEntry(key, definition, allAgents) {
|
|
12072
|
-
const publicName = getConfiguredAgentName(definition);
|
|
12073
|
-
if (!publicName || key !== publicName || !publicName.startsWith("[")) {
|
|
12074
|
-
return false;
|
|
12075
|
-
}
|
|
12076
|
-
return Object.entries(allAgents).some(([otherKey, otherDefinition]) => {
|
|
12077
|
-
if (!isCompatibleCrewBeeOwnedKey(otherKey)) {
|
|
12078
|
-
return false;
|
|
12079
|
-
}
|
|
12080
|
-
return getConfiguredAgentName(otherDefinition) === publicName;
|
|
12081
|
-
});
|
|
12082
|
-
}
|
|
12083
12129
|
function applyOpenCodeAgentConfigPatch(config2, patch) {
|
|
12084
12130
|
const nextAgents = { ...config2.agent ?? {} };
|
|
12085
12131
|
const insertedAgentKeys = [];
|
|
12086
12132
|
const updatedAgentKeys = [];
|
|
12087
12133
|
const skippedAgentKeys = [];
|
|
12088
|
-
const nextPublicNames = new Set(
|
|
12089
|
-
Object.values(patch.agent).map((definition) => definition.name).filter((name) => Boolean(name))
|
|
12090
|
-
);
|
|
12091
|
-
for (const [key, definition] of Object.entries(nextAgents)) {
|
|
12092
|
-
const publicName = getConfiguredAgentName(definition);
|
|
12093
|
-
if (publicName && isLegacyCrewBeeOwnedKey(key) && nextPublicNames.has(publicName)) {
|
|
12094
|
-
delete nextAgents[key];
|
|
12095
|
-
}
|
|
12096
|
-
}
|
|
12097
12134
|
for (const [key, definition] of Object.entries(patch.agent)) {
|
|
12098
12135
|
if (!(key in nextAgents)) {
|
|
12099
12136
|
nextAgents[key] = definition;
|
|
@@ -12101,7 +12138,7 @@ function applyOpenCodeAgentConfigPatch(config2, patch) {
|
|
|
12101
12138
|
continue;
|
|
12102
12139
|
}
|
|
12103
12140
|
const existingDefinition = nextAgents[key];
|
|
12104
|
-
if (
|
|
12141
|
+
if (isCompatibleCrewBeeOwnedKey(key)) {
|
|
12105
12142
|
nextAgents[key] = definition;
|
|
12106
12143
|
updatedAgentKeys.push(key);
|
|
12107
12144
|
continue;
|
|
@@ -12112,7 +12149,7 @@ function applyOpenCodeAgentConfigPatch(config2, patch) {
|
|
|
12112
12149
|
...config2,
|
|
12113
12150
|
agent: nextAgents
|
|
12114
12151
|
};
|
|
12115
|
-
if (patch.defaultAgent
|
|
12152
|
+
if (patch.defaultAgent) {
|
|
12116
12153
|
nextConfig.default_agent = patch.defaultAgent;
|
|
12117
12154
|
}
|
|
12118
12155
|
return {
|
|
@@ -12131,16 +12168,13 @@ function createOpenCodeCoexistencePolicy() {
|
|
|
12131
12168
|
featureDevelopmentMode: "mutually-exclusive",
|
|
12132
12169
|
safeWhenCoInstalled: true,
|
|
12133
12170
|
reservedConfigKeyPrefix: "crewbee.",
|
|
12134
|
-
reservedPublicNamePrefix: "[",
|
|
12135
12171
|
neverMutateForeignAgents: true
|
|
12136
12172
|
};
|
|
12137
12173
|
}
|
|
12138
12174
|
function detectOpenCodeProjectionCollisions(input) {
|
|
12139
12175
|
const existingConfigKeys = new Set(input.existingConfigKeys ?? []);
|
|
12140
|
-
const existingPublicNames = new Set(input.existingPublicNames ?? []);
|
|
12141
12176
|
return {
|
|
12142
|
-
configKeyCollisions: input.projectedAgents.filter((agent) => existingConfigKeys.has(agent.configKey)).map((agent) => agent.configKey)
|
|
12143
|
-
publicNameCollisions: input.projectedAgents.filter((agent) => existingPublicNames.has(agent.publicName)).map((agent) => agent.publicName)
|
|
12177
|
+
configKeyCollisions: input.projectedAgents.filter((agent) => existingConfigKeys.has(agent.configKey)).map((agent) => agent.configKey)
|
|
12144
12178
|
};
|
|
12145
12179
|
}
|
|
12146
12180
|
|
|
@@ -12175,7 +12209,6 @@ function createOpenCodeAdapterDefinition() {
|
|
|
12175
12209
|
coexistence: {
|
|
12176
12210
|
independentFromForeignPlugins: true,
|
|
12177
12211
|
safeWhenCoInstalled: coexistence.safeWhenCoInstalled,
|
|
12178
|
-
reservedAgentNamePrefix: coexistence.reservedPublicNamePrefix,
|
|
12179
12212
|
reservedConfigKeyPrefix: coexistence.reservedConfigKeyPrefix
|
|
12180
12213
|
}
|
|
12181
12214
|
};
|
|
@@ -12184,13 +12217,12 @@ function resolveBindingAgent(input) {
|
|
|
12184
12217
|
if (input.selectedHostAgent) {
|
|
12185
12218
|
const normalizedHostAgent = input.selectedHostAgent.startsWith(LEGACY_PLUGIN_KEY_PREFIX2) ? `${CURRENT_PLUGIN_KEY_PREFIX2}${input.selectedHostAgent.slice(LEGACY_PLUGIN_KEY_PREFIX2.length)}` : input.selectedHostAgent;
|
|
12186
12219
|
const hostSelection = resolveProjectedAgentSelection(input.projectedAgents, {
|
|
12187
|
-
configKey: normalizedHostAgent
|
|
12188
|
-
publicName: input.selectedHostAgent
|
|
12220
|
+
configKey: normalizedHostAgent
|
|
12189
12221
|
});
|
|
12190
12222
|
if (hostSelection) {
|
|
12191
12223
|
return {
|
|
12192
12224
|
teamId: hostSelection.teamId,
|
|
12193
|
-
sourceAgentId: hostSelection.
|
|
12225
|
+
sourceAgentId: hostSelection.canonicalAgentId
|
|
12194
12226
|
};
|
|
12195
12227
|
}
|
|
12196
12228
|
}
|
|
@@ -12199,7 +12231,7 @@ function resolveBindingAgent(input) {
|
|
|
12199
12231
|
if (explicit) {
|
|
12200
12232
|
return {
|
|
12201
12233
|
teamId: explicit.teamId,
|
|
12202
|
-
sourceAgentId: explicit.
|
|
12234
|
+
sourceAgentId: explicit.canonicalAgentId
|
|
12203
12235
|
};
|
|
12204
12236
|
}
|
|
12205
12237
|
}
|
|
@@ -12215,81 +12247,42 @@ function resolveBindingAgent(input) {
|
|
|
12215
12247
|
}
|
|
12216
12248
|
return {
|
|
12217
12249
|
teamId: fallbackTeam.team.manifest.id,
|
|
12218
|
-
sourceAgentId: fallbackAgent.metadata.id
|
|
12250
|
+
sourceAgentId: fallbackAgent.canonicalAgentId ?? fallbackAgent.metadata.id
|
|
12219
12251
|
};
|
|
12220
12252
|
}
|
|
12221
12253
|
return void 0;
|
|
12222
12254
|
}
|
|
12223
12255
|
function filterSafeProjectedAgents(agents, collisions) {
|
|
12224
12256
|
const blockedConfigKeys = new Set(collisions.configKeyCollisions);
|
|
12225
|
-
const blockedPublicNames = new Set(collisions.publicNameCollisions);
|
|
12226
12257
|
return agents.filter((agent) => {
|
|
12227
12258
|
if (blockedConfigKeys.has(agent.configKey)) {
|
|
12228
12259
|
return false;
|
|
12229
12260
|
}
|
|
12230
|
-
|
|
12231
|
-
return false;
|
|
12232
|
-
}
|
|
12233
|
-
return !blockedPublicNames.has(agent.publicName);
|
|
12261
|
+
return true;
|
|
12234
12262
|
});
|
|
12235
12263
|
}
|
|
12236
12264
|
function isCompatibleCrewBeeOwnedKey2(key) {
|
|
12237
12265
|
return key.startsWith(CURRENT_PLUGIN_KEY_PREFIX2) || key.startsWith(LEGACY_PLUGIN_KEY_PREFIX2);
|
|
12238
12266
|
}
|
|
12239
|
-
function getConfiguredAgentName2(definition) {
|
|
12240
|
-
if (typeof definition !== "object" || definition === null || !("name" in definition)) {
|
|
12241
|
-
return void 0;
|
|
12242
|
-
}
|
|
12243
|
-
const candidate = definition.name;
|
|
12244
|
-
return typeof candidate === "string" ? candidate : void 0;
|
|
12245
|
-
}
|
|
12246
|
-
function isCrewBeePublicNameAliasEntry2(key, definition, allAgents) {
|
|
12247
|
-
const publicName = getConfiguredAgentName2(definition);
|
|
12248
|
-
if (!publicName || key !== publicName || !publicName.startsWith("[")) {
|
|
12249
|
-
return false;
|
|
12250
|
-
}
|
|
12251
|
-
return Object.entries(allAgents).some(([otherKey, otherDefinition]) => {
|
|
12252
|
-
if (!isCompatibleCrewBeeOwnedKey2(otherKey)) {
|
|
12253
|
-
return false;
|
|
12254
|
-
}
|
|
12255
|
-
return getConfiguredAgentName2(otherDefinition) === publicName;
|
|
12256
|
-
});
|
|
12257
|
-
}
|
|
12258
12267
|
function getForeignCollisionInputs(input) {
|
|
12259
12268
|
if (!input.existingConfig?.agent) {
|
|
12260
12269
|
return {
|
|
12261
|
-
existingConfigKeys: input.existingConfigKeys
|
|
12262
|
-
existingPublicNames: input.existingPublicNames
|
|
12270
|
+
existingConfigKeys: input.existingConfigKeys
|
|
12263
12271
|
};
|
|
12264
12272
|
}
|
|
12265
12273
|
const compatibleOwnedConfigKeys = /* @__PURE__ */ new Set();
|
|
12266
|
-
const compatibleOwnedPublicNames = /* @__PURE__ */ new Set();
|
|
12267
12274
|
for (const [key, definition] of Object.entries(input.existingConfig.agent)) {
|
|
12268
|
-
if (!isCompatibleCrewBeeOwnedKey2(key)
|
|
12275
|
+
if (!isCompatibleCrewBeeOwnedKey2(key)) {
|
|
12269
12276
|
continue;
|
|
12270
12277
|
}
|
|
12271
12278
|
compatibleOwnedConfigKeys.add(key);
|
|
12272
|
-
const publicName = getConfiguredAgentName2(definition);
|
|
12273
|
-
if (publicName) {
|
|
12274
|
-
compatibleOwnedPublicNames.add(publicName);
|
|
12275
|
-
}
|
|
12276
12279
|
}
|
|
12277
12280
|
return {
|
|
12278
|
-
existingConfigKeys: input.existingConfigKeys?.filter((key) => !compatibleOwnedConfigKeys.has(key))
|
|
12279
|
-
existingPublicNames: input.existingPublicNames?.filter((name) => !compatibleOwnedPublicNames.has(name))
|
|
12281
|
+
existingConfigKeys: input.existingConfigKeys?.filter((key) => !compatibleOwnedConfigKeys.has(key))
|
|
12280
12282
|
};
|
|
12281
12283
|
}
|
|
12282
12284
|
function shouldSetDefaultAgent(input) {
|
|
12283
|
-
|
|
12284
|
-
return void 0;
|
|
12285
|
-
}
|
|
12286
|
-
if (!input.existingDefaultAgent) {
|
|
12287
|
-
return input.defaultAgentConfigKey;
|
|
12288
|
-
}
|
|
12289
|
-
if (isCompatibleCrewBeeOwnedKey2(input.existingDefaultAgent)) {
|
|
12290
|
-
return input.defaultAgentConfigKey;
|
|
12291
|
-
}
|
|
12292
|
-
return void 0;
|
|
12285
|
+
return input.defaultAgentConfigKey;
|
|
12293
12286
|
}
|
|
12294
12287
|
function createOpenCodeBootstrap(input) {
|
|
12295
12288
|
const projection = createTeamLibraryProjection(input.teamLibrary);
|
|
@@ -12299,13 +12292,11 @@ function createOpenCodeBootstrap(input) {
|
|
|
12299
12292
|
});
|
|
12300
12293
|
const foreignCollisions = getForeignCollisionInputs({
|
|
12301
12294
|
existingConfig: input.existingConfig,
|
|
12302
|
-
existingConfigKeys: input.existingConfigKeys
|
|
12303
|
-
existingPublicNames: input.existingPublicNames
|
|
12295
|
+
existingConfigKeys: input.existingConfigKeys
|
|
12304
12296
|
});
|
|
12305
12297
|
const collisions = detectOpenCodeProjectionCollisions({
|
|
12306
12298
|
projectedAgents: projectedAgents.flatMap((agent) => createOpenCodeProjectedIdentities(agent)),
|
|
12307
|
-
existingConfigKeys: foreignCollisions.existingConfigKeys
|
|
12308
|
-
existingPublicNames: foreignCollisions.existingPublicNames
|
|
12299
|
+
existingConfigKeys: foreignCollisions.existingConfigKeys
|
|
12309
12300
|
});
|
|
12310
12301
|
const safeProjectedAgents = filterSafeProjectedAgents(projectedAgents, collisions);
|
|
12311
12302
|
const bindingAgent = resolveBindingAgent({
|
|
@@ -12320,12 +12311,12 @@ function createOpenCodeBootstrap(input) {
|
|
|
12320
12311
|
projection,
|
|
12321
12312
|
sessionID: input.sessionID,
|
|
12322
12313
|
teamId: bindingAgent.teamId,
|
|
12323
|
-
|
|
12314
|
+
canonicalAgentId: bindingAgent.sourceAgentId,
|
|
12324
12315
|
mode: input.selectedMode ?? input.defaults.defaultMode,
|
|
12325
12316
|
source: input.selectedHostAgent || input.selectedSourceAgentId ? "host-agent-selection" : "plugin-default"
|
|
12326
12317
|
}) : void 0;
|
|
12327
12318
|
const defaultProjectedAgent = bindingAgent ? safeProjectedAgents.find(
|
|
12328
|
-
(agent) => agent.teamId === bindingAgent.teamId && agent.
|
|
12319
|
+
(agent) => agent.teamId === bindingAgent.teamId && agent.canonicalAgentId === bindingAgent.sourceAgentId
|
|
12329
12320
|
) : void 0;
|
|
12330
12321
|
const configPatch = createOpenCodeAgentConfigPatch({
|
|
12331
12322
|
agents: safeProjectedAgents,
|
|
@@ -12368,7 +12359,6 @@ var DEFAULT_MODE = "single-executor";
|
|
|
12368
12359
|
function summarizeProjectedAgents(boot) {
|
|
12369
12360
|
return boot.projectedAgents.map((agent) => ({
|
|
12370
12361
|
configKey: agent.configKey,
|
|
12371
|
-
publicName: agent.publicName,
|
|
12372
12362
|
hidden: agent.hidden,
|
|
12373
12363
|
model: agent.resolvedModel ? `${agent.resolvedModel.providerID}/${agent.resolvedModel.modelID}` : void 0
|
|
12374
12364
|
}));
|
|
@@ -25085,27 +25075,15 @@ config(en_default());
|
|
|
25085
25075
|
var zod_default = external_exports;
|
|
25086
25076
|
|
|
25087
25077
|
// src/adapters/opencode/delegation/resolve-agent.ts
|
|
25088
|
-
function findBySourceAgentId(agents, agent) {
|
|
25089
|
-
return agents.find((item) => item.sourceAgentId === agent);
|
|
25090
|
-
}
|
|
25091
25078
|
function resolveDelegateAgent(input) {
|
|
25092
|
-
const bySource = findBySourceAgentId(input.agents, input.agent);
|
|
25093
|
-
if (bySource) {
|
|
25094
|
-
return {
|
|
25095
|
-
agent: bySource,
|
|
25096
|
-
configKey: bySource.configKey,
|
|
25097
|
-
sourceAgentId: bySource.sourceAgentId
|
|
25098
|
-
};
|
|
25099
|
-
}
|
|
25100
25079
|
const bySelection = resolveProjectedAgentSelection(input.agents, {
|
|
25101
|
-
configKey: input.agent
|
|
25102
|
-
publicName: input.agent
|
|
25080
|
+
configKey: input.agent
|
|
25103
25081
|
});
|
|
25104
25082
|
if (bySelection) {
|
|
25105
25083
|
return {
|
|
25106
25084
|
agent: bySelection,
|
|
25107
25085
|
configKey: bySelection.configKey,
|
|
25108
|
-
|
|
25086
|
+
canonicalAgentId: bySelection.canonicalAgentId
|
|
25109
25087
|
};
|
|
25110
25088
|
}
|
|
25111
25089
|
const byAlias = resolveProjectedAgentAlias(input.aliasIndex, input.agent);
|
|
@@ -25115,14 +25093,14 @@ function resolveDelegateAgent(input) {
|
|
|
25115
25093
|
return {
|
|
25116
25094
|
agent: byAlias.agent,
|
|
25117
25095
|
configKey: byAlias.agent.configKey,
|
|
25118
|
-
|
|
25096
|
+
canonicalAgentId: byAlias.agent.canonicalAgentId
|
|
25119
25097
|
};
|
|
25120
25098
|
}
|
|
25121
|
-
function isSelfDelegate(binding3,
|
|
25099
|
+
function isSelfDelegate(binding3, canonicalAgentId) {
|
|
25122
25100
|
if (!binding3) {
|
|
25123
25101
|
return false;
|
|
25124
25102
|
}
|
|
25125
|
-
return binding3.selectedAgentId ===
|
|
25103
|
+
return binding3.selectedAgentId === canonicalAgentId;
|
|
25126
25104
|
}
|
|
25127
25105
|
|
|
25128
25106
|
// src/adapters/opencode/delegation/tool-result.ts
|
|
@@ -25174,7 +25152,7 @@ async function resolveChildSession(input) {
|
|
|
25174
25152
|
input.store.putSession({
|
|
25175
25153
|
sessionID,
|
|
25176
25154
|
parentSessionID: input.parentSessionID,
|
|
25177
|
-
|
|
25155
|
+
canonicalAgentId: input.canonicalAgentId,
|
|
25178
25156
|
configKey: input.configKey
|
|
25179
25157
|
});
|
|
25180
25158
|
return { sessionID, existing: false };
|
|
@@ -25186,7 +25164,7 @@ async function resolveChildSession(input) {
|
|
|
25186
25164
|
if (known.parentSessionID !== input.parentSessionID) {
|
|
25187
25165
|
return createFailedResult(input.args.session_id, "invalid_session_id", "Use a delegated session_id created from the current parent session.");
|
|
25188
25166
|
}
|
|
25189
|
-
if (known.
|
|
25167
|
+
if (known.canonicalAgentId !== input.canonicalAgentId) {
|
|
25190
25168
|
return createFailedResult(input.args.session_id, "agent_session_mismatch", "The delegated session is already bound to a different agent.");
|
|
25191
25169
|
}
|
|
25192
25170
|
await input.client.session.get({ path: { id: input.args.session_id } }).catch(() => {
|
|
@@ -25198,7 +25176,7 @@ async function runForeground(input) {
|
|
|
25198
25176
|
const anchor = await getSessionAnchor(input.client, input.sessionID);
|
|
25199
25177
|
const model = resolveDelegateModel(input.target, input.store.getCheckpoint(input.ctx.sessionID)?.model);
|
|
25200
25178
|
const envelope = createDelegationEnvelope({
|
|
25201
|
-
agent: input.target.
|
|
25179
|
+
agent: input.target.canonicalAgentId,
|
|
25202
25180
|
parentSessionID: input.parentSessionID,
|
|
25203
25181
|
sessionID: input.sessionID,
|
|
25204
25182
|
prompt: input.args.prompt
|
|
@@ -25219,7 +25197,7 @@ async function runForeground(input) {
|
|
|
25219
25197
|
message,
|
|
25220
25198
|
resume_supported: true
|
|
25221
25199
|
};
|
|
25222
|
-
input.ctx.metadata({ title: input.title, metadata: { sessionId: input.sessionID, agent: input.target.
|
|
25200
|
+
input.ctx.metadata({ title: input.title, metadata: { sessionId: input.sessionID, agent: input.target.canonicalAgentId } });
|
|
25223
25201
|
return result;
|
|
25224
25202
|
}
|
|
25225
25203
|
function createBackgroundRecord(input) {
|
|
@@ -25228,7 +25206,7 @@ function createBackgroundRecord(input) {
|
|
|
25228
25206
|
sessionID: input.sessionID,
|
|
25229
25207
|
parentSessionID: input.ctx.sessionID,
|
|
25230
25208
|
parentMessageID: input.ctx.messageID,
|
|
25231
|
-
|
|
25209
|
+
canonicalAgentId: input.target.canonicalAgentId,
|
|
25232
25210
|
configKey: input.target.configKey,
|
|
25233
25211
|
description: input.description,
|
|
25234
25212
|
status: "queued",
|
|
@@ -25240,7 +25218,7 @@ function createBackgroundRecord(input) {
|
|
|
25240
25218
|
function launchBackground(input) {
|
|
25241
25219
|
const model = resolveDelegateModel(input.target, input.store.getCheckpoint(input.ctx.sessionID)?.model);
|
|
25242
25220
|
const envelope = createDelegationEnvelope({
|
|
25243
|
-
agent: input.target.
|
|
25221
|
+
agent: input.target.canonicalAgentId,
|
|
25244
25222
|
parentSessionID: input.ctx.sessionID,
|
|
25245
25223
|
sessionID: input.sessionID,
|
|
25246
25224
|
prompt: input.args.prompt
|
|
@@ -25289,17 +25267,17 @@ function createDelegateTools(input) {
|
|
|
25289
25267
|
return stringifyDelegateTaskResult(createFailedResult(ctx.sessionID, "unknown_agent", `Unknown CrewBee agent: ${args.agent}`));
|
|
25290
25268
|
}
|
|
25291
25269
|
const binding3 = input.bindings.get(ctx.sessionID);
|
|
25292
|
-
if (isSelfDelegate(binding3, target.
|
|
25270
|
+
if (isSelfDelegate(binding3, target.canonicalAgentId)) {
|
|
25293
25271
|
return stringifyDelegateTaskResult(createFailedResult(ctx.sessionID, "self_delegate_forbidden", "Do not delegate a CrewBee session back to the same active agent."));
|
|
25294
25272
|
}
|
|
25295
|
-
const title = createDelegatedTitle(target.
|
|
25273
|
+
const title = createDelegatedTitle(target.canonicalAgentId, args.prompt);
|
|
25296
25274
|
const child = await resolveChildSession({
|
|
25297
25275
|
args,
|
|
25298
25276
|
client: input.client,
|
|
25299
25277
|
parentSessionID: ctx.sessionID,
|
|
25300
25278
|
title,
|
|
25301
25279
|
store: input.store,
|
|
25302
|
-
|
|
25280
|
+
canonicalAgentId: target.canonicalAgentId,
|
|
25303
25281
|
configKey: target.configKey
|
|
25304
25282
|
}).catch((error45) => error45);
|
|
25305
25283
|
if (typeof child === "object" && "status" in child && child.status === "failed") {
|
|
@@ -25341,7 +25319,7 @@ function createDelegateTools(input) {
|
|
|
25341
25319
|
sessionID,
|
|
25342
25320
|
taskRef: record2.taskRef
|
|
25343
25321
|
});
|
|
25344
|
-
ctx.metadata({ title, metadata: { sessionId: sessionID, taskRef: record2.taskRef, agent: target.
|
|
25322
|
+
ctx.metadata({ title, metadata: { sessionId: sessionID, taskRef: record2.taskRef, agent: target.canonicalAgentId } });
|
|
25345
25323
|
return stringifyDelegateTaskResult({
|
|
25346
25324
|
status: "running",
|
|
25347
25325
|
session_id: sessionID,
|