opencode-swarm 7.152.0 → 7.153.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.
Files changed (89) hide show
  1. package/.opencode/skills/swarm-pr-review/SKILL.md +10 -10
  2. package/.opencode/skills/{resume → swarm-resume}/SKILL.md +1 -1
  3. package/dist/cli/{capability-probe-va4kk8vg.js → capability-probe-5wa7mcp6.js} +3 -2
  4. package/dist/cli/{config-doctor-4hctd61b.js → config-doctor-7s7xga6f.js} +3 -3
  5. package/dist/cli/{core-ea8xgnwy.js → core-vkpy14vv.js} +2 -2
  6. package/dist/cli/{curation-policy-vb2f0vm7.js → curation-policy-xy7tm4ad.js} +4 -4
  7. package/dist/cli/{curator-krg3abzq.js → curator-6freqnhf.js} +25 -26
  8. package/dist/cli/{curator-llm-factory-6xnnfpt4.js → curator-llm-factory-q5cjk7mt.js} +25 -26
  9. package/dist/cli/{evidence-summary-service-dtjr30pg.js → evidence-summary-service-engtgjww.js} +11 -11
  10. package/dist/cli/{gate-evidence-msnd1tda.js → gate-evidence-6bzzz8kq.js} +5 -5
  11. package/dist/cli/{guardrail-explain-nbgds0g0.js → guardrail-explain-vsck39dh.js} +26 -27
  12. package/dist/cli/{guardrail-log-emgfqa5s.js → guardrail-log-0dn8m3k6.js} +4 -4
  13. package/dist/cli/{guardrail-reset-95jhw7rg.js → guardrail-reset-6e2vyfn9.js} +25 -26
  14. package/dist/cli/{hive-promoter-ch6h94j3.js → hive-promoter-021abs6z.js} +25 -26
  15. package/dist/cli/{index-kca6ng28.js → index-0n7nm9e8.js} +1 -1
  16. package/dist/cli/{index-r0bwks42.js → index-1yfpw7w0.js} +1 -1
  17. package/dist/cli/{index-h9tcawtm.js → index-3z2f1cy8.js} +54 -11
  18. package/dist/cli/{index-cgfjvkps.js → index-3z5jtyan.js} +15 -7
  19. package/dist/cli/{index-85gkedsf.js → index-4fwbbad3.js} +521 -15
  20. package/dist/cli/{index-rqc83msp.js → index-4gn111h3.js} +5 -5
  21. package/dist/cli/{index-trj11few.js → index-5w915x8b.js} +4 -4
  22. package/dist/cli/{index-dsg5aqtj.js → index-5x67858f.js} +3 -3
  23. package/dist/cli/{index-nwpbfh8x.js → index-6v77adf7.js} +84 -23
  24. package/dist/cli/{index-qdnj3nwt.js → index-77xy577c.js} +6 -6
  25. package/dist/cli/{index-h6tvj6nr.js → index-7q56f3se.js} +2 -2
  26. package/dist/cli/{index-fk3msss3.js → index-80ekaf5b.js} +1 -1
  27. package/dist/cli/{index-9hc6ytb1.js → index-95qra69h.js} +3827 -2019
  28. package/dist/cli/{index-ek6t1e9h.js → index-9gjbe4e4.js} +1 -1
  29. package/dist/cli/{index-1hbmy0ny.js → index-9vdh4kdx.js} +22 -150
  30. package/dist/cli/{index-8nzqtv6b.js → index-babtfqa0.js} +2 -2
  31. package/dist/cli/{index-ngzc8db3.js → index-dh1gk5c5.js} +29 -28
  32. package/dist/cli/{index-7afvf50d.js → index-e2hs0bh7.js} +1 -1
  33. package/dist/cli/{index-n1j0cmj3.js → index-eajfs7v4.js} +2 -2
  34. package/dist/cli/{index-19tznm6x.js → index-eqh3t8eh.js} +6 -6
  35. package/dist/cli/{index-cxt62pxj.js → index-g0m6kypc.js} +1 -1
  36. package/dist/cli/{index-n8yastrw.js → index-hexhzq5j.js} +4 -4
  37. package/dist/cli/{index-93rgk3ax.js → index-hkmgzesw.js} +3 -3
  38. package/dist/cli/{index-dc7hh4d9.js → index-hw49515c.js} +2 -2
  39. package/dist/cli/{index-30gf3exm.js → index-k2ydsqs7.js} +3 -3
  40. package/dist/cli/{index-cpg98bh1.js → index-myt57pht.js} +1 -1
  41. package/dist/cli/{index-5th6khpe.js → index-qgfnd206.js} +1 -1
  42. package/dist/cli/{index-s85abenr.js → index-x6zy6veh.js} +1 -1
  43. package/dist/cli/{index-sgdqbhkv.js → index-xv881ahz.js} +5 -5
  44. package/dist/cli/index.js +25 -26
  45. package/dist/cli/{knowledge-escalator-n4nx4veq.js → knowledge-escalator-79zbhpz5.js} +10 -10
  46. package/dist/cli/{knowledge-events-t77r3zhe.js → knowledge-events-79cak7eb.js} +8 -8
  47. package/dist/cli/{knowledge-link-r6hfj2ep.js → knowledge-link-40zsr5ja.js} +3 -3
  48. package/dist/cli/{knowledge-store-w1v0041d.js → knowledge-store-w29aw5w0.js} +4 -4
  49. package/dist/cli/{knowledge-validator-6fcx0xdb.js → knowledge-validator-qsecnt2d.js} +6 -6
  50. package/dist/cli/{model-preflight-7ea00h34.js → model-preflight-b95w8wxy.js} +1 -1
  51. package/dist/cli/{runner-cmvgkbtp.js → runner-fbgsxs74.js} +4 -4
  52. package/dist/cli/{scan-cursor-936pmv37.js → scan-cursor-1r3pcdqp.js} +5 -5
  53. package/dist/cli/{schema-exk5afyz.js → schema-19qsv6fw.js} +2 -2
  54. package/dist/cli/{scope-persistence-0ddz95ke.js → scope-persistence-ypcrvqtt.js} +6 -6
  55. package/dist/cli/{skill-generator-qk0mf7da.js → skill-generator-wpp9kpa0.js} +12 -12
  56. package/dist/cli/{worktree-isolation-2jvaebns.js → worktree-isolation-wcry8qnn.js} +25 -26
  57. package/dist/commands/approve-write.d.ts +1 -0
  58. package/dist/commands/index.d.ts +1 -0
  59. package/dist/commands/registry.d.ts +7 -0
  60. package/dist/config/bundled-skills.d.ts +10 -1
  61. package/dist/config/schema.d.ts +39 -4
  62. package/dist/consensus/contracts.d.ts +14 -0
  63. package/dist/hooks/full-auto-permission.d.ts +7 -0
  64. package/dist/hooks/guardrails/index.d.ts +2 -1
  65. package/dist/hooks/guardrails/tool-before.d.ts +4 -0
  66. package/dist/hooks/pr-workflow-gate.d.ts +12 -0
  67. package/dist/hooks/scope-guard.d.ts +1 -3
  68. package/dist/index.js +626 -608
  69. package/dist/learning/provenance.d.ts +9 -0
  70. package/dist/sandbox/capability-probe.d.ts +40 -1
  71. package/dist/sandbox/executor.d.ts +26 -1
  72. package/dist/sandbox/linux/bubblewrap-executor.d.ts +3 -1
  73. package/dist/sandbox/macos/sandbox-exec-executor.d.ts +3 -1
  74. package/dist/sandbox/skip-state.d.ts +24 -0
  75. package/dist/sandbox/win32/native-sandbox-executor.d.ts +5 -1
  76. package/dist/security/command-classifier.d.ts +22 -0
  77. package/dist/security/protected-input-integrity.d.ts +19 -0
  78. package/dist/security/protected-path-policy.d.ts +9 -0
  79. package/dist/security/write-authority.d.ts +46 -0
  80. package/dist/services/diagnose-service.d.ts +1 -1
  81. package/dist/services/skill-generator.d.ts +2 -0
  82. package/dist/services/skill-improver.d.ts +69 -0
  83. package/dist/tools/dispatch-lanes.d.ts +47 -0
  84. package/dist/tools/repo-graph/query.d.ts +2 -1
  85. package/dist/tools/repo-graph/types.d.ts +64 -0
  86. package/dist/tools/repo-graph.d.ts +1 -1
  87. package/dist/tools/skill-improve.d.ts +7 -0
  88. package/package.json +2 -2
  89. package/dist/cli/index-3g0xk6tk.js +0 -219
