repoburg 1.3.20 → 1.3.21

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.
Files changed (46) hide show
  1. package/backend/.env +2 -2
  2. package/backend/.repoburg/hooks/README.md +53 -0
  3. package/backend/.repoburg/hooks/eslint-hook.ts +46 -0
  4. package/backend/.repoburg/hooks/example-hook.ts +62 -0
  5. package/backend/dist/src/app.module.js +4 -0
  6. package/backend/dist/src/app.module.js.map +1 -1
  7. package/backend/dist/src/core-entities/index.d.ts +1 -0
  8. package/backend/dist/src/core-entities/index.js +1 -0
  9. package/backend/dist/src/core-entities/index.js.map +1 -1
  10. package/backend/dist/src/core-entities/tool-hook.entity.d.ts +7 -0
  11. package/backend/dist/src/core-entities/tool-hook.entity.js +37 -0
  12. package/backend/dist/src/core-entities/tool-hook.entity.js.map +1 -0
  13. package/backend/dist/src/llm-orchestration/llm-orchestration.interfaces.d.ts +1 -1
  14. package/backend/dist/src/llm-orchestration/llm-orchestration.module.js +87 -50
  15. package/backend/dist/src/llm-orchestration/llm-orchestration.module.js.map +1 -1
  16. package/backend/dist/src/llm-orchestration/llm-turn-processor.service.d.ts +3 -1
  17. package/backend/dist/src/llm-orchestration/llm-turn-processor.service.js +70 -2
  18. package/backend/dist/src/llm-orchestration/llm-turn-processor.service.js.map +1 -1
  19. package/backend/dist/src/seeding/data/system-prompts/default_master-agent.d.ts +1 -1
  20. package/backend/dist/src/seeding/data/system-prompts/default_master-agent.js +2 -2
  21. package/backend/dist/src/seeding/data/tool-hooks/eslint-hook.d.ts +2 -0
  22. package/backend/dist/src/seeding/data/tool-hooks/eslint-hook.js +52 -0
  23. package/backend/dist/src/seeding/data/tool-hooks/eslint-hook.js.map +1 -0
  24. package/backend/dist/src/seeding/data/tool-hooks/example-hook.d.ts +2 -0
  25. package/backend/dist/src/seeding/data/tool-hooks/example-hook.js +68 -0
  26. package/backend/dist/src/seeding/data/tool-hooks/example-hook.js.map +1 -0
  27. package/backend/dist/src/seeding/data/tool-hooks/readme.d.ts +2 -0
  28. package/backend/dist/src/seeding/data/tool-hooks/readme.js +59 -0
  29. package/backend/dist/src/seeding/data/tool-hooks/readme.js.map +1 -0
  30. package/backend/dist/src/tool-hooks/dto/create-tool-hook.dto.d.ts +6 -0
  31. package/backend/dist/src/tool-hooks/dto/create-tool-hook.dto.js +36 -0
  32. package/backend/dist/src/tool-hooks/dto/create-tool-hook.dto.js.map +1 -0
  33. package/backend/dist/src/tool-hooks/dto/update-tool-hook.dto.d.ts +6 -0
  34. package/backend/dist/src/tool-hooks/dto/update-tool-hook.dto.js +38 -0
  35. package/backend/dist/src/tool-hooks/dto/update-tool-hook.dto.js.map +1 -0
  36. package/backend/dist/src/tool-hooks/tool-hooks.controller.d.ts +27 -0
  37. package/backend/dist/src/tool-hooks/tool-hooks.controller.js +123 -0
  38. package/backend/dist/src/tool-hooks/tool-hooks.controller.js.map +1 -0
  39. package/backend/dist/src/tool-hooks/tool-hooks.module.d.ts +2 -0
  40. package/backend/dist/src/tool-hooks/tool-hooks.module.js +27 -0
  41. package/backend/dist/src/tool-hooks/tool-hooks.module.js.map +1 -0
  42. package/backend/dist/src/tool-hooks/tool-hooks.service.d.ts +31 -0
  43. package/backend/dist/src/tool-hooks/tool-hooks.service.js +337 -0
  44. package/backend/dist/src/tool-hooks/tool-hooks.service.js.map +1 -0
  45. package/backend/dist/tsconfig.build.tsbuildinfo +1 -1
  46. package/package.json +3 -3
package/backend/.env CHANGED
@@ -1,5 +1,5 @@
1
1
  #REPOBURG_PROJECT_PATH='/Users/celalertug/WebstormProjects/hihiho'
2
- REPOBURG_PROJECT_PATH='/Users/celalertug/github/webcoder'
2
+ #REPOBURG_PROJECT_PATH='/Users/celalertug/github/webcoder'
3
3
  #REPOBURG_PROJECT_PATH='/Users/celalertug/WebstormProjects/appdb'
4
4
  #REPOBURG_PROJECT_PATH='/tmp/a/cleanappdev'
5
5
  #REPOBURG_PROJECT_PATH='/Users/celalertug/everest/cleanappdev'
@@ -7,7 +7,7 @@ REPOBURG_PROJECT_PATH='/Users/celalertug/github/webcoder'
7
7
 
8
8
  #react project
9
9
  #REPOBURG_PROJECT_PATH='/Users/celalertug/WebstormProjects/ttt1234'
10
- #REPOBURG_PROJECT_PATH=/Users/celalertug/Desktop/tmp/repoburg-preview-boilerplate-main
10
+ REPOBURG_PROJECT_PATH=/Users/celalertug/Desktop/tmp/repoburg-preview-boilerplate-main
11
11
 
