dsh-select-quote 0.3.17 → 0.3.19
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/README.md +19 -5
- package/lib/client.js +2116 -319
- package/lib/index.js +300 -8
- package/lib/typert.js +168 -75
- package/locale/de.json +1 -1
- package/locale/en.json +1 -1
- package/locale/es.json +1 -1
- package/locale/fr.json +1 -1
- package/locale/ja.json +1 -1
- package/locale/pt.json +1 -1
- package/locale/ru.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +5 -2
package/lib/index.js
CHANGED
|
@@ -899,15 +899,17 @@ defineMethod("transform", [
|
|
|
899
899
|
*/
|
|
900
900
|
const PACKAGE_NAME = "dsh-select-quote";
|
|
901
901
|
//#endregion
|
|
902
|
-
//#region src/shared/
|
|
902
|
+
//#region src/shared/plugin-remote.ts
|
|
903
903
|
/**
|
|
904
904
|
* Wire contract shared by the two halves.
|
|
905
905
|
*
|
|
906
|
-
* The Host owns the
|
|
907
|
-
* mounts the same descriptor group
|
|
908
|
-
* schemas are written here so the
|
|
906
|
+
* The Host owns the implementations (`ctx.selectQuoteSideTask`,
|
|
907
|
+
* `ctx.selectQuoteTranslate`); the browser mounts the same descriptor group
|
|
908
|
+
* through `ctx.remote.$mount(...)`. Both schemas are written here so the
|
|
909
|
+
* argument shapes cannot drift apart.
|
|
909
910
|
*/
|
|
910
911
|
const SIDE_TASK_SERVICE = "selectQuoteSideTask";
|
|
912
|
+
const TRANSLATE_SERVICE = "selectQuoteTranslate";
|
|
911
913
|
//#endregion
|
|
912
914
|
//#region src/shared/side-task-reuse.ts
|
|
913
915
|
/**
|
|
@@ -945,8 +947,8 @@ function isNotResumable(error) {
|
|
|
945
947
|
* It is a plain string (not a Symbol), so a third-party package can publish the
|
|
946
948
|
* same marker without importing the protocol package at runtime.
|
|
947
949
|
*/
|
|
948
|
-
const REMOTE_METHOD_DESCRIPTOR = "@deepseek-ai/dsh-typert-protocol/remote-methods";
|
|
949
|
-
const REMOTE_METHODS = Object.freeze({
|
|
950
|
+
const REMOTE_METHOD_DESCRIPTOR$1 = "@deepseek-ai/dsh-typert-protocol/remote-methods";
|
|
951
|
+
const REMOTE_METHODS$1 = Object.freeze({
|
|
950
952
|
version: 1,
|
|
951
953
|
methods: Object.freeze([Object.freeze({
|
|
952
954
|
method: "create",
|
|
@@ -1016,7 +1018,280 @@ var SelectQuoteSideTask = class extends Service {
|
|
|
1016
1018
|
})).childId };
|
|
1017
1019
|
}
|
|
1018
1020
|
};
|
|
1019
|
-
Object.defineProperty(SelectQuoteSideTask.prototype, REMOTE_METHOD_DESCRIPTOR, {
|
|
1021
|
+
Object.defineProperty(SelectQuoteSideTask.prototype, REMOTE_METHOD_DESCRIPTOR$1, {
|
|
1022
|
+
configurable: true,
|
|
1023
|
+
value: REMOTE_METHODS$1
|
|
1024
|
+
});
|
|
1025
|
+
//#endregion
|
|
1026
|
+
//#region src/translate-service.ts
|
|
1027
|
+
/**
|
|
1028
|
+
* Host face of the translation entry point.
|
|
1029
|
+
*
|
|
1030
|
+
* The browser owns the popover, language choice, and the prompt (built-in or
|
|
1031
|
+
* the user's custom text). This service only resolves the route, calls the
|
|
1032
|
+
* provider once, and streams the text back. No subagent and no session
|
|
1033
|
+
* context: the model receives exactly the system prompt plus the selected
|
|
1034
|
+
* passage.
|
|
1035
|
+
*
|
|
1036
|
+
* Thinking is requested off. A route that cannot disable it keeps its own
|
|
1037
|
+
* default; the stream then announces `thinking` so the popover can show a
|
|
1038
|
+
* reasoning loader instead of a frozen spinner.
|
|
1039
|
+
*/
|
|
1040
|
+
const REMOTE_METHOD_DESCRIPTOR = "@deepseek-ai/dsh-typert-protocol/remote-methods";
|
|
1041
|
+
const REMOTE_METHODS = Object.freeze({
|
|
1042
|
+
version: 1,
|
|
1043
|
+
methods: Object.freeze([Object.freeze({
|
|
1044
|
+
method: "translate",
|
|
1045
|
+
mode: "stream",
|
|
1046
|
+
invocation: Object.freeze({ kind: "direct" })
|
|
1047
|
+
})])
|
|
1048
|
+
});
|
|
1049
|
+
/** Generous enough for a reasoning model to answer one bounded passage. */
|
|
1050
|
+
const TIMEOUT_MS = 9e4;
|
|
1051
|
+
const MAX_TEXT_CHARS = 8e3;
|
|
1052
|
+
const MAX_PROMPT_CHARS = 8e3;
|
|
1053
|
+
const LANGUAGES = /* @__PURE__ */ new Set([
|
|
1054
|
+
"zh",
|
|
1055
|
+
"en",
|
|
1056
|
+
"ja",
|
|
1057
|
+
"es",
|
|
1058
|
+
"fr",
|
|
1059
|
+
"de",
|
|
1060
|
+
"ru",
|
|
1061
|
+
"pt"
|
|
1062
|
+
]);
|
|
1063
|
+
var SelectQuoteTranslate = class extends Service {
|
|
1064
|
+
/** Visible binding the Gateway's source-mode discovery requires. */
|
|
1065
|
+
typertRemote;
|
|
1066
|
+
constructor(ctx) {
|
|
1067
|
+
super(ctx, TRANSLATE_SERVICE);
|
|
1068
|
+
this.typertRemote = Object.freeze({
|
|
1069
|
+
service: this,
|
|
1070
|
+
serviceKey: TRANSLATE_SERVICE,
|
|
1071
|
+
namespace: TRANSLATE_SERVICE
|
|
1072
|
+
});
|
|
1073
|
+
}
|
|
1074
|
+
async *translate(agent, request, signal) {
|
|
1075
|
+
const services = this.ctx;
|
|
1076
|
+
const log = loggerOf(services.logger);
|
|
1077
|
+
const meta = {
|
|
1078
|
+
target: request.target,
|
|
1079
|
+
chars: request.text.length,
|
|
1080
|
+
provider: request.provider,
|
|
1081
|
+
model: request.model
|
|
1082
|
+
};
|
|
1083
|
+
const controller = new AbortController();
|
|
1084
|
+
let timedOut = false;
|
|
1085
|
+
const abortFromCaller = () => {
|
|
1086
|
+
controller.abort(signal?.reason);
|
|
1087
|
+
};
|
|
1088
|
+
const timer = setTimeout(() => {
|
|
1089
|
+
timedOut = true;
|
|
1090
|
+
controller.abort(/* @__PURE__ */ new Error("translation timed out"));
|
|
1091
|
+
}, TIMEOUT_MS);
|
|
1092
|
+
if (signal?.aborted) abortFromCaller();
|
|
1093
|
+
else signal?.addEventListener("abort", abortFromCaller, { once: true });
|
|
1094
|
+
try {
|
|
1095
|
+
if (request.text.trim().length === 0) throw new Error("nothing to translate");
|
|
1096
|
+
if (request.text.length > MAX_TEXT_CHARS) throw new Error("the selection is too long to translate");
|
|
1097
|
+
if (request.prompt.trim().length === 0) throw new Error("the translation prompt is empty");
|
|
1098
|
+
if (request.prompt.length > MAX_PROMPT_CHARS) throw new Error("the translation prompt is too long");
|
|
1099
|
+
if (!LANGUAGES.has(request.target)) throw new Error("unsupported translation target");
|
|
1100
|
+
const llm = services.llm;
|
|
1101
|
+
if (llm === void 0) throw new Error("the model service is unavailable");
|
|
1102
|
+
const route = resolveRoute(agent, request, services);
|
|
1103
|
+
if (route === void 0) throw new Error("no translation model is available");
|
|
1104
|
+
meta.provider = route.provider;
|
|
1105
|
+
meta.model = route.model;
|
|
1106
|
+
controller.signal.throwIfAborted();
|
|
1107
|
+
const call = await prepareCall(llm, route, controller.signal, log);
|
|
1108
|
+
controller.signal.throwIfAborted();
|
|
1109
|
+
const effort = call.config.reasoningEffort;
|
|
1110
|
+
let thinking = typeof effort === "string" && effort !== "off";
|
|
1111
|
+
if (thinking) log?.debug("dsh-select-quote: translation keeps reasoning on for %s/%s", route.provider, route.model);
|
|
1112
|
+
yield {
|
|
1113
|
+
type: "thinking",
|
|
1114
|
+
active: thinking
|
|
1115
|
+
};
|
|
1116
|
+
const messages = [{
|
|
1117
|
+
id: randomUUID(),
|
|
1118
|
+
role: "user",
|
|
1119
|
+
content: [{
|
|
1120
|
+
type: "text",
|
|
1121
|
+
text: request.text
|
|
1122
|
+
}],
|
|
1123
|
+
source: { kind: "dsh-select-quote" }
|
|
1124
|
+
}];
|
|
1125
|
+
const options = {
|
|
1126
|
+
...call.config,
|
|
1127
|
+
messages,
|
|
1128
|
+
system: request.prompt,
|
|
1129
|
+
sessionId: agent.id,
|
|
1130
|
+
purpose: "select-quote-translate",
|
|
1131
|
+
signal: controller.signal
|
|
1132
|
+
};
|
|
1133
|
+
let accumulated = "";
|
|
1134
|
+
let reasoning = "";
|
|
1135
|
+
let failure;
|
|
1136
|
+
for await (const chunk of call.stream(options)) {
|
|
1137
|
+
controller.signal.throwIfAborted();
|
|
1138
|
+
if (chunk.type === "reasoning-delta") {
|
|
1139
|
+
const delta = chunk.text ?? "";
|
|
1140
|
+
if (delta.length === 0) continue;
|
|
1141
|
+
if (!thinking) {
|
|
1142
|
+
thinking = true;
|
|
1143
|
+
yield {
|
|
1144
|
+
type: "thinking",
|
|
1145
|
+
active: true
|
|
1146
|
+
};
|
|
1147
|
+
}
|
|
1148
|
+
reasoning += delta;
|
|
1149
|
+
yield {
|
|
1150
|
+
type: "reasoning",
|
|
1151
|
+
text: reasoning
|
|
1152
|
+
};
|
|
1153
|
+
} else if (chunk.type === "block-end" && chunk.block?.type === "reasoning") {
|
|
1154
|
+
const full = chunk.block.text ?? "";
|
|
1155
|
+
if (full.length === 0 || reasoning.length > 0) continue;
|
|
1156
|
+
if (!thinking) {
|
|
1157
|
+
thinking = true;
|
|
1158
|
+
yield {
|
|
1159
|
+
type: "thinking",
|
|
1160
|
+
active: true
|
|
1161
|
+
};
|
|
1162
|
+
}
|
|
1163
|
+
reasoning = full;
|
|
1164
|
+
yield {
|
|
1165
|
+
type: "reasoning",
|
|
1166
|
+
text: reasoning
|
|
1167
|
+
};
|
|
1168
|
+
} else if (chunk.type === "text-delta") {
|
|
1169
|
+
const delta = chunk.text ?? "";
|
|
1170
|
+
if (delta.length === 0) continue;
|
|
1171
|
+
if (thinking) {
|
|
1172
|
+
thinking = false;
|
|
1173
|
+
yield {
|
|
1174
|
+
type: "thinking",
|
|
1175
|
+
active: false
|
|
1176
|
+
};
|
|
1177
|
+
}
|
|
1178
|
+
accumulated += delta;
|
|
1179
|
+
yield {
|
|
1180
|
+
type: "text",
|
|
1181
|
+
text: accumulated
|
|
1182
|
+
};
|
|
1183
|
+
} else if (chunk.type === "block-end" && chunk.block?.type === "text") {
|
|
1184
|
+
const full = chunk.block.text ?? "";
|
|
1185
|
+
if (full.length === 0 || accumulated.length > 0) continue;
|
|
1186
|
+
if (thinking) {
|
|
1187
|
+
thinking = false;
|
|
1188
|
+
yield {
|
|
1189
|
+
type: "thinking",
|
|
1190
|
+
active: false
|
|
1191
|
+
};
|
|
1192
|
+
}
|
|
1193
|
+
accumulated = full;
|
|
1194
|
+
yield {
|
|
1195
|
+
type: "text",
|
|
1196
|
+
text: accumulated
|
|
1197
|
+
};
|
|
1198
|
+
} else if (chunk.type === "finish") failure = chunk.reason;
|
|
1199
|
+
}
|
|
1200
|
+
controller.signal.throwIfAborted();
|
|
1201
|
+
if (failure?.kind === "error" || failure?.kind === "aborted") {
|
|
1202
|
+
const code = failure.failure?.code;
|
|
1203
|
+
const message = failure.failure?.message;
|
|
1204
|
+
throw new Error(code === void 0 ? message === void 0 ? "translation failed" : trimMessage(message) : `${code}: ${trimMessage(message ?? "translation failed")}`);
|
|
1205
|
+
}
|
|
1206
|
+
const translated = accumulated.trim();
|
|
1207
|
+
if (translated.length === 0) throw new Error(failure?.kind === "max-tokens" ? "the model ran out of output tokens before returning a translation" : "the model returned no translation");
|
|
1208
|
+
if (failure?.kind === "max-tokens") log?.warn("dsh-select-quote: translation truncated at the output limit for %s/%s", route.provider, route.model);
|
|
1209
|
+
else if (failure?.kind !== void 0 && failure.kind !== "stop") log?.warn("dsh-select-quote: translation finished with %s for %s/%s", failure.kind, route.provider, route.model);
|
|
1210
|
+
yield {
|
|
1211
|
+
type: "done",
|
|
1212
|
+
text: translated
|
|
1213
|
+
};
|
|
1214
|
+
} catch (error) {
|
|
1215
|
+
if (timedOut) {
|
|
1216
|
+
const timeout = /* @__PURE__ */ new Error("translation timed out");
|
|
1217
|
+
logFailure(log, meta, timeout, routeOf(meta));
|
|
1218
|
+
throw timeout;
|
|
1219
|
+
}
|
|
1220
|
+
if (signal?.aborted) {
|
|
1221
|
+
log?.debug("dsh-select-quote: translation cancelled by the client");
|
|
1222
|
+
throw error;
|
|
1223
|
+
}
|
|
1224
|
+
logFailure(log, meta, error, routeOf(meta));
|
|
1225
|
+
throw error;
|
|
1226
|
+
} finally {
|
|
1227
|
+
clearTimeout(timer);
|
|
1228
|
+
signal?.removeEventListener("abort", abortFromCaller);
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
};
|
|
1232
|
+
/** Prefer disabled thinking; fall back to the provider default when rejected. */
|
|
1233
|
+
async function prepareCall(llm, route, signal, log) {
|
|
1234
|
+
try {
|
|
1235
|
+
return await llm.prepareCall({
|
|
1236
|
+
provider: route.provider,
|
|
1237
|
+
model: route.model,
|
|
1238
|
+
reasoningEffort: "off"
|
|
1239
|
+
}, signal);
|
|
1240
|
+
} catch (error) {
|
|
1241
|
+
signal.throwIfAborted();
|
|
1242
|
+
log?.debug("dsh-select-quote: thinking cannot be disabled for %s/%s (%s); using the model default", route.provider, route.model, describe(error));
|
|
1243
|
+
return llm.prepareCall(route, signal);
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
/** Explicit config route wins; otherwise follow the conversation's own model. */
|
|
1247
|
+
function resolveRoute(agent, request, services) {
|
|
1248
|
+
if (request.provider !== void 0 && request.model !== void 0) return {
|
|
1249
|
+
provider: request.provider,
|
|
1250
|
+
model: request.model
|
|
1251
|
+
};
|
|
1252
|
+
const live = agent.options;
|
|
1253
|
+
if (live?.provider !== void 0 && live.model !== void 0) return {
|
|
1254
|
+
provider: live.provider,
|
|
1255
|
+
model: live.model
|
|
1256
|
+
};
|
|
1257
|
+
const current = services.get("agentDefaultModel")?.currentSelection();
|
|
1258
|
+
if (current?.provider !== void 0 && current.model !== void 0) return {
|
|
1259
|
+
provider: current.provider,
|
|
1260
|
+
model: current.model
|
|
1261
|
+
};
|
|
1262
|
+
}
|
|
1263
|
+
/** Resolve the callable logger facade (`ctx.logger` is callable in Cordis). */
|
|
1264
|
+
function loggerOf(source) {
|
|
1265
|
+
if (typeof source === "function") try {
|
|
1266
|
+
return source("dsh-select-quote");
|
|
1267
|
+
} catch {
|
|
1268
|
+
return;
|
|
1269
|
+
}
|
|
1270
|
+
return source;
|
|
1271
|
+
}
|
|
1272
|
+
function routeOf(meta) {
|
|
1273
|
+
return `${meta.provider ?? "?"}/${meta.model ?? "?"}`;
|
|
1274
|
+
}
|
|
1275
|
+
function logFailure(log, meta, error, route) {
|
|
1276
|
+
log?.warn("dsh-select-quote: translation failed %o", {
|
|
1277
|
+
target: meta.target,
|
|
1278
|
+
chars: meta.chars,
|
|
1279
|
+
route,
|
|
1280
|
+
error: describe(error)
|
|
1281
|
+
});
|
|
1282
|
+
}
|
|
1283
|
+
function trimMessage(message) {
|
|
1284
|
+
const oneLine = message.replace(/\s+/g, " ").trim();
|
|
1285
|
+
return oneLine.length > 240 ? `${oneLine.slice(0, 239)}…` : oneLine;
|
|
1286
|
+
}
|
|
1287
|
+
function describe(error) {
|
|
1288
|
+
if (error instanceof Error) {
|
|
1289
|
+
const code = error.code;
|
|
1290
|
+
return typeof code === "string" ? `${code}: ${error.message}` : error.message;
|
|
1291
|
+
}
|
|
1292
|
+
return String(error);
|
|
1293
|
+
}
|
|
1294
|
+
Object.defineProperty(SelectQuoteTranslate.prototype, REMOTE_METHOD_DESCRIPTOR, {
|
|
1020
1295
|
configurable: true,
|
|
1021
1296
|
value: REMOTE_METHODS
|
|
1022
1297
|
});
|
|
@@ -1030,13 +1305,30 @@ const Config = Schema.object({
|
|
|
1030
1305
|
]).default("auto").volatile(),
|
|
1031
1306
|
toolbarPlacement: Schema.union(["above", "below"]).default("above").volatile(),
|
|
1032
1307
|
shortcut: Schema.boolean().default(false).volatile(),
|
|
1033
|
-
sideTaskMode: Schema.union(["separate", "reuse"]).default("separate").volatile()
|
|
1308
|
+
sideTaskMode: Schema.union(["separate", "reuse"]).default("separate").volatile(),
|
|
1309
|
+
translateTarget: Schema.union([
|
|
1310
|
+
"auto",
|
|
1311
|
+
"zh",
|
|
1312
|
+
"en",
|
|
1313
|
+
"ja",
|
|
1314
|
+
"es",
|
|
1315
|
+
"fr",
|
|
1316
|
+
"de",
|
|
1317
|
+
"ru",
|
|
1318
|
+
"pt"
|
|
1319
|
+
]).default("auto").volatile(),
|
|
1320
|
+
translateProvider: Schema.string().default("").volatile(),
|
|
1321
|
+
translateModel: Schema.string().default("").volatile(),
|
|
1322
|
+
translatePrompt: Schema.string().default("").volatile()
|
|
1034
1323
|
});
|
|
1035
1324
|
const name = PACKAGE_NAME;
|
|
1036
1325
|
function apply(ctx, _config) {
|
|
1037
1326
|
ctx.inject(["subagents"], (scope) => {
|
|
1038
1327
|
new SelectQuoteSideTask(scope);
|
|
1039
1328
|
});
|
|
1329
|
+
ctx.inject(["llm"], (scope) => {
|
|
1330
|
+
new SelectQuoteTranslate(scope);
|
|
1331
|
+
});
|
|
1040
1332
|
}
|
|
1041
1333
|
//#endregion
|
|
1042
1334
|
export { Config, apply, name };
|
package/lib/typert.js
CHANGED
|
@@ -13671,29 +13671,32 @@ function createRemoteInfo(spec, zod) {
|
|
|
13671
13671
|
};
|
|
13672
13672
|
}
|
|
13673
13673
|
//#endregion
|
|
13674
|
-
//#region src/shared/
|
|
13674
|
+
//#region src/shared/plugin-remote.ts
|
|
13675
13675
|
/**
|
|
13676
13676
|
* Wire contract shared by the two halves.
|
|
13677
13677
|
*
|
|
13678
|
-
* The Host owns the
|
|
13679
|
-
* mounts the same descriptor group
|
|
13680
|
-
* schemas are written here so the
|
|
13678
|
+
* The Host owns the implementations (`ctx.selectQuoteSideTask`,
|
|
13679
|
+
* `ctx.selectQuoteTranslate`); the browser mounts the same descriptor group
|
|
13680
|
+
* through `ctx.remote.$mount(...)`. Both schemas are written here so the
|
|
13681
|
+
* argument shapes cannot drift apart.
|
|
13681
13682
|
*/
|
|
13682
13683
|
const SIDE_TASK_SERVICE = "selectQuoteSideTask";
|
|
13683
13684
|
const SIDE_TASK_METHOD = `${SIDE_TASK_SERVICE}/create`;
|
|
13685
|
+
const TRANSLATE_SERVICE = "selectQuoteTranslate";
|
|
13686
|
+
const TRANSLATE_METHOD = `${TRANSLATE_SERVICE}/translate`;
|
|
13684
13687
|
const modelShape = () => ({
|
|
13685
13688
|
provider: string$1(),
|
|
13686
13689
|
model: string$1(),
|
|
13687
13690
|
reasoningEffort: string$1().optional()
|
|
13688
13691
|
});
|
|
13689
|
-
const
|
|
13692
|
+
const sideRequestSchema = () => object({
|
|
13690
13693
|
prompt: string$1(),
|
|
13691
13694
|
label: string$1().optional(),
|
|
13692
13695
|
model: object(modelShape()).optional(),
|
|
13693
13696
|
/** Continue the parent's one side-task child instead of forking a new one. */
|
|
13694
13697
|
reuse: boolean$1().optional()
|
|
13695
13698
|
});
|
|
13696
|
-
const
|
|
13699
|
+
const strictSideRequestSchema = () => strictObject({
|
|
13697
13700
|
prompt: string$1(),
|
|
13698
13701
|
label: string$1().optional(),
|
|
13699
13702
|
model: strictObject(modelShape()).optional(),
|
|
@@ -13709,96 +13712,186 @@ const modelJsonSchema = (additionalProperties) => ({
|
|
|
13709
13712
|
required: ["provider", "model"],
|
|
13710
13713
|
additionalProperties
|
|
13711
13714
|
});
|
|
13712
|
-
const
|
|
13713
|
-
|
|
13715
|
+
const translateRouteShape = () => ({
|
|
13716
|
+
provider: string$1().optional(),
|
|
13717
|
+
model: string$1().optional()
|
|
13718
|
+
});
|
|
13719
|
+
const translateRequestSchema = () => object({
|
|
13720
|
+
text: string$1(),
|
|
13721
|
+
target: string$1(),
|
|
13722
|
+
/** Resolved instructions: built-in or the user's custom prompt. */
|
|
13723
|
+
prompt: string$1(),
|
|
13724
|
+
...translateRouteShape()
|
|
13725
|
+
});
|
|
13726
|
+
const strictTranslateRequestSchema = () => strictObject({
|
|
13727
|
+
text: string$1(),
|
|
13728
|
+
target: string$1(),
|
|
13729
|
+
prompt: string$1(),
|
|
13730
|
+
...translateRouteShape()
|
|
13731
|
+
});
|
|
13732
|
+
const translateJsonSchema = (additionalProperties) => ({
|
|
13733
|
+
type: "object",
|
|
13734
|
+
properties: {
|
|
13735
|
+
text: { type: "string" },
|
|
13736
|
+
target: { type: "string" },
|
|
13737
|
+
prompt: { type: "string" },
|
|
13738
|
+
provider: { type: "string" },
|
|
13739
|
+
model: { type: "string" }
|
|
13740
|
+
},
|
|
13741
|
+
required: [
|
|
13742
|
+
"text",
|
|
13743
|
+
"target",
|
|
13744
|
+
"prompt"
|
|
13745
|
+
],
|
|
13746
|
+
additionalProperties
|
|
13747
|
+
});
|
|
13748
|
+
/** The owning live agent, resolved by the Gateway from the session id. */
|
|
13749
|
+
const agentParameter = () => ({
|
|
13750
|
+
name: "agent",
|
|
13751
|
+
wire: "agentId",
|
|
13752
|
+
description: "owning live agent.",
|
|
13753
|
+
source: "lookup",
|
|
13754
|
+
lookup: "agent",
|
|
13755
|
+
codec: {
|
|
13756
|
+
mode: "strict",
|
|
13757
|
+
typeSymbol: "@deepseek-ai/dsh-session/types#SessionId",
|
|
13758
|
+
create: () => string$1(),
|
|
13759
|
+
jsonSchema: { type: "string" }
|
|
13760
|
+
},
|
|
13761
|
+
strictCodec: {
|
|
13762
|
+
mode: "strict",
|
|
13763
|
+
typeSymbol: "@deepseek-ai/dsh-session/types#SessionId",
|
|
13764
|
+
create: () => string$1(),
|
|
13765
|
+
jsonSchema: { type: "string" }
|
|
13766
|
+
}
|
|
13767
|
+
});
|
|
13768
|
+
function createPluginRemote() {
|
|
13714
13769
|
return createRemoteInfo({
|
|
13715
13770
|
package: PACKAGE_NAME,
|
|
13716
|
-
methods: {
|
|
13717
|
-
|
|
13718
|
-
|
|
13719
|
-
|
|
13720
|
-
|
|
13721
|
-
|
|
13722
|
-
|
|
13723
|
-
|
|
13724
|
-
parameters: [{
|
|
13725
|
-
name: "agent",
|
|
13726
|
-
wire: "agentId",
|
|
13727
|
-
description: "owning live agent.",
|
|
13728
|
-
source: "lookup",
|
|
13729
|
-
lookup: "agent",
|
|
13730
|
-
codec: {
|
|
13731
|
-
mode: "strict",
|
|
13732
|
-
typeSymbol: "@deepseek-ai/dsh-session/types#SessionId",
|
|
13733
|
-
create: () => string$1(),
|
|
13734
|
-
jsonSchema: { type: "string" }
|
|
13771
|
+
methods: {
|
|
13772
|
+
[SIDE_TASK_METHOD]: {
|
|
13773
|
+
service: SIDE_TASK_SERVICE,
|
|
13774
|
+
description: "Start a fork-backed side task for one live agent.",
|
|
13775
|
+
invocation: { kind: "direct" },
|
|
13776
|
+
scope: {
|
|
13777
|
+
context: "agent",
|
|
13778
|
+
wire: "agentId"
|
|
13735
13779
|
},
|
|
13736
|
-
|
|
13737
|
-
|
|
13738
|
-
|
|
13739
|
-
|
|
13740
|
-
|
|
13741
|
-
|
|
13742
|
-
|
|
13743
|
-
|
|
13744
|
-
|
|
13745
|
-
|
|
13746
|
-
|
|
13780
|
+
parameters: [agentParameter(), {
|
|
13781
|
+
name: "request",
|
|
13782
|
+
description: "initial prompt, display label, optional child model, and whether to reuse the side child.",
|
|
13783
|
+
source: "json",
|
|
13784
|
+
codec: {
|
|
13785
|
+
mode: "strict",
|
|
13786
|
+
typeSymbol: "dsh-select-quote#SideTaskRequest",
|
|
13787
|
+
create: sideRequestSchema,
|
|
13788
|
+
jsonSchema: {
|
|
13789
|
+
type: "object",
|
|
13790
|
+
properties: {
|
|
13791
|
+
prompt: { type: "string" },
|
|
13792
|
+
label: { type: "string" },
|
|
13793
|
+
model: modelJsonSchema(true),
|
|
13794
|
+
reuse: { type: "boolean" }
|
|
13795
|
+
},
|
|
13796
|
+
required: ["prompt"],
|
|
13797
|
+
additionalProperties: true
|
|
13798
|
+
}
|
|
13799
|
+
},
|
|
13800
|
+
strictCodec: {
|
|
13801
|
+
mode: "strict",
|
|
13802
|
+
typeSymbol: "dsh-select-quote#SideTaskRequest",
|
|
13803
|
+
create: strictSideRequestSchema,
|
|
13804
|
+
jsonSchema: {
|
|
13805
|
+
type: "object",
|
|
13806
|
+
properties: {
|
|
13807
|
+
prompt: { type: "string" },
|
|
13808
|
+
label: { type: "string" },
|
|
13809
|
+
model: modelJsonSchema(false),
|
|
13810
|
+
reuse: { type: "boolean" }
|
|
13811
|
+
},
|
|
13812
|
+
required: ["prompt"],
|
|
13813
|
+
additionalProperties: false
|
|
13814
|
+
}
|
|
13815
|
+
}
|
|
13816
|
+
}],
|
|
13817
|
+
result: {
|
|
13747
13818
|
mode: "strict",
|
|
13748
|
-
typeSymbol: "dsh-select-quote#
|
|
13749
|
-
create:
|
|
13819
|
+
typeSymbol: "dsh-select-quote#SideTaskCreateResult",
|
|
13820
|
+
create: () => object({ childId: string$1() }),
|
|
13821
|
+
description: "the created child session id.",
|
|
13750
13822
|
jsonSchema: {
|
|
13751
13823
|
type: "object",
|
|
13752
|
-
properties: {
|
|
13753
|
-
|
|
13754
|
-
|
|
13755
|
-
model: modelJsonSchema(true),
|
|
13756
|
-
reuse: { type: "boolean" }
|
|
13757
|
-
},
|
|
13758
|
-
required: ["prompt"],
|
|
13759
|
-
additionalProperties: true
|
|
13824
|
+
properties: { childId: { type: "string" } },
|
|
13825
|
+
required: ["childId"],
|
|
13826
|
+
additionalProperties: false
|
|
13760
13827
|
}
|
|
13761
13828
|
},
|
|
13762
|
-
|
|
13829
|
+
sourceLocation: {
|
|
13830
|
+
file: "src/side-task-service.ts",
|
|
13831
|
+
line: 1,
|
|
13832
|
+
column: 1
|
|
13833
|
+
}
|
|
13834
|
+
},
|
|
13835
|
+
[TRANSLATE_METHOD]: {
|
|
13836
|
+
service: TRANSLATE_SERVICE,
|
|
13837
|
+
description: "Stream one translation of a selected passage with a direct model call.",
|
|
13838
|
+
invocation: { kind: "direct" },
|
|
13839
|
+
/** Live stream: thinking state, growing text snapshots, then the final text. */
|
|
13840
|
+
mode: "stream",
|
|
13841
|
+
cancellation: { parameter: "signal" },
|
|
13842
|
+
scope: {
|
|
13843
|
+
context: "agent",
|
|
13844
|
+
wire: "agentId"
|
|
13845
|
+
},
|
|
13846
|
+
parameters: [agentParameter(), {
|
|
13847
|
+
name: "request",
|
|
13848
|
+
description: "selected text, target language, resolved instructions, and optional model route.",
|
|
13849
|
+
source: "json",
|
|
13850
|
+
codec: {
|
|
13851
|
+
mode: "strict",
|
|
13852
|
+
typeSymbol: "dsh-select-quote#TranslateRequest",
|
|
13853
|
+
create: translateRequestSchema,
|
|
13854
|
+
jsonSchema: translateJsonSchema(true)
|
|
13855
|
+
},
|
|
13856
|
+
strictCodec: {
|
|
13857
|
+
mode: "strict",
|
|
13858
|
+
typeSymbol: "dsh-select-quote#TranslateRequest",
|
|
13859
|
+
create: strictTranslateRequestSchema,
|
|
13860
|
+
jsonSchema: translateJsonSchema(false)
|
|
13861
|
+
}
|
|
13862
|
+
}],
|
|
13863
|
+
result: {
|
|
13763
13864
|
mode: "strict",
|
|
13764
|
-
typeSymbol: "dsh-select-quote#
|
|
13765
|
-
create:
|
|
13865
|
+
typeSymbol: "dsh-select-quote#TranslateStreamEvent",
|
|
13866
|
+
create: () => object({
|
|
13867
|
+
type: string$1(),
|
|
13868
|
+
text: string$1().optional(),
|
|
13869
|
+
active: boolean$1().optional()
|
|
13870
|
+
}),
|
|
13871
|
+
description: "streamed translation events.",
|
|
13766
13872
|
jsonSchema: {
|
|
13767
13873
|
type: "object",
|
|
13768
13874
|
properties: {
|
|
13769
|
-
|
|
13770
|
-
|
|
13771
|
-
|
|
13772
|
-
reuse: { type: "boolean" }
|
|
13875
|
+
type: { type: "string" },
|
|
13876
|
+
text: { type: "string" },
|
|
13877
|
+
active: { type: "boolean" }
|
|
13773
13878
|
},
|
|
13774
|
-
required: ["
|
|
13879
|
+
required: ["type"],
|
|
13775
13880
|
additionalProperties: false
|
|
13776
13881
|
}
|
|
13882
|
+
},
|
|
13883
|
+
sourceLocation: {
|
|
13884
|
+
file: "src/translate-service.ts",
|
|
13885
|
+
line: 1,
|
|
13886
|
+
column: 1
|
|
13777
13887
|
}
|
|
13778
|
-
}],
|
|
13779
|
-
result: {
|
|
13780
|
-
mode: "strict",
|
|
13781
|
-
typeSymbol: "dsh-select-quote#SideTaskCreateResult",
|
|
13782
|
-
create: resultSchema,
|
|
13783
|
-
description: "the created child session id.",
|
|
13784
|
-
jsonSchema: {
|
|
13785
|
-
type: "object",
|
|
13786
|
-
properties: { childId: { type: "string" } },
|
|
13787
|
-
required: ["childId"],
|
|
13788
|
-
additionalProperties: false
|
|
13789
|
-
}
|
|
13790
|
-
},
|
|
13791
|
-
sourceLocation: {
|
|
13792
|
-
file: "src/side-task-service.ts",
|
|
13793
|
-
line: 1,
|
|
13794
|
-
column: 1
|
|
13795
13888
|
}
|
|
13796
|
-
}
|
|
13889
|
+
}
|
|
13797
13890
|
}, external_exports);
|
|
13798
13891
|
}
|
|
13799
13892
|
//#endregion
|
|
13800
13893
|
//#region src/typert.ts
|
|
13801
|
-
const $remote =
|
|
13894
|
+
const $remote = createPluginRemote();
|
|
13802
13895
|
/**
|
|
13803
13896
|
* Host-face Typert contribution.
|
|
13804
13897
|
*
|
package/locale/de.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "Auswahlanmerkungen",
|
|
4
|
-
"description": "Zitiere ausgewählten Text
|
|
4
|
+
"description": "Zitiere ausgewählten Text in deiner nächsten Nachricht, frage in einer Seitenaufgabe nach oder übersetze ihn direkt: Die Auswahl bleibt im Original markiert, und das Modell antwortet auf jede Stelle."
|
|
5
5
|
}
|
|
6
6
|
}
|
package/locale/en.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "Selection Annotations",
|
|
4
|
-
"description": "Quote text from the conversation into your next message: the selection stays marked in the source and the model points back at it."
|
|
4
|
+
"description": "Quote text from the conversation into your next message, ask in a sidebar subagent, or translate the selection in place: the selection stays marked in the source and the model points back at it."
|
|
5
5
|
}
|
|
6
6
|
}
|
package/locale/es.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "Anotaciones de selección",
|
|
4
|
-
"description": "Cita texto
|
|
4
|
+
"description": "Cita el texto seleccionado en el próximo mensaje, pregunta en una tarea lateral o tradúcelo en el sitio: la selección queda marcada en el original y el modelo responde a cada fragmento."
|
|
5
5
|
}
|
|
6
6
|
}
|
package/locale/fr.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "Annotations de sélection",
|
|
4
|
-
"description": "Citez le texte sélectionné
|
|
4
|
+
"description": "Citez le texte sélectionné dans votre prochain message, posez une question dans une tâche latérale ou traduisez-le sur place : la sélection reste marquée dans l’original et le modèle répond à chaque passage."
|
|
5
5
|
}
|
|
6
6
|
}
|