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.
- package/CODEMAP.md +8 -8
- package/backend/.env +4 -0
- package/backend/dist/src/ai-actions/ai-action-batch.service.d.ts +10 -3
- package/backend/dist/src/ai-actions/ai-action-batch.service.js +134 -12
- package/backend/dist/src/ai-actions/ai-action-batch.service.js.map +1 -1
- package/backend/dist/src/ai-actions/ai-actions.module.js +2 -7
- package/backend/dist/src/ai-actions/ai-actions.module.js.map +1 -1
- package/backend/dist/src/ai-actions/ai-actions.service.d.ts +16 -3
- package/backend/dist/src/ai-actions/ai-actions.service.js +75 -11
- package/backend/dist/src/ai-actions/ai-actions.service.js.map +1 -1
- package/backend/dist/src/app.module.js +0 -4
- package/backend/dist/src/app.module.js.map +1 -1
- package/backend/dist/src/core-entities/ai-action.entity.d.ts +1 -0
- package/backend/dist/src/core-entities/ai-action.entity.js +4 -0
- package/backend/dist/src/core-entities/ai-action.entity.js.map +1 -1
- package/backend/dist/src/llm-orchestration/action-handlers/action-handler.interface.d.ts +7 -0
- package/backend/dist/src/llm-orchestration/action-handlers/action-handler.interface.js +3 -0
- package/backend/dist/src/llm-orchestration/action-handlers/action-handler.interface.js.map +1 -0
- package/backend/dist/src/llm-orchestration/action-handlers/create-file.handler.d.ts +11 -0
- package/backend/dist/src/llm-orchestration/action-handlers/create-file.handler.js +65 -0
- package/backend/dist/src/llm-orchestration/action-handlers/create-file.handler.js.map +1 -0
- package/backend/dist/src/llm-orchestration/action-handlers/delete-file.handler.d.ts +12 -0
- package/backend/dist/src/llm-orchestration/action-handlers/delete-file.handler.js +85 -0
- package/backend/dist/src/llm-orchestration/action-handlers/delete-file.handler.js.map +1 -0
- package/backend/dist/src/llm-orchestration/action-handlers/dto/create-file.args.dto.d.ts +4 -0
- package/backend/dist/src/llm-orchestration/action-handlers/dto/create-file.args.dto.js +29 -0
- package/backend/dist/src/llm-orchestration/action-handlers/dto/create-file.args.dto.js.map +1 -0
- package/backend/dist/src/llm-orchestration/action-handlers/dto/delete-file.args.dto.d.ts +3 -0
- package/backend/dist/src/llm-orchestration/action-handlers/dto/delete-file.args.dto.js +22 -0
- package/backend/dist/src/llm-orchestration/action-handlers/dto/delete-file.args.dto.js.map +1 -0
- package/backend/dist/src/llm-orchestration/action-handlers/dto/edit-file.args.dto.d.ts +4 -0
- package/backend/dist/src/llm-orchestration/action-handlers/dto/edit-file.args.dto.js +29 -0
- package/backend/dist/src/llm-orchestration/action-handlers/dto/edit-file.args.dto.js.map +1 -0
- package/backend/dist/src/llm-orchestration/action-handlers/dto/final.args.dto.d.ts +3 -0
- package/backend/dist/src/{llm-response-parser/llm-response-parser.module.js → llm-orchestration/action-handlers/dto/final.args.dto.js} +14 -13
- package/backend/dist/src/llm-orchestration/action-handlers/dto/final.args.dto.js.map +1 -0
- package/backend/dist/src/llm-orchestration/action-handlers/dto/new-session.args.dto.d.ts +3 -0
- package/backend/dist/src/llm-orchestration/action-handlers/dto/new-session.args.dto.js +22 -0
- package/backend/dist/src/llm-orchestration/action-handlers/dto/new-session.args.dto.js.map +1 -0
- package/backend/dist/src/llm-orchestration/action-handlers/dto/quick-edit.args.dto.d.ts +6 -0
- package/backend/dist/src/llm-orchestration/action-handlers/dto/quick-edit.args.dto.js +46 -0
- package/backend/dist/src/llm-orchestration/action-handlers/dto/quick-edit.args.dto.js.map +1 -0
- package/backend/dist/src/llm-orchestration/action-handlers/dto/request-context.args.dto.d.ts +11 -0
- package/backend/dist/src/llm-orchestration/action-handlers/dto/request-context.args.dto.js +50 -0
- package/backend/dist/src/llm-orchestration/action-handlers/dto/request-context.args.dto.js.map +1 -0
- package/backend/dist/src/llm-orchestration/action-handlers/dto/run-command.args.dto.d.ts +4 -0
- package/backend/dist/src/llm-orchestration/action-handlers/dto/run-command.args.dto.js +27 -0
- package/backend/dist/src/llm-orchestration/action-handlers/dto/run-command.args.dto.js.map +1 -0
- package/backend/dist/src/llm-orchestration/action-handlers/dto/sanitizer.decorator.d.ts +1 -0
- package/backend/dist/src/llm-orchestration/action-handlers/dto/sanitizer.decorator.js +15 -0
- package/backend/dist/src/llm-orchestration/action-handlers/dto/sanitizer.decorator.js.map +1 -0
- package/backend/dist/src/llm-orchestration/action-handlers/dto/use-mcp-tool.args.dto.d.ts +5 -0
- package/backend/dist/src/llm-orchestration/action-handlers/dto/use-mcp-tool.args.dto.js +49 -0
- package/backend/dist/src/llm-orchestration/action-handlers/dto/use-mcp-tool.args.dto.js.map +1 -0
- package/backend/dist/src/llm-orchestration/action-handlers/edit-file.handler.d.ts +12 -0
- package/backend/dist/src/llm-orchestration/action-handlers/edit-file.handler.js +78 -0
- package/backend/dist/src/llm-orchestration/action-handlers/edit-file.handler.js.map +1 -0
- package/backend/dist/src/llm-orchestration/action-handlers/final.handler.d.ts +8 -0
- package/backend/dist/src/llm-orchestration/action-handlers/final.handler.js +40 -0
- package/backend/dist/src/llm-orchestration/action-handlers/final.handler.js.map +1 -0
- package/backend/dist/src/llm-orchestration/action-handlers/new-session.handler.d.ts +8 -0
- package/backend/dist/src/llm-orchestration/action-handlers/new-session.handler.js +45 -0
- package/backend/dist/src/llm-orchestration/action-handlers/new-session.handler.js.map +1 -0
- package/backend/dist/src/llm-orchestration/action-handlers/quick-edit.handler.d.ts +12 -0
- package/backend/dist/src/llm-orchestration/action-handlers/quick-edit.handler.js +133 -0
- package/backend/dist/src/llm-orchestration/action-handlers/quick-edit.handler.js.map +1 -0
- package/backend/dist/src/llm-orchestration/action-handlers/request-context.handler.d.ts +8 -0
- package/backend/dist/src/llm-orchestration/action-handlers/request-context.handler.js +49 -0
- package/backend/dist/src/llm-orchestration/action-handlers/request-context.handler.js.map +1 -0
- package/backend/dist/src/llm-orchestration/action-handlers/run-command.handler.d.ts +10 -0
- package/backend/dist/src/llm-orchestration/action-handlers/run-command.handler.js +73 -0
- package/backend/dist/src/llm-orchestration/action-handlers/run-command.handler.js.map +1 -0
- package/backend/dist/src/llm-orchestration/action-handlers/use-mcp-tool.handler.d.ts +12 -0
- package/backend/dist/src/llm-orchestration/action-handlers/use-mcp-tool.handler.js +61 -0
- package/backend/dist/src/llm-orchestration/action-handlers/use-mcp-tool.handler.js.map +1 -0
- package/backend/dist/src/llm-orchestration/errors/handler-validation.error.d.ts +4 -0
- package/backend/dist/src/llm-orchestration/errors/handler-validation.error.js +12 -0
- package/backend/dist/src/llm-orchestration/errors/handler-validation.error.js.map +1 -0
- package/backend/dist/src/llm-orchestration/hooks/follow-up-post-execution.hook.d.ts +25 -0
- package/backend/dist/src/llm-orchestration/hooks/follow-up-post-execution.hook.js +144 -0
- package/backend/dist/src/llm-orchestration/hooks/follow-up-post-execution.hook.js.map +1 -0
- package/backend/dist/src/llm-orchestration/hooks/frontend-notification.hook.d.ts +10 -0
- package/backend/dist/src/llm-orchestration/hooks/frontend-notification.hook.js +38 -0
- package/backend/dist/src/llm-orchestration/hooks/frontend-notification.hook.js.map +1 -0
- package/backend/dist/src/llm-orchestration/hooks/post-execution-hook.interface.d.ts +5 -0
- package/backend/dist/src/llm-orchestration/hooks/post-execution-hook.interface.js +3 -0
- package/backend/dist/src/llm-orchestration/hooks/post-execution-hook.interface.js.map +1 -0
- package/backend/dist/src/llm-orchestration/hooks/yolo-mode-post-execution.hook.d.ts +12 -0
- package/backend/dist/src/llm-orchestration/hooks/yolo-mode-post-execution.hook.js +55 -0
- package/backend/dist/src/llm-orchestration/hooks/yolo-mode-post-execution.hook.js.map +1 -0
- package/backend/dist/src/llm-orchestration/llm-orchestration.interfaces.d.ts +52 -0
- package/backend/dist/src/llm-orchestration/llm-orchestration.interfaces.js +13 -0
- package/backend/dist/src/llm-orchestration/llm-orchestration.interfaces.js.map +1 -0
- package/backend/dist/src/llm-orchestration/llm-orchestration.module.d.ts +2 -0
- package/backend/dist/src/llm-orchestration/llm-orchestration.module.js +90 -0
- package/backend/dist/src/llm-orchestration/llm-orchestration.module.js.map +1 -0
- package/backend/dist/src/llm-orchestration/llm-turn-processor.service.d.ts +20 -0
- package/backend/dist/src/llm-orchestration/llm-turn-processor.service.js +156 -0
- package/backend/dist/src/llm-orchestration/llm-turn-processor.service.js.map +1 -0
- package/backend/dist/src/llm-orchestration/parser/llm-output-parser.service.d.ts +5 -0
- package/backend/dist/src/llm-orchestration/parser/llm-output-parser.service.js +105 -0
- package/backend/dist/src/llm-orchestration/parser/llm-output-parser.service.js.map +1 -0
- package/backend/dist/src/llm-orchestration/parser/parsing.constants.d.ts +7 -0
- package/backend/dist/src/llm-orchestration/parser/parsing.constants.js +11 -0
- package/backend/dist/src/llm-orchestration/parser/parsing.constants.js.map +1 -0
- package/backend/dist/src/llm-responses/llm-responses.module.js +2 -0
- package/backend/dist/src/llm-responses/llm-responses.module.js.map +1 -1
- package/backend/dist/src/llm-responses/llm-responses.service.d.ts +3 -6
- package/backend/dist/src/llm-responses/llm-responses.service.js +9 -112
- package/backend/dist/src/llm-responses/llm-responses.service.js.map +1 -1
- package/backend/dist/src/seeding/data/system-prompts/carryover-agent.d.ts +1 -1
- package/backend/dist/src/seeding/data/system-prompts/carryover-agent.js +8 -8
- package/backend/dist/src/seeding/data/system-prompts/default_master-agent.d.ts +1 -1
- package/backend/dist/src/seeding/data/system-prompts/default_master-agent.js +184 -91
- package/backend/dist/src/seeding/data/system-prompts/default_master-agent.js.map +1 -1
- package/backend/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/backend/dist/src/action-execution/action-execution.module.d.ts +0 -2
- package/backend/dist/src/action-execution/action-execution.module.js +0 -23
- package/backend/dist/src/action-execution/action-execution.module.js.map +0 -1
- package/backend/dist/src/action-execution/action-execution.service.d.ts +0 -19
- package/backend/dist/src/action-execution/action-execution.service.js +0 -149
- package/backend/dist/src/action-execution/action-execution.service.js.map +0 -1
- package/backend/dist/src/ai-actions/ai-action-creation.service.d.ts +0 -29
- package/backend/dist/src/ai-actions/ai-action-creation.service.js +0 -416
- package/backend/dist/src/ai-actions/ai-action-creation.service.js.map +0 -1
- package/backend/dist/src/llm-response-parser/dto/ai-action.dto.d.ts +0 -30
- package/backend/dist/src/llm-response-parser/dto/ai-action.dto.js +0 -162
- package/backend/dist/src/llm-response-parser/dto/ai-action.dto.js.map +0 -1
- package/backend/dist/src/llm-response-parser/errors/parsing.error.d.ts +0 -4
- package/backend/dist/src/llm-response-parser/errors/parsing.error.js +0 -13
- package/backend/dist/src/llm-response-parser/errors/parsing.error.js.map +0 -1
- package/backend/dist/src/llm-response-parser/llm-response-parser.module.d.ts +0 -2
- package/backend/dist/src/llm-response-parser/llm-response-parser.module.js.map +0 -1
- package/backend/dist/src/llm-response-parser/llm-response-parser.service.d.ts +0 -9
- package/backend/dist/src/llm-response-parser/llm-response-parser.service.js +0 -215
- package/backend/dist/src/llm-response-parser/llm-response-parser.service.js.map +0 -1
- package/backend/dist/src/llm-response-parser/parsing.constants.d.ts +0 -20
- package/backend/dist/src/llm-response-parser/parsing.constants.js +0 -24
- package/backend/dist/src/llm-response-parser/parsing.constants.js.map +0 -1
|
@@ -0,0 +1,90 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.LlmOrchestrationModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
12
|
+
const core_entities_1 = require("../core-entities");
|
|
13
|
+
const llm_output_parser_service_1 = require("./parser/llm-output-parser.service");
|
|
14
|
+
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");
|
|
19
|
+
const session_inputs_module_1 = require("../session-inputs/session-inputs.module");
|
|
20
|
+
const events_module_1 = require("../events/events.module");
|
|
21
|
+
const system_prompts_module_1 = require("../system-prompts/system-prompts.module");
|
|
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");
|
|
28
|
+
const mcp_module_1 = require("../mcp/mcp.module");
|
|
29
|
+
const frontend_notification_hook_1 = require("./hooks/frontend-notification.hook");
|
|
30
|
+
const create_file_handler_1 = require("./action-handlers/create-file.handler");
|
|
31
|
+
const edit_file_handler_1 = require("./action-handlers/edit-file.handler");
|
|
32
|
+
const delete_file_handler_1 = require("./action-handlers/delete-file.handler");
|
|
33
|
+
const execution_logs_module_1 = require("../execution-logs/execution-logs.module");
|
|
34
|
+
const quick_edit_handler_1 = require("./action-handlers/quick-edit.handler");
|
|
35
|
+
const actionHandlers = [
|
|
36
|
+
create_file_handler_1.CreateFileHandler,
|
|
37
|
+
edit_file_handler_1.EditFileHandler,
|
|
38
|
+
delete_file_handler_1.DeleteFileHandler,
|
|
39
|
+
quick_edit_handler_1.QuickEditHandler,
|
|
40
|
+
run_command_handler_1.RunCommandHandler,
|
|
41
|
+
use_mcp_tool_handler_1.UseMcpToolHandler,
|
|
42
|
+
request_context_handler_1.RequestContextHandler,
|
|
43
|
+
new_session_handler_1.NewSessionHandler,
|
|
44
|
+
final_handler_1.FinalHandler,
|
|
45
|
+
];
|
|
46
|
+
const postExecutionHooks = [
|
|
47
|
+
follow_up_post_execution_hook_1.FollowUpPostExecutionHook,
|
|
48
|
+
yolo_mode_post_execution_hook_1.YoloModePostExecutionHook,
|
|
49
|
+
frontend_notification_hook_1.FrontendNotificationHook,
|
|
50
|
+
];
|
|
51
|
+
let LlmOrchestrationModule = class LlmOrchestrationModule {
|
|
52
|
+
};
|
|
53
|
+
exports.LlmOrchestrationModule = LlmOrchestrationModule;
|
|
54
|
+
exports.LlmOrchestrationModule = LlmOrchestrationModule = __decorate([
|
|
55
|
+
(0, common_1.Module)({
|
|
56
|
+
imports: [
|
|
57
|
+
typeorm_1.TypeOrmModule.forFeature([core_entities_1.AIAction, core_entities_1.SessionInput]),
|
|
58
|
+
application_state_module_1.ApplicationStateModule,
|
|
59
|
+
(0, common_1.forwardRef)(() => chat_module_1.InteractiveChatModule),
|
|
60
|
+
(0, common_1.forwardRef)(() => session_inputs_module_1.SessionInputsModule),
|
|
61
|
+
events_module_1.EventsModule,
|
|
62
|
+
system_prompts_module_1.SystemPromptsModule,
|
|
63
|
+
sessions_module_1.SessionsModule,
|
|
64
|
+
mcp_module_1.McpModule,
|
|
65
|
+
execution_logs_module_1.ExecutionLogsModule,
|
|
66
|
+
],
|
|
67
|
+
providers: [
|
|
68
|
+
llm_output_parser_service_1.LlmOutputParserService,
|
|
69
|
+
llm_turn_processor_service_1.LlmTurnProcessorService,
|
|
70
|
+
...actionHandlers,
|
|
71
|
+
...postExecutionHooks,
|
|
72
|
+
{
|
|
73
|
+
provide: 'ACTION_HANDLER_REGISTRY',
|
|
74
|
+
useFactory: (...handlers) => {
|
|
75
|
+
const registry = new Map();
|
|
76
|
+
handlers.forEach((handler) => registry.set(handler.toolName, handler));
|
|
77
|
+
return registry;
|
|
78
|
+
},
|
|
79
|
+
inject: actionHandlers,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
provide: 'POST_EXECUTION_HOOKS',
|
|
83
|
+
useFactory: (...hooks) => hooks,
|
|
84
|
+
inject: postExecutionHooks,
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
exports: [llm_turn_processor_service_1.LlmTurnProcessorService],
|
|
88
|
+
})
|
|
89
|
+
], LlmOrchestrationModule);
|
|
90
|
+
//# sourceMappingURL=llm-orchestration.module.js.map
|
|
@@ -0,0 +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;AAGxE,MAAM,cAAc,GAAG;IACrB,uCAAiB;IACjB,mCAAe;IACf,uCAAiB;IACjB,qCAAgB;IAChB,uCAAiB;IACjB,wCAAiB;IACjB,+CAAqB;IACrB,uCAAiB;IACjB,4BAAY;CACb,CAAC;AAEF,MAAM,kBAAkB,GAAG;IACzB,yDAAyB;IACzB,yDAAyB;IACzB,qDAAwB;CACzB,CAAC;AAqCK,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;CAAG,CAAA;AAAzB,wDAAsB;iCAAtB,sBAAsB;IAlClC,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,uBAAa,CAAC,UAAU,CAAC,CAAC,wBAAQ,EAAE,4BAAY,CAAC,CAAC;YAClD,iDAAsB;YACtB,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,mCAAqB,CAAC;YACvC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,2CAAmB,CAAC;YACrC,4BAAY;YACZ,2CAAmB;YACnB,gCAAc;YACd,sBAAS;YACT,2CAAmB;SACpB;QACD,SAAS,EAAE;YACT,kDAAsB;YACtB,oDAAuB;YACvB,GAAG,cAAc;YACjB,GAAG,kBAAkB;YACrB;gBACE,OAAO,EAAE,yBAAyB;gBAClC,UAAU,EAAE,CAAC,GAAG,QAAyB,EAAE,EAAE;oBAC3C,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAyB,CAAC;oBAClD,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;oBACvE,OAAO,QAAQ,CAAC;gBAClB,CAAC;gBACD,MAAM,EAAE,cAAc;aACvB;YACD;gBACE,OAAO,EAAE,sBAAsB;gBAC/B,UAAU,EAAE,CAAC,GAAG,KAAK,EAAE,EAAE,CAAC,KAAK;gBAC/B,MAAM,EAAE,kBAAkB;aAC3B;SACF;QACD,OAAO,EAAE,CAAC,oDAAuB,CAAC;KACnC,CAAC;GACW,sBAAsB,CAAG"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Repository } from 'typeorm';
|
|
2
|
+
import { AIAction, SessionInput } from '../core-entities';
|
|
3
|
+
import { LlmOutputParserService } from './parser/llm-output-parser.service';
|
|
4
|
+
import { ActionHandler } from './action-handlers/action-handler.interface';
|
|
5
|
+
import { PostExecutionHook } from './hooks/post-execution-hook.interface';
|
|
6
|
+
import { ApplicationStateService } from '../application-state/application-state.service';
|
|
7
|
+
import { ExecutionLogsService } from '../execution-logs/execution-logs.service';
|
|
8
|
+
export declare class LlmTurnProcessorService {
|
|
9
|
+
private readonly parser;
|
|
10
|
+
private readonly handlerRegistry;
|
|
11
|
+
private readonly postExecutionHooks;
|
|
12
|
+
private readonly aiActionsRepository;
|
|
13
|
+
private readonly sessionInputsRepository;
|
|
14
|
+
private readonly applicationStateService;
|
|
15
|
+
private readonly executionLogsService;
|
|
16
|
+
private readonly logger;
|
|
17
|
+
constructor(parser: LlmOutputParserService, handlerRegistry: Map<string, ActionHandler>, postExecutionHooks: PostExecutionHook[], aiActionsRepository: Repository<AIAction>, sessionInputsRepository: Repository<SessionInput>, applicationStateService: ApplicationStateService, executionLogsService: ExecutionLogsService);
|
|
18
|
+
processTurn(sessionInput: SessionInput): Promise<SessionInput>;
|
|
19
|
+
private getSuccessStatusForStrategy;
|
|
20
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
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 LlmTurnProcessorService_1;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.LlmTurnProcessorService = void 0;
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
18
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
19
|
+
const typeorm_2 = require("typeorm");
|
|
20
|
+
const core_entities_1 = require("../core-entities");
|
|
21
|
+
const llm_output_parser_service_1 = require("./parser/llm-output-parser.service");
|
|
22
|
+
const llm_orchestration_interfaces_1 = require("./llm-orchestration.interfaces");
|
|
23
|
+
const handler_validation_error_1 = require("./errors/handler-validation.error");
|
|
24
|
+
const ai_actions_service_1 = require("../ai-actions/ai-actions.service");
|
|
25
|
+
const application_state_service_1 = require("../application-state/application-state.service");
|
|
26
|
+
const execution_logs_service_1 = require("../execution-logs/execution-logs.service");
|
|
27
|
+
let LlmTurnProcessorService = LlmTurnProcessorService_1 = class LlmTurnProcessorService {
|
|
28
|
+
constructor(parser, handlerRegistry, postExecutionHooks, aiActionsRepository, sessionInputsRepository, applicationStateService, executionLogsService) {
|
|
29
|
+
this.parser = parser;
|
|
30
|
+
this.handlerRegistry = handlerRegistry;
|
|
31
|
+
this.postExecutionHooks = postExecutionHooks;
|
|
32
|
+
this.aiActionsRepository = aiActionsRepository;
|
|
33
|
+
this.sessionInputsRepository = sessionInputsRepository;
|
|
34
|
+
this.applicationStateService = applicationStateService;
|
|
35
|
+
this.executionLogsService = executionLogsService;
|
|
36
|
+
this.logger = new common_1.Logger(LlmTurnProcessorService_1.name);
|
|
37
|
+
}
|
|
38
|
+
async processTurn(sessionInput) {
|
|
39
|
+
this.logger.log(`Starting new orchestration for input ${sessionInput.id}`);
|
|
40
|
+
const { explanation, actions: parsedActions } = await this.parser.parse(sessionInput.raw_llm_response);
|
|
41
|
+
sessionInput.llm_response_explanation = explanation;
|
|
42
|
+
await this.sessionInputsRepository.save(sessionInput);
|
|
43
|
+
const executionContext = new llm_orchestration_interfaces_1.PlanExecutionContext();
|
|
44
|
+
executionContext.originalParsedActions = parsedActions;
|
|
45
|
+
const createdActions = [];
|
|
46
|
+
for (const action of parsedActions) {
|
|
47
|
+
const handler = this.handlerRegistry.get(action.tool_name);
|
|
48
|
+
let result;
|
|
49
|
+
if (!handler) {
|
|
50
|
+
this.logger.warn(`No handler found for tool: ${action.tool_name}. Skipping.`);
|
|
51
|
+
result = {
|
|
52
|
+
status: 'FAILURE',
|
|
53
|
+
summary: `Tool '${action.tool_name}' is not a valid tool.`,
|
|
54
|
+
error_message: `No handler registered for tool name '${action.tool_name}'.`,
|
|
55
|
+
persisted_args: action.arguments,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
try {
|
|
60
|
+
result = await handler.execute(action.arguments, executionContext);
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
if (error instanceof handler_validation_error_1.HandlerValidationError) {
|
|
64
|
+
this.logger.warn(`Handler for ${action.tool_name} had a validation failure: ${error.validationErrors}`);
|
|
65
|
+
executionContext.feedback.validationErrors.push({
|
|
66
|
+
tool_name: action.tool_name,
|
|
67
|
+
error: error.validationErrors,
|
|
68
|
+
});
|
|
69
|
+
executionContext.flags.should_halt = true;
|
|
70
|
+
executionContext.flags.halt_reason = 'VALIDATION_FAILED';
|
|
71
|
+
result = {
|
|
72
|
+
status: 'FAILURE',
|
|
73
|
+
summary: `Tool arguments were invalid: ${error.validationErrors}`,
|
|
74
|
+
error_message: error.validationErrors,
|
|
75
|
+
persisted_args: action.arguments,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
this.logger.error(`Handler for ${action.tool_name} failed during execution: ${error.message}`, error.stack);
|
|
80
|
+
result = {
|
|
81
|
+
status: 'FAILURE',
|
|
82
|
+
summary: `An unexpected error occurred: ${error.message}`,
|
|
83
|
+
error_message: error.message,
|
|
84
|
+
persisted_args: action.arguments,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const executionStrategy = await this.applicationStateService.getExecutionStrategy();
|
|
90
|
+
this.logger.log(`Using execution strategy: ${executionStrategy}`);
|
|
91
|
+
const successStatus = this.getSuccessStatusForStrategy(executionStrategy);
|
|
92
|
+
const aiActionEntity = this.aiActionsRepository.create({
|
|
93
|
+
input_id: sessionInput.id,
|
|
94
|
+
sessionInput: { id: sessionInput.id },
|
|
95
|
+
action_type: action.tool_name,
|
|
96
|
+
status: result.status === 'SUCCESS'
|
|
97
|
+
? successStatus
|
|
98
|
+
: ai_actions_service_1.AIActionStatus.EXECUTION_FAILED,
|
|
99
|
+
order_of_execution: action.arguments['order_of_execution'] ?? createdActions.length,
|
|
100
|
+
original_content_for_revert: result.original_content_for_revert,
|
|
101
|
+
...result.persisted_args,
|
|
102
|
+
});
|
|
103
|
+
const savedAction = await this.aiActionsRepository.save(aiActionEntity);
|
|
104
|
+
createdActions.push(savedAction);
|
|
105
|
+
if (result.execution_log) {
|
|
106
|
+
await this.executionLogsService.createLog({
|
|
107
|
+
action_id: savedAction.id,
|
|
108
|
+
output: result.execution_log.output,
|
|
109
|
+
error_message: result.execution_log.error_message,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
if (executionContext.flags.should_halt) {
|
|
113
|
+
this.logger.log(`Execution context flagged to halt. Reason: ${executionContext.flags.halt_reason}. Ending plan execution early.`);
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
sessionInput.aiActions = createdActions;
|
|
118
|
+
this.logger.log(`Running ${this.postExecutionHooks.length} post-execution hooks.`);
|
|
119
|
+
for (const hook of this.postExecutionHooks) {
|
|
120
|
+
try {
|
|
121
|
+
await hook.run(sessionInput, executionContext);
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
this.logger.error(`Post-execution hook ${hook.constructor.name} failed: ${error.message}`, error.stack);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
this.logger.log(`Orchestration finished for input ${sessionInput.id}.`);
|
|
128
|
+
return this.sessionInputsRepository.save(sessionInput);
|
|
129
|
+
}
|
|
130
|
+
getSuccessStatusForStrategy(strategy) {
|
|
131
|
+
switch (strategy) {
|
|
132
|
+
case 'auto_apply':
|
|
133
|
+
return ai_actions_service_1.AIActionStatus.CONFIRMED_KEPT;
|
|
134
|
+
case 'review_first':
|
|
135
|
+
case 'apply_revert':
|
|
136
|
+
return ai_actions_service_1.AIActionStatus.APPLIED_PENDING_REVIEW;
|
|
137
|
+
default:
|
|
138
|
+
this.logger.warn(`Unknown execution strategy: '${strategy}'. Defaulting to APPLIED_PENDING_REVIEW.`);
|
|
139
|
+
return ai_actions_service_1.AIActionStatus.APPLIED_PENDING_REVIEW;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
exports.LlmTurnProcessorService = LlmTurnProcessorService;
|
|
144
|
+
exports.LlmTurnProcessorService = LlmTurnProcessorService = LlmTurnProcessorService_1 = __decorate([
|
|
145
|
+
(0, common_1.Injectable)(),
|
|
146
|
+
__param(1, (0, common_1.Inject)('ACTION_HANDLER_REGISTRY')),
|
|
147
|
+
__param(2, (0, common_1.Inject)('POST_EXECUTION_HOOKS')),
|
|
148
|
+
__param(3, (0, typeorm_1.InjectRepository)(core_entities_1.AIAction)),
|
|
149
|
+
__param(4, (0, typeorm_1.InjectRepository)(core_entities_1.SessionInput)),
|
|
150
|
+
__metadata("design:paramtypes", [llm_output_parser_service_1.LlmOutputParserService,
|
|
151
|
+
Map, Array, typeorm_2.Repository,
|
|
152
|
+
typeorm_2.Repository,
|
|
153
|
+
application_state_service_1.ApplicationStateService,
|
|
154
|
+
execution_logs_service_1.ExecutionLogsService])
|
|
155
|
+
], LlmTurnProcessorService);
|
|
156
|
+
//# sourceMappingURL=llm-turn-processor.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-turn-processor.service.js","sourceRoot":"","sources":["../../../src/llm-orchestration/llm-turn-processor.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAA4D;AAC5D,6CAAmD;AACnD,qCA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OAAO,mCAAc,CAAC,sBAAsB,CAAC;YAC/C;gBAEE,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,gCAAgC,QAAQ,0CAA0C,CACnF,CAAC;gBACF,OAAO,mCAAc,CAAC,sBAAsB,CAAC;QACjD,CAAC;IACH,CAAC;CACF,CAAA;AAjKY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,mBAAU,GAAE;IAMR,WAAA,IAAA,eAAM,EAAC,yBAAyB,CAAC,CAAA;IAEjC,WAAA,IAAA,eAAM,EAAC,sBAAsB,CAAC,CAAA;IAE9B,WAAA,IAAA,0BAAgB,EAAC,wBAAQ,CAAC,CAAA;IAE1B,WAAA,IAAA,0BAAgB,EAAC,4BAAY,CAAC,CAAA;qCAPN,kDAAsB;QAEb,GAAG,SAIC,oBAAU;QAEN,oBAAU;QACV,mDAAuB;QAC1B,6CAAoB;GAdlD,uBAAuB,CAiKnC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
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 LlmOutputParserService_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.LlmOutputParserService = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const parsing_constants_1 = require("./parsing.constants");
|
|
13
|
+
let LlmOutputParserService = LlmOutputParserService_1 = class LlmOutputParserService {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.logger = new common_1.Logger(LlmOutputParserService_1.name);
|
|
16
|
+
}
|
|
17
|
+
async parse(rawResponse) {
|
|
18
|
+
if (!rawResponse || rawResponse.trim() === '') {
|
|
19
|
+
return { explanation: null, actions: [] };
|
|
20
|
+
}
|
|
21
|
+
const firstActionStart = rawResponse.indexOf(parsing_constants_1.ACTION_ITEM_START_TAG);
|
|
22
|
+
let explanation = null;
|
|
23
|
+
let actionsPart = rawResponse;
|
|
24
|
+
if (firstActionStart > 0) {
|
|
25
|
+
explanation = rawResponse.substring(0, firstActionStart).trim();
|
|
26
|
+
actionsPart = rawResponse.substring(firstActionStart);
|
|
27
|
+
}
|
|
28
|
+
else if (firstActionStart === -1) {
|
|
29
|
+
if (!rawResponse.includes(parsing_constants_1.PARTIAL_ACTION_ITEM_END_TAG)) {
|
|
30
|
+
return { explanation: rawResponse.trim(), actions: [] };
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const actionBlocks = actionsPart
|
|
34
|
+
.split(parsing_constants_1.ACTION_ITEM_START_TAG)
|
|
35
|
+
.filter((block) => block.trim() !== '');
|
|
36
|
+
if (actionBlocks.length === 0) {
|
|
37
|
+
this.logger.log('No action item blocks found in the response.');
|
|
38
|
+
return { explanation, actions: [] };
|
|
39
|
+
}
|
|
40
|
+
const parsedActions = [];
|
|
41
|
+
for (const block of actionBlocks) {
|
|
42
|
+
try {
|
|
43
|
+
const endTagRegex = new RegExp(`${parsing_constants_1.PARTIAL_ACTION_ITEM_END_TAG}§?`);
|
|
44
|
+
const cleanBlock = block.split(endTagRegex)[0].trim();
|
|
45
|
+
const actionArgs = {};
|
|
46
|
+
const fieldRegex = /¦(.*?)¦/g;
|
|
47
|
+
const matches = [];
|
|
48
|
+
let match;
|
|
49
|
+
while ((match = fieldRegex.exec(cleanBlock)) !== null) {
|
|
50
|
+
matches.push({
|
|
51
|
+
key: match[1].trim(),
|
|
52
|
+
index: match.index,
|
|
53
|
+
markerLength: match[0].length,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
if (matches.length === 0) {
|
|
57
|
+
this.logger.warn(`Skipping block with no field markers.`);
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
for (let i = 0; i < matches.length; i++) {
|
|
61
|
+
const currentMatch = matches[i];
|
|
62
|
+
const nextMatch = matches[i + 1];
|
|
63
|
+
const valueStartIndex = currentMatch.index + currentMatch.markerLength;
|
|
64
|
+
const valueEndIndex = nextMatch ? nextMatch.index : cleanBlock.length;
|
|
65
|
+
const value = cleanBlock
|
|
66
|
+
.substring(valueStartIndex, valueEndIndex)
|
|
67
|
+
.trim();
|
|
68
|
+
actionArgs[currentMatch.key.toLowerCase()] = value;
|
|
69
|
+
}
|
|
70
|
+
const toolNameKey = parsing_constants_1.FIELD_TOOL_NAME.toLowerCase();
|
|
71
|
+
const toolName = actionArgs[toolNameKey];
|
|
72
|
+
if (!toolName || typeof toolName !== 'string') {
|
|
73
|
+
this.logger.warn(`Skipping action block due to missing or invalid 'tool_name'.`);
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
delete actionArgs[toolNameKey];
|
|
77
|
+
const newAction = {
|
|
78
|
+
tool_name: toolName,
|
|
79
|
+
arguments: actionArgs,
|
|
80
|
+
};
|
|
81
|
+
parsedActions.push(newAction);
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
this.logger.warn(`Skipping malformed action block due to error: ${error.message}`, `Block content: ${block.substring(0, 200)}...`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
parsedActions.sort((a, b) => {
|
|
88
|
+
const orderA = a.arguments[parsing_constants_1.FIELD_ORDER_OF_EXECUTION];
|
|
89
|
+
const orderB = b.arguments[parsing_constants_1.FIELD_ORDER_OF_EXECUTION];
|
|
90
|
+
if (orderA === undefined && orderB === undefined)
|
|
91
|
+
return 0;
|
|
92
|
+
if (orderA === undefined)
|
|
93
|
+
return 1;
|
|
94
|
+
if (orderB === undefined)
|
|
95
|
+
return -1;
|
|
96
|
+
return parseInt(orderA, 10) - parseInt(orderB, 10);
|
|
97
|
+
});
|
|
98
|
+
return { explanation, actions: parsedActions };
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
exports.LlmOutputParserService = LlmOutputParserService;
|
|
102
|
+
exports.LlmOutputParserService = LlmOutputParserService = LlmOutputParserService_1 = __decorate([
|
|
103
|
+
(0, common_1.Injectable)()
|
|
104
|
+
], LlmOutputParserService);
|
|
105
|
+
//# sourceMappingURL=llm-output-parser.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-output-parser.service.js","sourceRoot":"","sources":["../../../../src/llm-orchestration/parser/llm-output-parser.service.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAoD;AAEpD,2DAK6B;AAGtB,IAAM,sBAAsB,8BAA5B,MAAM,sBAAsB;IAA5B;QACY,WAAM,GAAG,IAAI,eAAM,CAAC,wBAAsB,CAAC,IAAI,CAAC,CAAC;IAkHpE,CAAC;IA1GC,KAAK,CAAC,KAAK,CAAC,WAAmB;QAC7B,IAAI,CAAC,WAAW,IAAI,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YAC9C,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;QAC5C,CAAC;QAED,MAAM,gBAAgB,GAAG,WAAW,CAAC,OAAO,CAAC,yCAAqB,CAAC,CAAC;QACpE,IAAI,WAAW,GAAkB,IAAI,CAAC;QACtC,IAAI,WAAW,GAAG,WAAW,CAAC;QAE9B,IAAI,gBAAgB,GAAG,CAAC,EAAE,CAAC;YACzB,WAAW,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC,IAAI,EAAE,CAAC;YAChE,WAAW,GAAG,WAAW,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;QACxD,CAAC;aAAM,IAAI,gBAAgB,KAAK,CAAC,CAA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,CAAC,SAAS,CAAC,CAAC;YAChC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,iDAAiD,KAAK,CAAC,OAAO,EAAE,EAChE,kBAAkB,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,KAAK,CAC/C,CAAC;YACJ,CAAC;QACH,CAAC;QAGD,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YAC1B,MAAM,MAAM,GAAG,CAAC,CAAC,SAAS,CAAC,4CAAwB,CAAC,CAAC;YACrD,MAAM,MAAM,GAAG,CAAC,CAAC,SAAS,CAAC,4CAAwB,CAAC,CAAC;YACrD,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,SAAS;gBAAE,OAAO,CAAC,CAAC;YAC3D,IAAI,MAAM,KAAK,SAAS;gBAAE,OAAO,CAAC,CAAC;YACnC,IAAI,MAAM,KAAK,SAAS;gBAAE,OAAO,CAAC,CAAC,CAAC;YACpC,OAAO,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACrD,CAAC,CAAC,CAAC;QAEH,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC;IACjD,CAAC;CACF,CAAA;AAnHY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,mBAAU,GAAE;GACA,sBAAsB,CAmHlC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const ACTION_ITEM_START_TAG = "\u00A7ACTION_ITEM_START\u00A7";
|
|
2
|
+
export declare const ACTION_ITEM_END_TAG = "\u00A7ACTION_ITEM_END\u00A7";
|
|
3
|
+
export declare const PARTIAL_ACTION_ITEM_END_TAG = "\u00A7ACTION_ITEM_END";
|
|
4
|
+
export declare const FIELD_TOOL_NAME = "tool_name";
|
|
5
|
+
export declare const FIELD_ORDER_OF_EXECUTION = "order_of_execution";
|
|
6
|
+
export declare const TITLE_START_TAG = "\u00A7TITLE_START\u00A7";
|
|
7
|
+
export declare const TITLE_END_TAG = "\u00A7TITLE_END\u00A7";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TITLE_END_TAG = exports.TITLE_START_TAG = exports.FIELD_ORDER_OF_EXECUTION = exports.FIELD_TOOL_NAME = exports.PARTIAL_ACTION_ITEM_END_TAG = exports.ACTION_ITEM_END_TAG = exports.ACTION_ITEM_START_TAG = void 0;
|
|
4
|
+
exports.ACTION_ITEM_START_TAG = '§ACTION_ITEM_START§';
|
|
5
|
+
exports.ACTION_ITEM_END_TAG = '§ACTION_ITEM_END§';
|
|
6
|
+
exports.PARTIAL_ACTION_ITEM_END_TAG = '§ACTION_ITEM_END';
|
|
7
|
+
exports.FIELD_TOOL_NAME = 'tool_name';
|
|
8
|
+
exports.FIELD_ORDER_OF_EXECUTION = 'order_of_execution';
|
|
9
|
+
exports.TITLE_START_TAG = '§TITLE_START§';
|
|
10
|
+
exports.TITLE_END_TAG = '§TITLE_END§';
|
|
11
|
+
//# sourceMappingURL=parsing.constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parsing.constants.js","sourceRoot":"","sources":["../../../../src/llm-orchestration/parser/parsing.constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,qBAAqB,GAAG,qBAAqB,CAAC;AAC9C,QAAA,mBAAmB,GAAG,mBAAmB,CAAC;AAC1C,QAAA,2BAA2B,GAAG,kBAAkB,CAAC;AAEjD,QAAA,eAAe,GAAG,WAAW,CAAC;AAC9B,QAAA,wBAAwB,GAAG,oBAAoB,CAAC;AAChD,QAAA,eAAe,GAAG,eAAe,CAAC;AAClC,QAAA,aAAa,GAAG,aAAa,CAAC"}
|
|
@@ -20,6 +20,7 @@ const workspace_module_1 = require("../workspace/workspace.module");
|
|
|
20
20
|
const chat_module_1 = require("../interactive-chat/chat.module");
|
|
21
21
|
const ai_actions_module_1 = require("../ai-actions/ai-actions.module");
|
|
22
22
|
const system_prompts_module_1 = require("../system-prompts/system-prompts.module");
|
|
23
|
+
const llm_orchestration_module_1 = require("../llm-orchestration/llm-orchestration.module");
|
|
23
24
|
let LlmResponsesModule = class LlmResponsesModule {
|
|
24
25
|
};
|
|
25
26
|
exports.LlmResponsesModule = LlmResponsesModule;
|
|
@@ -35,6 +36,7 @@ exports.LlmResponsesModule = LlmResponsesModule = __decorate([
|
|
|
35
36
|
(0, common_1.forwardRef)(() => chat_module_1.InteractiveChatModule),
|
|
36
37
|
(0, common_1.forwardRef)(() => ai_actions_module_1.AIActionsModule),
|
|
37
38
|
system_prompts_module_1.SystemPromptsModule,
|
|
39
|
+
llm_orchestration_module_1.LlmOrchestrationModule,
|
|
38
40
|
],
|
|
39
41
|
controllers: [llm_responses_controller_1.LlmResponsesController],
|
|
40
42
|
providers: [llm_responses_service_1.LlmResponsesService],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llm-responses.module.js","sourceRoot":"","sources":["../../../src/llm-responses/llm-responses.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAoD;AACpD,yEAAoE;AACpE,mEAA8D;AAC9D,iEAA6D;AAC7D,4FAAuF;AACvF,mFAA8E;AAC9E,6CAAgD;AAChD,oDAAyD;AACzD,2DAAuD;AACvD,oEAAgE;AAChE,iEAAwE;AACxE,uEAAkE;AAClE,mFAA8E;
|
|
1
|
+
{"version":3,"file":"llm-responses.module.js","sourceRoot":"","sources":["../../../src/llm-responses/llm-responses.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAoD;AACpD,yEAAoE;AACpE,mEAA8D;AAC9D,iEAA6D;AAC7D,4FAAuF;AACvF,mFAA8E;AAC9E,6CAAgD;AAChD,oDAAyD;AACzD,2DAAuD;AACvD,oEAAgE;AAChE,iEAAwE;AACxE,uEAAkE;AAClE,mFAA8E;AAC9E,4FAAuF;AAmBhF,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;CAAG,CAAA;AAArB,gDAAkB;6BAAlB,kBAAkB;IAjB9B,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,uBAAa,CAAC,UAAU,CAAC,CAAC,uBAAO,EAAE,4BAAY,CAAC,CAAC;YACjD,gCAAc;YACd,iDAAsB;YACtB,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,2CAAmB,CAAC;YACrC,4BAAY;YACZ,kCAAe;YACf,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,mCAAqB,CAAC;YACvC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,mCAAe,CAAC;YACjC,2CAAmB;YACnB,iDAAsB;SACvB;QACD,WAAW,EAAE,CAAC,iDAAsB,CAAC;QACrC,SAAS,EAAE,CAAC,2CAAmB,CAAC;QAChC,OAAO,EAAE,CAAC,2CAAmB,CAAC;KAC/B,CAAC;GACW,kBAAkB,CAAG"}
|
|
@@ -5,10 +5,10 @@ import { SubmitLlmResponseDto } from './dto/submit-llm-response.dto';
|
|
|
5
5
|
import { Session, SessionInput } from '../core-entities';
|
|
6
6
|
import { Repository } from 'typeorm';
|
|
7
7
|
import { EventsGateway } from '../events/events.gateway';
|
|
8
|
-
import { AIActionCreationService } from '../ai-actions/ai-action-creation.service';
|
|
9
8
|
import { ChatService } from '../interactive-chat/chat.service';
|
|
10
9
|
import { SystemPromptsService } from '../system-prompts/system-prompts.service';
|
|
11
10
|
import { SyncConversationDto } from './dto/sync-conversation.dto';
|
|
11
|
+
import { LlmTurnProcessorService } from '../llm-orchestration/llm-turn-processor.service';
|
|
12
12
|
export declare class LlmResponsesService {
|
|
13
13
|
private sessionsRepository;
|
|
14
14
|
private sessionInputsRepository;
|
|
@@ -17,16 +17,13 @@ export declare class LlmResponsesService {
|
|
|
17
17
|
private readonly applicationStateService;
|
|
18
18
|
private readonly sessionInputsService;
|
|
19
19
|
private readonly eventsGateway;
|
|
20
|
-
private readonly aiActionCreationService;
|
|
21
20
|
private readonly chatService;
|
|
21
|
+
private readonly newTurnProcessor;
|
|
22
22
|
private readonly logger;
|
|
23
|
-
constructor(sessionsRepository: Repository<Session>, sessionInputsRepository: Repository<SessionInput>, systemPromptsService: SystemPromptsService, sessionsService: SessionsService, applicationStateService: ApplicationStateService, sessionInputsService: SessionInputsService, eventsGateway: EventsGateway,
|
|
23
|
+
constructor(sessionsRepository: Repository<Session>, sessionInputsRepository: Repository<SessionInput>, systemPromptsService: SystemPromptsService, sessionsService: SessionsService, applicationStateService: ApplicationStateService, sessionInputsService: SessionInputsService, eventsGateway: EventsGateway, chatService: ChatService, newTurnProcessor: LlmTurnProcessorService);
|
|
24
24
|
private extractAndUpdateSessionTitle;
|
|
25
25
|
submit(dto: SubmitLlmResponseDto): Promise<SessionInput>;
|
|
26
26
|
private createInputForExternalSubmission;
|
|
27
|
-
private processLlmResponse;
|
|
28
|
-
private handleAutoContextFetch;
|
|
29
|
-
private handleNewSessionAction;
|
|
30
27
|
submitExternal(dto: SubmitLlmResponseDto): Promise<SessionInput>;
|
|
31
28
|
syncConversation(dto: SyncConversationDto): Promise<string>;
|
|
32
29
|
}
|