@@ -17,6 +17,7 @@
17
17
  * supply `producedAt` — callers that need determinism pass it explicitly.
18
18
  */
19
19
  import { z } from 'zod';
20
+ import { type WriteAuthorityOrigin } from '../security/write-authority.js';
20
21
  /**
21
22
  * Hard cap on entries retained per reference class. Sorting happens before the
22
23
  * cap so truncation is deterministic rather than insertion-order dependent.
@@ -41,6 +42,12 @@ export declare const LearningProvenanceV1Schema: z.ZodObject<{
41
42
  writeOrigin: z.ZodObject<{
42
43
  sessionId: z.ZodOptional<z.ZodString>;
43
44
  agentRole: z.ZodOptional<z.ZodString>;
45
+ authority: z.ZodOptional<z.ZodEnum<{
46
+ critic_approved: "critic_approved";
47
+ autonomous: "autonomous";
48
+ optimizer_proposed: "optimizer_proposed";
49
+ human_approved: "human_approved";
50
+ }>>;
44
51
  producedAt: z.ZodISODateTime;
45
52
  }, z.core.$strict>;
46
53
  }, z.core.$strict>;
@@ -56,6 +63,7 @@ export interface LearningProvenanceV1 {
56
63
  writeOrigin: {
57
64
  sessionId?: string;
58
65
  agentRole?: string;
66
+ authority?: WriteAuthorityOrigin;
59
67
  producedAt: string;
60
68
  };
61
69
  }
@@ -72,6 +80,7 @@ export interface LearningProvenanceInput {
72
80
  export interface LearningWriteOriginInput {
73
81
  sessionId?: string;
74
82
  agentRole?: string;
83
+ authority?: WriteAuthorityOrigin;
75
84
  producedAt?: string;
76
85
  }
77
86
  /**
@@ -9,6 +9,8 @@
9
9
  * Each probe is bounded to 2 seconds via AbortController to satisfy
10
10
  * Invariant 1 (plugin init is fast, bounded, fail-open).
11
11
  */
12
+ import { spawnSync } from 'node:child_process';
13
+ import * as fs from 'node:fs';
12
14
  /** Possible sandbox status values. */
13
15
  export type SandboxStatus = 'enabled' | 'disabled' | 'unsupported';
14
16
  /**
@@ -20,6 +22,7 @@ export type SandboxStatus = 'enabled' | 'disabled' | 'unsupported';
20
22
  * (issue #1778 H2).
21
23
  */
22
24
  export type SandboxStrength = 'strong' | 'advisory';
25
+ export type SandboxDimensionStrength = 'real' | 'weak' | 'none';
23
26
  /** Result of a sandbox capability probe. */
