dsh-opendesign-corouter 0.1.15 → 0.1.16
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 +7 -3
- package/lib/client-config-writes.d.ts +36 -0
- package/lib/client-context-quick.d.ts +35 -0
- package/lib/client.d.ts +29 -6
- package/lib/client.js +1042 -446
- package/lib/config.d.ts +3 -0
- package/lib/context-budget.d.ts +23 -0
- package/lib/device-auth.d.ts +1 -1
- package/lib/generated/typert.host.js +9 -1
- package/lib/generated/typert.remote-client.js +9 -1
- package/lib/index.js +37 -10
- package/lib/index.js.map +3 -3
- package/lib/model-settings.d.ts +7 -4
- package/lib/remote.d.ts +2 -0
- package/package.json +3 -1
package/lib/config.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export declare const Config: Schema<Schemastery.ObjectS<NoInfer<{
|
|
|
13
13
|
modelSettings: Schema<NoInfer<import("@deepseek-ai/cosmokit").Dict<unknown, string>>, NoInfer<ModelSettingsMap>, "volatile-defined">;
|
|
14
14
|
useDesktopCredential: Schema<boolean, boolean, "volatile-defined">;
|
|
15
15
|
emptyTurnGuard: Schema<boolean, boolean, "volatile-defined">;
|
|
16
|
+
turnCompletionReview: Schema<boolean, boolean, "volatile-defined">;
|
|
16
17
|
turnReviewMaxContinuations: Schema<number, number, "volatile-defined">;
|
|
17
18
|
turnReviewNoProgressLimit: Schema<number, number, "volatile-defined">;
|
|
18
19
|
quotaRefreshSeconds: Schema<number, number, "volatile-defined">;
|
|
@@ -26,6 +27,7 @@ export declare const Config: Schema<Schemastery.ObjectS<NoInfer<{
|
|
|
26
27
|
modelSettings: Schema<NoInfer<import("@deepseek-ai/cosmokit").Dict<unknown, string>>, NoInfer<ModelSettingsMap>, "volatile-defined">;
|
|
27
28
|
useDesktopCredential: Schema<boolean, boolean, "volatile-defined">;
|
|
28
29
|
emptyTurnGuard: Schema<boolean, boolean, "volatile-defined">;
|
|
30
|
+
turnCompletionReview: Schema<boolean, boolean, "volatile-defined">;
|
|
29
31
|
turnReviewMaxContinuations: Schema<number, number, "volatile-defined">;
|
|
30
32
|
turnReviewNoProgressLimit: Schema<number, number, "volatile-defined">;
|
|
31
33
|
quotaRefreshSeconds: Schema<number, number, "volatile-defined">;
|
|
@@ -45,6 +47,7 @@ export interface RuntimeConfig {
|
|
|
45
47
|
modelSettings?: ModelSettingsMap;
|
|
46
48
|
quotaRefreshSeconds?: number;
|
|
47
49
|
maxRequestImageBytes?: number;
|
|
50
|
+
turnCompletionReview?: boolean;
|
|
48
51
|
turnReviewMaxContinuations?: number;
|
|
49
52
|
turnReviewNoProgressLimit?: number;
|
|
50
53
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Client working windows, including both input and reserved output tokens. */
|
|
2
|
+
export declare const CONTEXT_WINDOW_PRESETS: readonly [{
|
|
3
|
+
readonly id: "default";
|
|
4
|
+
readonly label: "默认";
|
|
5
|
+
readonly tokens: 272000;
|
|
6
|
+
}, {
|
|
7
|
+
readonly id: "extended";
|
|
8
|
+
readonly label: "扩展";
|
|
9
|
+
readonly tokens: 500000;
|
|
10
|
+
}, {
|
|
11
|
+
readonly id: "maximum";
|
|
12
|
+
readonly label: "最大";
|
|
13
|
+
readonly tokens: 872000;
|
|
14
|
+
}];
|
|
15
|
+
export type ContextWindowPresetId = typeof CONTEXT_WINDOW_PRESETS[number]['id'];
|
|
16
|
+
/** Saved numbers are always legacy custom windows; only an explicit tier selects a preset. */
|
|
17
|
+
export declare function contextWindowPreset(legacyOverride: number | undefined, tier?: ContextWindowPresetId): ContextWindowPresetId | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Presets never increase a known catalog/gateway reference. Historical custom
|
|
20
|
+
* numbers retain their prior meaning until the user explicitly chooses a preset.
|
|
21
|
+
* An unknown reference does not imply model capacity: the preset is a local budget.
|
|
22
|
+
*/
|
|
23
|
+
export declare function effectiveContextWindow(reference: number | undefined, override?: number, tier?: ContextWindowPresetId): number;
|
package/lib/device-auth.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export interface DeviceTokens {
|
|
|
3
3
|
runtimeKey: string;
|
|
4
4
|
}
|
|
5
5
|
export declare const DEVICE_AUTH_ENDPOINT = "https://amr-api.open-design.ai/api/v1/cli/device-authorizations";
|
|
6
|
-
export declare const DEVICE_AUTH_PLUGIN_VERSION = "0.1.
|
|
6
|
+
export declare const DEVICE_AUTH_PLUGIN_VERSION = "0.1.16";
|
|
7
7
|
export declare const DEVICE_REQUEST_TIMEOUT_MS = 20000;
|
|
8
8
|
/** One bounded launch step of the temporary activation window. */
|
|
9
9
|
export declare const DEVICE_OPEN_TIMEOUT_MS = 30000;
|
|
@@ -43,7 +43,7 @@ function parseModelSettingsMap(value) {
|
|
|
43
43
|
if (value === null || typeof value !== "object" || Array.isArray(value)) throw new Error("\u6A21\u578B\u8BBE\u7F6E\u5FC5\u987B\u662F\u5BF9\u8C61");
|
|
44
44
|
const keys = Object.keys(value);
|
|
45
45
|
if (keys.length > 512) throw new Error("\u6A21\u578B\u8BBE\u7F6E\u6700\u591A\u5141\u8BB8 512 \u4E2A\u6A21\u578B");
|
|
46
|
-
const fields = /* @__PURE__ */ new Set(["enabled", "imageInput", "temperature", "topP", "maxTokens", "contextWindow", "reasoningEffort"]);
|
|
46
|
+
const fields = /* @__PURE__ */ new Set(["enabled", "imageInput", "temperature", "topP", "maxTokens", "contextWindow", "contextTier", "reasoningEffort"]);
|
|
47
47
|
const efforts = ["none", "minimal", "low", "medium", "high", "xhigh", "ultra", "max"];
|
|
48
48
|
const out = {};
|
|
49
49
|
for (const id of keys) {
|
|
@@ -76,6 +76,13 @@ function parseModelSettingsMap(value) {
|
|
|
76
76
|
if (typeof item !== "number" || !Number.isSafeInteger(item) || item < 1 || item > max) throw new Error(`\u6A21\u578B\u8BBE\u7F6E\u7684 ${field} \u5FC5\u987B\u662F 1 \u5230 ${max} \u4E4B\u95F4\u7684\u6574\u6570`);
|
|
77
77
|
parsed[field] = item;
|
|
78
78
|
}
|
|
79
|
+
if (settings.contextTier !== void 0) {
|
|
80
|
+
if (settings.contextTier !== "default" && settings.contextTier !== "extended" && settings.contextTier !== "maximum") throw new Error("\u6A21\u578B\u8BBE\u7F6E\u7684 contextTier \u4E0D\u5728\u5141\u8BB8\u7684\u53D6\u503C\u5185");
|
|
81
|
+
if (parsed.contextWindow !== void 0) throw new Error("\u4E0A\u4E0B\u6587\u6863\u4F4D\u4E0E\u65E7\u81EA\u5B9A\u4E49\u7A97\u53E3\u4E0D\u80FD\u540C\u65F6\u8BBE\u7F6E");
|
|
82
|
+
parsed.contextTier = settings.contextTier;
|
|
83
|
+
const window = parsed.contextTier === "default" ? 272e3 : parsed.contextTier === "extended" ? 5e5 : 872e3;
|
|
84
|
+
if (parsed.maxTokens !== void 0 && parsed.maxTokens >= window) throw new Error("\u6A21\u578B\u8BBE\u7F6E\u7684 maxTokens \u5FC5\u987B\u5C0F\u4E8E\u6863\u4F4D\u603B\u7A97\u53E3");
|
|
85
|
+
}
|
|
79
86
|
if (settings.reasoningEffort !== void 0) {
|
|
80
87
|
if (typeof settings.reasoningEffort !== "string" || !efforts.includes(settings.reasoningEffort)) throw new Error("\u6A21\u578B\u8BBE\u7F6E\u7684 reasoningEffort \u4E0D\u5728\u5141\u8BB8\u7684\u53D6\u503C\u5185");
|
|
81
88
|
parsed.reasoningEffort = settings.reasoningEffort;
|
|
@@ -276,6 +283,7 @@ function parseStatusConfig(value) {
|
|
|
276
283
|
if (!ENV_REF.test(apiKeyEnv)) throw new Error("\u51ED\u636E\u5F15\u7528\u540D\u5FC5\u987B\u662F\u5408\u6CD5\u6807\u8BC6\u7B26");
|
|
277
284
|
return {
|
|
278
285
|
emptyTurnGuard: flag(value.emptyTurnGuard, "\u7A7A\u8F6E\u4FDD\u62A4\u5F00\u5173"),
|
|
286
|
+
...value.turnCompletionReview === void 0 ? {} : { turnCompletionReview: flag(value.turnCompletionReview, "\u7ED3\u675F\u56DE\u5408\u6838\u9A8C\u5F00\u5173") },
|
|
279
287
|
useDesktopCredential: flag(value.useDesktopCredential, "\u684C\u9762\u767B\u5F55\u6001\u5F00\u5173"),
|
|
280
288
|
baseURL: text(value.baseURL, "\u63A8\u7406\u5730\u5740", MAX_BASE_URL),
|
|
281
289
|
apiKeyEnv,
|
|
@@ -43,7 +43,7 @@ function parseModelSettingsMap(value) {
|
|
|
43
43
|
if (value === null || typeof value !== "object" || Array.isArray(value)) throw new Error("\u6A21\u578B\u8BBE\u7F6E\u5FC5\u987B\u662F\u5BF9\u8C61");
|
|
44
44
|
const keys = Object.keys(value);
|
|
45
45
|
if (keys.length > 512) throw new Error("\u6A21\u578B\u8BBE\u7F6E\u6700\u591A\u5141\u8BB8 512 \u4E2A\u6A21\u578B");
|
|
46
|
-
const fields = /* @__PURE__ */ new Set(["enabled", "imageInput", "temperature", "topP", "maxTokens", "contextWindow", "reasoningEffort"]);
|
|
46
|
+
const fields = /* @__PURE__ */ new Set(["enabled", "imageInput", "temperature", "topP", "maxTokens", "contextWindow", "contextTier", "reasoningEffort"]);
|
|
47
47
|
const efforts = ["none", "minimal", "low", "medium", "high", "xhigh", "ultra", "max"];
|
|
48
48
|
const out = {};
|
|
49
49
|
for (const id of keys) {
|
|
@@ -76,6 +76,13 @@ function parseModelSettingsMap(value) {
|
|
|
76
76
|
if (typeof item !== "number" || !Number.isSafeInteger(item) || item < 1 || item > max) throw new Error(`\u6A21\u578B\u8BBE\u7F6E\u7684 ${field} \u5FC5\u987B\u662F 1 \u5230 ${max} \u4E4B\u95F4\u7684\u6574\u6570`);
|
|
77
77
|
parsed[field] = item;
|
|
78
78
|
}
|
|
79
|
+
if (settings.contextTier !== void 0) {
|
|
80
|
+
if (settings.contextTier !== "default" && settings.contextTier !== "extended" && settings.contextTier !== "maximum") throw new Error("\u6A21\u578B\u8BBE\u7F6E\u7684 contextTier \u4E0D\u5728\u5141\u8BB8\u7684\u53D6\u503C\u5185");
|
|
81
|
+
if (parsed.contextWindow !== void 0) throw new Error("\u4E0A\u4E0B\u6587\u6863\u4F4D\u4E0E\u65E7\u81EA\u5B9A\u4E49\u7A97\u53E3\u4E0D\u80FD\u540C\u65F6\u8BBE\u7F6E");
|
|
82
|
+
parsed.contextTier = settings.contextTier;
|
|
83
|
+
const window = parsed.contextTier === "default" ? 272e3 : parsed.contextTier === "extended" ? 5e5 : 872e3;
|
|
84
|
+
if (parsed.maxTokens !== void 0 && parsed.maxTokens >= window) throw new Error("\u6A21\u578B\u8BBE\u7F6E\u7684 maxTokens \u5FC5\u987B\u5C0F\u4E8E\u6863\u4F4D\u603B\u7A97\u53E3");
|
|
85
|
+
}
|
|
79
86
|
if (settings.reasoningEffort !== void 0) {
|
|
80
87
|
if (typeof settings.reasoningEffort !== "string" || !efforts.includes(settings.reasoningEffort)) throw new Error("\u6A21\u578B\u8BBE\u7F6E\u7684 reasoningEffort \u4E0D\u5728\u5141\u8BB8\u7684\u53D6\u503C\u5185");
|
|
81
88
|
parsed.reasoningEffort = settings.reasoningEffort;
|
|
@@ -276,6 +283,7 @@ function parseStatusConfig(value) {
|
|
|
276
283
|
if (!ENV_REF.test(apiKeyEnv)) throw new Error("\u51ED\u636E\u5F15\u7528\u540D\u5FC5\u987B\u662F\u5408\u6CD5\u6807\u8BC6\u7B26");
|
|
277
284
|
return {
|
|
278
285
|
emptyTurnGuard: flag(value.emptyTurnGuard, "\u7A7A\u8F6E\u4FDD\u62A4\u5F00\u5173"),
|
|
286
|
+
...value.turnCompletionReview === void 0 ? {} : { turnCompletionReview: flag(value.turnCompletionReview, "\u7ED3\u675F\u56DE\u5408\u6838\u9A8C\u5F00\u5173") },
|
|
279
287
|
useDesktopCredential: flag(value.useDesktopCredential, "\u684C\u9762\u767B\u5F55\u6001\u5F00\u5173"),
|
|
280
288
|
baseURL: text(value.baseURL, "\u63A8\u7406\u5730\u5740", MAX_BASE_URL),
|
|
281
289
|
apiKeyEnv,
|
package/lib/index.js
CHANGED
|
@@ -249,13 +249,25 @@ function inferenceEndpoint(baseURL, protocol) {
|
|
|
249
249
|
return baseURL.trim() === "" ? suffix : `${openAiBaseURL(baseURL.trim())}${suffix}`;
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
+
// src/context-budget.ts
|
|
253
|
+
var CONTEXT_WINDOW_PRESETS = [
|
|
254
|
+
{ id: "default", label: "\u9ED8\u8BA4", tokens: 272e3 },
|
|
255
|
+
{ id: "extended", label: "\u6269\u5C55", tokens: 5e5 },
|
|
256
|
+
{ id: "maximum", label: "\u6700\u5927", tokens: 872e3 }
|
|
257
|
+
];
|
|
258
|
+
function effectiveContextWindow(reference, override, tier) {
|
|
259
|
+
if (tier === void 0 && override !== void 0) return override;
|
|
260
|
+
const requested = (CONTEXT_WINDOW_PRESETS.find((preset) => preset.id === (tier ?? "default")) ?? CONTEXT_WINDOW_PRESETS[0]).tokens;
|
|
261
|
+
return reference === void 0 ? requested : Math.min(requested, reference);
|
|
262
|
+
}
|
|
263
|
+
|
|
252
264
|
// src/model-settings.ts
|
|
253
265
|
var RESERVED_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
254
266
|
function parseModelSettingsMap(value) {
|
|
255
267
|
if (value === null || typeof value !== "object" || Array.isArray(value)) throw new Error("\u6A21\u578B\u8BBE\u7F6E\u5FC5\u987B\u662F\u5BF9\u8C61");
|
|
256
268
|
const keys = Object.keys(value);
|
|
257
269
|
if (keys.length > 512) throw new Error("\u6A21\u578B\u8BBE\u7F6E\u6700\u591A\u5141\u8BB8 512 \u4E2A\u6A21\u578B");
|
|
258
|
-
const fields = /* @__PURE__ */ new Set(["enabled", "imageInput", "temperature", "topP", "maxTokens", "contextWindow", "reasoningEffort"]);
|
|
270
|
+
const fields = /* @__PURE__ */ new Set(["enabled", "imageInput", "temperature", "topP", "maxTokens", "contextWindow", "contextTier", "reasoningEffort"]);
|
|
259
271
|
const efforts = ["none", "minimal", "low", "medium", "high", "xhigh", "ultra", "max"];
|
|
260
272
|
const out = {};
|
|
261
273
|
for (const id of keys) {
|
|
@@ -288,6 +300,13 @@ function parseModelSettingsMap(value) {
|
|
|
288
300
|
if (typeof item !== "number" || !Number.isSafeInteger(item) || item < 1 || item > max) throw new Error(`\u6A21\u578B\u8BBE\u7F6E\u7684 ${field} \u5FC5\u987B\u662F 1 \u5230 ${max} \u4E4B\u95F4\u7684\u6574\u6570`);
|
|
289
301
|
parsed[field] = item;
|
|
290
302
|
}
|
|
303
|
+
if (settings.contextTier !== void 0) {
|
|
304
|
+
if (settings.contextTier !== "default" && settings.contextTier !== "extended" && settings.contextTier !== "maximum") throw new Error("\u6A21\u578B\u8BBE\u7F6E\u7684 contextTier \u4E0D\u5728\u5141\u8BB8\u7684\u53D6\u503C\u5185");
|
|
305
|
+
if (parsed.contextWindow !== void 0) throw new Error("\u4E0A\u4E0B\u6587\u6863\u4F4D\u4E0E\u65E7\u81EA\u5B9A\u4E49\u7A97\u53E3\u4E0D\u80FD\u540C\u65F6\u8BBE\u7F6E");
|
|
306
|
+
parsed.contextTier = settings.contextTier;
|
|
307
|
+
const window = parsed.contextTier === "default" ? 272e3 : parsed.contextTier === "extended" ? 5e5 : 872e3;
|
|
308
|
+
if (parsed.maxTokens !== void 0 && parsed.maxTokens >= window) throw new Error("\u6A21\u578B\u8BBE\u7F6E\u7684 maxTokens \u5FC5\u987B\u5C0F\u4E8E\u6863\u4F4D\u603B\u7A97\u53E3");
|
|
309
|
+
}
|
|
291
310
|
if (settings.reasoningEffort !== void 0) {
|
|
292
311
|
if (typeof settings.reasoningEffort !== "string" || !efforts.includes(settings.reasoningEffort)) throw new Error("\u6A21\u578B\u8BBE\u7F6E\u7684 reasoningEffort \u4E0D\u5728\u5141\u8BB8\u7684\u53D6\u503C\u5185");
|
|
293
312
|
parsed.reasoningEffort = settings.reasoningEffort;
|
|
@@ -298,14 +317,14 @@ function parseModelSettingsMap(value) {
|
|
|
298
317
|
return out;
|
|
299
318
|
}
|
|
300
319
|
function applyModelSettings(row, settings) {
|
|
301
|
-
const { contextWindow, maxTokens, imageInput } = settings ?? {};
|
|
302
|
-
if (contextWindow === void 0 && maxTokens === void 0 && imageInput === void 0) return { ...row };
|
|
320
|
+
const { contextWindow, contextTier, maxTokens, imageInput } = settings ?? {};
|
|
303
321
|
if (contextWindow !== void 0) parseModelSettingsMap({ model: { contextWindow } });
|
|
322
|
+
if (contextTier !== void 0) parseModelSettingsMap({ model: { contextTier, ...contextWindow === void 0 ? {} : { contextWindow } } });
|
|
304
323
|
if (maxTokens !== void 0) parseModelSettingsMap({ model: { maxTokens } });
|
|
305
324
|
if (imageInput !== void 0) parseModelSettingsMap({ model: { imageInput } });
|
|
306
325
|
return {
|
|
307
326
|
...row,
|
|
308
|
-
|
|
327
|
+
contextWindow: effectiveContextWindow(row.contextWindow, contextWindow, contextTier),
|
|
309
328
|
...maxTokens === void 0 ? {} : { maxOutputTokens: maxTokens },
|
|
310
329
|
...imageInput === void 0 ? {} : { inputModalities: imageInput ? ["text", "image"] : ["text"] }
|
|
311
330
|
};
|
|
@@ -340,7 +359,8 @@ var Config = Schema.object({
|
|
|
340
359
|
apiProtocol: Schema.union(API_PROTOCOL_IDS).default("chat-completions").description("\u7F51\u5173\u652F\u6301\u7684\u63A8\u7406\u534F\u8BAE\uFF1B\u6A21\u578B\u76EE\u5F55\u901A\u8FC7\u8BE5\u7F51\u5173\u7684\u517C\u5BB9\u63A5\u53E3\u8BFB\u53D6").volatile(),
|
|
341
360
|
modelSettings: Schema.transform(Schema.dict(Schema.any()), serializableTransform(parseModelSettingsMap)).default({}).description("\u9010\u6A21\u578B\u542F\u7528\u72B6\u6001\u3001\u56FE\u7247\u8F93\u5165\u548C\u8BF7\u6C42\u53C2\u6570").volatile(),
|
|
342
361
|
useDesktopCredential: Schema.boolean().default(true).description("\u4F18\u5148\u8BFB\u53D6 OpenDesign \u684C\u9762\u7AEF\u767B\u5F55\u6001\u67E5\u8BE2\u989D\u5EA6").volatile(),
|
|
343
|
-
emptyTurnGuard: Schema.boolean().default(true).description("\u4FDD\u62A4 DeepSeek V4.1 Flash \u5DE5\u5177\u5BF9\u8BDD\uFF1A\u6062\u590D\u7A7A\u56DE\u7B54\
|
|
362
|
+
emptyTurnGuard: Schema.boolean().default(true).description("\u4FDD\u62A4 DeepSeek V4.1 Flash \u5DE5\u5177\u5BF9\u8BDD\uFF1A\u6062\u590D\u7A7A\u56DE\u7B54\u4E0E\u5DF2\u77E5\u534F\u8BAE\u6B8B\u7559\u7ED3\u675F").volatile(),
|
|
363
|
+
turnCompletionReview: Schema.boolean().default(false).description("\u56DE\u590D\u7ED3\u675F\u540E\u8FFD\u52A0\u6709\u754C\u7684\u7ED3\u6784\u5316\u6536\u5C3E\u6838\u9A8C\uFF0C\u8981\u6C42\u6A21\u578B\u8C03\u7528\u6536\u5C3E\u5DE5\u5177\u62A5\u544A\u72B6\u6001").volatile(),
|
|
344
364
|
turnReviewMaxContinuations: Schema.natural().min(1).max(10).default(3).description("\u6BCF\u8F6E\u4EFB\u52A1\u7684\u6536\u5C3E\u6838\u9A8C\u6700\u591A\u7EED\u529E\u6B21\u6570").volatile(),
|
|
345
365
|
turnReviewNoProgressLimit: Schema.natural().min(1).max(5).default(2).description("\u8FDE\u7EED\u7F3A\u5C11\u65B0\u6210\u529F\u5DE5\u5177\u7ED3\u679C\u65F6\u505C\u6B62\u6536\u5C3E\u7EED\u529E\u7684\u6B21\u6570").volatile(),
|
|
346
366
|
quotaRefreshSeconds: Schema.natural().min(5).max(3600).default(60).description("\u989D\u5EA6\u81EA\u52A8\u5237\u65B0\u95F4\u9694\uFF08\u79D2\uFF09").volatile(),
|
|
@@ -374,6 +394,7 @@ function readConfig(config) {
|
|
|
374
394
|
requestTimeoutMs: config.requestTimeoutMs.get(),
|
|
375
395
|
streamIdleTimeoutMs: config.streamIdleTimeoutMs.get(),
|
|
376
396
|
maxRequestImageBytes: config.maxRequestImageBytes.get(),
|
|
397
|
+
turnCompletionReview: config.turnCompletionReview.get(),
|
|
377
398
|
turnReviewMaxContinuations: config.turnReviewMaxContinuations.get(),
|
|
378
399
|
turnReviewNoProgressLimit: config.turnReviewNoProgressLimit.get()
|
|
379
400
|
};
|
|
@@ -2008,7 +2029,7 @@ var CoRouterAdapter = class extends LlmAdapter {
|
|
|
2008
2029
|
if (!isModelEnabled(id, config.modelSettings)) throw new LlmError11("\u8BE5\u6A21\u578B\u5DF2\u5728 CoRouter \u8BBE\u7F6E\u4E2D\u505C\u7528", "MODEL_DISABLED");
|
|
2009
2030
|
const configured = applyModelSettings(row, config.modelSettings?.[id]);
|
|
2010
2031
|
const output = config.modelSettings?.[id]?.maxTokens;
|
|
2011
|
-
if (output !== void 0 && configured.contextWindow !== void 0 && output >= configured.contextWindow) throw new LlmError11("\u6A21\u578B\u6700\u5927\u8F93\u51FA\u5FC5\u987B\u5C0F\u4E8E\
|
|
2032
|
+
if (output !== void 0 && configured.contextWindow !== void 0 && output >= configured.contextWindow) throw new LlmError11("\u6A21\u578B\u6700\u5927\u8F93\u51FA\u5FC5\u987B\u5C0F\u4E8E\u5F53\u524D\u603B\u7A97\u53E3\uFF08\u542B\u8F93\u51FA\u9884\u7559\uFF09\uFF0C\u8BF7\u8C03\u6574\u6A21\u578B\u53C2\u6570", "INVALID_REQUEST");
|
|
2012
2033
|
return configured;
|
|
2013
2034
|
}
|
|
2014
2035
|
async listModels(provider) {
|
|
@@ -2446,6 +2467,11 @@ var TurnMonitor = class {
|
|
|
2446
2467
|
#report(decision, reason) {
|
|
2447
2468
|
this.#last = { at: new Date(this.now()).toISOString(), decision, reason };
|
|
2448
2469
|
}
|
|
2470
|
+
/** The completion handshake is opt-in; the empty-turn guard stays the outer switch. */
|
|
2471
|
+
#reviewing() {
|
|
2472
|
+
const config = this.config();
|
|
2473
|
+
return config.emptyTurnGuard === true && config.turnCompletionReview === true;
|
|
2474
|
+
}
|
|
2449
2475
|
#release(state) {
|
|
2450
2476
|
const remove = state.removeTool;
|
|
2451
2477
|
state.removeTool = void 0;
|
|
@@ -2466,7 +2492,7 @@ var TurnMonitor = class {
|
|
|
2466
2492
|
this.#active.delete(state);
|
|
2467
2493
|
}
|
|
2468
2494
|
configurationChanged() {
|
|
2469
|
-
if (this
|
|
2495
|
+
if (this.#reviewing()) return;
|
|
2470
2496
|
for (const state of [...this.#active]) {
|
|
2471
2497
|
state.settled = true;
|
|
2472
2498
|
this.#release(state);
|
|
@@ -2584,7 +2610,7 @@ var TurnMonitor = class {
|
|
|
2584
2610
|
output: { schema: outcomeSchema, render: (_args, value) => [{ type: "text", text: JSON.stringify(value) }] },
|
|
2585
2611
|
execute: async (args, exec) => {
|
|
2586
2612
|
exec.signal.throwIfAborted();
|
|
2587
|
-
if (this.#disposed || !this
|
|
2613
|
+
if (this.#disposed || !this.#reviewing() || state.settled || exec.agent !== state.agent || !state.removeTool || !exec.agent || this.#states.get(exec.agent.session) !== state || !monitored(exec.agent.session)) {
|
|
2588
2614
|
throw new LlmError13("\u5F53\u524D\u6CA1\u6709\u53EF\u63D0\u4EA4\u7684\u6536\u5C3E\u6838\u9A8C", "INVALID_REQUEST");
|
|
2589
2615
|
}
|
|
2590
2616
|
const outcome = parseOutcome(args);
|
|
@@ -2624,7 +2650,7 @@ var TurnMonitor = class {
|
|
|
2624
2650
|
stopping = ({ agent, turn, signal }) => {
|
|
2625
2651
|
const state = this.#states.get(agent.session);
|
|
2626
2652
|
if (!state || state.turn !== turn || state.settled || state.assistantSeq < 0 || state.checkedSeq === state.assistantSeq) return;
|
|
2627
|
-
if (this.#disposed || !this
|
|
2653
|
+
if (this.#disposed || !this.#reviewing() || !monitored(agent.session) || !state.assistantMonitored) {
|
|
2628
2654
|
this.#release(state);
|
|
2629
2655
|
return;
|
|
2630
2656
|
}
|
|
@@ -3399,7 +3425,7 @@ import { randomUUID as randomUUID2 } from "node:crypto";
|
|
|
3399
3425
|
|
|
3400
3426
|
// src/device-auth.ts
|
|
3401
3427
|
var DEVICE_AUTH_ENDPOINT = "https://amr-api.open-design.ai/api/v1/cli/device-authorizations";
|
|
3402
|
-
var DEVICE_AUTH_PLUGIN_VERSION = "0.1.
|
|
3428
|
+
var DEVICE_AUTH_PLUGIN_VERSION = "0.1.16";
|
|
3403
3429
|
var DEVICE_REQUEST_TIMEOUT_MS = 2e4;
|
|
3404
3430
|
var DEVICE_RESPONSE_MAX_BYTES = 65536;
|
|
3405
3431
|
var DEVICE_POLL_MIN_MS = 1e3;
|
|
@@ -4515,6 +4541,7 @@ function parseStatusConfig(value) {
|
|
|
4515
4541
|
if (!ENV_REF.test(apiKeyEnv)) throw new Error("\u51ED\u636E\u5F15\u7528\u540D\u5FC5\u987B\u662F\u5408\u6CD5\u6807\u8BC6\u7B26");
|
|
4516
4542
|
return {
|
|
4517
4543
|
emptyTurnGuard: flag(value.emptyTurnGuard, "\u7A7A\u8F6E\u4FDD\u62A4\u5F00\u5173"),
|
|
4544
|
+
...value.turnCompletionReview === void 0 ? {} : { turnCompletionReview: flag(value.turnCompletionReview, "\u7ED3\u675F\u56DE\u5408\u6838\u9A8C\u5F00\u5173") },
|
|
4518
4545
|
useDesktopCredential: flag(value.useDesktopCredential, "\u684C\u9762\u767B\u5F55\u6001\u5F00\u5173"),
|
|
4519
4546
|
baseURL: text(value.baseURL, "\u63A8\u7406\u5730\u5740", MAX_BASE_URL),
|
|
4520
4547
|
apiKeyEnv,
|