opencode-swarm 6.33.5 → 6.33.7

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.
Files changed (2) hide show
  1. package/dist/index.js +127 -86
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -50891,17 +50891,10 @@ async function getEvidenceTaskId(session, directory) {
50891
50891
  }
50892
50892
  }
50893
50893
  } catch (err2) {
50894
- if (err2 instanceof Error) {
50895
- if (err2 instanceof SyntaxError) {
50896
- return null;
50897
- }
50898
- const code = err2.code;
50899
- if (code === "ENOENT" || code === "ENOTDIR") {
50900
- return null;
50901
- }
50902
- throw err2;
50894
+ if (process.env.DEBUG_SWARM && err2 instanceof Error) {
50895
+ console.warn(`[delegation-gate] getEvidenceTaskId error: ${err2.message} (code=${err2.code ?? "none"})`);
50903
50896
  }
50904
- throw err2;
50897
+ return null;
50905
50898
  }
50906
50899
  return null;
50907
50900
  }
@@ -50995,10 +50988,10 @@ function createDelegationGateHook(config3, directory) {
50995
50988
  }
50996
50989
  }
50997
50990
  if (typeof subagentType === "string") {
50998
- const rawTaskId = directArgs?.task_id;
50999
- const evidenceTaskId = typeof rawTaskId === "string" && rawTaskId.length <= 20 && /^\d+\.\d+$/.test(rawTaskId.trim()) ? rawTaskId.trim() : await getEvidenceTaskId(session, directory);
51000
- if (evidenceTaskId) {
51001
- try {
50991
+ try {
50992
+ const rawTaskId = directArgs?.task_id;
50993
+ const evidenceTaskId = typeof rawTaskId === "string" && rawTaskId.length <= 20 && /^\d+\.\d+$/.test(rawTaskId.trim()) ? rawTaskId.trim() : await getEvidenceTaskId(session, directory);
50994
+ if (evidenceTaskId) {
51002
50995
  const turbo = hasActiveTurboMode();
51003
50996
  const gateAgents = [
51004
50997
  "reviewer",
@@ -51017,9 +51010,9 @@ function createDelegationGateHook(config3, directory) {
51017
51010
  const { recordAgentDispatch: recordAgentDispatch2 } = await Promise.resolve().then(() => (init_gate_evidence(), exports_gate_evidence));
51018
51011
  await recordAgentDispatch2(directory, evidenceTaskId, targetAgentForEvidence, turbo);
51019
51012
  }
51020
- } catch (err2) {
51021
- console.warn(`[delegation-gate] evidence write failed for task ${evidenceTaskId}: ${err2 instanceof Error ? err2.message : String(err2)}`);
51022
51013
  }
51014
+ } catch (err2) {
51015
+ console.warn(`[delegation-gate] evidence recording failed: ${err2 instanceof Error ? err2.message : String(err2)}`);
51023
51016
  }
51024
51017
  }
51025
51018
  if (storedArgs !== undefined) {
@@ -51114,24 +51107,22 @@ function createDelegationGateHook(config3, directory) {
51114
51107
  }
51115
51108
  }
51116
51109
  }
51117
- {
51110
+ try {
51118
51111
  const rawTaskId = directArgs?.task_id;
51119
51112
  const evidenceTaskId = typeof rawTaskId === "string" && rawTaskId.length <= 20 && /^\d+\.\d+$/.test(rawTaskId.trim()) ? rawTaskId.trim() : await getEvidenceTaskId(session, directory);
51120
51113
  if (evidenceTaskId) {
51121
- try {
51122
- const turbo = hasActiveTurboMode();
51123
- if (hasReviewer) {
51124
- const { recordGateEvidence: recordGateEvidence2 } = await Promise.resolve().then(() => (init_gate_evidence(), exports_gate_evidence));
51125
- await recordGateEvidence2(directory, evidenceTaskId, "reviewer", input.sessionID, turbo);
51126
- }
51127
- if (hasTestEngineer) {
51128
- const { recordGateEvidence: recordGateEvidence2 } = await Promise.resolve().then(() => (init_gate_evidence(), exports_gate_evidence));
51129
- await recordGateEvidence2(directory, evidenceTaskId, "test_engineer", input.sessionID, turbo);
51130
- }
51131
- } catch (err2) {
51132
- console.warn(`[delegation-gate] evidence write failed for task ${evidenceTaskId}: ${err2 instanceof Error ? err2.message : String(err2)}`);
51114
+ const turbo = hasActiveTurboMode();
51115
+ if (hasReviewer) {
51116
+ const { recordGateEvidence: recordGateEvidence2 } = await Promise.resolve().then(() => (init_gate_evidence(), exports_gate_evidence));
51117
+ await recordGateEvidence2(directory, evidenceTaskId, "reviewer", input.sessionID, turbo);
51118
+ }
51119
+ if (hasTestEngineer) {
51120
+ const { recordGateEvidence: recordGateEvidence2 } = await Promise.resolve().then(() => (init_gate_evidence(), exports_gate_evidence));
51121
+ await recordGateEvidence2(directory, evidenceTaskId, "test_engineer", input.sessionID, turbo);
51133
51122
  }
51134
51123
  }
51124
+ } catch (err2) {
51125
+ console.warn(`[delegation-gate] fallback evidence recording failed: ${err2 instanceof Error ? err2.message : String(err2)}`);
51135
51126
  }
51136
51127
  }
51137
51128
  }
@@ -55065,6 +55056,17 @@ async function rehydrateState(snapshot) {
55065
55056
  window2.warningReason = "";
55066
55057
  }
55067
55058
  }
55059
+ session.revisionLimitHit = false;
55060
+ session.coderRevisions = 0;
55061
+ session.selfFixAttempted = false;
55062
+ session.lastGateFailure = null;
55063
+ session.architectWriteCount = 0;
55064
+ session.selfCodingWarnedAtCount = 0;
55065
+ session.pendingAdvisoryMessages = [];
55066
+ session.model_fallback_index = 0;
55067
+ session.modelFallbackExhausted = false;
55068
+ session.scopeViolationDetected = false;
55069
+ session.delegationActive = false;
55068
55070
  swarmState.agentSessions.set(sessionId, session);
55069
55071
  }
