opencode-swarm 7.25.1 → 7.26.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.
@@ -16,6 +16,8 @@ export declare const _internals: {
16
16
  getProviderFailureFingerprint: typeof getProviderFailureFingerprint;
17
17
  isTransientProviderFailureText: typeof isTransientProviderFailureText;
18
18
  resolveFallbackModel: typeof resolveFallbackModel;
19
+ dcCheckJunctionCreation: typeof dcCheckJunctionCreation;
20
+ extractErrorSignal: typeof extractErrorSignal;
19
21
  };
20
22
  /**
21
23
  * Issue #853 Layer B: tools that are structurally blocked while
@@ -38,6 +40,12 @@ export declare const SPEC_DRIFT_BLOCKED_TOOLS: Set<string>;
38
40
  * immediately on the next tool call.
39
41
  */
40
42
  export declare function enforceSpecDriftGate(directory: string | undefined, toolName: string): void;
43
+ /**
44
+ * Extracts bounded provider/error signal from unknown hook error payloads.
45
+ * Do not stringify arbitrary objects here: unrelated fields like `phase: 502`
46
+ * must not accidentally become transient provider errors.
47
+ */
48
+ declare function extractErrorSignal(errorContent: unknown): string;
41
49
  type ChatMessageLike = {
42
50
  info?: {
43
51
  role?: string;
@@ -70,6 +78,20 @@ export declare function setStoredInputArgs(callID: string, args: unknown): void;
70
78
  * @param callID The callID to delete
71
79
  */
72
80
  export declare function deleteStoredInputArgs(callID: string): void;
81
+ /**
82
+ * Detect Windows junction or symlink CREATION commands.
83
+ * Junction creation followed by recursive deletion of the junction is the
84
+ * exact mechanism of the K2.6 data-loss incident.
85
+ * Block junction/symlink creation where the target resolves outside cwd.
86
+ *
87
+ * Patterns covered:
88
+ * mklink /J <link> <target>
89
+ * mklink /D <link> <target>
90
+ * New-Item -ItemType Junction -Path <link> -Target <target>
91
+ * New-Item -ItemType SymbolicLink -Path <link> -Target <target>
92
+ * ln -s <target> <link> (when target is outside cwd)
93
+ */
94
+ declare function dcCheckJunctionCreation(segment: string, cwd: string): string | null;
73
95
  /**
74
96
  * Redacts sensitive values from a shell command string before audit logging.
75
97
  * Covers env-var assignments, CLI flags, Bearer/Basic auth, and -H header flags.
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Shell Write Detector — POSIX AST + Windows regex-based write-operation detection
3
+ *
4
+ * Parses POSIX shell commands using bash-parser and statically detects
5
+ * file-system write operations using regex heuristics for Windows shells.
6
+ * Used by guardrails and scope-validation hooks to catch opaque shell
7
+ * commands that would bypass direct tool coverage.
8
+ *
9
+ * @module shell-write-detect
10
+ */
11
+ /**
12
+ * All write-operation categories detected by this module.
13
+ */
14
+ export type WriteCategory = 'redirect' | 'here_doc' | 'builtin_write' | 'inplace_edit' | 'interpreter_eval' | 'network_download' | 'archive_extract' | 'git_destructive';
15
+ /**
16
+ * A single write target detected in a shell command.
17
+ */
18
+ export interface WriteTarget {
19
+ /** The category of write operation. */
20
+ category: WriteCategory;
21
+ /** The tool or operator that triggered this write, e.g. "cp", ">", "sed -i". */
22
+ operator: string;
23
+ /** The file path written to, or null when the path cannot be determined statically. */
24
+ path: string | null;
25
+ }
26
+ /**
27
+ * Result of analyzing a single shell command.
28
+ */
29
+ export interface WriteAnalysis {
30
+ /** All write targets detected in the command (empty if none). */
31
+ writes: WriteTarget[];
32
+ /** Whether the command contains any detected writes. */
33
+ hasWrites: boolean;
34
+ /** Whether the command could not be parsed (fail-closed). */
35
+ parseError?: boolean;
36
+ }
37
+ /**
38
+ * A write target with its resolved absolute path.
39
+ */
40
+ export interface ResolvedWriteTarget {
41
+ /** The original write target. */
42
+ original: WriteTarget;
43
+ /**
44
+ * The resolved absolute path, or null if the path could not be determined
45
+ * (null original path) or was marked unresolvable (dynamic path).
46
+ */
47
+ resolvedPath: string | null;
48
+ /**
49
+ * Whether the path was successfully resolved to an absolute path.
50
+ * false when: path is null, path contains env vars ($VAR), or path
51
+ * contains command substitution ($(cmd) or `cmd`).
52
+ */
53
+ resolved: boolean;
54
+ }
55
+ /**
56
+ * Detect interactive/session tools that should be denied regardless of scope.
57
+ *
58
+ * These tools create persistent sessions or run commands repeatedly in a way
59
+ * that is inherently open-ended and cannot be bounded safely.
60
+ *
61
+ * @param command - A shell command string
62
+ * @param shell - The shell type: 'posix', 'powershell', or 'cmd'
63
+ * @returns true if the command uses an interactive/session tool
64
+ */
65
+ export declare function detectInteractiveSession(command: string, shell: 'posix' | 'powershell' | 'cmd'): boolean;
66
+ /**
67
+ * Parse a POSIX shell command and detect all file-system write operations.
68
+ *
69
+ * Detects:
70
+ * - Redirection operators: >, >>, >|, <<, <<- (here-docs)
71
+ * - Write-effect builtins: cp, mv, install, ln, truncate, dd (of=)
72
+ * - In-place editors: sed -i, perl -i, awk -i
73
+ * - Interpreter eval: python -c/-m, node -e, bun -e, ruby -e, perl -e, php -r
74
+ * - Network downloaders: curl -o, wget -O, scp
75
+ * - Archive extraction: tar -x, unzip, gunzip
76
+ * - Git destructive: git checkout --, git restore, git reset --hard, git clean -fd
77
+ *
78
+ * @param command - A POSIX shell command string
79
+ * @returns WriteAnalysis with array of detected write targets; hasWrites is false when array is empty
80
+ */
81
+ export declare function detectPosixWrites(command: string): WriteAnalysis;
82
+ /**
83
+ * Parse a Windows shell command (PowerShell or cmd.exe) and detect all
84
+ * file-system write operations using regex heuristics.
85
+ *
86
+ * Detects:
87
+ * - Redirection operators: >, >>
88
+ * - PowerShell cmdlets: Out-File, Set-Content, Add-Content, Clear-Content,
89
+ * Copy-Item, Move-Item, Remove-Item, Invoke-WebRequest (-OutFile), Start-Process
90
+ * - PowerShell aliases: echo, write (when used with redirection)
91
+ * - cmd.exe builtins: copy, move, ren, del, rd, md
92
+ * - cmd.exe redirections: >, >>
93
+ * - cmd.exe echo/set with redirection
94
+ *
95
+ * @param command - A Windows shell command string
96
+ * @param shell - Either 'powershell' or 'cmd'
97
+ * @returns WriteAnalysis with array of detected write targets; hasWrites is false when array is empty
98
+ */
99
+ export declare function detectWindowsWrites(command: string, shell: 'powershell' | 'cmd'): WriteAnalysis;
100
+ /**
101
+ * Resolve write targets from a POSIX shell command against a given cwd,
102
+ * tracking directory changes through subshell `cd` commands.
103
+ *
104
+ * This function is pure: it does not modify any external state.
105
+ *
106
+ * @param command - A POSIX shell command string (e.g., "(cd /tmp && echo x > file)")
107
+ * @param cwd - The starting current working directory (e.g., "/home/user")
108
+ * @returns Array of ResolvedWriteTarget with resolved absolute paths
109
+ */
110
+ export declare function resolveWriteTargets(command: string, writes: WriteTarget[], cwd: string): ResolvedWriteTarget[];