opencode-swarm 6.33.6 → 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.
- package/dist/index.js +115 -85
- 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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
50999
|
-
|
|
51000
|
-
|
|
51001
|
-
|
|
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
|
-
|
|
51122
|
-
|
|
51123
|
-
|
|
51124
|
-
|
|
51125
|
-
|
|
51126
|
-
|
|
51127
|
-
|
|
51128
|
-
|
|
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
|
}
|
|
@@ -65267,6 +65258,7 @@ var OpenCodeSwarm = async (ctx) => {
|
|
|
65267
65258
|
},
|
|
65268
65259
|
"experimental.chat.messages.transform": composeHandlers(...[
|
|
65269
65260
|
(input, _output) => {
|
|
65261
|
+
console.error(`[DIAG] messagesTransform START`);
|
|
65270
65262
|
const p = input;
|
|
65271
65263
|
if (p.sessionID) {
|
|
65272
65264
|
const archAgent = swarmState.activeAgent.get(p.sessionID);
|
|
@@ -65290,16 +65282,24 @@ var OpenCodeSwarm = async (ctx) => {
|
|
|
65290
65282
|
if (output.messages) {
|
|
65291
65283
|
output.messages = consolidateSystemMessages(output.messages);
|
|
65292
65284
|
}
|
|
65285
|
+
console.error(`[DIAG] messagesTransform DONE`);
|
|
65293
65286
|
return Promise.resolve();
|
|
65294
65287
|
}
|
|
65295
65288
|
].filter((fn) => Boolean(fn))),
|
|
65296
65289
|
"experimental.chat.system.transform": composeHandlers(...[
|
|
65290
|
+
async (input, output) => {
|
|
65291
|
+
console.error(`[DIAG] systemTransform START`);
|
|
65292
|
+
},
|
|
65297
65293
|
systemEnhancerHook["experimental.chat.system.transform"],
|
|
65294
|
+
async (_input, _output) => {
|
|
65295
|
+
console.error(`[DIAG] systemTransform enhancer DONE`);
|
|
65296
|
+
},
|
|
65298
65297
|
automationConfig.capabilities?.phase_preflight === true && preflightTriggerManager ? createPhaseMonitorHook(ctx.directory, preflightTriggerManager) : knowledgeConfig.enabled ? createPhaseMonitorHook(ctx.directory) : undefined
|
|
65299
65298
|
].filter(Boolean)),
|
|
65300
65299
|
"experimental.session.compacting": compactionHook["experimental.session.compacting"],
|
|
65301
65300
|
"command.execute.before": safeHook(commandHandler),
|
|
65302
65301
|
"tool.execute.before": async (input, output) => {
|
|
65302
|
+
console.error(`[DIAG] toolBefore tool=${input.tool?.replace?.(/^[^:]+[:.]/, "") ?? input.tool} session=${input.sessionID}`);
|
|
65303
65303
|
if (!swarmState.activeAgent.has(input.sessionID)) {
|
|
65304
65304
|
swarmState.activeAgent.set(input.sessionID, ORCHESTRATOR_NAME);
|
|
65305
65305
|
}
|
|
@@ -65328,72 +65328,102 @@ var OpenCodeSwarm = async (ctx) => {
|
|
|
65328
65328
|
await safeHook(activityHooks.toolBefore)(input, output);
|
|
65329
65329
|
},
|
|
65330
65330
|
"tool.execute.after": async (input, output) => {
|
|
65331
|
-
|
|
65332
|
-
|
|
65333
|
-
}
|
|
65334
|
-
await activityHooks.toolAfter(input, output);
|
|
65335
|
-
await guardrailsHooks.toolAfter(input, output);
|
|
65336
|
-
await safeHook(delegationLedgerHook.toolAfter)(input, output);
|
|
65337
|
-
await safeHook(selfReviewHook.toolAfter)(input, output);
|
|
65338
|
-
await safeHook(delegationGateHooks.toolAfter)(input, output);
|
|
65339
|
-
if (knowledgeCuratorHook)
|
|
65340
|
-
await safeHook(knowledgeCuratorHook)(input, output);
|
|
65341
|
-
if (hivePromoterHook)
|
|
65342
|
-
await safeHook(hivePromoterHook)(input, output);
|
|
65343
|
-
await safeHook(steeringConsumedHook)(input, output);
|
|
65344
|
-
await safeHook(coChangeSuggesterHook)(input, output);
|
|
65345
|
-
await safeHook(darkMatterDetectorHook)(input, output);
|
|
65346
|
-
await snapshotWriterHook(input, output);
|
|
65347
|
-
await toolSummarizerHook?.(input, output);
|
|
65348
|
-
const execMode = config3.execution_mode ?? "balanced";
|
|
65349
|
-
if (execMode === "strict") {
|
|
65350
|
-
if (slopDetectorHook)
|
|
65351
|
-
await slopDetectorHook.toolAfter(input, output);
|
|
65352
|
-
if (incrementalVerifyHook)
|
|
65353
|
-
await incrementalVerifyHook.toolAfter(input, output);
|
|
65354
|
-
if (compactionServiceHook)
|
|
65355
|
-
await compactionServiceHook.toolAfter(input, output);
|
|
65356
|
-
}
|
|
65357
|
-
const toolOutputConfig = config3.tool_output;
|
|
65358
|
-
if (toolOutputConfig && toolOutputConfig.truncation_enabled !== false && typeof output.output === "string") {
|
|
65359
|
-
const defaultTruncatableTools = new Set([
|
|
65360
|
-
"diff",
|
|
65361
|
-
"symbols",
|
|
65362
|
-
"bash",
|
|
65363
|
-
"shell",
|
|
65364
|
-
"test_runner",
|
|
65365
|
-
"lint",
|
|
65366
|
-
"pre_check_batch",
|
|
65367
|
-
"complexity_hotspots",
|
|
65368
|
-
"pkg_audit",
|
|
65369
|
-
"sbom_generate",
|
|
65370
|
-
"schema_drift"
|
|
65371
|
-
]);
|
|
65372
|
-
const configuredTools = toolOutputConfig.truncation_tools;
|
|
65373
|
-
const truncatableTools = configuredTools && configuredTools.length > 0 ? new Set(configuredTools) : defaultTruncatableTools;
|
|
65374
|
-
const maxLines = toolOutputConfig.per_tool?.[input.tool] ?? toolOutputConfig.max_lines ?? 150;
|
|
65375
|
-
if (truncatableTools.has(input.tool)) {
|
|
65376
|
-
output.output = truncateToolOutput(output.output, maxLines, input.tool, 10);
|
|
65377
|
-
}
|
|
65378
|
-
}
|
|
65331
|
+
const _toolName = input.tool?.replace?.(/^[^:]+[:.]/, "") ?? input.tool;
|
|
65332
|
+
console.error(`[DIAG] toolAfter START tool=${_toolName} session=${input.sessionID}`);
|
|
65379
65333
|
const normalizedTool = input.tool.replace(/^[^:]+[:.]/, "");
|
|
65380
|
-
|
|
65334
|
+
const isTaskTool = normalizedTool === "Task" || normalizedTool === "task";
|
|
65335
|
+
if (isTaskTool) {
|
|
65381
65336
|
const sessionId = input.sessionID;
|
|
65382
65337
|
swarmState.activeAgent.set(sessionId, ORCHESTRATOR_NAME);
|
|
65383
65338
|
ensureAgentSession(sessionId, ORCHESTRATOR_NAME);
|
|
65384
|
-
const
|
|
65385
|
-
if (
|
|
65386
|
-
|
|
65387
|
-
|
|
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
|
+
}
|
|
65388
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`);
|
|
65389
65419
|
}
|
|
65390
65420
|
deleteStoredInputArgs(input.callID);
|
|
65421
|
+
console.error(`[DIAG] toolAfter COMPLETE tool=${_toolName}`);
|
|
65391
65422
|
},
|
|
65392
65423
|
"chat.message": safeHook(async (input, output) => {
|
|
65393
|
-
|
|
65394
|
-
console.debug("[session] chat.message sessionID=%s agent=%s", input.sessionID, input.agent);
|
|
65395
|
-
}
|
|
65424
|
+
console.error(`[DIAG] chat.message agent=${input.agent ?? "none"} session=${input.sessionID}`);
|
|
65396
65425
|
await delegationHandler(input, output);
|
|
65426
|
+
console.error(`[DIAG] chat.message DONE agent=${input.agent ?? "none"}`);
|
|
65397
65427
|
}),
|
|
65398
65428
|
automation: automationManager
|
|
65399
65429
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-swarm",
|
|
3
|
-
"version": "6.33.
|
|
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",
|