repoburg 1.2.13 → 1.3.1

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 (140) hide show
  1. package/CODEMAP.md +8 -8
  2. package/backend/.env +4 -0
  3. package/backend/dist/src/ai-actions/ai-action-batch.service.d.ts +10 -3
  4. package/backend/dist/src/ai-actions/ai-action-batch.service.js +134 -12
  5. package/backend/dist/src/ai-actions/ai-action-batch.service.js.map +1 -1
  6. package/backend/dist/src/ai-actions/ai-actions.module.js +2 -7
  7. package/backend/dist/src/ai-actions/ai-actions.module.js.map +1 -1
  8. package/backend/dist/src/ai-actions/ai-actions.service.d.ts +16 -3
  9. package/backend/dist/src/ai-actions/ai-actions.service.js +75 -11
  10. package/backend/dist/src/ai-actions/ai-actions.service.js.map +1 -1
  11. package/backend/dist/src/app.module.js +0 -4
  12. package/backend/dist/src/app.module.js.map +1 -1
  13. package/backend/dist/src/core-entities/ai-action.entity.d.ts +1 -0
  14. package/backend/dist/src/core-entities/ai-action.entity.js +4 -0
  15. package/backend/dist/src/core-entities/ai-action.entity.js.map +1 -1
  16. package/backend/dist/src/llm-orchestration/action-handlers/action-handler.interface.d.ts +7 -0
  17. package/backend/dist/src/llm-orchestration/action-handlers/action-handler.interface.js +3 -0
  18. package/backend/dist/src/llm-orchestration/action-handlers/action-handler.interface.js.map +1 -0
  19. package/backend/dist/src/llm-orchestration/action-handlers/create-file.handler.d.ts +11 -0
  20. package/backend/dist/src/llm-orchestration/action-handlers/create-file.handler.js +65 -0
  21. package/backend/dist/src/llm-orchestration/action-handlers/create-file.handler.js.map +1 -0
  22. package/backend/dist/src/llm-orchestration/action-handlers/delete-file.handler.d.ts +12 -0
  23. package/backend/dist/src/llm-orchestration/action-handlers/delete-file.handler.js +85 -0
  24. package/backend/dist/src/llm-orchestration/action-handlers/delete-file.handler.js.map +1 -0
  25. package/backend/dist/src/llm-orchestration/action-handlers/dto/create-file.args.dto.d.ts +4 -0
  26. package/backend/dist/src/llm-orchestration/action-handlers/dto/create-file.args.dto.js +29 -0
  27. package/backend/dist/src/llm-orchestration/action-handlers/dto/create-file.args.dto.js.map +1 -0
  28. package/backend/dist/src/llm-orchestration/action-handlers/dto/delete-file.args.dto.d.ts +3 -0
  29. package/backend/dist/src/llm-orchestration/action-handlers/dto/delete-file.args.dto.js +22 -0
  30. package/backend/dist/src/llm-orchestration/action-handlers/dto/delete-file.args.dto.js.map +1 -0
  31. package/backend/dist/src/llm-orchestration/action-handlers/dto/edit-file.args.dto.d.ts +4 -0
  32. package/backend/dist/src/llm-orchestration/action-handlers/dto/edit-file.args.dto.js +29 -0
  33. package/backend/dist/src/llm-orchestration/action-handlers/dto/edit-file.args.dto.js.map +1 -0
  34. package/backend/dist/src/llm-orchestration/action-handlers/dto/final.args.dto.d.ts +3 -0
  35. package/backend/dist/src/{llm-response-parser/llm-response-parser.module.js → llm-orchestration/action-handlers/dto/final.args.dto.js} +14 -13
  36. package/backend/dist/src/llm-orchestration/action-handlers/dto/final.args.dto.js.map +1 -0
  37. package/backend/dist/src/llm-orchestration/action-handlers/dto/new-session.args.dto.d.ts +3 -0
  38. package/backend/dist/src/llm-orchestration/action-handlers/dto/new-session.args.dto.js +22 -0
  39. package/backend/dist/src/llm-orchestration/action-handlers/dto/new-session.args.dto.js.map +1 -0
  40. package/backend/dist/src/llm-orchestration/action-handlers/dto/quick-edit.args.dto.d.ts +6 -0
  41. package/backend/dist/src/llm-orchestration/action-handlers/dto/quick-edit.args.dto.js +46 -0
  42. package/backend/dist/src/llm-orchestration/action-handlers/dto/quick-edit.args.dto.js.map +1 -0
  43. package/backend/dist/src/llm-orchestration/action-handlers/dto/request-context.args.dto.d.ts +11 -0
  44. package/backend/dist/src/llm-orchestration/action-handlers/dto/request-context.args.dto.js +50 -0
  45. package/backend/dist/src/llm-orchestration/action-handlers/dto/request-context.args.dto.js.map +1 -0
  46. package/backend/dist/src/llm-orchestration/action-handlers/dto/run-command.args.dto.d.ts +4 -0
  47. package/backend/dist/src/llm-orchestration/action-handlers/dto/run-command.args.dto.js +27 -0
  48. package/backend/dist/src/llm-orchestration/action-handlers/dto/run-command.args.dto.js.map +1 -0
  49. package/backend/dist/src/llm-orchestration/action-handlers/dto/sanitizer.decorator.d.ts +1 -0
  50. package/backend/dist/src/llm-orchestration/action-handlers/dto/sanitizer.decorator.js +15 -0
  51. package/backend/dist/src/llm-orchestration/action-handlers/dto/sanitizer.decorator.js.map +1 -0
  52. package/backend/dist/src/llm-orchestration/action-handlers/dto/use-mcp-tool.args.dto.d.ts +5 -0
  53. package/backend/dist/src/llm-orchestration/action-handlers/dto/use-mcp-tool.args.dto.js +49 -0
  54. package/backend/dist/src/llm-orchestration/action-handlers/dto/use-mcp-tool.args.dto.js.map +1 -0
  55. package/backend/dist/src/llm-orchestration/action-handlers/edit-file.handler.d.ts +12 -0
  56. package/backend/dist/src/llm-orchestration/action-handlers/edit-file.handler.js +78 -0
  57. package/backend/dist/src/llm-orchestration/action-handlers/edit-file.handler.js.map +1 -0
  58. package/backend/dist/src/llm-orchestration/action-handlers/final.handler.d.ts +8 -0
  59. package/backend/dist/src/llm-orchestration/action-handlers/final.handler.js +40 -0
  60. package/backend/dist/src/llm-orchestration/action-handlers/final.handler.js.map +1 -0
  61. package/backend/dist/src/llm-orchestration/action-handlers/new-session.handler.d.ts +8 -0
  62. package/backend/dist/src/llm-orchestration/action-handlers/new-session.handler.js +45 -0
  63. package/backend/dist/src/llm-orchestration/action-handlers/new-session.handler.js.map +1 -0
  64. package/backend/dist/src/llm-orchestration/action-handlers/quick-edit.handler.d.ts +12 -0
  65. package/backend/dist/src/llm-orchestration/action-handlers/quick-edit.handler.js +133 -0
  66. package/backend/dist/src/llm-orchestration/action-handlers/quick-edit.handler.js.map +1 -0
  67. package/backend/dist/src/llm-orchestration/action-handlers/request-context.handler.d.ts +8 -0
  68. package/backend/dist/src/llm-orchestration/action-handlers/request-context.handler.js +49 -0
  69. package/backend/dist/src/llm-orchestration/action-handlers/request-context.handler.js.map +1 -0
  70. package/backend/dist/src/llm-orchestration/action-handlers/run-command.handler.d.ts +10 -0
  71. package/backend/dist/src/llm-orchestration/action-handlers/run-command.handler.js +73 -0
  72. package/backend/dist/src/llm-orchestration/action-handlers/run-command.handler.js.map +1 -0
  73. package/backend/dist/src/llm-orchestration/action-handlers/use-mcp-tool.handler.d.ts +12 -0
  74. package/backend/dist/src/llm-orchestration/action-handlers/use-mcp-tool.handler.js +61 -0
  75. package/backend/dist/src/llm-orchestration/action-handlers/use-mcp-tool.handler.js.map +1 -0
  76. package/backend/dist/src/llm-orchestration/errors/handler-validation.error.d.ts +4 -0
  77. package/backend/dist/src/llm-orchestration/errors/handler-validation.error.js +12 -0
  78. package/backend/dist/src/llm-orchestration/errors/handler-validation.error.js.map +1 -0
  79. package/backend/dist/src/llm-orchestration/hooks/follow-up-post-execution.hook.d.ts +25 -0
  80. package/backend/dist/src/llm-orchestration/hooks/follow-up-post-execution.hook.js +144 -0
  81. package/backend/dist/src/llm-orchestration/hooks/follow-up-post-execution.hook.js.map +1 -0
  82. package/backend/dist/src/llm-orchestration/hooks/frontend-notification.hook.d.ts +10 -0
  83. package/backend/dist/src/llm-orchestration/hooks/frontend-notification.hook.js +38 -0
  84. package/backend/dist/src/llm-orchestration/hooks/frontend-notification.hook.js.map +1 -0
  85. package/backend/dist/src/llm-orchestration/hooks/post-execution-hook.interface.d.ts +5 -0
  86. package/backend/dist/src/llm-orchestration/hooks/post-execution-hook.interface.js +3 -0
  87. package/backend/dist/src/llm-orchestration/hooks/post-execution-hook.interface.js.map +1 -0
  88. package/backend/dist/src/llm-orchestration/hooks/yolo-mode-post-execution.hook.d.ts +12 -0
  89. package/backend/dist/src/llm-orchestration/hooks/yolo-mode-post-execution.hook.js +55 -0
  90. package/backend/dist/src/llm-orchestration/hooks/yolo-mode-post-execution.hook.js.map +1 -0
  91. package/backend/dist/src/llm-orchestration/llm-orchestration.interfaces.d.ts +52 -0
  92. package/backend/dist/src/llm-orchestration/llm-orchestration.interfaces.js +13 -0
  93. package/backend/dist/src/llm-orchestration/llm-orchestration.interfaces.js.map +1 -0
  94. package/backend/dist/src/llm-orchestration/llm-orchestration.module.d.ts +2 -0
  95. package/backend/dist/src/llm-orchestration/llm-orchestration.module.js +90 -0
  96. package/backend/dist/src/llm-orchestration/llm-orchestration.module.js.map +1 -0
  97. package/backend/dist/src/llm-orchestration/llm-turn-processor.service.d.ts +20 -0
  98. package/backend/dist/src/llm-orchestration/llm-turn-processor.service.js +156 -0
  99. package/backend/dist/src/llm-orchestration/llm-turn-processor.service.js.map +1 -0
  100. package/backend/dist/src/llm-orchestration/parser/llm-output-parser.service.d.ts +5 -0
  101. package/backend/dist/src/llm-orchestration/parser/llm-output-parser.service.js +105 -0
  102. package/backend/dist/src/llm-orchestration/parser/llm-output-parser.service.js.map +1 -0
  103. package/backend/dist/src/llm-orchestration/parser/parsing.constants.d.ts +7 -0
  104. package/backend/dist/src/llm-orchestration/parser/parsing.constants.js +11 -0
  105. package/backend/dist/src/llm-orchestration/parser/parsing.constants.js.map +1 -0
  106. package/backend/dist/src/llm-responses/llm-responses.module.js +2 -0
  107. package/backend/dist/src/llm-responses/llm-responses.module.js.map +1 -1
  108. package/backend/dist/src/llm-responses/llm-responses.service.d.ts +3 -6
  109. package/backend/dist/src/llm-responses/llm-responses.service.js +9 -112
  110. package/backend/dist/src/llm-responses/llm-responses.service.js.map +1 -1
  111. package/backend/dist/src/seeding/data/system-prompts/carryover-agent.d.ts +1 -1
  112. package/backend/dist/src/seeding/data/system-prompts/carryover-agent.js +8 -8
  113. package/backend/dist/src/seeding/data/system-prompts/default_master-agent.d.ts +1 -1
  114. package/backend/dist/src/seeding/data/system-prompts/default_master-agent.js +184 -91
  115. package/backend/dist/src/seeding/data/system-prompts/default_master-agent.js.map +1 -1
  116. package/backend/dist/tsconfig.build.tsbuildinfo +1 -1
  117. package/package.json +1 -1
  118. package/backend/dist/src/action-execution/action-execution.module.d.ts +0 -2
  119. package/backend/dist/src/action-execution/action-execution.module.js +0 -23
  120. package/backend/dist/src/action-execution/action-execution.module.js.map +0 -1
  121. package/backend/dist/src/action-execution/action-execution.service.d.ts +0 -19
  122. package/backend/dist/src/action-execution/action-execution.service.js +0 -149
  123. package/backend/dist/src/action-execution/action-execution.service.js.map +0 -1
  124. package/backend/dist/src/ai-actions/ai-action-creation.service.d.ts +0 -29
  125. package/backend/dist/src/ai-actions/ai-action-creation.service.js +0 -416
  126. package/backend/dist/src/ai-actions/ai-action-creation.service.js.map +0 -1
  127. package/backend/dist/src/llm-response-parser/dto/ai-action.dto.d.ts +0 -30
  128. package/backend/dist/src/llm-response-parser/dto/ai-action.dto.js +0 -162
  129. package/backend/dist/src/llm-response-parser/dto/ai-action.dto.js.map +0 -1
  130. package/backend/dist/src/llm-response-parser/errors/parsing.error.d.ts +0 -4
  131. package/backend/dist/src/llm-response-parser/errors/parsing.error.js +0 -13
  132. package/backend/dist/src/llm-response-parser/errors/parsing.error.js.map +0 -1
  133. package/backend/dist/src/llm-response-parser/llm-response-parser.module.d.ts +0 -2
  134. package/backend/dist/src/llm-response-parser/llm-response-parser.module.js.map +0 -1
  135. package/backend/dist/src/llm-response-parser/llm-response-parser.service.d.ts +0 -9
  136. package/backend/dist/src/llm-response-parser/llm-response-parser.service.js +0 -215
  137. package/backend/dist/src/llm-response-parser/llm-response-parser.service.js.map +0 -1
  138. package/backend/dist/src/llm-response-parser/parsing.constants.d.ts +0 -20
  139. package/backend/dist/src/llm-response-parser/parsing.constants.js +0 -24
  140. package/backend/dist/src/llm-response-parser/parsing.constants.js.map +0 -1
