@opencow-ai/opencow-agent-sdk 0.4.17 → 0.4.18

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 CHANGED
@@ -148,6 +148,7 @@ const stream = query({
148
148
  cwd: process.cwd(),
149
149
  model: 'gpt-4o',
150
150
  maxTurns: 3,
151
+ builtInToolPreset: 'default',
151
152
  },
152
153
  })
153
154
 
@@ -158,6 +159,11 @@ for await (const message of stream) {
158
159
  }
159
160
  ```
160
161
 
162
+ `builtInToolPreset: 'default'` enables the SDK-owned tools for that query.
163
+ On Windows the SDK registers Bash when Git Bash is available; otherwise it
164
+ registers PowerShell (`pwsh`, then Windows PowerShell). Use `'none'`, or omit
165
+ the option, when the embedding host does not want SDK built-in tools.
166
+
161
167
  ### Use SDK MCP tools in-process
162
168
 
163
169
  ```bash
package/dist/Tool.d.ts CHANGED
@@ -22,7 +22,7 @@ import type { SpinnerMode } from './types/spinner.js';
22
22
  import type { HookProgress } from './types/hooks.js';
23
23
  import type { DeepImmutable } from './types/utils.js';
24
24
  import type { ToolUI } from './types/toolUI.js';
25
- import type { ToolRuntimeContext } from './types/toolRuntime.js';
25
+ import type { ToolRuntimeContext, ToolRuntimes } from './types/toolRuntime.js';
26
26
  export type QueryChainTracking = {
27
27
  chainId: string;
28
28
  depth: number;
@@ -80,13 +80,7 @@ export type ToolUICallbacks = {
80
80
  /** Open the interactive message selector dialog (REPL only). */
81
81
  openMessageSelector?: () => void;
82
82
  };
83
- export type ToolUseContext = ToolRuntimeContext & ToolUICallbacks & {
84
- /** Narrow tools to full Tool[] for CLI code that needs render methods. */
85
- options: ToolRuntimeContext['options'] & {
86
- tools: Tools;
87
- refreshTools?: () => Tools;
88
- };
89
- };
83
+ export type ToolUseContext = ToolRuntimeContext & ToolUICallbacks;
90
84
  export type { ToolProgressData };
91
85
  export type Progress = ToolProgressData | HookProgress;
92
86
  export type ToolProgress<P extends ToolProgressData> = {
@@ -97,7 +91,7 @@ export declare function filterToolProgressMessages(progressMessagesForMessage: P
97
91
  export type ToolResult<T> = {
98
92
  data: T;
99
93
  newMessages?: (UserMessage | AssistantMessage | AttachmentMessage | SystemMessage)[];
100
- contextModifier?: (context: ToolUseContext) => ToolUseContext;
94
+ contextModifier?: (context: ToolRuntimeContext) => ToolRuntimeContext;
101
95
  /** MCP protocol metadata (structuredContent, _meta) to pass through to SDK consumers */
102
96
  mcpMeta?: {
103
97
  _meta?: Record<string, unknown>;
@@ -136,7 +130,7 @@ export type Tool<Input extends AnyObject = AnyObject, Output = unknown, P extend
136
130
  description(input: z.infer<Input>, options: {
137
131
  isNonInteractiveSession: boolean;
138
132
  toolPermissionContext: ToolPermissionContext;
139
- tools: Tools;
133
+ tools: ToolRuntimes;
140
134
  }): Promise<string>;
141
135
  readonly inputSchema: Input;
142
136
  readonly inputJSONSchema?: ToolInputJSONSchema;
@@ -248,7 +242,7 @@ export type Tool<Input extends AnyObject = AnyObject, Output = unknown, P extend
248
242
  preparePermissionMatcher?(input: z.infer<Input>): Promise<(pattern: string) => boolean>;
249
243
  prompt(options: {
250
244
  getToolPermissionContext: () => Promise<ToolPermissionContext>;
251
- tools: Tools;
245
+ tools: ToolRuntimes;
252
246
  agents: AgentDefinition[];
253
247
  allowedAgentTypes?: string[];
254
248
  }): Promise<string>;
@@ -1,6 +1,6 @@
1
1
  import type { Command } from '../../types/command.js';
2
2
  type AgentMcpServerInfo = any;
3
- import type { Tool } from '../../Tool.js';
3
+ import type { ToolRuntime } from '../../types/toolRuntime.js';
4
4
  import type { AgentDefinition } from '../tools/AgentTool/loadAgentsDir.js';
5
5
  import { type ConfigScope, type MCPServerConnection, type McpServerConfig, type ScopedMcpServerConfig, type ServerResource } from './types.js';
6
6
  /**
@@ -10,7 +10,7 @@ import { type ConfigScope, type MCPServerConnection, type McpServerConfig, type
10
10
  * @param serverName Name of the MCP server
11
11
  * @returns Tools belonging to the specified server
12
12
  */
13
- export declare function filterToolsByServer(tools: Tool[], serverName: string): Tool[];
13
+ export declare function filterToolsByServer(tools: ToolRuntime[], serverName: string): ToolRuntime[];
14
14
  /**
15
15
  * True when a command belongs to the given MCP server.
16
16
  *
@@ -49,7 +49,7 @@ export declare function filterResourcesByServer(resources: ServerResource[], ser
49
49
  * @param serverName Name of the MCP server to exclude
50
50
  * @returns Tools not belonging to the specified server
51
51
  */
52
- export declare function excludeToolsByServer(tools: Tool[], serverName: string): Tool[];
52
+ export declare function excludeToolsByServer(tools: ToolRuntime[], serverName: string): ToolRuntime[];
53
53
  /**
54
54
  * Removes commands belonging to a specific MCP server
55
55
  * @param commands Array of commands
@@ -87,12 +87,12 @@ export declare function hashMcpConfig(config: ScopedMcpServerConfig): string;
87
87
  */
88
88
  export declare function excludeStalePluginClients(mcp: {
89
89
  clients: MCPServerConnection[];
90
- tools: Tool[];
90
+ tools: ToolRuntime[];
91
91
  commands: Command[];
92
92
  resources: Record<string, ServerResource[]>;
93
93
  }, configs: Record<string, ScopedMcpServerConfig>): {
94
94
  clients: MCPServerConnection[];
95
- tools: Tool[];
95
+ tools: ToolRuntime[];
96
96
  commands: Command[];
97
97
  resources: Record<string, ServerResource[]>;
98
98
  stale: MCPServerConnection[];
@@ -109,7 +109,7 @@ export declare function isToolFromMcpServer(toolName: string, serverName: string
109
109
  * @param tool The tool to check
110
110
  * @returns True if the tool is from an MCP server
111
111
  */
112
- export declare function isMcpTool(tool: Tool): boolean;
112
+ export declare function isMcpTool(tool: Pick<ToolRuntime, 'name' | 'isMcp'>): boolean;
113
113
  /**
114
114
  * Checks if a command belongs to any MCP server
115
115
  * @param command The command to check
@@ -0,0 +1 @@
1
+ export declare function findPosixShell(): Promise<string>;
@@ -10,11 +10,6 @@
10
10
  * Windows/macOS, PATH is sufficient.
11
11
  */
12
12
  export declare function findPowerShell(): Promise<string | null>;
13
- /**
14
- * Gets the cached PowerShell path. Returns a memoized promise that
15
- * resolves to the PowerShell executable path or null.
16
- */
17
- export declare function getCachedPowerShellPath(): Promise<string | null>;
18
13
  export type PowerShellEdition = 'core' | 'desktop';
19
14
  /**
20
15
  * Infers the PowerShell edition from the binary name without spawning.
@@ -29,8 +24,4 @@ export type PowerShellEdition = 'core' | 'desktop';
29
24
  * the model doesn't emit `cmd1 && cmd2` on 5.1 (parser error) or avoid
30
25
  * `&&` on 7+ where it's the correct short-circuiting operator.
31
26
  */
32
- export declare function getPowerShellEdition(): Promise<PowerShellEdition | null>;
33
- /**
34
- * Resets the cached PowerShell path. Only for testing.
35
- */
36
- export declare function resetPowerShellCache(): void;
27
+ export declare function inferPowerShellEdition(executablePath: string | null): PowerShellEdition | null;
@@ -0,0 +1,33 @@
1
+ import type { Platform } from '../../lib/platform.js';
2
+ import { type GitBashExecutable } from '../../lib/windowsPaths.js';
3
+ import type { ShellType } from './shellProvider.js';
4
+ export type ShellCapabilitySource = 'env' | 'standard-path' | 'path';
5
+ export type ShellExecutable = {
6
+ type: ShellType;
7
+ path: string;
8
+ source: ShellCapabilitySource;
9
+ };
10
+ export type ShellCapabilities = {
11
+ platform: Platform;
12
+ defaultShell: ShellExecutable | null;
13
+ bash: ShellExecutable | null;
14
+ powershell: ShellExecutable | null;
15
+ };
16
+ export type ShellCapabilityDependencies = {
17
+ platform: () => Platform;
18
+ findGitBash: () => GitBashExecutable | null;
19
+ findPowerShell: () => Promise<string | null>;
20
+ findPosixShell: () => Promise<string>;
21
+ setProcessShell: (shellPath: string) => void;
22
+ };
23
+ export declare class ShellCapabilityError extends Error {
24
+ readonly code: 'NO_SHELL_AVAILABLE' | 'SHELL_NOT_AVAILABLE';
25
+ constructor(code: 'NO_SHELL_AVAILABLE' | 'SHELL_NOT_AVAILABLE', message: string);
26
+ }
27
+ export declare function detectShellCapabilities(dependencies?: ShellCapabilityDependencies): Promise<ShellCapabilities>;
28
+ export declare function initializeShellCapabilities(): Promise<ShellCapabilities>;
29
+ export declare function resolveShellCapability(capabilities: ShellCapabilities, type?: ShellType): ShellExecutable;
30
+ export declare function requireDefaultShellCapability(): Promise<ShellExecutable>;
31
+ export declare function requireShellCapability(type: ShellType): Promise<ShellExecutable>;
32
+ /** Test-only reset for deterministic platform and PATH fixtures. */
33
+ export declare function resetShellCapabilitiesForTest(): void;
@@ -1,6 +1,5 @@
1
1
  export declare const SHELL_TYPES: readonly ["bash", "powershell"];
2
2
  export type ShellType = (typeof SHELL_TYPES)[number];
3
- export declare const DEFAULT_HOOK_SHELL: ShellType;
4
3
  export type ShellProvider = {
5
4
  type: ShellType;
6
5
  shellPath: string;
@@ -1,11 +1 @@
1
1
  export declare const SHELL_TOOL_NAMES: string[];
2
- /**
3
- * Runtime gate for PowerShellTool. Windows-only (the permission engine uses
4
- * Win32-specific path normalizations). Ant defaults on (opt-out via env=0);
5
- * external defaults off (opt-in via env=1).
6
- *
7
- * Used by tools.ts (tool-list visibility), processBashCommand (! routing),
8
- * and promptShellExecution (skill frontmatter routing) so the gate is
9
- * consistent across all paths that invoke PowerShellTool.call().
10
- */
11
- export declare function isPowerShellToolEnabled(): boolean;