12
12
  #modern football
13
13
  #REPOBURG_PROJECT_PATH=/Users/celalertug/WebstormProjects/fm1
@@ -0,0 +1,53 @@
1
+ # Repoburg Tool Hooks
2
+
3
+ This directory contains TypeScript scripts that can be attached to AI tool execution events.
4
+ You can configure these hooks in the "Tool Hooks" section of the Repoburg UI.
5
+
6
+ ## How it works
7
+
8
+ 1. **Create a script** in this folder (e.g., `audit-patch.ts`).
9
+ 2. **Go to UI**: Open Repoburg -> Tool Hooks -> Add Hook.
10
+ 3. **Configure**: Select the tool (e.g., `patch`), timing (`before` or `after`), and your script.
11
+
12
+ ## Script Interface
13
+
14
+ Your script must **export a default function** that receives the context.
15
+
16
+ ### Input Context
17
+
18
+ ```typescript
19
+ interface HookContext {
20
+ hook_type: 'before' | 'after';
21
+
22
+ action: {
23
+ tool_name: string; // e.g. "patch"
24
+ args: any; // e.g. { file_path: "src/app.ts", patch_code: "..." }
25
+
26
+ // Only present for 'after' hooks
27
+ result?: {
28
+ status: 'SUCCESS' | 'FAILURE';
29
+ output?: string;
30
+ error?: string;
31
+ };
32
+ };
33
+
34
+ plan_context: any; // Shared state of the current AI plan
35
+ }
36
+ ```
37
+
38
+ ### Output Format
39
+
40
+ Your function should return an object (or void if passive):
41
+
42
+ ```typescript
43
+ interface HookOutput {
44
+ // If true, the AI plan stops immediately.
45
+ should_halt_plan?: boolean;
46
+
47
+ // Optional message to log in the UI
48
+ message?: string;
49
+
50
+ // Optional data to merge back into the plan context
51
+ update_context?: Record<string, any>;
52
+ }
53
+ ```
@@ -0,0 +1,46 @@
1
+ /**
2
+ * ESLint Validation Hook
3
+ *
4
+ * Usage: Attach as 'after' hook to 'create_file', 'edit_file', 'patch'.
5
+ */
6
+ import { exec } from 'child_process';
7
+ import { promisify } from 'util';
8
+
9
+ const execAsync = promisify(exec);
10
+
11
+ // Redefining types locally since this runs in a standalone VM context
12
+ export interface HookContext {
13
+ action: {
14
+ tool_name: string;
15
+ args: { file_path?: string; [key: string]: any };
16
+ };
17
+ plan_context: {
18
+ feedback: {
19
+ validationErrors: Array<{ tool_name: string; error: string }>;
20
+ };
21
+ };
22
+ }
23
+
24
+ export default async function(context: HookContext) {
25
+ const filePath = context.action.args.file_path;
26
+ if (!filePath) return;
27
+
28
+ console.log(`[Hook] Running ESLint on ${filePath}`);
29
+
30
+ try {
31
+ // Adjust command as needed for your project structure
32
+ // We use --no-color to keep the error message clean for the AI
33
+ await execAsync(`npx eslint "${filePath}" --no-color`);
34
+ } catch (e: any) {
35
+ const errorOutput = e.stdout || e.stderr || e.message;
36
+
37
+ console.log(`[Hook] ESLint failed for ${filePath}`);
38
+
39
+ // Inject error into the shared plan context
40
+ // The orchestration engine will pick this up and present it to the AI in the next turn (or immediate feedback)
41
+ context.plan_context.feedback.validationErrors.push({
42
+ tool_name: context.action.tool_name,
43
+ error: `ESLint check failed:\n${errorOutput}`
44
+ });
45
+ }
46
+ }
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Example Hook Script
3
+ *
4
+ * Usage:
5
+ * 1. Attach to 'patch' or 'edit_file' tool as a 'before' hook.
6
+ * 2. It will block edits to any file with 'lock' in the name.
7
+ */
8
+
9
+ // --- Type Definitions ---
10
+
11
+ export interface HookAction {
12
+ tool_name: string;
13
+ args: Record<string, any>;
14
+ // Only present for 'after' hooks
15
+ result?: {
16
+ status: 'SUCCESS' | 'FAILURE';
17
+ output?: string;
18
+ error?: string;
19
+ };
20
+ }
21
+
22
+ export interface HookContext {
23
+ hook_type: 'before' | 'after';
24
+ action: HookAction;
25
+ plan_context: any; // Shared state of the current AI plan
26
+ }
27
+
28
+ export interface HookOutput {
29
+ // If true, the AI plan stops immediately.
30
+ should_halt_plan?: boolean;
31
+
32
+ // Optional message to log in the UI
33
+ message?: string;
34
+
35
+ // Optional data to merge back into the plan context
36
+ update_context?: Record<string, any>;
37
+ }
38
+
39
+ // --- Hook Logic ---
40
+
41
+ export default async function(context: HookContext): Promise<HookOutput | void> {
42
+ // 1. Extract Data
43
+ const filePath = context.action?.args?.file_path || '';
44
+
45
+ // Log to console (appears in backend logs)
46
+ console.log(`[Hook] analyzing action on: ${filePath}`);
47
+
48
+ // 2. Logic
49
+ if (filePath.includes('lock')) {
50
+ // Return Halt Signal
51
+ return {
52
+ should_halt_plan: true,
53
+ message: `BLOCKED: Editing files with "lock" in the name is forbidden by policy. File: ${filePath}`
54
+ };
55
+ } else {
56
+ // Return Pass Signal
57
+ return {
58
+ should_halt_plan: false,
59
+ message: `Hook allowed action on ${filePath}`
60
+ };
61
+ }
62
+ }
@@ -35,6 +35,8 @@ const chat_module_1 = require("./interactive-chat/chat.module");
35
35
  const mcp_module_1 = require("./mcp/mcp.module");
