dsh-github-copilot 0.4.0-alpha.37 → 0.4.0-alpha.38
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/AGENTS.md +7 -4
- package/CHANGELOG.md +8 -0
- package/README.md +21 -14
- package/README.zh.md +21 -14
- package/deployment-baseline.json +44 -16
- package/docs/npm-distribution.md +28 -18
- package/docs/official-first-020-rc1.md +28 -0
- package/lib/client.js +8 -5
- package/lib/client.js.map +1 -1
- package/lib/index.js +144 -90
- package/lib/routed-web.js +1 -1
- package/lib/{search-routing-DqLKem1c.js → search-routing-C1o895V6.js} +29 -2
- package/lib/types/compatibility.d.ts +5 -5
- package/lib/types/config.d.ts +3 -0
- package/lib/types/pi-provider-bridge.d.ts +1 -1
- package/lib/types/route-ownership.d.ts +1 -1
- package/lib/types/serialize.d.ts +8 -11
- package/lib/types/settings-reader.d.ts +11 -0
- package/package.json +44 -43
- package/scripts/check-search-composition.mjs +2 -2
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as currentSearchInitiator, D as
|
|
1
|
+
import { A as GITHUB_COPILOT_PREVIEW_PROVIDER_ID, C as currentSearchInitiator, D as isPluginPreviewProvider, E as readSettingsNamespace, O as readCopilotCatalog, S as currentChatRoute, T as onSettingsNamespaceUpdated, _ as RESPONSES_WEB_SEARCH_TOOL_TYPE, a as COPILOT_HOSTED_SEARCH_PROVIDER_ID, b as candidatesForRoute, c as abortable$1, d as readBounded, f as applyRequestAuth, h as ANTHROPIC_WEB_SEARCH_TOOL_TYPE, i as describeSearchBackend, j as GITHUB_COPILOT_PROVIDER_ID, k as GITHUB_COPILOT_CREDENTIAL_KEY, l as isAbortError, m as providerRequestHeaders, n as routeSessionSearch, o as GITHUB_COPILOT_HOSTED_SEARCH_PROVIDER_ID, p as normalizeRequestAuth, r as DescribedSearchFallbackError, s as createTraditionalSearchProvider, t as isCopilotSearchSelection, u as providerErrorMessage, v as SearchPlan, w as currentSearchSelection, x as sameCandidates, y as WEB_SEARCH_TOOL_TYPE } from "./search-routing-C1o895V6.js";
|
|
2
2
|
import AuthorizationService from "@deepseek-ai/dsh-authorization";
|
|
3
3
|
import { createHash, randomUUID } from "node:crypto";
|
|
4
4
|
import * as dshScope from "@deepseek-ai/dsh-scope";
|
|
@@ -387,7 +387,9 @@ let GitHubCopilotDualModel = (() => {
|
|
|
387
387
|
}
|
|
388
388
|
};
|
|
389
389
|
}, { prepend: true });
|
|
390
|
-
ctx.on("agent/created", ({ agent }) =>
|
|
390
|
+
ctx.on("agent/created", async ({ agent }) => {
|
|
391
|
+
this.restore(agent);
|
|
392
|
+
});
|
|
391
393
|
ctx.on("agent/disposed", ({ agent }) => {
|
|
392
394
|
const subject = agent;
|
|
393
395
|
const overlay = this.overlays.get(subject);
|
|
@@ -1584,7 +1586,7 @@ let GitHubCopilotUsageController = (() => {
|
|
|
1584
1586
|
ctx.on("credentials/record-updated", (key) => {
|
|
1585
1587
|
if (key === "llm-pi-ai/github-copilot") this.source.invalidate();
|
|
1586
1588
|
});
|
|
1587
|
-
ctx
|
|
1589
|
+
onSettingsNamespaceUpdated(ctx, (namespace) => {
|
|
1588
1590
|
if (namespace === "github-copilot" || namespace === "llm-pi-ai") this.source.invalidate();
|
|
1589
1591
|
});
|
|
1590
1592
|
ctx.effect(() => () => this.source.dispose());
|
|
@@ -1600,7 +1602,7 @@ let GitHubCopilotUsageController = (() => {
|
|
|
1600
1602
|
//#endregion
|
|
1601
1603
|
//#region package.json
|
|
1602
1604
|
var name$1 = "dsh-github-copilot";
|
|
1603
|
-
var version = "0.4.0-alpha.
|
|
1605
|
+
var version = "0.4.0-alpha.38";
|
|
1604
1606
|
//#endregion
|
|
1605
1607
|
//#region lib/types/probe.js
|
|
1606
1608
|
/**
|
|
@@ -1988,6 +1990,30 @@ function selectCompactionReasoning(supportedEfforts, requestedEffort, mode = DEF
|
|
|
1988
1990
|
return supportedEfforts.find((effort) => effort === "minimal") ?? supportedEfforts.find((effort) => effort === "low");
|
|
1989
1991
|
}
|
|
1990
1992
|
//#endregion
|
|
1993
|
+
//#region lib/types/search-routing-policy.js
|
|
1994
|
+
/** Resolve old and new settings without guessing registered providers or dropping unknown ids. */
|
|
1995
|
+
function normalizeWebSearchRouting(config) {
|
|
1996
|
+
const defaultProvider = config.defaultSearchProvider?.trim() || "deepseek-official";
|
|
1997
|
+
const legacy = config.searchProvider === void 0;
|
|
1998
|
+
return {
|
|
1999
|
+
primaryProvider: legacy ? config.searchMode === "fixed" ? defaultProvider : "auto" : config.searchProvider?.trim() || "auto",
|
|
2000
|
+
defaultProvider,
|
|
2001
|
+
legacy
|
|
2002
|
+
};
|
|
2003
|
+
}
|
|
2004
|
+
//#endregion
|
|
2005
|
+
//#region lib/types/web-search-routing-config.js
|
|
2006
|
+
/** Plugin-owned settings namespace for cross-provider web-search routing. */
|
|
2007
|
+
const WEB_SEARCH_ROUTING_SETTINGS_NAMESPACE = "github-copilot-search-routing";
|
|
2008
|
+
/** Sentinel that disables the default/fixed search backend. */
|
|
2009
|
+
const NO_DEFAULT_SEARCH_PROVIDER = "none";
|
|
2010
|
+
/** User-facing routing settings; provider-specific credentials and models remain provider-owned. */
|
|
2011
|
+
const WebSearchRoutingConfigSchema = z.object({
|
|
2012
|
+
searchProvider: z.string(),
|
|
2013
|
+
searchMode: z.union(["auto", "fixed"]).default("auto"),
|
|
2014
|
+
defaultSearchProvider: z.string().default("deepseek-official")
|
|
2015
|
+
});
|
|
2016
|
+
//#endregion
|
|
1991
2017
|
//#region lib/types/config.js
|
|
1992
2018
|
/**
|
|
1993
2019
|
* Settings section of the inline web-search plugin: the narrow-gate switch,
|
|
@@ -2014,33 +2040,10 @@ const Config = z.object({
|
|
|
2014
2040
|
routeWebSearch: z.boolean().default(true),
|
|
2015
2041
|
searchFallback: z.union(["none", "deepseek"]).default("deepseek"),
|
|
2016
2042
|
searchModel: z.string().hidden(),
|
|
2043
|
+
searchRouting: WebSearchRoutingConfigSchema.default({}),
|
|
2017
2044
|
temporaryRouteBackup: z.string().hidden()
|
|
2018
2045
|
});
|
|
2019
2046
|
//#endregion
|
|
2020
|
-
//#region lib/types/search-routing-policy.js
|
|
2021
|
-
/** Resolve old and new settings without guessing registered providers or dropping unknown ids. */
|
|
2022
|
-
function normalizeWebSearchRouting(config) {
|
|
2023
|
-
const defaultProvider = config.defaultSearchProvider?.trim() || "deepseek-official";
|
|
2024
|
-
const legacy = config.searchProvider === void 0;
|
|
2025
|
-
return {
|
|
2026
|
-
primaryProvider: legacy ? config.searchMode === "fixed" ? defaultProvider : "auto" : config.searchProvider?.trim() || "auto",
|
|
2027
|
-
defaultProvider,
|
|
2028
|
-
legacy
|
|
2029
|
-
};
|
|
2030
|
-
}
|
|
2031
|
-
//#endregion
|
|
2032
|
-
//#region lib/types/web-search-routing-config.js
|
|
2033
|
-
/** Plugin-owned settings namespace for cross-provider web-search routing. */
|
|
2034
|
-
const WEB_SEARCH_ROUTING_SETTINGS_NAMESPACE = "github-copilot-search-routing";
|
|
2035
|
-
/** Sentinel that disables the default/fixed search backend. */
|
|
2036
|
-
const NO_DEFAULT_SEARCH_PROVIDER = "none";
|
|
2037
|
-
/** User-facing routing settings; provider-specific credentials and models remain provider-owned. */
|
|
2038
|
-
const WebSearchRoutingConfigSchema = z.object({
|
|
2039
|
-
searchProvider: z.string(),
|
|
2040
|
-
searchMode: z.union(["auto", "fixed"]).default("auto"),
|
|
2041
|
-
defaultSearchProvider: z.string().default("deepseek-official")
|
|
2042
|
-
});
|
|
2043
|
-
//#endregion
|
|
2044
2047
|
//#region lib/types/search-tool-routing.js
|
|
2045
2048
|
function aborted() {
|
|
2046
2049
|
return new WebError("web search aborted", "WEB_ABORTED");
|
|
@@ -2377,8 +2380,33 @@ function splitCallId(id) {
|
|
|
2377
2380
|
* @param content - the message content blocks.
|
|
2378
2381
|
* @returns the joined text.
|
|
2379
2382
|
*/
|
|
2383
|
+
function isTextBlock(value) {
|
|
2384
|
+
return typeof value === "object" && value !== null && "type" in value && value.type === "text" && "text" in value && typeof value.text === "string";
|
|
2385
|
+
}
|
|
2380
2386
|
function flattenText(content) {
|
|
2381
|
-
return content.filter(
|
|
2387
|
+
return content.filter(isTextBlock).map((block) => block.text).join("");
|
|
2388
|
+
}
|
|
2389
|
+
function legacyToolResult(value) {
|
|
2390
|
+
return typeof value === "object" && value !== null && "type" in value && value.type === "tool-result" && "toolCallId" in value && typeof value.toolCallId === "string" && "content" in value && Array.isArray(value.content);
|
|
2391
|
+
}
|
|
2392
|
+
function legacyToolResults(content) {
|
|
2393
|
+
const results = [];
|
|
2394
|
+
for (const block of content) if (legacyToolResult(block)) results.push(block);
|
|
2395
|
+
return results;
|
|
2396
|
+
}
|
|
2397
|
+
function responsesToolResult(result, pairedCallIds) {
|
|
2398
|
+
const callId = splitCallId(result.toolCallId).callId;
|
|
2399
|
+
if (pairedCallIds !== void 0 && !pairedCallIds.has(callId)) return [];
|
|
2400
|
+
return [{
|
|
2401
|
+
type: "function_call_output",
|
|
2402
|
+
call_id: callId,
|
|
2403
|
+
output: (result.isError === true ? "[Error] " : "") + (flattenText(result.content) || "(no output)")
|
|
2404
|
+
}];
|
|
2405
|
+
}
|
|
2406
|
+
/** Detect a grounded sandbox denial in either current tool-role or retained legacy message layout. */
|
|
2407
|
+
function hasToolResultText(message, needle) {
|
|
2408
|
+
if (message.role === "tool") return flattenText(message.content).includes(needle);
|
|
2409
|
+
return message.role === "user" && legacyToolResults(message.content).some((result) => flattenText(result.content).includes(needle));
|
|
2382
2410
|
}
|
|
2383
2411
|
/**
|
|
2384
2412
|
* Serialize one dsh message into Responses input items.
|
|
@@ -2388,15 +2416,11 @@ function flattenText(content) {
|
|
|
2388
2416
|
*/
|
|
2389
2417
|
function serializeMessage(message, pairedCallIds) {
|
|
2390
2418
|
if (hasResponsesReplayContext([message])) throw new UnsupportedContentError("Core-owned reasoning or replay context");
|
|
2419
|
+
if (message.role === "tool") return responsesToolResult(message, pairedCallIds);
|
|
2391
2420
|
if (message.role === "user") {
|
|
2392
2421
|
if (message.content.some((block) => block.type === "image")) throw new UnsupportedContentError("image content");
|
|
2393
|
-
const toolResults = message.content
|
|
2394
|
-
if (toolResults.length > 0) return toolResults.
|
|
2395
|
-
type: "function_call_output",
|
|
2396
|
-
call_id: splitCallId(result.toolCallId).callId,
|
|
2397
|
-
output: (result.isError === true ? "[Error] " : "") + (flattenText(result.content) || "(no output)")
|
|
2398
|
-
}));
|
|
2399
|
-
if (message.content.some((block) => block.type === "tool-result") && flattenText(message.content).length === 0) return [];
|
|
2422
|
+
const toolResults = legacyToolResults(message.content);
|
|
2423
|
+
if (toolResults.length > 0) return toolResults.flatMap((result) => responsesToolResult(result, pairedCallIds));
|
|
2400
2424
|
return [{
|
|
2401
2425
|
role: "user",
|
|
2402
2426
|
content: [{
|
|
@@ -2412,6 +2436,7 @@ function serializeMessage(message, pairedCallIds) {
|
|
|
2412
2436
|
text: flattenText(message.content)
|
|
2413
2437
|
}]
|
|
2414
2438
|
}];
|
|
2439
|
+
if (message.role === "developer") throw new UnsupportedContentError("Core-owned developer tool history");
|
|
2415
2440
|
const items = [];
|
|
2416
2441
|
for (const block of message.content) {
|
|
2417
2442
|
const suffix = items.length;
|
|
@@ -2451,9 +2476,13 @@ function serializeMessage(message, pairedCallIds) {
|
|
|
2451
2476
|
function pairedToolCallIds(messages) {
|
|
2452
2477
|
const calls = /* @__PURE__ */ new Set();
|
|
2453
2478
|
const results = /* @__PURE__ */ new Set();
|
|
2454
|
-
for (const message of messages)
|
|
2455
|
-
if (
|
|
2456
|
-
|
|
2479
|
+
for (const message of messages) {
|
|
2480
|
+
if (message.role === "tool") results.add(splitCallId(message.toolCallId).callId);
|
|
2481
|
+
for (const block of message.content) {
|
|
2482
|
+
if (block.type === "tool-call") calls.add(splitCallId(block.id).callId);
|
|
2483
|
+
const candidate = block;
|
|
2484
|
+
if (legacyToolResult(candidate)) results.add(splitCallId(candidate.toolCallId).callId);
|
|
2485
|
+
}
|
|
2457
2486
|
}
|
|
2458
2487
|
return new Set([...calls].filter((callId) => results.has(callId)));
|
|
2459
2488
|
}
|
|
@@ -2550,9 +2579,18 @@ function anthropicWireTools(tools, stripServerTools) {
|
|
|
2550
2579
|
* @throws UnsupportedContentError for image content.
|
|
2551
2580
|
*/
|
|
2552
2581
|
function serializeAnthropicMessage(message) {
|
|
2582
|
+
if (message.role === "tool") return [{
|
|
2583
|
+
role: "user",
|
|
2584
|
+
content: [{
|
|
2585
|
+
type: "tool_result",
|
|
2586
|
+
tool_use_id: splitCallId(message.toolCallId).callId,
|
|
2587
|
+
content: flattenText(message.content) || "(no output)",
|
|
2588
|
+
...message.isError === true ? { is_error: true } : {}
|
|
2589
|
+
}]
|
|
2590
|
+
}];
|
|
2553
2591
|
if (message.role === "user") {
|
|
2554
2592
|
if (message.content.some((block) => block.type === "image")) throw new UnsupportedContentError("image content");
|
|
2555
|
-
const results = message.content
|
|
2593
|
+
const results = legacyToolResults(message.content);
|
|
2556
2594
|
if (results.length > 0) return results.map((result) => ({
|
|
2557
2595
|
role: "user",
|
|
2558
2596
|
content: [{
|
|
@@ -2577,6 +2615,7 @@ function serializeAnthropicMessage(message) {
|
|
|
2577
2615
|
text: flattenText(message.content)
|
|
2578
2616
|
}]
|
|
2579
2617
|
}];
|
|
2618
|
+
if (message.role === "developer") throw new UnsupportedContentError("Core-owned developer tool history");
|
|
2580
2619
|
const content = [];
|
|
2581
2620
|
for (const block of message.content) if (block.type === "reasoning") content.push({
|
|
2582
2621
|
type: "text",
|
|
@@ -3144,8 +3183,7 @@ function contentHasImageAttachments(request) {
|
|
|
3144
3183
|
*/
|
|
3145
3184
|
function hasGroundedSandboxEscalation(request) {
|
|
3146
3185
|
const last = request.messages.at(-1);
|
|
3147
|
-
|
|
3148
|
-
return last.content.some((block) => block.type === "tool-result" && flattenText(block.content).includes(SANDBOX_DENIAL_MARKER));
|
|
3186
|
+
return last !== void 0 && hasToolResultText(last, SANDBOX_DENIAL_MARKER);
|
|
3149
3187
|
}
|
|
3150
3188
|
/**
|
|
3151
3189
|
* Strip speculative sandbox escalation fields while preserving sanctioned
|
|
@@ -3597,6 +3635,12 @@ async function* inlineStream(request, candidate, hooks, cfg) {
|
|
|
3597
3635
|
}
|
|
3598
3636
|
//#endregion
|
|
3599
3637
|
//#region lib/types/deepseek-search-fallback.js
|
|
3638
|
+
function isVolatileSetting(value) {
|
|
3639
|
+
return typeof value === "object" && value !== null && typeof Reflect.get(value, "get") === "function";
|
|
3640
|
+
}
|
|
3641
|
+
function readConfigValue(value) {
|
|
3642
|
+
return isVolatileSetting(value) ? value.get() : value;
|
|
3643
|
+
}
|
|
3600
3644
|
var InvalidFallbackBase = class extends WebError {
|
|
3601
3645
|
constructor() {
|
|
3602
3646
|
super("DeepSeek fallback requires an HTTP(S) API base URL without userinfo, query or fragment", "WEB_PROVIDER_UNAVAILABLE");
|
|
@@ -3621,14 +3665,19 @@ async function createDeepSeekSearchFallback(ctx, owner, canContinue) {
|
|
|
3621
3665
|
throw new WebError("the official launch-environment API required by DeepSeek fallback is unavailable", "WEB_PROVIDER_UNAVAILABLE");
|
|
3622
3666
|
});
|
|
3623
3667
|
const resolveOptions = (signal) => {
|
|
3624
|
-
const config = ctx
|
|
3668
|
+
const config = readSettingsNamespace(ctx, native.WEB_SEARCH_DEEPSEEK_SETTINGS_NAMESPACE) ?? {};
|
|
3625
3669
|
const environment = launchEnvironmentOf(ctx);
|
|
3626
|
-
const baseURL = config.baseURL ?? environment.get("DEEPSEEK_SEARCH_BASE_URL")?.value ?? native.DEEPSEEK_DEFAULT_BASE_URL;
|
|
3670
|
+
const baseURL = readConfigValue(config.baseURL) ?? environment.get("DEEPSEEK_SEARCH_BASE_URL")?.value ?? native.DEEPSEEK_DEFAULT_BASE_URL;
|
|
3627
3671
|
const parsed = URL.canParse(baseURL) ? new URL(baseURL) : void 0;
|
|
3628
3672
|
if (parsed === void 0 || !["http:", "https:"].includes(parsed.protocol) || parsed.username.length > 0 || parsed.password.length > 0 || parsed.href.includes("?") || parsed.href.includes("#")) throw new InvalidFallbackBase();
|
|
3629
|
-
const
|
|
3673
|
+
const configuredApiKey = readConfigValue(config.apiKey);
|
|
3674
|
+
const apiKeyEnv = credentialRef(readConfigValue(config.apiKeyEnv) ?? "DEEPSEEK_API_KEY");
|
|
3675
|
+
const model = readConfigValue(config.model);
|
|
3676
|
+
const apiVersion = readConfigValue(config.apiVersion);
|
|
3677
|
+
const maxTokens = readConfigValue(config.maxTokens);
|
|
3678
|
+
const maxUses = readConfigValue(config.maxUses);
|
|
3630
3679
|
return {
|
|
3631
|
-
...
|
|
3680
|
+
...configuredApiKey === void 0 || configuredApiKey.length === 0 ? {} : { apiKey: configuredApiKey },
|
|
3632
3681
|
apiKeyEnv,
|
|
3633
3682
|
resolveApiKey: async () => {
|
|
3634
3683
|
const credentials = ctx.get("credentials");
|
|
@@ -3637,10 +3686,10 @@ async function createDeepSeekSearchFallback(ctx, owner, canContinue) {
|
|
|
3637
3686
|
return ambient === void 0 || ambient.length === 0 ? void 0 : ambient;
|
|
3638
3687
|
},
|
|
3639
3688
|
baseURL,
|
|
3640
|
-
model:
|
|
3641
|
-
apiVersion:
|
|
3642
|
-
maxTokens:
|
|
3643
|
-
maxUses:
|
|
3689
|
+
model: model ?? native.DEEPSEEK_DEFAULT_MODEL,
|
|
3690
|
+
apiVersion: apiVersion ?? native.DEEPSEEK_DEFAULT_API_VERSION,
|
|
3691
|
+
maxTokens: maxTokens ?? native.DEEPSEEK_DEFAULT_MAX_TOKENS,
|
|
3692
|
+
maxUses: maxUses ?? native.DEEPSEEK_DEFAULT_MAX_USES,
|
|
3644
3693
|
recordRequest: (request) => {
|
|
3645
3694
|
if (signal?.aborted === true) throw new WebError("web search aborted", "WEB_ABORTED");
|
|
3646
3695
|
if (!canContinue()) throw new InvalidFallbackProof();
|
|
@@ -3695,20 +3744,10 @@ async function createDeepSeekSearchFallback(ctx, owner, canContinue) {
|
|
|
3695
3744
|
* @module dsh-github-copilot/compatibility
|
|
3696
3745
|
*/
|
|
3697
3746
|
const DSH_COMPATIBILITY = {
|
|
3698
|
-
release: "0.
|
|
3699
|
-
developmentRelease: "0.
|
|
3700
|
-
peerRange: "0.
|
|
3701
|
-
supportedReleases: [
|
|
3702
|
-
"0.1.1-rc.2",
|
|
3703
|
-
"0.1.2-rc.1",
|
|
3704
|
-
"0.1.3-alpha.1",
|
|
3705
|
-
"0.1.5-alpha.1",
|
|
3706
|
-
"0.1.5-alpha.2",
|
|
3707
|
-
"0.1.5-rc.1",
|
|
3708
|
-
"0.1.5-rc.2",
|
|
3709
|
-
"0.1.6-alpha.1",
|
|
3710
|
-
"0.1.6-alpha.2"
|
|
3711
|
-
],
|
|
3747
|
+
release: "0.2.0-rc.1",
|
|
3748
|
+
developmentRelease: "0.2.0-rc.1",
|
|
3749
|
+
peerRange: "0.2.0-rc.1",
|
|
3750
|
+
supportedReleases: ["0.2.0-rc.1"],
|
|
3712
3751
|
requiredApis: [
|
|
3713
3752
|
"agentDefaultModel.currentSelection",
|
|
3714
3753
|
"authorization.describe",
|
|
@@ -3719,10 +3758,8 @@ const DSH_COMPATIBILITY = {
|
|
|
3719
3758
|
"credentials.listRecords",
|
|
3720
3759
|
"credentials.modifyRecord",
|
|
3721
3760
|
"credentials.deleteRecord",
|
|
3722
|
-
"settings.get",
|
|
3723
3761
|
"settings.describe",
|
|
3724
3762
|
"settings.mutate",
|
|
3725
|
-
"settings.installSection",
|
|
3726
3763
|
"web.registerSearchProvider",
|
|
3727
3764
|
"systemPrompt.section",
|
|
3728
3765
|
"context.on",
|
|
@@ -3754,10 +3791,8 @@ function assertDshCompatibility(ctx) {
|
|
|
3754
3791
|
"deleteRecord"
|
|
3755
3792
|
]) if (!method(credentials, api)) incompatible(`credentials.${api}`);
|
|
3756
3793
|
const settings = ctx.get("settings");
|
|
3757
|
-
if (!method(settings, "get")) incompatible("settings.get");
|
|
3758
3794
|
if (!method(settings, "describe")) incompatible("settings.describe");
|
|
3759
3795
|
if (!method(settings, "mutate")) incompatible("settings.mutate");
|
|
3760
|
-
if (typeof dshSettings.installSettingsSection !== "function" && !method(settings, "installSection")) incompatible("settings.installSection");
|
|
3761
3796
|
if (!method(ctx.get("web"), "registerSearchProvider")) incompatible("web.registerSearchProvider");
|
|
3762
3797
|
if (!method(ctx["systemPrompt"], "section")) incompatible("systemPrompt.section");
|
|
3763
3798
|
if (typeof ctx["on"] !== "function") incompatible("context.on");
|
|
@@ -3922,7 +3957,7 @@ function settingsSnapshot(settings) {
|
|
|
3922
3957
|
const route = descriptors.find((item) => item.ns === "llm-pi-ai");
|
|
3923
3958
|
const marker = descriptors.find((item) => item.ns === "github-copilot");
|
|
3924
3959
|
if (!route || !marker || !Number.isSafeInteger(route.revision) || !Number.isSafeInteger(marker.revision)) throw new Error("github-copilot: required DSH API \"settings.describe revision\" is unavailable");
|
|
3925
|
-
const current = profileAt(
|
|
3960
|
+
const current = profileAt(route.value);
|
|
3926
3961
|
const raw = profileAt(route.user);
|
|
3927
3962
|
const secrets = (route.secrets ?? []).filter((secret) => secret.set && secret.path[0] === "providers" && secret.path[1] === "github-copilot");
|
|
3928
3963
|
const hasSecrets = secrets.length > 0;
|
|
@@ -3935,7 +3970,7 @@ function settingsSnapshot(settings) {
|
|
|
3935
3970
|
hasOwnedSecrets,
|
|
3936
3971
|
routeRevision: route.revision,
|
|
3937
3972
|
markerRevision: marker.revision,
|
|
3938
|
-
backup: readBackup(object$3(
|
|
3973
|
+
backup: readBackup(object$3(marker.value)?.temporaryRouteBackup)
|
|
3939
3974
|
};
|
|
3940
3975
|
}
|
|
3941
3976
|
function assertOwned(current, backup) {
|
|
@@ -4359,7 +4394,7 @@ async function describeGitHubCopilotProviderProfile(ctx) {
|
|
|
4359
4394
|
if (record === void 0) return { state: "not-configured" };
|
|
4360
4395
|
validateGrant(record);
|
|
4361
4396
|
try {
|
|
4362
|
-
const snapshot = settingsSnapshot(service(ctx, "settings", ["
|
|
4397
|
+
const snapshot = settingsSnapshot(service(ctx, "settings", ["describe"]));
|
|
4363
4398
|
const plan = planRoute(snapshot);
|
|
4364
4399
|
return { state: plan.operations.length > 0 || plan.clearBackup === true || plan.backup !== void 0 && !equalJson(plan.backup, snapshot.backup) ? "needs-repair" : snapshot.current === void 0 ? "not-configured" : "ready" };
|
|
4365
4400
|
} catch (error) {
|
|
@@ -4371,11 +4406,7 @@ async function repairGitHubCopilotProviderProfile(ctx) {
|
|
|
4371
4406
|
const record = await service(ctx, "credentials", ["readRecord"]).readRecord(GITHUB_COPILOT_CREDENTIAL_KEY);
|
|
4372
4407
|
if (record === void 0) return { changed: false };
|
|
4373
4408
|
validateGrant(record);
|
|
4374
|
-
const settings = service(ctx, "settings", [
|
|
4375
|
-
"get",
|
|
4376
|
-
"describe",
|
|
4377
|
-
"mutate"
|
|
4378
|
-
]);
|
|
4409
|
+
const settings = service(ctx, "settings", ["describe", "mutate"]);
|
|
4379
4410
|
const snapshot = settingsSnapshot(settings);
|
|
4380
4411
|
const plan = planRoute(snapshot);
|
|
4381
4412
|
let markerRevision = snapshot.markerRevision;
|
|
@@ -4834,7 +4865,7 @@ function installCopilotToolSchemaCompatibility(ctx) {
|
|
|
4834
4865
|
* same `tool-result.content` recursion so file context always fails closed.
|
|
4835
4866
|
*/
|
|
4836
4867
|
function contentHasFileCompat(content, official = dshLlm.contentHasFile) {
|
|
4837
|
-
if (official
|
|
4868
|
+
if (official?.(content)) return true;
|
|
4838
4869
|
return content.some((block) => {
|
|
4839
4870
|
if (typeof block !== "object" || block === null || !("type" in block)) return false;
|
|
4840
4871
|
if (block.type === "file") return true;
|
|
@@ -4861,7 +4892,7 @@ function unavailable() {
|
|
|
4861
4892
|
/** Resolve only the selected model's declared/native efforts, with the same precedence as Core. */
|
|
4862
4893
|
function resolveCopilotResponsesReasoning(ctx, request, candidate) {
|
|
4863
4894
|
if (request.provider !== "github-copilot" || candidate.protocol !== "openai-responses" || candidate.model !== request.model) return unavailable();
|
|
4864
|
-
const profile = object$1(object$1(object$1(ctx
|
|
4895
|
+
const profile = object$1(object$1(object$1(readSettingsNamespace(ctx, "llm-pi-ai"))?.providers)?.["github-copilot"]);
|
|
4865
4896
|
const effort = request.reasoningEffort ?? profile?.reasoning;
|
|
4866
4897
|
if (effort === void 0) return void 0;
|
|
4867
4898
|
const level = levels.find((value) => value === effort);
|
|
@@ -4917,7 +4948,7 @@ var CopilotResponsesReplayError = class extends Error {
|
|
|
4917
4948
|
this.name = "CopilotResponsesReplayError";
|
|
4918
4949
|
}
|
|
4919
4950
|
};
|
|
4920
|
-
function isRecord(value) {
|
|
4951
|
+
function isRecord$1(value) {
|
|
4921
4952
|
if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
|
|
4922
4953
|
const prototype = Object.getPrototypeOf(value);
|
|
4923
4954
|
return prototype === Object.prototype || prototype === null;
|
|
@@ -4926,7 +4957,7 @@ function nonemptyString(value) {
|
|
|
4926
4957
|
return typeof value === "string" && value.trim().length > 0;
|
|
4927
4958
|
}
|
|
4928
4959
|
function normalizeItem(item) {
|
|
4929
|
-
if (!isRecord(item)) throw new CopilotResponsesReplayError("invalid-payload");
|
|
4960
|
+
if (!isRecord$1(item)) throw new CopilotResponsesReplayError("invalid-payload");
|
|
4930
4961
|
if (item.type === "item_reference") throw new CopilotResponsesReplayError();
|
|
4931
4962
|
if ((item.type === "message" || item.type === void 0) && (item.role === "user" || item.role === "system" || item.role === "developer")) return item;
|
|
4932
4963
|
if (!Object.hasOwn(item, "id") || item.id === void 0) return item;
|
|
@@ -4939,7 +4970,7 @@ function normalizeItem(item) {
|
|
|
4939
4970
|
/** Normalize only the outgoing managed Responses payload, never stored history/context. */
|
|
4940
4971
|
function normalizeCopilotResponsesPayload(payload) {
|
|
4941
4972
|
try {
|
|
4942
|
-
if (!isRecord(payload) || typeof payload.input !== "string" && !Array.isArray(payload.input)) throw new CopilotResponsesReplayError("invalid-payload");
|
|
4973
|
+
if (!isRecord$1(payload) || typeof payload.input !== "string" && !Array.isArray(payload.input)) throw new CopilotResponsesReplayError("invalid-payload");
|
|
4943
4974
|
if (payload.previous_response_id !== void 0 && payload.previous_response_id !== null && payload.previous_response_id !== "") throw new CopilotResponsesReplayError(typeof payload.previous_response_id === "string" ? "unsupported" : "invalid-payload");
|
|
4944
4975
|
if (typeof payload.input === "string") return payload;
|
|
4945
4976
|
let changed = false;
|
|
@@ -4976,9 +5007,9 @@ async function readScopeError(reader) {
|
|
|
4976
5007
|
}
|
|
4977
5008
|
text += decoder.decode();
|
|
4978
5009
|
const body = JSON.parse(text);
|
|
4979
|
-
if (!isRecord(body)) return false;
|
|
5010
|
+
if (!isRecord$1(body)) return false;
|
|
4980
5011
|
const error = Object.hasOwn(body, "error") ? body.error : body;
|
|
4981
|
-
if (!isRecord(error) || typeof error.message !== "string" || !scopeMessages.has(error.message)) return false;
|
|
5012
|
+
if (!isRecord$1(error) || typeof error.message !== "string" || !scopeMessages.has(error.message)) return false;
|
|
4982
5013
|
return (!Object.hasOwn(body, "message") || body.message === error.message) && [
|
|
4983
5014
|
body.code,
|
|
4984
5015
|
body.type,
|
|
@@ -6044,6 +6075,17 @@ function failure(code, category = "AUTH") {
|
|
|
6044
6075
|
function tokenFingerprint(value) {
|
|
6045
6076
|
return createHash("sha256").update(value).digest("hex");
|
|
6046
6077
|
}
|
|
6078
|
+
function isRecord(value) {
|
|
6079
|
+
return typeof value === "object" && value !== null;
|
|
6080
|
+
}
|
|
6081
|
+
function providerProfiles(value) {
|
|
6082
|
+
if (!isRecord(value)) return void 0;
|
|
6083
|
+
if (typeof value.get === "function") {
|
|
6084
|
+
const resolved = value.get();
|
|
6085
|
+
return isRecord(resolved) ? resolved : void 0;
|
|
6086
|
+
}
|
|
6087
|
+
return value;
|
|
6088
|
+
}
|
|
6047
6089
|
function owned(provider) {
|
|
6048
6090
|
if (provider !== "github-copilot-preview") throw failure("COPILOT_PREVIEW_MODEL_MISMATCH", "UNKNOWN_MODEL");
|
|
6049
6091
|
}
|
|
@@ -6207,13 +6249,13 @@ function resolvedProfile(provider, config) {
|
|
|
6207
6249
|
"retryPolicy"
|
|
6208
6250
|
]);
|
|
6209
6251
|
if (Object.keys(config).some((key) => !permitted.has(key))) throw failure("COPILOT_PREVIEW_CONFIG_UNSUPPORTED", "INVALID_REQUEST");
|
|
6210
|
-
const parsed = Config$1({ providers: { [GITHUB_COPILOT_PREVIEW_PROVIDER_ID]: {
|
|
6252
|
+
const parsed = providerProfiles(Config$1({ providers: { [GITHUB_COPILOT_PREVIEW_PROVIDER_ID]: {
|
|
6211
6253
|
...config,
|
|
6212
6254
|
api: "openai-responses"
|
|
6213
|
-
} } }).providers?.[GITHUB_COPILOT_PREVIEW_PROVIDER_ID];
|
|
6214
|
-
if (parsed
|
|
6255
|
+
} } }).providers)?.[GITHUB_COPILOT_PREVIEW_PROVIDER_ID];
|
|
6256
|
+
if (!isRecord(parsed)) throw failure("COPILOT_PREVIEW_CONFIG_UNAVAILABLE", "INVALID_REQUEST");
|
|
6215
6257
|
const positive = (value) => {
|
|
6216
|
-
if (value
|
|
6258
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) throw failure("COPILOT_PREVIEW_CONFIG_DEFAULTS_UNAVAILABLE", "INVALID_REQUEST");
|
|
6217
6259
|
return value;
|
|
6218
6260
|
};
|
|
6219
6261
|
return Object.freeze({
|
|
@@ -6225,7 +6267,7 @@ function resolvedProfile(provider, config) {
|
|
|
6225
6267
|
maxRequestImageBytes: positive(parsed.maxRequestImageBytes),
|
|
6226
6268
|
requestImagePixelBudget: positive(parsed.requestImagePixelBudget),
|
|
6227
6269
|
requestImageMaxBytes: positive(parsed.requestImageMaxBytes),
|
|
6228
|
-
retryPolicy: resolveRetryPolicy(
|
|
6270
|
+
retryPolicy: resolveRetryPolicy(config.retryPolicy, "github-copilot-preview"),
|
|
6229
6271
|
configuredMaxTokens: /* @__PURE__ */ new Map(),
|
|
6230
6272
|
modelErrors: /* @__PURE__ */ new Map()
|
|
6231
6273
|
});
|
|
@@ -6755,8 +6797,19 @@ function installSettingsNamespace(ctx, namespace, schema, config, hooks) {
|
|
|
6755
6797
|
return;
|
|
6756
6798
|
}
|
|
6757
6799
|
ctx.inject(["settings"], (settingsCtx) => {
|
|
6758
|
-
if (
|
|
6759
|
-
|
|
6800
|
+
if (isInstanceSettingsInstaller(settingsCtx.settings)) {
|
|
6801
|
+
settingsCtx.settings.installSection(ctx, namespace, schema, config, hooks);
|
|
6802
|
+
return;
|
|
6803
|
+
}
|
|
6804
|
+
const fallback = namespace === "github-copilot-search-routing" ? (typeof config === "object" && config !== null ? config : void 0)?.searchRouting ?? {} : config;
|
|
6805
|
+
hooks.setSource(() => {
|
|
6806
|
+
return readSettingsNamespace(ctx, namespace) ?? fallback;
|
|
6807
|
+
});
|
|
6808
|
+
const watched = namespace === "github-copilot-search-routing" ? /* @__PURE__ */ new Set([namespace, GITHUB_COPILOT_SETTINGS_NAMESPACE]) : /* @__PURE__ */ new Set([namespace]);
|
|
6809
|
+
const dispose = onSettingsNamespaceUpdated(ctx, (changed) => {
|
|
6810
|
+
if (watched.has(changed)) hooks.onChange();
|
|
6811
|
+
});
|
|
6812
|
+
ctx.effect(() => dispose);
|
|
6760
6813
|
});
|
|
6761
6814
|
}
|
|
6762
6815
|
/**
|
|
@@ -7306,6 +7359,7 @@ function preflight(request, cfg, ctx, route) {
|
|
|
7306
7359
|
if (!providerAllowed(request, cfg, route)) return false;
|
|
7307
7360
|
if (request.messages.some((message) => contentHasFileCompat(message.content))) return false;
|
|
7308
7361
|
if (contentHasImageAttachments(request)) return false;
|
|
7362
|
+
if (request.messages.some((message) => message.role === "developer")) return false;
|
|
7309
7363
|
if (route?.api === "anthropic-messages" && request.messages.some((message) => String(message.role) === "system")) return false;
|
|
7310
7364
|
if (hasResponsesReplayContext(request.messages)) return false;
|
|
7311
7365
|
if (route?.api === "openai-responses") try {
|
package/lib/routed-web.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as currentSearchInitiator,
|
|
1
|
+
import { C as currentSearchInitiator, D as isPluginPreviewProvider, t as isCopilotSearchSelection, w as currentSearchSelection } from "./search-routing-C1o895V6.js";
|
|
2
2
|
import { WebError, WebRuntime } from "@deepseek-ai/dsh-web";
|
|
3
3
|
//#region lib/types/routed-web.js
|
|
4
4
|
/**
|
|
@@ -45,6 +45,33 @@ function isPluginPreviewProvider(ctx, provider) {
|
|
|
45
45
|
return typeof view === "object" && view !== null && Reflect.get(view, "provider") === provider;
|
|
46
46
|
}
|
|
47
47
|
//#endregion
|
|
48
|
+
//#region lib/types/settings-reader.js
|
|
49
|
+
function isRecord(value) {
|
|
50
|
+
return typeof value === "object" && value !== null;
|
|
51
|
+
}
|
|
52
|
+
function isSettingsForms(value) {
|
|
53
|
+
return isRecord(value) && typeof value.describe === "function";
|
|
54
|
+
}
|
|
55
|
+
function isLegacySettings(value) {
|
|
56
|
+
return isRecord(value) && typeof value.get === "function";
|
|
57
|
+
}
|
|
58
|
+
/** Read non-secret configuration through the API available on the running Core. */
|
|
59
|
+
function readSettingsNamespace(ctx, namespace) {
|
|
60
|
+
const settings = ctx.get("settings");
|
|
61
|
+
if (isLegacySettings(settings)) return settings.get(namespace);
|
|
62
|
+
if (!isSettingsForms(settings)) return void 0;
|
|
63
|
+
return settings.describe({ redactSecrets: true }).find((candidate) => candidate.ns === namespace)?.value;
|
|
64
|
+
}
|
|
65
|
+
/** Subscribe to namespace changes across the legacy settings provider and current form service. */
|
|
66
|
+
function onSettingsNamespaceUpdated(ctx, listener) {
|
|
67
|
+
const disposeDocument = ctx.on("settings/document-updated", (namespace) => listener(namespace));
|
|
68
|
+
const disposeLegacy = ctx.on("settings/updated", (namespace) => listener(namespace));
|
|
69
|
+
return () => {
|
|
70
|
+
disposeDocument();
|
|
71
|
+
disposeLegacy();
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
//#endregion
|
|
48
75
|
//#region lib/types/current-provider.js
|
|
49
76
|
/**
|
|
50
77
|
* Detection of an operation's provider route: the initiating Agent or explicit
|
|
@@ -181,7 +208,7 @@ function currentChatRoute(ctx, explicit) {
|
|
|
181
208
|
const selection = explicit ?? currentSearchSelection(currentSearchInitiator(ctx));
|
|
182
209
|
if (!selection?.provider || !selection.model) return void 0;
|
|
183
210
|
if (selection.provider === "github-copilot-preview" && !isPluginPreviewProvider(ctx, selection.provider)) return void 0;
|
|
184
|
-
const profile = selection.provider === "github-copilot-preview" ? void 0 : profileFacts(ctx
|
|
211
|
+
const profile = selection.provider === "github-copilot-preview" ? void 0 : profileFacts(readSettingsNamespace(ctx, LLM_PI_AI_NAMESPACE), selection.provider, selection.model);
|
|
185
212
|
const catalog = catalogModelFacts(ctx, selection.provider, selection.model);
|
|
186
213
|
return {
|
|
187
214
|
provider: selection.provider,
|
|
@@ -760,4 +787,4 @@ async function routeSessionSearch(request, signal, deps) {
|
|
|
760
787
|
};
|
|
761
788
|
}
|
|
762
789
|
//#endregion
|
|
763
|
-
export { currentSearchInitiator as C,
|
|
790
|
+
export { GITHUB_COPILOT_PREVIEW_PROVIDER_ID as A, currentSearchInitiator as C, isPluginPreviewProvider as D, readSettingsNamespace as E, readCopilotCatalog as O, currentChatRoute as S, onSettingsNamespaceUpdated as T, RESPONSES_WEB_SEARCH_TOOL_TYPE as _, COPILOT_HOSTED_SEARCH_PROVIDER_ID as a, candidatesForRoute as b, abortable as c, readBounded as d, applyRequestAuth as f, GITHUB_COPILOT_CREDENTIAL_KEY as g, ANTHROPIC_WEB_SEARCH_TOOL_TYPE as h, describeSearchBackend as i, GITHUB_COPILOT_PROVIDER_ID as j, GITHUB_COPILOT_CREDENTIAL_KEY$1 as k, isAbortError as l, providerRequestHeaders as m, routeSessionSearch as n, GITHUB_COPILOT_HOSTED_SEARCH_PROVIDER_ID as o, normalizeRequestAuth as p, DescribedSearchFallbackError as r, createTraditionalSearchProvider as s, isCopilotSearchSelection as t, providerErrorMessage as u, SearchPlan as v, currentSearchSelection as w, sameCandidates as x, WEB_SEARCH_TOOL_TYPE as y };
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { Context } from '@deepseek-ai/cordis';
|
|
8
8
|
export declare const DSH_COMPATIBILITY: {
|
|
9
|
-
readonly release: "0.
|
|
10
|
-
readonly developmentRelease: "0.
|
|
11
|
-
readonly peerRange: "0.
|
|
12
|
-
readonly supportedReleases: readonly ["0.
|
|
13
|
-
readonly requiredApis: readonly ["agentDefaultModel.currentSelection", "authorization.describe", "authorization.begin", "authorization.cancel", "credentials.describeRecord", "credentials.readRecord", "credentials.listRecords", "credentials.modifyRecord", "credentials.deleteRecord", "settings.
|
|
9
|
+
readonly release: "0.2.0-rc.1";
|
|
10
|
+
readonly developmentRelease: "0.2.0-rc.1";
|
|
11
|
+
readonly peerRange: "0.2.0-rc.1";
|
|
12
|
+
readonly supportedReleases: readonly ["0.2.0-rc.1"];
|
|
13
|
+
readonly requiredApis: readonly ["agentDefaultModel.currentSelection", "authorization.describe", "authorization.begin", "authorization.cancel", "credentials.describeRecord", "credentials.readRecord", "credentials.listRecords", "credentials.modifyRecord", "credentials.deleteRecord", "settings.describe", "settings.mutate", "web.registerSearchProvider", "systemPrompt.section", "context.on", "context.effect", "context.plugin"];
|
|
14
14
|
};
|
|
15
15
|
/** Assert every required Core service shape before registering any effects. */
|
|
16
16
|
export declare function assertDshCompatibility(ctx: Context): void;
|
package/lib/types/config.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import z from '@deepseek-ai/schemastery';
|
|
8
8
|
import type { RequestBudgetPolicy } from './request-budget.ts';
|
|
9
|
+
import type { WebSearchRoutingConfig } from './web-search-routing-config.ts';
|
|
9
10
|
/** Plugin configuration. Defaults make the current chat route decide. */
|
|
10
11
|
export interface InlineConfig {
|
|
11
12
|
/** Master switch; false sends every request down the normal adapter path. */
|
|
@@ -41,6 +42,8 @@ export interface InlineConfig {
|
|
|
41
42
|
searchFallback?: 'none' | 'deepseek';
|
|
42
43
|
/** Optional authoritative legacy override; otherwise hosted search resolves bounded account-owned candidates independently of Chat. */
|
|
43
44
|
searchModel?: string;
|
|
45
|
+
/** Provider routing folded into this plugin entry on current Core releases. */
|
|
46
|
+
searchRouting?: WebSearchRoutingConfig;
|
|
44
47
|
/** Internal JSON backup of route leaves temporarily owned by the GPT-6 overlay. */
|
|
45
48
|
temporaryRouteBackup?: string;
|
|
46
49
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Provider, AssistantMessageEventStream } from '@earendil-works/pi-ai';
|
|
2
2
|
import type { ResolvedPiAiProviderProfile } from '@deepseek-ai/dsh-llm-pi-ai';
|
|
3
|
-
export type CoreCompatibleProvider = ResolvedPiAiProviderProfile['piProvider']
|
|
3
|
+
export type CoreCompatibleProvider = NonNullable<ResolvedPiAiProviderProfile['piProvider']>;
|
|
4
4
|
export type SimpleNativeProvider = Pick<Provider, 'id' | 'name' | 'baseUrl' | 'headers' | 'auth' | 'getModels' | 'filterModels' | 'streamSimple'>;
|
|
5
5
|
type CoreStream = ReturnType<CoreCompatibleProvider['streamSimple']>;
|
|
6
6
|
type PublicCoreStream = Pick<CoreStream, keyof CoreStream>;
|
|
@@ -9,11 +9,11 @@ export type RouteMutation = {
|
|
|
9
9
|
readonly path: string[];
|
|
10
10
|
};
|
|
11
11
|
export interface RouteSettings {
|
|
12
|
-
get(namespace: string): unknown;
|
|
13
12
|
describe(options?: {
|
|
14
13
|
redactSecrets?: boolean;
|
|
15
14
|
}): Array<{
|
|
16
15
|
ns: string;
|
|
16
|
+
value: unknown;
|
|
17
17
|
revision: number;
|
|
18
18
|
user?: unknown;
|
|
19
19
|
base?: unknown;
|