opencode-swarm 7.7.0 → 7.8.0
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 +3 -1
- package/dist/agents/index.d.ts +11 -3
- package/dist/cli/index.js +788 -358
- package/dist/commands/full-auto.d.ts +13 -2
- package/dist/config/evidence-schema.d.ts +3 -3
- package/dist/config/schema.d.ts +82 -9
- package/dist/full-auto/cadence.d.ts +64 -0
- package/dist/full-auto/input-probe.d.ts +22 -0
- package/dist/full-auto/oversight.d.ts +93 -0
- package/dist/full-auto/phase-approval.d.ts +7 -0
- package/dist/full-auto/policy.d.ts +85 -0
- package/dist/full-auto/state.d.ts +121 -0
- package/dist/hooks/full-auto-delegation.d.ts +28 -0
- package/dist/hooks/full-auto-input-probe.d.ts +27 -0
- package/dist/hooks/full-auto-intercept.d.ts +1 -1
- package/dist/hooks/full-auto-permission.d.ts +39 -0
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/utils.d.ts +40 -0
- package/dist/index.js +3936 -1209
- package/dist/state.d.ts +8 -0
- package/package.json +1 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Full-Auto v2 pre-tool permission hook.
|
|
3
|
+
*
|
|
4
|
+
* Runs in `tool.execute.before` AFTER guardrails / scope-guard / delegation-gate
|
|
5
|
+
* so it adds an additional decision layer rather than replacing those checks.
|
|
6
|
+
*
|
|
7
|
+
* Behavior:
|
|
8
|
+
* - If Full-Auto is not enabled in the resolved config, no-op.
|
|
9
|
+
* - If the durable run-state is `paused` or `terminated`, block any
|
|
10
|
+
* write-like, shell, network, plan-mutation, phase-completion, or
|
|
11
|
+
* subagent-delegation tool with a clear message instructing the user to
|
|
12
|
+
* re-enable Full-Auto.
|
|
13
|
+
* - Otherwise classify the tool action via `classifyFullAutoToolAction`:
|
|
14
|
+
* * allow — increment counters and continue.
|
|
15
|
+
* * deny — record denial; throw a structured denial error so
|
|
16
|
+
* the agent receives a recoverable signal.
|
|
17
|
+
* * escalate_critic — call the shared oversight dispatcher; allow if
|
|
18
|
+
* APPROVED/ANSWER, deny if NEEDS_REVISION/REJECTED/
|
|
19
|
+
* BLOCKED, terminate if ESCALATE_TO_HUMAN.
|
|
20
|
+
* * escalate_human — terminate Full-Auto run.
|
|
21
|
+
* * pause — pause Full-Auto run and block.
|
|
22
|
+
*
|
|
23
|
+
* - When a denial is recorded, also evaluate denial thresholds and pause
|
|
24
|
+
* or terminate per `full_auto.denials.on_limit`.
|
|
25
|
+
*/
|
|
26
|
+
import type { PluginConfig } from '../config';
|
|
27
|
+
export interface FullAutoPermissionHookOptions {
|
|
28
|
+
config: PluginConfig;
|
|
29
|
+
directory: string;
|
|
30
|
+
}
|
|
31
|
+
export declare function createFullAutoPermissionHook(options: FullAutoPermissionHookOptions): {
|
|
32
|
+
toolBefore: (input: {
|
|
33
|
+
tool: string;
|
|
34
|
+
sessionID: string;
|
|
35
|
+
callID: string;
|
|
36
|
+
}, output: {
|
|
37
|
+
args: unknown;
|
|
38
|
+
}) => Promise<void>;
|
|
39
|
+
};
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -18,4 +18,4 @@ export { createRepoGraphBuilderHook, type RepoGraphBuilderHook, } from './repo-g
|
|
|
18
18
|
export { buildApprovedReceipt, buildReceiptContextForDrift, buildRejectedReceipt, persistReviewReceipt, readAllReceipts, readReceiptsByScopeHash, } from './review-receipt';
|
|
19
19
|
export { createSystemEnhancerHook } from './system-enhancer';
|
|
20
20
|
export { createToolSummarizerHook, resetSummaryIdCounter, } from './tool-summarizer';
|
|
21
|
-
export { composeHandlers, estimateTokens, readSwarmFileAsync, safeHook, validateSwarmPath, } from './utils';
|
|
21
|
+
export { composeBlockingHandlers, composeHandlers, estimateTokens, readSwarmFileAsync, safeHook, validateSwarmPath, } from './utils';
|
package/dist/hooks/utils.d.ts
CHANGED
|
@@ -20,7 +20,47 @@ export declare const _internals: {
|
|
|
20
20
|
readSwarmFileAsync: typeof readSwarmFileAsync;
|
|
21
21
|
};
|
|
22
22
|
export declare function safeHook<I, O>(fn: (input: I, output: O) => Promise<void>): (input: I, output: O) => Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* `composeHandlers` runs handlers sequentially, wrapping EACH handler in
|
|
25
|
+
* `safeHook` so any thrown error is downgraded to a warning. Use this for
|
|
26
|
+
* advisory / telemetry / observer hooks where a failure must not block
|
|
27
|
+
* tool execution.
|
|
28
|
+
*
|
|
29
|
+
* **DO NOT use this for fail-closed security or policy hooks.** A fail-closed
|
|
30
|
+
* hook MUST propagate its throws to the host so the tool call is rejected;
|
|
31
|
+
* wrapping it in `safeHook` silently disables the policy. For fail-closed
|
|
32
|
+
* hooks, use `composeBlockingHandlers` (or, as the existing
|
|
33
|
+
* `tool.execute.before` chain in `src/index.ts` does, call them directly
|
|
34
|
+
* with raw `await`).
|
|
35
|
+
*
|
|
36
|
+
* Reference: AGENTS.md invariant 11 + Full-Auto v2 fail-closed contract.
|
|
37
|
+
*/
|
|
23
38
|
export declare function composeHandlers<I, O>(...fns: Array<(input: I, output: O) => Promise<void>>): (input: I, output: O) => Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* `composeBlockingHandlers` runs handlers sequentially WITHOUT `safeHook`,
|
|
41
|
+
* so any thrown error propagates to the caller and stops the chain.
|
|
42
|
+
*
|
|
43
|
+
* Use this for fail-closed security / policy hooks at `tool.execute.before`,
|
|
44
|
+
* including:
|
|
45
|
+
* - guardrails authority enforcement
|
|
46
|
+
* - scope-guard
|
|
47
|
+
* - delegation-gate (reviewer gate)
|
|
48
|
+
* - Full-Auto v2 outbound delegation guard (`createFullAutoDelegationHook`)
|
|
49
|
+
* - Full-Auto v2 permission policy (`createFullAutoPermissionHook`)
|
|
50
|
+
*
|
|
51
|
+
* Semantic contract:
|
|
52
|
+
* - Handlers run in registration order.
|
|
53
|
+
* - The first thrown error stops execution and propagates unchanged.
|
|
54
|
+
* - Later handlers are NOT called after a throw.
|
|
55
|
+
* - The host (OpenCode) interprets the propagated throw as a tool
|
|
56
|
+
* rejection and surfaces it to the calling agent.
|
|
57
|
+
*
|
|
58
|
+
* Companion regression tests live at
|
|
59
|
+
* `tests/unit/hooks/hook-composition.test.ts` to lock this semantics in
|
|
60
|
+
* place — silently swallowing a Full-Auto denial would be a runtime
|
|
61
|
+
* fail-open and is a critical regression.
|
|
62
|
+
*/
|
|
63
|
+
export declare function composeBlockingHandlers<I, O>(...fns: Array<(input: I, output: O) => Promise<void>>): (input: I, output: O) => Promise<void>;
|
|
24
64
|
/**
|
|
25
65
|
* Validates that a filename is safe to use within the .swarm directory
|
|
26
66
|
*
|