55070
55072
  }
@@ -65256,6 +65258,7 @@ var OpenCodeSwarm = async (ctx) => {
65256
65258
  },
65257
65259
  "experimental.chat.messages.transform": composeHandlers(...[
65258
65260
  (input, _output) => {
65261
+ console.error(`[DIAG] messagesTransform START`);
65259
65262
  const p = input;
65260
65263
  if (p.sessionID) {
65261
65264
  const archAgent = swarmState.activeAgent.get(p.sessionID);
@@ -65279,16 +65282,24 @@ var OpenCodeSwarm = async (ctx) => {
65279
65282
  if (output.messages) {
65280
65283
  output.messages = consolidateSystemMessages(output.messages);
65281
65284
  }
65285
+ console.error(`[DIAG] messagesTransform DONE`);
65282
65286
  return Promise.resolve();
65283
65287
  }
65284
65288
  ].filter((fn) => Boolean(fn))),
65285
65289
  "experimental.chat.system.transform": composeHandlers(...[
65290
+ async (input, output) => {
65291
+ console.error(`[DIAG] systemTransform START`);
65292
+ },
65286
65293
  systemEnhancerHook["experimental.chat.system.transform"],
65294
+ async (_input, _output) => {
65295
+ console.error(`[DIAG] systemTransform enhancer DONE`);
65296
+ },
65287
65297
  automationConfig.capabilities?.phase_preflight === true && preflightTriggerManager ? createPhaseMonitorHook(ctx.directory, preflightTriggerManager) : knowledgeConfig.enabled ? createPhaseMonitorHook(ctx.directory) : undefined
65288
65298
  ].filter(Boolean)),
65289
65299
  "experimental.session.compacting": compactionHook["experimental.session.compacting"],
65290
65300
  "command.execute.before": safeHook(commandHandler),
65291
65301
  "tool.execute.before": async (input, output) => {
65302
+ console.error(`[DIAG] toolBefore tool=${input.tool?.replace?.(/^[^:]+[:.]/, "") ?? input.tool} session=${input.sessionID}`);
65292
65303
  if (!swarmState.activeAgent.has(input.sessionID)) {
65293
65304
  swarmState.activeAgent.set(input.sessionID, ORCHESTRATOR_NAME);
65294
65305
  }
@@ -65297,7 +65308,7 @@ var OpenCodeSwarm = async (ctx) => {
65297
65308
  if (session && activeAgent && activeAgent !== ORCHESTRATOR_NAME) {
65298
65309
  const stripActive = stripKnownSwarmPrefix(activeAgent);
65299
65310
  if (stripActive !== ORCHESTRATOR_NAME) {
65300
- const staleDelegation = !session.delegationActive || Date.now() - session.lastAgentEventTime > 1e4;
65311
+ const staleDelegation = !session.delegationActive && Date.now() - session.lastAgentEventTime > 1e4;
65301
65312
  if (staleDelegation) {
65302
65313
  swarmState.activeAgent.set(input.sessionID, ORCHESTRATOR_NAME);
65303
65314
  ensureAgentSession(input.sessionID, ORCHESTRATOR_NAME);
@@ -65317,72 +65328,102 @@ var OpenCodeSwarm = async (ctx) => {
65317
65328
  await safeHook(activityHooks.toolBefore)(input, output);
65318
65329
  },
65319
65330
  "tool.execute.after": async (input, output) => {
65320
- if (process.env.DEBUG_SWARM) {
65321
- console.debug("[hook-chain] toolAfter start sessionID=%s agent=%s tool=%s", input.sessionID, input.agent, input.tool?.name);
65322
- }
65323
- await activityHooks.toolAfter(input, output);
65324
- await guardrailsHooks.toolAfter(input, output);
65325
- await safeHook(delegationLedgerHook.toolAfter)(input, output);
65326
- await safeHook(selfReviewHook.toolAfter)(input, output);
65327
- await safeHook(delegationGateHooks.toolAfter)(input, output);
65328
- if (knowledgeCuratorHook)
65329
- await safeHook(knowledgeCuratorHook)(input, output);
65330
- if (hivePromoterHook)
65331
- await safeHook(hivePromoterHook)(input, output);
65332
- await safeHook(steeringConsumedHook)(input, output);
65333
- await safeHook(coChangeSuggesterHook)(input, output);
65334
- await safeHook(darkMatterDetectorHook)(input, output);
65335
- await snapshotWriterHook(input, output);
65336
- await toolSummarizerHook?.(input, output);
65337
- const execMode = config3.execution_mode ?? "balanced";
65338
- if (execMode === "strict") {
65339
- if (slopDetectorHook)
65340
- await slopDetectorHook.toolAfter(input, output);
65341
- if (incrementalVerifyHook)
65342
- await incrementalVerifyHook.toolAfter(input, output);
65343
- if (compactionServiceHook)
65344
- await compactionServiceHook.toolAfter(input, output);
65345
- }
65346
- const toolOutputConfig = config3.tool_output;
65347
- if (toolOutputConfig && toolOutputConfig.truncation_enabled !== false && typeof output.output === "string") {
65348
- const defaultTruncatableTools = new Set([
65349
- "diff",
65350
- "symbols",
65351
- "bash",
65352
- "shell",
65353
- "test_runner",
65354
- "lint",
65355
- "pre_check_batch",
65356
- "complexity_hotspots",
65357
- "pkg_audit",
65358
- "sbom_generate",
65359
- "schema_drift"
65360
- ]);
65361
- const configuredTools = toolOutputConfig.truncation_tools;
65362
- const truncatableTools = configuredTools && configuredTools.length > 0 ? new Set(configuredTools) : defaultTruncatableTools;
65363
- const maxLines = toolOutputConfig.per_tool?.[input.tool] ?? toolOutputConfig.max_lines ?? 150;
65364
- if (truncatableTools.has(input.tool)) {
65365
- output.output = truncateToolOutput(output.output, maxLines, input.tool, 10);
65366
- }
65367
- }
65331
+ const _toolName = input.tool?.replace?.(/^[^:]+[:.]/, "") ?? input.tool;
65332
+ console.error(`[DIAG] toolAfter START tool=${_toolName} session=${input.sessionID}`);
65368
65333
  const normalizedTool = input.tool.replace(/^[^:]+[:.]/, "");
65369
- if (normalizedTool === "Task" || normalizedTool === "task") {
65334
+ const isTaskTool = normalizedTool === "Task" || normalizedTool === "task";
65335
+ if (isTaskTool) {
65370
65336
  const sessionId = input.sessionID;
65371
65337
  swarmState.activeAgent.set(sessionId, ORCHESTRATOR_NAME);
65372
65338
  ensureAgentSession(sessionId, ORCHESTRATOR_NAME);
65373
- const session = swarmState.agentSessions.get(sessionId);
65374
- if (session) {
65375
- session.delegationActive = false;
65376
- session.lastAgentEventTime = Date.now();
65339
+ const taskSession = swarmState.agentSessions.get(sessionId);
65340
+ if (taskSession) {
65341
+ taskSession.delegationActive = false;
65342
+ taskSession.lastAgentEventTime = Date.now();
65343
+ }
65344
+ console.error(`[DIAG] Task handoff DONE (early) session=${sessionId} activeAgent=${swarmState.activeAgent.get(sessionId)}`);
65345
+ }
65346
+ const HOOK_CHAIN_TIMEOUT_MS = 30000;
65347
+ const hookChainStart = Date.now();
65348
+ let hookChainTimedOut = false;
65349
+ const hookChain = async () => {
65350
+ await activityHooks.toolAfter(input, output);
65351
+ console.error(`[DIAG] toolAfter activity done tool=${_toolName}`);
65352
+ await guardrailsHooks.toolAfter(input, output);
65353
+ console.error(`[DIAG] toolAfter guardrails done tool=${_toolName}`);
65354
+ await safeHook(delegationLedgerHook.toolAfter)(input, output);
65355
+ console.error(`[DIAG] toolAfter ledger done tool=${_toolName}`);
65356
+ await safeHook(selfReviewHook.toolAfter)(input, output);
65357
+ console.error(`[DIAG] toolAfter selfReview done tool=${_toolName}`);
65358
+ await safeHook(delegationGateHooks.toolAfter)(input, output);
65359
+ console.error(`[DIAG] toolAfter delegationGate done tool=${_toolName}`);
65360
+ if (knowledgeCuratorHook)
65361
+ await safeHook(knowledgeCuratorHook)(input, output);
65362
+ if (hivePromoterHook)
65363
+ await safeHook(hivePromoterHook)(input, output);
65364
+ console.error(`[DIAG] toolAfter knowledge done tool=${_toolName}`);
65365
+ await safeHook(steeringConsumedHook)(input, output);
65366
+ await safeHook(coChangeSuggesterHook)(input, output);
65367
+ await safeHook(darkMatterDetectorHook)(input, output);
65368
+ console.error(`[DIAG] toolAfter intelligence done tool=${_toolName}`);
65369
+ await snapshotWriterHook(input, output);
65370
+ await toolSummarizerHook?.(input, output);
65371
+ console.error(`[DIAG] toolAfter snapshot+summarizer done tool=${_toolName}`);
65372
+ const execMode = config3.execution_mode ?? "balanced";
65373
+ if (execMode === "strict") {
65374
+ if (slopDetectorHook)
65375
+ await slopDetectorHook.toolAfter(input, output);
65376
+ if (incrementalVerifyHook)
65377
+ await incrementalVerifyHook.toolAfter(input, output);
65378
+ if (compactionServiceHook)
65379
+ await compactionServiceHook.toolAfter(input, output);
65380
+ }
65381
+ const toolOutputConfig = config3.tool_output;
65382
+ if (toolOutputConfig && toolOutputConfig.truncation_enabled !== false && typeof output.output === "string") {
65383
+ const defaultTruncatableTools = new Set([
65384
+ "diff",
65385
+ "symbols",
65386
+ "bash",
65387
+ "shell",
65388
+ "test_runner",
65389
+ "lint",
65390
+ "pre_check_batch",
65391
+ "complexity_hotspots",
65392
+ "pkg_audit",
65393
+ "sbom_generate",
65394
+ "schema_drift"
65395
+ ]);
65396
+ const configuredTools = toolOutputConfig.truncation_tools;
65397
+ const truncatableTools = configuredTools && configuredTools.length > 0 ? new Set(configuredTools) : defaultTruncatableTools;
65398
+ const maxLines = toolOutputConfig.per_tool?.[input.tool] ?? toolOutputConfig.max_lines ?? 150;
65399
+ if (truncatableTools.has(input.tool)) {
65400
+ output.output = truncateToolOutput(output.output, maxLines, input.tool, 10);
65401
+ }
65377
65402
  }
65403
+ };
65404
+ const timeout = new Promise((resolve23) => {
65405
+ setTimeout(() => {
65406
+ hookChainTimedOut = true;
65407
+ resolve23();
65408
+ }, HOOK_CHAIN_TIMEOUT_MS);
65409
+ });
65410
+ await Promise.race([
65411
+ hookChain().catch((err2) => {
65412
+ console.error(`[DIAG] toolAfter hook chain error tool=${_toolName}: ${err2 instanceof Error ? err2.message : String(err2)}`);
65413
+ }),
65414
+ timeout
65415
+ ]);
65416
+ if (hookChainTimedOut) {
65417
+ const elapsed = Date.now() - hookChainStart;
65418
+ console.error(`[DIAG] toolAfter TIMEOUT after ${elapsed}ms tool=${_toolName} session=${input.sessionID} \u2014 hooks abandoned to prevent session freeze`);
65378
65419
  }
65379
65420
  deleteStoredInputArgs(input.callID);
65421
+ console.error(`[DIAG] toolAfter COMPLETE tool=${_toolName}`);
65380
65422
  },
65381
65423
  "chat.message": safeHook(async (input, output) => {
65382
- if (process.env.DEBUG_SWARM) {
65383
- console.debug("[session] chat.message sessionID=%s agent=%s", input.sessionID, input.agent);
65384
- }
65424
+ console.error(`[DIAG] chat.message agent=${input.agent ?? "none"} session=${input.sessionID}`);
65385
65425
  await delegationHandler(input, output);
65426
+ console.error(`[DIAG] chat.message DONE agent=${input.agent ?? "none"}`);
65386
65427
  }),
65387
65428
  automation: automationManager
65388
65429
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-swarm",
3
- "version": "6.33.5",
3
+ "version": "6.33.7",
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",