dsh-github-copilot 0.1.0-alpha.2.dsh.0.2.2.rc.3 → 0.1.0-alpha.3.dsh.0.2.2.rc.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/AGENTS.md +9 -0
- package/CHANGELOG.md +6 -0
- package/README.md +14 -6
- package/README.zh.md +12 -5
- package/deployment-baseline.json +7 -2
- package/docs/auto-review-sampling.md +21 -1
- package/lib/client.js +1 -1
- package/lib/index.js +400 -58
- package/lib/routed-web.js +1 -1
- package/lib/{traditional-search-BZpWOTZA.js → traditional-search-CgIL4oRu.js} +36 -2
- package/lib/types/native-copilot-access.d.ts +16 -0
- package/lib/types/native-copilot-search.d.ts +5 -0
- package/lib/types/traditional-search.d.ts +3 -1
- package/package.json +1 -1
- package/scripts/check-search-composition.mjs +0 -1
package/AGENTS.md
CHANGED
|
@@ -31,6 +31,15 @@ Use native DSH tools for goals, background jobs and scoped subagents. Use local
|
|
|
31
31
|
|
|
32
32
|
### Confirmed product scope (#455, #456)
|
|
33
33
|
|
|
34
|
+
The native enhancement request (#460/#461) adds only reviewer-scoped Responses
|
|
35
|
+
sampling compatibility and an optional canonical-account hosted-search backend.
|
|
36
|
+
Use public native ownership/configuration proof and prepared dispatch; never
|
|
37
|
+
replace Web, select a backend, migrate accounts/settings, or bypass review.
|
|
38
|
+
Search permits one fixed capability proof and one final query within 25 seconds,
|
|
39
|
+
with four concurrent operations and configuration/credential/disposal fences.
|
|
40
|
+
The former plugin routing UI and managed Auto remain retired. Supplier calls,
|
|
41
|
+
live installation and restarts are separate from synthetic CI acceptance.
|
|
42
|
+
|
|
34
43
|
The user-confirmed direction on 2026-11-14 supersedes conflicting legacy feature
|
|
35
44
|
requirements below: this plugin is a lightweight GitHub Copilot model integration
|
|
36
45
|
for DSH Desktop, not a second agent product. The qualification target is the exact
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.0-alpha.3.dsh.0.2.2.rc.3 (prepared)
|
|
4
|
+
|
|
5
|
+
- Extend reviewer-only temperature omission to qualified DSH native `github-copilot` Responses calls, preserving ordinary Chat and native verdict/permission ownership (#460).
|
|
6
|
+
- Add optional canonical-account Copilot hosted search through the existing native Web registry, with one bounded proof and one final query, cancellation and configuration/credential invalidation (#461).
|
|
7
|
+
- Preserve native settings, selected backends, accounts and histories. No live installation, restart or supplier acceptance is implied.
|
|
8
|
+
|
|
3
9
|
## 0.1.0-alpha.2.dsh.0.2.2.rc.3 (prepared)
|
|
4
10
|
|
|
5
11
|
- Explain the native provider's canonical OAuth binding and the existing additional-account coexistence limit, while retaining the visible account panel outside the native Add draft (#458).
|
package/README.md
CHANGED
|
@@ -67,15 +67,15 @@ After the exact compatible release is available and verified, download its
|
|
|
67
67
|
original asset and checksum in an empty directory:
|
|
68
68
|
|
|
69
69
|
```sh
|
|
70
|
-
curl -fLO https://github.com/cloga/dsh-github-copilot/releases/download/v0.1.0-alpha.
|
|
71
|
-
curl -fLO https://github.com/cloga/dsh-github-copilot/releases/download/v0.1.0-alpha.
|
|
70
|
+
curl -fLO https://github.com/cloga/dsh-github-copilot/releases/download/v0.1.0-alpha.3.dsh.0.2.2.rc.3/dsh-github-copilot-0.1.0-alpha.3.dsh.0.2.2.rc.3.tgz
|
|
71
|
+
curl -fLO https://github.com/cloga/dsh-github-copilot/releases/download/v0.1.0-alpha.3.dsh.0.2.2.rc.3/SHA256SUMS
|
|
72
72
|
sha256sum --check SHA256SUMS
|
|
73
73
|
```
|
|
74
74
|
|
|
75
75
|
For the `web` profile, install the same Release asset:
|
|
76
76
|
|
|
77
77
|
```sh
|
|
78
|
-
dsh plugin --profile web add https://github.com/cloga/dsh-github-copilot/releases/download/v0.1.0-alpha.
|
|
78
|
+
dsh plugin --profile web add https://github.com/cloga/dsh-github-copilot/releases/download/v0.1.0-alpha.3.dsh.0.2.2.rc.3/dsh-github-copilot-0.1.0-alpha.3.dsh.0.2.2.rc.3.tgz
|
|
79
79
|
```
|
|
80
80
|
|
|
81
81
|
Choose the intended profile explicitly. Then:
|
|
@@ -100,9 +100,17 @@ additional-account requests and switching. The native picker is not guaranteed
|
|
|
100
100
|
to filter its bundled catalog by account entitlement.
|
|
101
101
|
Starting the plugin or completing sign-in does not automatically repair the
|
|
102
102
|
native provider's settings.
|
|
103
|
-
The
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
The plugin registers optional `github-copilot-hosted` search in DSH's existing
|
|
104
|
+
Web service. Select it explicitly in native Web settings and enable the native
|
|
105
|
+
search tool as needed; installation does not change the selected backend.
|
|
106
|
+
Search uses only the canonical OAuth account and models shared by the native
|
|
107
|
+
configured catalog and current account metadata. Each search makes one fixed
|
|
108
|
+
capability probe and, only after proof, one user query; both may incur charges.
|
|
109
|
+
Custom endpoint, credential or transport overrides and unproven models remain
|
|
110
|
+
unavailable. There is no model retry, backend replacement or plugin routing UI.
|
|
111
|
+
The native Auto reviewer's qualified Copilot Responses requests omit
|
|
112
|
+
`temperature`; ordinary Chat and native allow/deny/error/cancel behavior remain
|
|
113
|
+
unchanged. See [reviewer compatibility](./docs/auto-review-sampling.md).
|
|
106
114
|
The native route's quota display uses only the canonical OAuth account. If the
|
|
107
115
|
provider names a credential, endpoint or nonempty headers override, or its configuration
|
|
108
116
|
cannot be verified, quota is shown as unavailable rather than attributed to a
|
package/README.zh.md
CHANGED
|
@@ -55,15 +55,15 @@ node scripts/select-core-release.mjs 0.2.2-rc.3
|
|
|
55
55
|
精确兼容版本发布且通过验证后,在空目录下载原始制品并校验:
|
|
56
56
|
|
|
57
57
|
```sh
|
|
58
|
-
curl -fLO https://github.com/cloga/dsh-github-copilot/releases/download/v0.1.0-alpha.
|
|
59
|
-
curl -fLO https://github.com/cloga/dsh-github-copilot/releases/download/v0.1.0-alpha.
|
|
58
|
+
curl -fLO https://github.com/cloga/dsh-github-copilot/releases/download/v0.1.0-alpha.3.dsh.0.2.2.rc.3/dsh-github-copilot-0.1.0-alpha.3.dsh.0.2.2.rc.3.tgz
|
|
59
|
+
curl -fLO https://github.com/cloga/dsh-github-copilot/releases/download/v0.1.0-alpha.3.dsh.0.2.2.rc.3/SHA256SUMS
|
|
60
60
|
sha256sum --check SHA256SUMS
|
|
61
61
|
```
|
|
62
62
|
|
|
63
63
|
例如安装到 `web` profile:
|
|
64
64
|
|
|
65
65
|
```sh
|
|
66
|
-
dsh plugin --profile web add https://github.com/cloga/dsh-github-copilot/releases/download/v0.1.0-alpha.
|
|
66
|
+
dsh plugin --profile web add https://github.com/cloga/dsh-github-copilot/releases/download/v0.1.0-alpha.3.dsh.0.2.2.rc.3/dsh-github-copilot-0.1.0-alpha.3.dsh.0.2.2.rc.3.tgz
|
|
67
67
|
```
|
|
68
68
|
|
|
69
69
|
请明确选择目标 profile,然后:
|
|
@@ -82,8 +82,15 @@ dsh plugin --profile web add https://github.com/cloga/dsh-github-copilot/release
|
|
|
82
82
|
附加账号。在托管路线仍然注册的期间,保存原生 provider 可能阻止附加账号的请求
|
|
83
83
|
和切换。原生选择器不保证按账号权限过滤内置模型目录。
|
|
84
84
|
启动插件或完成登录时,不会自动修复原生 provider 设置。
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
插件在 DSH 现有 Web 服务中注册可选的 `github-copilot-hosted` 搜索后端。
|
|
86
|
+
请在原生 Web 设置中明确选择,并按需启用原生搜索工具;安装不会改变默认后端。
|
|
87
|
+
搜索只使用 canonical OAuth 账号,以及原生配置目录与当前账号元数据共同支持的模型。
|
|
88
|
+
每次先发送一个固定能力探测,证明可用后才发送一次用户查询;两者均可能产生费用。
|
|
89
|
+
自定义端点、凭据或传输覆盖,以及无法确认的模型,保持不可用。没有自动换模型重试、
|
|
90
|
+
Web 服务替换或旧插件路由 UI。
|
|
91
|
+
原生 Auto reviewer 经确认的 Copilot Responses 审核请求会省略 `temperature`;
|
|
92
|
+
普通聊天和原生 allow/deny/error/cancel 行为不变。参见
|
|
93
|
+
[审核兼容说明](./docs/auto-review-sampling.md)。
|
|
87
94
|
原生路线的额度显示只使用 canonical OAuth 账号;如果 provider 指定了其他凭据、
|
|
88
95
|
端点或非空请求头,或无法确认其配置,则显示额度不可用,不会将其他账号的额度归到原生路线。
|
|
89
96
|
这不证明单次请求实际计费的账号。
|
package/deployment-baseline.json
CHANGED
|
@@ -8,14 +8,14 @@
|
|
|
8
8
|
},
|
|
9
9
|
"package": {
|
|
10
10
|
"name": "dsh-github-copilot",
|
|
11
|
-
"version": "0.1.0-alpha.
|
|
11
|
+
"version": "0.1.0-alpha.3.dsh.0.2.2.rc.3"
|
|
12
12
|
},
|
|
13
13
|
"releaseLines": [
|
|
14
14
|
{ "core": "0.2.0-rc.2", "version": "0.4.2-alpha.15", "status": "published" },
|
|
15
15
|
{ "core": "0.2.1-alpha.4", "version": "0.4.2-alpha.16", "status": "published" },
|
|
16
16
|
{ "core": "0.2.1-alpha.5", "version": "0.1.0-alpha.2.dsh.0.2.1.alpha.5", "status": "published" },
|
|
17
17
|
{ "core": "0.2.1-rc.3", "version": "0.1.0-alpha.5.dsh.0.2.1.rc.3", "status": "published" },
|
|
18
|
-
{ "core": "0.2.2-rc.3", "version": "0.1.0-alpha.
|
|
18
|
+
{ "core": "0.2.2-rc.3", "version": "0.1.0-alpha.3.dsh.0.2.2.rc.3", "status": "pending" }
|
|
19
19
|
],
|
|
20
20
|
"evidence": {
|
|
21
21
|
"kind": "source-and-synthetic-test-inventory",
|
|
@@ -1022,10 +1022,15 @@
|
|
|
1022
1022
|
{"file": "src/preview-provider.ts", "marker": "guard.responsesOmitTemperature === true"},
|
|
1023
1023
|
{"file": "src/index.ts", "marker": "ctx.effect(() => installAutoReviewSampling(ctx))"},
|
|
1024
1024
|
{"file": "src/auto-review-sampling.ts", "marker": "module.apply === fiber.runtime.callback"},
|
|
1025
|
+
{"file": "src/native-copilot-access.ts", "marker": "captureNativeCopilot"},
|
|
1026
|
+
{"file": "src/native-copilot-search.ts", "marker": "createNativeCopilotSearch"},
|
|
1025
1027
|
{"file": "vitest.auto-review-published.config.ts", "marker": "passWithNoTests: false"},
|
|
1026
1028
|
{"file": "scripts/verify-tagged-core.mjs", "marker": "tests/fixtures/auto-review-copilot-core.fixture.ts"}
|
|
1027
1029
|
],
|
|
1028
1030
|
"tests": [
|
|
1031
|
+
{"file": "tests/native-copilot-access.spec.ts", "name": "uses the published catalog only within the native configured model set"},
|
|
1032
|
+
{"file": "tests/native-copilot-search.spec.ts", "name": "sends one fixed proof and one user query using the canonical account"},
|
|
1033
|
+
{"file": "tests/fixtures/auto-review-copilot-core.fixture.ts", "name": "uses the actual canonical adapter without changing the native %s boundary"},
|
|
1029
1034
|
{"file": "tests/config.spec.ts", "name": "keeps managed Responses temperature omission default-off and boolean-only"},
|
|
1030
1035
|
{"file": "tests/preview-provider.spec.ts", "name": "applies explicit Responses omission=%s independently of thinking metadata %j"},
|
|
1031
1036
|
{"file": "tests/preview-provider.spec.ts", "name": "preserves default Responses temperature regardless of thinking metadata %j"},
|
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# Native Auto reviewer sampling compatibility
|
|
2
2
|
|
|
3
|
+
## Canonical native route (DSH 0.2.2-rc.3)
|
|
4
|
+
|
|
5
|
+
The same reviewer-only policy also covers `github-copilot` when the public
|
|
6
|
+
Loader root, native adapter package callback, configurable-provider directory,
|
|
7
|
+
settings revision and exact shared pi-ai 1.3.0 catalog prove a native Responses
|
|
8
|
+
route. It requires `purpose: 'auto-review'` and excludes loop-owned requests.
|
|
9
|
+
Custom credential, endpoint and compatibility overrides remain native; unknown
|
|
10
|
+
models are diagnosed, never assigned a guessed protocol.
|
|
11
|
+
|
|
12
|
+
The auxiliary request is cloned without temperature and prepared through public
|
|
13
|
+
`llm.prepareCall`. Identity and configuration are checked again after awaits,
|
|
14
|
+
and the prepared generation is dispatched once. Preparation failures, cancellation
|
|
15
|
+
and revocation never trigger a fallback or resend. The canonical fixture uses
|
|
16
|
+
the actual native pi-ai adapter and reviewer/tool pipeline with synthetic HTTP
|
|
17
|
+
responses for allow, deny, malformed verdict, HTTP error and cancellation.
|
|
18
|
+
Disposing the enhancement reproduces the unsupported-temperature failure.
|
|
19
|
+
These are synthetic acceptance requirements, not proof of live supplier access.
|
|
20
|
+
|
|
21
|
+
## Managed-route compatibility
|
|
22
|
+
|
|
3
23
|
The plugin automatically omits `temperature` only from a supported official DSH
|
|
4
24
|
Auto reviewer root's account-proven managed `openai-responses`
|
|
5
25
|
requests. No user opt-in is required. Concurrent ordinary Chat, even on the same
|
|
@@ -41,7 +61,7 @@ Plugin disposal revokes its listener and in-flight scoped dispatch.
|
|
|
41
61
|
|
|
42
62
|
## Scope and evidence limits
|
|
43
63
|
|
|
44
|
-
|
|
64
|
+
Unqualified canonical Copilot, other providers/protocols, aliases, descendants,
|
|
45
65
|
impostor callbacks and unresolved identity remain native. Unqualified reviewer
|
|
46
66
|
identity reports bounded fixed-code Host diagnostics, not a broad omission
|
|
47
67
|
fallback. Missing optional reviewer packages do not prevent ordinary startup.
|
package/lib/client.js
CHANGED
|
@@ -7639,7 +7639,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
7639
7639
|
};
|
|
7640
7640
|
//#endregion
|
|
7641
7641
|
//#region package.json
|
|
7642
|
-
var version = "0.1.0-alpha.
|
|
7642
|
+
var version = "0.1.0-alpha.3.dsh.0.2.2.rc.3";
|
|
7643
7643
|
//#endregion
|
|
7644
7644
|
//#region lib/types/diagnostics-client.js
|
|
7645
7645
|
let owner;
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as autoModelPreference, n as GITHUB_COPILOT_PREVIEW_PROVIDER_ID, r as GITHUB_COPILOT_PROVIDER_ID, t as GITHUB_COPILOT_CREDENTIAL_KEY } from "./copilot-identity-BF8J8-9O.js";
|
|
2
2
|
import { C as normalizeExcludedModelIds, S as excludedModelSet, _ as AUTO_ALLOCATION_POLICIES, b as normalizeHighCostModelIds, c as DiagnosticsViewSchema, d as diagnosticsReason, f as CredentialChangeSchema, g as emptyAutoAllocationDiagnostics, h as AutoAllocationDiagnosticsCollector, i as DIAGNOSTICS_RETENTION_MS, l as diagnosticsBucket, m as RequestDiagnosticSchema, o as DiagnosticsRowSchema, p as REQUEST_DIAGNOSTICS_RETENTION_MS, s as DiagnosticsSnapshotSchema, u as diagnosticsOutcome, v as AUTO_ALLOCATION_POLICY, x as ModelExclusionTurns, y as AutoAllocationSchema } from "./diagnostics-types-eEWwFOFD.js";
|
|
3
|
-
import {
|
|
3
|
+
import { i as currentSearchInitiator, n as GITHUB_COPILOT_HOSTED_SEARCH_PROVIDER_ID, o as abortable$1, r as normalizeSearchResponse, s as isPluginPreviewProvider, t as COPILOT_HOSTED_SEARCH_PROVIDER_ID } from "./traditional-search-CgIL4oRu.js";
|
|
4
4
|
import { a as selectCompactionReasoning, i as resolveRequestBudgetPolicy, n as assessRequestBudget, r as calculateRequestBudget, t as DEFAULT_REQUEST_BUDGET_POLICY } from "./request-budget-DLY_aRq0.js";
|
|
5
5
|
import { Remote, RemoteError, TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
|
|
6
6
|
import { z } from "zod";
|
|
@@ -16,7 +16,8 @@ import { githubCopilotProvider } from "@earendil-works/pi-ai/providers/github-co
|
|
|
16
16
|
import { symbols } from "@deepseek-ai/cordis";
|
|
17
17
|
import { getBuiltinModels } from "@earendil-works/pi-ai/providers/all";
|
|
18
18
|
import { credentialKey } from "@deepseek-ai/dsh-credentials";
|
|
19
|
-
import {
|
|
19
|
+
import { WebError } from "@deepseek-ai/dsh-web";
|
|
20
|
+
import { CONTEXT_WINDOW_EXCEEDED_CODE, LlmError, ReasoningEffortId, attributionHeaders, callConfigEquals, isAgentLoopRequest, resolveImageAttachmentAccess, resolveRetryPolicy } from "@deepseek-ai/dsh-llm";
|
|
20
21
|
import { buildCopilotDynamicHeaders, hasCopilotVisionInput } from "@earendil-works/pi-ai/api/github-copilot-headers";
|
|
21
22
|
import { setImmediate } from "node:timers/promises";
|
|
22
23
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
@@ -24,6 +25,7 @@ import { channel } from "node:diagnostics_channel";
|
|
|
24
25
|
import { constants, gzip } from "node:zlib";
|
|
25
26
|
import { Config as Config$1, PiAiAdapter } from "@deepseek-ai/dsh-llm-pi-ai";
|
|
26
27
|
import { estimateContextTokens, estimateMessageTokens } from "@earendil-works/pi-ai/utils/estimate";
|
|
28
|
+
import { pathToFileURL } from "node:url";
|
|
27
29
|
//#region lib/types/diagnostics-collector.js
|
|
28
30
|
const noop = {
|
|
29
31
|
stage() {},
|
|
@@ -615,7 +617,7 @@ const result$1 = strictRemoteCodec("dsh-github-copilot#DiagnosticsView", Diagnos
|
|
|
615
617
|
var package_default = {
|
|
616
618
|
name: "dsh-github-copilot",
|
|
617
619
|
description: "Account-aware GitHub Copilot models for DeepSeek Harness through its published native adapter.",
|
|
618
|
-
version: "0.1.0-alpha.
|
|
620
|
+
version: "0.1.0-alpha.3.dsh.0.2.2.rc.3",
|
|
619
621
|
releaseNotes: "CHANGELOG.md",
|
|
620
622
|
publishConfig: {
|
|
621
623
|
"access": "public",
|
|
@@ -2569,7 +2571,7 @@ var Budget = class {
|
|
|
2569
2571
|
if (this.consumed > ACCOUNT_MODEL_CATALOG_LIMITS.maxBytes) fail$1("CATALOG_TOO_LARGE", true);
|
|
2570
2572
|
}
|
|
2571
2573
|
};
|
|
2572
|
-
function record$
|
|
2574
|
+
function record$12(value, code) {
|
|
2573
2575
|
if (typeof value !== "object" || value === null || Array.isArray(value)) fail$1(code);
|
|
2574
2576
|
return value;
|
|
2575
2577
|
}
|
|
@@ -2622,11 +2624,11 @@ function normalizeModel(raw, id, options, budget) {
|
|
|
2622
2624
|
if (options.availableModelIds?.has(id) !== true) fail$1("MISSING_POLICY");
|
|
2623
2625
|
policySource = "account-available-id";
|
|
2624
2626
|
} else {
|
|
2625
|
-
if (text$1(field(record$
|
|
2627
|
+
if (text$1(field(record$12(rawPolicy, "INVALID_POLICY"), "state", budget), 64, "INVALID_POLICY", budget) !== "enabled") fail$1("POLICY_NOT_ENABLED");
|
|
2626
2628
|
policySource = "server-enabled";
|
|
2627
2629
|
}
|
|
2628
|
-
const capabilities = record$
|
|
2629
|
-
const supports = record$
|
|
2630
|
+
const capabilities = record$12(field(raw, "capabilities", budget), "INVALID_CAPABILITIES");
|
|
2631
|
+
const supports = record$12(field(capabilities, "supports", budget), "INVALID_SUPPORTS");
|
|
2630
2632
|
const streaming = field(supports, "streaming", budget);
|
|
2631
2633
|
if (streaming === false) fail$1("STREAMING_UNSUPPORTED");
|
|
2632
2634
|
if (streaming !== true) fail$1("INVALID_SUPPORTS");
|
|
@@ -2647,7 +2649,7 @@ function normalizeModel(raw, id, options, budget) {
|
|
|
2647
2649
|
if (selected === void 0) fail$1(unsupportedEndpointCount === 0 && endpoints.includes("ws:/responses") ? "WEBSOCKET_ONLY" : "UNSUPPORTED_ENDPOINTS");
|
|
2648
2650
|
const rawLimits = field(capabilities, "limits", budget);
|
|
2649
2651
|
if (rawLimits === void 0) fail$1("MISSING_LIMITS");
|
|
2650
|
-
const limits = record$
|
|
2652
|
+
const limits = record$12(rawLimits, "INVALID_LIMITS");
|
|
2651
2653
|
const maxContext = optionalPositive(limits, "max_context_window_tokens", "INVALID_LIMITS", budget);
|
|
2652
2654
|
const maxInputTokens = optionalPositive(limits, "max_prompt_tokens", "INVALID_LIMITS", budget);
|
|
2653
2655
|
if (maxContext === void 0 && maxInputTokens === void 0) fail$1("MISSING_CONTEXT_LIMIT");
|
|
@@ -2665,7 +2667,7 @@ function normalizeModel(raw, id, options, budget) {
|
|
|
2665
2667
|
if (vision === true) {
|
|
2666
2668
|
const rawVisionLimits = field(limits, "vision", budget);
|
|
2667
2669
|
if (rawVisionLimits !== void 0) {
|
|
2668
|
-
const rawMediaTypes = field(record$
|
|
2670
|
+
const rawMediaTypes = field(record$12(rawVisionLimits, "INVALID_VISION_LIMITS"), "supported_media_types", budget);
|
|
2669
2671
|
if (rawMediaTypes !== void 0) {
|
|
2670
2672
|
const mediaTypes = stringList(rawMediaTypes, ACCOUNT_MODEL_CATALOG_LIMITS.maxMediaTypes, 128, "INVALID_VISION_LIMITS", budget);
|
|
2671
2673
|
const mime = /^[a-z0-9][a-z0-9!#$%&'*+.^_`|~-]*\/[a-z0-9][a-z0-9!#$%&'*+.^_`|~-]*$/iu;
|
|
@@ -2727,7 +2729,7 @@ function normalizeAccountModelCatalog(raw, options = {}) {
|
|
|
2727
2729
|
fail$1("INVALID_JSON", true);
|
|
2728
2730
|
}
|
|
2729
2731
|
}
|
|
2730
|
-
const data = field(record$
|
|
2732
|
+
const data = field(record$12(raw, "INVALID_CATALOG"), "data", budget);
|
|
2731
2733
|
if (!Array.isArray(data)) fail$1("INVALID_CATALOG");
|
|
2732
2734
|
const count = field(data, "length", budget);
|
|
2733
2735
|
if (typeof count !== "number" || !Number.isSafeInteger(count) || count < 0) fail$1("INVALID_CATALOG");
|
|
@@ -2750,7 +2752,7 @@ function normalizeAccountModelCatalog(raw, options = {}) {
|
|
|
2750
2752
|
for (let index = 0; index < count; index++) {
|
|
2751
2753
|
let id;
|
|
2752
2754
|
try {
|
|
2753
|
-
const candidate = record$
|
|
2755
|
+
const candidate = record$12(field(data, String(index), budget), "INVALID_MODEL");
|
|
2754
2756
|
const candidateId = text$1(field(candidate, "id", budget), ACCOUNT_MODEL_CATALOG_LIMITS.maxIdLength, "INVALID_ID", budget);
|
|
2755
2757
|
if (!identifier.test(candidateId)) fail$1("INVALID_ID");
|
|
2756
2758
|
id = candidateId;
|
|
@@ -4181,7 +4183,7 @@ function formatRequestUploadEvidence(evidence) {
|
|
|
4181
4183
|
//#endregion
|
|
4182
4184
|
//#region lib/types/request-body-timeout.js
|
|
4183
4185
|
const observedMessage = "Timed out reading request body. Try again, or use a smaller request size.";
|
|
4184
|
-
function record$
|
|
4186
|
+
function record$11(value) {
|
|
4185
4187
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4186
4188
|
}
|
|
4187
4189
|
function correlation(response, dispatch) {
|
|
@@ -4199,9 +4201,9 @@ function correlation(response, dispatch) {
|
|
|
4199
4201
|
async function requestBodyTimeoutDiagnostic(response, body, signal, dispatch) {
|
|
4200
4202
|
if (response.status !== 408 || signal?.aborted) return void 0;
|
|
4201
4203
|
const value = await readResponseErrorJson(response, signal);
|
|
4202
|
-
if (signal?.aborted || !record$
|
|
4204
|
+
if (signal?.aborted || !record$11(value)) return void 0;
|
|
4203
4205
|
const error = Object.hasOwn(value, "error") ? value.error : value;
|
|
4204
|
-
if (!record$
|
|
4206
|
+
if (!record$11(error) || error.code !== "user_request_timeout" || error.message !== observedMessage || value.code !== void 0 && value.code !== error.code || value.message !== void 0 && value.message !== error.message) return void 0;
|
|
4205
4207
|
const compression = dispatch?.compression;
|
|
4206
4208
|
const encoding = compression?.encoding === "gzip" ? ` Encoded body: ${compression.wireBytes} gzip bytes (prepared HTTP body, excluding transport framing; not confirmed delivered bytes). Lossless content encoding does not reduce context tokens or prove remote receipt.` : compression !== void 0 && compression.reason !== "disabled" ? ` Request compression not applied: ${compression.reason}; original request retained.` : "";
|
|
4207
4209
|
const size = body === void 0 ? "Request body size unavailable." : `Request body${compression?.encoding === "gzip" ? " (original JSON)" : ""}: ${Buffer.byteLength(body, "utf8")} UTF-8 bytes (not context tokens).`;
|
|
@@ -7208,7 +7210,7 @@ const usageSchema = z.object({
|
|
|
7208
7210
|
totalTokens: count$2.optional(),
|
|
7209
7211
|
reasoningTokens: count$2.optional()
|
|
7210
7212
|
});
|
|
7211
|
-
function record$
|
|
7213
|
+
function record$10(value) {
|
|
7212
7214
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7213
7215
|
}
|
|
7214
7216
|
function sameRoute(left, right) {
|
|
@@ -7230,7 +7232,7 @@ function initialContextEvidence() {
|
|
|
7230
7232
|
}
|
|
7231
7233
|
/** Read only counts and routing leaves; never message content or opaque replay. */
|
|
7232
7234
|
function foldContextEvidence(state, event) {
|
|
7233
|
-
if (!record$
|
|
7235
|
+
if (!record$10(event) || typeof event.type !== "string" || !record$10(event.data)) return state;
|
|
7234
7236
|
if (event.type === "step/start") {
|
|
7235
7237
|
const step = stepSchema.safeParse({
|
|
7236
7238
|
turn: event.data.turn,
|
|
@@ -7292,7 +7294,7 @@ function foldContextEvidence(state, event) {
|
|
|
7292
7294
|
};
|
|
7293
7295
|
const operation = state.compaction;
|
|
7294
7296
|
if (operation?.state === "running" && count$2.safeParse(event.seq).success && Number(event.seq) > operation.startSeq) {
|
|
7295
|
-
if (event.type === "user/message" && record$
|
|
7297
|
+
if (event.type === "user/message" && record$10(event.data.source) && event.data.source.kind === "compact-checkpoint" && event.data.source.compactionId === operation.id) state = {
|
|
7296
7298
|
...state,
|
|
7297
7299
|
compaction: {
|
|
7298
7300
|
...operation,
|
|
@@ -7309,7 +7311,7 @@ function foldContextEvidence(state, event) {
|
|
|
7309
7311
|
};
|
|
7310
7312
|
}
|
|
7311
7313
|
if (event.type === "request/header" || event.type === "model/selection") {
|
|
7312
|
-
const raw = event.type === "request/header" ? record$
|
|
7314
|
+
const raw = event.type === "request/header" ? record$10(event.data.header) ? event.data.header.config : void 0 : event.data;
|
|
7313
7315
|
const revoke = () => state.compaction ? {
|
|
7314
7316
|
...state.compaction,
|
|
7315
7317
|
headerSeq: null,
|
|
@@ -7317,7 +7319,7 @@ function foldContextEvidence(state, event) {
|
|
|
7317
7319
|
step: null,
|
|
7318
7320
|
request: "unknown"
|
|
7319
7321
|
} : state.compaction;
|
|
7320
|
-
if (!record$
|
|
7322
|
+
if (!record$10(raw)) return {
|
|
7321
7323
|
...state,
|
|
7322
7324
|
route: null,
|
|
7323
7325
|
sample: null,
|
|
@@ -7368,7 +7370,7 @@ function foldContextEvidence(state, event) {
|
|
|
7368
7370
|
};
|
|
7369
7371
|
}
|
|
7370
7372
|
if (event.type.startsWith("compaction/") || event.surfaceOp !== void 0 && event.surfaceOp !== "append") {
|
|
7371
|
-
const checkpoint = event.type === "user/message" && record$
|
|
7373
|
+
const checkpoint = event.type === "user/message" && record$10(event.data.source) && event.data.source.kind === "compact-checkpoint" && event.data.source.compactionId === state.compaction?.id;
|
|
7372
7374
|
return {
|
|
7373
7375
|
...state,
|
|
7374
7376
|
sample: null,
|
|
@@ -7386,9 +7388,9 @@ function foldContextEvidence(state, event) {
|
|
|
7386
7388
|
}
|
|
7387
7389
|
if (event.type !== "assistant/message" && event.type !== "assistant/attempt") return state;
|
|
7388
7390
|
if (!copilot(state.route)) return state;
|
|
7389
|
-
const source = record$
|
|
7391
|
+
const source = record$10(event.data.message) ? event.data.message.source : event.data.source;
|
|
7390
7392
|
if (event.type === "assistant/message" && source !== void 0) {
|
|
7391
|
-
const parsed = routeSchema.safeParse(record$
|
|
7393
|
+
const parsed = routeSchema.safeParse(record$10(source) ? {
|
|
7392
7394
|
provider: source.provider,
|
|
7393
7395
|
model: source.model
|
|
7394
7396
|
} : source);
|
|
@@ -7418,11 +7420,11 @@ function foldContextEvidence(state, event) {
|
|
|
7418
7420
|
const settledUsage = usage !== void 0;
|
|
7419
7421
|
let terminal;
|
|
7420
7422
|
for (const entry of stream) {
|
|
7421
|
-
if (!record$
|
|
7423
|
+
if (!record$10(entry) || entry.type !== "chunk" || !record$10(entry.chunk)) continue;
|
|
7422
7424
|
if (!settledUsage && entry.chunk.type === "usage") usage = entry.chunk.usage;
|
|
7423
7425
|
if (entry.chunk.type === "finish") terminal = entry.chunk.reason;
|
|
7424
7426
|
}
|
|
7425
|
-
const successful = event.data.interrupted !== true && record$
|
|
7427
|
+
const successful = event.data.interrupted !== true && record$10(terminal) && (terminal.kind === "stop" || terminal.kind === "max-tokens" || terminal.kind === "tool-calls");
|
|
7426
7428
|
const compact = state.compaction;
|
|
7427
7429
|
if (compact?.state === "completed") {
|
|
7428
7430
|
if (compact.headerSeq === null || !count$2.safeParse(event.seq).success || Number(event.seq) <= compact.headerSeq) return state;
|
|
@@ -7439,7 +7441,7 @@ function foldContextEvidence(state, event) {
|
|
|
7439
7441
|
...state,
|
|
7440
7442
|
compaction: {
|
|
7441
7443
|
...compact,
|
|
7442
|
-
request: event.type === "assistant/message" && successful && source !== void 0 ? "succeeded" : record$
|
|
7444
|
+
request: event.type === "assistant/message" && successful && source !== void 0 ? "succeeded" : record$10(terminal) && terminal.kind === "aborted" ? "cancelled" : record$10(terminal) && terminal.kind === "error" ? "failed" : "unknown"
|
|
7443
7445
|
}
|
|
7444
7446
|
};
|
|
7445
7447
|
} else if (compact?.state === "running") return state;
|
|
@@ -7506,7 +7508,7 @@ const contextEvidenceDefinition = {
|
|
|
7506
7508
|
function installContextEvidence(ctx) {
|
|
7507
7509
|
ctx.inject(["sessionProjections"], (scope) => {
|
|
7508
7510
|
const registry = scope.get("sessionProjections");
|
|
7509
|
-
if (!record$
|
|
7511
|
+
if (!record$10(registry) || typeof registry.register !== "function") {
|
|
7510
7512
|
scope.logger.warn("[github-copilot] COPILOT_CONTEXT_PROJECTION_UNAVAILABLE");
|
|
7511
7513
|
return;
|
|
7512
7514
|
}
|
|
@@ -8711,13 +8713,13 @@ let GitHubCopilotAuthorizationController = (() => {
|
|
|
8711
8713
|
})();
|
|
8712
8714
|
//#endregion
|
|
8713
8715
|
//#region lib/types/replay-recovery.js
|
|
8714
|
-
function record$
|
|
8716
|
+
function record$9(value) {
|
|
8715
8717
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
8716
8718
|
}
|
|
8717
8719
|
function parsed(body) {
|
|
8718
8720
|
if (requestBodyEvidence(body, "openai-responses").state !== "complete" || body === void 0) throw new Error("COPILOT_REPLAY_RECOVERY_EVIDENCE_UNAVAILABLE");
|
|
8719
8721
|
const payload = JSON.parse(body);
|
|
8720
|
-
if (!record$
|
|
8722
|
+
if (!record$9(payload) || !Array.isArray(payload.input) || !payload.input.every(record$9)) throw new Error("COPILOT_REPLAY_RECOVERY_INVALID_PAYLOAD");
|
|
8721
8723
|
return {
|
|
8722
8724
|
input: payload.input,
|
|
8723
8725
|
payload
|
|
@@ -8813,7 +8815,7 @@ var ReplayRecoveryStore = class {
|
|
|
8813
8815
|
const value = hash(item);
|
|
8814
8816
|
return value === void 0 || !admitted.has(value);
|
|
8815
8817
|
}).length === decoded.input.length) return payload;
|
|
8816
|
-
if (!record$
|
|
8818
|
+
if (!record$9(payload) || !Array.isArray(payload.input)) throw new Error("COPILOT_REPLAY_RECOVERY_INVALID_PAYLOAD");
|
|
8817
8819
|
const input = payload.input.filter((_, index) => {
|
|
8818
8820
|
const item = decoded.input[index];
|
|
8819
8821
|
const value = hash(item);
|
|
@@ -8854,18 +8856,18 @@ function isReplayScopeFailure(message) {
|
|
|
8854
8856
|
}
|
|
8855
8857
|
//#endregion
|
|
8856
8858
|
//#region lib/types/replay-failure-evidence.js
|
|
8857
|
-
function record$
|
|
8859
|
+
function record$8(value) {
|
|
8858
8860
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8859
8861
|
}
|
|
8860
8862
|
function foldReplayFailure(state, event) {
|
|
8861
|
-
if (!record$
|
|
8863
|
+
if (!record$8(event) || !Number.isSafeInteger(event.seq) || Number(event.seq) < state.inherited || !record$8(event.data)) return state;
|
|
8862
8864
|
if (event.type === "turn/start") return {
|
|
8863
8865
|
...state,
|
|
8864
8866
|
failureSeq: null
|
|
8865
8867
|
};
|
|
8866
8868
|
if (event.type !== "turn/end") return state;
|
|
8867
8869
|
const reason = event.data.reason;
|
|
8868
|
-
const failed = record$
|
|
8870
|
+
const failed = record$8(reason) && reason.kind === "error" && record$8(reason.error) && isReplayScopeFailure(reason.error.message);
|
|
8869
8871
|
return {
|
|
8870
8872
|
...state,
|
|
8871
8873
|
failureSeq: failed ? Number(event.seq) : null
|
|
@@ -8889,7 +8891,7 @@ const replayFailureDefinition = {
|
|
|
8889
8891
|
function installReplayFailureEvidence(ctx) {
|
|
8890
8892
|
const registration = ctx.inject(["sessionProjections"], (scope) => {
|
|
8891
8893
|
const registry = scope.get("sessionProjections");
|
|
8892
|
-
if (!record$
|
|
8894
|
+
if (!record$8(registry) || typeof registry.register !== "function") throw new Error("COPILOT_REPLAY_FAILURE_PROJECTION_UNAVAILABLE");
|
|
8893
8895
|
const remove = registry.register(replayFailureDefinition);
|
|
8894
8896
|
if (typeof remove !== "function") throw new Error("COPILOT_REPLAY_FAILURE_PROJECTION_DISPOSER_UNAVAILABLE");
|
|
8895
8897
|
return () => {
|
|
@@ -9089,7 +9091,7 @@ const SESSION_CONTINUATION_LIMITS = Object.freeze({
|
|
|
9089
9091
|
ciphertextCodeUnits: 67108864,
|
|
9090
9092
|
chunkCodeUnits: 65536
|
|
9091
9093
|
});
|
|
9092
|
-
function record$
|
|
9094
|
+
function record$7(value) {
|
|
9093
9095
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9094
9096
|
}
|
|
9095
9097
|
/** One admitted turn; fingerprints never become durable history or account provenance. */
|
|
@@ -9102,7 +9104,7 @@ var SessionContinuationTurn = class {
|
|
|
9102
9104
|
async transform(payload, assertCurrent = () => {}) {
|
|
9103
9105
|
assertCurrent();
|
|
9104
9106
|
if (this.processing) throw new Error("COPILOT_CONTINUATION_PROCESSING_OVERLAP");
|
|
9105
|
-
if (!record$
|
|
9107
|
+
if (!record$7(payload) || !Array.isArray(payload.input) || payload.input.length > SESSION_CONTINUATION_LIMITS.inputItems) throw new Error("COPILOT_CONTINUATION_INVALID_PAYLOAD");
|
|
9106
9108
|
this.processing = true;
|
|
9107
9109
|
try {
|
|
9108
9110
|
const hashes = /* @__PURE__ */ new Map();
|
|
@@ -9113,7 +9115,7 @@ var SessionContinuationTurn = class {
|
|
|
9113
9115
|
assertCurrent();
|
|
9114
9116
|
}
|
|
9115
9117
|
const item = payload.input[index];
|
|
9116
|
-
if (!record$
|
|
9118
|
+
if (!record$7(item)) throw new Error("COPILOT_CONTINUATION_INVALID_PAYLOAD");
|
|
9117
9119
|
if (item.type !== "reasoning") continue;
|
|
9118
9120
|
const ciphertext = item.encrypted_content;
|
|
9119
9121
|
if (typeof ciphertext !== "string" || !ciphertext || item.status !== void 0 && item.status !== "completed") throw new Error("COPILOT_CONTINUATION_UNSUPPORTED_REASONING");
|
|
@@ -9212,7 +9214,7 @@ const compactionContinuationDefinition = {
|
|
|
9212
9214
|
view: (state) => state
|
|
9213
9215
|
}
|
|
9214
9216
|
};
|
|
9215
|
-
function record$
|
|
9217
|
+
function record$6(value) {
|
|
9216
9218
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9217
9219
|
}
|
|
9218
9220
|
/** Native brackets authorize scope, never loss; the existing Session policy authorizes loss. */
|
|
@@ -9222,7 +9224,7 @@ function installCompactionContinuation(ctx, enabled) {
|
|
|
9222
9224
|
let disposed = false;
|
|
9223
9225
|
const removeProjection = ctx.inject(["sessionProjections"], (scope) => {
|
|
9224
9226
|
const registry = scope.get("sessionProjections");
|
|
9225
|
-
if (!record$
|
|
9227
|
+
if (!record$6(registry) || typeof registry.register !== "function") throw new Error("COPILOT_CONTINUATION_COMPACTION_PROJECTION_UNAVAILABLE");
|
|
9226
9228
|
const remove = registry.register(compactionContinuationDefinition);
|
|
9227
9229
|
if (typeof remove !== "function") throw new Error("COPILOT_CONTINUATION_COMPACTION_PROJECTION_DISPOSER_UNAVAILABLE");
|
|
9228
9230
|
return () => {
|
|
@@ -9678,7 +9680,7 @@ function installCompactionReplay(ctx) {
|
|
|
9678
9680
|
}
|
|
9679
9681
|
//#endregion
|
|
9680
9682
|
//#region lib/types/agent-compaction.js
|
|
9681
|
-
function record$
|
|
9683
|
+
function record$5(value) {
|
|
9682
9684
|
return typeof value === "object" && value !== null;
|
|
9683
9685
|
}
|
|
9684
9686
|
/** Resolve the owning preset's service without reaching into Core's service registry. */
|
|
@@ -9686,7 +9688,7 @@ function agentCompaction(agent) {
|
|
|
9686
9688
|
if (typeof agent.ctx?.get !== "function") throw new LlmError("COPILOT_COMPACTION_AGENT_CONTEXT_UNAVAILABLE", "INVALID_REQUEST");
|
|
9687
9689
|
const presets = agent.ctx.get("agentPresets");
|
|
9688
9690
|
if (presets !== void 0) {
|
|
9689
|
-
if (!record$
|
|
9691
|
+
if (!record$5(presets) || typeof presets.composedPreset !== "function" || typeof presets.serviceFor !== "function") throw new LlmError("COPILOT_COMPACTION_PRESET_LOOKUP_UNAVAILABLE", "INVALID_REQUEST");
|
|
9690
9692
|
const preset = presets.composedPreset(agent.ctx);
|
|
9691
9693
|
if (preset !== void 0) {
|
|
9692
9694
|
if (typeof preset !== "string" || preset.trim().length === 0) throw new LlmError("COPILOT_COMPACTION_PRESET_LOOKUP_UNAVAILABLE", "INVALID_REQUEST");
|
|
@@ -9809,14 +9811,14 @@ function installCopilotCompactionPressure(ctx, callbacks) {
|
|
|
9809
9811
|
}
|
|
9810
9812
|
//#endregion
|
|
9811
9813
|
//#region lib/types/pre-step-pressure.js
|
|
9812
|
-
function record$
|
|
9814
|
+
function record$4(value) {
|
|
9813
9815
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9814
9816
|
}
|
|
9815
9817
|
function positive(value) {
|
|
9816
9818
|
return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
9817
9819
|
}
|
|
9818
9820
|
function isEngine(value) {
|
|
9819
|
-
return record$
|
|
9821
|
+
return record$4(value) && record$4(value.config) && typeof value.compactIfNeeded === "function";
|
|
9820
9822
|
}
|
|
9821
9823
|
/**
|
|
9822
9824
|
* Prevent a continuing, unchanged route's known pressure from becoming an
|
|
@@ -9837,12 +9839,12 @@ function installCopilotPreStepPressure(ctx, callbacks) {
|
|
|
9837
9839
|
const header = agent.session.requestHeader();
|
|
9838
9840
|
if (header?.config.provider !== "github-copilot-preview" || !isPluginPreviewProvider(ctx, header.config.provider)) return decision;
|
|
9839
9841
|
const projections = ctx.get("sessionProjections");
|
|
9840
|
-
if (!record$
|
|
9842
|
+
if (!record$4(projections) || typeof projections.stateOf !== "function") {
|
|
9841
9843
|
unavailable();
|
|
9842
9844
|
return decision;
|
|
9843
9845
|
}
|
|
9844
9846
|
const selection = projections.stateOf(agent.session, "modelSelection");
|
|
9845
|
-
if (!record$
|
|
9847
|
+
if (!record$4(selection) || !Object.hasOwn(selection, "pending")) {
|
|
9846
9848
|
unavailable();
|
|
9847
9849
|
return decision;
|
|
9848
9850
|
}
|
|
@@ -9864,20 +9866,20 @@ function installCopilotPreStepPressure(ctx, callbacks) {
|
|
|
9864
9866
|
unavailable();
|
|
9865
9867
|
return decision;
|
|
9866
9868
|
}
|
|
9867
|
-
const policy = Array.isArray(config.modelPolicies) ? config.modelPolicies.find((value) => record$
|
|
9868
|
-
const retries = record$
|
|
9869
|
+
const policy = Array.isArray(config.modelPolicies) ? config.modelPolicies.find((value) => record$4(value) && value.provider === header.config.provider && value.model === header.config.model) : void 0;
|
|
9870
|
+
const retries = record$4(policy) ? policy.maxOverflowRetries ?? config.maxOverflowRetries : config.maxOverflowRetries;
|
|
9869
9871
|
if (retries === 0) return decision;
|
|
9870
9872
|
if (!positive(retries)) {
|
|
9871
9873
|
unavailable();
|
|
9872
9874
|
return decision;
|
|
9873
9875
|
}
|
|
9874
9876
|
const meter = ctx.get("tokenMeter");
|
|
9875
|
-
if (!record$
|
|
9877
|
+
if (!record$4(meter) || typeof meter.measure !== "function") {
|
|
9876
9878
|
unavailable();
|
|
9877
9879
|
return decision;
|
|
9878
9880
|
}
|
|
9879
9881
|
const measured = meter.measure(agent.session);
|
|
9880
|
-
if (!record$
|
|
9882
|
+
if (!record$4(measured) || typeof measured.totalTokens !== "number" || !Number.isSafeInteger(measured.totalTokens) || measured.totalTokens < 0) {
|
|
9881
9883
|
unavailable();
|
|
9882
9884
|
return decision;
|
|
9883
9885
|
}
|
|
@@ -10137,7 +10139,7 @@ const TurnRequestModelsStateSchema = z.object({
|
|
|
10137
10139
|
}).strict().nullable(),
|
|
10138
10140
|
turns: z.array(row).max(128)
|
|
10139
10141
|
}).strict();
|
|
10140
|
-
function record$
|
|
10142
|
+
function record$3(value) {
|
|
10141
10143
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10142
10144
|
}
|
|
10143
10145
|
const validCount = (value) => count.safeParse(value).success;
|
|
@@ -10152,14 +10154,14 @@ function uncertain(state) {
|
|
|
10152
10154
|
};
|
|
10153
10155
|
}
|
|
10154
10156
|
function foldTurnRequestModels(state, event) {
|
|
10155
|
-
if (!record$
|
|
10157
|
+
if (!record$3(event)) return state;
|
|
10156
10158
|
const lifecycle = [
|
|
10157
10159
|
"turn/start",
|
|
10158
10160
|
"turn/end",
|
|
10159
10161
|
"step/start",
|
|
10160
10162
|
"step/end"
|
|
10161
10163
|
].includes(String(event.type));
|
|
10162
|
-
if (!record$
|
|
10164
|
+
if (!record$3(event.data)) return lifecycle || event.type === "request/header" ? uncertain(state) : state;
|
|
10163
10165
|
const data = event.data;
|
|
10164
10166
|
if (lifecycle && (!validCount(data.turn) || event.type !== "turn/start" && state.active !== null && data.turn !== state.active.turn || String(event.type).startsWith("step/") && !validCount(data.step) || event.type === "step/start" && state.active?.step != null || event.type === "step/end" && state.active !== null && data.step !== state.active.step)) return uncertain(state);
|
|
10165
10167
|
if (event.type === "turn/start" && validCount(data.turn)) return {
|
|
@@ -10194,8 +10196,8 @@ function foldTurnRequestModels(state, event) {
|
|
|
10194
10196
|
active: null
|
|
10195
10197
|
};
|
|
10196
10198
|
if (event.type !== "request/header" || active.step === null) return state;
|
|
10197
|
-
const config = record$
|
|
10198
|
-
const parsed = route.safeParse(record$
|
|
10199
|
+
const config = record$3(data.header) ? data.header.config : void 0;
|
|
10200
|
+
const parsed = route.safeParse(record$3(config) && [
|
|
10199
10201
|
"initial",
|
|
10200
10202
|
"resume",
|
|
10201
10203
|
"change",
|
|
@@ -10239,7 +10241,7 @@ const turnRequestModelsDefinition = {
|
|
|
10239
10241
|
function installTurnRequestModels(ctx) {
|
|
10240
10242
|
ctx.inject(["sessionProjections"], (scope) => {
|
|
10241
10243
|
const registry = scope.get("sessionProjections");
|
|
10242
|
-
if (!record$
|
|
10244
|
+
if (!record$3(registry) || typeof registry.register !== "function") {
|
|
10243
10245
|
scope.logger.warn("[github-copilot] COPILOT_TURN_REQUEST_PROJECTION_UNAVAILABLE");
|
|
10244
10246
|
return;
|
|
10245
10247
|
}
|
|
@@ -10292,7 +10294,7 @@ var __esDecorate = function(ctor, descriptorIn, decorators, contextIn, initializ
|
|
|
10292
10294
|
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
10293
10295
|
done = true;
|
|
10294
10296
|
};
|
|
10295
|
-
function record$
|
|
10297
|
+
function record$2(value) {
|
|
10296
10298
|
return typeof value === "object" && value !== null;
|
|
10297
10299
|
}
|
|
10298
10300
|
/** Public Host binding for the existing bounded, runtime-only decision store. */
|
|
@@ -10363,7 +10365,7 @@ let TurnSelectionController = (() => {
|
|
|
10363
10365
|
requestedModels(agent, turn) {
|
|
10364
10366
|
if (!Number.isSafeInteger(turn) || turn < 0) throw new Error("COPILOT_TURN_SELECTION_INVALID_TURN");
|
|
10365
10367
|
const registry = this.ctx.get("sessionProjections");
|
|
10366
|
-
if (!record$
|
|
10368
|
+
if (!record$2(registry) || typeof registry.stateOf !== "function") throw new Error("COPILOT_TURN_REQUEST_PROJECTION_UNAVAILABLE");
|
|
10367
10369
|
const row = TurnRequestModelsStateSchema.parse(registry.stateOf(agent.session, TURN_REQUEST_MODELS)).turns.find((value) => value.turn === turn);
|
|
10368
10370
|
return row ? {
|
|
10369
10371
|
routes: row.routes,
|
|
@@ -11752,6 +11754,83 @@ var preview_route_default = {
|
|
|
11752
11754
|
apply: apply$1
|
|
11753
11755
|
};
|
|
11754
11756
|
//#endregion
|
|
11757
|
+
//#region lib/types/native-copilot-access.js
|
|
11758
|
+
const NATIVE = "@deepseek-ai/dsh-llm-pi-ai";
|
|
11759
|
+
const PI = "@earendil-works/pi-ai";
|
|
11760
|
+
const NATIVE_COPILOT = "github-copilot";
|
|
11761
|
+
function record$1(value) {
|
|
11762
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
11763
|
+
}
|
|
11764
|
+
function customTransport(value) {
|
|
11765
|
+
return [
|
|
11766
|
+
"apiKeyEnv",
|
|
11767
|
+
"baseURL",
|
|
11768
|
+
"headers",
|
|
11769
|
+
"compat"
|
|
11770
|
+
].some((key) => {
|
|
11771
|
+
const field = value[key];
|
|
11772
|
+
return field !== void 0 && field !== "" && (!record$1(field) || Object.keys(field).length > 0);
|
|
11773
|
+
});
|
|
11774
|
+
}
|
|
11775
|
+
/** Only the unchanged native catalog and its explicit native narrowing are qualified. */
|
|
11776
|
+
function nativeCopilotModels(profile) {
|
|
11777
|
+
if (!record$1(profile) || customTransport(profile)) return void 0;
|
|
11778
|
+
const configured = profile.models;
|
|
11779
|
+
if (configured !== void 0 && !Array.isArray(configured)) return void 0;
|
|
11780
|
+
if (Array.isArray(configured) && configured.some((value) => !record$1(value) || customTransport(value))) return void 0;
|
|
11781
|
+
if (record$1(profile.modelOverrides) && Object.values(profile.modelOverrides).some((value) => !record$1(value) || customTransport(value))) return void 0;
|
|
11782
|
+
const ids = Array.isArray(configured) && configured.length > 0 ? new Set(configured.filter(record$1).map((value) => value.id)) : void 0;
|
|
11783
|
+
const api = profile.api;
|
|
11784
|
+
if (api !== void 0 && api !== "" && api !== "openai-responses" && api !== "openai-completions" && api !== "anthropic-messages") return void 0;
|
|
11785
|
+
return new Map(getBuiltinModels(NATIVE_COPILOT).filter((model) => ids === void 0 || ids.has(model.id)).map((model) => [model.id, {
|
|
11786
|
+
...model,
|
|
11787
|
+
...api ? { api } : {}
|
|
11788
|
+
}]));
|
|
11789
|
+
}
|
|
11790
|
+
/**
|
|
11791
|
+
* Qualify the native Loader root and its exact published pi-ai dependency.
|
|
11792
|
+
* No credential, discovery, settings write or private adapter registry access.
|
|
11793
|
+
*/
|
|
11794
|
+
async function captureNativeCopilot(ctx, diagnose = () => {}) {
|
|
11795
|
+
const unproven = (code) => {
|
|
11796
|
+
diagnose(code);
|
|
11797
|
+
};
|
|
11798
|
+
const llm = ctx.get("llm");
|
|
11799
|
+
const settings = ctx.get("settings");
|
|
11800
|
+
const loader = ctx.get("loader");
|
|
11801
|
+
const packages = ctx.get("pluginPackages");
|
|
11802
|
+
if (!llm || !settings || !loader || !packages) return unproven("COPILOT_NATIVE_SERVICES_UNAVAILABLE");
|
|
11803
|
+
const directory = llm.listConfigurableProviders().find((value) => value.provider === NATIVE_COPILOT);
|
|
11804
|
+
if (!directory || directory.declared !== false || directory.error !== void 0 || directory.settingsPath.length !== 2 || directory.settingsPath[0] !== "providers" || directory.settingsPath[1] !== "github-copilot" || directory.nativeAuth?.oauth !== true || !llm.listProviders().some((value) => value.id === "github-copilot")) return unproven("COPILOT_NATIVE_DIRECTORY_UNPROVEN");
|
|
11805
|
+
const entries = [...loader.entries()].filter((entry) => entry.options.id === directory.settingsNs);
|
|
11806
|
+
if (entries.length !== 1) return unproven("COPILOT_NATIVE_ENTRY_UNPROVEN");
|
|
11807
|
+
const entry = entries[0];
|
|
11808
|
+
const fiber = entry.fiber?.ctx.fiber;
|
|
11809
|
+
const base = entry.parent.tree.ctx.baseUrl;
|
|
11810
|
+
if (!fiber || fiber.uid === null || entry.options.name !== NATIVE || !base) return unproven("COPILOT_NATIVE_FIBER_UNPROVEN");
|
|
11811
|
+
const owner = packages.packageOf(NATIVE, base);
|
|
11812
|
+
const importedOwner = packages.packageOf(NATIVE, import.meta.url);
|
|
11813
|
+
if (owner?.version !== "0.2.2-rc.3" || owner.manifestPath !== importedOwner?.manifestPath) return unproven("COPILOT_NATIVE_PACKAGE_UNPROVEN");
|
|
11814
|
+
const nativePi = packages.packageOf(PI, pathToFileURL(owner.manifestPath).href);
|
|
11815
|
+
const localPi = packages.packageOf(PI, import.meta.url);
|
|
11816
|
+
if (nativePi?.version !== "1.3.0" || localPi?.manifestPath !== nativePi.manifestPath) return unproven("COPILOT_NATIVE_PI_UNPROVEN");
|
|
11817
|
+
const view = () => settings.describe({ redactSecrets: true }).find((value) => value.ns === directory.settingsNs);
|
|
11818
|
+
const captured = view();
|
|
11819
|
+
if (!captured || !record$1(captured.value) || !record$1(captured.value.providers)) return unproven("COPILOT_NATIVE_SETTINGS_UNPROVEN");
|
|
11820
|
+
const models = nativeCopilotModels(captured.value.providers[NATIVE_COPILOT]);
|
|
11821
|
+
if (!models) return unproven("COPILOT_NATIVE_MODELS_UNPROVEN");
|
|
11822
|
+
const module = await import("@deepseek-ai/dsh-llm-pi-ai");
|
|
11823
|
+
const current = () => fiber.uid !== null && entry.fiber?.ctx.fiber === fiber && fiber.runtime?.callback === module.apply && entry.options.name === NATIVE && view()?.revision === captured.revision && llm.listProviders().some((value) => value.id === "github-copilot");
|
|
11824
|
+
if (!current()) return unproven("COPILOT_NATIVE_SNAPSHOT_REVOKED");
|
|
11825
|
+
return {
|
|
11826
|
+
models,
|
|
11827
|
+
namespace: directory.settingsNs,
|
|
11828
|
+
assertCurrent() {
|
|
11829
|
+
if (!current()) throw new Error("COPILOT_NATIVE_ROUTE_CHANGED");
|
|
11830
|
+
}
|
|
11831
|
+
};
|
|
11832
|
+
}
|
|
11833
|
+
//#endregion
|
|
11755
11834
|
//#region lib/types/auto-review-sampling.js
|
|
11756
11835
|
var __rewriteRelativeImportExtension = function(path, preserveJsx) {
|
|
11757
11836
|
if (typeof path === "string" && /^\.\.?\//.test(path)) return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function(m, tsx, d, ext, cm) {
|
|
@@ -11771,7 +11850,7 @@ function record(value) {
|
|
|
11771
11850
|
return value !== null && typeof value === "object";
|
|
11772
11851
|
}
|
|
11773
11852
|
function streamService(value) {
|
|
11774
|
-
return record(value) && typeof value.stream === "function";
|
|
11853
|
+
return record(value) && typeof value.stream === "function" && typeof value.prepareCall === "function";
|
|
11775
11854
|
}
|
|
11776
11855
|
/** Resolve the published callback, never the configured entry's display name. */
|
|
11777
11856
|
async function isNativeReviewerContext(caller) {
|
|
@@ -11804,7 +11883,8 @@ function installAutoReviewSampling(ctx) {
|
|
|
11804
11883
|
if (entry === void 0 || entry.fiber?.ctx.fiber !== caller.fiber || entry.options.name !== REVIEWER) return native;
|
|
11805
11884
|
const runtime = native;
|
|
11806
11885
|
const scopedStream = (options) => (async function* () {
|
|
11807
|
-
|
|
11886
|
+
const canonical = options.provider === NATIVE_COPILOT;
|
|
11887
|
+
if (!active || !canonical && options.provider !== "github-copilot-preview" || canonical && (options.purpose !== "auto-review" || isAgentLoopRequest(options))) {
|
|
11808
11888
|
yield* runtime.stream(options);
|
|
11809
11889
|
return;
|
|
11810
11890
|
}
|
|
@@ -11821,6 +11901,52 @@ function installAutoReviewSampling(ctx) {
|
|
|
11821
11901
|
yield* runtime.stream(options);
|
|
11822
11902
|
return;
|
|
11823
11903
|
}
|
|
11904
|
+
if (canonical) {
|
|
11905
|
+
const route = await captureNativeCopilot(ctx, diagnose);
|
|
11906
|
+
if (!route || route.models.get(options.model)?.api !== "openai-responses") {
|
|
11907
|
+
diagnose("COPILOT_AUTO_REVIEW_NATIVE_ROUTE_UNPROVEN");
|
|
11908
|
+
yield* runtime.stream(options);
|
|
11909
|
+
return;
|
|
11910
|
+
}
|
|
11911
|
+
const invalidation = new AbortController();
|
|
11912
|
+
const signal = AbortSignal.any([
|
|
11913
|
+
lifecycle.signal,
|
|
11914
|
+
invalidation.signal,
|
|
11915
|
+
...options.signal ? [options.signal] : []
|
|
11916
|
+
]);
|
|
11917
|
+
const stopSettings = onSettingsNamespaceUpdated(ctx, (namespace) => {
|
|
11918
|
+
if (namespace === route.namespace) invalidation.abort();
|
|
11919
|
+
});
|
|
11920
|
+
const stopAdapters = ctx.on("llm/adapters-updated", () => invalidation.abort());
|
|
11921
|
+
try {
|
|
11922
|
+
signal.throwIfAborted();
|
|
11923
|
+
route.assertCurrent();
|
|
11924
|
+
const prepared = await runtime.prepareCall({
|
|
11925
|
+
provider: options.provider,
|
|
11926
|
+
model: options.model,
|
|
11927
|
+
...options.reasoningEffort === void 0 ? {} : { reasoningEffort: options.reasoningEffort },
|
|
11928
|
+
...options.maxTokens === void 0 ? {} : { maxTokens: options.maxTokens },
|
|
11929
|
+
...options.stop === void 0 ? {} : { stop: options.stop }
|
|
11930
|
+
}, signal);
|
|
11931
|
+
signal.throwIfAborted();
|
|
11932
|
+
route.assertCurrent();
|
|
11933
|
+
if (!await isNativeReviewerContext(caller)) throw new Error("COPILOT_AUTO_REVIEW_IDENTITY_REVOKED");
|
|
11934
|
+
signal.throwIfAborted();
|
|
11935
|
+
route.assertCurrent();
|
|
11936
|
+
const request = {
|
|
11937
|
+
...options,
|
|
11938
|
+
temperature: void 0,
|
|
11939
|
+
...prepared.config,
|
|
11940
|
+
signal
|
|
11941
|
+
};
|
|
11942
|
+
if (Object.isFrozen(options)) Object.freeze(request);
|
|
11943
|
+
yield* prepared.stream(request);
|
|
11944
|
+
} finally {
|
|
11945
|
+
stopSettings();
|
|
11946
|
+
stopAdapters();
|
|
11947
|
+
}
|
|
11948
|
+
return;
|
|
11949
|
+
}
|
|
11824
11950
|
const preview = ctx.get("githubCopilotPreview");
|
|
11825
11951
|
if (preview === void 0) {
|
|
11826
11952
|
diagnose("COPILOT_AUTO_REVIEW_ROUTE_UNAVAILABLE");
|
|
@@ -11856,6 +11982,212 @@ function installAutoReviewSampling(ctx) {
|
|
|
11856
11982
|
};
|
|
11857
11983
|
}
|
|
11858
11984
|
//#endregion
|
|
11985
|
+
//#region lib/types/native-copilot-search.js
|
|
11986
|
+
const unavailable = () => new WebError("COPILOT_NATIVE_SEARCH_UNAVAILABLE", "WEB_PROVIDER_UNAVAILABLE");
|
|
11987
|
+
const failed = () => new WebError("COPILOT_NATIVE_SEARCH_FAILED", "WEB_PROVIDER_ERROR");
|
|
11988
|
+
/** One bounded read; cancellation also releases an uncooperative response reader. */
|
|
11989
|
+
async function json(response, signal) {
|
|
11990
|
+
if (response.redirected || !response.ok || !response.body) {
|
|
11991
|
+
response.body?.cancel().catch(() => void 0);
|
|
11992
|
+
throw failed();
|
|
11993
|
+
}
|
|
11994
|
+
const reader = response.body.getReader();
|
|
11995
|
+
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
11996
|
+
let bytes = 0;
|
|
11997
|
+
let text = "";
|
|
11998
|
+
try {
|
|
11999
|
+
for (;;) {
|
|
12000
|
+
const part = await abortable$1(reader.read(), signal);
|
|
12001
|
+
signal.throwIfAborted();
|
|
12002
|
+
if (part.done) break;
|
|
12003
|
+
bytes += part.value.byteLength;
|
|
12004
|
+
if (bytes > 1048576) throw failed();
|
|
12005
|
+
text += decoder.decode(part.value, { stream: true });
|
|
12006
|
+
}
|
|
12007
|
+
return JSON.parse(text + decoder.decode());
|
|
12008
|
+
} finally {
|
|
12009
|
+
reader.cancel().catch(() => void 0);
|
|
12010
|
+
}
|
|
12011
|
+
}
|
|
12012
|
+
function hasSearchEvidence(value) {
|
|
12013
|
+
if (value === null || typeof value !== "object" || !("output" in value) || !Array.isArray(value.output)) return false;
|
|
12014
|
+
return value.output.some((item) => item !== null && typeof item === "object" && item.type === "web_search_call" && item.status === "completed");
|
|
12015
|
+
}
|
|
12016
|
+
/** Add only a backend to the existing Web service; never select it or replace native tools. */
|
|
12017
|
+
function createNativeCopilotSearch(ctx) {
|
|
12018
|
+
let active = true;
|
|
12019
|
+
const selected = () => {
|
|
12020
|
+
const value = readSettingsNamespace(ctx, "web");
|
|
12021
|
+
return value !== null && typeof value === "object" && "searchProvider" in value && value.searchProvider === "github-copilot-hosted";
|
|
12022
|
+
};
|
|
12023
|
+
const pending = /* @__PURE__ */ new Map();
|
|
12024
|
+
ctx.effect(() => () => {
|
|
12025
|
+
active = false;
|
|
12026
|
+
for (const controller of pending.keys()) controller.abort();
|
|
12027
|
+
});
|
|
12028
|
+
const revoke = () => {
|
|
12029
|
+
for (const controller of pending.keys()) controller.abort();
|
|
12030
|
+
};
|
|
12031
|
+
ctx.on("credentials/record-updated", (key) => {
|
|
12032
|
+
if (key === "llm-pi-ai/github-copilot") revoke();
|
|
12033
|
+
});
|
|
12034
|
+
ctx.on("llm/adapters-updated", revoke);
|
|
12035
|
+
ctx.on("llm/models-updated", (provider) => {
|
|
12036
|
+
if (provider === "github-copilot") revoke();
|
|
12037
|
+
});
|
|
12038
|
+
ctx.effect(() => onSettingsNamespaceUpdated(ctx, (namespace) => {
|
|
12039
|
+
for (const [controller, owner] of pending) if (owner === namespace || namespace === "web") controller.abort();
|
|
12040
|
+
}));
|
|
12041
|
+
return {
|
|
12042
|
+
id: "github-copilot-hosted",
|
|
12043
|
+
title: "GitHub Copilot",
|
|
12044
|
+
description: {
|
|
12045
|
+
en: "Optional Copilot hosted search using the native account. Each search runs one capability probe before the query; both may incur supplier charges.",
|
|
12046
|
+
zh: "使用原生账号的可选 Copilot 搜索。每次先执行一次能力探测,再发送查询;两者均可能产生供应商费用。"
|
|
12047
|
+
},
|
|
12048
|
+
available: () => active && selected(),
|
|
12049
|
+
async ready() {
|
|
12050
|
+
if (!active || !selected()) return false;
|
|
12051
|
+
try {
|
|
12052
|
+
const signal = AbortSignal.timeout(1e4);
|
|
12053
|
+
const route = await abortable$1(captureNativeCopilot(ctx), signal);
|
|
12054
|
+
if (!route) return false;
|
|
12055
|
+
const credential = await abortable$1(createGitHubCopilotCredentialStore(ctx).read(NATIVE_COPILOT), signal);
|
|
12056
|
+
if (!active || credential?.type !== "oauth") return false;
|
|
12057
|
+
route.assertCurrent();
|
|
12058
|
+
return true;
|
|
12059
|
+
} catch {
|
|
12060
|
+
ctx.logger.warn("github-copilot: COPILOT_NATIVE_SEARCH_READINESS_UNAVAILABLE");
|
|
12061
|
+
return false;
|
|
12062
|
+
}
|
|
12063
|
+
},
|
|
12064
|
+
async search(request, callerSignal) {
|
|
12065
|
+
if (callerSignal?.aborted) throw new WebError("web search aborted", "ABORTED");
|
|
12066
|
+
if (!active || !selected() || pending.size >= 4) throw unavailable();
|
|
12067
|
+
if (typeof request.query !== "string" || request.query.length > 16384 || request.query.trim().length === 0 || new TextEncoder().encode(request.query).byteLength > 16384) throw failed();
|
|
12068
|
+
const controller = new AbortController();
|
|
12069
|
+
const deadline = AbortSignal.timeout(25e3);
|
|
12070
|
+
const signal = AbortSignal.any([
|
|
12071
|
+
controller.signal,
|
|
12072
|
+
deadline,
|
|
12073
|
+
...callerSignal ? [callerSignal] : []
|
|
12074
|
+
]);
|
|
12075
|
+
pending.set(controller, void 0);
|
|
12076
|
+
let disposeSource;
|
|
12077
|
+
try {
|
|
12078
|
+
const route = await abortable$1(captureNativeCopilot(ctx), signal);
|
|
12079
|
+
if (!route) throw unavailable();
|
|
12080
|
+
pending.set(controller, route.namespace);
|
|
12081
|
+
const check = () => {
|
|
12082
|
+
signal.throwIfAborted();
|
|
12083
|
+
if (!selected()) throw unavailable();
|
|
12084
|
+
route.assertCurrent();
|
|
12085
|
+
};
|
|
12086
|
+
check();
|
|
12087
|
+
const store = createGitHubCopilotCredentialStore(ctx);
|
|
12088
|
+
const models = createModels({ credentials: store });
|
|
12089
|
+
models.setProvider(githubCopilotProvider());
|
|
12090
|
+
if ((await abortable$1(store.read("github-copilot"), signal))?.type !== "oauth") throw unavailable();
|
|
12091
|
+
const auth = await abortable$1(models.getAuth(NATIVE_COPILOT), signal);
|
|
12092
|
+
check();
|
|
12093
|
+
if (!auth?.auth.apiKey) throw unavailable();
|
|
12094
|
+
const current = await abortable$1(store.read(NATIVE_COPILOT), signal);
|
|
12095
|
+
check();
|
|
12096
|
+
const grant = normalizeGitHubCopilotOAuthCredential(current);
|
|
12097
|
+
if (grant.access !== auth.auth.apiKey || grant.expires <= Date.now()) throw unavailable();
|
|
12098
|
+
const baseURL = trustedGitHubCopilotBaseUrl(auth.auth.baseUrl, grant);
|
|
12099
|
+
const apiKey = auth.auth.apiKey;
|
|
12100
|
+
const headers = new Headers({
|
|
12101
|
+
...copilotPublicHeaders(),
|
|
12102
|
+
...attributionHeaders()
|
|
12103
|
+
});
|
|
12104
|
+
for (const [name, value] of Object.entries(auth.auth.headers ?? {})) if (value !== null) headers.set(name, value);
|
|
12105
|
+
headers.set("authorization", `Bearer ${apiKey}`);
|
|
12106
|
+
headers.set("content-type", "application/json");
|
|
12107
|
+
headers.set("accept", "application/json");
|
|
12108
|
+
headers.set("X-Initiator", "user");
|
|
12109
|
+
headers.set("Openai-Intent", "conversation-edits");
|
|
12110
|
+
const source = createAccountModelSource({
|
|
12111
|
+
resolveAuth: async () => ({
|
|
12112
|
+
apiKey,
|
|
12113
|
+
baseURL,
|
|
12114
|
+
accountKey: "native-canonical-operation",
|
|
12115
|
+
availableModelIds: grant.availableModelIds
|
|
12116
|
+
}),
|
|
12117
|
+
assertAuthCurrent: check,
|
|
12118
|
+
nativeApis: new Map([...route.models].map(([id, model]) => [id, model.api])),
|
|
12119
|
+
headers: copilotPublicHeaders(),
|
|
12120
|
+
timeoutMs: 1e4
|
|
12121
|
+
});
|
|
12122
|
+
disposeSource = () => source.dispose();
|
|
12123
|
+
const catalog = await abortable$1(source.load({ signal }), signal);
|
|
12124
|
+
check();
|
|
12125
|
+
const model = catalog.models.filter((model) => model.api === "openai-responses" && route.models.get(model.id)?.api === "openai-responses").sort((a, b) => a.id.localeCompare(b.id))[0];
|
|
12126
|
+
if (!model) throw unavailable();
|
|
12127
|
+
const dispatch = async (query, probe) => {
|
|
12128
|
+
check();
|
|
12129
|
+
const callSignal = probe ? AbortSignal.any([signal, AbortSignal.timeout(8e3)]) : signal;
|
|
12130
|
+
const body = await json(await abortable$1(fetch(`${baseURL}/responses`, {
|
|
12131
|
+
method: "POST",
|
|
12132
|
+
redirect: "error",
|
|
12133
|
+
signal: callSignal,
|
|
12134
|
+
headers,
|
|
12135
|
+
body: JSON.stringify({
|
|
12136
|
+
model: model.id,
|
|
12137
|
+
input: [{
|
|
12138
|
+
role: "user",
|
|
12139
|
+
content: [{
|
|
12140
|
+
type: "input_text",
|
|
12141
|
+
text: query
|
|
12142
|
+
}]
|
|
12143
|
+
}],
|
|
12144
|
+
tools: [{ type: "web_search" }],
|
|
12145
|
+
tool_choice: "required",
|
|
12146
|
+
stream: false,
|
|
12147
|
+
include: ["web_search_call.action.sources"],
|
|
12148
|
+
max_output_tokens: probe ? 64 : Math.min(4096, model.maxTokens)
|
|
12149
|
+
})
|
|
12150
|
+
}).then((response) => {
|
|
12151
|
+
if (callSignal.aborted) {
|
|
12152
|
+
response.body?.cancel().catch(() => void 0);
|
|
12153
|
+
throw failed();
|
|
12154
|
+
}
|
|
12155
|
+
return response;
|
|
12156
|
+
}), callSignal), callSignal);
|
|
12157
|
+
check();
|
|
12158
|
+
if (!hasSearchEvidence(body)) throw unavailable();
|
|
12159
|
+
return body;
|
|
12160
|
+
};
|
|
12161
|
+
await dispatch("Probe web search capability.", true);
|
|
12162
|
+
const body = await dispatch(request.query, false);
|
|
12163
|
+
const result = normalizeSearchResponse(body);
|
|
12164
|
+
return {
|
|
12165
|
+
...result,
|
|
12166
|
+
sources: result.sources.filter((source) => {
|
|
12167
|
+
try {
|
|
12168
|
+
const url = new URL(source.url);
|
|
12169
|
+
return (url.protocol === "http:" || url.protocol === "https:") && !url.username && !url.password;
|
|
12170
|
+
} catch {
|
|
12171
|
+
return false;
|
|
12172
|
+
}
|
|
12173
|
+
}).slice(0, 64),
|
|
12174
|
+
truncated: result.sources.length > 64
|
|
12175
|
+
};
|
|
12176
|
+
} catch (error) {
|
|
12177
|
+
if (callerSignal?.aborted) throw new WebError("web search aborted", "ABORTED");
|
|
12178
|
+
if (controller.signal.aborted || !active) throw unavailable();
|
|
12179
|
+
if (deadline.aborted) throw new WebError("web search timed out", "WEB_PROVIDER_ERROR");
|
|
12180
|
+
if (error instanceof WebError) throw error;
|
|
12181
|
+
throw failed();
|
|
12182
|
+
} finally {
|
|
12183
|
+
controller.abort();
|
|
12184
|
+
disposeSource?.();
|
|
12185
|
+
pending.delete(controller);
|
|
12186
|
+
}
|
|
12187
|
+
}
|
|
12188
|
+
};
|
|
12189
|
+
}
|
|
12190
|
+
//#endregion
|
|
11859
12191
|
//#region lib/types/index.js
|
|
11860
12192
|
/** Account-scoped Copilot model integration for the native DSH runtime. */
|
|
11861
12193
|
/** Cordis plugin name used by loader diagnostics. */
|
|
@@ -11879,6 +12211,16 @@ const GITHUB_COPILOT_SETTINGS_NAMESPACE = "github-copilot";
|
|
|
11879
12211
|
/** Register model integration after the required native services are available. */
|
|
11880
12212
|
function apply(ctx, config) {
|
|
11881
12213
|
ctx.effect(() => installAutoReviewSampling(ctx));
|
|
12214
|
+
ctx.inject([
|
|
12215
|
+
"web",
|
|
12216
|
+
"llm",
|
|
12217
|
+
"settings",
|
|
12218
|
+
"credentials",
|
|
12219
|
+
"loader",
|
|
12220
|
+
"pluginPackages"
|
|
12221
|
+
], (scope) => {
|
|
12222
|
+
scope.effect(() => scope.web.registerSearchProvider(createNativeCopilotSearch(scope)));
|
|
12223
|
+
});
|
|
11882
12224
|
ctx.plugin({ apply(scope) {
|
|
11883
12225
|
new DiagnosticsController(scope);
|
|
11884
12226
|
} });
|
package/lib/routed-web.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./copilot-identity-BF8J8-9O.js";
|
|
2
|
-
import {
|
|
2
|
+
import { a as currentSearchSelection, i as currentSearchInitiator, s as isPluginPreviewProvider } from "./traditional-search-CgIL4oRu.js";
|
|
3
3
|
import { WebError, WebRuntime } from "@deepseek-ai/dsh-web";
|
|
4
4
|
//#region lib/types/search-routing.js
|
|
5
5
|
/** Match only the canonical route or a verified plugin-owned managed route. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "./copilot-identity-BF8J8-9O.js";
|
|
2
2
|
import "@earendil-works/pi-ai";
|
|
3
3
|
import "@earendil-works/pi-ai/providers/all";
|
|
4
|
-
import "@deepseek-ai/dsh-web";
|
|
4
|
+
import { WebError } from "@deepseek-ai/dsh-web";
|
|
5
5
|
import "@deepseek-ai/dsh-llm";
|
|
6
6
|
//#region lib/types/model-protocol.js
|
|
7
7
|
/** Scope optional preview contributions to this plugin's successfully mounted route service. */
|
|
@@ -76,5 +76,39 @@ function currentSearchSelection(agent) {
|
|
|
76
76
|
const GITHUB_COPILOT_HOSTED_SEARCH_PROVIDER_ID = "github-copilot-hosted";
|
|
77
77
|
/** @deprecated Use {@link GITHUB_COPILOT_HOSTED_SEARCH_PROVIDER_ID}. */
|
|
78
78
|
const COPILOT_HOSTED_SEARCH_PROVIDER_ID = GITHUB_COPILOT_HOSTED_SEARCH_PROVIDER_ID;
|
|
79
|
+
/** Shared normalization for the legacy bridge and the optional native backend. */
|
|
80
|
+
function normalizeSearchResponse(value) {
|
|
81
|
+
if (value === null || typeof value !== "object" || "output" in value && value.output !== void 0 && !Array.isArray(value.output)) throw new WebError("Responses API returned an invalid search result", "WEB_PROVIDER_ERROR");
|
|
82
|
+
const body = value;
|
|
83
|
+
const content = [];
|
|
84
|
+
const sources = /* @__PURE__ */ new Map();
|
|
85
|
+
for (const item of body.output ?? []) {
|
|
86
|
+
if (item.type === "web_search_call") {
|
|
87
|
+
for (const source of item.action?.sources ?? []) addSource(sources, source);
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (item.type !== "message") continue;
|
|
91
|
+
for (const part of item.content ?? []) {
|
|
92
|
+
if (typeof part.text === "string" && part.text.length > 0) content.push(part.text);
|
|
93
|
+
for (const annotation of part.annotations ?? []) addSource(sources, annotation);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
...content.length > 0 ? { content: content.join("\n") } : {},
|
|
98
|
+
sources: [...sources.values()],
|
|
99
|
+
truncated: false
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/** Add one valid source, merging richer duplicate metadata without inventing it. */
|
|
103
|
+
function addSource(sources, source) {
|
|
104
|
+
if (typeof source.url !== "string" || source.url.length === 0) return;
|
|
105
|
+
const existing = sources.get(source.url);
|
|
106
|
+
sources.set(source.url, {
|
|
107
|
+
url: source.url,
|
|
108
|
+
...existing?.title !== void 0 ? { title: existing.title } : typeof source.title === "string" ? { title: source.title } : {},
|
|
109
|
+
...existing?.snippet !== void 0 ? { snippet: existing.snippet } : typeof source.snippet === "string" ? { snippet: source.snippet } : {},
|
|
110
|
+
...existing?.publishedAt !== void 0 ? { publishedAt: existing.publishedAt } : typeof source.published_at === "string" ? { publishedAt: source.published_at } : {}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
79
113
|
//#endregion
|
|
80
|
-
export {
|
|
114
|
+
export { currentSearchSelection as a, currentSearchInitiator as i, GITHUB_COPILOT_HOSTED_SEARCH_PROVIDER_ID as n, abortable as o, normalizeSearchResponse as r, isPluginPreviewProvider as s, COPILOT_HOSTED_SEARCH_PROVIDER_ID as t };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import type { Api, Model } from '@earendil-works/pi-ai';
|
|
3
|
+
export declare const NATIVE_COPILOT = "github-copilot";
|
|
4
|
+
/** Only the unchanged native catalog and its explicit native narrowing are qualified. */
|
|
5
|
+
export declare function nativeCopilotModels(profile: unknown): ReadonlyMap<string, Model<Api>> | undefined;
|
|
6
|
+
export interface NativeCopilotSnapshot {
|
|
7
|
+
readonly models: ReadonlyMap<string, Model<Api>>;
|
|
8
|
+
readonly namespace: string;
|
|
9
|
+
assertCurrent(): void;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Qualify the native Loader root and its exact published pi-ai dependency.
|
|
13
|
+
* No credential, discovery, settings write or private adapter registry access.
|
|
14
|
+
*/
|
|
15
|
+
export declare function captureNativeCopilot(ctx: Context, diagnose?: (code: string) => void): Promise<NativeCopilotSnapshot | undefined>;
|
|
16
|
+
//# sourceMappingURL=native-copilot-access.d.ts.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import { type WebSearchProvider } from '@deepseek-ai/dsh-web';
|
|
3
|
+
/** Add only a backend to the existing Web service; never select it or replace native tools. */
|
|
4
|
+
export declare function createNativeCopilotSearch(ctx: Context): WebSearchProvider;
|
|
5
|
+
//# sourceMappingURL=native-copilot-search.d.ts.map
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* dedicated anonymous fetch providers.
|
|
5
5
|
* @module dsh-github-copilot/traditional-search
|
|
6
6
|
*/
|
|
7
|
-
import type { WebSearchProvider } from '@deepseek-ai/dsh-web';
|
|
7
|
+
import type { WebSearchProvider, WebSearchResult } from '@deepseek-ai/dsh-web';
|
|
8
8
|
import type { InlineConfig } from './config.ts';
|
|
9
9
|
import type { SearchPlan } from './plan.ts';
|
|
10
10
|
import type { InlineHooks } from './wire.ts';
|
|
@@ -14,4 +14,6 @@ export declare const GITHUB_COPILOT_HOSTED_SEARCH_PROVIDER_ID = "github-copilot-
|
|
|
14
14
|
export declare const COPILOT_HOSTED_SEARCH_PROVIDER_ID = "github-copilot-hosted";
|
|
15
15
|
/** Build the search-only provider registered with `ctx.web`. */
|
|
16
16
|
export declare function createTraditionalSearchProvider(available: () => boolean, plan: (signal?: AbortSignal) => SearchPlan | Promise<SearchPlan>, hooks: InlineHooks, config: () => InlineConfig, unavailableMessage?: string): WebSearchProvider;
|
|
17
|
+
/** Shared normalization for the legacy bridge and the optional native backend. */
|
|
18
|
+
export declare function normalizeSearchResponse(value: unknown): WebSearchResult;
|
|
17
19
|
//# sourceMappingURL=traditional-search.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-github-copilot",
|
|
3
3
|
"description": "Account-aware GitHub Copilot models for DeepSeek Harness through its published native adapter.",
|
|
4
|
-
"version": "0.1.0-alpha.
|
|
4
|
+
"version": "0.1.0-alpha.3.dsh.0.2.2.rc.3",
|
|
5
5
|
"releaseNotes": "CHANGELOG.md",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public",
|
|
@@ -38,7 +38,6 @@ export function checkSearchComposition(entries) {
|
|
|
38
38
|
if (entry.disabled !== undefined && entry.disabled !== false) reasons.add('WEB_DISABLED_OR_DYNAMIC')
|
|
39
39
|
if (entry.config !== undefined && (!entry.config || typeof entry.config !== 'object' || Array.isArray(entry.config)
|
|
40
40
|
|| Object.entries(entry.config).some(([key, value]) => !['searchProvider', 'fetchProvider'].includes(key) || typeof value !== 'string'))) reasons.add('WEB_CONFIG_REQUIRES_REVIEW')
|
|
41
|
-
if (entry.config?.searchProvider === 'github-copilot-hosted') reasons.add('LEGACY_COPILOT_SEARCH_PROVIDER')
|
|
42
41
|
if (entry.isolate !== undefined && (!entry.isolate || typeof entry.isolate !== 'object' || Array.isArray(entry.isolate) || Object.keys(entry.isolate).length > 0)) reasons.add('PREEXISTING_WEB_ISOLATION')
|
|
43
42
|
}
|
|
44
43
|
return { schemaVersion: 1, supported: reasons.size === 0, reasons: [...reasons].sort(), scope: 'pre-install-structural-only; no boot, credentials, network or writes' }
|