openmcp-sdk 0.0.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 (85) hide show
  1. package/README.md +95 -0
  2. package/icons/openmcp.png +0 -0
  3. package/package.json +38 -0
  4. package/service/common/index.d.ts +5 -0
  5. package/service/common/index.d.ts.map +1 -0
  6. package/service/common/index.dto.d.ts +24 -0
  7. package/service/common/index.dto.d.ts.map +1 -0
  8. package/service/common/index.dto.js +2 -0
  9. package/service/common/index.js +17 -0
  10. package/service/common/router.d.ts +10 -0
  11. package/service/common/router.d.ts.map +1 -0
  12. package/service/common/router.js +54 -0
  13. package/service/hook/adapter.d.ts +67 -0
  14. package/service/hook/adapter.d.ts.map +1 -0
  15. package/service/hook/adapter.js +123 -0
  16. package/service/hook/db.d.ts +46 -0
  17. package/service/hook/db.d.ts.map +1 -0
  18. package/service/hook/db.js +179 -0
  19. package/service/hook/llm.d.ts +13 -0
  20. package/service/hook/llm.d.ts.map +1 -0
  21. package/service/hook/llm.js +89 -0
  22. package/service/hook/setting.d.ts +5 -0
  23. package/service/hook/setting.d.ts.map +1 -0
  24. package/service/hook/setting.js +13 -0
  25. package/service/hook/types.d.ts +90 -0
  26. package/service/hook/types.d.ts.map +1 -0
  27. package/service/hook/types.js +2 -0
  28. package/service/index.d.ts +5 -0
  29. package/service/index.d.ts.map +1 -0
  30. package/service/index.js +14 -0
  31. package/service/llm/llm.controller.d.ts +10 -0
  32. package/service/llm/llm.controller.d.ts.map +1 -0
  33. package/service/llm/llm.controller.js +61 -0
  34. package/service/llm/llm.dto.d.ts +8 -0
  35. package/service/llm/llm.dto.d.ts.map +1 -0
  36. package/service/llm/llm.dto.js +2 -0
  37. package/service/llm/llm.service.d.ts +8 -0
  38. package/service/llm/llm.service.d.ts.map +1 -0
  39. package/service/llm/llm.service.js +176 -0
  40. package/service/mcp/client.controller.d.ts +791 -0
  41. package/service/mcp/client.controller.d.ts.map +1 -0
  42. package/service/mcp/client.controller.js +177 -0
  43. package/service/mcp/client.dto.d.ts +42 -0
  44. package/service/mcp/client.dto.d.ts.map +1 -0
  45. package/service/mcp/client.dto.js +2 -0
  46. package/service/mcp/client.service.d.ts +763 -0
  47. package/service/mcp/client.service.d.ts.map +1 -0
  48. package/service/mcp/client.service.js +186 -0
  49. package/service/mcp/connect.controller.d.ts +17 -0
  50. package/service/mcp/connect.controller.d.ts.map +1 -0
  51. package/service/mcp/connect.controller.js +63 -0
  52. package/service/mcp/connect.service.d.ts +7 -0
  53. package/service/mcp/connect.service.d.ts.map +1 -0
  54. package/service/mcp/connect.service.js +76 -0
  55. package/service/mcp/ocr.controller.d.ts +18 -0
  56. package/service/mcp/ocr.controller.d.ts.map +1 -0
  57. package/service/mcp/ocr.controller.js +57 -0
  58. package/service/mcp/ocr.dto.d.ts +8 -0
  59. package/service/mcp/ocr.dto.d.ts.map +1 -0
  60. package/service/mcp/ocr.dto.js +2 -0
  61. package/service/mcp/ocr.service.d.ts +9 -0
  62. package/service/mcp/ocr.service.d.ts.map +1 -0
  63. package/service/mcp/ocr.service.js +143 -0
  64. package/service/panel/panel.controller.d.ts +32 -0
  65. package/service/panel/panel.controller.d.ts.map +1 -0
  66. package/service/panel/panel.controller.js +118 -0
  67. package/service/panel/panel.dto.d.ts +12 -0
  68. package/service/panel/panel.dto.d.ts.map +1 -0
  69. package/service/panel/panel.dto.js +2 -0
  70. package/service/panel/panel.service.d.ts +6 -0
  71. package/service/panel/panel.service.d.ts.map +1 -0
  72. package/service/panel/panel.service.js +95 -0
  73. package/service/setting/setting.controller.d.ts +23 -0
  74. package/service/setting/setting.controller.d.ts.map +1 -0
  75. package/service/setting/setting.controller.js +77 -0
  76. package/service/setting/setting.dto.d.ts +5 -0
  77. package/service/setting/setting.dto.d.ts.map +1 -0
  78. package/service/setting/setting.dto.js +2 -0
  79. package/service/setting/setting.service.d.ts +8 -0
  80. package/service/setting/setting.service.d.ts.map +1 -0
  81. package/service/setting/setting.service.js +121 -0
  82. package/task-loop.d.ts +105 -0
  83. package/task-loop.js +10985 -0
  84. package/task-loop.js.map +1 -0
  85. package/tools.js +8 -0