36
36
  const visual_editor_module_1 = require("./visual-editor/visual-editor.module");
37
37
  const custom_variables_module_1 = require("./custom-variables/custom-variables.module");
38
+ const tool_hooks_module_1 = require("./tool-hooks/tool-hooks.module");
39
+ const core_entities_2 = require("./core-entities");
38
40
  let dbPath = ':memory:';
39
41
  if (process.env.NODE_ENV === 'production') {
40
42
  const projectPath = process.env.REPOBURG_PROJECT_PATH || process.cwd();
@@ -68,6 +70,7 @@ exports.AppModule = AppModule = __decorate([
68
70
  core_entities_1.McpConfig,
69
71
  core_entities_1.McpTool,
70
72
  core_entities_1.CustomVariable,
73
+ core_entities_2.ToolHook,
71
74
  ],
72
75
  synchronize: true,
73
76
  autoLoadEntities: true,
@@ -93,6 +96,7 @@ exports.AppModule = AppModule = __decorate([
93
96
  mcp_module_1.McpModule,
94
97
  visual_editor_module_1.VisualEditorModule,
95
98
  custom_variables_module_1.CustomVariablesModule,
99
+ tool_hooks_module_1.ToolHooksModule,
96
100
  ],
97
101
  controllers: [app_controller_1.AppController],
98
102
  providers: [app_service_1.AppService],
@@ -1 +1 @@
1
- {"version":3,"file":"app.module.js","sourceRoot":"","sources":["../../src/app.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,qDAAiD;AACjD,+CAA2C;AAC3C,6CAAgD;AAChD,mDAcyB;AACzB,gEAA4D;AAC5D,gEAA4D;AAC5D,kFAA6E;AAC7E,sEAAiE;AACjE,kFAA6E;AAC7E,2FAAsF;AACtF,8FAAyF;AACzF,kFAA6E;AAC7E,6DAAyD;AACzD,mEAA+D;AAC/D,qFAAgF;AAChF,6BAA6B;AAC7B,yBAAyB;AACzB,wFAAmF;AACnF,wFAAmF;AACnF,2FAAsF;AACtF,+EAA0E;AAC1E,0DAAsD;AACtD,wFAAmF;AACnF,gEAAuE;AACvE,iDAA6C;AAC7C,+EAA0E;AAC1E,wFAAmF;AAEnF,IAAI,MAAM,GAAG,UAAU,CAAC;AAExB,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE,CAAC;IAC1C,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IACvE,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IAClD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3C,CAAC;IACD,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;IACzC,OAAO,CAAC,GAAG,CAAC,iCAAiC,MAAM,EAAE,CAAC,CAAC;AACzD,CAAC;AAkDM,IAAM,SAAS,GAAf,MAAM,SAAS;CAAG,CAAA;AAAZ,8BAAS;oBAAT,SAAS;IAhDrB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,uBAAa,CAAC,OAAO,CAAC;gBACpB,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,MAAM;gBAChB,QAAQ,EAAE;oBACR,uBAAO;oBACP,uBAAO;oBACP,+BAAe;oBACf,4BAAY;oBACZ,wBAAQ;oBACR,4BAAY;oBACZ,4BAAY;oBACZ,6BAAa;oBACb,gCAAgB;oBAChB,8BAAc;oBACd,yBAAS;oBACT,uBAAO;oBACP,8BAAc;iBACf;gBACD,WAAW,EAAE,IAAI;gBACjB,gBAAgB,EAAE,IAAI;aACvB,CAAC;YACF,gCAAc;YACd,gCAAc;YACd,2CAAmB;YACnB,mCAAe;YACf,2CAAmB;YACnB,iDAAsB;YACtB,mDAAuB;YACvB,2CAAmB;YACnB,8BAAa;YACb,kCAAe;YACf,6CAAoB;YACpB,+CAAqB;YACrB,+CAAqB;YACrB,iDAAsB;YACtB,yCAAkB;YAClB,4BAAY;YACZ,+CAAqB;YACrB,mCAAqB;YACrB,sBAAS;YACT,yCAAkB;YAClB,+CAAqB;SACtB;QACD,WAAW,EAAE,CAAC,8BAAa,CAAC;QAC5B,SAAS,EAAE,CAAC,wBAAU,CAAC;KACxB,CAAC;GACW,SAAS,CAAG"}
1
+ {"version":3,"file":"app.module.js","sourceRoot":"","sources":["../../src/app.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,qDAAiD;AACjD,+CAA2C;AAC3C,6CAAgD;AAChD,mDAcyB;AACzB,gEAA4D;AAC5D,gEAA4D;AAC5D,kFAA6E;AAC7E,sEAAiE;AACjE,kFAA6E;AAC7E,2FAAsF;AACtF,8FAAyF;AACzF,kFAA6E;AAC7E,6DAAyD;AACzD,mEAA+D;AAC/D,qFAAgF;AAChF,6BAA6B;AAC7B,yBAAyB;AACzB,wFAAmF;AACnF,wFAAmF;AACnF,2FAAsF;AACtF,+E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mB;YACnB,mCAAe;YACf,2CAAmB;YACnB,iDAAsB;YACtB,mDAAuB;YACvB,2CAAmB;YACnB,8BAAa;YACb,kCAAe;YACf,6CAAoB;YACpB,+CAAqB;YACrB,+CAAqB;YACrB,iDAAsB;YACtB,yCAAkB;YAClB,4BAAY;YACZ,+CAAqB;YACrB,mCAAqB;YACrB,sBAAS;YACT,yCAAkB;YAClB,+CAAqB;YACrB,mCAAe;SAChB;QACD,WAAW,EAAE,CAAC,8BAAa,CAAC;QAC5B,SAAS,EAAE,CAAC,wBAAU,CAAC;KACxB,CAAC;GACW,SAAS,CAAG"}
@@ -12,3 +12,4 @@ export * from './context-snippet.entity';
12
12
  export * from './mcp-config.entity';
13
13
  export * from './mcp-tool.entity';
14
14
  export * from './custom-variable.entity';
15
+ export * from './tool-hook.entity';
@@ -28,4 +28,5 @@ __exportStar(require("./context-snippet.entity"), exports);
28
28
  __exportStar(require("./mcp-config.entity"), exports);
29
29
  __exportStar(require("./mcp-tool.entity"), exports);
30
30
  __exportStar(require("./custom-variable.entity"), exports);
31
+ __exportStar(require("./tool-hook.entity"), exports);
31
32
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core-entities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,mDAAiC;AACjC,mDAAiC;AACjC,4DAA0C;AAC1C,yDAAuC;AACvC,qDAAmC;AACnC,yDAAuC;AACvC,yDAAuC;AACvC,0DAAwC;AACxC,6DAA2C;AAC3C,2DAAyC;AACzC,sDAAoC;AACpC,oDAAkC;AAClC,2DAAyC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core-entities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,mDAAiC;AACjC,mDAAiC;AACjC,4DAA0C;AAC1C,yDAAuC;AACvC,qDAAmC;AACnC,yDAAuC;AACvC,yDAAuC;AACvC,0DAAwC;AACxC,6DAA2C;AAC3C,2DAAyC;AACzC,sDAAoC;AACpC,oDAAkC;AAClC,2DAAyC;AACzC,qDAAmC"}
@@ -0,0 +1,7 @@
1
+ import { BaseEntity } from './base.entity';
2
+ export declare class ToolHook extends BaseEntity {
3
+ tool_name: string;
4
+ timing: 'before' | 'after';
5
+ script_filename: string;
6
+ is_active: boolean;
7
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ToolHook = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const base_entity_1 = require("./base.entity");
15
+ let ToolHook = class ToolHook extends base_entity_1.BaseEntity {
16
+ };
17
+ exports.ToolHook = ToolHook;
18
+ __decorate([
19
+ (0, typeorm_1.Column)(),
20
+ __metadata("design:type", String)
21
+ ], ToolHook.prototype, "tool_name", void 0);
22
+ __decorate([
23
+ (0, typeorm_1.Column)(),
24
+ __metadata("design:type", String)
25
+ ], ToolHook.prototype, "timing", void 0);
26
+ __decorate([
27
+ (0, typeorm_1.Column)(),
28
+ __metadata("design:type", String)
29
+ ], ToolHook.prototype, "script_filename", void 0);
30
+ __decorate([
31
+ (0, typeorm_1.Column)({ default: true }),
32
+ __metadata("design:type", Boolean)
33
+ ], ToolHook.prototype, "is_active", void 0);
34
+ exports.ToolHook = ToolHook = __decorate([
35
+ (0, typeorm_1.Entity)('tool_hooks')
36
+ ], ToolHook);
37
+ //# sourceMappingURL=tool-hook.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-hook.entity.js","sourceRoot":"","sources":["../../../src/core-entities/tool-hook.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAyC;AACzC,+CAA2C;AAGpC,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,wBAAU;CAYvC,CAAA;AAZY,4BAAQ;AAEnB;IADC,IAAA,gBAAM,GAAE;;2CACS;AAGlB;IADC,IAAA,gBAAM,GAAE;;wCACkB;AAG3B;IADC,IAAA,gBAAM,GAAE;;iDACe;AAGxB;IADC,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;2CACP;mBAXR,QAAQ;IADpB,IAAA,gBAAM,EAAC,YAAY,CAAC;GACR,QAAQ,CAYpB"}
@@ -45,7 +45,7 @@ export declare class PlanExecutionContext {
45
45
  };
46
46
  flags: {
47
47
  should_halt: boolean;
48
- halt_reason?: 'CONTEXT_REQUESTED' | 'VALIDATION_FAILED' | 'NEW_SESSION';
48
+ halt_reason?: string;
49
49
  is_final: boolean;
50
50
  follow_up_initiated: boolean;
51
51
  should_halt_hooks?: boolean;
@@ -9,59 +9,39 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.LlmOrchestrationModule = void 0;
10
10
  const common_1 = require("@nestjs/common");
11
11
  const typeorm_1 = require("@nestjs/typeorm");
12
- const core_entities_1 = require("../core-entities");
13
12
  const llm_output_parser_service_1 = require("./parser/llm-output-parser.service");
14
13
  const llm_turn_processor_service_1 = require("./llm-turn-processor.service");
15
- const follow_up_post_execution_hook_1 = require("./hooks/follow-up-post-execution.hook");
16
- const yolo_mode_post_execution_hook_1 = require("./hooks/yolo-mode-post-execution.hook");
17
- const application_state_module_1 = require("../application-state/application-state.module");
18
- const chat_module_1 = require("../interactive-chat/chat.module");
14
+ const ai_actions_module_1 = require("../ai-actions/ai-actions.module");
19
15
  const session_inputs_module_1 = require("../session-inputs/session-inputs.module");
16
+ const chat_module_1 = require("../interactive-chat/chat.module");
20
17
  const events_module_1 = require("../events/events.module");
18
+ const application_state_module_1 = require("../application-state/application-state.module");
19
+ const core_entities_1 = require("../core-entities");
20
+ const execution_logs_module_1 = require("../execution-logs/execution-logs.module");
21
21
  const system_prompts_module_1 = require("../system-prompts/system-prompts.module");
22
22
  const sessions_module_1 = require("../sessions/sessions.module");
23
- const run_command_handler_1 = require("./action-handlers/run-command.handler");
24
- const use_mcp_tool_handler_1 = require("./action-handlers/use-mcp-tool.handler");
25
- const request_context_handler_1 = require("./action-handlers/request-context.handler");
26
- const new_session_handler_1 = require("./action-handlers/new-session.handler");
27
- const final_handler_1 = require("./action-handlers/final.handler");
23
+ const workspace_module_1 = require("../workspace/workspace.module");
28
24
  const mcp_module_1 = require("../mcp/mcp.module");
29
- const frontend_notification_hook_1 = require("./hooks/frontend-notification.hook");
25
+ const tool_hooks_module_1 = require("../tool-hooks/tool-hooks.module");
30
26
  const create_file_handler_1 = require("./action-handlers/create-file.handler");
31
- const edit_file_handler_1 = require("./action-handlers/edit-file.handler");
32
27
  const delete_file_handler_1 = require("./action-handlers/delete-file.handler");
33
- const execution_logs_module_1 = require("../execution-logs/execution-logs.module");
28
+ const edit_file_handler_1 = require("./action-handlers/edit-file.handler");
29
+ const execute_shell_handler_1 = require("./action-handlers/execute-shell.handler");
30
+ const run_command_handler_1 = require("./action-handlers/run-command.handler");
31
+ const request_context_handler_1 = require("./action-handlers/request-context.handler");
32
+ const final_handler_1 = require("./action-handlers/final.handler");
33
+ const use_mcp_tool_handler_1 = require("./action-handlers/use-mcp-tool.handler");
34
34
  const quick_edit_handler_1 = require("./action-handlers/quick-edit.handler");
35
- const invalid_tool_feedback_hook_1 = require("./hooks/invalid-tool-feedback.hook");
36
- const patch_handler_1 = require("./action-handlers/patch.handler");
37
35
  const apply_diff_handler_1 = require("./action-handlers/apply-diff.handler");
36
+ const patch_handler_1 = require("./action-handlers/patch.handler");
37
+ const new_session_handler_1 = require("./action-handlers/new-session.handler");
38
38
  const write_todo_handler_1 = require("./action-handlers/write-todo.handler");
39
- const howto_handler_1 = require("./action-handlers/howto.handler");
40
- const execute_shell_handler_1 = require("./action-handlers/execute-shell.handler");
41
39
  const execute_code_handler_1 = require("./action-handlers/execute-code.handler");
42
- const actionHandlers = [
43
- create_file_handler_1.CreateFileHandler,
44
- edit_file_handler_1.EditFileHandler,
45
- delete_file_handler_1.DeleteFileHandler,
46
- quick_edit_handler_1.QuickEditHandler,
47
- apply_diff_handler_1.ApplyDiffHandler,
48
- patch_handler_1.PatchHandler,
49
- write_todo_handler_1.WriteTodoHandler,
50
- run_command_handler_1.RunCommandHandler,
51
- execute_shell_handler_1.ExecuteShellHandler,
52
- execute_code_handler_1.ExecuteCodeHandler,
53
- use_mcp_tool_handler_1.UseMcpToolHandler,
54
- request_context_handler_1.RequestContextHandler,
55
- new_session_handler_1.NewSessionHandler,
56
- final_handler_1.FinalHandler,
57
- howto_handler_1.HowtoHandler,
58
- ];
59
- const postExecutionHooks = [
60
- invalid_tool_feedback_hook_1.InvalidToolFeedbackHook,
61
- follow_up_post_execution_hook_1.FollowUpPostExecutionHook,
62
- yolo_mode_post_execution_hook_1.YoloModePostExecutionHook,
63
- frontend_notification_hook_1.FrontendNotificationHook,
64
- ];
40
+ const howto_handler_1 = require("./action-handlers/howto.handler");
41
+ const invalid_tool_feedback_hook_1 = require("./hooks/invalid-tool-feedback.hook");
42
+ const frontend_notification_hook_1 = require("./hooks/frontend-notification.hook");
43
+ const follow_up_post_execution_hook_1 = require("./hooks/follow-up-post-execution.hook");
44
+ const yolo_mode_post_execution_hook_1 = require("./hooks/yolo-mode-post-execution.hook");
65
45
  let LlmOrchestrationModule = class LlmOrchestrationModule {
66
46
  };
67
47
  exports.LlmOrchestrationModule = LlmOrchestrationModule;
@@ -69,33 +49,90 @@ exports.LlmOrchestrationModule = LlmOrchestrationModule = __decorate([
69
49
  (0, common_1.Module)({
70
50
  imports: [
71
51
  typeorm_1.TypeOrmModule.forFeature([core_entities_1.AIAction, core_entities_1.SessionInput]),
72
- application_state_module_1.ApplicationStateModule,
73
- (0, common_1.forwardRef)(() => chat_module_1.InteractiveChatModule),
52
+ (0, common_1.forwardRef)(() => ai_actions_module_1.AIActionsModule),
74
53
  (0, common_1.forwardRef)(() => session_inputs_module_1.SessionInputsModule),
54
+ (0, common_1.forwardRef)(() => chat_module_1.InteractiveChatModule),
75
55
  events_module_1.EventsModule,
76
56
  (0, common_1.forwardRef)(() => system_prompts_module_1.SystemPromptsModule),
77
57
  sessions_module_1.SessionsModule,
78
- mcp_module_1.McpModule,
58
+ application_state_module_1.ApplicationStateModule,
79
59
  execution_logs_module_1.ExecutionLogsModule,
60
+ workspace_module_1.WorkspaceModule,
61
+ mcp_module_1.McpModule,
62
+ tool_hooks_module_1.ToolHooksModule,
80
63
  ],
81
64
  providers: [
82
65
  llm_output_parser_service_1.LlmOutputParserService,
83
66
  llm_turn_processor_service_1.LlmTurnProcessorService,
84
- ...actionHandlers,
85
- ...postExecutionHooks,
67
+ create_file_handler_1.CreateFileHandler,
68
+ delete_file_handler_1.DeleteFileHandler,
69
+ edit_file_handler_1.EditFileHandler,
70
+ execute_shell_handler_1.ExecuteShellHandler,
71
+ run_command_handler_1.RunCommandHandler,
72
+ request_context_handler_1.RequestContextHandler,
73
+ final_handler_1.FinalHandler,
74
+ use_mcp_tool_handler_1.UseMcpToolHandler,
75
+ quick_edit_handler_1.QuickEditHandler,
76
+ apply_diff_handler_1.ApplyDiffHandler,
77
+ patch_handler_1.PatchHandler,
78
+ new_session_handler_1.NewSessionHandler,
79
+ write_todo_handler_1.WriteTodoHandler,
80
+ execute_code_handler_1.ExecuteCodeHandler,
81
+ howto_handler_1.HowtoHandler,
82
+ invalid_tool_feedback_hook_1.InvalidToolFeedbackHook,
83
+ frontend_notification_hook_1.FrontendNotificationHook,
84
+ follow_up_post_execution_hook_1.FollowUpPostExecutionHook,
85
+ yolo_mode_post_execution_hook_1.YoloModePostExecutionHook,
86
86
  {
87
87
  provide: 'ACTION_HANDLER_REGISTRY',
88
- useFactory: (...handlers) => {
88
+ useFactory: (createFile, deleteFile, editFile, executeShell, runCommand, requestContext, final, useMcpTool, quickEdit, applyDiff, patch, newSession, writeTodo, executeCode, howto) => {
89
89
  const registry = new Map();
90
- handlers.forEach((handler) => registry.set(handler.toolName, handler));
90
+ registry.set(createFile.toolName, createFile);
91
+ registry.set(deleteFile.toolName, deleteFile);
92
+ registry.set(editFile.toolName, editFile);
93
+ registry.set(executeShell.toolName, executeShell);
94
+ registry.set(runCommand.toolName, runCommand);
95
+ registry.set(requestContext.toolName, requestContext);
96
+ registry.set(final.toolName, final);
97
+ registry.set(useMcpTool.toolName, useMcpTool);
98
+ registry.set(quickEdit.toolName, quickEdit);
99
+ registry.set(applyDiff.toolName, applyDiff);
100
+ registry.set(patch.toolName, patch);
101
+ registry.set(newSession.toolName, newSession);
102
+ registry.set(writeTodo.toolName, writeTodo);
103
+ registry.set(executeCode.toolName, executeCode);
104
+ registry.set(howto.toolName, howto);
91
105
  return registry;
92
106
  },
93
- inject: actionHandlers,
107
+ inject: [
108
+ create_file_handler_1.CreateFileHandler,
109
+ delete_file_handler_1.DeleteFileHandler,
110
+ edit_file_handler_1.EditFileHandler,
111
+ execute_shell_handler_1.ExecuteShellHandler,
112
+ run_command_handler_1.RunCommandHandler,
113
+ request_context_handler_1.RequestContextHandler,
114
+ final_handler_1.FinalHandler,
115
+ use_mcp_tool_handler_1.UseMcpToolHandler,
116
+ quick_edit_handler_1.QuickEditHandler,
117
+ apply_diff_handler_1.ApplyDiffHandler,
118
+ patch_handler_1.PatchHandler,
119
+ new_session_handler_1.NewSessionHandler,
120
+ write_todo_handler_1.WriteTodoHandler,
121
+ execute_code_handler_1.ExecuteCodeHandler,
122
+ howto_handler_1.HowtoHandler,
123
+ ],
94
124
  },
95
125
  {
96
126
  provide: 'POST_EXECUTION_HOOKS',
97
- useFactory: (...hooks) => hooks,
98
- inject: postExecutionHooks,
127
+ useFactory: (invalidTool, frontendNotification, followUp, yoloMode) => {
128
+ return [invalidTool, yoloMode, followUp, frontendNotification];
129
+ },
130
+ inject: [
131
+ invalid_tool_feedback_hook_1.InvalidToolFeedbackHook,
132
+ frontend_notification_hook_1.FrontendNotificationHook,
133
+ follow_up_post_execution_hook_1.FollowUpPostExecutionHook,
134
+ yolo_mode_post_execution_hook_1.YoloModePostExecutionHook,
135
+ ],
99
136
  },
100
137
  ],
101
138
  exports: [llm_turn_processor_service_1.LlmTurnProcessorService, 'ACTION_HANDLER_REGISTRY'],
@@ -1 +1 @@
1
- {"version":3,"file":"llm-orchestration.module.js","sourceRoot":"","sources":["../../../src/llm-orchestration/llm-orchestration.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAoD;AACpD,6CAAgD;AAChD,oDAA0D;AAC1D,kFAA4E;AAC5E,6EAAuE;AACvE,yFAAkF;AAClF,yFAAkF;AAClF,4FAAuF;AACvF,iEAAwE;AACxE,mFAA8E;AAC9E,2DAAuD;AACvD,mFAA8E;AAC9E,iEAA6D;AAC7D,+EAA0E;AAC1E,iFAA2E;AAC3E,uFAAkF;AAClF,+EAA0E;AAC1E,mEAA+D;AAC/D,kDAA8C;AAE9C,mFAA8E;AAC9E,+EAA0E;AAC1E,2EAAsE;AACtE,+EAA0E;AAC1E,mFAA8E;AAC9E,6EAAwE;AACxE,mFAA6E;AAC7E,mEAA+D;AAC/D,6EAAwE;AACxE,6EAAwE;AACxE,mEAA+D;AAC/D,mFAA8E;AAC9E,iFAA4E;AAG5E,MAAM,cAAc,GAAG;IACrB,uCAAiB;IACjB,mCAAe;IACf,uCAAiB;IACjB,qCAAgB;IAChB,qCAAgB;IAChB,4BAAY;IACZ,qCAAgB;IAChB,uCAAiB;IACjB,2CAAmB;IACnB,yCAAkB;IAClB,wCAAiB;IACjB,+C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AAsB,CAAG"}
1
+ {"version":3,"file":"llm-orchestration.module.js","sourceRoot":"","sources":["../../../src/llm-orchestration/llm-orchestration.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAoD;AACpD,6CAAgD;AAChD,kFAA4E;AAC5E,6EAAuE;AACvE,uEAAkE;AAClE,mFAA8E;AAC9E,iEAAwE;AAExE,2DAAuD;AACvD,4FAAuF;AACvF,oDAA0D;AAC1D,mFAA8E;AAE9E,mFAA8E;AAC9E,iEAA6D;AAC7D,oEAAgE;AAChE,kDAA8C;AAC9C,uEAAkE;AAGlE,+EAA0E;AAC1E,+EAA0E;AAC1E,2EAAsE;AACtE,mFAA8E;AAC9E,+EAA0E;AAC1E,uFAAkF;AAClF,mEAA+D;AAC/D,iFAA2E;AAC3E,6EAAwE;AACxE,6EAAwE;AACxE,mEAA+D;AAC/D,+EAA0E;AAC1E,6EAAwE;AACxE,iFAA4E;AAC5E,mEAA+D;AAG/D,mFAA6E;AAC7E,mFAA8E;AAC9E,yFAAkF;AAClF,yFAAkF;AAsH3E,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;CAAG,CAAA;AAAzB,wDAAsB;iCAAtB,sBAAsB;IApHlC,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,uBAAa,CAAC,UAAU,CAAC,CAAC,wBAAQ,EAAE,4BAAY,CAAC,CAAC;YAClD,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,mCAAe,CAAC;YACjC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,2CAAmB,CAAC;YACrC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,mCAAqB,CAAC;YACvC,4BAAY;YAEZ,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,2CAAmB,CAAC;YACrC,gCAAc;YACd,iDAAsB;YACtB,2CAAmB;YACnB,kCAAe;YACf,sBAAS;YACT,mCAAe;SAChB;QACD,SAAS,EAAE;YACT,kDAAsB;YACtB,oDAAuB;YAEvB,uCAA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ler.interface';
5
5
  import { PostExecutionHook } from './hooks/post-execution-hook.interface';
6
6
  import { ApplicationStateService } from '../application-state/application-state.service';
7
7
  import { ExecutionLogsService } from '../execution-logs/execution-logs.service';
8
+ import { ToolHooksService } from '../tool-hooks/tool-hooks.service';
8
9
  export declare class LlmTurnProcessorService {
9
10
  private readonly parser;
10
11
  private readonly handlerRegistry;
@@ -13,8 +14,9 @@ export declare class LlmTurnProcessorService {
13
14
  private readonly sessionInputsRepository;
14
15
  private readonly applicationStateService;
15
16
  private readonly executionLogsService;
17
+ private readonly toolHooksService;
16
18
  private readonly logger;
17
- constructor(parser: LlmOutputParserService, handlerRegistry: Map<string, ActionHandler>, postExecutionHooks: PostExecutionHook[], aiActionsRepository: Repository<AIAction>, sessionInputsRepository: Repository<SessionInput>, applicationStateService: ApplicationStateService, executionLogsService: ExecutionLogsService);
19
+ constructor(parser: LlmOutputParserService, handlerRegistry: Map<string, ActionHandler>, postExecutionHooks: PostExecutionHook[], aiActionsRepository: Repository<AIAction>, sessionInputsRepository: Repository<SessionInput>, applicationStateService: ApplicationStateService, executionLogsService: ExecutionLogsService, toolHooksService: ToolHooksService);
18
20
  processTurn(sessionInput: SessionInput): Promise<SessionInput>;
19
21
  private getSuccessStatusForStrategy;
20
22
  }
@@ -24,8 +24,9 @@ const handler_validation_error_1 = require("./errors/handler-validation.error");
24
24
  const ai_actions_service_1 = require("../ai-actions/ai-actions.service");
25
25
  const application_state_service_1 = require("../application-state/application-state.service");
26
26
  const execution_logs_service_1 = require("../execution-logs/execution-logs.service");
27
+ const tool_hooks_service_1 = require("../tool-hooks/tool-hooks.service");
27
28
  let LlmTurnProcessorService = LlmTurnProcessorService_1 = class LlmTurnProcessorService {
28
- constructor(parser, handlerRegistry, postExecutionHooks, aiActionsRepository, sessionInputsRepository, applicationStateService, executionLogsService) {
29
+ constructor(parser, handlerRegistry, postExecutionHooks, aiActionsRepository, sessionInputsRepository, applicationStateService, executionLogsService, toolHooksService) {
29
30
  this.parser = parser;
30
31
  this.handlerRegistry = handlerRegistry;
31
32
  this.postExecutionHooks = postExecutionHooks;
@@ -33,6 +34,7 @@ let LlmTurnProcessorService = LlmTurnProcessorService_1 = class LlmTurnProcessor
33
34
  this.sessionInputsRepository = sessionInputsRepository;
34
35
  this.applicationStateService = applicationStateService;
35
36
  this.executionLogsService = executionLogsService;
37
+ this.toolHooksService = toolHooksService;
36
38
  this.logger = new common_1.Logger(LlmTurnProcessorService_1.name);
37
39
  }
38
40
  async processTurn(sessionInput) {
@@ -68,6 +70,47 @@ let LlmTurnProcessorService = LlmTurnProcessorService_1 = class LlmTurnProcessor
68
70
  for (const action of parsedActions) {
69
71
  const handler = this.handlerRegistry.get(action.tool_name);
70
72
  let result;
73
+ const beforeHooks = await this.toolHooksService.findByTrigger(action.tool_name, 'before');
74
+ let hookHalted = false;
75
+ for (const hook of beforeHooks) {
76
+ try {
77
+ this.logger.log(`Running BEFORE hook: ${hook.script_filename} for tool ${action.tool_name}`);
78
+ const hookResult = await this.toolHooksService.executeHook(hook.script_filename, {
79
+ hook_type: 'before',
80
+ action: { tool_name: action.tool_name, args: action.arguments },
81
+ plan_context: executionContext,
82
+ });
83
+ if (hookResult.should_halt_plan) {
84
+ this.logger.warn(`Hook ${hook.script_filename} halted execution.`);
85
+ executionContext.flags.should_halt = true;
86
+ executionContext.flags.halt_reason = `Hook ${hook.script_filename} returned halt signal.`;
87
+ hookHalted = true;
88
+ break;
89
+ }
90
+ }
91
+ catch (e) {
92
+ this.logger.error(`Before-hook failed: ${e.message}`);
93
+ }
94
+ }
95
+ if (hookHalted) {
96
+ const aiActionEntity = this.aiActionsRepository.create({
97
+ input_id: sessionInput.id,
98
+ sessionInput: { id: sessionInput.id },
99
+ action_type: action.tool_name,
100
+ status: ai_actions_service_1.AIActionStatus.EXECUTION_FAILED,
101
+ order_of_execution: createdActions.length,
102
+ original_content_for_revert: null,
103
+ ...action.arguments,
104
+ });
105
+ const savedAction = await this.aiActionsRepository.save(aiActionEntity);
106
+ createdActions.push(savedAction);
107
+ await this.executionLogsService.createLog({
108
+ action_id: savedAction.id,
109
+ error_message: executionContext.flags.halt_reason || 'Blocked by tool hook.',
110
+ output: 'Action execution prevented by a "before" hook.',
111
+ });
112
+ break;
113
+ }
71
114
  if (!handler) {
72
115
  this.logger.warn(`No handler found for tool: ${action.tool_name}. Skipping.`);
73
116
  executionContext.feedback.invalidToolErrors.push({
@@ -112,6 +155,30 @@ let LlmTurnProcessorService = LlmTurnProcessorService_1 = class LlmTurnProcessor
112
155
  }
113
156
  }
114
157
  }
158
+ if (result) {
159
+ const afterHooks = await this.toolHooksService.findByTrigger(action.tool_name, 'after');
160
+ for (const hook of afterHooks) {
161
+ try {
162
+ this.logger.log(`Running AFTER hook: ${hook.script_filename} for tool ${action.tool_name}`);
163
+ await this.toolHooksService.executeHook(hook.script_filename, {
164
+ hook_type: 'after',
165
+ action: {
166
+ tool_name: action.tool_name,
167
+ args: action.arguments,
168
+ result: {
169
+ status: result.status,
170
+ output: result.execution_log?.output,
171
+ error: result.error_message,
172
+ },
173
+ },
174
+ plan_context: executionContext,
175
+ });
176
+ }
177
+ catch (e) {
178
+ this.logger.error(`After-hook failed: ${e.message}`);
179
+ }
180
+ }
181
+ }
115
182
  const executionStrategy = await this.applicationStateService.getExecutionStrategy();
116
183
  this.logger.log(`Using execution strategy: ${executionStrategy}`);
117
184
  const successStatus = this.getSuccessStatusForStrategy(executionStrategy);
@@ -181,6 +248,7 @@ exports.LlmTurnProcessorService = LlmTurnProcessorService = LlmTurnProcessorServ
181
248
  Map, Array, typeorm_2.Repository,
182
249
  typeorm_2.Repository,
183
250
  application_state_service_1.ApplicationStateService,
184
- execution_logs_service_1.ExecutionLogsService])
251
+ execution_logs_service_1.ExecutionLogsService,
252
+ tool_hooks_service_1.ToolHooksService])
185
253
  ], LlmTurnProcessorService);
186
254
  //# sourceMappingURL=llm-turn-processor.service.js.map