oh-my-opencode 2.5.4 → 2.6.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.
Files changed (45) hide show
  1. package/README.ja.md +13 -5
  2. package/README.ko.md +13 -5
  3. package/README.md +43 -5
  4. package/README.zh-cn.md +13 -5
  5. package/dist/cli/get-local-version/formatter.d.ts +3 -0
  6. package/dist/cli/get-local-version/index.d.ts +3 -0
  7. package/dist/cli/get-local-version/types.d.ts +13 -0
  8. package/dist/cli/index.js +1241 -108
  9. package/dist/config/index.d.ts +1 -1
  10. package/dist/config/schema.d.ts +87 -0
  11. package/dist/features/background-agent/manager.d.ts +1 -0
  12. package/dist/features/claude-code-plugin-loader/index.d.ts +3 -0
  13. package/dist/features/claude-code-plugin-loader/loader.d.ts +20 -0
  14. package/dist/features/claude-code-plugin-loader/types.d.ts +173 -0
  15. package/dist/hooks/anthropic-auto-compact/index.d.ts +1 -1
  16. package/dist/hooks/anthropic-auto-compact/pruning-deduplication.d.ts +7 -0
  17. package/dist/hooks/anthropic-auto-compact/pruning-deduplication.test.d.ts +1 -0
  18. package/dist/hooks/anthropic-auto-compact/pruning-executor.d.ts +3 -0
  19. package/dist/hooks/anthropic-auto-compact/pruning-purge-errors.d.ts +7 -0
  20. package/dist/hooks/anthropic-auto-compact/pruning-storage.d.ts +2 -0
  21. package/dist/hooks/anthropic-auto-compact/pruning-supersede.d.ts +6 -0
  22. package/dist/hooks/anthropic-auto-compact/pruning-types.d.ts +36 -0
  23. package/dist/hooks/anthropic-auto-compact/types.d.ts +5 -0
  24. package/dist/hooks/index.d.ts +1 -0
  25. package/dist/hooks/session-notification-utils.d.ts +9 -0
  26. package/dist/hooks/thinking-block-validator/index.d.ts +30 -0
  27. package/dist/index.js +2723 -644
  28. package/dist/shared/claude-config-dir.d.ts +1 -0
  29. package/dist/shared/claude-config-dir.test.d.ts +1 -0
  30. package/dist/shared/index.d.ts +2 -0
  31. package/dist/shared/jsonc-parser.d.ts +15 -0
  32. package/dist/shared/jsonc-parser.test.d.ts +1 -0
  33. package/dist/tools/ast-grep/index.d.ts +2 -90
  34. package/dist/tools/ast-grep/tools.d.ts +3 -88
  35. package/dist/tools/background-task/tools.d.ts +4 -38
  36. package/dist/tools/call-omo-agent/tools.d.ts +2 -21
  37. package/dist/tools/glob/tools.d.ts +2 -11
  38. package/dist/tools/grep/tools.d.ts +2 -13
  39. package/dist/tools/index.d.ts +3 -367
  40. package/dist/tools/interactive-bash/tools.d.ts +2 -9
  41. package/dist/tools/look-at/tools.d.ts +2 -12
  42. package/dist/tools/lsp/tools.d.ts +12 -152
  43. package/dist/tools/session-manager/tools.d.ts +5 -52
  44. package/dist/tools/slashcommand/tools.d.ts +2 -9
  45. package/package.json +2 -1
@@ -1,2 +1,2 @@
1
1
  export { OhMyOpenCodeConfigSchema, AgentOverrideConfigSchema, AgentOverridesSchema, McpNameSchema, AgentNameSchema, HookNameSchema, SisyphusAgentConfigSchema, ExperimentalConfigSchema, } from "./schema";
