opencode-swarm 7.66.1 → 7.66.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.
@@ -17,6 +17,15 @@ export type { AgentDefinition } from './architect';
17
17
  * Returns the name unchanged if `swarmPrefix` is empty or does not match.
18
18
  */
19
19
  export declare function stripSwarmPrefix(agentName: string, swarmPrefix?: string): string;
20
+ /**
21
+ * Extract the swarm ID from a prefixed agent name.
22
+ * For multi-swarm configurations, agent names are prefixed: "swarmId_agentName"
23
+ * For the default swarm, agent names have no prefix.
24
+ *
25
+ * Example: "local_coder" -> "local", "coder" -> undefined (default swarm)
26
+ * The regex matches everything before the first underscore.
27
+ */
28
+ export declare function extractSwarmIdFromAgentName(agentName: string): string | undefined;
20
29
  /**
21
30
  * Resolve the fallback model for an agent based on its config and fallback index.
22
31
  * Called by guardrails at runtime when a transient model error is detected.
@@ -33,8 +42,12 @@ export declare function resolveFallbackModel(agentBaseName: string, fallbackInde
33
42
  }>): string | null;
34
43
  /**
35
44
  * Get the swarm agents config (for runtime fallback resolution by guardrails).
45
+ *
46
+ * @param swarmId - The swarm ID to retrieve config for. Defaults to 'default' for the default swarm.
47
+ * For multi-swarm configs, use the swarm's ID (e.g., 'local', 'fast', 'precise').
48
+ * Can also be extracted from a prefixed agent name using extractSwarmIdFromAgentName().
36
49
  */