@@ -0,0 +1,179 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
+ return new (P || (P = Promise))(function (resolve, reject) {
38
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
42
+ });
43
+ };
44
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
45
+ if (kind === "m") throw new TypeError("Private method is not writable");
46
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
47
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
48
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
49
+ };
50
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
51
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
52
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
53
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
54
+ };
55
+ var __importDefault = (this && this.__importDefault) || function (mod) {
56
+ return (mod && mod.__esModule) ? mod : { "default": mod };
57
+ };
58
+ var _DiskStorage_storageHome;
59
+ Object.defineProperty(exports, "__esModule", { value: true });
60
+ exports.systemPromptDB = exports.ocrDB = exports.settingDB = exports.diskStorage = exports.LocalDB = void 0;
61
+ const nedb_1 = __importDefault(require("@seald-io/nedb"));
62
+ const os = __importStar(require("os"));
63
+ const path = __importStar(require("path"));
64
+ const fs = __importStar(require("fs"));
65
+ const dbConnections = {};
66
+ class LocalDB {
67
+ constructor(tableName) {
68
+ this.tableName = tableName;
69
+ this.init();
70
+ }
71
+ init() {
72
+ return __awaiter(this, void 0, void 0, function* () {
73
+ const homedir = os.homedir();
74
+ const dbPath = path.join(homedir, '.openmcp', 'nedb');
75
+ if (!fs.existsSync(dbPath)) {
76
+ fs.mkdirSync(dbPath, { recursive: true });
77
+ }
78
+ const filename = path.join(dbPath, `${this.tableName}.db`);
79
+ if (!dbConnections[filename]) {
80
+ dbConnections[filename] = new nedb_1.default({
81
+ filename,
82
+ autoload: true,
83
+ timestampData: true
84
+ });
85
+ }
86
+ this.db = dbConnections[filename];
87
+ yield this.db.ensureIndex({ fieldName: 'id', unique: true });
88
+ });
89
+ }
90
+ insert(entity) {
91
+ return __awaiter(this, void 0, void 0, function* () {
92
+ yield this.db.update({ id: entity.id }, entity, { upsert: true });
93
+ });
94
+ }
95
+ findById(id) {
96
+ return __awaiter(this, void 0, void 0, function* () {
97
+ return yield this.db.findOne({ id });
98
+ });
99
+ }
100
+ findAll() {
101
+ return __awaiter(this, void 0, void 0, function* () {
102
+ return yield this.db.find({});
103
+ });
104
+ }
105
+ delete(id) {
106
+ return __awaiter(this, void 0, void 0, function* () {
107
+ yield this.db.remove({ id });
108
+ });
109
+ }
110
+ close() {
111
+ return __awaiter(this, void 0, void 0, function* () {
112
+ // NeDB 不需要显式关闭
113
+ });
114
+ }
115
+ }
116
+ exports.LocalDB = LocalDB;
117
+ class DiskStorage {
118
+ constructor() {
119
+ _DiskStorage_storageHome.set(this, void 0);
120
+ const homedir = os.homedir();
121
+ const imageStorageFolder = path.join(homedir, '.openmcp', 'storage');
122
+ // 确保存储目录存在
123
+ if (!fs.existsSync(imageStorageFolder)) {
124
+ fs.mkdirSync(imageStorageFolder, { recursive: true });
125
+ }
126
+ __classPrivateFieldSet(this, _DiskStorage_storageHome, imageStorageFolder, "f");
127
+ }
128
+ get(filename) {
129
+ return __awaiter(this, void 0, void 0, function* () {
130
+ const filePath = path.join(__classPrivateFieldGet(this, _DiskStorage_storageHome, "f"), filename);
131
+ if (fs.existsSync(filePath)) {
132
+ return fs.promises.readFile(filePath);
133
+ }
134
+ return null;
135
+ });
136
+ }
137
+ set(filename, data, options) {
138
+ return __awaiter(this, void 0, void 0, function* () {
139
+ const filePath = path.join(__classPrivateFieldGet(this, _DiskStorage_storageHome, "f"), filename);
140
+ yield fs.promises.writeFile(filePath, data, options);
141
+ });
142
+ }
143
+ delete(filename) {
144
+ return __awaiter(this, void 0, void 0, function* () {
145
+ const filePath = path.join(__classPrivateFieldGet(this, _DiskStorage_storageHome, "f"), filename);
146
+ if (fs.existsSync(filePath)) {
147
+ yield fs.promises.unlink(filePath);
148
+ }
149
+ });
150
+ }
151
+ getSync(filename) {
152
+ const filePath = path.join(__classPrivateFieldGet(this, _DiskStorage_storageHome, "f"), filename);
153
+ if (fs.existsSync(filePath)) {
154
+ return fs.readFileSync(filePath);
155
+ }
156
+ return null;
157
+ }
158
+ setSync(filename, data, options) {
159
+ if (!fs.existsSync(__classPrivateFieldGet(this, _DiskStorage_storageHome, "f"))) {
160
+ fs.mkdirSync(__classPrivateFieldGet(this, _DiskStorage_storageHome, "f"), { recursive: true });
161
+ }
162
+ const filePath = path.join(__classPrivateFieldGet(this, _DiskStorage_storageHome, "f"), filename);
163
+ fs.writeFileSync(filePath, data, options);
164
+ }
165
+ getStoragePath(filename) {
166
+ return path.join(__classPrivateFieldGet(this, _DiskStorage_storageHome, "f"), filename);
167
+ }
168
+ deleteSync(filename) {
169
+ const filePath = path.join(__classPrivateFieldGet(this, _DiskStorage_storageHome, "f"), filename);
170
+ if (fs.existsSync(filePath)) {
171
+ fs.unlinkSync(filePath);
172
+ }
173
+ }
174
+ }
175
+ _DiskStorage_storageHome = new WeakMap();
176
+ exports.diskStorage = new DiskStorage();
177
+ exports.settingDB = new LocalDB('setting');
178
+ exports.ocrDB = new LocalDB('ocr');
179
+ exports.systemPromptDB = new LocalDB('systemPrompt');
@@ -0,0 +1,13 @@
1
+ export declare const llms: {
2
+ id: string;
3
+ name: string;
4
+ baseUrl: string;
5
+ models: string[];
6
+ provider: string;
7
+ isOpenAICompatible: boolean;
8
+ description: string;
9
+ website: string;
10
+ userToken: string;
11
+ userModel: string;
12
+ }[];
13
+ //# sourceMappingURL=llm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llm.d.ts","sourceRoot":"","sources":["../../src/hook/llm.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI;;;;;;;;;;;GAqFhB,CAAC"}
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.llms = void 0;
4
+ exports.llms = [
5
+ {
6
+ id: 'deepseek',
7
+ name: 'DeepSeek',
8
+ baseUrl: 'https://api.deepseek.com/v1',
9
+ models: ['deepseek-chat', 'deepseek-reasoner'],
10
+ provider: 'DeepSeek',
11
+ isOpenAICompatible: true,
12
+ description: '深度求索推出的大模型,擅长中文和代码',
13
+ website: 'https://www.deepseek.com',
14
+ userToken: '',
15
+ userModel: 'deepseek-chat'
16
+ },
17
+ {
18
+ id: 'openai',
19
+ name: 'OpenAI',
20
+ baseUrl: 'https://api.openai.com/v1',
21
+ models: ['gpt-4-turbo', 'gpt-4', 'gpt-3.5-turbo'],
22
+ provider: 'OpenAI',
23
+ isOpenAICompatible: true,
24
+ description: 'OpenAI官方API',
25
+ website: 'https://openai.com',
26
+ userToken: '',
27
+ userModel: 'gpt-4-turbo'
28
+ },
29
+ {
30
+ id: 'mistral',
31
+ name: 'Mistral',
32
+ baseUrl: 'https://api.mistral.ai/v1',
33
+ models: ['mistral-tiny', 'mistral-small', 'mistral-medium'],
34
+ provider: 'Mistral AI',
35
+ isOpenAICompatible: true,
36
+ description: '欧洲开源大模型代表',
37
+ website: 'https://mistral.ai',
38
+ userToken: '',
39
+ userModel: 'mistral-tiny'
40
+ },
41
+ {
42
+ id: 'ollama',
43
+ name: 'Ollama (Local)',
44
+ baseUrl: 'http://localhost:11434/v1',
45
+ models: ['llama2', 'mistral', 'codellama'],
46
+ provider: 'Ollama',
47
+ isOpenAICompatible: true,
48
+ description: '本地运行的大模型',
49
+ website: 'https://ollama.com',
50
+ userToken: '',
51
+ userModel: 'llama2'
52
+ },
53
+ {
54
+ id: 'groq',
55
+ name: 'Groq',
56
+ baseUrl: 'https://api.groq.com/openai/v1',
57
+ models: ['mixtral-8x7b-32768', 'llama2-70b-4096'],
58
+ provider: 'Groq',
59
+ isOpenAICompatible: true,
60
+ description: '超高速推理API',
61
+ website: 'https://groq.com',
62
+ userToken: '',
63
+ userModel: 'mixtral-8x7b-32768'
64
+ },
65
+ {
66
+ id: 'perplexity',
67
+ name: 'Perplexity',
68
+ baseUrl: 'https://api.perplexity.ai/v1',
69
+ models: ['pplx-7b-online', 'pplx-70b-online'],
70
+ provider: 'Perplexity AI',
71
+ isOpenAICompatible: true,
72
+ description: '联网搜索增强的大模型',
73
+ website: 'https://www.perplexity.ai',
74
+ userToken: '',
75
+ userModel: 'pplx-7b-online'
76
+ },
77
+ {
78
+ id: 'kimi',
79
+ name: 'Kimi Chat',
80
+ baseUrl: 'https://api.moonshot.cn/v1',
81
+ models: ['moonshot-v1-8k', 'moonshot-v1-32k', 'moonshot-v1-128k'],
82
+ provider: '月之暗面 (Moonshot AI)',
83
+ isOpenAICompatible: true,
84
+ description: '支持超长上下文的中文大模型,上下文窗口高达128K',
85
+ website: 'https://kimi.moonshot.cn',
86
+ userToken: '',
87
+ userModel: 'moonshot-v1-8k'
88
+ }
89
+ ];
@@ -0,0 +1,5 @@
1
+ export declare let VSCODE_WORKSPACE: string;
2
+ export declare let RUNNING_CWD: string;
3
+ export declare function setVscodeWorkspace(workspace: string): void;
4
+ export declare function setRunningCWD(path: string): void;
5
+ //# sourceMappingURL=setting.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setting.d.ts","sourceRoot":"","sources":["../../src/hook/setting.ts"],"names":[],"mappings":"AAAA,eAAO,IAAI,gBAAgB,QAAK,CAAC;AACjC,eAAO,IAAI,WAAW,QAAK,CAAC;AAE5B,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,QAEnD;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,QAEzC"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RUNNING_CWD = exports.VSCODE_WORKSPACE = void 0;
4
+ exports.setVscodeWorkspace = setVscodeWorkspace;
5
+ exports.setRunningCWD = setRunningCWD;
6
+ exports.VSCODE_WORKSPACE = '';
7
+ exports.RUNNING_CWD = '';
8
+ function setVscodeWorkspace(workspace) {
9
+ exports.VSCODE_WORKSPACE = workspace;
10
+ }
11
+ function setRunningCWD(path) {
12
+ exports.RUNNING_CWD = path;
13
+ }
@@ -0,0 +1,90 @@
1
+ export interface IMessage {
2
+ type: string;
3
+ data: Record<string, unknown>;
4
+ timestamp?: number;
5
+ }
6
+ export type MessageHandler = (message: IMessage) => void;
7
+ export interface SchemaProperty {
8
+ title: string;
9
+ type: string;
10
+ }
11
+ export interface InputSchema {
12
+ type: string;
13
+ properties: Record<string, SchemaProperty>;
14
+ required?: string[];
15
+ title?: string;
16
+ }
17
+ export interface Argument {
18
+ name: string;
19
+ required: boolean;
20
+ }
21
+ export interface Content {
22
+ uri: string;
23
+ mimeType: string;
24
+ text: string;
25
+ }
26
+ export interface MessageContent {
27
+ type: string;
28
+ text: string;
29
+ }
30
+ export interface ToolsListResponse {
31
+ tools: Array<{
32
+ name: string;
33
+ description: string;
34
+ inputSchema: InputSchema;
35
+ }>;
36
+ }
37
+ export interface PromptsListResponse {
38
+ prompts: Array<{
39
+ name: string;
40
+ description: string;
41
+ arguments: Argument[];
42
+ }>;
43
+ }
44
+ export interface ResourceTemplatesListResponse {
45
+ resourceTemplates: Array<{
46
+ uriTemplate: string;
47
+ name: string;
48
+ description: string;
49
+ }>;
50
+ }
51
+ export interface ResourcesListResponse {
52
+ resources: any[];
53
+ }
54
+ export interface ResourcesReadResponse {
55
+ contents: Content[];
56
+ }
57
+ export interface PromptsGetResponse {
58
+ messages: Array<{
59
+ role: string;
60
+ content: MessageContent;
61
+ }>;
62
+ }
63
+ export interface ToolListItem {
64
+ name: string;
65
+ description: string;
66
+ inputSchema: InputSchema;
67
+ }
68
+ export interface ToolsListResponse {
69
+ tools: ToolListItem[];
70
+ }
71
+ export interface BaseRequest {
72
+ method: string;
73
+ params: Record<string, any>;
74
+ }
75
+ export interface ResourcesReadRequest extends BaseRequest {
76
+ method: 'resources/read';
77
+ params: {
78
+ uri: string;
79
+ };
80
+ }
81
+ export interface PromptsGetRequest extends BaseRequest {
82
+ method: 'prompts/get';
83
+ params: {
84
+ name: string;
85
+ arguments: Record<string, any>;
86
+ };
87
+ }
88
+ export type APIResponse = ToolsListResponse | PromptsListResponse | ResourceTemplatesListResponse | ResourcesListResponse | ResourcesReadResponse | PromptsGetResponse;
89
+ export type APIRequest = BaseRequest | ResourcesReadRequest | PromptsGetRequest;
90
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/hook/types.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,5 @@
1
+ export { routeMessage } from './common/router';
2
+ export { VSCodeWebViewLike, TaskLoopAdapter } from './hook/adapter';
3
+ export { setVscodeWorkspace, setRunningCWD } from './hook/setting';
4
+ export { client } from './mcp/connect.service';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEnE,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.client = exports.setRunningCWD = exports.setVscodeWorkspace = exports.TaskLoopAdapter = exports.VSCodeWebViewLike = exports.routeMessage = void 0;
4
+ var router_1 = require("./common/router");
5
+ Object.defineProperty(exports, "routeMessage", { enumerable: true, get: function () { return router_1.routeMessage; } });
6
+ var adapter_1 = require("./hook/adapter");
7
+ Object.defineProperty(exports, "VSCodeWebViewLike", { enumerable: true, get: function () { return adapter_1.VSCodeWebViewLike; } });
8
+ Object.defineProperty(exports, "TaskLoopAdapter", { enumerable: true, get: function () { return adapter_1.TaskLoopAdapter; } });
9
+ var setting_1 = require("./hook/setting");
10
+ Object.defineProperty(exports, "setVscodeWorkspace", { enumerable: true, get: function () { return setting_1.setVscodeWorkspace; } });
11
+ Object.defineProperty(exports, "setRunningCWD", { enumerable: true, get: function () { return setting_1.setRunningCWD; } });
12
+ // TODO: 更加规范
13
+ var connect_service_1 = require("./mcp/connect.service");
14
+ Object.defineProperty(exports, "client", { enumerable: true, get: function () { return connect_service_1.client; } });
@@ -0,0 +1,10 @@
1
+ import { RequestClientType } from "../common";
2
+ import { PostMessageble } from "../hook/adapter";
3
+ export declare class LlmController {
4
+ chatCompletion(client: RequestClientType, data: any, webview: PostMessageble): Promise<{
5
+ code: number;
6
+ msg: string;
7
+ }>;
8
+ abortChatCompletion(client: RequestClientType, data: any, webview: PostMessageble): Promise<import("../common/index.dto").RestfulResponse>;
9
+ }
10
+ //# sourceMappingURL=llm.controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llm.controller.d.ts","sourceRoot":"","sources":["../../src/llm/llm.controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGjD,qBAAa,aAAa;IAGhB,cAAc,CAAC,MAAM,EAAE,iBAAiB,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,cAAc;;;;IAgC5E,mBAAmB,CAAC,MAAM,EAAE,iBAAiB,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,cAAc;CAI1F"}
@@ -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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
9
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
10
+ return new (P || (P = Promise))(function (resolve, reject) {
11
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
12
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
13
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
14
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
15
+ });
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.LlmController = void 0;
19
+ const common_1 = require("../common");
20
+ const llm_service_1 = require("./llm.service");
21
+ class LlmController {
22
+ chatCompletion(client, data, webview) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ let { tools = [] } = data;
25
+ if (tools.length > 0 && !client) {
26
+ return {
27
+ code: 501,
28
+ msg: 'mcp client 尚未连接'
29
+ };
30
+ }
31
+ try {
32
+ yield (0, llm_service_1.streamingChatCompletion)(data, webview);
33
+ }
34
+ catch (error) {
35
+ console.log('error' + error);
36
+ webview.postMessage({
37
+ command: 'llm/chat/completions/error',
38
+ data: {
39
+ msg: error
40
+ }
41
+ });
42
+ }
43
+ return {
44
+ code: -1,
45
+ msg: 'terminate'
46
+ };
47
+ });
48
+ }
49
+ abortChatCompletion(client, data, webview) {
50
+ return __awaiter(this, void 0, void 0, function* () {
51
+ return (0, llm_service_1.abortMessageService)(data, webview);
52
+ });
53
+ }
54
+ }
55
+ exports.LlmController = LlmController;
56
+ __decorate([
57
+ (0, common_1.Controller)('llm/chat/completions')
58
+ ], LlmController.prototype, "chatCompletion", null);
59
+ __decorate([
60
+ (0, common_1.Controller)('llm/chat/completions/abort')
61
+ ], LlmController.prototype, "abortChatCompletion", null);
@@ -0,0 +1,8 @@
1
+ import { OpenAI } from "openai";
2
+ export type MyMessageType = OpenAI.Chat.ChatCompletionMessageParam & {
3
+ extraInfo?: any;
4
+ };
5
+ export type MyToolMessageType = OpenAI.Chat.ChatCompletionToolMessageParam & {
6
+ extraInfo?: any;
7
+ };
8
+ //# sourceMappingURL=llm.dto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llm.dto.d.ts","sourceRoot":"","sources":["../../src/llm/llm.dto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,0BAA0B,GAAG;IACpE,SAAS,CAAC,EAAE,GAAG,CAAC;CAChB,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,IAAI,CAAC,8BAA8B,GAAG;IAC5E,SAAS,CAAC,EAAE,GAAG,CAAC;CAChB,CAAA"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ import { PostMessageble } from "../hook/adapter";
2
+ import { MyMessageType } from "./llm.dto";
3
+ import { RestfulResponse } from "../common/index.dto";
4
+ export declare let currentStream: AsyncIterable<any> | null;
5
+ export declare function streamingChatCompletion(data: any, webview: PostMessageble): Promise<void>;
6
+ export declare function abortMessageService(data: any, webview: PostMessageble): RestfulResponse;
7
+ export declare function postProcessMessages(messages: MyMessageType[]): Promise<void>;
8
+ //# sourceMappingURL=llm.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llm.service.d.ts","sourceRoot":"","sources":["../../src/llm/llm.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,aAAa,EAAqB,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAKtD,eAAO,IAAI,aAAa,EAAE,aAAa,CAAC,GAAG,CAAC,GAAG,IAAW,CAAC;AAE3D,wBAAsB,uBAAuB,CACzC,IAAI,EAAE,GAAG,EACT,OAAO,EAAE,cAAc,iBA0E1B;AAID,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,cAAc,GAAG,eAAe,CAYvF;AA0CD,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,aAAa,EAAE,iBAyBlE"}