sema-core 1.0.11 → 1.0.13
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 -11
- package/dist/core/Conversation.d.ts +6 -1
- package/dist/core/Conversation.d.ts.map +1 -1
- package/dist/core/Conversation.js +72 -28
- package/dist/core/Conversation.js.map +1 -1
- package/dist/core/RunTools.d.ts.map +1 -1
- package/dist/core/RunTools.js +1 -1
- package/dist/core/RunTools.js.map +1 -1
- package/dist/core/SemaCore.d.ts +16 -0
- package/dist/core/SemaCore.d.ts.map +1 -1
- package/dist/core/SemaCore.js +30 -3
- package/dist/core/SemaCore.js.map +1 -1
- package/dist/core/SemaEngine.d.ts +2 -18
- package/dist/core/SemaEngine.d.ts.map +1 -1
- package/dist/core/SemaEngine.js +101 -131
- package/dist/core/SemaEngine.js.map +1 -1
- package/dist/events/EventSystem.d.ts.map +1 -1
- package/dist/events/EventSystem.js +6 -2
- package/dist/events/EventSystem.js.map +1 -1
- package/dist/events/types.d.ts +60 -13
- package/dist/events/types.d.ts.map +1 -1
- package/dist/events/types.js +0 -1
- package/dist/events/types.js.map +1 -1
- package/dist/manager/ConfManager.d.ts.map +1 -1
- package/dist/manager/ConfManager.js +3 -1
- package/dist/manager/ConfManager.js.map +1 -1
- package/dist/manager/CronManager.d.ts +52 -0
- package/dist/manager/CronManager.d.ts.map +1 -0
- package/dist/manager/CronManager.js +426 -0
- package/dist/manager/CronManager.js.map +1 -0
- package/dist/manager/PermissionManager.d.ts +1 -1
- package/dist/manager/PermissionManager.d.ts.map +1 -1
- package/dist/manager/PermissionManager.js +63 -12
- package/dist/manager/PermissionManager.js.map +1 -1
- package/dist/manager/StateManager.d.ts +79 -11
- package/dist/manager/StateManager.d.ts.map +1 -1
- package/dist/manager/StateManager.js +287 -4
- package/dist/manager/StateManager.js.map +1 -1
- package/dist/manager/TaskManager.d.ts +106 -0
- package/dist/manager/TaskManager.d.ts.map +1 -0
- package/dist/manager/TaskManager.js +664 -0
- package/dist/manager/TaskManager.js.map +1 -0
- package/dist/services/agents/defaultBuiltInAgentsConfs.js +3 -3
- package/dist/services/agents/defaultBuiltInAgentsConfs.js.map +1 -1
- package/dist/services/agents/systemReminder.d.ts.map +1 -1
- package/dist/services/agents/systemReminder.js +8 -118
- package/dist/services/agents/systemReminder.js.map +1 -1
- package/dist/services/api/adapt/anthropic.js +2 -2
- package/dist/services/api/adapt/anthropic.js.map +1 -1
- package/dist/services/api/adapt/openai.js +2 -2
- package/dist/services/api/adapt/openai.js.map +1 -1
- package/dist/services/api/adapt/util.d.ts +1 -1
- package/dist/services/api/adapt/util.d.ts.map +1 -1
- package/dist/services/api/adapt/util.js +2 -2
- package/dist/services/api/adapt/util.js.map +1 -1
- package/dist/services/api/cache.d.ts.map +1 -1
- package/dist/services/api/cache.js +1 -3
- package/dist/services/api/cache.js.map +1 -1
- package/dist/services/api/queryLLM.d.ts.map +1 -1
- package/dist/services/api/queryLLM.js +5 -0
- package/dist/services/api/queryLLM.js.map +1 -1
- package/dist/services/commands/runCommand.d.ts.map +1 -1
- package/dist/services/commands/runCommand.js +12 -0
- package/dist/services/commands/runCommand.js.map +1 -1
- package/dist/services/mcp/MCPManager.d.ts.map +1 -1
- package/dist/services/mcp/MCPManager.js +6 -1
- package/dist/services/mcp/MCPManager.js.map +1 -1
- package/dist/services/plugins/pluginsManager.d.ts.map +1 -1
- package/dist/services/plugins/pluginsManager.js +8 -1
- package/dist/services/plugins/pluginsManager.js.map +1 -1
- package/dist/services/rules/rulesManager.d.ts +51 -0
- package/dist/services/rules/rulesManager.d.ts.map +1 -0
- package/dist/services/rules/rulesManager.js +192 -0
- package/dist/services/rules/rulesManager.js.map +1 -0
- package/dist/tools/Agent/Agent.d.ts +19 -11
- package/dist/tools/Agent/Agent.d.ts.map +1 -1
- package/dist/tools/Agent/Agent.js +249 -72
- package/dist/tools/Agent/Agent.js.map +1 -1
- package/dist/tools/Agent/prompt.d.ts.map +1 -1
- package/dist/tools/Agent/prompt.js +7 -9
- package/dist/tools/Agent/prompt.js.map +1 -1
- package/dist/tools/Bash/Bash.d.ts +21 -11
- package/dist/tools/Bash/Bash.d.ts.map +1 -1
- package/dist/tools/Bash/Bash.js +74 -17
- package/dist/tools/Bash/Bash.js.map +1 -1
- package/dist/tools/Bash/prompt.d.ts.map +1 -1
- package/dist/tools/Bash/prompt.js +53 -70
- package/dist/tools/Bash/prompt.js.map +1 -1
- package/dist/tools/Bash/utils.d.ts +5 -1
- package/dist/tools/Bash/utils.d.ts.map +1 -1
- package/dist/tools/Bash/utils.js +24 -4
- package/dist/tools/Bash/utils.js.map +1 -1
- package/dist/tools/CronCreate/CronCreate.d.ts +68 -0
- package/dist/tools/CronCreate/CronCreate.d.ts.map +1 -0
- package/dist/tools/CronCreate/CronCreate.js +75 -0
- package/dist/tools/CronCreate/CronCreate.js.map +1 -0
- package/dist/tools/CronCreate/prompt.d.ts +3 -0
- package/dist/tools/CronCreate/prompt.d.ts.map +1 -0
- package/dist/tools/CronCreate/prompt.js +41 -0
- package/dist/tools/CronCreate/prompt.js.map +1 -0
- package/dist/tools/CronDelete/CronDelete.d.ts +45 -0
- package/dist/tools/CronDelete/CronDelete.d.ts.map +1 -0
- package/dist/tools/CronDelete/CronDelete.js +51 -0
- package/dist/tools/CronDelete/CronDelete.js.map +1 -0
- package/dist/tools/CronDelete/prompt.d.ts +3 -0
- package/dist/tools/CronDelete/prompt.d.ts.map +1 -0
- package/dist/tools/CronDelete/prompt.js +6 -0
- package/dist/tools/CronDelete/prompt.js.map +1 -0
- package/dist/tools/CronList/CronList.d.ts +33 -0
- package/dist/tools/CronList/CronList.d.ts.map +1 -0
- package/dist/tools/CronList/CronList.js +55 -0
- package/dist/tools/CronList/CronList.js.map +1 -0
- package/dist/tools/CronList/prompt.d.ts +3 -0
- package/dist/tools/CronList/prompt.d.ts.map +1 -0
- package/dist/tools/CronList/prompt.js +6 -0
- package/dist/tools/CronList/prompt.js.map +1 -0
- package/dist/tools/Edit/Edit.d.ts.map +1 -1
- package/dist/tools/Edit/Edit.js +7 -3
- package/dist/tools/Edit/Edit.js.map +1 -1
- package/dist/tools/Edit/utils.d.ts.map +1 -1
- package/dist/tools/Edit/utils.js +14 -5
- package/dist/tools/Edit/utils.js.map +1 -1
- package/dist/tools/Grep/Grep.d.ts +4 -4
- package/dist/tools/NotebookEdit/NotebookEdit.js +1 -1
- package/dist/tools/NotebookEdit/NotebookEdit.js.map +1 -1
- package/dist/tools/Read/Read.d.ts +74 -3
- package/dist/tools/Read/Read.d.ts.map +1 -1
- package/dist/tools/Read/Read.js +188 -18
- package/dist/tools/Read/Read.js.map +1 -1
- package/dist/tools/Read/prompt.d.ts +1 -1
- package/dist/tools/Read/prompt.d.ts.map +1 -1
- package/dist/tools/Read/prompt.js +2 -1
- package/dist/tools/Read/prompt.js.map +1 -1
- package/dist/tools/Skill/Skill.d.ts +2 -1
- package/dist/tools/Skill/Skill.d.ts.map +1 -1
- package/dist/tools/Skill/Skill.js +3 -2
- package/dist/tools/Skill/Skill.js.map +1 -1
- package/dist/tools/TaskCreate/TaskCreate.d.ts +54 -0
- package/dist/tools/TaskCreate/TaskCreate.d.ts.map +1 -0
- package/dist/tools/TaskCreate/TaskCreate.js +51 -0
- package/dist/tools/TaskCreate/TaskCreate.js.map +1 -0
- package/dist/tools/TaskCreate/prompt.d.ts +3 -0
- package/dist/tools/TaskCreate/prompt.d.ts.map +1 -0
- package/dist/tools/TaskCreate/prompt.js +45 -0
- package/dist/tools/TaskCreate/prompt.js.map +1 -0
- package/dist/tools/TaskGet/TaskGet.d.ts +34 -0
- package/dist/tools/TaskGet/TaskGet.d.ts.map +1 -0
- package/dist/tools/TaskGet/TaskGet.js +57 -0
- package/dist/tools/TaskGet/TaskGet.js.map +1 -0
- package/dist/tools/TaskGet/prompt.d.ts +3 -0
- package/dist/tools/TaskGet/prompt.d.ts.map +1 -0
- package/dist/tools/TaskGet/prompt.js +26 -0
- package/dist/tools/TaskGet/prompt.js.map +1 -0
- package/dist/tools/TaskList/TaskList.d.ts +27 -0
- package/dist/tools/TaskList/TaskList.d.ts.map +1 -0
- package/dist/tools/TaskList/TaskList.js +56 -0
- package/dist/tools/TaskList/TaskList.js.map +1 -0
- package/dist/tools/TaskList/prompt.d.ts +3 -0
- package/dist/tools/TaskList/prompt.d.ts.map +1 -0
- package/dist/tools/TaskList/prompt.js +25 -0
- package/dist/tools/TaskList/prompt.js.map +1 -0
- package/dist/tools/TaskOutput/TaskOutput.d.ts +58 -0
- package/dist/tools/TaskOutput/TaskOutput.d.ts.map +1 -0
- package/dist/tools/TaskOutput/TaskOutput.js +95 -0
- package/dist/tools/TaskOutput/TaskOutput.js.map +1 -0
- package/dist/tools/TaskStop/TaskStop.d.ts +50 -0
- package/dist/tools/TaskStop/TaskStop.d.ts.map +1 -0
- package/dist/tools/TaskStop/TaskStop.js +69 -0
- package/dist/tools/TaskStop/TaskStop.js.map +1 -0
- package/dist/tools/TaskUpdate/TaskUpdate.d.ts +88 -0
- package/dist/tools/TaskUpdate/TaskUpdate.d.ts.map +1 -0
- package/dist/tools/TaskUpdate/TaskUpdate.js +115 -0
- package/dist/tools/TaskUpdate/TaskUpdate.js.map +1 -0
- package/dist/tools/TaskUpdate/prompt.d.ts +3 -0
- package/dist/tools/TaskUpdate/prompt.d.ts.map +1 -0
- package/dist/tools/TaskUpdate/prompt.js +80 -0
- package/dist/tools/TaskUpdate/prompt.js.map +1 -0
- package/dist/tools/WebFetch/WebFetch.d.ts +62 -0
- package/dist/tools/WebFetch/WebFetch.d.ts.map +1 -0
- package/dist/tools/WebFetch/WebFetch.js +143 -0
- package/dist/tools/WebFetch/WebFetch.js.map +1 -0
- package/dist/tools/WebFetch/prompt.d.ts +4 -0
- package/dist/tools/WebFetch/prompt.d.ts.map +1 -0
- package/dist/tools/WebFetch/prompt.js +38 -0
- package/dist/tools/WebFetch/prompt.js.map +1 -0
- package/dist/tools/WebFetch/utils.d.ts +20 -0
- package/dist/tools/WebFetch/utils.d.ts.map +1 -0
- package/dist/tools/WebFetch/utils.js +223 -0
- package/dist/tools/WebFetch/utils.js.map +1 -0
- package/dist/tools/Write/Write.js +1 -1
- package/dist/tools/Write/Write.js.map +1 -1
- package/dist/tools/base/Tool.d.ts +1 -0
- package/dist/tools/base/Tool.d.ts.map +1 -1
- package/dist/tools/base/tools.d.ts +4 -2
- package/dist/tools/base/tools.d.ts.map +1 -1
- package/dist/tools/base/tools.js +61 -14
- package/dist/tools/base/tools.js.map +1 -1
- package/dist/types/cron.d.ts +21 -0
- package/dist/types/cron.d.ts.map +1 -0
- package/dist/types/cron.js +6 -0
- package/dist/types/cron.js.map +1 -0
- package/dist/types/index.d.ts +9 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +4 -2
- package/dist/types/index.js.map +1 -1
- package/dist/types/rule.d.ts +8 -0
- package/dist/types/rule.d.ts.map +1 -0
- package/dist/types/rule.js +3 -0
- package/dist/types/rule.js.map +1 -0
- package/dist/types/task.d.ts +93 -0
- package/dist/types/task.d.ts.map +1 -0
- package/dist/types/task.js +3 -0
- package/dist/types/task.js.map +1 -0
- package/dist/types/todoTask.d.ts +29 -0
- package/dist/types/todoTask.d.ts.map +1 -0
- package/dist/types/todoTask.js +6 -0
- package/dist/types/todoTask.js.map +1 -0
- package/dist/util/assembleTools.d.ts +6 -0
- package/dist/util/assembleTools.d.ts.map +1 -0
- package/dist/util/assembleTools.js +17 -0
- package/dist/util/assembleTools.js.map +1 -0
- package/dist/util/btw.d.ts +6 -0
- package/dist/util/btw.d.ts.map +1 -0
- package/dist/util/btw.js +80 -0
- package/dist/util/btw.js.map +1 -0
- package/dist/util/compact.d.ts +16 -4
- package/dist/util/compact.d.ts.map +1 -1
- package/dist/util/compact.js +12 -18
- package/dist/util/compact.js.map +1 -1
- package/dist/util/cron.d.ts +17 -0
- package/dist/util/cron.d.ts.map +1 -0
- package/dist/util/cron.js +82 -0
- package/dist/util/cron.js.map +1 -0
- package/dist/util/file.d.ts +16 -0
- package/dist/util/file.d.ts.map +1 -1
- package/dist/util/file.js +55 -0
- package/dist/util/file.js.map +1 -1
- package/dist/util/fileReference.d.ts.map +1 -1
- package/dist/util/fileReference.js +10 -1
- package/dist/util/fileReference.js.map +1 -1
- package/dist/util/format.d.ts +6 -0
- package/dist/util/format.d.ts.map +1 -1
- package/dist/util/format.js +17 -0
- package/dist/util/format.js.map +1 -1
- package/dist/util/history.d.ts +4 -1
- package/dist/util/history.d.ts.map +1 -1
- package/dist/util/history.js +9 -5
- package/dist/util/history.js.map +1 -1
- package/dist/util/inputQueue.d.ts +19 -0
- package/dist/util/inputQueue.d.ts.map +1 -0
- package/dist/util/inputQueue.js +30 -0
- package/dist/util/inputQueue.js.map +1 -0
- package/dist/util/message.d.ts +4 -0
- package/dist/util/message.d.ts.map +1 -1
- package/dist/util/message.js +27 -0
- package/dist/util/message.js.map +1 -1
- package/dist/util/pdf.d.ts +83 -0
- package/dist/util/pdf.d.ts.map +1 -0
- package/dist/util/pdf.js +472 -0
- package/dist/util/pdf.js.map +1 -0
- package/dist/util/process.d.ts +10 -0
- package/dist/util/process.d.ts.map +1 -0
- package/dist/util/process.js +88 -0
- package/dist/util/process.js.map +1 -0
- package/dist/util/savePath.d.ts +0 -11
- package/dist/util/savePath.d.ts.map +1 -1
- package/dist/util/savePath.js +0 -17
- package/dist/util/savePath.js.map +1 -1
- package/dist/util/shell.d.ts +10 -1
- package/dist/util/shell.d.ts.map +1 -1
- package/dist/util/shell.js +89 -34
- package/dist/util/shell.js.map +1 -1
- package/dist/util/topic.d.ts +7 -0
- package/dist/util/topic.d.ts.map +1 -1
- package/dist/util/topic.js +40 -0
- package/dist/util/topic.js.map +1 -1
- package/package.json +2 -1
- package/dist/services/command/customCommands.d.ts +0 -1
- package/dist/services/command/customCommands.d.ts.map +0 -1
- package/dist/services/command/customCommands.js +0 -197
- package/dist/services/command/customCommands.js.map +0 -1
- package/dist/services/command/runCommand.d.ts +0 -18
- package/dist/services/command/runCommand.d.ts.map +0 -1
- package/dist/services/command/runCommand.js +0 -147
- package/dist/services/command/runCommand.js.map +0 -1
- package/dist/services/plugins/customCommands.d.ts +0 -29
- package/dist/services/plugins/customCommands.d.ts.map +0 -1
- package/dist/services/plugins/customCommands.js +0 -227
- package/dist/services/plugins/customCommands.js.map +0 -1
- package/dist/services/skill/skillLoader.d.ts +0 -17
- package/dist/services/skill/skillLoader.d.ts.map +0 -1
- package/dist/services/skill/skillLoader.js +0 -122
- package/dist/services/skill/skillLoader.js.map +0 -1
- package/dist/services/skill/skillParser.d.ts +0 -15
- package/dist/services/skill/skillParser.d.ts.map +0 -1
- package/dist/services/skill/skillParser.js +0 -66
- package/dist/services/skill/skillParser.js.map +0 -1
- package/dist/services/skill/skillRegistry.d.ts +0 -34
- package/dist/services/skill/skillRegistry.d.ts.map +0 -1
- package/dist/services/skill/skillRegistry.js +0 -98
- package/dist/services/skill/skillRegistry.js.map +0 -1
- package/dist/services/skill/skillsManager.d.ts +0 -79
- package/dist/services/skill/skillsManager.d.ts.map +0 -1
- package/dist/services/skill/skillsManager.js +0 -289
- package/dist/services/skill/skillsManager.js.map +0 -1
- package/dist/tools/Task/Task.d.ts +0 -59
- package/dist/tools/Task/Task.d.ts.map +0 -1
- package/dist/tools/Task/Task.js +0 -212
- package/dist/tools/Task/Task.js.map +0 -1
- package/dist/tools/Task/prompt.d.ts +0 -6
- package/dist/tools/Task/prompt.d.ts.map +0 -1
- package/dist/tools/Task/prompt.js +0 -75
- package/dist/tools/Task/prompt.js.map +0 -1
- package/dist/util/frontmatter.d.ts +0 -35
- package/dist/util/frontmatter.d.ts.map +0 -1
- package/dist/util/frontmatter.js +0 -119
- package/dist/util/frontmatter.js.map +0 -1
- package/dist/util/rules.d.ts +0 -6
- package/dist/util/rules.d.ts.map +0 -1
- package/dist/util/rules.js +0 -162
- package/dist/util/rules.js.map +0 -1
- package/dist/util/systemReminder.d.ts +0 -10
- package/dist/util/systemReminder.d.ts.map +0 -1
- package/dist/util/systemReminder.js +0 -177
- package/dist/util/systemReminder.js.map +0 -1
|
@@ -3,15 +3,18 @@ import { ValidationResult } from '../base/Tool';
|
|
|
3
3
|
export declare const inputSchema: z.ZodObject<{
|
|
4
4
|
command: z.ZodString;
|
|
5
5
|
timeout: z.ZodOptional<z.ZodNumber>;
|
|
6
|
-
description: z.ZodString
|
|
6
|
+
description: z.ZodOptional<z.ZodString>;
|
|
7
|
+
run_in_background: z.ZodOptional<z.ZodBoolean>;
|
|
7
8
|
}, "strict", z.ZodTypeAny, {
|
|
8
9
|
command: string;
|
|
9
|
-
description: string;
|
|
10
10
|
timeout?: number | undefined;
|
|
11
|
+
description?: string | undefined;
|
|
12
|
+
run_in_background?: boolean | undefined;
|
|
11
13
|
}, {
|
|
12
14
|
command: string;
|
|
13
|
-
description: string;
|
|
14
15
|
timeout?: number | undefined;
|
|
16
|
+
description?: string | undefined;
|
|
17
|
+
run_in_background?: boolean | undefined;
|
|
15
18
|
}>;
|
|
16
19
|
export type Out = {
|
|
17
20
|
stdout: string;
|
|
@@ -29,25 +32,30 @@ export declare const BashTool: {
|
|
|
29
32
|
inputSchema: z.ZodObject<{
|
|
30
33
|
command: z.ZodString;
|
|
31
34
|
timeout: z.ZodOptional<z.ZodNumber>;
|
|
32
|
-
description: z.ZodString
|
|
35
|
+
description: z.ZodOptional<z.ZodString>;
|
|
36
|
+
run_in_background: z.ZodOptional<z.ZodBoolean>;
|
|
33
37
|
}, "strict", z.ZodTypeAny, {
|
|
34
38
|
command: string;
|
|
35
|
-
description: string;
|
|
36
39
|
timeout?: number | undefined;
|
|
40
|
+
description?: string | undefined;
|
|
41
|
+
run_in_background?: boolean | undefined;
|
|
37
42
|
}, {
|
|
38
43
|
command: string;
|
|
39
|
-
description: string;
|
|
40
44
|
timeout?: number | undefined;
|
|
45
|
+
description?: string | undefined;
|
|
46
|
+
run_in_background?: boolean | undefined;
|
|
41
47
|
}>;
|
|
42
48
|
validateInput({ command }: {
|
|
43
49
|
command: string;
|
|
44
|
-
description: string;
|
|
45
50
|
timeout?: number | undefined;
|
|
51
|
+
description?: string | undefined;
|
|
52
|
+
run_in_background?: boolean | undefined;
|
|
46
53
|
}, agentContext: any): Promise<ValidationResult>;
|
|
47
54
|
genToolPermission(input: {
|
|
48
55
|
command: string;
|
|
49
|
-
description: string;
|
|
50
56
|
timeout?: number | undefined;
|
|
57
|
+
description?: string | undefined;
|
|
58
|
+
run_in_background?: boolean | undefined;
|
|
51
59
|
}): {
|
|
52
60
|
title: string;
|
|
53
61
|
content: string;
|
|
@@ -59,14 +67,16 @@ export declare const BashTool: {
|
|
|
59
67
|
};
|
|
60
68
|
getDisplayTitle(input: {
|
|
61
69
|
command: string;
|
|
62
|
-
description: string;
|
|
63
70
|
timeout?: number | undefined;
|
|
71
|
+
description?: string | undefined;
|
|
72
|
+
run_in_background?: boolean | undefined;
|
|
64
73
|
} | undefined): string;
|
|
65
74
|
genResultForAssistant({ interrupted, stdout, stderr }: Out): string;
|
|
66
|
-
call({ command, timeout }: {
|
|
75
|
+
call({ command, timeout, run_in_background }: {
|
|
67
76
|
command: string;
|
|
68
|
-
description: string;
|
|
69
77
|
timeout?: number | undefined;
|
|
78
|
+
description?: string | undefined;
|
|
79
|
+
run_in_background?: boolean | undefined;
|
|
70
80
|
}, agentContext: any): AsyncGenerator<{
|
|
71
81
|
type: "result";
|
|
72
82
|
data: Out;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Bash.d.ts","sourceRoot":"","sources":["../../../src/tools/Bash/Bash.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAQ,gBAAgB,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"Bash.d.ts","sourceRoot":"","sources":["../../../src/tools/Bash/Bash.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAQ,gBAAgB,EAAE,MAAM,cAAc,CAAA;AA6CrD,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;EAsBtB,CAAA;AAGF,MAAM,MAAM,GAAG,GAAG;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,OAAO,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;qBAY4B,GAAG,GAAG,OAAO,CAAC,gBAAgB,CAAC;;;;;;;;;;;;;;;;;;;;;iEAmEtB,MAAM;;;;;;qBAmB9C,GAAG;;;;;CA+KI,CAAA"}
|
package/dist/tools/Bash/Bash.js
CHANGED
|
@@ -7,9 +7,11 @@ const zod_1 = require("zod");
|
|
|
7
7
|
const commands_1 = require("../../util/commands");
|
|
8
8
|
const file_1 = require("../../util/file");
|
|
9
9
|
const shell_1 = require("../../util/shell");
|
|
10
|
+
const TaskManager_1 = require("../../manager/TaskManager");
|
|
10
11
|
const cwd_1 = require("../../util/cwd");
|
|
11
12
|
const format_1 = require("../../util/format");
|
|
12
13
|
const prompt_1 = require("./prompt");
|
|
14
|
+
const ConfManager_1 = require("../../manager/ConfManager");
|
|
13
15
|
const utils_1 = require("./utils");
|
|
14
16
|
const EventSystem_1 = require("../../events/EventSystem");
|
|
15
17
|
const StateManager_1 = require("../../manager/StateManager");
|
|
@@ -47,7 +49,7 @@ exports.inputSchema = zod_1.z.strictObject({
|
|
|
47
49
|
.number()
|
|
48
50
|
.optional()
|
|
49
51
|
.describe(`Optional timeout in milliseconds (max ${prompt_1.MAX_TIMEOUT_MS})`),
|
|
50
|
-
description: zod_1.z.string().describe(`Clear, concise description of what this command does in 5-10 words, in active voice. Examples:
|
|
52
|
+
description: zod_1.z.string().optional().describe(`Clear, concise description of what this command does in 5-10 words, in active voice. Examples:
|
|
51
53
|
Input: ls
|
|
52
54
|
Output: List files in current directory
|
|
53
55
|
|
|
@@ -58,7 +60,11 @@ Input: npm install
|
|
|
58
60
|
Output: Install package dependencies
|
|
59
61
|
|
|
60
62
|
Input: mkdir foo
|
|
61
|
-
Output: Create directory 'foo'`)
|
|
63
|
+
Output: Create directory 'foo'`),
|
|
64
|
+
run_in_background: zod_1.z
|
|
65
|
+
.boolean()
|
|
66
|
+
.optional()
|
|
67
|
+
.describe(`Set to true to run this command in the background. Use TaskOutput to read the output later.`),
|
|
62
68
|
});
|
|
63
69
|
exports.BashTool = {
|
|
64
70
|
name: prompt_1.TOOL_NAME_FOR_PROMPT,
|
|
@@ -102,16 +108,16 @@ exports.BashTool = {
|
|
|
102
108
|
const title = getTitle(input);
|
|
103
109
|
return {
|
|
104
110
|
title,
|
|
105
|
-
content: input.description
|
|
111
|
+
content: input.description || ''
|
|
106
112
|
};
|
|
107
113
|
},
|
|
108
114
|
genToolResultMessage({ stdout, stderr, interrupted, command }) {
|
|
109
115
|
let result = '';
|
|
110
116
|
if (stdout !== '') {
|
|
111
|
-
result += (0, utils_1.formatOutput)(stdout.trim()).truncatedContent + '\n';
|
|
117
|
+
result += (0, utils_1.formatOutput)(stdout.trim(), utils_1.STDOUT_HEAD_TAIL_LINES).truncatedContent + '\n';
|
|
112
118
|
}
|
|
113
119
|
if (stderr !== '') {
|
|
114
|
-
result += (0, utils_1.formatOutput)(stderr.trim()).truncatedContent + '\n';
|
|
120
|
+
result += (0, utils_1.formatOutput)(stderr.trim(), utils_1.STDERR_HEAD_TAIL_LINES).truncatedContent + '\n';
|
|
115
121
|
}
|
|
116
122
|
if (stdout === '' && stderr === '') {
|
|
117
123
|
result = '(No content)';
|
|
@@ -127,27 +133,56 @@ exports.BashTool = {
|
|
|
127
133
|
return getTitle(input);
|
|
128
134
|
},
|
|
129
135
|
genResultForAssistant({ interrupted, stdout, stderr }) {
|
|
130
|
-
const headTailLines = 500;
|
|
131
136
|
const { truncatedContent: stdoutContent } = stdout.trim()
|
|
132
|
-
? (0, utils_1.formatOutput)(stdout.trim(),
|
|
137
|
+
? (0, utils_1.formatOutput)(stdout.trim(), utils_1.STDOUT_HEAD_TAIL_LINES)
|
|
133
138
|
: { truncatedContent: '' };
|
|
134
139
|
const { truncatedContent: stderrContent } = stderr.trim()
|
|
135
|
-
? (0, utils_1.formatOutput)(stderr.trim(),
|
|
140
|
+
? (0, utils_1.formatOutput)(stderr.trim(), utils_1.STDERR_HEAD_TAIL_LINES)
|
|
136
141
|
: { truncatedContent: '' };
|
|
137
142
|
if (interrupted) {
|
|
138
|
-
const
|
|
139
|
-
return
|
|
140
|
-
? `${errorMsg}\n${message_1.INTERRUPT_MESSAGE_FOR_TOOL_USE}\n${stdoutContent}`
|
|
141
|
-
: `${errorMsg}`;
|
|
143
|
+
const parts = [stdoutContent, message_1.INTERRUPT_MESSAGE_FOR_TOOL_USE, stderrContent].filter(Boolean);
|
|
144
|
+
return parts.join('\n');
|
|
142
145
|
}
|
|
143
146
|
const hasBoth = stdoutContent && stderrContent;
|
|
144
147
|
const result = `${stdoutContent}${hasBoth ? '\n' : ''}${stderrContent}`;
|
|
145
148
|
return result || '(no content)';
|
|
146
149
|
},
|
|
147
|
-
async *call({ command, timeout = prompt_1.DEFAULT_TIMEOUT_MS }, agentContext) {
|
|
150
|
+
async *call({ command, timeout = prompt_1.DEFAULT_TIMEOUT_MS, run_in_background }, agentContext) {
|
|
151
|
+
const abortController = agentContext.abortController;
|
|
152
|
+
// 子代理不支持后台执行,强制前台
|
|
153
|
+
const isSubAgent = agentContext.agentId !== StateManager_1.MAIN_AGENT_ID;
|
|
154
|
+
const disableBackground = (0, ConfManager_1.getConfManager)().getCoreConfig()?.disableBackgroundTasks ?? false;
|
|
155
|
+
// ① run_in_background=true → 直接 spawn 独立进程(仅主代理,且未禁用后台任务)
|
|
156
|
+
if (run_in_background && !isSubAgent && !disableBackground) {
|
|
157
|
+
try {
|
|
158
|
+
const { taskId, filepath } = (0, TaskManager_1.getTaskManager)().spawnBashTask(command, agentContext.currentToolUseID || '', agentContext);
|
|
159
|
+
const msg = `Command running in background. Task ID: ${taskId}. Output: ${filepath}`;
|
|
160
|
+
const data = {
|
|
161
|
+
stdout: msg,
|
|
162
|
+
stdoutLines: 1,
|
|
163
|
+
stderr: '',
|
|
164
|
+
stderrLines: 0,
|
|
165
|
+
interrupted: false,
|
|
166
|
+
command,
|
|
167
|
+
};
|
|
168
|
+
yield { type: 'result', data, resultForAssistant: msg };
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
172
|
+
const data = {
|
|
173
|
+
stdout: '',
|
|
174
|
+
stdoutLines: 0,
|
|
175
|
+
stderr: errMsg,
|
|
176
|
+
stderrLines: 1,
|
|
177
|
+
interrupted: false,
|
|
178
|
+
command,
|
|
179
|
+
};
|
|
180
|
+
yield { type: 'result', data, resultForAssistant: errMsg };
|
|
181
|
+
}
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
148
184
|
let stdout = '';
|
|
149
185
|
let stderr = '';
|
|
150
|
-
const abortController = agentContext.abortController;
|
|
151
186
|
if (abortController?.signal.aborted) {
|
|
152
187
|
const data = {
|
|
153
188
|
stdout: '',
|
|
@@ -174,9 +209,9 @@ exports.BashTool = {
|
|
|
174
209
|
const onChunk = isMainAgent ? (chunkStdout, chunkStderr) => {
|
|
175
210
|
let content = '';
|
|
176
211
|
if (chunkStdout.trim())
|
|
177
|
-
content += (0, utils_1.formatOutput)(chunkStdout.trim()).truncatedContent;
|
|
212
|
+
content += (0, utils_1.formatOutput)(chunkStdout.trim(), undefined, { resolveCR: false }).truncatedContent;
|
|
178
213
|
if (chunkStderr.trim())
|
|
179
|
-
content += (content ? '\n' : '') + (0, utils_1.formatOutput)(chunkStderr.trim()).truncatedContent;
|
|
214
|
+
content += (content ? '\n' : '') + (0, utils_1.formatOutput)(chunkStderr.trim(), undefined, { resolveCR: false }).truncatedContent;
|
|
180
215
|
const chunkData = {
|
|
181
216
|
agentId: agentContext.agentId,
|
|
182
217
|
toolId: agentContext.currentToolUseID || '',
|
|
@@ -187,8 +222,30 @@ exports.BashTool = {
|
|
|
187
222
|
};
|
|
188
223
|
(0, EventSystem_1.getEventBus)().emit('tool:execution:chunk', chunkData);
|
|
189
224
|
} : undefined;
|
|
225
|
+
// ② 超时接管回调(子代理不接管,超时直接 kill;禁用后台任务时同样直接 kill)
|
|
226
|
+
let bgTaskId;
|
|
227
|
+
let bgFilepath;
|
|
228
|
+
const onTimeout = (isSubAgent || disableBackground) ? undefined : (ctx) => {
|
|
229
|
+
const result = (0, TaskManager_1.getTaskManager)().takeoverTask(ctx, command, agentContext.currentToolUseID || '', agentContext);
|
|
230
|
+
bgTaskId = result.taskId;
|
|
231
|
+
bgFilepath = result.filepath;
|
|
232
|
+
};
|
|
190
233
|
try {
|
|
191
|
-
const result = await shell_1.PersistentShell.getInstance().exec(command, abortController?.signal, effectiveTimeout, onChunk);
|
|
234
|
+
const result = await shell_1.PersistentShell.getInstance().exec(command, abortController?.signal, effectiveTimeout, onChunk, onTimeout);
|
|
235
|
+
// ③ 超时接管标记(code === -1)
|
|
236
|
+
if (result.code === -1 && bgTaskId) {
|
|
237
|
+
const msg = `Command timed out after ${(0, shell_1.formatDuration)(effectiveTimeout)}, moved to background.\nTask ID: ${bgTaskId}.\nOutput: ${bgFilepath}`;
|
|
238
|
+
const data = {
|
|
239
|
+
stdout: msg,
|
|
240
|
+
stdoutLines: 1,
|
|
241
|
+
stderr: '',
|
|
242
|
+
stderrLines: 0,
|
|
243
|
+
interrupted: false,
|
|
244
|
+
command,
|
|
245
|
+
};
|
|
246
|
+
yield { type: 'result', data, resultForAssistant: msg };
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
192
249
|
stdout += (result.stdout || '').trim() + os_1.EOL;
|
|
193
250
|
if (result.code !== 0) {
|
|
194
251
|
stderr += `Exit code ${result.code}` + os_1.EOL;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Bash.js","sourceRoot":"","sources":["../../../src/tools/Bash/Bash.ts"],"names":[],"mappings":";;;AAAA,2BAAwB;AACxB,+BAAoD;AACpD,6BAAuB;AAEvB,kDAAkD;AAClD,0CAA+C;AAC/C,
|
|
1
|
+
{"version":3,"file":"Bash.js","sourceRoot":"","sources":["../../../src/tools/Bash/Bash.ts"],"names":[],"mappings":";;;AAAA,2BAAwB;AACxB,+BAAoD;AACpD,6BAAuB;AAEvB,kDAAkD;AAClD,0CAA+C;AAC/C,4CAA+F;AAC/F,2DAA0D;AAC1D,wCAAuD;AACvD,8CAAyD;AACzD,qCAAgG;AAChG,2DAA0D;AAC1D,mCAAsF;AACtF,0DAAsD;AAEtD,6DAA0D;AAC1D,qDAAwE;AAGxE,MAAM,eAAe,GAAG;IACtB,OAAO;IACP,MAAM;IACN,QAAQ;IACR,MAAM;IACN,MAAM;IACN,QAAQ;IACR,IAAI;IACJ,QAAQ;IACR,MAAM;IACN,KAAK;IACL,OAAO;IACP,QAAQ;IACR,IAAI;IACJ,aAAa;IACb,QAAQ;IACR,SAAS;IACT,QAAQ;CACT,CAAA;AAED,cAAc;AACd,SAAS,QAAQ,CAAC,KAA4B;IAC5C,IAAI,KAAK,EAAE,OAAO,EAAE,CAAC;QACnB,MAAM,OAAO,GAAG,IAAA,8BAAqB,EAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QACpD,OAAO,GAAG,OAAO,EAAE,CAAA;IACrB,CAAC;IACD,OAAO,6BAAoB,CAAA;AAC7B,CAAC;AAEY,QAAA,WAAW,GAAG,OAAC,CAAC,YAAY,CAAC;IACxC,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,wBAAwB,CAAC;IACtD,OAAO,EAAE,OAAC;SACP,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,yCAAyC,uBAAc,GAAG,CAAC;IACvE,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE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AI,CAAC;aACrD,CAAA;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,SAAS,GAAG,eAAe,EAAE,MAAM,CAAC,OAAO,IAAI,KAAK,CAAA;YAC1D,MAAM,YAAY,GAAG,SAAS;gBAC5B,CAAC,CAAC,+BAA+B;gBACjC,CAAC,CAAC,mBAAmB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAA;YAE/E,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,gBAAgB,EAAE,aAAa,EAAE,GAAG,IAAA,oBAAY,EAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAA;YAChG,MAAM,IAAI,GAAQ;gBAChB,MAAM,EAAE,aAAa;gBACrB,WAAW;gBACX,MAAM,EAAE,YAAY;gBACpB,WAAW,EAAE,CAAC;gBACd,WAAW,EAAE,SAAS;gBACtB,OAAO;aACR,CAAA;YAED,MAAM;gBACJ,IAAI,EAAE,QAAQ;gBACd,IAAI;gBACJ,kBAAkB,EAAE,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC;aACrD,CAAA;QACH,CAAC;IACH,CAAC;CACsB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../src/tools/Bash/prompt.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../src/tools/Bash/prompt.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,eAAO,MAAM,kBAAkB,SAAS,CAAC;AAEzC,eAAO,MAAM,oBAAoB,SAAS,CAAA;AAE1C,eAAO,MAAM,WAAW,EAAE,MAyH8C,CAAA"}
|
|
@@ -2,62 +2,47 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DESCRIPTION = exports.TOOL_NAME_FOR_PROMPT = exports.DEFAULT_TIMEOUT_MS = exports.MAX_TIMEOUT_MS = void 0;
|
|
4
4
|
const product_1 = require("../../constants/product");
|
|
5
|
-
const prompt_1 = require("../Read/prompt");
|
|
6
|
-
const prompt_2 = require("../Edit/prompt");
|
|
7
|
-
const prompt_3 = require("../Write/prompt");
|
|
8
|
-
const prompt_4 = require("../Agent/prompt");
|
|
9
|
-
const prompt_5 = require("../Glob/prompt");
|
|
10
|
-
const prompt_6 = require("../Grep/prompt");
|
|
11
|
-
const prompt_7 = require("../TodoWrite/prompt");
|
|
12
|
-
const MAX_OUTPUT_LENGTH = 30000;
|
|
13
5
|
exports.MAX_TIMEOUT_MS = 600000; // 最大超时毫秒数 10分钟
|
|
14
6
|
exports.DEFAULT_TIMEOUT_MS = 120000; // 默认超时毫秒数 2分钟
|
|
15
7
|
exports.TOOL_NAME_FOR_PROMPT = 'Bash';
|
|
16
|
-
exports.DESCRIPTION = `Executes a given bash command
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
- Try to maintain your current working directory throughout the session by using absolute paths and avoiding usage of \`cd\`. You may use \`cd\` if the User explicitly requests it.
|
|
55
|
-
<good-example>
|
|
56
|
-
pytest /foo/bar/tests
|
|
57
|
-
</good-example>
|
|
58
|
-
<bad-example>
|
|
59
|
-
cd /foo/bar && pytest tests
|
|
60
|
-
</bad-example>
|
|
8
|
+
exports.DESCRIPTION = `Executes a given bash command and returns its output.
|
|
9
|
+
|
|
10
|
+
The working directory persists between commands, but shell state does not. The shell environment is initialized from the user's profile (bash or zsh).
|
|
11
|
+
|
|
12
|
+
IMPORTANT: Avoid using this tool to run \`find\`, \`grep\`, \`cat\`, \`head\`, \`tail\`, \`sed\`, \`awk\`, or \`echo\` commands, unless explicitly instructed or after you have verified that a dedicated tool cannot accomplish your task. Instead, use the appropriate dedicated tool as this will provide a much better experience for the user:
|
|
13
|
+
|
|
14
|
+
- File search: Use Glob (NOT find or ls)
|
|
15
|
+
- Content search: Use Grep (NOT grep or rg)
|
|
16
|
+
- Read files: Use Read (NOT cat/head/tail)
|
|
17
|
+
- Edit files: Use Edit (NOT sed/awk)
|
|
18
|
+
- Write files: Use Write (NOT echo >/cat <<EOF)
|
|
19
|
+
- Communication: Output text directly (NOT echo/printf)
|
|
20
|
+
While the Bash tool can do similar things, it’s better to use the built-in tools as they provide a better user experience and make it easier to review tool calls and give permission.
|
|
21
|
+
|
|
22
|
+
# Instructions
|
|
23
|
+
- If your command will create new directories or files, first use this tool to run \`ls\` to verify the parent directory exists and is the correct location.
|
|
24
|
+
- Always quote file paths that contain spaces with double quotes in your command (e.g., cd "path with spaces/file.txt")
|
|
25
|
+
- Try to maintain your current working directory throughout the session by using absolute paths and avoiding usage of \`cd\`. You may use \`cd\` if the User explicitly requests it.
|
|
26
|
+
- You may specify an optional timeout in milliseconds (up to ${exports.MAX_TIMEOUT_MS}ms / ${exports.MAX_TIMEOUT_MS / 60000} minutes). By default, your command will timeout after ${exports.DEFAULT_TIMEOUT_MS}ms (${exports.DEFAULT_TIMEOUT_MS / 60000} minutes).
|
|
27
|
+
- You can use the \`run_in_background\` parameter to run the command in the background. Only use this if you don't need the result immediately and are OK being notified when the command completes later. You do not need to check the output right away - you'll be notified when it finishes. You do not need to use '&' at the end of the command when using this parameter.
|
|
28
|
+
- Write a clear, concise description of what your command does. For simple commands, keep it brief (5-10 words). For complex commands (piped commands, obscure flags, or anything hard to understand at a glance), include enough context so that the user can understand what your command will do.
|
|
29
|
+
- When issuing multiple commands:
|
|
30
|
+
- If the commands are independent and can run in parallel, make multiple Bash tool calls in a single message. Example: if you need to run "git status" and "git diff", send a single message with two Bash tool calls in parallel.
|
|
31
|
+
- If the commands depend on each other and must run sequentially, use a single Bash call with '&&' to chain them together.
|
|
32
|
+
- Use ';' only when you need to run commands sequentially but don't care if earlier commands fail.
|
|
33
|
+
- DO NOT use newlines to separate commands (newlines are ok in quoted strings).
|
|
34
|
+
- For git commands:
|
|
35
|
+
- Prefer to create a new commit rather than amending an existing commit.
|
|
36
|
+
- Before running destructive operations (e.g., git reset --hard, git push --force, git checkout --), consider whether there is a safer alternative that achieves the same goal. Only use destructive operations when they are truly the best approach.
|
|
37
|
+
- Never skip hooks (--no-verify) or bypass signing (--no-gpg-sign, -c commit.gpgsign=false) unless the user has explicitly asked for it. If a hook fails, investigate and fix the underlying issue.
|
|
38
|
+
- Avoid unnecessary \`sleep\` commands:
|
|
39
|
+
- Do not sleep between commands that can run immediately — just run them.
|
|
40
|
+
- If your command is long running and you would like to be notified when it finishes – simply run your command using \`run_in_background\`. There is no need to sleep in this case.
|
|
41
|
+
- Do not retry failing commands in a sleep loop — diagnose the root cause or consider an alternative approach.
|
|
42
|
+
- If waiting for a background task you started with \`run_in_background\`, you will be notified when it completes — do not poll.
|
|
43
|
+
- If you must poll an external process, use a check command (e.g. \`gh run view\`) rather than sleeping first.
|
|
44
|
+
- If you must sleep, keep the duration short (1-5 seconds) to avoid blocking the user.
|
|
45
|
+
|
|
61
46
|
|
|
62
47
|
# Committing changes with git
|
|
63
48
|
|
|
@@ -65,15 +50,15 @@ Only create commits when requested by the user. If unclear, ask first. When the
|
|
|
65
50
|
|
|
66
51
|
Git Safety Protocol:
|
|
67
52
|
- NEVER update the git config
|
|
68
|
-
- NEVER run destructive
|
|
53
|
+
- NEVER run destructive git commands (push --force, reset --hard, checkout ., restore ., clean -f, branch -D) unless the user explicitly requests these actions. Taking unauthorized destructive actions is unhelpful and can result in lost work, so it's best to ONLY run these commands when given direct instructions
|
|
69
54
|
- NEVER skip hooks (--no-verify, --no-gpg-sign, etc) unless the user explicitly requests it
|
|
70
55
|
- NEVER run force push to main/master, warn the user if they request it
|
|
71
|
-
-
|
|
72
|
-
-
|
|
73
|
-
- NEVER commit changes unless the user explicitly asks you to. It is VERY IMPORTANT to only commit when explicitly asked, otherwise the user will feel that you are being too proactive
|
|
56
|
+
- CRITICAL: Always create NEW commits rather than amending, unless the user explicitly requests a git amend. When a pre-commit hook fails, the commit did NOT happen — so --amend would modify the PREVIOUS commit, which may result in destroying work or losing previous changes. Instead, after hook failure, fix the issue, re-stage, and create a NEW commit
|
|
57
|
+
- When staging files, prefer adding specific files by name rather than using "git add -A" or "git add .", which can accidentally include sensitive files (.env, credentials) or large binaries
|
|
58
|
+
- NEVER commit changes unless the user explicitly asks you to. It is VERY IMPORTANT to only commit when explicitly asked, otherwise the user will feel that you are being too proactive
|
|
74
59
|
|
|
75
60
|
1. You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel for optimal performance. run the following bash commands in parallel, each using the Bash tool:
|
|
76
|
-
- Run a git status command to see all untracked files.
|
|
61
|
+
- Run a git status command to see all untracked files. IMPORTANT: Never use the -uall flag as it can cause memory issues on large repos.
|
|
77
62
|
- Run a git diff command to see both staged and unstaged changes that will be committed.
|
|
78
63
|
- Run a git log command to see recent commit messages, so that you can follow this repository's commit message style.
|
|
79
64
|
2. Analyze all staged changes (both previously staged and newly added) and draft a commit message:
|
|
@@ -84,28 +69,24 @@ Git Safety Protocol:
|
|
|
84
69
|
3. You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel for optimal performance. run the following commands:
|
|
85
70
|
- Add relevant untracked files to the staging area.
|
|
86
71
|
- Create the commit with a message ending with:
|
|
87
|
-
|
|
88
|
-
|
|
72
|
+
Co-Authored-By: [${product_1.PRODUCT_NAME}](${product_1.PRODUCT_URL})
|
|
89
73
|
- Run git status after the commit completes to verify success.
|
|
90
74
|
Note: git status depends on the commit completing, so run it sequentially after the commit.
|
|
91
|
-
4. If the commit fails due to pre-commit hook
|
|
92
|
-
- Check authorship: git log -1 --format='%an %ae'
|
|
93
|
-
- Check not pushed: git status shows "Your branch is ahead"
|
|
94
|
-
- If both true: amend your commit. Otherwise: create NEW commit (never amend other developers' commits)
|
|
75
|
+
4. If the commit fails due to pre-commit hook: fix the issue and create a NEW commit
|
|
95
76
|
|
|
96
77
|
Important notes:
|
|
97
78
|
- NEVER run additional commands to read or explore code, besides git bash commands
|
|
98
|
-
- NEVER use the
|
|
79
|
+
- NEVER use the Task or Agent tools
|
|
99
80
|
- DO NOT push to the remote repository unless the user explicitly asks you to do so
|
|
100
81
|
- IMPORTANT: Never use git commands with the -i flag (like git rebase -i or git add -i) since they require interactive input which is not supported.
|
|
82
|
+
- IMPORTANT: Do not use --no-edit with git rebase commands, as the --no-edit flag is not a valid option for git rebase.
|
|
101
83
|
- If there are no changes to commit (i.e., no untracked files and no modifications), do not create an empty commit
|
|
102
84
|
- In order to ensure good formatting, ALWAYS pass the commit message via a HEREDOC, a la this example:
|
|
103
85
|
<example>
|
|
104
86
|
git commit -m "$(cat <<'EOF'
|
|
105
87
|
Commit message here.
|
|
106
88
|
|
|
107
|
-
|
|
108
|
-
|
|
89
|
+
Co-Authored-By: [${product_1.PRODUCT_NAME}](${product_1.PRODUCT_URL})
|
|
109
90
|
EOF
|
|
110
91
|
)"
|
|
111
92
|
</example>
|
|
@@ -116,11 +97,13 @@ Use the gh command via the Bash tool for ALL GitHub-related tasks including work
|
|
|
116
97
|
IMPORTANT: When the user asks you to create a pull request, follow these steps carefully:
|
|
117
98
|
|
|
118
99
|
1. You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel for optimal performance. run the following bash commands in parallel using the Bash tool, in order to understand the current state of the branch since it diverged from the main branch:
|
|
119
|
-
- Run a git status command to see all untracked files
|
|
100
|
+
- Run a git status command to see all untracked files (never use -uall flag)
|
|
120
101
|
- Run a git diff command to see both staged and unstaged changes that will be committed
|
|
121
102
|
- Check if the current branch tracks a remote branch and is up to date with the remote, so you know if you need to push to the remote
|
|
122
103
|
- Run a git log command and \`git diff [base-branch]...HEAD\` to understand the full commit history for the current branch (from the time it diverged from the base branch)
|
|
123
|
-
2. Analyze all changes that will be included in the pull request, making sure to look at all relevant commits (NOT just the latest commit, but ALL commits that will be included in the pull request!!!), and draft a pull request summary
|
|
104
|
+
2. Analyze all changes that will be included in the pull request, making sure to look at all relevant commits (NOT just the latest commit, but ALL commits that will be included in the pull request!!!), and draft a pull request title and summary:
|
|
105
|
+
- Keep the PR title short (under 70 characters)
|
|
106
|
+
- Use the description/body for details, not the title
|
|
124
107
|
3. You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel for optimal performance. run the following commands in parallel:
|
|
125
108
|
- Create new branch if needed
|
|
126
109
|
- Push to remote with -u flag if needed
|
|
@@ -139,7 +122,7 @@ EOF
|
|
|
139
122
|
</example>
|
|
140
123
|
|
|
141
124
|
Important:
|
|
142
|
-
- DO NOT use the
|
|
125
|
+
- DO NOT use the Task or Agent tools
|
|
143
126
|
- Return the PR URL when you're done, so the user can see it
|
|
144
127
|
|
|
145
128
|
# Other common operations
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../src/tools/Bash/prompt.ts"],"names":[],"mappings":";;;AAAA,qDAAmE;
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../src/tools/Bash/prompt.ts"],"names":[],"mappings":";;;AAAA,qDAAmE;AAEtD,QAAA,cAAc,GAAG,MAAM,CAAC,CAAC,eAAe;AACxC,QAAA,kBAAkB,GAAG,MAAM,CAAC,CAAC,cAAc;AAE3C,QAAA,oBAAoB,GAAG,MAAM,CAAA;AAE7B,QAAA,WAAW,GAAW;;;;;;;;;;;;;;;;;;gEAkB6B,sBAAc,QAAQ,sBAAc,GAAG,KAAK,0DAA0D,0BAAkB,OAAO,0BAAkB,GAAG,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBA8CnM,sBAAY,KAAK,qBAAW;;;;;;;;;;;;;;;;;sBAiB5B,sBAAY,KAAK,qBAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBA8B7B,sBAAY,KAAK,qBAAW;;;;;;;;;;wEAUuB,CAAA"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
export declare
|
|
1
|
+
export declare const STDOUT_HEAD_TAIL_LINES = 500;
|
|
2
|
+
export declare const STDERR_HEAD_TAIL_LINES = 50;
|
|
3
|
+
export declare function formatOutput(content: string, headTailLines?: number, { resolveCR }?: {
|
|
4
|
+
resolveCR?: boolean;
|
|
5
|
+
}): {
|
|
2
6
|
totalLines: number;
|
|
3
7
|
truncatedContent: string;
|
|
4
8
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/tools/Bash/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/tools/Bash/utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,MAAM,CAAA;AACzC,eAAO,MAAM,sBAAsB,KAAK,CAAA;AAsBxC,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,SAAyB,EAAE,EAAE,SAAgB,EAAE,GAAE;IAAE,SAAS,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG;IACzI,UAAU,EAAE,MAAM,CAAA;IAClB,gBAAgB,EAAE,MAAM,CAAA;CACzB,CAoBA"}
|
package/dist/tools/Bash/utils.js
CHANGED
|
@@ -1,12 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.STDERR_HEAD_TAIL_LINES = exports.STDOUT_HEAD_TAIL_LINES = void 0;
|
|
3
4
|
exports.formatOutput = formatOutput;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
exports.STDOUT_HEAD_TAIL_LINES = 500;
|
|
6
|
+
exports.STDERR_HEAD_TAIL_LINES = 50;
|
|
7
|
+
const MAX_LINE_LENGTH = 2000;
|
|
8
|
+
/**
|
|
9
|
+
* 处理 \r(回车符):模拟终端行为,只保留每行最后一次 \r 后的内容。
|
|
10
|
+
* 进度条等工具用 \r 覆盖同一行,原始内容会变成超长单行,
|
|
11
|
+
* 这里将其还原为终端实际显示的最终状态。
|
|
12
|
+
*/
|
|
13
|
+
function resolveCarriageReturns(content) {
|
|
14
|
+
return content.split('\n').map(line => {
|
|
15
|
+
if (!line.includes('\r'))
|
|
16
|
+
return line;
|
|
17
|
+
const parts = line.split('\r');
|
|
18
|
+
return parts[parts.length - 1];
|
|
19
|
+
}).join('\n');
|
|
20
|
+
}
|
|
21
|
+
function truncateLines(lines) {
|
|
22
|
+
return lines.map(l => l.length > MAX_LINE_LENGTH ? l.slice(0, MAX_LINE_LENGTH) + '...[line truncated]' : l);
|
|
23
|
+
}
|
|
24
|
+
function formatOutput(content, headTailLines = exports.STDOUT_HEAD_TAIL_LINES, { resolveCR = true } = {}) {
|
|
25
|
+
const text = resolveCR ? resolveCarriageReturns(content) : content;
|
|
26
|
+
const lines = truncateLines(text.split('\n'));
|
|
7
27
|
const totalLines = lines.length;
|
|
8
28
|
if (totalLines <= headTailLines * 2) {
|
|
9
|
-
return { totalLines, truncatedContent:
|
|
29
|
+
return { totalLines, truncatedContent: lines.join('\n') };
|
|
10
30
|
}
|
|
11
31
|
const firstLines = lines.slice(0, headTailLines);
|
|
12
32
|
const lastLines = lines.slice(-headTailLines);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/tools/Bash/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/tools/Bash/utils.ts"],"names":[],"mappings":";;;AAuBA,oCAuBC;AA9CY,QAAA,sBAAsB,GAAG,GAAG,CAAA;AAC5B,QAAA,sBAAsB,GAAG,EAAE,CAAA;AACxC,MAAM,eAAe,GAAG,IAAI,CAAA;AAE5B;;;;GAIG;AACH,SAAS,sBAAsB,CAAC,OAAe;IAC7C,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QACpC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,CAAA;QACrC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAC9B,OAAO,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IAChC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACf,CAAC;AAED,SAAS,aAAa,CAAC,KAAe;IACpC,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CACnB,CAAC,CAAC,MAAM,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,eAAe,CAAC,GAAG,qBAAqB,CAAC,CAAC,CAAC,CAAC,CACrF,CAAA;AACH,CAAC;AAED,SAAgB,YAAY,CAAC,OAAe,EAAE,aAAa,GAAG,8BAAsB,EAAE,EAAE,SAAS,GAAG,IAAI,KAA8B,EAAE;IAItI,MAAM,IAAI,GAAG,SAAS,CAAC,CAAC,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAA;IAClE,MAAM,KAAK,GAAG,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;IAC7C,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAA;IAE/B,IAAI,UAAU,IAAI,aAAa,GAAG,CAAC,EAAE,CAAC;QACpC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAA;IAC3D,CAAC;IAED,MAAM,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,aAAa,CAAC,CAAA;IAChD,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,aAAa,CAAC,CAAA;IAC7C,MAAM,YAAY,GAAG,UAAU,GAAG,aAAa,GAAG,CAAC,CAAA;IAEnD,MAAM,gBAAgB,GAAG;QACvB,GAAG,UAAU;QACb,UAAU,YAAY,yBAAyB;QAC/C,GAAG,SAAS;KACb,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAEZ,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,CAAA;AACzC,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
declare const inputSchema: z.ZodObject<{
|
|
3
|
+
cron: z.ZodString;
|
|
4
|
+
prompt: z.ZodString;
|
|
5
|
+
recurring: z.ZodOptional<z.ZodBoolean>;
|
|
6
|
+
durable: z.ZodOptional<z.ZodBoolean>;
|
|
7
|
+
}, "strict", z.ZodTypeAny, {
|
|
8
|
+
cron: string;
|
|
9
|
+
prompt: string;
|
|
10
|
+
recurring?: boolean | undefined;
|
|
11
|
+
durable?: boolean | undefined;
|
|
12
|
+
}, {
|
|
13
|
+
cron: string;
|
|
14
|
+
prompt: string;
|
|
15
|
+
recurring?: boolean | undefined;
|
|
16
|
+
durable?: boolean | undefined;
|
|
17
|
+
}>;
|
|
18
|
+
type Out = {
|
|
19
|
+
id: string;
|
|
20
|
+
cron: string;
|
|
21
|
+
prompt: string;
|
|
22
|
+
humanSchedule: string;
|
|
23
|
+
recurring: boolean;
|
|
24
|
+
durable: boolean;
|
|
25
|
+
};
|
|
26
|
+
export declare const CronCreateTool: {
|
|
27
|
+
name: string;
|
|
28
|
+
description(): string;
|
|
29
|
+
inputSchema: z.ZodObject<{
|
|
30
|
+
cron: z.ZodString;
|
|
31
|
+
prompt: z.ZodString;
|
|
32
|
+
recurring: z.ZodOptional<z.ZodBoolean>;
|
|
33
|
+
durable: z.ZodOptional<z.ZodBoolean>;
|
|
34
|
+
}, "strict", z.ZodTypeAny, {
|
|
35
|
+
cron: string;
|
|
36
|
+
prompt: string;
|
|
37
|
+
recurring?: boolean | undefined;
|
|
38
|
+
durable?: boolean | undefined;
|
|
39
|
+
}, {
|
|
40
|
+
cron: string;
|
|
41
|
+
prompt: string;
|
|
42
|
+
recurring?: boolean | undefined;
|
|
43
|
+
durable?: boolean | undefined;
|
|
44
|
+
}>;
|
|
45
|
+
isReadOnly(): false;
|
|
46
|
+
canRunConcurrently(): true;
|
|
47
|
+
validateInput(input: z.infer<typeof inputSchema>, agentContext: any): Promise<{
|
|
48
|
+
result: false;
|
|
49
|
+
message: string;
|
|
50
|
+
} | {
|
|
51
|
+
result: true;
|
|
52
|
+
message?: undefined;
|
|
53
|
+
}>;
|
|
54
|
+
genResultForAssistant(data: Out): string;
|
|
55
|
+
genToolResultMessage(output: Out): {
|
|
56
|
+
title: string;
|
|
57
|
+
summary: string;
|
|
58
|
+
content: string;
|
|
59
|
+
};
|
|
60
|
+
getDisplayTitle(input: any): string;
|
|
61
|
+
call({ cron, prompt, recurring, durable }: z.infer<typeof inputSchema>, _agentContext: any): AsyncGenerator<{
|
|
62
|
+
type: "result";
|
|
63
|
+
data: Out;
|
|
64
|
+
resultForAssistant: string;
|
|
65
|
+
}, void, unknown>;
|
|
66
|
+
};
|
|
67
|
+
export {};
|
|
68
|
+
//# sourceMappingURL=CronCreate.d.ts.map
|