37
- export declare function getSwarmAgents(): Record<string, {
50
+ export declare function getSwarmAgents(swarmId?: string): Record<string, {
38
51
  model?: string;
39
52
  fallback_models?: string[];
40
53
  disabled?: boolean;
package/dist/cli/index.js CHANGED
@@ -52,7 +52,7 @@ var package_default;
52
52
  var init_package = __esm(() => {
53
53
  package_default = {
54
54
  name: "opencode-swarm",
55
- version: "7.66.1",
55
+ version: "7.66.3",
56
56
  description: "Architect-centric agentic swarm plugin for OpenCode - hub-and-spoke orchestration with SME consultation, code generation, and QA review",
57
57
  main: "dist/index.js",
58
58
  types: "dist/index.d.ts",
@@ -18788,7 +18788,7 @@ var init_schema = __esm(() => {
18788
18788
  const trimmed = v.trim();
18789
18789
  return trimmed === "" ? false : trimmed;
18790
18790
  }),
18791
- swarms: exports_external.record(exports_external.string(), SwarmConfigSchema).optional(),
18791
+ swarms: exports_external.record(exports_external.string().regex(/^[^_]+$/, "Swarm ID must not contain underscores"), SwarmConfigSchema).optional(),
18792
18792
  max_iterations: exports_external.number().min(1).max(10).default(5),
18793
18793
  pipeline: PipelineConfigSchema.optional(),
18794
18794
  phase_complete: PhaseCompleteConfigSchema.optional(),
@@ -22299,7 +22299,7 @@ var init_docs = () => {};
22299
22299
  // src/agents/reviewer.ts
22300
22300
  var init_reviewer = () => {};
22301
22301
  // src/agents/index.ts
22302
- var warnedAgents, KNOWN_VARIANT_VALUES;
22302
+ var warnedAgents, _swarmAgentsMap, KNOWN_VARIANT_VALUES;
22303
22303
  var init_agents2 = __esm(() => {
22304
22304
  init_config();
22305
22305
  init_constants();
@@ -22318,6 +22318,7 @@ var init_agents2 = __esm(() => {
22318
22318
  init_docs();
22319
22319
  init_reviewer();
22320
22320
  warnedAgents = new Set;
22321
+ _swarmAgentsMap = new Map;
22321
22322
  KNOWN_VARIANT_VALUES = new Set([
22322
22323
  "low",
22323
22324
  "medium",
@@ -7,10 +7,11 @@
7
7
  * - Layer 2 (Hard Block @ 100%): Throws error in toolBefore to block further calls, injects STOP message
8
8
  */
9
9
  import * as path from 'node:path';
10
- import { getSwarmAgents, resolveFallbackModel } from '../agents/index';
10
+ import { extractSwarmIdFromAgentName, getSwarmAgents, resolveFallbackModel } from '../agents/index';
11
11
  import { type AuthorityConfig, type GuardrailsConfig } from '../config/schema';
12
12
  import { type FileZone } from '../context/zone-classifier';
13
13
  export declare const _internals: {
14
+ extractSwarmIdFromAgentName: typeof extractSwarmIdFromAgentName;
14
15
  getSwarmAgents: typeof getSwarmAgents;
15
16
  getMostRecentAssistantText: typeof getMostRecentAssistantText;
16
17
  getProviderFailureFingerprint: typeof getProviderFailureFingerprint;
package/dist/index.js CHANGED
@@ -69,7 +69,7 @@ var package_default;
69
69
  var init_package = __esm(() => {
70
70
  package_default = {
71
71
  name: "opencode-swarm",
72
- version: "7.66.1",
72
+ version: "7.66.3",
73
73
  description: "Architect-centric agentic swarm plugin for OpenCode - hub-and-spoke orchestration with SME consultation, code generation, and QA review",
74
74
  main: "dist/index.js",
75
75
  types: "dist/index.d.ts",
@@ -16129,7 +16129,7 @@ var init_schema = __esm(() => {
16129
16129
  const trimmed = v.trim();
16130
16130
  return trimmed === "" ? false : trimmed;
16131
16131
  }),
16132
- swarms: exports_external.record(exports_external.string(), SwarmConfigSchema).optional(),
16132
+ swarms: exports_external.record(exports_external.string().regex(/^[^_]+$/, "Swarm ID must not contain underscores"), SwarmConfigSchema).optional(),
16133
16133
  max_iterations: exports_external.number().min(1).max(10).default(5),
16134
16134
  pipeline: PipelineConfigSchema.optional(),
16135
16135
  phase_complete: PhaseCompleteConfigSchema.optional(),
@@ -40726,8 +40726,9 @@ function createGuardrailsHooks(directory, directoryOrConfig, config2, authorityC
40726
40726
  const isContentFilter = CONTENT_FILTER_PATTERN.test(errorSignal);
40727
40727
  if (session && !session.modelFallbackExhausted) {
40728
40728
  session.model_fallback_index++;
40729
+ const swarmId = _internals16.extractSwarmIdFromAgentName(session.agentName);
40729
40730
  const baseAgentName = session.agentName ? session.agentName.replace(/^[^_]+[_]/, "") : "";
40730
- const swarmAgents = _internals16.getSwarmAgents();
40731
+ const swarmAgents = _internals16.getSwarmAgents(swarmId);
40731
40732
  const fallbackModels = swarmAgents?.[baseAgentName]?.fallback_models;
40732
40733
  session.modelFallbackExhausted = !fallbackModels || session.model_fallback_index > fallbackModels.length;
40733
40734
  session.pendingAdvisoryMessages ??= [];
@@ -40750,8 +40751,9 @@ function createGuardrailsHooks(directory, directoryOrConfig, config2, authorityC
40750
40751
  let modelFallbackAdvisoryEmitted = false;
40751
40752
  if (session && isTransientMatch && !session.modelFallbackExhausted && !isDegraded) {
40752
40753
  session.model_fallback_index++;
40754
+ const swarmId = _internals16.extractSwarmIdFromAgentName(session.agentName);
40753
40755
  const baseAgentName = session.agentName ? session.agentName.replace(/^[^_]+[_]/, "") : "";
40754
- const swarmAgents = _internals16.getSwarmAgents();
40756
+ const swarmAgents = _internals16.getSwarmAgents(swarmId);
40755
40757
  const fallbackModels = swarmAgents?.[baseAgentName]?.fallback_models;
40756
40758
  session.modelFallbackExhausted = !fallbackModels || session.model_fallback_index > fallbackModels.length;
40757
40759
  const fallbackModel = _internals16.resolveFallbackModel(baseAgentName, session.model_fallback_index, swarmAgents);
@@ -41433,6 +41435,7 @@ var init_guardrails = __esm(() => {
41433
41435
  "**/.golangci*"
41434
41436
  ];
41435
41437
  _internals16 = {
41438
+ extractSwarmIdFromAgentName,
41436
41439
  getSwarmAgents,
41437
41440
  getMostRecentAssistantText,
41438
41441
  getProviderFailureFingerprint,
@@ -91504,6 +91507,12 @@ function stripSwarmPrefix(agentName, swarmPrefix) {
91504
91507
  }
91505
91508
  return agentName;
91506
91509
  }
91510
+ function extractSwarmIdFromAgentName(agentName) {
91511
+ if (!agentName)
91512
+ return;
91513
+ const match = agentName.match(/^([^_]+)_/);
91514
+ return match ? match[1] : undefined;
91515
+ }
91507
91516
  function getModelForAgent(agentName, swarmAgents, swarmPrefix, quiet) {
91508
91517
  const baseAgentName = stripSwarmPrefix(agentName, swarmPrefix);
91509
91518
  const explicit = swarmAgents?.[baseAgentName]?.model;
@@ -91532,8 +91541,9 @@ function resolveFallbackModel(agentBaseName, fallbackIndex, swarmAgents) {
91532
91541
  return null;
91533
91542
  return fallbackModels[fallbackIndex - 1];
91534
91543
  }
91535
- function getSwarmAgents() {
91536
- return _swarmAgents;
91544
+ function getSwarmAgents(swarmId) {
91545
+ const id = swarmId ?? "default";
91546
+ return _swarmAgentsMap.get(id);
91537
91547
  }
91538
91548
  function isAgentDisabled(agentName, swarmAgents, swarmPrefix) {
91539
91549
  const baseAgentName = stripSwarmPrefix(agentName, swarmPrefix);
@@ -91575,7 +91585,7 @@ function applyOverrides(agent, swarmAgents, swarmPrefix, quiet) {
91575
91585
  function createSwarmAgents(swarmId, swarmConfig, isDefault, pluginConfig, projectContext = emptyProjectContext()) {
91576
91586
  const agents = [];
91577
91587
  const swarmAgents = swarmConfig.agents;
91578
- _swarmAgents = swarmAgents;
91588
+ _swarmAgentsMap.set(swarmId, swarmAgents ?? {});
91579
91589
  const prefix = isDefault ? "" : `${swarmId}_`;
91580
91590
  const swarmPrefix = isDefault ? undefined : swarmId;
91581
91591
  const qaRetryLimit = pluginConfig?.qa_retry_limit ?? 3;
@@ -91754,6 +91764,7 @@ function createAgents(config3, projectContext = emptyProjectContext()) {
91754
91764
  const allAgents = [];
91755
91765
  const swarms = config3?.swarms;
91756
91766
  if (swarms && Object.keys(swarms).length > 0) {
91767
+ _swarmAgentsMap.set("default", {});
91757
91768
  for (const swarmId of Object.keys(swarms)) {
91758
91769
  let swarmConfig = swarms[swarmId];
91759
91770
  const isDefault = swarmId === "default";
@@ -91948,7 +91959,7 @@ function getAgentConfigs(config3, directory, sessionId, projectContext) {
91948
91959
  }
91949
91960
  return result;
91950
91961
  }
91951
- var warnedAgents, _swarmAgents, KNOWN_VARIANT_VALUES;
91962
+ var warnedAgents, _swarmAgentsMap, KNOWN_VARIANT_VALUES;
91952
91963
  var init_agents2 = __esm(() => {
91953
91964
  init_config();
91954
91965
  init_constants();
@@ -91967,6 +91978,7 @@ var init_agents2 = __esm(() => {
91967
91978
  init_docs();
91968
91979
  init_reviewer();
91969
91980
  warnedAgents = new Set;
91981
+ _swarmAgentsMap = new Map;
91970
91982
  KNOWN_VARIANT_VALUES = new Set([
91971
91983
  "low",
91972
91984
  "medium",
@@ -138033,22 +138045,22 @@ async function initializeOpenCodeSwarm(ctx) {
138033
138045
  const guardrailsFallback = config3.guardrails?.enabled === false ? { ...config3.guardrails, enabled: false } : config3.guardrails ?? {};
138034
138046
  const guardrailsConfig = GuardrailsConfigSchema.parse(guardrailsFallback);
138035
138047
  if (loadedFromFile && guardrailsConfig.enabled === false) {
138036
- console.warn("");
138037
- console.warn("══════════════════════════════════════════════════════════════");
138038
- console.warn("[opencode-swarm] \uD83D\uDD34 SECURITY WARNING: GUARDRAILS ARE DISABLED");
138039
- console.warn("══════════════════════════════════════════════════════════════");
138040
- console.warn("Guardrails have been explicitly disabled in user configuration.");
138041
- console.warn("This disables safety measures including:");
138042
- console.warn(" - Tool call limits");
138043
- console.warn(" - Duration limits");
138044
- console.warn(" - Repetition detection");
138045
- console.warn(" - Error rate limits");
138046
- console.warn(" - Idle timeouts");
138047
- console.warn("");
138048
- console.warn("Only disable guardrails if you fully understand the security implications.");
138049
- console.warn('To re-enable guardrails, set "guardrails.enabled" to true in your config.');
138050
- console.warn("══════════════════════════════════════════════════════════════");
138051
- console.warn("");
138048
+ warn("");
138049
+ warn("══════════════════════════════════════════════════════════════");
138050
+ warn("[opencode-swarm] \uD83D\uDD34 SECURITY WARNING: GUARDRAILS ARE DISABLED");
138051
+ warn("══════════════════════════════════════════════════════════════");
138052
+ warn("Guardrails have been explicitly disabled in user configuration.");
138053
+ warn("This disables safety measures including:");
138054
+ warn(" - Tool call limits");
138055
+ warn(" - Duration limits");
138056
+ warn(" - Repetition detection");
138057
+ warn(" - Error rate limits");
138058
+ warn(" - Idle timeouts");
138059
+ warn("");
138060
+ warn("Only disable guardrails if you fully understand the security implications.");
138061
+ warn('To re-enable guardrails, set "guardrails.enabled" to true in your config.');
138062
+ warn("══════════════════════════════════════════════════════════════");
138063
+ warn("");
138052
138064
  }
138053
138065
  const delegationHandler = createDelegationTrackerHook(config3, guardrailsConfig.enabled);
138054
138066
  const authorityConfig = AuthorityConfigSchema.parse(config3.authority ?? {});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-swarm",
3
- "version": "7.66.1",
3
+ "version": "7.66.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",