@prompt-optimizer/mcp-server 0.1.0
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/LICENSE +669 -0
- package/README.md +267 -0
- package/THIRD_PARTY_NOTICES.txt +4476 -0
- package/bin/prompt-optimizer-desktop-mcp.cjs +10 -0
- package/bin/prompt-optimizer-mcp.cjs +20 -0
- package/dist/browser.cjs +1 -0
- package/dist/browser.js +4202 -0
- package/dist/chunk-3FYJ3FRD.js +57 -0
- package/dist/chunk-E7Z4Y3F4.js +36402 -0
- package/dist/chunk-GBDJTSRW.js +298 -0
- package/dist/chunk-HLCN3DLS.js +19745 -0
- package/dist/chunk-HYVN7FZZ.js +4787 -0
- package/dist/chunk-MEUCFQGU.js +537 -0
- package/dist/chunk-N6AUTPPS.js +10647 -0
- package/dist/chunk-Q52SACHI.js +304 -0
- package/dist/chunk-Q5B3KFB3.js +31 -0
- package/dist/chunk-QSPNNVX3.js +49017 -0
- package/dist/chunk-SO4YJHYW.js +13450 -0
- package/dist/chunk-SV2GETJH.js +65 -0
- package/dist/chunk-TFH2LO2H.js +58 -0
- package/dist/chunk-TFJEYQ3G.js +786 -0
- package/dist/chunk-TLOFCHZI.js +70 -0
- package/dist/chunk-TQGHULC7.js +188 -0
- package/dist/chunk-UTOMPKTK.js +2209 -0
- package/dist/chunk-XXALDAL7.js +1838 -0
- package/dist/chunk-YT3U6B54.js +21 -0
- package/dist/desktop-business.cjs +1 -0
- package/dist/desktop-business.js +1227 -0
- package/dist/desktop-comparison-HDIQ6K45.js +22 -0
- package/dist/desktop-storage-YRABQCLF.js +14 -0
- package/dist/desktop.cjs +1 -0
- package/dist/desktop.js +26 -0
- package/dist/dist-O5VNBF5I.js +622 -0
- package/dist/dist-UMX52UME.js +481 -0
- package/dist/index.cjs +1 -0
- package/dist/index.js +12 -0
- package/dist/legacy.cjs +1 -0
- package/dist/legacy.js +26933 -0
- package/dist/multipart-parser-XE6WGDAU.js +373 -0
- package/dist/node-2RBNZOSK.js +2225 -0
- package/dist/node-4Z3USCHW.js +21 -0
- package/dist/node-QHGLD5ST.js +25 -0
- package/dist/registry-H5F4DGAM-UHR4F6LL.js +13 -0
- package/dist/src-7PBMYCGI.js +1398 -0
- package/dist/start.cjs +1 -0
- package/dist/start.js +16 -0
- package/package.json +30 -0
- package/preload-env.cjs +352 -0
- package/skills/prompt-optimizer-compare/SKILL.md +21 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { createRequire as __mcpCreateRequire } from "node:module";
|
|
2
|
+
const require = __mcpCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
DesktopSourceError
|
|
5
|
+
} from "./chunk-GBDJTSRW.js";
|
|
6
|
+
|
|
7
|
+
// src/cli.ts
|
|
8
|
+
import { isAbsolute } from "node:path";
|
|
9
|
+
function selectLaunchMode(args) {
|
|
10
|
+
if (args.includes("--mode")) throw new DesktopSourceError("INVALID_INPUT");
|
|
11
|
+
const modes = args.filter((arg) => arg.startsWith("--mode="));
|
|
12
|
+
if (modes.length > 1) throw new DesktopSourceError("INVALID_INPUT");
|
|
13
|
+
const mode = modes[0]?.slice("--mode=".length) ?? "legacy";
|
|
14
|
+
const paths = args.filter((arg) => arg.startsWith("--desktop-profile="));
|
|
15
|
+
if (mode === "browser") {
|
|
16
|
+
if (args.some((arg) => arg !== "--mode=browser" && arg !== "--transport=stdio") || args.filter((arg) => arg.startsWith("--transport=")).length > 1) throw new DesktopSourceError("INVALID_INPUT");
|
|
17
|
+
return { mode };
|
|
18
|
+
}
|
|
19
|
+
if (mode === "legacy") {
|
|
20
|
+
if (args.some((arg) => arg.startsWith("--desktop-"))) throw new DesktopSourceError("INVALID_INPUT");
|
|
21
|
+
return { mode };
|
|
22
|
+
}
|
|
23
|
+
if (mode !== "desktop-readonly" && mode !== "desktop-comparison" && mode !== "desktop") throw new DesktopSourceError("INVALID_INPUT");
|
|
24
|
+
if (args.some((arg) => !arg.startsWith("--desktop-profile=") && arg !== modes[0] && arg !== "--transport=stdio")) {
|
|
25
|
+
throw new DesktopSourceError("INVALID_INPUT");
|
|
26
|
+
}
|
|
27
|
+
if (paths.length < 1 || paths.length > 8 || args.filter((arg) => arg.startsWith("--transport=")).length > 1) throw new DesktopSourceError("INVALID_INPUT");
|
|
28
|
+
const profiles = paths.map((arg, index) => {
|
|
29
|
+
const userDataPath = arg.slice("--desktop-profile=".length);
|
|
30
|
+
if (!isAbsolute(userDataPath)) throw new DesktopSourceError("INVALID_INPUT");
|
|
31
|
+
return { label: `Desktop profile ${index + 1}`, userDataPath };
|
|
32
|
+
});
|
|
33
|
+
return { mode, profiles };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// src/index.ts
|
|
37
|
+
async function main(args = process.argv.slice(2), dependencies = {}) {
|
|
38
|
+
const selection = selectLaunchMode(args);
|
|
39
|
+
if (selection.mode === "desktop") {
|
|
40
|
+
console.log = console.info = console.debug = console.warn = console.error = () => {
|
|
41
|
+
};
|
|
42
|
+
const { startDesktopBusinessStdio } = await import("./desktop-business.js");
|
|
43
|
+
return startDesktopBusinessStdio(selection.profiles);
|
|
44
|
+
}
|
|
45
|
+
if (selection.mode === "browser") return (await import("./browser.js")).startBrowserStdio();
|
|
46
|
+
if (selection.mode === "desktop-readonly") {
|
|
47
|
+
const start = dependencies.desktopMain ?? (await import("./desktop.js")).startDesktopReadonlyStdio;
|
|
48
|
+
const opener = dependencies.openDesktop ?? (await import("./desktop-storage-YRABQCLF.js")).openReadonlyDesktop;
|
|
49
|
+
return start(selection.profiles, opener);
|
|
50
|
+
}
|
|
51
|
+
if (selection.mode === "desktop-comparison") {
|
|
52
|
+
const start = dependencies.desktopComparisonMain ?? (await import("./desktop.js")).startDesktopComparisonStdio;
|
|
53
|
+
const opener = dependencies.openDesktopComparison ?? (await import("./desktop-storage-YRABQCLF.js")).openComparisonDesktop;
|
|
54
|
+
return start(selection.profiles, opener);
|
|
55
|
+
}
|
|
56
|
+
if (dependencies.legacyMain) return dependencies.legacyMain();
|
|
57
|
+
if ((args.find((arg) => arg.startsWith("--transport="))?.slice("--transport=".length) ?? "stdio") === "stdio") {
|
|
58
|
+
console.log = console.error.bind(console);
|
|
59
|
+
console.info = console.error.bind(console);
|
|
60
|
+
console.debug = console.error.bind(console);
|
|
61
|
+
}
|
|
62
|
+
const preloadPath = "../preload-env.cjs";
|
|
63
|
+
await import(preloadPath);
|
|
64
|
+
const legacyPath = "./legacy.js";
|
|
65
|
+
return (await import(legacyPath)).main();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export {
|
|
69
|
+
main
|
|
70
|
+
};
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { createRequire as __mcpCreateRequire } from "node:module";
|
|
2
|
+
const require = __mcpCreateRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
// ../core/dist/chunk-HZQN6G7J.js
|
|
5
|
+
var EVALUATION_ERROR_CODES = {
|
|
6
|
+
VALIDATION_ERROR: "error.evaluation.validation",
|
|
7
|
+
MODEL_NOT_FOUND: "error.evaluation.model_not_found",
|
|
8
|
+
TEMPLATE_NOT_FOUND: "error.evaluation.template_not_found",
|
|
9
|
+
PARSE_ERROR: "error.evaluation.parse",
|
|
10
|
+
EXECUTION_ERROR: "error.evaluation.execution"
|
|
11
|
+
};
|
|
12
|
+
var LLM_ERROR_CODES = {
|
|
13
|
+
API_ERROR: "error.llm.api",
|
|
14
|
+
CONFIG_ERROR: "error.llm.config",
|
|
15
|
+
VALIDATION_ERROR: "error.llm.validation",
|
|
16
|
+
INITIALIZATION_ERROR: "error.llm.initialization",
|
|
17
|
+
API_KEY_REQUIRED: "error.llm.api_key_required",
|
|
18
|
+
MODEL_NOT_FOUND: "error.llm.model_not_found",
|
|
19
|
+
TEMPLATE_INVALID: "error.llm.template_invalid",
|
|
20
|
+
EMPTY_INPUT: "error.llm.empty_input",
|
|
21
|
+
OPTIMIZATION_FAILED: "error.llm.optimization_failed",
|
|
22
|
+
ITERATION_FAILED: "error.llm.iteration_failed",
|
|
23
|
+
TEST_FAILED: "error.llm.test_failed",
|
|
24
|
+
MODEL_KEY_REQUIRED: "error.llm.model_key_required",
|
|
25
|
+
INPUT_TOO_LONG: "error.llm.input_too_long"
|
|
26
|
+
};
|
|
27
|
+
var HISTORY_ERROR_CODES = {
|
|
28
|
+
NOT_FOUND: "error.history.not_found",
|
|
29
|
+
CHAIN_ERROR: "error.history.chain",
|
|
30
|
+
RECORD_NOT_FOUND: "error.history.record_not_found",
|
|
31
|
+
STORAGE_ERROR: "error.history.storage",
|
|
32
|
+
VALIDATION_ERROR: "error.history.validation"
|
|
33
|
+
};
|
|
34
|
+
var COMPARE_ERROR_CODES = {
|
|
35
|
+
VALIDATION_ERROR: "error.compare.validation",
|
|
36
|
+
CALCULATION_ERROR: "error.compare.calculation"
|
|
37
|
+
};
|
|
38
|
+
var STORAGE_ERROR_CODES = {
|
|
39
|
+
READ_ERROR: "error.storage.read",
|
|
40
|
+
WRITE_ERROR: "error.storage.write",
|
|
41
|
+
DELETE_ERROR: "error.storage.delete",
|
|
42
|
+
CLEAR_ERROR: "error.storage.clear",
|
|
43
|
+
CONFIG_ERROR: "error.storage.config"
|
|
44
|
+
};
|
|
45
|
+
var MODEL_ERROR_CODES = {
|
|
46
|
+
VALIDATION_ERROR: "error.model.validation",
|
|
47
|
+
CONFIG_ERROR: "error.model.config"
|
|
48
|
+
};
|
|
49
|
+
var TEMPLATE_ERROR_CODES = {
|
|
50
|
+
LOAD_ERROR: "error.template.load",
|
|
51
|
+
NOT_FOUND: "error.template.not_found",
|
|
52
|
+
VALIDATION_ERROR: "error.template.validation",
|
|
53
|
+
CACHE_ERROR: "error.template.cache",
|
|
54
|
+
STORAGE_ERROR: "error.template.storage"
|
|
55
|
+
};
|
|
56
|
+
var CONTEXT_ERROR_CODES = {
|
|
57
|
+
NOT_FOUND: "error.context.not_found",
|
|
58
|
+
MINIMUM_VIOLATION: "error.context.minimum_violation",
|
|
59
|
+
INVALID_ID: "error.context.invalid_id",
|
|
60
|
+
IMPORT_FORMAT_ERROR: "error.context.import_format",
|
|
61
|
+
INVALID_STORE: "error.context.invalid_store",
|
|
62
|
+
STORAGE_ERROR: "error.context.storage",
|
|
63
|
+
ELECTRON_API_UNAVAILABLE: "error.context.electron_api_unavailable"
|
|
64
|
+
};
|
|
65
|
+
var PROMPT_ERROR_CODES = {
|
|
66
|
+
OPTIMIZATION_ERROR: "error.prompt.optimization",
|
|
67
|
+
ITERATION_ERROR: "error.prompt.iteration",
|
|
68
|
+
TEST_ERROR: "error.prompt.test",
|
|
69
|
+
SERVICE_DEPENDENCY_ERROR: "error.prompt.service_dependency"
|
|
70
|
+
};
|
|
71
|
+
var VARIABLE_EXTRACTION_ERROR_CODES = {
|
|
72
|
+
VALIDATION_ERROR: "error.variable_extraction.validation",
|
|
73
|
+
MODEL_NOT_FOUND: "error.variable_extraction.model_not_found",
|
|
74
|
+
PARSE_ERROR: "error.variable_extraction.parse",
|
|
75
|
+
EXECUTION_ERROR: "error.variable_extraction.execution"
|
|
76
|
+
};
|
|
77
|
+
var VARIABLE_VALUE_GENERATION_ERROR_CODES = {
|
|
78
|
+
VALIDATION_ERROR: "error.variable_value_generation.validation",
|
|
79
|
+
MODEL_NOT_FOUND: "error.variable_value_generation.model_not_found",
|
|
80
|
+
PARSE_ERROR: "error.variable_value_generation.parse",
|
|
81
|
+
EXECUTION_ERROR: "error.variable_value_generation.execution"
|
|
82
|
+
};
|
|
83
|
+
var FAVORITE_ERROR_CODES = {
|
|
84
|
+
NOT_FOUND: "error.favorite.not_found",
|
|
85
|
+
ALREADY_EXISTS: "error.favorite.already_exists",
|
|
86
|
+
CATEGORY_NOT_FOUND: "error.favorite.category_not_found",
|
|
87
|
+
VALIDATION_ERROR: "error.favorite.validation",
|
|
88
|
+
STORAGE_ERROR: "error.favorite.storage",
|
|
89
|
+
TAG_ERROR: "error.favorite.tag",
|
|
90
|
+
TAG_ALREADY_EXISTS: "error.favorite.tag_already_exists",
|
|
91
|
+
TAG_NOT_FOUND: "error.favorite.tag_not_found",
|
|
92
|
+
MIGRATION_ERROR: "error.favorite.migration",
|
|
93
|
+
IMPORT_EXPORT_ERROR: "error.favorite.import_export"
|
|
94
|
+
};
|
|
95
|
+
var IMAGE_ERROR_CODES = {
|
|
96
|
+
PROMPT_EMPTY: "error.image.prompt_empty",
|
|
97
|
+
CONFIG_ID_EMPTY: "error.image.config_id_empty",
|
|
98
|
+
CONFIG_NOT_FOUND: "error.image.config_not_found",
|
|
99
|
+
CONFIG_NOT_ENABLED: "error.image.config_not_enabled",
|
|
100
|
+
CONFIG_ALREADY_EXISTS: "error.image.config_already_exists",
|
|
101
|
+
CONFIG_DOES_NOT_EXIST: "error.image.config_does_not_exist",
|
|
102
|
+
CONFIG_INVALID: "error.image.config_invalid",
|
|
103
|
+
API_KEY_REQUIRED: "error.image.api_key_required",
|
|
104
|
+
MODEL_ID_REQUIRED: "error.image.model_id_required",
|
|
105
|
+
CONFIG_PROVIDER_MISMATCH: "error.image.config_provider_mismatch",
|
|
106
|
+
CONNECTION_CONFIG_MISSING_FIELD: "error.image.connection_config_missing_field",
|
|
107
|
+
CONNECTION_CONFIG_INVALID_FIELD_TYPE: "error.image.connection_config_invalid_field_type",
|
|
108
|
+
PROVIDER_NOT_FOUND: "error.image.provider_not_found",
|
|
109
|
+
DYNAMIC_MODELS_NOT_SUPPORTED: "error.image.dynamic_models_not_supported",
|
|
110
|
+
UNSUPPORTED_TEST_TYPE: "error.image.unsupported_test_type",
|
|
111
|
+
INVALID_RESPONSE_FORMAT: "error.image.invalid_response_format",
|
|
112
|
+
BASE64_DECODING_NOT_SUPPORTED: "error.image.base64_decoding_not_supported",
|
|
113
|
+
ONLY_SINGLE_IMAGE_SUPPORTED: "error.image.only_single_image_supported",
|
|
114
|
+
TEXT2IMAGE_INPUT_IMAGE_NOT_ALLOWED: "error.image.text2image_input_image_not_allowed",
|
|
115
|
+
IMAGE2IMAGE_INPUT_IMAGE_REQUIRED: "error.image.image2image_input_image_required",
|
|
116
|
+
INPUT_IMAGE_B64_REQUIRED: "error.image.input_image_b64_required",
|
|
117
|
+
INPUT_IMAGE_URL_NOT_SUPPORTED: "error.image.input_image_url_not_supported",
|
|
118
|
+
INPUT_IMAGE_INVALID_FORMAT: "error.image.input_image_invalid_format",
|
|
119
|
+
INPUT_IMAGE_UNSUPPORTED_MIME: "error.image.input_image_unsupported_mime",
|
|
120
|
+
INPUT_IMAGE_TOO_LARGE: "error.image.input_image_too_large",
|
|
121
|
+
INPUT_IMAGE_NORMALIZATION_FAILED: "error.image.input_image_normalization_failed",
|
|
122
|
+
INPUT_IMAGE_TOO_MANY: "error.image.input_image_too_many",
|
|
123
|
+
MULTI_IMAGE_AT_LEAST_TWO_REQUIRED: "error.image.multi_image_at_least_two_required",
|
|
124
|
+
MODEL_NOT_SUPPORT_TEXT2IMAGE: "error.image.model_not_support_text2image",
|
|
125
|
+
MODEL_NOT_SUPPORT_IMAGE2IMAGE: "error.image.model_not_support_image2image",
|
|
126
|
+
MODEL_NOT_SUPPORT_MULTI_IMAGE: "error.image.model_not_support_multi_image",
|
|
127
|
+
MODEL_ONLY_SUPPORTS_IMAGE2IMAGE_NEED_INPUT: "error.image.model_only_supports_image2image_need_input",
|
|
128
|
+
GENERATION_FAILED: "error.image.generation_failed"
|
|
129
|
+
};
|
|
130
|
+
var IMPORT_EXPORT_ERROR_CODES = {
|
|
131
|
+
EXPORT_FAILED: "error.import_export.export_failed",
|
|
132
|
+
IMPORT_FAILED: "error.import_export.import_failed",
|
|
133
|
+
VALIDATION_ERROR: "error.import_export.validation"
|
|
134
|
+
};
|
|
135
|
+
var DATA_ERROR_CODES = {
|
|
136
|
+
INVALID_JSON: "error.data.invalid_json",
|
|
137
|
+
INVALID_FORMAT: "error.data.invalid_format",
|
|
138
|
+
IMPORT_PARTIAL_FAILED: "error.data.import_partial_failed",
|
|
139
|
+
EXPORT_FAILED: "error.data.export_failed",
|
|
140
|
+
ELECTRON_API_UNAVAILABLE: "error.data.electron_api_unavailable"
|
|
141
|
+
};
|
|
142
|
+
var CORE_ERROR_CODES = {
|
|
143
|
+
IPC_SERIALIZATION_FAILED: "error.core.ipc_serialization_failed"
|
|
144
|
+
};
|
|
145
|
+
var ERROR_CODES = {
|
|
146
|
+
EVALUATION: EVALUATION_ERROR_CODES,
|
|
147
|
+
LLM: LLM_ERROR_CODES,
|
|
148
|
+
HISTORY: HISTORY_ERROR_CODES,
|
|
149
|
+
COMPARE: COMPARE_ERROR_CODES,
|
|
150
|
+
STORAGE: STORAGE_ERROR_CODES,
|
|
151
|
+
MODEL: MODEL_ERROR_CODES,
|
|
152
|
+
TEMPLATE: TEMPLATE_ERROR_CODES,
|
|
153
|
+
CONTEXT: CONTEXT_ERROR_CODES,
|
|
154
|
+
PROMPT: PROMPT_ERROR_CODES,
|
|
155
|
+
VARIABLE_EXTRACTION: VARIABLE_EXTRACTION_ERROR_CODES,
|
|
156
|
+
VARIABLE_VALUE_GENERATION: VARIABLE_VALUE_GENERATION_ERROR_CODES,
|
|
157
|
+
FAVORITE: FAVORITE_ERROR_CODES,
|
|
158
|
+
IMAGE: IMAGE_ERROR_CODES,
|
|
159
|
+
IMPORT_EXPORT: IMPORT_EXPORT_ERROR_CODES,
|
|
160
|
+
DATA: DATA_ERROR_CODES,
|
|
161
|
+
CORE: CORE_ERROR_CODES
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
// ../core/dist/chunk-PKBMQBKP.js
|
|
165
|
+
var __defProp = Object.defineProperty;
|
|
166
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
167
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
168
|
+
|
|
169
|
+
export {
|
|
170
|
+
EVALUATION_ERROR_CODES,
|
|
171
|
+
LLM_ERROR_CODES,
|
|
172
|
+
HISTORY_ERROR_CODES,
|
|
173
|
+
COMPARE_ERROR_CODES,
|
|
174
|
+
STORAGE_ERROR_CODES,
|
|
175
|
+
MODEL_ERROR_CODES,
|
|
176
|
+
TEMPLATE_ERROR_CODES,
|
|
177
|
+
CONTEXT_ERROR_CODES,
|
|
178
|
+
PROMPT_ERROR_CODES,
|
|
179
|
+
VARIABLE_EXTRACTION_ERROR_CODES,
|
|
180
|
+
VARIABLE_VALUE_GENERATION_ERROR_CODES,
|
|
181
|
+
FAVORITE_ERROR_CODES,
|
|
182
|
+
IMAGE_ERROR_CODES,
|
|
183
|
+
IMPORT_EXPORT_ERROR_CODES,
|
|
184
|
+
DATA_ERROR_CODES,
|
|
185
|
+
CORE_ERROR_CODES,
|
|
186
|
+
ERROR_CODES,
|
|
187
|
+
__publicField
|
|
188
|
+
};
|