@renxqoo/renx-code 0.0.4 → 0.0.6
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 +82 -51
- package/bin/renx.cjs +16 -0
- package/package.json +2 -45
- package/src/agent/runtime/runtime.context-usage.test.ts +4 -5
- package/src/agent/runtime/runtime.error-handling.test.ts +4 -5
- package/src/agent/runtime/runtime.test.ts +7 -4
- package/src/agent/runtime/runtime.ts +3 -9
- package/src/agent/runtime/runtime.usage-forwarding.test.ts +4 -5
- package/src/agent/runtime/source-modules.test.ts +16 -35
- package/src/agent/runtime/source-modules.ts +17 -0
- package/vendor/agent-root/src/agent/ENTERPRISE_ACCEPTANCE_CHECKLIST.md +95 -0
- package/vendor/agent-root/src/agent/ENTERPRISE_REALTIME.html +1345 -0
- package/vendor/agent-root/src/agent/ENTERPRISE_REALTIME.md +1353 -0
- package/vendor/agent-root/src/agent/ERROR_CONTRACT.md +60 -0
- package/vendor/agent-root/src/agent/TEST_COVERAGE_ANALYSIS.md +278 -0
- package/vendor/agent-root/src/agent/__test__/error-contract.test.ts +72 -0
- package/vendor/agent-root/src/agent/__test__/types.test.ts +137 -0
- package/vendor/agent-root/src/agent/agent/__test__/abort-runtime.test.ts +83 -0
- package/vendor/agent-root/src/agent/agent/__test__/callback-safety.test.ts +34 -0
- package/vendor/agent-root/src/agent/agent/__test__/compaction.test.ts +323 -0
- package/vendor/agent-root/src/agent/agent/__test__/concurrency.test.ts +290 -0
- package/vendor/agent-root/src/agent/agent/__test__/error-normalizer.test.ts +377 -0
- package/vendor/agent-root/src/agent/agent/__test__/error.test.ts +212 -0
- package/vendor/agent-root/src/agent/agent/__test__/fault-injection.test.ts +295 -0
- package/vendor/agent-root/src/agent/agent/__test__/index.test.ts +3607 -0
- package/vendor/agent-root/src/agent/agent/__test__/logger.test.ts +35 -0
- package/vendor/agent-root/src/agent/agent/__test__/message-utils.test.ts +517 -0
- package/vendor/agent-root/src/agent/agent/__test__/telemetry.test.ts +97 -0
- package/vendor/agent-root/src/agent/agent/__test__/timeout-budget.test.ts +479 -0
- package/vendor/agent-root/src/agent/agent/__test__/tool-call-merge.test.ts +80 -0
- package/vendor/agent-root/src/agent/agent/__test__/tool-execution-ledger.test.ts +76 -0
- package/vendor/agent-root/src/agent/agent/__test__/write-buffer.test.ts +173 -0
- package/vendor/agent-root/src/agent/agent/__test__/write-file-session.test.ts +109 -0
- package/vendor/agent-root/src/agent/agent/abort-runtime.ts +71 -0
- package/vendor/agent-root/src/agent/agent/callback-safety.ts +33 -0
- package/vendor/agent-root/src/agent/agent/compaction.ts +291 -0
- package/vendor/agent-root/src/agent/agent/concurrency.ts +103 -0
- package/vendor/agent-root/src/agent/agent/error-normalizer.ts +190 -0
- package/vendor/agent-root/src/agent/agent/error.ts +198 -0
- package/vendor/agent-root/src/agent/agent/index.ts +1772 -0
- package/vendor/agent-root/src/agent/agent/logger.ts +65 -0
- package/vendor/agent-root/src/agent/agent/message-utils.ts +101 -0
- package/vendor/agent-root/src/agent/agent/stream-events.ts +61 -0
- package/vendor/agent-root/src/agent/agent/telemetry.ts +123 -0
- package/vendor/agent-root/src/agent/agent/timeout-budget.ts +227 -0
- package/vendor/agent-root/src/agent/agent/tool-call-merge.ts +111 -0
- package/vendor/agent-root/src/agent/agent/tool-execution-ledger.ts +164 -0
- package/vendor/agent-root/src/agent/agent/write-buffer.ts +188 -0
- package/vendor/agent-root/src/agent/agent/write-file-session.ts +238 -0
- package/vendor/agent-root/src/agent/app/__test__/agent-app-service.test.ts +1053 -0
- package/vendor/agent-root/src/agent/app/__test__/minimal-agent-application.test.ts +158 -0
- package/vendor/agent-root/src/agent/app/__test__/sqlite-agent-app-store.test.ts +437 -0
- package/vendor/agent-root/src/agent/app/agent-app-service.ts +748 -0
- package/vendor/agent-root/src/agent/app/contracts.ts +109 -0
- package/vendor/agent-root/src/agent/app/index.ts +5 -0
- package/vendor/agent-root/src/agent/app/minimal-agent-application.ts +151 -0
- package/vendor/agent-root/src/agent/app/ports.ts +72 -0
- package/vendor/agent-root/src/agent/app/sqlite-agent-app-store.ts +1182 -0
- package/vendor/agent-root/src/agent/app/sqlite-client.ts +177 -0
- package/vendor/agent-root/src/agent/docs/cli-app-layer/00-README.md +36 -0
- package/vendor/agent-root/src/agent/docs/cli-app-layer/01-scope-and-goals.md +33 -0
- package/vendor/agent-root/src/agent/docs/cli-app-layer/02-architecture-overview.md +40 -0
- package/vendor/agent-root/src/agent/docs/cli-app-layer/03-domain-model-and-contracts.md +91 -0
- package/vendor/agent-root/src/agent/docs/cli-app-layer/04-ports-and-interfaces.md +116 -0
- package/vendor/agent-root/src/agent/docs/cli-app-layer/05-run-orchestration-and-state-machine.md +52 -0
- package/vendor/agent-root/src/agent/docs/cli-app-layer/06-cli-commands-and-ux.md +53 -0
- package/vendor/agent-root/src/agent/docs/cli-app-layer/07-storage-design-local.md +52 -0
- package/vendor/agent-root/src/agent/docs/cli-app-layer/08-error-and-observability.md +40 -0
- package/vendor/agent-root/src/agent/docs/cli-app-layer/09-security-and-policy-boundary.md +19 -0
- package/vendor/agent-root/src/agent/docs/cli-app-layer/10-test-plan-and-acceptance.md +28 -0
- package/vendor/agent-root/src/agent/docs/cli-app-layer/11-implementation-phases.md +26 -0
- package/vendor/agent-root/src/agent/docs/cli-app-layer/12-open-questions-and-risks.md +30 -0
- package/vendor/agent-root/src/agent/docs/cli-app-layer/13-sqlite-schema-fields-and-rationale.md +567 -0
- package/vendor/agent-root/src/agent/docs/cli-app-layer/14-project-flow-mermaid.md +583 -0
- package/vendor/agent-root/src/agent/docs/cli-app-layer/15-openclaw-style-project-blueprint.md +972 -0
- package/vendor/agent-root/src/agent/error-contract.ts +154 -0
- package/vendor/agent-root/src/agent/prompts/system.ts +246 -0
- package/vendor/agent-root/src/agent/prompts/system1.ts +208 -0
- package/vendor/agent-root/src/agent/storage/__test__/file-history-store.test.ts +98 -0
- package/vendor/agent-root/src/agent/storage/file-history-store.ts +313 -0
- package/vendor/agent-root/src/agent/storage/file-storage-config.ts +94 -0
- package/vendor/agent-root/src/agent/storage/file-system.ts +31 -0
- package/vendor/agent-root/src/agent/storage/file-write-service.ts +21 -0
- package/vendor/agent-root/src/agent/tool/__test__/base-tool.test.ts +413 -0
- package/vendor/agent-root/src/agent/tool/__test__/bash-policy.test.ts +356 -0
- package/vendor/agent-root/src/agent/tool/__test__/bash.mocked-coverage.test.ts +375 -0
- package/vendor/agent-root/src/agent/tool/__test__/bash.test.ts +372 -0
- package/vendor/agent-root/src/agent/tool/__test__/error.test.ts +108 -0
- package/vendor/agent-root/src/agent/tool/__test__/file-edit-tool.test.ts +258 -0
- package/vendor/agent-root/src/agent/tool/__test__/file-history-tools.test.ts +121 -0
- package/vendor/agent-root/src/agent/tool/__test__/file-read-tool.test.ts +210 -0
- package/vendor/agent-root/src/agent/tool/__test__/glob.test.ts +139 -0
- package/vendor/agent-root/src/agent/tool/__test__/grep.mocked-coverage.test.ts +456 -0
- package/vendor/agent-root/src/agent/tool/__test__/grep.test.ts +192 -0
- package/vendor/agent-root/src/agent/tool/__test__/lsp.test.ts +300 -0
- package/vendor/agent-root/src/agent/tool/__test__/outside-workspace-confirmation.test.ts +214 -0
- package/vendor/agent-root/src/agent/tool/__test__/path-security.test.ts +336 -0
- package/vendor/agent-root/src/agent/tool/__test__/skill-loader.test.ts +494 -0
- package/vendor/agent-root/src/agent/tool/__test__/skill-parser.test.ts +543 -0
- package/vendor/agent-root/src/agent/tool/__test__/skill-tool.test.ts +172 -0
- package/vendor/agent-root/src/agent/tool/__test__/task-concurrency-and-version.test.ts +116 -0
- package/vendor/agent-root/src/agent/tool/__test__/task-create-get-list-update.test.ts +267 -0
- package/vendor/agent-root/src/agent/tool/__test__/task-create.test.ts +519 -0
- package/vendor/agent-root/src/agent/tool/__test__/task-errors.test.ts +225 -0
- package/vendor/agent-root/src/agent/tool/__test__/task-output-blocking.test.ts +223 -0
- package/vendor/agent-root/src/agent/tool/__test__/task-output.test.ts +184 -0
- package/vendor/agent-root/src/agent/tool/__test__/task-parent-abort.test.ts +287 -0
- package/vendor/agent-root/src/agent/tool/__test__/task-real-runner-adapter.test.ts +190 -0
- package/vendor/agent-root/src/agent/tool/__test__/task-run-lifecycle.test.ts +352 -0
- package/vendor/agent-root/src/agent/tool/__test__/task-store-runner-branches.test.ts +395 -0
- package/vendor/agent-root/src/agent/tool/__test__/task-store.test.ts +391 -0
- package/vendor/agent-root/src/agent/tool/__test__/task-subagent-config-integration.test.ts +176 -0
- package/vendor/agent-root/src/agent/tool/__test__/task-subagent-config.test.ts +68 -0
- package/vendor/agent-root/src/agent/tool/__test__/task-tools-core-edges.test.ts +630 -0
- package/vendor/agent-root/src/agent/tool/__test__/task-tools-runtime-edges.test.ts +732 -0
- package/vendor/agent-root/src/agent/tool/__test__/task-types.test.ts +494 -0
- package/vendor/agent-root/src/agent/tool/__test__/task-utils-branches.test.ts +175 -0
- package/vendor/agent-root/src/agent/tool/__test__/tool-manager.test.ts +505 -0
- package/vendor/agent-root/src/agent/tool/__test__/types.test.ts +55 -0
- package/vendor/agent-root/src/agent/tool/__test__/web-fetch.test.ts +244 -0
- package/vendor/agent-root/src/agent/tool/__test__/web-search.test.ts +290 -0
- package/vendor/agent-root/src/agent/tool/__test__/write-file.test.ts +368 -0
- package/vendor/agent-root/src/agent/tool/base-tool.ts +345 -0
- package/vendor/agent-root/src/agent/tool/bash-policy.ts +636 -0
- package/vendor/agent-root/src/agent/tool/bash.ts +688 -0
- package/vendor/agent-root/src/agent/tool/error.ts +131 -0
- package/vendor/agent-root/src/agent/tool/file-edit-tool.ts +264 -0
- package/vendor/agent-root/src/agent/tool/file-history-list.ts +103 -0
- package/vendor/agent-root/src/agent/tool/file-history-restore.ts +149 -0
- package/vendor/agent-root/src/agent/tool/file-read-tool.ts +211 -0
- package/vendor/agent-root/src/agent/tool/glob.ts +171 -0
- package/vendor/agent-root/src/agent/tool/grep.ts +496 -0
- package/vendor/agent-root/src/agent/tool/lsp.ts +481 -0
- package/vendor/agent-root/src/agent/tool/path-security.ts +117 -0
- package/vendor/agent-root/src/agent/tool/search/common.ts +153 -0
- package/vendor/agent-root/src/agent/tool/skill/index.ts +13 -0
- package/vendor/agent-root/src/agent/tool/skill/loader.ts +229 -0
- package/vendor/agent-root/src/agent/tool/skill/parser.ts +124 -0
- package/vendor/agent-root/src/agent/tool/skill/types.ts +27 -0
- package/vendor/agent-root/src/agent/tool/skill-tool.ts +143 -0
- package/vendor/agent-root/src/agent/tool/task-create.ts +186 -0
- package/vendor/agent-root/src/agent/tool/task-errors.ts +42 -0
- package/vendor/agent-root/src/agent/tool/task-get.ts +116 -0
- package/vendor/agent-root/src/agent/tool/task-graph.ts +78 -0
- package/vendor/agent-root/src/agent/tool/task-list.ts +141 -0
- package/vendor/agent-root/src/agent/tool/task-mock-runner-adapter.ts +232 -0
- package/vendor/agent-root/src/agent/tool/task-output.ts +223 -0
- package/vendor/agent-root/src/agent/tool/task-parent-abort.ts +115 -0
- package/vendor/agent-root/src/agent/tool/task-real-runner-adapter.ts +336 -0
- package/vendor/agent-root/src/agent/tool/task-runner-adapter.ts +55 -0
- package/vendor/agent-root/src/agent/tool/task-stop.ts +187 -0
- package/vendor/agent-root/src/agent/tool/task-store.ts +217 -0
- package/vendor/agent-root/src/agent/tool/task-subagent-config.ts +149 -0
- package/vendor/agent-root/src/agent/tool/task-types.ts +264 -0
- package/vendor/agent-root/src/agent/tool/task-update.ts +315 -0
- package/vendor/agent-root/src/agent/tool/task.ts +209 -0
- package/vendor/agent-root/src/agent/tool/tool-manager.ts +362 -0
- package/vendor/agent-root/src/agent/tool/tool-prompts.ts +242 -0
- package/vendor/agent-root/src/agent/tool/types.ts +116 -0
- package/vendor/agent-root/src/agent/tool/web-fetch.ts +227 -0
- package/vendor/agent-root/src/agent/tool/web-search.ts +208 -0
- package/vendor/agent-root/src/agent/tool/write-file.ts +497 -0
- package/vendor/agent-root/src/agent/types.ts +232 -0
- package/vendor/agent-root/src/agent/utils/__tests__/index.test.ts +18 -0
- package/vendor/agent-root/src/agent/utils/__tests__/message-utils.test.ts +610 -0
- package/vendor/agent-root/src/agent/utils/__tests__/message.test.ts +223 -0
- package/vendor/agent-root/src/agent/utils/__tests__/token.test.ts +42 -0
- package/vendor/agent-root/src/agent/utils/index.ts +16 -0
- package/vendor/agent-root/src/agent/utils/message.ts +171 -0
- package/vendor/agent-root/src/agent/utils/token.ts +28 -0
- package/vendor/agent-root/src/config/__tests__/load-config-to-env.test.ts +129 -0
- package/vendor/agent-root/src/config/__tests__/loader.test.ts +247 -0
- package/vendor/agent-root/src/config/__tests__/runtime.test.ts +88 -0
- package/vendor/agent-root/src/config/index.ts +54 -0
- package/vendor/agent-root/src/config/loader.ts +431 -0
- package/vendor/agent-root/src/config/paths.ts +30 -0
- package/vendor/agent-root/src/config/runtime.ts +163 -0
- package/vendor/agent-root/src/config/types.ts +70 -0
- package/vendor/agent-root/src/logger/index.ts +57 -0
- package/vendor/agent-root/src/logger/logger.ts +819 -0
- package/vendor/agent-root/src/logger/types.ts +150 -0
- package/vendor/agent-root/src/providers/__tests__/errors.test.ts +441 -0
- package/vendor/agent-root/src/providers/__tests__/index.test.ts +16 -0
- package/vendor/agent-root/src/providers/__tests__/openai-compatible.options.test.ts +318 -0
- package/vendor/agent-root/src/providers/__tests__/openai-compatible.test.ts +600 -0
- package/vendor/agent-root/src/providers/__tests__/registry.test.ts +449 -0
- package/vendor/agent-root/src/providers/__tests__/responses-adapter.test.ts +298 -0
- package/vendor/agent-root/src/providers/adapters/__tests__/anthropic.test.ts +354 -0
- package/vendor/agent-root/src/providers/adapters/__tests__/kimi.test.ts +58 -0
- package/vendor/agent-root/src/providers/adapters/__tests__/standard.test.ts +261 -0
- package/vendor/agent-root/src/providers/adapters/anthropic.ts +572 -0
- package/vendor/agent-root/src/providers/adapters/base.ts +131 -0
- package/vendor/agent-root/src/providers/adapters/kimi.ts +48 -0
- package/vendor/agent-root/src/providers/adapters/responses.ts +732 -0
- package/vendor/agent-root/src/providers/adapters/standard.ts +120 -0
- package/vendor/agent-root/src/providers/http/__tests__/client.timeout.test.ts +313 -0
- package/vendor/agent-root/src/providers/http/client.ts +289 -0
- package/vendor/agent-root/src/providers/http/stream-parser.ts +109 -0
- package/vendor/agent-root/src/providers/index.ts +76 -0
- package/vendor/agent-root/src/providers/kimi-headers.ts +177 -0
- package/vendor/agent-root/src/providers/openai-compatible.ts +387 -0
- package/vendor/agent-root/src/providers/registry/model-config.ts +230 -0
- package/vendor/agent-root/src/providers/registry/provider-factory.ts +123 -0
- package/vendor/agent-root/src/providers/registry.ts +135 -0
- package/vendor/agent-root/src/providers/types/api.ts +284 -0
- package/vendor/agent-root/src/providers/types/config.ts +58 -0
- package/vendor/agent-root/src/providers/types/errors.ts +323 -0
- package/vendor/agent-root/src/providers/types/index.ts +72 -0
- package/vendor/agent-root/src/providers/types/provider.ts +45 -0
- package/vendor/agent-root/src/providers/types/registry.ts +88 -0
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Manager 工具管理器
|
|
3
|
+
* 参考: ENTERPRISE_REALTIME.md
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
LLMTool,
|
|
8
|
+
ToolCall,
|
|
9
|
+
ToolConcurrencyPolicy,
|
|
10
|
+
ToolConfirmInfo,
|
|
11
|
+
ToolPolicyCheckInfo,
|
|
12
|
+
ToolPolicyDecision,
|
|
13
|
+
ToolExecutionContext,
|
|
14
|
+
} from './types';
|
|
15
|
+
import { BaseTool, ToolConfirmDetails } from './base-tool';
|
|
16
|
+
import { ToolResult } from './base-tool';
|
|
17
|
+
import {
|
|
18
|
+
EmptyToolNameError,
|
|
19
|
+
InvalidArgumentsError,
|
|
20
|
+
ToolNotFoundError,
|
|
21
|
+
ToolValidationError,
|
|
22
|
+
ToolDeniedError,
|
|
23
|
+
ToolExecutionError,
|
|
24
|
+
ToolPolicyDeniedError,
|
|
25
|
+
} from './error';
|
|
26
|
+
import * as path from 'node:path';
|
|
27
|
+
|
|
28
|
+
interface BashRule {
|
|
29
|
+
id: string;
|
|
30
|
+
pattern: RegExp;
|
|
31
|
+
message: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type ToolConfirmationMode = 'manual' | 'auto-approve' | 'auto-deny';
|
|
35
|
+
|
|
36
|
+
export interface ToolManagerConfig {
|
|
37
|
+
enableBuiltInPolicy?: boolean;
|
|
38
|
+
dangerousBashRules?: BashRule[];
|
|
39
|
+
restrictedWritePathPrefixes?: string[];
|
|
40
|
+
confirmationMode?: ToolConfirmationMode;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const DEFAULT_DANGEROUS_BASH_RULES: BashRule[] = [
|
|
44
|
+
{
|
|
45
|
+
id: 'rm_root',
|
|
46
|
+
pattern: /(^|[;&|]\s*)rm\s+-rf\s+\/(\s|$)/i,
|
|
47
|
+
message: 'Dangerous destructive root deletion command is blocked',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
id: 'disk_format',
|
|
51
|
+
pattern: /\bmkfs(\.[a-z0-9]+)?\b/i,
|
|
52
|
+
message: 'Disk formatting command is blocked',
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: 'fork_bomb',
|
|
56
|
+
pattern: /:\(\)\s*\{\s*:\|:\s*&\s*\};:/,
|
|
57
|
+
message: 'Fork bomb pattern is blocked',
|
|
58
|
+
},
|
|
59
|
+
];
|
|
60
|
+
|
|
61
|
+
const DEFAULT_RESTRICTED_WRITE_PREFIXES = [
|
|
62
|
+
'/etc',
|
|
63
|
+
'/bin',
|
|
64
|
+
'/sbin',
|
|
65
|
+
'/usr',
|
|
66
|
+
'/System',
|
|
67
|
+
'/private/etc',
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
const TOOL_CONFIRMATION_MODE_ENV = 'AGENT_TOOL_CONFIRMATION_MODE';
|
|
71
|
+
|
|
72
|
+
const normalizeConfirmationMode = (raw?: string): ToolConfirmationMode => {
|
|
73
|
+
if (!raw || raw.trim().length === 0) {
|
|
74
|
+
return 'manual';
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const normalized = raw.trim().toLowerCase().replace(/_/g, '-');
|
|
78
|
+
if (normalized === 'manual' || normalized === 'auto-approve' || normalized === 'auto-deny') {
|
|
79
|
+
return normalized;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
throw new Error(
|
|
83
|
+
`Invalid ${TOOL_CONFIRMATION_MODE_ENV}: "${raw}" (expected "manual", "auto-approve", or "auto-deny")`
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export interface ToolManager {
|
|
88
|
+
execute(toolCall: ToolCall, options?: ToolExecutionContext): Promise<ToolResult>;
|
|
89
|
+
registerTool(tool: BaseTool): void;
|
|
90
|
+
getTools(): BaseTool[];
|
|
91
|
+
getConcurrencyPolicy?(toolCall: ToolCall): ToolConcurrencyPolicy;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* 默认工具管理器实现
|
|
96
|
+
*/
|
|
97
|
+
export class DefaultToolManager implements ToolManager {
|
|
98
|
+
private tools: Map<string, BaseTool> = new Map();
|
|
99
|
+
private readonly enableBuiltInPolicy: boolean;
|
|
100
|
+
private readonly dangerousBashRules: BashRule[];
|
|
101
|
+
private readonly restrictedWritePathPrefixes: string[];
|
|
102
|
+
private readonly confirmationMode: ToolConfirmationMode;
|
|
103
|
+
|
|
104
|
+
constructor(config: ToolManagerConfig = {}) {
|
|
105
|
+
this.enableBuiltInPolicy = config.enableBuiltInPolicy ?? true;
|
|
106
|
+
this.dangerousBashRules = config.dangerousBashRules ?? DEFAULT_DANGEROUS_BASH_RULES;
|
|
107
|
+
this.restrictedWritePathPrefixes = (
|
|
108
|
+
config.restrictedWritePathPrefixes ?? DEFAULT_RESTRICTED_WRITE_PREFIXES
|
|
109
|
+
).map((prefix) => path.resolve(prefix));
|
|
110
|
+
this.confirmationMode =
|
|
111
|
+
config.confirmationMode ?? normalizeConfirmationMode(process.env[TOOL_CONFIRMATION_MODE_ENV]);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async execute(toolCall: ToolCall, options: ToolExecutionContext): Promise<ToolResult> {
|
|
115
|
+
const toolName = toolCall.function.name;
|
|
116
|
+
|
|
117
|
+
if (!toolName) {
|
|
118
|
+
const err = new EmptyToolNameError();
|
|
119
|
+
return {
|
|
120
|
+
success: false,
|
|
121
|
+
error: err,
|
|
122
|
+
output: err.message,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
let args: Record<string, unknown>;
|
|
127
|
+
try {
|
|
128
|
+
args = JSON.parse(toolCall.function.arguments);
|
|
129
|
+
} catch (error) {
|
|
130
|
+
const err = new InvalidArgumentsError(toolName, (error as Error).message);
|
|
131
|
+
return {
|
|
132
|
+
success: false,
|
|
133
|
+
error: err,
|
|
134
|
+
output: err.message,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const handler = this.tools.get(toolName);
|
|
139
|
+
|
|
140
|
+
if (!handler) {
|
|
141
|
+
const err = new ToolNotFoundError(toolName);
|
|
142
|
+
return {
|
|
143
|
+
success: false,
|
|
144
|
+
error: err,
|
|
145
|
+
output: err.message,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const validationResult = handler.safeValidateArgs(args);
|
|
150
|
+
|
|
151
|
+
if ('error' in validationResult) {
|
|
152
|
+
const err = new ToolValidationError(toolName, validationResult.error.issues);
|
|
153
|
+
return {
|
|
154
|
+
success: false,
|
|
155
|
+
error: err,
|
|
156
|
+
output: err.message,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const policyCheckInfo: ToolPolicyCheckInfo = {
|
|
161
|
+
toolCallId: toolCall.id,
|
|
162
|
+
toolName,
|
|
163
|
+
arguments: toolCall.function.arguments,
|
|
164
|
+
parsedArguments: validationResult.data as Record<string, unknown>,
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
if (options?.onPolicyCheck) {
|
|
168
|
+
const policyDecision = await options.onPolicyCheck(policyCheckInfo);
|
|
169
|
+
if (!policyDecision.allowed) {
|
|
170
|
+
return this.buildPolicyDeniedResult(toolName, toolCall.id, policyDecision, 'callback');
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const builtInDecision = this.evaluateBuiltInPolicy(policyCheckInfo);
|
|
175
|
+
if (!builtInDecision.allowed) {
|
|
176
|
+
return this.buildPolicyDeniedResult(toolName, toolCall.id, builtInDecision, 'builtin');
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const confirmDetails = handler.getConfirmDetails(validationResult.data);
|
|
180
|
+
const needsConfirm = handler.shouldConfirm(validationResult.data) || Boolean(confirmDetails);
|
|
181
|
+
let executionContext = options;
|
|
182
|
+
|
|
183
|
+
if (needsConfirm && this.confirmationMode === 'auto-deny') {
|
|
184
|
+
const err = new ToolDeniedError(
|
|
185
|
+
toolName,
|
|
186
|
+
`Denied by ${TOOL_CONFIRMATION_MODE_ENV}=auto-deny`
|
|
187
|
+
);
|
|
188
|
+
return {
|
|
189
|
+
success: false,
|
|
190
|
+
error: err,
|
|
191
|
+
output: err.message,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (needsConfirm && this.confirmationMode === 'auto-approve') {
|
|
196
|
+
executionContext = {
|
|
197
|
+
...options,
|
|
198
|
+
confirmationApproved: true,
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (needsConfirm && this.confirmationMode === 'manual' && options?.onConfirm) {
|
|
203
|
+
const confirmInfo: ToolConfirmInfo = {
|
|
204
|
+
toolCallId: toolCall.id,
|
|
205
|
+
toolName,
|
|
206
|
+
arguments: toolCall.function.arguments,
|
|
207
|
+
...this.normalizeConfirmDetails(confirmDetails),
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
const decision = await options.onConfirm(confirmInfo);
|
|
211
|
+
|
|
212
|
+
if (!decision.approved) {
|
|
213
|
+
const err = new ToolDeniedError(toolName, decision.message);
|
|
214
|
+
return {
|
|
215
|
+
success: false,
|
|
216
|
+
error: err,
|
|
217
|
+
output: err.message,
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
executionContext = {
|
|
222
|
+
...options,
|
|
223
|
+
confirmationApproved: true,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
try {
|
|
228
|
+
const result = await handler.execute(validationResult.data, executionContext);
|
|
229
|
+
return result;
|
|
230
|
+
} catch (error) {
|
|
231
|
+
const err = new ToolExecutionError((error as Error).message);
|
|
232
|
+
options?.onChunk?.({ type: 'stderr', data: err.message });
|
|
233
|
+
return {
|
|
234
|
+
success: false,
|
|
235
|
+
error: err,
|
|
236
|
+
output: err.message,
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
registerTool(tool: BaseTool): void {
|
|
242
|
+
this.tools.set(tool.name, tool);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
toToolsSchema(): LLMTool[] {
|
|
246
|
+
return this.getTools().map((tool) => tool.toToolSchema());
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
getTools(): BaseTool[] {
|
|
250
|
+
return Array.from(this.tools.values());
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
getConcurrencyPolicy(toolCall: ToolCall): ToolConcurrencyPolicy {
|
|
254
|
+
const toolName = toolCall.function.name;
|
|
255
|
+
const handler = this.tools.get(toolName);
|
|
256
|
+
if (!handler) {
|
|
257
|
+
return { mode: 'exclusive' };
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
let rawArgs: Record<string, unknown> = {};
|
|
261
|
+
try {
|
|
262
|
+
rawArgs = JSON.parse(toolCall.function.arguments);
|
|
263
|
+
} catch {
|
|
264
|
+
return { mode: 'exclusive' };
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const validated = handler.safeValidateArgs(rawArgs);
|
|
268
|
+
if (!validated.success) {
|
|
269
|
+
return { mode: 'exclusive' };
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
const mode = handler.getConcurrencyMode(validated.data);
|
|
273
|
+
const lockKey = handler.getConcurrencyLockKey(validated.data);
|
|
274
|
+
return lockKey ? { mode, lockKey } : { mode };
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
private buildPolicyDeniedResult(
|
|
278
|
+
toolName: string,
|
|
279
|
+
toolCallId: string,
|
|
280
|
+
decision: ToolPolicyDecision,
|
|
281
|
+
source: 'callback' | 'builtin'
|
|
282
|
+
): ToolResult {
|
|
283
|
+
const audit = {
|
|
284
|
+
toolCallId,
|
|
285
|
+
toolName,
|
|
286
|
+
source,
|
|
287
|
+
timestamp: Date.now(),
|
|
288
|
+
...(decision.audit || {}),
|
|
289
|
+
};
|
|
290
|
+
const err = new ToolPolicyDeniedError(
|
|
291
|
+
toolName,
|
|
292
|
+
decision.code || 'POLICY_DENIED',
|
|
293
|
+
decision.message,
|
|
294
|
+
audit
|
|
295
|
+
);
|
|
296
|
+
return {
|
|
297
|
+
success: false,
|
|
298
|
+
error: err,
|
|
299
|
+
output: err.message,
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
private normalizeConfirmDetails(details: ToolConfirmDetails | null): Partial<ToolConfirmInfo> {
|
|
304
|
+
if (!details) {
|
|
305
|
+
return {};
|
|
306
|
+
}
|
|
307
|
+
return {
|
|
308
|
+
...(details.reason ? { reason: details.reason } : {}),
|
|
309
|
+
...(details.metadata ? { metadata: details.metadata } : {}),
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
private evaluateBuiltInPolicy(info: ToolPolicyCheckInfo): ToolPolicyDecision {
|
|
314
|
+
if (!this.enableBuiltInPolicy) {
|
|
315
|
+
return { allowed: true };
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
if (info.toolName === 'bash') {
|
|
319
|
+
const command = info.parsedArguments.command;
|
|
320
|
+
if (typeof command === 'string') {
|
|
321
|
+
for (const rule of this.dangerousBashRules) {
|
|
322
|
+
if (rule.pattern.test(command)) {
|
|
323
|
+
return {
|
|
324
|
+
allowed: false,
|
|
325
|
+
code: 'DANGEROUS_COMMAND',
|
|
326
|
+
message: rule.message,
|
|
327
|
+
audit: {
|
|
328
|
+
ruleId: rule.id,
|
|
329
|
+
matchedValue: command.slice(0, 200),
|
|
330
|
+
},
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
if (info.toolName === 'write_file') {
|
|
338
|
+
const targetPath = info.parsedArguments.path;
|
|
339
|
+
if (typeof targetPath === 'string') {
|
|
340
|
+
const resolvedPath = path.resolve(targetPath);
|
|
341
|
+
for (const restrictedPrefix of this.restrictedWritePathPrefixes) {
|
|
342
|
+
if (
|
|
343
|
+
resolvedPath === restrictedPrefix ||
|
|
344
|
+
resolvedPath.startsWith(`${restrictedPrefix}${path.sep}`)
|
|
345
|
+
) {
|
|
346
|
+
return {
|
|
347
|
+
allowed: false,
|
|
348
|
+
code: 'PATH_NOT_ALLOWED',
|
|
349
|
+
message: `Path targets restricted location: ${targetPath}`,
|
|
350
|
+
audit: {
|
|
351
|
+
ruleId: 'restricted_write_path',
|
|
352
|
+
matchedValue: resolvedPath,
|
|
353
|
+
},
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
return { allowed: true };
|
|
361
|
+
}
|
|
362
|
+
}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
export const BASH_TOOL_DESCRIPTION = `Executes a given shell command with optional timeout.
|
|
2
|
+
|
|
3
|
+
IMPORTANT: This tool is for terminal operations like git, npm, docker, and test commands.
|
|
4
|
+
DO NOT use it for file operations (reading, writing, editing, searching, finding files) when
|
|
5
|
+
dedicated tools are available. Use file_read, file_edit, write_file, glob, and grep instead.
|
|
6
|
+
|
|
7
|
+
Usage notes:
|
|
8
|
+
- command is required.
|
|
9
|
+
- timeout is optional, max 600000ms. If omitted, default timeout is 60000ms.
|
|
10
|
+
- run_in_background can be used for long-running commands when immediate output is not required.
|
|
11
|
+
- Do not append "&" manually when run_in_background=true.
|
|
12
|
+
- Quote file paths that contain spaces.
|
|
13
|
+
- Prefer absolute paths and avoid unnecessary "cd" usage.
|
|
14
|
+
|
|
15
|
+
When issuing multiple commands:
|
|
16
|
+
- If independent, run multiple bash calls in parallel.
|
|
17
|
+
- If dependent, chain with "&&" (or ";" when later commands should still run on failure).
|
|
18
|
+
- Do not separate commands with raw newlines.`;
|
|
19
|
+
|
|
20
|
+
export const GLOB_TOOL_DESCRIPTION = `- Fast file pattern matching tool that works with any codebase size
|
|
21
|
+
- Supports glob patterns like "**/*.js" or "src/**/*.ts"
|
|
22
|
+
- Returns matching file paths for downstream tools
|
|
23
|
+
- Use this tool when you need to find files by name patterns
|
|
24
|
+
- For open-ended multi-round exploration, prefer the Task tool with an exploration subagent
|
|
25
|
+
- It is often better to run multiple glob searches in parallel when useful`;
|
|
26
|
+
|
|
27
|
+
export const GREP_TOOL_DESCRIPTION = `A powerful search tool built on ripgrep.
|
|
28
|
+
|
|
29
|
+
Usage:
|
|
30
|
+
- ALWAYS use this tool for content search tasks. Do not run "grep" or "rg" via bash for normal searches.
|
|
31
|
+
- Supports full regex syntax (for example "log.*Error" or "function\\s+\\w+").
|
|
32
|
+
- Use the glob parameter to constrain files (for example "**/*.ts" or "src/**/*.tsx").
|
|
33
|
+
- Use Task for broad open-ended search workflows that need many iterative rounds.
|
|
34
|
+
- Ripgrep regex semantics apply. Escape literals when needed.`;
|
|
35
|
+
|
|
36
|
+
export const FILE_READ_TOOL_DESCRIPTION = `Reads a file from the local filesystem. You can access any file directly by using this tool.
|
|
37
|
+
Assume this tool is able to read all files on the machine. If the User provides a path to a file assume that path is valid. It is okay to read a file that does not exist; an error will be returned.
|
|
38
|
+
|
|
39
|
+
Usage:
|
|
40
|
+
- The filePath parameter must be an absolute path, not a relative path
|
|
41
|
+
- By default, it reads up to 1000 lines starting from the beginning of the file
|
|
42
|
+
- You can optionally specify a startLine (0-based) and limit (number of lines to read) for line-based slicing
|
|
43
|
+
- startLine: The line number to start reading from (0-based, defaults to 0)
|
|
44
|
+
- limit: The number of lines to read (defaults to 1000)
|
|
45
|
+
- Any lines longer than 2000 characters will be truncated
|
|
46
|
+
- Results are returned using cat -n format, with line numbers starting at 1
|
|
47
|
+
- You have the capability to call multiple tools in a single response. It is always better to speculatively read multiple files as a batch that are potentially useful.
|
|
48
|
+
- If you read a file that exists but has empty contents you will receive a system reminder warning in place of file contents.
|
|
49
|
+
- You can read image files using this tool.
|
|
50
|
+
`;
|
|
51
|
+
|
|
52
|
+
export const FILE_EDIT_TOOL_DESCRIPTION = `Apply one or more old/new text replacements to a single file and return a unified diff.
|
|
53
|
+
|
|
54
|
+
Recommended workflow:
|
|
55
|
+
1. Read latest content with file_read.
|
|
56
|
+
2. Build all intended replacements in one file_edit call.
|
|
57
|
+
3. Use dry_run=true to preview before writing when risk is high.
|
|
58
|
+
|
|
59
|
+
Notes:
|
|
60
|
+
- Edits are applied in order.
|
|
61
|
+
- If oldText is not found, the tool returns EDIT_CONFLICT so you can re-read and retry.
|
|
62
|
+
- This is preferred over write_file for precise incremental edits to existing files.`;
|
|
63
|
+
|
|
64
|
+
export const FILE_HISTORY_LIST_TOOL_DESCRIPTION = `Lists saved historical versions for a file.
|
|
65
|
+
|
|
66
|
+
Use this when:
|
|
67
|
+
- You want to see whether a previous version is available before restoring.
|
|
68
|
+
- You need a versionId for a later file_history_restore call.
|
|
69
|
+
|
|
70
|
+
Notes:
|
|
71
|
+
- Results are ordered newest-first.
|
|
72
|
+
- Each entry includes versionId, createdAt, size, and source.`;
|
|
73
|
+
|
|
74
|
+
export const FILE_HISTORY_RESTORE_TOOL_DESCRIPTION = `Restores a file from previously saved history.
|
|
75
|
+
|
|
76
|
+
Use this when:
|
|
77
|
+
- You need to roll back a file to a prior saved version.
|
|
78
|
+
- The user asks to restore the previous or a specific old version.
|
|
79
|
+
|
|
80
|
+
Usage notes:
|
|
81
|
+
- Provide path and, optionally, versionId.
|
|
82
|
+
- If versionId is omitted, the latest saved version is restored.
|
|
83
|
+
- Restoring also preserves the current file content as a new history snapshot before overwrite.`;
|
|
84
|
+
|
|
85
|
+
export const WRITE_FILE_TOOL_DESCRIPTION = `Writes file content to the local filesystem.
|
|
86
|
+
|
|
87
|
+
Behavior:
|
|
88
|
+
- direct mode writes content immediately.
|
|
89
|
+
- direct mode buffers the full payload when it exceeds the chunk limit and returns a bufferId.
|
|
90
|
+
- finalize mode commits buffered content to the target file and can resolve the target path from bufferId.
|
|
91
|
+
|
|
92
|
+
Usage notes:
|
|
93
|
+
- Prefer editing existing files with file_edit when possible.
|
|
94
|
+
- Use write_file when replacing full content or when buffered large writes are required.
|
|
95
|
+
- Provide plain text content directly, not Markdown code fences.
|
|
96
|
+
- Avoid creating new documentation files unless the user explicitly asks.`;
|
|
97
|
+
|
|
98
|
+
export const TASK_TOOL_DESCRIPTION = `Launch a new agent to handle complex, multi-step tasks autonomously.
|
|
99
|
+
|
|
100
|
+
The Agent tool launches specialized subagents that autonomously handle complex work. Each subagent type has a specific role and an explicit tool allowlist.
|
|
101
|
+
|
|
102
|
+
Available subagent types and their default tools:
|
|
103
|
+
- Bash: terminal and command execution specialist. Use for focused shell work. (Tools: bash)
|
|
104
|
+
- general-purpose: broad multi-step research and implementation agent. Use when the task may require several rounds of searching, reading, editing, and verification. (Tools: bash, glob, grep, file_read, file_edit, write_file, skill)
|
|
105
|
+
- Explore: fast codebase exploration and discovery agent. Use for open-ended codebase exploration, pattern-based file discovery, and multi-round keyword searches. (Tools: glob, grep, file_read, skill)
|
|
106
|
+
- Restore: focused rollback agent for restoring a file from saved history when the parent agent already knows the target path. (Tools: glob, file_read, file_history_list, file_history_restore)
|
|
107
|
+
- Plan: implementation planning and architecture strategy agent. Use when you need a concrete implementation plan, critical file list, risks, and trade-offs before editing code. (Tools: glob, grep, file_read, skill)
|
|
108
|
+
- research-agent: long-form research and synthesis agent. Use when you need evidence collection and structured findings from local project context. (Tools: glob, grep, file_read, skill)
|
|
109
|
+
- find-skills: local skill lookup + installation guidance agent. Use to discover the right skill, prefer local skills first, and fall back to verified installation steps when needed. (Tools: skill, bash)
|
|
110
|
+
|
|
111
|
+
When to use the Agent tool:
|
|
112
|
+
- Complex, multi-step work that benefits from delegation.
|
|
113
|
+
- Open-ended exploration or research that will likely take multiple searches.
|
|
114
|
+
- Parallel, independent branches of investigation.
|
|
115
|
+
- Broad codebase search when you are not confident a direct glob/grep query will find the right match in the first few tries.
|
|
116
|
+
|
|
117
|
+
When NOT to use the Agent tool:
|
|
118
|
+
- If you already know the file path, use file_read.
|
|
119
|
+
- If you need a direct filename/pattern match, use glob.
|
|
120
|
+
- If you need exact content search, use grep.
|
|
121
|
+
- If you only need to inspect one file or a small known set of files, use direct tools instead.
|
|
122
|
+
|
|
123
|
+
Usage notes:
|
|
124
|
+
- Always include a short description (3-5 words) summarizing the subagent run.
|
|
125
|
+
- Always set subagent_type explicitly to the agent you want.
|
|
126
|
+
- Use foreground execution when you need the result before continuing.
|
|
127
|
+
- Use run_in_background=true only when the work is genuinely independent.
|
|
128
|
+
- For background runs, use task_output to retrieve status/output later and task_stop to cancel when needed.
|
|
129
|
+
- Launch multiple task calls in parallel when the work is independent.
|
|
130
|
+
- The subagent result is returned to you through the tool response; summarize relevant findings to the user.
|
|
131
|
+
- Provide a clear prompt that states whether the subagent should research only or also make code changes.
|
|
132
|
+
- For direct needle queries, prefer direct tools first (glob/grep/file_read/file_edit).`;
|
|
133
|
+
|
|
134
|
+
export const TASK_CREATE_DESCRIPTION = `Use this tool to create a structured task list entry for the current coding session.
|
|
135
|
+
|
|
136
|
+
When to use:
|
|
137
|
+
- Multi-step implementation work.
|
|
138
|
+
- Non-trivial tasks that benefit from explicit tracking.
|
|
139
|
+
- User requests a todo/task list.
|
|
140
|
+
- You need clearer progress visibility for the user.
|
|
141
|
+
|
|
142
|
+
Task fields:
|
|
143
|
+
- subject: imperative short title.
|
|
144
|
+
- description: detailed task context and acceptance criteria.
|
|
145
|
+
- active_form: present-continuous text shown while in progress.`;
|
|
146
|
+
|
|
147
|
+
export const TASK_GET_DESCRIPTION = `Retrieve a task by ID from the task list.
|
|
148
|
+
|
|
149
|
+
Use this to:
|
|
150
|
+
- Read full task requirements before execution.
|
|
151
|
+
- Inspect dependency and blocker information.
|
|
152
|
+
- Decide whether a task can start now.`;
|
|
153
|
+
|
|
154
|
+
export const TASK_LIST_DESCRIPTION = `List tasks in the namespace with summary state.
|
|
155
|
+
|
|
156
|
+
Use this to:
|
|
157
|
+
- Find available work items.
|
|
158
|
+
- Review overall progress and blocked tasks.
|
|
159
|
+
- Pick the next task after finishing current work.
|
|
160
|
+
|
|
161
|
+
Tip:
|
|
162
|
+
- Prefer lower-ID tasks first when multiple tasks are available.`;
|
|
163
|
+
|
|
164
|
+
export const TASK_UPDATE_DESCRIPTION = `Update a task in the task list.
|
|
165
|
+
|
|
166
|
+
Use this to:
|
|
167
|
+
- Move task status through workflow.
|
|
168
|
+
- Update subject/description/owner/progress/metadata.
|
|
169
|
+
- Add or remove dependency edges.
|
|
170
|
+
- Mark tasks completed, failed, cancelled, or back to pending when appropriate.
|
|
171
|
+
|
|
172
|
+
Best practice:
|
|
173
|
+
- Read the latest task state before updating to avoid stale writes.`;
|
|
174
|
+
|
|
175
|
+
export const TASK_STOP_DESCRIPTION = `Stops a running subagent execution by agent_id or linked task_id.
|
|
176
|
+
|
|
177
|
+
Usage:
|
|
178
|
+
- Provide agent_id directly when available.
|
|
179
|
+
- Or provide task_id to resolve the linked agent run.
|
|
180
|
+
- Optionally cancel linked planning tasks in the same call.`;
|
|
181
|
+
|
|
182
|
+
export const TASK_OUTPUT_DESCRIPTION = `Retrieves output from a running or completed task (background shell, agent, or remote session) - Takes a task_id parameter identifying the task - Returns the task output along with status information - Use block=true (default) to wait for task completion - Use block=false for non-blocking check of current status - Task IDs can be found using the /tasks command - Works with all task types: background shells, async agents, and remote sessions`;
|
|
183
|
+
|
|
184
|
+
export const SKILL_TOOL_BASE_DESCRIPTION = `Load a skill to get detailed task-specific instructions.
|
|
185
|
+
Skills contain specialized workflows and reusable operational context.`;
|
|
186
|
+
|
|
187
|
+
export const SKILL_FIND_TOOL_DESCRIPTION = `Automatically find the most relevant skill for a user request.
|
|
188
|
+
|
|
189
|
+
Usage:
|
|
190
|
+
- Provide query with the task intent or requirement.
|
|
191
|
+
- top_k controls how many ranked candidates are returned (default 5).
|
|
192
|
+
- min_score filters weak matches (default 0.1).
|
|
193
|
+
- auto_load=true returns full matched skill content in the same call.
|
|
194
|
+
|
|
195
|
+
When to use:
|
|
196
|
+
- User asks "which skill should I use?".
|
|
197
|
+
- Skill name is unknown but task intent is clear.
|
|
198
|
+
- You need ranked skill suggestions before loading one manually.`;
|
|
199
|
+
|
|
200
|
+
export const WEB_FETCH_TOOL_DESCRIPTION = `Fetches content from a URL with SSRF protection.
|
|
201
|
+
|
|
202
|
+
Features:
|
|
203
|
+
- Extract modes: text (plain text), markdown (simplified), html (raw)
|
|
204
|
+
- SSRF protection blocks localhost, private IPs, and cloud metadata endpoints
|
|
205
|
+
- Response size limit: 5MB
|
|
206
|
+
- Configurable timeout (default 30s, max 120s)
|
|
207
|
+
|
|
208
|
+
Usage notes:
|
|
209
|
+
- url is required and must be a valid HTTP/HTTPS URL
|
|
210
|
+
- extractMode defaults to 'text' for clean plain text extraction
|
|
211
|
+
- maxChars limits output length (default 30000, max 100000)
|
|
212
|
+
- Internal/private network addresses are blocked for security`;
|
|
213
|
+
|
|
214
|
+
export const WEB_SEARCH_TOOL_DESCRIPTION = `Performs a web search using Tavily or Brave Search API.
|
|
215
|
+
|
|
216
|
+
Requires one of these environment variables:
|
|
217
|
+
- TAVILY_API_KEY for Tavily search
|
|
218
|
+
- BRAVE_SEARCH_API_KEY for Brave Search
|
|
219
|
+
|
|
220
|
+
Usage notes:
|
|
221
|
+
- query is required (1-500 characters)
|
|
222
|
+
- maxResults controls result count (1-10, default 5)
|
|
223
|
+
- provider can be 'tavily', 'brave', or 'auto' (default)
|
|
224
|
+
- 'auto' uses the first available API key
|
|
225
|
+
|
|
226
|
+
Results include title, URL, snippet, and relevance score.`;
|
|
227
|
+
|
|
228
|
+
export const LSP_TOOL_DESCRIPTION = `TypeScript Language Service operations for code intelligence.
|
|
229
|
+
|
|
230
|
+
Supported operations:
|
|
231
|
+
- goToDefinition: Jump to symbol definition
|
|
232
|
+
- findReferences: Find all references to a symbol
|
|
233
|
+
- hover: Get type information and documentation
|
|
234
|
+
- documentSymbols: List all symbols in a file
|
|
235
|
+
|
|
236
|
+
Usage notes:
|
|
237
|
+
- filePath is required (absolute or relative path)
|
|
238
|
+
- line and character are 1-based (editor-style)
|
|
239
|
+
- line and character are required for goToDefinition, findReferences, and hover
|
|
240
|
+
- Supports .ts, .tsx, .js, .jsx, .mjs, .cjs files
|
|
241
|
+
- Uses TypeScript Compiler API for accurate results
|
|
242
|
+
- Respects tsconfig.json when present`;
|