2
- export type { OhMyOpenCodeConfig, AgentOverrideConfig, AgentOverrides, McpName, AgentName, HookName, SisyphusAgentConfig, ExperimentalConfig, } from "./schema";
2
+ export type { OhMyOpenCodeConfig, AgentOverrideConfig, AgentOverrides, McpName, AgentName, HookName, SisyphusAgentConfig, ExperimentalConfig, DynamicContextPruningConfig, } from "./schema";
@@ -52,6 +52,7 @@ export declare const HookNameSchema: z.ZodEnum<{
52
52
  "non-interactive-env": "non-interactive-env";
53
53
  "interactive-bash-session": "interactive-bash-session";
54
54
  "empty-message-sanitizer": "empty-message-sanitizer";
55
+ "thinking-block-validator": "thinking-block-validator";
55
56
  }>;
56
57
  export declare const AgentOverrideConfigSchema: z.ZodObject<{
57
58
  model: z.ZodOptional<z.ZodString>;
@@ -625,6 +626,8 @@ export declare const ClaudeCodeConfigSchema: z.ZodObject<{
625
626
  skills: z.ZodOptional<z.ZodBoolean>;
626
627
  agents: z.ZodOptional<z.ZodBoolean>;
627
628
  hooks: z.ZodOptional<z.ZodBoolean>;
629
+ plugins: z.ZodOptional<z.ZodBoolean>;
630
+ plugins_override: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
628
631
  }, z.core.$strip>;
629
632
  export declare const SisyphusAgentConfigSchema: z.ZodObject<{
630
633
  disabled: z.ZodOptional<z.ZodBoolean>;
@@ -632,12 +635,65 @@ export declare const SisyphusAgentConfigSchema: z.ZodObject<{
632
635
  planner_enabled: z.ZodOptional<z.ZodBoolean>;
633
636
  replace_plan: z.ZodOptional<z.ZodBoolean>;
634
637
  }, z.core.$strip>;
638
+ export declare const DynamicContextPruningConfigSchema: z.ZodObject<{
639
+ enabled: z.ZodDefault<z.ZodBoolean>;
640
+ notification: z.ZodDefault<z.ZodEnum<{
641
+ off: "off";
642
+ minimal: "minimal";
643
+ detailed: "detailed";
644
+ }>>;
645
+ turn_protection: z.ZodOptional<z.ZodObject<{
646
+ enabled: z.ZodDefault<z.ZodBoolean>;
647
+ turns: z.ZodDefault<z.ZodNumber>;
648
+ }, z.core.$strip>>;
649
+ protected_tools: z.ZodDefault<z.ZodArray<z.ZodString>>;
650
+ strategies: z.ZodOptional<z.ZodObject<{
651
+ deduplication: z.ZodOptional<z.ZodObject<{
652
+ enabled: z.ZodDefault<z.ZodBoolean>;
653
+ }, z.core.$strip>>;
654
+ supersede_writes: z.ZodOptional<z.ZodObject<{
655
+ enabled: z.ZodDefault<z.ZodBoolean>;
656
+ aggressive: z.ZodDefault<z.ZodBoolean>;
657
+ }, z.core.$strip>>;
658
+ purge_errors: z.ZodOptional<z.ZodObject<{
659
+ enabled: z.ZodDefault<z.ZodBoolean>;
660
+ turns: z.ZodDefault<z.ZodNumber>;
661
+ }, z.core.$strip>>;
662
+ }, z.core.$strip>>;
663
+ }, z.core.$strip>;
635
664
  export declare const ExperimentalConfigSchema: z.ZodObject<{
636
665
  aggressive_truncation: z.ZodOptional<z.ZodBoolean>;
637
666
  auto_resume: z.ZodOptional<z.ZodBoolean>;
638
667
  preemptive_compaction: z.ZodOptional<z.ZodBoolean>;
639
668
  preemptive_compaction_threshold: z.ZodOptional<z.ZodNumber>;
640
669
  truncate_all_tool_outputs: z.ZodDefault<z.ZodBoolean>;
670
+ dynamic_context_pruning: z.ZodOptional<z.ZodObject<{
671
+ enabled: z.ZodDefault<z.ZodBoolean>;
672
+ notification: z.ZodDefault<z.ZodEnum<{
673
+ off: "off";
674
+ minimal: "minimal";
675
+ detailed: "detailed";
676
+ }>>;
677
+ turn_protection: z.ZodOptional<z.ZodObject<{
678
+ enabled: z.ZodDefault<z.ZodBoolean>;
679
+ turns: z.ZodDefault<z.ZodNumber>;
680
+ }, z.core.$strip>>;
681
+ protected_tools: z.ZodDefault<z.ZodArray<z.ZodString>>;
682
+ strategies: z.ZodOptional<z.ZodObject<{
683
+ deduplication: z.ZodOptional<z.ZodObject<{
684
+ enabled: z.ZodDefault<z.ZodBoolean>;
685
+ }, z.core.$strip>>;
686
+ supersede_writes: z.ZodOptional<z.ZodObject<{
687
+ enabled: z.ZodDefault<z.ZodBoolean>;
688
+ aggressive: z.ZodDefault<z.ZodBoolean>;
689
+ }, z.core.$strip>>;
690
+ purge_errors: z.ZodOptional<z.ZodObject<{
691
+ enabled: z.ZodDefault<z.ZodBoolean>;
692
+ turns: z.ZodDefault<z.ZodNumber>;
693
+ }, z.core.$strip>>;
694
+ }, z.core.$strip>>;
695
+ }, z.core.$strip>>;
696
+ dcp_on_compaction_failure: z.ZodOptional<z.ZodBoolean>;
641
697
  }, z.core.$strip>;
642
698
  export declare const OhMyOpenCodeConfigSchema: z.ZodObject<{
643
699
  $schema: z.ZodOptional<z.ZodString>;
@@ -677,6 +733,7 @@ export declare const OhMyOpenCodeConfigSchema: z.ZodObject<{
677
733
  "non-interactive-env": "non-interactive-env";
678
734
  "interactive-bash-session": "interactive-bash-session";
679
735
  "empty-message-sanitizer": "empty-message-sanitizer";
736
+ "thinking-block-validator": "thinking-block-validator";
680
737
  }>>>;
681
738
  agents: z.ZodOptional<z.ZodObject<{
682
739
  build: z.ZodOptional<z.ZodObject<{
@@ -1203,6 +1260,8 @@ export declare const OhMyOpenCodeConfigSchema: z.ZodObject<{
1203
1260
  skills: z.ZodOptional<z.ZodBoolean>;
1204
1261
  agents: z.ZodOptional<z.ZodBoolean>;
1205
1262
  hooks: z.ZodOptional<z.ZodBoolean>;
1263
+ plugins: z.ZodOptional<z.ZodBoolean>;
1264
+ plugins_override: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
1206
1265
  }, z.core.$strip>>;
1207
1266
  google_auth: z.ZodOptional<z.ZodBoolean>;
1208
1267
  sisyphus_agent: z.ZodOptional<z.ZodObject<{
@@ -1217,6 +1276,33 @@ export declare const OhMyOpenCodeConfigSchema: z.ZodObject<{
1217
1276
  preemptive_compaction: z.ZodOptional<z.ZodBoolean>;
1218
1277
  preemptive_compaction_threshold: z.ZodOptional<z.ZodNumber>;
1219
1278
  truncate_all_tool_outputs: z.ZodDefault<z.ZodBoolean>;
1279
+ dynamic_context_pruning: z.ZodOptional<z.ZodObject<{
1280
+ enabled: z.ZodDefault<z.ZodBoolean>;
1281
+ notification: z.ZodDefault<z.ZodEnum<{
1282
+ off: "off";
1283
+ minimal: "minimal";
1284
+ detailed: "detailed";
1285
+ }>>;
1286
+ turn_protection: z.ZodOptional<z.ZodObject<{
1287
+ enabled: z.ZodDefault<z.ZodBoolean>;
1288
+ turns: z.ZodDefault<z.ZodNumber>;
1289
+ }, z.core.$strip>>;
1290
+ protected_tools: z.ZodDefault<z.ZodArray<z.ZodString>>;
1291
+ strategies: z.ZodOptional<z.ZodObject<{
1292
+ deduplication: z.ZodOptional<z.ZodObject<{
1293
+ enabled: z.ZodDefault<z.ZodBoolean>;
1294
+ }, z.core.$strip>>;
1295
+ supersede_writes: z.ZodOptional<z.ZodObject<{
1296
+ enabled: z.ZodDefault<z.ZodBoolean>;
1297
+ aggressive: z.ZodDefault<z.ZodBoolean>;
1298
+ }, z.core.$strip>>;
1299
+ purge_errors: z.ZodOptional<z.ZodObject<{
1300
+ enabled: z.ZodDefault<z.ZodBoolean>;
1301
+ turns: z.ZodDefault<z.ZodNumber>;
1302
+ }, z.core.$strip>>;
1303
+ }, z.core.$strip>>;
1304
+ }, z.core.$strip>>;
1305
+ dcp_on_compaction_failure: z.ZodOptional<z.ZodBoolean>;
1220
1306
  }, z.core.$strip>>;
1221
1307
  auto_update: z.ZodOptional<z.ZodBoolean>;
1222
1308
  }, z.core.$strip>;
@@ -1227,4 +1313,5 @@ export type AgentName = z.infer<typeof AgentNameSchema>;
1227
1313
  export type HookName = z.infer<typeof HookNameSchema>;
1228
1314
  export type SisyphusAgentConfig = z.infer<typeof SisyphusAgentConfigSchema>;
1229
1315
  export type ExperimentalConfig = z.infer<typeof ExperimentalConfigSchema>;
1316
+ export type DynamicContextPruningConfig = z.infer<typeof DynamicContextPruningConfigSchema>;
1230
1317
  export { McpNameSchema, type McpName } from "../mcp/types";
@@ -31,6 +31,7 @@ export declare class BackgroundManager {
31
31
  private clearNotificationsForTask;
32
32
  private startPolling;
33
33
  private stopPolling;
34
+ cleanup(): void;
34
35
  private notifyParentSession;
35
36
  private formatDuration;
36
37
  private hasRunningTasks;
@@ -0,0 +1,3 @@
1
+ export * from "./types";
2
+ export * from "./loader";
3
+ export type { PluginLoaderOptions, ClaudeSettings } from "./types";
@@ -0,0 +1,20 @@
1
+ import type { AgentConfig } from "@opencode-ai/sdk";
2
+ import type { CommandDefinition } from "../claude-code-command-loader/types";
3
+ import type { McpServerConfig } from "../claude-code-mcp-loader/types";
4
+ import type { LoadedPlugin, PluginLoadResult, PluginLoadError, HooksConfig, PluginLoaderOptions } from "./types";
5
+ export declare function discoverInstalledPlugins(options?: PluginLoaderOptions): PluginLoadResult;
6
+ export declare function loadPluginCommands(plugins: LoadedPlugin[]): Record<string, CommandDefinition>;
7
+ export declare function loadPluginSkillsAsCommands(plugins: LoadedPlugin[]): Record<string, CommandDefinition>;
8
+ export declare function loadPluginAgents(plugins: LoadedPlugin[]): Record<string, AgentConfig>;
9
+ export declare function loadPluginMcpServers(plugins: LoadedPlugin[]): Promise<Record<string, McpServerConfig>>;
10
+ export declare function loadPluginHooksConfigs(plugins: LoadedPlugin[]): HooksConfig[];
11
+ export interface PluginComponentsResult {
12
+ commands: Record<string, CommandDefinition>;
13
+ skills: Record<string, CommandDefinition>;
14
+ agents: Record<string, AgentConfig>;
15
+ mcpServers: Record<string, McpServerConfig>;
16
+ hooksConfigs: HooksConfig[];
17
+ plugins: LoadedPlugin[];
18
+ errors: PluginLoadError[];
19
+ }
20
+ export declare function loadAllPluginComponents(options?: PluginLoaderOptions): Promise<PluginComponentsResult>;
@@ -0,0 +1,173 @@
1
+ /**
2
+ * Claude Code Plugin Types
3
+ *
4
+ * Type definitions for Claude Code plugin system compatibility.
5
+ * Based on https://code.claude.com/docs/en/plugins-reference
6
+ */
7
+ export type PluginScope = "user" | "project" | "local" | "managed";
8
+ /**
9
+ * Plugin installation entry in installed_plugins.json
10
+ */
11
+ export interface PluginInstallation {
12
+ scope: PluginScope;
13
+ installPath: string;
14
+ version: string;
15
+ installedAt: string;
16
+ lastUpdated: string;
17
+ gitCommitSha?: string;
18
+ isLocal?: boolean;
19
+ }
20
+ /**
21
+ * Installed plugins database structure
22
+ * Located at ~/.claude/plugins/installed_plugins.json
23
+ */
24
+ export interface InstalledPluginsDatabase {
25
+ version: number;
26
+ plugins: Record<string, PluginInstallation[]>;
27
+ }
28
+ /**
29
+ * Plugin author information
30
+ */
31
+ export interface PluginAuthor {
32
+ name?: string;
33
+ email?: string;
34
+ url?: string;
35
+ }
36
+ /**
37
+ * Plugin manifest (plugin.json)
38
+ * Located at <plugin_root>/.claude-plugin/plugin.json
39
+ */
40
+ export interface PluginManifest {
41
+ name: string;
42
+ version?: string;
43
+ description?: string;
44
+ author?: PluginAuthor;
45
+ homepage?: string;
46
+ repository?: string;
47
+ license?: string;
48
+ keywords?: string[];
49
+ commands?: string | string[];
50
+ agents?: string | string[];
51
+ skills?: string | string[];
52
+ hooks?: string | HooksConfig;
53
+ mcpServers?: string | McpServersConfig;
54
+ lspServers?: string | LspServersConfig;
55
+ outputStyles?: string | string[];
56
+ }
57
+ /**
58
+ * Hooks configuration
59
+ */
60
+ export interface HookEntry {
61
+ type: "command" | "prompt" | "agent";
62
+ command?: string;
63
+ prompt?: string;
64
+ agent?: string;
65
+ }
66
+ export interface HookMatcher {
67
+ matcher?: string;
68
+ hooks: HookEntry[];
69
+ }
70
+ export interface HooksConfig {
71
+ hooks?: {
72
+ PreToolUse?: HookMatcher[];
73
+ PostToolUse?: HookMatcher[];
74
+ PostToolUseFailure?: HookMatcher[];
75
+ PermissionRequest?: HookMatcher[];
76
+ UserPromptSubmit?: HookMatcher[];
77
+ Notification?: HookMatcher[];
78
+ Stop?: HookMatcher[];
79
+ SubagentStart?: HookMatcher[];
80
+ SubagentStop?: HookMatcher[];
81
+ SessionStart?: HookMatcher[];
82
+ SessionEnd?: HookMatcher[];
83
+ PreCompact?: HookMatcher[];
84
+ };
85
+ }
86
+ /**
87
+ * MCP servers configuration in plugin
88
+ */
89
+ export interface PluginMcpServer {
90
+ command?: string;
91
+ args?: string[];
92
+ env?: Record<string, string>;
93
+ cwd?: string;
94
+ url?: string;
95
+ type?: "stdio" | "http" | "sse";
96
+ disabled?: boolean;
97
+ }
98
+ export interface McpServersConfig {
99
+ mcpServers?: Record<string, PluginMcpServer>;
100
+ }
101
+ /**
102
+ * LSP server configuration
103
+ */
104
+ export interface LspServerConfig {
105
+ command: string;
106
+ args?: string[];
107
+ extensionToLanguage: Record<string, string>;
108
+ transport?: "stdio" | "socket";
109
+ env?: Record<string, string>;
110
+ initializationOptions?: Record<string, unknown>;
111
+ settings?: Record<string, unknown>;
112
+ workspaceFolder?: string;
113
+ startupTimeout?: number;
114
+ shutdownTimeout?: number;
115
+ restartOnCrash?: boolean;
116
+ maxRestarts?: number;
117
+ loggingConfig?: {
118
+ args?: string[];
119
+ env?: Record<string, string>;
120
+ };
121
+ }
122
+ export interface LspServersConfig {
123
+ [language: string]: LspServerConfig;
124
+ }
125
+ /**
126
+ * Loaded plugin with all resolved components
127
+ */
128
+ export interface LoadedPlugin {
129
+ name: string;
130
+ version: string;
131
+ scope: PluginScope;
132
+ installPath: string;
133
+ manifest?: PluginManifest;
134
+ pluginKey: string;
135
+ commandsDir?: string;
136
+ agentsDir?: string;
137
+ skillsDir?: string;
138
+ hooksPath?: string;
139
+ mcpPath?: string;
140
+ lspPath?: string;
141
+ }
142
+ /**
143
+ * Plugin load result with all components
144
+ */
145
+ export interface PluginLoadResult {
146
+ plugins: LoadedPlugin[];
147
+ errors: PluginLoadError[];
148
+ }
149
+ export interface PluginLoadError {
150
+ pluginKey: string;
151
+ installPath: string;
152
+ error: string;
153
+ }
154
+ /**
155
+ * Claude settings from ~/.claude/settings.json
156
+ */
157
+ export interface ClaudeSettings {
158
+ enabledPlugins?: Record<string, boolean>;
159
+ [key: string]: unknown;
160
+ }
161
+ /**
162
+ * Plugin loader options
163
+ */
164
+ export interface PluginLoaderOptions {
165
+ /**
166
+ * Override enabled plugins from oh-my-opencode config.
167
+ * Key format: "pluginName@marketplace" (e.g., "shell-scripting@claude-code-workflows")
168
+ * Value: true = enabled, false = disabled
169
+ *
170
+ * This takes precedence over ~/.claude/settings.json enabledPlugins
171
+ */
172
+ enabledPluginsOverride?: Record<string, boolean>;
173
+ }
@@ -11,6 +11,6 @@ export declare function createAnthropicAutoCompactHook(ctx: PluginInput, options
11
11
  };
12
12
  }) => Promise<void>;
13
13
  };
14
- export type { AutoCompactState, FallbackState, ParsedTokenLimitError, TruncateState } from "./types";
14
+ export type { AutoCompactState, DcpState, FallbackState, ParsedTokenLimitError, TruncateState } from "./types";
15
15
  export { parseAnthropicTokenLimitError } from "./parser";
16
16
  export { executeCompact, getLastAssistant } from "./executor";
@@ -0,0 +1,7 @@
1
+ import type { PruningState } from "./pruning-types";
2
+ export interface DeduplicationConfig {
3
+ enabled: boolean;
4
+ protectedTools?: string[];
5
+ }
6
+ export declare function createToolSignature(toolName: string, input: unknown): string;
7
+ export declare function executeDeduplication(sessionID: string, state: PruningState, config: DeduplicationConfig, protectedTools: Set<string>): number;
@@ -0,0 +1,3 @@
1
+ import type { DynamicContextPruningConfig } from "../../config";
2
+ import type { PruningResult } from "./pruning-types";
3
+ export declare function executeDynamicContextPruning(sessionID: string, config: DynamicContextPruningConfig, client: any): Promise<PruningResult>;
@@ -0,0 +1,7 @@
1
+ import type { PruningState } from "./pruning-types";
2
+ export interface PurgeErrorsConfig {
3
+ enabled: boolean;
4
+ turns: number;
5
+ protectedTools?: string[];
6
+ }
7
+ export declare function executePurgeErrors(sessionID: string, state: PruningState, config: PurgeErrorsConfig, protectedTools: Set<string>): number;
@@ -0,0 +1,2 @@
1
+ import type { PruningState } from "./pruning-types";
2
+ export declare function applyPruning(sessionID: string, state: PruningState): Promise<number>;
@@ -0,0 +1,6 @@
1
+ import type { PruningState } from "./pruning-types";
2
+ export interface SupersedeWritesConfig {
3
+ enabled: boolean;
4
+ aggressive: boolean;
5
+ }
6
+ export declare function executeSupersedeWrites(sessionID: string, state: PruningState, config: SupersedeWritesConfig, protectedTools: Set<string>): number;
@@ -0,0 +1,36 @@
1
+ export interface ToolCallSignature {
2
+ toolName: string;
3
+ signature: string;
4
+ callID: string;
5
+ turn: number;
6
+ }
7
+ export interface FileOperation {
8
+ callID: string;
9
+ tool: string;
10
+ filePath: string;
11
+ turn: number;
12
+ }
13
+ export interface ErroredToolCall {
14
+ callID: string;
15
+ toolName: string;
16
+ turn: number;
17
+ errorAge: number;
18
+ }
19
+ export interface PruningResult {
20
+ itemsPruned: number;
21
+ totalTokensSaved: number;
22
+ strategies: {
23
+ deduplication: number;
24
+ supersedeWrites: number;
25
+ purgeErrors: number;
26
+ };
27
+ }
28
+ export interface PruningState {
29
+ toolIdsToPrune: Set<string>;
30
+ currentTurn: number;
31
+ fileOperations: Map<string, FileOperation[]>;
32
+ toolSignatures: Map<string, ToolCallSignature[]>;
33
+ erroredTools: Map<string, ErroredToolCall>;
34
+ }
35
+ export declare const CHARS_PER_TOKEN = 4;
36
+ export declare function estimateTokens(text: string): number;
@@ -19,12 +19,17 @@ export interface TruncateState {
19
19
  truncateAttempt: number;
20
20
  lastTruncatedPartId?: string;
21
21
  }
22
+ export interface DcpState {
23
+ attempted: boolean;
24
+ itemsPruned: number;
25
+ }
22
26
  export interface AutoCompactState {
23
27
  pendingCompact: Set<string>;
24
28
  errorDataBySession: Map<string, ParsedTokenLimitError>;
25
29
  retryStateBySession: Map<string, RetryState>;
26
30
  fallbackStateBySession: Map<string, FallbackState>;
27
31
  truncateStateBySession: Map<string, TruncateState>;
32
+ dcpStateBySession: Map<string, DcpState>;
28
33
  emptyContentAttemptBySession: Map<string, number>;
29
34
  compactionInProgress: Set<string>;
30
35
  }
@@ -20,3 +20,4 @@ export { createKeywordDetectorHook } from "./keyword-detector";
20
20
  export { createNonInteractiveEnvHook } from "./non-interactive-env";
21
21
  export { createInteractiveBashSessionHook } from "./interactive-bash-session";
22
22
  export { createEmptyMessageSanitizerHook } from "./empty-message-sanitizer";
23
+ export { createThinkingBlockValidatorHook } from "./thinking-block-validator";
@@ -0,0 +1,9 @@
1
+ type Platform = "darwin" | "linux" | "win32" | "unsupported";
2
+ export declare function getNotifySendPath(): Promise<string | null>;
3
+ export declare function getOsascriptPath(): Promise<string | null>;
4
+ export declare function getPowershellPath(): Promise<string | null>;
5
+ export declare function getAfplayPath(): Promise<string | null>;
6
+ export declare function getPaplayPath(): Promise<string | null>;
7
+ export declare function getAplayPath(): Promise<string | null>;
8
+ export declare function startBackgroundCheck(platform: Platform): void;
9
+ export {};
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Proactive Thinking Block Validator Hook
3
+ *
4
+ * Prevents "Expected thinking/redacted_thinking but found tool_use" errors
5
+ * by validating and fixing message structure BEFORE sending to Anthropic API.
6
+ *
7
+ * This hook runs on the "experimental.chat.messages.transform" hook point,
8
+ * which is called before messages are converted to ModelMessage format and
9
+ * sent to the API.
10
+ *
11
+ * Key differences from session-recovery hook:
12
+ * - PROACTIVE (prevents error) vs REACTIVE (fixes after error)
13
+ * - Runs BEFORE API call vs AFTER API error
14
+ * - User never sees the error vs User sees error then recovery
15
+ */
16
+ import type { Message, Part } from "@opencode-ai/sdk";
17
+ interface MessageWithParts {
18
+ info: Message;
19
+ parts: Part[];
20
+ }
21
+ type MessagesTransformHook = {
22
+ "experimental.chat.messages.transform"?: (input: Record<string, never>, output: {
23
+ messages: MessageWithParts[];
24
+ }) => Promise<void>;
25
+ };
26
+ /**
27
+ * Validate and fix assistant messages that have tool_use but no thinking block
28
+ */
29
+ export declare function createThinkingBlockValidatorHook(): MessagesTransformHook;
30
+ export {};