@openspecui/core 3.11.1 → 3.11.3
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/dist/{document-translation-Dnl1lz2K.mjs → document-translation-BrlCvnLZ.mjs} +9 -1
- package/dist/{document-translation-AlZtjOt5.d.mts → document-translation-Cv6BIGL5.d.mts} +117 -23
- package/dist/document-translation.d.mts +1 -1
- package/dist/document-translation.mjs +2 -2
- package/dist/index.d.mts +215 -47
- package/dist/index.mjs +254 -6
- package/dist/{local-download-profiles-DISrU0mw.d.mts → local-download-profiles-GKs2OOqJ.d.mts} +1 -1
- package/dist/local-download-profiles.d.mts +2 -2
- package/dist/{notifications-gGjGaYsF.d.mts → notifications-CJQ_F_Un.d.mts} +9 -9
- package/dist/notifications.d.mts +2 -2
- package/dist/{openspec-projection-BojcJ9zl.d.mts → openspec-projection-BbuPTbvj.d.mts} +1 -1
- package/dist/openspec-projection.d.mts +2 -2
- package/dist/{opsx-entity-BdyGTVs_.d.mts → opsx-entity-BO9G2SCW.d.mts} +7 -7
- package/dist/opsx-entity.d.mts +2 -2
- package/dist/{opsx-schema-detail-Cf8YIflR.d.mts → opsx-schema-detail-DTajJW4g.d.mts} +1 -1
- package/dist/opsx-schema-detail.d.mts +3 -3
- package/dist/{schemas-DV6yABO9.d.mts → schemas-DQzd1hgp.d.mts} +30 -30
- package/dist/{sounds-C906qHTJ.d.mts → sounds-3yEx1YXT.d.mts} +5 -5
- package/dist/sounds.d.mts +1 -1
- package/dist/{terminal-audio-D6dE8O1_.d.mts → terminal-audio-UCLlM1qN.d.mts} +2 -2
- package/dist/terminal-audio.d.mts +2 -2
- package/dist/terminal-control.d.mts +2 -2
- package/dist/{terminal-invocation-Cz0vfgkw.d.mts → terminal-invocation-DCPc8hmm.d.mts} +42 -42
- package/dist/terminal-invocation.d.mts +1 -1
- package/dist/{translation-language-pair-D6f5u70K.mjs → translation-language-pair-Cb4a0hG6.mjs} +2 -1
- package/dist/translation-language-pair.mjs +1 -1
- package/dist/translator-Car0_7uk.mjs +412 -0
- package/dist/{translator-tTXEGRdz.d.mts → translator-prn3W9lf.d.mts} +786 -111
- package/dist/translator.d.mts +2 -2
- package/dist/translator.mjs +2 -2
- package/package.json +1 -1
- package/dist/translator-B0T5VL9k.mjs +0 -239
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/translator.ts
|
|
4
|
+
const TRANSLATOR_CONTRACT_VERSION = 3;
|
|
5
|
+
const TRANSLATION_ENGINE_IDS = [
|
|
6
|
+
"browser",
|
|
7
|
+
"local",
|
|
8
|
+
"local-ct2",
|
|
9
|
+
"local-llama",
|
|
10
|
+
"openai"
|
|
11
|
+
];
|
|
12
|
+
const TranslationEngineIdSchema = z.enum(TRANSLATION_ENGINE_IDS);
|
|
13
|
+
const DEFAULT_TRANSLATION_ENGINE_ID = "browser";
|
|
14
|
+
function isManagedLocalTranslationEngineId(engineId) {
|
|
15
|
+
return engineId === "local" || engineId === "local-ct2" || engineId === "local-llama";
|
|
16
|
+
}
|
|
17
|
+
function isDirectionalManagedLocalTranslationEngineId(engineId) {
|
|
18
|
+
return engineId === "local" || engineId === "local-ct2";
|
|
19
|
+
}
|
|
20
|
+
const SERVICE_TRANSLATION_ENGINE_IDS = [
|
|
21
|
+
"local",
|
|
22
|
+
"local-ct2",
|
|
23
|
+
"local-llama",
|
|
24
|
+
"openai"
|
|
25
|
+
];
|
|
26
|
+
const ServiceTranslationEngineIdSchema = z.enum(SERVICE_TRANSLATION_ENGINE_IDS);
|
|
27
|
+
const LocalModelDownloadStatusSchema = z.enum([
|
|
28
|
+
"not-downloaded",
|
|
29
|
+
"queued",
|
|
30
|
+
"downloading",
|
|
31
|
+
"paused",
|
|
32
|
+
"downloaded",
|
|
33
|
+
"error",
|
|
34
|
+
"deleting"
|
|
35
|
+
]);
|
|
36
|
+
const TranslationDownloadFilePlanSchema = z.object({
|
|
37
|
+
path: z.string().min(1),
|
|
38
|
+
sizeBytes: z.number().int().nonnegative().optional(),
|
|
39
|
+
required: z.boolean(),
|
|
40
|
+
etag: z.string().min(1).optional(),
|
|
41
|
+
revision: z.string().min(1).optional(),
|
|
42
|
+
sourceUrl: z.string().min(1).optional(),
|
|
43
|
+
raw: z.unknown().optional()
|
|
44
|
+
});
|
|
45
|
+
const TranslationDownloadGroupPlanSchema = z.object({
|
|
46
|
+
id: z.string().min(1),
|
|
47
|
+
label: z.string().min(1),
|
|
48
|
+
description: z.string().optional(),
|
|
49
|
+
profile: z.string().min(1).optional(),
|
|
50
|
+
dtype: z.string().min(1).optional(),
|
|
51
|
+
estimatedTotalBytes: z.number().int().nonnegative().optional(),
|
|
52
|
+
baseGroupId: z.string().min(1).optional(),
|
|
53
|
+
commitHash: z.string().min(1).optional(),
|
|
54
|
+
shortCommitHash: z.string().min(1).optional(),
|
|
55
|
+
rootDir: z.string().min(1).optional(),
|
|
56
|
+
status: LocalModelDownloadStatusSchema.optional(),
|
|
57
|
+
progress: z.number().min(0).max(1).optional(),
|
|
58
|
+
bytesDownloaded: z.number().int().nonnegative().optional(),
|
|
59
|
+
totalBytes: z.number().int().nonnegative().optional(),
|
|
60
|
+
resumable: z.boolean().optional(),
|
|
61
|
+
error: z.string().optional(),
|
|
62
|
+
selectable: z.boolean(),
|
|
63
|
+
selected: z.boolean(),
|
|
64
|
+
files: z.array(TranslationDownloadFilePlanSchema)
|
|
65
|
+
});
|
|
66
|
+
const LocalModelProfileStatusSchema = z.enum([
|
|
67
|
+
"idle",
|
|
68
|
+
"loading",
|
|
69
|
+
"ready",
|
|
70
|
+
"error"
|
|
71
|
+
]);
|
|
72
|
+
const LocalModelProfileManifestFileSchema = z.object({
|
|
73
|
+
path: z.string().min(1),
|
|
74
|
+
sizeBytes: z.number().int().nonnegative().optional(),
|
|
75
|
+
required: z.boolean(),
|
|
76
|
+
etag: z.string().min(1).optional(),
|
|
77
|
+
revision: z.string().min(1).optional(),
|
|
78
|
+
sourceUrl: z.string().min(1).optional(),
|
|
79
|
+
raw: z.unknown().optional()
|
|
80
|
+
});
|
|
81
|
+
const LocalModelProfileManifestGroupSchema = z.object({
|
|
82
|
+
id: z.string().min(1),
|
|
83
|
+
baseGroupId: z.string().min(1),
|
|
84
|
+
label: z.string().min(1),
|
|
85
|
+
displayLabel: z.string().min(1),
|
|
86
|
+
description: z.string().optional(),
|
|
87
|
+
profile: z.string().min(1).optional(),
|
|
88
|
+
dtype: z.string().min(1).optional(),
|
|
89
|
+
commitHash: z.string().min(1),
|
|
90
|
+
shortCommitHash: z.string().min(1),
|
|
91
|
+
rootDir: z.string().min(1),
|
|
92
|
+
estimatedTotalBytes: z.number().int().nonnegative().optional(),
|
|
93
|
+
selectable: z.boolean(),
|
|
94
|
+
files: z.array(LocalModelProfileManifestFileSchema)
|
|
95
|
+
});
|
|
96
|
+
const LocalModelProfileManifestSchema = z.object({
|
|
97
|
+
modelId: z.string().min(1),
|
|
98
|
+
source: z.literal("huggingface"),
|
|
99
|
+
endpoint: z.string().default(""),
|
|
100
|
+
revision: z.string().min(1),
|
|
101
|
+
commitHash: z.string().min(1),
|
|
102
|
+
shortCommitHash: z.string().min(1),
|
|
103
|
+
fetchedAt: z.number().int().nonnegative(),
|
|
104
|
+
updatedAt: z.number().int().nonnegative(),
|
|
105
|
+
raw: z.unknown().optional(),
|
|
106
|
+
groups: z.record(z.string(), LocalModelProfileManifestGroupSchema).default({}),
|
|
107
|
+
groupOrder: z.array(z.string().min(1)).default([])
|
|
108
|
+
});
|
|
109
|
+
const LocalModelLifecycleFileStateSchema = z.object({
|
|
110
|
+
path: z.string().min(1),
|
|
111
|
+
sizeBytes: z.number().int().nonnegative().optional(),
|
|
112
|
+
downloadedBytes: z.number().int().nonnegative().optional(),
|
|
113
|
+
required: z.boolean().default(true),
|
|
114
|
+
status: LocalModelDownloadStatusSchema.default("not-downloaded"),
|
|
115
|
+
updatedAt: z.number().int().nonnegative().optional(),
|
|
116
|
+
error: z.string().optional()
|
|
117
|
+
});
|
|
118
|
+
const LocalModelLifecycleGroupStateSchema = z.object({
|
|
119
|
+
groupId: z.string().min(1),
|
|
120
|
+
baseGroupId: z.string().min(1).optional(),
|
|
121
|
+
status: LocalModelDownloadStatusSchema.default("not-downloaded"),
|
|
122
|
+
rootDir: z.string().min(1).optional(),
|
|
123
|
+
bytesDownloaded: z.number().int().nonnegative().optional(),
|
|
124
|
+
totalBytes: z.number().int().nonnegative().optional(),
|
|
125
|
+
progress: z.number().min(0).max(1).optional(),
|
|
126
|
+
resumable: z.boolean().default(false),
|
|
127
|
+
error: z.string().optional(),
|
|
128
|
+
installedAt: z.number().int().nonnegative().optional(),
|
|
129
|
+
updatedAt: z.number().int().nonnegative().optional(),
|
|
130
|
+
files: z.array(LocalModelLifecycleFileStateSchema).default([])
|
|
131
|
+
});
|
|
132
|
+
const LocalModelProfileLoadStateSchema = z.object({
|
|
133
|
+
status: LocalModelProfileStatusSchema.default("idle"),
|
|
134
|
+
message: z.string().optional(),
|
|
135
|
+
error: z.string().optional(),
|
|
136
|
+
updatedAt: z.number().int().nonnegative().optional()
|
|
137
|
+
});
|
|
138
|
+
const LocalModelAssetLogSchema = z.object({
|
|
139
|
+
engineId: z.enum([
|
|
140
|
+
"local",
|
|
141
|
+
"local-ct2",
|
|
142
|
+
"local-llama"
|
|
143
|
+
]),
|
|
144
|
+
modelId: z.string().min(1),
|
|
145
|
+
selectedGroupId: z.string().min(1).optional(),
|
|
146
|
+
groupId: z.string().min(1).optional(),
|
|
147
|
+
status: LocalModelDownloadStatusSchema,
|
|
148
|
+
message: z.string(),
|
|
149
|
+
progress: z.number().min(0).max(1).optional(),
|
|
150
|
+
bytesDownloaded: z.number().int().nonnegative().optional(),
|
|
151
|
+
totalBytes: z.number().int().nonnegative().optional(),
|
|
152
|
+
sessionId: z.string().optional(),
|
|
153
|
+
resumable: z.boolean().optional(),
|
|
154
|
+
files: z.array(z.object({
|
|
155
|
+
path: z.string().min(1),
|
|
156
|
+
sizeBytes: z.number().int().nonnegative().optional(),
|
|
157
|
+
downloadedBytes: z.number().int().nonnegative().optional()
|
|
158
|
+
})).optional(),
|
|
159
|
+
updatedAt: z.number().int().nonnegative()
|
|
160
|
+
});
|
|
161
|
+
const LocalModelAssetPlanSnapshotSchema = z.object({
|
|
162
|
+
modelId: z.string().min(1),
|
|
163
|
+
estimatedTotalBytes: z.number().int().nonnegative().optional(),
|
|
164
|
+
files: z.array(TranslationDownloadFilePlanSchema),
|
|
165
|
+
profile: z.string().min(1).optional(),
|
|
166
|
+
selectedGroupId: z.string().min(1).optional(),
|
|
167
|
+
groups: z.array(TranslationDownloadGroupPlanSchema).optional()
|
|
168
|
+
});
|
|
169
|
+
const LocalModelAssetStateSchema = z.object({
|
|
170
|
+
modelId: z.string().min(1),
|
|
171
|
+
version: z.literal(2).default(2),
|
|
172
|
+
status: LocalModelDownloadStatusSchema.default("not-downloaded"),
|
|
173
|
+
selected: z.boolean().default(false),
|
|
174
|
+
selectedGroupId: z.string().min(1).optional(),
|
|
175
|
+
installedAt: z.number().int().nonnegative().optional(),
|
|
176
|
+
updatedAt: z.number().int().nonnegative().optional(),
|
|
177
|
+
bytesDownloaded: z.number().int().nonnegative().optional(),
|
|
178
|
+
totalBytes: z.number().int().nonnegative().optional(),
|
|
179
|
+
progress: z.number().min(0).max(1).optional(),
|
|
180
|
+
resumable: z.boolean().default(false),
|
|
181
|
+
error: z.string().optional(),
|
|
182
|
+
profileLoad: LocalModelProfileLoadStateSchema.default(LocalModelProfileLoadStateSchema.parse({})),
|
|
183
|
+
profileManifest: LocalModelProfileManifestSchema.optional(),
|
|
184
|
+
groupsState: z.record(z.string(), LocalModelLifecycleGroupStateSchema).default({}),
|
|
185
|
+
plan: LocalModelAssetPlanSnapshotSchema.optional(),
|
|
186
|
+
files: z.array(z.object({
|
|
187
|
+
path: z.string().min(1),
|
|
188
|
+
sizeBytes: z.number().int().nonnegative().optional(),
|
|
189
|
+
downloadedBytes: z.number().int().nonnegative().optional()
|
|
190
|
+
})).default([])
|
|
191
|
+
});
|
|
192
|
+
const ManagedLocalCatalogSourceSchema = z.enum([
|
|
193
|
+
"local",
|
|
194
|
+
"network",
|
|
195
|
+
"recommended"
|
|
196
|
+
]);
|
|
197
|
+
const TranslationEngineDependencyStateSchema = z.enum([
|
|
198
|
+
"installed",
|
|
199
|
+
"installing",
|
|
200
|
+
"missing",
|
|
201
|
+
"error",
|
|
202
|
+
"not-applicable"
|
|
203
|
+
]);
|
|
204
|
+
const TranslationEngineRuntimeStateSchema = z.enum([
|
|
205
|
+
"ready",
|
|
206
|
+
"probing",
|
|
207
|
+
"failed",
|
|
208
|
+
"error",
|
|
209
|
+
"not-applicable"
|
|
210
|
+
]);
|
|
211
|
+
const TranslationEngineAssetStateSchema = z.enum([
|
|
212
|
+
"ready",
|
|
213
|
+
"missing",
|
|
214
|
+
"downloading",
|
|
215
|
+
"error",
|
|
216
|
+
"not-applicable"
|
|
217
|
+
]);
|
|
218
|
+
const TranslationEngineLifecyclePhaseMetaSchema = z.object({
|
|
219
|
+
message: z.string().optional(),
|
|
220
|
+
progress: z.number().min(0).max(1).optional(),
|
|
221
|
+
error: z.string().optional()
|
|
222
|
+
});
|
|
223
|
+
const TranslationEngineDependencyStatusSchema = TranslationEngineLifecyclePhaseMetaSchema.extend({ state: TranslationEngineDependencyStateSchema });
|
|
224
|
+
const TranslationEngineRuntimeStatusSchema = TranslationEngineLifecyclePhaseMetaSchema.extend({ state: TranslationEngineRuntimeStateSchema });
|
|
225
|
+
const TranslationEngineAssetStatusSchema = TranslationEngineLifecyclePhaseMetaSchema.extend({ state: TranslationEngineAssetStateSchema });
|
|
226
|
+
const TranslationEngineLifecycleStatusSchema = z.object({
|
|
227
|
+
dependency: TranslationEngineDependencyStatusSchema,
|
|
228
|
+
runtime: TranslationEngineRuntimeStatusSchema,
|
|
229
|
+
assets: TranslationEngineAssetStatusSchema,
|
|
230
|
+
summary: z.string().optional()
|
|
231
|
+
});
|
|
232
|
+
function createTranslationEngineLifecycleStatus(input = {}) {
|
|
233
|
+
return {
|
|
234
|
+
dependency: {
|
|
235
|
+
state: "not-applicable",
|
|
236
|
+
...input.dependency
|
|
237
|
+
},
|
|
238
|
+
runtime: {
|
|
239
|
+
state: "not-applicable",
|
|
240
|
+
...input.runtime
|
|
241
|
+
},
|
|
242
|
+
assets: {
|
|
243
|
+
state: "not-applicable",
|
|
244
|
+
...input.assets
|
|
245
|
+
},
|
|
246
|
+
...input.summary ? { summary: input.summary } : {}
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
function isTranslationEngineDependencyReady(status) {
|
|
250
|
+
return status.dependency.state === "installed" || status.dependency.state === "not-applicable";
|
|
251
|
+
}
|
|
252
|
+
function isTranslationEngineRuntimeReady(status) {
|
|
253
|
+
return status.runtime.state === "ready" || status.runtime.state === "not-applicable";
|
|
254
|
+
}
|
|
255
|
+
function shouldShowTranslationEngineInstallGate(status) {
|
|
256
|
+
if (!status) return false;
|
|
257
|
+
return !isTranslationEngineDependencyReady(status) || !isTranslationEngineRuntimeReady(status);
|
|
258
|
+
}
|
|
259
|
+
function getTranslationEngineLifecycleMessage(status) {
|
|
260
|
+
if (!status) return void 0;
|
|
261
|
+
return status.summary ?? status.runtime.error ?? status.runtime.message ?? status.dependency.error ?? status.dependency.message ?? status.assets.error ?? status.assets.message;
|
|
262
|
+
}
|
|
263
|
+
const TranslationEngineInstallLogStreamSchema = z.enum(["stdout", "stderr"]);
|
|
264
|
+
const TranslationEngineInstallLogEventSchema = z.object({
|
|
265
|
+
stream: TranslationEngineInstallLogStreamSchema,
|
|
266
|
+
text: z.string()
|
|
267
|
+
});
|
|
268
|
+
const TranslationEngineLifecycleEventSchema = z.discriminatedUnion("type", [
|
|
269
|
+
z.object({
|
|
270
|
+
type: z.literal("status"),
|
|
271
|
+
lifecycle: TranslationEngineLifecycleStatusSchema
|
|
272
|
+
}),
|
|
273
|
+
z.object({
|
|
274
|
+
type: z.literal("log"),
|
|
275
|
+
stream: TranslationEngineInstallLogStreamSchema,
|
|
276
|
+
text: z.string()
|
|
277
|
+
}),
|
|
278
|
+
z.object({
|
|
279
|
+
type: z.literal("exit"),
|
|
280
|
+
lifecycle: TranslationEngineLifecycleStatusSchema
|
|
281
|
+
})
|
|
282
|
+
]);
|
|
283
|
+
const TRANSLATION_ENGINE_MANIFESTS = [
|
|
284
|
+
{
|
|
285
|
+
id: "browser",
|
|
286
|
+
label: "Browser",
|
|
287
|
+
description: "Uses the browser Translator API and future browser-side providers.",
|
|
288
|
+
technicalSummary: "Browser-native Web Translator adapter. Package payload is about 5 KB; browser language packs are managed by the browser.",
|
|
289
|
+
runtime: "browser",
|
|
290
|
+
kind: "browser",
|
|
291
|
+
installDescription: "Browser translation support is built into the browser runtime.",
|
|
292
|
+
moduleName: "@openspecui/browser-translator",
|
|
293
|
+
factoryExport: "createBrowserTranslatorFactory"
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
id: "local",
|
|
297
|
+
label: "Local-Transformers",
|
|
298
|
+
description: "Runs an ONNX Runtime-backed local translation adapter through Transformers.js with managed ONNX model files.",
|
|
299
|
+
technicalSummary: "Server-side ONNX Runtime adapter via Transformers.js. Runtime package is installed on demand; selected ONNX model groups are downloaded separately and can range from tens to hundreds of MB.",
|
|
300
|
+
runtime: "server",
|
|
301
|
+
kind: "managed-local",
|
|
302
|
+
settingsKey: "local",
|
|
303
|
+
defaultModel: "Xenova/nllb-200-distilled-600M",
|
|
304
|
+
runtimePackageName: "@huggingface/transformers",
|
|
305
|
+
installDescription: "Install the Local-Transformers runtime package to enable server-side translation.",
|
|
306
|
+
modelLabel: "Local Model",
|
|
307
|
+
downloadGroupsLabel: "Local download profiles",
|
|
308
|
+
refreshTooltip: "Refresh local model profiles",
|
|
309
|
+
moduleName: "@openspecui/local-translator",
|
|
310
|
+
factoryExport: "createLocalTranslatorFactory"
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
id: "local-ct2",
|
|
314
|
+
label: "Local-CT2",
|
|
315
|
+
description: "Runs a bundled local CTranslate2 translation runtime with managed model files.",
|
|
316
|
+
technicalSummary: "Server-side native CTranslate2 adapter. Runtime package is installed on demand; selected model artifacts are downloaded separately and can range from tens to hundreds of MB.",
|
|
317
|
+
runtime: "server",
|
|
318
|
+
kind: "managed-local",
|
|
319
|
+
settingsKey: "localCt2",
|
|
320
|
+
defaultModel: "ooeoeo/opus-mt-en-zh-ct2-float16",
|
|
321
|
+
runtimePackageName: "ctranslate2",
|
|
322
|
+
installDescription: "Install the Local-CT2 runtime package to enable server-side translation.",
|
|
323
|
+
modelLabel: "CT2 Model",
|
|
324
|
+
downloadGroupsLabel: "Local CT2 download groups",
|
|
325
|
+
refreshTooltip: "Refresh local model artifacts",
|
|
326
|
+
moduleName: "@openspecui/local-ct2-translator",
|
|
327
|
+
factoryExport: "createLocalCt2TranslatorFactory"
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
id: "local-llama",
|
|
331
|
+
label: "Local-Llama",
|
|
332
|
+
description: "Runs a local GGUF translation-capable LLM through node-llama-cpp with managed GGUF model files.",
|
|
333
|
+
technicalSummary: "Server-side llama.cpp adapter via node-llama-cpp. Runtime package is installed on demand; selected GGUF model files are downloaded separately and can range from hundreds of MB to multiple GB.",
|
|
334
|
+
runtime: "server",
|
|
335
|
+
kind: "managed-local",
|
|
336
|
+
settingsKey: "localLlama",
|
|
337
|
+
defaultModel: "bartowski/Qwen2.5-0.5B-Instruct-GGUF",
|
|
338
|
+
runtimePackageName: "node-llama-cpp",
|
|
339
|
+
installDescription: "Install the Local-Llama runtime package to enable server-side GGUF translation.",
|
|
340
|
+
modelLabel: "Llama Model",
|
|
341
|
+
downloadGroupsLabel: "Local GGUF files",
|
|
342
|
+
refreshTooltip: "Refresh local GGUF artifacts",
|
|
343
|
+
moduleName: "@openspecui/local-llama-translator",
|
|
344
|
+
factoryExport: "createLocalLlamaTranslatorFactory"
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
id: "openai",
|
|
348
|
+
label: "OpenAI-Completion",
|
|
349
|
+
description: "Uses an OpenAI-compatible TanStack AI completion provider for context-aware translation.",
|
|
350
|
+
technicalSummary: "Server-side TanStack AI adapter for OpenAI-compatible APIs. Package payload is about 5 KB; model size stays with the remote provider.",
|
|
351
|
+
runtime: "server",
|
|
352
|
+
kind: "remote-provider",
|
|
353
|
+
settingsKey: "openai",
|
|
354
|
+
defaultModel: "gpt-4.1-mini",
|
|
355
|
+
installDescription: "OpenAI completion translation is bundled with the server runtime.",
|
|
356
|
+
moduleName: "@openspecui/openai-completion-translator",
|
|
357
|
+
factoryExport: "createOpenAICompletionTranslatorFactory"
|
|
358
|
+
}
|
|
359
|
+
];
|
|
360
|
+
function getTranslationEngineManifest(engineId) {
|
|
361
|
+
const manifest = TRANSLATION_ENGINE_MANIFESTS.find((engine) => engine.id === engineId);
|
|
362
|
+
if (!manifest) throw new Error(`Unknown translation engine: ${engineId}`);
|
|
363
|
+
return manifest;
|
|
364
|
+
}
|
|
365
|
+
function getManagedLocalTranslationEngineManifest(engineId) {
|
|
366
|
+
const manifest = getTranslationEngineManifest(engineId);
|
|
367
|
+
if (manifest.kind !== "managed-local") throw new Error(`Translation engine ${engineId} is not a managed-local engine.`);
|
|
368
|
+
return manifest;
|
|
369
|
+
}
|
|
370
|
+
const TranslationOpenAISettingsSchema = z.object({
|
|
371
|
+
baseUrl: z.string().default(""),
|
|
372
|
+
token: z.string().default(""),
|
|
373
|
+
model: z.string().default("gpt-4.1-mini")
|
|
374
|
+
});
|
|
375
|
+
const TranslationLocalSettingsSchema = z.object({
|
|
376
|
+
model: z.string().default("Xenova/nllb-200-distilled-600M"),
|
|
377
|
+
selectedGroupId: z.string().optional(),
|
|
378
|
+
hfEndpoint: z.string().default("")
|
|
379
|
+
});
|
|
380
|
+
const TranslationLocalCt2SettingsSchema = z.object({
|
|
381
|
+
model: z.string().default("ooeoeo/opus-mt-en-zh-ct2-float16"),
|
|
382
|
+
selectedGroupId: z.string().optional(),
|
|
383
|
+
hfEndpoint: z.string().default("")
|
|
384
|
+
});
|
|
385
|
+
const TranslationLocalLlamaSettingsSchema = z.object({
|
|
386
|
+
model: z.string().default("bartowski/Qwen2.5-0.5B-Instruct-GGUF"),
|
|
387
|
+
selectedGroupId: z.string().optional(),
|
|
388
|
+
hfEndpoint: z.string().default("")
|
|
389
|
+
});
|
|
390
|
+
const TranslationEngineGlobalSettingsSchema = z.object({
|
|
391
|
+
openai: TranslationOpenAISettingsSchema.default(TranslationOpenAISettingsSchema.parse({})),
|
|
392
|
+
local: TranslationLocalSettingsSchema.default(TranslationLocalSettingsSchema.parse({})),
|
|
393
|
+
localCt2: TranslationLocalCt2SettingsSchema.default(TranslationLocalCt2SettingsSchema.parse({})),
|
|
394
|
+
localLlama: TranslationLocalLlamaSettingsSchema.default(TranslationLocalLlamaSettingsSchema.parse({}))
|
|
395
|
+
});
|
|
396
|
+
const BatchTranslateInputSchema = z.object({
|
|
397
|
+
engineId: TranslationEngineIdSchema,
|
|
398
|
+
sourceLanguage: z.string().min(1),
|
|
399
|
+
targetLanguage: z.string().min(1),
|
|
400
|
+
model: z.string().min(1).optional(),
|
|
401
|
+
selectedGroupId: z.string().min(1).optional(),
|
|
402
|
+
inputs: z.array(z.string()).min(1),
|
|
403
|
+
instructions: z.string().optional(),
|
|
404
|
+
context: z.string().optional()
|
|
405
|
+
});
|
|
406
|
+
const BatchTranslateEventSchema = z.object({
|
|
407
|
+
index: z.number().int().nonnegative(),
|
|
408
|
+
output: z.string()
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
//#endregion
|
|
412
|
+
export { TranslationEngineInstallLogStreamSchema as A, getManagedLocalTranslationEngineManifest as B, TranslationEngineAssetStateSchema as C, TranslationEngineGlobalSettingsSchema as D, TranslationEngineDependencyStatusSchema as E, TranslationLocalCt2SettingsSchema as F, isTranslationEngineDependencyReady as G, getTranslationEngineManifest as H, TranslationLocalLlamaSettingsSchema as I, isTranslationEngineRuntimeReady as K, TranslationLocalSettingsSchema as L, TranslationEngineLifecycleStatusSchema as M, TranslationEngineRuntimeStateSchema as N, TranslationEngineIdSchema as O, TranslationEngineRuntimeStatusSchema as P, TranslationOpenAISettingsSchema as R, TranslationDownloadGroupPlanSchema as S, TranslationEngineDependencyStateSchema as T, isDirectionalManagedLocalTranslationEngineId as U, getTranslationEngineLifecycleMessage as V, isManagedLocalTranslationEngineId as W, ServiceTranslationEngineIdSchema as _, LocalModelAssetPlanSnapshotSchema as a, TRANSLATOR_CONTRACT_VERSION as b, LocalModelLifecycleFileStateSchema as c, LocalModelProfileManifestFileSchema as d, LocalModelProfileManifestGroupSchema as f, SERVICE_TRANSLATION_ENGINE_IDS as g, ManagedLocalCatalogSourceSchema as h, LocalModelAssetLogSchema as i, TranslationEngineLifecycleEventSchema as j, TranslationEngineInstallLogEventSchema as k, LocalModelLifecycleGroupStateSchema as l, LocalModelProfileStatusSchema as m, BatchTranslateInputSchema as n, LocalModelAssetStateSchema as o, LocalModelProfileManifestSchema as p, shouldShowTranslationEngineInstallGate as q, DEFAULT_TRANSLATION_ENGINE_ID as r, LocalModelDownloadStatusSchema as s, BatchTranslateEventSchema as t, LocalModelProfileLoadStateSchema as u, TRANSLATION_ENGINE_IDS as v, TranslationEngineAssetStatusSchema as w, TranslationDownloadFilePlanSchema as x, TRANSLATION_ENGINE_MANIFESTS as y, createTranslationEngineLifecycleStatus as z };
|