@@ -0,0 +1,73 @@
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 RunCommandHandler_1;
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.RunCommandHandler = void 0;
11
+ const common_1 = require("@nestjs/common");
12
+ const child_process_1 = require("child_process");
13
+ const util_1 = require("util");
14
+ const run_command_args_dto_1 = require("./dto/run-command.args.dto");
15
+ const class_transformer_1 = require("class-transformer");
16
+ const class_validator_1 = require("class-validator");
17
+ const handler_validation_error_1 = require("../errors/handler-validation.error");
18
+ const execAsync = (0, util_1.promisify)(child_process_1.exec);
19
+ let RunCommandHandler = RunCommandHandler_1 = class RunCommandHandler {
20
+ constructor() {
21
+ this.toolName = 'run_command';
22
+ this.logger = new common_1.Logger(RunCommandHandler_1.name);
23
+ this.projectRoot = process.env.REPOBURG_PROJECT_PATH || process.cwd();
24
+ }
25
+ async execute(args, context) {
26
+ const validatedArgs = (0, class_transformer_1.plainToClass)(run_command_args_dto_1.RunCommandArgsDto, args);
27
+ const errors = await (0, class_validator_1.validate)(validatedArgs);
28
+ if (errors.length > 0) {
29
+ const errorMessages = errors
30
+ .map((err) => Object.values(err.constraints || {}).join(', '))
31
+ .join('; ');
32
+ throw new handler_validation_error_1.HandlerValidationError(errorMessages);
33
+ }
34
+ const { command_string } = validatedArgs;
35
+ let unifiedOutput;
36
+ let summary;
37
+ let status = 'SUCCESS';
38
+ let errorMessage;
39
+ try {
40
+ const { stdout, stderr } = await execAsync(command_string, {
41
+ cwd: this.projectRoot,
42
+ maxBuffer: 128 * 1024 * 1024,
43
+ timeout: 15000,
44
+ });
45
+ unifiedOutput = stdout || stderr || '(Command produced no output)';
46
+ summary = `Command "${command_string}" executed.`;
47
+ }
48
+ catch (error) {
49
+ const execError = error;
50
+ unifiedOutput = `COMMAND FAILED: ${execError.message}\n\nSTDOUT:\n${execError.stdout || 'N/A'}\n\nSTDERR:\n${execError.stderr || 'N/A'}`;
51
+ summary = `Command "${command_string}" failed.`;
52
+ status = 'FAILURE';
53
+ errorMessage = execError.message;
54
+ this.logger.error(`Error executing command: ${unifiedOutput}`);
55
+ }
56
+ context.outputs.commands.push({
57
+ command: command_string,
58
+ output: unifiedOutput,
59
+ });
60
+ return {
61
+ status,
62
+ summary: `${summary} Output captured.`,
63
+ persisted_args: { command_string },
64
+ error_message: errorMessage,
65
+ execution_log: { output: unifiedOutput, error_message: errorMessage },
66
+ };
67
+ }
68
+ };
69
+ exports.RunCommandHandler = RunCommandHandler;
70
+ exports.RunCommandHandler = RunCommandHandler = RunCommandHandler_1 = __decorate([
71
+ (0, common_1.Injectable)()
72
+ ], RunCommandHandler);
73
+ //# sourceMappingURL=run-command.handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-command.handler.js","sourceRoot":"","sources":["../../../../src/llm-orchestration/action-handlers/run-command.handler.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAoD;AAMpD,iDAAqC;AACrC,+BAAiC;AACjC,qEAA+D;AAC/D,yDAAiD;AACjD,qDAA2C;AAC3C,iFAA4E;AAE5E,MAAM,SAAS,GAAG,IAAA,gBAAS,EAAC,oBAAI,CAAC,CAAC;AAG3B,IAAM,iBAAiB,yBAAvB,MAAM,iBAAiB;IAAvB;QACI,aAAQ,GAAG,aAAa,CAAC;QACjB,WAAM,GAAG,IAAI,eAAM,CAAC,mBAAiB,CAAC,IAAI,CAAC,CAAC;QAC5C,gBAAW,GAC1B,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAqDvD,CAAC;IAnDC,KAAK,CAAC,OAAO,CACX,IAA4B,EAC5B,OAA6B;QAE7B,MAAM,aAAa,GAAG,IAAA,gCAAY,EAAC,wCAAiB,EAAE,IAAI,CAAC,CAAC;QAC5D,MAAM,MAAM,GAAG,MAAM,IAAA,0BAAQ,EAAC,aAAa,CAAC,CAAC;QAC7C,IAA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,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;YAC5B,OAAO,EAAE,cAAc;YACvB,MAAM,EAAE,aAAa;SACtB,CAAC,CAAC;QAEH,OAAO;YACL,MAAM;YACN,OAAO,EAAE,GAAG,OAAO,mBAAmB;YACtC,cAAc,EAAE,EAAE,cAAc,EAAE;YAClC,aAAa,EAAE,YAAY;YAC3B,aAAa,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE;SACtE,CAAC;IACJ,CAAC;CACF,CAAA;AAzDY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;GACA,iBAAiB,CAyD7B"}
@@ -0,0 +1,12 @@
1
+ import { ActionHandler } from './action-handler.interface';
2
+ import { ActionExecutionResult, PlanExecutionContext } from '../llm-orchestration.interfaces';
3
+ import { McpService } from '../../mcp/mcp.service';
4
+ export declare class UseMcpToolHandler implements ActionHandler {
5
+ private readonly mcpService;
6
+ readonly toolName = "use_mcp_tool";
7
+ private readonly logger;
8
+ constructor(mcpService: McpService);
9
+ execute(args: {
10
+ [key: string]: any;
11
+ }, context: PlanExecutionContext): Promise<ActionExecutionResult>;
12
+ }
@@ -0,0 +1,61 @@
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
+ var UseMcpToolHandler_1;
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.UseMcpToolHandler = void 0;
14
+ const common_1 = require("@nestjs/common");
15
+ const mcp_service_1 = require("../../mcp/mcp.service");
16
+ const use_mcp_tool_args_dto_1 = require("./dto/use-mcp-tool.args.dto");
17
+ const class_transformer_1 = require("class-transformer");
18
+ const class_validator_1 = require("class-validator");
19
+ const handler_validation_error_1 = require("../errors/handler-validation.error");
20
+ let UseMcpToolHandler = UseMcpToolHandler_1 = class UseMcpToolHandler {
21
+ constructor(mcpService) {
22
+ this.mcpService = mcpService;
23
+ this.toolName = 'use_mcp_tool';
24
+ this.logger = new common_1.Logger(UseMcpToolHandler_1.name);
25
+ }
26
+ async execute(args, context) {
27
+ const validatedArgs = (0, class_transformer_1.plainToClass)(use_mcp_tool_args_dto_1.UseMcpToolArgsDto, args);
28
+ const errors = await (0, class_validator_1.validate)(validatedArgs);
29
+ if (errors.length > 0) {
30
+ const errorMessages = errors
31
+ .map((err) => Object.values(err.constraints || {}).join(', '))
32
+ .join('; ');
33
+ throw new handler_validation_error_1.HandlerValidationError(errorMessages);
34
+ }
35
+ const { server_name, mcp_tool_name, arguments: tool_args } = validatedArgs;
36
+ const { stdout, stderr } = await this.mcpService.executeMcpTool(server_name, mcp_tool_name, tool_args);
37
+ const unifiedOutput = stdout || stderr || '(Tool produced no output)';
38
+ context.outputs.mcp_tools.push({
39
+ tool_name: `${server_name}.${mcp_tool_name}`,
40
+ output: unifiedOutput,
41
+ });
42
+ return {
43
+ status: 'SUCCESS',
44
+ summary: `MCP tool "${server_name}.${mcp_tool_name}" executed. Output captured.`,
45
+ persisted_args: {
46
+ server_name,
47
+ tool_name: mcp_tool_name,
48
+ arguments: JSON.stringify(tool_args),
49
+ },
50
+ execution_log: {
51
+ output: unifiedOutput,
52
+ },
53
+ };
54
+ }
55
+ };
56
+ exports.UseMcpToolHandler = UseMcpToolHandler;
57
+ exports.UseMcpToolHandler = UseMcpToolHandler = UseMcpToolHandler_1 = __decorate([
58
+ (0, common_1.Injectable)(),
59
+ __metadata("design:paramtypes", [mcp_service_1.McpService])
60
+ ], UseMcpToolHandler);
61
+ //# sourceMappingURL=use-mcp-tool.handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-mcp-tool.handler.js","sourceRoot":"","sources":["../../../../src/llm-orchestration/action-handlers/use-mcp-tool.handler.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AAMpD,uDAAmD;AACnD,uEAAgE;AAChE,yDAAiD;AACjD,qDAA2C;AAC3C,iFAA4E;AAGrE,IAAM,iBAAiB,yBAAvB,MAAM,iBAAiB;IAI5B,YAA6B,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;QAH1C,aAAQ,GAAG,cAAc,CAAC;QAClB,WAAM,GAAG,IAAI,eAAM,CAAC,mBAAiB,CAAC,IAAI,CAAC,CAAC;IAEP,CAAC;IAEvD,KAAK,CAAC,OAAO,CACX,IAA4B,EAC5B,OAA6B;QAE7B,MAAM,aAAa,GAAG,IAAA,gCAAY,EAAC,yCAAiB,EAAE,IAAI,CAAC,CAAC;QAC5D,MAAM,MAAM,GAAG,MAAM,IAAA,0BAAQ,EAAC,aAAa,CAAC,CAAC;QAC7C,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtB,MAAM,aAAa,GAAG,MAAM;iBACzB,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;iBAC7D,IAAI,CAAC,IAAI,CAAC,CAAC;YACd,MAAM,IAAI,iDAAsB,CAAC,aAAa,CAAC,CAAC;QAClD,CAAC;QAED,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,aAAa,CAAC;QAC3E,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,cAAc,CAC7D,WAAW,EACX,aAAa,EACb,SAAS,CACV,CAAC;QAEF,MAAM,aAAa,GAAG,MAAM,IAAI,MAAM,IAAI,2BAA2B,CAAC;QACtE,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC;YAC7B,SAAS,EAAE,GAAG,WAAW,IAAI,aAAa,EAAE;YAC5C,MAAM,EAAE,aAAa;SACtB,CAAC,CAAC;QAEH,OAAO;YACL,MAAM,EAAE,SAAS;YACjB,OAAO,EAAE,aAAa,WAAW,IAAI,aAAa,8BAA8B;YAChF,cAAc,EAAE;gBACd,WAAW;gBACX,SAAS,EAAE,aAAa;gBACxB,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC;aACrC;YACD,aAAa,EAAE;gBACb,MAAM,EAAE,aAAa;aACtB;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AA7CY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;qCAK8B,wBAAU;GAJxC,iBAAiB,CA6C7B"}
@@ -0,0 +1,4 @@
1
+ export declare class HandlerValidationError extends Error {
2
+ readonly validationErrors: string;
3
+ constructor(validationErrors: string);
4
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HandlerValidationError = void 0;
4
+ class HandlerValidationError extends Error {
5
+ constructor(validationErrors) {
6
+ super(`Handler validation failed: ${validationErrors}`);
7
+ this.validationErrors = validationErrors;
8
+ this.name = 'HandlerValidationError';
9
+ }
10
+ }
11
+ exports.HandlerValidationError = HandlerValidationError;
12
+ //# sourceMappingURL=handler-validation.error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler-validation.error.js","sourceRoot":"","sources":["../../../../src/llm-orchestration/errors/handler-validation.error.ts"],"names":[],"mappings":";;;AAAA,MAAa,sBAAuB,SAAQ,KAAK;IAC/C,YAA4B,gBAAwB;QAClD,KAAK,CAAC,8BAA8B,gBAAgB,EAAE,CAAC,CAAC;QAD9B,qBAAgB,GAAhB,gBAAgB,CAAQ;QAElD,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AALD,wDAKC"}
@@ -0,0 +1,25 @@
1
+ import { PostExecutionHook } from './post-execution-hook.interface';
2
+ import { PlanExecutionContext } from '../llm-orchestration.interfaces';
3
+ import { SessionInput } from '../../core-entities';
4
+ import { ChatService } from '../../interactive-chat/chat.service';
5
+ import { SessionInputsService } from '../../session-inputs/session-inputs.service';
6
+ import { EventsGateway } from '../../events/events.gateway';
7
+ import { SystemPromptsService } from '../../system-prompts/system-prompts.service';
8
+ import { SessionsService } from '../../sessions/sessions.service';
9
+ import { ApplicationStateService } from '../../application-state/application-state.service';
10
+ export declare class FollowUpPostExecutionHook implements PostExecutionHook {
11
+ private readonly chatService;
12
+ private readonly sessionInputsService;
13
+ private readonly eventsGateway;
14
+ private readonly systemPromptsService;
15
+ private readonly sessionsService;
16
+ private readonly applicationStateService;
17
+ private readonly logger;
18
+ constructor(chatService: ChatService, sessionInputsService: SessionInputsService, eventsGateway: EventsGateway, systemPromptsService: SystemPromptsService, sessionsService: SessionsService, applicationStateService: ApplicationStateService);
19
+ run(sessionInput: SessionInput, context: PlanExecutionContext): Promise<void>;
20
+ private handleValidationFeedback;
21
+ private handleHaltedPlan;
22
+ private handleAutoContextFetch;
23
+ private handleNewSession;
24
+ private handleCommandOutputs;
25
+ }
@@ -0,0 +1,144 @@
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
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var FollowUpPostExecutionHook_1;
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.FollowUpPostExecutionHook = void 0;
17
+ const common_1 = require("@nestjs/common");
18
+ const chat_service_1 = require("../../interactive-chat/chat.service");
19
+ const session_inputs_service_1 = require("../../session-inputs/session-inputs.service");
20
+ const events_gateway_1 = require("../../events/events.gateway");
21
+ const system_prompts_service_1 = require("../../system-prompts/system-prompts.service");
22
+ const sessions_service_1 = require("../../sessions/sessions.service");
23
+ const application_state_service_1 = require("../../application-state/application-state.service");
24
+ let FollowUpPostExecutionHook = FollowUpPostExecutionHook_1 = class FollowUpPostExecutionHook {
25
+ constructor(chatService, sessionInputsService, eventsGateway, systemPromptsService, sessionsService, applicationStateService) {
26
+ this.chatService = chatService;
27
+ this.sessionInputsService = sessionInputsService;
28
+ this.eventsGateway = eventsGateway;
29
+ this.systemPromptsService = systemPromptsService;
30
+ this.sessionsService = sessionsService;
31
+ this.applicationStateService = applicationStateService;
32
+ this.logger = new common_1.Logger(FollowUpPostExecutionHook_1.name);
33
+ }
34
+ async run(sessionInput, context) {
35
+ if (context.feedback.validationErrors.length > 0) {
36
+ await this.handleValidationFeedback(sessionInput, context);
37
+ context.flags.follow_up_initiated = true;
38
+ return;
39
+ }
40
+ if (context.flags.should_halt && context.followUpAction) {
41
+ await this.handleHaltedPlan(sessionInput, context);
42
+ context.flags.follow_up_initiated = true;
43
+ return;
44
+ }
45
+ if (context.outputs.commands.length > 0 ||
46
+ context.outputs.mcp_tools.length > 0) {
47
+ await this.handleCommandOutputs(sessionInput, context);
48
+ context.flags.follow_up_initiated = true;
49
+ return;
50
+ }
51
+ this.logger.log('No follow-up action needed for this plan.');
52
+ }
53
+ async handleValidationFeedback(sessionInput, context) {
54
+ const validationErrors = context.feedback.validationErrors;
55
+ let feedbackMessage = `The plan could not be executed due to the following validation errors. Please correct your tool usage and regenerate the plan.\n\n`;
56
+ for (const err of validationErrors) {
57
+ feedbackMessage += `- Tool: \`${err.tool_name}\`\n - Error: ${err.error}\n`;
58
+ }
59
+ this.logger.log('Triggering self-correction AI call due to validation errors.');
60
+ const isManualFlow = await this.applicationStateService.getManualLlmEnabled();
61
+ await this.chatService.sendMessage(sessionInput.session_id, feedbackMessage, isManualFlow);
62
+ }
63
+ async handleHaltedPlan(sessionInput, context) {
64
+ this.logger.log(`Handling halted plan with follow-up action: ${context.followUpAction.type}`);
65
+ switch (context.followUpAction.type) {
66
+ case 'AUTO_CONTEXT_FETCH':
67
+ await this.handleAutoContextFetch(sessionInput, context.followUpAction.data);
68
+ break;
69
+ case 'NEW_SESSION':
70
+ await this.handleNewSession(context.followUpAction.data);
71
+ break;
72
+ default:
73
+ this.logger.warn(`Unknown follow-up action type: ${context.followUpAction.type}`);
74
+ }
75
+ }
76
+ async handleAutoContextFetch(originalInput, data) {
77
+ const session = await this.sessionsService.findOne(originalInput.session_id);
78
+ const newDto = {
79
+ user_prompt: '',
80
+ execution_strategy: originalInput.execution_strategy,
81
+ ad_hoc_context_definition: JSON.stringify(data),
82
+ context_template_id: session.default_followup_context_template_id,
83
+ };
84
+ this.logger.log(`Auto Context Fetch is re-submitting for session ${originalInput.session_id}.`);
85
+ await this.sessionInputsService.create(originalInput.session_id, newDto);
86
+ }
87
+ async handleNewSession(data) {
88
+ this.eventsGateway.sendToAll('external-new-session', {});
89
+ const defaultSystemPrompt = await this.systemPromptsService.findDefault();
90
+ if (defaultSystemPrompt?.prompt_content) {
91
+ await new Promise((resolve) => setTimeout(resolve, 1000));
92
+ this.eventsGateway.sendToAll('system-prompt-update', {
93
+ content: defaultSystemPrompt.prompt_content,
94
+ });
95
+ }
96
+ const newSession = await this.sessionsService.create({
97
+ session_title: 'Handover Session',
98
+ });
99
+ if (data.handover_string) {
100
+ const executionStrategy = await this.applicationStateService.getExecutionStrategy();
101
+ await new Promise((resolve) => setTimeout(resolve, 1000));
102
+ this.sessionInputsService
103
+ .create(newSession.id, {
104
+ user_prompt: data.handover_string,
105
+ execution_strategy: executionStrategy,
106
+ context_template_id: newSession.default_initial_context_template_id,
107
+ })
108
+ .catch((err) => {
109
+ this.logger.error(`Error creating initial session input from handover: ${err.message}`, err.stack);
110
+ });
111
+ }
112
+ await new Promise((resolve) => setTimeout(resolve, 1000));
113
+ this.eventsGateway.sendToAll('session-created', {
114
+ sessionId: newSession.id,
115
+ });
116
+ }
117
+ async handleCommandOutputs(sessionInput, context) {
118
+ let followUpMessage = 'The previous plan produced the following outputs. Please analyze them and continue with the next logical step.\n\n';
119
+ for (const cmd of context.outputs.commands) {
120
+ followUpMessage += `--- Output from: \`run_command\` ---\n`;
121
+ followUpMessage += `Command: ${cmd.command}\nOutput:\n${cmd.output}\n\n`;
122
+ }
123
+ for (const tool of context.outputs.mcp_tools) {
124
+ followUpMessage += `--- Output from: \`use_mcp_tool\` ---\n`;
125
+ followUpMessage += `Tool: ${tool.tool_name}\nOutput:\n${tool.output}\n\n`;
126
+ }
127
+ this.logger.log('Triggering follow-up AI call with consolidated outputs.');
128
+ const isManualFlow = await this.applicationStateService.getManualLlmEnabled();
129
+ await this.chatService.sendMessage(sessionInput.session_id, followUpMessage, isManualFlow);
130
+ }
131
+ };
132
+ exports.FollowUpPostExecutionHook = FollowUpPostExecutionHook;
133
+ exports.FollowUpPostExecutionHook = FollowUpPostExecutionHook = FollowUpPostExecutionHook_1 = __decorate([
134
+ (0, common_1.Injectable)(),
135
+ __param(0, (0, common_1.Inject)((0, common_1.forwardRef)(() => chat_service_1.ChatService))),
136
+ __param(1, (0, common_1.Inject)((0, common_1.forwardRef)(() => session_inputs_service_1.SessionInputsService))),
137
+ __metadata("design:paramtypes", [chat_service_1.ChatService,
138
+ session_inputs_service_1.SessionInputsService,
139
+ events_gateway_1.EventsGateway,
140
+ system_prompts_service_1.SystemPromptsService,
141
+ sessions_service_1.SessionsService,
142
+ application_state_service_1.ApplicationStateService])
143
+ ], FollowUpPostExecutionHook);
144
+ //# sourceMappingURL=follow-up-post-execution.hook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"follow-up-post-execution.hook.js","sourceRoot":"","sources":["../../../../src/llm-orchestration/hooks/follow-up-post-execution.hook.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwE;AAIxE,sEAAkE;AAClE,wFAAmF;AACnF,gEAA4D;AAC5D,wFAAmF;AACnF,sEAAkE;AAClE,iGAA4F;AAIrF,IAAM,yBAAyB,iCAA/B,MAAM,yBAAyB;IAGpC,YAEE,WAAyC,EAEzC,oBAA2D,EAC1C,aAA4B,EAC5B,oBAA0C,EAC1C,eAAgC,EAChC,uBAAgD;QANhD,gBAAW,GAAX,WAAW,CAAa;QAExB,yBAAoB,GAApB,oBAAoB,CAAsB;QAC1C,kBAAa,GAAb,aAAa,CAAe;QAC5B,yBAAoB,GAApB,oBAAoB,CAAsB;QAC1C,oBAAe,GAAf,eAAe,CAAiB;QAChC,4BAAuB,GAAvB,uBAAuB,CAAyB;QAVlD,WAAM,GAAG,IAAI,eAAM,CAAC,2BAAyB,CAAC,IAAI,CAAC,CAAC;IAWlE,CAAC;IAEJ,KAAK,CAAC,GAAG,CACP,YAA0B,EAC1B,OAA6B;QAG7B,IAAI,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACjD,MAAM,IAAI,CAAC,wBAAwB,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;YAC3D,OAAO,CAAC,KAAK,CAAC,mBAAmB,GAAG,IAAI,CAAC;YACzC,OAAO;QACT,CAAC;QAGD,IAAI,OAAO,CAAC,KAAK,CAAC,WAAW,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;YACxD,MAAM,IAAI,CA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GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;YAC3C,eAAe,IAAI,wCAAwC,CAAC;YAC5D,eAAe,IAAI,YAAY,GAAG,CAAC,OAAO,cAAc,GAAG,CAAC,MAAM,MAAM,CAAC;QAC3E,CAAC;QAED,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;YAC7C,eAAe,IAAI,yCAAyC,CAAC;YAC7D,eAAe,IAAI,SAAS,IAAI,CAAC,SAAS,cAAc,IAAI,CAAC,MAAM,MAAM,CAAC;QAC5E,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,yDAAyD,CAAC,CAAC;QAC3E,MAAM,YAAY,GAChB,MAAM,IAAI,CAAC,uBAAuB,CAAC,mBAAmB,EAAE,CAAC;QAC3D,MAAM,IAAI,CAAC,WAAW,CAAC,WAAW,CAChC,YAAY,CAAC,UAAU,EACvB,eAAe,EACf,YAAY,CACb,CAAC;IACJ,CAAC;CACF,CAAA;AApLY,8DAAyB;oCAAzB,yBAAyB;IADrC,IAAA,mBAAU,GAAE;IAKR,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,0BAAW,CAAC,CAAC,CAAA;IAErC,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,6CAAoB,CAAC,CAAC,CAAA;qCADjB,0BAAW;QAEF,6CAAoB;QAC3B,8BAAa;QACN,6CAAoB;QACzB,kCAAe;QACP,mDAAuB;GAXxD,yBAAyB,CAoLrC"}
@@ -0,0 +1,10 @@
1
+ import { PostExecutionHook } from './post-execution-hook.interface';
2
+ import { PlanExecutionContext } from '../llm-orchestration.interfaces';
3
+ import { SessionInput } from '../../core-entities';
4
+ import { EventsGateway } from '../../events/events.gateway';
5
+ export declare class FrontendNotificationHook implements PostExecutionHook {
6
+ private readonly eventsGateway;
7
+ private readonly logger;
8
+ constructor(eventsGateway: EventsGateway);
9
+ run(sessionInput: SessionInput, context: PlanExecutionContext): Promise<void>;
10
+ }
@@ -0,0 +1,38 @@
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
+ var FrontendNotificationHook_1;
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.FrontendNotificationHook = void 0;
14
+ const common_1 = require("@nestjs/common");
15
+ const events_gateway_1 = require("../../events/events.gateway");
16
+ let FrontendNotificationHook = FrontendNotificationHook_1 = class FrontendNotificationHook {
17
+ constructor(eventsGateway) {
18
+ this.eventsGateway = eventsGateway;
19
+ this.logger = new common_1.Logger(FrontendNotificationHook_1.name);
20
+ }
21
+ async run(sessionInput, context) {
22
+ if (context.flags.follow_up_initiated) {
23
+ this.logger.log('Skipping frontend notification because a follow-up action was initiated.');
24
+ return;
25
+ }
26
+ this.logger.log('Notifying frontend that plan is ready for review.');
27
+ this.eventsGateway.sendToAll('plan-ready', {
28
+ sessionId: sessionInput.session_id,
29
+ inputId: sessionInput.id,
30
+ });
31
+ }
32
+ };
33
+ exports.FrontendNotificationHook = FrontendNotificationHook;
34
+ exports.FrontendNotificationHook = FrontendNotificationHook = FrontendNotificationHook_1 = __decorate([
35
+ (0, common_1.Injectable)(),
36
+ __metadata("design:paramtypes", [events_gateway_1.EventsGateway])
37
+ ], FrontendNotificationHook);
38
+ //# sourceMappingURL=frontend-notification.hook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frontend-notification.hook.js","sourceRoot":"","sources":["../../../../src/llm-orchestration/hooks/frontend-notification.hook.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AAIpD,gEAA4D;AAGrD,IAAM,wBAAwB,gCAA9B,MAAM,wBAAwB;IAGnC,YAA6B,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;QAFxC,WAAM,GAAG,IAAI,eAAM,CAAC,0BAAwB,CAAC,IAAI,CAAC,CAAC;IAER,CAAC;IAE7D,KAAK,CAAC,GAAG,CACP,YAA0B,EAC1B,OAA6B;QAI7B,IAAI,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE,CAAC;YACtC,IAAI,CAAC,MAAM,CAAC,GAAG,CACb,0EAA0E,CAC3E,CAAC;YACF,OAAO;QACT,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,mDAAmD,CAAC,CAAC;QACrE,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,YAAY,EAAE;YACzC,SAAS,EAAE,YAAY,CAAC,UAAU;YAClC,OAAO,EAAE,YAAY,CAAC,EAAE;SACzB,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAxBY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,mBAAU,GAAE;qCAIiC,8BAAa;GAH9C,wBAAwB,CAwBpC"}
@@ -0,0 +1,5 @@
1
+ import { SessionInput } from '../../core-entities';
2
+ import { PlanExecutionContext } from '../llm-orchestration.interfaces';
3
+ export interface PostExecutionHook {
4
+ run(sessionInput: SessionInput, context: PlanExecutionContext): Promise<void>;
5
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=post-execution-hook.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"post-execution-hook.interface.js","sourceRoot":"","sources":["../../../../src/llm-orchestration/hooks/post-execution-hook.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,12 @@
1
+ import { PostExecutionHook } from './post-execution-hook.interface';
2
+ import { PlanExecutionContext } from '../llm-orchestration.interfaces';
3
+ import { SessionInput } from '../../core-entities';
4
+ import { ApplicationStateService } from '../../application-state/application-state.service';
5
+ import { ChatService } from '../../interactive-chat/chat.service';
6
+ export declare class YoloModePostExecutionHook implements PostExecutionHook {
7
+ private readonly appStateService;
8
+ private readonly chatService;
9
+ private readonly logger;
10
+ constructor(appStateService: ApplicationStateService, chatService: ChatService);
11
+ run(sessionInput: SessionInput, context: PlanExecutionContext): Promise<void>;
12
+ }
@@ -0,0 +1,55 @@
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
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var YoloModePostExecutionHook_1;
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.YoloModePostExecutionHook = void 0;
17
+ const common_1 = require("@nestjs/common");
18
+ const application_state_service_1 = require("../../application-state/application-state.service");
19
+ const chat_service_1 = require("../../interactive-chat/chat.service");
20
+ const FILE_MODIFICATION_ACTIONS = ['create_file', 'edit_file', 'delete_file'];
21
+ let YoloModePostExecutionHook = YoloModePostExecutionHook_1 = class YoloModePostExecutionHook {
22
+ constructor(appStateService, chatService) {
23
+ this.appStateService = appStateService;
24
+ this.chatService = chatService;
25
+ this.logger = new common_1.Logger(YoloModePostExecutionHook_1.name);
26
+ }
27
+ async run(sessionInput, context) {
28
+ const isYoloMode = await this.appStateService.getYoloModeEnabled();
29
+ if (!isYoloMode) {
30
+ return;
31
+ }
32
+ const hasFinalAction = context.originalParsedActions.some((a) => a.tool_name === 'final');
33
+ if (hasFinalAction) {
34
+ this.logger.log('YOLO mode: "final" action detected. Disabling YOLO mode.');
35
+ await this.appStateService.setYoloModeEnabled(false);
36
+ return;
37
+ }
38
+ const hasFileModification = context.originalParsedActions.some((a) => FILE_MODIFICATION_ACTIONS.includes(a.tool_name));
39
+ if (hasFileModification) {
40
+ this.logger.log('YOLO mode: File modification detected. Triggering "yolo" prompt.');
41
+ const isManualFlow = await this.appStateService.getManualLlmEnabled();
42
+ this.chatService
43
+ .sendMessage(sessionInput.session_id, 'yolo', isManualFlow)
44
+ .catch((err) => this.logger.error(`YOLO follow-up failed: ${err.message}`));
45
+ }
46
+ }
47
+ };
48
+ exports.YoloModePostExecutionHook = YoloModePostExecutionHook;
49
+ exports.YoloModePostExecutionHook = YoloModePostExecutionHook = YoloModePostExecutionHook_1 = __decorate([
50
+ (0, common_1.Injectable)(),
51
+ __param(1, (0, common_1.Inject)((0, common_1.forwardRef)(() => chat_service_1.ChatService))),
52
+ __metadata("design:paramtypes", [application_state_service_1.ApplicationStateService,
53
+ chat_service_1.ChatService])
54
+ ], YoloModePostExecutionHook);
55
+ //# sourceMappingURL=yolo-mode-post-execution.hook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"yolo-mode-post-execution.hook.js","sourceRoot":"","sources":["../../../../src/llm-orchestration/hooks/yolo-mode-post-execution.hook.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwE;AAIxE,iGAA4F;AAC5F,sEAAkE;AAElE,MAAM,yBAAyB,GAAG,CAAC,aAAa,EAAE,WAAW,EA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AM,CAAC,KAAK,CAAC,0BAA0B,GAAG,CAAC,OAAO,EAAE,CAAC,CAC3D,CAAC;QACN,CAAC;IACH,CAAC;CACF,CAAA;AA9CY,8DAAyB;oCAAzB,yBAAyB;IADrC,IAAA,mBAAU,GAAE;IAMR,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,0BAAW,CAAC,CAAC,CAAA;qCADJ,mDAAuB;QAE3B,0BAAW;GANhC,yBAAyB,CA8CrC"}
@@ -0,0 +1,52 @@
1
+ export interface Action {
2
+ tool_name: string;
3
+ arguments: {
4
+ [key: string]: any;
5
+ };
6
+ }
7
+ export interface ParsedLlmOutput {
8
+ explanation: string | null;
9
+ actions: Action[];
10
+ }
11
+ export interface ActionExecutionResult {
12
+ status: 'SUCCESS' | 'FAILURE';
13
+ summary: string;
14
+ persisted_args: {
15
+ [key: string]: any;
16
+ };
17
+ error_message?: string;
18
+ original_content_for_revert?: string | null;
19
+ execution_log?: {
20
+ output?: string;
21
+ error_message?: string;
22
+ };
23
+ }
24
+ export declare class PlanExecutionContext {
25
+ originalParsedActions: Action[];
26
+ outputs: {
27
+ commands: {
28
+ command: string;
29
+ output: string;
30
+ }[];
31
+ mcp_tools: {
32
+ tool_name: string;
33
+ output: string;
34
+ }[];
35
+ };
36
+ feedback: {
37
+ validationErrors: {
38
+ tool_name: string;
39
+ error: string;
40
+ }[];
41
+ };
42
+ flags: {
43
+ should_halt: boolean;
44
+ halt_reason?: 'CONTEXT_REQUESTED' | 'VALIDATION_FAILED' | 'NEW_SESSION';
45
+ is_final: boolean;
46
+ follow_up_initiated: boolean;
47
+ };
48
+ followUpAction?: {
49
+ type: 'AUTO_CONTEXT_FETCH' | 'NEW_SESSION';
50
+ data: any;
51
+ };
52
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PlanExecutionContext = void 0;
4
+ class PlanExecutionContext {
5
+ constructor() {
6
+ this.originalParsedActions = [];
7
+ this.outputs = { commands: [], mcp_tools: [] };
8
+ this.feedback = { validationErrors: [] };
9
+ this.flags = { should_halt: false, is_final: false, follow_up_initiated: false };
10
+ }
11
+ }
12
+ exports.PlanExecutionContext = PlanExecutionContext;
13
+ //# sourceMappingURL=llm-orchestration.interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llm-orchestration.interfaces.js","sourceRoot":"","sources":["../../../src/llm-orchestration/llm-orchestration.interfaces.ts"],"names":[],"mappings":";;;AAqDA,MAAa,oBAAoB;IAAjC;QAEE,0BAAqB,GAAa,EAAE,CAAC;QAGrC,YAAO,GAGH,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;QAGpC,aAAQ,GAEJ,EAAE,gBAAgB,EAAE,EAAE,EAAE,CAAC;QAG7B,UAAK,GAKD,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,CAAC;IAO1E,CAAC;CAAA;AA5BD,oDA4BC"}
@@ -0,0 +1,2 @@
1
+ export declare class LlmOrchestrationModule {
2
+ }