opencode-swarm 5.0.2 → 5.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/schema.d.ts +12 -0
- package/dist/index.js +25 -4
- package/package.json +1 -1
package/dist/config/schema.d.ts
CHANGED
|
@@ -62,6 +62,18 @@ export declare const GuardrailsConfigSchema: z.ZodObject<{
|
|
|
62
62
|
}, z.core.$strip>>>;
|
|
63
63
|
}, z.core.$strip>;
|
|
64
64
|
export type GuardrailsConfig = z.infer<typeof GuardrailsConfigSchema>;
|
|
65
|
+
/**
|
|
66
|
+
* Strip any swarm prefix from an agent name to get the base agent name.
|
|
67
|
+
* Works with any swarm name by checking if the name (or suffix after removing
|
|
68
|
+
* a prefix) matches a known agent name from ALL_AGENT_NAMES.
|
|
69
|
+
*
|
|
70
|
+
* Examples: 'local_architect' → 'architect', 'enterprise_coder' → 'coder',
|
|
71
|
+
* 'architect' → 'architect', 'unknown_thing' → 'unknown_thing'
|
|
72
|
+
*
|
|
73
|
+
* @param name - The agent name (possibly prefixed)
|
|
74
|
+
* @returns The base agent name if recognized, or the original name
|
|
75
|
+
*/
|
|
76
|
+
export declare function stripKnownSwarmPrefix(name: string): string;
|
|
65
77
|
/**
|
|
66
78
|
* Resolve guardrails configuration for a specific agent.
|
|
67
79
|
* Merges the base config with built-in defaults (for the architect) and
|
package/dist/index.js
CHANGED
|
@@ -13638,12 +13638,26 @@ var GuardrailsConfigSchema = exports_external.object({
|
|
|
13638
13638
|
warning_threshold: exports_external.number().min(0.1).max(0.9).default(0.5),
|
|
13639
13639
|
profiles: exports_external.record(exports_external.string(), GuardrailsProfileSchema).optional()
|
|
13640
13640
|
});
|
|
13641
|
+
function stripKnownSwarmPrefix(name) {
|
|
13642
|
+
if (!name)
|
|
13643
|
+
return name;
|
|
13644
|
+
if (ALL_AGENT_NAMES.includes(name))
|
|
13645
|
+
return name;
|
|
13646
|
+
for (const agentName of ALL_AGENT_NAMES) {
|
|
13647
|
+
const suffix = `_${agentName}`;
|
|
13648
|
+
if (name.endsWith(suffix)) {
|
|
13649
|
+
return agentName;
|
|
13650
|
+
}
|
|
13651
|
+
}
|
|
13652
|
+
return name;
|
|
13653
|
+
}
|
|
13641
13654
|
function resolveGuardrailsConfig(base, agentName) {
|
|
13642
13655
|
if (!agentName) {
|
|
13643
13656
|
return base;
|
|
13644
13657
|
}
|
|
13645
|
-
const
|
|
13646
|
-
const
|
|
13658
|
+
const baseName = stripKnownSwarmPrefix(agentName);
|
|
13659
|
+
const builtIn = baseName === ORCHESTRATOR_NAME ? DEFAULT_ARCHITECT_PROFILE : undefined;
|
|
13660
|
+
const userProfile = base.profiles?.[baseName] ?? base.profiles?.[agentName];
|
|
13647
13661
|
if (!builtIn && !userProfile) {
|
|
13648
13662
|
return base;
|
|
13649
13663
|
}
|
|
@@ -16222,12 +16236,19 @@ function createGuardrailsHooks(config2) {
|
|
|
16222
16236
|
toolBefore: async (input, output) => {
|
|
16223
16237
|
let session = getAgentSession(input.sessionID);
|
|
16224
16238
|
if (!session) {
|
|
16225
|
-
|
|
16239
|
+
const agentName = swarmState.activeAgent.get(input.sessionID) ?? "unknown";
|
|
16240
|
+
startAgentSession(input.sessionID, agentName);
|
|
16226
16241
|
session = getAgentSession(input.sessionID);
|
|
16227
16242
|
if (!session) {
|
|
16228
16243
|
warn(`Failed to create session for ${input.sessionID}`);
|
|
16229
16244
|
return;
|
|
16230
16245
|
}
|
|
16246
|
+
} else if (session.agentName === "unknown") {
|
|
16247
|
+
const activeAgentName = swarmState.activeAgent.get(input.sessionID);
|
|
16248
|
+
if (activeAgentName) {
|
|
16249
|
+
session.agentName = activeAgentName;
|
|
16250
|
+
session.startTime = Date.now();
|
|
16251
|
+
}
|
|
16231
16252
|
}
|
|
16232
16253
|
const agentConfig = resolveGuardrailsConfig(config2, session.agentName);
|
|
16233
16254
|
if (session.hardLimitHit) {
|
|
@@ -16467,7 +16488,7 @@ function extractAgentContext(contextContent, activeAgent, maxChars) {
|
|
|
16467
16488
|
const activitySection = activityMatch[1].trim();
|
|
16468
16489
|
if (!activitySection || activitySection === "No tool activity recorded yet.")
|
|
16469
16490
|
return null;
|
|
16470
|
-
const agentName = activeAgent
|
|
16491
|
+
const agentName = stripKnownSwarmPrefix(activeAgent);
|
|
16471
16492
|
let contextSummary;
|
|
16472
16493
|
switch (agentName) {
|
|
16473
16494
|
case "coder":
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-swarm",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.3",
|
|
4
4
|
"description": "Architect-centric agentic swarm plugin for OpenCode - hub-and-spoke orchestration with SME consultation, code generation, and QA review",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|