24
27
  export interface SandboxCapability {
25
28
  /** Whether the sandbox mechanism is available. */
@@ -36,6 +39,37 @@ export interface SandboxCapability {
36
39
  /** Error message from the probe, if any. */
37
40
  error?: string;
38
41
  }
42
+ export interface SandboxCapabilityV1 extends SandboxCapability {
43
+ v: 1;
44
+ filesystem: SandboxDimensionStrength;
45
+ network: SandboxDimensionStrength;
46
+ process: SandboxDimensionStrength;
47
+ effective: SandboxDimensionStrength;
48
+ reasons: string[];
49
+ identity: string;
50
+ }
51
+ export interface SandboxRequirements {
52
+ mode?: 'advisory' | 'required';
53
+ require_filesystem?: boolean;
54
+ require_network?: boolean;
55
+ require_process?: boolean;
56
+ network_mode?: 'off' | 'on';
57
+ network_allowlist?: readonly string[];
58
+ writable_roots?: readonly string[];
59
+ }
60
+ export declare function assessSandboxRequirements(capability: SandboxCapabilityV1, requirements: SandboxRequirements | undefined): {
61
+ satisfied: boolean;
62
+ missing: string[];
63
+ };
64
+ interface BehavioralEvidence {
65
+ filesystem: SandboxDimensionStrength;
66
+ network: SandboxDimensionStrength;
67
+ process: SandboxDimensionStrength;
68
+ reasons: string[];
69
+ }
70
+ declare function currentProbeSourceIdentity(platform: 'linux' | 'darwin' | 'win32'): string;
71
+ declare function resolveWindowsCommandProcessorBinary(): string;
72
+ declare function detectBehavioralEvidence(capability: SandboxCapability): BehavioralEvidence;
39
73
  /** Reset the session-lifetime capability cache. Test-only. */
40
74
  export declare function _resetCapabilityCache(): void;
41
75
  /**
@@ -56,6 +90,11 @@ declare function withProbeTimeout(cmd: string, args: string[], ms: number): Prom
56
90
  */
57
91
  export declare const _internals: {
58
92
  withProbeTimeout: typeof withProbeTimeout;
93
+ spawnSync: typeof spawnSync;
94
+ detectBehavioralEvidence: typeof detectBehavioralEvidence;
95
+ resolveWindowsCommandProcessorBinary: typeof resolveWindowsCommandProcessorBinary;
96
+ currentProbeSourceIdentity: typeof currentProbeSourceIdentity;
97
+ removeProbeTempRoot: typeof fs.rmSync;
59
98
  };
60
99
  /**
61
100
  * Detects the availability of OS-native sandbox mechanisms.
@@ -86,6 +125,6 @@ export declare class SandboxCapabilityProbe {
86
125
  *
87
126
  * @returns A promise that resolves to the sandbox capability result.
88
127
  */
89
- detect(): Promise<SandboxCapability>;
128
+ detect(): Promise<SandboxCapabilityV1>;
90
129
  }
91
130
  export {};
@@ -4,6 +4,7 @@
4
4
  * Provides a unified interface for sandboxed shell command execution across
5
5
  * Linux (Bubblewrap), macOS (sandbox-exec), and Windows (restricted token/Low Integrity).
6
6
  */
7
+ import { type SandboxCapabilityV1, type SandboxRequirements } from './capability-probe';
7
8
  /**
8
9
  * Error thrown when sandbox operations fail.
9
10
  */
@@ -11,6 +12,7 @@ export declare class SandboxError extends Error {
11
12
  readonly code: string;
12
13
  constructor(message: string, code: string);
13
14
  }
15
+ export declare function normalizeSandboxMechanism(mechanism: string): string;
14
16
  /**
15
17
  * Validate that a string is a valid POSIX environment variable name.
16
18
  * POSIX env var names: [a-zA-Z_][a-zA-Z0-9_]*
@@ -43,13 +45,33 @@ export interface SandboxExecutor {
43
45
  * @returns The wrapped command string with sandbox prefix
44
46
  * @throws SandboxError if sandbox cannot wrap the command
45
47
  */
46
- wrapCommand(command: string, scopePaths: string[], tempDir?: string, envOverrides?: Record<string, string | null>): string;
48
+ wrapCommand(command: string, scopePaths: string[], tempDir?: string, envOverrides?: Record<string, string | null>, policy?: SandboxPolicyOptions): string;
47
49
  /**
48
50
  * Get the environment variable overrides for this sandbox.
49
51
  * Returns a record of env vars to set/unset.
50
52
  */
51
53
  getEnvOverrides(): Record<string, string | null>;
52
54
  }
55
+ export interface SandboxPolicyOptions {
56
+ network_mode?: 'off' | 'on';
57
+ network_allowlist?: readonly string[];
58
+ writable_roots?: readonly string[];
59
+ }
60
+ declare function detectSandboxCapability(): Promise<SandboxCapabilityV1>;
61
+ export declare const _internals: {
62
+ detectSandboxCapability: typeof detectSandboxCapability;
63
+ };
64
+ export interface SandboxEnforcementAssessment {
65
+ capability: SandboxCapabilityV1;
66
+ requirements: Required<SandboxRequirements>;
67
+ policy: Required<SandboxPolicyOptions>;
68
+ satisfied: boolean;
69
+ missing: string[];
70
+ supported: boolean;
71
+ unsupported: string[];
72
+ cacheKey: string;
73
+ }
74
+ export declare function assessSandboxEnforcement(requirements: SandboxRequirements | undefined): Promise<SandboxEnforcementAssessment>;
53
75
  /**
54
76
  * Get the platform-appropriate sandbox executor.
55
77
  *
@@ -80,3 +102,6 @@ export declare function _getMacOSSandboxPolicyForTest(): boolean;
80
102
  * @internal
81
103
  */
82
104
  export declare function _resetExecutorCache(): void;
