qlogicagent 0.5.2 → 0.6.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.
- package/README.md +403 -402
- package/dist/agent.js +18 -0
- package/dist/cli.js +384 -0
- package/dist/contracts.js +1 -0
- package/dist/index.js +383 -0
- package/dist/orchestration.js +34 -0
- package/dist/types/agent/agent.d.ts +43 -0
- package/dist/types/agent/constants.d.ts +47 -0
- package/dist/types/agent/tool-access.d.ts +30 -0
- package/dist/types/agent/tool-loop.d.ts +94 -0
- package/dist/types/agent/types.d.ts +238 -0
- package/dist/types/cli/main.d.ts +11 -0
- package/dist/types/cli/stdio-server.d.ts +78 -0
- package/dist/types/cli/tool-bootstrap.d.ts +40 -0
- package/dist/types/cli/transport.d.ts +40 -0
- package/dist/types/config/config.d.ts +17 -0
- package/dist/types/contracts/hooks.d.ts +175 -0
- package/dist/types/contracts/index.d.ts +9 -0
- package/dist/types/contracts/planner.d.ts +35 -0
- package/dist/types/contracts/todo.d.ts +23 -0
- package/dist/types/index.d.ts +16 -0
- package/dist/types/llm/builtin-providers.d.ts +10 -0
- package/dist/types/llm/debug-transport.d.ts +12 -0
- package/dist/types/llm/index.d.ts +16 -0
- package/dist/types/llm/llm-client.d.ts +43 -0
- package/dist/types/llm/model-catalog.d.ts +53 -0
- package/dist/types/llm/provider-def.d.ts +59 -0
- package/dist/types/llm/provider-registry.d.ts +54 -0
- package/dist/types/llm/transport.d.ts +62 -0
- package/dist/types/llm/transports/anthropic-messages.d.ts +31 -0
- package/dist/types/llm/transports/openai-chat.d.ts +36 -0
- package/dist/types/orchestration/context/context-collapse.d.ts +58 -0
- package/dist/types/orchestration/context/context-compression.d.ts +301 -0
- package/dist/types/orchestration/context/reactive-compact.d.ts +73 -0
- package/dist/types/orchestration/context/turn-loop-guard.d.ts +86 -0
- package/dist/types/orchestration/error-handling/error-classification.d.ts +12 -0
- package/dist/types/orchestration/error-handling/failover-classification.d.ts +8 -0
- package/dist/types/orchestration/error-handling/failover-error.d.ts +33 -0
- package/dist/types/orchestration/error-handling/retry-loop.d.ts +69 -0
- package/dist/types/orchestration/index.d.ts +15 -0
- package/dist/types/orchestration/skill-improvement.d.ts +59 -0
- package/dist/types/orchestration/subagent/agent-registry.d.ts +46 -0
- package/dist/types/orchestration/subagent/fork-subagent.d.ts +98 -0
- package/dist/types/orchestration/subagent/task-types.d.ts +142 -0
- package/dist/types/orchestration/tool-loop/conversation-repair.d.ts +61 -0
- package/dist/types/orchestration/tool-loop/tool-choice-policy.d.ts +54 -0
- package/dist/types/orchestration/tool-loop/tool-loop-state.d.ts +50 -0
- package/dist/types/orchestration/tool-loop/tool-schema.d.ts +39 -0
- package/dist/types/runtime/execution/dream-agent.d.ts +199 -0
- package/dist/types/runtime/execution/forked-agent.d.ts +109 -0
- package/dist/types/runtime/execution/index.d.ts +6 -0
- package/dist/types/runtime/execution/progress-tracker.d.ts +78 -0
- package/dist/types/runtime/execution/remote-agent.d.ts +63 -0
- package/dist/types/runtime/execution/streaming-tool-executor.d.ts +100 -0
- package/dist/types/runtime/execution/tool-eligibility.d.ts +59 -0
- package/dist/types/runtime/execution/tool-result-storage.d.ts +87 -0
- package/dist/types/runtime/hooks/context-compression.d.ts +61 -0
- package/dist/types/runtime/hooks/hook-registry.d.ts +12 -0
- package/dist/types/runtime/hooks/index.d.ts +3 -0
- package/dist/types/runtime/hooks/memory-hooks.d.ts +49 -0
- package/dist/types/runtime/index.d.ts +5 -0
- package/dist/types/runtime/infra/agent-paths.d.ts +57 -0
- package/dist/types/runtime/infra/checkpoint-backend.d.ts +8 -0
- package/dist/types/runtime/infra/cleanup-registry.d.ts +23 -0
- package/dist/types/runtime/infra/disk-storage.d.ts +36 -0
- package/dist/types/runtime/infra/file-watcher.d.ts +72 -0
- package/dist/types/runtime/infra/index.d.ts +8 -0
- package/dist/types/runtime/infra/secure-storage.d.ts +81 -0
- package/dist/types/runtime/infra/task-runtime.d.ts +108 -0
- package/dist/types/runtime/infra/token-budget.d.ts +92 -0
- package/dist/types/runtime/infra/worktree-backend.d.ts +85 -0
- package/dist/types/runtime/prompt/environment-context.d.ts +23 -0
- package/dist/types/runtime/prompt/index.d.ts +3 -0
- package/dist/types/runtime/prompt/instruction-loader.d.ts +64 -0
- package/dist/types/runtime/prompt/system-prompt-sections.d.ts +63 -0
- package/dist/types/runtime/session/index.d.ts +2 -0
- package/dist/types/runtime/session/session-memory.d.ts +90 -0
- package/dist/types/runtime/session/session-persistence.d.ts +94 -0
- package/dist/types/runtime/session/session-state.d.ts +117 -0
- package/dist/types/skills/index.d.ts +119 -0
- package/dist/types/skills/mcp/index.d.ts +3 -0
- package/dist/types/skills/mcp/mcp-http-client.d.ts +66 -0
- package/dist/types/skills/mcp/mcp-manager.d.ts +83 -0
- package/dist/types/skills/mcp/mcp-stdio-client.d.ts +84 -0
- package/dist/types/skills/memory/memory-extractor.d.ts +64 -0
- package/dist/types/skills/memory/memory-store.d.ts +86 -0
- package/dist/types/skills/memory/memory-tool.d.ts +87 -0
- package/dist/types/skills/memory/qmemory-adapter.d.ts +42 -0
- package/dist/types/skills/permissions/bash-classifier.d.ts +30 -0
- package/dist/types/skills/permissions/classifier-cache.d.ts +51 -0
- package/dist/types/skills/permissions/denial-tracking.d.ts +42 -0
- package/dist/types/skills/permissions/hook-runner.d.ts +85 -0
- package/dist/types/skills/permissions/index.d.ts +12 -0
- package/dist/types/skills/permissions/permission-classifier.d.ts +41 -0
- package/dist/types/skills/permissions/rule-engine.d.ts +41 -0
- package/dist/types/skills/permissions/settings-watcher.d.ts +46 -0
- package/dist/types/skills/permissions/types.d.ts +113 -0
- package/dist/types/skills/plugins/index.d.ts +2 -0
- package/dist/types/skills/plugins/plugin-api.d.ts +38 -0
- package/dist/types/skills/plugins/plugin-loader.d.ts +42 -0
- package/dist/types/skills/plugins/plugin-marketplace.d.ts +61 -0
- package/dist/types/skills/portable-tool.d.ts +104 -0
- package/dist/types/skills/skill-system/skill-frontmatter.d.ts +19 -0
- package/dist/types/skills/skill-system/skill-guard.d.ts +23 -0
- package/dist/types/skills/skill-system/skill-loader.d.ts +16 -0
- package/dist/types/skills/skill-system/skill-source.d.ts +119 -0
- package/dist/types/skills/skill-system/skill-types.d.ts +199 -0
- package/dist/types/skills/think-tool.d.ts +16 -0
- package/dist/types/skills/todo-tool.d.ts +72 -0
- package/dist/types/skills/tools/agent-tool.d.ts +91 -0
- package/dist/types/skills/tools/apply-patch-tool.d.ts +29 -0
- package/dist/types/skills/tools/ask-user-tool.d.ts +80 -0
- package/dist/types/skills/tools/brief-tool.d.ts +74 -0
- package/dist/types/skills/tools/browser-tool.d.ts +114 -0
- package/dist/types/skills/tools/checkpoint-tool.d.ts +66 -0
- package/dist/types/skills/tools/config-tool.d.ts +63 -0
- package/dist/types/skills/tools/cron-tool.d.ts +116 -0
- package/dist/types/skills/tools/edit-tool.d.ts +43 -0
- package/dist/types/skills/tools/exec-tool.d.ts +97 -0
- package/dist/types/skills/tools/image-generate-tool.d.ts +62 -0
- package/dist/types/skills/tools/instructions-tool.d.ts +65 -0
- package/dist/types/skills/tools/lsp-tool.d.ts +153 -0
- package/dist/types/skills/tools/mcp-client-types.d.ts +269 -0
- package/dist/types/skills/tools/mcp-resource-tools.d.ts +14 -0
- package/dist/types/skills/tools/mcp-tool.d.ts +249 -0
- package/dist/types/skills/tools/monitor-tool.d.ts +113 -0
- package/dist/types/skills/tools/music-generate-tool.d.ts +55 -0
- package/dist/types/skills/tools/notebook-edit-tool.d.ts +15 -0
- package/dist/types/skills/tools/notify-tool.d.ts +53 -0
- package/dist/types/skills/tools/patch-tool.d.ts +45 -0
- package/dist/types/skills/tools/plan-mode-tool.d.ts +98 -0
- package/dist/types/skills/tools/read-tool.d.ts +51 -0
- package/dist/types/skills/tools/repl-tool.d.ts +70 -0
- package/dist/types/skills/tools/search-tool.d.ts +112 -0
- package/dist/types/skills/tools/send-message-tool.d.ts +51 -0
- package/dist/types/skills/tools/shell/bash-provider.d.ts +26 -0
- package/dist/types/skills/tools/shell/command-classification.d.ts +44 -0
- package/dist/types/skills/tools/shell/command-semantics.d.ts +14 -0
- package/dist/types/skills/tools/shell/destructive-command-warning.d.ts +10 -0
- package/dist/types/skills/tools/shell/exec-permissions.d.ts +52 -0
- package/dist/types/skills/tools/shell/index.d.ts +17 -0
- package/dist/types/skills/tools/shell/powershell-provider.d.ts +15 -0
- package/dist/types/skills/tools/shell/shell-command.d.ts +54 -0
- package/dist/types/skills/tools/shell/shell-exec.d.ts +33 -0
- package/dist/types/skills/tools/shell/shell-provider.d.ts +85 -0
- package/dist/types/skills/tools/shell/task-output.d.ts +45 -0
- package/dist/types/skills/tools/skill-invoke-tool.d.ts +46 -0
- package/dist/types/skills/tools/skill-list-tool.d.ts +33 -0
- package/dist/types/skills/tools/skill-manage-tool.d.ts +73 -0
- package/dist/types/skills/tools/skill-view-tool.d.ts +37 -0
- package/dist/types/skills/tools/sleep-tool.d.ts +49 -0
- package/dist/types/skills/tools/structured-output-tool.d.ts +116 -0
- package/dist/types/skills/tools/task-tool.d.ts +104 -0
- package/dist/types/skills/tools/team-tool.d.ts +89 -0
- package/dist/types/skills/tools/tool-search-tool.d.ts +51 -0
- package/dist/types/skills/tools/tts-tool.d.ts +38 -0
- package/dist/types/skills/tools/video-edit-tool.d.ts +69 -0
- package/dist/types/skills/tools/video-generate-tool.d.ts +62 -0
- package/dist/types/skills/tools/video-merge-tool.d.ts +105 -0
- package/dist/types/skills/tools/video-upscale-tool.d.ts +45 -0
- package/dist/types/skills/tools/web-fetch-tool.d.ts +78 -0
- package/dist/types/skills/tools/web-search-tool.d.ts +57 -0
- package/dist/types/skills/tools/workflow-tool.d.ts +44 -0
- package/dist/types/skills/tools/worktree-tool.d.ts +69 -0
- package/dist/types/skills/tools/write-tool.d.ts +45 -0
- package/dist/types/skills/tools.d.ts +65 -0
- package/package.json +4 -3
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { PortableTool } from "../portable-tool.js";
|
|
2
|
+
export declare const MUSIC_GENERATE_TOOL_NAME: "music_generate";
|
|
3
|
+
export interface MusicGenerateToolParams {
|
|
4
|
+
prompt: string;
|
|
5
|
+
purpose?: string;
|
|
6
|
+
style?: string;
|
|
7
|
+
lyrics?: string;
|
|
8
|
+
duration?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare const MUSIC_GENERATE_TOOL_SCHEMA: {
|
|
11
|
+
readonly type: "object";
|
|
12
|
+
readonly properties: {
|
|
13
|
+
readonly prompt: {
|
|
14
|
+
readonly type: "string";
|
|
15
|
+
readonly description: string;
|
|
16
|
+
};
|
|
17
|
+
readonly purpose: {
|
|
18
|
+
readonly type: "string";
|
|
19
|
+
readonly description: "Intended use: 'background-music', 'ringtone', 'short-video-bgm', 'full-song', 'notification-sound', etc.";
|
|
20
|
+
};
|
|
21
|
+
readonly style: {
|
|
22
|
+
readonly type: "string";
|
|
23
|
+
readonly description: "Musical style/genre: 'lo-fi', 'pop', 'rock', 'jazz', 'classical', 'electronic', 'ambient', etc.";
|
|
24
|
+
};
|
|
25
|
+
readonly lyrics: {
|
|
26
|
+
readonly type: "string";
|
|
27
|
+
readonly description: "Optional lyrics for vocal music. Structure with [verse], [chorus], [bridge] tags if desired.";
|
|
28
|
+
};
|
|
29
|
+
readonly duration: {
|
|
30
|
+
readonly type: "number";
|
|
31
|
+
readonly description: "Duration in seconds (5-300). Infer from purpose: ringtone 15-30s, BGM 30-60s, full song 120-180s.";
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
readonly required: readonly ["prompt"];
|
|
35
|
+
};
|
|
36
|
+
export interface MusicGenerateResult {
|
|
37
|
+
mediaUrls: string[];
|
|
38
|
+
model?: string;
|
|
39
|
+
durationMs?: number;
|
|
40
|
+
}
|
|
41
|
+
/** Deps injected by the host runtime for music generation. */
|
|
42
|
+
export interface MusicGenerateToolDeps {
|
|
43
|
+
/**
|
|
44
|
+
* Generate music via the configured backend.
|
|
45
|
+
* The host handles model selection, failover, and storage.
|
|
46
|
+
*/
|
|
47
|
+
generateMusic(params: {
|
|
48
|
+
prompt: string;
|
|
49
|
+
purpose?: string;
|
|
50
|
+
style?: string;
|
|
51
|
+
lyrics?: string;
|
|
52
|
+
duration?: number;
|
|
53
|
+
}): Promise<MusicGenerateResult>;
|
|
54
|
+
}
|
|
55
|
+
export declare function createMusicGenerateTool(deps: MusicGenerateToolDeps): PortableTool<MusicGenerateToolParams>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PortableTool } from "../portable-tool.js";
|
|
2
|
+
export type NotebookEditMode = "replace" | "insert" | "delete";
|
|
3
|
+
export interface NotebookEditParams {
|
|
4
|
+
/** Absolute path to the .ipynb file */
|
|
5
|
+
notebook_path: string;
|
|
6
|
+
/** Cell number (1-based) to operate on */
|
|
7
|
+
cell_number: number;
|
|
8
|
+
/** New cell source content (required for replace/insert) */
|
|
9
|
+
new_source?: string;
|
|
10
|
+
/** Cell type for insert (default: "code") */
|
|
11
|
+
cell_type?: "code" | "markdown";
|
|
12
|
+
/** Edit mode (default: "replace") */
|
|
13
|
+
edit_mode?: NotebookEditMode;
|
|
14
|
+
}
|
|
15
|
+
export declare function createNotebookEditTool(): PortableTool<NotebookEditParams>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { PortableTool } from "../portable-tool.js";
|
|
2
|
+
export declare const NOTIFY_TOOL_NAME: "notify";
|
|
3
|
+
export interface NotifyToolParams {
|
|
4
|
+
/** Notification message */
|
|
5
|
+
message: string;
|
|
6
|
+
/** Optional title/subject */
|
|
7
|
+
title?: string;
|
|
8
|
+
/** Priority level */
|
|
9
|
+
priority?: "low" | "normal" | "high";
|
|
10
|
+
/** Target channel override (default: user's primary channel) */
|
|
11
|
+
channel?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const NOTIFY_TOOL_SCHEMA: {
|
|
14
|
+
readonly type: "object";
|
|
15
|
+
readonly properties: {
|
|
16
|
+
readonly message: {
|
|
17
|
+
readonly type: "string";
|
|
18
|
+
readonly description: "Notification content to send to the user.";
|
|
19
|
+
};
|
|
20
|
+
readonly title: {
|
|
21
|
+
readonly type: "string";
|
|
22
|
+
readonly description: "Optional notification title/subject line.";
|
|
23
|
+
};
|
|
24
|
+
readonly priority: {
|
|
25
|
+
readonly type: "string";
|
|
26
|
+
readonly enum: readonly ["low", "normal", "high"];
|
|
27
|
+
readonly description: "Notification priority (default: normal). High may trigger sound/vibration.";
|
|
28
|
+
};
|
|
29
|
+
readonly channel: {
|
|
30
|
+
readonly type: "string";
|
|
31
|
+
readonly description: "Target delivery channel (e.g. 'wechat', 'feishu', 'discord'). Default: user's primary.";
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
readonly required: readonly ["message"];
|
|
35
|
+
};
|
|
36
|
+
export interface NotifyResult {
|
|
37
|
+
delivered: boolean;
|
|
38
|
+
channel: string;
|
|
39
|
+
error?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Host-provided notification delivery backend.
|
|
43
|
+
*/
|
|
44
|
+
export interface NotifyToolDeps {
|
|
45
|
+
/** Send notification to user. Host routes to correct platform. */
|
|
46
|
+
sendNotification(params: {
|
|
47
|
+
message: string;
|
|
48
|
+
title?: string;
|
|
49
|
+
priority?: string;
|
|
50
|
+
channel?: string;
|
|
51
|
+
}): Promise<NotifyResult>;
|
|
52
|
+
}
|
|
53
|
+
export declare function createNotifyTool(deps: NotifyToolDeps): PortableTool<NotifyToolParams>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { PortableTool } from "../portable-tool.js";
|
|
2
|
+
export declare const PATCH_TOOL_NAME: "patch";
|
|
3
|
+
export interface PatchToolParams {
|
|
4
|
+
/** V4A unified diff or simple find-replace */
|
|
5
|
+
input: string;
|
|
6
|
+
/** When true, replace all occurrences in each file (default: false) */
|
|
7
|
+
replaceAll?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare const PATCH_TOOL_SCHEMA: {
|
|
10
|
+
readonly type: "object";
|
|
11
|
+
readonly properties: {
|
|
12
|
+
readonly input: {
|
|
13
|
+
readonly type: "string";
|
|
14
|
+
readonly description: string;
|
|
15
|
+
};
|
|
16
|
+
readonly replaceAll: {
|
|
17
|
+
readonly type: "boolean";
|
|
18
|
+
readonly description: "Replace all occurrences instead of first only (default: false).";
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
readonly required: readonly ["input"];
|
|
22
|
+
};
|
|
23
|
+
export interface PatchResult {
|
|
24
|
+
filesModified: string[];
|
|
25
|
+
filesAdded: string[];
|
|
26
|
+
filesDeleted: string[];
|
|
27
|
+
strategies: Record<string, string>;
|
|
28
|
+
errors: string[];
|
|
29
|
+
}
|
|
30
|
+
export interface PatchToolDeps {
|
|
31
|
+
readFile(path: string): Promise<string>;
|
|
32
|
+
writeFile(path: string, content: string): Promise<void>;
|
|
33
|
+
deleteFile(path: string): Promise<void>;
|
|
34
|
+
fileExists(path: string): Promise<boolean>;
|
|
35
|
+
resolvePath(input: string): string;
|
|
36
|
+
}
|
|
37
|
+
export type MatchStrategy = "exact" | "line_trimmed" | "whitespace_normalized" | "indentation_flexible" | "escape_normalized" | "trimmed_boundary" | "unicode_normalized" | "block_anchor" | "context_aware";
|
|
38
|
+
interface MatchResult {
|
|
39
|
+
start: number;
|
|
40
|
+
end: number;
|
|
41
|
+
strategy: MatchStrategy;
|
|
42
|
+
}
|
|
43
|
+
declare function fuzzyFind(content: string, search: string, replaceAll: boolean): MatchResult[];
|
|
44
|
+
export declare function createPatchTool(deps: PatchToolDeps): PortableTool<PatchToolParams>;
|
|
45
|
+
export { fuzzyFind, type MatchResult };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { PortableTool } from "../portable-tool.js";
|
|
2
|
+
export declare const PLAN_MODE_TOOL_NAME: "plan_mode";
|
|
3
|
+
export type PlanModeAction = "enter" | "exit";
|
|
4
|
+
export interface PlanModeToolParams {
|
|
5
|
+
/** Action: enter or exit plan mode */
|
|
6
|
+
action: PlanModeAction;
|
|
7
|
+
/** Plan text (for exit — the finalized plan to present for approval) */
|
|
8
|
+
plan?: string;
|
|
9
|
+
/** File path where plan was saved (optional) */
|
|
10
|
+
planFilePath?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Semantic permissions to request on exit (CC ExitPlanModeV2 parity).
|
|
13
|
+
* Each entry describes a tool + intent the agent wants permission for.
|
|
14
|
+
*/
|
|
15
|
+
allowedPrompts?: Array<{
|
|
16
|
+
tool: string;
|
|
17
|
+
prompt: string;
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
20
|
+
export declare const PLAN_MODE_TOOL_SCHEMA: {
|
|
21
|
+
readonly type: "object";
|
|
22
|
+
readonly properties: {
|
|
23
|
+
readonly action: {
|
|
24
|
+
readonly type: "string";
|
|
25
|
+
readonly enum: readonly ["enter", "exit"];
|
|
26
|
+
readonly description: string;
|
|
27
|
+
};
|
|
28
|
+
readonly plan: {
|
|
29
|
+
readonly type: "string";
|
|
30
|
+
readonly description: string;
|
|
31
|
+
};
|
|
32
|
+
readonly planFilePath: {
|
|
33
|
+
readonly type: "string";
|
|
34
|
+
readonly description: "Optional file path where the plan was saved for reference.";
|
|
35
|
+
};
|
|
36
|
+
readonly allowedPrompts: {
|
|
37
|
+
readonly type: "array";
|
|
38
|
+
readonly description: string;
|
|
39
|
+
readonly items: {
|
|
40
|
+
readonly type: "object";
|
|
41
|
+
readonly properties: {
|
|
42
|
+
readonly tool: {
|
|
43
|
+
readonly type: "string";
|
|
44
|
+
readonly description: "Tool name to pre-approve.";
|
|
45
|
+
};
|
|
46
|
+
readonly prompt: {
|
|
47
|
+
readonly type: "string";
|
|
48
|
+
readonly description: "Intent description for this permission.";
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
readonly required: readonly ["tool", "prompt"];
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
readonly required: readonly ["action"];
|
|
56
|
+
};
|
|
57
|
+
/** Tools allowed during plan mode (read-only + reasoning) */
|
|
58
|
+
export declare const PLAN_MODE_ALLOWED_TOOLS: readonly string[];
|
|
59
|
+
export interface PlanModeState {
|
|
60
|
+
active: boolean;
|
|
61
|
+
enteredAt?: string;
|
|
62
|
+
plan?: string;
|
|
63
|
+
planFilePath?: string;
|
|
64
|
+
}
|
|
65
|
+
export interface PlanModeResult {
|
|
66
|
+
success: boolean;
|
|
67
|
+
state: PlanModeState;
|
|
68
|
+
allowedTools?: readonly string[];
|
|
69
|
+
error?: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Host-provided plan mode backend.
|
|
73
|
+
* The host is responsible for filtering tool availability based on mode state.
|
|
74
|
+
*/
|
|
75
|
+
export interface PlanModeToolDeps {
|
|
76
|
+
/** Get current plan mode state */
|
|
77
|
+
getState(): PlanModeState;
|
|
78
|
+
/** Enter plan mode — host should restrict tool availability */
|
|
79
|
+
enterPlanMode(): Promise<PlanModeResult>;
|
|
80
|
+
/** Exit plan mode — host restores full tool availability */
|
|
81
|
+
exitPlanMode(plan?: string, planFilePath?: string): Promise<PlanModeResult>;
|
|
82
|
+
/** Check if in agent/sub-agent context (plan mode not allowed in sub-agents) */
|
|
83
|
+
isAgentContext?(): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Request approval for the plan from the user/coordinator.
|
|
86
|
+
* CC parity: ExitPlanModeV2 triggers an approval dialog on exit.
|
|
87
|
+
* Returns true if approved, false if rejected.
|
|
88
|
+
*/
|
|
89
|
+
requestPlanApproval?(plan: string, allowedPrompts?: Array<{
|
|
90
|
+
tool: string;
|
|
91
|
+
prompt: string;
|
|
92
|
+
}>): Promise<boolean>;
|
|
93
|
+
/**
|
|
94
|
+
* Persist plan to disk (CC parity: plan is saved to planFilePath).
|
|
95
|
+
*/
|
|
96
|
+
persistPlan?(plan: string, filePath: string): Promise<void>;
|
|
97
|
+
}
|
|
98
|
+
export declare function createPlanModeTool(deps: PlanModeToolDeps): PortableTool<PlanModeToolParams>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { PortableTool } from "../portable-tool.js";
|
|
2
|
+
export declare const READ_TOOL_NAME: "read";
|
|
3
|
+
export interface ReadToolParams {
|
|
4
|
+
path: string;
|
|
5
|
+
offset?: number;
|
|
6
|
+
limit?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare const READ_TOOL_SCHEMA: {
|
|
9
|
+
readonly type: "object";
|
|
10
|
+
readonly properties: {
|
|
11
|
+
readonly path: {
|
|
12
|
+
readonly type: "string";
|
|
13
|
+
readonly description: "Absolute path to the file to read.";
|
|
14
|
+
};
|
|
15
|
+
readonly offset: {
|
|
16
|
+
readonly type: "number";
|
|
17
|
+
readonly description: "Line number to start reading from (1-indexed). Default: 1.";
|
|
18
|
+
};
|
|
19
|
+
readonly limit: {
|
|
20
|
+
readonly type: "number";
|
|
21
|
+
readonly description: "Maximum number of lines to read. Default/max: 2000.";
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
readonly required: readonly ["path"];
|
|
25
|
+
};
|
|
26
|
+
export type ReadResultType = "text" | "image" | "binary_rejected";
|
|
27
|
+
/** Deps injected by the host runtime for file reading. */
|
|
28
|
+
export interface ReadToolDeps {
|
|
29
|
+
/** Read file content. Return string for text, base64 for images, or rejection. */
|
|
30
|
+
readFile(path: string): Promise<{
|
|
31
|
+
type: "text";
|
|
32
|
+
text: string;
|
|
33
|
+
} | {
|
|
34
|
+
type: "image";
|
|
35
|
+
base64: string;
|
|
36
|
+
mimeType: string;
|
|
37
|
+
} | {
|
|
38
|
+
type: "binary";
|
|
39
|
+
mimeType: string;
|
|
40
|
+
}>;
|
|
41
|
+
/** Resolve a relative path to absolute. */
|
|
42
|
+
resolvePath(input: string): string;
|
|
43
|
+
/**
|
|
44
|
+
* Validate read access for the given path.
|
|
45
|
+
* Returns null if allowed, or an error message if blocked.
|
|
46
|
+
* Blocks device paths (/dev/zero, /dev/random, etc.) and
|
|
47
|
+
* paths outside the allowed workspace.
|
|
48
|
+
*/
|
|
49
|
+
validatePath?(path: string): string | null;
|
|
50
|
+
}
|
|
51
|
+
export declare function createReadTool(deps: ReadToolDeps): PortableTool<ReadToolParams>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { PortableTool } from "../portable-tool.js";
|
|
2
|
+
export declare const REPL_TOOL_NAME: "repl";
|
|
3
|
+
export interface ReplToolParams {
|
|
4
|
+
/** JavaScript code to execute in the persistent VM context */
|
|
5
|
+
code: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const REPL_TOOL_SCHEMA: {
|
|
8
|
+
readonly type: "object";
|
|
9
|
+
readonly properties: {
|
|
10
|
+
readonly code: {
|
|
11
|
+
readonly type: "string";
|
|
12
|
+
readonly description: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
readonly required: readonly ["code"];
|
|
16
|
+
};
|
|
17
|
+
export interface ReplExecResult {
|
|
18
|
+
output: string;
|
|
19
|
+
error?: string;
|
|
20
|
+
duration: number;
|
|
21
|
+
}
|
|
22
|
+
/** Primitive operations injected into the VM context. */
|
|
23
|
+
export interface ReplPrimitives {
|
|
24
|
+
readFile(path: string): Promise<string>;
|
|
25
|
+
writeFile(path: string, content: string): Promise<void>;
|
|
26
|
+
editFile(path: string, edits: Array<{
|
|
27
|
+
oldText: string;
|
|
28
|
+
newText: string;
|
|
29
|
+
}>): Promise<string>;
|
|
30
|
+
exec(command: string): Promise<{
|
|
31
|
+
stdout: string;
|
|
32
|
+
stderr: string;
|
|
33
|
+
exitCode: number;
|
|
34
|
+
}>;
|
|
35
|
+
glob(pattern: string): Promise<string[]>;
|
|
36
|
+
grep(pattern: string, path?: string): Promise<Array<{
|
|
37
|
+
file: string;
|
|
38
|
+
line: number;
|
|
39
|
+
text: string;
|
|
40
|
+
}>>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Host-provided REPL execution backend.
|
|
44
|
+
*/
|
|
45
|
+
export interface ReplToolDeps {
|
|
46
|
+
/**
|
|
47
|
+
* Execute JavaScript code within a persistent VM context.
|
|
48
|
+
* The VM is pre-initialized with the primitive functions above.
|
|
49
|
+
* Each tool invocation reuses the same VM (preserving variable state).
|
|
50
|
+
*/
|
|
51
|
+
executeInVm(code: string): Promise<ReplExecResult>;
|
|
52
|
+
/**
|
|
53
|
+
* Reset the VM context (clear state). Optional hook called on errors.
|
|
54
|
+
*/
|
|
55
|
+
resetVm?(): void;
|
|
56
|
+
/**
|
|
57
|
+
* The host-provided primitives injected into the VM.
|
|
58
|
+
* When provided, the tool validates that the host has set up all required primitives.
|
|
59
|
+
*/
|
|
60
|
+
primitives?: ReplPrimitives;
|
|
61
|
+
/**
|
|
62
|
+
* Permission check for individual primitive operations.
|
|
63
|
+
* Called before each primitive executes inside the VM.
|
|
64
|
+
* Returns null if allowed, or an error message if denied.
|
|
65
|
+
*/
|
|
66
|
+
checkPermission?(operation: string, args: unknown[]): Promise<string | null>;
|
|
67
|
+
}
|
|
68
|
+
/** Tool names that should be hidden from direct LLM access when REPL is active. */
|
|
69
|
+
export declare const REPL_HIDES_TOOLS: readonly string[];
|
|
70
|
+
export declare function createReplTool(deps: ReplToolDeps): PortableTool<ReplToolParams>;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { PortableTool } from "../portable-tool.js";
|
|
2
|
+
export declare const SEARCH_TOOL_NAME: "search";
|
|
3
|
+
export type SearchMode = "filename" | "content" | "both";
|
|
4
|
+
export interface SearchToolParams {
|
|
5
|
+
mode: SearchMode;
|
|
6
|
+
pattern: string;
|
|
7
|
+
path?: string;
|
|
8
|
+
fileGlob?: string;
|
|
9
|
+
contextLines?: number;
|
|
10
|
+
caseInsensitive?: boolean;
|
|
11
|
+
headLimit?: number;
|
|
12
|
+
offset?: number;
|
|
13
|
+
}
|
|
14
|
+
export declare const SEARCH_TOOL_SCHEMA: {
|
|
15
|
+
readonly type: "object";
|
|
16
|
+
readonly properties: {
|
|
17
|
+
readonly mode: {
|
|
18
|
+
readonly type: "string";
|
|
19
|
+
readonly enum: readonly ["filename", "content", "both"];
|
|
20
|
+
readonly description: string;
|
|
21
|
+
};
|
|
22
|
+
readonly pattern: {
|
|
23
|
+
readonly type: "string";
|
|
24
|
+
readonly description: string;
|
|
25
|
+
};
|
|
26
|
+
readonly path: {
|
|
27
|
+
readonly type: "string";
|
|
28
|
+
readonly description: "Directory to search in. Defaults to workdir/cwd if omitted.";
|
|
29
|
+
};
|
|
30
|
+
readonly fileGlob: {
|
|
31
|
+
readonly type: "string";
|
|
32
|
+
readonly description: string;
|
|
33
|
+
};
|
|
34
|
+
readonly contextLines: {
|
|
35
|
+
readonly type: "number";
|
|
36
|
+
readonly description: string;
|
|
37
|
+
};
|
|
38
|
+
readonly caseInsensitive: {
|
|
39
|
+
readonly type: "boolean";
|
|
40
|
+
readonly description: "Case insensitive search (content/both modes). Default: false.";
|
|
41
|
+
};
|
|
42
|
+
readonly headLimit: {
|
|
43
|
+
readonly type: "number";
|
|
44
|
+
readonly description: string;
|
|
45
|
+
};
|
|
46
|
+
readonly offset: {
|
|
47
|
+
readonly type: "number";
|
|
48
|
+
readonly description: "Skip first N results before applying headLimit. Default: 0.";
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
readonly required: readonly ["mode", "pattern"];
|
|
52
|
+
};
|
|
53
|
+
export interface SearchFileResult {
|
|
54
|
+
path: string;
|
|
55
|
+
}
|
|
56
|
+
export interface SearchContentResult {
|
|
57
|
+
path: string;
|
|
58
|
+
line: number;
|
|
59
|
+
text: string;
|
|
60
|
+
contextBefore?: string[];
|
|
61
|
+
contextAfter?: string[];
|
|
62
|
+
}
|
|
63
|
+
export interface SearchOutput {
|
|
64
|
+
mode: SearchMode;
|
|
65
|
+
totalMatches: number;
|
|
66
|
+
truncated: boolean;
|
|
67
|
+
fileResults?: SearchFileResult[];
|
|
68
|
+
contentResults?: SearchContentResult[];
|
|
69
|
+
}
|
|
70
|
+
/** Host-provided search backend. */
|
|
71
|
+
export interface SearchToolDeps {
|
|
72
|
+
/**
|
|
73
|
+
* Find files matching a glob pattern.
|
|
74
|
+
* Returns array of relative file paths.
|
|
75
|
+
* The host SHOULD auto-exclude VCS directories (.git, .svn, .hg, .bzr)
|
|
76
|
+
* unless the user explicitly includes them.
|
|
77
|
+
*/
|
|
78
|
+
glob(pattern: string, options: {
|
|
79
|
+
cwd: string;
|
|
80
|
+
limit: number;
|
|
81
|
+
}): Promise<{
|
|
82
|
+
files: string[];
|
|
83
|
+
truncated: boolean;
|
|
84
|
+
}>;
|
|
85
|
+
/**
|
|
86
|
+
* Search file contents using regex.
|
|
87
|
+
* The implementation may use ripgrep, native grep, or a custom engine.
|
|
88
|
+
* Returns match records.
|
|
89
|
+
* The host SHOULD auto-exclude VCS directories (.git, .svn, .hg, .bzr)
|
|
90
|
+
* and enforce --max-columns 500 to avoid minified file noise.
|
|
91
|
+
*/
|
|
92
|
+
grep(pattern: string, options: {
|
|
93
|
+
cwd: string;
|
|
94
|
+
fileGlob?: string;
|
|
95
|
+
caseInsensitive?: boolean;
|
|
96
|
+
contextLines?: number;
|
|
97
|
+
headLimit?: number;
|
|
98
|
+
offset?: number;
|
|
99
|
+
}): Promise<{
|
|
100
|
+
matches: Array<{
|
|
101
|
+
path: string;
|
|
102
|
+
line: number;
|
|
103
|
+
text: string;
|
|
104
|
+
contextBefore?: string[];
|
|
105
|
+
contextAfter?: string[];
|
|
106
|
+
}>;
|
|
107
|
+
truncated: boolean;
|
|
108
|
+
}>;
|
|
109
|
+
/** Resolve relative path to absolute. If omitted, cwd is used. */
|
|
110
|
+
resolvePath?(input: string): string;
|
|
111
|
+
}
|
|
112
|
+
export declare function createSearchTool(deps: SearchToolDeps): PortableTool<SearchToolParams>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { PortableTool } from "../portable-tool.js";
|
|
2
|
+
export declare const SEND_MESSAGE_TOOL_NAME: "send_message";
|
|
3
|
+
export interface SendMessageToolParams {
|
|
4
|
+
/** Target agent name or '*' for broadcast */
|
|
5
|
+
to: string;
|
|
6
|
+
/** Message content */
|
|
7
|
+
message: string;
|
|
8
|
+
/** Optional short summary for routing/display */
|
|
9
|
+
summary?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const SEND_MESSAGE_TOOL_SCHEMA: {
|
|
12
|
+
readonly type: "object";
|
|
13
|
+
readonly properties: {
|
|
14
|
+
readonly to: {
|
|
15
|
+
readonly type: "string";
|
|
16
|
+
readonly description: string;
|
|
17
|
+
};
|
|
18
|
+
readonly message: {
|
|
19
|
+
readonly type: "string";
|
|
20
|
+
readonly description: "Message content to send to the target agent.";
|
|
21
|
+
};
|
|
22
|
+
readonly summary: {
|
|
23
|
+
readonly type: "string";
|
|
24
|
+
readonly description: "Optional short summary (for logging/routing).";
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
readonly required: readonly ["to", "message"];
|
|
28
|
+
};
|
|
29
|
+
export interface SendMessageResult {
|
|
30
|
+
success: boolean;
|
|
31
|
+
recipients?: string[];
|
|
32
|
+
error?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Host-provided message routing backend.
|
|
36
|
+
* Messages are delivered asynchronously via mailbox pattern.
|
|
37
|
+
*/
|
|
38
|
+
export interface SendMessageToolDeps {
|
|
39
|
+
/** Send message to target agent(s). Returns delivery status. */
|
|
40
|
+
sendMessage(params: {
|
|
41
|
+
to: string;
|
|
42
|
+
message: string;
|
|
43
|
+
summary?: string;
|
|
44
|
+
senderId: string;
|
|
45
|
+
}): Promise<SendMessageResult>;
|
|
46
|
+
/** Get the current agent's ID */
|
|
47
|
+
getSenderId(): string;
|
|
48
|
+
/** List available teammates */
|
|
49
|
+
listTeammates?(): string[];
|
|
50
|
+
}
|
|
51
|
+
export declare function createSendMessageTool(deps: SendMessageToolDeps): PortableTool<SendMessageToolParams>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ShellProvider } from "./shell-provider.js";
|
|
2
|
+
export interface BashProviderOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Absolute path to a pre-saved shell snapshot file.
|
|
5
|
+
* If provided, will be `source`d before every command
|
|
6
|
+
* to restore environment (virtualenvs, PATHs, etc.).
|
|
7
|
+
*/
|
|
8
|
+
snapshotFilePath?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Script fragment that sets session-specific env vars.
|
|
11
|
+
* Injected between snapshot sourcing and command execution.
|
|
12
|
+
*/
|
|
13
|
+
sessionEnvScript?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Create a bash ShellProvider.
|
|
17
|
+
*
|
|
18
|
+
* @param shellPath Absolute path to bash (e.g. `/bin/bash`, `/usr/bin/bash`)
|
|
19
|
+
* @param options Optional snapshot / session env
|
|
20
|
+
*/
|
|
21
|
+
export declare function createBashProvider(shellPath: string, options?: BashProviderOptions): ShellProvider;
|
|
22
|
+
/**
|
|
23
|
+
* Update the snapshot file path at runtime (e.g. after re-snapshotting).
|
|
24
|
+
* This is a convenience — in practice the provider is re-created infrequently.
|
|
25
|
+
*/
|
|
26
|
+
export declare function updateSnapshot(provider: ShellProvider, snapshotFilePath: string | undefined): void;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** Commands that search/find content (collapsible in UI). */
|
|
2
|
+
export declare const SEARCH_COMMANDS: Set<string>;
|
|
3
|
+
/** Commands that read/display file content (collapsible in UI). */
|
|
4
|
+
export declare const READ_COMMANDS: Set<string>;
|
|
5
|
+
/** Commands that list directory contents. */
|
|
6
|
+
export declare const LIST_COMMANDS: Set<string>;
|
|
7
|
+
/**
|
|
8
|
+
* Commands that are semantically neutral — they don't interact
|
|
9
|
+
* with the file system in a meaningful way. Skipped when
|
|
10
|
+
* classifying piped commands.
|
|
11
|
+
*/
|
|
12
|
+
export declare const SEMANTIC_NEUTRAL_COMMANDS: Set<string>;
|
|
13
|
+
/**
|
|
14
|
+
* Commands that produce no stdout on success.
|
|
15
|
+
* For these, the tool shows "Done" instead of "(No output)".
|
|
16
|
+
*/
|
|
17
|
+
export declare const SILENT_COMMANDS: Set<string>;
|
|
18
|
+
export interface CommandClassification {
|
|
19
|
+
/** First "real" command word (after env vars / wrappers). */
|
|
20
|
+
firstCommand: string | null;
|
|
21
|
+
/** Whether the command is search-like (find, grep, etc.). */
|
|
22
|
+
isSearch: boolean;
|
|
23
|
+
/** Whether the command only reads (cat, head, stat, etc.). */
|
|
24
|
+
isRead: boolean;
|
|
25
|
+
/** Whether the command lists files (ls, tree, du). */
|
|
26
|
+
isList: boolean;
|
|
27
|
+
/** Whether the command is expected to produce no stdout. */
|
|
28
|
+
isSilent: boolean;
|
|
29
|
+
/** Whether the command is safe to run in parallel with others. */
|
|
30
|
+
isConcurrencySafe: boolean;
|
|
31
|
+
/** Whether the command only reads state (never mutates). */
|
|
32
|
+
isReadOnly: boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Check whether a command has any `cd` or pushd/popd that changes CWD.
|
|
36
|
+
* Ported from cc's `commandHasAnyCd()`.
|
|
37
|
+
*/
|
|
38
|
+
export declare function commandHasAnyCd(command: string): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Classify a shell command.
|
|
41
|
+
*
|
|
42
|
+
* Mirrors cc's `isSearchOrReadBashCommand()` + `isSilentBashCommand()`.
|
|
43
|
+
*/
|
|
44
|
+
export declare function classifyCommand(command: string): CommandClassification;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface CommandSemanticResult {
|
|
2
|
+
isError: boolean;
|
|
3
|
+
message?: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Interpret a command's exit code using semantic rules.
|
|
7
|
+
*
|
|
8
|
+
* @param command - The shell command that was executed
|
|
9
|
+
* @param exitCode - The process exit code
|
|
10
|
+
* @param stdout - Standard output
|
|
11
|
+
* @param stderr - Standard error
|
|
12
|
+
* @returns Semantic interpretation (isError + optional message)
|
|
13
|
+
*/
|
|
14
|
+
export declare function interpretCommandResult(command: string, exitCode: number, stdout: string, stderr: string): CommandSemanticResult;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check a bash/sh command for destructive patterns.
|
|
3
|
+
* Returns the first matching warning, or null.
|
|
4
|
+
*/
|
|
5
|
+
export declare function getDestructiveCommandWarning(command: string): string | null;
|
|
6
|
+
/**
|
|
7
|
+
* Check a PowerShell command for destructive patterns.
|
|
8
|
+
* Returns the first matching warning, or null.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getPowerShellDestructiveCommandWarning(command: string): string | null;
|