@opencow-ai/opencow-agent-sdk 0.4.17 → 0.4.19
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 +6 -0
- package/dist/Tool.d.ts +5 -11
- package/dist/capabilities/mcp/utils.d.ts +6 -6
- package/dist/capabilities/shell/posixShellDetection.d.ts +1 -0
- package/dist/capabilities/shell/powershellDetection.d.ts +1 -10
- package/dist/capabilities/shell/shellCapabilities.d.ts +33 -0
- package/dist/capabilities/shell/shellProvider.d.ts +0 -1
- package/dist/capabilities/shell/shellToolUtils.d.ts +0 -10
- package/dist/capabilities/tools/AgentTool/agentLifecycleFinalizer.d.ts +3 -0
- package/dist/cli.mjs +173450 -173159
- package/dist/client.d.ts +3 -2
- package/dist/client.js +5600 -5155
- package/dist/constants/envVars.d.ts +0 -1
- package/dist/constants/prompts.d.ts +6 -4
- package/dist/entrypoints/sdk/runtimeTypes.d.ts +14 -7
- package/dist/lib/frontmatterParser.d.ts +4 -4
- package/dist/lib/windowsPaths.d.ts +12 -10
- package/dist/sdk.js +5600 -5155
- package/dist/session/backgroundAbortRegistry.d.ts +15 -7
- package/dist/session/backgroundTaskScope.d.ts +29 -0
- package/dist/session/collapseReadSearch.d.ts +2 -1
- package/dist/session/promptShellExecution.d.ts +3 -5
- package/dist/session/settings/types.d.ts +0 -4
- package/dist/state/AppStateStore.d.ts +3 -2
- package/dist/tasks/LocalAgentTask/LocalAgentTask.d.ts +3 -3
- package/dist/tools.d.ts +6 -7
- package/package.json +1 -1
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
type BackgroundAgentStopActions = {
|
|
2
|
+
abort: () => void;
|
|
3
|
+
stopShells: () => void;
|
|
4
|
+
};
|
|
5
|
+
export declare function registerBackgroundAgentAbort(agentId: string, actions: BackgroundAgentStopActions): void;
|
|
2
6
|
export declare function unregisterBackgroundAgentAbort(agentId: string): void;
|
|
3
7
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* The
|
|
7
|
-
*
|
|
8
|
-
*
|
|
8
|
+
* Stop a background sub-agent by id and wait for its runAgent finalizer.
|
|
9
|
+
*
|
|
10
|
+
* The first caller synchronously aborts the run and stops its owned shells.
|
|
11
|
+
* Later callers share the same Promise. The Promise resolves only when
|
|
12
|
+
* runAgent unregisters after MCP cleanup and all remaining finalizers.
|
|
13
|
+
* Unknown or already-settled agents are an idempotent completed stop.
|
|
9
14
|
*/
|
|
10
|
-
export declare function abortBackgroundAgentById(agentId: string):
|
|
15
|
+
export declare function abortBackgroundAgentById(agentId: string): Promise<void>;
|
|
16
|
+
export declare function hasBackgroundAgent(agentId: string): boolean;
|
|
17
|
+
export declare function stopBackgroundAgentShellsById(agentId: string): void;
|
|
11
18
|
/**
|
|
12
19
|
* Record that the natural-stop path delivered SubagentStop for this run.
|
|
13
20
|
* No-op when the run is gone (e.g. the fallback delivery in runAgent's
|
|
@@ -21,3 +28,4 @@ export declare function markSubagentStopFired(agentId: string): void;
|
|
|
21
28
|
* is still needed. Purely a read — the per-run state dies with the entry.
|
|
22
29
|
*/
|
|
23
30
|
export declare function hasSubagentStopFired(agentId: string): boolean;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { SetAppState } from '../tasks/Task.js';
|
|
2
|
+
type OwnedBackgroundTask = {
|
|
3
|
+
stop: () => Promise<void>;
|
|
4
|
+
settled: Promise<void>;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Query/Session 维度的后台任务所有权。
|
|
8
|
+
*
|
|
9
|
+
* stop() 会先触发每个任务的 stop,再等待任务自身 settled;重复调用共享
|
|
10
|
+
* 同一个 Promise。任务自然结束时会从 scope 自动注销。
|
|
11
|
+
*/
|
|
12
|
+
export declare class BackgroundTaskScope {
|
|
13
|
+
private readonly tasks;
|
|
14
|
+
private stopPromise;
|
|
15
|
+
private stopped;
|
|
16
|
+
register(task: OwnedBackgroundTask): () => void;
|
|
17
|
+
stop(): Promise<void>;
|
|
18
|
+
private drain;
|
|
19
|
+
private stopTask;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* 用每个 SDK Query 独有的 setAppState 函数作为窄 owner key。
|
|
23
|
+
*
|
|
24
|
+
* 这只负责把深层 shell spawn 路由到已有 scope,不保存 QueryContext,
|
|
25
|
+
* 也不创建第二套 AsyncLocalStorage。
|
|
26
|
+
*/
|
|
27
|
+
export declare function bindBackgroundTaskScope(setAppState: SetAppState, scope: BackgroundTaskScope): () => void;
|
|
28
|
+
export declare function getBackgroundTaskScope(setAppState: SetAppState): BackgroundTaskScope | undefined;
|
|
29
|
+
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type Tools } from '../Tool.js';
|
|
2
|
+
import { type ToolRuntimes } from '../types/toolRuntime.js';
|
|
2
3
|
import type { CollapsedReadSearchGroup, CollapsibleMessage, RenderableMessage } from '../types/message.js';
|
|
3
4
|
/**
|
|
4
5
|
* Result of checking if a tool use is a search or read operation.
|
|
@@ -27,7 +28,7 @@ export type SearchOrReadResult = {
|
|
|
27
28
|
* Also treats Write/Edit of memory files as collapsible.
|
|
28
29
|
* Returns detailed information about whether it's a search or read operation.
|
|
29
30
|
*/
|
|
30
|
-
export declare function getToolSearchOrReadInfo(toolName: string, toolInput: unknown, tools:
|
|
31
|
+
export declare function getToolSearchOrReadInfo(toolName: string, toolInput: unknown, tools: ToolRuntimes): SearchOrReadResult;
|
|
31
32
|
/**
|
|
32
33
|
* Check if a tool_use content block is a search/read operation.
|
|
33
34
|
* Returns { isSearch, isRead, isREPL } if it's a collapsible search/read, null otherwise.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ToolRuntimeContext } from '../
|
|
1
|
+
import type { ToolRuntimeContext } from '../types/toolRuntime.js';
|
|
2
2
|
import type { FrontmatterShell } from '../lib/frontmatterParser.js';
|
|
3
3
|
/**
|
|
4
4
|
* Parses prompt text and executes any embedded shell commands.
|
|
@@ -6,9 +6,7 @@ import type { FrontmatterShell } from '../lib/frontmatterParser.js';
|
|
|
6
6
|
* - Code blocks: ```! command ```
|
|
7
7
|
* - Inline: !`command`
|
|
8
8
|
*
|
|
9
|
-
* @param shell -
|
|
10
|
-
*
|
|
11
|
-
* frontmatter (author's choice) or is undefined for built-in commands.
|
|
12
|
-
* See docs/design/ps-shell-selection.md §5.3.
|
|
9
|
+
* @param shell - Explicit frontmatter shell. When omitted, uses the detected
|
|
10
|
+
* process default. Explicit requests never fall back to another language.
|
|
13
11
|
*/
|
|
14
12
|
export declare function executeShellCommandsInPrompt(text: string, context: ToolRuntimeContext, slashCommandName: string, shell?: FrontmatterShell): Promise<string>;
|
|
@@ -333,10 +333,6 @@ export declare const SettingsSchema: () => z.ZodObject<{
|
|
|
333
333
|
sparsePaths: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
334
334
|
}, z.core.$strip>>;
|
|
335
335
|
disableAllHooks: z.ZodOptional<z.ZodBoolean>;
|
|
336
|
-
defaultShell: z.ZodOptional<z.ZodEnum<{
|
|
337
|
-
bash: "bash";
|
|
338
|
-
powershell: "powershell";
|
|
339
|
-
}>>;
|
|
340
336
|
allowManagedHooksOnly: z.ZodOptional<z.ZodBoolean>;
|
|
341
337
|
allowedHttpHookUrls: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
342
338
|
httpHookAllowedEnvVars: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
@@ -5,7 +5,8 @@ import type { Command } from '../types/command.js';
|
|
|
5
5
|
import type { ChannelPermissionCallbacks } from '../capabilities/mcp/channelPermissions.js';
|
|
6
6
|
import type { ElicitationRequestEvent } from '../capabilities/mcp/elicitationHandler.js';
|
|
7
7
|
import type { MCPServerConnection, ServerResource } from '../capabilities/mcp/types.js';
|
|
8
|
-
import { type
|
|
8
|
+
import { type ToolPermissionContext } from '../Tool.js';
|
|
9
|
+
import type { ToolRuntime } from '../types/toolRuntime.js';
|
|
9
10
|
import type { TaskState } from '../tasks/types.js';
|
|
10
11
|
import type { AgentColorName } from '../capabilities/tools/AgentTool/agentColorManager.js';
|
|
11
12
|
import type { AgentDefinitionsResult } from '../capabilities/tools/AgentTool/loadAgentsDir.js';
|
|
@@ -119,7 +120,7 @@ export type AppState = DeepImmutable<{
|
|
|
119
120
|
companionPetAt?: number;
|
|
120
121
|
mcp: {
|
|
121
122
|
clients: MCPServerConnection[];
|
|
122
|
-
tools:
|
|
123
|
+
tools: ToolRuntime[];
|
|
123
124
|
commands: Command[];
|
|
124
125
|
resources: Record<string, ServerResource[]>;
|
|
125
126
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AppState } from '../../state/AppStateStore.js';
|
|
2
2
|
import type { SetAppState, Task, TaskStateBase } from '../Task.js';
|
|
3
|
-
import type
|
|
3
|
+
import { type ToolRuntimes } from '../../types/toolRuntime.js';
|
|
4
4
|
import type { AgentToolResult } from '../../capabilities/tools/AgentTool/agentToolUtils.js';
|
|
5
5
|
import type { AgentDefinition } from '../../capabilities/tools/AgentTool/loadAgentsDir.js';
|
|
6
6
|
import type { Message } from '../../types/message.js';
|
|
@@ -36,13 +36,13 @@ export declare function getTokenCountFromTracker(tracker: ProgressTracker): numb
|
|
|
36
36
|
* from Tool.getActivityDescription() at recording time.
|
|
37
37
|
*/
|
|
38
38
|
export type ActivityDescriptionResolver = (toolName: string, input: Record<string, unknown>) => string | undefined;
|
|
39
|
-
export declare function updateProgressFromMessage(tracker: ProgressTracker, message: Message, resolveActivityDescription?: ActivityDescriptionResolver, tools?:
|
|
39
|
+
export declare function updateProgressFromMessage(tracker: ProgressTracker, message: Message, resolveActivityDescription?: ActivityDescriptionResolver, tools?: ToolRuntimes): void;
|
|
40
40
|
export declare function getProgressUpdate(tracker: ProgressTracker): AgentProgress;
|
|
41
41
|
/**
|
|
42
42
|
* Creates an ActivityDescriptionResolver from a tools list.
|
|
43
43
|
* Looks up the tool by name and calls getActivityDescription if available.
|
|
44
44
|
*/
|
|
45
|
-
export declare function createActivityDescriptionResolver(tools:
|
|
45
|
+
export declare function createActivityDescriptionResolver(tools: ToolRuntimes): ActivityDescriptionResolver;
|
|
46
46
|
export type LocalAgentTaskState = TaskStateBase & {
|
|
47
47
|
type: 'local_agent';
|
|
48
48
|
agentId: string;
|
package/dist/tools.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ToolPermissionContext, type ToolRuntimes } from './types/toolRuntime.js';
|
|
2
2
|
/**
|
|
3
3
|
* Register the built-in tools provider. Called by CLI at startup with a
|
|
4
4
|
* function that returns getAllBaseTools(). SDK mode leaves this null.
|
|
5
5
|
*/
|
|
6
|
-
export declare function registerBuiltInToolsProvider(provider: () =>
|
|
6
|
+
export declare function registerBuiltInToolsProvider(provider: () => ToolRuntimes): void;
|
|
7
7
|
export { ALL_AGENT_DISALLOWED_TOOLS, CUSTOM_AGENT_DISALLOWED_TOOLS, ASYNC_AGENT_ALLOWED_TOOLS, COORDINATOR_MODE_ALLOWED_TOOLS, } from './constants/tools.js';
|
|
8
|
-
import type { ToolPermissionContext } from './Tool.js';
|
|
9
8
|
import { REPL_ONLY_TOOLS } from './capabilities/tools/REPLTool/constants.js';
|
|
10
9
|
export { REPL_ONLY_TOOLS };
|
|
11
10
|
/**
|
|
@@ -28,7 +27,7 @@ export declare function getToolsForDefaultPreset(): string[];
|
|
|
28
27
|
*
|
|
29
28
|
* NOTE: This MUST stay in sync with https://console.statsig.com/4aF3Ewatb6xPVpCwxb5nA3/dynamic_configs/claude_code_global_system_caching, in order to cache the system prompt across users.
|
|
30
29
|
*/
|
|
31
|
-
export declare function getAllBaseTools():
|
|
30
|
+
export declare function getAllBaseTools(): ToolRuntimes;
|
|
32
31
|
/**
|
|
33
32
|
* Filters out tools that are blanket-denied by the permission context.
|
|
34
33
|
* A tool is filtered out if there's a deny rule matching its name with no
|
|
@@ -45,7 +44,7 @@ export declare function filterToolsByDenyRules<T extends {
|
|
|
45
44
|
toolName: string;
|
|
46
45
|
};
|
|
47
46
|
}>(tools: readonly T[], permissionContext: ToolPermissionContext): T[];
|
|
48
|
-
export declare const getTools: (permissionContext: ToolPermissionContext) =>
|
|
47
|
+
export declare const getTools: (permissionContext: ToolPermissionContext, explicitBuiltIns?: ToolRuntimes) => ToolRuntimes;
|
|
49
48
|
/**
|
|
50
49
|
* Assemble the full tool pool for a given permission context and MCP tools.
|
|
51
50
|
*
|
|
@@ -62,7 +61,7 @@ export declare const getTools: (permissionContext: ToolPermissionContext) => Too
|
|
|
62
61
|
* @param mcpTools - MCP tools from appState.mcp.tools
|
|
63
62
|
* @returns Combined, deduplicated array of built-in and MCP tools
|
|
64
63
|
*/
|
|
65
|
-
export declare function assembleToolPool(permissionContext: ToolPermissionContext, mcpTools:
|
|
64
|
+
export declare function assembleToolPool(permissionContext: ToolPermissionContext, mcpTools: ToolRuntimes, explicitBuiltIns?: ToolRuntimes): ToolRuntimes;
|
|
66
65
|
/**
|
|
67
66
|
* Get all tools including both built-in tools and MCP tools.
|
|
68
67
|
*
|
|
@@ -77,4 +76,4 @@ export declare function assembleToolPool(permissionContext: ToolPermissionContex
|
|
|
77
76
|
* @param mcpTools - MCP tools from appState.mcp.tools
|
|
78
77
|
* @returns Combined array of built-in and MCP tools
|
|
79
78
|
*/
|
|
80
|
-
export declare function getMergedTools(permissionContext: ToolPermissionContext, mcpTools:
|
|
79
|
+
export declare function getMergedTools(permissionContext: ToolPermissionContext, mcpTools: ToolRuntimes): ToolRuntimes;
|
package/package.json
CHANGED