opencode-swarm 7.18.3 → 7.19.1
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 +22 -35
- package/dist/cli/index.js +755 -480
- package/dist/commands/command-dispatch.d.ts +33 -0
- package/dist/commands/council.d.ts +1 -1
- package/dist/commands/doctor.d.ts +2 -7
- package/dist/commands/index.d.ts +11 -2
- package/dist/commands/registry.d.ts +0 -1
- package/dist/commands/tool-policy.d.ts +6 -0
- package/dist/config/plan-schema.d.ts +8 -0
- package/dist/evidence/lock.d.ts +1 -1
- package/dist/gate-evidence.d.ts +2 -2
- package/dist/hooks/guardrails.d.ts +21 -0
- package/dist/hooks/system-enhancer.d.ts +19 -0
- package/dist/index.js +2318 -2370
- package/dist/plan/ledger.d.ts +8 -3
- package/dist/plan/manager.d.ts +52 -0
- package/dist/services/config-doctor.d.ts +2 -15
- package/dist/services/evidence-service.d.ts +8 -0
- package/dist/services/plan-service.d.ts +16 -0
- package/dist/services/status-service.d.ts +8 -0
- package/dist/state/agent-run-context.d.ts +4 -4
- package/dist/state.d.ts +13 -8
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/save-plan.d.ts +19 -0
- package/dist/tools/swarm-command.d.ts +3 -0
- package/dist/tools/tool-names.d.ts +1 -1
- package/dist/tools/update-task-status.d.ts +1 -1
- package/dist/tools/write-final-council-evidence.d.ts +0 -12
- package/dist/types/events.d.ts +21 -1
- package/package.json +1 -1
- package/dist/parallel/runtime-config.d.ts +0 -11
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { AgentDefinition } from '../agents/index.js';
|
|
2
|
+
import { type CommandEntry, resolveCommand } from './registry.js';
|
|
3
|
+
export type ResolvedSwarmCommand = NonNullable<ReturnType<typeof resolveCommand>>;
|
|
4
|
+
export type SwarmCommandPolicyResult = {
|
|
5
|
+
allowed: true;
|
|
6
|
+
} | {
|
|
7
|
+
allowed: false;
|
|
8
|
+
message: string;
|
|
9
|
+
};
|
|
10
|
+
export type SwarmCommandPolicy = (resolved: ResolvedSwarmCommand) => SwarmCommandPolicyResult;
|
|
11
|
+
export type SwarmCommandExecutionResult = {
|
|
12
|
+
text: string;
|
|
13
|
+
resolved?: ResolvedSwarmCommand;
|
|
14
|
+
canonicalKey?: string;
|
|
15
|
+
};
|
|
16
|
+
export declare function normalizeSwarmCommandInput(command: string, argumentText: string): {
|
|
17
|
+
isSwarmCommand: boolean;
|
|
18
|
+
tokens: string[];
|
|
19
|
+
};
|
|
20
|
+
export declare function canonicalCommandKey(resolved: ResolvedSwarmCommand): string;
|
|
21
|
+
export declare function formatCommandNotFound(tokens: string[]): string;
|
|
22
|
+
export declare function maybeMarkFirstRun(directory: string): boolean;
|
|
23
|
+
export declare function prependWelcome(text: string): string;
|
|
24
|
+
export declare function executeSwarmCommand(args: {
|
|
25
|
+
directory: string;
|
|
26
|
+
agents: Record<string, AgentDefinition>;
|
|
27
|
+
sessionID: string;
|
|
28
|
+
tokens: string[];
|
|
29
|
+
includeWelcome?: boolean;
|
|
30
|
+
buildHelpText?: () => string;
|
|
31
|
+
policy?: SwarmCommandPolicy;
|
|
32
|
+
}): Promise<SwarmCommandExecutionResult>;
|
|
33
|
+
export type { CommandEntry };
|
|
@@ -14,4 +14,4 @@
|
|
|
14
14
|
* Sanitizes the question to prevent prompt injection of rival MODE: headers
|
|
15
15
|
* or control sequences (mirrors brainstorm.ts).
|
|
16
16
|
*/
|
|
17
|
-
export declare function handleCouncilCommand(
|
|
17
|
+
export declare function handleCouncilCommand(_directory: string, args: string[]): Promise<string>;
|
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
import { type ConfigDoctorResult
|
|
1
|
+
import { type ConfigDoctorResult } from '../services/config-doctor';
|
|
2
2
|
/**
|
|
3
3
|
* Format tool doctor result as markdown for command output.
|
|
4
4
|
*
|
|
5
5
|
* Exported for unit testing of the BLOCKING footer enforcement path.
|
|
6
6
|
*/
|
|
7
7
|
export declare function formatToolDoctorMarkdown(result: ConfigDoctorResult): string;
|
|
8
|
-
export declare function loadModelAvailability(directory: string, client: unknown, options?: {
|
|
9
|
-
timeoutMs?: number;
|
|
10
|
-
}): Promise<ModelAvailability | undefined>;
|
|
11
8
|
/**
|
|
12
9
|
* Handle /swarm config doctor command.
|
|
13
10
|
* Maps to: config doctor service (runConfigDoctor)
|
|
14
11
|
*/
|
|
15
|
-
export declare function handleDoctorCommand(directory: string, args: string[]
|
|
16
|
-
client?: unknown;
|
|
17
|
-
}): Promise<string>;
|
|
12
|
+
export declare function handleDoctorCommand(directory: string, args: string[]): Promise<string>;
|
|
18
13
|
/**
|
|
19
14
|
* Handle /swarm doctor tools command.
|
|
20
15
|
* Maps to: tool doctor service (runToolDoctor)
|
package/dist/commands/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export { handleBrainstormCommand } from './brainstorm';
|
|
|
8
8
|
export { handleCheckpointCommand } from './checkpoint';
|
|
9
9
|
export { handleClarifyCommand } from './clarify';
|
|
10
10
|
export { handleCloseCommand } from './close';
|
|
11
|
+
export { executeSwarmCommand, formatCommandNotFound, normalizeSwarmCommandInput, } from './command-dispatch.js';
|
|
11
12
|
export type { CommandName } from './command-names.js';
|
|
12
13
|
export { COMMAND_NAME_SET, COMMAND_NAMES } from './command-names.js';
|
|
13
14
|
export { handleConfigCommand } from './config';
|
|
@@ -38,18 +39,26 @@ export { handleSimulateCommand } from './simulate';
|
|
|
38
39
|
export { handleSpecifyCommand } from './specify';
|
|
39
40
|
export { handleStatusCommand } from './status';
|
|
40
41
|
export { handleSyncPlanCommand } from './sync-plan';
|
|
42
|
+
export { classifySwarmCommandChatFallbackUse, classifySwarmCommandToolUse, SWARM_COMMAND_TOOL_ALLOWLIST, SWARM_COMMAND_TOOL_COMMANDS, } from './tool-policy.js';
|
|
41
43
|
export { handleTurboCommand } from './turbo';
|
|
42
44
|
export { handleWriteRetroCommand } from './write-retro';
|
|
43
|
-
export declare const LLM_MEDIATION_WARNING: string;
|
|
44
45
|
export declare function buildHelpText(): string;
|
|
45
46
|
/**
|
|
46
47
|
* Creates a command.execute.before handler for /swarm commands.
|
|
47
48
|
* Uses factory pattern to close over directory and agents.
|
|
48
49
|
*/
|
|
49
|
-
export declare function createSwarmCommandHandler(directory: string, agents: Record<string, AgentDefinition>,
|
|
50
|
+
export declare function createSwarmCommandHandler(directory: string, agents: Record<string, AgentDefinition>, options?: {
|
|
51
|
+
getActiveAgentName?: (sessionID: string) => string | undefined;
|
|
52
|
+
registeredAgents?: Record<string, {
|
|
53
|
+
tools?: Record<string, boolean>;
|
|
54
|
+
}>;
|
|
55
|
+
}): (input: {
|
|
50
56
|
command: string;
|
|
51
57
|
sessionID: string;
|
|
52
58
|
arguments: string;
|
|
53
59
|
}, output: {
|
|
54
60
|
parts: unknown[];
|
|
55
61
|
}) => Promise<void>;
|
|
62
|
+
export declare function agentHasSwarmCommandTool(activeAgentName: string | undefined, agents: Record<string, AgentDefinition>, registeredAgents?: Record<string, {
|
|
63
|
+
tools?: Record<string, boolean>;
|
|
64
|
+
}>): boolean;
|
|
@@ -8,7 +8,6 @@ export type CommandContext = {
|
|
|
8
8
|
args: string[];
|
|
9
9
|
sessionID: string;
|
|
10
10
|
agents: Record<string, AgentDefinition>;
|
|
11
|
-
client?: unknown;
|
|
12
11
|
};
|
|
13
12
|
export type CommandResult = Promise<string>;
|
|
14
13
|
export type CommandCategory = 'core' | 'agent' | 'config' | 'diagnostics' | 'utility';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ResolvedSwarmCommand, SwarmCommandPolicyResult } from './command-dispatch.js';
|
|
2
|
+
export declare const SWARM_COMMAND_TOOL_COMMANDS: readonly ["agents", "config", "config doctor", "config-doctor", "doctor", "doctor tools", "status", "show-plan", "plan", "help", "history", "evidence", "evidence summary", "evidence-summary", "retrieve", "diagnose", "preflight", "benchmark", "knowledge", "sync-plan", "export", "list-agents"];
|
|
3
|
+
export type SwarmCommandToolInputCommand = (typeof SWARM_COMMAND_TOOL_COMMANDS)[number];
|
|
4
|
+
export declare const SWARM_COMMAND_TOOL_ALLOWLIST: Set<string>;
|
|
5
|
+
export declare function classifySwarmCommandToolUse(resolved: ResolvedSwarmCommand): SwarmCommandPolicyResult;
|
|
6
|
+
export declare function classifySwarmCommandChatFallbackUse(resolved: ResolvedSwarmCommand): SwarmCommandPolicyResult;
|
|
@@ -172,10 +172,18 @@ export type Plan = z.infer<typeof PlanSchema>;
|
|
|
172
172
|
/**
|
|
173
173
|
* Runtime plan with spec staleness tracking.
|
|
174
174
|
* Extends Plan with runtime-only fields that are not persisted.
|
|
175
|
+
*
|
|
176
|
+
* `_midLoadRemovals` is attached by loadPlan-recovery paths that auto-
|
|
177
|
+
* acknowledged task removals (issue #853) so the system-enhancer Layer A
|
|
178
|
+
* can disclose the count to the model without re-reading the ledger.
|
|
175
179
|
*/
|
|
176
180
|
export type RuntimePlan = Plan & {
|
|
177
181
|
_specStale?: boolean;
|
|
178
182
|
_specStaleReason?: string;
|
|
183
|
+
_midLoadRemovals?: {
|
|
184
|
+
count: number;
|
|
185
|
+
source: string;
|
|
186
|
+
};
|
|
179
187
|
};
|
|
180
188
|
/**
|
|
181
189
|
* Find the first phase that is in progress.
|
package/dist/evidence/lock.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Evidence write-lock helper
|
|
2
|
+
* Evidence write-lock helper (PR 1 — dark foundation).
|
|
3
3
|
*
|
|
4
4
|
* Wraps every evidence read-modify-write path with a proper-lockfile-backed
|
|
5
5
|
* exclusive lock so that concurrent writers cannot interleave their
|
package/dist/gate-evidence.d.ts
CHANGED
|
@@ -44,13 +44,13 @@ export declare function expandRequiredGates(existingGates: string[], newAgentTyp
|
|
|
44
44
|
* If file exists: merges gate entry, expands required_gates via expandRequiredGates.
|
|
45
45
|
* Atomic write: temp file + rename.
|
|
46
46
|
*/
|
|
47
|
-
export declare function recordGateEvidence(directory: string, taskId: string, gate: string, sessionId: string, turbo?: boolean
|
|
47
|
+
export declare function recordGateEvidence(directory: string, taskId: string, gate: string, sessionId: string, turbo?: boolean): Promise<void>;
|
|
48
48
|
/**
|
|
49
49
|
* Sets or expands required_gates WITHOUT recording a gate pass.
|
|
50
50
|
* Used when non-gate agents are dispatched (coder, explorer, sme, etc.).
|
|
51
51
|
* Creates evidence file if it doesn't exist yet.
|
|
52
52
|
*/
|
|
53
|
-
export declare function recordAgentDispatch(directory: string, taskId: string, agentType: string, turbo?: boolean
|
|
53
|
+
export declare function recordAgentDispatch(directory: string, taskId: string, agentType: string, turbo?: boolean): Promise<void>;
|
|
54
54
|
/**
|
|
55
55
|
* Returns the TaskEvidence for a task, or null if file missing or parse error.
|
|
56
56
|
* Never throws.
|
|
@@ -9,6 +9,27 @@
|
|
|
9
9
|
import * as path from 'node:path';
|
|
10
10
|
import { type AuthorityConfig, type GuardrailsConfig } from '../config/schema';
|
|
11
11
|
import { type FileZone } from '../context/zone-classifier';
|
|
12
|
+
/**
|
|
13
|
+
* Issue #853 Layer B: tools that are structurally blocked while
|
|
14
|
+
* `.swarm/spec-staleness.json` exists. Every blocked tool mutates plan
|
|
15
|
+
* state (save_plan, update_task_status, phase_complete) or proceeds with
|
|
16
|
+
* lean-turbo execution (lean_turbo_run_phase, lean_turbo_acquire_locks).
|
|
17
|
+
* The architect must run /swarm clarify or /swarm acknowledge-spec-drift
|
|
18
|
+
* before any of these will succeed.
|
|
19
|
+
*
|
|
20
|
+
* Read tools (get_approved_plan, lint_spec, set_qa_gates, convene_*,
|
|
21
|
+
* lean_turbo_plan_lanes, lean_turbo_runner_status, lean_turbo_review) are
|
|
22
|
+
* intentionally NOT blocked — drift surfacing should not block exploration.
|
|
23
|
+
*/
|
|
24
|
+
export declare const SPEC_DRIFT_BLOCKED_TOOLS: Set<string>;
|
|
25
|
+
/**
|
|
26
|
+
* Throw SPEC_DRIFT_BLOCK if the tool is on the block-list and the
|
|
27
|
+
* spec-staleness marker file exists. Layer B is structural (not a
|
|
28
|
+
* retryable error) — deterministic disk read every call, no cache, so
|
|
29
|
+
* /swarm acknowledge-spec-drift (which removes the marker) is reflected
|
|
30
|
+
* immediately on the next tool call.
|
|
31
|
+
*/
|
|
32
|
+
export declare function enforceSpecDriftGate(directory: string | undefined, toolName: string): void;
|
|
12
33
|
/**
|
|
13
34
|
* Retrieves stored input args for a given callID.
|
|
14
35
|
* Used by other hooks (e.g., delegation-gate) to access tool input args.
|
|
@@ -6,6 +6,25 @@
|
|
|
6
6
|
* Reads plan.md and injects phase context into the system prompt.
|
|
7
7
|
*/
|
|
8
8
|
import type { PluginConfig } from '../config';
|
|
9
|
+
/**
|
|
10
|
+
* Build the [spec-drift] advisory injected into the model's system prompt
|
|
11
|
+
* after every loadPlan whenever spec staleness is detected (issue #853
|
|
12
|
+
* Layer A). The text is appended to `output.system` and survives the
|
|
13
|
+
* single-system-message collapse at `experimental.chat.system.transform`.
|
|
14
|
+
*
|
|
15
|
+
* The "Do NOT proceed" line enumerates every tool in SPEC_DRIFT_BLOCKED_TOOLS
|
|
16
|
+
* so the architect knows exactly which calls will return SPEC_DRIFT_BLOCK
|
|
17
|
+
* from Layer B.
|
|
18
|
+
*/
|
|
19
|
+
export declare function buildSpecDriftAdvisory(args: {
|
|
20
|
+
reason: string;
|
|
21
|
+
currentHash: string | null;
|
|
22
|
+
storedHash: string;
|
|
23
|
+
midLoadRemovals?: {
|
|
24
|
+
count: number;
|
|
25
|
+
source: string;
|
|
26
|
+
};
|
|
27
|
+
}): string;
|
|
9
28
|
/**
|
|
10
29
|
* Build a retrospective injection string for the architect system message.
|
|
11
30
|
* Tier 1: direct phase-scoped lookup for same-plan previous phase.
|