105
+ /** @internal test seam */
106
+ export declare function _resetSandboxAssessmentCache(): void;
107
+ export {};
@@ -75,7 +75,9 @@ export declare class BubblewrapSandboxExecutor implements SandboxExecutor {
75
75
  * @returns A bwrap-wrapped command string ready for shell execution,
76
76
  * or the raw command string when the sandbox is unavailable (passthrough mode)
77
77
  */
78
- wrapCommand(command: string, scopePaths: string[], tempDir?: string, envOverrides?: Record<string, string | null>): string;
78
+ wrapCommand(command: string, scopePaths: string[], tempDir?: string, envOverrides?: Record<string, string | null>, policy?: {
79
+ network_mode?: 'off' | 'on';
80
+ }): string;
79
81
  /**
80
82
  * Return environment variable overrides required for the bubblewrap sandbox.
81
83
  *
@@ -104,7 +104,9 @@ export declare class MacOSSandboxExecutor implements SandboxExecutor {
104
104
  * @returns A sandbox-exec wrapped command string ready for shell execution,
105
105
  * or the raw command string when the sandbox is unavailable (passthrough mode)
106
106
  */
107
- wrapCommand(command: string, scopePaths: string[], tempDir?: string, envOverrides?: Record<string, string | null>): string;
107
+ wrapCommand(command: string, scopePaths: string[], tempDir?: string, envOverrides?: Record<string, string | null>, _policy?: {
108
+ network_mode?: 'off' | 'on';
109
+ }): string;
108
110
  /**
109
111
  * Return environment variable overrides required for the macOS sandbox.
110
112
  *
@@ -0,0 +1,24 @@
1
+ export interface SandboxWrapOutcome {
2
+ sessionID: string;
3
+ callID: string;
4
+ originalCommandHash: number;
5
+ finalCommandHash: number;
6
+ wrapped: boolean;
7
+ capabilityIdentity: string;
8
+ assessmentCacheKey: string;
9
+ reason: string;
10
+ originalCommand: string;
11
+ executorMechanism: string;
12
+ capabilityMechanism: string;
13
+ }
14
+ export declare function recordSandboxWrapOutcome(outcome: SandboxWrapOutcome): void;
15
+ export declare function readSandboxWrapOutcome(sessionID: string, callID: string): SandboxWrapOutcome | null;
16
+ export declare function clearSandboxWrapOutcome(sessionID: string, callID: string): void;
17
+ export declare function getSandboxSkipSummary(sessionID?: string): {
18
+ count: number;
19
+ reasons: readonly string[];
20
+ };
21
+ /** @internal test seam */
22
+ export declare function _resetSandboxWrapOutcomeState(): void;
23
+ /** @internal test seam */
24
+ export declare function _sandboxWrapOutcomeStateSize(): number;
@@ -37,7 +37,11 @@ export declare class NativeWindowsSandboxExecutor implements SandboxExecutor {
37
37
  *
38
38
  * When the runner is unavailable, falls back to the PowerShell wrapper.
39
39
  */
40
- wrapCommand(command: string, scopePaths: string[], tempDir?: string, envOverrides?: Record<string, string | null>): string;
40
+ wrapCommand(command: string, scopePaths: string[], tempDir?: string, envOverrides?: Record<string, string | null>, policy?: {
41
+ network_mode?: 'off' | 'on';
42
+ network_allowlist?: readonly string[];
43
+ writable_roots?: readonly string[];
44
+ }): string;
41
45
  private _wrapWithRunner;
42
46
  getEnvOverrides(): Record<string, string | null>;
43
47
  /**
@@ -0,0 +1,22 @@
1
+ export type CommandRiskCategory = 'catastrophic' | 'destructive' | 'unknown' | 'escalate' | 'safe';
2
+ export interface CommandSegmentClassificationV1 {
3
+ segment: string;
4
+ category: CommandRiskCategory;
5
+ reason: string;
6
+ ruleId?: string;
7
+ }
8
+ export interface CommandClassificationV1 {
9
+ v: 1;
10
+ originalDigest: string;
11
+ aggregate: CommandRiskCategory;
12
+ ambiguous: boolean;
13
+ segments: readonly CommandSegmentClassificationV1[];
14
+ }
15
+ export interface SharedClassifierGuardrailBlockV1 {
16
+ ruleId: string;
17
+ category: Extract<CommandRiskCategory, 'catastrophic' | 'destructive'>;
18
+ destructiveCategory: string;
19
+ message: string;
20
+ }
21
+ export declare function getSharedClassifierGuardrailBlock(classification: Readonly<CommandClassificationV1>): Readonly<SharedClassifierGuardrailBlockV1> | null;
22
+ export declare function classifyCommand(original: string): Readonly<CommandClassificationV1>;
@@ -0,0 +1,19 @@
1
+ export interface ProtectedManifestV1 {
2
+ v: 1;
3
+ root: string;
4
+ digest: string;
5
+ entries: readonly string[];
6
+ }
7
+ /** Snapshot a protected regular-file tree; ambiguity and budget exhaustion fail closed. */
8
+ export declare function snapshotProtectedTree(root: string): Promise<ProtectedManifestV1>;
9
+ export declare function verifyProtectedTree(before: ProtectedManifestV1): Promise<void>;
10
+ /** Mandatory transaction wrapper for governed evaluators. Verification always runs. */
11
+ export declare function withProtectedInputIntegrity<T>(root: string, operation: () => Promise<T>): Promise<T>;
12
+ export interface ProtectedSetManifestV1 {
13
+ v: 1;
14
+ roots: readonly string[];
15
+ states: readonly (ProtectedManifestV1 | 'missing')[];
16
+ }
17
+ export declare function snapshotProtectedSet(roots: readonly string[]): Promise<ProtectedSetManifestV1>;
18
+ export declare function verifyProtectedSet(before: ProtectedSetManifestV1): Promise<void>;
19
+ export declare function withProtectedSetIntegrity<T>(roots: readonly string[], operation: () => Promise<T>): Promise<T>;
@@ -0,0 +1,9 @@
1
+ export interface ProtectedPathPolicyOptions {
2
+ includeDefaults?: boolean;
3
+ additional?: readonly string[];
4
+ }
5
+ export declare const DEFAULT_PROTECTED_PATH_PREFIXES: readonly [".github/workflows", ".github/CODEOWNERS", "src/sandbox", "src/hooks/guardrails", "src/security", "src/evaluation", "docs/releases", "tests/fixtures/evaluation"];
6
+ export declare function normalizeProtectedPath(value: string): string;
7
+ /** Central lexical policy; canonical containment remains caller-owned. */
8
+ export declare function isPolicyProtectedPath(filePath: string, options?: ProtectedPathPolicyOptions): boolean;
9
+ export declare function protectedRoots(projectRoot: string, additional?: readonly string[]): string[];
@@ -0,0 +1,46 @@
1
+ export type WriteAuthorityOrigin = 'autonomous' | 'optimizer_proposed' | 'critic_approved' | 'human_approved';
2
+ export type WriteApprovalAction = 'skill_improve';
3
+ export interface WriteApprovalRequest {
4
+ targetSessionId: string;
5
+ action: WriteApprovalAction;
6
+ candidateId: string;
7
+ candidateContentHash: string;
8
+ allowedPathDigest?: string;
9
+ generation?: number;
10
+ }
11
+ export interface WriteApprovalFactV1 extends WriteApprovalRequest {
12
+ v: 1;
13
+ id: string;
14
+ issuingSessionId: string;
15
+ issuedByCommand: 'approve-write';
16
+ issuedAt: string;
17
+ expiresAt: string;
18
+ }
19
+ export interface WriteAuthorityContext {
20
+ origin: WriteAuthorityOrigin;
21
+ fact?: WriteApprovalFactV1;
22
+ }
23
+ export declare function computeWriteApprovalHash(input: Record<string, unknown>): string;
24
+ export declare function getCurrentWriteAuthority(): WriteAuthorityContext;
25
+ export declare function withWriteAuthority<T>(context: WriteAuthorityContext, fn: () => Promise<T>): Promise<T>;
26
+ export declare function buildHumanApprovedWriteAuthority(fact: WriteApprovalFactV1): WriteAuthorityContext;
27
+ export declare function currentWriteAuthoritySatisfies(request: WriteApprovalRequest): boolean;
28
+ export declare function formatApproveWriteCommand(request: WriteApprovalRequest): string;
29
+ export declare function findWriteApprovalFact(args: {
30
+ directory: string;
31
+ request: WriteApprovalRequest;
32
+ now?: Date;
33
+ }): Promise<WriteApprovalFactV1 | null>;
34
+ export declare function issueWriteApprovalFact(args: {
35
+ directory: string;
36
+ request: WriteApprovalRequest;
37
+ issuingSessionId: string;
38
+ now?: Date;
39
+ ttlMs?: number;
40
+ }): Promise<WriteApprovalFactV1>;
41
+ export declare function consumeWriteApprovalFact(args: {
42
+ directory: string;
43
+ request: WriteApprovalRequest;
44
+ consumerSessionId: string;
45
+ now?: Date;
46
+ }): Promise<WriteApprovalFactV1 | null>;
@@ -1,6 +1,6 @@
1
1
  import { getExecutor } from '../sandbox/executor.js';
2
2
  export declare const _internals: {
3
- detectSandboxCapability: () => Promise<import("../sandbox/capability-probe.js").SandboxCapability>;
3
+ detectSandboxCapability: () => Promise<import("../sandbox/capability-probe.js").SandboxCapabilityV1>;
4
4
  getSandboxExecutor: typeof getExecutor;
5
5
  };
6
6
  /**
@@ -100,6 +100,7 @@ export interface GenerateRequest {
100
100
  evaluate?: boolean;
101
101
  minConfidence?: number;
102
102
  minConfirmations?: number;
103
+ preview?: boolean;
103
104
  }
104
105
  export interface GenerateResult {
105
106
  written: Array<{
@@ -110,6 +111,7 @@ export interface GenerateResult {
110
111
  missingSourceKnowledgeIds?: string[];
111
112
  preserved: boolean;
112
113
  evaluation?: SkillEvaluationResult;
114
+ content?: string;
113
115
  }>;
114
116
  skipped: Array<{
115
117
  slug: string;
@@ -19,6 +19,7 @@
19
19
  import type { EnrichmentQuotaOptions } from '../hooks/knowledge-curator.js';
20
20
  import type { KnowledgeEntryBase } from '../hooks/knowledge-types.js';
21
21
  import { type SkillImproverLLMDelegate } from '../hooks/skill-improver-llm-factory.js';
22
+ import { type WriteApprovalRequest } from '../security/write-authority.js';
22
23
  import { type AutoApplyResult, regenerateSkill } from './skill-generator.js';
23
24
  import { type QuotaWindow } from './skill-improver-quota.js';
24
25
  export interface SkillImproverConfigInput {
@@ -56,10 +57,20 @@ export interface SkillImproveRequest {
56
57
  evaluateDrafts?: boolean;
57
58
  /** Consolidation callers stage proposals only and must never auto-apply. */
58
59
  allowAutoApply?: boolean;
60
+ /** Exact approval-phase proposal body returned by a prior challenge. */
61
+ approvedCandidateContent?: string;
59
62
  }
60
63
  export interface SkillImproveResult {
61
64
  ran: boolean;
62
65
  reason?: string;
66
+ approvalRequired?: {
67
+ request?: WriteApprovalRequest;
68
+ command?: string;
69
+ candidateContent?: string;
70
+ candidateContentChars?: number;
71
+ candidateContentTokenEstimate?: number;
72
+ allowedPaths?: string[];
73
+ };
63
74
  proposalPath?: string;
64
75
  source?: 'llm' | 'deterministic_fallback';
65
76
  quota: {
@@ -100,6 +111,59 @@ export interface SkillImproveResult {
100
111
  /** #1234 Part 3D: critic-gated auto-apply of proposals in full-auto mode. */
101
112
  autoApply?: AutoApplyResult;
102
113
  }
114
+ export declare const SKILL_IMPROVER_APPROVAL_CANDIDATE_ID = "skill_improve_request";
115
+ export declare const MAX_APPROVED_CANDIDATE_CONTENT_CHARS = 64000;
116
+ interface SkillImproverDraftWrite {
117
+ slug: string;
118
+ path: string;
119
+ content: string;
120
+ sourceKnowledgeIds: string[];
121
+ missingSourceKnowledgeIds?: string[];
122
+ }
123
+ interface SkillImproverDraftSourceStampTarget {
124
+ knowledgePath: string;
125
+ ids: string[];
126
+ slug: string;
127
+ draftGeneratedSkillPath: string;
128
+ updatedAt: string;
129
+ }
130
+ export declare function buildSkillImproverApprovalRequest(input: {
131
+ sessionId?: string;
132
+ candidateContent: string;
133
+ allowedPaths: string[];
134
+ candidateId?: string;
135
+ generation?: number;
136
+ }): WriteApprovalRequest | null;
137
+ export interface PreparedSkillImproverApprovalCandidate {
138
+ directory: string;
139
+ sessionId: string;
140
+ now: Date;
141
+ source: 'llm' | 'deterministic_fallback';
142
+ model?: string;
143
+ proposalPath: string;
144
+ proposalContent: string;
145
+ allowedPaths: string[];
146
+ candidateContent: string;
147
+ draftWrites: SkillImproverDraftWrite[];
148
+ draftSourceStamps: SkillImproverDraftSourceStampTarget[];
149
+ request: WriteApprovalRequest;
150
+ quota: {
151
+ date: string;
152
+ calls_used: number;
153
+ max_calls: number;
154
+ };
155
+ quotaWindow: QuotaWindow;
156
+ maxCalls: number;
157
+ maxCallsPerDay: number;
158
+ released: boolean;
159
+ }
160
+ type SkillImproverApprovalPreparation = {
161
+ kind: 'result';
162
+ result: SkillImproveResult;
163
+ } | {
164
+ kind: 'prepared';
165
+ prepared: PreparedSkillImproverApprovalCandidate;
166
+ };
103
167
  interface InventorySnapshot {
104
168
  knowledge: {
105
169
  swarm: number;
@@ -152,6 +216,10 @@ export interface StaleSkillReconciliationResult {
152
216
  export declare function reconcileStaleActiveSkills(directory: string, options?: {
153
217
  dryRun?: boolean;
154
218
  }): Promise<StaleSkillReconciliationResult>;
219
+ export declare function prepareSkillImproverApprovalCandidate(req: SkillImproveRequest): Promise<SkillImproverApprovalPreparation>;
220
+ export declare function prepareApprovedSkillImproverCandidateWrite(req: SkillImproveRequest): Promise<SkillImproverApprovalPreparation>;
221
+ export declare function releasePreparedSkillImproverApprovalCandidate(prepared: PreparedSkillImproverApprovalCandidate): Promise<SkillImproveResult['quota']>;
222
+ export declare function writeApprovedSkillImproverCandidate(prepared: PreparedSkillImproverApprovalCandidate): Promise<SkillImproveResult>;
155
223
  export declare function runSkillImprover(req: SkillImproveRequest): Promise<SkillImproveResult>;
156
224
  export declare const _internals: {
157
225
  runSkillImprover: typeof runSkillImprover;
@@ -159,6 +227,7 @@ export declare const _internals: {
159
227
  buildLLMProposalFrame: typeof buildLLMProposalFrame;
160
228
  buildSystemPrompt: typeof buildSystemPrompt;
161
229
  buildUserPrompt: typeof buildUserPrompt;
230
+ buildSkillImproverApprovalRequest: typeof buildSkillImproverApprovalRequest;
162
231
  gatherInventory: typeof gatherInventory;
163
232
  reconcileStaleActiveSkills: typeof reconcileStaleActiveSkills;
164
233
  regenerateSkill: typeof regenerateSkill;
@@ -203,8 +203,30 @@ export interface CollectLaneResultsResult {
203
203
  * or any lane's state.
204
204
  */
205
205
  pending_liveness?: PrWorkflowPendingLaneLiveness[];
206
+ /**
207
+ * Issue #2381: identities of every lane that had NOT settled when this
208
+ * collection returned. Present whenever any lane is unsettled, INDEPENDENT of
209
+ * `include_pending` — a caller must never have to opt in to learn that work is
210
+ * still outstanding, and a wait budget expiring is not evidence the work died.
211
+ *
212
+ * Purely additive: `lane_results` filtering and every aggregate counter are
213
+ * unchanged, so existing consumers are unaffected.
214
+ */
215
+ pending_lanes?: CollectPendingLaneIdentity[];
206
216
  errors?: string[];
207
217
  }
218
+ /**
219
+ * Issue #2381: minimal, stable identity of an unsettled lane. `output_ref` is
220
+ * carried when the record already has one (for example an `ingesting` lane whose
221
+ * artifact was written before settlement) so a caller can still recover partial
222
+ * output via `retrieve_lane_output` without a second collection.
223
+ */
224
+ export interface CollectPendingLaneIdentity {
225
+ batch_id: string;
226
+ lane_id: string;
227
+ status: string;
228
+ output_ref?: string;
229
+ }
208
230
  export interface SessionOps {
209
231
  create(args: {
210
232
  body?: {
@@ -341,6 +363,8 @@ export declare const _test_exports: {
341
363
  nextCollectPollInterval: typeof nextCollectPollInterval;
342
364
  promptHash: typeof promptHash;
343
365
  reserveCollectionLaneCallBudgets: typeof reserveCollectionLaneCallBudgets;
366
+ assembleCollectionDiagnostics: typeof assembleCollectionDiagnostics;
367
+ addLaneDiagnostic: typeof addLaneDiagnostic;
344
368
  isRetryableSessionCreateFailure: typeof isRetryableSessionCreateFailure;
345
369
  DispatchLanesArgsSchema: z.ZodObject<{
346
370
  lanes: z.ZodArray<z.ZodObject<{
@@ -451,6 +475,29 @@ export declare function executeDispatchLanes(args: unknown, directory: string, c
451
475
  export declare function executeDispatchLanesAsync(args: unknown, directory: string, context?: DispatchLanesExecutionContext): Promise<DispatchLanesAsyncResult>;
452
476
  export declare function executeCollectLaneResults(args: unknown, directory: string, context?: Pick<DispatchLanesExecutionContext, 'sessionID'>): Promise<CollectLaneResultsResult>;
453
477
  declare function isRetryableSessionCreateFailure(error: unknown): boolean;
478
+ /**
479
+ * Issue #2381 (PR review follow-up): lane-keyed collection diagnostics.
480
+ *
481
+ * These were message-keyed `Set<string>`s, which forced clearing to match on the
482
+ * quoted lane label inside the message. Because entries embed host-derived error
483
+ * text, one lane's error could literally contain another lane's quoted id and
484
+ * clear it — a missing diagnostic, never a wrong lane state, but a real residue.
485
+ * Keying by lane removes the class outright: clearing is an exact `delete`, and
486
+ * no message content can ever influence another lane's entries.
487
+ */
488
+ type LaneDiagnostics = Map<string, Set<string>>;
489
+ /**
490
+ * Assemble `result.errors` from the three diagnostic channels.
491
+ *
492
+ * Extracted as a pure function so the starvation invariant is testable without
493
+ * having to drive the poll loop into a real timeout flood: each channel is
494
+ * bounded INDEPENDENTLY, so no channel can crowd out another no matter how one
495
+ * of them behaves. The lane-keyed channels lead because they carry the per-lane
496
+ * cause an operator acts on; `hostTimeouts` is the coarser "a host call ran out
497
+ * of budget" signal and takes its own slice.
498
+ */
499
+ declare function assembleCollectionDiagnostics(hostTimeouts: ReadonlySet<string>, settleFailureLogs: LaneDiagnostics, collectionResourceFailures: LaneDiagnostics): string[];
500
+ declare function addLaneDiagnostic(diagnostics: LaneDiagnostics, laneLabel: string, message: string): void;
454
501
  declare function consumePrReviewReceiptAppendFailureLog(loggedFailures: Set<string>, parentSessionId: string, correlationId: string): boolean;
455
502
  /**
456
503
  * Issue #2349: a terminal error read off the last assistant message of a lane
@@ -1,5 +1,5 @@
1
1
  import type { FreshnessProbe } from './freshness';
2
- import type { BlastRadiusResult, CallerReference, ContextPackResult, DeadExportsResult, FileOntology, FileReference, GraphHealthResult, GraphNode, LocalizationBlock, PackageBoundarySummary, RepoGraph, SymbolReference } from './types';
2
+ import type { BlastRadiusResult, CallerReference, ContextPackResult, ContextPackSourceMode, DeadExportsResult, FileOntology, FileReference, GraphHealthResult, GraphNode, LocalizationBlock, PackageBoundarySummary, RepoGraph, SymbolReference } from './types';
3
3
  export declare function getGraphNode(graph: RepoGraph, input: string): GraphNode | undefined;
4
4
  export declare function resetQueryCache(): void;
5
5
  /**
@@ -49,6 +49,7 @@ export declare function getContextPack(graph: RepoGraph, file: string, symbol: s
49
49
  maxDepth?: number;
50
50
  maxTokens?: number;
51
51
  includeSource?: boolean;
52
+ sourceMode?: ContextPackSourceMode;
52
53
  directory?: string;
53
54
  }): ContextPackResult;
54
55
  export declare function getPackageBoundaries(graph: RepoGraph, topN?: number): PackageBoundarySummary[];
@@ -286,6 +286,64 @@ export interface ContextPackSpan {
286
286
  text?: string;
287
287
  note?: string;
288
288
  }
289
+ /**
290
+ * Source-text extraction mode for source-bearing context packs (issue #1533).
291
+ * `include_source` remains the sole gate; `source_mode` only refines what is
292
+ * extracted once source was requested.
293
+ *
294
+ * - `mixed` (default): body text for near spans (span mode 'full'), signature
295
+ * text for periphery spans (span mode 'signature').
296
+ * - `body`: body text for every span with an export range.
297
+ * - `signature`: signature text for every span with an export range.
298
+ */
299
+ export type ContextPackSourceMode = 'signature' | 'body' | 'mixed';
300
+ /**
301
+ * A bounded source snippet with provenance (issue #1533). Emitted one per
302
+ * returned span that actually had text extracted; internal-symbol fallback
303
+ * spans produce no snippet.
304
+ *
305
+ * `mode` describes the returned text, independent of the owning span's
306
+ * traversal mode: 'full' = whole range text; 'signature' = signature-only
307
+ * extraction; 'summary' = body text line-capped at 80 lines.
308
+ *
309
+ * `hash` is the sha256 hex of the returned `text` — a content fingerprint.
310
+ * It is stable for a given source mode and file content; summary-mode hashes
311
+ * are cap-dependent by design because the text itself is truncated.
312
+ *
313
+ * `confidence` is a deterministic resolution-quality score in [0, 1]:
314
+ * 1.0 = the exact requested target symbol, 0.8 = a resolved neighbor with
315
+ * extracted text. Spans whose read failed or which lack an export range
316
+ * produce no snippet at all (their state surfaces via span.note, coverage,
317
+ * and warnings). It is NOT language grammar quality; issue #1532 (KG-11
318
+ * SymbolEdge v2) will replace this derivation with real edge confidence.
319
+ */
320
+ export interface ContextPackSnippet {
321
+ file: string;
322
+ symbol: string;
323
+ startLine: number;
324
+ endLine: number;
325
+ mode: 'full' | 'signature' | 'summary';
326
+ text: string;
327
+ hash: string;
328
+ confidence: number;
329
+ }
330
+ /**
331
+ * Coverage accounting for a context pack (issue #1533).
332
+ *
333
+ * `unresolvedEdges` and `lowConfidenceEdges` count distinct destination
334
+ * SYMBOLS (keyed `file\0symbol`, collected at BFS first discovery), not edge
335
+ * instances — duplicate edges toward the same unresolved symbol count once.
336
+ * `lowConfidenceEdges` uses exactly the same predicate as the internal-symbol
337
+ * span fallback (destination file present, no own-property export range for
338
+ * the symbol), so coverage and spans can never disagree.
339
+ */
340
+ export interface ContextPackCoverage {
341
+ reachedSymbols: number;
342
+ returnedSymbols: number;
343
+ omittedByBudget: number;
344
+ unresolvedEdges: number;
345
+ lowConfidenceEdges: number;
346
+ }
289
347
  /**
290
348
  * Result of a context-pack query: the set of spans needed to understand
291
349
  * how a target symbol is used across the workspace.
@@ -308,6 +366,12 @@ export interface ContextPackResult {
308
366
  note?: string;
309
367
  /** Whether source text was embedded in spans (only present when include_source was requested). */
310
368
  sourceIncluded?: boolean;
369
+ /** Source snippets with provenance; only present when include_source was requested. */
370
+ snippets?: ContextPackSnippet[];
371
+ /** Reach/omission and edge-resolution accounting; present on every result. */
372
+ coverage?: ContextPackCoverage;
373
+ /** Bounded, deduplicated non-fatal warnings (budget omissions, read failures, containment). */
374
+ warnings?: string[];
311
375
  }
312
376
  export interface AskHit {
313
377
  file: string;
@@ -26,6 +26,6 @@ export { extractFileOntology } from './repo-graph/ontology';
26
26
  export type { DeadExportsOptions } from './repo-graph/query';
27
27
  export { buildOntologyPreflightPacket, getBlastRadius, getCallers, getContextPack, getDeadExports, getDependencies, getFileOntology, getGraphHealth, getGraphNode, getImporters, getKeyFiles, getLocalizationContext, getPackageBoundaries, getSymbolConsumers, isGraphFresh, resetQueryCache, } from './repo-graph/query';
28
28
  export { getGraphPath, loadGraph, loadGraphSync, loadOrCreateGraph, saveGraph, saveIfDirty, } from './repo-graph/storage';
29
- export type { AskHit, AskOptions, AskResult, BlastRadiusResult, BuildWorkspaceGraphOptions, CallerReference, ContextPackResult, ContextPackSpan, ConventionFact, DataOperationFact, DeadExportCandidate, DeadExportsResult, FileOntology, FileReference, FileRole, FreshnessProbeState, GraphEdge, GraphExtractionFailure, GraphExtractorInputWitness, GraphHealthResult, GraphNode, GraphUnresolvedImport, LocalizationBlock, OntologyFinding, PackageBoundarySummary, RepoGraph, RepoGraphDiagnostics, RouteFact, RouteMethod, SecurityFact, SymbolEdge, SymbolEdgeEvidence, SymbolEdgeKind, SymbolEdgeResolution, SymbolIdentityKind, SymbolReference, } from './repo-graph/types';
29
+ export type { AskHit, AskOptions, AskResult, BlastRadiusResult, BuildWorkspaceGraphOptions, CallerReference, ContextPackCoverage, ContextPackResult, ContextPackSnippet, ContextPackSourceMode, ContextPackSpan, ConventionFact, DataOperationFact, DeadExportCandidate, DeadExportsResult, FileOntology, FileReference, FileRole, FreshnessProbeState, GraphEdge, GraphExtractionFailure, GraphExtractorInputWitness, GraphHealthResult, GraphNode, GraphUnresolvedImport, LocalizationBlock, OntologyFinding, PackageBoundarySummary, RepoGraph, RepoGraphDiagnostics, RouteFact, RouteMethod, SecurityFact, SymbolEdge, SymbolEdgeEvidence, SymbolEdgeKind, SymbolEdgeResolution, SymbolIdentityKind, SymbolReference, } from './repo-graph/types';
30
30
  export { createEmptyGraph, GRAPH_SCHEMA_VERSION, inferPackageBoundary, isSchemaVersionAtLeast, normalizeGraphPath, REPO_GRAPH_FILENAME, updateGraphMetadata, } from './repo-graph/types';
31
31
  export { validateGraphEdge, validateGraphNode, validateWorkspace, } from './repo-graph/validation';
@@ -9,8 +9,15 @@
9
9
  * Closes issue #629: lets users wire an expensive OpenRouter model and cap
10
10
  * its usage to e.g. 10 calls/day.
11
11
  */
12
+ import { findWriteApprovalFact, formatApproveWriteCommand } from '../security/write-authority.js';
12
13
  import { createSwarmTool } from './create-tool.js';
14
+ declare const writeAuthorityDependencies: {
15
+ findWriteApprovalFact: typeof findWriteApprovalFact;
16
+ formatApproveWriteCommand: typeof formatApproveWriteCommand;
17
+ };
13
18
  export declare const skill_improve: ReturnType<typeof createSwarmTool>;
14
19
  export declare const _internals: {
15
20
  skill_improve: typeof skill_improve;
21
+ writeAuthorityDependencies: typeof writeAuthorityDependencies;
16
22
  };
23
+ export {};